Handle hostnames with upper-case letters
[webmin.git] / dhcpd / lookup_subnet.cgi
1 #!/usr/local/bin/perl
2 # lookup_subnet.cgi
3 # Find a subnet with a certain address and re-direct to its editing form
4
5 require './dhcpd-lib.pl';
6 &ReadParse();
7 $in{'subnet'} || &error($text{'lookup_esubnetname'});
8
9 # Recursively find subnets
10 $conf = &get_config();
11 @subnets = &find_recursive("subnet", $conf);
12
13 # Look for a match
14 %access = &get_module_acl();
15 foreach $s (@subnets) {
16         local $can_view = &can('r', \%access, $s);
17         next if !$can_view && $access{'hide'};
18         if (&search_re($s->{'values'}->[0], $in{'subnet'}) ||
19             &search_re($s->{'values'}->[0]."/".$s->{'values'}->[2], $in{'subnet'})) {
20                 $subnet = $s;
21                 last;
22                 }
23         }
24
25 # Go to the subnet or show an error
26 if ($subnet) {
27         ($gidx, $uidx, $sidx) = &find_parents($subnet);
28         &redirect("edit_subnet.cgi?idx=$subnet->{'index'}".
29                   (defined($gidx) ? "&gidx=$gidx" : "").
30                   (defined($uidx) ? "&uidx=$uidx" : "").
31                   (defined($sidx) ? "&sidx=$sidx" : ""));
32         }
33 else {
34         &error(&text('lookup_esubnet', $in{'subnet'}));
35         }
36