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