]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - html/cgi-bin/urlfilter.cgi
Fixed build and core 11
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / urlfilter.cgi
index 697965546cbd6d60e8993cdc3a2cf66ca85662ff..20390372cb945e50aae18d5929af2012cdcd1567 100644 (file)
@@ -1,17 +1,29 @@
 #!/usr/bin/perl
-#
-# This code is distributed under the terms of the GPL
-#
-# (c) 2004-2007 marco.s - http://www.urlfilter.net
-#
-# $Id: urlfilter.cgi,v 1.9.1 2007/03/22 00:00:00 marco.s Exp $
-#
+###############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2007  Michael Tremer & Christian Schmidt                      #
+#                                                                             #
+# 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        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
 
 use strict;
 
 # enable only the following on debugging purpose
-use warnings;
-use CGI::Carp 'fatalsToBrowser';
+#use warnings;
+#use CGI::Carp 'fatalsToBrowser';
 
 use File::Copy;
 use IO::Socket;
@@ -147,7 +159,6 @@ if (($filtersettings{'ACTION'} eq $Lang::tr{'save'}) ||
     ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter save and restart'}) ||
     ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter upload file'}) ||
     ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter remove file'}) ||
-    ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter upload background'}) ||
     ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter upload blacklist'}) ||
     ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter backup'}) ||
     ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter restore'}))
@@ -205,18 +216,7 @@ if (($filtersettings{'ACTION'} eq $Lang::tr{'save'}) ||
                }
 
        }
-       
-       if ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter upload background'})
-       {
-               &Header::getcgihash(\%filtersettings, {'wantfile' => 1, 'filevar' => 'BACKGROUND'});
 
-               if (copy($filtersettings{'BACKGROUND'}, "/home/httpd/html/images/urlfilter/background.jpg") != 1)
-               {
-                       $errormessage = $!;
-                       goto ERROR;
-               }
-       }
-       
        if ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter upload blacklist'})
        {
                &Header::getcgihash(\%filtersettings, {'wantfile' => 1, 'filevar' => 'UPDATEFILE'});
@@ -232,11 +232,11 @@ if (($filtersettings{'ACTION'} eq $Lang::tr{'save'}) ||
                        $errormessage = $!;
                        goto ERROR;
                }
-               
+
                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");
-               
+
                if ($exitcode > 0)
                {
                        $errormessage = $Lang::tr{'urlfilter tar error'};
@@ -314,7 +314,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");
                if ($exitcode > 0)
                {
@@ -789,7 +789,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");
                        if ($exitcode > 0)
                        {
@@ -1466,17 +1466,6 @@ print <<END
        <td>&nbsp;</td>
 </tr>
 </table>
-<table width='100%'>
-<tr>
-       <td class='base'><b>$Lang::tr{'urlfilter background image'}</b></td>
-</tr>
-<tr>
-       <td><br>$Lang::tr{'urlfilter background text'}:</td>
-</tr>
-<tr>
-       <td><input type='file' name='BACKGROUND' size='40' /> &nbsp; <input type='submit' name='ACTION' value='$Lang::tr{'urlfilter upload background'}' /></td>
-</tr>
-</table>
 <hr size='1'>
 <table width='100%'>
 <tr>
@@ -2783,7 +2772,7 @@ 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'}:$http_port\/redirect.cgi".$redirect; 
+                       $redirect = "http:\/\/$netsettings{'GREEN_ADDRESS'}:$http_port\/redirect.cgi".$redirect;
                } else {
                        $redirect="http:\/\/$netsettings{'GREEN_ADDRESS'}:$http_port\/redirect.cgi";
                }
@@ -3001,6 +2990,7 @@ sub writeconfigfile
        foreach $category (@categories) {
                $blacklist = $category;
                $category =~ s/\//_/g;
+               if ( $filtersettings{"FILTER_".uc($category)} ne "on" ){next;}
                print FILE "dest $category {\n";
                if (-e "$dbdir/$blacklist/domains") {
                        print FILE "    domainlist     $blacklist\/domains\n";
@@ -3027,7 +3017,7 @@ sub writeconfigfile
                print FILE "}\n\n";
                $category = $blacklist;
        }
-       
+
        print FILE "dest files {\n";
        print FILE "    expressionlist custom\/blocked\/files\n";
        if ($filtersettings{'ENABLE_LOG'} eq 'on')