X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=html%2Fcgi-bin%2Furlfilter.cgi;h=3316ff27122e41f184dd0cc1a437b102239b5fbf;hb=cb5e9c6c64d5281eba5c790f14c2e5f3066becbf;hp=78fe9915a187fed191c4a82128bf64bdada05bc8;hpb=e24010a9a90b8a5a4fdb1cffcac94df5a07a17fc;p=ipfire-2.x.git diff --git a/html/cgi-bin/urlfilter.cgi b/html/cgi-bin/urlfilter.cgi index 78fe9915a1..3316ff2712 100644 --- a/html/cgi-bin/urlfilter.cgi +++ b/html/cgi-bin/urlfilter.cgi @@ -1,12 +1,10 @@ #!/usr/bin/perl # -# SmoothWall CGIs -# # This code is distributed under the terms of the GPL # -# (c) written from scratch +# (c) 2004-2007 marco.s - http://www.urlfilter.net # -# $Id: urlfilter.cgi,v 1.7 2006/05/08 00:00:00 marco Exp $ +# $Id: urlfilter.cgi,v 1.9.1 2007/03/22 00:00:00 marco.s Exp $ # use strict; @@ -22,6 +20,7 @@ require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; +my $http_port='81'; my %netsettings=(); my %mainsettings=(); my %proxysettings=(); @@ -74,6 +73,7 @@ my @filtergroups=(); my @tclist=(); my @uqlist=(); my @source_urllist=(); +my @clients=(); my @temp=(); my $lastslashpos=0; @@ -151,7 +151,26 @@ if (($filtersettings{'ACTION'} eq $Lang::tr{'save'}) || ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter upload blacklist'}) || ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter backup'}) || ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter restore'})) -{ +{ + + @clients = split(/\n/,$filtersettings{'UNFILTERED_CLIENTS'}); + foreach (@clients) + { + s/^\s+//g; s/\s+$//g; s/\s+-\s+/-/g; s/\s+/ /g; s/\n//g; + if (/.*-.*-.*/) { $errormessage = $Lang::tr{'urlfilter invalid ip or mask error'}; } + @temp = split(/-/); + foreach (@temp) { unless ((&General::validipormask($_)) || (&General::validipandmask($_))) { $errormessage = $Lang::tr{'urlfilter invalid ip or mask error'}; } } + } + @clients = split(/\n/,$filtersettings{'BANNED_CLIENTS'}); + foreach (@clients) + { + s/^\s+//g; s/\s+$//g; s/\s+-\s+/-/g; s/\s+/ /g; s/\n//g; + if (/.*-.*-.*/) { $errormessage = $Lang::tr{'urlfilter invalid ip or mask error'}; } + @temp = split(/-/); + foreach (@temp) { unless ((&General::validipormask($_)) || (&General::validipandmask($_))) { $errormessage = $Lang::tr{'urlfilter invalid ip or mask error'}; } } + } + if ($errormessage) { goto ERROR; } + if (!($filtersettings{'CHILDREN'} =~ /^\d+$/) || ($filtersettings{'CHILDREN'} < 1)) { $errormessage = $Lang::tr{'urlfilter invalid num of children'}; @@ -223,6 +242,11 @@ if (($filtersettings{'ACTION'} eq $Lang::tr{'save'}) || $errormessage = $Lang::tr{'urlfilter tar error'}; } else { + if (-d "${General::swroot}/urlfilter/update/BL") + { + system("mv ${General::swroot}/urlfilter/update/BL ${General::swroot}/urlfilter/update/blacklists"); + } + if (-d "${General::swroot}/urlfilter/update/category") { system("mv ${General::swroot}/urlfilter/update/category ${General::swroot}/urlfilter/update/blacklists"); @@ -322,7 +346,7 @@ if (($filtersettings{'ACTION'} eq $Lang::tr{'save'}) || if ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter save and restart'}) { - if (!(-e "${General::swroot}/proxy/enable")) + if ((!(-e "${General::swroot}/proxy/enable")) && (!(-e "${General::swroot}/proxy/enable_blue"))) { $errormessage = $Lang::tr{'urlfilter web proxy service required'}; goto ERROR; @@ -343,29 +367,10 @@ if (($filtersettings{'ACTION'} eq $Lang::tr{'save'}) || if (-e "$dbdir/custom/blocked/domains.db") { unlink("$dbdir/custom/blocked/domains.db"); } if (-e "$dbdir/custom/blocked/urls.db") { unlink("$dbdir/custom/blocked/urls.db"); } - foreach (<$dbdir/*>) - { - if (-d $_){ system("chmod 644 $_/*"); } - if (-d $_){ system("chmod 666 $_/*.db"); } - } - if (-d "$dbdir/custom/allowed") - { - system("chmod 755 $dbdir/custom/allowed"); - system("chmod 644 $dbdir/custom/allowed/*"); - } - if (-d "$dbdir/custom/blocked") - { - system("chmod 755 $dbdir/custom/blocked"); - system("chmod 644 $dbdir/custom/blocked/*"); - } + &setpermissions ($dbdir); - system('/usr/local/bin/restartsquid'); + system('/usr/local/bin/squidctrl restart >/dev/null 2>&1'); } - -ERROR: - - if ($errormessage) { $filtersettings{'VALID'} = 'no'; } - } if ($tcsettings{'ACTION'} eq $Lang::tr{'urlfilter set time constraints'}) { $tcsettings{'TCMODE'} = 'on'} @@ -396,6 +401,16 @@ if (($tcsettings{'MODE'} eq 'TIMECONSTRAINT') && ($tcsettings{'ACTION'} eq $Lang if (!$errormessage) { + # transform to pre1.8 client definitions + @clients = split(/\n/,$tcsettings{'SRC'}); + undef $tcsettings{'SRC'}; + foreach(@clients) + { + s/^\s+//g; s/\s+$//g; s/\s+-\s+/-/g; s/\s+/ /g; s/\n//g; + $tcsettings{'SRC'} .= "$_ "; + } + $tcsettings{'SRC'} =~ s/\s+$//; + if ($tcsettings{'DST'} =~ /^any/) { $tcsettings{'DST'} = 'any'; } if ($tcsettings{'ENABLERULE'} eq 'on') { $tcsettings{'ACTIVE'} = $tcsettings{'ENABLERULE'}; } else { $tcsettings{'ACTIVE'} = 'off'} @@ -430,6 +445,38 @@ if (($tcsettings{'MODE'} eq 'TIMECONSTRAINT') && ($tcsettings{'ACTION'} eq $Lang } } +if (($tcsettings{'MODE'} eq 'TIMECONSTRAINT') && ($tcsettings{'ACTION'} eq $Lang::tr{'urlfilter copy rule'}) && (!$errormessage)) +{ + $id = 0; + foreach $line (@tclist) + { + $id++; + if ($tcsettings{'ID'} eq $id) + { + chomp($line); + @temp = split(/\,/,$line); + $tcsettings{'DEFINITION'} = $temp[0]; + $tcsettings{'MON'} = $temp[1]; + $tcsettings{'TUE'} = $temp[2]; + $tcsettings{'WED'} = $temp[3]; + $tcsettings{'THU'} = $temp[4]; + $tcsettings{'FRI'} = $temp[5]; + $tcsettings{'SAT'} = $temp[6]; + $tcsettings{'SUN'} = $temp[7]; + $tcsettings{'FROM_HOUR'} = $temp[8]; + $tcsettings{'FROM_MINUTE'} = $temp[9]; + $tcsettings{'TO_HOUR'} = $temp[10]; + $tcsettings{'TO_MINUTE'} = $temp[11]; + $tcsettings{'SRC'} = $temp[12]; + $tcsettings{'DST'} = $temp[13]; + $tcsettings{'ACCESS'} = $temp[14]; + $tcsettings{'ENABLERULE'} = $temp[15]; + $tcsettings{'COMMENT'} = $temp[16]; + } + } + $tcsettings{'TCMODE'}='on'; +} + if (($tcsettings{'MODE'} eq 'TIMECONSTRAINT') && ($tcsettings{'ACTION'} eq $Lang::tr{'remove'})) { $id = 0; @@ -451,12 +498,12 @@ if (($tcsettings{'MODE'} eq 'TIMECONSTRAINT') && ($tcsettings{'ACTION'} eq $Lang { $errormessage = $Lang::tr{'urlfilter not enabled'}; } - if (!(-e "${General::swroot}/proxy/enable")) + if ((!(-e "${General::swroot}/proxy/enable")) && (!(-e "${General::swroot}/proxy/enable_blue"))) { $errormessage = $Lang::tr{'urlfilter web proxy service required'}; } - if (!$errormessage) { system('/usr/local/bin/restartsquid'); } + if (!$errormessage) { system('/usr/local/bin/squidctrl restart >/dev/null 2>&1'); } $tcsettings{'TCMODE'}='on'; } @@ -482,11 +529,6 @@ if (($tcsettings{'MODE'} eq 'TIMECONSTRAINT') && ($tcsettings{'ACTION'} eq $Lang $tcsettings{'TCMODE'}='on'; } -if (!$errormessage) { - $tcsettings{'ENABLERULE'}='on'; - $tcsettings{'TO_HOUR'}='24'; -} - if (($tcsettings{'MODE'} eq 'TIMECONSTRAINT') && ($tcsettings{'ACTION'} eq $Lang::tr{'edit'}) && (!$errormessage)) { $id = 0; @@ -519,6 +561,11 @@ if (($tcsettings{'MODE'} eq 'TIMECONSTRAINT') && ($tcsettings{'ACTION'} eq $Lang $tcsettings{'TCMODE'}='on'; } +if ((!$errormessage) && (!($tcsettings{'ACTION'} eq $Lang::tr{'urlfilter copy rule'})) && (!($tcsettings{'ACTION'} eq $Lang::tr{'edit'}))) { + $tcsettings{'ENABLERULE'}='on'; + $tcsettings{'TO_HOUR'}='24'; +} + if ($uqsettings{'ACTION'} eq $Lang::tr{'urlfilter set user quota'}) { $uqsettings{'UQMODE'} = 'on'} if (($uqsettings{'MODE'} eq 'USERQUOTA') && ($uqsettings{'ACTION'} eq $Lang::tr{'add'})) @@ -654,12 +701,12 @@ if (($uqsettings{'MODE'} eq 'USERQUOTA') && ($uqsettings{'ACTION'} eq $Lang::tr{ { $errormessage = $Lang::tr{'urlfilter not enabled'}; } - if (!(-e "${General::swroot}/proxy/enable")) + if ((!(-e "${General::swroot}/proxy/enable")) && (!(-e "${General::swroot}/proxy/enable_blue"))) { $errormessage = $Lang::tr{'urlfilter web proxy service required'}; } - if (!$errormessage) { system('/usr/local/bin/restartsquid'); } + if (!$errormessage) { system('/usr/local/bin/squidctrl restart >/dev/null 2>&1'); } $uqsettings{'UQMODE'}='on'; } @@ -913,7 +960,7 @@ if (($besettings{'ACTION'} eq $Lang::tr{'urlfilter install blacklist'}) && ($bes &writeconfigfile; - system('/usr/local/bin/restartsquid') unless ($besettings{'NORESTART'} eq 'on'); + system('/usr/local/bin/squidctrl restart >/dev/null 2>&1') unless ($besettings{'NORESTART'} eq 'on'); if (-d $editdir) { system("rm -rf $editdir"); } } else { @@ -981,6 +1028,10 @@ if (-e "${General::swroot}/urlfilter/settings") { &General::readhash("${General: &readcustomlists; +ERROR: + +if ($errormessage) { $filtersettings{'VALID'} = 'no'; } + $checked{'ENABLE_CUSTOM_BLACKLIST'}{'off'} = ''; $checked{'ENABLE_CUSTOM_BLACKLIST'}{'on'} = ''; $checked{'ENABLE_CUSTOM_BLACKLIST'}{$filtersettings{'ENABLE_CUSTOM_BLACKLIST'}} = "checked='checked'"; @@ -1325,10 +1376,46 @@ print <  - $Lang::tr{'urlfilter unfiltered clients'}: * - - $Lang::tr{'urlfilter banned clients'}: * - + $Lang::tr{'urlfilter unfiltered clients'} * + $Lang::tr{'urlfilter banned clients'} * + + + +
@@ -1433,9 +1520,8 @@ print <  $Lang::tr{'this field may be blank'} - -URL filter - +   + @@ -1819,10 +1905,28 @@ print <  - + + - + + + + + + + @@ -1862,6 +1973,7 @@ print <  +
  - +  
    
