File: edit_stub.cgi

package info (click to toggle)
webmin-extra 1.180-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 12,324 kB
  • ctags: 1,200
  • sloc: perl: 39,117; makefile: 125
file content (141 lines) | stat: -rwxr-xr-x 4,165 bytes parent folder | download | duplicates (2)
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
#!/usr/local/bin/perl
# edit_slave.cgi
# Display records and other info for an existing slave or stub zone

require './bind-lib.pl';
%access = &get_module_acl();
&ReadParse();
$bconf = $conf = &get_config();
if ($in{'view'} ne '') {
	$view = $conf->[$in{'view'}];
	$conf = $view->{'members'};
	}
$zconf = $conf->[$in{'index'}]->{'members'};
$dom = $conf->[$in{'index'}]->{'value'};
%access = &get_module_acl();
&can_edit_zone(\%access, $conf->[$in{'index'}], $view) ||
	&error($text{'slave_ecannot'});
$desc = &ip6int_to_net(&arpa_to_ip($dom));
if ($0 =~ /edit_slave/) {
	&ui_print_header($desc, $text{'slave_title'}, "");
	}
else {
	&ui_print_header($desc, $text{'stub_title'}, "");
	}

if (&find("file", $zconf)) {
	$file = &find("file", $zconf)->{'value'};
	print "<p>\n";
	@recs = &read_zone_file($file, $dom);
	if ($dom =~ /in-addr\.arpa/i || $dom =~ /\.$ipv6revzone/i) {
		@rcodes = ("PTR", "NS");
		}
	else {
		@rcodes = ("A", "NS", "CNAME", "MX", "HINFO",
			   "TXT", "WKS", "RP");
		if ($config{'support_aaaa'}) {
			push(@rcodes, "AAAA");
			}
		}
	foreach $c (@rcodes) { $rnum{$c} = 0; }
	foreach $r (@recs) {
		$rnum{$r->{'type'}}++;
		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%>\n";
		&types_table(@rcodes[0..$mid-1]);
		print "</td><td width=50%>\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]"}.
				       " ($rnum{$rcodes[$i]})");
			push(@ricons, "images/$rcodes[$i].gif");
			}
		&icons_table(\@rlinks, \@rtitles, \@ricons);
		}
	$done_recs = 1;
	}

# Shut buttons for editing, options and whois
if ($access{'file'} && $file) {
	push(@links, "view_text.cgi?index=$in{'index'}&view=$in{'view'}");
	push(@titles, $text{'slave_manual'});
	push(@images, "images/text.gif");
	}
if ($access{'opts'}) {
	push(@links, "edit_soptions.cgi?index=$in{'index'}&view=$in{'view'}");
	push(@titles, $text{'master_options'});
	push(@images, "images/options.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" if ($done_recs);
	&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'}) {
		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{'slave_delmsg'}\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{'slave_apply'}\">\n";
		$args = $view ? "$dom IN $view->{'value'}" : $dom;
		$cmd = &has_ndc() == 2 ? $config{'rndc_cmd'}
				       : $config{'ndc_cmd'};
		print "</td> <td>",&text('slave_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{"type_$_[$i]"},"</a></td>\n";
		print "<td>$rnum{$_[$i]}</td> </tr>\n";
		}
	print "</table>\n";
	}
}