]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - html/cgi-bin/proxy.cgi
Hardcode theme to ipfire
[ipfire-2.x.git] / html / cgi-bin / proxy.cgi
index 3139e51729091548bc3f1040b1e6bf980131d339..b6d71db84d6ce2c46d9ad0fad5bf2590cd171e06 100644 (file)
@@ -2,7 +2,7 @@
 ###############################################################################
 #                                                                             #
 # IPFire.org - A linux based firewall                                         #
-# Copyright (C) 2007-2013  IPFire Team  <info@ipfire.org>                     #
+# Copyright (C) 2007-2020  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        #
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
 #                                                                             #
 ###############################################################################
-#
-# (c) 2004-2009 marco.s - http://www.advproxy.net
-#
-# This code is distributed under the terms of the GPL
-#
-# $Id: advproxy.cgi,v 3.0.2 2009/02/04 00:00:00 marco.s Exp $
-#
 
 use strict;
 use Apache::Htpasswd;
@@ -37,6 +30,8 @@ require '/var/ipfire/general-functions.pl';
 require "${General::swroot}/lang.pl";
 require "${General::swroot}/header.pl";
 
+require "${General::swroot}/ids-functions.pl";
+
 my @squidversion = `/usr/sbin/squid -v`;
 my $http_port='81';
 my $https_port='444';
@@ -44,7 +39,7 @@ 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);
+&General::readhash("/srv/web/ipfire/html/themes/ipfire/include/colors.txt", \%color);
 
 my %proxysettings=();
 my %netsettings=();
@@ -56,17 +51,11 @@ my %mainsettings=();
 my %checked=();
 my %selected=();
 
-my @throttle_limits=(64,128,256,384,512,768,1024,1280,1536,1792,2048,2560,3072,3584,4096,5120,6144,7168,8192,10240,12288,16384,20480);
-my $throttle_binary="7z|arj|bin|bz2|cab|exe|gz|lzh|rar|sea|tar|tgz|xz|zip";
-my $throttle_dskimg="b5t|bin|bwt|ccd|cdi|cue|gho|img|iso|mds|nrg|pqi|vmdk";
-my $throttle_mmedia="aiff?|asf|avi|divx|mov|mp3|mpe?g|ogg|qt|ra?m|ts|vob";
+my @throttle_limits=(64,128,256,512,1024,1536,2048,3072,4096,5120,6144,7168,8192,10240,16384,20480,51200,102400);
 
 my $def_ports_safe="80 # http\n21 # ftp\n443 # https\n563 # snews\n70 # gopher\n210 # wais\n1025-65535 # unregistered ports\n280 # http-mgmt\n488 # gss-http\n591 # filemaker\n777 # multiling http\n800 # Squids port (for icons)\n";
 my $def_ports_ssl="443 # https\n563 # snews\n";
 
-my @useragent=();
-my @useragentlist=();
-
 my $hintcolour='#FFFFCC';
 my $ncsa_buttontext='';
 my $language='';
@@ -98,7 +87,6 @@ my $stdgrp = "$ncsadir/standard.grp";
 my $extgrp = "$ncsadir/extended.grp";
 my $disgrp = "$ncsadir/disabled.grp";
 
-my $browserdb = "${General::swroot}/proxy/advanced/useragents";
 my $mimetypes = "${General::swroot}/proxy/advanced/mimetypes";
 my $throttled_urls = "${General::swroot}/proxy/advanced/throttle";
 
@@ -108,7 +96,7 @@ my $cre_svhosts = "${General::swroot}/proxy/advanced/cre/supervisors";
 
 my $identhosts = "$identdir/hosts";
 
-my $authdir  = "/usr/lib/squid/";
+my $authdir  = "/usr/lib/squid";
 my $errordir = "/usr/lib/squid/errors";
 
 my $acl_src_subnets = "$acldir/src_subnets.acl";
@@ -131,6 +119,9 @@ my $acl_ports_safe = "$acldir/ports_safe.acl";
 my $acl_ports_ssl  = "$acldir/ports_ssl.acl";
 my $acl_include = "$acldir/include.acl";
 
