3 # Display options and directives in an existing master 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) || &error($text{'master_ecannot'});
17 $desc = &ip6int_to_net(&arpa_to_ip($dom));
18 &ui_print_header($desc, $text{'master_title'}, "",
19 undef, undef, undef, undef, &restart_links($zone));
21 # Find the record types
22 if (!$config{'largezones'}) {
23 @recs = grep { !$_->{'generate'} && !$_->{'defttl'} }
24 &read_zone_file($zone->{'file'}, $dom);
26 if ($dom =~ /in-addr\.arpa/i || $dom =~ /\.$ipv6revzone/i) {
27 @rcodes = &get_reverse_record_types();
30 @rcodes = &get_forward_record_types();
33 @rcodes = grep { &can_edit_type($_, \%access) } @rcodes;
35 if (!$config{'largezones'}) {
36 # See what record type we have
37 foreach $c (@rcodes) { $rnum{$c} = 0; }
39 $rnum{$r->{'type'}}++;
40 $rnum{"ALL"}++ if ($r->{'type'} ne "SOA");
41 if ($r->{'type'} eq "SOA") { $soa = $r; }
45 # Just assume that we have all types
49 if ($config{'show_list'}) {
51 $mid = int((@rcodes+1)/2);
53 push(@grid, &types_table(@rcodes[0..$mid-1]));
54 push(@grid, &types_table(@rcodes[$mid..$#rcodes]));
55 print &ui_grid_table(\@grid, 2, 100, [ "width=50%", "width=50%" ]);
59 for($i=0; $i<@rcodes; $i++) {
60 push(@rlinks, "edit_recs.cgi?index=$in{'index'}&".
61 "view=$in{'view'}&type=$rcodes[$i]");
62 push(@rtitles, ($text{"type_$rcodes[$i]"} || $rcodes[$i]).
63 (defined(%rnum) ? " ($rnum{$rcodes[$i]})" : ""));
64 push(@ricons, $is_extra{$rcodes[$i]} ?
65 "images/extra.gif" : "images/$rcodes[$i].gif");
67 &icons_table(\@rlinks, \@rtitles, \@ricons);
70 # links to forms editing text, soa and zone options
71 if ($access{'file'}) {
73 push(@links, "edit_text.cgi?index=$in{'index'}&view=$in{'view'}");
74 push(@titles, $text{'master_manual'});
75 push(@images, "images/text.gif");
77 if ($access{'params'}) {
79 push(@links, "edit_soa.cgi?index=$in{'index'}&view=$in{'view'}");
80 push(@titles, $text{'master_soa'});
81 push(@images, "images/soa.gif");
83 if ($access{'opts'}) {
84 # Zone options in named.conf
85 push(@links, "edit_options.cgi?index=$in{'index'}&view=$in{'view'}");
86 push(@titles, $text{'master_options'});
87 push(@images, "images/options.gif");
89 if ($access{'findfree'}) {
91 push(@links, "find_free.cgi?index=$in{'index'}&view=$in{'view'}");
92 push(@titles, $text{'findfree_desc'});
93 push(@images, "images/findfree.gif");
97 push(@links, "list_gen.cgi?index=$in{'index'}&view=$in{'view'}");
98 push(@titles, $text{'gen_title'});
99 push(@images, "images/gen.gif");
101 if ($access{'whois'} && &has_command($config{'whois_cmd'}) &&
102 $dom !~ /in-addr\.arpa/i) {
104 push(@links, "whois.cgi?index=$in{'index'}&view=$in{'view'}");
105 push(@titles, $text{'master_whois'});
106 push(@images, "images/whois.gif");
108 if (&supports_dnssec()) {
110 push(@links, "edit_zonekey.cgi?index=$in{'index'}&view=$in{'view'}");
111 push(@titles, $text{'zonekey_title'});
112 push(@images, "images/zonekey.gif");
117 &icons_table(\@links, \@titles, \@images);
120 $apply = $access{'apply'} && &has_ndc();
121 if (!$access{'ro'} && ($access{'delete'} || $apply)) {
123 print &ui_buttons_start();
126 # Show button to freeze
127 print &ui_buttons_row(
128 "freeze_zone.cgi", $text{'master_freeze'},
129 $text{'master_freezemsg2'},
130 &ui_hidden("index", $in{'index'}).
131 &ui_hidden("view", $in{'view'})
134 # Show button to un-freeze
135 print &ui_buttons_row(
136 "unfreeze_zone.cgi", $text{'master_unfreeze'},
137 $text{'master_unfreezemsg2'},
138 &ui_hidden("index", $in{'index'}).
139 &ui_hidden("view", $in{'view'})
143 # Show button to check records
144 if (&supports_check_zone()) {
145 print &ui_buttons_row(
146 "check_zone.cgi", $text{'master_checkzone'},
147 $text{'master_checkzonemsg'},
148 &ui_hidden("index", $in{'index'}).
149 &ui_hidden("view", $in{'view'})
154 $conf = &get_config();
155 print &move_zone_button($conf, $in{'view'}, $in{'index'});
157 # Convert to slave zone
158 if ($access{'slave'}) {
159 print &ui_buttons_row("convert_master.cgi",
160 $text{'master_convert'},
161 $text{'master_convertdesc'},
162 &ui_hidden("index", $in{'index'}).
163 &ui_hidden("view", $in{'view'}));
166 if ($access{'delete'}) {
167 # Show button to delete zome
168 print &ui_buttons_row(
169 "delete_zone.cgi", $text{'master_del'},
170 $text{'master_delmsg'}." ".
171 ($dom !~ /in-addr\.arpa/i &&
172 $dom !~ /\.$ipv6revzone/i ? $text{'master_delrev'}
174 &ui_hidden("index", $in{'index'}).
175 &ui_hidden("view", $in{'view'})
179 print &ui_buttons_end();
182 &ui_print_footer("", $text{'index_return'});
188 $rv .= &ui_columns_start([
189 $text{'master_type'},
190 defined(%rnum) ? ( $text{'master_records'} ) : ( )
192 for(my $i=0; $_[$i]; $i++) {
193 local @cols = ( "<a href=\"edit_recs.cgi?".
194 "index=$in{'index'}&view=$in{'view'}&type=$_[$i]\">".
195 ($text{"recs_$_[$i]"} || $_[$i])."</a>" );
196 if (defined(%rnum)) {
197 push(@cols, $rnum{$_[$i]});
199 $rv .= &ui_columns_row(\@cols);
201 $rv .= &ui_columns_end();