Handle hostnames with upper-case letters
[webmin.git] / postfix / mailq_search.cgi
1 #!/usr/local/bin/perl
2 # mailq_search.cgi
3 # Display some messages from the mail queue
4
5 require './postfix-lib.pl';
6 require './boxes-lib.pl';
7 &ReadParse();
8 $access{'mailq'} || &error($text{'mailq_ecannot'});
9 &ui_print_header(undef, $text{'searchq_title'}, "");
10
11 # Get all of the queued messages that this user can see
12 @qfiles = &list_queue();
13
14 # Do the search
15 $neg = ($in{'field'} =~ s/^!//);
16 @qfiles = grep { my $r = &compare_field($_);
17                  $neg ? !$r : $r } @qfiles;
18
19 print "<p><b>",&text($in{'field'} =~ /^\!/ ? 'search_results3' :
20           'search_results2', scalar(@qfiles), "<tt>$in{'match'}</tt>"),"</b><p>\n";
21 if (@qfiles) {
22         # Show matching messages
23         &mailq_table(\@qfiles);
24         }
25 else {
26         print "<b>$text{'searchq_none'}</b> <p>\n";
27         }
28
29 &ui_print_footer("mailq.cgi", $text{'mailq_return'},
30                  "", $text{'index_return'});
31
32 sub compare_field
33 {
34 if ($in{'field'} eq 'size') {
35         return $_[0]->{$in{'field'}} > $in{'match'};
36         }
37 else {
38         return $_[0]->{$in{'field'}} =~ /\Q$in{'match'}\E/i;
39         }
40 }
41