2 # A form for editing or creating a header access control rule
4 require './squid-lib.pl';
5 $access{'headeracc'} || &error($text{'header_ecannot'});
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());
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'}};
21 print "<form action=save_headeracc.cgi>\n";
23 print "<input type=hidden name=index value='$in{'index'}'>\n";
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";
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];
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";
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);
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";
47 printf "<option %s>%s\n",
48 $match{$a->{'values'}->[0]} ? "selected" : "",
51 print "</select></td>\n";
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";
56 printf "<option %s>%s\n",
57 $match{"!$a->{'values'}->[0]"} ? "selected" : "",
60 print "</select></td> </tr>\n";
62 print "</table></td></tr></table>\n";
63 print "<input type=submit value='$text{'buttsave'}'>\n";
65 print "<input type=submit value='$text{'buttdel'}' name=delete>\n";
69 &ui_print_footer("list_headeracc.cgi", $text{'header_return'},
70 "", $text{'index_return'});