]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - html/cgi-bin/proxy.cgi
proxy.cgi: fix filename of ntlm authenticator.
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / proxy.cgi
index 6fedf4e273fe9b2dad5376448832ea4c425ce6bc..8b3200dab4306eb570857f416f518c73c0cbf680 100644 (file)
@@ -1,10 +1,29 @@
 #!/usr/bin/perl
+###############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2007-2011  IPFire Team  <info@ipfire.org>                     #
+#                                                                             #
+# 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/>.       #
+#                                                                             #
+###############################################################################
 #
-# IPCop  CGIs
+# (c) 2004-2009 marco.s - http://www.advproxy.net
 #
 # This code is distributed under the terms of the GPL
 #
-# $Id: advproxy.cgi,v 2.0.0 [beta] 2006/09/03 00:00:00 marco.s Exp $
+# $Id: advproxy.cgi,v 3.0.2 2009/02/04 00:00:00 marco.s Exp $
 #
 
 use strict;
@@ -21,14 +40,17 @@ my @squidversion = `/usr/sbin/squid -v`;
 my $http_port='81';
 my $https_port='444';
 
+my %color = ();
+my %mainsettings = ();
+&General::readhash("${General::swroot}/main/settings", \%mainsettings);
+&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
+
 my %proxysettings=();
 my %netsettings=();
 my %filtersettings=();
-my %updaccelsettings=();
+my %xlratorsettings=();
 my %stdproxysettings=();
 my %mainsettings=();
-my $urlfilter_addon=0;
-my $updaccel_addon=0;
 
 my %checked=();
 my %selected=();
@@ -60,7 +82,6 @@ my @templist=();
 my $cachemem=0;
 my $proxy1='';
 my $proxy2='';
-my $replybodymaxsize=0;
 my $browser_regexp='';
 my $needhup = 0;
 my $errormessage='';
@@ -87,7 +108,7 @@ my $cre_svhosts = "${General::swroot}/proxy/advanced/cre/supervisors";
 
 my $identhosts = "$identdir/hosts";
 
-my $authdir  = "/usr/lib/squid/auth";
+my $authdir  = "/usr/lib/squid/";
 my $errordir = "/usr/lib/squid/errors";
 
 my $acl_src_subnets = "$acldir/src_subnets.acl";
@@ -97,8 +118,14 @@ my $acl_src_unrestricted_ip  = "$acldir/src_unrestricted_ip.acl";
 my $acl_src_unrestricted_mac = "$acldir/src_unrestricted_mac.acl";
 my $acl_src_noaccess_ip  = "$acldir/src_noaccess_ip.acl";
 my $acl_src_noaccess_mac = "$acldir/src_noaccess_mac.acl";
-my $acl_dst_nocache  = "$acldir/dst_nocache.acl";
 my $acl_dst_noauth   = "$acldir/dst_noauth.acl";
+my $acl_dst_noauth_dom = "$acldir/dst_noauth_dom.acl";
+my $acl_dst_noauth_net = "$acldir/dst_noauth_net.acl";
+my $acl_dst_noauth_url = "$acldir/dst_noauth_url.acl";
+my $acl_dst_nocache  = "$acldir/dst_nocache.acl";
+my $acl_dst_nocache_dom = "$acldir/dst_nocache_dom.acl";
+my $acl_dst_nocache_net = "$acldir/dst_nocache_net.acl";
+my $acl_dst_nocache_url = "$acldir/dst_nocache_url.acl";
 my $acl_dst_throttle = "$acldir/dst_throttle.acl";
 my $acl_ports_safe = "$acldir/ports_safe.acl";
 my $acl_ports_ssl  = "$acldir/ports_ssl.acl";