$Lang::tr{'remark'} *         
    
@@ -1914,7 +2026,7 @@ print <$Lang::tr{'urlfilter time space'} $Lang::tr{'urlfilter src'} $Lang::tr{'urlfilter dst'} -   +   END ; @@ -1983,6 +2095,15 @@ print <
+ + + + +
+ + + +
@@ -2002,7 +2123,7 @@ END print <$temp[16] - + END @@ -2028,6 +2149,8 @@ print <$Lang::tr{'click to enable'}     $Lang::tr{ $Lang::tr{'edit'} +     $Lang::tr{ + $Lang::tr{'urlfilter copy rule'}     $Lang::tr{ $Lang::tr{'remove'} @@ -2409,6 +2532,26 @@ print "\n"; sub savesettings { + # transform to pre1.8 client definitions + @clients = split(/\n/,$filtersettings{'UNFILTERED_CLIENTS'}); + undef $filtersettings{'UNFILTERED_CLIENTS'}; + foreach(@clients) + { + s/^\s+//g; s/\s+$//g; s/\s+-\s+/-/g; s/\s+/ /g; s/\n//g; + $filtersettings{'UNFILTERED_CLIENTS'} .= "$_ "; + } + $filtersettings{'UNFILTERED_CLIENTS'} =~ s/\s+$//; + + # transform to pre1.8 client definitions + @clients = split(/\n/,$filtersettings{'BANNED_CLIENTS'}); + undef $filtersettings{'BANNED_CLIENTS'}; + foreach(@clients) + { + s/^\s+//g; s/\s+$//g; s/\s+-\s+/-/g; s/\s+/ /g; s/\n//g; + $filtersettings{'BANNED_CLIENTS'} .= "$_ "; + } + $filtersettings{'BANNED_CLIENTS'} =~ s/\s+$//; + &writeconfigfile; delete $filtersettings{'CUSTOM_BLACK_DOMAINS'}; @@ -2427,20 +2570,15 @@ sub savesettings sub readblockcategories { undef(@categories); - foreach $blacklist (<$dbdir/*>) { - if (-d $blacklist) { - $lastslashpos = rindex($blacklist,"/"); - if ($lastslashpos > -1) { - $section = substr($blacklist,$lastslashpos+1); - } else { - $section = $blacklist; - } - if (!($section eq 'custom')) { push(@categories,$section) }; - } - } + + &getblockcategory ($dbdir); + + foreach (@categories) { $_ = substr($_,length($dbdir)+1); } @filtergroups = @categories; + foreach (@filtergroups) { + s/\//_SLASH_/g; tr/a-z/A-Z/; $_ = "FILTER_".$_; } @@ -2448,6 +2586,23 @@ sub readblockcategories # ------------------------------------------------------------------- +sub getblockcategory +{ + foreach $category (<$_[0]/*>) + { + if (-d $category) + { + if ((-e "$category/domains") || (-e "$category/urls")) + { + unless ($category =~ /\bcustom\b/) { push(@categories,$category); } + } + &getblockcategory ($category); + } + } +} + +# ------------------------------------------------------------------- + sub readcustomlists { if (-e "$dbdir/custom/blocked/domains") { @@ -2512,7 +2667,7 @@ sub aggregatedconstraints foreach (@new) { @tmp2 = split(/\,/); - if ($tmp2[15] eq 'on') + if (($tmp1[15] eq 'on') && ($tmp2[15] eq 'on')) { if (($tmp1[0] eq $tmp2[0]) && ($tmp1[12] eq $tmp2[12]) && ($tmp1[13] eq $tmp2[13]) && ($tmp1[14] eq $tmp2[14])) { @@ -2554,10 +2709,31 @@ sub aggregatedconstraints # ------------------------------------------------------------------- +sub setpermissions +{ + my $bldir = $_[0]; + + foreach $category (<$bldir/*>) + { + if (-d $category){ + system("chmod 755 $category &> /dev/null"); + foreach $blacklist (<$category/*>) + { + if (-f $blacklist) { system("chmod 644 $blacklist &> /dev/null"); } + if (-d $blacklist) { system("chmod 755 $blacklist &> /dev/null"); } + } + system("chmod 666 $category/*.db &> /dev/null"); + &setpermissions ($category); + } + } +} + +# ------------------------------------------------------------------- + sub writeconfigfile { my $executables = "\\.\(ade|adp|asx|bas|bat|chm|com|cmd|cpl|crt|dll|eml|exe|hiv|hlp|hta|inc|inf|ins|isp|jse|jtd|lnk|msc|msh|msi|msp|mst|nws|ocx|oft|ops|pcd|pif|plx|reg|scr|sct|sha|shb|shm|shs|sys|tlb|tsp|url|vbe|vbs|vxd|wsc|wsf|wsh\)\$"; - my $audiovideo = "\\.\(aiff|asf|avi|dif|divx|mov|movie|mp3|mpe?g?|mpv2|ogg|ra?m|snd|qt|wav|wmf|wmv\)\$"; + my $audiovideo = "\\.\(aiff|asf|avi|dif|divx|mov|movie|mp3|mpe?g?|mpv2|ogg|ra?m|snd|qt|wav|wma|wmf|wmv\)\$"; my $archives = "\\.\(bin|bz2|cab|cdr|dmg|gz|hqx|rar|smi|sit|sea|tar|tgz|zip\)\$"; my $ident = " anonymous"; @@ -2607,9 +2783,9 @@ sub writeconfigfile if ($filtersettings{'SHOW_URL'} eq 'on') { $redirect .= "&url=%u"; } if ($filtersettings{'SHOW_IP'} eq 'on') { $redirect .= "&ip=%a"; } $redirect =~ s/^&/?/; - $redirect = "http:\/\/$netsettings{'GREEN_ADDRESS'}:81\/redirect.cgi".$redirect; + $redirect = "http:\/\/$netsettings{'GREEN_ADDRESS'}:$http_port\/redirect.cgi".$redirect; } else { - $redirect="http:\/\/$netsettings{'GREEN_ADDRESS'}:81\/redirect.cgi"; + $redirect="http:\/\/$netsettings{'GREEN_ADDRESS'}:$http_port\/redirect.cgi"; } } else { $redirect=$filtersettings{'REDIRECT_PAGE'}; } @@ -2654,6 +2830,8 @@ sub writeconfigfile $defaultrule .= "any"; } + $defaultrule =~ s/\//_/g; + open(FILE, ">${General::swroot}/urlfilter/squidGuard.conf") or die "Unable to write squidGuard.conf file"; flock(FILE, 2); @@ -2672,14 +2850,14 @@ sub writeconfigfile if ((($filtersettings{'ENABLE_REWRITE'} eq 'on') && (@repositoryfiles)) || ($filtersettings{'ENABLE_SAFESEARCH'} eq 'on')) { - print FILE "rewrite rew-rule-0 {\n"; + print FILE "rewrite rew-rule-1 {\n"; if (($filtersettings{'ENABLE_REWRITE'} eq 'on') && (@repositoryfiles)) { print FILE " # rewrite localfiles\n"; foreach (@repositoryfiles) { - print FILE " s@.*/$_\$\@http://$netsettings{'GREEN_ADDRESS'}:81/repository/$_\@i\n"; + print FILE " s@.*/$_\$\@http://$netsettings{'GREEN_ADDRESS'}:$http_port/repository/$_\@i\n"; } } @@ -2696,13 +2874,13 @@ sub writeconfigfile print FILE "}\n\n"; if ((!($filtersettings{'UNFILTERED_CLIENTS'} eq '')) && ($filtersettings{'ENABLE_SAFESEARCH'} eq 'on')) { - print FILE "rewrite rew-rule-1 {\n"; + print FILE "rewrite rew-rule-2 {\n"; if (($filtersettings{'ENABLE_REWRITE'} eq 'on') && (@repositoryfiles)) { print FILE " # rewrite localfiles\n"; foreach (@repositoryfiles) { - print FILE " s@.*/$_\$\@http://$netsettings{'GREEN_ADDRESS'}:81/repository/$_\@i\n"; + print FILE " s@.*/$_\$\@http://$netsettings{'GREEN_ADDRESS'}:$http_port/repository/$_\@i\n"; } } else { print FILE " # rewrite nothing\n"; @@ -2711,6 +2889,26 @@ sub writeconfigfile } } + if (!($filtersettings{'UNFILTERED_CLIENTS'} eq '')) { + print FILE "src unfiltered {\n"; + print FILE " ip $filtersettings{'UNFILTERED_CLIENTS'}\n"; + print FILE "}\n\n"; + } + if (!($filtersettings{'BANNED_CLIENTS'} eq '')) { + print FILE "src banned {\n"; + print FILE " ip $filtersettings{'BANNED_CLIENTS'}\n"; + if ($filtersettings{'ENABLE_LOG'} eq 'on') + { + if ($filtersettings{'ENABLE_CATEGORY_LOG'} eq 'on') + { + print FILE " logfile ".$ident." banned.log\n"; + } else { + print FILE " logfile ".$ident." urlfilter.log\n"; + } + } + print FILE "}\n\n"; + } + if (-e $uqfile) { open(UQ, $uqfile); @@ -2757,7 +2955,30 @@ sub writeconfigfile { $idx++; print FILE "src network-$idx {\n"; - print FILE " ip $tc[12]\n"; + @clients = split(/ /,$tc[12]); + @temp = split(/-/,$clients[0]); + if ( (&General::validipormask($temp[0])) || (&General::validipandmask($temp[0]))) + { + print FILE " ip $tc[12]\n"; + } else { + print FILE " user"; + @clients = split(/ /,$tc[12]); + foreach $line (@clients) + { + $line =~ s/(^\w+)\\(\w+$)/$1%5c$2/; + print FILE " $line"; + } + print FILE "\n"; + } + if (($filtersettings{'ENABLE_LOG'} eq 'on') && ($tc[14] eq 'block') && ($tc[13] eq 'any')) + { + if ($filtersettings{'ENABLE_CATEGORY_LOG'} eq 'on') + { + print FILE " logfile ".$ident." timeconst.log\n"; + } else { + print FILE " logfile ".$ident." urlfilter.log\n"; + } + } print FILE "}\n\n"; } } @@ -2777,31 +2998,22 @@ sub writeconfigfile } } - if (!($filtersettings{'UNFILTERED_CLIENTS'} eq '')) { - print FILE "src unfiltered {\n"; - print FILE " ip $filtersettings{'UNFILTERED_CLIENTS'}\n"; - print FILE "}\n\n"; - } - if (!($filtersettings{'BANNED_CLIENTS'} eq '')) { - print FILE "src banned {\n"; - print FILE " ip $filtersettings{'BANNED_CLIENTS'}\n"; - print FILE "}\n\n"; - } - foreach $category (@categories) { + $blacklist = $category; + $category =~ s/\//_/g; print FILE "dest $category {\n"; - if (-e "$dbdir/$category/domains") { - print FILE " domainlist $category\/domains\n"; + if (-e "$dbdir/$blacklist/domains") { + print FILE " domainlist $blacklist\/domains\n"; } - if (-e "$dbdir/$category/urls") { - print FILE " urllist $category\/urls\n"; + if (-e "$dbdir/$blacklist/urls") { + print FILE " urllist $blacklist\/urls\n"; } - if ((-e "$dbdir/$category/expressions") && ($filtersettings{'ENABLE_EXPR_LISTS'} eq 'on')) { - print FILE " expressionlist $category\/expressions\n"; + if ((-e "$dbdir/$blacklist/expressions") && ($filtersettings{'ENABLE_EXPR_LISTS'} eq 'on')) { + print FILE " expressionlist $blacklist\/expressions\n"; } - if (($category eq 'ads') && ($filtersettings{'ENABLE_EMPTY_ADS'} eq 'on')) + if ((($category eq 'ads') || ($category eq 'adv')) && ($filtersettings{'ENABLE_EMPTY_ADS'} eq 'on')) { - print FILE " redirect http:\/\/$netsettings{'GREEN_ADDRESS'}:81\/images/urlfilter/1x1.gif\n"; + print FILE " redirect http:\/\/$netsettings{'GREEN_ADDRESS'}:$http_port\/images/urlfilter/1x1.gif\n"; } if ($filtersettings{'ENABLE_LOG'} eq 'on') { @@ -2813,6 +3025,7 @@ sub writeconfigfile } } print FILE "}\n\n"; + $category = $blacklist; } print FILE "dest files {\n"; @@ -2866,7 +3079,7 @@ sub writeconfigfile print FILE " pass all\n"; if ($filtersettings{'ENABLE_SAFESEARCH'} eq 'on') { - print FILE " rewrite rew-rule-1\n"; + print FILE " rewrite rew-rule-2\n"; } print FILE " }\n\n"; } @@ -2918,6 +3131,7 @@ sub writeconfigfile chomp; @tc = split(/\,/); @ec = split(/\|/,$tc[13]); + foreach (@ec) { s/\//_/g; } if ($tc[15] eq 'on') { $idx++; @@ -2963,12 +3177,17 @@ sub writeconfigfile print FILE $tcrule unless ((@ec == 1) && ($ec[0] eq 'any')); } else { $tcrule = $defaultrule; - foreach (@ec) + if ((@ec == 1) && ($ec[0] eq 'any')) { - $tcrule =~ s/!$_ //; - print FILE "$_ " if ($_ eq 'any'); + print FILE "any"; + } else { + foreach (@ec) + { + $tcrule = "$_ ".$tcrule unless (index($defaultrule,"!".$_." ") ge 0); + $tcrule =~ s/!$_ //; + } + print FILE $tcrule; } - print FILE $tcrule unless ((@ec == 1) && ($ec[0] eq 'any')); } } @@ -2992,7 +3211,7 @@ sub writeconfigfile } if ((($filtersettings{'ENABLE_REWRITE'} eq 'on') && (@repositoryfiles)) || ($filtersettings{'ENABLE_SAFESEARCH'} eq 'on')) { - print FILE " rewrite rew-rule-0\n"; + print FILE " rewrite rew-rule-1\n"; } print FILE " redirect $redirect\n"; print FILE " }\n";