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