Handle hostnames with upper-case letters
[webmin.git] / wuftpd / edit_anon.cgi
1 #!/usr/local/bin/perl
2 # edit_anon.cgi
3 # Display anonymous FTP options
4
5 require './wuftpd-lib.pl';
6 &ui_print_header(undef, $text{'anon_title'}, "", "anon");
7
8 $conf = &get_ftpaccess();
9 @class = &find_value("class", $conf);
10
11 if (!getpwnam("ftp")) {
12         print "<b>$text{'anon_eftp'}</b> <p>\n";
13         }
14
15 print "<form action=save_anon.cgi>\n";
16 print "<table border width=100%>\n";
17 print "<tr $tb> <td><b>$text{'anon_header'}</b></td> </tr>\n";
18 print "<tr $cb> <td><table width=100%>\n";
19
20 # Display anonymous-root options
21 @root = ( &find_value('anonymous-root', $conf), [ ] );
22 print "<tr> <td valign=top><b>$text{'anon_root'}</b></td>\n";
23 print "<td colspan=3><table border>\n";
24 print "<tr $tb> <td><b>$text{'anon_dir'}</b></td>\n",
25       "<td><b>$text{'anon_class'}</b></td> </tr>\n";
26 $i = 0;
27 foreach $r (@root) {
28         print "<tr $cb>\n";
29         printf "<td><input name=dir_$i size=35 value='%s'> %s</td>\n",
30                 $r->[0], &file_chooser_button("dir_$i", 1);
31         print "<td><select name=class_$i>\n";
32         printf "<option value='' %s>%s\n",
33                 $r->[1] ? '' : 'selected', $text{'anon_any'};
34         foreach $c (@class) {
35                 printf "<option %s>%s\n",
36                         $r->[1] eq $c->[0] ? 'selected' : '', $c->[0];
37                 }
38         print "</select></td> </tr>\n";
39         $i++;
40         }
41 print "</table></td> </tr>\n";
42
43 # Display guest-root options
44 @root = ( &find_value('guest-root', $conf), [ ] );
45 print "<tr> <td valign=top><b>$text{'anon_groot'}</b></td>\n";
46 print "<td colspan=3><table border>\n";
47 print "<tr $tb> <td><b>$text{'anon_dir'}</b></td>\n",
48       "<td><b>$text{'anon_uids'}</b></td> </tr>\n";
49 $i = 0;
50 foreach $r (@root) {
51         print "<tr $cb>\n";
52         printf "<td><input name=gdir_$i size=35 value='%s'> %s</td>\n",
53                 $r->[0], &file_chooser_button("gdir_$i", 1);
54         printf "<td><input name=uids_$i size=20 value='%s'> %s</td>\n",
55                 join(" ", @$r[1..@$r-1]),
56                 &user_chooser_button("uids_$i", 1);
57         print "</tr>\n";
58         $i++;
59         }
60 print "</table></td> </tr>\n";
61
62 print "<tr> <td colspan=4><hr></td> </tr>\n";
63
64 # Display autogroup options
65 @auto = ( &find_value('autogroup', $conf), [ ] );
66 print "<tr> <td valign=top><b>$text{'anon_auto'}</b></td>\n";
67 print "<td colspan=3><table border>\n";
68 print "<tr $tb> <td><b>$text{'anon_group'}</b></td>\n",
69       "<td><b>$text{'anon_classes'}</b></td> </tr>\n";
70 $i = 0;
71 foreach $a (@auto) {
72         local %aclass;
73         map { $aclass{$_}++ } @$a[1..@$a-1];
74         print "<tr $cb>\n";
75         print "<td><input name=agroup_$i size=8 value='$a->[0]'> ",
76                 &group_chooser_button("agroup_$i"),"</td>\n";
77         print "<td>\n";
78         foreach $c (@class) {
79                 printf "<input name=aclass_$i type=checkbox %s value=%s> %s\n",
80                         $aclass{$c->[0]} ? 'checked' : '', $c->[0], $c->[0];
81                 }
82         print "</td> </tr>\n";
83         $i++;
84         }
85 print "</table></td> </tr>\n";
86 print "<tr> <td colspan=4><hr></td> </tr>\n";
87
88 # Display passwd-check field
89 $p = &find_value('passwd-check', $conf);
90 print "<tr> <td><b>$text{'anon_passwd'}</b></td> <td colspan=3>\n";
91 printf "<input type=radio name=passwd_def value=1 %s> %s\n",
92         $p ? '' : 'checked',  $text{'default'};
93 printf "<input type=radio name=passwd_def value=0 %s>\n",
94         $p ? 'checked' : '';
95 print "<select name=level>\n";
96 foreach $l ('none', 'trivial', 'rfc822') {
97         printf "<option %s value='%s'>%s\n",
98                 $p->[0] eq $l ? 'selected' : '', $l, $text{"anon_$l"};
99         }
100 print "</select> <select name=action>\n";
101 foreach $a ('enforce', 'warn') {
102         printf "<option %s value='%s'>%s\n",
103                 $p->[1] eq $a ? 'selected' : '', $a, $text{"anon_$a"};
104         }
105 print "</select></td> </tr>\n";
106
107 print "<tr> <td><b>$text{'anon_email'}</b></td>\n";
108 printf "<td colspan=3><input name=email size=50 value='%s'></td> </tr>\n",
109         join(" ", map { $_->[0] } &find_value('deny-email', $conf));
110
111 print "</table></td></tr></table>\n";
112 print "<input type=submit value=\"$text{'save'}\"></form>\n";
113
114 &ui_print_footer("", $text{'index_return'});
115