#!/usr/local/bin/perl # index.cgi # Display a list of domains and links to options require './bind8-lib.pl'; &ReadParse(); $need_create = !-r &make_chroot($config{'named_conf'}) || $in{'create'}; # Check if bind is installed if (!-x $config{'named_path'}) { &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0, &help_search_link("bind", "doc", "google")); print "
",&text('index_enamed', "$config{'named_path'}", "$gconfig{'webprefix'}/config.cgi?$module_name"),"
\n"; &foreign_require("software", "software-lib.pl"); $lnk = &software::missing_install_link("bind", $text{'index_bind'}, "../$module_name/", $text{'index_title'}); print $lnk,"
\n" if ($lnk); &ui_print_footer("/", $text{"index"}); exit; } # Check if BIND is the right version.. Only BIND 8/9 offers the -f option # Is there a better way to do this? if ($out = &check_bind_8()) { &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0, &help_search_link("bind", "doc", "google")); print "
",&text('index_eversion', "$config{'named_path'}", "/dnsadmin/", "$config{'named_path'} -help", "
$out"),"
\n"; &ui_print_footer("/", $text{"index"}); exit; } # Try to get the version number $out = `$config{'named_path'} -v 2>&1`; if ($out =~ /(bind|named)\s+([0-9\.]+)/i) { $bind_version = $2; } &open_tempfile(VERSION, ">$module_config_directory/version"); &print_tempfile(VERSION, "$bind_version\n"); &close_tempfile(VERSION); # Get the list of zones @allzones = &list_zone_names(); @zones = grep { $_->{'type'} ne 'view' && &can_edit_zone($_) && (!$access{'ro'} || $_->{'name'} ne '.') } @allzones; @views = grep { $_->{'type'} eq 'view' } @allzones; ($hashint) = grep { $_->{'type'} ne 'view' && $_->{'name'} eq '.' } @allzones; if (@zones == 1 && $access{'zones'} ne '*' && !$access{'defaults'} && !$access{'views'} && $access{'apply'} != 1 && !$access{'master'} && !$access{'slave'} && !$access{'forward'} && $access{'noconfig'}) { # Only one zone, so go direct to it $z = $zones[0]; &redirect("edit_master.cgi?index=$z->{'index'}". ($z->{'viewindex'} eq '' ? '' : '&view='.$z->{'viewindex'})); exit; } $chroot = &get_chroot(); &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0, &help_search_link("bind", "doc", "google"), undef, undef, &text($chroot eq "/" || !$chroot ? 'index_version' : 'index_chroot', $bind_version, "$chroot")); # If the named.conf file does not exist, offer to create it if ($need_create) { print &text('index_eempty', "".&make_chroot($config{'named_conf'}).""),"
\n"; print "
\n"; &ui_print_footer("/", $text{"index"}); exit; } if ($access{'defaults'}) { # display global options print &ui_subheading($text{'index_opts'}); @olinks = ("conf_servers.cgi", "conf_logging.cgi", "conf_acls.cgi", "conf_files.cgi", "conf_forwarding.cgi", "conf_net.cgi", "conf_misc.cgi", "conf_controls.cgi", "conf_keys.cgi", "conf_zonedef.cgi", "list_slaves.cgi", ($bind_version >= 9 ? ( "conf_rndc.cgi" ) : ( )), "conf_manual.cgi" ); @otitles = map { /(conf|list)_(\S+).cgi/; $text{$2."_title"} } @olinks; @oicons = map { /^(conf|list)_(\S+).cgi/; "images/$2.gif"; } @olinks; &icons_table(\@olinks, \@otitles, \@oicons, 6); print "$text{'index_toomany'}
\n"; print "
\n"; print &ui_links_row(\@crlinks); } elsif (@zones && (!@views || !$config{'by_view'})) { # Show all zones print &ui_subheading($text{'index_zones'}); foreach $z (@zones) { $v = $z->{'name'}; $t = $z->{'type'}; next if (!$t); $t = "delegation" if ($t eq "delegation-only"); local $zn = $v eq "." ? "$text{'index_root'}" : &ip6int_to_net(&arpa_to_ip($v)); if ($z->{'view'}) { local $vw = $z->{'viewindex'}; push(@zlinks, "edit_$t.cgi?index=$z->{'index'}". "&view=$vw"); push(@ztitles, $zn." ". &text('index_view', "$z->{'view'}")); push(@zdels, &can_edit_zone($z, $vw) ? $z->{'index'}." ".$z->{'viewindex'} : undef); } else { push(@zlinks, "edit_$t.cgi?index=$z->{'index'}"); push(@ztitles, $zn); push(@zdels, &can_edit_zone($z) ? $z->{'index'} : undef); } push(@zsort, $t eq 'hint' ? undef : $ztitles[$#ztitles]); push(@zicons, "images/$t.gif"); push(@ztypes, $text{"index_$t"}); $zhash{$zn} = $z; $ztitlehash{$zn} = $ztitles[$#ztitles]; $zlinkhash{$zn} = $zlinks[$#zlinks]; $ztypeshash{$zn} = $ztypes[$#ztypes]; $zdelhash{$zn} = $zdels[$#ztypes]; $len++; } # sort list of zones @zorder = sort { &compare_zones($zsort[$a], $zsort[$b]) } (0 .. $len-1); @zlinks = map { $zlinks[$_] } @zorder; @ztitles = map { $ztitles[$_] } @zorder; @zicons = map { $zicons[$_] } @zorder; @ztypes = map { $ztypes[$_] } @zorder; @zdels = map { $zdels[$_] } @zorder; print &ui_form_start("mass_delete.cgi", "post"); @links = ( &select_all_link("d", 0), &select_invert_link("d", 0), @crlinks ); print &ui_links_row(\@links); if ($config{'show_list'} == 1) { # display as list $mid = int((@zlinks+1)/2); print "| \n"; &zones_table([ @zlinks[0 .. $mid-1] ], [ @ztitles[0 .. $mid-1] ], [ @ztypes[0 .. $mid-1] ], [ @zdels[0 .. $mid-1] ] ); print " | \n"; if ($mid < @zlinks) { &zones_table([ @zlinks[$mid .. $#zlinks] ], [ @ztitles[$mid .. $#ztitles] ], [ @ztypes[$mid .. $#ztypes] ], [ @zdels[$mid .. $#zdels] ]); } print " |
| \n"; &zones_table([ @zlinks[0 .. $mid-1] ], [ @ztitles[0 .. $mid-1] ], [ @ztypes[0 .. $mid-1] ], [ @zdels[0 .. $mid-1] ]); print " | \n"; if ($mid < @zlinks) { &zones_table([ @zlinks[$mid .. $#zlinks] ], [ @ztitles[$mid .. $#ztitles] ], [ @ztypes[$mid .. $#ztypes] ], [ @zdels[$mid .. $#zdels] ]); } print " |
\n"; print &ui_links_row(\@crlinks); } if ($access{'views'} && $bind_version >= 9) { # Display list of views print "
\n"; } print &ui_links_row(\@links); } # read the PID if (!$access{'ro'} && ($access{'apply'} == 1 || $access{'apply'} == 3)) { print "
$1\n",
}
}
else {
# Is the root
print "
$text{'index_all'}\n";
}
if ($zhash{$name}) {
local $cb = $zdelhash{$name} ?
&ui_checkbox("d", $zdelhash{$name}, "", 0)." " : "";
print "