Handle hostnames with upper-case letters
[webmin.git] / updown / acl_security.pl
1
2 require 'updown-lib.pl';
3
4 # acl_security_form(&options)
5 # Output HTML for editing security options for the updown module
6 sub acl_security_form
7 {
8 print "<tr> <td><b>$text{'acl_upload'}</b></td>\n";
9 printf "<td colspan=3><input type=radio name=upload value=1 %s> %s\n",
10         $_[0]->{'upload'} ? "checked" : "", $text{'yes'};
11 printf "<input type=radio name=upload value=0 %s> %s</td> </tr>\n",
12         $_[0]->{'upload'} ? "" : "checked", $text{'no'};
13
14 print "<tr> <td nowrap><b>$text{'acl_max'}</b></td>\n";
15 printf "<td colspan=3><input type=radio name=max_def value=1 %s> %s\n",
16         $_[0]->{'max'} ? "" : "checked", $text{'acl_unlim'};
17 printf "<input type=radio name=max_def value=0 %s>\n",
18         $_[0]->{'max'} ? "checked" : "";
19 printf "<input name=max size=8 value='%s'> %s</td> </tr>\n",
20         $_[0]->{'max'}, $text{'acl_b'};
21
22 print "<tr> <td><b>$text{'acl_download'}</b></td>\n";
23 printf "<td colspan=3><input type=radio name=download value=1 %s> %s\n",
24         $_[0]->{'download'} == 1 ? "checked" : "", $text{'yes'};
25 printf "<input type=radio name=download value=2 %s> %s\n",
26         $_[0]->{'download'} == 2 ? "checked" : "", $text{'acl_nosched'};
27 printf "<input type=radio name=download value=0 %s> %s</td> </tr>\n",
28         $_[0]->{'download'} == 0 ? "checked" : "", $text{'no'};
29
30 print "<tr> <td valign=top><b>$text{'acl_users'}</b></td> <td colspan=3>\n";
31 printf "<input type=radio name=mode value=0 %s> $text{'acl_all'}<br>\n",
32         $_[0]->{'mode'} == 0 ? "checked" : "";
33 printf "<input type=radio name=mode value=3 %s> $text{'acl_this'}<br>\n",
34         $_[0]->{'mode'} == 3 ? "checked" : "";
35 printf "<input type=radio name=mode value=1 %s> $text{'acl_only'}\n",
36         $_[0]->{'mode'} == 1 ? "checked" : "";
37 printf "<input name=userscan size=40 value='%s'> %s<br>\n",
38         $_[0]->{'mode'} == 1 ? $_[0]->{'users'} : "",
39         &user_chooser_button("userscan", 1);
40 printf "<input type=radio name=mode value=2 %s> $text{'acl_except'}\n",
41         $_[0]->{'mode'} == 2 ? "checked" : "";
42 printf "<input name=userscannot size=40 value='%s'> %s</td> </tr>\n",
43         $_[0]->{'mode'} == 2 ? $_[0]->{'users'} : "",
44         &user_chooser_button("userscannot", 1);
45
46 print "<tr> <td valign=top><b>$text{'acl_dirs'}</b></td> <td colspan=3>\n";
47 print "<textarea name=dirs rows=3 cols=50>",
48         join("\n", split(/\s+/, $_[0]->{'dirs'})),"</textarea><br>\n";
49 printf "<input type=checkbox name=home value=1 %s> %s</td> </tr>\n",
50         $_[0]->{'home'} ? 'checked' : '', $text{'acl_home'};
51
52 print "<tr> <td><b>$text{'acl_fetch'}</b></td>\n";
53 printf "<td colspan=3><input type=radio name=fetch value=1 %s> %s\n",
54         $_[0]->{'fetch'} ? "checked" : "", $text{'yes'};
55 printf "<input type=radio name=fetch value=0 %s> %s</td> </tr>\n",
56         $_[0]->{'fetch'} ? "" : "checked", $text{'no'};
57 }
58
59 # acl_security_save(&options)
60 # Parse the form for security options for the cron module
61 sub acl_security_save
62 {
63 $_[0]->{'upload'} = $in{'upload'};
64 $_[0]->{'max'} = $in{'max_def'} ? undef : $in{'max'};
65 $_[0]->{'download'} = $in{'download'};
66 $_[0]->{'mode'} = $in{'mode'};
67 $_[0]->{'users'} = $in{'mode'} == 0 || $in{'mode'} == 3 ? "" :
68                    $in{'mode'} == 1 ? $in{'userscan'}
69                                     : $in{'userscannot'};
70 local @dirs = split(/\s+/, $in{'dirs'});
71 map { s/\/+/\//g } @dirs;
72 map { s/([^\/])\/+$/$1/ } @dirs;
73 $_[0]->{'dirs'} = join(" ", @dirs);
74 $_[0]->{'home'} = $in{'home'};
75 $_[0]->{'fetch'} = $in{'fetch'};
76 }
77