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
|
#!/usr/local/bin/perl
# find_zones.cgi
# Display zones matching some search
require './bind-lib.pl';
&ReadParse();
%access = &get_module_acl();
$conf = &get_config();
@views = &find("view", $conf);
foreach $v (@views) {
@vz = &find("zone", $v->{'members'});
map { $view{$_} = $v } @vz;
push(@zones, @vz);
}
push(@zones, &find("zone", $conf));
foreach $z (@zones) {
$v = $z->{'value'};
next if ($v eq "." || !&can_edit_zone(\%access, $z, $view{$z}) ||
$v !~ /$in{'search'}/i);
$t = &find("type", $z->{'members'})->{'value'};
if ($view{$z}) {
push(@zlinks, "edit_$t.cgi?index=$z->{'index'}".
"&view=$view{$z}->{'index'}");
push(@ztitles, &ip6int_to_net(&arpa_to_ip($v))." ".
&text('index_view', "<tt>$view{$z}->{'value'}</tt>"));
}
else {
push(@zlinks, "edit_$t.cgi?index=$z->{'index'}");
push(@ztitles, &ip6int_to_net(&arpa_to_ip($v)));
}
push(@zicons, "images/$t.gif");
push(@ztypes, $text{"index_$t"});
$len++;
}
if (@zlinks == 1) {
&redirect($zlinks[0]);
exit;
}
&ui_print_header(undef, $text{'find_title'}, "");
print "<p>",&text('find_match', "<tt>$in{'search'}</tt>"),"<p>\n";
if ($len) {
# sort list of zones
@zorder = sort { $ztitles[$a] cmp $ztitles[$b] } (0 .. $len-1);
@zlinks = map { $zlinks[$_] } @zorder;
@ztitles = map { $ztitles[$_] } @zorder;
@zicons = map { $zicons[$_] } @zorder;
@ztypes = map { $ztypes[$_] } @zorder;
if ($config{'show_list'}) {
# display as list
$mid = int((@zlinks+1)/2);
print "<table width=100%><tr><td width=50% valign=top>\n";
&zones_table([ @zlinks[0 .. $mid-1] ],
[ @ztitles[0 .. $mid-1] ],
[ @ztypes[0 .. $mid-1] ]);
print "</td><td width=50% valign=top>\n";
if ($mid < @zlinks) {
&zones_table([ @zlinks[$mid .. $#zlinks] ],
[ @ztitles[$mid .. $#ztitles] ],
[ @ztypes[$mid .. $#ztypes] ]);
}
print "</td></tr></table>\n";
}
else {
# display as icons
&icons_table(\@zlinks, \@ztitles, \@zicons);
}
}
else {
print "<b>$text{'find_none'}</b><p>\n";
}
&ui_print_footer("", $text{'index_return'});
|