2 require 'apache-lib.pl';
4 # acl_security_form(&options)
5 # Output HTML for editing security options for the apache module
8 print "<tr> <td valign=top rowspan=4><b>$text{'acl_virts'}</b></td>\n";
9 print "<td rowspan=4 valign=top>\n";
10 printf "<input type=radio name=virts_def value=1 %s> %s\n",
11 $_[0]->{'virts'} eq '*' ? 'checked' : '', $text{'acl_vall'};
12 printf "<input type=radio name=virts_def value=0 %s> %s<br>\n",
13 $_[0]->{'virts'} eq '*' ? '' : 'checked', $text{'acl_vsel'};
14 print "<select name=virts multiple size=5>\n";
15 local $conf = &get_config();
16 local @virts = ( { 'value' => '__default__' },
17 &find_directive_struct("VirtualHost", $conf) );
18 local %vcan = map { $_, 1 } split(/\s+/, $_[0]->{'virts'});
21 local @vn = &virt_acl_name($v);
22 local ($can) = grep { $vcan{$_} } @vn;
23 local $vn = $can || $vn[0];
24 printf "<option value=\"%s\" %s>%s\n",
25 $vn, $can ? "selected" : "",
26 $vn eq "__default__" ? $text{'acl_defserv'} : $vn;
27 delete($vcan{$can}) if ($can);
29 foreach $vn (keys %vcan) {
31 printf "<option value=\"%s\" %s>%s\n",
33 $vn eq "__default__" ? $text{'acl_defserv'} : $vn;
35 print "</select></td>\n";
37 print "<td><b>$text{'acl_global'}</b></td> <td><select name=global>\n";
38 printf "<option value=1 %s> $text{'yes'}\n",
39 $_[0]->{'global'} == 1 ? "selected" : "";
40 printf "<option value=2 %s> $text{'acl_htaccess'}\n",
41 $_[0]->{'global'} == 2 ? "selected" : "";
42 printf "<option value=0 %s> $text{'no'}</select></td> </tr>\n",
43 $_[0]->{'global'} == 0 ? "selected" : "";
45 print "<tr> <td><b>$text{'acl_create'}</b></td> <td>\n";
46 printf "<input type=radio name=create value=1 %s> $text{'yes'}\n",
47 $_[0]->{'create'} ? "checked" : "";
48 printf "<input type=radio name=create value=0 %s> $text{'no'}</td> </tr>\n",
49 $_[0]->{'create'} ? "" : "checked";
51 print "<tr> <td><b>$text{'acl_vuser'}</b></td> <td>\n";
52 printf "<input type=radio name=vuser value=1 %s> $text{'yes'}\n",
53 $_[0]->{'vuser'} ? "checked" : "";
54 printf "<input type=radio name=vuser value=0 %s> $text{'no'}</td> </tr>\n",
55 $_[0]->{'vuser'} ? "" : "checked";
57 print "<tr> <td><b>$text{'acl_vaddr'}</b></td> <td>\n";
58 printf "<input type=radio name=vaddr value=1 %s> $text{'yes'}\n",
59 $_[0]->{'vaddr'} ? "checked" : "";
60 printf "<input type=radio name=vaddr value=0 %s> $text{'no'}</td> </tr>\n",
61 $_[0]->{'vaddr'} ? "" : "checked";
63 print "<tr> <td><b>$text{'acl_pipe'}</b></td> <td>\n";
64 printf "<input type=radio name=pipe value=1 %s> $text{'yes'}\n",
65 $_[0]->{'pipe'} ? "checked" : "";
66 printf "<input type=radio name=pipe value=0 %s> $text{'no'}</td>\n",
67 $_[0]->{'pipe'} ? "" : "checked";
69 print "<td><b>$text{'acl_stop'}</b></td> <td>\n";
70 printf "<input type=radio name=stop value=1 %s> $text{'yes'}\n",
71 $_[0]->{'stop'} ? "checked" : "";
72 printf "<input type=radio name=stop value=0 %s> $text{'no'}</td> </tr>\n",
73 $_[0]->{'stop'} ? "" : "checked";
75 print "<tr> <td><b>$text{'acl_apply'}</b></td> <td>\n";
76 printf "<input type=radio name=apply value=1 %s> $text{'yes'}\n",
77 $_[0]->{'apply'} ? "checked" : "";
78 printf "<input type=radio name=apply value=0 %s> $text{'no'}</td>\n",
79 $_[0]->{'apply'} ? "" : "checked";
81 print "<td><b>$text{'acl_names'}</b></td> <td>\n";
82 printf "<input type=radio name=names value=1 %s> $text{'yes'}\n",
83 $_[0]->{'names'} ? "checked" : "";
84 printf "<input type=radio name=names value=0 %s> $text{'no'}</td> </tr>\n",
85 $_[0]->{'names'} ? "" : "checked";
87 print "<tr> <td><b>$text{'acl_dir'}</b></td>\n";
88 printf "<td colspan=3><input name=dir size=30 value='%s'> %s</td> </tr>\n",
89 $_[0]->{'dir'}, &file_chooser_button("dir", 1);
91 print "<tr> <td><b>$text{'acl_aliasdir'}</b></td>\n";
92 printf "<td colspan=3><input name=aliasdir size=30 value='%s'> %s</td> </tr>\n",
93 $_[0]->{'aliasdir'}, &file_chooser_button("aliasdir", 1);
95 print "<tr> <td valign=top><b>$text{'acl_types'}</b></td>\n";
96 print "<td colspan=3>\n";
97 printf "<input type=radio name=types_def value=1 %s> $text{'acl_all'} \n",
98 $_[0]->{'types'} eq '*' ? "checked" : "";
99 printf "<input type=radio name=types_def value=0 %s> $text{'acl_sel'}<br>\n",
100 $_[0]->{'types'} eq '*' ? "" : "checked";
101 map { $types{$_}++ } split(/\s+/, $_[0]->{'types'});
102 print "<select name=types size=5 multiple>\n";
103 for($i=0; $text{"type_$i"}; $i++) {
104 printf "<option value=\"%d\" %s>%s\n",
105 $i, $types{$i} ? "selected" : "", $text{"type_$i"};
107 print "</select></td> </tr>\n";
109 print "<tr> <td valign=top><b>$text{'acl_dirs'}</b></td>\n";
110 print "<td colspan=3>\n";
111 print &ui_radio("dirsmode", $_[0]->{'dirsmode'},
112 [ [ 0, $text{'acl_dirs0'} ],
113 [ 1, $text{'acl_dirs1'} ],
114 [ 2, $text{'acl_dirs2'} ] ]),"<br>\n";
115 print &ui_textarea("dirs", join("\n", split(/\s+/, $_[0]->{'dirs'})), 5, 50);
116 print "</td> </tr>\n";
119 # acl_security_save(&options)
120 # Parse the form for security options for the apache module
121 sub acl_security_save
123 if ($in{'virts_def'}) {
124 $_[0]->{'virts'} = "*";
127 $_[0]->{'virts'} = join(" ", split(/\0/, $in{'virts'}));
129 $_[0]->{'global'} = $in{'global'};
130 $_[0]->{'create'} = $in{'create'};
131 $_[0]->{'vuser'} = $in{'vuser'};
132 $_[0]->{'stop'} = $in{'stop'};
133 $_[0]->{'apply'} = $in{'apply'};
134 $_[0]->{'vaddr'} = $in{'vaddr'};
135 $_[0]->{'dir'} = $in{'dir'};
136 $_[0]->{'aliasdir'} = $in{'aliasdir'};
137 $_[0]->{'types'} = $in{'types_def'} ? '*'
138 : join(" ", split(/\0/, $in{'types'}));
139 $_[0]->{'pipe'} = $in{'pipe'};
140 $_[0]->{'names'} = $in{'names'};
141 $_[0]->{'dirsmode'} = $in{'dirsmode'};
142 $_[0]->{'dirs'} = join(" ", split(/\s+/, $in{'dirs'}));