3 # Display a list of all ACLs and restrictions using them
5 require './squid-lib.pl';
7 $access{'actrl'} || &error($text{'eacl_ecannot'});
8 &ui_print_header(undef, $text{'eacl_header'}, "", "edit_acl", 0, 0, 0, &restart_button());
11 # Start tabs for various ACL settings
12 $prog = "edit_acl.cgi";
13 @tabs = ( [ "acls", $text{'eacl_acls'}, $prog."?mode=acls" ],
14 [ "http", $text{'eacl_pr'}, $prog."?mode=http" ],
15 [ "icp", $text{'eacl_icpr'}, $prog."?mode=icp" ] );
16 if ($squid_version >= 2.5) {
17 push(@tabs, [ "external", $text{'eacl_ext'}, $prog."?mode=external" ],
18 [ "reply", $text{'eacl_replypr'}, $prog."?mode=reply" ] );
20 print &ui_tabs_start(\@tabs, "mode", $in{'mode'} || "acls", 1);
22 # List all defined access control directives
23 print &ui_tabs_start_tab("mode", "acls");
24 @acl = &find_config("acl", $conf);
26 print &ui_columns_start([ $text{'eacl_name'},
28 $text{'eacl_match'} ], 100);
30 @v = @{$a->{'values'}};
32 push(@cols, "<a href=\"acl.cgi?index=$a->{'index'}\">".
33 &html_escape($v[0])."</a>");
34 push(@cols, $acl_types{$v[1]});
35 if ($v[2] =~ /^"(.*)"$/ || $v[3] =~ /^"(.*)"$/) {
36 push(@cols, &text('eacl_file', "<tt>$1</tt>"));
39 push(@cols, &html_escape(join(' ', @v[2..$#v])));
41 print &ui_columns_row(\@cols, [ "", "nowrap", "" ]);
43 print &ui_columns_end();
46 print "<b>$text{'eacl_noacls'}</b><p>\n";
48 print "<form action=acl.cgi>\n";
49 print "<input type=submit value=\"$text{'eacl_buttcreate'}\">\n";
50 print "<select name=type>\n";
51 foreach $t (sort { $acl_types{$a} cmp $acl_types{$b} } keys %acl_types) {
52 print "<option value=$t>$acl_types{$t}\n";
54 print "</select></form>\n";
55 print &ui_tabs_end_tab();
57 # List all HTTP restrictions, based on ACLs
58 print &ui_tabs_start_tab("mode", "http");
59 @http = &find_config("http_access", $conf);
61 @tds = ( "width=5", "width=10%", undef, "width=32" );
62 print &ui_form_start("delete_http_accesses.cgi", "post");
63 print "<a href=http_access.cgi?new=1>$text{'eacl_addpr'}</a><br>\n";
64 print &ui_columns_start([ "",
67 $text{'eacl_move'} ], 100, 0, \@tds);
70 @v = @{$h->{'values'}};
71 if ($v[0] eq "allow") {
72 $v[0] = $text{'eacl_allow'};
75 $v[0] = $text{'eacl_deny'};
78 push(@cols, "<a href=\"http_access.cgi?index=$h->{'index'}\">".
80 push(@cols, &html_escape(join(' ', @v[1..$#v])));
81 local $mover = &ui_up_down_arrows(
82 "move_http.cgi?$hc+-1",
83 "move_http.cgi?$hc+1",
88 print &ui_checked_columns_row(\@cols, \@tds, "d",$h->{'index'});
91 print &ui_columns_end();
92 print "<a href=http_access.cgi?new=1>$text{'eacl_addpr'}</a><br>\n";
93 print &ui_form_end([ [ "delete", $text{'eacl_hdelete'} ] ]);
96 print "<b>$text{'eacl_nopr'}</b><p>\n";
97 print "<a href=http_access.cgi?new=1>$text{'eacl_addpr'}</a><br>\n";
99 print &ui_tabs_end_tab();
101 # List all ICP restrictions, based on ACLs
102 print &ui_tabs_start_tab("mode", "icp");
103 @icp = &find_config("icp_access", $conf);
105 print &ui_form_start("delete_icp_accesses.cgi", "post");
106 @tds = ( "width=5", "width=10%", undef, "width=32" );
107 print "<a href=icp_access.cgi?new=1>$text{'eacl_addicpr'}</a><br>\n";
108 print &ui_columns_start([ "",
111 $text{'eacl_move'} ], 100, 0, \@tds);
114 @v = @{$i->{'values'}};
115 if ($v[0] eq "allow") {
116 $v[0] = $text{'eacl_allow'};
119 $v[0] = $text{'eacl_deny'};
122 push(@cols, "<a href=\"icp_access.cgi?index=$i->{'index'}\">".
124 push(@cols, &html_escape(join(' ', @v[1..$#v])));
125 local $mover = &ui_up_down_arrows(
126 "move_icp.cgi?$ic+-1",
127 "move_icp.cgi?$ic+1",
131 print &ui_checked_columns_row(\@cols, \@tds, "d",$i->{'index'});
134 print &ui_columns_end();
135 print "<a href=icp_access.cgi?new=1>$text{'eacl_addicpr'}</a><br>\n";
136 print &ui_form_end([ [ "delete", $text{'eacl_hdelete'} ] ]);
139 print "<b>$text{'eacl_noicpr'}</b><p>\n";
140 print "<a href=icp_access.cgi?new=1>$text{'eacl_addicpr'}</a><br>\n";
142 print &ui_tabs_end_tab();
144 # List all HTTP REPLY restrictions, based on ACLs
145 if ($squid_version >= 2.5) {
146 print &ui_tabs_start_tab("mode", "reply");
147 @http_reply = &find_config("http_reply_access", $conf);
149 @tds = ( "width=5", "width=10%", undef, "width=32" );
150 print &ui_form_start("delete_http_reply_accesses.cgi", "post");
151 print "<a href=http_reply_access.cgi?new=1>$text{'eacl_addpr'}</a><br>\n";
152 print &ui_columns_start([ "",
155 $text{'eacl_move'} ], 100, 0, \@tds);
157 foreach $h (@http_reply) {
158 @v = @{$h->{'values'}};
159 if ($v[0] eq "allow") {
160 $v[0] = $text{'eacl_allow'};
163 $v[0] = $text{'eacl_deny'};
166 push(@cols, "<a href=\"http_reply_access.cgi?index=$h->{'index'}\">".
168 push(@cols, &html_escape(join(' ', @v[1..$#v])));
170 if ($hc != @http_reply-1) {
171 $mover .= "<a href=\"move_http_reply.cgi?$hc+1\">".
172 "<img src=images/down.gif border=0></a>";
175 $mover .= "<img src=images/gap.gif>";
178 $mover .= "<a href=\"move_http_reply.cgi?$hc+-1\">".
179 "<img src=images/up.gif border=0></a>";
182 $mover .= "<img src=images/gap.gif>";
185 print &ui_checked_columns_row(\@cols, \@tds, "d",$h->{'index'});
188 print &ui_columns_end();
189 print "<a href=http_reply_access.cgi?new=1>$text{'eacl_addpr'}</a><br>\n";
190 print &ui_form_end([ [ "delete", $text{'eacl_hdelete'} ] ]);
193 print "<b>$text{'eacl_noprr'}</b><p>\n";
194 print "<a href=http_reply_access.cgi?new=1>$text{'eacl_addprr'}</a><br>\n";
196 print &ui_tabs_end_tab();
199 if ($squid_version >= 2.5) {
200 # Show table of external ACL types
201 print &ui_tabs_start_tab("mode", "external");
202 @ext = &find_config("external_acl_type", $conf);
204 print &ui_columns_start([ $text{'eacl_cname'},
205 $text{'eacl_format'},
206 $text{'eacl_program'} ], 100);
208 $ea = &parse_external($e);
209 print &ui_columns_row([
210 "<a href='edit_ext.cgi?index=$e->{'index'}'>".
213 join(" ", $ea->{'program'}, @{$ea->{'args'}})
216 print &ui_columns_end();
219 print "<b>$text{'eacl_noext'}</b><p>\n";
221 print "<a href=edit_ext.cgi?new=1>$text{'eacl_addext'}</a>\n";
222 print &ui_tabs_end_tab();
225 print &ui_tabs_end(1);
227 &ui_print_footer("", $text{'eacl_return'});