Handle hostnames with upper-case letters
[webmin.git] / dnsadmin / edit_master.cgi
1 #!/usr/local/bin/perl
2 # edit_master.cgi
3 # Display a form for editing a master domain
4
5 require './dns-lib.pl';
6 &ReadParse();
7 $conf = &get_config();
8 $zconf = $conf->[$in{'index'}];
9 $dom = $zconf->{'values'}->[0];
10 %access = &get_module_acl();
11 &can_edit_zone(\%access, $dom) ||
12         &error("You are not allowed to edit this zone");
13 &header("Edit Master Zone", "");
14 print "<center><font size=+2>",&arpa_to_ip($dom),"</font></center>\n";
15
16 print "<hr><p>\n";
17 @recs = &read_zone_file($zconf->{'values'}->[1], $dom);
18 if ($dom =~ /in-addr.arpa/i) {
19         @rcodes = ("PTR", "NS");
20         }
21 else {
22         @rcodes = ("A", "NS", "CNAME", "MX", "HINFO", "TXT", "WKS", "RP");
23         }
24 foreach $c (@rcodes) { $rnum{$c} = 0; }
25 foreach $r (@recs) {
26         $rnum{$r->{'type'}}++;
27         if ($r->{'type'} eq "SOA") { $soa = $r; }
28         }
29 if ($config{'show_list'}) {
30         # display as list
31         $mid = int((@rcodes+1)/2);
32         print "<table width=100%> <tr><td width=50%>\n";
33         &types_table(@rcodes[0..$mid-1]);
34         print "</td><td width=50%>\n";
35         &types_table(@rcodes[$mid..$#rcodes]);
36         print "</td></tr> </table>\n";
37         }
38 else {
39         # display as icons
40         for($i=0; $i<@rcodes; $i++) {
41                 push(@rlinks,
42                      "edit_recs.cgi?index=$in{'index'}&type=$rcodes[$i]");
43                 push(@rtitles, "$code_map{$rcodes[$i]} ($rnum{$rcodes[$i]})");
44                 push(@ricons, "../bind8/images/$rcodes[$i].gif");
45                 }
46         &icons_table(\@rlinks, \@rtitles, \@ricons);
47         }
48 $file = &absolute_path($zconf->{'values'}->[1]);
49 print "<a href=\"edit_text.cgi?index=$in{'index'}\">Manually edit ",
50       "records file</a><br>\n";
51
52 # form for editing SOA record
53 $v = $soa->{'values'};
54 print "<hr><a name=soa>\n";
55 print "<form action=save_master.cgi>\n";
56 print "<input type=hidden name=file value=\"$soa->{'file'}\">\n";
57 print "<input type=hidden name=num value=\"$soa->{'num'}\">\n";
58 print "<input type=hidden name=origin value=\"$dom\">\n";
59 print "<input type=hidden name=index value=\"$in{'index'}\">\n";
60 print "<table border width=100%>\n";
61 print "<tr $tb> <td><b>Master Zone Parameters</b></td> </tr>\n";
62 print "<tr $cb> <td><table width=100%>\n";
63
64 print "<tr> <td><b>Master server</b></td>\n";
65 print "<td><input name=master size=20 value=\"$v->[0]\"></td>\n";
66 $v->[1] =~ s/\./\@/; $v->[1] =~ s/\.$//;
67 print "<td><b>Email address</b></td>\n";
68 print "<td><input name=email size=20 value=\"$v->[1]\"></td> </tr>\n";
69
70 print "<tr> <td><b>Refresh time</b></td>\n";
71 print "<td><input name=refresh size=10 value=\"$v->[3]\"> secs</td>\n";
72 print "<td><b>Transfer retry time</b></td>\n";
73 print "<td><input name=retry size=10 value=\"$v->[4]\"> secs</td> </tr>\n";
74
75 print "<tr> <td><b>Expiry time</b></td>\n";
76 print "<td><input name=expiry size=10 value=\"$v->[5]\"> secs</td>\n";
77 print "<td><b>Default time-to-live</b></td>\n";
78 print "<td><input name=minimum size=10 value=\"$v->[6]\"> secs</td> </tr>\n";
79
80 print "</table></td></tr> </table>\n";
81 print "<table width=100%><tr><td valign=top align=left>\n";
82 print "<input type=submit value=Save></td></form>\n";
83 print "<form action=delete_zone.cgi>\n";
84 print "<input type=hidden name=index value=\"$in{'index'}\">\n";
85 print "<td align=right><input type=submit value=Delete>\n";
86 print "</td></form> </tr></table>\n";
87
88 print &ui_hr();
89 &footer("", "zone list");
90
91 sub types_table
92 {
93 if ($_[0]) {
94         local($i);
95         print "<table border width=100%>\n";
96         print "<tr $tb> <td><b>Type</b></td> <td><b>Records</b></td> </tr>\n";
97         for($i=0; $_[$i]; $i++) {
98                 print "<tr $cb> <td><a href=\"edit_recs.cgi?",
99                       "index=$in{'index'}&type=$_[$i]\">$code_map{$_[$i]}",
100                       "</a></td>\n";
101                 print "<td>$rnum{$_[$i]}</td> </tr>\n";
102                 }
103         print "</table>\n";
104         }
105 }
106