Handle hostnames with upper-case letters
[webmin.git] / sendmail / mailq_search.cgi
1 #!/usr/local/bin/perl
2 # mailq_search.cgi
3 # Display some messages from the mail queue
4
5 require './sendmail-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 $conf = &get_sendmailcf();
13 @qfiles = &list_mail_queue($conf);
14 @qmails = grep { &can_view_qfile($_) }
15                map { &mail_from_queue($_, "auto") } @qfiles;
16
17 # Do the search
18 $fields = [ [ $in{'field'}, $in{'match'} ] ];
19 @qmails = grep { &mail_matches($fields, 1, $_) } @qmails;
20 print "<p><b>",&text($in{'field'} =~ /^\!/ ? 'search_results3' :
21           'search_results2', scalar(@qmails), "<tt>$in{'match'}</tt>"),"</b><p>\n";
22
23 if (@qmails) {
24         %qmails = map { $_->{'file'}, $_ } @qmails;
25         &mailq_table([ map { $_->{'file'} } @qmails ], \%qmails);
26         }
27 else {
28         print "<b>$text{'searchq_none'}</b> <p>\n";
29         }
30
31 &ui_print_footer("list_mailq.cgi", $text{'mailq_return'},
32         "", $text{'index_return'});
33