squid / WPAD: Add GUI for exception-files for generation of proxy.pac
[ipfire-2.x.git] / html / cgi-bin / proxy.cgi
1 #!/usr/bin/perl
2 ###############################################################################
3 #                                                                             #
4 # IPFire.org - A linux based firewall                                         #
5 # Copyright (C) 2007-2013  IPFire Team  <info@ipfire.org>                     #
6 #                                                                             #
7 # This program is free software: you can redistribute it and/or modify        #
8 # it under the terms of the GNU General Public License as published by        #
9 # the Free Software Foundation, either version 3 of the License, or           #
10 # (at your option) any later version.                                         #
11 #                                                                             #
12 # This program is distributed in the hope that it will be useful,             #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of              #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
15 # GNU General Public License for more details.                                #
16 #                                                                             #
17 # You should have received a copy of the GNU General Public License           #
18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
19 #                                                                             #
20 ###############################################################################
21 #
22 # (c) 2004-2009 marco.s - http://www.advproxy.net
23 #
24 # This code is distributed under the terms of the GPL
25 #
26 # $Id: advproxy.cgi,v 3.0.2 2009/02/04 00:00:00 marco.s Exp $
27 #
28
29 use strict;
30 use Apache::Htpasswd;
31
32 # enable only the following on debugging purpose
33 #use warnings;
34 #use CGI::Carp 'fatalsToBrowser';
35
36 require '/var/ipfire/general-functions.pl';
37 require "${General::swroot}/lang.pl";
38 require "${General::swroot}/header.pl";
39
40 my @squidversion = `/usr/sbin/squid -v`;
41 my $http_port='81';
42 my $https_port='444';
43
44 my %color = ();
45 my %mainsettings = ();
46 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
47 &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
48
49 my %proxysettings=();
50 my %netsettings=();
51 my %filtersettings=();
52 my %xlratorsettings=();
53 my %stdproxysettings=();
54 my %mainsettings=();
55
56 my %checked=();
57 my %selected=();
58
59 my @throttle_limits=(64,128,256,512,1024,1536,2048,3072,4096,5120,6144,7168,8192,10240,16384,20480,51200,102400);
60
61 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";
62 my $def_ports_ssl="443 # https\n563 # snews\n";
63
64 my $hintcolour='#FFFFCC';
65 my $ncsa_buttontext='';
66 my $language='';
67 my $i=0;
68 my $n=0;
69 my $id=0;
70 my $line='';
71 my $user='';
72 my @userlist=();
73 my @grouplist=();
74 my @temp=();
75 my @templist=();
76
77 my $cachemem=0;
78 my $proxy1='';
79 my $proxy2='';
80 my $browser_regexp='';
81 my $needhup = 0;
82 my $errormessage='';
83
84 my $acldir   = "${General::swroot}/proxy/advanced/acls";
85 my $ncsadir  = "${General::swroot}/proxy/advanced/ncsa";
86 my $raddir   = "${General::swroot}/proxy/advanced/radius";
87 my $identdir = "${General::swroot}/proxy/advanced/ident";
88 my $credir   = "${General::swroot}/proxy/advanced/cre";
89
90 my $userdb = "$ncsadir/passwd";
91 my $stdgrp = "$ncsadir/standard.grp";
92 my $extgrp = "$ncsadir/extended.grp";
93 my $disgrp = "$ncsadir/disabled.grp";
94
95 my $mimetypes = "${General::swroot}/proxy/advanced/mimetypes";
96 my $throttled_urls = "${General::swroot}/proxy/advanced/throttle";
97
98 my $cre_enabled = "${General::swroot}/proxy/advanced/cre/enable";
99 my $cre_groups  = "${General::swroot}/proxy/advanced/cre/classrooms";
100 my $cre_svhosts = "${General::swroot}/proxy/advanced/cre/supervisors";
101
102 my $identhosts = "$identdir/hosts";
103
104 my $authdir  = "/usr/lib/squid";
105 my $errordir = "/usr/lib/squid/errors";
106
107 my $acl_src_subnets = "$acldir/src_subnets.acl";
108 my $acl_src_banned_ip  = "$acldir/src_banned_ip.acl";
109 my $acl_src_banned_mac = "$acldir/src_banned_mac.acl";
110 my $acl_src_unrestricted_ip  = "$acldir/src_unrestricted_ip.acl";
111 my $acl_src_unrestricted_mac = "$acldir/src_unrestricted_mac.acl";
112 my $acl_src_noaccess_ip  = "$acldir/src_noaccess_ip.acl";
113 my $acl_src_noaccess_mac = "$acldir/src_noaccess_mac.acl";
114 my $acl_dst_noauth   = "$acldir/dst_noauth.acl";
115 my $acl_dst_noauth_dom = "$acldir/dst_noauth_dom.acl";
116 my $acl_dst_noauth_net = "$acldir/dst_noauth_net.acl";
117 my $acl_dst_noauth_url = "$acldir/dst_noauth_url.acl";
118 my $acl_dst_nocache  = "$acldir/dst_nocache.acl";
119 my $acl_dst_nocache_dom = "$acldir/dst_nocache_dom.acl";
120 my $acl_dst_nocache_net = "$acldir/dst_nocache_net.acl";
121 my $acl_dst_nocache_url = "$acldir/dst_nocache_url.acl";
122 my $acl_dst_throttle = "$acldir/dst_throttle.acl";
123 my $acl_ports_safe = "$acldir/ports_safe.acl";
124 my $acl_ports_ssl  = "$acldir/ports_ssl.acl";
125 my $acl_include = "$acldir/include.acl";
126
127 my $acl_dst_noproxy_url = "$acldir/dst_noproxy_url.acl";
128 my $acl_dst_noproxy_ip = "$acldir/dst_noproxy_ip.acl";
129
130 my $updaccelversion  = 'n/a';
131 my $urlfilterversion = 'n/a';
132
133 unless (-d "$acldir")   { mkdir("$acldir"); }
134 unless (-d "$ncsadir")  { mkdir("$ncsadir"); }
135 unless (-d "$raddir")   { mkdir("$raddir"); }
136 unless (-d "$identdir") { mkdir("$identdir"); }
137 unless (-d "$credir")   { mkdir("$credir"); }
138
139 unless (-e $cre_groups)  { system("touch $cre_groups"); }
140 unless (-e $cre_svhosts) { system("touch $cre_svhosts"); }
141
142 unless (-e $userdb) { system("touch $userdb"); }
143 unless (-e $stdgrp) { system("touch $stdgrp"); }
144 unless (-e $extgrp) { system("touch $extgrp"); }
145 unless (-e $disgrp) { system("touch $disgrp"); }
146
147 unless (-e $acl_src_subnets)    { system("touch $acl_src_subnets"); }
148 unless (-e $acl_src_banned_ip)  { system("touch $acl_src_banned_ip"); }
149 unless (-e $acl_src_banned_mac) { system("touch $acl_src_banned_mac"); }
150 unless (-e $acl_src_unrestricted_ip)  { system("touch $acl_src_unrestricted_ip"); }
151 unless (-e $acl_src_unrestricted_mac) { system("touch $acl_src_unrestricted_mac"); }
152 unless (-e $acl_src_noaccess_ip)  { system("touch $acl_src_noaccess_ip"); }
153 unless (-e $acl_src_noaccess_mac) { system("touch $acl_src_noaccess_mac"); }
154 unless (-e $acl_dst_noauth)     { system("touch $acl_dst_noauth"); }
155 unless (-e $acl_dst_noauth_dom) { system("touch $acl_dst_noauth_dom"); }
156 unless (-e $acl_dst_noauth_net) { system("touch $acl_dst_noauth_net"); }
157 unless (-e $acl_dst_noauth_url) { system("touch $acl_dst_noauth_url"); }
158 unless (-e $acl_dst_nocache)     { system("touch $acl_dst_nocache"); }
159 unless (-e $acl_dst_nocache_dom) { system("touch $acl_dst_nocache_dom"); }
160 unless (-e $acl_dst_nocache_net) { system("touch $acl_dst_nocache_net"); }
161 unless (-e $acl_dst_nocache_url) { system("touch $acl_dst_nocache_url"); }
162 unless (-e $acl_dst_throttle)  { system("touch $acl_dst_throttle"); }
163 unless (-e $acl_ports_safe) { system("touch $acl_ports_safe"); }
164 unless (-e $acl_ports_ssl)  { system("touch $acl_ports_ssl"); }
165 unless (-e $acl_include) { system("touch $acl_include"); }
166
167 unless (-e $mimetypes) { system("touch $mimetypes"); }
168
169 my $HAVE_NTLM_AUTH = (-e "/usr/bin/ntlm_auth");
170
171 &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
172 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
173
174 my $green_cidr = &General::ipcidr("$netsettings{'GREEN_NETADDRESS'}\/$netsettings{'GREEN_NETMASK'}");
175 my $blue_cidr = "";
176 if (&Header::blue_used() && $netsettings{'BLUE_DEV'}) {
177         $blue_cidr = &General::ipcidr("$netsettings{'BLUE_NETADDRESS'}\/$netsettings{'BLUE_NETMASK'}");
178 }
179
180 &Header::showhttpheaders();
181
182 $proxysettings{'ACTION'} = '';
183 $proxysettings{'VALID'} = '';
184
185 $proxysettings{'ENABLE'} = 'off';
186 $proxysettings{'ENABLE_BLUE'} = 'off';
187 $proxysettings{'TRANSPARENT'} = 'off';
188 $proxysettings{'TRANSPARENT_BLUE'} = 'off';
189 $proxysettings{'PROXY_PORT'} = '800';
190 $proxysettings{'TRANSPARENT_PORT'} = '3128';
191 $proxysettings{'VISIBLE_HOSTNAME'} = '';
192 $proxysettings{'ADMIN_MAIL_ADDRESS'} = '';
193 $proxysettings{'ADMIN_PASSWORD'} = '';
194 $proxysettings{'ERR_LANGUAGE'} = 'en';
195 $proxysettings{'ERR_DESIGN'} = 'ipfire';
196 $proxysettings{'SUPPRESS_VERSION'} = 'off';
197 $proxysettings{'FORWARD_VIA'} = 'off';
198 $proxysettings{'FORWARD_IPADDRESS'} = 'off';
199 $proxysettings{'FORWARD_USERNAME'} = 'off';
200 $proxysettings{'NO_CONNECTION_AUTH'} = 'off';
201 $proxysettings{'UPSTREAM_PROXY'} = '';
202 $proxysettings{'UPSTREAM_USER'} = '';
203 $proxysettings{'UPSTREAM_PASSWORD'} = '';
204 $proxysettings{'LOGGING'} = 'off';
205 $proxysettings{'CACHEMGR'} = 'off';
206 $proxysettings{'LOGQUERY'} = 'off';
207 $proxysettings{'LOGUSERAGENT'} = 'off';
208 $proxysettings{'FILEDESCRIPTORS'} = '16384';
209 $proxysettings{'CACHE_MEM'} = '128';
210 $proxysettings{'CACHE_SIZE'} = '0';
211 $proxysettings{'MAX_SIZE'} = '4096';
212 $proxysettings{'MIN_SIZE'} = '0';
213 $proxysettings{'MEM_POLICY'} = 'LRU';
214 $proxysettings{'CACHE_POLICY'} = 'LRU';
215 $proxysettings{'L1_DIRS'} = '16';
216 $proxysettings{'OFFLINE_MODE'} = 'off';
217 $proxysettings{'CACHE_DIGESTS'} = 'off';
218 $proxysettings{'CLASSROOM_EXT'} = 'off';
219 $proxysettings{'SUPERVISOR_PASSWORD'} = '';
220 $proxysettings{'NO_PROXY_LOCAL'} = 'off';
221 $proxysettings{'NO_PROXY_LOCAL_BLUE'} = 'off';
222 $proxysettings{'TIME_ACCESS_MODE'} = 'allow';
223 $proxysettings{'TIME_FROM_HOUR'} = '00';
224 $proxysettings{'TIME_FROM_MINUTE'} = '00';
225 $proxysettings{'TIME_TO_HOUR'} = '24';
226 $proxysettings{'TIME_TO_MINUTE'} = '00';
227 $proxysettings{'MAX_OUTGOING_SIZE'} = '0';
228 $proxysettings{'MAX_INCOMING_SIZE'} = '0';
229 $proxysettings{'THROTTLING_GREEN_TOTAL'} = 'unlimited';
230 $proxysettings{'THROTTLING_GREEN_HOST'} = 'unlimited';
231 $proxysettings{'THROTTLING_BLUE_TOTAL'} = 'unlimited';
232 $proxysettings{'THROTTLING_BLUE_HOST'} = 'unlimited';
233 $proxysettings{'ENABLE_MIME_FILTER'} = 'off';
234 $proxysettings{'FAKE_USERAGENT'} = '';
235 $proxysettings{'FAKE_REFERER'} = '';
236 $proxysettings{'AUTH_METHOD'} = 'none';
237 $proxysettings{'AUTH_REALM'} = '';
238 $proxysettings{'AUTH_MAX_USERIP'} = '';
239 $proxysettings{'AUTH_CACHE_TTL'} = '60';
240 $proxysettings{'AUTH_CHILDREN'} = '5';
241 $proxysettings{'NCSA_MIN_PASS_LEN'} = '6';
242 $proxysettings{'NCSA_BYPASS_REDIR'} = 'off';
243 $proxysettings{'NCSA_USERNAME'} = '';
244 $proxysettings{'NCSA_GROUP'} = '';
245 $proxysettings{'NCSA_PASS'} = '';
246 $proxysettings{'NCSA_PASS_CONFIRM'} = '';
247 $proxysettings{'LDAP_BASEDN'} = '';
248 $proxysettings{'LDAP_TYPE'} = 'ADS';
249 $proxysettings{'LDAP_SERVER'} = '';
250 $proxysettings{'LDAP_PORT'} = '389';
251 $proxysettings{'LDAP_BINDDN_USER'} = '';
252 $proxysettings{'LDAP_BINDDN_PASS'} = '';
253 $proxysettings{'LDAP_GROUP'} = '';
254 $proxysettings{'NTLM_AUTH_GROUP'} = '';
255 $proxysettings{'NTLM_AUTH_BASIC'} = 'off';
256 $proxysettings{'NTLM_DOMAIN'} = '';
257 $proxysettings{'NTLM_PDC'} = '';
258 $proxysettings{'NTLM_BDC'} = '';
259 $proxysettings{'NTLM_ENABLE_ACL'} = 'off';
260 $proxysettings{'NTLM_USER_ACL'} = 'positive';
261 $proxysettings{'RADIUS_SERVER'} = '';
262 $proxysettings{'RADIUS_PORT'} = '1812';
263 $proxysettings{'RADIUS_IDENTIFIER'} = '';
264 $proxysettings{'RADIUS_SECRET'} = '';
265 $proxysettings{'RADIUS_ENABLE_ACL'} = 'off';
266 $proxysettings{'RADIUS_USER_ACL'} = 'positive';
267 $proxysettings{'IDENT_REQUIRED'} = 'off';
268 $proxysettings{'IDENT_TIMEOUT'} = '10';
269 $proxysettings{'IDENT_ENABLE_ACL'} = 'off';
270 $proxysettings{'IDENT_USER_ACL'} = 'positive';
271 $proxysettings{'ENABLE_FILTER'} = 'off';
272 $proxysettings{'ENABLE_UPDXLRATOR'} = 'off';
273 $proxysettings{'ENABLE_CLAMAV'} = 'off';
274
275 $ncsa_buttontext = $Lang::tr{'advproxy NCSA create user'};
276
277 &Header::getcgihash(\%proxysettings);
278
279 if ($proxysettings{'THROTTLING_GREEN_TOTAL'} eq 0) {$proxysettings{'THROTTLING_GREEN_TOTAL'} = 'unlimited';}
280 if ($proxysettings{'THROTTLING_GREEN_HOST'}  eq 0) {$proxysettings{'THROTTLING_GREEN_HOST'}  = 'unlimited';}
281 if ($proxysettings{'THROTTLING_BLUE_TOTAL'}  eq 0) {$proxysettings{'THROTTLING_BLUE_TOTAL'}  = 'unlimited';}
282 if ($proxysettings{'THROTTLING_BLUE_HOST'}   eq 0) {$proxysettings{'THROTTLING_BLUE_HOST'}   = 'unlimited';}
283
284 if ($proxysettings{'ACTION'} eq $Lang::tr{'advproxy NCSA user management'})
285 {
286         $proxysettings{'NCSA_EDIT_MODE'} = 'yes';
287 }
288
289 if ($proxysettings{'ACTION'} eq $Lang::tr{'add'})
290 {
291         $proxysettings{'NCSA_EDIT_MODE'} = 'yes';
292         if (length($proxysettings{'NCSA_PASS'}) < $proxysettings{'NCSA_MIN_PASS_LEN'}) {
293                 $errormessage = $Lang::tr{'advproxy errmsg password length 1'}.$proxysettings{'NCSA_MIN_PASS_LEN'}.$Lang::tr{'advproxy errmsg password length 2'};
294         }
295         if (!($proxysettings{'NCSA_PASS'} eq $proxysettings{'NCSA_PASS_CONFIRM'})) {
296                 $errormessage = $Lang::tr{'advproxy errmsg passwords different'};
297         }
298         if ($proxysettings{'NCSA_USERNAME'} eq '') {
299                 $errormessage = $Lang::tr{'advproxy errmsg no username'};
300         }
301         if (!$errormessage) {
302                 $proxysettings{'NCSA_USERNAME'} =~ tr/A-Z/a-z/;
303                 &adduser($proxysettings{'NCSA_USERNAME'}, $proxysettings{'NCSA_PASS'}, $proxysettings{'NCSA_GROUP'});
304         }
305         $proxysettings{'NCSA_USERNAME'} = '';
306         $proxysettings{'NCSA_GROUP'} = '';
307         $proxysettings{'NCSA_PASS'} = '';
308         $proxysettings{'NCSA_PASS_CONFIRM'} = '';
309 }
310
311 if ($proxysettings{'ACTION'} eq $Lang::tr{'remove'})
312 {
313         $proxysettings{'NCSA_EDIT_MODE'} = 'yes';
314         &deluser($proxysettings{'ID'});
315 }
316
317 $checked{'ENABLE_UPDXLRATOR'}{'off'} = '';
318 $checked{'ENABLE_UPDXLRATOR'}{'on'} = '';
319 $checked{'ENABLE_UPDXLRATOR'}{$proxysettings{'ENABLE_UPDXLRATOR'}} = "checked='checked'";
320
321 if ($proxysettings{'ACTION'} eq $Lang::tr{'edit'})
322 {
323         $proxysettings{'NCSA_EDIT_MODE'} = 'yes';
324         $ncsa_buttontext = $Lang::tr{'advproxy NCSA update user'};
325         @temp = split(/:/,$proxysettings{'ID'});
326         $proxysettings{'NCSA_USERNAME'} = $temp[0];
327         $proxysettings{'NCSA_GROUP'} = $temp[1];
328         $proxysettings{'NCSA_PASS'} = "lEaVeAlOnE";
329         $proxysettings{'NCSA_PASS_CONFIRM'} = $proxysettings{'NCSA_PASS'};
330 }
331
332 if (($proxysettings{'ACTION'} eq $Lang::tr{'save'}) || ($proxysettings{'ACTION'} eq $Lang::tr{'advproxy save and restart'}) || ($proxysettings{'ACTION'} eq $Lang::tr{'proxy reconfigure'}))
333 {
334         if ($proxysettings{'ENABLE'} !~ /^(on|off)$/ ||
335             $proxysettings{'TRANSPARENT'} !~ /^(on|off)$/ ||
336             $proxysettings{'ENABLE_BLUE'} !~ /^(on|off)$/ ||
337             $proxysettings{'TRANSPARENT_BLUE'} !~ /^(on|off)$/ ) {
338                 $errormessage = $Lang::tr{'invalid input'};
339                 goto ERROR;
340         }
341         if($proxysettings{'CACHE_MEM'} > $proxysettings{'CACHE_SIZE'} && $proxysettings{'CACHE_SIZE'} > 0){
342                 $errormessage = $Lang::tr{'advproxy errmsg cache'}." ".$proxysettings{'CACHE_MEM'}." > ".$proxysettings{'CACHE_SIZE'};
343                 goto ERROR;
344         }
345
346         if (!(&General::validport($proxysettings{'PROXY_PORT'})))
347         {
348                 $errormessage = $Lang::tr{'advproxy errmsg invalid proxy port'};
349                 goto ERROR;
350         }
351         if (!(&General::validport($proxysettings{'TRANSPARENT_PORT'})))
352         {
353                 $errormessage = $Lang::tr{'advproxy errmsg invalid proxy port'};
354                 goto ERROR;
355         }
356         if ($proxysettings{'PROXY_PORT'} eq $proxysettings{'TRANSPARENT_PORT'}) {
357                 $errormessage = $Lang::tr{'advproxy errmsg proxy ports equal'};
358                 goto ERROR;
359         }
360         if (!($proxysettings{'UPSTREAM_PROXY'} eq ''))
361         {
362                 my @temp = split(/:/,$proxysettings{'UPSTREAM_PROXY'});
363                 if (!(&General::validip($temp[0])))
364                 {
365                         if (!(&General::validdomainname($temp[0])))
366                         {
367                                 $errormessage = $Lang::tr{'advproxy errmsg invalid upstream proxy'};
368                                 goto ERROR;
369                         }
370                 }
371         }
372         if (!($proxysettings{'CACHE_SIZE'} =~ /^\d+/) ||
373                 ($proxysettings{'CACHE_SIZE'} < 10))
374         {
375                 if (!($proxysettings{'CACHE_SIZE'} eq '0'))
376                 {
377                         $errormessage = $Lang::tr{'advproxy errmsg hdd cache size'};
378                         goto ERROR;
379                 }
380         }
381         if (!($proxysettings{'FILEDESCRIPTORS'} =~ /^\d+/) ||
382                 ($proxysettings{'FILEDESCRIPTORS'} < 1) || ($proxysettings{'FILEDESCRIPTORS'} > 1048576))
383         {
384                 $errormessage = $Lang::tr{'proxy errmsg filedescriptors'};
385                 goto ERROR;
386         }
387         if (!($proxysettings{'CACHE_MEM'} =~ /^\d+/))
388         {
389                 $errormessage = $Lang::tr{'advproxy errmsg mem cache size'};
390                 goto ERROR;
391         }
392         my @free = `/usr/bin/free`;
393         $free[1] =~ m/(\d+)/;
394         $cachemem = int $1 / 2048;
395         if ($proxysettings{'CACHE_MEM'} > $cachemem) {
396                 $proxysettings{'CACHE_MEM'} = $cachemem;
397         }
398         if (!($proxysettings{'MAX_SIZE'} =~ /^\d+/))
399         {
400                 $errormessage = $Lang::tr{'invalid maximum object size'};
401                 goto ERROR;
402         }
403         if (!($proxysettings{'MIN_SIZE'} =~ /^\d+/))
404         {
405                 $errormessage = $Lang::tr{'invalid minimum object size'};
406                 goto ERROR;
407         }
408         if (!($proxysettings{'MAX_OUTGOING_SIZE'} =~ /^\d+/))
409         {
410                 $errormessage = $Lang::tr{'invalid maximum outgoing size'};
411                 goto ERROR;
412         }
413         if (!($proxysettings{'TIME_TO_HOUR'}.$proxysettings{'TIME_TO_MINUTE'} gt $proxysettings{'TIME_FROM_HOUR'}.$proxysettings{'TIME_FROM_MINUTE'}))
414         {
415                 $errormessage = $Lang::tr{'advproxy errmsg time restriction'};
416                 goto ERROR;
417         }
418         if (!($proxysettings{'MAX_INCOMING_SIZE'} =~ /^\d+/))
419         {
420                 $errormessage = $Lang::tr{'invalid maximum incoming size'};
421                 goto ERROR;
422         }
423         if (!($proxysettings{'AUTH_METHOD'} eq 'none'))
424         {
425                 unless (($proxysettings{'AUTH_METHOD'} eq 'ident') &&
426                         ($proxysettings{'IDENT_REQUIRED'} eq 'off') &&
427                         ($proxysettings{'IDENT_ENABLE_ACL'} eq 'off'))
428                 {
429                         if ($netsettings{'BLUE_DEV'})
430                         {
431                                 if ((($proxysettings{'ENABLE'} eq 'off') || ($proxysettings{'TRANSPARENT'} eq 'on')) &&
432                                         (($proxysettings{'ENABLE_BLUE'} eq 'off') || ($proxysettings{'TRANSPARENT_BLUE'} eq 'on')))
433                                 {
434                                         $errormessage = $Lang::tr{'advproxy errmsg non-transparent proxy required'};
435                                         goto ERROR;
436                                 }
437                         } else {
438                                 if (($proxysettings{'ENABLE'} eq 'off') || ($proxysettings{'TRANSPARENT'} eq 'on'))
439                                 {
440                                         $errormessage = $Lang::tr{'advproxy errmsg non-transparent proxy required'};
441                                         goto ERROR;
442                                 }
443                         }
444                 }
445                 if (!($proxysettings{'AUTH_CACHE_TTL'} =~ /^\d+/))
446                 {
447                         $errormessage = $Lang::tr{'advproxy errmsg auth cache ttl'};
448                         goto ERROR;
449                 }
450                 if ((!($proxysettings{'AUTH_MAX_USERIP'} eq '')) &&
451                         ((!($proxysettings{'AUTH_MAX_USERIP'} =~ /^\d+/)) || ($proxysettings{'AUTH_MAX_USERIP'} < 1) || ($proxysettings{'AUTH_MAX_USERIP'} > 255)))
452                 {
453                         $errormessage = $Lang::tr{'advproxy errmsg max userip'};
454                         goto ERROR;
455                 }
456                 if (!($proxysettings{'AUTH_MAX_USERIP'} eq ''))
457                 {
458                         $errormessage = $Lang::tr{'advproxy errmsg auth ipcache may not be null'};
459                         goto ERROR;
460                 }
461                 if ((!($proxysettings{'AUTH_CHILDREN'} =~ /^\d+/)) || ($proxysettings{'AUTH_CHILDREN'} < 1) || ($proxysettings{'AUTH_CHILDREN'} > 255))
462                 {
463                         $errormessage = $Lang::tr{'advproxy errmsg auth children'};
464                         goto ERROR;
465                 }
466         }
467         if ($proxysettings{'AUTH_METHOD'} eq 'ncsa')
468         {
469                 if ((!($proxysettings{'NCSA_MIN_PASS_LEN'} =~ /^\d+/)) || ($proxysettings{'NCSA_MIN_PASS_LEN'} < 1) || ($proxysettings{'NCSA_MIN_PASS_LEN'} > 255))
470                 {
471                         $errormessage = $Lang::tr{'advproxy errmsg password length'};
472                         goto ERROR;
473                 }
474         }
475         if ($proxysettings{'AUTH_METHOD'} eq 'ident')
476         {
477                 if ((!($proxysettings{'IDENT_TIMEOUT'} =~ /^\d+/)) || ($proxysettings{'IDENT_TIMEOUT'} < 1))
478                 {
479                         $errormessage = $Lang::tr{'advproxy errmsg ident timeout'};
480                         goto ERROR;
481                 }
482         }
483         if ($proxysettings{'AUTH_METHOD'} eq 'ldap')
484         {
485                 if ($proxysettings{'LDAP_BASEDN'} eq '')
486                 {
487                         $errormessage = $Lang::tr{'advproxy errmsg ldap base dn'};
488                         goto ERROR;
489                 }
490                 if (!&General::validip($proxysettings{'LDAP_SERVER'}))
491                 {
492                         if (!&General::validdomainname($proxysettings{'LDAP_SERVER'}))
493                         {
494                                 $errormessage = $Lang::tr{'advproxy errmsg ldap server'};
495                                 goto ERROR;
496                         }
497                 }
498                 if (!&General::validport($proxysettings{'LDAP_PORT'}))
499                 {
500                         $errormessage = $Lang::tr{'advproxy errmsg ldap port'};
501                         goto ERROR;
502                 }
503                 if (($proxysettings{'LDAP_TYPE'} eq 'ADS') || ($proxysettings{'LDAP_TYPE'} eq 'NDS'))
504                 {
505                         if (($proxysettings{'LDAP_BINDDN_USER'} eq '') || ($proxysettings{'LDAP_BINDDN_PASS'} eq ''))
506                         {
507                                 $errormessage = $Lang::tr{'advproxy errmsg ldap bind dn'};
508                                 goto ERROR;
509                         }
510                 }
511         }
512         if ($proxysettings{'AUTH_METHOD'} eq 'radius')
513         {
514                 if (!&General::validip($proxysettings{'RADIUS_SERVER'}))
515                 {
516                         $errormessage = $Lang::tr{'advproxy errmsg radius server'};
517                         goto ERROR;
518                 }
519                 if (!&General::validport($proxysettings{'RADIUS_PORT'}))
520                 {
521                         $errormessage = $Lang::tr{'advproxy errmsg radius port'};
522                         goto ERROR;
523                 }
524                 if ($proxysettings{'RADIUS_SECRET'} eq '')
525                 {
526                         $errormessage = $Lang::tr{'advproxy errmsg radius secret'};
527                         goto ERROR;
528                 }
529         }
530
531         # Quick parent proxy error checking of username and password info. If username password don't both exist give an error.
532         $proxy1 = 'YES';
533         $proxy2 = 'YES';
534         if (($proxysettings{'UPSTREAM_USER'} eq '')) {$proxy1 = '';}
535         if (($proxysettings{'UPSTREAM_PASSWORD'} eq '')) {$proxy2 = '';}
536         if ($proxysettings{'UPSTREAM_USER'} eq 'PASS')  {$proxy1=$proxy2='PASS'; $proxysettings{'UPSTREAM_PASSWORD'} = '';}
537         if (($proxy1 ne $proxy2))
538         {
539                 $errormessage = $Lang::tr{'advproxy errmsg invalid upstream proxy username or password setting'};
540                 goto ERROR;
541         }
542
543 ERROR:
544         &check_acls;
545
546         if ($errormessage) {
547                 $proxysettings{'VALID'} = 'no'; }
548         else {
549                 $proxysettings{'VALID'} = 'yes'; }
550
551         if ($proxysettings{'VALID'} eq 'yes')
552         {
553                 &write_acls;
554
555                 delete $proxysettings{'SRC_SUBNETS'};
556                 delete $proxysettings{'SRC_BANNED_IP'};
557                 delete $proxysettings{'SRC_BANNED_MAC'};
558                 delete $proxysettings{'SRC_UNRESTRICTED_IP'};
559                 delete $proxysettings{'SRC_UNRESTRICTED_MAC'};
560                 delete $proxysettings{'DST_NOCACHE'};
561                 delete $proxysettings{'DST_NOAUTH'};
562                 delete $proxysettings{'DST_NOPROXY_IP'};
563                 delete $proxysettings{'DST_NOPROXY_URL'};
564                 delete $proxysettings{'PORTS_SAFE'};
565                 delete $proxysettings{'PORTS_SSL'};
566                 delete $proxysettings{'MIME_TYPES'};
567                 delete $proxysettings{'NTLM_ALLOW_USERS'};
568                 delete $proxysettings{'NTLM_DENY_USERS'};
569                 delete $proxysettings{'RADIUS_ALLOW_USERS'};
570                 delete $proxysettings{'RADIUS_DENY_USERS'};
571                 delete $proxysettings{'IDENT_HOSTS'};
572                 delete $proxysettings{'IDENT_ALLOW_USERS'};
573                 delete $proxysettings{'IDENT_DENY_USERS'};
574
575                 delete $proxysettings{'CRE_GROUPS'};
576                 delete $proxysettings{'CRE_SVHOSTS'};
577
578                 delete $proxysettings{'NCSA_USERNAME'};
579                 delete $proxysettings{'NCSA_GROUP'};
580                 delete $proxysettings{'NCSA_PASS'};
581                 delete $proxysettings{'NCSA_PASS_CONFIRM'};
582
583                 $proxysettings{'TIME_MON'} = 'off' unless exists $proxysettings{'TIME_MON'};
584                 $proxysettings{'TIME_TUE'} = 'off' unless exists $proxysettings{'TIME_TUE'};
585                 $proxysettings{'TIME_WED'} = 'off' unless exists $proxysettings{'TIME_WED'};
586                 $proxysettings{'TIME_THU'} = 'off' unless exists $proxysettings{'TIME_THU'};
587                 $proxysettings{'TIME_FRI'} = 'off' unless exists $proxysettings{'TIME_FRI'};
588                 $proxysettings{'TIME_SAT'} = 'off' unless exists $proxysettings{'TIME_SAT'};
589                 $proxysettings{'TIME_SUN'} = 'off' unless exists $proxysettings{'TIME_SUN'};
590
591                 $proxysettings{'AUTH_ALWAYS_REQUIRED'} = 'off' unless exists $proxysettings{'AUTH_ALWAYS_REQUIRED'};
592                 $proxysettings{'NTLM_ENABLE_INT_AUTH'} = 'off' unless exists $proxysettings{'NTLM_ENABLE_INT_AUTH'};
593
594                 &General::writehash("${General::swroot}/proxy/advanced/settings", \%proxysettings);
595
596                 if (-e "${General::swroot}/proxy/settings") { &General::readhash("${General::swroot}/proxy/settings", \%stdproxysettings); }
597                 $stdproxysettings{'PROXY_PORT'} = $proxysettings{'PROXY_PORT'};
598                 $stdproxysettings{'UPSTREAM_PROXY'}    = $proxysettings{'UPSTREAM_PROXY'};
599                 $stdproxysettings{'UPSTREAM_USER'}     = $proxysettings{'UPSTREAM_USER'};
600                 $stdproxysettings{'UPSTREAM_PASSWORD'} = $proxysettings{'UPSTREAM_PASSWORD'};
601                 $stdproxysettings{'ENABLE_FILTER'} = $proxysettings{'ENABLE_FILTER'};
602                 $stdproxysettings{'ENABLE_UPDXLRATOR'} = $proxysettings{'ENABLE_UPDXLRATOR'};
603                 $stdproxysettings{'ENABLE_CLAMAV'} = $proxysettings{'ENABLE_CLAMAV'};
604                 &General::writehash("${General::swroot}/proxy/settings", \%stdproxysettings);
605
606                 &writeconfig;
607                 &writepacfile;
608
609                 if ($proxysettings{'CACHEMGR'} eq 'on'){&writecachemgr;}
610
611                 system ('/usr/local/bin/squidctrl', 'disable');
612                 unlink "${General::swroot}/proxy/enable";
613                 unlink "${General::swroot}/proxy/transparent";
614                 unlink "${General::swroot}/proxy/enable_blue";
615                 unlink "${General::swroot}/proxy/transparent_blue";
616
617                 if ($proxysettings{'ENABLE'} eq 'on') {
618                         system ('/usr/bin/touch', "${General::swroot}/proxy/enable");
619                         system ('/usr/local/bin/squidctrl', 'enable'); }
620                 if ($proxysettings{'TRANSPARENT'} eq 'on' && $proxysettings{'ENABLE'} eq 'on') {
621                         system ('/usr/bin/touch', "${General::swroot}/proxy/transparent"); }
622                 if ($proxysettings{'ENABLE_BLUE'} eq 'on') {
623                         system ('/usr/bin/touch', "${General::swroot}/proxy/enable_blue");
624                         system ('/usr/local/bin/squidctrl', 'enable'); }
625                 if ($proxysettings{'TRANSPARENT_BLUE'} eq 'on' && $proxysettings{'ENABLE_BLUE'} eq 'on') {
626                         system ('/usr/bin/touch', "${General::swroot}/proxy/transparent_blue"); }
627
628                 if ($proxysettings{'ACTION'} eq $Lang::tr{'advproxy save and restart'}) { system('/usr/local/bin/squidctrl restart >/dev/null 2>&1'); }
629                 if ($proxysettings{'ACTION'} eq $Lang::tr{'proxy reconfigure'}) { system('/usr/local/bin/squidctrl reconfigure >/dev/null 2>&1'); }
630   }
631 }
632
633 if ($proxysettings{'ACTION'} eq $Lang::tr{'advproxy clear cache'})
634 {
635         system('/usr/local/bin/squidctrl flush >/dev/null 2>&1');
636 }
637
638 if (!$errormessage)
639 {
640         if (-e "${General::swroot}/proxy/advanced/settings") {
641                 &General::readhash("${General::swroot}/proxy/advanced/settings", \%proxysettings);
642         } elsif (-e "${General::swroot}/proxy/settings") {
643                 &General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
644         }
645         &read_acls;
646 }
647
648 # ------------------------------------------------------------------
649
650 # Hook to regenerate the configuration files, if cgi got called from command line.
651 if ($ENV{"REMOTE_ADDR"} eq "") {
652         writeconfig();
653         exit(0);
654 }
655
656 # -------------------------------------------------------------------
657
658 $checked{'ENABLE'}{'off'} = '';
659 $checked{'ENABLE'}{'on'} = '';
660 $checked{'ENABLE'}{$proxysettings{'ENABLE'}} = "checked='checked'";
661
662 $checked{'TRANSPARENT'}{'off'} = '';
663 $checked{'TRANSPARENT'}{'on'} = '';
664 $checked{'TRANSPARENT'}{$proxysettings{'TRANSPARENT'}} = "checked='checked'";
665
666 $checked{'ENABLE_BLUE'}{'off'} = '';
667 $checked{'ENABLE_BLUE'}{'on'} = '';
668 $checked{'ENABLE_BLUE'}{$proxysettings{'ENABLE_BLUE'}} = "checked='checked'";
669
670 $checked{'TRANSPARENT_BLUE'}{'off'} = '';
671 $checked{'TRANSPARENT_BLUE'}{'on'} = '';
672 $checked{'TRANSPARENT_BLUE'}{$proxysettings{'TRANSPARENT_BLUE'}} = "checked='checked'";
673
674 $checked{'SUPPRESS_VERSION'}{'off'} = '';
675 $checked{'SUPPRESS_VERSION'}{'on'} = '';
676 $checked{'SUPPRESS_VERSION'}{$proxysettings{'SUPPRESS_VERSION'}} = "checked='checked'";
677
678 $checked{'FORWARD_IPADDRESS'}{'off'} = '';
679 $checked{'FORWARD_IPADDRESS'}{'on'} = '';
680 $checked{'FORWARD_IPADDRESS'}{$proxysettings{'FORWARD_IPADDRESS'}} = "checked='checked'";
681 $checked{'FORWARD_USERNAME'}{'off'} = '';
682 $checked{'FORWARD_USERNAME'}{'on'} = '';
683 $checked{'FORWARD_USERNAME'}{$proxysettings{'FORWARD_USERNAME'}} = "checked='checked'";
684 $checked{'FORWARD_VIA'}{'off'} = '';
685 $checked{'FORWARD_VIA'}{'on'} = '';
686 $checked{'FORWARD_VIA'}{$proxysettings{'FORWARD_VIA'}} = "checked='checked'";
687 $checked{'NO_CONNECTION_AUTH'}{'off'} = '';
688 $checked{'NO_CONNECTION_AUTH'}{'on'} = '';
689 $checked{'NO_CONNECTION_AUTH'}{$proxysettings{'NO_CONNECTION_AUTH'}} = "checked='checked'";
690
691 $selected{'MEM_POLICY'}{$proxysettings{'MEM_POLICY'}} = "selected='selected'";
692 $selected{'CACHE_POLICY'}{$proxysettings{'CACHE_POLICY'}} = "selected='selected'";
693 $selected{'L1_DIRS'}{$proxysettings{'L1_DIRS'}} = "selected='selected'";
694 $checked{'OFFLINE_MODE'}{'off'} = '';
695 $checked{'OFFLINE_MODE'}{'on'} = '';
696 $checked{'OFFLINE_MODE'}{$proxysettings{'OFFLINE_MODE'}} = "checked='checked'";
697 $checked{'CACHE_DIGESTS'}{'off'} = '';
698 $checked{'CACHE_DIGESTS'}{'on'} = '';
699 $checked{'CACHE_DIGESTS'}{$proxysettings{'CACHE_DIGESTS'}} = "checked='checked'";
700
701 $checked{'LOGGING'}{'off'} = '';
702 $checked{'LOGGING'}{'on'} = '';
703 $checked{'LOGGING'}{$proxysettings{'LOGGING'}} = "checked='checked'";
704 $checked{'CACHEMGR'}{'off'} = '';
705 $checked{'CACHEMGR'}{'on'} = '';
706 $checked{'CACHEMGR'}{$proxysettings{'CACHEMGR'}} = "checked='checked'";
707 $checked{'LOGQUERY'}{'off'} = '';
708 $checked{'LOGQUERY'}{'on'} = '';
709 $checked{'LOGQUERY'}{$proxysettings{'LOGQUERY'}} = "checked='checked'";
710 $checked{'LOGUSERAGENT'}{'off'} = '';
711 $checked{'LOGUSERAGENT'}{'on'} = '';
712 $checked{'LOGUSERAGENT'}{$proxysettings{'LOGUSERAGENT'}} = "checked='checked'";
713
714 $selected{'ERR_LANGUAGE'}{$proxysettings{'ERR_LANGUAGE'}} = "selected='selected'";
715 $selected{'ERR_DESIGN'}{$proxysettings{'ERR_DESIGN'}} = "selected='selected'";
716
717 $checked{'NO_PROXY_LOCAL'}{'off'} = '';
718 $checked{'NO_PROXY_LOCAL'}{'on'} = '';
719 $checked{'NO_PROXY_LOCAL'}{$proxysettings{'NO_PROXY_LOCAL'}} = "checked='checked'";
720 $checked{'NO_PROXY_LOCAL_BLUE'}{'off'} = '';
721 $checked{'NO_PROXY_LOCAL_BLUE'}{'on'} = '';
722 $checked{'NO_PROXY_LOCAL_BLUE'}{$proxysettings{'NO_PROXY_LOCAL_BLUE'}} = "checked='checked'";
723
724 $checked{'CLASSROOM_EXT'}{'off'} = '';
725 $checked{'CLASSROOM_EXT'}{'on'} = '';
726 $checked{'CLASSROOM_EXT'}{$proxysettings{'CLASSROOM_EXT'}} = "checked='checked'";
727
728 $selected{'TIME_ACCESS_MODE'}{$proxysettings{'TIME_ACCESS_MODE'}} = "selected='selected'";
729 $selected{'TIME_FROM_HOUR'}{$proxysettings{'TIME_FROM_HOUR'}} = "selected='selected'";
730 $selected{'TIME_FROM_MINUTE'}{$proxysettings{'TIME_FROM_MINUTE'}} = "selected='selected'";
731 $selected{'TIME_TO_HOUR'}{$proxysettings{'TIME_TO_HOUR'}} = "selected='selected'";
732 $selected{'TIME_TO_MINUTE'}{$proxysettings{'TIME_TO_MINUTE'}} = "selected='selected'";
733
734 $proxysettings{'TIME_MON'} = 'on' unless exists $proxysettings{'TIME_MON'};
735 $proxysettings{'TIME_TUE'} = 'on' unless exists $proxysettings{'TIME_TUE'};
736 $proxysettings{'TIME_WED'} = 'on' unless exists $proxysettings{'TIME_WED'};
737 $proxysettings{'TIME_THU'} = 'on' unless exists $proxysettings{'TIME_THU'};
738 $proxysettings{'TIME_FRI'} = 'on' unless exists $proxysettings{'TIME_FRI'};
739 $proxysettings{'TIME_SAT'} = 'on' unless exists $proxysettings{'TIME_SAT'};
740 $proxysettings{'TIME_SUN'} = 'on' unless exists $proxysettings{'TIME_SUN'};
741
742 $checked{'TIME_MON'}{'off'} = '';
743 $checked{'TIME_MON'}{'on'} = '';
744 $checked{'TIME_MON'}{$proxysettings{'TIME_MON'}} = "checked='checked'";
745 $checked{'TIME_TUE'}{'off'} = '';
746 $checked{'TIME_TUE'}{'on'} = '';
747 $checked{'TIME_TUE'}{$proxysettings{'TIME_TUE'}} = "checked='checked'";
748 $checked{'TIME_WED'}{'off'} = '';
749 $checked{'TIME_WED'}{'on'} = '';
750 $checked{'TIME_WED'}{$proxysettings{'TIME_WED'}} = "checked='checked'";
751 $checked{'TIME_THU'}{'off'} = '';
752 $checked{'TIME_THU'}{'on'} = '';
753 $checked{'TIME_THU'}{$proxysettings{'TIME_THU'}} = "checked='checked'";
754 $checked{'TIME_FRI'}{'off'} = '';
755 $checked{'TIME_FRI'}{'on'} = '';
756 $checked{'TIME_FRI'}{$proxysettings{'TIME_FRI'}} = "checked='checked'";
757 $checked{'TIME_SAT'}{'off'} = '';
758 $checked{'TIME_SAT'}{'on'} = '';
759 $checked{'TIME_SAT'}{$proxysettings{'TIME_SAT'}} = "checked='checked'";
760 $checked{'TIME_SUN'}{'off'} = '';
761 $checked{'TIME_SUN'}{'on'} = '';
762 $checked{'TIME_SUN'}{$proxysettings{'TIME_SUN'}} = "checked='checked'";
763
764 $selected{'THROTTLING_GREEN_TOTAL'}{$proxysettings{'THROTTLING_GREEN_TOTAL'}} = "selected='selected'";
765 $selected{'THROTTLING_GREEN_HOST'}{$proxysettings{'THROTTLING_GREEN_HOST'}} = "selected='selected'";
766 $selected{'THROTTLING_BLUE_TOTAL'}{$proxysettings{'THROTTLING_BLUE_TOTAL'}} = "selected='selected'";
767 $selected{'THROTTLING_BLUE_HOST'}{$proxysettings{'THROTTLING_BLUE_HOST'}} = "selected='selected'";
768
769 $checked{'ENABLE_MIME_FILTER'}{'off'} = '';
770 $checked{'ENABLE_MIME_FILTER'}{'on'} = '';
771 $checked{'ENABLE_MIME_FILTER'}{$proxysettings{'ENABLE_MIME_FILTER'}} = "checked='checked'";
772
773 $checked{'AUTH_METHOD'}{'none'} = '';
774 $checked{'AUTH_METHOD'}{'ncsa'} = '';
775 $checked{'AUTH_METHOD'}{'ident'} = '';
776 $checked{'AUTH_METHOD'}{'ldap'} = '';
777 $checked{'AUTH_METHOD'}{'ntlm-auth'} = '';
778 $checked{'AUTH_METHOD'}{'radius'} = '';
779 $checked{'AUTH_METHOD'}{$proxysettings{'AUTH_METHOD'}} = "checked='checked'";
780
781 $proxysettings{'AUTH_ALWAYS_REQUIRED'} = 'on' unless exists $proxysettings{'AUTH_ALWAYS_REQUIRED'};
782
783 $checked{'AUTH_ALWAYS_REQUIRED'}{'off'} = '';
784 $checked{'AUTH_ALWAYS_REQUIRED'}{'on'} = '';
785 $checked{'AUTH_ALWAYS_REQUIRED'}{$proxysettings{'AUTH_ALWAYS_REQUIRED'}} = "checked='checked'";
786
787 $checked{'NCSA_BYPASS_REDIR'}{'off'} = '';
788 $checked{'NCSA_BYPASS_REDIR'}{'on'} = '';
789 $checked{'NCSA_BYPASS_REDIR'}{$proxysettings{'NCSA_BYPASS_REDIR'}} = "checked='checked'";
790
791 $selected{'NCSA_GROUP'}{$proxysettings{'NCSA_GROUP'}} = "selected='selected'";
792
793 $selected{'LDAP_TYPE'}{$proxysettings{'LDAP_TYPE'}} = "selected='selected'";
794
795 $proxysettings{'NTLM_ENABLE_INT_AUTH'} = 'on' unless exists $proxysettings{'NTLM_ENABLE_INT_AUTH'};
796
797 $checked{'NTLM_ENABLE_INT_AUTH'}{'off'} = '';
798 $checked{'NTLM_ENABLE_INT_AUTH'}{'on'} = '';
799 $checked{'NTLM_ENABLE_INT_AUTH'}{$proxysettings{'NTLM_ENABLE_INT_AUTH'}} = "checked='checked'";
800
801 $checked{'NTLM_ENABLE_ACL'}{'off'} = '';
802 $checked{'NTLM_ENABLE_ACL'}{'on'} = '';
803 $checked{'NTLM_ENABLE_ACL'}{$proxysettings{'NTLM_ENABLE_ACL'}} = "checked='checked'";
804
805 $checked{'NTLM_USER_ACL'}{'positive'} = '';
806 $checked{'NTLM_USER_ACL'}{'negative'} = '';
807 $checked{'NTLM_USER_ACL'}{$proxysettings{'NTLM_USER_ACL'}} = "checked='checked'";
808
809 $checked{'NTLM_AUTH_BASIC'}{'on'} = '';
810 $checked{'NTLM_AUTH_BASIC'}{'off'} = '';
811 $checked{'NTLM_AUTH_BASIC'}{$proxysettings{'NTLM_AUTH_BASIC'}} = "checked='checked'";
812
813 $checked{'RADIUS_ENABLE_ACL'}{'off'} = '';
814 $checked{'RADIUS_ENABLE_ACL'}{'on'} = '';
815 $checked{'RADIUS_ENABLE_ACL'}{$proxysettings{'RADIUS_ENABLE_ACL'}} = "checked='checked'";
816
817 $checked{'RADIUS_USER_ACL'}{'positive'} = '';
818 $checked{'RADIUS_USER_ACL'}{'negative'} = '';
819 $checked{'RADIUS_USER_ACL'}{$proxysettings{'RADIUS_USER_ACL'}} = "checked='checked'";
820
821 $checked{'IDENT_REQUIRED'}{'off'} = '';
822 $checked{'IDENT_REQUIRED'}{'on'} = '';
823 $checked{'IDENT_REQUIRED'}{$proxysettings{'IDENT_REQUIRED'}} = "checked='checked'";
824
825 $checked{'IDENT_ENABLE_ACL'}{'off'} = '';
826 $checked{'IDENT_ENABLE_ACL'}{'on'} = '';
827 $checked{'IDENT_ENABLE_ACL'}{$proxysettings{'IDENT_ENABLE_ACL'}} = "checked='checked'";
828
829 $checked{'IDENT_USER_ACL'}{'positive'} = '';
830 $checked{'IDENT_USER_ACL'}{'negative'} = '';
831 $checked{'IDENT_USER_ACL'}{$proxysettings{'IDENT_USER_ACL'}} = "checked='checked'";
832
833 $checked{'ENABLE_FILTER'}{'off'} = '';
834 $checked{'ENABLE_FILTER'}{'on'} = '';
835 $checked{'ENABLE_FILTER'}{$proxysettings{'ENABLE_FILTER'}} = "checked='checked'";
836
837 $checked{'ENABLE_UPDXLRATOR'}{'off'} = '';
838 $checked{'ENABLE_UPDXLRATOR'}{'on'} = '';
839 $checked{'ENABLE_UPDXLRATOR'}{$proxysettings{'ENABLE_UPDXLRATOR'}} = "checked='checked'";
840
841 $checked{'ENABLE_CLAMAV'}{'off'} = '';
842 $checked{'ENABLE_CLAMAV'}{'on'} = '';
843 $checked{'ENABLE_CLAMAV'}{$proxysettings{'ENABLE_CLAMAV'}} = "checked='checked'";
844
845 &Header::openpage($Lang::tr{'advproxy advanced web proxy configuration'}, 1, '');
846
847 &Header::openbigbox('100%', 'left', '', $errormessage);
848
849 if ($errormessage) {
850         &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
851         print "<font class='base'>$errormessage&nbsp;</font>\n";
852         &Header::closebox();
853 }
854
855 if ($squidversion[0] =~ /^Squid\sCache:\sVersion\s/i)
856 {
857         $squidversion[0] =~ s/^Squid\sCache:\sVersion//i;
858         $squidversion[0] =~ s/^\s+//g;
859         $squidversion[0] =~ s/\s+$//g;
860 } else {
861         $squidversion[0] = $Lang::tr{'advproxy unknown'};
862 }
863
864 # ===================================================================
865 #  Main settings
866 # ===================================================================
867
868 unless ($proxysettings{'NCSA_EDIT_MODE'} eq 'yes') {
869
870 print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
871
872 &Header::openbox('100%', 'left', "$Lang::tr{'advproxy advanced web proxy'}");
873
874 print <<END
875 <table width='100%'>
876 <tr>
877         <td colspan='4' class='base'><b>$Lang::tr{'advproxy common settings'}</b></td>
878 </tr>
879 <tr>
880         <td width='25%' class='base'>$Lang::tr{'advproxy enabled on'} <font color="$Header::colourgreen">Green</font>:</td>
881         <td width='20%'><input type='checkbox' name='ENABLE' $checked{'ENABLE'}{'on'} /></td>
882         <td width='25%' class='base'>$Lang::tr{'advproxy proxy port'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
883         <td width='30%'><input type='text' name='PROXY_PORT' value='$proxysettings{'PROXY_PORT'}' size='5' /></td>
884 </tr>
885 <tr>
886         <td class='base'>$Lang::tr{'advproxy transparent on'} <font color="$Header::colourgreen">Green</font>:</td>
887         <td><input type='checkbox' name='TRANSPARENT' $checked{'TRANSPARENT'}{'on'} /></td>
888         <td width='25%' class='base'>$Lang::tr{'advproxy proxy port transparent'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
889         <td width='30%'><input type='text' name='TRANSPARENT_PORT' value='$proxysettings{'TRANSPARENT_PORT'}' size='5' /></td>
890 </tr>
891 <tr>
892 END
893 ;
894 if ($netsettings{'BLUE_DEV'}) {
895         print "<td class='base'>$Lang::tr{'advproxy enabled on'} <font color='$Header::colourblue'>Blue</font>:</td>";
896         print "<td><input type='checkbox' name='ENABLE_BLUE' $checked{'ENABLE_BLUE'}{'on'} /></td>";
897 } else {
898         print "<td colspan='2'>&nbsp;</td>";
899 }
900 print <<END
901         <td class='base'>$Lang::tr{'advproxy visible hostname'}:</td>
902         <td><input type='text' name='VISIBLE_HOSTNAME' value='$proxysettings{'VISIBLE_HOSTNAME'}' /></td>
903 </tr>
904 <tr>
905 END
906 ;
907 if ($netsettings{'BLUE_DEV'}) {
908         print "<td class='base'>$Lang::tr{'advproxy transparent on'} <font color='$Header::colourblue'>Blue</font>:</td>";
909         print "<td><input type='checkbox' name='TRANSPARENT_BLUE' $checked{'TRANSPARENT_BLUE'}{'on'} /></td>";
910 } else {
911         print "<td colspan='2'>&nbsp;</td>";
912 }
913 print <<END
914         <td class='base'>$Lang::tr{'advproxy error language'}:</td>
915         <td class='base'>
916         <select name='ERR_LANGUAGE'>
917 END
918 ;
919         foreach (<$errordir/*>) {
920                 if (-d) {
921                         $language = substr($_,rindex($_,"/")+1);
922                         print "<option value='$language' $selected{'ERR_LANGUAGE'}{$language}>$language</option>\n";
923                 }
924         }
925 print <<END
926         </select>
927         </td>
928 </tr>
929 <tr>
930         <td class='base'>$Lang::tr{'advproxy suppress version'}:</td>
931         <td><input type='checkbox' name='SUPPRESS_VERSION' $checked{'SUPPRESS_VERSION'}{'on'} /></td>
932         <td class='base'>$Lang::tr{'advproxy error design'}:</td>
933         <td class='base'><select name='ERR_DESIGN'>
934                 <option value='ipfire' $selected{'ERR_DESIGN'}{'ipfire'}>IPFire</option>
935                 <option value='squid' $selected{'ERR_DESIGN'}{'squid'}>$Lang::tr{'advproxy standard'}</option>
936         </select></td>
937 </tr>
938 <tr>
939         <td class='base'>$Lang::tr{'advproxy squid version'}:</td>
940         <td class='base'>&nbsp;[<font color='$Header::colourred'> $squidversion[0] </font>]</td>
941         <td>&nbsp;</td>
942         <td>&nbsp;</td>
943 </tr>
944 </table>
945 <hr size='1'>
946 <table width='100%'>
947 END
948 ;
949 if ( -e "/usr/bin/squidclamav" ) {
950         print "<td class='base'><b>".$Lang::tr{'advproxy squidclamav'}."</b><br />";
951         if ( ! -e "/var/run/clamav/clamd.pid" ){
952                 print "<font color='red'>clamav not running</font><br /><br />";
953                 $proxysettings{'ENABLE_CLAMAV'} = 'off';
954                 }
955         else {
956                 print $Lang::tr{'advproxy enabled'}."<input type='checkbox' name='ENABLE_CLAMAV' ".$checked{'ENABLE_CLAMAV'}{'on'}." /><br />";
957 }
958         print "</td>";
959 } else {
960         print "<td></td>";
961 }
962 print "<td class='base'><a href='/cgi-bin/urlfilter.cgi'><b>".$Lang::tr{'advproxy url filter'}."</a></b><br />";
963 print $Lang::tr{'advproxy enabled'}."<input type='checkbox' name='ENABLE_FILTER' ".$checked{'ENABLE_FILTER'}{'on'}." /><br />";
964 print "</td>";
965 print "<td class='base'><a href='/cgi-bin/updatexlrator.cgi'><b>".$Lang::tr{'advproxy update accelerator'}."</a></b><br />";
966 print $Lang::tr{'advproxy enabled'}."<input type='checkbox' name='ENABLE_UPDXLRATOR' ".$checked{'ENABLE_UPDXLRATOR'}{'on'}." /><br />";
967 print "</td></tr>";
968 print <<END
969 </table>
970 <hr size='1'>
971 <table width='100%'>
972 <tr>
973         <td colspan='4' class='base'><b>$Lang::tr{'advproxy upstream proxy'}</b></td>
974 </tr>
975 <tr>
976         <td width='25%' class='base'>$Lang::tr{'advproxy via forwarding'}:</td>
977         <td width='20%'><input type='checkbox' name='FORWARD_VIA' $checked{'FORWARD_VIA'}{'on'} /></td>
978         <td width='25%' class='base'>$Lang::tr{'advproxy upstream proxy host:port'}:</td>
979         <td width='30%'><input type='text' name='UPSTREAM_PROXY' value='$proxysettings{'UPSTREAM_PROXY'}' /></td>
980 </tr>
981 <tr>
982         <td class='base'>$Lang::tr{'advproxy client IP forwarding'}:</td>
983         <td><input type='checkbox' name='FORWARD_IPADDRESS' $checked{'FORWARD_IPADDRESS'}{'on'} /></td>
984         <td class='base'>$Lang::tr{'advproxy upstream username'}:</td>
985         <td><input type='text' name='UPSTREAM_USER' value='$proxysettings{'UPSTREAM_USER'}' /></td>
986 </tr>
987 <tr>
988         <td class='base'>$Lang::tr{'advproxy username forwarding'}:</td>
989         <td><input type='checkbox' name='FORWARD_USERNAME' $checked{'FORWARD_USERNAME'}{'on'} /></td>
990         <td class='base'>$Lang::tr{'advproxy upstream password'}:</td>
991         <td><input type='password' name='UPSTREAM_PASSWORD' value='$proxysettings{'UPSTREAM_PASSWORD'}' /></td>
992 </tr>
993 <tr>
994         <td class='base'>$Lang::tr{'advproxy no connection auth'}:</td>
995         <td><input type='checkbox' name='NO_CONNECTION_AUTH' $checked{'NO_CONNECTION_AUTH'}{'on'} /></td>
996         <td>&nbsp;</td>
997         <td>&nbsp;</td>
998 </tr>
999 </table>
1000 <hr size='1'>
1001 <table width='100%'>
1002 <tr>
1003         <td colspan='4' class='base'><b>$Lang::tr{'advproxy log settings'}</b></td>
1004 </tr>
1005 <tr>
1006         <td width='25%' class='base'>$Lang::tr{'advproxy log enabled'}:</td>
1007         <td width='20%'><input type='checkbox' name='LOGGING' $checked{'LOGGING'}{'on'} /></td>
1008         <td width='25%'class='base'>$Lang::tr{'advproxy log query'}:</td>
1009         <td width='30%'><input type='checkbox' name='LOGQUERY' $checked{'LOGQUERY'}{'on'} /></td>
1010 </tr>
1011 <tr>
1012         <td>&nbsp;</td>
1013         <td>&nbsp;</td>
1014         <td class='base'>$Lang::tr{'advproxy log useragent'}:</td>
1015         <td><input type='checkbox' name='LOGUSERAGENT' $checked{'LOGUSERAGENT'}{'on'} /></td>
1016 </tr>
1017 </table>
1018 <hr size='1'>
1019 <table width='100%'>
1020 <tr>
1021         <td colspan='4'><b>$Lang::tr{'advproxy cache management'}</b></td>
1022 </tr>
1023 <tr>
1024         <td class='base'><a href='/cgi-bin/cachemgr.cgi' target='_blank'>$Lang::tr{'proxy cachemgr'}:</td>
1025         <td><input type='checkbox' name='CACHEMGR' $checked{'CACHEMGR'}{'on'} /></td>
1026         <td class='base'>$Lang::tr{'advproxy admin mail'}:</td>
1027         <td><input type='text' name='ADMIN_MAIL_ADDRESS' value='$proxysettings{'ADMIN_MAIL_ADDRESS'}' /></td>
1028 </tr>
1029 <tr>
1030         <td class='base'>$Lang::tr{'proxy filedescriptors'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
1031         <td><input type='text' name='FILEDESCRIPTORS' value='$proxysettings{'FILEDESCRIPTORS'}' size='5' /></td>
1032         <td class='base'>$Lang::tr{'proxy admin password'}:</td>
1033         <td><input type='text' name='ADMIN_PASSWORD' value='$proxysettings{'ADMIN_PASSWORD'}' /></td>
1034 </tr>
1035 <tr>
1036         <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
1037 </tr>
1038 <tr>
1039         <td class='base'>$Lang::tr{'advproxy ram cache size'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
1040         <td><input type='text' name='CACHE_MEM' value='$proxysettings{'CACHE_MEM'}' size='5' /></td>
1041         <td class='base'>$Lang::tr{'advproxy hdd cache size'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
1042         <td><input type='text' name='CACHE_SIZE' value='$proxysettings{'CACHE_SIZE'}' size='5' /></td>
1043 </tr>
1044 <tr>
1045         <td class='base'>$Lang::tr{'advproxy min size'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
1046         <td><input type='text' name='MIN_SIZE' value='$proxysettings{'MIN_SIZE'}' size='5' /></td>
1047         <td class='base'>$Lang::tr{'advproxy max size'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
1048         <td><input type='text' name='MAX_SIZE' value='$proxysettings{'MAX_SIZE'}' size='5' /></td>
1049 </tr>
1050 <tr>
1051         <td class='base'>$Lang::tr{'advproxy number of L1 dirs'}:</td>
1052         <td class='base'><select name='L1_DIRS'>
1053                 <option value='16'  $selected{'L1_DIRS'}{'16'}>16</option>
1054                 <option value='32'  $selected{'L1_DIRS'}{'32'}>32</option>
1055                 <option value='64'  $selected{'L1_DIRS'}{'64'}>64</option>
1056                 <option value='128' $selected{'L1_DIRS'}{'128'}>128</option>
1057                 <option value='256' $selected{'L1_DIRS'}{'256'}>256</option>
1058         </select></td>
1059         <td colspan='2' rowspan= '5' valign='top' class='base'>
1060                 <table cellspacing='0' cellpadding='0'>
1061                         <tr>
1062                                 <!-- intentionally left empty -->
1063                         </tr>
1064                         <tr>
1065                         <td>$Lang::tr{'advproxy no cache sites'}:</td>
1066                         </tr>
1067                         <tr>
1068                                 <!-- intentionally left empty -->
1069                         </tr>
1070                         <tr>
1071                                 <!-- intentionally left empty -->
1072                         </tr>
1073                         <tr>
1074                         <td><textarea name='DST_NOCACHE' cols='32' rows='6' wrap='off'>
1075 END
1076 ;
1077
1078 print $proxysettings{'DST_NOCACHE'};
1079
1080 print <<END
1081 </textarea></td>
1082                 </tr>
1083                 </table>
1084         </td>
1085 </tr>
1086 <tr>
1087         <td class='base'>$Lang::tr{'advproxy memory replacement policy'}:</td>
1088         <td class='base'><select name='MEM_POLICY'>
1089                 <option value='LRU' $selected{'MEM_POLICY'}{'LRU'}>LRU</option>
1090                 <option value='heap LFUDA' $selected{'MEM_POLICY'}{'heap LFUDA'}>heap LFUDA</option>
1091                 <option value='heap GDSF' $selected{'MEM_POLICY'}{'heap GDSF'}>heap GDSF</option>
1092                 <option value='heap LRU' $selected{'MEM_POLICY'}{'heap LRU'}>heap LRU</option>
1093         </select></td>
1094 </tr>
1095 <tr>
1096         <td class='base'>$Lang::tr{'advproxy cache replacement policy'}:</td>
1097         <td class='base'><select name='CACHE_POLICY'>
1098                 <option value='LRU' $selected{'CACHE_POLICY'}{'LRU'}>LRU</option>
1099                 <option value='heap LFUDA' $selected{'CACHE_POLICY'}{'heap LFUDA'}>heap LFUDA</option>
1100                 <option value='heap GDSF' $selected{'CACHE_POLICY'}{'heap GDSF'}>heap GDSF</option>
1101                 <option value='heap LRU' $selected{'CACHE_POLICY'}{'heap LRU'}>heap LRU</option>
1102         </select></td>
1103 </tr>
1104 <tr>
1105         <td colspan='2'>&nbsp;</td>
1106 </tr>
1107 <tr>
1108         <td class='base'>$Lang::tr{'advproxy offline mode'}:</td>
1109         <td><input type='checkbox' name='OFFLINE_MODE' $checked{'OFFLINE_MODE'}{'on'} /></td>
1110 </tr>
1111 <tr>
1112         <td class='base'>$Lang::tr{'advproxy cache-digest'}:</td>
1113         <td><input type='checkbox' name='CACHE_DIGESTS' $checked{'CACHE_DIGESTS'}{'on'} /></td>
1114 </tr>
1115 </table>
1116 <hr size='1'>
1117 <table width='100%'>
1118 <tr>
1119         <td colspan='4'><b>$Lang::tr{'advproxy destination ports'}</b></td>
1120 </tr>
1121 <tr>
1122         <td width='25%' align='center'></td> <td width='20%' align='center'></td><td width='25%' align='center'></td><td width='30%' align='center'></td>
1123 </tr>
1124 <tr>
1125         <td colspan='2' class='base'>$Lang::tr{'advproxy standard ports'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
1126         <td colspan='2' class='base'>$Lang::tr{'advproxy ssl ports'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
1127 </tr>
1128 <tr>
1129         <td colspan='2'><textarea name='PORTS_SAFE' cols='32' rows='6' wrap='off'>
1130 END
1131 ;
1132         if (!$proxysettings{'PORTS_SAFE'}) { print $def_ports_safe; } else { print $proxysettings{'PORTS_SAFE'}; }
1133
1134 print <<END
1135 </textarea></td>
1136         <td colspan='2'><textarea name='PORTS_SSL' cols='32' rows='6' wrap='off'>
1137 END
1138 ;
1139         if (!$proxysettings{'PORTS_SSL'}) { print $def_ports_ssl; } else { print $proxysettings{'PORTS_SSL'}; }
1140
1141 print <<END
1142 </textarea></td>
1143 </tr>
1144 </table>
1145 <hr size='1'>
1146 <table width='100%'>
1147 <tr>
1148         <td colspan='4'><b>$Lang::tr{'advproxy network based access'}</b></td>
1149 </tr>
1150 <tr>
1151         <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
1152 </tr>
1153 <tr>
1154         <td colspan='4' class='base'>$Lang::tr{'advproxy allowed subnets'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
1155 </tr>
1156 <tr>
1157         <td colspan='2' rowspan='4'><textarea name='SRC_SUBNETS' cols='32' rows='3' wrap='off'>
1158 END
1159 ;
1160
1161 if (!$proxysettings{'SRC_SUBNETS'})
1162 {
1163         print "$green_cidr\n";
1164         if ($netsettings{'BLUE_DEV'})
1165         {
1166                 print "$blue_cidr\n";
1167         }
1168 } else { print $proxysettings{'SRC_SUBNETS'}; }
1169
1170 print <<END
1171 </textarea></td>
1172 END
1173 ;
1174
1175 $line = $Lang::tr{'advproxy no internal proxy on green'};
1176 $line =~ s/Green/<font color="$Header::colourgreen">Green<\/font>/i;
1177 print "<td class='base'>$line:</td>\n";
1178 print <<END
1179         <td><input type='checkbox' name='NO_PROXY_LOCAL' $checked{'NO_PROXY_LOCAL'}{'on'} /></td>
1180 </tr>
1181 END
1182 ;
1183 if ($netsettings{'BLUE_DEV'}) {
1184         $line = $Lang::tr{'advproxy no internal proxy on blue'};
1185         $line =~ s/Blue/<font color="$Header::colourblue">Blue<\/font>/i;
1186         print "<tr>\n";
1187         print "<td class='base'>$line:</td>\n";
1188         print <<END
1189         <td><input type='checkbox' name='NO_PROXY_LOCAL_BLUE' $checked{'NO_PROXY_LOCAL_BLUE'}{'on'} /></td>
1190 </tr>
1191 END
1192 ;
1193 }
1194 print <<END
1195 <tr>
1196         <td colspan='2'>&nbsp;</td>
1197 </tr>
1198 <tr>
1199         <td colspan='2'>&nbsp;</td>
1200 </tr>
1201 </table>
1202 <table width='100%'>
1203 <tr>
1204         <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
1205 </tr>
1206 <tr>
1207         <td colspan='2' class='base'>$Lang::tr{'advproxy unrestricted ip clients'}:</td>
1208         <td colspan='2' class='base'>$Lang::tr{'advproxy unrestricted mac clients'}:</td>
1209 </tr>
1210 <tr>
1211         <td colspan='2'><textarea name='SRC_UNRESTRICTED_IP' cols='32' rows='3' wrap='off'>
1212 END
1213 ;
1214
1215         print $proxysettings{'SRC_UNRESTRICTED_IP'};
1216
1217 print <<END
1218 </textarea></td>
1219         <td colspan='2'><textarea name='SRC_UNRESTRICTED_MAC' cols='32' rows='3' wrap='off'>
1220 END
1221 ;
1222
1223 print $proxysettings{'SRC_UNRESTRICTED_MAC'};
1224
1225 print <<END
1226 </textarea></td>
1227 </tr>
1228 </table>
1229 <table width='100%'>
1230 <tr>
1231         <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
1232 </tr>
1233 <tr>
1234         <td colspan='2' class='base'>$Lang::tr{'advproxy banned ip clients'}:</td>
1235         <td colspan='2' class='base'>$Lang::tr{'advproxy banned mac clients'}:</td>
1236 </tr>
1237 <tr>
1238         <td colspan='2'><textarea name='SRC_BANNED_IP' cols='32' rows='3' wrap='off'>
1239 END
1240 ;
1241
1242         print $proxysettings{'SRC_BANNED_IP'};
1243
1244 print <<END
1245 </textarea></td>
1246         <td colspan='2'><textarea name='SRC_BANNED_MAC' cols='32' rows='3' wrap='off'>
1247 END
1248 ;
1249
1250 print $proxysettings{'SRC_BANNED_MAC'};
1251
1252 print <<END
1253 </textarea></td>
1254 </tr>
1255 </table>
1256
1257 <hr size='1'>
1258
1259 END
1260 ;
1261 # -------------------------------------------------------------------
1262 #  CRE GUI - optional
1263 # -------------------------------------------------------------------
1264
1265 if (-e $cre_enabled) { print <<END
1266 <table width='100%'>
1267
1268 <tr>
1269         <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>
1270 </tr>
1271 <tr>
1272         <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
1273 </tr>
1274 <tr>
1275
1276 END
1277 ;
1278 if ($proxysettings{'CLASSROOM_EXT'} eq 'on'){
1279 print <<END
1280         <td class='base'>$Lang::tr{'advproxy supervisor password'}:</td>
1281         <td><input type='password' name='SUPERVISOR_PASSWORD' value='$proxysettings{'SUPERVISOR_PASSWORD'}' size='12' /></td>
1282 </tr>
1283 <tr>
1284         <td colspan='2' class='base'>$Lang::tr{'advproxy cre group definitions'}:</td>
1285         <td colspan='2' class='base'>$Lang::tr{'advproxy cre supervisors'}:</td>
1286 END
1287 ;
1288 }
1289 print "</tr>";
1290 if ($proxysettings{'CLASSROOM_EXT'} eq 'on'){
1291 print <<END
1292 <tr>
1293         <td colspan='2'><textarea name='CRE_GROUPS' cols='32' rows='6' wrap='off'>
1294 END
1295 ;
1296
1297         print $proxysettings{'CRE_GROUPS'};
1298
1299 print <<END
1300 </textarea></td>
1301         <td colspan='2'><textarea name='CRE_SVHOSTS' cols='32' rows='6' wrap='off'>
1302 END
1303 ;
1304         print $proxysettings{'CRE_SVHOSTS'};
1305
1306 print <<END
1307 </textarea></td>
1308 </tr>
1309 END
1310 ;
1311 }
1312 print "</table><hr size='1'>";
1313
1314 } else {
1315         print <<END
1316         <input type='hidden' name='SUPERVISOR_PASSWORD' value='$proxysettings{'SUPERVISOR_PASSWORD'}' />
1317         <input type='hidden' name='CRE_GROUPS'          value='$proxysettings{'CRE_GROUPS'}' />
1318         <input type='hidden' name='CRE_SVHOSTS'         value='$proxysettings{'CRE_SVHOSTS'}' />
1319 END
1320 ;
1321 }
1322
1323 # ===================================================================
1324 #  WPAD settings
1325 # ===================================================================
1326
1327 print <<END
1328 <table width='100%'>
1329 <tr>
1330         <td colspan='4'><b>$Lang::tr{'advproxy wpad title'}</b></td>
1331 </tr>
1332 <tr>
1333         <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
1334 </tr>
1335 <tr>
1336         <td colspan='2' class='base'>$Lang::tr{'advproxy wpad label dst_noproxy_ip'}:</td>
1337         <td colspan='2' class='base'>$Lang::tr{'advproxy wpad label dst_noproxy_url'}:</td>
1338 </tr>
1339 <tr>
1340         <td colspan='2'><textarea name='DST_NOPROXY_IP' cols='32' rows='3' wrap='off'>
1341 END
1342 ;
1343
1344         print $proxysettings{'DST_NOPROXY_IP'};
1345
1346 print <<END
1347 </textarea></td>
1348
1349         <td colspan='2'><textarea name='DST_NOPROXY_URL' cols='32' rows='3' wrap='off'>
1350 END
1351 ;
1352
1353         print $proxysettings{'DST_NOPROXY_URL'};
1354
1355 print <<END
1356 </textarea></td>
1357 </tr>
1358 <tr>
1359         <td colspan='2' class='base'>$Lang::tr{'advproxy wpad example dst_noproxy_ip'}</td>
1360         <td colspan='2' class='base'>$Lang::tr{'advproxy wpad example dst_noproxy_url'}</td>
1361 </tr>
1362 <tr>
1363         <td colspan="4">&nbsp;</td>
1364 </tr>
1365 <tr>
1366         <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>
1367 </tr>
1368 </table>
1369
1370 <hr size='1'>
1371
1372 END
1373 ;
1374
1375 # -------------------------------------------------------------------
1376
1377 print <<END
1378
1379 <table width='100%'>
1380 <tr>
1381         <td colspan='4'><b>$Lang::tr{'advproxy time restrictions'}</b></td>
1382 </tr>
1383 <table width='100%'>
1384 <tr>
1385         <td width='2%'>$Lang::tr{'advproxy access'}</td>
1386         <td width='1%'>&nbsp;</td>
1387         <td width='2%' align='center'>$Lang::tr{'advproxy monday'}</td>
1388         <td width='2%' align='center'>$Lang::tr{'advproxy tuesday'}</td>
1389         <td width='2%' align='center'>$Lang::tr{'advproxy wednesday'}</td>
1390         <td width='2%' align='center'>$Lang::tr{'advproxy thursday'}</td>
1391         <td width='2%' align='center'>$Lang::tr{'advproxy friday'}</td>
1392         <td width='2%' align='center'>$Lang::tr{'advproxy saturday'}</td>
1393         <td width='2%' align='center'>$Lang::tr{'advproxy sunday'}</td>
1394         <td width='1%'>&nbsp;&nbsp;</td>
1395         <td width='7%' colspan=3>$Lang::tr{'advproxy from'}</td>
1396         <td width='1%'>&nbsp;</td>
1397         <td width='7%' colspan=3>$Lang::tr{'advproxy to'}</td>
1398         <td>&nbsp;</td>
1399 </tr>
1400 <tr>
1401         <td class='base'>
1402         <select name='TIME_ACCESS_MODE'>
1403         <option value='allow' $selected{'TIME_ACCESS_MODE'}{'allow'}>$Lang::tr{'advproxy mode allow'}</option>
1404         <option value='deny'  $selected{'TIME_ACCESS_MODE'}{'deny'}>$Lang::tr{'advproxy mode deny'}</option>
1405         </select>
1406         </td>
1407         <td>&nbsp;</td>
1408         <td class='base'><input type='checkbox' name='TIME_MON' $checked{'TIME_MON'}{'on'} /></td>
1409         <td class='base'><input type='checkbox' name='TIME_TUE' $checked{'TIME_TUE'}{'on'} /></td>
1410         <td class='base'><input type='checkbox' name='TIME_WED' $checked{'TIME_WED'}{'on'} /></td>
1411         <td class='base'><input type='checkbox' name='TIME_THU' $checked{'TIME_THU'}{'on'} /></td>
1412         <td class='base'><input type='checkbox' name='TIME_FRI' $checked{'TIME_FRI'}{'on'} /></td>
1413         <td class='base'><input type='checkbox' name='TIME_SAT' $checked{'TIME_SAT'}{'on'} /></td>
1414         <td class='base'><input type='checkbox' name='TIME_SUN' $checked{'TIME_SUN'}{'on'} /></td>
1415         <td>&nbsp;</td>
1416         <td class='base'>
1417         <select name='TIME_FROM_HOUR'>
1418 END
1419 ;
1420 for ($i=0;$i<=24;$i++) {
1421         $_ = sprintf("%02s",$i);
1422         print "<option $selected{'TIME_FROM_HOUR'}{$_}>$_</option>\n";
1423 }
1424 print <<END
1425         </select>
1426         </td>
1427         <td>:</td>
1428         <td class='base'>
1429         <select name='TIME_FROM_MINUTE'>
1430 END
1431 ;
1432 for ($i=0;$i<=45;$i+=15) {
1433         $_ = sprintf("%02s",$i);
1434         print "<option $selected{'TIME_FROM_MINUTE'}{$_}>$_</option>\n";
1435 }
1436 print <<END
1437         </select>
1438         <td> - </td>
1439         </td>
1440         <td class='base'>
1441         <select name='TIME_TO_HOUR'>
1442 END
1443 ;
1444 for ($i=0;$i<=24;$i++) {
1445         $_ = sprintf("%02s",$i);
1446         print "<option $selected{'TIME_TO_HOUR'}{$_}>$_</option>\n";
1447 }
1448 print <<END
1449         </select>
1450         </td>
1451         <td>:</td>
1452         <td class='base'>
1453         <select name='TIME_TO_MINUTE'>
1454 END
1455 ;
1456 for ($i=0;$i<=45;$i+=15) {
1457         $_ = sprintf("%02s",$i);
1458         print "<option $selected{'TIME_TO_MINUTE'}{$_}>$_</option>\n";
1459 }
1460 print <<END
1461         </select>
1462         </td>
1463 </tr>
1464 </table>
1465 <hr size='1'>
1466 <table width='100%'>
1467 <tr>
1468         <td colspan='4'><b>$Lang::tr{'advproxy transfer limits'}</b></td>
1469 </tr>
1470 <tr>
1471         <td width='25%' class='base'>$Lang::tr{'advproxy max download size'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
1472         <td width='20%'><input type='text' name='MAX_INCOMING_SIZE' value='$proxysettings{'MAX_INCOMING_SIZE'}' size='5' /></td>
1473         <td width='25%' class='base'>$Lang::tr{'advproxy max upload size'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
1474         <td width='30%'><input type='text' name='MAX_OUTGOING_SIZE' value='$proxysettings{'MAX_OUTGOING_SIZE'}' size='5' /></td>
1475 </tr>
1476 </table>
1477 <hr size='1'>
1478 <table width='100%'>
1479 <tr>
1480         <td colspan='4'><b>$Lang::tr{'advproxy download throttling'}</b></td>
1481 </tr>
1482 <tr>
1483         <td width='25%' class='base'>$Lang::tr{'advproxy throttling total on'} <font color="$Header::colourgreen">Green</font>:</td>
1484         <td width='20%' class='base'>
1485         <select name='THROTTLING_GREEN_TOTAL'>
1486 END
1487 ;
1488
1489 foreach (@throttle_limits) {
1490         my $val = $_;
1491         my $unit = "kbit/s";
1492
1493         if ($val >= 1024) {
1494                 $unit = "Mbit/s";
1495                 $val /= 1024;
1496         }
1497
1498         print "\t<option value='$_' $selected{'THROTTLING_GREEN_TOTAL'}{$_}>$val $unit</option>\n";
1499 }
1500
1501 print <<END
1502         <option value='0' $selected{'THROTTLING_GREEN_TOTAL'}{'unlimited'}>$Lang::tr{'advproxy throttling unlimited'}</option>\n";
1503         </select>
1504         </td>
1505         <td width='25%' class='base'>$Lang::tr{'advproxy throttling per host on'} <font color="$Header::colourgreen">Green</font>:</td>
1506         <td width='30%' class='base'>
1507         <select name='THROTTLING_GREEN_HOST'>
1508 END
1509 ;
1510
1511 foreach (@throttle_limits) {
1512         print "\t<option value='$_' $selected{'THROTTLING_GREEN_HOST'}{$_}>$_ kbit/s</option>\n";
1513 }
1514
1515 print <<END
1516         <option value='0' $selected{'THROTTLING_GREEN_HOST'}{'unlimited'}>$Lang::tr{'advproxy throttling unlimited'}</option>\n";
1517         </select>
1518         </td>
1519 </tr>
1520 END
1521 ;
1522
1523 if ($netsettings{'BLUE_DEV'}) {
1524         print <<END
1525 <tr>
1526         <td class='base'>$Lang::tr{'advproxy throttling total on'} <font color="$Header::colourblue">Blue</font>:</td>
1527         <td class='base'>
1528         <select name='THROTTLING_BLUE_TOTAL'>
1529 END
1530 ;
1531
1532 foreach (@throttle_limits) {
1533         print "\t<option value='$_' $selected{'THROTTLING_BLUE_TOTAL'}{$_}>$_ kbit/s</option>\n";
1534 }
1535
1536 print <<END
1537         <option value='0' $selected{'THROTTLING_BLUE_TOTAL'}{'unlimited'}>$Lang::tr{'advproxy throttling unlimited'}</option>\n";
1538         </select>
1539         </td>
1540         <td class='base'>$Lang::tr{'advproxy throttling per host on'} <font color="$Header::colourblue">Blue</font>:</td>
1541         <td class='base'>
1542         <select name='THROTTLING_BLUE_HOST'>
1543 END
1544 ;
1545
1546 foreach (@throttle_limits) {
1547         print "\t<option value='$_' $selected{'THROTTLING_BLUE_HOST'}{$_}>$_ kbit/s</option>\n";
1548 }
1549
1550 print <<END
1551         <option value='0' $selected{'THROTTLING_BLUE_HOST'}{'unlimited'}>$Lang::tr{'advproxy throttling unlimited'}</option>\n";
1552         </select>
1553         </td>
1554 </tr>
1555 END
1556 ;
1557 }
1558
1559 print <<END
1560 </table>
1561 <hr size='1'>
1562 <table width='100%'>
1563 <tr>
1564         <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>
1565 </tr>
1566 END
1567 ;
1568 if ( $proxysettings{'ENABLE_MIME_FILTER'} eq 'on' ){
1569 print <<END
1570 <tr>
1571         <td  colspan='2' class='base'>$Lang::tr{'advproxy MIME block types'}:</td>
1572         <td>&nbsp;</td>
1573         <td>&nbsp;</td>
1574 </tr>
1575 <tr>
1576         <td colspan='2'><textarea name='MIME_TYPES' cols='32' rows='6' wrap='off'>
1577 END
1578 ;
1579
1580 print $proxysettings{'MIME_TYPES'};
1581
1582 print <<END
1583 </textarea></td>
1584         <td>&nbsp;</td>
1585         <td>&nbsp;</td>
1586 </tr>
1587 END
1588 ;
1589 }
1590 print <<END
1591 </table>
1592
1593 <hr size='1'>
1594
1595 <table width='100%'>
1596 <tr>
1597         <td><b>$Lang::tr{'advproxy privacy'}</b></td>
1598 </tr>
1599 <tr>
1600         <td class='base'>$Lang::tr{'advproxy fake useragent'}:</td>
1601         <td class='base'>$Lang::tr{'advproxy fake referer'}:</td>
1602 </tr>
1603 <tr>
1604         <td><input type='text' name='FAKE_USERAGENT' value='$proxysettings{'FAKE_USERAGENT'}' size='40%' /></td>
1605         <td><input type='text' name='FAKE_REFERER' value='$proxysettings{'FAKE_REFERER'}' size='40%' /></td>
1606 </tr>
1607 </table>
1608 <hr size='1'>
1609 END
1610 ;
1611
1612 my $auth_columns = 5;
1613 if ($HAVE_NTLM_AUTH) {
1614         $auth_columns++;
1615 }
1616 my $auth_column_width = 100 / $auth_columns;
1617
1618 print <<END;
1619 <table width='100%'>
1620 <tr>
1621         <td colspan='$auth_columns'><b>$Lang::tr{'advproxy AUTH method'}</b></td>
1622 </tr>
1623 <tr>
1624         <td width='$auth_column_width%' class='base'><input type='radio' name='AUTH_METHOD' value='none' $checked{'AUTH_METHOD'}{'none'} />$Lang::tr{'advproxy AUTH method none'}</td>
1625         <td width='$auth_column_width%' class='base'><input type='radio' name='AUTH_METHOD' value='ncsa' $checked{'AUTH_METHOD'}{'ncsa'} />$Lang::tr{'advproxy AUTH method ncsa'}</td>
1626         <td width='$auth_column_width%' class='base'><input type='radio' name='AUTH_METHOD' value='ident' $checked{'AUTH_METHOD'}{'ident'} />$Lang::tr{'advproxy AUTH method ident'}</td>
1627         <td width='$auth_column_width%' class='base'><input type='radio' name='AUTH_METHOD' value='ldap' $checked{'AUTH_METHOD'}{'ldap'} />$Lang::tr{'advproxy AUTH method ldap'}</td>
1628 END
1629
1630 if ($HAVE_NTLM_AUTH) {
1631         print <<END;
1632         <td width='$auth_column_width%' class='base'><input type='radio' name='AUTH_METHOD' value='ntlm-auth' $checked{'AUTH_METHOD'}{'ntlm-auth'} />$Lang::tr{'advproxy AUTH method ntlm auth'}</td>
1633 END
1634 }
1635
1636 print <<END
1637         <td width='$auth_column_width%' class='base'><input type='radio' name='AUTH_METHOD' value='radius' $checked{'AUTH_METHOD'}{'radius'} />$Lang::tr{'advproxy AUTH method radius'}</td>
1638 </tr>
1639 </table>
1640 END
1641 ;
1642
1643 if (!($proxysettings{'AUTH_METHOD'} eq 'none')) { if (!($proxysettings{'AUTH_METHOD'} eq 'ident')) { print <<END
1644 <hr size='1'>
1645 <table width='100%'>
1646 <tr>
1647         <td colspan='4'><b>$Lang::tr{'advproxy AUTH global settings'}</b></td>
1648 </tr>
1649 <tr>
1650         <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
1651 </tr>
1652 <tr>
1653         <td class='base'>$Lang::tr{'advproxy AUTH number of auth processes'}:</td>
1654         <td><input type='text' name='AUTH_CHILDREN' value='$proxysettings{'AUTH_CHILDREN'}' size='5' /></td>
1655         <td colspan='2' rowspan= '6' valign='top' class='base'>
1656                 <table cellpadding='0' cellspacing='0'>
1657                         <tr>
1658                         <td class='base'>$Lang::tr{'advproxy AUTH realm'}:</td>
1659                         </tr>
1660                         <tr>
1661                                 <!-- intentionally left empty -->
1662                         </tr>
1663                         <tr>
1664                                 <!-- intentionally left empty -->
1665                         </tr>
1666                         <tr>
1667                         <td><input type='text' name='AUTH_REALM' value='$proxysettings{'AUTH_REALM'}' size='40' /></td>
1668                         </tr>
1669                         <tr>
1670                                 <!-- intentionally left empty -->
1671                         </tr>
1672                         <tr>
1673                                 <!-- intentionally left empty -->
1674                         </tr>
1675                         <tr>
1676                         <td>$Lang::tr{'advproxy AUTH no auth'}:</td>
1677                         </tr>
1678                         <tr>
1679                                 <!-- intentionally left empty -->
1680                         </tr>
1681                         <tr>
1682                                 <!-- intentionally left empty -->
1683                         </tr>
1684                         <tr>
1685                         <td><textarea name='DST_NOAUTH' cols='32' rows='6' wrap='off'>
1686 END
1687 ;
1688
1689 print $proxysettings{'DST_NOAUTH'};
1690
1691 print <<END
1692 </textarea></td>
1693                 </tr>
1694                 </table>
1695         </td>
1696 </tr>
1697 <tr>
1698         <td class='base'>$Lang::tr{'advproxy AUTH auth cache TTL'}:</td>
1699         <td><input type='text' name='AUTH_CACHE_TTL' value='$proxysettings{'AUTH_CACHE_TTL'}' size='5' /></td>
1700 </tr>
1701 <tr>
1702         <td class='base'>$Lang::tr{'advproxy AUTH limit of IP addresses'}:</td>
1703         <td><input type='text' name='AUTH_MAX_USERIP' value='$proxysettings{'AUTH_MAX_USERIP'}' size='5' /></td>
1704 </tr>
1705 <tr>
1706         <td class='base'>$Lang::tr{'advproxy AUTH always required'}:</td>
1707         <td><input type='checkbox' name='AUTH_ALWAYS_REQUIRED' $checked{'AUTH_ALWAYS_REQUIRED'}{'on'} /></td>
1708 </tr>
1709 <tr>
1710         <td colspan='2'>&nbsp;</td>
1711 </tr>
1712 </table>
1713 END
1714 ;
1715 }
1716
1717 # ===================================================================
1718 #  NCSA auth settings
1719 # ===================================================================
1720
1721 if ($proxysettings{'AUTH_METHOD'} eq 'ncsa') {
1722 print <<END
1723 <hr size='1'>
1724 <table width='100%'>
1725 <tr>
1726         <td colspan='4'><b>$Lang::tr{'advproxy NCSA auth'}</b></td>
1727 </tr>
1728 <tr>
1729         <td width='25%' class='base'>$Lang::tr{'advproxy NCSA min password length'}:</td>
1730         <td width='20%'><input type='text' name='NCSA_MIN_PASS_LEN' value='$proxysettings{'NCSA_MIN_PASS_LEN'}' size='5' /></td>
1731         <td width='25%' class='base'>$Lang::tr{'advproxy NCSA redirector bypass'} \'$Lang::tr{'advproxy NCSA grp extended'}\':</td>
1732         <td width='20%'><input type='checkbox' name='NCSA_BYPASS_REDIR' $checked{'NCSA_BYPASS_REDIR'}{'on'} /></td>
1733 </tr>
1734 <tr>
1735         <td colspan='2'><br>&nbsp;<input type='submit' name='ACTION' value='$Lang::tr{'advproxy NCSA user management'}'></td>
1736         <td>&nbsp;</td>
1737         <td>&nbsp;</td>
1738 </tr>
1739 </table>
1740 END
1741 ; }
1742
1743 # ===================================================================
1744 #  IDENTD auth settings
1745 # ===================================================================
1746
1747 if ($proxysettings{'AUTH_METHOD'} eq 'ident') {
1748 print <<END
1749 <hr size ='1'>
1750 <table width='100%'>
1751 <tr>
1752         <td colspan='4'><b>$Lang::tr{'advproxy IDENT identd settings'}</b></td>
1753 </tr>
1754 <tr>
1755         <td width='25%' class='base'>$Lang::tr{'advproxy IDENT required'}:</td>
1756         <td width='20%'><input type='checkbox' name='IDENT_REQUIRED' $checked{'IDENT_REQUIRED'}{'on'} /></td>
1757         <td width='25%' class='base'>$Lang::tr{'advproxy AUTH always required'}:</td>
1758         <td width='30%'><input type='checkbox' name='AUTH_ALWAYS_REQUIRED' $checked{'AUTH_ALWAYS_REQUIRED'}{'on'} /></td>
1759 </tr>
1760 <tr>
1761         <td class='base'>$Lang::tr{'advproxy IDENT timeout'}:</td>
1762         <td><input type='text' name='IDENT_TIMEOUT' value='$proxysettings{'IDENT_TIMEOUT'}' size='5' /></td>
1763         <td>&nbsp;</td>
1764         <td>&nbsp;</td>
1765 </tr>
1766 <tr>
1767         <td colspan='2' class='base'>$Lang::tr{'advproxy IDENT aware hosts'}:</td>
1768         <td colspan='2' class='base'>$Lang::tr{'advproxy AUTH no auth'}:</td>
1769 </tr>
1770 <tr>
1771         <td colspan='2'><textarea name='IDENT_HOSTS' cols='32' rows='6' wrap='off'>
1772 END
1773 ;
1774 if (!$proxysettings{'IDENT_HOSTS'}) {
1775         print "$green_cidr\n";
1776         if ($netsettings{'BLUE_DEV'}) {
1777                 print "$blue_cidr\n";
1778         }
1779 } else {
1780         print $proxysettings{'IDENT_HOSTS'};
1781 }
1782
1783 print <<END
1784 </textarea></td>
1785                         <td colspan='2'><textarea name='DST_NOAUTH' cols='32' rows='6' wrap='off'>
1786 END
1787 ;
1788
1789 print $proxysettings{'DST_NOAUTH'};
1790
1791 print <<END
1792 </textarea></td>
1793 </tr>
1794 </table>
1795 <hr size ='1'>
1796 <table width='100%'>
1797 <tr>
1798         <td colspan='4'><b>$Lang::tr{'advproxy IDENT user based access restrictions'}</b></td>
1799 </tr>
1800 <tr>
1801         <td width='25%' class='base'>$Lang::tr{'advproxy enabled'}:</td>
1802         <td width='20%'><input type='checkbox' name='IDENT_ENABLE_ACL' $checked{'IDENT_ENABLE_ACL'}{'on'} /></td>
1803         <td width='25%'>&nbsp;</td>
1804         <td width='30%'>&nbsp;</td>
1805 </tr>
1806 <tr>
1807         <td colspan='2'><input type='radio' name='IDENT_USER_ACL' value='positive' $checked{'IDENT_USER_ACL'}{'positive'} />
1808         $Lang::tr{'advproxy IDENT use positive access list'}:</td>
1809         <td colspan='2'><input type='radio' name='IDENT_USER_ACL' value='negative' $checked{'IDENT_USER_ACL'}{'negative'} />
1810         $Lang::tr{'advproxy IDENT use negative access list'}:</td>
1811 </tr>
1812 <tr>
1813         <td colspan='2'>$Lang::tr{'advproxy IDENT authorized users'}</td>
1814         <td colspan='2'>$Lang::tr{'advproxy IDENT unauthorized users'}</td>
1815 </tr>
1816 <tr>
1817         <td colspan='2'><textarea name='IDENT_ALLOW_USERS' cols='32' rows='6' wrap='off'>
1818 END
1819 ; }
1820
1821 if ($proxysettings{'AUTH_METHOD'} eq 'ident') { print $proxysettings{'IDENT_ALLOW_USERS'}; }
1822
1823 if ($proxysettings{'AUTH_METHOD'} eq 'ident') { print <<END
1824 </textarea></td>
1825         <td colspan='2'><textarea name='IDENT_DENY_USERS' cols='32' rows='6' wrap='off'>
1826 END
1827 ; }
1828
1829 if ($proxysettings{'AUTH_METHOD'} eq 'ident') { print $proxysettings{'IDENT_DENY_USERS'}; }
1830
1831 if ($proxysettings{'AUTH_METHOD'} eq 'ident') { print <<END
1832 </textarea></td>
1833 </tr>
1834 </table>
1835 END
1836 ; }
1837
1838 # ===================================================================
1839 #  NTLM-AUTH settings
1840 # ===================================================================
1841
1842 if ($proxysettings{'AUTH_METHOD'} eq 'ntlm-auth') {
1843         print <<END;
1844                 <hr size ='1'>
1845                 <table width='100%'>
1846                         <td width='20%' class='base'>$Lang::tr{'advproxy basic authentication'}:</td>
1847                         <td width='40%'><input type='checkbox' name='NTLM_AUTH_BASIC' $checked{'NTLM_AUTH_BASIC'}{'on'} /></td>
1848                         <td colspan='2'>&nbsp;</td>
1849                 </table>
1850
1851                 <hr size='1' />
1852
1853                 <table width='100%'>
1854                         <tr>
1855                                 <td colspan='4'><b>$Lang::tr{'advproxy group access control'}</b></td>
1856                         </tr>
1857                         <tr>
1858                                 <td width='20%' class='base'>$Lang::tr{'advproxy group required'}:</td>
1859                                 <td width='40%'><input type='text' name='NTLM_AUTH_GROUP' value='$proxysettings{'NTLM_AUTH_GROUP'}' size='37' /></td>
1860                                 <td>&nbsp;</td>
1861                                 <td>&nbsp;</td>
1862                         </tr>
1863         </table>
1864 END
1865 }
1866
1867 # ===================================================================
1868 #  LDAP auth settings
1869 # ===================================================================
1870
1871 if ($proxysettings{'AUTH_METHOD'} eq 'ldap') {
1872 print <<END
1873 <hr size='1'>
1874 <table width='100%'>
1875 <tr>
1876         <td colspan='4'><b>$Lang::tr{'advproxy LDAP common settings'}</b></td>
1877 </tr>
1878 <tr>
1879         <td class='base'>$Lang::tr{'advproxy LDAP basedn'}:</td>
1880         <td><input type='text' name='LDAP_BASEDN' value='$proxysettings{'LDAP_BASEDN'}' size='37' /></td>
1881         <td class='base'>$Lang::tr{'advproxy LDAP type'}:</td>
1882         <td class='base'><select name='LDAP_TYPE'>
1883                 <option value='ADS' $selected{'LDAP_TYPE'}{'ADS'}>$Lang::tr{'advproxy LDAP ADS'}</option>
1884                 <option value='NDS' $selected{'LDAP_TYPE'}{'NDS'}>$Lang::tr{'advproxy LDAP NDS'}</option>
1885                 <option value='V2' $selected{'LDAP_TYPE'}{'V2'}>$Lang::tr{'advproxy LDAP V2'}</option>
1886                 <option value='V3' $selected{'LDAP_TYPE'}{'V3'}>$Lang::tr{'advproxy LDAP V3'}</option>
1887         </select></td>
1888 </tr>
1889 <tr>
1890         <td width='20%' class='base'>$Lang::tr{'advproxy LDAP server'}:</td>
1891         <td width='40%'><input type='text' name='LDAP_SERVER' value='$proxysettings{'LDAP_SERVER'}' size='14' /></td>
1892         <td width='20%' class='base'>$Lang::tr{'advproxy LDAP port'}:</td>
1893         <td><input type='text' name='LDAP_PORT' value='$proxysettings{'LDAP_PORT'}' size='3' /></td>
1894 </tr>
1895 </table>
1896 <hr size ='1'>
1897 <table width='100%'>
1898 <tr>
1899         <td colspan='4'><b>$Lang::tr{'advproxy LDAP binddn settings'}</b></td>
1900 </tr>
1901 <tr>
1902         <td width='20%' class='base'>$Lang::tr{'advproxy LDAP binddn username'}:</td>
1903         <td width='40%'><input type='text' name='LDAP_BINDDN_USER' value='$proxysettings{'LDAP_BINDDN_USER'}' size='37' /></td>
1904         <td width='20%' class='base'>$Lang::tr{'advproxy LDAP binddn password'}:</td>
1905         <td><input type='password' name='LDAP_BINDDN_PASS' value='$proxysettings{'LDAP_BINDDN_PASS'}' size='14' /></td>
1906 </tr>
1907 </table>
1908 <hr size ='1'>
1909 <table width='100%'>
1910 <tr>
1911         <td colspan='4'><b>$Lang::tr{'advproxy LDAP group access control'}</b></td>
1912 </tr>
1913 <tr>
1914         <td width='20%' class='base'>$Lang::tr{'advproxy LDAP group required'}:</td>
1915         <td width='40%'><input type='text' name='LDAP_GROUP' value='$proxysettings{'LDAP_GROUP'}' size='37' /></td>
1916         <td>&nbsp;</td>
1917         <td>&nbsp;</td>
1918 </tr>
1919 </table>
1920 END
1921 ; }
1922
1923 # ===================================================================
1924 #  RADIUS auth settings
1925 # ===================================================================
1926
1927 if ($proxysettings{'AUTH_METHOD'} eq 'radius') {
1928 print <<END
1929 <hr size='1'>
1930 <table width='100%'>
1931 <tr>
1932         <td colspan='4'><b>$Lang::tr{'advproxy RADIUS radius settings'}</b></td>
1933 </tr>
1934 <tr>
1935         <td width='25%' class='base'>$Lang::tr{'advproxy RADIUS server'}:</td>
1936         <td width='20%'><input type='text' name='RADIUS_SERVER' value='$proxysettings{'RADIUS_SERVER'}' size='14' /></td>
1937         <td width='25%' class='base'>$Lang::tr{'advproxy RADIUS port'}:</td>
1938         <td width='30%'><input type='text' name='RADIUS_PORT' value='$proxysettings{'RADIUS_PORT'}' size='3' /></td>
1939 </tr>
1940 <tr>
1941         <td class='base'>$Lang::tr{'advproxy RADIUS identifier'}:</td>
1942         <td><input type='text' name='RADIUS_IDENTIFIER' value='$proxysettings{'RADIUS_IDENTIFIER'}' size='14' /></td>
1943         <td class='base'>$Lang::tr{'advproxy RADIUS secret'}:</td>
1944         <td><input type='password' name='RADIUS_SECRET' value='$proxysettings{'RADIUS_SECRET'}' size='14' /></td>
1945 </tr>
1946 </table>
1947 <hr size ='1'>
1948 <table width='100%'>
1949 <tr>
1950         <td colspan='4'><b>$Lang::tr{'advproxy RADIUS user based access restrictions'}</b></td>
1951 </tr>
1952 <tr>
1953         <td width='25%' class='base'>$Lang::tr{'advproxy enabled'}:</td>
1954         <td width='20%'><input type='checkbox' name='RADIUS_ENABLE_ACL' $checked{'RADIUS_ENABLE_ACL'}{'on'} /></td>
1955         <td width='25%'>&nbsp;</td>
1956         <td width='30%'>&nbsp;</td>
1957 </tr>
1958 <tr>
1959         <td colspan='2'><input type='radio' name='RADIUS_USER_ACL' value='positive' $checked{'RADIUS_USER_ACL'}{'positive'} />
1960         $Lang::tr{'advproxy RADIUS use positive access list'}:</td>
1961         <td colspan='2'><input type='radio' name='RADIUS_USER_ACL' value='negative' $checked{'RADIUS_USER_ACL'}{'negative'} />
1962         $Lang::tr{'advproxy RADIUS use negative access list'}:</td>
1963 </tr>
1964 <tr>
1965         <td colspan='2'>$Lang::tr{'advproxy RADIUS authorized users'}</td>
1966         <td colspan='2'>$Lang::tr{'advproxy RADIUS unauthorized users'}</td>
1967 </tr>
1968 <tr>
1969         <td colspan='2'><textarea name='RADIUS_ALLOW_USERS' cols='32' rows='6' wrap='off'>
1970 END
1971 ; }
1972
1973 if ($proxysettings{'AUTH_METHOD'} eq 'radius') { print $proxysettings{'RADIUS_ALLOW_USERS'}; }
1974
1975 if ($proxysettings{'AUTH_METHOD'} eq 'radius') { print <<END
1976 </textarea></td>
1977         <td colspan='2'><textarea name='RADIUS_DENY_USERS' cols='32' rows='6' wrap='off'>
1978 END
1979 ; }
1980
1981 if ($proxysettings{'AUTH_METHOD'} eq 'radius') { print $proxysettings{'RADIUS_DENY_USERS'}; }
1982
1983 if ($proxysettings{'AUTH_METHOD'} eq 'radius') { print <<END
1984 </textarea></td>
1985 </tr>
1986 </table>
1987 END
1988 ; }
1989
1990 # ===================================================================
1991
1992 }
1993
1994 print "<table>\n";
1995
1996 if ($proxysettings{'AUTH_METHOD'} eq 'none') {
1997 print <<END
1998 <td><input type='hidden' name='AUTH_CHILDREN'        value='$proxysettings{'AUTH_CHILDREN'}'></td>
1999 <td><input type='hidden' name='AUTH_CACHE_TTL'       value='$proxysettings{'AUTH_CACHE_TTL'}' size='5' /></td>
2000 <td><input type='hidden' name='AUTH_MAX_USERIP'      value='$proxysettings{'AUTH_MAX_USERIP'}' size='5' /></td>
2001 <td><input type='hidden' name='AUTH_ALWAYS_REQUIRED' value='$proxysettings{'AUTH_ALWAYS_REQUIRED'}'></td>
2002 <td><input type='hidden' name='AUTH_REALM'           value='$proxysettings{'AUTH_REALM'}'></td>
2003 <td><input type='hidden' name='DST_NOAUTH'           value='$proxysettings{'DST_NOAUTH'}'></td>
2004 END
2005 ; }
2006
2007 if ($proxysettings{'AUTH_METHOD'} eq 'ident') {
2008 print <<END
2009 <td><input type='hidden' name='AUTH_CHILDREN'        value='$proxysettings{'AUTH_CHILDREN'}'></td>
2010 <td><input type='hidden' name='AUTH_CACHE_TTL'       value='$proxysettings{'AUTH_CACHE_TTL'}' size='5' /></td>
2011 <td><input type='hidden' name='AUTH_MAX_USERIP'      value='$proxysettings{'AUTH_MAX_USERIP'}' size='5' /></td>
2012 <td><input type='hidden' name='AUTH_REALM'           value='$proxysettings{'AUTH_REALM'}'></td>
2013 END
2014 ; }
2015
2016 if (!($proxysettings{'AUTH_METHOD'} eq 'ncsa')) {
2017 print <<END
2018 <td><input type='hidden' name='NCSA_MIN_PASS_LEN' value='$proxysettings{'NCSA_MIN_PASS_LEN'}'></td>
2019 <td><input type='hidden' name='NCSA_BYPASS_REDIR' value='$proxysettings{'NCSA_BYPASS_REDIR'}'></td>
2020 END
2021 ; }
2022
2023 if (!($proxysettings{'AUTH_METHOD'} eq 'ident')) {
2024 print <<END
2025 <td><input type='hidden' name='IDENT_REQUIRED'    value='$proxysettings{'IDENT_REQUIRED'}'></td>
2026 <td><input type='hidden' name='IDENT_TIMEOUT'     value='$proxysettings{'IDENT_TIMEOUT'}'></td>
2027 <td><input type='hidden' name='IDENT_HOSTS'       value='$proxysettings{'IDENT_HOSTS'}'></td>
2028 <td><input type='hidden' name='IDENT_ENABLE_ACL'  value='$proxysettings{'IDENT_ENABLE_ACL'}'></td>
2029 <td><input type='hidden' name='IDENT_USER_ACL'    value='$proxysettings{'IDENT_USER_ACL'}'></td>
2030 <td><input type='hidden' name='IDENT_ALLOW_USERS' value='$proxysettings{'IDENT_ALLOW_USERS'}'></td>
2031 <td><input type='hidden' name='IDENT_DENY_USERS'  value='$proxysettings{'IDENT_DENY_USERS'}'></td>
2032 END
2033 ; }
2034
2035 if (!($proxysettings{'AUTH_METHOD'} eq 'ldap')) {
2036 print <<END
2037 <td><input type='hidden' name='LDAP_BASEDN'      value='$proxysettings{'LDAP_BASEDN'}'></td>
2038 <td><input type='hidden' name='LDAP_TYPE'        value='$proxysettings{'LDAP_TYPE'}'></td>
2039 <td><input type='hidden' name='LDAP_SERVER'      value='$proxysettings{'LDAP_SERVER'}'></td>
2040 <td><input type='hidden' name='LDAP_PORT'        value='$proxysettings{'LDAP_PORT'}'></td>
2041 <td><input type='hidden' name='LDAP_BINDDN_USER' value='$proxysettings{'LDAP_BINDDN_USER'}'></td>
2042 <td><input type='hidden' name='LDAP_BINDDN_PASS' value='$proxysettings{'LDAP_BINDDN_PASS'}'></td>
2043 <td><input type='hidden' name='LDAP_GROUP'       value='$proxysettings{'LDAP_GROUP'}'></td>
2044 END
2045 ; }
2046
2047 if (!($proxysettings{'AUTH_METHOD'} eq 'radius')) {
2048 print <<END
2049 <td><input type='hidden' name='RADIUS_SERVER'      value='$proxysettings{'RADIUS_SERVER'}'></td>
2050 <td><input type='hidden' name='RADIUS_PORT'        value='$proxysettings{'RADIUS_PORT'}'></td>
2051 <td><input type='hidden' name='RADIUS_IDENTIFIER'  value='$proxysettings{'RADIUS_IDENTIFIER'}'></td>
2052 <td><input type='hidden' name='RADIUS_SECRET'      value='$proxysettings{'RADIUS_SECRET'}'></td>
2053 <td><input type='hidden' name='RADIUS_ENABLE_ACL'  value='$proxysettings{'RADIUS_ENABLE_ACL'}'></td>
2054 <td><input type='hidden' name='RADIUS_USER_ACL'    value='$proxysettings{'RADIUS_USER_ACL'}'></td>
2055 <td><input type='hidden' name='RADIUS_ALLOW_USERS' value='$proxysettings{'RADIUS_ALLOW_USERS'}'></td>
2056 <td><input type='hidden' name='RADIUS_DENY_USERS'  value='$proxysettings{'RADIUS_DENY_USERS'}'></td>
2057 END
2058 ; }
2059
2060 print "</table>\n";
2061
2062 print <<END
2063 <hr size='1'>
2064 END
2065 ;
2066
2067 print <<END
2068 <table width='100%'>
2069 <tr>
2070         <td>&nbsp;</td>
2071         <td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
2072         <td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'proxy reconfigure'}' /></td>
2073         <td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'advproxy save and restart'}' /></td>
2074         <td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'advproxy clear cache'}' /></td>
2075         <td>&nbsp;</td>
2076 </tr>
2077
2078 </table>
2079 <br />
2080 <table width='100%'>
2081 <tr>
2082         <td><img src='/blob.gif' align='top' alt='*' />&nbsp;<font class='base'>$Lang::tr{'required field'}</font></td>
2083         <td align='right'>&nbsp;</td>
2084 </tr>
2085 </table>
2086 </form>
2087 END
2088 ;
2089
2090 &Header::closebox();
2091
2092 } else {
2093
2094 # ===================================================================
2095 #  NCSA user management
2096 # ===================================================================
2097
2098 &Header::openbox('100%', 'left', "$Lang::tr{'advproxy NCSA auth'}");
2099 print <<END
2100 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
2101 <table width='100%'>
2102 <tr>
2103         <td colspan='4'><b>$Lang::tr{'advproxy NCSA user management'}</b></td>
2104 </tr>
2105 <tr>
2106         <td width='25%' class='base'>$Lang::tr{'advproxy NCSA username'}:</td>
2107         <td width='25%'><input type='text' name='NCSA_USERNAME' value='$proxysettings{'NCSA_USERNAME'}' size='12'
2108 END
2109 ;
2110         if ($proxysettings{'ACTION'} eq $Lang::tr{'edit'}) { print " readonly='readonly' "; }
2111         print <<END
2112          /></td>
2113         <td width='25%' class='base'>$Lang::tr{'advproxy NCSA group'}:</td>
2114         <td class='base'>
2115                 <select name='NCSA_GROUP'>
2116                 <option value='standard' $selected{'NCSA_GROUP'}{'standard'}>$Lang::tr{'advproxy NCSA grp standard'}</option>
2117                 <option value='extended' $selected{'NCSA_GROUP'}{'extended'}>$Lang::tr{'advproxy NCSA grp extended'}</option>
2118                 <option value='disabled' $selected{'NCSA_GROUP'}{'disabled'}>$Lang::tr{'advproxy NCSA grp disabled'}</option>
2119                 </select>
2120         </td>
2121
2122 </tr>
2123 <tr>
2124         <td class='base'>$Lang::tr{'advproxy NCSA password'}:</td>
2125         <td><input type='password' name='NCSA_PASS' value='$proxysettings{'NCSA_PASS'}' size='14' /></td>
2126         <td class='base'>$Lang::tr{'advproxy NCSA password confirm'}:</td>
2127         <td><input type='password' name='NCSA_PASS_CONFIRM' value='$proxysettings{'NCSA_PASS_CONFIRM'}' size='14' /></td>
2128 </tr>
2129 </table>
2130 <br>
2131 <table>
2132 <tr>
2133         <td>&nbsp;</td>
2134         <td><input type='submit' name='SUBMIT' value='$ncsa_buttontext' /></td>
2135         <td><input type='hidden' name='ACTION' value='$Lang::tr{'add'}' /></td>
2136         <td><input type='hidden' name='NCSA_MIN_PASS_LEN' value='$proxysettings{'NCSA_MIN_PASS_LEN'}'></td>
2137 END
2138 ;
2139         if ($proxysettings{'ACTION'} eq $Lang::tr{'edit'}) {
2140                 print "<td><input type='reset' name='ACTION' value='$Lang::tr{'advproxy reset'}' /></td>\n";
2141         }
2142
2143 print <<END
2144         <td>&nbsp;</td>
2145         <td>&nbsp;</td>
2146         <td><input type='button' name='return2main' value='$Lang::tr{'advproxy back to main page'}' onClick='self.location.href="$ENV{'SCRIPT_NAME'}"'></td>
2147 </tr>
2148 </table>
2149 </form>
2150 <hr size='1'>
2151 <table width='100%'>
2152 <tr>
2153         <td><b>$Lang::tr{'advproxy NCSA user accounts'}:</b></td>
2154 </tr>
2155 </table>
2156 <table width='100%' align='center'>
2157 END
2158 ;
2159
2160 if (-e $extgrp)
2161 {
2162         open(FILE, $extgrp); @grouplist = <FILE>; close(FILE);
2163         foreach $user (@grouplist) { chomp($user); push(@userlist,$user.":extended"); }
2164 }
2165 if (-e $stdgrp)
2166 {
2167         open(FILE, $stdgrp); @grouplist = <FILE>; close(FILE);
2168         foreach $user (@grouplist) { chomp($user); push(@userlist,$user.":standard"); }
2169 }
2170 if (-e $disgrp)
2171 {
2172         open(FILE, $disgrp); @grouplist = <FILE>; close(FILE);
2173         foreach $user (@grouplist) { chomp($user); push(@userlist,$user.":disabled"); }
2174 }
2175
2176 @userlist = sort(@userlist);
2177
2178 # If the password file contains entries, print entries and action icons
2179
2180 if ( ! -z "$userdb" ) {
2181         print <<END
2182         <tr>
2183                 <td width='30%' class='boldbase' align='center'><b><i>$Lang::tr{'advproxy NCSA username'}</i></b></td>
2184                 <td width='30%' class='boldbase' align='center'><b><i>$Lang::tr{'advproxy NCSA group membership'}</i></b></td>
2185                 <td class='boldbase' colspan='2' align='center'>&nbsp;</td>
2186         </tr>
2187 END
2188 ;
2189         $id = 0;
2190         foreach $line (@userlist)
2191         {
2192                 $id++;
2193                 chomp($line);
2194                 @temp = split(/:/,$line);
2195                 if($proxysettings{'ACTION'} eq $Lang::tr{'edit'} && $proxysettings{'ID'} eq $line) {
2196                         print "<tr bgcolor='$Header::colouryellow'>\n"; }
2197                 elsif ($id % 2) {
2198                         print "<tr bgcolor='$color{'color20'}'>\n"; }
2199                 else {
2200                         print "<tr bgcolor='$color{'color22'}'>\n"; }
2201
2202                 print <<END
2203                 <td align='center'>$temp[0]</td>
2204                 <td align='center'>
2205 END
2206 ;
2207                 if ($temp[1] eq 'standard') {
2208                         print $Lang::tr{'advproxy NCSA grp standard'};
2209                 } elsif ($temp[1] eq 'extended') {
2210                         print $Lang::tr{'advproxy NCSA grp extended'};
2211                 } elsif ($temp[1] eq 'disabled') {
2212                         print $Lang::tr{'advproxy NCSA grp disabled'}; }
2213                 print <<END
2214                 </td>
2215                 <td width='8%' align='center'>
2216                 <form method='post' name='frma$id' action='$ENV{'SCRIPT_NAME'}'>
2217                 <input type='image' name='$Lang::tr{'edit'}' src='/images/edit.gif' title='$Lang::tr{'edit'}' alt='$Lang::tr{'edit'}' />
2218                 <input type='hidden' name='ID' value='$line' />
2219                 <input type='hidden' name='ACTION' value='$Lang::tr{'edit'}' />
2220                 </form>
2221                 </td>
2222
2223                 <td width='8%' align='center'>
2224                 <form method='post' name='frmb$id' action='$ENV{'SCRIPT_NAME'}'>
2225                 <input type='image' name='$Lang::tr{'remove'}' src='/images/delete.gif' title='$Lang::tr{'remove'}' alt='$Lang::tr{'remove'}' />
2226                 <input type='hidden' name='ID' value='$temp[0]' />
2227                 <input type='hidden' name='ACTION' value='$Lang::tr{'remove'}' />
2228                 </form>
2229                 </td>
2230         </tr>
2231 END
2232 ;
2233         }
2234
2235 print <<END
2236 </table>
2237 <br>
2238 <table>
2239 <tr>
2240         <td class='boldbase'>&nbsp; <b>$Lang::tr{'legend'}:</b></td>
2241         <td>&nbsp; &nbsp; <img src='/images/edit.gif' alt='$Lang::tr{'edit'}' /></td>
2242         <td class='base'>$Lang::tr{'edit'}</td>
2243         <td>&nbsp; &nbsp; <img src='/images/delete.gif' alt='$Lang::tr{'remove'}' /></td>
2244         <td class='base'>$Lang::tr{'remove'}</td>
2245 </tr>
2246 END
2247 ;
2248 } else {
2249         print <<END
2250         <tr>
2251                 <td><i>$Lang::tr{'advproxy NCSA no accounts'}</i></td>
2252         </tr>
2253 END
2254 ;
2255 }
2256
2257 print <<END
2258 </table>
2259 END
2260 ;
2261
2262 &Header::closebox();
2263
2264 }
2265
2266 # ===================================================================
2267
2268 &Header::closebigbox();
2269
2270 &Header::closepage();
2271
2272 # -------------------------------------------------------------------
2273
2274 sub read_acls
2275 {
2276         if (-e "$acl_src_subnets") {
2277                 open(FILE,"$acl_src_subnets");
2278                 delete $proxysettings{'SRC_SUBNETS'};
2279                 while (<FILE>) { $proxysettings{'SRC_SUBNETS'} .= $_ };
2280                 close(FILE);
2281         }
2282         if (-e "$acl_src_banned_ip") {
2283                 open(FILE,"$acl_src_banned_ip");
2284                 delete $proxysettings{'SRC_BANNED_IP'};
2285                 while (<FILE>) { $proxysettings{'SRC_BANNED_IP'} .= $_ };
2286                 close(FILE);
2287         }
2288         if (-e "$acl_src_banned_mac") {
2289                 open(FILE,"$acl_src_banned_mac");
2290                 delete $proxysettings{'SRC_BANNED_MAC'};
2291                 while (<FILE>) { $proxysettings{'SRC_BANNED_MAC'} .= $_ };
2292                 close(FILE);
2293         }
2294         if (-e "$acl_src_unrestricted_ip") {
2295                 open(FILE,"$acl_src_unrestricted_ip");
2296                 delete $proxysettings{'SRC_UNRESTRICTED_IP'};
2297                 while (<FILE>) { $proxysettings{'SRC_UNRESTRICTED_IP'} .= $_ };
2298                 close(FILE);
2299         }
2300         if (-e "$acl_src_unrestricted_mac") {
2301                 open(FILE,"$acl_src_unrestricted_mac");
2302                 delete $proxysettings{'SRC_UNRESTRICTED_MAC'};
2303                 while (<FILE>) { $proxysettings{'SRC_UNRESTRICTED_MAC'} .= $_ };
2304                 close(FILE);
2305         }
2306         if (-e "$acl_dst_nocache") {
2307                 open(FILE,"$acl_dst_nocache");
2308                 delete $proxysettings{'DST_NOCACHE'};
2309                 while (<FILE>) { $proxysettings{'DST_NOCACHE'} .= $_ };
2310                 close(FILE);
2311         }
2312         if (-e "$acl_dst_noauth") {
2313                 open(FILE,"$acl_dst_noauth");
2314                 delete $proxysettings{'DST_NOAUTH'};
2315                 while (<FILE>) { $proxysettings{'DST_NOAUTH'} .= $_ };
2316                 close(FILE);
2317         }
2318         if (-e "$acl_dst_noproxy_ip") {
2319                 open(FILE,"$acl_dst_noproxy_ip");
2320                 delete $proxysettings{'DST_NOPROXY_IP'};
2321                 while (<FILE>) { $proxysettings{'DST_NOPROXY_IP'} .= $_ };
2322                 close(FILE);
2323         }
2324         if (-e "$acl_dst_noproxy_url") {
2325                 open(FILE,"$acl_dst_noproxy_url");
2326                 delete $proxysettings{'DST_NOPROXY_URL'};
2327                 while (<FILE>) { $proxysettings{'DST_NOPROXY_URL'} .= $_ };
2328                 close(FILE);
2329         }
2330         if (-e "$acl_ports_safe") {
2331                 open(FILE,"$acl_ports_safe");
2332                 delete $proxysettings{'PORTS_SAFE'};
2333                 while (<FILE>) { $proxysettings{'PORTS_SAFE'} .= $_ };
2334                 close(FILE);
2335         }
2336         if (-e "$acl_ports_ssl") {
2337                 open(FILE,"$acl_ports_ssl");
2338                 delete $proxysettings{'PORTS_SSL'};
2339                 while (<FILE>) { $proxysettings{'PORTS_SSL'} .= $_ };
2340                 close(FILE);
2341         }
2342         if (-e "$mimetypes") {
2343                 open(FILE,"$mimetypes");
2344                 delete $proxysettings{'MIME_TYPES'};
2345                 while (<FILE>) { $proxysettings{'MIME_TYPES'} .= $_ };
2346                 close(FILE);
2347         }
2348         if (-e "$raddir/radauth.allowusers") {
2349                 open(FILE,"$raddir/radauth.allowusers");
2350                 delete $proxysettings{'RADIUS_ALLOW_USERS'};
2351                 while (<FILE>) { $proxysettings{'RADIUS_ALLOW_USERS'} .= $_ };
2352                 close(FILE);
2353         }
2354         if (-e "$raddir/radauth.denyusers") {
2355                 open(FILE,"$raddir/radauth.denyusers");
2356                 delete $proxysettings{'RADIUS_DENY_USERS'};
2357                 while (<FILE>) { $proxysettings{'RADIUS_DENY_USERS'} .= $_ };
2358                 close(FILE);
2359         }
2360         if (-e "$identdir/identauth.allowusers") {
2361                 open(FILE,"$identdir/identauth.allowusers");
2362                 delete $proxysettings{'IDENT_ALLOW_USERS'};
2363                 while (<FILE>) { $proxysettings{'IDENT_ALLOW_USERS'} .= $_ };
2364                 close(FILE);
2365         }
2366         if (-e "$identdir/identauth.denyusers") {
2367                 open(FILE,"$identdir/identauth.denyusers");
2368                 delete $proxysettings{'IDENT_DENY_USERS'};
2369                 while (<FILE>) { $proxysettings{'IDENT_DENY_USERS'} .= $_ };
2370                 close(FILE);
2371         }
2372         if (-e "$identhosts") {
2373                 open(FILE,"$identhosts");
2374                 delete $proxysettings{'IDENT_HOSTS'};
2375                 while (<FILE>) { $proxysettings{'IDENT_HOSTS'} .= $_ };
2376                 close(FILE);
2377         }
2378         if (-e "$cre_groups") {
2379                 open(FILE,"$cre_groups");
2380                 delete $proxysettings{'CRE_GROUPS'};
2381                 while (<FILE>) { $proxysettings{'CRE_GROUPS'} .= $_ };
2382                 close(FILE);
2383         }
2384         if (-e "$cre_svhosts") {
2385                 open(FILE,"$cre_svhosts");
2386                 delete $proxysettings{'CRE_SVHOSTS'};
2387                 while (<FILE>) { $proxysettings{'CRE_SVHOSTS'} .= $_ };
2388                 close(FILE);
2389         }
2390 }
2391
2392 # -------------------------------------------------------------------
2393
2394 sub check_acls
2395 {
2396         @temp = split(/\n/,$proxysettings{'PORTS_SAFE'});
2397         undef $proxysettings{'PORTS_SAFE'};
2398         foreach (@temp)
2399         {
2400                 s/^\s+//g; s/\s+$//g;
2401                 if ($_)
2402                 {
2403                         $line = $_;
2404                         if (/^[^#]+\s+#\sSquids\sport/) { s/(^[^#]+)(\s+#\sSquids\sport)/$proxysettings{'PROXY_PORT'}\2/; $line=$_; }
2405                         s/#.*//g; s/\s+//g;
2406                         if (/.*-.*-.*/) { $errormessage = $Lang::tr{'advproxy errmsg invalid destination port'}; }
2407                         @templist = split(/-/);
2408                         foreach (@templist) { unless (&General::validport($_)) { $errormessage = $Lang::tr{'advproxy errmsg invalid destination port'}; } }
2409                         $proxysettings{'PORTS_SAFE'} .= $line."\n";
2410                 }
2411         }
2412
2413         @temp = split(/\n/,$proxysettings{'PORTS_SSL'});
2414         undef $proxysettings{'PORTS_SSL'};
2415         foreach (@temp)
2416         {
2417                 s/^\s+//g; s/\s+$//g;
2418                 if ($_)
2419                 {
2420                         $line = $_;
2421                         s/#.*//g; s/\s+//g;
2422                         if (/.*-.*-.*/) { $errormessage = $Lang::tr{'advproxy errmsg invalid destination port'}; }
2423                         @templist = split(/-/);
2424                         foreach (@templist) { unless (&General::validport($_)) { $errormessage = $Lang::tr{'advproxy errmsg invalid destination port'}; } }
2425                         $proxysettings{'PORTS_SSL'} .= $line."\n";
2426                 }
2427         }
2428
2429         @temp = split(/\n/,$proxysettings{'DST_NOCACHE'});
2430         undef $proxysettings{'DST_NOCACHE'};
2431         foreach (@temp)
2432         {
2433                 s/^\s+//g;
2434                 unless (/^#/) { s/\s+//g; }
2435                 if ($_)
2436                 {
2437                         if (/^\./) { $_ = '*'.$_; }
2438                         $proxysettings{'DST_NOCACHE'} .= $_."\n";
2439                 }
2440         }
2441
2442         @temp = split(/\n/,$proxysettings{'SRC_SUBNETS'});
2443         undef $proxysettings{'SRC_SUBNETS'};
2444         foreach (@temp)
2445         {
2446                 s/^\s+//g; s/\s+$//g;
2447                 if ($_)
2448                 {
2449                         unless (&General::validipandmask($_)) { $errormessage = $Lang::tr{'advproxy errmsg invalid ip or mask'}; }
2450                         $proxysettings{'SRC_SUBNETS'} .= $_."\n";
2451                 }
2452         }
2453
2454         @temp = split(/\n/,$proxysettings{'SRC_BANNED_IP'});
2455         undef $proxysettings{'SRC_BANNED_IP'};
2456         foreach (@temp)
2457         {
2458                 s/^\s+//g; s/\s+$//g;
2459                 if ($_)
2460                 {
2461                         unless (&General::validipormask($_)) { $errormessage = $Lang::tr{'advproxy errmsg invalid ip or mask'}; }
2462                         $proxysettings{'SRC_BANNED_IP'} .= $_."\n";
2463                 }
2464         }
2465
2466         @temp = split(/\n/,$proxysettings{'SRC_BANNED_MAC'});
2467         undef $proxysettings{'SRC_BANNED_MAC'};
2468         foreach (@temp)
2469         {
2470                 s/^\s+//g; s/\s+$//g; s/-/:/g;
2471                 if ($_)
2472                 {
2473                         unless (&General::validmac($_)) { $errormessage = $Lang::tr{'advproxy errmsg invalid mac'}; }
2474                         $proxysettings{'SRC_BANNED_MAC'} .= $_."\n";
2475                 }
2476         }
2477
2478         @temp = split(/\n/,$proxysettings{'SRC_UNRESTRICTED_IP'});
2479         undef $proxysettings{'SRC_UNRESTRICTED_IP'};
2480         foreach (@temp)
2481         {
2482                 s/^\s+//g; s/\s+$//g;
2483                 if ($_)
2484                 {
2485                         unless (&General::validipormask($_)) { $errormessage = $Lang::tr{'advproxy errmsg invalid ip or mask'}; }
2486                         $proxysettings{'SRC_UNRESTRICTED_IP'} .= $_."\n";
2487                 }
2488         }
2489
2490         @temp = split(/\n/,$proxysettings{'SRC_UNRESTRICTED_MAC'});
2491         undef $proxysettings{'SRC_UNRESTRICTED_MAC'};
2492         foreach (@temp)
2493         {
2494                 s/^\s+//g; s/\s+$//g; s/-/:/g;
2495                 if ($_)
2496                 {
2497                         unless (&General::validmac($_)) { $errormessage = $Lang::tr{'advproxy errmsg invalid mac'}; }
2498                         $proxysettings{'SRC_UNRESTRICTED_MAC'} .= $_."\n";
2499                 }
2500         }
2501
2502         @temp = split(/\n/,$proxysettings{'DST_NOAUTH'});
2503         undef $proxysettings{'DST_NOAUTH'};
2504         foreach (@temp)
2505         {
2506                 s/^\s+//g;
2507                 unless (/^#/) { s/\s+//g; }
2508                 if ($_)
2509                 {
2510                         if (/^\./) { $_ = '*'.$_; }
2511                         $proxysettings{'DST_NOAUTH'} .= $_."\n";
2512                 }
2513         }
2514
2515         @temp = split(/\n/,$proxysettings{'DST_NOPROXY_IP'});
2516         undef $proxysettings{'DST_NOPROXY_IP'};
2517         foreach (@temp)
2518         {
2519                         s/^\s+//g; s/\s+$//g;
2520                         if ($_)
2521                         {
2522                                         unless (&General::validipormask($_)) { $errormessage = $Lang::tr{'advproxy errmsg wpad invalid ip or mask'}; }
2523                                         $proxysettings{'DST_NOPROXY_IP'} .= $_."\n";
2524                         }
2525         }
2526
2527         @temp = split(/\n/,$proxysettings{'DST_NOPROXY_URL'});
2528         undef $proxysettings{'DST_NOPROXY_URL'};
2529         foreach (@temp)
2530         {
2531                         s/^\s+//g;
2532                         unless (/^#/) { s/\s+//g; }
2533                         if ($_)
2534                         {
2535                                         if (/^\./) { $_ = '*'.$_; }
2536                                         $proxysettings{'DST_NOPROXY_URL'} .= $_."\n";
2537                         }
2538         }
2539
2540         if (($proxysettings{'NTLM_ENABLE_ACL'} eq 'on') && ($proxysettings{'NTLM_USER_ACL'} eq 'positive'))
2541         {
2542                 @temp = split(/\n/,$proxysettings{'NTLM_ALLOW_USERS'});
2543                 undef $proxysettings{'NTLM_ALLOW_USERS'};
2544                 foreach (@temp)
2545                 {
2546                         s/^\s+//g; s/\s+$//g;
2547                         if ($_) { $proxysettings{'NTLM_ALLOW_USERS'} .= $_."\n"; }
2548                 }
2549                 if ($proxysettings{'NTLM_ALLOW_USERS'} eq '') { $errormessage = $Lang::tr{'advproxy errmsg acl cannot be empty'}; }
2550         }
2551
2552         if (($proxysettings{'NTLM_ENABLE_ACL'} eq 'on') && ($proxysettings{'NTLM_USER_ACL'} eq 'negative'))
2553         {
2554                 @temp = split(/\n/,$proxysettings{'NTLM_DENY_USERS'});
2555                 undef $proxysettings{'NTLM_DENY_USERS'};
2556                 foreach (@temp)
2557                 {
2558                         s/^\s+//g; s/\s+$//g;
2559                         if ($_) { $proxysettings{'NTLM_DENY_USERS'} .= $_."\n"; }
2560                 }
2561                 if ($proxysettings{'NTLM_DENY_USERS'} eq '') { $errormessage = $Lang::tr{'advproxy errmsg acl cannot be empty'}; }
2562         }
2563
2564         if (($proxysettings{'IDENT_ENABLE_ACL'} eq 'on') && ($proxysettings{'IDENT_USER_ACL'} eq 'positive'))
2565         {
2566                 @temp = split(/\n/,$proxysettings{'IDENT_ALLOW_USERS'});
2567                 undef $proxysettings{'IDENT_ALLOW_USERS'};
2568                 foreach (@temp)
2569                 {
2570                         s/^\s+//g; s/\s+$//g;
2571                         if ($_) { $proxysettings{'IDENT_ALLOW_USERS'} .= $_."\n"; }
2572                 }
2573                 if ($proxysettings{'IDENT_ALLOW_USERS'} eq '') { $errormessage = $Lang::tr{'advproxy errmsg acl cannot be empty'}; }
2574         }
2575
2576         if (($proxysettings{'IDENT_ENABLE_ACL'} eq 'on') && ($proxysettings{'IDENT_USER_ACL'} eq 'negative'))
2577         {
2578                 @temp = split(/\n/,$proxysettings{'IDENT_DENY_USERS'});
2579                 undef $proxysettings{'IDENT_DENY_USERS'};
2580                 foreach (@temp)
2581                 {
2582                         s/^\s+//g; s/\s+$//g;
2583                         if ($_) { $proxysettings{'IDENT_DENY_USERS'} .= $_."\n"; }
2584                 }
2585                 if ($proxysettings{'IDENT_DENY_USERS'} eq '') { $errormessage = $Lang::tr{'advproxy errmsg acl cannot be empty'}; }
2586         }
2587
2588         if (($proxysettings{'RADIUS_ENABLE_ACL'} eq 'on') && ($proxysettings{'RADIUS_USER_ACL'} eq 'positive'))
2589         {
2590                 @temp = split(/\n/,$proxysettings{'RADIUS_ALLOW_USERS'});
2591                 undef $proxysettings{'RADIUS_ALLOW_USERS'};
2592                 foreach (@temp)
2593                 {
2594                         s/^\s+//g; s/\s+$//g;
2595                         if ($_) { $proxysettings{'RADIUS_ALLOW_USERS'} .= $_."\n"; }
2596                 }
2597                 if ($proxysettings{'RADIUS_ALLOW_USERS'} eq '') { $errormessage = $Lang::tr{'advproxy errmsg acl cannot be empty'}; }
2598         }
2599
2600         if (($proxysettings{'RADIUS_ENABLE_ACL'} eq 'on') && ($proxysettings{'RADIUS_USER_ACL'} eq 'negative'))
2601         {
2602                 @temp = split(/\n/,$proxysettings{'RADIUS_DENY_USERS'});
2603                 undef $proxysettings{'RADIUS_DENY_USERS'};
2604                 foreach (@temp)
2605                 {
2606                         s/^\s+//g; s/\s+$//g;
2607                         if ($_) { $proxysettings{'RADIUS_DENY_USERS'} .= $_."\n"; }
2608                 }
2609                 if ($proxysettings{'RADIUS_DENY_USERS'} eq '') { $errormessage = $Lang::tr{'advproxy errmsg acl cannot be empty'}; }
2610         }
2611
2612         @temp = split(/\n/,$proxysettings{'IDENT_HOSTS'});
2613         undef $proxysettings{'IDENT_HOSTS'};
2614         foreach (@temp)
2615         {
2616                 s/^\s+//g; s/\s+$//g;
2617                 if ($_)
2618                 {
2619                         unless (&General::validipormask($_)) { $errormessage = $Lang::tr{'advproxy errmsg invalid ip or mask'}; }
2620                         $proxysettings{'IDENT_HOSTS'} .= $_."\n";
2621                 }
2622         }
2623
2624         @temp = split(/\n/,$proxysettings{'CRE_SVHOSTS'});
2625         undef $proxysettings{'CRE_SVHOSTS'};
2626         foreach (@temp)
2627         {
2628                 s/^\s+//g; s/\s+$//g;
2629                 if ($_)
2630                 {
2631                         unless (&General::validipormask($_)) { $errormessage = $Lang::tr{'advproxy errmsg invalid ip or mask'}; }
2632                         $proxysettings{'CRE_SVHOSTS'} .= $_."\n";
2633                 }
2634         }
2635 }
2636
2637 # -------------------------------------------------------------------
2638
2639 sub write_acls
2640 {
2641         open(FILE, ">$acl_src_subnets");
2642         flock(FILE, 2);
2643         if (!$proxysettings{'SRC_SUBNETS'})
2644         {
2645                 print FILE "$green_cidr\n";
2646                 if ($netsettings{'BLUE_DEV'})
2647                 {
2648                         print FILE "$blue_cidr\n";
2649                 }
2650         } else { print FILE $proxysettings{'SRC_SUBNETS'}; }
2651         close(FILE);
2652
2653         open(FILE, ">$acl_src_banned_ip");
2654         flock(FILE, 2);
2655         print FILE $proxysettings{'SRC_BANNED_IP'};
2656         close(FILE);
2657
2658         open(FILE, ">$acl_src_banned_mac");
2659         flock(FILE, 2);
2660         print FILE $proxysettings{'SRC_BANNED_MAC'};
2661         close(FILE);
2662
2663         open(FILE, ">$acl_src_unrestricted_ip");
2664         flock(FILE, 2);
2665         print FILE $proxysettings{'SRC_UNRESTRICTED_IP'};
2666         close(FILE);
2667
2668         open(FILE, ">$acl_src_unrestricted_mac");
2669         flock(FILE, 2);
2670         print FILE $proxysettings{'SRC_UNRESTRICTED_MAC'};
2671         close(FILE);
2672
2673         open(FILE, ">$acl_dst_noauth");
2674         flock(FILE, 2);
2675         print FILE $proxysettings{'DST_NOAUTH'};
2676         close(FILE);
2677
2678         open(FILE, ">$acl_dst_noproxy_ip");
2679         flock(FILE, 2);
2680         print FILE $proxysettings{'DST_NOPROXY_IP'};
2681         close(FILE);
2682
2683         open(FILE, ">$acl_dst_noproxy_url");
2684         flock(FILE, 2);
2685         print FILE $proxysettings{'DST_NOPROXY_URL'};
2686         close(FILE);
2687
2688         open(FILE, ">$acl_dst_noauth_net");
2689         close(FILE);
2690         open(FILE, ">$acl_dst_noauth_dom");
2691         close(FILE);
2692         open(FILE, ">$acl_dst_noauth_url");
2693         close(FILE);
2694
2695         @temp = split(/\n/,$proxysettings{'DST_NOAUTH'});
2696         foreach(@temp)
2697         {
2698                 unless (/^#/)
2699                 {
2700                         if (/^\*\.\w/)
2701                         {
2702                                 s/^\*//;
2703                                 open(FILE, ">>$acl_dst_noauth_dom");
2704                                 flock(FILE, 2);
2705                                 print FILE "$_\n";
2706                                 close(FILE);
2707                         }
2708                         elsif (&General::validipormask($_))
2709                         {
2710                                 open(FILE, ">>$acl_dst_noauth_net");
2711                                 flock(FILE, 2);
2712                                 print FILE "$_\n";
2713                                 close(FILE);
2714                         }
2715                         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?/)
2716                         {
2717                                 open(FILE, ">>$acl_dst_noauth_net");
2718                                 flock(FILE, 2);
2719                                 print FILE "$_\n";
2720                                 close(FILE);
2721                         }
2722                         else
2723                         {
2724                                 open(FILE, ">>$acl_dst_noauth_url");
2725                                 flock(FILE, 2);
2726                                 if (/^[fh]tt?ps?:\/\//) { print FILE "$_\n"; } else { print FILE "^[fh]tt?ps?://$_\n"; }
2727                                 close(FILE);
2728                         }
2729                 }
2730         }
2731
2732         open(FILE, ">$acl_dst_nocache");
2733         flock(FILE, 2);
2734         print FILE $proxysettings{'DST_NOCACHE'};
2735         close(FILE);
2736
2737         open(FILE, ">$acl_dst_nocache_net");
2738         close(FILE);
2739         open(FILE, ">$acl_dst_nocache_dom");
2740         close(FILE);
2741         open(FILE, ">$acl_dst_nocache_url");
2742         close(FILE);
2743
2744         @temp = split(/\n/,$proxysettings{'DST_NOCACHE'});
2745         foreach(@temp)
2746         {
2747                 unless (/^#/)
2748                 {
2749                         if (/^\*\.\w/)
2750                         {
2751                                 s/^\*//;
2752                                 open(FILE, ">>$acl_dst_nocache_dom");
2753                                 flock(FILE, 2);
2754                                 print FILE "$_\n";
2755                                 close(FILE);
2756                         }
2757                         elsif (&General::validipormask($_))
2758                         {
2759                                 open(FILE, ">>$acl_dst_nocache_net");
2760                                 flock(FILE, 2);
2761                                 print FILE "$_\n";
2762                                 close(FILE);
2763                         }
2764                         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?/)
2765                         {
2766                                 open(FILE, ">>$acl_dst_nocache_net");
2767                                 flock(FILE, 2);
2768                                 print FILE "$_\n";
2769                                 close(FILE);
2770                         }
2771                         else
2772                         {
2773                                 open(FILE, ">>$acl_dst_nocache_url");
2774                                 flock(FILE, 2);
2775                                 if (/^[fh]tt?ps?:\/\//) { print FILE "$_\n"; } else { print FILE "^[fh]tt?ps?://$_\n"; }
2776                                 close(FILE);
2777                         }
2778                 }
2779         }
2780
2781         open(FILE, ">$acl_ports_safe");
2782         flock(FILE, 2);
2783         if (!$proxysettings{'PORTS_SAFE'}) { print FILE $def_ports_safe; } else { print FILE $proxysettings{'PORTS_SAFE'}; }
2784         close(FILE);
2785
2786         open(FILE, ">$acl_ports_ssl");
2787         flock(FILE, 2);
2788         if (!$proxysettings{'PORTS_SSL'}) { print FILE $def_ports_ssl; } else { print FILE $proxysettings{'PORTS_SSL'}; }
2789         close(FILE);
2790
2791         if (-s $throttled_urls)
2792         {
2793                 open(URLFILE, $throttled_urls);
2794                 @temp = <URLFILE>;
2795                 close(URLFILE);
2796                 foreach (@temp) { print FILE; }
2797         }
2798         close(FILE);
2799
2800         open(FILE, ">$mimetypes");
2801         flock(FILE, 2);
2802         print FILE $proxysettings{'MIME_TYPES'};
2803         close(FILE);
2804
2805         open(FILE, ">$raddir/radauth.allowusers");
2806         flock(FILE, 2);
2807         print FILE $proxysettings{'RADIUS_ALLOW_USERS'};
2808         close(FILE);
2809
2810         open(FILE, ">$raddir/radauth.denyusers");
2811         flock(FILE, 2);
2812         print FILE $proxysettings{'RADIUS_DENY_USERS'};
2813         close(FILE);
2814
2815         open(FILE, ">$identdir/identauth.allowusers");
2816         flock(FILE, 2);
2817         print FILE $proxysettings{'IDENT_ALLOW_USERS'};
2818         close(FILE);
2819
2820         open(FILE, ">$identdir/identauth.denyusers");
2821         flock(FILE, 2);
2822         print FILE $proxysettings{'IDENT_DENY_USERS'};
2823         close(FILE);
2824
2825         open(FILE, ">$identhosts");
2826         flock(FILE, 2);
2827         print FILE $proxysettings{'IDENT_HOSTS'};
2828         close(FILE);
2829
2830         open(FILE, ">$cre_groups");
2831         flock(FILE, 2);
2832         print FILE $proxysettings{'CRE_GROUPS'};
2833         close(FILE);
2834
2835         open(FILE, ">$cre_svhosts");
2836         flock(FILE, 2);
2837         print FILE $proxysettings{'CRE_SVHOSTS'};
2838         close(FILE);
2839 }
2840
2841 # -------------------------------------------------------------------
2842
2843 sub writepacfile
2844 {
2845         open(FILE, ">/srv/web/ipfire/html/proxy.pac");
2846         flock(FILE, 2);
2847         print FILE "function FindProxyForURL(url, host)\n";
2848         print FILE "{\n";
2849         if (($proxysettings{'ENABLE'} eq 'on') || ($proxysettings{'ENABLE_BLUE'} eq 'on'))
2850         {
2851                 print FILE <<END
2852 if (
2853      (isPlainHostName(host)) ||
2854      (isInNet(host, "127.0.0.1", "255.0.0.0")) ||
2855 END
2856 ;
2857
2858         if ($netsettings{'GREEN_DEV'}) {
2859                 print FILE "     (isInNet(host, \"$netsettings{'GREEN_NETADDRESS'}\", \"$netsettings{'GREEN_NETMASK'}\")) ||\n";
2860         }
2861
2862         if (&Header::blue_used() && $netsettings{'BLUE_DEV'}) {
2863                 print FILE "     (isInNet(host, \"$netsettings{'BLUE_NETADDRESS'}\", \"$netsettings{'BLUE_NETMASK'}\")) ||\n";
2864         }
2865
2866         if (&Header::orange_used() && $netsettings{'ORANGE_DEV'}) {
2867                 print FILE "     (isInNet(host, \"$netsettings{'ORANGE_NETADDRESS'}\", \"$netsettings{'ORANGE_NETMASK'}\")) ||\n";
2868         }
2869
2870         # Additional exceptions for URLs
2871         # The file has to be created by the user and should contain one entry per line
2872         # Line-Format: <URL incl. wildcards>
2873         # e.g. *.ipfire.org*
2874         if (-s "$acl_dst_noproxy_url") {
2875                 undef @templist;
2876
2877                 open(NOPROXY,"$acl_dst_noproxy_url");
2878                 @templist = <NOPROXY>;
2879                 close(NOPROXY);
2880                 chomp (@templist);
2881
2882                 foreach (@templist)
2883                 {
2884                         print FILE "     (shExpMatch(url, \"$_\")) ||\n";
2885                 }
2886         }
2887
2888         # Additional exceptions for Subnets
2889         # The file has to be created by the user and should contain one entry per line
2890         # Line-Format: <IP>/<SUBNET MASK>
2891         # e.g. 192.168.0.0/255.255.255.0
2892         if (-s "$acl_dst_noproxy_ip") {
2893                 undef @templist;
2894
2895                 open(NOPROXY,"$acl_dst_noproxy_ip");
2896                 @templist = <NOPROXY>;
2897                 close(NOPROXY);
2898                 chomp (@templist);
2899
2900                 foreach (@templist)
2901                 {
2902                         @temp = split(/\//);
2903                         print FILE "     (isInNet(host, \"$temp[0]\", \"$temp[1]\")) ||\n";
2904                 }
2905         }
2906
2907         print FILE <<END
2908      (isInNet(host, "169.254.0.0", "255.255.0.0"))
2909    )
2910      return "DIRECT";
2911
2912  else
2913
2914 END
2915 ;
2916                 if ($proxysettings{'ENABLE'} eq 'on')
2917                 {
2918                         print FILE "if (\n";
2919                         print FILE "     (isInNet(myIpAddress(), \"$netsettings{'GREEN_NETADDRESS'}\", \"$netsettings{'GREEN_NETMASK'}\"))";
2920
2921                         undef @templist;
2922                         if (-e "$acl_src_subnets") {
2923                                 open(SUBNETS,"$acl_src_subnets");
2924                                 @templist = <SUBNETS>;
2925                                 close(SUBNETS);
2926                         }
2927
2928                         foreach (@templist)
2929                         {
2930                                 @temp = split(/\//);
2931                                 if (
2932                                         ($temp[0] ne $netsettings{'GREEN_NETADDRESS'}) && ($temp[1] ne $netsettings{'GREEN_NETMASK'}) &&
2933                                         ($temp[0] ne $netsettings{'BLUE_NETADDRESS'}) && ($temp[1] ne $netsettings{'BLUE_NETMASK'})
2934                                         )
2935                                 {
2936                                         chomp $temp[1];
2937                                         print FILE " ||\n     (isInNet(myIpAddress(), \"$temp[0]\", \"$temp[1]\"))";
2938                                 }
2939                         }
2940
2941                         print FILE "\n";
2942
2943                         print FILE <<END
2944    )
2945      return "PROXY $netsettings{'GREEN_ADDRESS'}:$proxysettings{'PROXY_PORT'}";
2946 END
2947 ;
2948                 }
2949                 if (($proxysettings{'ENABLE'} eq 'on') && ($proxysettings{'ENABLE_BLUE'} eq 'on') && ($netsettings{'BLUE_DEV'}))
2950                 {
2951                         print FILE "\n else\n\n";
2952                 }
2953                 if (($netsettings{'BLUE_DEV'}) && ($proxysettings{'ENABLE_BLUE'} eq 'on'))
2954                 {
2955                         print FILE <<END
2956 if (
2957      (isInNet(myIpAddress(), "$netsettings{'BLUE_NETADDRESS'}", "$netsettings{'BLUE_NETMASK'}"))
2958    )
2959      return "PROXY $netsettings{'BLUE_ADDRESS'}:$proxysettings{'PROXY_PORT'}";
2960 END
2961 ;
2962                 }
2963         }
2964         print FILE "}\n";
2965         close(FILE);
2966 }
2967
2968 # -------------------------------------------------------------------
2969
2970 sub writeconfig
2971 {
2972         my $authrealm;
2973         my $delaypools;
2974
2975         if ($proxysettings{'THROTTLING_GREEN_TOTAL'} +
2976             $proxysettings{'THROTTLING_GREEN_HOST'}  +
2977             $proxysettings{'THROTTLING_BLUE_TOTAL'}  +
2978             $proxysettings{'THROTTLING_BLUE_HOST'} gt 0)
2979         {
2980                 $delaypools = 1; } else { $delaypools = 0;
2981         }
2982
2983         if ($proxysettings{'AUTH_REALM'} eq '')
2984         {
2985                 $authrealm = "IPFire Advanced Proxy Server";
2986         } else {
2987                 $authrealm = $proxysettings{'AUTH_REALM'};
2988         }
2989
2990         $_ = $proxysettings{'UPSTREAM_PROXY'};
2991         my ($remotehost, $remoteport) = split(/:/,$_);
2992
2993         if ($remoteport eq '') { $remoteport = 80; }
2994
2995         open(FILE, ">${General::swroot}/proxy/squid.conf");
2996         flock(FILE, 2);
2997         print FILE <<END
2998 # Do not modify '${General::swroot}/proxy/squid.conf' directly since any changes
2999 # you make will be overwritten whenever you resave proxy settings using the
3000 # web interface!
3001 #
3002 # Instead, modify the file '$acl_include' and
3003 # then restart the proxy service using the web interface. Changes made to the
3004 # 'include.acl' file will propagate to the 'squid.conf' file at that time.
3005
3006 shutdown_lifetime 5 seconds
3007 icp_port 0
3008
3009 END
3010         ;
3011
3012         # Include file with user defined settings.
3013         if (-e "/etc/squid/squid.conf.pre.local") {
3014                 print FILE "include /etc/squid/squid.conf.pre.local\n\n";
3015         }
3016
3017         print FILE "http_port $netsettings{'GREEN_ADDRESS'}:$proxysettings{'PROXY_PORT'}";
3018         if ($proxysettings{'NO_CONNECTION_AUTH'} eq 'on') { print FILE " no-connection-auth" }
3019         print FILE "\n";
3020
3021         if ($proxysettings{'TRANSPARENT'} eq 'on') {
3022                 print FILE "http_port $netsettings{'GREEN_ADDRESS'}:$proxysettings{'TRANSPARENT_PORT'} intercept";
3023                 if ($proxysettings{'NO_CONNECTION_AUTH'} eq 'on') { print FILE " no-connection-auth" }
3024                 print FILE "\n";
3025         }
3026
3027         if ($netsettings{'BLUE_DEV'} && $proxysettings{'ENABLE_BLUE'} eq 'on') {
3028                 print FILE "http_port $netsettings{'BLUE_ADDRESS'}:$proxysettings{'PROXY_PORT'}";
3029                 if ($proxysettings{'NO_CONNECTION_AUTH'} eq 'on') { print FILE " no-connection-auth" }
3030                 print FILE "\n";
3031
3032                 if ($proxysettings{'TRANSPARENT_BLUE'} eq 'on') {
3033                         print FILE "http_port $netsettings{'BLUE_ADDRESS'}:$proxysettings{'TRANSPARENT_PORT'} intercept";
3034                         if ($proxysettings{'NO_CONNECTION_AUTH'} eq 'on') { print FILE " no-connection-auth" }
3035                         print FILE "\n";
3036                 }
3037         }
3038
3039         if (($proxysettings{'CACHE_SIZE'} > 0) || ($proxysettings{'CACHE_MEM'} > 0))
3040         {
3041                 print FILE "\n";
3042
3043                 if (!-z $acl_dst_nocache_dom) {
3044                         print FILE "acl no_cache_domains dstdomain \"$acl_dst_nocache_dom\"\n";
3045                         print FILE "cache deny no_cache_domains\n";
3046                 }
3047                 if (!-z $acl_dst_nocache_net) {
3048                         print FILE "acl no_cache_ipaddr dst \"$acl_dst_nocache_net\"\n";
3049                         print FILE "cache deny no_cache_ipaddr\n";
3050                 }
3051                 if (!-z $acl_dst_nocache_url) {
3052                         print FILE "acl no_cache_hosts url_regex -i \"$acl_dst_nocache_url\"\n";
3053                         print FILE "cache deny no_cache_hosts\n";
3054                 }
3055         }
3056
3057         print FILE <<END
3058
3059 cache_effective_user squid
3060 umask 022
3061
3062 pid_filename /var/run/squid.pid
3063
3064 cache_mem $proxysettings{'CACHE_MEM'} MB
3065 END
3066         ;
3067         print FILE "error_directory $errordir/$proxysettings{'ERR_LANGUAGE'}\n\n";
3068
3069         if ($proxysettings{'OFFLINE_MODE'} eq 'on') {  print FILE "offline_mode on\n\n"; }
3070         if ($proxysettings{'CACHE_DIGESTS'} eq 'on') {  print FILE "digest_generation on\n\n"; } else {  print FILE "digest_generation off\n\n"; }
3071
3072         if ((!($proxysettings{'MEM_POLICY'} eq 'LRU')) || (!($proxysettings{'CACHE_POLICY'} eq 'LRU')))
3073         {
3074                 if (!($proxysettings{'MEM_POLICY'} eq 'LRU'))
3075                 {
3076                         print FILE "memory_replacement_policy $proxysettings{'MEM_POLICY'}\n";
3077                 }
3078                 if (!($proxysettings{'CACHE_POLICY'} eq 'LRU'))
3079                 {
3080                         print FILE "cache_replacement_policy $proxysettings{'CACHE_POLICY'}\n";
3081                 }
3082                 print FILE "\n";
3083         }
3084
3085         open (PORTS,"$acl_ports_ssl");
3086         my @ssl_ports = <PORTS>;
3087         close PORTS;
3088
3089         if (@ssl_ports) {
3090                 foreach (@ssl_ports) {
3091                         print FILE "acl SSL_ports port $_";
3092                 }
3093         }
3094
3095         open (PORTS,"$acl_ports_safe");
3096         my @safe_ports = <PORTS>;
3097         close PORTS;
3098
3099         if (@safe_ports) {
3100                 foreach (@safe_ports) {
3101                         print FILE "acl Safe_ports port $_";
3102                 }
3103         }
3104
3105         print FILE <<END
3106
3107 acl IPFire_http  port $http_port
3108 acl IPFire_https port $https_port
3109 acl IPFire_ips              dst $netsettings{'GREEN_ADDRESS'}
3110 acl IPFire_networks         src "$acl_src_subnets"
3111 acl IPFire_servers          dst "$acl_src_subnets"
3112 acl IPFire_green_network    src $green_cidr
3113 acl IPFire_green_servers    dst $green_cidr
3114 END
3115         ;
3116         if ($netsettings{'BLUE_DEV'}) { print FILE "acl IPFire_blue_network     src $blue_cidr\n"; }
3117         if ($netsettings{'BLUE_DEV'}) { print FILE "acl IPFire_blue_servers     dst $blue_cidr\n"; }
3118         if (!-z $acl_src_banned_ip) { print FILE "acl IPFire_banned_ips       src \"$acl_src_banned_ip\"\n"; }
3119         if (!-z $acl_src_banned_mac) { print FILE "acl IPFire_banned_mac       arp \"$acl_src_banned_mac\"\n"; }
3120         if (!-z $acl_src_unrestricted_ip) { print FILE "acl IPFire_unrestricted_ips src \"$acl_src_unrestricted_ip\"\n"; }
3121         if (!-z $acl_src_unrestricted_mac) { print FILE "acl IPFire_unrestricted_mac arp \"$acl_src_unrestricted_mac\"\n"; }
3122         print FILE <<END
3123 acl CONNECT method CONNECT
3124 END
3125         ;
3126
3127         if ($proxysettings{'CACHE_SIZE'} > 0) {
3128                 print FILE <<END
3129 maximum_object_size $proxysettings{'MAX_SIZE'} KB
3130 minimum_object_size $proxysettings{'MIN_SIZE'} KB
3131
3132 cache_dir aufs /var/log/cache $proxysettings{'CACHE_SIZE'} $proxysettings{'L1_DIRS'} 256
3133 END
3134                 ;
3135         } else {
3136                 if ($proxysettings{'CACHE_MEM'} > 0) {
3137                         # always 2% of CACHE_MEM defined as max object size
3138                         print FILE "maximum_object_size_in_memory " . int($proxysettings{'CACHE_MEM'} * 1024 * 0.02) . " KB\n\n";
3139                 } else {
3140                         print FILE "cache deny all\n\n";
3141             }
3142         }
3143
3144         print FILE <<END
3145 request_body_max_size $proxysettings{'MAX_OUTGOING_SIZE'} KB
3146 END
3147         ;
3148
3149         if ($proxysettings{'MAX_INCOMING_SIZE'} > 0) {
3150                 if (!-z $acl_src_unrestricted_ip) { print FILE "reply_body_max_size none IPFire_unrestricted_ips\n"; }
3151                 if (!-z $acl_src_unrestricted_mac) { print FILE "reply_body_max_size none IPFire_unrestricted_mac\n"; }
3152                 if ($proxysettings{'AUTH_METHOD'} eq 'ncsa')
3153                 {
3154                         if (!-z $extgrp) { print FILE "reply_body_max_size none for_extended_users\n"; }
3155                 }
3156         }
3157
3158         if ( $proxysettings{'MAX_INCOMING_SIZE'} != '0' )
3159         {
3160                 print FILE "reply_body_max_size $proxysettings{'MAX_INCOMING_SIZE'} KB all\n\n";
3161         }
3162
3163         if ($proxysettings{'LOGGING'} eq 'on')
3164         {
3165                 print FILE <<END
3166 access_log stdio:/var/log/squid/access.log
3167 cache_log /var/log/squid/cache.log
3168 cache_store_log none
3169 END
3170         ;
3171                 if ($proxysettings{'LOGUSERAGENT'} eq 'on') { print FILE "access_log stdio:\/var\/log\/squid\/user_agent.log useragent\n"; }
3172                 if ($proxysettings{'LOGQUERY'} eq 'on') { print FILE "\nstrip_query_terms off\n"; }
3173         } else {
3174                 print FILE <<END
3175 access_log /dev/null
3176 cache_log /dev/null
3177 cache_store_log none
3178 END
3179         ;}
3180         print FILE <<END
3181
3182 log_mime_hdrs off
3183 END
3184         ;
3185
3186         if ($proxysettings{'FORWARD_IPADDRESS'} eq 'on')
3187         {
3188                 print FILE "forwarded_for on\n";
3189         } else {
3190                 print FILE "forwarded_for off\n";
3191         }
3192         if ($proxysettings{'FORWARD_VIA'} eq 'on')
3193         {
3194                 print FILE "via on\n";
3195         } else {
3196                 print FILE "via off\n";
3197         }
3198         print FILE "\n";
3199
3200         # If we use authentication, users must always authenticate
3201         unless ($proxysettings{"AUTH_METHOD"} eq "") {
3202                 print FILE "authenticate_ip_ttl 0\n\n";
3203         }
3204
3205         if ((!($proxysettings{'AUTH_METHOD'} eq 'none')) && (!($proxysettings{'AUTH_METHOD'} eq 'ident')))
3206         {
3207                 if ($proxysettings{'AUTH_METHOD'} eq 'ncsa')
3208                 {
3209                         print FILE "auth_param basic program $authdir/basic_ncsa_auth $userdb\n";
3210                         print FILE "auth_param basic children $proxysettings{'AUTH_CHILDREN'}\n";
3211                         print FILE "auth_param basic realm $authrealm\n";
3212                         print FILE "auth_param basic credentialsttl $proxysettings{'AUTH_CACHE_TTL'} minutes\n";
3213                 }
3214
3215                 if ($proxysettings{'AUTH_METHOD'} eq 'ldap')
3216                 {
3217                         print FILE "auth_param basic utf8 on\n";
3218                         print FILE "auth_param basic program $authdir/basic_ldap_auth -b \"$proxysettings{'LDAP_BASEDN'}\"";
3219                         if (!($proxysettings{'LDAP_BINDDN_USER'} eq '')) { print FILE " -D \"$proxysettings{'LDAP_BINDDN_USER'}\""; }
3220                         if (!($proxysettings{'LDAP_BINDDN_PASS'} eq '')) { print FILE " -w $proxysettings{'LDAP_BINDDN_PASS'}"; }
3221                         if ($proxysettings{'LDAP_TYPE'} eq 'ADS')
3222                         {
3223                                 if ($proxysettings{'LDAP_GROUP'} eq '')
3224                                 {
3225                                         print FILE " -f \"(\&(objectClass=person)(sAMAccountName=\%s))\"";
3226                                 } else {
3227                                         print FILE " -f \"(\&(\&(objectClass=person)(sAMAccountName=\%s))(memberOf=$proxysettings{'LDAP_GROUP'}))\"";
3228                                 }
3229                                 print FILE " -u sAMAccountName -P";
3230                         }
3231                         if ($proxysettings{'LDAP_TYPE'} eq 'NDS')
3232                         {
3233                                 if ($proxysettings{'LDAP_GROUP'} eq '')
3234                                 {
3235                                         print FILE " -f \"(\&(objectClass=person)(cn=\%s))\"";
3236                                 } else {
3237                                         print FILE " -f \"(\&(\&(objectClass=person)(cn=\%s))(groupMembership=$proxysettings{'LDAP_GROUP'}))\"";
3238                                 }
3239                                 print FILE " -u cn -P";
3240                         }
3241                         if (($proxysettings{'LDAP_TYPE'} eq 'V2') || ($proxysettings{'LDAP_TYPE'} eq 'V3'))
3242                         {
3243                                 if ($proxysettings{'LDAP_GROUP'} eq '')
3244                                 {
3245                                         print FILE " -f \"(\&(objectClass=person)(uid=\%s))\"";
3246                                 } else {
3247                                         print FILE " -f \"(\&(\&(objectClass=person)(uid=\%s))(memberOf=$proxysettings{'LDAP_GROUP'}))\"";
3248                                 }
3249                                 if ($proxysettings{'LDAP_TYPE'} eq 'V2') { print FILE " -v 2"; }
3250                                 if ($proxysettings{'LDAP_TYPE'} eq 'V3') { print FILE " -v 3"; }
3251                                 print FILE " -u uid -P";
3252                         }
3253                         print FILE " $proxysettings{'LDAP_SERVER'}:$proxysettings{'LDAP_PORT'}\n";
3254                         print FILE "auth_param basic children $proxysettings{'AUTH_CHILDREN'}\n";
3255                         print FILE "auth_param basic realm $authrealm\n";
3256                         print FILE "auth_param basic credentialsttl $proxysettings{'AUTH_CACHE_TTL'} minutes\n";
3257                 }
3258
3259                 if ($proxysettings{'AUTH_METHOD'} eq 'ntlm-auth')
3260                 {
3261                         print FILE "auth_param ntlm program /usr/bin/ntlm_auth --helper-protocol=squid-2.5-ntlmssp";
3262                         if ($proxysettings{'NTLM_AUTH_GROUP'}) {
3263                                 my $ntlm_auth_group = $proxysettings{'NTLM_AUTH_GROUP'};
3264                                 $ntlm_auth_group =~ s/\\/\+/;
3265
3266                                 print FILE " --require-membership-of=$ntlm_auth_group";
3267                         }
3268                         print FILE "\n";
3269
3270                         print FILE "auth_param ntlm children $proxysettings{'AUTH_CHILDREN'}\n\n";
3271                         print FILE "auth_param ntlm credentialsttl $proxysettings{'AUTH_CACHE_TTL'} minutes\n\n";
3272
3273                         # BASIC authentication
3274                         if ($proxysettings{'NTLM_AUTH_BASIC'} eq "on") {
3275                                 print FILE "auth_param basic program /usr/bin/ntlm_auth --helper-protocol=squid-2.5-basic";
3276                                 if ($proxysettings{'NTLM_AUTH_GROUP'}) {
3277                                         my $ntlm_auth_group = $proxysettings{'NTLM_AUTH_GROUP'};
3278                                         $ntlm_auth_group =~ s/\\/\+/;
3279
3280                                         print FILE " --require-membership-of=$ntlm_auth_group";
3281                                 }
3282                                 print FILE "\n";
3283                                 print FILE "auth_param basic children $proxysettings{'AUTH_CHILDREN'}\n";
3284                                 print FILE "auth_param basic realm $authrealm\n";
3285                                 print FILE "auth_param basic credentialsttl $proxysettings{'AUTH_CACHE_TTL'} minutes\n\n";
3286                         }
3287                 }
3288
3289                 if ($proxysettings{'AUTH_METHOD'} eq 'radius')
3290                 {
3291                         print FILE "auth_param basic program $authdir/basic_radius_auth -h $proxysettings{'RADIUS_SERVER'} -p $proxysettings{'RADIUS_PORT'} ";
3292                         if (!($proxysettings{'RADIUS_IDENTIFIER'} eq '')) { print FILE "-i $proxysettings{'RADIUS_IDENTIFIER'} "; }
3293                         print FILE "-w $proxysettings{'RADIUS_SECRET'}\n";
3294                         print FILE "auth_param basic children $proxysettings{'AUTH_CHILDREN'}\n";
3295                         print FILE "auth_param basic realm $authrealm\n";
3296                         print FILE "auth_param basic credentialsttl $proxysettings{'AUTH_CACHE_TTL'} minutes\n";
3297                 }
3298
3299                 print FILE "\n";
3300                 print FILE "acl for_inetusers proxy_auth REQUIRED\n";
3301                 if (($proxysettings{'AUTH_METHOD'} eq 'radius') && ($proxysettings{'RADIUS_ENABLE_ACL'} eq 'on'))
3302                 {
3303                         if ((!-z "$raddir/radauth.allowusers") && ($proxysettings{'RADIUS_USER_ACL'} eq 'positive'))
3304                         {
3305                                 print FILE "acl for_acl_users proxy_auth \"$raddir/radauth.allowusers\"\n";
3306                         }
3307                         if ((!-z "$raddir/radauth.denyusers") && ($proxysettings{'RADIUS_USER_ACL'} eq 'negative'))
3308                         {
3309                                 print FILE "acl for_acl_users proxy_auth \"$raddir/radauth.denyusers\"\n";
3310                         }
3311                 }
3312                 if ($proxysettings{'AUTH_METHOD'} eq 'ncsa')
3313                 {
3314                         print FILE "\n";
3315                         if (!-z $extgrp) { print FILE "acl for_extended_users proxy_auth \"$extgrp\"\n"; }
3316                         if (!-z $disgrp) { print FILE "acl for_disabled_users proxy_auth \"$disgrp\"\n"; }
3317                 }
3318                 if (!($proxysettings{'AUTH_MAX_USERIP'} eq '')) { print FILE "\nacl concurrent max_user_ip -s $proxysettings{'AUTH_MAX_USERIP'}\n"; }
3319                 print FILE "\n";
3320
3321                 if (!-z $acl_dst_noauth_net) { print FILE "acl to_ipaddr_without_auth dst \"$acl_dst_noauth_net\"\n"; }
3322                 if (!-z $acl_dst_noauth_dom) { print FILE "acl to_domains_without_auth dstdomain \"$acl_dst_noauth_dom\"\n"; }
3323                 if (!-z $acl_dst_noauth_url) { print FILE "acl to_hosts_without_auth url_regex -i \"$acl_dst_noauth_url\"\n"; }
3324                 print FILE "\n";
3325
3326         }
3327
3328         if ($proxysettings{'AUTH_METHOD'} eq 'ident')
3329         {
3330                 if ($proxysettings{'IDENT_REQUIRED'} eq 'on')
3331                 {
3332                         print FILE "acl for_inetusers ident REQUIRED\n";
3333                 }
3334                 if ($proxysettings{'IDENT_ENABLE_ACL'} eq 'on')
3335                 {
3336                         if ((!-z "$identdir/identauth.allowusers") && ($proxysettings{'IDENT_USER_ACL'} eq 'positive'))
3337                         {
3338                                 print FILE "acl for_acl_users ident_regex -i \"$identdir/identauth.allowusers\"\n\n";
3339                         }
3340                         if ((!-z "