diff --git a/squid/edit_icp.cgi b/squid/edit_icp.cgi index 460466057..264e34ca2 100755 --- a/squid/edit_icp.cgi +++ b/squid/edit_icp.cgi @@ -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"), - "$text{'eicp_aac'}" ); +my @ch = &find_config($cache_host, $conf); +my @links = ( &select_all_link("d"), + &select_invert_link("d"), + "$text{'eicp_aac'}" ); 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 "
\n"; - &cache_table(0, $mid-1); + print &cache_table(0, $mid-1, \@ch); print "\n"; - if ($mid < @ch) { &cache_table($mid, $#ch); } + if ($mid < @ch) { + print &cache_table($mid, $#ch, \@ch); + } print "
\n"; print &ui_links_row(\@links); print &ui_form_end([ [ "delete", $text{'eicp_delete'} ] ]); } else { - print "$text{'eicp_nocd'}.

\n"; + print "$text{'eicp_nocd'}

\n"; print &ui_links_row([ $links[2] ]); } print &ui_hr(); -print "

\n"; -print "\n"; -print "\n"; -print "
$text{'eicp_cso'}
\n"; + +print &ui_form_start("save_icp.cgi", "post"); +print &ui_table_start($text{'eicp_cso'}, "width=100%", 4); if ($squid_version < 2) { - print "\n"; print &list_input($text{'eicp_fdfd'}, "local_domain", $conf); print &address_input($text{'eicp_fdfi'}, "local_ip", $conf); - print "\n"; - print "\n"; print &list_input($text{'eicp_dif'}, "inside_firewall", $conf); print &address_input($text{'eicp_iif'}, "firewall_ip", $conf); - print "\n"; } -print "\n"; print &list_input($text{'eicp_dfuc'}, "hierarchy_stoplist", $conf, 1, $text{'default'}); -print "\n"; if ($squid_version < 2) { - print "\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 "\n"; - print "\n"; print &opt_input($text{'eicp_crt'}, "neighbor_timeout", $conf, $text{'default'}, 4, $text{'eicp_secs'}); - print "\n"; } else { - print "\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 "\n"; - print "\n"; print &opt_input($text{'eicp_dpt'}, "dead_peer_timeout", $conf, $text{'default'}, 8, $text{'eicp_secs'}); - print "\n"; } if ($squid_version >= 2.3) { # Display always/never_direct options - print "\n"; + print &ui_hr(); - print "\n"; + $table .= &ui_links_row([ &ui_link("never.cgi?new=1", + $text{'eicp_addnever'}) ]); + print &ui_table_row($text{'eicp_never'}, $table, 3); } -print "

\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 "$text{'eicp_always'}

\n"; - print "\n"; - print "\n"; - print "\n"; - print "\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 "\n"; - print "\n"; - print "\n"; - print "\n"; + $table .= &ui_columns_row([ + &ui_link("always.cgi?index=$h->{'index'}", $v[0]), + &html_escape(join(' ', @v[1..$#v])), + join("", @moves), + ]); $hc++; } - print "
$text{'eacl_act'}$text{'eacl_acls1'}$text{'eacl_move'}
{'index'}\">", - "$v[0]",&html_escape(join(' ', @v[1..$#v])), - "\n"; + } + my @moves; if ($hc != @always-1) { - print "", - ""; + push(@moves, &ui_link( + "move_always.cgi?$hc+1", + "")); + } + else { + push(@moves, ""); } - else { print ""; } if ($hc != 0) { - print "", - ""; + push(@moves, &ui_link( + "move_always.cgi?$hc+-1", + "")); } - print "
\n"; + $table .= &ui_columns_end(); } else { - print "$text{'eicp_noalways'}

\n"; + $table = "$text{'eicp_noalways'}

\n"; } - print "$text{'eicp_addalways'}\n"; + $table .= &ui_links_row([ &ui_link("always.cgi?new=1", + $text{'eicp_addalways'}) ]); + print &ui_table_row($text{'eicp_always'}, $table, 3); - print "

\n"; - @never = &find_config("never_direct", $conf); + my @never = &find_config("never_direct", $conf); if (@never) { - print "$text{'eicp_never'}

\n"; - print "\n"; - print "\n"; - print "\n"; - print "\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 "\n"; - print "\n"; - print "\n"; - print "\n"; + $table .= &ui_columns_row([ + &ui_link("never.cgi?index=$h->{'index'}", $v[0]), + &html_escape(join(' ', @v[1..$#v])), + join("", @moves), + ]); $hc++; } - print "
$text{'eacl_act'}$text{'eacl_acls1'}$text{'eacl_move'}
{'index'}\">", - "$v[0]",&html_escape(join(' ', @v[1..$#v])), - "\n"; + } + my @moves; if ($hc != @never-1) { - print "", - ""; + push(@moves, &ui_link( + "move_never.cgi?$hc+1", + "")); + } + else { + push(@moves, ""); } - else { print ""; } if ($hc != 0) { - print "", - ""; + push(@moves, &ui_link( + "move_never.cgi?$hc+-1", + "")); } - print "
\n"; + $table .= &ui_columns_end(); } else { - print "$text{'eicp_nonever'}

\n"; + $table = "$text{'eicp_nonever'}

\n"; } - print "$text{'eicp_addnever'}\n"; - print "

\n"; -print "
\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([ - "". - &html_escape($chv[0])."", + &ui_link("edit_cache_host.cgi?num=$i", + &html_escape($chv[0])), &html_escape($chv[1]), &html_escape($chv[2]), &html_escape($chv[3]) diff --git a/squid/edit_ports.cgi b/squid/edit_ports.cgi index 53a6cffd4..58e1c3ca6 100755 --- a/squid/edit_ports.cgi +++ b/squid/edit_ports.cgi @@ -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 "$text{'eports_paap'}\n"; - &ports_table("http_port"); - print "\n"; + print &ui_table_row($text{'eports_paap'}, + &ports_table("http_port"), 3); if ($squid_version >= 2.5) { # Display table of SSL ports - print " $text{'eports_ssl'}\n"; - &ports_table("https_port"); - print "\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, diff --git a/squid/lang/en b/squid/lang/en index 0838a0220..ea3be2e78 100644 --- a/squid/lang/en +++ b/squid/lang/en @@ -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 diff --git a/squid/save_icp.cgi b/squid/save_icp.cgi index c50c79c86..5f0f8a39b 100755 --- a/squid/save_icp.cgi +++ b/squid/save_icp.cgi @@ -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); }