mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 14:13:29 +00:00
strict and ui-lib conversion
This commit is contained in:
@@ -26,7 +26,7 @@ else {
|
||||
($pool) = grep { $_->{'values'}->[0] == $in{'idx'} } @pools;
|
||||
my @params = &find_config("delay_parameters", $conf);
|
||||
($param) = grep { $_->{'values'}->[0] == $in{'idx'} } @params;
|
||||
my @access = &find_config("delay_access", $conf);
|
||||
@access = &find_config("delay_access", $conf);
|
||||
@access = grep { $_->{'values'}->[0] == $in{'idx'} } @access;
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ if (!$in{'new'}) {
|
||||
$hc != 0,
|
||||
$hc != @access-1
|
||||
);
|
||||
print &ui_table_row([
|
||||
$table .= &ui_columns_row([
|
||||
&ui_link("pool_access.cgi?index=".
|
||||
"$h->{'index'}&idx=$in{'idx'}",
|
||||
$v[1]),
|
||||
|
||||
@@ -2,11 +2,15 @@
|
||||
# pool_access.cgi
|
||||
# A form for editing or creating delay pool ACL
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
our (%text, %in, %access, $squid_version, %config);
|
||||
require './squid-lib.pl';
|
||||
$access{'delay'} || &error($text{'delay_ecannot'});
|
||||
&ReadParse();
|
||||
$conf = &get_config();
|
||||
my $conf = &get_config();
|
||||
|
||||
my @delay;
|
||||
if (!defined($in{'index'})) {
|
||||
&ui_print_header(undef, $text{'apool_header'}, "",
|
||||
undef, 0, 0, 0, &restart_button());
|
||||
@@ -17,50 +21,46 @@ else {
|
||||
@delay = @{$conf->[$in{'index'}]->{'values'}};
|
||||
}
|
||||
|
||||
print "<form action=pool_access_save.cgi>\n";
|
||||
print &ui_form_start("pool_access_save.cgi", "post");
|
||||
print &ui_hidden("idx", $in{'idx'});
|
||||
if (@delay) {
|
||||
print "<input type=hidden name=index value=$in{'index'}>\n";
|
||||
print &ui_hidden("index", $in{'index'});
|
||||
}
|
||||
print "<input type=hidden name=idx value=$in{'idx'}>\n";
|
||||
print "<table border>\n";
|
||||
print "<tr $tb> <td><b>$text{'apool_pr'}</b></td> </tr>\n";
|
||||
print "<tr $cb> <td><table>\n";
|
||||
print &ui_table_start($text{'apool_pr'}, undef, 2);
|
||||
|
||||
print "<tr> <td><b>$text{'ahttp_a'}</b></td> <td colspan=3>\n";
|
||||
printf "<input type=radio name=action value=allow %s> $text{'ahttp_a1'}\n",
|
||||
$delay[1] eq "allow" ? "checked" : "";
|
||||
printf "<input type=radio name=action value=deny %s> $text{'ahttp_d'}</td> </tr>\n",
|
||||
$delay[1] eq "allow" ? "" : "checked";
|
||||
# Allow or deny ACLs
|
||||
print &ui_table_row($text{'ahttp_a'},
|
||||
&ui_radio("action", $delay[1] || "allow",
|
||||
[ [ "allow", $text{'ahttp_a1'} ],
|
||||
[ "deny", $text{'ahttp_d'} ] ]));
|
||||
|
||||
for($i=2; $i<@delay; $i++) { $match{$delay[$i]}++; }
|
||||
@acls = grep { !$done{$_->{'values'}->[0]}++ } &find_config("acl", $conf);
|
||||
# Get list of ACLs being matched, and all ACLs
|
||||
my (@yes, @no);
|
||||
for(my $i=2; $i<@delay; $i++) {
|
||||
if ($delay[$i] =~ /^!(.*)/) {
|
||||
push(@no, $1);
|
||||
}
|
||||
else {
|
||||
push(@yes, $delay[$i]);
|
||||
}
|
||||
}
|
||||
my %done;
|
||||
my @acls = grep { !$done{$_->{'values'}->[0]}++ } &find_config("acl", $conf);
|
||||
unshift(@acls, { 'values' => [ 'all' ] }) if ($squid_version >= 3);
|
||||
$r = @acls; $r = 10 if ($r > 10);
|
||||
my $r = @acls;
|
||||
$r = 10 if ($r > 10);
|
||||
|
||||
print "<tr> <td valign=top><b>$text{'ahttp_ma'}</b></td>\n";
|
||||
print "<td valign=top><select name=yes multiple size=$r width=100>\n";
|
||||
foreach $a (@acls) {
|
||||
printf "<option %s>%s</option>\n",
|
||||
$match{$a->{'values'}->[0]} ? "selected" : "",
|
||||
$a->{'values'}->[0];
|
||||
}
|
||||
print "</select></td>\n";
|
||||
print &ui_table_row($text{'ahttp_ma'},
|
||||
&ui_select("yes", \@yes, [ map { $_->{'values'}->[0] } @acls ],
|
||||
$r, 1, 1));
|
||||
|
||||
print "<td valign=top><b>$text{'ahttp_dma'}</b></td>\n";
|
||||
print "<td valign=top><select name=no multiple size=$r width=100>\n";
|
||||
foreach $a (@acls) {
|
||||
printf "<option %s>%s</option>\n",
|
||||
$match{"!$a->{'values'}->[0]"} ? "selected" : "",
|
||||
$a->{'values'}->[0];
|
||||
}
|
||||
print "</select></td> </tr>\n";
|
||||
print &ui_table_row($text{'ahttp_dma'},
|
||||
&ui_select("no", \@no, [ map { $_->{'values'}->[0] } @acls ],
|
||||
$r, 1, 1));
|
||||
|
||||
print "</table></td></tr></table>\n";
|
||||
print "<input type=submit value='$text{'buttsave'}'>\n";
|
||||
if (@delay) {
|
||||
print "<input type=submit value='$text{'buttdel'}' name=delete>\n";
|
||||
}
|
||||
print "</form>\n";
|
||||
print &ui_table_end();
|
||||
print &ui_form_end([ [ undef, $text{'buttsave'} ],
|
||||
@delay ? ( [ 'delete', $text{'buttdel'} ] ) : ( ) ]);
|
||||
|
||||
&ui_print_footer("edit_pool.cgi?idx=$in{'idx'}", $text{'pool_return'},
|
||||
"", $text{'index_return'});
|
||||
|
||||
@@ -2,13 +2,17 @@
|
||||
# pool_access_save.cgi
|
||||
# Save or delete a delay pool ACL
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
our (%text, %in, %access, $squid_version, %config);
|
||||
require './squid-lib.pl';
|
||||
$access{'delay'} || &error($text{'delay_ecannot'});
|
||||
&ReadParse();
|
||||
&lock_file($config{'squid_conf'});
|
||||
$conf = &get_config();
|
||||
my $conf = &get_config();
|
||||
|
||||
@delays = &find_config("delay_access", $conf);
|
||||
my @delays = &find_config("delay_access", $conf);
|
||||
my $delay;
|
||||
if (defined($in{'index'})) {
|
||||
$delay = $conf->[$in{'index'}];
|
||||
}
|
||||
@@ -18,10 +22,10 @@ if ($in{'delete'}) {
|
||||
}
|
||||
else {
|
||||
# update or create
|
||||
@vals = ( $in{'idx'}, $in{'action'} );
|
||||
foreach $y (split(/\0/, $in{'yes'})) { push(@vals, $y); }
|
||||
foreach $n (split(/\0/, $in{'no'})) { push(@vals, "!$n"); }
|
||||
$newdelay = { 'name' => 'delay_access', 'values' => \@vals };
|
||||
my @vals = ( $in{'idx'}, $in{'action'} );
|
||||
foreach my $y (split(/\0/, $in{'yes'})) { push(@vals, $y); }
|
||||
foreach my $n (split(/\0/, $in{'no'})) { push(@vals, "!$n"); }
|
||||
my $newdelay = { 'name' => 'delay_access', 'values' => \@vals };
|
||||
if ($delay) { splice(@delays, &indexof($delay, @delays), 1, $newdelay);}
|
||||
else { push(@delays, $newdelay); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user