Handle hostnames with upper-case letters
[webmin.git] / squid / edit_headeracc.cgi
1 #!/usr/local/bin/perl
2 # A form for editing or creating a header access control rule
3
4 require './squid-lib.pl';
5 $access{'headeracc'} || &error($text{'header_ecannot'});
6 &ReadParse();
7 $conf = &get_config();
8
9 if (!defined($in{'index'})) {
10         &ui_print_header(undef, $text{'header_create_'.$in{'type'}} ||
11                                 $text{'header_create'}, "",
12                 undef, 0, 0, 0, &restart_button());
13         }
14 else {
15         &ui_print_header(undef, $text{'header_edit_'.$in{'type'}} ||
16                                 $text{'header_edit'}, "",
17                 undef, 0, 0, 0, &restart_button());
18         @v = @{$conf->[$in{'index'}]->{'values'}};
19         }
20
21 print "<form action=save_headeracc.cgi>\n";
22 if (@v) {
23         print "<input type=hidden name=index value='$in{'index'}'>\n";
24         }
25 print &ui_hidden("type", $in{'type'});
26 print "<table border>\n";
27 print "<tr $tb> <td><b>$text{'header_header'}</b></td> </tr>\n";
28 print "<tr $cb> <td><table>\n";
29
30 print "<tr> <td><b>$text{'header_name'}</b></td> <td colspan=3>\n";
31 printf "<input name=name size=30 value='%s'></td> </tr>\n", $v[0];
32
33 print "<tr> <td><b>$text{'ahttp_a'}</b></td> <td colspan=3>\n";
34 printf "<input type=radio name=action value=allow %s> $text{'ahttp_a1'}\n",
35         $v[1] eq "allow" ? "checked" : "";
36 printf "<input type=radio name=action value=deny %s> $text{'ahttp_d'}</td> </tr>\n",
37         $v[1] eq "allow" ? "" : "checked";
38
39 for($i=2; $i<@v; $i++) { $match{$v[$i]}++; }
40 @acls = grep { !$done{$_->{'values'}->[0]}++ } &find_config("acl", $conf);
41 unshift(@acls, { 'values' => [ 'all' ] }) if ($squid_version >= 3);
42 $r = @acls; $r = 10 if ($r > 10);
43
44 print "<tr> <td valign=top><b>$text{'ahttp_ma'}</b></td>\n";
45 print "<td valign=top><select name=yes multiple size=$r width=100>\n";
46 foreach $a (@acls) {
47         printf "<option %s>%s\n",
48                 $match{$a->{'values'}->[0]} ? "selected" : "",
49                 $a->{'values'}->[0];
50         }
51 print "</select></td>\n";
52
53 print "<td valign=top><b>$text{'ahttp_dma'}</b></td>\n";
54 print "<td valign=top><select name=no multiple size=$r width=100>\n";
55 foreach $a (@acls) {
56         printf "<option %s>%s\n",
57                 $match{"!$a->{'values'}->[0]"} ? "selected" : "",
58                 $a->{'values'}->[0];
59         }
60 print "</select></td> </tr>\n";
61
62 print "</table></td></tr></table>\n";
63 print "<input type=submit value='$text{'buttsave'}'>\n";
64 if (@v) {
65         print "<input type=submit value='$text{'buttdel'}' name=delete>\n";
66         }
67 print "</form>\n";
68
69 &ui_print_footer("list_headeracc.cgi", $text{'header_return'},
70         "", $text{'index_return'});
71