X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=html%2Fcgi-bin%2Furlfilter.cgi;h=1e54372f18fc173350ff8ba83376d0da978d103d;hb=66c3619872bcf723d7bac550165ad5658de95644;hp=23410835dc7c5e3aa391604136d56236200fa23a;hpb=62459123fa8adc36984552956648daeec462bf41;p=people%2Fpmueller%2Fipfire-2.x.git diff --git a/html/cgi-bin/urlfilter.cgi b/html/cgi-bin/urlfilter.cgi index 23410835dc..1e54372f18 100644 --- a/html/cgi-bin/urlfilter.cgi +++ b/html/cgi-bin/urlfilter.cgi @@ -2,7 +2,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007 Michael Tremer & Christian Schmidt # +# Copyright (C) 2005-2010 IPFire Team # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -59,15 +59,13 @@ my $tcfile = "${General::swroot}/urlfilter/timeconst"; my $uqfile = "${General::swroot}/urlfilter/userquota"; my $dbdir = "${General::swroot}/urlfilter/blacklists"; my $editdir = "${General::swroot}/urlfilter/editor"; -my $repository = "/home/httpd/html/repository"; +my $templatedir = "/srv/web/ipfire/html/redirect-templates"; +my $repository = "/var/urlrepo"; my $hintcolour = '#FFFFCC'; my $sourceurlfile = "${General::swroot}/urlfilter/autoupdate/autoupdate.urls"; my $updconffile = "${General::swroot}/urlfilter/autoupdate/autoupdate.conf"; my $updflagfile = "${General::swroot}/urlfilter/blacklists/.autoupdate.last"; -my $upd_cron_dly = "${General::swroot}/urlfilter/autoupdate/cron.daily"; -my $upd_cron_wly = "${General::swroot}/urlfilter/autoupdate/cron.weekly"; -my $upd_cron_mly = "${General::swroot}/urlfilter/autoupdate/cron.monthly"; my $errormessage=''; my $updatemessage=''; @@ -97,9 +95,9 @@ my $ldesc=''; my $gdesc=''; if (! -d $dbdir) { mkdir("$dbdir"); } -if (! -e $tcfile) { system("touch $tcfile"); } -if (! -e $uqfile) { system("touch $uqfile"); } -if (! -e $sourceurlfile) { system("touch $sourceurlfile"); } +if (! -e $tcfile) { &General::system("touch", "$tcfile"); } +if (! -e $uqfile) { &General::system("touch", "$uqfile"); } +if (! -e $sourceurlfile) { &General::system("touch", "$sourceurlfile"); } &General::readhash("${General::swroot}/ethernet/settings", \%netsettings); &General::readhash("${General::swroot}/main/settings", \%mainsettings); @@ -140,11 +138,11 @@ $filtersettings{'BLOCK_IP_ADDR'} = 'off'; $filtersettings{'BLOCK_ALL'} = 'off'; $filtersettings{'ENABLE_EMPTY_ADS'} = 'off'; $filtersettings{'ENABLE_GLOBAL_WHITELIST'} = 'off'; -$filtersettings{'ENABLE_SAFESEARCH'} = 'off'; $filtersettings{'ENABLE_LOG'} = 'off'; $filtersettings{'ENABLE_USERNAME_LOG'} = 'off'; $filtersettings{'ENABLE_CATEGORY_LOG'} = 'off'; $filtersettings{'ENABLE_AUTOUPDATE'} = 'off'; +$filtersettings{'REDIRECT_TEMPLATE'} = 'legacy'; $filtersettings{'ACTION'} = ''; $filtersettings{'VALID'} = ''; @@ -228,7 +226,7 @@ if (($filtersettings{'ACTION'} eq $Lang::tr{'save'}) || if (!(-d "${General::swroot}/urlfilter/update")) { mkdir("${General::swroot}/urlfilter/update"); } - my $exitcode = system("/bin/tar --no-same-owner -xzf ${General::swroot}/urlfilter/blacklists.tar.gz -C ${General::swroot}/urlfilter/update"); + my $exitcode = &General::system("/bin/tar", "--no-same-owner", "-xzf", "${General::swroot}/urlfilter/blacklists.tar.gz", "-C", "${General::swroot}/urlfilter/update"); if ($exitcode > 0) { @@ -237,18 +235,19 @@ if (($filtersettings{'ACTION'} eq $Lang::tr{'save'}) || if (-d "${General::swroot}/urlfilter/update/BL") { - system("mv ${General::swroot}/urlfilter/update/BL ${General::swroot}/urlfilter/update/blacklists"); + &General::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"); + &General::system("mv", "${General::swroot}/urlfilter/update/category", "${General::swroot}/urlfilter/update/blacklists"); } if (!(-d "${General::swroot}/urlfilter/update/blacklists")) { $errormessage = $Lang::tr{'urlfilter invalid content'}; } else { + # XXX Uses globbing system("cp -r ${General::swroot}/urlfilter/update/blacklists/* $dbdir"); &readblockcategories; @@ -257,11 +256,11 @@ if (($filtersettings{'ACTION'} eq $Lang::tr{'save'}) || &writeconfigfile; $updatemessage = $Lang::tr{'urlfilter upload success'}; - system("${General::swroot}/urlfilter/bin/prebuild.pl &"); - system("logger -t installpackage[urlfilter] \"URL filter blacklist - Blacklist update from local source completed\""); + &General::system_background("${General::swroot}/urlfilter/bin/prebuild.pl"); + &General::system("logger", "-t", "installpackage[urlfilter]", "URL filter blacklist - Blacklist update from local source completed"); } } - if (-d "${General::swroot}/urlfilter/update") { system("rm -rf ${General::swroot}/urlfilter/update"); } + if (-d "${General::swroot}/urlfilter/update") { &General::system("rm", "-rf", "${General::swroot}/urlfilter/update"); } if (-e "${General::swroot}/urlfilter/blacklists.tar.gz") { unlink("${General::swroot}/urlfilter/blacklists.tar.gz"); } if ($errormessage) { goto ERROR; } } @@ -269,7 +268,7 @@ if (($filtersettings{'ACTION'} eq $Lang::tr{'save'}) || if ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter backup'}) { $blistbackup = ($filtersettings{'ENABLE_FULLBACKUP'} eq 'on') ? "blacklists" : "blacklists/custom"; - if (system("/bin/tar -C ${General::swroot}/urlfilter -czf ${General::swroot}/urlfilter/backup.tar.gz settings timeconst userquota autoupdate $blistbackup")) + if (&General::system("/bin/tar", "-C", "${General::swroot}/urlfilter", "-czf", "${General::swroot}/urlfilter/backup.tar.gz", "settings", "timeconst", "userquota", "autoupdate", "$blistbackup")) { $errormessage = $Lang::tr{'urlfilter backup error'}; goto ERROR; @@ -308,7 +307,7 @@ if (($filtersettings{'ACTION'} eq $Lang::tr{'save'}) || $errormessage = $!; } - my $exitcode = system("/bin/tar --no-same-owner --preserve-permissions -xzf ${General::swroot}/urlfilter/backup.tar.gz -C ${General::swroot}/urlfilter/restore"); + my $exitcode = &General::system("/bin/tar", "--no-same-owner", "--preserve-permissions", "-xzf", "${General::swroot}/urlfilter/backup.tar.gz", "-C", "${General::swroot}/urlfilter/restore"); if ($exitcode > 0) { $errormessage = $Lang::tr{'urlfilter tar error'}; @@ -317,6 +316,7 @@ if (($filtersettings{'ACTION'} eq $Lang::tr{'save'}) || { $errormessage = $Lang::tr{'urlfilter invalid restore file'}; } else { + # XXX uses globbing system("cp -rp ${General::swroot}/urlfilter/restore/* ${General::swroot}/urlfilter/"); &readblockcategories; &readcustomlists; @@ -327,7 +327,7 @@ if (($filtersettings{'ACTION'} eq $Lang::tr{'save'}) || } if (-e "${General::swroot}/urlfilter/backup.tar.gz") { unlink("${General::swroot}/urlfilter/backup.tar.gz"); } - if (-d "${General::swroot}/urlfilter/restore") { system("rm -rf ${General::swroot}/urlfilter/restore"); } + if (-d "${General::swroot}/urlfilter/restore") { &General::system("rm", "-rf", "${General::swroot}/urlfilter/restore"); } if ($errormessage) { goto ERROR; } } @@ -353,16 +353,7 @@ if (($filtersettings{'ACTION'} eq $Lang::tr{'save'}) || $filtersettings{'VALID'} = 'yes'; &savesettings; - system("chown -R nobody.nobody $dbdir"); - - if (-e "$dbdir/custom/allowed/domains.db") { unlink("$dbdir/custom/allowed/domains.db"); } - if (-e "$dbdir/custom/allowed/urls.db") { unlink("$dbdir/custom/allowed/urls.db"); } - 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"); } - - &setpermissions ($dbdir); - - system('/usr/local/bin/squidctrl restart >/dev/null 2>&1'); + &General::system('/usr/local/bin/squidctrl', 'restart'); } } @@ -496,7 +487,7 @@ if (($tcsettings{'MODE'} eq 'TIMECONSTRAINT') && ($tcsettings{'ACTION'} eq $Lang $errormessage = $Lang::tr{'urlfilter web proxy service required'}; } - if (!$errormessage) { system('/usr/local/bin/squidctrl restart >/dev/null 2>&1'); } + if (!$errormessage) { &General::system('/usr/local/bin/squidctrl', 'restart'); } $tcsettings{'TCMODE'}='on'; } @@ -699,7 +690,7 @@ if (($uqsettings{'MODE'} eq 'USERQUOTA') && ($uqsettings{'ACTION'} eq $Lang::tr{ $errormessage = $Lang::tr{'urlfilter web proxy service required'}; } - if (!$errormessage) { system('/usr/local/bin/squidctrl restart >/dev/null 2>&1'); } + if (!$errormessage) { &General::system('/usr/local/bin/squidctrl', 'restart'); } $uqsettings{'UQMODE'}='on'; } @@ -783,7 +774,7 @@ if (($besettings{'ACTION'} eq $Lang::tr{'urlfilter import blacklist'}) && ($bese $errormessage = $!; } else { - my $exitcode = system("/bin/tar --no-same-owner --preserve-permissions -xzf $editdir/blacklist.tar.gz -C $editdir"); + my $exitcode = &General::system("/bin/tar", "--no-same-owner", "--preserve-permissions", "-xzf", "$editdir/blacklist.tar.gz", "-C", "$editdir"); if ($exitcode > 0) { $errormessage = $Lang::tr{'urlfilter tar error'}; @@ -830,7 +821,7 @@ if (($besettings{'ACTION'} eq $Lang::tr{'urlfilter import blacklist'}) && ($bese } } - if (-d $editdir) { system("rm -rf $editdir"); } + if (-d $editdir) { &General::system("rm", "-rf", "$editdir"); } } } @@ -864,7 +855,7 @@ if (($besettings{'ACTION'} eq $Lang::tr{'urlfilter export blacklist'}) && ($bese print FILE "$besettings{'BE_EXPRESSIONS'}\n"; close FILE; - if (system("/bin/tar -C $editdir -czf $editdir/$besettings{'BE_NAME'}.tar.gz blacklists")) + if (&General::system("/bin/tar", "-C", "$editdir", "-czf", "$editdir/$besettings{'BE_NAME'}.tar.gz", "blacklists")) { $errormessage = $Lang::tr{'urlfilter export error'}; } @@ -880,7 +871,7 @@ if (($besettings{'ACTION'} eq $Lang::tr{'urlfilter export blacklist'}) && ($bese while () { print; } close (FILE); - if (-d $editdir) { system("rm -rf $editdir"); } + if (-d $editdir) { &General::system("rm", "-rf", "$editdir"); } exit; } } else { @@ -944,8 +935,10 @@ if (($besettings{'ACTION'} eq $Lang::tr{'urlfilter install blacklist'}) && ($bes print FILE "}\n"; close FILE; + # XXX uses globbing system("rm -f $dbdir/$besettings{'BE_NAME'}/*.db"); - system("/usr/sbin/squidGuard -c $editdir/install.conf -C all"); + &General::system("/usr/bin/squidGuard", "-c", "$editdir/install.conf", "-C", "all"); + # XXX uses globbing system("chmod a+w $dbdir/$besettings{'BE_NAME'}/*.db"); &readblockcategories; @@ -953,9 +946,9 @@ if (($besettings{'ACTION'} eq $Lang::tr{'urlfilter install blacklist'}) && ($bes &writeconfigfile; - system('/usr/local/bin/squidctrl restart >/dev/null 2>&1') unless ($besettings{'NORESTART'} eq 'on'); + &General::system('/usr/local/bin/squidctrl', 'restart') unless ($besettings{'NORESTART'} eq 'on'); - if (-d $editdir) { system("rm -rf $editdir"); } + if (-d $editdir) { &General::system("rm", "-rf", "$editdir"); } } else { $errormessage = $Lang::tr{'urlfilter category data error'}; } @@ -974,29 +967,20 @@ if ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter save schedule'}) print FILE "CUSTOM_UPDATE_URL=$filtersettings{'CUSTOM_UPDATE_URL'}\n"; close FILE; - if (-e $upd_cron_dly) { unlink($upd_cron_dly); } - if (-e $upd_cron_wly) { unlink($upd_cron_wly); } - if (-e $upd_cron_mly) { unlink($upd_cron_mly); } if (($filtersettings{'ENABLE_AUTOUPDATE'} eq 'on') && ($filtersettings{'UPDATE_SCHEDULE'} eq 'daily')) { - symlink("../bin/autoupdate.pl",$upd_cron_dly) - } else { - symlink("/bin/false",$upd_cron_dly) + &General::system('/usr/local/bin/urlfilterctrl', 'cron', 'daily'); } if (($filtersettings{'ENABLE_AUTOUPDATE'} eq 'on') && ($filtersettings{'UPDATE_SCHEDULE'} eq 'weekly')) { - symlink("../bin/autoupdate.pl",$upd_cron_wly) - } else { - symlink("/bin/false",$upd_cron_wly) + &General::system('/usr/local/bin/urlfilterctrl', 'cron', 'weekly'); } if (($filtersettings{'ENABLE_AUTOUPDATE'} eq 'on') && ($filtersettings{'UPDATE_SCHEDULE'} eq 'monthly')) { - symlink("../bin/autoupdate.pl",$upd_cron_mly) - } else { - symlink("/bin/false",$upd_cron_mly) + &General::system('/usr/local/bin/urlfilterctrl', 'cron', 'monthly'); } } } @@ -1009,10 +993,10 @@ if ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter update now'}) { $errormessage = $Lang::tr{'urlfilter custom url required'}; } else { - system("${General::swroot}/urlfilter/bin/autoupdate.pl $filtersettings{'CUSTOM_UPDATE_URL'} &"); + &General::system_background("${General::swroot}/urlfilter/bin/autoupdate.pl", "$filtersettings{'CUSTOM_UPDATE_URL'}"); } } else { - system("${General::swroot}/urlfilter/bin/autoupdate.pl $filtersettings{'UPDATE_SOURCE'} &"); + &General::system_background("${General::swroot}/urlfilter/bin/autoupdate.pl", "$filtersettings{'UPDATE_SOURCE'}"); } } @@ -1076,9 +1060,6 @@ $checked{'ENABLE_EMPTY_ADS'}{$filtersettings{'ENABLE_EMPTY_ADS'}} = "checked='ch $checked{'ENABLE_GLOBAL_WHITELIST'}{'off'} = ''; $checked{'ENABLE_GLOBAL_WHITELIST'}{'on'} = ''; $checked{'ENABLE_GLOBAL_WHITELIST'}{$filtersettings{'ENABLE_GLOBAL_WHITELIST'}} = "checked='checked'"; -$checked{'ENABLE_SAFESEARCH'}{'off'} = ''; -$checked{'ENABLE_SAFESEARCH'}{'on'} = ''; -$checked{'ENABLE_SAFESEARCH'}{$filtersettings{'ENABLE_SAFESEARCH'}} = "checked='checked'"; $checked{'ENABLE_LOG'}{'off'} = ''; $checked{'ENABLE_LOG'}{'on'} = ''; $checked{'ENABLE_LOG'}{$filtersettings{'ENABLE_LOG'}} = "checked='checked'"; @@ -1095,6 +1076,8 @@ foreach $category (@filtergroups) { $checked{$category}{$filtersettings{$category}} = "checked='checked'"; } +$selected{'REDIRECT_TEMPLATE'}{$filtersettings{'REDIRECT_TEMPLATE'}} = "selected='selected'"; + $selected{'DEFINITION'}{$tcsettings{'DEFINITION'}} = "selected='selected'"; $selected{'FROM_HOUR'}{$tcsettings{'FROM_HOUR'}} = "selected='selected'"; $selected{'FROM_MINUTE'}{$tcsettings{'FROM_MINUTE'}} = "selected='selected'"; @@ -1187,7 +1170,7 @@ if (!($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter manage repository'})) { print "
\n"; -&Header::openbox('100%', 'left', "$Lang::tr{'urlfilter filter settings'}:"); +&Header::openbox('100%', 'left', "$Lang::tr{'urlfilter filter settings'}"); print < @@ -1231,8 +1214,12 @@ print <  - $Lang::tr{'urlfilter blocked domains'} * - $Lang::tr{'urlfilter blocked urls'} * + $Lang::tr{'urlfilter blocked domains'} + $Lang::tr{'urlfilter blocked urls'} + + + $Lang::tr{'urlfilter example'} + $Lang::tr{'urlfilter example ads'}