1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
|
#!/usr/local/bin/perl
# edit_master.cgi
# Display options and directives in an existing master zone
require './bind-lib.pl';
&ReadParse();
$conf = &get_config();
if ($in{'zone'}) {
foreach $z (@$conf) {
if ($z->{'value'} eq $in{'zone'}) {
$zconf = $z->{'members'};
$zone = $z;
$in{'index'} = $z->{'index'};
$dom = $in{'zone'};
}
}
}
else {
if ($in{'view'} ne '') {
$view = $conf->[$in{'view'}];
$conf = $view->{'members'};
}
$zconf = $conf->[$in{'index'}]->{'members'};
$zone = $conf->[$in{'index'}];
$dom = $conf->[$in{'index'}]->{'value'};
}
%access = &get_module_acl();
&can_edit_zone(\%access, $zone, $view) || &error($text{'master_ecannot'});
$desc = &ip6int_to_net(&arpa_to_ip($dom));
&ui_print_header($desc, $text{'master_title'}, "");
@recs = grep { !$_->{'generate'} && !$_->{'defttl'} }
&read_zone_file(&find("file", $zconf)->{'value'}, $dom);
if ($dom =~ /in-addr\.arpa/i || $dom =~ /\.$ipv6revzone/i) {
@rcodes = ("PTR", "NS", "CNAME", @extra_reverse, "ALL");
}
else {
@rcodes = ("A", "NS", "CNAME", "MX", "HINFO", "TXT", "WKS", "RP", "PTR", "LOC", "SRV", "KEY", $config{'support_aaaa'} ? ( "AAAA" ) : ( ), @extra_forward, "ALL");
}
@rcodes = grep { &can_edit_type($_, \%access) } @rcodes;
foreach $c (@rcodes) { $rnum{$c} = 0; }
foreach $r (@recs) {
$rnum{$r->{'type'}}++;
$rnum{"ALL"}++ if ($r->{'type'} ne "SOA");
if ($r->{'type'} eq "SOA") { $soa = $r; }
}
if ($config{'show_list'}) {
# display as list
$mid = int((@rcodes+1)/2);
print "<table width=100%> <tr><td width=50% valign=top>\n";
&types_table(@rcodes[0..$mid-1]);
print "</td><td width=50% valign=top>\n";
&types_table(@rcodes[$mid..$#rcodes]);
print "</td></tr> </table>\n";
}
else {
# display as icons
for($i=0; $i<@rcodes; $i++) {
push(@rlinks, "edit_recs.cgi?index=$in{'index'}&".
"view=$in{'view'}&type=$rcodes[$i]");
push(@rtitles, ($text{"type_$rcodes[$i]"} || $rcodes[$i]).
" ($rnum{$rcodes[$i]})");
push(@ricons, $is_extra{$rcodes[$i]} ?
"images/extra.gif" : "images/$rcodes[$i].gif");
}
&icons_table(\@rlinks, \@rtitles, \@ricons);
}
$file = &absolute_path(&find("file", $zconf)->{'value'});
# links to forms editing text, soa and zone options
if ($access{'file'}) {
push(@links, "edit_text.cgi?index=$in{'index'}&view=$in{'view'}");
push(@titles, $text{'master_manual'});
push(@images, "images/text.gif");
}
if ($access{'params'}) {
push(@links, "edit_soa.cgi?index=$in{'index'}&view=$in{'view'}");
push(@titles, $text{'master_soa'});
push(@images, "images/soa.gif");
}
if ($access{'opts'}) {
push(@links, "edit_options.cgi?index=$in{'index'}&view=$in{'view'}");
push(@titles, $text{'master_options'});
push(@images, "images/options.gif");
}
if ($access{'findfree'}) {
push(@links, "find_free.cgi?index=$in{'index'}&view=$in{'view'}");
push(@titles, $text{'findfree_desc'});
push(@images, "images/findfree.gif");
}
if ($access{'gen'}) {
push(@links, "list_gen.cgi?index=$in{'index'}&view=$in{'view'}");
push(@titles, $text{'gen_title'});
push(@images, "images/gen.gif");
}
if ($access{'whois'} && &has_command($config{'whois_cmd'}) &&
$dom !~ /in-addr\.arpa/i) {
push(@links, "whois.cgi?index=$in{'index'}&view=$in{'view'}");
push(@titles, $text{'master_whois'});
push(@images, "images/whois.gif");
}
if (@links) {
print "<hr>\n";
&icons_table(\@links, \@titles, \@images);
}
$apply = $access{'apply'} && &has_ndc();
if (!$access{'ro'} && ($access{'delete'} || $apply)) {
print "<hr>\n";
print "<table width=100%>\n";
if ($access{'delete'}) {
# Show button to delete zome
print "<form action=delete_zone.cgi>\n";
print "<input type=hidden name=index value=\"$in{'index'}\">\n";
print "<input type=hidden name=view value=\"$in{'view'}\">\n";
print "<tr><td>\n";
print "<input type=submit value=\"$text{'master_del'}\">\n";
print "</td> <td>$text{'master_delmsg'}\n";
if ($dom !~ /in-addr\.arpa/i && $dom !~ /\.$ipv6revzone/i) {
print "$text{'master_delrev'}\n";
}
print "</td> </tr></form>\n";
}
if ($apply) {
# Show button to do an NDC reload
print "<form action=restart_zone.cgi>\n";
print "<input type=hidden name=index value=\"$in{'index'}\">\n";
print "<input type=hidden name=view value=\"$in{'view'}\">\n";
print "<tr><td>\n";
print "<input type=submit value=\"$text{'master_apply'}\">\n";
$args = $view ? "$dom IN $view->{'value'}" : $dom;
$cmd = &has_ndc() == 2 ? $config{'rndc_cmd'}
: $config{'ndc_cmd'};
print "</td> <td>",&text('master_applymsg',
"<tt>$cmd reload $args</tt>");
print "</td> </tr></form>\n";
}
print "</table>\n";
}
&ui_print_footer("", $text{'index_return'});
sub types_table
{
if ($_[0]) {
local($i);
print "<table border width=100%>\n";
print "<tr $tb> <td><b>$text{'master_type'}</b></td> ",
"<td><b>$text{'master_records'}</b></td> </tr>\n";
for($i=0; $_[$i]; $i++) {
print "<tr $cb> <td><a href=\"edit_recs.cgi?",
"index=$in{'index'}&view=$in{'view'}&type=$_[$i]\">",
$text{"recs_$_[$i]"},"</a></td>\n";
print "<td>$rnum{$_[$i]}</td> </tr>\n";
}
print "</table>\n";
}
}
|