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