Handle hostnames with upper-case letters
[webmin.git] / spam / edit_procmail.cgi
1 #!/usr/local/bin/perl
2 # Allow changing of the rule for delivering spam
3
4 require './spam-lib.pl';
5 &ReadParse();
6 &set_config_file_in(\%in);
7 &can_use_check("procmail");
8 &ui_print_header(undef, $text{'procmail_title'}, "");
9
10 print &text('procmail_desc', "<tt>$pmrc</tt>"),"<p>\n";
11
12 # Find the existing recipe
13 &foreign_require("procmail", "procmail-lib.pl");
14 @pmrcs = &get_procmailrc();
15 $pmrc = $pmrcs[$#pmrcs];
16 @recipes = &procmail::parse_procmail_file($pmrc);
17 $spamrec = &find_file_recipe(\@recipes);
18
19 if (!$spamrec) {
20         $mode = 4;
21         }
22 elsif ($spamrec->{'action'} eq "\$DEFAULT") {
23         $mode = 4;
24         }
25 elsif ($spamrec->{'action'} eq "/dev/null") {
26         $mode = 0;
27         }
28 elsif ($spamrec->{'action'} =~ /^(.*)\/$/) {
29         $mode = 2;
30         $file = $1;
31         }
32 elsif ($spamrec->{'action'} =~ /^(.*)\/\.$/) {
33         $mode = 3;
34         $file = $1;
35         }
36 elsif ($spamrec->{'type'} eq '!') {
37         $mode = 5;
38         $email = $spamrec->{'action'};
39         }
40 else {
41         $mode = 1;
42         $file = $spamrec->{'action'};
43         }
44
45 print &ui_form_start("save_procmail.cgi", "post");
46 print &ui_table_start(undef, undef, 2);
47 print $form_hiddens;
48
49 # Spam destination inputs
50 print &ui_table_row($text{'setup_to'},
51         &ui_radio_table("to", $mode,
52           [ [ 0, $text{'setup_null'} ],
53             [ 4, $text{'setup_default'} ],
54             [ 1, $text{'setup_file'},
55                  &ui_textbox("mbox", $mode == 1 ? $file : "", 40) ],
56             [ 2, $text{'setup_maildir'},
57                  &ui_textbox("maildir", $mode == 2 ? $file : "", 40) ],
58             [ 3, $text{'setup_mhdir'},
59                  &ui_textbox("mhdir", $mode == 3 ? $file : "", 40) ],
60             [ 5, $text{'setup_email'},
61                  &ui_textbox("email", $mode == 5 ? $email : "", 40) ] ]));
62
63 # Message about path
64 if ($module_info{'usermin'}) {
65         $msg = "$text{'setup_rel'}<p>\n";
66         }
67 else {
68         $msg = "$text{'setup_home'}<p>\n";
69         }
70 $msg .= "$text{'setup_head'}<p>\n";
71 print &ui_table_row(undef, $msg, 2);
72
73 print &ui_table_end();
74 print &ui_form_end([ [ undef, $text{'procmail_ok'} ] ]);
75
76 &ui_print_footer($redirect_url, $text{'index_return'});
77