+my $acl_dst_noproxy_url = "$acldir/dst_noproxy_url.acl";
+my $acl_dst_noproxy_ip = "$acldir/dst_noproxy_ip.acl";
+
 my $updaccelversion  = 'n/a';
 my $urlfilterversion = 'n/a';
 
@@ -168,15 +159,10 @@ unless (-e $acl_ports_safe) { system("touch $acl_ports_safe"); }
 unless (-e $acl_ports_ssl)  { system("touch $acl_ports_ssl"); }
 unless (-e $acl_include) { system("touch $acl_include"); }
 
-unless (-e $browserdb) { system("touch $browserdb"); }
 unless (-e $mimetypes) { system("touch $mimetypes"); }
 
 my $HAVE_NTLM_AUTH = (-e "/usr/bin/ntlm_auth");
 
-open FILE, $browserdb;
-@useragentlist = sort { reverse(substr(reverse(substr($a,index($a,',')+1)),index(reverse(substr($a,index($a,','))),',')+1)) cmp reverse(substr(reverse(substr($b,index($b,',')+1)),index(reverse(substr($b,index($b,','))),',')+1))} grep !/(^$)|(^\s*#)/,<FILE>;
-close(FILE);
-
 &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
 
@@ -200,7 +186,7 @@ $proxysettings{'TRANSPARENT_PORT'} = '3128';
 $proxysettings{'VISIBLE_HOSTNAME'} = '';
 $proxysettings{'ADMIN_MAIL_ADDRESS'} = '';
 $proxysettings{'ADMIN_PASSWORD'} = '';
-$proxysettings{'ERR_LANGUAGE'} = 'German';
+$proxysettings{'ERR_LANGUAGE'} = 'en';
 $proxysettings{'ERR_DESIGN'} = 'ipfire';
 $proxysettings{'SUPPRESS_VERSION'} = 'off';
 $proxysettings{'FORWARD_VIA'} = 'off';
@@ -215,8 +201,8 @@ $proxysettings{'CACHEMGR'} = 'off';
 $proxysettings{'LOGQUERY'} = 'off';
 $proxysettings{'LOGUSERAGENT'} = 'off';
 $proxysettings{'FILEDESCRIPTORS'} = '16384';
-$proxysettings{'CACHE_MEM'} = '2';
-$proxysettings{'CACHE_SIZE'} = '50';
+$proxysettings{'CACHE_MEM'} = '128';
+$proxysettings{'CACHE_SIZE'} = '0';
 $proxysettings{'MAX_SIZE'} = '4096';
 $proxysettings{'MIN_SIZE'} = '0';
 $proxysettings{'MEM_POLICY'} = 'LRU';
@@ -239,11 +225,7 @@ $proxysettings{'THROTTLING_GREEN_TOTAL'} = 'unlimited';
 $proxysettings{'THROTTLING_GREEN_HOST'} = 'unlimited';
 $proxysettings{'THROTTLING_BLUE_TOTAL'} = 'unlimited';
 $proxysettings{'THROTTLING_BLUE_HOST'} = 'unlimited';
-$proxysettings{'THROTTLE_BINARY'} = 'off';
-$proxysettings{'THROTTLE_DSKIMG'} = 'off';
-$proxysettings{'THROTTLE_MMEDIA'} = 'off';
 $proxysettings{'ENABLE_MIME_FILTER'} = 'off';
-$proxysettings{'ENABLE_BROWSER_CHECK'} = 'off';
 $proxysettings{'FAKE_USERAGENT'} = '';
 $proxysettings{'FAKE_REFERER'} = '';
 $proxysettings{'AUTH_METHOD'} = 'none';
@@ -434,22 +416,6 @@ if (($proxysettings{'ACTION'} eq $Lang::tr{'save'}) || ($proxysettings{'ACTION'}
                $errormessage = $Lang::tr{'invalid maximum incoming size'};
                goto ERROR;
        }
-       if ($proxysettings{'ENABLE_BROWSER_CHECK'} eq 'on')
-       {
-               $browser_regexp = '';
-               foreach (@useragentlist)
-               {
-                       chomp;
-                       @useragent = split(/,/);
-                       if ($proxysettings{'UA_'.$useragent[0]} eq 'on') { $browser_regexp .= "$useragent[2]|"; }
-               }
-               chop($browser_regexp);
-               if (!$browser_regexp)
-               {
-                       $errormessage = $Lang::tr{'advproxy errmsg no browser'};
-                       goto ERROR;
-               }
-       }
        if (!($proxysettings{'AUTH_METHOD'} eq 'none'))
        {
                unless (($proxysettings{'AUTH_METHOD'} eq 'ident') &&
@@ -585,6 +551,29 @@ ERROR:
 
        if ($proxysettings{'VALID'} eq 'yes')
        {
+               # Determine if suricata may needs to be restarted.
+               my $suricata_proxy_ports_changed;
+
+               # Check if the IDS is running
+               if(&IDS::ids_is_running()) {
+                       my %oldproxysettings;
+
+                       # Read-in current proxy settings and store them as oldsettings hash.
+                       &General::readhash("${General::swroot}/proxy/advanced/settings", \%oldproxysettings);
+
+                       # Check if the proxy port has been changed.
+                       unless ($proxysettings{'PROXY_PORT'} eq $oldproxysettings{'PROXY_PORT'}) {
+                               # Port has changed, suricata needs to be adjusted.
+                               $suricata_proxy_ports_changed = 1;
+                       }
+
+                       # Check if the transparent port has been changed.
+                       unless ($proxysettings{'TRANSPARENT_PORT'} eq $oldproxysettings{'TRANSPARENT_PORT'}) {
+                               # Transparent port has changed, suricata needs to be adjusted.
+                               $suricata_proxy_ports_changed = 1;
+                       }
+               }
+
                &write_acls;
 
                delete $proxysettings{'SRC_SUBNETS'};
@@ -594,6 +583,8 @@ ERROR:
                delete $proxysettings{'SRC_UNRESTRICTED_MAC'};
                delete $proxysettings{'DST_NOCACHE'};
                delete $proxysettings{'DST_NOAUTH'};
+               delete $proxysettings{'DST_NOPROXY_IP'};
+               delete $proxysettings{'DST_NOPROXY_URL'};
                delete $proxysettings{'PORTS_SAFE'};
                delete $proxysettings{'PORTS_SSL'};
                delete $proxysettings{'MIME_TYPES'};
@@ -660,6 +651,15 @@ ERROR:
 
                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'); }
+
+               # Check if the suricata_proxy_ports_changed flag has been set.
+               if ($suricata_proxy_ports_changed) {
+                       # Re-generate HTTP ports file.
+                       &IDS::generate_http_ports_file();
+
+                       # Restart suricata.
+                       &IDS::call_suricatactrl("restart");
+               }
   }
 }
 
@@ -799,31 +799,10 @@ $selected{'THROTTLING_GREEN_HOST'}{$proxysettings{'THROTTLING_GREEN_HOST'}} = "s
 $selected{'THROTTLING_BLUE_TOTAL'}{$proxysettings{'THROTTLING_BLUE_TOTAL'}} = "selected='selected'";
 $selected{'THROTTLING_BLUE_HOST'}{$proxysettings{'THROTTLING_BLUE_HOST'}} = "selected='selected'";
 
-$checked{'THROTTLE_BINARY'}{'off'} = '';
-$checked{'THROTTLE_BINARY'}{'on'} = '';
-$checked{'THROTTLE_BINARY'}{$proxysettings{'THROTTLE_BINARY'}} = "checked='checked'";
-$checked{'THROTTLE_DSKIMG'}{'off'} = '';
-$checked{'THROTTLE_DSKIMG'}{'on'} = '';
-$checked{'THROTTLE_DSKIMG'}{$proxysettings{'THROTTLE_DSKIMG'}} = "checked='checked'";
-$checked{'THROTTLE_MMEDIA'}{'off'} = '';
-$checked{'THROTTLE_MMEDIA'}{'on'} = '';
-$checked{'THROTTLE_MMEDIA'}{$proxysettings{'THROTTLE_MMEDIA'}} = "checked='checked'";
-
 $checked{'ENABLE_MIME_FILTER'}{'off'} = '';
 $checked{'ENABLE_MIME_FILTER'}{'on'} = '';
 $checked{'ENABLE_MIME_FILTER'}{$proxysettings{'ENABLE_MIME_FILTER'}} = "checked='checked'";
 
-$checked{'ENABLE_BROWSER_CHECK'}{'off'} = '';
-$checked{'ENABLE_BROWSER_CHECK'}{'on'} = '';
-$checked{'ENABLE_BROWSER_CHECK'}{$proxysettings{'ENABLE_BROWSER_CHECK'}} = "checked='checked'";
-
-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{'AUTH_METHOD'}{'none'} = '';
 $checked{'AUTH_METHOD'}{'ncsa'} = '';
 $checked{'AUTH_METHOD'}{'ident'} = '';
@@ -1374,6 +1353,64 @@ END
 ;
 }
 
+# ===================================================================
+#  WPAD settings
+# ===================================================================
+
+print <<END
+<table width='100%'>
+<tr>
+       <td colspan='4'><b>$Lang::tr{'advproxy wpad title'}</b></td>
+</tr>
+<tr>
+       <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 wpad label dst_noproxy_ip'}:</td>
+       <td colspan='2' class='base'>$Lang::tr{'advproxy wpad label dst_noproxy_url'}:</td>
+</tr>
+<tr>
+       <td colspan='2'><textarea name='DST_NOPROXY_IP' cols='32' rows='3' wrap='off'>
+END
+;
+
+       print $proxysettings{'DST_NOPROXY_IP'};
+
+print <<END
+</textarea></td>
+
+       <td colspan='2'><textarea name='DST_NOPROXY_URL' cols='32' rows='3' wrap='off'>
+END
+;
+
+       print $proxysettings{'DST_NOPROXY_URL'};
+
+print <<END
+</textarea></td>
+</tr>
+<tr>
+       <td colspan='2' class='base'>$Lang::tr{'advproxy wpad example dst_noproxy_ip'}</td>
+       <td colspan='2' class='base'>$Lang::tr{'advproxy wpad example dst_noproxy_url'}</td>
+</tr>
+<tr>
+       <td colspan="4">&nbsp;</td>
+</tr>
+<tr>
+       <td colspan="4">$Lang::tr{'advproxy wpad view pac'}: <a href="http://$ENV{SERVER_ADDR}:81/wpad.dat" target="_blank">http://$ENV{SERVER_ADDR}:81/wpad.dat</a></td>
+</tr>
+<tr>
+       <td colspan="4">&nbsp;</td>
+</tr>
+<tr>
+       <td colspan="4">$Lang::tr{'advproxy wpad notice'}</td>
+</tr>
+</table>
+
+<hr size='1'>
+
+END
+;
+
 # -------------------------------------------------------------------
 
 print <<END
@@ -1489,7 +1526,15 @@ END
 ;
 
 foreach (@throttle_limits) {
-       print "\t<option value='$_' $selected{'THROTTLING_GREEN_TOTAL'}{$_}>$_ kbit/s</option>\n";
+       my $val = $_;
+       my $unit = "kbit/s";
+
+       if ($val >= 1024) {
+               $unit = "Mbit/s";
+               $val /= 1024;
+       }
+
+       print "\t<option value='$_' $selected{'THROTTLING_GREEN_TOTAL'}{$_}>$val $unit</option>\n";
 }
 
 print <<END
@@ -1552,21 +1597,6 @@ END
 
 print <<END
 </table>
-<table width='100%'>
-<tr>
-       <td colspan='4'><i>$Lang::tr{'advproxy content based throttling'}:</i></td>
-</tr>
-<tr>
-       <td width='15%' class='base'>$Lang::tr{'advproxy throttle binary'}:</td>
-       <td width='10%'><input type='checkbox' name='THROTTLE_BINARY' $checked{'THROTTLE_BINARY'}{'on'} /></td>
-       <td width='15%' class='base'>$Lang::tr{'advproxy throttle dskimg'}:</td>
-       <td width='10%'><input type='checkbox' name='THROTTLE_DSKIMG' $checked{'THROTTLE_DSKIMG'}{'on'} /></td>
-       <td width='15%' class='base'>$Lang::tr{'advproxy throttle mmedia'}:</td>
-       <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>
-</table>
 <hr size='1'>
 <table width='100%'>
 <tr>
@@ -1600,42 +1630,7 @@ print <<END
 </table>
 
 <hr size='1'>
-<table width='100%'>
-<tr>
-       <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
-;
-if (@useragentlist) { print "$Lang::tr{'advproxy allowed web browsers'}:"; } else { print "$Lang::tr{'advproxy no clients defined'}"; }
-print <<END
-</i></td>
-</tr>
-</table>
-<table width='100%'>
-END
-;
 
-for ($n=0; $n<=@useragentlist; $n = $n + $i) {
-       for ($i=0; $i<=3; $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";
-               }
-               if ($i eq 3) { print "<\/tr>\n"; }
-       }
-}
-}
-print <<END
-</table>
-<hr size='1'>
 <table width='100%'>
 <tr>
        <td><b>$Lang::tr{'advproxy privacy'}</b></td>
