3 # Display records and other info for an existing slave or stub zone
5 require './bind8-lib.pl';
8 $zone = &get_zone_name($in{'zone'}, 'any');
9 $in{'index'} = $zone->{'index'};
10 $in{'view'} = $zone->{'viewindex'};
13 $zone = &get_zone_name($in{'index'}, $in{'view'});
15 $dom = $zone->{'name'};
16 &can_edit_zone($zone) ||
17 &error($text{'slave_ecannot'});
19 $desc = &ip6int_to_net(&arpa_to_ip($dom));
20 if ($zone->{'file'}) {
21 @st = stat(&make_chroot(&absolute_path($zone->{'file'})));
22 $lasttrans = &text('slave_last', @st && $st[7] ? &make_date($st[9])
23 : $text{'slave_never'});
25 &ui_print_header($desc, $0 =~ /edit_slave/ ? $text{'slave_title'}
26 : $text{'stub_title'},
27 "", undef, 0, 0, 0, &restart_links($zone),
28 undef, undef, $lasttrans);
30 if ($zone->{'file'}) {
32 @recs = &read_zone_file($zone->{'file'}, $dom);
33 if ($dom =~ /in-addr\.arpa/i || $dom =~ /\.$ipv6revzone/i) {
34 @rcodes = &get_reverse_record_types();
37 @rcodes = &get_forward_record_types();
39 foreach $c (@rcodes) { $rnum{$c} = 0; }
41 $rnum{$r->{'type'}}++;
42 if ($r->{'type'} eq "SOA") { $soa = $r; }
44 if ($config{'show_list'}) {
46 $mid = int((@rcodes+1)/2);
48 push(@grid, &types_table(@rcodes[0..$mid-1]));
49 push(@grid, &types_table(@rcodes[$mid..$#rcodes]));
50 print &ui_grid_table(\@grid, 2, 100,
51 [ "width=50%", "width=50%" ]);
55 for($i=0; $i<@rcodes; $i++) {
56 push(@rlinks, "edit_recs.cgi?index=$in{'index'}".
57 "&view=$in{'view'}&type=$rcodes[$i]");
58 push(@rtitles, $text{"type_$rcodes[$i]"}.
59 " ($rnum{$rcodes[$i]})");
60 push(@ricons, "images/$rcodes[$i].gif");
62 &icons_table(\@rlinks, \@rtitles, \@ricons);
67 # Shut buttons for editing, options and whois
68 if ($access{'file'} && $zone->{'file'}) {
69 push(@links, "view_text.cgi?index=$in{'index'}&view=$in{'view'}");
70 push(@titles, $text{'slave_manual'});
71 push(@images, "images/text.gif");
73 if ($access{'opts'}) {
74 push(@links, "edit_soptions.cgi?index=$in{'index'}&view=$in{'view'}");
75 push(@titles, $text{'master_options'});
76 push(@images, "images/options.gif");
78 if ($access{'whois'} && &has_command($config{'whois_cmd'}) &&
79 $dom !~ /in-addr\.arpa/i) {
80 push(@links, "whois.cgi?index=$in{'index'}&view=$in{'view'}");
81 push(@titles, $text{'master_whois'});
82 push(@images, "images/whois.gif");
84 push(@links, "xfer.cgi?index=$in{'index'}&view=$in{'view'}");
85 push(@titles, $text{'slave_xfer'});
86 push(@images, "images/xfer.gif");
88 print &ui_hr() if ($done_recs);
89 &icons_table(\@links, \@titles, \@images);
92 $apply = $access{'apply'} && &has_ndc();
93 if (!$access{'ro'} && ($access{'delete'} || $apply)) {
95 print &ui_buttons_start();
98 $conf = &get_config();
99 print &move_zone_button($conf, $in{'view'}, $in{'index'});
101 # Convert to master zone
102 if ($access{'master'} && $st[7]) {
103 print &ui_buttons_row("convert_slave.cgi",
104 $text{'slave_convert'},
105 $text{'slave_convertdesc'},
106 &ui_hidden("index", $in{'index'}).
107 &ui_hidden("view", $in{'view'}));
111 if ($access{'delete'}) {
112 print &ui_buttons_row("delete_zone.cgi",
113 $text{'master_del'}, $text{'slave_delmsg'},
114 &ui_hidden("index", $in{'index'}).
115 &ui_hidden("view", $in{'view'}));
118 print &ui_buttons_end();
121 &ui_print_footer("", $text{'index_return'});
127 $rv .= &ui_columns_start([
128 $text{'master_type'},
129 $text{'master_records'},
131 for(my $i=0; $_[$i]; $i++) {
132 local @cols = ( "<a href=\"edit_recs.cgi?".
133 "index=$in{'index'}&view=$in{'view'}&type=$_[$i]\">".
134 ($text{"recs_$_[$i]"} || $_[$i])."</a>",
136 $rv .= &ui_columns_row(\@cols);
138 $rv .= &ui_columns_end();