mirror of
https://github.com/webmin/webmin.git
synced 2026-03-20 16:50:24 +00:00
more strict and ui-lib conversion
This commit is contained in:
@@ -2,192 +2,191 @@
|
||||
# edit_icp.cgi
|
||||
# A form for editing options for communication with other caches
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
our (%text, %in, %access, $squid_version, %config);
|
||||
require './squid-lib.pl';
|
||||
$access{'othercaches'} || &error($text{'eicp_ecannot'});
|
||||
&ui_print_header(undef, $text{'eicp_header'}, "", "edit_icp", 0, 0, 0, &restart_button());
|
||||
$conf = &get_config();
|
||||
$cache_host = $squid_version >= 2 ? "cache_peer" : "cache_host";
|
||||
my $conf = &get_config();
|
||||
my $cache_host = $squid_version >= 2 ? "cache_peer" : "cache_host";
|
||||
|
||||
@ch = &find_config($cache_host, $conf);
|
||||
@links = ( &select_all_link("d"),
|
||||
&select_invert_link("d"),
|
||||
"<a href='edit_cache_host.cgi?new=1'>$text{'eicp_aac'}</a>" );
|
||||
my @ch = &find_config($cache_host, $conf);
|
||||
my @links = ( &select_all_link("d"),
|
||||
&select_invert_link("d"),
|
||||
"<a href='edit_cache_host.cgi?new=1'>$text{'eicp_aac'}</a>" );
|
||||
if (@ch) {
|
||||
#print &ui_subheading($text{'eicp_opcs'});
|
||||
$mid = int((@ch+1)/2);
|
||||
my $mid = int((@ch+1)/2);
|
||||
print &ui_form_start("delete_icps.cgi", "post");
|
||||
print &ui_links_row(\@links);
|
||||
print "<table width=100%><tr> <td width=50% valign=top>\n";
|
||||
&cache_table(0, $mid-1);
|
||||
print &cache_table(0, $mid-1, \@ch);
|
||||
print "</td><td width=50% valign=top>\n";
|
||||
if ($mid < @ch) { &cache_table($mid, $#ch); }
|
||||
if ($mid < @ch) {
|
||||
print &cache_table($mid, $#ch, \@ch);
|
||||
}
|
||||
print "</td> </tr></table>\n";
|
||||
print &ui_links_row(\@links);
|
||||
print &ui_form_end([ [ "delete", $text{'eicp_delete'} ] ]);
|
||||
}
|
||||
else {
|
||||
print "<b>$text{'eicp_nocd'}</b>.<p>\n";
|
||||
print "<b>$text{'eicp_nocd'}</b><p>\n";
|
||||
print &ui_links_row([ $links[2] ]);
|
||||
}
|
||||
|
||||
print &ui_hr();
|
||||
print "<form action=save_icp.cgi>\n";
|
||||
print "<table border width=100%>\n";
|
||||
print "<tr $tb> <td><b>$text{'eicp_cso'}</b></td> </tr>\n";
|
||||
print "<tr $cb> <td><table width=100%>\n";
|
||||
|
||||
print &ui_form_start("save_icp.cgi", "post");
|
||||
print &ui_table_start($text{'eicp_cso'}, "width=100%", 4);
|
||||
|
||||
if ($squid_version < 2) {
|
||||
print "<tr>\n";
|
||||
print &list_input($text{'eicp_fdfd'}, "local_domain", $conf);
|
||||
print &address_input($text{'eicp_fdfi'}, "local_ip", $conf);
|
||||
print "</tr>\n";
|
||||
|
||||
print "<tr>\n";
|
||||
print &list_input($text{'eicp_dif'}, "inside_firewall", $conf);
|
||||
print &address_input($text{'eicp_iif'}, "firewall_ip", $conf);
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
print "<tr>\n";
|
||||
print &list_input($text{'eicp_dfuc'}, "hierarchy_stoplist",
|
||||
$conf, 1, $text{'default'});
|
||||
print "</tr>\n";
|
||||
|
||||
if ($squid_version < 2) {
|
||||
print "<tr>\n";
|
||||
print &choice_input($text{'eicp_bpfsp'},
|
||||
"single_parent_bypass",
|
||||
$conf, "off", $text{'yes'}, "on", $text{'no'}, "off");
|
||||
print &choice_input($text{'eicp_ssip'}, "source_ping", $conf, "off",
|
||||
$text{'yes'}, "on", $text{'no'}, "off");
|
||||
print "</tr>\n";
|
||||
|
||||
print "<tr>\n";
|
||||
print &opt_input($text{'eicp_crt'}, "neighbor_timeout", $conf,
|
||||
$text{'default'}, 4, $text{'eicp_secs'});
|
||||
print "</tr>\n";
|
||||
}
|
||||
else {
|
||||
print "<tr>\n";
|
||||
print &opt_input($text{'eicp_iqt'}, "icp_query_timeout", $conf,
|
||||
$text{'default'}, 8, "ms");
|
||||
print &opt_input($text{'eicp_mit'}, "mcast_icp_query_timeout",
|
||||
$conf, $text{'default'}, 8, "ms");
|
||||
print "</tr>\n";
|
||||
|
||||
print "<tr>\n";
|
||||
print &opt_input($text{'eicp_dpt'}, "dead_peer_timeout", $conf,
|
||||
$text{'default'}, 8, $text{'eicp_secs'});
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
if ($squid_version >= 2.3) {
|
||||
# Display always/never_direct options
|
||||
print "<tr> <td colspan=4><hr></td> </tr>\n";
|
||||
print &ui_hr();
|
||||
|
||||
print "<tr> <td colspan=2 valign=top width=50%>\n";
|
||||
@always = &find_config("always_direct", $conf);
|
||||
my @always = &find_config("always_direct", $conf);
|
||||
my @tds = ( "width=10%", undef, "width=10%" );
|
||||
my $table;
|
||||
if (@always) {
|
||||
print "<b>$text{'eicp_always'}</b><p>\n";
|
||||
print "<table border>\n";
|
||||
print "<tr $tb><td width=10%><b>$text{'eacl_act'}</b></td>\n";
|
||||
print "<td><b>$text{'eacl_acls1'}</b></td>\n";
|
||||
print "<td width=10%><b>$text{'eacl_move'}</b></td> </tr>\n";
|
||||
$hc = 0;
|
||||
foreach $h (@always) {
|
||||
@v = @{$h->{'values'}};
|
||||
$table = &ui_columns_start([ $text{'eacl_act'},
|
||||
$text{'eacl_acls1'},
|
||||
$text{'eacl_move'} ], undef, 0,
|
||||
\@tds);
|
||||
my $hc = 0;
|
||||
foreach my $h (@always) {
|
||||
my @v = @{$h->{'values'}};
|
||||
if ($v[0] eq "allow") {
|
||||
$v[0] = $text{'eacl_allow'};
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$v[0] = $text{'eacl_deny'};
|
||||
}
|
||||
print "<tr $cb>\n";
|
||||
print "<td><a href=\"always.cgi?index=$h->{'index'}\">",
|
||||
"$v[0]</a></td>\n";
|
||||
print "<td>",&html_escape(join(' ', @v[1..$#v])),
|
||||
"</td>\n";
|
||||
print "<td>\n";
|
||||
}
|
||||
my @moves;
|
||||
if ($hc != @always-1) {
|
||||
print "<a href=\"move_always.cgi?$hc+1\">",
|
||||
"<img src=images/down.gif border=0></a>";
|
||||
push(@moves, &ui_link(
|
||||
"move_always.cgi?$hc+1",
|
||||
"<img src=images/down.gif border=0>"));
|
||||
}
|
||||
else {
|
||||
push(@moves, "<img src=images/gap.gif>");
|
||||
}
|
||||
else { print "<img src=images/gap.gif>"; }
|
||||
if ($hc != 0) {
|
||||
print "<a href=\"move_always.cgi?$hc+-1\">",
|
||||
"<img src=images/up.gif border=0></a>";
|
||||
push(@moves, &ui_link(
|
||||
"move_always.cgi?$hc+-1",
|
||||
"<img src=images/up.gif border=0>"));
|
||||
}
|
||||
print "</td></tr>\n";
|
||||
$table .= &ui_columns_row([
|
||||
&ui_link("always.cgi?index=$h->{'index'}", $v[0]),
|
||||
&html_escape(join(' ', @v[1..$#v])),
|
||||
join("", @moves),
|
||||
]);
|
||||
$hc++;
|
||||
}
|
||||
print "</table>\n";
|
||||
$table .= &ui_columns_end();
|
||||
}
|
||||
else {
|
||||
print "<b>$text{'eicp_noalways'}</b><p>\n";
|
||||
$table = "<b>$text{'eicp_noalways'}</b><p>\n";
|
||||
}
|
||||
print "<a href=always.cgi?new=1>$text{'eicp_addalways'}</a>\n";
|
||||
$table .= &ui_links_row([ &ui_link("always.cgi?new=1",
|
||||
$text{'eicp_addalways'}) ]);
|
||||
print &ui_table_row($text{'eicp_always'}, $table, 3);
|
||||
|
||||
print "</td> <td colspan=2 valign=top width=50%>\n";
|
||||
@never = &find_config("never_direct", $conf);
|
||||
my @never = &find_config("never_direct", $conf);
|
||||
if (@never) {
|
||||
print "<b>$text{'eicp_never'}</b><p>\n";
|
||||
print "<table border>\n";
|
||||
print "<tr $tb><td width=10%><b>$text{'eacl_act'}</b></td>\n";
|
||||
print "<td><b>$text{'eacl_acls1'}</b></td>\n";
|
||||
print "<td width=10%><b>$text{'eacl_move'}</b></td> </tr>\n";
|
||||
$hc = 0;
|
||||
foreach $h (@never) {
|
||||
@v = @{$h->{'values'}};
|
||||
$table = &ui_columns_start([ $text{'eacl_act'},
|
||||
$text{'eacl_acls1'},
|
||||
$text{'eacl_move'} ], undef, 0,
|
||||
\@tds);
|
||||
my $hc = 0;
|
||||
foreach my $h (@never) {
|
||||
my @v = @{$h->{'values'}};
|
||||
if ($v[0] eq "allow") {
|
||||
$v[0] = $text{'eacl_allow'};
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$v[0] = $text{'eacl_deny'};
|
||||
}
|
||||
print "<tr $cb>\n";
|
||||
print "<td><a href=\"never.cgi?index=$h->{'index'}\">",
|
||||
"$v[0]</a></td>\n";
|
||||
print "<td>",&html_escape(join(' ', @v[1..$#v])),
|
||||
"</td>\n";
|
||||
print "<td>\n";
|
||||
}
|
||||
my @moves;
|
||||
if ($hc != @never-1) {
|
||||
print "<a href=\"move_never.cgi?$hc+1\">",
|
||||
"<img src=images/down.gif border=0></a>";
|
||||
push(@moves, &ui_link(
|
||||
"move_never.cgi?$hc+1",
|
||||
"<img src=images/down.gif border=0>"));
|
||||
}
|
||||
else {
|
||||
push(@moves, "<img src=images/gap.gif>");
|
||||
}
|
||||
else { print "<img src=images/gap.gif>"; }
|
||||
if ($hc != 0) {
|
||||
print "<a href=\"move_never.cgi?$hc+-1\">",
|
||||
"<img src=images/up.gif border=0></a>";
|
||||
push(@moves, &ui_link(
|
||||
"move_never.cgi?$hc+-1",
|
||||
"<img src=images/up.gif border=0>"));
|
||||
}
|
||||
print "</td></tr>\n";
|
||||
$table .= &ui_columns_row([
|
||||
&ui_link("never.cgi?index=$h->{'index'}", $v[0]),
|
||||
&html_escape(join(' ', @v[1..$#v])),
|
||||
join("", @moves),
|
||||
]);
|
||||
$hc++;
|
||||
}
|
||||
print "</table>\n";
|
||||
$table .= &ui_columns_end();
|
||||
}
|
||||
else {
|
||||
print "<b>$text{'eicp_nonever'}</b><p>\n";
|
||||
$table = "<b>$text{'eicp_nonever'}</b><p>\n";
|
||||
}
|
||||
print "<a href=never.cgi?new=1>$text{'eicp_addnever'}</a>\n";
|
||||
print "</td> </tr>\n";
|
||||
$table .= &ui_links_row([ &ui_link("never.cgi?new=1",
|
||||
$text{'eicp_addnever'}) ]);
|
||||
print &ui_table_row($text{'eicp_never'}, $table, 3);
|
||||
}
|
||||
|
||||
print "</table></td></tr></table>\n";
|
||||
print "<input type=submit value=$text{'buttsave'}></form>\n";
|
||||
print &ui_table_end();
|
||||
print &ui_form_end([ [ undef, $text{'buttsave'} ] ]);
|
||||
|
||||
&ui_print_footer("", $text{'eicp_return'});
|
||||
|
||||
# cache_table(start, end)
|
||||
# cache_table(start, end, &caches)
|
||||
sub cache_table
|
||||
{
|
||||
local @tds = ( "width=5" );
|
||||
print &ui_columns_start([ "",
|
||||
$text{'eicp_thost'},
|
||||
$text{'eicp_ttype'},
|
||||
$text{'eicp_tpport'},
|
||||
$text{'eicp_tiport'} ], 100, 0, \@tds);
|
||||
for($i=$_[0]; $i<=$_[1]; $i++) {
|
||||
@chv = @{$ch[$i]->{'values'}};
|
||||
my ($start, $end, $ch) = @_;
|
||||
my @tds = ( "width=5" );
|
||||
my $rv = &ui_columns_start([ "",
|
||||
$text{'eicp_thost'},
|
||||
$text{'eicp_ttype'},
|
||||
$text{'eicp_tpport'},
|
||||
$text{'eicp_tiport'} ], 100, 0, \@tds);
|
||||
for(my $i=$start; $i<=$end; $i++) {
|
||||
my @chv = @{$ch->[$i]->{'values'}};
|
||||
print &ui_checked_columns_row([
|
||||
"<a href=\"edit_cache_host.cgi?num=$i\">".
|
||||
&html_escape($chv[0])."</a>",
|
||||
&ui_link("edit_cache_host.cgi?num=$i",
|
||||
&html_escape($chv[0])),
|
||||
&html_escape($chv[1]),
|
||||
&html_escape($chv[2]),
|
||||
&html_escape($chv[3])
|
||||
|
||||
@@ -15,15 +15,13 @@ print &ui_table_start($text{'eports_pano'}, "width=100%", 4);
|
||||
|
||||
if ($squid_version >= 2.3) {
|
||||
# Display table of normal ports
|
||||
print "<td valign=top><b>$text{'eports_paap'}</b></td><td colspan=3>\n";
|
||||
&ports_table("http_port");
|
||||
print "</table></td></tr>\n";
|
||||
print &ui_table_row($text{'eports_paap'},
|
||||
&ports_table("http_port"), 3);
|
||||
|
||||
if ($squid_version >= 2.5) {
|
||||
# Display table of SSL ports
|
||||
print "<tr> <td valign=top><b>$text{'eports_ssl'}</b></td><td colspan=3>\n";
|
||||
&ports_table("https_port");
|
||||
print "</table></td></tr>\n";
|
||||
print &ui_table_row($text{'eports_ssl'},
|
||||
&ports_table("https_port"), 3);
|
||||
}
|
||||
print &opt_input($text{'eports_ip'}, "icp_port",
|
||||
$conf, $text{'default'}, 6);
|
||||
@@ -92,6 +90,7 @@ $rv .= &ui_columns_start([ $text{'eports_p'}, $text{'eports_hia'},
|
||||
: ( ) ]);
|
||||
my $i = 0;
|
||||
foreach my $p (@ports, '') {
|
||||
$opts[$i] ||= [];
|
||||
$rv .= &ui_columns_row([
|
||||
&ui_textbox($name."_port_".$i, $p =~ /(\d+)$/ ? $1 : '', 6),
|
||||
&ui_radio($name."_addr_def_".$i,
|
||||
|
||||
@@ -332,7 +332,7 @@ ech_ssl=Connect using SSL?
|
||||
eicp_ecannot=You are not allowed to edit other caches
|
||||
eicp_header=Other Caches
|
||||
eicp_opcs=Other proxy cache servers
|
||||
eicp_nocd=No other caches defined
|
||||
eicp_nocd=No other caches defined.
|
||||
eicp_aac=Add another cache.
|
||||
eicp_cso=Cache Selection Options
|
||||
eicp_fdfd=Fetch directly from domains
|
||||
@@ -356,10 +356,10 @@ eicp_pp=Proxy port
|
||||
eicp_ip=ICP port
|
||||
eicp_return=squid index
|
||||
eicp_always=ACLs to fetch directly
|
||||
eicp_noalways=No direct fetch ACLs defined
|
||||
eicp_noalways=No direct fetch ACLs defined.
|
||||
eicp_addalways=Add ACLs to fetch directly.
|
||||
eicp_never=ACLs never to fetch directly
|
||||
eicp_nonever=No never direct fetch ACLs defined
|
||||
eicp_nonever=No never direct fetch ACLs defined.
|
||||
eicp_addnever=Add ACLs never to fetch directly.
|
||||
eicp_thost=Hostname
|
||||
eicp_ttype=Type
|
||||
|
||||
@@ -2,12 +2,15 @@
|
||||
# save_icp.cgi
|
||||
# Save cache options
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
our (%text, %in, %access, $squid_version, %config);
|
||||
require './squid-lib.pl';
|
||||
$access{'othercaches'} || &error($text{'eicp_ecannot'});
|
||||
&ReadParse();
|
||||
&lock_file($config{'squid_conf'});
|
||||
$conf = &get_config();
|
||||
$whatfailed = $text{'sicp_ftsco'};
|
||||
my $conf = &get_config();
|
||||
&error_setup($text{'sicp_ftsco'});
|
||||
|
||||
if ($squid_version < 2) {
|
||||
&save_list("local_domain", undef, $conf);
|
||||
@@ -33,6 +36,7 @@ else {
|
||||
|
||||
sub check_timeout
|
||||
{
|
||||
return $_[0] =~ /^\d+$/ ? undef : &text('sicp_emsg1',$_[0]);
|
||||
my ($value) = @_;
|
||||
return $value =~ /^\d+$/ ? undef : &text('sicp_emsg1', $value);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user