Handle hostnames with upper-case letters
[webmin.git] / mailboxes / find.cgi
1 #!/usr/local/bin/perl
2 # find.cgi
3 # Display users matching some criteria
4
5 require './mailboxes-lib.pl';
6 &ReadParse();
7
8 # Build a list of all matching users
9 foreach $uinfo (&list_mail_users()) {
10         if (&can_user(@$uinfo)) {
11                 if ($in{'match'} == 0 && lc($in{'user'}) eq $uinfo->[0] ||
12                     $in{'match'} == 1 && $uinfo->[0] =~ /\Q$in{'user'}\E/i) {
13                         push(@users, $uinfo);
14                         }
15                 }
16         }
17
18 if (@users == 1) {
19         # Can go direct to user
20         &redirect("list_mail.cgi?user=$users[0]->[0]");
21         }
22 elsif (@users == 0) {
23         # No matches
24         &error($text{'find_enone'});
25         }
26 else {
27         # Show table of matches
28         &ui_print_header(undef, $text{'find_title'}, "");
29         print &text('find_results', $in{'user'}),"<p>\n";
30         &show_users_table(\@users);
31         &ui_print_footer();
32         }
33
34