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