Handle hostnames with upper-case letters
[webmin.git] / wuftpd / edit_class.cgi
1 #!/usr/local/bin/perl
2 # edit_class.cgi
3 # Display a list of user classes for editing
4
5 require './wuftpd-lib.pl';
6 &ui_print_header(undef, $text{'class_title'}, "", "class");
7 $conf = &get_ftpaccess();
8
9 print "<form action=save_class.cgi>\n";
10 print "<table border width=100%>\n";
11 print "<tr $tb> <td><b>$text{'class_header'}</b></td> </tr>\n";
12 print "<tr $cb> <td><table width=100%>\n";
13
14 @class = ( &find_value("class", $conf), [ ] );
15 print "<tr> <td valign=top><b>$text{'class_class'}</b></td>\n";
16 print "<td colspan=3><table border width=100%>\n";
17 print "<tr $tb> <td><b>$text{'class_name'}</b></td> ",
18       "<td><b>$text{'class_types'}</b></td> ",
19       "<td><b>$text{'class_addrs'}</b></td> </tr>\n";
20 $i = 0;
21 foreach $c (@class) {
22         print "<tr $cb>\n";
23         print "<td><input name=class_$i size=10 value='$c->[0]'></td>\n";
24         local %types;
25         map { $types{$_}++ } split(/,/, $c->[1]);
26         printf "<td><input type=checkbox name=types_$i value=real %s> %s\n",
27                 $types{'real'} ? 'checked' : '', $text{'class_real'};
28         printf "<input type=checkbox name=types_$i value=anonymous %s> %s\n",
29                 $types{'anonymous'} ? 'checked' : '', $text{'class_anonymous'};
30         printf "<input type=checkbox name=types_$i value=guest %s> %s</td>\n",
31                 $types{'guest'} ? 'checked' : '', $text{'class_guest'};
32         printf "<td><input name=addrs_$i size=30 value='%s'></td>\n",
33                 join(" ", @$c[2..@$c-1]);
34         print "</tr>\n";
35         $i++;
36         }
37 print "</table></td> </tr>\n";
38
39 print "<tr> <td colspan=4><hr></td> </tr>\n";
40 foreach $g ('guestuser', 'guestgroup', 'realuser', 'realgroup') {
41         print "<tr> <td><b>",$text{"class_$g"},"</b></td> <td colspan=3>\n";
42         printf "<input name=%s size=50 value='%s'> %s</td> </tr>\n",
43                 $g, &join_all($g, $conf),
44                 $g =~ /user$/ ? &user_chooser_button($g, 1)
45                               : &group_chooser_button($g, 1);
46         }
47
48 print "<tr> <td colspan=4><hr></td> </tr>\n";
49 print "<tr> <td><b>",&text('class_ftpusers', "<tt>$config{'ftpusers'}</tt>"),
50       "</b></td> <td colspan=3>\n";
51 open(FTPUSERS, $config{'ftpusers'});
52 while(<FTPUSERS>) {
53         s/\r|\n//g;
54         s/#.*$//;
55         push(@ftpusers, $_) if (/\S/);
56         }
57 close(FTPUSERS);
58 printf "<input name=ftpusers size=40 value='%s'> %s</td> </tr>\n",
59         join(" ", @ftpusers), &user_chooser_button('ftpusers', 1);
60 foreach $g ('deny-uid', 'deny-gid', 'allow-uid', 'allow-gid') {
61         ($fg = $g) =~ s/-/_/g;
62         print "<tr> <td><b>",$text{"class_$fg"},"</b></td> <td colspan=3>\n";
63         printf "<input name=%s size=40 value='%s'> %s</td> </tr>\n",
64                 $fg, &join_all($g, $conf),
65                 $g =~ /uid$/ ? &user_chooser_button($fg, 1)
66                              : &group_chooser_button($fg, 1);
67         }
68
69 print "</table></td></tr></table>\n";
70 print "<input type=submit value=\"$text{'save'}\"></form>\n";
71
72 &ui_print_footer("", $text{'index_return'});
73
74 # join_all(name, &config)
75 sub join_all
76 {
77 local (@rv, $v);
78 foreach $v (&find_value($_[0], $_[1])) {
79         push(@rv, @$v);
80         }
81 return join(" ", @rv);
82 }
83