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