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