📄 index.cgi
字号:
unless ($access{'ro'} || $access{'views'} == 2 || $#views < 100) { print '<a href="view_form.cgi">', $text{'index_addview'}, '</a><br>'; } if (@views) { if ($config{'show_list'}) { # # Display as a list. # $third1 = int(@vlinks / 3); $third2 = 2 * $third1; if (@vlinks % 3 > 0) { $third1++; $third2++; $third2++ if (@vlinks % 3 == 2); } $third2 = $third1 if (@vlinks == 1); $third2++ if ($third1 == $third2); print '<table width=100%><tr><td width=33% valign=top>'; &view_table([ @vlinks[0 .. $third1 - 1] ], [ @vtitles[0 .. $third1 - 1] ]); print '</td><td width=33% valign=top>'; if ($third1 < @vlinks) { &view_table([ @vlinks[$third1 .. $third2 - 1] ], [ @vtitles[$third1 .. $third2 - 1] ]); } print '</td><td width=33% valign=top>'; if ($third2 < @vlinks) { &view_table([ @vlinks[$third2 .. $#vlinks] ], [ @vtitles[$third2 .. $#vtitles] ]); } print '</td></tr></table>'; } else { &icons_table(\@vlinks, \@vtitles, \@vicons, 5); } print '<br>'; } else { print $text{'index_vnone'}, '<p>'; } if ($access{'ro'} || $access{'views'} == 2) { print '<font color=grey>', $text{'index_addview'}, '</font><p>'; } else { print '<a href="view_form.cgi">', $text{'index_addview'}, '</a><p>'; }}## Display the name server start and stop buttons.#&show_controls();print '<hr>';&footer('/', $text{'index'});exit;sub show_buttons { $v = ' ' x 6; print '<br><center>'; if ($access{'master'} && ! $access{'ro'}) { print '<a href="master_form.cgi">', $text{'index_addmaster'}, '</a>'; } else { print '<font color=grey>', $text{'index_addmaster'}, '</font>'; } print $v; if ($access{'slave'} && ! $access{'ro'}) { print '<a href="slave_form.cgi?slave=1">', $text{'index_addslave'}, '</a>'; print $v, '<a href="slave_form.cgi?slave=0">', $text{'index_addstub'}, '</a>'; } else { print '<font color=grey>', $text{'index_addslave'}, '</font>'; print $v, '<font color=grey>', $text{'index_addstub'}, '</font>'; } print $v; if ($access{'forward'} && ! $access{'ro'} && $bind_version >= 9.1) { print '<a href="forward_form.cgi">', $text{'index_addfwd'}, '</a>'; } else { print '<font color=grey>', $text{'index_addfwd'}, '</font>'; } print $v; if ($access{'master'} && ! $access{'ro'} && $hashint < (@views ? scalar(@views) : 1)) { print '<a href="hint_form.cgi">', $text{'index_addhint'}, '</a>'; } else { print '<font color=grey>', $text{'index_addhint'}, '</font>'; } print "</center><p>\n"; return;}sub show_controls { $read_only = ($access{'ro'} || $access{'apply'} != 1); print '<hr><h3>', $text{'named_controls'}, '</h3>'; $named_status = &named_running(); if ($named_status == 0) { $err = $text{'not'} . ' '; } elsif ($named_status == 1) { $err = ''; } elsif ($named_status == -1) { $err = $text{'named_ctrl_disabled'}; } else { $err = $text{'named_ctrl_unknown'} . ' </b>(' . &named_err($named_status) . ')'; } print $text{'named_status'}, ': <b>', (($named_status >= 0) ? &text('named_ctrl_running', $err) : $err), '</b><p>'; # # We don't use rndc to stop/start the name server because the user may # want other things to happen when named is stopped/started. Instead we # use whatever commands they have configured for these functions. # print '<table width=100%>'; $disabled = ($read_only || $named_status == 1 || $named_status == -1) ? 'disabled' : ''; print '<tr><form action=start_named.cgi>'; print '<input type=hidden name=start value=1>'; print "<td align=left><input type=submit $disabled value='", $text{'index_start'}, "'>"; print "</td></form>\n"; $disabled = ($read_only || $named_status == 0 || $named_status == -1) ? 'disabled' : ''; print '<form action=start_named.cgi>'; print '<input type=hidden name=start value=0>'; print "<td align=center><input type=submit $disabled value='", $text{'index_stop'}, "'>"; print "</td></form>\n"; $disabled = ($read_only || $named_status != 1) ? 'disabled' : ''; print '<form action=rndc_cmd.cgi>'; print '<input type=hidden name=cmd value="flush">'; print "<td align=right><input type=submit $disabled value=' ", $text{'index_flush'}, " '>"; print "</td></form></tr></table><br>\n"; $len = 0; &foreign_require('servers', 'servers-lib.pl'); @servers = grep { $_->{'user'} } &servers::list_servers(); foreach $server (@servers) { $server_name = ($server->{'desc'}) ? $server->{'desc'} : $server->{'host'}; $len = length($server_name) if (length($server_name) > $len); } print '<table width=100%>'; print '<form action=rndc_cmd.cgi>'; print '<input type=hidden name=cmd value="reload">'; printf "<td align=%s><input type=submit %s value='%s'>\n", ($len > 20) ? 'center' : 'left', $disabled, $text{'index_reload'}; print "<select name=slave $disabled>"; print '<option ', $disabled, ' value="" selected> localhost'; $disabled = ($disabled || ! $access{'remote'}) ? 'disabled' : ''; foreach $server (@servers) { printf "<option %s value=%s> %s\n", $disabled, $server->{'host'}, ($server->{'desc'}) ? $server->{'desc'} : $server->{'host'}; } print "</select></td></form>\n"; print '</tr></table><br><table width=100%><tr>' if ($len > 20); $disabled = ($read_only || $named_status != 1) ? 'disabled' : ''; print '<form action=rndc_cmd.cgi>'; print '<input type=hidden name=cmd value="reconfig">'; printf "<td align=%s><input type=submit %s value='%s'>\n", ($len > 20) ? 'center' : 'right', $disabled, $text{'index_reconfig'}; print "<select name=slave $disabled>"; print '<option ', $disabled, ' value="" selected> localhost'; $disabled = ($disabled || ! $access{'remote'}) ? 'disabled' : ''; foreach $server (@servers) { printf "<option %s value=%s> %s\n", $disabled, $server->{'host'}, $server->{'desc'} ? $server->{'desc'} : $server->{'host'}; } print "</select></td></form></tr></table><br>\n"; return;}sub finish { my ($err, $file, $other) = @_; $other = "<tt>" . $other . "</tt>" if ($other); &header($text{'index_title'}, '', undef, 1, 1, 0); print '<hr><p>'; print $text{'index_mconfig_error'} if ($mconfig_err); print &text($err, "<tt>$file</tt>", $other); print '</p><hr>'; &footer('/', $text{'index'}); &unlock_all_files(); exit 1;}sub verify_mconfig { my $count = 0; my $cmd = my $dir = my $err = my $tmp = ''; my @cmd_list = ('', 'to start named', 'to stop named', 'nsupdate', 'dig', 'rndc'); $mconfig_err = 1; # # Check that named and all the required commands are available. # foreach ($config{'named_path'}, $config{'start_cmd'}, $config{'stop_cmd'}, $config{'nsupdate_cmd'}, $config{'dig_cmd'}, $config{'rndc_cmd'}) { $err = ($_ eq $config{'named_path'}) ? 'config_no_named' : 'config_no_cmd'; $cmd = $_; $cmd = $1 if (/^\s*(\S+)/o); if (! $cmd || ($cmd =~ /\//o && (! -f $cmd || ! -x $cmd)) || ! &has_command($cmd)) { $cmd = $cmd_list[$count] unless ($cmd); &finish($err, $cmd, ''); } $count++; } # # Check that the required directories exist. We must check the # chroot directory first though. # foreach $dir ($config{'chroot'}, $config{'named_conf'}, $config{'pid_file'}) { next unless ($dir); unless ($dir =~ /^\//o) { &finish('config_invalid_dir', $dir, ''); } $tmp = $dir; if ($dir eq $config{'pid_file'} || $dir eq $config{'named_conf'}) { if ($dir =~ /^(\S+)\/[^\/\s]+$/o) { $tmp = $config{'chroot'} . $1; } else { $tmp = $config{'chroot'} . $dir; } } if (! -d $tmp || $dir =~ /\s/o) { &finish('config_no_dir', $dir, ''); } } $err = $access{'dir'}; foreach $dir ($config{'master_dir'}, $config{'slave_dir'}) { next unless ($dir); unless ($dir =~ /^\//o) { &finish('config_invalid_dir', $dir, ''); } if (! -d $config{'chroot'} . $dir || $dir =~ /\s/o) { &finish('config_no_dir', $dir, ''); } unless ($dir =~ /^$err/) { &finish('config_invalid_mstr_dir', $dir, $err); } } # # Check that numeric-only options are just positive integers. # $cmd = $config{'max_zones'}; if (! $cmd || $cmd =~ /\D/o) { &finish('config_not_int', '<b>The maximum number of zones to display</b>', $cmd); } $cmd = $config{'record_filter'}; if (! $cmd || $cmd =~ /\D/o) { &finish('config_not_int', '<b>The minimum number of records to display the record filter</b>', $cmd); } # # Check the zone file format options. # foreach $cmd ($config{'fwd_zone_fn_fmt'}, $config{'rev_zone_fn_fmt'}) { if (! $cmd || $cmd !~ /\bZONE\b/o || $cmd =~ /\s/o) { &finish('config_invalid_zn_fmt', $cmd, ''); } } # # Check that the name server interfaces for queries, transfers and # updates are an IPv4 or IPv6 address or a domain name. # $cmd = $config{'ns_if_query'}; unless (&valdnsname($cmd, 0, '.') || &valipaddr($cmd, '.', 0, 0, 0, -1)) { &finish('config_invalid_ns_if_q', $cmd, ''); } $cmd = $config{'ns_if_transfer'}; unless (&valdnsname($cmd, 0, '.') || &valipaddr($cmd, '.', 0, 0, 0, -1)) { &finish('config_invalid_ns_if_t', $cmd, ''); } $cmd = $config{'ns_if_update'}; unless (&valipaddr($cmd, '.', 0, 0, 0, -1)) { &finish('config_invalid_ns_if_u', $cmd, ''); } $mconfig_err = 0; return;}## Display a table of views.## view_table(@view_link, @view_title)#sub view_table { my $i = 0; print '<table border width=100%>'; print "<tr $tb><td><b>$text{'View'}</b></td></tr>\n"; for ($i = 0; $i < @{ $_[0] }; $i++) { print "<tr $cb>\n"; print '<td><a href="', $_[0]->[$i], '">', $_[1]->[$i], '</a></td></tr>'; } print "</table>\n"; return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -