Handle hostnames with upper-case letters
[webmin.git] / useradmin / search_group.cgi
1 #!/usr/local/bin/perl
2 # search_group.cgi
3 # Search the group file, and display a list of results
4
5 require './user-lib.pl';
6 &ReadParse();
7 @glist = &list_groups();
8 $m = $in{'match'};
9 $w = lc($in{'what'});
10 for($i=0; $i<@glist; $i++) {
11         $g = $glist[$i];
12         $f = lc($g->{$in{'field'}});
13         if ($m == 0 && $f eq $w ||
14             $m == 1 && eval { $f =~ /$w/i } ||
15             $m == 4 && index($f, $w) >= 0 ||
16             $m == 2 && $f ne $w ||
17             $m == 3 && eval { $f !~ /$w/i } ||
18             $m == 5 && index($f, $w) < 0 ||
19             $m == 6 && $f < $w ||
20             $m == 7 && $f > $w) {
21                 push(@match, $g);
22                 }
23         }
24 if (@match == 1) {
25         &redirect("edit_group.cgi?group=".$match[0]->{'group'});
26         }
27 else {
28         &ui_print_header(undef, $text{'search_title'}, "");
29         if (@match == 0) {
30                 print "<b>$text{'search_gnotfound'}</b>. <p>\n";
31                 }
32         else {
33                 print "<b>",&text('search_gfound', scalar(@match)),"</b><br>\n";
34                 @match = &sort_groups(\@match, $config{'sort_mode'});
35                 &groups_table(\@match);
36                 }
37         &ui_print_footer("", $text{'index_return'});
38         }
39