3 # Allow editing of a filter config file
5 require (-r 'sendmail-lib.pl' ? './sendmail-lib.pl' :
6 -r 'qmail-lib.pl' ? './qmail-lib.pl' :
9 if (substr($in{'file'}, 0, length($access{'apath'})) ne $access{'apath'}) {
10 &error(&text('ffile_efile', $in{'file'}));
13 &ui_print_header(undef, $text{'ffile_title'}, "");
14 &open_readfile(FILE, $in{'file'});
17 if (/^(\S+)\s+(\S+)\s+(\S+)\s+(.*)$/) {
18 push(@filter, [ $1, $2, $3, $4 ]);
20 elsif (/^(2)\s+(\S+)$/) {
26 print "<b>",&text('ffile_desc', "<tt>$in{'file'}</tt>"),"</b><p>\n";
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";
34 foreach $f (@filter, [ 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"} : " ";
45 $field .= "</select>\n";
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";
54 $match = "<input name=match_$i size=20 value='$f->[3]'>\n";
56 $action = "<input name=action_$i size=30 value='$f->[1]'>\n";
58 print &text('ffile_line', $field, $what, $match, $action),"<br>\n";
61 print &text('ffile_other',
62 "<input name=other size=30 value='$other'>"),"<br>\n";
64 print "<input type=submit value=\"$text{'save'}\">\n";
67 &ui_print_footer("edit_alias.cgi?name=$in{'name'}&num=$in{'num'}", $text{'aform_return'});