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