#!/usr/local/bin/perl # edit_acl.cgi # Display a list of all ACLs and restrictions using them require './squid-lib.pl'; $access{'actrl'} || &error($text{'eacl_ecannot'}); &ui_print_header(undef, $text{'eacl_header'}, "", "edit_acl", 0, 0, 0, &restart_button()); $conf = &get_config(); print "
| \n";
# List all defined access control directives
@acl = &find_config("acl", $conf);
if (@acl) {
print &ui_subheading($text{'eacl_acls'});
print &ui_columns_start([ $text{'eacl_name'},
$text{'eacl_type'},
$text{'eacl_match'} ], 100);
foreach $a (@acl) {
@v = @{$a->{'values'}};
local @cols;
push(@cols, "{'index'}\">".
&html_escape($v[0])."");
push(@cols, $acl_types{$v[1]});
if ($v[2] =~ /^"(.*)"$/ || $v[3] =~ /^"(.*)"$/) {
push(@cols, &text('eacl_file', "$1"));
}
else {
push(@cols, &html_escape(join(' ', @v[2..$#v])));
}
print &ui_columns_row(\@cols, [ "", "nowrap", "" ]);
}
print &ui_columns_end();
}
else {
print "$text{'eacl_noacls'} \n"; } print " \n"; print " | \n";
# List all HTTP restrictions, based on ACLs
@http = &find_config("http_access", $conf);
if (@http) {
print &ui_subheading($text{'eacl_pr'});
@tds = ( "width=5", "width=10%", undef, "width=32" );
print &ui_form_start("delete_http_accesses.cgi", "post");
print "$text{'eacl_addpr'} \n"; print &ui_columns_start([ "", $text{'eacl_act'}, $text{'eacl_acls1'}, $text{'eacl_move'} ], 100, 0, \@tds); $hc = 0; foreach $h (@http) { @v = @{$h->{'values'}}; if ($v[0] eq "allow") { $v[0] = $text{'eacl_allow'}; } else { $v[0] = $text{'eacl_deny'}; } local @cols; push(@cols, "{'index'}\">". "$v[0]"); push(@cols, &html_escape(join(' ', @v[1..$#v]))); local $mover; if ($hc != @http-1) { $mover .= "". " ";
}
else {
$mover .= " ";
}
if ($hc != 0) {
$mover .= "".
" ";
}
else {
$mover .= " ";
}
push(@cols, $mover);
print &ui_checked_columns_row(\@cols, \@tds, "d",$h->{'index'});
$hc++;
}
print &ui_columns_end();
print "$text{'eacl_addpr'}\n"; print &ui_form_end([ [ "delete", $text{'eacl_hdelete'} ] ]); } else { print "$text{'eacl_nopr'} \n";
print "$text{'eacl_addpr'} |
| \n";
# List all ICP restrictions, based on ACLs
@icp = &find_config("icp_access", $conf);
if (@icp) {
print &ui_subheading($text{'eacl_icpr'});
print &ui_form_start("delete_icp_accesses.cgi", "post");
@tds = ( "width=5", "width=10%", undef, "width=32" );
print "$text{'eacl_addicpr'} \n"; print &ui_columns_start([ "", $text{'eacl_act'}, $text{'eacl_acls1'}, $text{'eacl_move'} ], 100, 0, \@tds); $ic = 0; foreach $i (@icp) { @v = @{$i->{'values'}}; if ($v[0] eq "allow") { $v[0] = $text{'eacl_allow'}; } else { $v[0] = $text{'eacl_deny'}; } local @cols; push(@cols, "{'index'}\">". "$v[0]"); push(@cols, &html_escape(join(' ', @v[1..$#v]))); local $mover; if ($hc != @icp-1) { $mover .= "". " ";
}
else {
$mover .= " ";
}
if ($hc != 0) {
$mover .= "".
" ";
}
else {
$mover .= " ";
}
push(@cols, $mover);
print &ui_checked_columns_row(\@cols, \@tds, "d",$i->{'index'});
$ic++;
}
print &ui_columns_end();
print "$text{'eacl_addicpr'}\n"; print &ui_form_end([ [ "delete", $text{'eacl_hdelete'} ] ]); } else { print "$text{'eacl_noicpr'} \n";
print "$text{'eacl_addicpr'} | |
| \n";
print &ui_subheading($text{'eacl_ext'});
@ext = &find_config("external_acl_type", $conf);
if (@ext) {
print &ui_columns_start([ $text{'eacl_cname'},
$text{'eacl_format'},
$text{'eacl_program'} ], 100);
foreach $e (@ext) {
$ea = &parse_external($e);
print &ui_columns_row([
"".
"$ea->{'name'}",
$ea->{'format'},
join(" ", $ea->{'program'}, @{$ea->{'args'}})
]);
}
print &ui_columns_end();
}
else {
print "$text{'eacl_noext'} \n"; } print "$text{'eacl_addext'}\n"; print " | |
\n"; &ui_print_footer("", $text{'eacl_return'});