@@ -129,8 +156,14 @@ unless (-e $acl_src_unrestricted_ip)  { system("touch $acl_src_unrestricted_ip")
 unless (-e $acl_src_unrestricted_mac) { system("touch $acl_src_unrestricted_mac"); }
 unless (-e $acl_src_noaccess_ip)  { system("touch $acl_src_noaccess_ip"); }
 unless (-e $acl_src_noaccess_mac) { system("touch $acl_src_noaccess_mac"); }
-unless (-e $acl_dst_nocache)   { system("touch $acl_dst_nocache"); }
-unless (-e $acl_dst_noauth)    { system("touch $acl_dst_noauth"); }
+unless (-e $acl_dst_noauth)     { system("touch $acl_dst_noauth"); }
+unless (-e $acl_dst_noauth_dom) { system("touch $acl_dst_noauth_dom"); }
+unless (-e $acl_dst_noauth_net) { system("touch $acl_dst_noauth_net"); }
+unless (-e $acl_dst_noauth_url) { system("touch $acl_dst_noauth_url"); }
+unless (-e $acl_dst_nocache)     { system("touch $acl_dst_nocache"); }
+unless (-e $acl_dst_nocache_dom) { system("touch $acl_dst_nocache_dom"); }
+unless (-e $acl_dst_nocache_net) { system("touch $acl_dst_nocache_net"); }
+unless (-e $acl_dst_nocache_url) { system("touch $acl_dst_nocache_url"); }
 unless (-e $acl_dst_throttle)  { system("touch $acl_dst_throttle"); }
 unless (-e $acl_ports_safe) { system("touch $acl_ports_safe"); }
 unless (-e $acl_ports_ssl)  { system("touch $acl_ports_ssl"); }
@@ -146,25 +179,10 @@ close(FILE);
 &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
 
-if (-e "${General::swroot}/urlfilter/version") { $urlfilter_addon = 1; }
-if (-e "${General::swroot}/updatexlrator/version") { $updaccel_addon = 1; }
-
-if ($urlfilter_addon) {
-       $filtersettings{'CHILDREN'} = '5';
-       if (-e "${General::swroot}/urlfilter/settings") {
-               &General::readhash("${General::swroot}/urlfilter/settings", \%filtersettings);
-       }
-       $urlfilterversion = `cat ${General::swroot}/urlfilter/version`;
-       $urlfilterversion =~ s/([^\s]+).*/$1/;
-}
-
-if ($updaccel_addon) {
-       $updaccelsettings{'CHILDREN'} = '10';
-       if (-e "${General::swroot}/updatexlrator/settings") {
-               &General::readhash("${General::swroot}/updatexlrator/settings", \%updaccelsettings);
-       }
-       $updaccelversion = `cat ${General::swroot}/updatexlrator/version`;
-       $updaccelversion =~ s/([^\s]+).*/$1/;
+my $green_cidr = &General::ipcidr("$netsettings{'GREEN_NETADDRESS'}\/$netsettings{'GREEN_NETMASK'}");
+my $blue_cidr = "# Blue not defined";
+if ($netsettings{'BLUE_DEV'}) {
+       $blue_cidr = &General::ipcidr("$netsettings{'BLUE_NETADDRESS'}\/$netsettings{'BLUE_NETMASK'}");
 }
 
 &Header::showhttpheaders();
@@ -179,8 +197,9 @@ $proxysettings{'TRANSPARENT_BLUE'} = 'off';
 $proxysettings{'PROXY_PORT'} = '800';
 $proxysettings{'VISIBLE_HOSTNAME'} = '';
 $proxysettings{'ADMIN_MAIL_ADDRESS'} = '';
-$proxysettings{'ERR_LANGUAGE'} = 'English';
-$proxysettings{'ERR_DESIGN'} = 'IPCop';
+$proxysettings{'ADMIN_PASSWORD'} = '';
+$proxysettings{'ERR_LANGUAGE'} = 'German';
+$proxysettings{'ERR_DESIGN'} = 'ipfire';
 $proxysettings{'SUPPRESS_VERSION'} = 'off';
 $proxysettings{'FORWARD_VIA'} = 'off';
 $proxysettings{'FORWARD_IPADDRESS'} = 'off';
@@ -190,8 +209,10 @@ $proxysettings{'UPSTREAM_PROXY'} = '';
 $proxysettings{'UPSTREAM_USER'} = '';
 $proxysettings{'UPSTREAM_PASSWORD'} = '';
 $proxysettings{'LOGGING'} = 'off';
+$proxysettings{'CACHEMGR'} = 'off';
 $proxysettings{'LOGQUERY'} = 'off';
 $proxysettings{'LOGUSERAGENT'} = 'off';
+$proxysettings{'FILEDESCRIPTORS'} = '4096';
 $proxysettings{'CACHE_MEM'} = '2';
 $proxysettings{'CACHE_SIZE'} = '50';
 $proxysettings{'MAX_SIZE'} = '4096';
@@ -202,6 +223,8 @@ $proxysettings{'L1_DIRS'} = '16';
 $proxysettings{'OFFLINE_MODE'} = 'off';
 $proxysettings{'CLASSROOM_EXT'} = 'off';
 $proxysettings{'SUPERVISOR_PASSWORD'} = '';
+$proxysettings{'NO_PROXY_LOCAL'} = 'off';
+$proxysettings{'NO_PROXY_LOCAL_BLUE'} = 'off';
 $proxysettings{'TIME_ACCESS_MODE'} = 'allow';
 $proxysettings{'TIME_FROM_HOUR'} = '00';
 $proxysettings{'TIME_FROM_MINUTE'} = '00';
@@ -254,14 +277,10 @@ $proxysettings{'IDENT_REQUIRED'} = 'off';
 $proxysettings{'IDENT_TIMEOUT'} = '10';
 $proxysettings{'IDENT_ENABLE_ACL'} = 'off';
 $proxysettings{'IDENT_USER_ACL'} = 'positive';
-
-if ($urlfilter_addon) {
-       $proxysettings{'ENABLE_FILTER'} = 'off';
-}
-
-if ($updaccel_addon) {
-       $proxysettings{'ENABLE_UPDXLRATOR'} = 'off';
-}
+$proxysettings{'ENABLE_FILTER'} = 'off';
+$proxysettings{'ENABLE_UPDXLRATOR'} = 'off';
+$proxysettings{'ENABLE_CLAMAV'} = 'off';
+$proxysettings{'CHILDREN'} = '10';
 
 $ncsa_buttontext = $Lang::tr{'advproxy NCSA create user'};
 
@@ -305,6 +324,10 @@ if ($proxysettings{'ACTION'} eq $Lang::tr{'remove'})
        &deluser($proxysettings{'ID'});
 }
 
+$checked{'ENABLE_UPDXLRATOR'}{'off'} = '';
+$checked{'ENABLE_UPDXLRATOR'}{'on'} = '';
+$checked{'ENABLE_UPDXLRATOR'}{$proxysettings{'ENABLE_UPDXLRATOR'}} = "checked='checked'";
+
 if ($proxysettings{'ACTION'} eq $Lang::tr{'edit'})
 {
        $proxysettings{'NCSA_EDIT_MODE'} = 'yes';
@@ -316,15 +339,15 @@ if ($proxysettings{'ACTION'} eq $Lang::tr{'edit'})
        $proxysettings{'NCSA_PASS_CONFIRM'} = $proxysettings{'NCSA_PASS'};
 }
 
-if (($proxysettings{'ACTION'} eq $Lang::tr{'save'}) || ($proxysettings{'ACTION'} eq $Lang::tr{'advproxy save and restart'}))
-{ 
-       if ($proxysettings{'ENABLE'} !~ /^(on|off)$/ || 
-           $proxysettings{'TRANSPARENT'} !~ /^(on|off)$/ || 
-           $proxysettings{'ENABLE_BLUE'} !~ /^(on|off)$/ || 
+if (($proxysettings{'ACTION'} eq $Lang::tr{'save'}) || ($proxysettings{'ACTION'} eq $Lang::tr{'advproxy save and restart'}) || ($proxysettings{'ACTION'} eq $Lang::tr{'proxy reconfigure'}))
+{
+       if ($proxysettings{'ENABLE'} !~ /^(on|off)$/ ||
+           $proxysettings{'TRANSPARENT'} !~ /^(on|off)$/ ||
+           $proxysettings{'ENABLE_BLUE'} !~ /^(on|off)$/ ||
            $proxysettings{'TRANSPARENT_BLUE'} !~ /^(on|off)$/ ) {
                $errormessage = $Lang::tr{'invalid input'};
                goto ERROR;
-       } 
+       }
        if (!(&General::validport($proxysettings{'PROXY_PORT'})))
        {
                $errormessage = $Lang::tr{'advproxy errmsg invalid proxy port'};
@@ -333,7 +356,16 @@ if (($proxysettings{'ACTION'} eq $Lang::tr{'save'}) || ($proxysettings{'ACTION'}
        if (!($proxysettings{'CACHE_SIZE'} =~ /^\d+/) ||
                ($proxysettings{'CACHE_SIZE'} < 10))
        {
-               $errormessage = $Lang::tr{'advproxy errmsg hdd cache size'};
+               if (!($proxysettings{'CACHE_SIZE'} eq '0'))
+               {
+                       $errormessage = $Lang::tr{'advproxy errmsg hdd cache size'};
+                       goto ERROR;
+               }
+       }
+       if (!($proxysettings{'FILEDESCRIPTORS'} =~ /^\d+/) ||
+               ($proxysettings{'FILEDESCRIPTORS'} < 1) || ($proxysettings{'FILEDESCRIPTORS'} > 16384))
+       {
+               $errormessage = $Lang::tr{'proxy errmsg filedescriptors'};
                goto ERROR;
        }
        if (!($proxysettings{'CACHE_MEM'} =~ /^\d+/) ||
@@ -341,7 +373,7 @@ if (($proxysettings{'ACTION'} eq $Lang::tr{'save'}) || ($proxysettings{'ACTION'}
        {
                $errormessage = $Lang::tr{'advproxy errmsg mem cache size'};
                goto ERROR;
-       }               
+       }
        my @free = `/usr/bin/free`;
        $free[1] =~ m/(\d+)/;
        $cachemem = int $1 / 2048;
@@ -372,6 +404,11 @@ if (($proxysettings{'ACTION'} eq $Lang::tr{'save'}) || ($proxysettings{'ACTION'}
        {
                $errormessage = $Lang::tr{'invalid maximum incoming size'};
                goto ERROR;
+       }
+               if (!($proxysettings{'CHILDREN'} =~ /^\d+$/) || ($proxysettings{'CHILDREN'} < 1))
+       {
+               $errormessage = $Lang::tr{'advproxy invalid num of children'};
+               goto ERROR;
        }
        if ($proxysettings{'ENABLE_BROWSER_CHECK'} eq 'on')
        {
@@ -380,7 +417,7 @@ if (($proxysettings{'ACTION'} eq $Lang::tr{'save'}) || ($proxysettings{'ACTION'}
                {
                        chomp;
                        @useragent = split(/,/);
-                       if ($proxysettings{'UA_'.@useragent[0]} eq 'on') { $browser_regexp .= "@useragent[2]|"; }
+                       if ($proxysettings{'UA_'.$useragent[0]} eq 'on') { $browser_regexp .= "$useragent[2]|"; }
                }
                chop($browser_regexp);
                if (!$browser_regexp)
@@ -411,8 +448,8 @@ if (($proxysettings{'ACTION'} eq $Lang::tr{'save'}) || ($proxysettings{'ACTION'}
                                }
                        }
                }
-               if ((!($proxysettings{'AUTH_MAX_USERIP'} eq '')) && 
-                       ((!($proxysettings{'AUTH_MAX_USERIP'} =~ /^\d+/)) || ($proxysettings{'AUTH_MAX_USERIP'} < 1) || ($proxysettings{'AUTH_MAX_USERIP'} > 255)))     
+               if ((!($proxysettings{'AUTH_MAX_USERIP'} eq '')) &&
+                       ((!($proxysettings{'AUTH_MAX_USERIP'} =~ /^\d+/)) || ($proxysettings{'AUTH_MAX_USERIP'} < 1) || ($proxysettings{'AUTH_MAX_USERIP'} > 255)))
                {
                        $errormessage = $Lang::tr{'advproxy errmsg max userip'};
                        goto ERROR;
@@ -502,6 +539,10 @@ if (($proxysettings{'ACTION'} eq $Lang::tr{'save'}) || ($proxysettings{'ACTION'}
                        $errormessage = $Lang::tr{'advproxy errmsg invalid bdc'};
                        goto ERROR;
                }
+
+               $proxysettings{'NTLM_DOMAIN'} = lc($proxysettings{'NTLM_DOMAIN'});
+               $proxysettings{'NTLM_PDC'}    = lc($proxysettings{'NTLM_PDC'});
+               $proxysettings{'NTLM_BDC'}    = lc($proxysettings{'NTLM_BDC'});
        }
        if ($proxysettings{'AUTH_METHOD'} eq 'radius')
        {
@@ -587,34 +628,44 @@ ERROR:
 
                if (-e "${General::swroot}/proxy/settings") { &General::readhash("${General::swroot}/proxy/settings", \%stdproxysettings); }
                $stdproxysettings{'PROXY_PORT'} = $proxysettings{'PROXY_PORT'};
-               if ($urlfilter_addon) { $stdproxysettings{'ENABLE_FILTER'} = $proxysettings{'ENABLE_FILTER'}; }
-               if ($updaccel_addon) { $stdproxysettings{'ENABLE_UPDXLRATOR'} = $proxysettings{'ENABLE_UPDXLRATOR'}; }
+               $stdproxysettings{'UPSTREAM_PROXY'}    = $proxysettings{'UPSTREAM_PROXY'};
+               $stdproxysettings{'UPSTREAM_USER'}     = $proxysettings{'UPSTREAM_USER'};
+               $stdproxysettings{'UPSTREAM_PASSWORD'} = $proxysettings{'UPSTREAM_PASSWORD'};
+               $stdproxysettings{'ENABLE_FILTER'} = $proxysettings{'ENABLE_FILTER'};
+               $stdproxysettings{'ENABLE_UPDXLRATOR'} = $proxysettings{'ENABLE_UPDXLRATOR'};
+               $stdproxysettings{'ENABLE_CLAMAV'} = $proxysettings{'ENABLE_CLAMAV'};
                &General::writehash("${General::swroot}/proxy/settings", \%stdproxysettings);
 
                &writeconfig;
                &writepacfile;
 
+               if ($proxysettings{'CACHEMGR'} eq 'on'){&writecachemgr;}
+
+               system ('/usr/local/bin/squidctrl', 'disable');
                unlink "${General::swroot}/proxy/enable";
                unlink "${General::swroot}/proxy/transparent";
                unlink "${General::swroot}/proxy/enable_blue";
                unlink "${General::swroot}/proxy/transparent_blue";
 
                if ($proxysettings{'ENABLE'} eq 'on') {
-                       system ('/bin/touch', "${General::swroot}/proxy/enable"); }
-               if ($proxysettings{'TRANSPARENT'} eq 'on') {
-                       system ('/bin/touch', "${General::swroot}/proxy/transparent"); }
+                       system ('/usr/bin/touch', "${General::swroot}/proxy/enable");
+                       system ('/usr/local/bin/squidctrl', 'enable'); }
+               if ($proxysettings{'TRANSPARENT'} eq 'on' && $proxysettings{'ENABLE'} eq 'on') {
+                       system ('/usr/bin/touch', "${General::swroot}/proxy/transparent"); }
                if ($proxysettings{'ENABLE_BLUE'} eq 'on') {
-                       system ('/bin/touch', "${General::swroot}/proxy/enable_blue"); }
-               if ($proxysettings{'TRANSPARENT_BLUE'} eq 'on') {
-                       system ('/bin/touch', "${General::swroot}/proxy/transparent_blue"); }
-
-               if ($proxysettings{'ACTION'} eq $Lang::tr{'advproxy save and restart'}) { system('/usr/local/bin/restartsquid'); }
-       }
+                       system ('/usr/bin/touch', "${General::swroot}/proxy/enable_blue");
+                       system ('/usr/local/bin/squidctrl', 'enable'); }
+               if ($proxysettings{'TRANSPARENT_BLUE'} eq 'on' && $proxysettings{'ENABLE_BLUE'} eq 'on') {
+                       system ('/usr/bin/touch', "${General::swroot}/proxy/transparent_blue"); }
+
+               if ($proxysettings{'ACTION'} eq $Lang::tr{'advproxy save and restart'}) { system('/usr/local/bin/squidctrl restart >/dev/null 2>&1'); }
+               if ($proxysettings{'ACTION'} eq $Lang::tr{'proxy reconfigure'}) { system('/usr/local/bin/squidctrl reconfigure >/dev/null 2>&1'); }     
+  }
 }
 
 if ($proxysettings{'ACTION'} eq $Lang::tr{'advproxy clear cache'})
 {
-       system('/usr/local/bin/restartsquid','-f');
+       system('/usr/local/bin/squidctrl flush >/dev/null 2>&1');
 }
 
 if (!$errormessage)
@@ -670,6 +721,9 @@ $checked{'OFFLINE_MODE'}{$proxysettings{'OFFLINE_MODE'}} = "checked='checked'";
 $checked{'LOGGING'}{'off'} = '';
 $checked{'LOGGING'}{'on'} = '';
 $checked{'LOGGING'}{$proxysettings{'LOGGING'}} = "checked='checked'";
+$checked{'CACHEMGR'}{'off'} = '';
+$checked{'CACHEMGR'}{'on'} = '';
+$checked{'CACHEMGR'}{$proxysettings{'CACHEMGR'}} = "checked='checked'";
 $checked{'LOGQUERY'}{'off'} = '';
 $checked{'LOGQUERY'}{'on'} = '';
 $checked{'LOGQUERY'}{$proxysettings{'LOGQUERY'}} = "checked='checked'";
@@ -680,6 +734,13 @@ $checked{'LOGUSERAGENT'}{$proxysettings{'LOGUSERAGENT'}} = "checked='checked'";
 $selected{'ERR_LANGUAGE'}{$proxysettings{'ERR_LANGUAGE'}} = "selected='selected'";
 $selected{'ERR_DESIGN'}{$proxysettings{'ERR_DESIGN'}} = "selected='selected'";
 
+$checked{'NO_PROXY_LOCAL'}{'off'} = '';
+$checked{'NO_PROXY_LOCAL'}{'on'} = '';
+$checked{'NO_PROXY_LOCAL'}{$proxysettings{'NO_PROXY_LOCAL'}} = "checked='checked'";
+$checked{'NO_PROXY_LOCAL_BLUE'}{'off'} = '';
+$checked{'NO_PROXY_LOCAL_BLUE'}{'on'} = '';
+$checked{'NO_PROXY_LOCAL_BLUE'}{$proxysettings{'NO_PROXY_LOCAL_BLUE'}} = "checked='checked'";
+
 $checked{'CLASSROOM_EXT'}{'off'} = '';
 $checked{'CLASSROOM_EXT'}{'on'} = '';
 $checked{'CLASSROOM_EXT'}{$proxysettings{'CLASSROOM_EXT'}} = "checked='checked'";
@@ -745,9 +806,9 @@ $checked{'ENABLE_BROWSER_CHECK'}{$proxysettings{'ENABLE_BROWSER_CHECK'}} = "chec
 
 foreach (@useragentlist) {
        @useragent = split(/,/);
-       $checked{'UA_'.@useragent[0]}{'off'} = '';
-       $checked{'UA_'.@useragent[0]}{'on'} = '';
-       $checked{'UA_'.@useragent[0]}{$proxysettings{'UA_'.@useragent[0]}} = "checked='checked'";
+       $checked{'UA_'.$useragent[0]}{'off'} = '';
+       $checked{'UA_'.$useragent[0]}{'on'} = '';
+       $checked{'UA_'.$useragent[0]}{$proxysettings{'UA_'.$useragent[0]}} = "checked='checked'";
 }
 
 $checked{'AUTH_METHOD'}{'none'} = '';
@@ -806,17 +867,17 @@ $checked{'IDENT_USER_ACL'}{'positive'} = '';
 $checked{'IDENT_USER_ACL'}{'negative'} = '';
 $checked{'IDENT_USER_ACL'}{$proxysettings{'IDENT_USER_ACL'}} = "checked='checked'";
 
-if ($urlfilter_addon) {
-       $checked{'ENABLE_FILTER'}{'off'} = '';
-       $checked{'ENABLE_FILTER'}{'on'} = '';
-       $checked{'ENABLE_FILTER'}{$proxysettings{'ENABLE_FILTER'}} = "checked='checked'";
-}
+$checked{'ENABLE_FILTER'}{'off'} = '';
+$checked{'ENABLE_FILTER'}{'on'} = '';
+$checked{'ENABLE_FILTER'}{$proxysettings{'ENABLE_FILTER'}} = "checked='checked'";
 
-if ($updaccel_addon) {
-       $checked{'ENABLE_UPDXLRATOR'}{'off'} = '';
-       $checked{'ENABLE_UPDXLRATOR'}{'on'} = '';
-       $checked{'ENABLE_UPDXLRATOR'}{$proxysettings{'ENABLE_UPDXLRATOR'}} = "checked='checked'";
-}
+$checked{'ENABLE_UPDXLRATOR'}{'off'} = '';
+$checked{'ENABLE_UPDXLRATOR'}{'on'} = '';
+$checked{'ENABLE_UPDXLRATOR'}{$proxysettings{'ENABLE_UPDXLRATOR'}} = "checked='checked'";
+
+$checked{'ENABLE_CLAMAV'}{'off'} = '';
+$checked{'ENABLE_CLAMAV'}{'on'} = '';
+$checked{'ENABLE_CLAMAV'}{$proxysettings{'ENABLE_CLAMAV'}} = "checked='checked'";
 
 &Header::openpage($Lang::tr{'advproxy advanced web proxy configuration'}, 1, '');
 
@@ -874,8 +935,7 @@ if ($netsettings{'BLUE_DEV'}) {
        print "<td colspan='2'>&nbsp;</td>";
 }
 print <<END
-       <td class='base'>$Lang::tr{'advproxy admin mail'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
-       <td><input type='text' name='ADMIN_MAIL_ADDRESS' value='$proxysettings{'ADMIN_MAIL_ADDRESS'}' /></td>
+       <td colspan='2'>&nbsp;</td>
 </tr>
 <tr>
 END
@@ -907,7 +967,7 @@ print <<END
        <td><input type='checkbox' name='SUPPRESS_VERSION' $checked{'SUPPRESS_VERSION'}{'on'} /></td>
        <td class='base'>$Lang::tr{'advproxy error design'}:</td>
        <td class='base'><select name='ERR_DESIGN'>
-               <option value='ipcop' $selected{'ERR_DESIGN'}{'ipcop'}>IPCop</option>
+               <option value='ipfire' $selected{'ERR_DESIGN'}{'ipfire'}>IPFire</option>
                <option value='squid' $selected{'ERR_DESIGN'}{'squid'}>$Lang::tr{'advproxy standard'}</option>
        </select></td>
 </tr>
@@ -920,6 +980,37 @@ print <<END
 </table>
 <hr size='1'>
 <table width='100%'>
+<tr><td class='base' colspan='4'><b>$Lang::tr{'advproxy redirector children'}</b></td></tr>
+<tr><td class='base' >$Lang::tr{'processes'}<input type='text' name='CHILDREN' value='$proxysettings{'CHILDREN'}' size='5' /></td>
+END
+;
+my $count = `arp -a | wc -l`;
+if ( $count < 1 ){$count = 1;}
+if ( -e "/usr/bin/squidclamav" ) {
+       print "<td class='base'><b>".$Lang::tr{'advproxy squidclamav'}."</b><br />";
+       if ( ! -e "/var/run/clamav/clamd.pid" ){
+               print "<font color='red'>clamav not running</font><br /><br />";
+               $proxysettings{'ENABLE_CLAMAV'} = 'off';
+               }
+       else {
+               print $Lang::tr{'advproxy enabled'}."<input type='checkbox' name='ENABLE_CLAMAV' ".$checked{'ENABLE_CLAMAV'}{'on'}." /><br />";
+               print "+ ".int(( $count**(1/3)) * 8);}
+       print "</td>";
+} else {
+       print "<td></td>";
+}
+print "<td class='base'><b>".$Lang::tr{'advproxy url filter'}."</b><br />";
+print $Lang::tr{'advproxy enabled'}."<input type='checkbox' name='ENABLE_FILTER' ".$checked{'ENABLE_FILTER'}{'on'}." /><br />";
+print "+ ".int(($count**(1/3)) * 6);
+print "</td>";
+print "<td class='base'><b>".$Lang::tr{'advproxy update accelerator'}."</b><br />";
+print $Lang::tr{'advproxy enabled'}."<input type='checkbox' name='ENABLE_UPDXLRATOR' ".$checked{'ENABLE_UPDXLRATOR'}{'on'}." /><br />";
+print "+ ".int(($count**(1/3)) * 5);
+print "</td></tr>";
+print <<END
+</table>
+<hr size='1'>
+<table width='100%'>
 <tr>
        <td colspan='4' class='base'><b>$Lang::tr{'advproxy upstream proxy'}</b></td>
 </tr>
@@ -971,6 +1062,18 @@ print <<END
 <tr>
        <td colspan='4'><b>$Lang::tr{'advproxy cache management'}</b></td>
 </tr>
+<tr>
+       <td class='base'>$Lang::tr{'proxy cachemgr'}:</td>
+       <td><input type='checkbox' name='CACHEMGR' $checked{'CACHEMGR'}{'on'} /></td>
+       <td class='base'>$Lang::tr{'advproxy admin mail'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
+       <td><input type='text' name='ADMIN_MAIL_ADDRESS' value='$proxysettings{'ADMIN_MAIL_ADDRESS'}' /></td>
+</tr>
+<tr>
+       <td class='base'>$Lang::tr{'proxy filedescriptors'}:</td>
+       <td><input type='text' name='FILEDESCRIPTORS' value='$proxysettings{'FILEDESCRIPTORS'}' size='5' /></td>
+       <td class='base'>$Lang::tr{'proxy admin password'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
+       <td><input type='text' name='ADMIN_PASSWORD' value='$proxysettings{'ADMIN_PASSWORD'}' /></td>
+</tr>
 <tr>
        <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
 </tr>
@@ -1054,7 +1157,7 @@ print <<END
        <td colspan='4'><b>$Lang::tr{'advproxy destination ports'}</b></td>
 </tr>
 <tr>
-       <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
+       <td width='25%' align=center></td> <td width='20%' align=center></td><td width='25%' align=center></td><td width='30%' align=center></td>
 </tr>
 <tr>
        <td colspan='2' class='base'>$Lang::tr{'advproxy standard ports'}:</td>
@@ -1086,25 +1189,51 @@ print <<END
        <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
 </tr>
 <tr>
-       <td colspan='2' class='base'>$Lang::tr{'advproxy allowed subnets'}:</td>
-       <td colspan='2'>&nbsp;</td>
+       <td colspan='4' class='base'>$Lang::tr{'advproxy allowed subnets'}:</td>
 </tr>
 <tr>
-       <td colspan='2'><textarea name='SRC_SUBNETS' cols='32' rows='6' wrap='off'>
+       <td colspan='2' rowspan='4'><textarea name='SRC_SUBNETS' cols='32' rows='3' wrap='off'>
 END
 ;
 
 if (!$proxysettings{'SRC_SUBNETS'})
 {
-       print "$netsettings{'GREEN_NETADDRESS'}\/$netsettings{'GREEN_NETMASK'}\n";
+       print "$green_cidr\n";
        if ($netsettings{'BLUE_DEV'})
        {
-               print "$netsettings{'BLUE_NETADDRESS'}\/$netsettings{'BLUE_NETMASK'}\n";
+               print "$blue_cidr\n";
        }
 } else { print $proxysettings{'SRC_SUBNETS'}; }
 
 print <<END
 </textarea></td>
+END
+;
+
+$line = $Lang::tr{'advproxy no internal proxy on green'};
+$line =~ s/Green/<font color="$Header::colourgreen">Green<\/font>/i;
+print "<td class='base'>$line:</td>\n";
+print <<END
+       <td><input type='checkbox' name='NO_PROXY_LOCAL' $checked{'NO_PROXY_LOCAL'}{'on'} /></td>
+</tr>
+END
+;
+if ($netsettings{'BLUE_DEV'}) {
+       $line = $Lang::tr{'advproxy no internal proxy on blue'};
+       $line =~ s/Blue/<font color="$Header::colourblue">Blue<\/font>/i;
+       print "<tr>\n";
+       print "<td class='base'>$line:</td>\n";
+       print <<END
+       <td><input type='checkbox' name='NO_PROXY_LOCAL_BLUE' $checked{'NO_PROXY_LOCAL_BLUE'}{'on'} /></td>
+</tr>
+END
+;
+}
+print <<END
+<tr>
+       <td colspan='2'>&nbsp;</td>
+</tr>
+<tr>
        <td colspan='2'>&nbsp;</td>
 </tr>
 </table>
@@ -1117,7 +1246,7 @@ print <<END
        <td colspan='2' class='base'>$Lang::tr{'advproxy unrestricted mac clients'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
 </tr>
 <tr>
-       <td colspan='2'><textarea name='SRC_UNRESTRICTED_IP' cols='32' rows='6' wrap='off'>
+       <td colspan='2'><textarea name='SRC_UNRESTRICTED_IP' cols='32' rows='3' wrap='off'>
 END
 ;
 
@@ -1125,7 +1254,7 @@ END
 
 print <<END
 </textarea></td>
-       <td colspan='2'><textarea name='SRC_UNRESTRICTED_MAC' cols='32' rows='6' wrap='off'>
+       <td colspan='2'><textarea name='SRC_UNRESTRICTED_MAC' cols='32' rows='3' wrap='off'>
 END
 ;
 
@@ -1144,7 +1273,7 @@ print <<END
        <td colspan='2' class='base'>$Lang::tr{'advproxy banned mac clients'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
 </tr>
 <tr>
-       <td colspan='2'><textarea name='SRC_BANNED_IP' cols='32' rows='6' wrap='off'>
+       <td colspan='2'><textarea name='SRC_BANNED_IP' cols='32' rows='3' wrap='off'>
 END
 ;
 
@@ -1152,7 +1281,7 @@ END
 
 print <<END
 </textarea></td>
-       <td colspan='2'><textarea name='SRC_BANNED_MAC' cols='32' rows='6' wrap='off'>
+       <td colspan='2'><textarea name='SRC_BANNED_MAC' cols='32' rows='3' wrap='off'>
 END
 ;
 
@@ -1175,21 +1304,29 @@ if (-e $cre_enabled) { print <<END
 <table width='100%'>
 
 <tr>
-       <td colspan='4'><b>$Lang::tr{'advproxy classroom extensions'}</b></td>
+       <td colspan='4'><b>$Lang::tr{'advproxy classroom extensions'}</b> $Lang::tr{'advproxy enabled'}:<input type='checkbox' name='CLASSROOM_EXT' $checked{'CLASSROOM_EXT'}{'on'} /></td>
 </tr>
 <tr>
        <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
 </tr>
 <tr>
-       <td class='base'>$Lang::tr{'advproxy enabled'}:</td>
-       <td><input type='checkbox' name='CLASSROOM_EXT' $checked{'CLASSROOM_EXT'}{'on'} /></td>
+
+END
+;
+if ($proxysettings{'CLASSROOM_EXT'} eq 'on'){
+print <<END
        <td class='base'>$Lang::tr{'advproxy supervisor password'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
        <td><input type='password' name='SUPERVISOR_PASSWORD' value='$proxysettings{'SUPERVISOR_PASSWORD'}' size='12' /></td>
 </tr>
 <tr>
        <td colspan='2' class='base'>$Lang::tr{'advproxy cre group definitions'}:</td>
        <td colspan='2' class='base'>$Lang::tr{'advproxy cre supervisors'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
-</tr>
+END
+;
+}
+print "</tr>";
+if ($proxysettings{'CLASSROOM_EXT'} eq 'on'){
+print <<END
 <tr>
        <td colspan='2'><textarea name='CRE_GROUPS' cols='32' rows='6' wrap='off'>
 END
@@ -1207,12 +1344,11 @@ END
 print <<END
 </textarea></td>
 </tr>
-
-</table>
-
-<hr size='1'>
 END
 ;
+}
+print "</table><hr size='1'>";
+
 } else {
        print <<END
        <input type='hidden' name='SUPERVISOR_PASSWORD' value='$proxysettings{'SUPERVISOR_PASSWORD'}' />
@@ -1224,7 +1360,7 @@ END
 
 # -------------------------------------------------------------------
 
-print <<END 
+print <<END
 
 <table width='100%'>
 <tr>
@@ -1413,17 +1549,17 @@ print <<END
        <td width='10%'><input type='checkbox' name='THROTTLE_MMEDIA' $checked{'THROTTLE_MMEDIA'}{'on'} /></td>
        <td width='15%'>&nbsp;</td>
        <td width='10%'>&nbsp;</td>
-</tr>  
+</tr>
 </table>
 <hr size='1'>
 <table width='100%'>
 <tr>
-       <td colspan='4'><b>$Lang::tr{'advproxy MIME filter'}</b></td>
-</tr>
-<tr>
-       <td width='25%' class='base'>$Lang::tr{'advproxy enabled'}:</td>
-       <td width='20%'><input type='checkbox' name='ENABLE_MIME_FILTER' $checked{'ENABLE_MIME_FILTER'}{'on'} /></td>
+       <td colspan='4'><b>$Lang::tr{'advproxy MIME filter'}</b> $Lang::tr{'advproxy enabled'}:<input type='checkbox' name='ENABLE_MIME_FILTER' $checked{'ENABLE_MIME_FILTER'}{'on'} /></td>
 </tr>
+END
+;
+if ( $proxysettings{'ENABLE_MIME_FILTER'} eq 'on' ){
+print <<END
 <tr>
        <td  colspan='2' class='base'>$Lang::tr{'advproxy MIME block types'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
        <td>&nbsp;</td>
@@ -1441,18 +1577,21 @@ print <<END
        <td>&nbsp;</td>
        <td>&nbsp;</td>
 </tr>
+END
+;
+}
+print <<END
 </table>
+
 <hr size='1'>
 <table width='100%'>
 <tr>
-       <td colspan='4'><b>$Lang::tr{'advproxy web browser'}</b></td>
-</tr>
-<tr>
-       <td width='25%' class='base'>$Lang::tr{'advproxy UA enable filter'}:</td>
-       <td width='20%'><input type='checkbox' name='ENABLE_BROWSER_CHECK' $checked{'ENABLE_BROWSER_CHECK'}{'on'} /></td>
-       <td>&nbsp;</td>
-       <td>&nbsp;</td>
+       <td colspan='4'><b>$Lang::tr{'advproxy web browser'}</b> $Lang::tr{'advproxy UA enable filter'}:<input type='checkbox' name='ENABLE_BROWSER_CHECK' $checked{'ENABLE_BROWSER_CHECK'}{'on'} /></td>
 </tr>
+END
+;
+if ( $proxysettings{'ENABLE_BROWSER_CHECK'} eq 'on' ){
+print <<END
 <tr>
        <td colspan='4'><i>
 END
@@ -1471,13 +1610,13 @@ for ($n=0; $n<=@useragentlist; $n = $n + $i) {
                if ($i eq 0) { print "<tr>\n"; }
                if (($n+$i) < @useragentlist) {
                        @useragent = split(/,/,@useragentlist[$n+$i]);
-                       print "<td width='15%'>@useragent[1]:<\/td>\n";
-                       print "<td width='10%'><input type='checkbox' name='UA_@useragent[0]' $checked{'UA_'.@useragent[0]}{'on'} /></td>\n";
+                       print "<td width='15%'>$useragent[1]:<\/td>\n";
+                       print "<td width='10%'><input type='checkbox' name='UA_$useragent[0]' $checked{'UA_'.$useragent[0]}{'on'} /></td>\n";
                }
                if ($i eq 3) { print "<\/tr>\n"; }
        }
 }
-
+}
 print <<END
 </table>
 <hr size='1'>
@@ -1487,14 +1626,10 @@ print <<END
 </tr>
 <tr>
        <td class='base'>$Lang::tr{'advproxy fake useragent'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
-</tr>
-<tr>
-       <td><input type='text' name='FAKE_USERAGENT' value='$proxysettings{'FAKE_USERAGENT'}' size='56' /></td>
-</tr>
-<tr>
        <td class='base'>$Lang::tr{'advproxy fake referer'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
 </tr>
 <tr>
+       <td><input type='text' name='FAKE_USERAGENT' value='$proxysettings{'FAKE_USERAGENT'}' size='56' /></td>
        <td><input type='text' name='FAKE_REFERER' value='$proxysettings{'FAKE_REFERER'}' size='56' /></td>
 </tr>
 </table>
@@ -1502,40 +1637,6 @@ print <<END
 END
 ;
 
-if ($urlfilter_addon) {
-       print <<END
-<table width='100%'>
-<tr>
-       <td class='base' colspan='4'><b>$Lang::tr{'advproxy url filter'}</b>&nbsp; [<font color='$Header::colourred'> $urlfilterversion </font>]</td>
-</tr>
-<tr>
-       <td class='base' width='25%'>$Lang::tr{'advproxy enabled'}:</td>
-       <td class='base' width='20%'><input type='checkbox' name='ENABLE_FILTER' $checked{'ENABLE_FILTER'}{'on'} /></td>
-       <td>&nbsp;</td>
-       <td>&nbsp;</td>
-</tr>
-</table>
-<hr size='1'>
-END
-; }
-
-if ($updaccel_addon) {
-       print <<END
-<table width='100%'>
-<tr>
-       <td class='base' colspan='4'><b>$Lang::tr{'advproxy update accelerator'}</b>&nbsp; [<font color='$Header::colourred'> $updaccelversion </font>]</td>
-</tr>
-<tr>
-       <td class='base' width='25%'>$Lang::tr{'advproxy enabled'}:</td>
-       <td class='base' width='20%'><input type='checkbox' name='ENABLE_UPDXLRATOR' $checked{'ENABLE_UPDXLRATOR'}{'on'} /></td>
-       <td>&nbsp;</td>
-       <td>&nbsp;</td>
-</tr>
-</table>
-<hr size='1'>
-END
-; }
-
 print <<END
 <table width='100%'>
 <tr>
@@ -1689,9 +1790,9 @@ print <<END
 END
 ;
 if (!$proxysettings{'IDENT_HOSTS'}) {
-       print "$netsettings{'GREEN_NETADDRESS'}\/$netsettings{'GREEN_NETMASK'}\n";
+       print "$green_cidr\n";
        if ($netsettings{'BLUE_DEV'}) {
-               print "$netsettings{'BLUE_NETADDRESS'}\/$netsettings{'BLUE_NETMASK'}\n";
+               print "$blue_cidr\n";
        }
 } else {
        print $proxysettings{'IDENT_HOSTS'};
@@ -2046,6 +2147,7 @@ print <<END
 <tr>
        <td>&nbsp;</td>
        <td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
+       <td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'proxy reconfigure'}' /></td>
        <td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'advproxy save and restart'}' /></td>
        <td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'advproxy clear cache'}' /></td>
        <td>&nbsp;</td>
@@ -2155,7 +2257,7 @@ if (-e $disgrp)
 
 # If the password file contains entries, print entries and action icons
 
-if (! -z "$userdb") {
+if ( ! -z "$userdb" ) {
        print <<END
        <tr>
                <td width='30%' class='boldbase' align='center'><b><i>$Lang::tr{'advproxy NCSA username'}</i></b></td>
@@ -2173,9 +2275,9 @@ END
                if($proxysettings{'ACTION'} eq $Lang::tr{'edit'} && $proxysettings{'ID'} eq $line) {
                        print "<tr bgcolor='$Header::colouryellow'>\n"; }
                elsif ($id % 2) {
-                       print "<tr bgcolor='$Header::table1colour'>\n"; }
+                       print "<tr bgcolor='$color{'color20'}'>\n"; }
                else {
-                       print "<tr bgcolor='$Header::table2colour'>\n"; }
+                       print "<tr bgcolor='$color{'color22'}'>\n"; }
 
                print <<END
                <td align='center'>$temp[0]</td>
@@ -2213,7 +2315,7 @@ END
 print <<END
 </table>
 <br>
-<table width='100%'>
+<table>
 <tr>
        <td class='boldbase'>&nbsp; <b>$Lang::tr{'legend'}:</b></td>
        <td>&nbsp; &nbsp; <img src='/images/edit.gif' alt='$Lang::tr{'edit'}' /></td>
@@ -2408,10 +2510,11 @@ sub check_acls
        undef $proxysettings{'DST_NOCACHE'};
        foreach (@temp)
        {
-               s/^\s+//g; s/\s+$//g;
+               s/^\s+//g;
+               unless (/^#/) { s/\s+//g; }
                if ($_)
                {
-                       unless (/^\./) { $_ = '.'.$_; }
+                       if (/^\./) { $_ = '*'.$_; }
                        $proxysettings{'DST_NOCACHE'} .= $_."\n";
                }
        }
@@ -2480,10 +2583,11 @@ sub check_acls
        undef $proxysettings{'DST_NOAUTH'};
        foreach (@temp)
        {
-               s/^\s+//g; s/\s+$//g;
+               s/^\s+//g;
+               unless (/^#/) { s/\s+//g; }
                if ($_)
                {
-                       unless (/^\./) { $_ = '.'.$_; }
+                       if (/^\./) { $_ = '*'.$_; }
                        $proxysettings{'DST_NOAUTH'} .= $_."\n";
                }
        }
@@ -2593,10 +2697,10 @@ sub write_acls
        flock(FILE, 2);
        if (!$proxysettings{'SRC_SUBNETS'})
        {
-               print FILE "$netsettings{'GREEN_NETADDRESS'}\/$netsettings{'GREEN_NETMASK'}\n";
+               print FILE "$green_cidr\n";
                if ($netsettings{'BLUE_DEV'})
                {
-                       print FILE "$netsettings{'BLUE_NETADDRESS'}\/$netsettings{'BLUE_NETMASK'}\n";
+                       print FILE "$blue_cidr\n";
                }
        } else { print FILE $proxysettings{'SRC_SUBNETS'}; }
        close(FILE);
@@ -2621,16 +2725,104 @@ sub write_acls
        print FILE $proxysettings{'SRC_UNRESTRICTED_MAC'};
        close(FILE);
 
+       open(FILE, ">$acl_dst_noauth");
+       flock(FILE, 2);
+       print FILE $proxysettings{'DST_NOAUTH'};
+       close(FILE);
+
+       open(FILE, ">$acl_dst_noauth_net");
+       close(FILE);
+       open(FILE, ">$acl_dst_noauth_dom");
+       close(FILE);
+       open(FILE, ">$acl_dst_noauth_url");
+       close(FILE);
+
+       @temp = split(/\n/,$proxysettings{'DST_NOAUTH'});
+       foreach(@temp)
+       {
+               unless (/^#/)
+               {
+                       if (/^\*\.\w/)
+                       {
+                               s/^\*//;
+                               open(FILE, ">>$acl_dst_noauth_dom");
+                               flock(FILE, 2);
+                               print FILE "$_\n";
+                               close(FILE);
+                       }
+                       elsif (&General::validipormask($_))
+                       {
+                               open(FILE, ">>$acl_dst_noauth_net");
+                               flock(FILE, 2);
+                               print FILE "$_\n";
+                               close(FILE);
+                       }
+                       elsif (/\d\d?\d?\.\d\d?\d?\.\d\d?\d?\.\d\d?\d?-\d\d?\d?\.\d\d?\d?\.\d\d?\d?\.\d\d?\d?/)
+                       {
+                               open(FILE, ">>$acl_dst_noauth_net");
+                               flock(FILE, 2);
+                               print FILE "$_\n";
+                               close(FILE);
+                       }
+                       else
+                       {
+                               open(FILE, ">>$acl_dst_noauth_url");
+                               flock(FILE, 2);
+                               if (/^[fh]tt?ps?:\/\//) { print FILE "$_\n"; } else { print FILE "^[fh]tt?ps?://$_\n"; }
+                               close(FILE);
+                       }
+               }
+       }
+
        open(FILE, ">$acl_dst_nocache");
        flock(FILE, 2);
        print FILE $proxysettings{'DST_NOCACHE'};
        close(FILE);
 
-       open(FILE, ">$acl_dst_noauth");
-       flock(FILE, 2);
-       print FILE $proxysettings{'DST_NOAUTH'};
+       open(FILE, ">$acl_dst_nocache_net");
+       close(FILE);
+       open(FILE, ">$acl_dst_nocache_dom");
+       close(FILE);
+       open(FILE, ">$acl_dst_nocache_url");
        close(FILE);
 
+       @temp = split(/\n/,$proxysettings{'DST_NOCACHE'});
+       foreach(@temp)
+       {
+               unless (/^#/)
+               {
+                       if (/^\*\.\w/)
+                       {
+                               s/^\*//;
+                               open(FILE, ">>$acl_dst_nocache_dom");
+                               flock(FILE, 2);
+                               print FILE "$_\n";
+                               close(FILE);
+                       }
+                       elsif (&General::validipormask($_))
+                       {
+                               open(FILE, ">>$acl_dst_nocache_net");
+                               flock(FILE, 2);
+                               print FILE "$_\n";
+                               close(FILE);
+                       }
+                       elsif (/\d\d?\d?\.\d\d?\d?\.\d\d?\d?\.\d\d?\d?-\d\d?\d?\.\d\d?\d?\.\d\d?\d?\.\d\d?\d?/)
+                       {
+                               open(FILE, ">>$acl_dst_nocache_net");
+                               flock(FILE, 2);
+                               print FILE "$_\n";
+                               close(FILE);
+                       }
+                       else
+                       {
+                               open(FILE, ">>$acl_dst_nocache_url");
+                               flock(FILE, 2);
+                               if (/^[fh]tt?ps?:\/\//) { print FILE "$_\n"; } else { print FILE "^[fh]tt?ps?://$_\n"; }
+                               close(FILE);
+                       }
+               }
+       }
+
        open(FILE, ">$acl_ports_safe");
        flock(FILE, 2);
        if (!$proxysettings{'PORTS_SAFE'}) { print FILE $def_ports_safe; } else { print FILE $proxysettings{'PORTS_SAFE'}; }
@@ -2722,7 +2914,7 @@ sub write_acls
 
 sub writepacfile
 {
-       open(FILE, ">/home/httpd/html/proxy.pac");
+       open(FILE, ">/srv/web/ipfire/html/proxy.pac");
        flock(FILE, 2);
        print FILE "function FindProxyForURL(url, host)\n";
        print FILE "{\n";
@@ -2734,8 +2926,8 @@ if (
      (dnsDomainIs(host, ".$mainsettings{'DOMAINNAME'}")) ||
      (isInNet(host, "10.0.0.0", "255.0.0.0")) ||
      (isInNet(host, "172.16.0.0", "255.240.0.0")) ||
-     (isInNet(host, "169.254.0.0", "255.255.0.0")) ||
-     (isInNet(host, "192.168.0.0", "255.255.0.0"))
+     (isInNet(host, "192.168.0.0", "255.255.0.0")) ||
+     (isInNet(host, "169.254.0.0", "255.255.0.0"))
    )
      return "DIRECT";
 
@@ -2745,9 +2937,34 @@ END
 ;
                if ($proxysettings{'ENABLE'} eq 'on')
                {
+                       print FILE "if (\n";
+                       print FILE "     (isInNet(myIpAddress(), \"$netsettings{'GREEN_NETADDRESS'}\", \"$netsettings{'GREEN_NETMASK'}\"))";
+
+                       undef @templist;
+                       if (-e "$acl_src_subnets") {
+                               open(SUBNETS,"$acl_src_subnets");
+                               @templist = <SUBNETS>;
+                               close(SUBNETS);
+                       }
+
+                       foreach (@templist)
+                       {
+                               @temp = split(/\//);
+                               if (
+                                       ($temp[0] ne $netsettings{'GREEN_NETADDRESS'}) && ($temp[1] ne $netsettings{'GREEN_NETMASK'}) &&
+                                       ($temp[0] ne $netsettings{'BLUE_NETADDRESS'}) && ($temp[1] ne $netsettings{'BLUE_NETMASK'})
+                                       )
+                               {
+                                       chomp $temp[1];
+                                       print FILE " ||\n     (isInNet(myIpAddress(), \"$temp[0]\", \"$temp[1]\"))";
+                               }
+                       }
+
+                       print FILE "\n";
+
                        print FILE <<END
-if (
-     (isInNet(myIpAddress(), "$netsettings{'GREEN_NETADDRESS'}", "$netsettings{'GREEN_NETMASK'}"))
+
+
    )
      return "PROXY $netsettings{'GREEN_ADDRESS'}:$proxysettings{'PROXY_PORT'}";
 END
@@ -2789,7 +3006,7 @@ sub writeconfig
 
        if ($proxysettings{'AUTH_REALM'} eq '')
        {
-               $authrealm = "IPCop Advanced Proxy Server";
+               $authrealm = "IPFire Advanced Proxy Server";
        } else {
                $authrealm = $proxysettings{'AUTH_REALM'};
        }
@@ -2827,15 +3044,22 @@ END
                print FILE "\n";
        }
 
-       print FILE <<END
+       if ($proxysettings{'CACHE_SIZE'} > 0)
+       {
+               print FILE "\n";
 
-acl QUERY urlpath_regex cgi-bin \\?
-cache deny QUERY
-END
-       ;
-       if (!-z $acl_dst_nocache) {
-               print FILE "acl no_cache_domains dstdomain \"$acl_dst_nocache\"\n";
-               print FILE "cache deny no_cache_domains\n";
+               if (!-z $acl_dst_nocache_dom) {
+                       print FILE "acl no_cache_domains dstdomain \"$acl_dst_nocache_dom\"\n";
+                       print FILE "cache deny no_cache_domains\n";
+               }
+               if (!-z $acl_dst_nocache_net) {
+                       print FILE "acl no_cache_ipaddr dst \"$acl_dst_nocache_net\"\n";
+                       print FILE "cache deny no_cache_ipaddr\n";
+               }
+               if (!-z $acl_dst_nocache_url) {
+                       print FILE "acl no_cache_hosts url_regex -i \"$acl_dst_nocache_url\"\n";
+                       print FILE "cache deny no_cache_hosts\n";
+               }
        }
 
        print FILE <<END
@@ -2847,18 +3071,16 @@ umask 022
 pid_filename /var/run/squid.pid
 
 cache_mem $proxysettings{'CACHE_MEM'} MB
-cache_dir aufs /var/log/cache $proxysettings{'CACHE_SIZE'} $proxysettings{'L1_DIRS'} 256
-
 END
        ;
 
-       if (($proxysettings{'ERR_DESIGN'} eq 'ipcop') && ($proxysettings{'VISIBLE_HOSTNAME'} eq ''))
+       if ($proxysettings{'CACHE_SIZE'} ne '0')
        {
-               print FILE "error_directory $errordir.ipcop/$proxysettings{'ERR_LANGUAGE'}\n\n";
-       } else {
-               print FILE "error_directory $errordir/$proxysettings{'ERR_LANGUAGE'}\n\n";
+               print FILE "cache_dir aufs /var/log/cache $proxysettings{'CACHE_SIZE'} $proxysettings{'L1_DIRS'} 256\n\n";
        }
 
+       print FILE "error_directory $errordir/$proxysettings{'ERR_LANGUAGE'}\n\n";
+
        if ($proxysettings{'OFFLINE_MODE'} eq 'on') {  print FILE "offline_mode on\n\n"; }
 
        if ((!($proxysettings{'MEM_POLICY'} eq 'LRU')) || (!($proxysettings{'CACHE_POLICY'} eq 'LRU')))
@@ -2970,7 +3192,7 @@ END
                {
                        if ($proxysettings{'NTLM_ENABLE_INT_AUTH'} eq 'on')
                        {
-                               print FILE "auth_param ntlm program $authdir/ntlm_auth $proxysettings{'NTLM_DOMAIN'}/$proxysettings{'NTLM_PDC'}";
+                               print FILE "auth_param ntlm program $authdir/ntlm_smb_lm_auth $proxysettings{'NTLM_DOMAIN'}/$proxysettings{'NTLM_PDC'}";
                                if ($proxysettings{'NTLM_BDC'} eq '') { print FILE "\n"; } else { print FILE " $proxysettings{'NTLM_DOMAIN'}/$proxysettings{'NTLM_BDC'}\n"; }
                                print FILE "auth_param ntlm children $proxysettings{'AUTH_CHILDREN'}\n";
                                if (!($proxysettings{'AUTH_IPCACHE_TTL'} eq '0')) { print FILE "\nauthenticate_ip_ttl $proxysettings{'AUTH_IPCACHE_TTL'} minutes\n"; }
@@ -2993,7 +3215,7 @@ END
                                                print MSNTCONF "allowusers $ntlmdir/msntauth.allowusers\n";
                                        } else {
                                                print MSNTCONF "denyusers $ntlmdir/msntauth.denyusers\n";
-                                       } 
+                                       }
                                }
                                close(MSNTCONF);
                        }
@@ -3043,8 +3265,11 @@ END
                if (!($proxysettings{'AUTH_MAX_USERIP'} eq '')) { print FILE "\nacl concurrent max_user_ip -s $proxysettings{'AUTH_MAX_USERIP'}\n"; }
                print FILE "\n";
 
-               if (!-z $acl_dst_noauth) { print FILE "acl to_domains_without_auth dstdomain \"$acl_dst_noauth\"\n"; }
+               if (!-z $acl_dst_noauth_net) { print FILE "acl to_ipaddr_without_auth dst \"$acl_dst_noauth_net\"\n"; }
+               if (!-z $acl_dst_noauth_dom) { print FILE "acl to_domains_without_auth dstdomain \"$acl_dst_noauth_dom\"\n"; }
+               if (!-z $acl_dst_noauth_url) { print FILE "acl to_hosts_without_auth url_regex -i \"$acl_dst_noauth_url\"\n"; }
                print FILE "\n";
+
        }
 
        if ($proxysettings{'AUTH_METHOD'} eq 'ident')
@@ -3064,7 +3289,9 @@ END
                                print FILE "acl for_acl_users ident_regex -i \"$identdir/identauth.denyusers\"\n\n";
                        }
                }
-               if (!-z $acl_dst_noauth) { print FILE "acl to_domains_without_auth dstdomain \"$acl_dst_noauth\"\n"; }
+               if (!-z $acl_dst_noauth_net) { print FILE "acl to_ipaddr_without_auth dst \"$acl_dst_noauth_net\"\n"; }
+               if (!-z $acl_dst_noauth_dom) { print FILE "acl to_domains_without_auth dstdomain \"$acl_dst_noauth_dom\"\n"; }
+               if (!-z $acl_dst_noauth_url) { print FILE "acl to_hosts_without_auth url_regex -i \"$acl_dst_noauth_url\"\n"; }
                print FILE "\n";
        }
 
@@ -3072,7 +3299,7 @@ END
 
        if ($proxysettings{'ENABLE_BROWSER_CHECK'} eq 'on') { print FILE "acl with_allowed_useragents browser $browser_regexp\n\n"; }
 
-       print FILE "acl within_timeframe time "; 
+       print FILE "acl within_timeframe time ";
        if ($proxysettings{'TIME_MON'} eq 'on') { print FILE "M"; }
        if ($proxysettings{'TIME_TUE'} eq 'on') { print FILE "T"; }
        if ($proxysettings{'TIME_WED'} eq 'on') { print FILE "W"; }
@@ -3090,8 +3317,8 @@ END
        }
 
        print FILE <<END
-acl all src 0.0.0.0/0.0.0.0
-acl localhost src 127.0.0.1/255.255.255.255
+#acl all src all
+acl localhost src 127.0.0.1/32
 END
 ;
 open (PORTS,"$acl_ports_ssl");
@@ -3110,18 +3337,21 @@ if (@temp)
 }
        print FILE <<END
 
-acl IPCop_http  port $http_port
-acl IPCop_https port $https_port
-acl IPCop_ips              dst $netsettings{'GREEN_ADDRESS'}
-acl IPCop_networks         src "$acl_src_subnets"
-acl IPCop_green_network    src $netsettings{'GREEN_NETADDRESS'}/$netsettings{'GREEN_NETMASK'}
+acl IPFire_http  port $http_port
+acl IPFire_https port $https_port
+acl IPFire_ips              dst $netsettings{'GREEN_ADDRESS'}
+acl IPFire_networks         src "$acl_src_subnets"
+acl IPFire_servers          dst "$acl_src_subnets"
+acl IPFire_green_network    src $green_cidr
+acl IPFire_green_servers    dst $green_cidr
 END
        ;
-       if ($netsettings{'BLUE_DEV'}) { print FILE "acl IPCop_blue_network     src $netsettings{'BLUE_NETADDRESS'}/$netsettings{'BLUE_NETMASK'}\n"; }
-       if (!-z $acl_src_banned_ip) { print FILE "acl IPCop_banned_ips       src \"$acl_src_banned_ip\"\n"; }
-       if (!-z $acl_src_banned_mac) { print FILE "acl IPCop_banned_mac       arp \"$acl_src_banned_mac\"\n"; }
-       if (!-z $acl_src_unrestricted_ip) { print FILE "acl IPCop_unrestricted_ips src \"$acl_src_unrestricted_ip\"\n"; }
-       if (!-z $acl_src_unrestricted_mac) { print FILE "acl IPCop_unrestricted_mac arp \"$acl_src_unrestricted_mac\"\n"; }
+       if ($netsettings{'BLUE_DEV'}) { print FILE "acl IPFire_blue_network     src $blue_cidr\n"; }
+       if ($netsettings{'BLUE_DEV'}) { print FILE "acl IPFire_blue_servers     dst $blue_cidr\n"; }
+       if (!-z $acl_src_banned_ip) { print FILE "acl IPFire_banned_ips       src \"$acl_src_banned_ip\"\n"; }
+       if (!-z $acl_src_banned_mac) { print FILE "acl IPFire_banned_mac       arp \"$acl_src_banned_mac\"\n"; }
+       if (!-z $acl_src_unrestricted_ip) { print FILE "acl IPFire_unrestricted_ips src \"$acl_src_unrestricted_ip\"\n"; }
+       if (!-z $acl_src_unrestricted_mac) { print FILE "acl IPFire_unrestricted_mac arp \"$acl_src_unrestricted_mac\"\n"; }
        print FILE <<END
 acl CONNECT method CONNECT
 END
@@ -3131,32 +3361,30 @@ END
                print FILE <<END
 
 #Classroom extensions
-acl IPCop_no_access_ips src "$acl_src_noaccess_ip"
-acl IPCop_no_access_mac arp "$acl_src_noaccess_mac"
+acl IPFire_no_access_ips src "$acl_src_noaccess_ip"
+acl IPFire_no_access_mac arp "$acl_src_noaccess_mac"
 END
                ;
                print FILE "deny_info ";
-               if ((($proxysettings{'ERR_DESIGN'} eq 'ipcop') && (-e "$errordir.ipcop/$proxysettings{'ERR_LANGUAGE'}/ERR_ACCESS_DISABLED")) ||
-                   (($proxysettings{'ERR_DESIGN'} eq 'squid') && (-e "$errordir/$proxysettings{'ERR_LANGUAGE'}/ERR_ACCESS_DISABLED")))
+               if (($proxysettings{'ERR_DESIGN'} eq 'squid') && (-e "$errordir/$proxysettings{'ERR_LANGUAGE'}/ERR_ACCESS_DISABLED"))
                {
                        print FILE "ERR_ACCESS_DISABLED";
                } else {
                        print FILE "ERR_ACCESS_DENIED";
                }
-               print FILE " IPCop_no_access_ips\n";
+               print FILE " IPFire_no_access_ips\n";
                print FILE "deny_info ";
-               if ((($proxysettings{'ERR_DESIGN'} eq 'ipcop') && (-e "$errordir.ipcop/$proxysettings{'ERR_LANGUAGE'}/ERR_ACCESS_DISABLED")) ||
-                   (($proxysettings{'ERR_DESIGN'} eq 'squid') && (-e "$errordir/$proxysettings{'ERR_LANGUAGE'}/ERR_ACCESS_DISABLED")))
+               if (($proxysettings{'ERR_DESIGN'} eq 'squid') && (-e "$errordir/$proxysettings{'ERR_LANGUAGE'}/ERR_ACCESS_DISABLED"))
                {
                        print FILE "ERR_ACCESS_DISABLED";
                } else {
                        print FILE "ERR_ACCESS_DENIED";
                }
-               print FILE " IPCop_no_access_mac\n";
+               print FILE " IPFire_no_access_mac\n";
 
                print FILE <<END
-http_access deny IPCop_no_access_ips
-http_access deny IPCop_no_access_mac
+http_access deny IPFire_no_access_ips
+http_access deny IPFire_no_access_mac
 END
        ;
        }
@@ -3165,22 +3393,22 @@ END
        my $blue_net = ''; #BLUE empty by default
        my $blue_ip = '';
        if ($netsettings{'BLUE_DEV'} && $proxysettings{'ENABLE_BLUE'} eq 'on') {
-               $blue_net = "$netsettings{'BLUE_NETADDRESS'}/$netsettings{'BLUE_NETMASK'}";
+               $blue_net = "$blue_cidr";
                $blue_ip  = "$netsettings{'BLUE_ADDRESS'}";
        }
        if (!-z $acl_include)
        {
                open (ACL, "$acl_include");
-               print FILE "\n#Start of custom includes\n";
+               print FILE "\n#Start of custom includes\n\n";
                while (<ACL>) {
                        $_ =~ s/__GREEN_IP__/$netsettings{'GREEN_ADDRESS'}/;
-                       $_ =~ s/__GREEN_NET__/$netsettings{'GREEN_NETADDRESS'}\/$netsettings{'GREEN_NETMASK'}/;
+                       $_ =~ s/__GREEN_NET__/$green_cidr/;
                        $_ =~ s/__BLUE_IP__/$blue_ip/;
                        $_ =~ s/__BLUE_NET__/$blue_net/;
                        $_ =~ s/__PROXY_PORT__/$proxysettings{'PROXY_PORT'}/;
                        print FILE $_;
                }
-               print FILE "#End of custom includes\n";
+               print FILE "\n#End of custom includes\n";
                close (ACL);
        }
        if ((!-z $extgrp) && ($proxysettings{'AUTH_METHOD'} eq 'ncsa') && ($proxysettings{'NCSA_BYPASS_REDIR'} eq 'on')) { print FILE "\nredirector_access deny for_extended_users\n"; }
@@ -3191,8 +3419,8 @@ END
 http_access allow         localhost
 
 #GUI admin if local machine connects
-http_access allow         IPCop_ips IPCop_networks IPCop_http
-http_access allow CONNECT IPCop_ips IPCop_networks IPCop_https
+http_access allow         IPFire_ips IPFire_networks IPFire_http
+http_access allow CONNECT IPFire_ips IPFire_networks IPFire_https
 
 #Deny not web services
 http_access deny          !Safe_ports
@@ -3272,14 +3500,14 @@ if ($delaypools) {
                print FILE "\n";
        }
 
-       print FILE "delay_access 1 deny  IPCop_ips\n";
-       if (!-z $acl_src_unrestricted_ip)  { print FILE "delay_access 1 deny  IPCop_unrestricted_ips\n"; }
-       if (!-z $acl_src_unrestricted_mac) { print FILE "delay_access 1 deny  IPCop_unrestricted_mac\n"; }
+       print FILE "delay_access 1 deny  IPFire_ips\n";
+       if (!-z $acl_src_unrestricted_ip)  { print FILE "delay_access 1 deny  IPFire_unrestricted_ips\n"; }
+       if (!-z $acl_src_unrestricted_mac) { print FILE "delay_access 1 deny  IPFire_unrestricted_mac\n"; }
        if (($proxysettings{'AUTH_METHOD'} eq 'ncsa') && (!-z $extgrp)) { print FILE "delay_access 1 deny  for_extended_users\n"; }
 
        if ($netsettings{'BLUE_DEV'})
        {
-               print FILE "delay_access 1 allow IPCop_green_network";
+               print FILE "delay_access 1 allow IPFire_green_network";
                if (!-z $acl_dst_throttle) { print FILE " for_throttled_urls"; }
                print FILE "\n";
                print FILE "delay_access 1 deny  all\n";
@@ -3291,43 +3519,84 @@ if ($delaypools) {
 
        if ($netsettings{'BLUE_DEV'})
        {
-               print FILE "delay_access 2 deny  IPCop_ips\n";
-               if (!-z $acl_src_unrestricted_ip)  { print FILE "delay_access 2 deny  IPCop_unrestricted_ips\n"; }
-               if (!-z $acl_src_unrestricted_mac) { print FILE "delay_access 2 deny  IPCop_unrestricted_mac\n"; }
+               print FILE "delay_access 2 deny  IPFire_ips\n";
+               if (!-z $acl_src_unrestricted_ip)  { print FILE "delay_access 2 deny  IPFire_unrestricted_ips\n"; }
+               if (!-z $acl_src_unrestricted_mac) { print FILE "delay_access 2 deny  IPFire_unrestricted_mac\n"; }
                if (($proxysettings{'AUTH_METHOD'} eq 'ncsa') && (!-z $extgrp)) { print FILE "delay_access 2 deny  for_extended_users\n"; }
-               print FILE "delay_access 2 allow IPCop_blue_network";
+               print FILE "delay_access 2 allow IPFire_blue_network";
                if (!-z $acl_dst_throttle) { print FILE " for_throttled_urls"; }
                print FILE "\n";
                print FILE "delay_access 2 deny  all\n";
        }
 
-       print FILE "delay_initial_bucket_level 100%\n"; 
+       print FILE "delay_initial_bucket_level 100\n";
        print FILE "\n";
 }
+
+if ($proxysettings{'NO_PROXY_LOCAL'} eq 'on')
+{
+       print FILE "#Prevent internal proxy access to Green\n";
+       print FILE "http_access deny IPFire_green_servers !IPFire_green_network\n\n";
+}
+
+if ($proxysettings{'NO_PROXY_LOCAL_BLUE'} eq 'on')
+{
+       print FILE "#Prevent internal proxy access from Blue\n";
+       print FILE "http_access allow IPFire_blue_network IPFire_blue_servers\n";
+       print FILE "http_access deny  IPFire_blue_network IPFire_servers\n\n";
+}
+
        print FILE <<END
 #Set custom configured ACLs
 END
        ;
-       if (!-z $acl_src_banned_ip) { print FILE "http_access deny  IPCop_banned_ips\n"; }
-       if (!-z $acl_src_banned_mac) { print FILE "http_access deny  IPCop_banned_mac\n"; }
+       if (!-z $acl_src_banned_ip) { print FILE "http_access deny  IPFire_banned_ips\n"; }
+       if (!-z $acl_src_banned_mac) { print FILE "http_access deny  IPFire_banned_mac\n"; }
 
        if ((!-z $acl_dst_noauth) && (!($proxysettings{'AUTH_METHOD'} eq 'none')))
        {
                if (!-z $acl_src_unrestricted_ip)
                {
-                       print FILE "http_access allow IPCop_unrestricted_ips to_domains_without_auth\n";
+                       if (!-z $acl_dst_noauth_net) { print FILE "http_access allow IPFire_unrestricted_ips to_ipaddr_without_auth\n"; }
+                       if (!-z $acl_dst_noauth_dom) { print FILE "http_access allow IPFire_unrestricted_ips to_domains_without_auth\n"; }
+                       if (!-z $acl_dst_noauth_url) { print FILE "http_access allow IPFire_unrestricted_ips to_hosts_without_auth\n"; }
                }
                if (!-z $acl_src_unrestricted_mac)
                {
-                       print FILE "http_access allow IPCop_unrestricted_mac to_domains_without_auth\n";
+                       if (!-z $acl_dst_noauth_net) { print FILE "http_access allow IPFire_unrestricted_mac to_ipaddr_without_auth\n"; }
+                       if (!-z $acl_dst_noauth_dom) { print FILE "http_access allow IPFire_unrestricted_mac to_domains_without_auth\n"; }
+                       if (!-z $acl_dst_noauth_url) { print FILE "http_access allow IPFire_unrestricted_mac to_hosts_without_auth\n"; }
+               }
+               if (!-z $acl_dst_noauth_net)
+               {
+                       print FILE "http_access allow IPFire_networks";
+                       if ($proxysettings{'TIME_ACCESS_MODE'} eq 'deny') {
+                               print FILE " !within_timeframe";
+                       } else {
+                               print FILE " within_timeframe"; }
+                       if ($proxysettings{'ENABLE_BROWSER_CHECK'} eq 'on') { print FILE " with_allowed_useragents"; }
+                       print FILE " to_ipaddr_without_auth\n";
+               }
+               if (!-z $acl_dst_noauth_dom)
+               {
+                       print FILE "http_access allow IPFire_networks";
+                       if ($proxysettings{'TIME_ACCESS_MODE'} eq 'deny') {
+                               print FILE " !within_timeframe";
+                       } else {
+                               print FILE " within_timeframe"; }
+                       if ($proxysettings{'ENABLE_BROWSER_CHECK'} eq 'on') { print FILE " with_allowed_useragents"; }
+                       print FILE " to_domains_without_auth\n";
+               }
+               if (!-z $acl_dst_noauth_url)
+               {
+                       print FILE "http_access allow IPFire_networks";
+                       if ($proxysettings{'TIME_ACCESS_MODE'} eq 'deny') {
+                               print FILE " !within_timeframe";
+                       } else {
+                               print FILE " within_timeframe"; }
+                       if ($proxysettings{'ENABLE_BROWSER_CHECK'} eq 'on') { print FILE " with_allowed_useragents"; }
+                       print FILE " to_hosts_without_auth\n";
                }
-               print FILE "http_access allow IPCop_networks";
-               if ($proxysettings{'TIME_ACCESS_MODE'} eq 'deny') {
-                       print FILE " !within_timeframe";
-               } else {
-                       print FILE " within_timeframe"; }
-               if ($proxysettings{'ENABLE_BROWSER_CHECK'} eq 'on') { print FILE " with_allowed_useragents"; }
-               print FILE " to_domains_without_auth\n";
        }
 
        if (($proxysettings{'AUTH_METHOD'} eq 'ident') && ($proxysettings{'IDENT_REQUIRED'} eq 'on') && ($proxysettings{'AUTH_ALWAYS_REQUIRED'} eq 'on'))
@@ -3352,7 +3621,7 @@ END
 
        if (!-z $acl_src_unrestricted_ip)
        {
-               print FILE "http_access allow IPCop_unrestricted_ips";
+               print FILE "http_access allow IPFire_unrestricted_ips";
                if ($proxysettings{'AUTH_ALWAYS_REQUIRED'} eq 'on')
                {
                        if ($proxysettings{'AUTH_METHOD'} eq 'ncsa')
@@ -3366,7 +3635,7 @@ END
                        if (($proxysettings{'AUTH_METHOD'} eq 'ntlm') && ($proxysettings{'NTLM_ENABLE_INT_AUTH'} eq 'on'))
                        {
                                if ($proxysettings{'NTLM_ENABLE_ACL'} eq 'on')
-                               {       
+                               {
                                        if (($proxysettings{'NTLM_USER_ACL'} eq 'positive') && (!-z "$ntlmdir/msntauth.allowusers"))
                                        {
                                                print FILE " for_acl_users";
@@ -3397,7 +3666,7 @@ END
 
        if (!-z $acl_src_unrestricted_mac)
        {
-               print FILE "http_access allow IPCop_unrestricted_mac";
+               print FILE "http_access allow IPFire_unrestricted_mac";
                if ($proxysettings{'AUTH_ALWAYS_REQUIRED'} eq 'on')
                {
                        if ($proxysettings{'AUTH_METHOD'} eq 'ncsa')
@@ -3411,7 +3680,7 @@ END
                        if (($proxysettings{'AUTH_METHOD'} eq 'ntlm') && ($proxysettings{'NTLM_ENABLE_INT_AUTH'} eq 'on'))
                        {
                                if ($proxysettings{'NTLM_ENABLE_ACL'} eq 'on')
-                               {       
+                               {
                                        if (($proxysettings{'NTLM_USER_ACL'} eq 'positive') && (!-z "$ntlmdir/msntauth.allowusers"))
                                        {
                                                print FILE " for_acl_users";
@@ -3443,7 +3712,7 @@ END
        if ($proxysettings{'AUTH_METHOD'} eq 'ncsa')
        {
                if (!-z $disgrp) { print FILE "http_access deny  for_disabled_users\n"; }
-               if (!-z $extgrp) { print FILE "http_access allow IPCop_networks for_extended_users\n"; }
+               if (!-z $extgrp) { print FILE "http_access allow IPFire_networks for_extended_users\n"; }
        }
 
        if (
@@ -3487,7 +3756,7 @@ END
                print FILE " !on_ident_aware_hosts\n";
        }
 
-       print FILE "http_access allow IPCop_networks";
+       print FILE "http_access allow IPFire_networks";
        if (
            (
             ($proxysettings{'AUTH_METHOD'} eq 'ntlm') &&
@@ -3538,19 +3807,23 @@ END
 
                if ($proxysettings{'FORWARD_IPADDRESS'} eq 'off')
                {
-                       print FILE "header_access X-Forwarded-For deny all\n";
+                       print FILE "request_header_access X-Forwarded-For deny all\n";
+                       print FILE "reply_header_access X-Forwarded-For deny all\n";
                }
                if ($proxysettings{'FORWARD_VIA'} eq 'off')
                {
-                       print FILE "header_access Via deny all\n";
+                       print FILE "request_header_access Via deny all\n";
+                       print FILE "reply_header_access Via deny all\n";
                }
                if (!($proxysettings{'FAKE_USERAGENT'} eq ''))
                {
-                       print FILE "header_access User-Agent deny all\n";
+                       print FILE "request_header_access User-Agent deny all\n";
+                       print FILE "reply_header_access User-Agent deny all\n";
                }
                if (!($proxysettings{'FAKE_REFERER'} eq ''))
                {
-                       print FILE "header_access Referer deny all\n";
+                       print FILE "request_header_access Referer deny all\n";
+                       print FILE "reply_header_access Referer deny all\n";
                }
 
                print FILE "\n";
@@ -3572,8 +3845,8 @@ END
        if ($proxysettings{'SUPPRESS_VERSION'} eq 'on') { print FILE "httpd_suppress_version_string on\n\n" }
 
        if ((!-z $mimetypes) && ($proxysettings{'ENABLE_MIME_FILTER'} eq 'on')) {
-               if (!-z $acl_src_unrestricted_ip)  { print FILE "http_reply_access allow IPCop_unrestricted_ips\n"; }
-               if (!-z $acl_src_unrestricted_mac) { print FILE "http_reply_access allow IPCop_unrestricted_mac\n"; }
+               if (!-z $acl_src_unrestricted_ip)  { print FILE "http_reply_access allow IPFire_unrestricted_ips\n"; }
+               if (!-z $acl_src_unrestricted_mac) { print FILE "http_reply_access allow IPFire_unrestricted_mac\n"; }
                if ($proxysettings{'AUTH_METHOD'} eq 'ncsa')
                {
                        if (!-z $extgrp) { print FILE "http_reply_access allow for_extended_users\n"; }
@@ -3582,23 +3855,33 @@ END
                print FILE "http_reply_access allow all\n\n";
        }
 
-       print FILE <<END
+       if ($proxysettings{'CACHE_SIZE'} > 0)
+       {
+               print FILE <<END
 maximum_object_size $proxysettings{'MAX_SIZE'} KB
 minimum_object_size $proxysettings{'MIN_SIZE'} KB
 
+END
+               ;
+       } else { print FILE "cache deny all\n\n";       }
+
+       print FILE <<END
 request_body_max_size $proxysettings{'MAX_OUTGOING_SIZE'} KB
 END
        ;
-       $replybodymaxsize = 1024 * $proxysettings{'MAX_INCOMING_SIZE'};
        if ($proxysettings{'MAX_INCOMING_SIZE'} > 0) {
-               if (!-z $acl_src_unrestricted_ip) { print FILE "reply_body_max_size 0 allow IPCop_unrestricted_ips\n"; }
-               if (!-z $acl_src_unrestricted_mac) { print FILE "reply_body_max_size 0 allow IPCop_unrestricted_mac\n"; }
+               if (!-z $acl_src_unrestricted_ip) { print FILE "reply_body_max_size none IPFire_unrestricted_ips\n"; }
+               if (!-z $acl_src_unrestricted_mac) { print FILE "reply_body_max_size none IPFire_unrestricted_mac\n"; }
                if ($proxysettings{'AUTH_METHOD'} eq 'ncsa')
                {
-                       if (!-z $extgrp) { print FILE "reply_body_max_size 0 allow for_extended_users\n"; }
+                       if (!-z $extgrp) { print FILE "reply_body_max_size none for_extended_users\n"; }
                }
        }
-       print FILE "reply_body_max_size $replybodymaxsize allow all\n\n";
+       
+       if ( $proxysettings{'MAX_INCOMING_SIZE'} != '0' )
+       {
+               print FILE "reply_body_max_size $proxysettings{'MAX_INCOMING_SIZE'} KB all\n\n";
+       }
 
        print FILE "visible_hostname";
        if ($proxysettings{'VISIBLE_HOSTNAME'} eq '')
@@ -3608,7 +3891,11 @@ END
                print FILE " $proxysettings{'VISIBLE_HOSTNAME'}\n\n";
        }
 
-       if (!($proxysettings{'ADMIN_MAIL_ADDRESS'} eq '')) { print FILE "cache_mgr $proxysettings{'ADMIN_MAIL_ADDRESS'}\n\n"; }
+       if (!($proxysettings{'ADMIN_MAIL_ADDRESS'} eq '')) { print FILE "cache_mgr $proxysettings{'ADMIN_MAIL_ADDRESS'}\n"; }
+       if (!($proxysettings{'ADMIN_PASSWORD'} eq '')) { print FILE "cachemgr_passwd $proxysettings{'ADMIN_PASSWORD'} all\n"; }
+       print FILE "\n";
+
+       print FILE "max_filedescriptors $proxysettings{'FILEDESCRIPTORS'}\n\n";
 
        # Write the parent proxy info, if needed.
        if ($remotehost ne '')
@@ -3626,41 +3913,13 @@ END
                }
                elsif ($proxysettings{'FORWARD_USERNAME'} eq 'on') { print FILE " login=*:password"; }
 
-               print FILE "\nnever_direct allow all\n\n";
+               print FILE "\nalways_direct allow IPFire_ips\n";
+               print FILE "never_direct  allow all\n\n";
        }
-       if (($urlfilter_addon) && ($updaccel_addon) && ($proxysettings{'ENABLE_FILTER'} eq 'on') && ($proxysettings{'ENABLE_UPDXLRATOR'} eq 'on'))
+       if (($proxysettings{'ENABLE_FILTER'} eq 'on') || ($proxysettings{'ENABLE_UPDXLRATOR'} eq 'on') || ($proxysettings{'ENABLE_CLAMAV'} eq 'on'))
        {
                print FILE "url_rewrite_program /usr/sbin/redirect_wrapper\n";
-               if ($filtersettings{'CHILDREN'} > $updaccelsettings{'CHILDREN'})
-               {
-                       print FILE "url_rewrite_children $filtersettings{'CHILDREN'}\n\n";
-               } else {
-                       print FILE "url_rewrite_children $updaccelsettings{'CHILDREN'}\n\n";
-               }
-       } else
-       {
-               if ($urlfilter_addon) {
-                       if ($proxysettings{'ENABLE_FILTER'} eq 'on')
-                       {
-                               print FILE <<END
-url_rewrite_program /usr/bin/squidGuard
-url_rewrite_children $filtersettings{'CHILDREN'}
-
-END
-                               ;
-                       }
-               }
-               if ($updaccel_addon) {
-                       if ($proxysettings{'ENABLE_UPDXLRATOR'} eq 'on')
-                       {
-                               print FILE <<END
-url_rewrite_program /usr/sbin/updxlrator
-url_rewrite_children $updaccelsettings{'CHILDREN'}
-
-END
-                               ;
-                       }
-               }
+               print FILE "url_rewrite_children $proxysettings{'CHILDREN'}\n\n";
        }
        close FILE;
 }
@@ -3685,7 +3944,7 @@ sub adduser
                close(FILE);
        } else {
                &deluser($str_user);
-               system("/usr/bin/htpasswd -b $userdb $str_user $str_pass");
+               system("/usr/sbin/htpasswd -b $userdb $str_user $str_pass");
        }
 
        if ($str_group eq 'standard') { open(FILE, ">>$stdgrp");
@@ -3734,3 +3993,15 @@ sub deluser
 }
 
 # -------------------------------------------------------------------
+
+sub writecachemgr
+{
+       open(FILE, ">${General::swroot}/proxy/cachemgr.conf");
+       flock(FILE, 2);
+       print FILE "$netsettings{'GREEN_ADDRESS'}:$proxysettings{'PROXY_PORT'}\n";
+       print FILE "localhost";
+       close(FILE);
+  return;
+}
+
+# -------------------------------------------------------------------