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