Handle hostnames with upper-case letters
[webmin.git] / sendmail / edit_ffile.cgi
1 #!/usr/local/bin/perl
2 # edit_ffile.cgi
3 # Allow editing of a filter config file
4
5 require (-r 'sendmail-lib.pl' ? './sendmail-lib.pl' :
6          -r 'qmail-lib.pl' ? './qmail-lib.pl' :
7                              './postfix-lib.pl');
8 &ReadParse();
9 if (substr($in{'file'}, 0, length($access{'apath'})) ne $access{'apath'}) {
10         &error(&text('ffile_efile', $in{'file'}));
11         }
12
13 &ui_print_header(undef, $text{'ffile_title'}, "");
14 &open_readfile(FILE, $in{'file'});
15 while(<FILE>) {
16         s/\r|\n//g;
17         if (/^(\S+)\s+(\S+)\s+(\S+)\s+(.*)$/) {
18                 push(@filter, [ $1, $2, $3, $4 ]);
19                 }
20         elsif (/^(2)\s+(\S+)$/) {
21                 $other = $2;
22                 }
23         }
24 close(FILE);
25
26 print "<b>",&text('ffile_desc', "<tt>$in{'file'}</tt>"),"</b><p>\n";
27
28 print "<form action=save_ffile.cgi method=post enctype=multipart/form-data>\n";
29 print "<input type=hidden name=file value=\"$in{'file'}\">\n";
30 print "<input type=hidden name=num value=\"$in{'num'}\">\n";
31 print "<input type=hidden name=name value=\"$in{'name'}\">\n";
32
33 $i = 0;
34 foreach $f (@filter, [ 1, '', '', '' ],
35                      [ 1, '', '', '' ],
36                      [ 1, '', '', '' ],
37                      [ 1, '', '', '' ],
38                      [ 1, '', '', '' ]) {
39         $field = "<select name=field_$i>\n";
40         foreach $ft ('', 'from', 'to', 'subject', 'cc', 'body') {
41                 $field .= sprintf "<option value='%s' %s>%s\n",
42                         $ft, $f->[2] eq $ft ? "selected" : "",
43                         $ft ? $text{"ffile_$ft"} : "&nbsp";
44                 }
45         $field .= "</select>\n";
46
47         $what = "<select name=what_$i>\n";
48         $what .= sprintf "<option value=0 %s>%s\n",
49                 $f->[0] == 0 ? "selected" : "", $text{"ffile_what0"};
50         $what .= sprintf "<option value=1 %s>%s\n",
51                 $f->[0] == 1 ? "selected" : "", $text{"ffile_what1"};
52         $what .= "</select>\n";
53
54         $match = "<input name=match_$i size=20 value='$f->[3]'>\n";
55
56         $action = "<input name=action_$i size=30 value='$f->[1]'>\n";
57
58         print &text('ffile_line', $field, $what, $match, $action),"<br>\n";
59         $i++;
60         }
61 print &text('ffile_other',
62             "<input name=other size=30 value='$other'>"),"<br>\n";
63
64 print "<input type=submit value=\"$text{'save'}\">\n";
65 print "</form>\n";
66
67 &ui_print_footer("edit_alias.cgi?name=$in{'name'}&num=$in{'num'}", $text{'aform_return'});
68