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