Handle hostnames with upper-case letters
[webmin.git] / squid / icp_access.cgi
1 #!/usr/local/bin/perl
2 # icp_access.cgi
3 # A form for editing or creating an ICP access restriction
4
5 require './squid-lib.pl';
6 $access{'actrl'} || &error($text{'eacl_ecannot'});
7 &ReadParse();
8 $conf = &get_config();
9
10 if (!defined($in{'index'})) {
11         &ui_print_header(undef, $text{'aicp_header'}, "",
12                 undef, 0, 0, 0, &restart_button());
13         }
14 else {
15         &ui_print_header(undef, $text{'aicp_header1'}, "",
16                 undef, 0, 0, 0, &restart_button());
17         @icp = @{$conf->[$in{'index'}]->{'values'}};
18         }
19
20 print "<form action=icp_access_save.cgi>\n";
21 if (@icp) {
22         print "<input type=hidden name=index value=$in{'index'}>\n";
23         }
24 print "<table border>\n";
25 print "<tr $tb> <td><b>$text{'aicp_ir'}</b></td> </tr>\n";
26 print "<tr $cb> <td><table>\n";
27
28 print "<tr> <td><b>$text{'aicp_a'}</b></td> <td colspan=3>\n";
29 printf "<input type=radio name=action value=allow %s> $text{'aicp_a1'}\n",
30         $icp[0] eq "allow" ? "checked" : "";
31 printf "<input type=radio name=action value=deny %s> $text{'aicp_d'}</td> </tr>\n",
32         $icp[0] eq "allow" ? "" : "checked";
33
34 for($i=1; $i<@icp; $i++) { $match{$icp[$i]}++; }
35 @acls = grep { !$done{$_->{'values'}->[0]}++ } &find_config("acl", $conf);
36 unshift(@acls, { 'values' => [ 'all' ] }) if ($squid_version >= 3);
37 $r = @acls; $r = 10 if ($r > 10);
38
39 print "<tr> <td valign=top><b>$text{'aicp_ma'}</b></td>\n";
40 print "<td><select name=yes multiple rows=$r width=100>\n";
41 foreach $a (@acls) {
42         printf "<option %s>%s\n",
43                 $match{$a->{'values'}->[0]} ? "selected" : "",
44                 $a->{'values'}->[0];
45         }
46 print "</select></td>\n";
47
48 print "<td valign=top><b>$text{'aicp_dma'}</b></td>\n";
49 print "<td><select name=no multiple rows=$r width=100>\n";
50 foreach $a (@acls) {
51         printf "<option %s>%s\n",
52                 $match{"!$a->{'values'}->[0]"} ? "selected" : "",
53                 $a->{'values'}->[0];
54         }
55 print "</select></td> </tr>\n";
56
57 print "</table></td></tr></table>\n";
58 print "<input type=submit value='$text{'buttsave'}'>\n";
59 if (@icp) {
60         print "<input type=submit value='$text{'buttdel'}' name=delete>\n";
61         }
62 print "</form>\n";
63
64 &ui_print_footer("edit_acl.cgi?mode=icp", $text{'aicp_return'},
65                  "", $text{'index_return'});
66