@@ -2365,6 +2360,18 @@ sub read_acls
                while (<FILE>) { $proxysettings{'DST_NOAUTH'} .= $_ };
                close(FILE);
        }
+       if (-e "$acl_dst_noproxy_ip") {
+               open(FILE,"$acl_dst_noproxy_ip");
+               delete $proxysettings{'DST_NOPROXY_IP'};
+               while (<FILE>) { $proxysettings{'DST_NOPROXY_IP'} .= $_ };
+               close(FILE);
+       }
+       if (-e "$acl_dst_noproxy_url") {
+               open(FILE,"$acl_dst_noproxy_url");
+               delete $proxysettings{'DST_NOPROXY_URL'};
+               while (<FILE>) { $proxysettings{'DST_NOPROXY_URL'} .= $_ };
+               close(FILE);
+       }
        if (-e "$acl_ports_safe") {
                open(FILE,"$acl_ports_safe");
                delete $proxysettings{'PORTS_SAFE'};
@@ -2550,6 +2557,31 @@ sub check_acls
                }
        }
 
+       @temp = split(/\n/,$proxysettings{'DST_NOPROXY_IP'});
+       undef $proxysettings{'DST_NOPROXY_IP'};
+       foreach (@temp)
+       {
+                       s/^\s+//g; s/\s+$//g;
+                       if ($_)
+                       {
+                                       unless (&General::validipormask($_)) { $errormessage = $Lang::tr{'advproxy errmsg wpad invalid ip or mask'}; }
+                                       $proxysettings{'DST_NOPROXY_IP'} .= $_."\n";
+                       }
+       }
+
+       @temp = split(/\n/,$proxysettings{'DST_NOPROXY_URL'});
+       undef $proxysettings{'DST_NOPROXY_URL'};
+       foreach (@temp)
+       {
+                       s/^\s+//g;
+                       unless (/^#/) { s/\s+//g; }
+                       if ($_)
+                       {
+                                       if (/^\./) { $_ = '*'.$_; }
+                                       $proxysettings{'DST_NOPROXY_URL'} .= $_."\n";
+                       }
+       }
+
        if (($proxysettings{'NTLM_ENABLE_ACL'} eq 'on') && ($proxysettings{'NTLM_USER_ACL'} eq 'positive'))
        {
                @temp = split(/\n/,$proxysettings{'NTLM_ALLOW_USERS'});
@@ -2688,6 +2720,16 @@ sub write_acls
        print FILE $proxysettings{'DST_NOAUTH'};
        close(FILE);
 
+       open(FILE, ">$acl_dst_noproxy_ip");
+       flock(FILE, 2);
+       print FILE $proxysettings{'DST_NOPROXY_IP'};
+       close(FILE);
+
+       open(FILE, ">$acl_dst_noproxy_url");
+       flock(FILE, 2);
+       print FILE $proxysettings{'DST_NOPROXY_URL'};
+       close(FILE);
+
        open(FILE, ">$acl_dst_noauth_net");
        close(FILE);
        open(FILE, ">$acl_dst_noauth_dom");
@@ -2791,23 +2833,6 @@ sub write_acls
        if (!$proxysettings{'PORTS_SSL'}) { print FILE $def_ports_ssl; } else { print FILE $proxysettings{'PORTS_SSL'}; }
        close(FILE);
 
-       open(FILE, ">$acl_dst_throttle");
-       flock(FILE, 2);
-       if ($proxysettings{'THROTTLE_BINARY'} eq 'on')
-       {
-               @temp = split(/\|/,$throttle_binary);
-               foreach (@temp) { print FILE "\\.$_\$\n"; }
-       }
-       if ($proxysettings{'THROTTLE_DSKIMG'} eq 'on')
-       {
-               @temp = split(/\|/,$throttle_dskimg);
-               foreach (@temp) { print FILE "\\.$_\$\n"; }
-       }
-       if ($proxysettings{'THROTTLE_MMEDIA'} eq 'on')
-       {
-               @temp = split(/\|/,$throttle_mmedia);
-               foreach (@temp) { print FILE "\\.$_\$\n"; }
-       }
        if (-s $throttled_urls)
        {
                open(URLFILE, $throttled_urls);
@@ -2862,6 +2887,10 @@ sub write_acls
 
 sub writepacfile
 {
+       my %vpnconfig=();
+       my %ovpnconfig=();
+       &General::readhasharray("${General::swroot}/vpn/config", \%vpnconfig);
+       &General::readhasharray("${General::swroot}/ovpn/ovpnconfig", \%ovpnconfig);
        open(FILE, ">/srv/web/ipfire/html/proxy.pac");
        flock(FILE, 2);
        print FILE "function FindProxyForURL(url, host)\n";
@@ -2887,6 +2916,64 @@ END
                print FILE "     (isInNet(host, \"$netsettings{'ORANGE_NETADDRESS'}\", \"$netsettings{'ORANGE_NETMASK'}\")) ||\n";
        }
 
+       # Additional exceptions for URLs
+       # The file has to be created by the user and should contain one entry per line
+       # Line-Format: <URL incl. wildcards>
+       # e.g. *.ipfire.org*
+       if (-s "$acl_dst_noproxy_url") {
+               undef @templist;
+
+               open(NOPROXY,"$acl_dst_noproxy_url");
+               @templist = <NOPROXY>;
+               close(NOPROXY);
+               chomp (@templist);
+
+               foreach (@templist)
+               {
+                       print FILE "     (shExpMatch(url, \"$_\")) ||\n";
+               }
+       }
+
+       # Additional exceptions for Subnets
+       # The file has to be created by the user and should contain one entry per line
+       # Line-Format: <IP>/<SUBNET MASK>
+       # e.g. 192.168.0.0/255.255.255.0
+       if (-s "$acl_dst_noproxy_ip") {
+               undef @templist;
+
+               open(NOPROXY,"$acl_dst_noproxy_ip");
+               @templist = <NOPROXY>;
+               close(NOPROXY);
+               chomp (@templist);
+
+               foreach (@templist)
+               {
+                       @temp = split(/\//);
+                       print FILE "     (isInNet(host, \"$temp[0]\", \"$temp[1]\")) ||\n";
+               }
+       }
+
+       foreach my $key (sort { uc($vpnconfig{$a}[1]) cmp uc($vpnconfig{$b}[1]) } keys %vpnconfig) {
+               if ($vpnconfig{$key}[0] eq 'on' && $vpnconfig{$key}[3] ne 'host') {
+                       my @networks = split(/\|/, $vpnconfig{$key}[11]);
+                       foreach my $network (@networks) {
+                               my ($vpnip, $vpnsub) = split("/", $network);
+                               $vpnsub = &Network::convert_prefix2netmask($vpnsub) || $vpnsub;
+                               print FILE "     (isInNet(host, \"$vpnip\", \"$vpnsub\")) ||\n";
+                       }
+               }
+       }
+
+       foreach my $key (sort { uc($ovpnconfig{$a}[1]) cmp uc($ovpnconfig{$b}[1]) } keys %ovpnconfig) {
+               if ($ovpnconfig{$key}[0] eq 'on' && $ovpnconfig{$key}[3] ne 'host') {
+                       my @networks = split(/\|/, $ovpnconfig{$key}[11]);
+                       foreach my $network (@networks) {
+                               my ($vpnip, $vpnsub) = split("/", $network);
+                               print FILE "     (isInNet(host, \"$vpnip\", \"$vpnsub\")) ||\n";
+                       }
+               }
+       }
+
        print FILE <<END
      (isInNet(host, "169.254.0.0", "255.255.0.0"))
    )
@@ -2917,7 +3004,8 @@ END
                                        )
                                {
                                        chomp $temp[1];
-                                       print FILE " ||\n     (isInNet(myIpAddress(), \"$temp[0]\", \"$temp[1]\"))";
+                                       my $tempmask = &Network::convert_prefix2netmask($temp[1]);
+                                       print FILE " ||\n     (isInNet(myIpAddress(), \"$temp[0]\", \"$tempmask\"))";
                                }
                        }
 
@@ -3248,6 +3336,7 @@ END
                        print FILE "\n";
 
                        print FILE "auth_param ntlm children $proxysettings{'AUTH_CHILDREN'}\n\n";
+                       print FILE "auth_param ntlm credentialsttl $proxysettings{'AUTH_CACHE_TTL'} minutes\n\n";
 
                        # BASIC authentication
                        if ($proxysettings{'NTLM_AUTH_BASIC'} eq "on") {
@@ -3259,9 +3348,9 @@ END
                                        print FILE " --require-membership-of=$ntlm_auth_group";
                                }
                                print FILE "\n";
-                               print FILE "auth_param basic children 10\n";
-                               print FILE "auth_param basic realm IPFire Web Proxy Server\n";
-                               print FILE "auth_param basic credentialsttl 2 hours\n\n";
+                               print FILE "auth_param basic children $proxysettings{'AUTH_CHILDREN'}\n";
+                               print FILE "auth_param basic realm $authrealm\n";
+                               print FILE "auth_param basic credentialsttl $proxysettings{'AUTH_CACHE_TTL'} minutes\n\n";
                        }
                }
 
