mirror of
https://github.com/webmin/webmin.git
synced 2026-03-20 16:50:24 +00:00
strict and ui-lib conversion
This commit is contained in:
@@ -2,23 +2,26 @@
|
||||
# edit_delay.cgi
|
||||
# Displays a list of existing delay pools
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
our (%text, %in, %access, $squid_version, %config);
|
||||
require './squid-lib.pl';
|
||||
$access{'delay'} || &error($text{'delay_ecannot'});
|
||||
&ui_print_header(undef, $text{'delay_title'}, "", "edit_delay", 0, 0, 0, &restart_button());
|
||||
$conf = &get_config();
|
||||
my $conf = &get_config();
|
||||
|
||||
# Display all known delay pools
|
||||
$pools = &find_value("delay_pools", $conf);
|
||||
@links = ( &select_all_link("d"),
|
||||
&select_invert_link("d"),
|
||||
"<a href='edit_pool.cgi?new=1'>$text{'delay_add'}</a>" );
|
||||
my $pools = &find_value("delay_pools", $conf);
|
||||
my @links = ( &select_all_link("d"),
|
||||
&select_invert_link("d"),
|
||||
&ui_link("edit_pool.cgi?new=1", $text{'delay_add'}) );
|
||||
if ($pools) {
|
||||
@pools = sort { $a->{'values'}->[0] <=> $b->{'values'}->[0] }
|
||||
my @pools = sort { $a->{'values'}->[0] <=> $b->{'values'}->[0] }
|
||||
&find_config("delay_class", $conf);
|
||||
@params = &find_config("delay_parameters", $conf);
|
||||
my @params = &find_config("delay_parameters", $conf);
|
||||
print &ui_form_start("delete_pools.cgi", "post");
|
||||
print &ui_links_row(\@links);
|
||||
@tds = ( "width=5" );
|
||||
my @tds = ( "width=5" );
|
||||
print &ui_columns_start([ "",
|
||||
$text{'delay_num'},
|
||||
$text{'delay_class'},
|
||||
@@ -29,12 +32,12 @@ if ($pools) {
|
||||
$text{'delay_user'},
|
||||
$text{'delay_tag'} ) : ( ),
|
||||
], 100, 0, \@tds);
|
||||
foreach $p (@pools) {
|
||||
local ($pr) = grep { $_->{'values'}->[0] ==
|
||||
$p->{'values'}->[0] } @params;
|
||||
local @cols;
|
||||
push(@cols, "<a href='edit_pool.cgi?idx=$p->{'values'}->[0]'>".
|
||||
"$p->{'values'}->[0]</a>");
|
||||
foreach my $p (@pools) {
|
||||
my ($pr) = grep { $_->{'values'}->[0] ==
|
||||
$p->{'values'}->[0] } @params;
|
||||
my @cols;
|
||||
push(@cols, &ui_link("edit_pool.cgi?idx=$p->{'values'}->[0]",
|
||||
$p->{'values'}->[0]));
|
||||
push(@cols, $text{"delay_class_$p->{'values'}->[1]"});
|
||||
if ($p->{'values'}->[1] == 5) {
|
||||
push(@cols, "", "", "", "");
|
||||
@@ -73,31 +76,27 @@ else {
|
||||
print &ui_links_row([ $links[2] ]);
|
||||
}
|
||||
|
||||
print "<form action=save_delay.cgi>\n";
|
||||
print "<table border width=100%>\n";
|
||||
print "<tr $tb> <td><b>$text{'delay_header'}</b></td> </tr>\n";
|
||||
print "<tr $cb> <td><table width=100%>\n";
|
||||
print &ui_form_start("save_delay.cgi", "post");
|
||||
print &ui_table_start($text{'delay_header'}, undef, 4);
|
||||
|
||||
print "<tr>\n";
|
||||
print &opt_input($text{'delay_initial'}, "delay_initial_bucket_level", $conf,
|
||||
$text{'default'}, 4, "%");
|
||||
print "<td colspan=2 width=50%></td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
print "</table></td></tr></table>\n";
|
||||
print "<input type=submit value='$text{'save'}'></form>\n";
|
||||
print &ui_table_end();
|
||||
print &ui_form_end([ [ undef, $text{'save'} ] ]);
|
||||
|
||||
&ui_print_footer("", $text{'eicp_return'});
|
||||
|
||||
# pool_param(param)
|
||||
sub pool_param
|
||||
{
|
||||
if ($_[0] =~ /^([0-9\-]+)\/([0-9\-]+)$/) {
|
||||
my ($param) = @_;
|
||||
if ($param =~ /^([0-9\-]+)\/([0-9\-]+)$/) {
|
||||
return $1 == -1 ? $text{'delay_unlimited'} :
|
||||
&text('delay_param', "$1", "$2");
|
||||
}
|
||||
else {
|
||||
return $_[0]; # huh?
|
||||
return $param; # huh?
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -155,5 +155,5 @@ else {
|
||||
}
|
||||
return &ui_textbox($name."_n", $value > 0 ? $value/$ud[$u] : $value, 8)." ".
|
||||
&ui_select($name."_u", $u,
|
||||
[ map { [ $ud[$_], $text{'pool_unit'.$_} ] } (0..$#ud) ]);
|
||||
[ map { [ $_, $text{'pool_unit'.$_} ] } (0..$#ud) ]);
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@
|
||||
# save_delay.cgi
|
||||
# Save global delay pool options
|
||||
|
||||
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();
|
||||
&error_setup($text{'delay_err'});
|
||||
|
||||
&save_opt("delay_initial_bucket_level", \&check_initial, $conf);
|
||||
|
||||
@@ -99,8 +99,8 @@ else {
|
||||
my $u2 = $in{$name."_2_n"};
|
||||
$u1 =~ /^\d+$/ || $u1 == -1 || &error(&text('pool_elimit1', $u1));
|
||||
$u2 =~ /^\d+$/ || $u2 == -1 || &error(&text('pool_elimit2', $u2));
|
||||
$u1 = int($u1 * $ud[$in{"$_[0]_1_u"}]);
|
||||
$u2 = int($u2 * $ud[$in{"$_[0]_2_u"}]);
|
||||
$u1 = int($u1 * $ud[$in{$name."_1_u"}]);
|
||||
$u2 = int($u2 * $ud[$in{$name."_2_u"}]);
|
||||
return "$u1/$u2";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user