Revision: 6062 http://ipcop.svn.sourceforge.net/ipcop/?rev=6062&view=rev Author: dotzball Date: 2011-11-12 21:12:01 +0000 (Sat, 12 Nov 2011) Log Message: ----------- More modifications on urlfilter/proxy.
The urlfilter ui has a new option 'ENABLED' and option CHILDREN is moved from urlfilter to proxy page. Urlfilter now writes a redirector config to proxy/redirector/ directory. The proxy ui has new option 'ENABLE_REDIRECTOR' to enable/disable all redirectors and it displays all available redirectors sorted by rank order. The proxy ui is now clean of specific redirector code ("URLfilter addon", "Update Accelerator addon") it is open for multiple redirectors now. Some new texts (not applied to ipcop.po lang files yet). Modified Paths: -------------- ipcop/trunk/html/cgi-bin/proxy.cgi ipcop/trunk/html/cgi-bin/urlfilter.cgi ipcop/trunk/langs/ipcop.new.en.pl Modified: ipcop/trunk/html/cgi-bin/proxy.cgi =================================================================== --- ipcop/trunk/html/cgi-bin/proxy.cgi 2011-11-12 20:56:17 UTC (rev 6061) +++ ipcop/trunk/html/cgi-bin/proxy.cgi 2011-11-12 21:12:01 UTC (rev 6062) @@ -37,6 +37,9 @@ require '/usr/lib/ipcop/lang.pl'; require '/usr/lib/ipcop/header.pl'; +# enable(==1)/disable(==0) HTML Form debugging +my $debugFormparams = 0; + my @squidversion = `/usr/sbin/squid -v`; my $http_port='81'; my $https_port='8443'; # default value, pull actual value from main/settings later @@ -48,9 +51,7 @@ my %filtersettings=(); my %updaccelsettings=(); my %stdproxysettings=(); -my %redirectorsettings=(); my %mainsettings=(); -my $updaccel_addon=0; my %checked=(); my %selected=(); @@ -186,9 +187,6 @@ my $acl_ports_ssl = "$acldir/ports_ssl.acl"; my $acl_include = "$acldir/include.acl"; -my $updaccelversion = 'n/a'; -my $urlfilterversion = 'n/a'; - unless (-d "$acldir") { mkdir("$acldir"); } unless (-d "$ncsadir") { mkdir("$ncsadir"); } unless (-d "$ntlmdir") { mkdir("$ntlmdir"); } @@ -249,17 +247,6 @@ $https_port = $mainsettings{'GUIPORT'} if (defined($mainsettings{'GUIPORT'})); -if (-e "/var/ipcop/addons/updatexlrator/version") { $updaccel_addon = 1; } - -if ($updaccel_addon) { - $updaccelsettings{'CHILDREN'} = '10'; - if (-e "/var/ipcop/addons/updatexlrator/settings") { - &General::readhash("/var/ipcop/addons/updatexlrator/settings", \%updaccelsettings); - } - $updaccelversion = `cat /var/ipcop/addons/updatexlrator/version`; - $updaccelversion =~ s/([^\s]+).*/$1/; -} - &Header::showhttpheaders(); $proxysettings{'ACTION'} = ''; @@ -352,11 +339,9 @@ $proxysettings{'IDENT_TIMEOUT'} = '10'; $proxysettings{'IDENT_ENABLE_ACL'} = 'off'; $proxysettings{'IDENT_USER_ACL'} = 'positive'; +$proxysettings{'CHILDREN'} = '5'; +$proxysettings{'ENABLE_REDIRECTOR'} = 'off'; -if ($updaccel_addon) { - $proxysettings{'ENABLE_UPDXLRATOR'} = 'off'; -} - $ncsa_buttontext = $Lang::tr{'NCSA create user'}; &General::getcgihash(\%proxysettings); @@ -652,9 +637,31 @@ goto ERROR; } + + if ((!($proxysettings{'CHILDREN'} =~ /^\d+$/)) || ($proxysettings{'CHILDREN'} < 1)) { + $errormessage = $Lang::tr{'errmsg filter children'}; + goto ERROR; + } + ERROR: &check_acls; + ############### + # DEBUG DEBUG + if ($debugFormparams == 1) { + &Header::openbox('100%', 'left', 'DEBUG'); + my $debugCount = 0; + foreach my $line (sort keys %proxysettings) { + print "$line = $proxysettings{$line}<br />\n"; + $debugCount++; + } + print " Count: $debugCount\n"; + &Header::closebox(); + } + + # DEBUG DEBUG + ############### + if ($errormessage) { $proxysettings{'VALID'} = 'no'; } else { @@ -927,11 +934,9 @@ $checked{'IDENT_USER_ACL'}{'negative'} = ''; $checked{'IDENT_USER_ACL'}{$proxysettings{'IDENT_USER_ACL'}} = "checked='checked'"; -if ($updaccel_addon) { - $checked{'ENABLE_UPDXLRATOR'}{'off'} = ''; - $checked{'ENABLE_UPDXLRATOR'}{'on'} = ''; - $checked{'ENABLE_UPDXLRATOR'}{$proxysettings{'ENABLE_UPDXLRATOR'}} = "checked='checked'"; -} +$checked{'ENABLE_REDIRECTOR'}{'off'} = ''; +$checked{'ENABLE_REDIRECTOR'}{'on'} = ''; +$checked{'ENABLE_REDIRECTOR'}{$proxysettings{'ENABLE_REDIRECTOR'}} = "checked='checked'"; &Header::openpage($Lang::tr{'web proxy configuration'}, 1, ''); @@ -1665,52 +1670,84 @@ END ; +my %redirectors = (); foreach $redirector (</var/ipcop/proxy/redirector/*>) { if (-e $redirector) { - %redirectorsettings=(); + my %redirectorsettings=(); &General::readhash($redirector, \%redirectorsettings); - if (!defined($redirectorsettings{'VERSION'})) { $redirectorsettings{'VERSION'} = "n/a"; } - if ($redirectorsettings{'ENABLED'} eq 'on') { $redirectorsettings{'ENABLED'} = 'checked'; } + if (defined($redirectorsettings{'NAME'})) { + $redirectors{$redirectorsettings{'NAME'}}{'ENABLED'} = $redirectorsettings{'ENABLED'}; + $redirectors{$redirectorsettings{'NAME'}}{'ORDER'} = $redirectorsettings{'ORDER'}; + } + } +} - if (defined($redirectorsettings{'NAME'})) { - print <<END +#sort redirectors +my @redirectornames = &General::sortHashArray('ORDER', 'n', 'asc', \%redirectors); + +if($#redirectornames >= 0) { + print <<END <table width='100%'> <tr> - <td class='base' colspan='4'><b>$redirectorsettings{'NAME'}</b> [ $redirectorsettings{'VERSION'} ]</td> + <td class='base' colspan='4'><b>$Lang::tr{'redirector'}</b></td> </tr> <tr> <td class='base' width='25%'>$Lang::tr{'enabled'}:</td> - <td class='base' width='20%'><input type='checkbox' $redirectorsettings{'ENABLED'} disabled/></td> - <td class='base'>Number of processes:</td> - <td class='base'><input type='text' value='$redirectorsettings{'CHILDREN'}' size='5' disabled/></td> + <td class='base' width='20%'><input type='checkbox' name='ENABLE_REDIRECTOR' $checked{'ENABLE_REDIRECTOR'}{'on'} /></td> + <td> </td> + <td> </td> </tr> +<tr> + <td class='base'>$Lang::tr{'redirector children'}:</td> + <td class='base'><input type='text' name='CHILDREN' value='$proxysettings{'CHILDREN'}' size='5' /></td> + <td> </td> + <td> </td> +</tr> +<tr> + <td class='base' colspan='4'><i>$Lang::tr{'available redirectors'}:</i></td> +</tr> +END +; -</table> -<hr size='1'/> + + foreach my $redirector (@redirectornames) { + + if ($redirectors{$redirector}{'ENABLED'} eq 'on') { + $redirectors{$redirector}{'ENABLED'} = 'checked'; + } + + print <<END + <tr> + <td class='base'> $redirector:</td> + <td class='base'><input type='checkbox' $redirectors{$redirector}{'ENABLED'} disabled/></td> + <td class='base' colspan='2'></td> + </tr> + END ; - } } -} -if ($updaccel_addon) { + print <<END +</table> +<hr size='1'/> +END +; +} +else { + print <<END <table width='100%'> <tr> - <td class='base' colspan='4'><b>$Lang::tr{'update accelerator'}</b> [ $updaccelversion ]</td> + <td> + <input type='hidden' name='ENABLE_REDIRECTOR' value='off'/> + <input type='hidden' name='CHILDREN' value='$proxysettings{'CHILDREN'}'/> + </td> </tr> -<tr> - <td class='base' width='25%'>$Lang::tr{'enabled'}:</td> - <td class='base' width='20%'><input type='checkbox' name='ENABLE_UPDXLRATOR' $checked{'ENABLE_UPDXLRATOR'}{'on'} /></td> - <td> </td> - <td> </td> -</tr> -</table> -<hr size='1'/> END -; } +; +} print <<END <table width='100%'> @@ -4052,8 +4089,8 @@ END ; - } - else { + } + else { print FILE "cache deny all\n\n"; } @@ -4103,9 +4140,12 @@ print FILE "never_direct allow all\n\n"; } - # TODO: other mechanism to add/remove redirector and to configure url_rewrite_children + if($proxysettings{'ENABLE_REDIRECTOR'} eq 'on') + { + print FILE "url_rewrite_program /usr/sbin/redirect_wrapper\n"; + print FILE "url_rewrite_children $proxysettings{'CHILDREN'}\n\n"; + } - close FILE; } Modified: ipcop/trunk/html/cgi-bin/urlfilter.cgi =================================================================== --- ipcop/trunk/html/cgi-bin/urlfilter.cgi 2011-11-12 20:56:17 UTC (rev 6061) +++ ipcop/trunk/html/cgi-bin/urlfilter.cgi 2011-11-12 21:12:01 UTC (rev 6062) @@ -125,6 +125,7 @@ @source_urllist = <FILE>; close(FILE); +$filtersettings{'ENABLED'} = 'off'; $filtersettings{'ENABLE_CUSTOM_BLACKLIST'} = 'off'; $filtersettings{'ENABLE_CUSTOM_WHITELIST'} = 'off'; $filtersettings{'ENABLE_CUSTOM_EXPRESSIONS'} = 'off'; @@ -152,7 +153,6 @@ $filtersettings{'ENABLE_LOG'} = 'off'; $filtersettings{'ENABLE_USERNAME_LOG'} = 'off'; $filtersettings{'ENABLE_CATEGORY_LOG'} = 'off'; -$filtersettings{'CHILDREN'} = '5'; $filtersettings{'ENABLE_AUTOUPDATE'} = 'off'; $filtersettings{'ACTION'} = ''; @@ -172,6 +172,9 @@ || ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter backup'}) || ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter restore'})) { + if($filtersettings{'ENABLED'} ne 'on') { + $filtersettings{'ENABLED'} = 'off'; + } @clients = split(/\n/, $filtersettings{'UNFILTERED_CLIENTS'}); foreach (@clients) { @@ -206,11 +209,6 @@ } if ($errormessage) { goto ERROR; } - if (!($filtersettings{'CHILDREN'} =~ /^\d+$/) || ($filtersettings{'CHILDREN'} < 1)) { - $errormessage = $Lang::tr{'errmsg filter children'}; - goto ERROR; - } - if ((!($filtersettings{'REDIRECT_PAGE'} eq '')) && (!($filtersettings{'REDIRECT_PAGE'} =~ /^https?:\/\//))) { $filtersettings{'REDIRECT_PAGE'} = "http://" . $filtersettings{'REDIRECT_PAGE'}; } @@ -375,8 +373,8 @@ $errormessage = $Lang::tr{'urlfilter web proxy service required'}; goto ERROR; } - if (!($proxysettings{'ENABLE_FILTER'} eq 'on')) { - $errormessage = $Lang::tr{'urlfilter not enabled'}; + if (!($proxysettings{'ENABLE_REDIRECTOR'} eq 'on')) { + $errormessage = $Lang::tr{'redirector not enabled'}; goto ERROR; } @@ -1054,6 +1052,9 @@ if ($errormessage) { $filtersettings{'VALID'} = 'no'; } +$checked{'ENABLED'}{'off'} = ''; +$checked{'ENABLED'}{'on'} = ''; +$checked{'ENABLED'}{$filtersettings{'ENABLED'}} = "checked='checked'"; $checked{'ENABLE_CUSTOM_BLACKLIST'}{'off'} = ''; $checked{'ENABLE_CUSTOM_BLACKLIST'}{'on'} = ''; $checked{'ENABLE_CUSTOM_BLACKLIST'}{$filtersettings{'ENABLE_CUSTOM_BLACKLIST'}} = "checked='checked'"; @@ -1228,6 +1229,18 @@ print <<END <table width='100%'> <tr> + <td colspan='4'><b>$Lang::tr{'url filter'}</b></td> +</tr> +<tr> + <td width='25%'>$Lang::tr{'enabled'}:</td> + <td width='25%'><input type='checkbox' name='ENABLED' $checked{'ENABLED'}{'on'} /></td> + <td width='25%'> </td> + <td width='25%'> </td> +</tr> +</table> +<hr size='1'> +<table width='100%'> +<tr> <td colspan='4'><b>$Lang::tr{'urlfilter block categories'}</b></td> </tr> END @@ -2719,6 +2732,16 @@ delete $filtersettings{'UPDATEFILE'}; &General::writehash("/var/ipcop/proxy/filtersettings", \%filtersettings); + + # write redirector config + my %redirectorconf=(); + $redirectorconf{'NAME'} = "$Lang::tr{'url filter'}"; + $redirectorconf{'ORDER'} = 10; + $redirectorconf{'CMD'} = '/usr/bin/squidGuard'; + $redirectorconf{'ENABLED'} = $filtersettings{'ENABLED'}; + + &General::writehash("/var/ipcop/proxy/redirector/urlfilter", \%redirectorconf); + } # ------------------------------------------------------------------- Modified: ipcop/trunk/langs/ipcop.new.en.pl =================================================================== --- ipcop/trunk/langs/ipcop.new.en.pl 2011-11-12 20:56:17 UTC (rev 6061) +++ ipcop/trunk/langs/ipcop.new.en.pl 2011-11-12 21:12:01 UTC (rev 6062) @@ -166,6 +166,11 @@ #'chgwebpwd SUCCESS' => 'S U C C E S S :', #'chgwebpwd ERROR' => 'E R R O R :', +'redirector' => 'Redirectors', +'redirector not enabled' => 'Redirectors are disabled on the Web proxy page', +'redirector children' => 'Number of redirector processes', +'available redirectors' => 'Available redirectors', + 'urlfilter activity detection' => 'Activity detection', 'urlfilter add new time constraint rule' => 'Add new time constraint rule', 'urlfilter add new user quota rule' => 'Add new user quota rule', @@ -204,7 +209,6 @@ 'urlfilter category log' => 'Split log by categories', 'urlfilter category name error' => 'Blacklist category name required', 'urlfilter category' => 'Category', -'urlfilter children' => 'Number of filter processes', 'urlfilter configuration' => 'URL filter configuration', 'urlfilter constraint definition' => 'Definition', 'urlfilter constraint outside' => 'outside', @@ -258,7 +262,6 @@ 'urlfilter msg text 3' => 'Message line 3', 'urlfilter network access control' => 'Network based access control', 'urlfilter no categories' => 'No categories available', -'urlfilter not enabled' => 'URL filter is not enabled on the Web proxy page', 'urlfilter quota restart message' => 'Note: The counters will be reset for all users when restarting the URL filter', 'urlfilter quota time error' => 'Invalid value for time quota', 'urlfilter quota user error' => 'At least one username is required', This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ RSA(R) Conference 2012 Save $700 by Nov 18 Register now http://p.sf.net/sfu/rsa-sfdev2dev1 _______________________________________________ Ipcop-svn mailing list Ipcop-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ipcop-svn