Handle hostnames with upper-case letters
[webmin.git] / sendmail / edit_feature.cgi
1 #!/usr/local/bin/perl
2 # edit_feature.cgi
3 # Displays a form for editing or creating some M4 file entry, which may be a
4 # feature, define, mailer or other line.
5
6 require './sendmail-lib.pl';
7 require './features-lib.pl';
8 &ReadParse();
9 $features_access || &error($text{'features_ecannot'});
10
11 if ($in{'manual'}) {
12         # Display manual edit form
13         &ui_print_header(undef, $text{'feature_manual'}, "");
14
15         print "<form action=manual_features.cgi method=post ",
16               "enctype=multipart/form-data>\n";
17         print &text('feature_mdesc', "<tt>$config{'sendmail_mc'}</tt>"),
18               "<br>\n";
19         print "<textarea name=data rows=20 cols=80>";
20         open(FEAT, $config{'sendmail_mc'});
21         while(<FEAT>) {
22                 print &html_escape($_);
23                 }
24         close(FEAT);
25         print "</textarea><br>\n";
26         print "<input type=submit value='$text{'save'}'></form>\n";
27
28         &ui_print_footer("list_features.cgi", $text{'features_return'});
29         exit;
30         }
31 if ($in{'new'}) {
32         &ui_print_header(undef, $text{'feature_add'}, "");
33         $feature = { 'type' => $in{'type'} };
34         }
35 else {
36         &ui_print_header(undef, $text{'feature_edit'}, "");
37         @features = &list_features();
38         $feature = $features[$in{'idx'}];
39         }
40
41 print "<form action=save_feature.cgi>\n";
42 print "<input type=hidden name=new value='$in{'new'}'>\n";
43 print "<input type=hidden name=idx value='$in{'idx'}'>\n";
44 print "<input type=hidden name=type value='$feature->{'type'}'>\n";
45
46 print "<table border width=100%>\n";
47 print "<tr $tb> <td><b>$text{'feature_header'}</b></td> </tr>\n";
48 print "<tr $cb> <td><table>\n";
49
50 if (!$in{'new'} && $feature->{'type'}) {
51         print "<tr> <td><b>$text{'feature_old'}</b></td>\n";
52         print "<td><tt>$feature->{'text'}</tt></td> </tr>\n";
53         }
54
55 if ($feature->{'type'} == 0) {
56         # Unsupported text line
57         print "<tr> <td><b>$text{'feature_text'}</b></td>\n";
58         printf "<td><input name=text size=50 value='%s'></td> </tr>\n",
59                 &html_escape($feature->{'text'});
60         }
61 elsif ($feature->{'type'} == 1) {
62         # A FEATURE() definition
63         print "<tr> <td><b>$text{'feature_feat'}</b></td>\n";
64         print "<td><select name=name>\n";
65         foreach $f (&list_feature_types()) {
66                 printf "<option value=%s %s>%s\n",
67                         $f->[0], $feature->{'name'} eq $f->[0] ? 'selected' : '',
68                         $f->[1];
69                 }
70         print "</select></td> </tr>\n";
71
72         print "<tr> <td valign=top><b>$text{'feature_values'}</b></td> <td>\n";
73         local @v = @{$feature->{'values'}};
74         @v = ( "" ) if (!@v);
75         for($i=0; $i<=@v; $i++) {
76                 print "<input name=value_$i size=50 value='$v[$i]'><br>\n";
77                 }
78         print "</td> </tr>\n";
79         }
80 elsif ($feature->{'type'} == 2 || $feature->{'type'} == 3) {
81         # A define() or undefine()
82         print "<tr> <td><b>$text{'feature_def'}</b></td>\n";
83         print "<td><select name=name>\n";
84         foreach $d (&list_define_types()) {
85                 printf "<option value=%s %s>%s\n",
86                         $d->[0], $d->[0] eq $feature->{'name'} ? "selected" : "",
87                         $d->[1];
88                 $found++ if ($d->[0] eq $feature->{'name'});
89                 }
90         print "<option value=$feature->{'name'} selected>$feature->{'name'}\n"
91                 if (!$found && !$in{'new'});
92         print "</select>\n";
93
94         print "<tr> <td valign=top><b>$text{'feature_defval'}</b></td>\n";
95         print "<td valign=top>\n";
96         printf "<input type=radio name=undef value=0 %s> %s\n",
97                 $feature->{'type'} == 2 ? "checked" : "", $text{'feature_defmode1'};
98         printf "<input name=value size=50 value='%s'><br>\n",
99                 $feature->{'value'};
100         printf "<input type=radio name=undef value=1 %s> %s\n",
101                 $feature->{'type'} == 3 ? "checked" : "", $text{'feature_defmode0'};
102         print "</td> </tr>\n";
103         }
104 elsif ($feature->{'type'} == 4) {
105         # A MAILER() definition
106         print "<tr> <td><b>$text{'feature_mailer'}</b></td>\n";
107         print "<td><select name=mailer>\n";
108         foreach $m (&list_mailer_types()) {
109                 printf "<option value=%s %s>%s\n",
110                         $m->[0], $feature->{'mailer'} eq $m->[0] ? 'selected' : '',
111                         $m->[1];
112                 }
113         print "</select></td> </tr>\n";
114         }
115 elsif ($feature->{'type'} == 5) {
116         # An OSTYPE() definition
117         print "<tr> <td><b>$text{'feature_ostype'}</b></td>\n";
118         print "<td><select name=ostype>\n";
119         foreach $m (&list_ostype_types()) {
120                 printf "<option value=%s %s>%s\n",
121                         $m->[0], $feature->{'ostype'} eq $m->[0] ? 'selected' : '',
122                         $m->[1];
123                 }
124         print "</select></td> </tr>\n";
125         }
126
127 print "</table></td></tr></table>\n";
128 print "<table width=100%><tr>\n";
129 if ($in{'new'}) {
130         print "<td><input type=submit value='$text{'create'}'></td>\n";
131         }
132 else {
133         print "<td><input type=submit value='$text{'save'}'></td>\n";
134         print "<td align=right><input type=submit name=delete ",
135               "value='$text{'delete'}'></td>\n";
136         }
137 print "</tr></table></form>\n";
138
139 &ui_print_footer("list_features.cgi", $text{'features_return'});
140