Handle hostnames with upper-case letters
[webmin.git] / sendmail / del_mailq.cgi
1 #!/usr/local/bin/perl
2 # del_mailq.cgi
3 # Delete some mail message from the queue
4
5 require './sendmail-lib.pl';
6 require './boxes-lib.pl';
7 &ReadParse();
8
9 if ($in{'flush'}) {
10         # Just go to flushing page
11         &redirect("del_mailqs.cgi?flush=1&file=".&urlize($in{'file'}));
12         exit;
13         }
14
15 &error_setup($text{'delq_err'});
16 $access{'mailq'} == 2 || &error($text{'delq_ecannot'});
17 $in{'file'} =~ /\.\./ && &error($text{'delq_ecannot'});
18 $conf = &get_sendmailcf();
19 foreach $mqueue (&mailq_dir($conf)) {
20         $ok++ if ($in{'file'} =~ /^$mqueue\//);
21         }
22 $ok || &error($text{'mailq_ecannot'});
23
24 $qfile = $in{'file'};
25 $mail = &mail_from_queue($qfile, "auto");
26 &can_view_qfile($mail) || &error($text{'delq_ecannot'});
27
28 if (-r $mail->{'lfile'} && !$in{'force'}) {
29         &ui_print_header(undef, $text{'delq_title'}, "");
30         print "<center><form action=del_mailq.cgi>\n";
31         print "<b>$main::whatfailed : $text{'delq_locked'}</b><p>\n";
32         print "<input type=hidden name=file value='$in{'file'}'>\n";
33         print "<input type=submit name=force value='$text{'delq_force'}'>\n";
34         print "</form></center>\n";
35         &ui_print_footer("list_mailq.cgi", $text{'mailq_return'});
36         exit;
37         }
38
39 unlink($mail->{'file'}, $mail->{'dfile'}, $mail->{'lfile'});
40 &webmin_log("delmailq", undef, undef, { 'to' => $mail->{'header'}->{'to'},
41                                         'from' => $mail->{'header'}->{'from'} });
42 &redirect("list_mailq.cgi");
43