|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /usr/libexec/webmin/dhcpd/ |
Upload File : |
#!/usr/bin/perl
# lookup_host.cgi
# Find a host with a certain name and re-direct to its editing form
require './dhcpd-lib.pl';
&ReadParse();
$in{'host'} || &error($text{'lookup_ehostname'});
# Recursively find hosts
$conf = &get_config();
@hosts = &find_recursive("host", $conf);
# Look for a match
%access = &get_module_acl();
foreach $h (@hosts) {
local $can_view = &can('r', \%access, $h);
next if !$can_view && $access{'hide'};
local $fixed = &find("fixed-address", $h->{'members'});
local $hard = &find("hardware", $h->{'members'});
if (&search_re($h->{'values'}->[0], $in{'host'}) ||
$fixed && &search_re($fixed->{'values'}->[0], $in{'host'}) ||
$hard && &search_re($hard->{'values'}->[1], $in{'host'})) {
$host = $h;
last;
}
}
# Go to the host or show an error
if ($host) {
($gidx, $uidx, $sidx) = &find_parents($host);
&redirect("edit_host.cgi?idx=$host->{'index'}".
(defined($gidx) ? "&gidx=$gidx" : "").
(defined($uidx) ? "&uidx=$uidx" : "").
(defined($sidx) ? "&sidx=$sidx" : ""));
}
else {
&error(&text('lookup_ehost', $in{'host'}));
}