@@ -3330,8 +3419,6 @@ END
 
        if (($delaypools) && (!-z $acl_dst_throttle)) { print FILE "acl for_throttled_urls url_regex -i \"$acl_dst_throttle\"\n\n"; }
 
-       if ($proxysettings{'ENABLE_BROWSER_CHECK'} eq 'on') { print FILE "acl with_allowed_useragents browser $browser_regexp\n\n"; }
-
        print FILE "acl within_timeframe time ";
        if ($proxysettings{'TIME_MON'} eq 'on') { print FILE "M"; }
        if ($proxysettings{'TIME_TUE'} eq 'on') { print FILE "T"; }
@@ -3582,7 +3669,6 @@ END
                                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)
@@ -3592,7 +3678,6 @@ END
                                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)
@@ -3602,7 +3687,6 @@ END
                                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";
                }
        }
@@ -3724,7 +3808,6 @@ END
                        print FILE " !within_timeframe";
                } else {
                        print FILE " within_timeframe"; }
-               if ($proxysettings{'ENABLE_BROWSER_CHECK'} eq 'on') { print FILE " with_allowed_useragents"; }
                print FILE " !on_ident_aware_hosts\n";
        }
 
@@ -3759,7 +3842,6 @@ END
                print FILE " !within_timeframe";
        } else {
                print FILE " within_timeframe"; }
-       if ($proxysettings{'ENABLE_BROWSER_CHECK'} eq 'on') { print FILE " with_allowed_useragents"; }
        print FILE "\n";
 
        print FILE "http_access deny  all\n\n";
@@ -3901,7 +3983,13 @@ sub adduser
        } else {
                &deluser($str_user);
 
-               my $htpasswd = new Apache::Htpasswd("$userdb");
+               my %htpasswd_options = (
+                       passwdFile => "$userdb",
+                       UseMD5 => 1,
+               );
+
+               my $htpasswd = new Apache::Htpasswd(\%htpasswd_options);
+
                $htpasswd->htpasswd($str_user, $str_pass);
        }