Handle hostnames with upper-case letters
[webmin.git] / sendmail / edit_rfile.cgi
1 #!/usr/local/bin/perl
2 # edit_rfile.cgi
3 # Display the contents of an autoreply 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('rfile_efile', $in{'file'}));
11         }
12
13 &ui_print_header(undef, $text{'rfile_title'}, "");
14 &open_readfile(FILE, $in{'file'});
15 while(<FILE>) {
16         if (/^Reply-Tracking:\s*(.*)/) {
17                 $replies = $1;
18                 }
19         elsif (/^Reply-Period:\s*(.*)/) {
20                 $period = $1;
21                 }
22         elsif (/^No-Autoreply:\s*(.*)/) {
23                 $no_autoreply = $1;
24                 }
25         elsif (/^No-Autoreply-Regexp:\s*(.*)/) {
26                 push(@no_regexp, $1);
27                 }
28         elsif (/^From:\s*(.*)/) {
29                 $from = $1;
30                 }
31         else {
32                 push(@lines, $_);
33                 }
34         }
35 close(FILE);
36
37 print &text('rfile_desc', "<tt>$in{'file'}</tt>"),"<p>\n";
38 print "$text{'rfile_desc2'}<p>\n";
39
40 print "<form action=save_rfile.cgi method=post enctype=multipart/form-data>\n";
41 print "<input type=hidden name=file value=\"$in{'file'}\">\n";
42 print "<input type=hidden name=num value=\"$in{'num'}\">\n";
43 print "<input type=hidden name=name value=\"$in{'name'}\">\n";
44 print "<textarea name=text rows=20 cols=80 $config{'wrap_mode'}>",
45         join("", @lines),"</textarea>\n";
46
47 print "<table>\n";
48
49 # Show From: address
50 print "<tr> <td>$text{'rfile_from'}</td>\n";
51 printf "<td><input type=radio name=from_def value=1 %s> %s\n",
52         $from eq '' ? "checked" : "", $text{'rfile_auto'};
53 printf "<input type=radio name=from_def value=0 %s>\n",
54         $from eq '' ? "" :"checked";
55 printf "<input name=from size=30 value='%s'></td> </tr>\n",
56         $from;
57 print "<tr> <td></td> <td><font size=-1>$text{'rfile_fromdesc'}</font></td> </tr>\n";
58
59 # Show reply-tracking file
60 print "<tr> <td>$text{'rfile_replies'}</td>\n";
61 printf "<td><input type=radio name=replies_def value=1 %s> %s\n",
62         $replies eq '' ? "checked" : "", $text{'rfile_none'};
63 printf "<input type=radio name=replies_def value=0 %s> %s\n",
64         $replies eq '' ? "" :"checked", $text{'rfile_file'};
65 printf "<input name=replies size=30 value='%s'> %s</td> </tr>\n",
66         $replies, &file_chooser_button("replies");
67 print "&nbsp;" x 3;
68
69 # Show reply-tracking period
70 print "<tr> <td>&nbsp;&nbsp;&nbsp;$text{'rfile_period'}</td>\n";
71 printf "<td><input type=radio name=period_def value=1 %s> %s\n",
72         $period eq '' ? "checked" : "", $text{'rfile_default'};
73 printf "<input type=radio name=period_def value=0 %s>\n",
74         $period eq '' ? "" :"checked";
75 printf "<input name=period size=5 value='%s'> %s</td> </tr>\n",
76         $period, $text{'rfile_secs'};
77
78 # Show people to not autoreply to
79 print "<tr> <td>$text{'rfile_no_autoreply'}</td>\n";
80 printf "<td><input name=no_autoreply size=40 value='%s'></td> </tr>\n",
81         $no_autoreply;
82
83 # Show regexps to not autoreply to
84 print "<tr> <td>$text{'rfile_no_regexp'}</td>\n";
85 print "<td>",&ui_textarea("no_regexp", join("\n", @no_regexp), 3, 40),"</td> </tr>\n";
86
87 print "</table>\n";
88
89 print "<input type=submit value=\"$text{'save'}\"> ",
90       "<input type=reset value=\"$text{'rfile_undo'}\">\n";
91 print "</form>\n";
92
93 &ui_print_footer("edit_alias.cgi?name=$in{'name'}&num=$in{'num'}", $text{'aform_return'});
94