3 # Allow editing of a filter config file
5 require './qmail-lib.pl';
8 &ui_print_header(undef, $text{'ffile_title'}, "");
9 open(FILE, $in{'file'});
12 if (/^(\S+)\s+(\S+)\s+(\S+)\s+(.*)$/) {
13 push(@filter, [ $1, $2, $3, $4 ]);
15 elsif (/^(2)\s+(\S+)$/) {
21 print "<b>",&text('ffile_desc', "<tt>$in{'file'}</tt>"),"</b><p>\n";
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";
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"} : " ";
35 $field .= "</select>\n";
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";
44 $match = "<input name=match_$i size=20 value='$f->[3]'>\n";
46 $action = "<input name=action_$i size=30 value='$f->[1]'>\n";
48 print &text('ffile_line', $field, $what, $match, $action),"<br>\n";
51 print &text('ffile_other',
52 "<input name=other size=30 value='$other'>"),"<br>\n";
54 print "<input type=submit value=\"$text{'save'}\">\n";
57 &ui_print_footer("edit_alias.cgi?name=$in{'name'}", $text{'aform_return'});