Fixed the urlfilter bug #0000552
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / urlfilter.cgi
1 #!/usr/bin/perl
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2010 Michael Tremer & Christian Schmidt #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21
22 use strict;
23
24 # enable only the following on debugging purpose
25 #use warnings;
26 #use CGI::Carp 'fatalsToBrowser';
27
28 use File::Copy;
29 use IO::Socket;
30
31 require '/var/ipfire/general-functions.pl';
32 require "${General::swroot}/lang.pl";
33 require "${General::swroot}/header.pl";
34
35 my $http_port='81';
36 my %netsettings=();
37 my %mainsettings=();
38 my %proxysettings=();
39 my %filtersettings=();
40 my %tcsettings=();
41 my %uqsettings=();
42 my %besettings=();
43 my %updatesettings=();
44 my %checked=();
45 my %selected=();
46 my $id=0;
47 my $line='';
48 my $i=0;
49 my $n=0;
50 my $time='';
51 my $filesize;
52 my $category='';
53 my $section='';
54 my $blacklist='';
55 my $blistbackup='';
56
57 my $changed = 'no';
58 my $tcfile = "${General::swroot}/urlfilter/timeconst";
59 my $uqfile = "${General::swroot}/urlfilter/userquota";
60 my $dbdir = "${General::swroot}/urlfilter/blacklists";
61 my $editdir = "${General::swroot}/urlfilter/editor";
62 my $repository = "/home/httpd/html/repository";
63 my $hintcolour = '#FFFFCC';
64
65 my $sourceurlfile = "${General::swroot}/urlfilter/autoupdate/autoupdate.urls";
66 my $updconffile = "${General::swroot}/urlfilter/autoupdate/autoupdate.conf";
67 my $updflagfile = "${General::swroot}/urlfilter/blacklists/.autoupdate.last";
68 my $upd_cron_dly = "${General::swroot}/urlfilter/autoupdate/cron.daily";
69 my $upd_cron_wly = "${General::swroot}/urlfilter/autoupdate/cron.weekly";
70 my $upd_cron_mly = "${General::swroot}/urlfilter/autoupdate/cron.monthly";
71
72 my $errormessage='';
73 my $updatemessage='';
74 my $restoremessage='';
75 my $buttontext='';
76 my $source_name='';
77 my $source_url='';
78 my $blacklistage=0;
79
80 my @repositorylist=();
81 my @repositoryfiles=();
82 my @categories=();
83 my @selectedcategories=();
84 my @filtergroups=();
85 my @tclist=();
86 my @uqlist=();
87 my @source_urllist=();
88 my @clients=();
89 my @temp=();
90
91 my $lastslashpos=0;
92
93 my $toggle='';
94 my $gif='';
95 my $led='';
96 my $ldesc='';
97 my $gdesc='';
98
99 if (! -d $dbdir) { mkdir("$dbdir"); }
100 if (! -e $tcfile) { system("touch $tcfile"); }
101 if (! -e $uqfile) { system("touch $uqfile"); }
102 if (! -e $sourceurlfile) { system("touch $sourceurlfile"); }
103
104 &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
105 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
106 &General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
107
108 &readblockcategories;
109
110 open(FILE, $tcfile);
111 @tclist = <FILE>;
112 close(FILE);
113 open(FILE, $uqfile);
114 @uqlist = <FILE>;
115 close(FILE);
116 open(FILE, $sourceurlfile);
117 @source_urllist = <FILE>;
118 close(FILE);
119
120 $filtersettings{'ENABLE_CUSTOM_BLACKLIST'} = 'off';
121 $filtersettings{'ENABLE_CUSTOM_WHITELIST'} = 'off';
122 $filtersettings{'ENABLE_CUSTOM_EXPRESSIONS'} = 'off';
123 $filtersettings{'BLOCK_EXECUTABLES'} = 'off';
124 $filtersettings{'BLOCK_AUDIO-VIDEO'} = 'off';
125 $filtersettings{'BLOCK_ARCHIVES'} = 'off';
126 $filtersettings{'ENABLE_REWRITE'} = 'off';
127 $filtersettings{'UNFILTERED_CLIENTS'} = '';
128 $filtersettings{'BANNED_CLIENTS'} = '';
129 $filtersettings{'SHOW_CATEGORY'} = 'off';
130 $filtersettings{'SHOW_URL'} = 'off';
131 $filtersettings{'SHOW_IP'} = 'off';
132 $filtersettings{'ENABLE_DNSERROR'} = 'off';
133 $filtersettings{'ENABLE_JPEG'} = 'off';
134 $filtersettings{'REDIRECT_PAGE'} = '';
135 $filtersettings{'MSG_TEXT_1'} = '';
136 $filtersettings{'MSG_TEXT_2'} = '';
137 $filtersettings{'MSG_TEXT_3'} = '';
138 $filtersettings{'ENABLE_EXPR_LISTS'} = 'off';
139 $filtersettings{'BLOCK_IP_ADDR'} = 'off';
140 $filtersettings{'BLOCK_ALL'} = 'off';
141 $filtersettings{'ENABLE_EMPTY_ADS'} = 'off';
142 $filtersettings{'ENABLE_GLOBAL_WHITELIST'} = 'off';
143 $filtersettings{'ENABLE_SAFESEARCH'} = 'off';
144 $filtersettings{'ENABLE_LOG'} = 'off';
145 $filtersettings{'ENABLE_USERNAME_LOG'} = 'off';
146 $filtersettings{'ENABLE_CATEGORY_LOG'} = 'off';
147 $filtersettings{'ENABLE_AUTOUPDATE'} = 'off';
148
149 $filtersettings{'ACTION'} = '';
150 $filtersettings{'VALID'} = '';
151
152 &Header::getcgihash(\%filtersettings);
153 &Header::getcgihash(\%tcsettings);
154 &Header::getcgihash(\%uqsettings);
155 &Header::getcgihash(\%besettings);
156
157 if (($filtersettings{'ACTION'} eq $Lang::tr{'save'}) ||
158 ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter save and restart'}) ||
159 ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter upload file'}) ||
160 ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter remove file'}) ||
161 ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter upload blacklist'}) ||
162 ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter backup'}) ||
163 ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter restore'}))
164 {
165
166 @clients = split(/\n/,$filtersettings{'UNFILTERED_CLIENTS'});
167 foreach (@clients)
168 {
169 s/^\s+//g; s/\s+$//g; s/\s+-\s+/-/g; s/\s+/ /g; s/\n//g;
170 if (/.*-.*-.*/) { $errormessage = $Lang::tr{'urlfilter invalid ip or mask error'}; }
171 @temp = split(/-/);
172 foreach (@temp) { unless ((&General::validipormask($_)) || (&General::validipandmask($_))) { $errormessage = $Lang::tr{'urlfilter invalid ip or mask error'}; } }
173 }
174 @clients = split(/\n/,$filtersettings{'BANNED_CLIENTS'});
175 foreach (@clients)
176 {
177 s/^\s+//g; s/\s+$//g; s/\s+-\s+/-/g; s/\s+/ /g; s/\n//g;
178 if (/.*-.*-.*/) { $errormessage = $Lang::tr{'urlfilter invalid ip or mask error'}; }
179 @temp = split(/-/);
180 foreach (@temp) { unless ((&General::validipormask($_)) || (&General::validipandmask($_))) { $errormessage = $Lang::tr{'urlfilter invalid ip or mask error'}; } }
181 }
182 if ($errormessage) { goto ERROR; }
183
184 if ((!($filtersettings{'REDIRECT_PAGE'} eq '')) && (!($filtersettings{'REDIRECT_PAGE'} =~ /^https?:\/\//)))
185 {
186 $filtersettings{'REDIRECT_PAGE'} = "http://".$filtersettings{'REDIRECT_PAGE'};
187 }
188
189 if ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter remove file'})
190 {
191 if (-e "$repository/$filtersettings{'ID'}") { unlink("$repository/$filtersettings{'ID'}"); }
192 $filtersettings{'ACTION'} = $Lang::tr{'urlfilter manage repository'};
193 }
194
195 if ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter upload file'})
196 {
197 &Header::getcgihash(\%filtersettings, {'wantfile' => 1, 'filevar' => 'UPLOADFILE'});
198
199 $filtersettings{'ACTION'} = $Lang::tr{'urlfilter manage repository'};
200 $_ = $filtersettings{'UPLOADFILE'};
201 tr/\\/\//;
202 $_ = substr($_,rindex($_,"/")+1);
203 if ($_) {
204 if (copy($filtersettings{'UPLOADFILE'}, "$repository/$_") != 1)
205 {
206 $errormessage = $!;
207 goto ERROR;
208 }
209 }
210
211 }
212
213 if ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter upload blacklist'})
214 {
215 &Header::getcgihash(\%filtersettings, {'wantfile' => 1, 'filevar' => 'UPDATEFILE'});
216
217 if (!($filtersettings{'UPDATEFILE'} =~ /.tar.gz$/))
218 {
219 $errormessage = $Lang::tr{'urlfilter wrong filetype'};
220 goto ERROR;
221 }
222
223 if (copy($filtersettings{'UPDATEFILE'}, "${General::swroot}/urlfilter/blacklists.tar.gz") != 1)
224 {
225 $errormessage = $!;
226 goto ERROR;
227 }
228
229 if (!(-d "${General::swroot}/urlfilter/update")) { mkdir("${General::swroot}/urlfilter/update"); }
230
231 my $exitcode = system("/bin/tar --no-same-owner -xzf ${General::swroot}/urlfilter/blacklists.tar.gz -C ${General::swroot}/urlfilter/update");
232
233 if ($exitcode > 0)
234 {
235 $errormessage = $Lang::tr{'urlfilter tar error'};
236 } else {
237
238 if (-d "${General::swroot}/urlfilter/update/BL")
239 {
240 system("mv ${General::swroot}/urlfilter/update/BL ${General::swroot}/urlfilter/update/blacklists");
241 }
242
243 if (-d "${General::swroot}/urlfilter/update/category")
244 {
245 system("mv ${General::swroot}/urlfilter/update/category ${General::swroot}/urlfilter/update/blacklists");
246 }
247
248 if (!(-d "${General::swroot}/urlfilter/update/blacklists"))
249 {
250 $errormessage = $Lang::tr{'urlfilter invalid content'};
251 } else {
252 system("cp -r ${General::swroot}/urlfilter/update/blacklists/* $dbdir");
253
254 &readblockcategories;
255 &readcustomlists;
256
257 &writeconfigfile;
258
259 $updatemessage = $Lang::tr{'urlfilter upload success'};
260 system("${General::swroot}/urlfilter/bin/prebuild.pl &");
261 system("logger -t installpackage[urlfilter] \"URL filter blacklist - Blacklist update from local source completed\"");
262 }
263 }
264 if (-d "${General::swroot}/urlfilter/update") { system("rm -rf ${General::swroot}/urlfilter/update"); }
265 if (-e "${General::swroot}/urlfilter/blacklists.tar.gz") { unlink("${General::swroot}/urlfilter/blacklists.tar.gz"); }
266 if ($errormessage) { goto ERROR; }
267 }
268
269 if ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter backup'})
270 {
271 $blistbackup = ($filtersettings{'ENABLE_FULLBACKUP'} eq 'on') ? "blacklists" : "blacklists/custom";
272 if (system("/bin/tar -C ${General::swroot}/urlfilter -czf ${General::swroot}/urlfilter/backup.tar.gz settings timeconst userquota autoupdate $blistbackup"))
273 {
274 $errormessage = $Lang::tr{'urlfilter backup error'};
275 goto ERROR;
276 }
277 else
278 {
279 print "Content-type: application/gzip\n";
280 print "Content-length: ";
281 print (-s "${General::swroot}/urlfilter/backup.tar.gz");
282 print "\n";
283 print "Content-disposition: attachment; filename=urlfilter-backup.tar.gz\n\n";
284
285 open (FILE, "${General::swroot}/urlfilter/backup.tar.gz");
286 while (<FILE>) { print; }
287 close (FILE);
288
289 if (-e "${General::swroot}/urlfilter/backup.tar.gz") { unlink("${General::swroot}/urlfilter/backup.tar.gz"); }
290 exit;
291 }
292 }
293
294 if ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter restore'})
295 {
296 &Header::getcgihash(\%filtersettings, {'wantfile' => 1, 'filevar' => 'UPDATEFILE'});
297
298 if (!($filtersettings{'UPDATEFILE'} =~ /.tar.gz$/))
299 {
300 $errormessage = $Lang::tr{'urlfilter wrong filetype'};
301 goto ERROR;
302 }
303
304 if (!(-d "${General::swroot}/urlfilter/restore")) { mkdir("${General::swroot}/urlfilter/restore"); }
305
306 if (copy($filtersettings{'UPDATEFILE'}, "${General::swroot}/urlfilter/backup.tar.gz") != 1)
307 {
308 $errormessage = $!;
309 }
310
311 my $exitcode = system("/bin/tar --no-same-owner --preserve-permissions -xzf ${General::swroot}/urlfilter/backup.tar.gz -C ${General::swroot}/urlfilter/restore");
312 if ($exitcode > 0)
313 {
314 $errormessage = $Lang::tr{'urlfilter tar error'};
315 } else {
316 if (!(-e "${General::swroot}/urlfilter/restore/settings"))
317 {
318 $errormessage = $Lang::tr{'urlfilter invalid restore file'};
319 } else {
320 system("cp -rp ${General::swroot}/urlfilter/restore/* ${General::swroot}/urlfilter/");
321 &readblockcategories;
322 &readcustomlists;
323 &writeconfigfile;
324
325 $restoremessage = $Lang::tr{'urlfilter restore success'};
326 }
327 }
328
329 if (-e "${General::swroot}/urlfilter/backup.tar.gz") { unlink("${General::swroot}/urlfilter/backup.tar.gz"); }
330 if (-d "${General::swroot}/urlfilter/restore") { system("rm -rf ${General::swroot}/urlfilter/restore"); }
331 if ($errormessage) { goto ERROR; }
332 }
333
334 if ($filtersettings{'ACTION'} eq $Lang::tr{'save'})
335 {
336 $filtersettings{'VALID'} = 'yes';
337 &savesettings;
338 }
339
340 if ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter save and restart'})
341 {
342 if ((!(-e "${General::swroot}/proxy/enable")) && (!(-e "${General::swroot}/proxy/enable_blue")))
343 {
344 $errormessage = $Lang::tr{'urlfilter web proxy service required'};
345 goto ERROR;
346 }
347 if (!($proxysettings{'ENABLE_FILTER'} eq 'on'))
348 {
349 $errormessage = $Lang::tr{'urlfilter not enabled'};
350 goto ERROR;
351 }
352
353 $filtersettings{'VALID'} = 'yes';
354 &savesettings;
355
356 system('/usr/local/bin/squidctrl restart >/dev/null 2>&1');
357 }
358 }
359
360 if ($tcsettings{'ACTION'} eq $Lang::tr{'urlfilter set time constraints'}) { $tcsettings{'TCMODE'} = 'on'}
361
362 if (($tcsettings{'MODE'} eq 'TIMECONSTRAINT') && ($tcsettings{'ACTION'} eq $Lang::tr{'add'}))
363 {
364 $tcsettings{'TCMODE'}='on';
365
366 if (!$tcsettings{'DST'})
367 {
368 $errormessage=$Lang::tr{'urlfilter dst error'};
369 }
370
371 if (!$tcsettings{'SRC'})
372 {
373 $errormessage=$Lang::tr{'urlfilter src error'};
374 }
375
376 if (!($tcsettings{'TO_HOUR'}.$tcsettings{'TO_MINUTE'} gt $tcsettings{'FROM_HOUR'}.$tcsettings{'FROM_MINUTE'}))
377 {
378 $errormessage=$Lang::tr{'urlfilter timespace error'};
379 }
380
381 if (!(($tcsettings{'MON'} eq 'on') || ($tcsettings{'TUE'} eq 'on') || ($tcsettings{'WED'} eq 'on') || ($tcsettings{'THU'} eq 'on') || ($tcsettings{'FRI'} eq 'on') || ($tcsettings{'SAT'} eq 'on') || ($tcsettings{'SUN'} eq 'on')))
382 {
383 $errormessage=$Lang::tr{'urlfilter weekday error'};
384 }
385
386 if (!$errormessage)
387 {
388 # transform to pre1.8 client definitions
389 @clients = split(/\n/,$tcsettings{'SRC'});
390 undef $tcsettings{'SRC'};
391 foreach(@clients)
392 {
393 s/^\s+//g; s/\s+$//g; s/\s+-\s+/-/g; s/\s+/ /g; s/\n//g;
394 $tcsettings{'SRC'} .= "$_ ";
395 }
396 $tcsettings{'SRC'} =~ s/\s+$//;
397
398 if ($tcsettings{'DST'} =~ /^any/) { $tcsettings{'DST'} = 'any'; }
399 if ($tcsettings{'ENABLERULE'} eq 'on') { $tcsettings{'ACTIVE'} = $tcsettings{'ENABLERULE'}; } else { $tcsettings{'ACTIVE'} = 'off'}
400
401 $tcsettings{'ENABLERULE'} = 'on';
402 if($tcsettings{'EDITING'} eq 'no') {
403 open(FILE,">>$tcfile");
404 flock FILE, 2;
405 print FILE "$tcsettings{'DEFINITION'},$tcsettings{'MON'},$tcsettings{'TUE'},$tcsettings{'WED'},$tcsettings{'THU'},$tcsettings{'FRI'},$tcsettings{'SAT'},$tcsettings{'SUN'},$tcsettings{'FROM_HOUR'},$tcsettings{'FROM_MINUTE'},$tcsettings{'TO_HOUR'},$tcsettings{'TO_MINUTE'},$tcsettings{'SRC'},$tcsettings{'DST'},$tcsettings{'ACCESS'},$tcsettings{'ACTIVE'},$tcsettings{'COMMENT'}\n";
406 } else {
407 open(FILE, ">$tcfile");
408 flock FILE, 2;
409 $id = 0;
410 foreach $line (@tclist)
411 {
412 $id++;
413 if ($tcsettings{'EDITING'} eq $id) {
414 print FILE "$tcsettings{'DEFINITION'},$tcsettings{'MON'},$tcsettings{'TUE'},$tcsettings{'WED'},$tcsettings{'THU'},$tcsettings{'FRI'},$tcsettings{'SAT'},$tcsettings{'SUN'},$tcsettings{'FROM_HOUR'},$tcsettings{'FROM_MINUTE'},$tcsettings{'TO_HOUR'},$tcsettings{'TO_MINUTE'},$tcsettings{'SRC'},$tcsettings{'DST'},$tcsettings{'ACCESS'},$tcsettings{'ACTIVE'},$tcsettings{'COMMENT'}\n";
415 } else { print FILE "$line"; }
416 }
417 }
418 close(FILE);
419 undef %tcsettings;
420 $tcsettings{'CHANGED'}='yes';
421 $tcsettings{'TCMODE'}='on';
422 $changed = 'yes';
423 } else {
424 if ($tcsettings{'EDITING'} ne 'no')
425 {
426 $tcsettings{'ACTION'} = $Lang::tr{'edit'};
427 $tcsettings{'ID'} = $tcsettings{'EDITING'};
428 }
429 }
430 }
431
432 if (($tcsettings{'MODE'} eq 'TIMECONSTRAINT') && ($tcsettings{'ACTION'} eq $Lang::tr{'urlfilter copy rule'}) && (!$errormessage))
433 {
434 $id = 0;
435 foreach $line (@tclist)
436 {
437 $id++;
438 if ($tcsettings{'ID'} eq $id)
439 {
440 chomp($line);
441 @temp = split(/\,/,$line);
442 $tcsettings{'DEFINITION'} = $temp[0];
443 $tcsettings{'MON'} = $temp[1];
444 $tcsettings{'TUE'} = $temp[2];
445 $tcsettings{'WED'} = $temp[3];
446 $tcsettings{'THU'} = $temp[4];
447 $tcsettings{'FRI'} = $temp[5];
448 $tcsettings{'SAT'} = $temp[6];
449 $tcsettings{'SUN'} = $temp[7];
450 $tcsettings{'FROM_HOUR'} = $temp[8];
451 $tcsettings{'FROM_MINUTE'} = $temp[9];
452 $tcsettings{'TO_HOUR'} = $temp[10];
453 $tcsettings{'TO_MINUTE'} = $temp[11];
454 $tcsettings{'SRC'} = $temp[12];
455 $tcsettings{'DST'} = $temp[13];
456 $tcsettings{'ACCESS'} = $temp[14];
457 $tcsettings{'ENABLERULE'} = $temp[15];
458 $tcsettings{'COMMENT'} = $temp[16];
459 }
460 }
461 $tcsettings{'TCMODE'}='on';
462 }
463
464 if (($tcsettings{'MODE'} eq 'TIMECONSTRAINT') && ($tcsettings{'ACTION'} eq $Lang::tr{'remove'}))
465 {
466 $id = 0;
467 open(FILE, ">$tcfile");
468 flock FILE, 2;
469 foreach $line (@tclist)
470 {
471 $id++;
472 unless ($tcsettings{'ID'} eq $id) { print FILE "$line"; }
473 }
474 close(FILE);
475 $tcsettings{'CHANGED'}='yes';
476 $tcsettings{'TCMODE'}='on';
477 }
478
479 if (($tcsettings{'MODE'} eq 'TIMECONSTRAINT') && ($tcsettings{'ACTION'} eq $Lang::tr{'urlfilter restart'}))
480 {
481 if (!($proxysettings{'ENABLE_FILTER'} eq 'on'))
482 {
483 $errormessage = $Lang::tr{'urlfilter not enabled'};
484 }
485 if ((!(-e "${General::swroot}/proxy/enable")) && (!(-e "${General::swroot}/proxy/enable_blue")))
486 {
487 $errormessage = $Lang::tr{'urlfilter web proxy service required'};
488 }
489
490 if (!$errormessage) { system('/usr/local/bin/squidctrl restart >/dev/null 2>&1'); }
491 $tcsettings{'TCMODE'}='on';
492 }
493
494 if (($tcsettings{'MODE'} eq 'TIMECONSTRAINT') && ($tcsettings{'ACTION'} eq $Lang::tr{'toggle enable disable'}))
495 {
496 open(FILE, ">$tcfile");
497 flock FILE, 2;
498 $id = 0;
499 foreach $line (@tclist)
500 {
501 $id++;
502 unless ($tcsettings{'ID'} eq $id) { print FILE "$line"; }
503 else
504 {
505 chomp($line);
506 @temp = split(/\,/,$line);
507 if ($temp[15] eq 'on') { $temp[15] = 'off'; } else { $temp[15] = 'on' }
508 print FILE "$temp[0],$temp[1],$temp[2],$temp[3],$temp[4],$temp[5],$temp[6],$temp[7],$temp[8],$temp[9],$temp[10],$temp[11],$temp[12],$temp[13],$temp[14],$temp[15],$temp[16]\n";
509 }
510 }
511 close(FILE);
512 $tcsettings{'CHANGED'}='yes';
513 $tcsettings{'TCMODE'}='on';
514 }
515
516 if (($tcsettings{'MODE'} eq 'TIMECONSTRAINT') && ($tcsettings{'ACTION'} eq $Lang::tr{'edit'}) && (!$errormessage))
517 {
518 $id = 0;
519 foreach $line (@tclist)
520 {
521 $id++;
522 if ($tcsettings{'ID'} eq $id)
523 {
524 chomp($line);
525 @temp = split(/\,/,$line);
526 $tcsettings{'DEFINITION'} = $temp[0];
527 $tcsettings{'MON'} = $temp[1];
528 $tcsettings{'TUE'} = $temp[2];
529 $tcsettings{'WED'} = $temp[3];
530 $tcsettings{'THU'} = $temp[4];
531 $tcsettings{'FRI'} = $temp[5];
532 $tcsettings{'SAT'} = $temp[6];
533 $tcsettings{'SUN'} = $temp[7];
534 $tcsettings{'FROM_HOUR'} = $temp[8];
535 $tcsettings{'FROM_MINUTE'} = $temp[9];
536 $tcsettings{'TO_HOUR'} = $temp[10];
537 $tcsettings{'TO_MINUTE'} = $temp[11];
538 $tcsettings{'SRC'} = $temp[12];
539 $tcsettings{'DST'} = $temp[13];
540 $tcsettings{'ACCESS'} = $temp[14];
541 $tcsettings{'ENABLERULE'} = $temp[15];
542 $tcsettings{'COMMENT'} = $temp[16];
543 }
544 }
545 $tcsettings{'TCMODE'}='on';
546 }
547
548 if ((!$errormessage) && (!($tcsettings{'ACTION'} eq $Lang::tr{'urlfilter copy rule'})) && (!($tcsettings{'ACTION'} eq $Lang::tr{'edit'}))) {
549 $tcsettings{'ENABLERULE'}='on';
550 $tcsettings{'TO_HOUR'}='24';
551 }
552
553 if ($uqsettings{'ACTION'} eq $Lang::tr{'urlfilter set user quota'}) { $uqsettings{'UQMODE'} = 'on'}
554
555 if (($uqsettings{'MODE'} eq 'USERQUOTA') && ($uqsettings{'ACTION'} eq $Lang::tr{'add'}))
556 {
557 $uqsettings{'UQMODE'}='on';
558
559 if ((!($uqsettings{'TIME_QUOTA'} =~ /^\d+/)) || ($uqsettings{'TIME_QUOTA'} < '1'))
560 {
561 $errormessage=$Lang::tr{'urlfilter quota time error'};
562 }
563
564 @temp = split(/\n/,$uqsettings{'QUOTA_USERS'});
565 undef $uqsettings{'QUOTA_USERS'};
566 foreach (@temp)
567 {
568 s/^\s+//g; s/\s+$//g;
569 if ($_) { $uqsettings{'QUOTA_USERS'} .= $_."\n"; }
570 }
571
572 if ($uqsettings{'QUOTA_USERS'} eq '')
573 {
574 $errormessage=$Lang::tr{'urlfilter quota user error'};
575 }
576
577 $_ = $uqsettings{'QUOTA_USERS'};
578 chomp; s/\n/|/g;
579 my $quota_users = $_;
580
581 if ($uqsettings{'QUOTA_USERS'} =~ /\\/)
582 {
583 $errormessage=$Lang::tr{'urlfilter invalid user error'};
584 }
585
586 if (!$errormessage) {
587 if ($uqsettings{'ENABLEQUOTA'} eq 'on') { $uqsettings{'ACTIVE'} = $uqsettings{'ENABLEQUOTA'}; } else { $uqsettings{'ACTIVE'} = 'off'}
588
589 $uqsettings{'ENABLERULE'} = 'on';
590 if($uqsettings{'EDITING'} eq 'no') {
591 open(FILE,">>$uqfile");
592 flock FILE, 2;
593 print FILE "$uqsettings{'TIME_QUOTA'},$uqsettings{'SPORADIC'},$uqsettings{'RENEWAL'},$quota_users,$uqsettings{'ACTIVE'}\n";
594 } else {
595 open(FILE, ">$uqfile");
596 flock FILE, 2;
597 $id = 0;
598 foreach $line (@uqlist)
599 {
600 $id++;
601 if ($uqsettings{'EDITING'} eq $id) {
602 print FILE "$uqsettings{'TIME_QUOTA'},$uqsettings{'SPORADIC'},$uqsettings{'RENEWAL'},$quota_users,$uqsettings{'ACTIVE'}\n";
603 } else { print FILE "$line"; }
604 }
605 }
606 close(FILE);
607 undef %uqsettings;
608 $uqsettings{'CHANGED'}='yes';
609 $uqsettings{'MODE'}='USERQUOTA';
610 $uqsettings{'UQMODE'}='on';
611 $changed = 'yes';
612 } else {
613 if ($uqsettings{'EDITING'} ne 'no')
614 {
615 $uqsettings{'ACTION'} = $Lang::tr{'edit'};
616 $uqsettings{'ID'} = $uqsettings{'EDITING'};
617 }
618 }
619 }
620
621 if (($uqsettings{'MODE'} eq 'USERQUOTA') && ($uqsettings{'ACTION'} eq $Lang::tr{'remove'}))
622 {
623 $id = 0;
624 open(FILE, ">$uqfile");
625 flock FILE, 2;
626 foreach $line (@uqlist)
627 {
628 $id++;
629 unless ($uqsettings{'ID'} eq $id) { print FILE "$line"; }
630 }
631 close(FILE);
632 $uqsettings{'CHANGED'}='yes';
633 $uqsettings{'UQMODE'}='on';
634 }
635
636 if (!$errormessage) {
637 $uqsettings{'ENABLEQUOTA'}='on';
638 }
639
640 if (($uqsettings{'MODE'} eq 'USERQUOTA') && ($uqsettings{'ACTION'} eq $Lang::tr{'edit'}) && (!$errormessage))
641 {
642 $id = 0;
643 foreach $line (@uqlist)
644 {
645 $id++;
646 if ($uqsettings{'ID'} eq $id)
647 {
648 chomp($line);
649 @temp = split(/\,/,$line);
650 $uqsettings{'TIME_QUOTA'} = $temp[0];
651 $uqsettings{'SPORADIC'} = $temp[1];
652 $uqsettings{'RENEWAL'} = $temp[2];
653 $uqsettings{'QUOTA_USERS'} = $temp[3];
654 $uqsettings{'ENABLEQUOTA'} = $temp[4];
655 }
656 }
657 $uqsettings{'UQMODE'}='on';
658 }
659
660 if (($uqsettings{'MODE'} eq 'USERQUOTA') && ($uqsettings{'ACTION'} eq $Lang::tr{'toggle enable disable'}))
661 {
662 open(FILE, ">$uqfile");
663 flock FILE, 2;
664 $id = 0;
665 foreach $line (@uqlist)
666 {
667 $id++;
668 unless ($uqsettings{'ID'} eq $id) { print FILE "$line"; }
669 else
670 {
671 chomp($line);
672 @temp = split(/\,/,$line);
673 if ($temp[4] eq 'on') { $temp[4] = 'off'; } else { $temp[4] = 'on' }
674 print FILE "$temp[0],$temp[1],$temp[2],$temp[3],$temp[4]\n";
675 }
676 }
677 close(FILE);
678 $uqsettings{'CHANGED'}='yes';
679 $uqsettings{'UQMODE'}='on';
680 }
681
682 if (($uqsettings{'MODE'} eq 'USERQUOTA') && ($uqsettings{'ACTION'} eq $Lang::tr{'urlfilter restart'}))
683 {
684 if (!($proxysettings{'ENABLE_FILTER'} eq 'on'))
685 {
686 $errormessage = $Lang::tr{'urlfilter not enabled'};
687 }
688 if ((!(-e "${General::swroot}/proxy/enable")) && (!(-e "${General::swroot}/proxy/enable_blue")))
689 {
690 $errormessage = $Lang::tr{'urlfilter web proxy service required'};
691 }
692
693 if (!$errormessage) { system('/usr/local/bin/squidctrl restart >/dev/null 2>&1'); }
694 $uqsettings{'UQMODE'}='on';
695 }
696
697 if ($besettings{'ACTION'} eq $Lang::tr{'urlfilter blacklist editor'}) { $besettings{'BEMODE'} = 'on'; }
698
699 if ($besettings{'MODE'} eq 'BLACKLIST_EDITOR')
700 {
701 @temp = split(/\n/,$besettings{'BE_DOMAINS'});
702 undef $besettings{'BE_DOMAINS'};
703 foreach (@temp)
704 {
705 s/^\s+//g; s/\s+$//g;
706 if ($_) { $besettings{'BE_DOMAINS'} .= $_."\n"; }
707 }
708 chomp($besettings{'BE_DOMAINS'});
709 @temp = split(/\n/,$besettings{'BE_URLS'});
710 undef $besettings{'BE_URLS'};
711 foreach (@temp)
712 {
713 s/^\s+//g; s/\s+$//g;
714 if ($_) { $besettings{'BE_URLS'} .= $_."\n"; }
715 }
716 chomp($besettings{'BE_URLS'});
717 @temp = split(/\n/,$besettings{'BE_EXPRESSIONS'});
718 undef $besettings{'BE_EXPRESSIONS'};
719 foreach (@temp)
720 {
721 s/^\s+//g; s/\s+$//g;
722 if ($_) { $besettings{'BE_EXPRESSIONS'} .= $_."\n"; }
723 }
724 chomp($besettings{'BE_EXPRESSIONS'});
725 }
726
727 if (($besettings{'ACTION'} eq $Lang::tr{'urlfilter load blacklist'}) && ($besettings{'MODE'} = 'BLACKLIST_EDITOR'))
728 {
729 $besettings{'BEMODE'} = 'on';
730
731 $besettings{'BE_NAME'} = $besettings{'BE_BLACKLIST'};
732
733 delete $besettings{'BE_DOMAINS'};
734 delete $besettings{'BE_URLS'};
735 delete $besettings{'BE_EXPRESSIONS'};
736
737 if (-e "$dbdir/$besettings{'BE_NAME'}/domains")
738 {
739 open(FILE, "$dbdir/$besettings{'BE_NAME'}/domains");
740 while (<FILE>) { unless ($_ eq '\n') { $besettings{'BE_DOMAINS'} .= $_ } };
741 close FILE;
742 chomp($besettings{'BE_DOMAINS'});
743 }
744 if (-e "$dbdir/$besettings{'BE_NAME'}/urls")
745 {
746 open(FILE, "$dbdir/$besettings{'BE_NAME'}/urls");
747 while (<FILE>) { unless ($_ eq '\n') { $besettings{'BE_URLS'} .= $_ } };
748 close FILE;
749 chomp($besettings{'BE_URLS'});
750 }
751 if (-e "$dbdir/$besettings{'BE_NAME'}/expressions")
752 {
753 open(FILE, "$dbdir/$besettings{'BE_NAME'}/expressions");
754 while (<FILE>) { unless ($_ eq '\n') { $besettings{'BE_EXPRESSIONS'} .= $_ } };
755 close FILE;
756 chomp($besettings{'BE_EXPRESSIONS'});
757 }
758 }
759
760 if (($besettings{'ACTION'} eq $Lang::tr{'urlfilter import blacklist'}) && ($besettings{'MODE'} = 'BLACKLIST_EDITOR'))
761 {
762 $besettings{'BEMODE'} = 'on';
763
764 &Header::getcgihash(\%besettings, {'wantfile' => 1, 'filevar' => 'IMPORTFILE'});
765
766 if (!($besettings{'IMPORTFILE'} =~ /.tar.gz$/))
767 {
768 $errormessage = $Lang::tr{'urlfilter wrong filetype'};
769 } else {
770 if (!-d "$editdir") { mkdir("$editdir"); }
771
772 if (copy($besettings{'IMPORTFILE'}, "$editdir/blacklist.tar.gz") != 1)
773 {
774 $errormessage = $!;
775 } else {
776
777 my $exitcode = system("/bin/tar --no-same-owner --preserve-permissions -xzf $editdir/blacklist.tar.gz -C $editdir");
778 if ($exitcode > 0)
779 {
780 $errormessage = $Lang::tr{'urlfilter tar error'};
781 } else {
782 $i = 0;
783 foreach (<$editdir/blacklists/*>)
784 {
785 if (-d)
786 {
787 $i++;
788 $besettings{'BE_NAME'} = substr($_, rindex($_,"/")+1);
789 }
790 }
791
792 if (!($i == 1))
793 {
794 $errormessage = $Lang::tr{'urlfilter invalid import file'};
795 } else {
796 delete $besettings{'BE_DOMAINS'};
797 delete $besettings{'BE_URLS'};
798 delete $besettings{'BE_EXPRESSIONS'};
799
800 if (-e "$editdir/blacklists/$besettings{'BE_NAME'}/domains")
801 {
802 open(FILE, "$editdir/blacklists/$besettings{'BE_NAME'}/domains");
803 while (<FILE>) { unless ($_ eq '\n') { $besettings{'BE_DOMAINS'} .= $_ } };
804 close FILE;
805 chomp($besettings{'BE_DOMAINS'});
806 }
807 if (-e "$editdir/blacklists/$besettings{'BE_NAME'}/urls")
808 {
809 open(FILE, "$editdir/blacklists/$besettings{'BE_NAME'}/urls");
810 while (<FILE>) { unless ($_ eq '\n') { $besettings{'BE_URLS'} .= $_ } };
811 close FILE;
812 chomp($besettings{'BE_URLS'});
813 }
814 if (-e "$editdir/blacklists/$besettings{'BE_NAME'}/expressions")
815 {
816 open(FILE, "$editdir/blacklists/$besettings{'BE_NAME'}/expressions");
817 while (<FILE>) { unless ($_ eq '\n') { $besettings{'BE_EXPRESSIONS'} .= $_ } };
818 close FILE;
819 chomp($besettings{'BE_EXPRESSIONS'});
820 }
821 }
822 }
823
824 if (-d $editdir) { system("rm -rf $editdir"); }
825
826 }
827 }
828 }
829
830 if (($besettings{'ACTION'} eq $Lang::tr{'urlfilter export blacklist'}) && ($besettings{'MODE'} = 'BLACKLIST_EDITOR'))
831 {
832 $besettings{'BEMODE'} = 'on';
833
834 if ($besettings{'BE_NAME'} eq '')
835 {
836 $errormessage = $Lang::tr{'urlfilter category name error'};
837 } elsif ($besettings{'BE_DOMAINS'} || $besettings{'BE_URLS'} || $besettings{'BE_EXPRESSIONS'}) {
838
839 $_ = $besettings{'BE_NAME'}; tr/A-Z/a-z/; $besettings{'BE_NAME'} = $_;
840
841 if (!(-d "$editdir")) { mkdir("$editdir"); }
842 if (!(-d "$editdir/blacklists")) { mkdir("$editdir/blacklists"); }
843 if (!(-d "$editdir/blacklists/$besettings{'BE_NAME'}")) { mkdir("$editdir/blacklists/$besettings{'BE_NAME'}"); }
844
845 open(FILE, ">$editdir/blacklists/$besettings{'BE_NAME'}/domains");
846 flock FILE, 2;
847 print FILE "$besettings{'BE_DOMAINS'}\n";
848 close FILE;
849 open(FILE, ">$editdir/blacklists/$besettings{'BE_NAME'}/urls");
850 flock FILE, 2;
851 print FILE "$besettings{'BE_URLS'}\n";
852 close FILE;
853 open(FILE, ">$editdir/blacklists/$besettings{'BE_NAME'}/expressions");
854 flock FILE, 2;
855 print FILE "$besettings{'BE_EXPRESSIONS'}\n";
856 close FILE;
857
858 if (system("/bin/tar -C $editdir -czf $editdir/$besettings{'BE_NAME'}.tar.gz blacklists"))
859 {
860 $errormessage = $Lang::tr{'urlfilter export error'};
861 }
862 else
863 {
864 print "Content-type: application/gzip\n";
865 print "Content-length: ";
866 print (-s "$editdir/$besettings{'BE_NAME'}.tar.gz");
867 print "\n";
868 print "Content-disposition: attachment; filename=$besettings{'BE_NAME'}.tar.gz\n\n";
869
870 open (FILE, "$editdir/$besettings{'BE_NAME'}.tar.gz");
871 while (<FILE>) { print; }
872 close (FILE);
873
874 if (-d $editdir) { system("rm -rf $editdir"); }
875 exit;
876 }
877 } else {
878 $errormessage = $Lang::tr{'urlfilter category data error'};
879 }
880 }
881
882 if (($besettings{'ACTION'} eq $Lang::tr{'urlfilter install blacklist'}) && ($besettings{'MODE'} = 'BLACKLIST_EDITOR'))
883 {
884 $besettings{'BEMODE'} = 'on';
885
886 if ($besettings{'BE_NAME'} eq '')
887 {
888 $errormessage = $Lang::tr{'urlfilter category name error'};
889 } elsif ($besettings{'BE_DOMAINS'} || $besettings{'BE_URLS'} || $besettings{'BE_EXPRESSIONS'}) {
890
891 $_ = $besettings{'BE_NAME'}; tr/A-Z/a-z/; $besettings{'BE_NAME'} = $_;
892
893 if (!-d "$editdir") { mkdir("$editdir"); }
894
895 if (!-d "$dbdir/$besettings{'BE_NAME'}") { mkdir("$dbdir/$besettings{'BE_NAME'}"); }
896
897 if (-e "$dbdir/$besettings{'BE_NAME'}/domains") { unlink("$dbdir/$besettings{'BE_NAME'}/domains"); }
898 if ($besettings{'BE_DOMAINS'})
899 {
900 open(FILE, ">$dbdir/$besettings{'BE_NAME'}/domains");
901 flock FILE, 2;
902 print FILE "$besettings{'BE_DOMAINS'}\n";
903 close FILE;
904 }
905 if (-e "$dbdir/$besettings{'BE_NAME'}/urls") { unlink("$dbdir/$besettings{'BE_NAME'}/urls"); }
906 if ($besettings{'BE_URLS'})
907 {
908 open(FILE, ">$dbdir/$besettings{'BE_NAME'}/urls");
909 flock FILE, 2;
910 print FILE "$besettings{'BE_URLS'}\n";
911 close FILE;
912 }
913 if (-e "$dbdir/$besettings{'BE_NAME'}/expressions") { unlink("$dbdir/$besettings{'BE_NAME'}/expressions"); }
914 if ($besettings{'BE_EXPRESSIONS'})
915 {
916 open(FILE, ">$dbdir/$besettings{'BE_NAME'}/expressions");
917 flock FILE, 2;
918 print FILE "$besettings{'BE_EXPRESSIONS'}\n";
919 close FILE;
920 }
921
922 open(FILE, ">$editdir/install.conf");
923 flock FILE, 2;
924 print FILE "logdir /var/log/squidGuard\n";
925 print FILE "dbhome $dbdir/$besettings{'BE_NAME'}\n\n";
926 print FILE "dest $besettings{'BE_NAME'} {\n";
927 if ($besettings{'BE_DOMAINS'}) { print FILE " domainlist domains\n"; }
928 if ($besettings{'BE_URLS'}) { print FILE " urllist urls\n"; }
929 if ($besettings{'BE_EXPRESSIONS'}) { print FILE " expressions expressions\n"; }
930 print FILE "}\n\n";
931 print FILE "acl {\n";
932 print FILE " default {\n";
933 print FILE " pass none\n";
934 print FILE " }\n";
935 print FILE "}\n";
936 close FILE;
937
938 system("rm -f $dbdir/$besettings{'BE_NAME'}/*.db");
939 system("/usr/sbin/squidGuard -c $editdir/install.conf -C all");
940 system("chmod a+w $dbdir/$besettings{'BE_NAME'}/*.db");
941
942 &readblockcategories;
943 &readcustomlists;
944
945 &writeconfigfile;
946
947 system('/usr/local/bin/squidctrl restart >/dev/null 2>&1') unless ($besettings{'NORESTART'} eq 'on');
948
949 if (-d $editdir) { system("rm -rf $editdir"); }
950 } else {
951 $errormessage = $Lang::tr{'urlfilter category data error'};
952 }
953 }
954
955 if ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter save schedule'})
956 {
957 if (($filtersettings{'UPDATE_SOURCE'} eq 'custom') && ($filtersettings{'CUSTOM_UPDATE_URL'} eq ''))
958 {
959 $errormessage = $Lang::tr{'urlfilter custom url required'};
960 } else {
961 open (FILE, ">$updconffile");
962 print FILE "ENABLE_AUTOUPDATE=$filtersettings{'ENABLE_AUTOUPDATE'}\n";
963 print FILE "UPDATE_SCHEDULE=$filtersettings{'UPDATE_SCHEDULE'}\n";
964 print FILE "UPDATE_SOURCE=$filtersettings{'UPDATE_SOURCE'}\n";
965 print FILE "CUSTOM_UPDATE_URL=$filtersettings{'CUSTOM_UPDATE_URL'}\n";
966 close FILE;
967
968 if (-e $upd_cron_dly) { unlink($upd_cron_dly); }
969 if (-e $upd_cron_wly) { unlink($upd_cron_wly); }
970 if (-e $upd_cron_mly) { unlink($upd_cron_mly); }
971
972 if (($filtersettings{'ENABLE_AUTOUPDATE'} eq 'on') && ($filtersettings{'UPDATE_SCHEDULE'} eq 'daily'))
973 {
974 symlink("../bin/autoupdate.pl",$upd_cron_dly)
975 } else {
976 symlink("/bin/false",$upd_cron_dly)
977 }
978
979 if (($filtersettings{'ENABLE_AUTOUPDATE'} eq 'on') && ($filtersettings{'UPDATE_SCHEDULE'} eq 'weekly'))
980 {
981 symlink("../bin/autoupdate.pl",$upd_cron_wly)
982 } else {
983 symlink("/bin/false",$upd_cron_wly)
984 }
985
986 if (($filtersettings{'ENABLE_AUTOUPDATE'} eq 'on') && ($filtersettings{'UPDATE_SCHEDULE'} eq 'monthly'))
987 {
988 symlink("../bin/autoupdate.pl",$upd_cron_mly)
989 } else {
990 symlink("/bin/false",$upd_cron_mly)
991 }
992 }
993 }
994
995 if ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter update now'})
996 {
997 if ($filtersettings{'UPDATE_SOURCE'} eq 'custom')
998 {
999 if ($filtersettings{'CUSTOM_UPDATE_URL'} eq '')
1000 {
1001 $errormessage = $Lang::tr{'urlfilter custom url required'};
1002 } else {
1003 system("${General::swroot}/urlfilter/bin/autoupdate.pl $filtersettings{'CUSTOM_UPDATE_URL'} &");
1004 }
1005 } else {
1006 system("${General::swroot}/urlfilter/bin/autoupdate.pl $filtersettings{'UPDATE_SOURCE'} &");
1007 }
1008 }
1009
1010
1011 if (-e "${General::swroot}/urlfilter/settings") { &General::readhash("${General::swroot}/urlfilter/settings", \%filtersettings); }
1012
1013 &readcustomlists;
1014
1015 ERROR:
1016
1017 if ($errormessage) { $filtersettings{'VALID'} = 'no'; }
1018
1019 $checked{'ENABLE_CUSTOM_BLACKLIST'}{'off'} = '';
1020 $checked{'ENABLE_CUSTOM_BLACKLIST'}{'on'} = '';
1021 $checked{'ENABLE_CUSTOM_BLACKLIST'}{$filtersettings{'ENABLE_CUSTOM_BLACKLIST'}} = "checked='checked'";
1022 $checked{'ENABLE_CUSTOM_WHITELIST'}{'off'} = '';
1023 $checked{'ENABLE_CUSTOM_WHITELIST'}{'on'} = '';
1024 $checked{'ENABLE_CUSTOM_WHITELIST'}{$filtersettings{'ENABLE_CUSTOM_WHITELIST'}} = "checked='checked'";
1025 $checked{'ENABLE_CUSTOM_EXPRESSIONS'}{'off'} = '';
1026 $checked{'ENABLE_CUSTOM_EXPRESSIONS'}{'on'} = '';
1027 $checked{'ENABLE_CUSTOM_EXPRESSIONS'}{$filtersettings{'ENABLE_CUSTOM_EXPRESSIONS'}} = "checked='checked'";
1028 $checked{'BLOCK_EXECUTABLES'}{'off'} = '';
1029 $checked{'BLOCK_EXECUTABLES'}{'on'} = '';
1030 $checked{'BLOCK_EXECUTABLES'}{$filtersettings{'BLOCK_EXECUTABLES'}} = "checked='checked'";
1031 $checked{'BLOCK_AUDIO-VIDEO'}{'off'} = '';
1032 $checked{'BLOCK_AUDIO-VIDEO'}{'on'} = '';
1033 $checked{'BLOCK_AUDIO-VIDEO'}{$filtersettings{'BLOCK_AUDIO-VIDEO'}} = "checked='checked'";
1034 $checked{'BLOCK_ARCHIVES'}{'off'} = '';
1035 $checked{'BLOCK_ARCHIVES'}{'on'} = '';
1036 $checked{'BLOCK_ARCHIVES'}{$filtersettings{'BLOCK_ARCHIVES'}} = "checked='checked'";
1037 $checked{'ENABLE_REWRITE'}{'off'} = '';
1038 $checked{'ENABLE_REWRITE'}{'on'} = '';
1039 $checked{'ENABLE_REWRITE'}{$filtersettings{'ENABLE_REWRITE'}} = "checked='checked'";
1040 $checked{'SHOW_CATEGORY'}{'off'} = '';
1041 $checked{'SHOW_CATEGORY'}{'on'} = '';
1042 $checked{'SHOW_CATEGORY'}{$filtersettings{'SHOW_CATEGORY'}} = "checked='checked'";
1043 $checked{'SHOW_URL'}{'off'} = '';
1044 $checked{'SHOW_URL'}{'on'} = '';
1045 $checked{'SHOW_URL'}{$filtersettings{'SHOW_URL'}} = "checked='checked'";
1046 $checked{'SHOW_IP'}{'off'} = '';
1047 $checked{'SHOW_IP'}{'on'} = '';
1048 $checked{'SHOW_IP'}{$filtersettings{'SHOW_IP'}} = "checked='checked'";
1049 $checked{'ENABLE_DNSERROR'}{'off'} = '';
1050 $checked{'ENABLE_DNSERROR'}{'on'} = '';
1051 $checked{'ENABLE_DNSERROR'}{$filtersettings{'ENABLE_DNSERROR'}} = "checked='checked'";
1052 $checked{'ENABLE_JPEG'}{'off'} = '';
1053 $checked{'ENABLE_JPEG'}{'on'} = '';
1054 $checked{'ENABLE_JPEG'}{$filtersettings{'ENABLE_JPEG'}} = "checked='checked'";
1055 $checked{'ENABLE_EXPR_LISTS'}{'off'} = '';
1056 $checked{'ENABLE_EXPR_LISTS'}{'on'} = '';
1057 $checked{'ENABLE_EXPR_LISTS'}{$filtersettings{'ENABLE_EXPR_LISTS'}} = "checked='checked'";
1058 $checked{'BLOCK_IP_ADDR'}{'off'} = '';
1059 $checked{'BLOCK_IP_ADDR'}{'on'} = '';
1060 $checked{'BLOCK_IP_ADDR'}{$filtersettings{'BLOCK_IP_ADDR'}} = "checked='checked'";
1061 $checked{'BLOCK_ALL'}{'off'} = '';
1062 $checked{'BLOCK_ALL'}{'on'} = '';
1063 $checked{'BLOCK_ALL'}{$filtersettings{'BLOCK_ALL'}} = "checked='checked'";
1064 $checked{'ENABLE_EMPTY_ADS'}{'off'} = '';
1065 $checked{'ENABLE_EMPTY_ADS'}{'on'} = '';
1066 $checked{'ENABLE_EMPTY_ADS'}{$filtersettings{'ENABLE_EMPTY_ADS'}} = "checked='checked'";
1067 $checked{'ENABLE_GLOBAL_WHITELIST'}{'off'} = '';
1068 $checked{'ENABLE_GLOBAL_WHITELIST'}{'on'} = '';
1069 $checked{'ENABLE_GLOBAL_WHITELIST'}{$filtersettings{'ENABLE_GLOBAL_WHITELIST'}} = "checked='checked'";
1070 $checked{'ENABLE_SAFESEARCH'}{'off'} = '';
1071 $checked{'ENABLE_SAFESEARCH'}{'on'} = '';
1072 $checked{'ENABLE_SAFESEARCH'}{$filtersettings{'ENABLE_SAFESEARCH'}} = "checked='checked'";
1073 $checked{'ENABLE_LOG'}{'off'} = '';
1074 $checked{'ENABLE_LOG'}{'on'} = '';
1075 $checked{'ENABLE_LOG'}{$filtersettings{'ENABLE_LOG'}} = "checked='checked'";
1076 $checked{'ENABLE_USERNAME_LOG'}{'off'} = '';
1077 $checked{'ENABLE_USERNAME_LOG'}{'on'} = '';
1078 $checked{'ENABLE_USERNAME_LOG'}{$filtersettings{'ENABLE_USERNAME_LOG'}} = "checked='checked'";
1079 $checked{'ENABLE_CATEGORY_LOG'}{'off'} = '';
1080 $checked{'ENABLE_CATEGORY_LOG'}{'on'} = '';
1081 $checked{'ENABLE_CATEGORY_LOG'}{$filtersettings{'ENABLE_CATEGORY_LOG'}} = "checked='checked'";
1082
1083 foreach $category (@filtergroups) {
1084 $checked{$category}{'off'} = '';
1085 $checked{$category}{'on'} = '';
1086 $checked{$category}{$filtersettings{$category}} = "checked='checked'";
1087 }
1088
1089 $selected{'DEFINITION'}{$tcsettings{'DEFINITION'}} = "selected='selected'";
1090 $selected{'FROM_HOUR'}{$tcsettings{'FROM_HOUR'}} = "selected='selected'";
1091 $selected{'FROM_MINUTE'}{$tcsettings{'FROM_MINUTE'}} = "selected='selected'";
1092 $selected{'TO_HOUR'}{$tcsettings{'TO_HOUR'}} = "selected='selected'";
1093 $selected{'TO_MINUTE'}{$tcsettings{'TO_MINUTE'}} = "selected='selected'";
1094
1095 @selectedcategories = split(/\|/,$tcsettings{'DST'});
1096 foreach (@selectedcategories)
1097 {
1098 $selected{'DST'}{$_} = "selected='selected'";
1099 }
1100
1101 $selected{'ACCESS'}{$tcsettings{'ACCESS'}} = "selected='selected'";
1102
1103 $checked{'ENABLERULE'}{'off'} = '';
1104 $checked{'ENABLERULE'}{'on'} = '';
1105 $checked{'ENABLERULE'}{$tcsettings{'ENABLERULE'}} = "checked='checked'";
1106 $checked{'MON'}{'off'} = '';
1107 $checked{'MON'}{'on'} = '';
1108 $checked{'MON'}{$tcsettings{'MON'}} = "checked='checked'";
1109 $checked{'TUE'}{'off'} = '';
1110 $checked{'TUE'}{'on'} = '';
1111 $checked{'TUE'}{$tcsettings{'TUE'}} = "checked='checked'";
1112 $checked{'WED'}{'off'} = '';
1113 $checked{'WED'}{'on'} = '';
1114 $checked{'WED'}{$tcsettings{'WED'}} = "checked='checked'";
1115 $checked{'THU'}{'off'} = '';
1116 $checked{'THU'}{'on'} = '';
1117 $checked{'THU'}{$tcsettings{'THU'}} = "checked='checked'";
1118 $checked{'FRI'}{'off'} = '';
1119 $checked{'FRI'}{'on'} = '';
1120 $checked{'FRI'}{$tcsettings{'FRI'}} = "checked='checked'";
1121 $checked{'SAT'}{'off'} = '';
1122 $checked{'SAT'}{'on'} = '';
1123 $checked{'SAT'}{$tcsettings{'SAT'}} = "checked='checked'";
1124 $checked{'SUN'}{'off'} = '';
1125 $checked{'SUN'}{'on'} = '';
1126 $checked{'SUN'}{$tcsettings{'SUN'}} = "checked='checked'";
1127
1128 $selected{'SPORADIC'}{$uqsettings{'SPORADIC'}} = "selected='selected'";
1129 $selected{'RENEWAL'} {$uqsettings{'RENEWAL'}} = "selected='selected'";
1130
1131 $checked{'ENABLEQUOTA'}{'off'} = '';
1132 $checked{'ENABLEQUOTA'}{'on'} = '';
1133 $checked{'ENABLEQUOTA'}{$uqsettings{'ENABLEQUOTA'}} = "checked='checked'";
1134
1135 $selected{'BE_BLACKLIST'}{$besettings{'BE_BLACKLIST'}} = "selected='selected'";
1136
1137
1138 &Header::showhttpheaders();
1139
1140 &Header::openpage($Lang::tr{'urlfilter configuration'}, 1, '');
1141
1142 &Header::openbigbox('100%', 'left', '', $errormessage);
1143
1144 if ($errormessage) {
1145 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
1146 print "<font class='base'>$errormessage&nbsp;</font>\n";
1147 &Header::closebox();
1148 } elsif (($tcsettings{'CHANGED'} eq 'yes') || ($uqsettings{'CHANGED'} eq 'yes') ) {
1149 &writeconfigfile;
1150 print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
1151 &Header::openbox('100%', 'left', "$Lang::tr{'urlfilter restart notification'}:");
1152 print "<class name='base'>$Lang::tr{'urlfilter restart message'}\n";
1153 if ($uqsettings{'MODE'} eq 'USERQUOTA') { print "<p><class name='base'>$Lang::tr{'urlfilter quota restart message'}\n"; }
1154 print "</class>\n";
1155 print "<p><input type='submit' name='ACTION' value='$Lang::tr{'urlfilter restart'}' />";
1156 if ($tcsettings{'MODE'} eq 'TIMECONSTRAINT') { print "<input type='hidden' name='MODE' value='TIMECONSTRAINT' />"; }
1157 if ($uqsettings{'MODE'} eq 'USERQUOTA') { print "<input type='hidden' name='MODE' value='USERQUOTA' />"; }
1158 &Header::closebox();
1159 print "</form>\n";
1160 }
1161
1162 if ($restoremessage) {
1163 &Header::openbox('100%', 'left', "$Lang::tr{'urlfilter restore results'}:");
1164 print "<class name='base'>$restoremessage\n";
1165 print "&nbsp;</class>\n";
1166 &Header::closebox();
1167 }
1168
1169 if ((!$tcsettings{'TCMODE'}) && (!$uqsettings{'UQMODE'}) && (!$besettings{'BEMODE'})) {
1170
1171 if (!($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter manage repository'})) {
1172
1173 #==========================================================
1174 #
1175 # Section: Main Configuration
1176 #
1177 #==========================================================
1178
1179 print "<form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>\n";
1180
1181 &Header::openbox('100%', 'left', "$Lang::tr{'urlfilter filter settings'}:");
1182 print <<END
1183 <table width='100%'>
1184 <tr>
1185 <td colspan='4'><b>$Lang::tr{'urlfilter block categories'}</b></td>
1186 </tr>
1187 END
1188 ;
1189
1190 if (@categories == 0) {
1191 print <<END
1192 <tr>
1193 <td><i>$Lang::tr{'urlfilter no categories'}</i></td>
1194 <td>&nbsp;</td>
1195 <td>&nbsp;</td>
1196 <td>&nbsp;</td>
1197 </tr>
1198
1199 END
1200 ;
1201 }
1202
1203 for ($n=0; $n<=@categories; $n = $n + $i) {
1204 for ($i=0; $i<=3; $i++) {
1205 if ($i eq 0) { print "<tr>\n"; }
1206 if (($n+$i) < @categories) {
1207 print "<td width='15%'>@categories[$n+$i]:<\/td>\n";
1208 print "<td width='10%'><input type='checkbox' name=@filtergroups[$n+$i] $checked{@filtergroups[$n+$i]}{'on'} /></td>\n";
1209 }
1210 if ($i eq 3) { print "<\/tr>\n"; }
1211 }
1212 }
1213
1214 print <<END
1215 </table>
1216 <hr size='1'>
1217 <table width='100%'>
1218 <tr>
1219 <td><b>$Lang::tr{'urlfilter custom blacklist'}</b></td>
1220 <td>&nbsp;</td>
1221 <td>&nbsp;</td>
1222 <td>&nbsp;</td>
1223 </tr>
1224 <tr>
1225 <td colspan='2'>$Lang::tr{'urlfilter blocked domains'}&nbsp;<img src='/blob.gif' alt='*' /></td>
1226 <td colspan='2'>$Lang::tr{'urlfilter blocked urls'}&nbsp;<img src='/blob.gif' alt='*' /></td>
1227 </tr>
1228 <tr>
1229 <td colspan='2' width='50%'><textarea name='CUSTOM_BLACK_DOMAINS' cols='32' rows='6' wrap='off'>
1230 END
1231 ;
1232
1233 print $filtersettings{'CUSTOM_BLACK_DOMAINS'};
1234
1235 print <<END
1236 </textarea></td>
1237 <td colspan='2' width='50%'><textarea name='CUSTOM_BLACK_URLS' cols='32' rows='6' wrap='off'>
1238 END
1239 ;
1240
1241 print $filtersettings{'CUSTOM_BLACK_URLS'};
1242
1243 print <<END
1244 </textarea></td>
1245 </tr>
1246 </table>
1247 <table width='100%'>
1248 <tr>
1249 <td class='base' width='25%'>$Lang::tr{'urlfilter enable custom blacklist'}:</td>
1250 <td><input type='checkbox' name='ENABLE_CUSTOM_BLACKLIST' $checked{'ENABLE_CUSTOM_BLACKLIST'}{'on'} /></td>
1251 <td>&nbsp;</td>
1252 <td>&nbsp;</td>
1253 </tr>
1254 </table>
1255 <hr size='1'>
1256 <table width='100%'>
1257 <tr>
1258 <td><b>$Lang::tr{'urlfilter custom whitelist'}</b></td>
1259 <td>&nbsp;</td>
1260 <td>&nbsp;</td>
1261 <td>&nbsp;</td>
1262 </tr>
1263 <tr>
1264 <td colspan='2'>$Lang::tr{'urlfilter allowed domains'}&nbsp;<img src='/blob.gif' alt='*' /></td>
1265 <td colspan='2'>$Lang::tr{'urlfilter allowed urls'}&nbsp;<img src='/blob.gif' alt='*' /></td>
1266 </tr>
1267 <tr>
1268 <td colspan='2' width='50%'><textarea name='CUSTOM_WHITE_DOMAINS' cols='32' rows='6' wrap='off'>
1269 END
1270 ;
1271
1272 print $filtersettings{'CUSTOM_WHITE_DOMAINS'};
1273
1274 print <<END
1275 </textarea></td>
1276 <td colspan='2' width='50%'><textarea name='CUSTOM_WHITE_URLS' cols='32' rows='6' wrap='off'>
1277 END
1278 ;
1279
1280 print $filtersettings{'CUSTOM_WHITE_URLS'};
1281
1282 print <<END
1283 </textarea></td>
1284 </tr>
1285 </table>
1286 <table width='100%'>
1287 <tr>
1288 <td class='base' width='25%'>$Lang::tr{'urlfilter enable custom whitelist'}:</td>
1289 <td><input type='checkbox' name='ENABLE_CUSTOM_WHITELIST' $checked{'ENABLE_CUSTOM_WHITELIST'}{'on'} /></td>
1290 <td>&nbsp;</td>
1291 <td>&nbsp;</td>
1292 </tr>
1293 </table>
1294 <hr size='1'>
1295 <table width='100%'>
1296 <tr>
1297 <td colspan='4'><b>$Lang::tr{'urlfilter custom expression list'}</b></td>
1298 </tr>
1299 <tr>
1300 <td colspan='4'>$Lang::tr{'urlfilter blocked expressions'}&nbsp;<img src='/blob.gif' alt='*' /></td>
1301 </tr>
1302 <tr>
1303 <td colspan='4'><textarea name='CUSTOM_EXPRESSIONS' cols='70' rows='3' wrap='off'>
1304 END
1305 ;
1306
1307 print $filtersettings{'CUSTOM_EXPRESSIONS'};
1308
1309 print <<END
1310 </textarea></td>
1311 </tr>
1312 <tr>
1313 <td class='base' width='25%'>$Lang::tr{'urlfilter enable custom expression list'}:</td>
1314 <td><input type='checkbox' name='ENABLE_CUSTOM_EXPRESSIONS' $checked{'ENABLE_CUSTOM_EXPRESSIONS'}{'on'} /></td>
1315 <td>&nbsp;</td>
1316 <td>&nbsp;</td>
1317 </tr>
1318 </table>
1319 <hr size='1'>
1320 <table width='100%'>
1321 <tr>
1322 <td colspan='4'><b>$Lang::tr{'urlfilter file ext block'}</b></td>
1323 </tr>
1324 <tr>
1325 <td width='25%' class='base'>$Lang::tr{'urlfilter block executables'}:</td>
1326 <td width='12%'><input type='checkbox' name='BLOCK_EXECUTABLES' $checked{'BLOCK_EXECUTABLES'}{'on'} /></td>
1327 <td width='25%' class='base'>$Lang::tr{'urlfilter block audio-video'}:</td>
1328 <td><input type='checkbox' name='BLOCK_AUDIO-VIDEO' $checked{'BLOCK_AUDIO-VIDEO'}{'on'} /></td>
1329 </tr>
1330 <tr>
1331 <td class='base'>$Lang::tr{'urlfilter block archives'}:</td>
1332 <td><input type='checkbox' name='BLOCK_ARCHIVES' $checked{'BLOCK_ARCHIVES'}{'on'} /></td>
1333 <td>&nbsp;</td>
1334 <td>&nbsp;</td>
1335 </tr>
1336 </table>
1337 <hr size='1'>
1338 <table width='100%'>
1339 <tr>
1340 <td colspan='4'><b>$Lang::tr{'urlfilter local file redirection'}</b></td>
1341 </tr>
1342 <tr>
1343 <td width='25%' class='base'>$Lang::tr{'urlfilter enable rewrite rules'}:</td>
1344 <td width='12%'><input type='checkbox' name='ENABLE_REWRITE' $checked{'ENABLE_REWRITE'}{'on'} /></td>
1345 <td>&nbsp;</td>
1346 <td>&nbsp;</td>
1347 </tr>
1348 <tr>
1349 <td><input type='submit' name='ACTION' value='$Lang::tr{'urlfilter manage repository'}'></td>
1350 <td>&nbsp;</td>
1351 <td>&nbsp;</td>
1352 <td>&nbsp;</td>
1353 </tr>
1354 </table>
1355 <hr size='1'>
1356 <table width='100%'>
1357 <tr>
1358 <td colspan='2'><b>$Lang::tr{'urlfilter network access control'}</b></td>
1359 <td>&nbsp;</td>
1360 <td>&nbsp;</td>
1361 </tr>
1362 <tr>
1363 <td colspan='2'>$Lang::tr{'urlfilter unfiltered clients'}&nbsp;<img src='/blob.gif' alt='*' /></td>
1364 <td colspan='2'>$Lang::tr{'urlfilter banned clients'}&nbsp;<img src='/blob.gif' alt='*' /></td>
1365 </tr>
1366 <tr>
1367 <td colspan='2' width='50%'><textarea name='UNFILTERED_CLIENTS' cols='32' rows='6' wrap='off'>
1368 END
1369 ;
1370
1371 # transform from pre1.8 client definitions
1372 $filtersettings{'UNFILTERED_CLIENTS'} =~ s/^\s+//g;
1373 $filtersettings{'UNFILTERED_CLIENTS'} =~ s/\s+$//g;
1374 $filtersettings{'UNFILTERED_CLIENTS'} =~ s/\s+-\s+/-/g;
1375 $filtersettings{'UNFILTERED_CLIENTS'} =~ s/\s+/ /g;
1376
1377 @clients = split(/ /,$filtersettings{'UNFILTERED_CLIENTS'});
1378 undef $filtersettings{'UNFILTERED_CLIENTS'};
1379 foreach (@clients) { $filtersettings{'UNFILTERED_CLIENTS'} .= "$_\n"; }
1380
1381 print $filtersettings{'UNFILTERED_CLIENTS'};
1382
1383 print <<END
1384 </textarea></td>
1385 <td colspan='2' width='50%'><textarea name='BANNED_CLIENTS' cols='32' rows='6' wrap='off'>
1386 END
1387 ;
1388
1389 # transform from pre1.8 client definitions
1390 $filtersettings{'BANNED_CLIENTS'} =~ s/^\s+//g;
1391 $filtersettings{'BANNED_CLIENTS'} =~ s/\s+$//g;
1392 $filtersettings{'BANNED_CLIENTS'} =~ s/\s+-\s+/-/g;
1393 $filtersettings{'BANNED_CLIENTS'} =~ s/\s+/ /g;
1394
1395 @clients = split(/ /,$filtersettings{'BANNED_CLIENTS'});
1396 undef $filtersettings{'BANNED_CLIENTS'};
1397 foreach (@clients) { $filtersettings{'BANNED_CLIENTS'} .= "$_\n"; }
1398
1399 print $filtersettings{'BANNED_CLIENTS'};
1400
1401 print <<END
1402 </textarea></td>
1403 </tr>
1404 </table>
1405 <hr size='1'>
1406 <table width='100%'>
1407 <tr>
1408 <td colspan='4'><b>$Lang::tr{'urlfilter timebased access control'}</b></td>
1409 </tr>
1410 <tr>
1411 <td width='25%'><input type='submit' name='ACTION' value='$Lang::tr{'urlfilter set time constraints'}'></td>
1412 <td width='25%'><input type='submit' name='ACTION' value='$Lang::tr{'urlfilter set user quota'}'></td>
1413 <td>&nbsp;</td>
1414 <td>&nbsp;</td>
1415 </tr>
1416 </table>
1417 <hr size='1'>
1418 <table width='100%'>
1419 <tr>
1420 <td colspan='4'><b>$Lang::tr{'urlfilter block settings'}</b></td>
1421 </tr>
1422 <tr>
1423 <td width='25%' class='base'>$Lang::tr{'urlfilter show category'}:</td>
1424 <td width='12%'><input type='checkbox' name='SHOW_CATEGORY' $checked{'SHOW_CATEGORY'}{'on'} /></td>
1425 <td width='25%' class='base'>$Lang::tr{'urlfilter redirectpage'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
1426 <td><input type='text' name='REDIRECT_PAGE' value='$filtersettings{'REDIRECT_PAGE'}' size='40' /></td>
1427 </tr>
1428 <tr>
1429 <td class='base'>$Lang::tr{'urlfilter show url'}:</td>
1430 <td><input type='checkbox' name='SHOW_URL' $checked{'SHOW_URL'}{'on'} /></td>
1431 <td class='base'>$Lang::tr{'urlfilter msg text 1'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
1432 <td><input type='text' name='MSG_TEXT_1' value='$filtersettings{'MSG_TEXT_1'}' size='40' /></td>
1433 </tr>
1434 <tr>
1435 <td class='base'>$Lang::tr{'urlfilter show ip'}:</td>
1436 <td><input type='checkbox' name='SHOW_IP' $checked{'SHOW_IP'}{'on'} /></td>
1437 <td class='base'>$Lang::tr{'urlfilter msg text 2'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
1438 <td><input type='text' name='MSG_TEXT_2' value='$filtersettings{'MSG_TEXT_2'}' size='40' /></td>
1439 </tr>
1440 <tr>
1441 <td class='base'>$Lang::tr{'urlfilter show dnserror'}:</td>
1442 <td><input type='checkbox' name='ENABLE_DNSERROR' $checked{'ENABLE_DNSERROR'}{'on'} /></td>
1443 <td class='base'>$Lang::tr{'urlfilter msg text 3'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
1444 <td><input type='text' name='MSG_TEXT_3' value='$filtersettings{'MSG_TEXT_3'}' size='40' /></td>
1445 </tr>
1446 </table>
1447 <hr size='1'>
1448 <table width='100%'>
1449 <tr>
1450 <td colspan='4'><b>$Lang::tr{'urlfilter advanced settings'}</b></td>
1451 </tr>
1452 <tr>
1453 <td width='25%' class='base'>$Lang::tr{'urlfilter enable expression lists'}:</td>
1454 <td width='12%'><input type='checkbox' name='ENABLE_EXPR_LISTS' $checked{'ENABLE_EXPR_LISTS'}{'on'} /></td>
1455 <td width='25%' class='base'>$Lang::tr{'urlfilter enable log'}:</td>
1456 <td><input type='checkbox' name='ENABLE_LOG' $checked{'ENABLE_LOG'}{'on'} /></td>
1457 </tr>
1458 <tr>
1459 <td class='base'>$Lang::tr{'urlfilter safesearch'}:</td>
1460 <td><input type='checkbox' name='ENABLE_SAFESEARCH' $checked{'ENABLE_SAFESEARCH'}{'on'} /></td>
1461 <td class='base'>$Lang::tr{'urlfilter username log'}:</td>
1462 <td><input type='checkbox' name='ENABLE_USERNAME_LOG' $checked{'ENABLE_USERNAME_LOG'}{'on'} /></td>
1463 </tr>
1464 <tr>
1465 <td class='base'>$Lang::tr{'urlfilter empty ads'}:</td>
1466 <td><input type='checkbox' name='ENABLE_EMPTY_ADS' $checked{'ENABLE_EMPTY_ADS'}{'on'} /></td>
1467 <td class='base'>$Lang::tr{'urlfilter category log'}:</td>
1468 <td><input type='checkbox' name='ENABLE_CATEGORY_LOG' $checked{'ENABLE_CATEGORY_LOG'}{'on'} /></td>
1469 </tr>
1470 <tr>
1471 <td class='base'>$Lang::tr{'urlfilter block ip'}:</td>
1472 <td><input type='checkbox' name='BLOCK_IP_ADDR' $checked{'BLOCK_IP_ADDR'}{'on'} /></td>
1473 </tr>
1474 <tr>
1475 <td class='base'>$Lang::tr{'urlfilter block all'}:</td>
1476 <td><input type='checkbox' name='BLOCK_ALL' $checked{'BLOCK_ALL'}{'on'} /></td>
1477 <td class='base'>$Lang::tr{'urlfilter whitelist always allowed'}:</td>
1478 <td><input type='checkbox' name='ENABLE_GLOBAL_WHITELIST' $checked{'ENABLE_GLOBAL_WHITELIST'}{'on'} /></td>
1479 </tr>
1480 </table>
1481 <hr size='1'>
1482 <table width='100%'>
1483 <tr>
1484 <td>
1485 <img src='/blob.gif' align='top' alt='*' />&nbsp;
1486 <font class='base'>$Lang::tr{'this field may be blank'}</font>
1487 </td>
1488 <td align='right'>&nbsp;
1489 </td>
1490 </tr>
1491 </table>
1492 <table width='100%'>
1493 <tr>
1494 <td>&nbsp;</td>
1495 <td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
1496 <td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'urlfilter save and restart'}' /></td>
1497 <td>&nbsp;</td>
1498 </tr>
1499 </table>
1500 END
1501 ;
1502
1503 &Header::closebox();
1504
1505 print "</form>\n";
1506
1507 print "<form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>\n";
1508
1509 &Header::openbox('100%', 'left', "$Lang::tr{'urlfilter maintenance'}:");
1510
1511 print <<END
1512 <table width='100%'>
1513 <tr>
1514 <td class='base'><b>$Lang::tr{'urlfilter blacklist update'}</b></td>
1515 </tr>
1516 <tr>
1517 <td>$Lang::tr{'urlfilter upload information'}<p>$Lang::tr{'urlfilter upload text'}:</td>
1518 </tr>
1519 <tr>
1520 <td><input type='file' name='UPDATEFILE' size='40' /> &nbsp; <input type='submit' name='ACTION' value='$Lang::tr{'urlfilter upload blacklist'}' /></td>
1521 </tr>
1522 </table>
1523
1524 <hr size='1'>
1525
1526 <table width='100%'>
1527 <tr>
1528 <td colspan='2' class='base'><b>$Lang::tr{'urlfilter automatic blacklist update'}</b>
1529 END
1530 ;
1531 if (-e "$updflagfile")
1532 {
1533 $blacklistage = int(-M "$updflagfile");
1534 print "&nbsp; <b>[</b> <small><i>$Lang::tr{'urlfilter blacklist age 1'} <b>$blacklistage</b> $Lang::tr{'urlfilter blacklist age 2'}</i></small> <b>]</b>";
1535 }
1536
1537 $updatesettings{'UPDATE_SCHEDULE'} = 'monthly';
1538 $updatesettings{'CUSTOM_UPDATE_URL'} = '';
1539
1540 if (-e "$updconffile") { &General::readhash("$updconffile", \%updatesettings); }
1541
1542 $checked{'ENABLE_AUTOUPDATE'}{'off'} = '';
1543 $checked{'ENABLE_AUTOUPDATE'}{'on'} = '';
1544 $checked{'ENABLE_AUTOUPDATE'}{$updatesettings{'ENABLE_AUTOUPDATE'}} = "checked='checked'";
1545
1546 $selected{'UPDATE_SCHEDULE'}{$updatesettings{'UPDATE_SCHEDULE'}} = "selected='selected'";
1547
1548 $selected{'UPDATE_SOURCE'}{$updatesettings{'UPDATE_SOURCE'}} = "selected='selected'";
1549
1550 print <<END
1551 </td>
1552 </tr>
1553 <tr>
1554 <td width='25%' class='base'>$Lang::tr{'urlfilter enable automatic blacklist update'}:</td>
1555 <td width='75%' class='base'><input type='checkbox' name='ENABLE_AUTOUPDATE' $checked{'ENABLE_AUTOUPDATE'}{'on'} /></td>
1556 </tr>
1557 <tr>
1558 <td class='base'>$Lang::tr{'urlfilter automatic update schedule'}:</td>
1559 <td class='base'>
1560 <select name='UPDATE_SCHEDULE'>
1561 <option value='daily' $selected{'UPDATE_SCHEDULE'}{'daily'}>$Lang::tr{'urlfilter daily'}</option>
1562 <option value='weekly' $selected{'UPDATE_SCHEDULE'}{'weekly'}>$Lang::tr{'urlfilter weekly'}</option>
1563 <option value='monthly' $selected{'UPDATE_SCHEDULE'}{'monthly'}>$Lang::tr{'urlfilter monthly'}</option>
1564 </select>
1565 </td>
1566 </tr>
1567 <tr>
1568 <td class='base'>$Lang::tr{'urlfilter select source'}:</td>
1569 <td class='base' colspan='2'>
1570 <select name='UPDATE_SOURCE'>
1571 END
1572 ;
1573
1574 foreach (@source_urllist) {
1575 chomp;
1576 $source_name = substr($_,0,rindex($_,","));
1577 $source_url = substr($_,index($_,",")+1);
1578 print "\t<option value='$source_url' $selected{'UPDATE_SOURCE'}{$source_url}>$source_name</option>\n";
1579 }
1580
1581 print <<END
1582 <option value='custom' $selected{'UPDATE_SOURCE'}{'custom'}>$Lang::tr{'urlfilter custom url'}</option>
1583 </select>
1584 </td>
1585 </tr>
1586 <tr>
1587 <td>$Lang::tr{'urlfilter custom url'}:</td>
1588 <td><input type='text' name='CUSTOM_UPDATE_URL' value='$updatesettings{'CUSTOM_UPDATE_URL'}' size='72' /></td>
1589 </tr>
1590 </table>
1591 <table width='100%'>
1592 <tr>
1593 <td width='25%'><input type='submit' name='ACTION' value='$Lang::tr{'urlfilter save schedule'}'>&nbsp;&nbsp;&nbsp;<input type='submit' name='ACTION' value='$Lang::tr{'urlfilter update now'}'></td>
1594 </tr>
1595 </table>
1596
1597 <hr size='1'>
1598
1599 <table width='100%'>
1600 <tr>
1601 <td class='base'><b>$Lang::tr{'urlfilter blacklist editor'}</b></td>
1602 </tr>
1603 <tr>
1604 <td>$Lang::tr{'urlfilter blacklist editor info'}</td>
1605 </tr>
1606 <tr>
1607 <td><input type='submit' name='ACTION' value='$Lang::tr{'urlfilter blacklist editor'}' /></td>
1608 </tr>
1609 </table>
1610
1611 <hr size='1'>
1612
1613 <table width='100%'>
1614 <tr>
1615 <td colspan='4' class='base'><b>$Lang::tr{'urlfilter backup settings'}</b></td>
1616 </tr>
1617 <tr>
1618 <td width='25%' class='base'>$Lang::tr{'urlfilter enable full backup'}:</td>
1619 <td width='12%' class='base'><input type='checkbox' name='ENABLE_FULLBACKUP' $checked{'ENABLE_FULLBACKUP'}{'on'} /></td>
1620 <td>&nbsp;</td>
1621 <td>&nbsp;</td>
1622 </tr>
1623 <tr>
1624 <td colspan='4' class='base'><input type='submit' name='ACTION' value='$Lang::tr{'urlfilter backup'}' /></td>
1625 </tr>
1626 </table>
1627
1628 <hr size='1'>
1629
1630 <table width='100%'>
1631 <tr>
1632 <td class='base'><b>$Lang::tr{'urlfilter restore settings'}</b></td>
1633 </tr>
1634 <tr>
1635 <td>$Lang::tr{'urlfilter restore text'}:</td>
1636 </tr>
1637 <tr>
1638 <td><input type='file' name='UPDATEFILE' size='40' /> &nbsp; <input type='submit' name='ACTION' value='$Lang::tr{'urlfilter restore'}' /></td>
1639 </tr>
1640 </table>
1641 </form>
1642 END
1643 ;
1644
1645 &Header::closebox();
1646
1647 } else {
1648
1649 #==========================================================
1650 #
1651 # Section: Manage Repository
1652 #
1653 #==========================================================
1654
1655 print "<form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>\n";
1656
1657 &Header::openbox('100%', 'left', "$Lang::tr{'urlfilter manage local file repository'}:");
1658 print <<END
1659 <table width='100%'>
1660 <tr>
1661 <td>$Lang::tr{'urlfilter repository information'}<br><br></td>
1662 </tr>
1663 <tr>
1664 <td>$Lang::tr{'urlfilter upload file text'}:</td>
1665 </tr>
1666 <tr>
1667 <td><input type='file' name='UPLOADFILE' size='50' /> &nbsp; <input type='submit' name='ACTION' value='$Lang::tr{'urlfilter upload file'}' /></td>
1668 </tr>
1669 <tr>
1670 <td><br><b>$Lang::tr{'urlfilter upload file information 1'}:</b> $Lang::tr{'urlfilter upload file information 2'}</td>
1671 </tr>
1672 </table>
1673 <hr size='1'>
1674 <table width='100%'>
1675 <tr>
1676 <td><input type='button' name='return2main' value='$Lang::tr{'urlfilter back to main page'}' onClick='self.location.href="$ENV{'SCRIPT_NAME'}"'></td>
1677 </tr>
1678 </table>
1679 </form>
1680 END
1681 ;
1682
1683 &Header::closebox();
1684
1685 &Header::openbox('100%', 'left', "$Lang::tr{'urlfilter current files'}: </b>[$repository]");
1686
1687 @repositorylist = <$repository/*>;
1688
1689 undef @repositoryfiles;
1690 foreach (@repositorylist)
1691 {
1692 if (!-d) { push(@repositoryfiles,substr($_,rindex($_,"/")+1)); }
1693 }
1694
1695 if (@repositoryfiles)
1696 {
1697 print <<END
1698 <table width='100%'>
1699 <tr>
1700 <td align='center'><b>$Lang::tr{'urlfilter filename'}</b></td>
1701 <td width='15%' align='center'><b>$Lang::tr{'urlfilter filesize'}</b></td>
1702 <td width='10%'></td>
1703 </tr>
1704 END
1705 ;
1706 $id = 0;
1707 foreach $line (@repositoryfiles)
1708 {
1709 $id++;
1710 if ($id % 2) {
1711 print "<tr bgcolor='$Header::table1colour'>\n"; }
1712 else {
1713 print "<tr bgcolor='$Header::table2colour'>\n"; }
1714 $filesize = (-s "$repository/$line");
1715 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/;
1716
1717 print <<END
1718 <td>&nbsp; &nbsp;$line</td>
1719 <td align='right'>$filesize&nbsp; &nbsp;</td>
1720
1721 <td align='center'>
1722 <form method='post' name='frma$id' action='$ENV{'SCRIPT_NAME'}'>
1723 <input type='image' name='$Lang::tr{'remove'}' src='/images/delete.gif' title='$Lang::tr{'remove'}' alt='$Lang::tr{'remove'}' />
1724 <input type='hidden' name='ID' value='$line' />
1725 <input type='hidden' name='ACTION' value='$Lang::tr{'urlfilter remove file'}' />
1726 </form>
1727 </td>
1728
1729 </tr>
1730 END
1731 ;
1732 }
1733
1734 print <<END
1735 </table>
1736 <table>
1737 <tr>
1738 </tr>
1739 </table>
1740 <table>
1741 <tr>
1742 <td class='boldbase'>&nbsp; <b>$Lang::tr{'legend'}:</b></td>
1743 <td>&nbsp; &nbsp; <img src='/images/delete.gif' alt='$Lang::tr{'remove'}' /></td>
1744 <td class='base'>$Lang::tr{'remove'}</td>
1745 </tr>
1746 </table>
1747 END
1748 ;
1749 } else {
1750
1751 print "<i>$Lang::tr{'urlfilter empty repository'}</i>\n";
1752 }
1753
1754 &Header::closebox();
1755
1756 }
1757
1758 } elsif ($tcsettings{'TCMODE'}) {
1759
1760 #==========================================================
1761 #
1762 # Section: Set Time Constraints
1763 #
1764 #==========================================================
1765
1766 print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
1767
1768 $buttontext = $Lang::tr{'urlfilter add rule'};
1769 if ($tcsettings{'ACTION'} eq $Lang::tr{'edit'}) {
1770 &Header::openbox('100%', 'left', $Lang::tr{'urlfilter edit time constraint rule'}.':');
1771 $buttontext = $Lang::tr{'urlfilter update rule'};
1772 } else {
1773 &Header::openbox('100%', 'left', $Lang::tr{'urlfilter add new time constraint rule'}.':');
1774 }
1775 print <<END
1776
1777 <table width='100%'>
1778 <tr>
1779 <td width='2%'>$Lang::tr{'urlfilter constraint definition'}</td>
1780 <td width='1%'>&nbsp;&nbsp;</td>
1781 <td width='2%' align='center'>$Lang::tr{'urlfilter monday'}</td>
1782 <td width='2%' align='center'>$Lang::tr{'urlfilter tuesday'}</td>
1783 <td width='2%' align='center'>$Lang::tr{'urlfilter wednesday'}</td>
1784 <td width='2%' align='center'>$Lang::tr{'urlfilter thursday'}</td>
1785 <td width='2%' align='center'>$Lang::tr{'urlfilter friday'}</td>
1786 <td width='2%' align='center'>$Lang::tr{'urlfilter saturday'}</td>
1787 <td width='2%' align='center'>$Lang::tr{'urlfilter sunday'}</td>
1788 <td width='1%'>&nbsp;&nbsp;</td>
1789 <td width='7%' colspan=3>$Lang::tr{'urlfilter from'}</td>
1790 <td width='1%'>&nbsp;</td>
1791 <td width='7%' colspan=3>$Lang::tr{'urlfilter to'}</td>
1792 <td>&nbsp;</td>
1793 </tr>
1794 <tr>
1795 <td class='base'>
1796 <select name='DEFINITION'>
1797 <option value='within' $selected{'DEFINITION'}{'within'}>$Lang::tr{'urlfilter constraint within'}</option>
1798 <option value='outside' $selected{'DEFINITION'}{'outside'}>$Lang::tr{'urlfilter constraint outside'}</option>
1799 </select>
1800 </td>
1801 <td>&nbsp;</td>
1802 <td class='base'><input type='checkbox' name='MON' $checked{'MON'}{'on'} /></td>
1803 <td class='base'><input type='checkbox' name='TUE' $checked{'TUE'}{'on'} /></td>
1804 <td class='base'><input type='checkbox' name='WED' $checked{'WED'}{'on'} /></td>
1805 <td class='base'><input type='checkbox' name='THU' $checked{'THU'}{'on'} /></td>
1806 <td class='base'><input type='checkbox' name='FRI' $checked{'FRI'}{'on'} /></td>
1807 <td class='base'><input type='checkbox' name='SAT' $checked{'SAT'}{'on'} /></td>
1808 <td class='base'><input type='checkbox' name='SUN' $checked{'SUN'}{'on'} /></td>
1809 <td>&nbsp;</td>
1810 <td class='base'>
1811 <select name='FROM_HOUR'>
1812 END
1813 ;
1814 for ($i=0;$i<=24;$i++) {
1815 $_ = sprintf("%02s",$i);
1816 print "<option $selected{'FROM_HOUR'}{$_}>$_</option>\n";
1817 }
1818 print <<END
1819 </select>
1820 </td>
1821 <td>:</td>
1822 <td class='base'>
1823 <select name='FROM_MINUTE'>
1824 END
1825 ;
1826 for ($i=0;$i<=45;$i+=15) {
1827 $_ = sprintf("%02s",$i);
1828 print "<option $selected{'FROM_MINUTE'}{$_}>$_</option>\n";
1829 }
1830 print <<END
1831 </select>
1832 <td> - </td>
1833 </td>
1834 <td class='base'>
1835 <select name='TO_HOUR'>
1836 END
1837 ;
1838 for ($i=0;$i<=24;$i++) {
1839 $_ = sprintf("%02s",$i);
1840 print "<option $selected{'TO_HOUR'}{$_}>$_</option>\n";
1841 }
1842 print <<END
1843 </select>
1844 </td>
1845 <td>:</td>
1846 <td class='base'>
1847 <select name='TO_MINUTE'>
1848 END
1849 ;
1850 for ($i=0;$i<=45;$i+=15) {
1851 $_ = sprintf("%02s",$i);
1852 print "<option $selected{'TO_MINUTE'}{$_}>$_</option>\n";
1853 }
1854 print <<END
1855 </select>
1856 </td>
1857 <td>&nbsp;</td>
1858 </tr>
1859 </table>
1860
1861 <br>
1862
1863 <table width='100%'>
1864 <tr>
1865 <td width='5%'>$Lang::tr{'urlfilter source'}</td>
1866 <td width='1%'>&nbsp;&nbsp;</td>
1867 <td width='5%'>$Lang::tr{'urlfilter dst'}&nbsp;<img src='/blob.gif' alt='*'><img src='/blob.gif' alt='*'></td>
1868 <td width='1%'>&nbsp;&nbsp;</td>
1869 <td width='5%'>$Lang::tr{'urlfilter access'}</td>
1870 <td>&nbsp;</td>
1871 </tr>
1872 <tr>
1873 <td rowspan='2'><textarea name='SRC' cols='28' rows='5' wrap='off'>
1874 END
1875 ;
1876
1877 # transform from pre1.8 client definitions
1878 $tcsettings{'SRC'} =~ s/^\s+//g;
1879 $tcsettings{'SRC'} =~ s/\s+$//g;
1880 $tcsettings{'SRC'} =~ s/\s+-\s+/-/g;
1881 $tcsettings{'SRC'} =~ s/\s+/ /g;
1882
1883 @clients = split(/ /,$tcsettings{'SRC'});
1884 undef $tcsettings{'SRC'};
1885 foreach (@clients) { $tcsettings{'SRC'} .= "$_\n"; }
1886
1887 print $tcsettings{'SRC'};
1888
1889 print <<END
1890 </textarea></td>
1891
1892 <td>&nbsp;</td>
1893 <td class='base' rowspan='2' valign='top'>
1894 <select name='DST' size='6' multiple>
1895 <option value='any' $selected{'DST'}{'any'} = "selected='selected'">$Lang::tr{'urlfilter category all'}</option>
1896 <option value='in-addr' $selected{'DST'}{'in-addr'} = "selected='selected'">in-addr</option>
1897 END
1898 ;
1899
1900 &readblockcategories;
1901 foreach (@categories)
1902 {
1903 print "<option value='$_' $selected{'DST'}{$_}>$_</option>\n";
1904 }
1905
1906 print <<END
1907 <option value='files' $selected{'DST'}{'files'} = "selected='selected'">files</option>
1908 <option value='custom-blocked' $selected{'DST'}{'custom-blocked'} = "selected='selected'">custom-blocked</option>
1909 <option value='custom-expressions' $selected{'DST'}{'custom-expressions'} = "selected='selected'">custom-expressions</option>
1910 </select>
1911 </td>
1912 <td>&nbsp;</td>
1913 <td class='base' valign='top'>
1914 <select name='ACCESS'>
1915 <option value='block' $selected{'ACCESS'}{'block'}>$Lang::tr{'urlfilter mode block'}</option>
1916 <option value='allow' $selected{'ACCESS'}{'allow'}>$Lang::tr{'urlfilter mode allow'}</option>
1917 </select>
1918 </td>
1919 <td>&nbsp;</td>
1920 </tr>
1921 <tr>
1922 <td>&nbsp;</td>
1923 <td>&nbsp;</td>
1924 <td>&nbsp;</td>
1925 <td>&nbsp;</td>
1926 </tr>
1927 <tr>
1928 <td>$Lang::tr{'remark'}&nbsp;<img src='/blob.gif' alt='*'></td>
1929 <td>&nbsp;</td>
1930 <td>&nbsp;</td>
1931 <td>&nbsp;</td>
1932 <td>&nbsp;</td>
1933 <td>&nbsp;</td>
1934 </tr>
1935 <tr>
1936 <td><input type='text' name='COMMENT' value='$tcsettings{'COMMENT'}' size='32' /></td>
1937 <td>&nbsp;</td>
1938 <td>&nbsp;</td>
1939 <td>&nbsp;</td>
1940 <td>&nbsp;</td>
1941 <td>&nbsp;</td>
1942 </tr>
1943 </table>
1944
1945 <table width='100%'>
1946 <tr>
1947 <td class='base'>$Lang::tr{'urlfilter enabled'}<input type='checkbox' name='ENABLERULE' $checked{'ENABLERULE'}{'on'} /></td>
1948 </tr>
1949 </table>
1950
1951 <p>
1952
1953 <table width='50%'>
1954 <tr>
1955 <td><input type='hidden' name='ACTION' value='$Lang::tr{'add'}' /></td>
1956 <td><input type='hidden' name='MODE' value='TIMECONSTRAINT' /></td>
1957 <td><input type='submit' name='SUBMIT' value='$buttontext' /></td>
1958 <td><input type='reset' name='ACTION' value='$Lang::tr{'urlfilter reset'}' /></td>
1959 <td>&nbsp;</td>
1960 <td><input type='button' name='return2main' value='$Lang::tr{'urlfilter back to main page'}' onClick='self.location.href="$ENV{'SCRIPT_NAME'}"'></td>
1961 </tr>
1962 </table>
1963 <p>
1964 <table width='100%'>
1965 <tr>
1966 <td width='1%' align='right'> <img src='/blob.gif' align='top' alt='*' />&nbsp;</td>
1967 <td><font class='base'>$Lang::tr{'this field may be blank'}</font></td>
1968 </tr>
1969 <tr>
1970 <td width='1%' align='right'><img src='/blob.gif' align='top' alt='*' /><img src='/blob.gif' align='top' alt='*' />&nbsp;</td>
1971 <td><font class='base'>$Lang::tr{'urlfilter select multi'}</font></td>
1972 </tr>
1973 </table>
1974 END
1975 ;
1976
1977 if ($tcsettings{'ACTION'} eq $Lang::tr{'edit'}) {
1978 print "<input type='hidden' name='EDITING' value='$tcsettings{'ID'}' />\n";
1979 } else {
1980 print "<input type='hidden' name='EDITING' value='no' />\n";
1981 }
1982
1983 &Header::closebox();
1984 print "</form>\n";
1985
1986 &Header::openbox('100%', 'left', $Lang::tr{'current rules'});
1987 print <<END
1988 <table width='100%'>
1989 <tr>
1990 <td width='5%' class='boldbase' align='center'><b>$Lang::tr{'urlfilter constraint definition'}</b></td>
1991 <td width='10%' class='boldbase' align='center'><b>$Lang::tr{'urlfilter time space'}</b></td>
1992 <td width='15%' class='boldbase' align='center'><b>$Lang::tr{'urlfilter src'}</b></td>
1993 <td width='5%' class='boldbase' align='center'><b>$Lang::tr{'urlfilter dst'}</b></td>
1994 <td width='10%' class='boldbase' colspan='5' align='center'>&nbsp;</td>
1995 </tr>
1996 END
1997 ;
1998
1999 if ($tcsettings{'ACTION'} ne '' or $changed ne 'no')
2000 {
2001 open(FILE, $tcfile);
2002 @tclist = <FILE>;
2003 close(FILE);
2004 }
2005
2006 $id = 0;
2007 foreach $line (@tclist)
2008 {
2009 $id++;
2010 chomp($line);
2011 @temp = split(/\,/,$line);
2012 if($tcsettings{'ACTION'} eq $Lang::tr{'edit'} && $tcsettings{'ID'} eq $id) {
2013 print "<tr bgcolor='$Header::colouryellow'>\n"; }
2014 elsif ($id % 2) {
2015 print "<tr bgcolor='$Header::table1colour'>\n"; }
2016 else {
2017 print "<tr bgcolor='$Header::table2colour'>\n"; }
2018 if ($temp[0] eq 'within') { $temp[0]=$Lang::tr{'urlfilter constraint within'}; } else { $temp[0]=$Lang::tr{'urlfilter constraint outside'}; }
2019 if ($temp[13] eq 'any') { $temp[13]=$Lang::tr{'urlfilter category all'}; }
2020 if ($temp[15] eq 'on') { $gif='on.gif'; $toggle='off'; $gdesc=$Lang::tr{'click to disable'};}
2021 else { $gif='off.gif'; $toggle='on'; $gdesc=$Lang::tr{'click to enable'}; }
2022 if ($temp[14] eq 'block') { $led='led-red.gif'; $ldesc=$Lang::tr{'urlfilter block access'};}
2023 else { $led='led-green.gif'; $ldesc=$Lang::tr{'urlfilter allow access'}; }
2024
2025 undef $time;
2026 if ($temp[1] eq 'on') { $time.=$Lang::tr{'urlfilter mon'}; } else { $time.='='; }
2027 if ($temp[2] eq 'on') { $time.=$Lang::tr{'urlfilter tue'}; } else { $time.='='; }
2028 if ($temp[3] eq 'on') { $time.=$Lang::tr{'urlfilter wed'}; } else { $time.='='; }
2029 if ($temp[4] eq 'on') { $time.=$Lang::tr{'urlfilter thu'}; } else { $time.='='; }
2030 if ($temp[5] eq 'on') { $time.=$Lang::tr{'urlfilter fri'}; } else { $time.='='; }
2031 if ($temp[6] eq 'on') { $time.=$Lang::tr{'urlfilter sat'}; } else { $time.='='; }
2032 if ($temp[7] eq 'on') { $time.=$Lang::tr{'urlfilter sun'}; } else { $time.='='; }
2033 $time=$time.' &nbsp; '.$temp[8].':'.$temp[9].' to '.$temp[10].':'.$temp[11];
2034
2035 print <<END
2036 <td align='center'>$temp[0]</td>
2037 <td align='center' nowrap>$time</td>
2038 <td align='center'>$temp[12]</td>
2039 <td align='center'>$temp[13]</td>
2040 <td align='center'><image src='/images/urlfilter/$led' alt='$ldesc'></td>
2041
2042 <td align='center'>
2043 <form method='post' name='frma$id' action='$ENV{'SCRIPT_NAME'}'>
2044 <input type='image' name='$Lang::tr{'toggle enable disable'}' src='/images/$gif' title='$gdesc' alt='$gdesc' />
2045 <input type='hidden' name='MODE' value='TIMECONSTRAINT' />
2046 <input type='hidden' name='ID' value='$id' />
2047 <input type='hidden' name='ACTIVE' value='$toggle' />
2048 <input type='hidden' name='ACTION' value='$Lang::tr{'toggle enable disable'}' />
2049 </form>
2050 </td>
2051
2052 <td align='center'>
2053 <form method='post' name='frmb$id' action='$ENV{'SCRIPT_NAME'}'>
2054 <input type='image' name='$Lang::tr{'edit'}' src='/images/edit.gif' title='$Lang::tr{'edit'}' alt='$Lang::tr{'edit'}' />
2055 <input type='hidden' name='MODE' value='TIMECONSTRAINT' />
2056 <input type='hidden' name='ID' value='$id' />
2057 <input type='hidden' name='ACTION' value='$Lang::tr{'edit'}' />
2058 </form>
2059 </td>
2060
2061 <td align='center'>
2062 <form method='post' name='frmc$id' action='$ENV{'SCRIPT_NAME'}'>
2063 <input type='image' name='$Lang::tr{'urlfilter copy rule'}' src='/images/urlfilter/copy.gif' title='$Lang::tr{'urlfilter copy rule'}' alt='$Lang::tr{'urlfilter copy rule'}' />
2064 <input type='hidden' name='MODE' value='TIMECONSTRAINT' />
2065 <input type='hidden' name='ID' value='$id' />
2066 <input type='hidden' name='ACTION' value='$Lang::tr{'urlfilter copy rule'}' />
2067 </form>
2068 </td>
2069
2070 <td align='center'>
2071 <form method='post' name='frmd$id' action='$ENV{'SCRIPT_NAME'}'>
2072 <input type='image' name='$Lang::tr{'remove'}' src='/images/delete.gif' title='$Lang::tr{'remove'}' alt='$Lang::tr{'remove'}' />
2073 <input type='hidden' name='MODE' value='TIMECONSTRAINT' />
2074 <input type='hidden' name='ID' value='$id' />
2075 <input type='hidden' name='ACTION' value='$Lang::tr{'remove'}' />
2076 </form>
2077 </td>
2078
2079 </tr>
2080 END
2081 ;
2082 if($tcsettings{'ACTION'} eq $Lang::tr{'edit'} && $tcsettings{'ID'} eq $id) {
2083 print "<tr bgcolor='$Header::colouryellow'>\n"; }
2084 elsif ($id % 2) {
2085 print "<tr bgcolor='$Header::table1colour'>\n"; }
2086 else {
2087 print "<tr bgcolor='$Header::table2colour'>\n"; }
2088 print <<END
2089 <td align='center' colspan='4'>$temp[16]
2090 </td>
2091 <td align='center' colspan='5'>
2092 </td>
2093 </tr>
2094 END
2095 ;
2096 }
2097
2098 print "</table>\n";
2099
2100 # If the time constraint file contains entries, print entries and action icons
2101 if (! -z "$tcfile") {
2102 print <<END
2103
2104 <table>
2105 <tr>
2106 <td class='boldbase'>&nbsp; <b>$Lang::tr{'legend'}:</b></td>
2107 <td>&nbsp; &nbsp; <img src='/images/urlfilter/led-green.gif' alt='$Lang::tr{'urlfilter allow access'}' /></td>
2108 <td class='base'>$Lang::tr{'urlfilter allow'}</td>
2109 <td>&nbsp; &nbsp; <img src='/images/urlfilter/led-red.gif' alt='$Lang::tr{'urlfilter block access'}' /></td>
2110 <td class='base'>$Lang::tr{'urlfilter block'}</td>
2111 <td>&nbsp; <img src='/images/on.gif' alt='$Lang::tr{'click to disable'}' /></td>
2112 <td class='base'>$Lang::tr{'click to disable'}</td>
2113 <td>&nbsp; &nbsp; <img src='/images/off.gif' alt='$Lang::tr{'click to enable'}' /></td>
2114 <td class='base'>$Lang::tr{'click to enable'}</td>
2115 <td>&nbsp; &nbsp; <img src='/images/edit.gif' alt='$Lang::tr{'edit'}' /></td>
2116 <td class='base'>$Lang::tr{'edit'}</td>
2117 <td>&nbsp; &nbsp; <img src='/images/urlfilter/copy.gif' alt='$Lang::tr{'urlfilter copy rule'}' /></td>
2118 <td class='base'>$Lang::tr{'urlfilter copy rule'}</td>
2119 <td>&nbsp; &nbsp; <img src='/images/delete.gif' alt='$Lang::tr{'remove'}' /></td>
2120 <td class='base'>$Lang::tr{'remove'}</td>
2121 </tr>
2122 </table>
2123 END
2124 ;
2125 }
2126
2127 &Header::closebox();
2128
2129 } elsif ($uqsettings{'UQMODE'}) {
2130
2131 #==========================================================
2132 #
2133 # Section: Set User Quota
2134 #
2135 #==========================================================
2136
2137 print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
2138
2139 $buttontext = $Lang::tr{'urlfilter add rule'};
2140 if ($uqsettings{'ACTION'} eq $Lang::tr{'edit'}) {
2141 &Header::openbox('100%', 'left', $Lang::tr{'urlfilter edit user quota rule'}.':');
2142 $buttontext = $Lang::tr{'urlfilter update rule'};
2143 } else {
2144 &Header::openbox('100%', 'left', $Lang::tr{'urlfilter add new user quota rule'}.':');
2145 }
2146 print <<END
2147
2148 <table width='100%'>
2149 <tr>
2150 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
2151 </tr>
2152 <tr>
2153 <td class='base'>$Lang::tr{'urlfilter user time quota'}:</td>
2154 <td><input type='text' name='TIME_QUOTA' value='$uqsettings{'TIME_QUOTA'}' size='5' /></td>
2155 <td colspan='2' rowspan= '5' valign='top' class='base'>
2156 <table cellpadding='0' cellspacing='0'>
2157 <tr>
2158 <!-- intentionally left empty -->
2159 </tr>
2160 <tr>
2161 <td>$Lang::tr{'urlfilter assigned quota users'}:</td>
2162 </tr>
2163 <tr>
2164 <!-- intentionally left empty -->
2165 </tr>
2166 <tr>
2167 <!-- intentionally left empty -->
2168 </tr>
2169 <tr>
2170 <td><textarea name='QUOTA_USERS' cols='32' rows='6' wrap='off'>
2171 END
2172 ;
2173
2174 $uqsettings{'QUOTA_USERS'} =~ s/\|/\n/g;
2175 print $uqsettings{'QUOTA_USERS'};
2176
2177 print <<END
2178 </textarea></td>
2179 </tr>
2180 </table>
2181 </td>
2182 </tr>
2183 <tr>
2184 <td class='base'>$Lang::tr{'urlfilter activity detection'}:</td>
2185 <td class='base'><select name='SPORADIC'>
2186 <option value='0' $selected{'SPORADIC'}{'0'}>$Lang::tr{'urlfilter disabled'}</option>
2187 <option value='300' $selected{'SPORADIC'}{'300'}>5 $Lang::tr{'urlfilter minutes'}</option>
2188 <option value='900' $selected{'SPORADIC'}{'900'}>15 $Lang::tr{'urlfilter minutes'}</option>
2189 </select></td>
2190 </tr>
2191 <tr>
2192 <td class='base'>$Lang::tr{'urlfilter renewal period'}:</td>
2193 <td class='base'><select name='RENEWAL'>
2194 <option value='hourly' $selected{'RENEWAL'}{'hourly'}>$Lang::tr{'urlfilter hourly'}</option>
2195 <option value='daily' $selected{'RENEWAL'}{'daily'}>$Lang::tr{'urlfilter daily'}</option>
2196 <option value='weekly' $selected{'RENEWAL'}{'weekly'}>$Lang::tr{'urlfilter weekly'}</option>
2197 </select></td>
2198 </tr>
2199 <tr>
2200 <td colspan='2'>&nbsp;</td>
2201 </tr>
2202 <tr>
2203 <td class='base'>$Lang::tr{'urlfilter enabled'}</td>
2204 <td class='base'><input type='checkbox' name='ENABLEQUOTA' $checked{'ENABLEQUOTA'}{'on'} /></td>
2205 </tr>
2206
2207 </table>
2208 <p>
2209
2210 <table width='50%'>
2211 <tr>
2212 <td><input type='hidden' name='ACTION' value='$Lang::tr{'add'}' /></td>
2213 <td><input type='hidden' name='MODE' value='USERQUOTA' /></td>
2214 <td><input type='submit' name='SUBMIT' value='$buttontext' /></td>
2215 <td><input type='reset' name='ACTION' value='$Lang::tr{'urlfilter reset'}' /></td>
2216 <td>&nbsp;</td>
2217 <td><input type='button' name='return2main' value='$Lang::tr{'urlfilter back to main page'}' onClick='self.location.href="$ENV{'SCRIPT_NAME'}"'></td>
2218 </tr>
2219 </table>
2220
2221 <p>
2222 END
2223 ;
2224
2225 if ($uqsettings{'ACTION'} eq $Lang::tr{'edit'}) {
2226 print "<input type='hidden' name='EDITING' value='$uqsettings{'ID'}' />\n";
2227 } else {
2228 print "<input type='hidden' name='EDITING' value='no' />\n";
2229 }
2230
2231 &Header::closebox();
2232 print "</form>\n";
2233
2234 &Header::openbox('100%', 'left', $Lang::tr{'current rules'});
2235 print <<END
2236 <table width='100%'>
2237 <tr>
2238 <td width='15%' class='boldbase' align='center'><b><nobr>$Lang::tr{'urlfilter time quota'}</nobr></b></td>
2239 <td width='15%' class='boldbase' align='center'><b><nobr>$Lang::tr{'urlfilter activity detection'}</nobr></b></td>
2240 <td width='10%' class='boldbase' align='center'><b>$Lang::tr{'urlfilter renewal'}</b></td>
2241 <td class='boldbase' align='center'><b>$Lang::tr{'urlfilter assigned users'}</b></td>
2242 <td width='20%' class='boldbase' colspan='4' align='center'>&nbsp;</td>
2243 </tr>
2244 END
2245 ;
2246
2247 if ($uqsettings{'ACTION'} ne '' or $changed ne 'no')
2248 {
2249 open(FILE, $uqfile);
2250 @uqlist = <FILE>;
2251 close(FILE);
2252 }
2253
2254 $id = 0;
2255 foreach $line (@uqlist)
2256 {
2257 $id++;
2258 chomp($line);
2259 @temp = split(/\,/,$line);
2260 if($uqsettings{'ACTION'} eq $Lang::tr{'edit'} && $uqsettings{'ID'} eq $id) {
2261 print "<tr bgcolor='$Header::colouryellow'>\n"; }
2262 elsif ($id % 2) {
2263 print "<tr bgcolor='$Header::table1colour'>\n"; }
2264 else {
2265 print "<tr bgcolor='$Header::table2colour'>\n"; }
2266 if ($temp[4] eq 'on') { $gif='on.gif'; $toggle='off'; $gdesc=$Lang::tr{'click to disable'};}
2267 else { $gif='off.gif'; $toggle='on'; $gdesc=$Lang::tr{'click to enable'}; }
2268
2269 $temp[5] = $temp[1];
2270 if ($temp[1] eq '0') { $temp[5] = $Lang::tr{'urlfilter disabled'} } else { $temp[5] = ($temp[5]/60).' '.$Lang::tr{'urlfilter minutes'} }
2271 $_ = $temp[3]; s/\|/, /g; $temp[6] = $_;
2272
2273 print <<END
2274 <td align='center'>$temp[0] $Lang::tr{'urlfilter minutes'}</td>
2275 <td align='center'>$temp[5]</td>
2276 <td align='center'>$Lang::tr{'urlfilter '.$temp[2]}</td>
2277 <td align='center'>$temp[6]</td>
2278
2279 <td align='center'>
2280 <form method='post' name='frma$id' action='$ENV{'SCRIPT_NAME'}'>
2281 <input type='image' name='$Lang::tr{'toggle enable disable'}' src='/images/$gif' title='$gdesc' alt='$gdesc' />
2282 <input type='hidden' name='MODE' value='USERQUOTA' />
2283 <input type='hidden' name='ID' value='$id' />
2284 <input type='hidden' name='ACTIVE' value='$toggle' />
2285 <input type='hidden' name='ACTION' value='$Lang::tr{'toggle enable disable'}' />
2286 </form>
2287 </td>
2288
2289 <td align='center'>
2290 <form method='post' name='frmb$id' action='$ENV{'SCRIPT_NAME'}'>
2291 <input type='image' name='$Lang::tr{'edit'}' src='/images/edit.gif' title='$Lang::tr{'edit'}' alt='$Lang::tr{'edit'}' />
2292 <input type='hidden' name='MODE' value='USERQUOTA' />
2293 <input type='hidden' name='ID' value='$id' />
2294 <input type='hidden' name='ACTION' value='$Lang::tr{'edit'}' />
2295 </form>
2296 </td>
2297
2298 <td align='center'>
2299 <form method='post' name='frmc$id' action='$ENV{'SCRIPT_NAME'}'>
2300 <input type='image' name='$Lang::tr{'remove'}' src='/images/delete.gif' title='$Lang::tr{'remove'}' alt='$Lang::tr{'remove'}' />
2301 <input type='hidden' name='MODE' value='USERQUOTA' />
2302 <input type='hidden' name='ID' value='$id' />
2303 <input type='hidden' name='ACTION' value='$Lang::tr{'remove'}' />
2304 </form>
2305 </td>
2306
2307 </tr>
2308 END
2309 ;
2310 }
2311
2312 print "</table>\n";
2313
2314 # If the user quota file contains entries, print entries and action icons
2315 if (! -z "$uqfile") {
2316 print <<END
2317
2318 <table>
2319 <tr>
2320 <td class='boldbase'>&nbsp; <b>$Lang::tr{'legend'}:</b></td>
2321 <td>&nbsp; <img src='/images/on.gif' alt='$Lang::tr{'click to disable'}' /></td>
2322 <td class='base'>$Lang::tr{'click to disable'}</td>
2323 <td>&nbsp; &nbsp; <img src='/images/off.gif' alt='$Lang::tr{'click to enable'}' /></td>
2324 <td class='base'>$Lang::tr{'click to enable'}</td>
2325 <td>&nbsp; &nbsp; <img src='/images/edit.gif' alt='$Lang::tr{'edit'}' /></td>
2326 <td class='base'>$Lang::tr{'edit'}</td>
2327 <td>&nbsp; &nbsp; <img src='/images/delete.gif' alt='$Lang::tr{'remove'}' /></td>
2328 <td class='base'>$Lang::tr{'remove'}</td>
2329 </tr>
2330 </table>
2331 END
2332 ;
2333 }
2334
2335 &Header::closebox();
2336
2337 } else {
2338
2339 #==========================================================
2340 #
2341 # Section: Blacklist editor
2342 #
2343 #==========================================================
2344
2345 print "<form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>\n";
2346
2347 &Header::openbox('100%', 'left', $Lang::tr{'urlfilter urlfilter blacklist editor'}.':');
2348
2349 print <<END
2350
2351 <table width='100%'>
2352 <tr>
2353 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
2354 </tr>
2355 <tr>
2356 <td class='base'><b>$Lang::tr{'urlfilter blacklist name'}</b></td>
2357 </tr>
2358 <tr>
2359 <td class='base'>$Lang::tr{'urlfilter blacklist category name'}:</td>
2360 <td><input type='text' name='BE_NAME' value='$besettings{'BE_NAME'}' size='12' /></td>
2361 </tr>
2362 </table>
2363 <hr size='1'>
2364 <table width='100%'>
2365 <tr>
2366 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='20%'></td>
2367 </tr>
2368 <tr>
2369 <td class='base' colspan='4'><b>$Lang::tr{'urlfilter edit domains urls expressions'}</b></td>
2370 </tr>
2371 <tr>
2372 <td colspan='2'>$Lang::tr{'urlfilter domains'}</td>
2373 <td colspan='2'>$Lang::tr{'urlfilter urls'}</td>
2374 </tr>
2375 <tr>
2376 <td colspan='2'><textarea name='BE_DOMAINS' cols='38' rows='10' wrap='off'>
2377 END
2378 ;
2379
2380 print $besettings{'BE_DOMAINS'};
2381
2382 print <<END
2383 </textarea></td>
2384 <td colspan='2'><textarea name='BE_URLS' cols='38' rows='10' wrap='off'>
2385 END
2386 ;
2387
2388 print $besettings{'BE_URLS'};
2389
2390 print <<END
2391 </textarea></td>
2392 </tr>
2393 <tr>
2394 <td colspan='4'>$Lang::tr{'urlfilter expressions'}</td>
2395 </tr>
2396 <tr>
2397 <td colspan='4'><textarea name='BE_EXPRESSIONS' cols='80' rows='3' wrap='off'>
2398 END
2399 ;
2400
2401 print $besettings{'BE_EXPRESSIONS'};
2402
2403 print <<END
2404 </textarea></td>
2405 </tr>
2406 </table>
2407 <hr size='1'>
2408 <table width='100%'>
2409 <tr>
2410 <td class='base' colspan='4'><b>$Lang::tr{'urlfilter load blacklist'}</b></td>
2411 </tr>
2412 <tr>
2413 <td width='25%' class='base'>$Lang::tr{'urlfilter select blacklist'}:</td>
2414 <td width='20%' class='base'>
2415 <select name='BE_BLACKLIST'>
2416 END
2417 ;
2418
2419 &readblockcategories;
2420 foreach (@categories)
2421 {
2422 print "<option value='$_' $selected{'BE_BLACKLIST'}{$_}>$_</option>\n";
2423 }
2424
2425 print <<END
2426 </select>
2427 </td>
2428 <td>&nbsp;</td>
2429 <td>&nbsp;</td>
2430 <tr>
2431 <td colpsan='4'><input type='submit' name='ACTION' value='$Lang::tr{'urlfilter load blacklist'}' /></td>
2432 </tr>
2433 </tr>
2434 </table>
2435 <hr size='1'>
2436 <table width='100%'>
2437 <tr>
2438 <td class='base' colspan='4'><b>$Lang::tr{'urlfilter import blacklist'}</b></td>
2439 </tr>
2440 <tr>
2441 <td colspan='4'>$Lang::tr{'urlfilter import text'}:</td>
2442 </tr>
2443 <tr>
2444 <td nowrap><input type='file' name='IMPORTFILE' size='40' /> &nbsp; <input type='submit' name='ACTION' value='$Lang::tr{'urlfilter import blacklist'}' /></td>
2445 <td><input type='hidden' name='MODE' value='BLACKLIST_EDITOR' /></td>
2446 </tr>
2447 </table>
2448 <hr size='1'>
2449 <table width='100%'>
2450 <tr>
2451 <td class='base' colspan='4'><b>$Lang::tr{'urlfilter export blacklist'}</b></td>
2452 </tr>
2453 <tr>
2454 <td><input type='submit' name='ACTION' value='$Lang::tr{'urlfilter export blacklist'}' /></td>
2455 </tr>
2456 </table>
2457 <hr size='1'>
2458 <table width='100%'>
2459 <tr>
2460 <td class='base' colspan='4'><b>$Lang::tr{'urlfilter install blacklist'}</b></td>
2461 </tr>
2462 <tr>
2463 <td width='25%' class='base'>$Lang::tr{'urlfilter dont restart urlfilter'}:</td>
2464 <td width='20%' class='base'><input type='checkbox' name='NORESTART' $checked{'NORESTART'}{'on'} /></td>
2465 <td>&nbsp;</td>
2466 <td>&nbsp;</td>
2467 </tr>
2468 <tr>
2469 <td><input type='submit' name='ACTION' value='$Lang::tr{'urlfilter install blacklist'}' /></td>
2470 </tr>
2471 <tr>
2472 <td class='base' colspan='4'><br>$Lang::tr{'urlfilter install information'}</td>
2473 </tr>
2474 </table>
2475 <hr size='1'>
2476 <table width='20%'>
2477 <tr>
2478 <td><input type='reset' name='ACTION' value='$Lang::tr{'urlfilter reset'}' /></td>
2479 <td>&nbsp;</td>
2480 <td><input type='button' name='return2main' value='$Lang::tr{'urlfilter back to main page'}' onClick='self.location.href="$ENV{'SCRIPT_NAME'}"'></td>
2481 </tr>
2482 </table>
2483
2484 END
2485 ;
2486
2487 &Header::closebox();
2488 print "</form>\n";
2489
2490 }
2491
2492 &Header::closebigbox();
2493
2494 &Header::closepage();
2495
2496 # -------------------------------------------------------------------
2497
2498 sub savesettings
2499 {
2500 # transform to pre1.8 client definitions
2501 @clients = split(/\n/,$filtersettings{'UNFILTERED_CLIENTS'});
2502 undef $filtersettings{'UNFILTERED_CLIENTS'};
2503 foreach(@clients)
2504 {
2505 s/^\s+//g; s/\s+$//g; s/\s+-\s+/-/g; s/\s+/ /g; s/\n//g;
2506 $filtersettings{'UNFILTERED_CLIENTS'} .= "$_ ";
2507 }
2508 $filtersettings{'UNFILTERED_CLIENTS'} =~ s/\s+$//;
2509
2510 # transform to pre1.8 client definitions
2511 @clients = split(/\n/,$filtersettings{'BANNED_CLIENTS'});
2512 undef $filtersettings{'BANNED_CLIENTS'};
2513 foreach(@clients)
2514 {
2515 s/^\s+//g; s/\s+$//g; s/\s+-\s+/-/g; s/\s+/ /g; s/\n//g;
2516 $filtersettings{'BANNED_CLIENTS'} .= "$_ ";
2517 }
2518 $filtersettings{'BANNED_CLIENTS'} =~ s/\s+$//;
2519
2520 &writeconfigfile;
2521
2522 delete $filtersettings{'CUSTOM_BLACK_DOMAINS'};
2523 delete $filtersettings{'CUSTOM_BLACK_URLS'};
2524 delete $filtersettings{'CUSTOM_WHITE_DOMAINS'};
2525 delete $filtersettings{'CUSTOM_WHITE_URLS'};
2526 delete $filtersettings{'CUSTOM_EXPRESSIONS'};
2527 delete $filtersettings{'BACKGROUND'};
2528 delete $filtersettings{'UPDATEFILE'};
2529
2530 system("chown -R nobody.nobody $dbdir");
2531 system('/usr/bin/squidGuard -C custom/allowed/domains >/dev/null 2>&1');
2532 system('/usr/bin/squidGuard -C custom/allowed/urls >/dev/null 2>&1');
2533 system('/usr/bin/squidGuard -C custom/blocked/domains >/dev/null 2>&1');
2534 system('/usr/bin/squidGuard -C custom/blocked/urls >/dev/null 2>&1 ');
2535 &setpermissions ($dbdir);
2536
2537 &General::writehash("${General::swroot}/urlfilter/settings", \%filtersettings);
2538 }
2539
2540 # -------------------------------------------------------------------
2541
2542 sub readblockcategories
2543 {
2544 undef(@categories);
2545
2546 &getblockcategory ($dbdir);
2547
2548 foreach (@categories) { $_ = substr($_,length($dbdir)+1); }
2549
2550 @filtergroups = @categories;
2551
2552 foreach (@filtergroups) {
2553 s/\//_/g;
2554 tr/a-z/A-Z/;
2555 $_ = "FILTER_".$_;
2556 }
2557 }
2558
2559 # -------------------------------------------------------------------
2560
2561 sub getblockcategory
2562 {
2563 foreach $category (<$_[0]/*>)
2564 {
2565 if (-d $category)
2566 {
2567 if ((-e "$category/domains") || (-e "$category/urls"))
2568 {
2569 unless ($category =~ /\bcustom\b/) { push(@categories,$category); }
2570 }
2571 &getblockcategory ($category);
2572 }
2573 }
2574 }
2575
2576 # -------------------------------------------------------------------
2577
2578 sub readcustomlists
2579 {
2580 if (-e "$dbdir/custom/blocked/domains") {
2581 open(FILE,"$dbdir/custom/blocked/domains");
2582 delete $filtersettings{'CUSTOM_BLACK_DOMAINS'};
2583 while (<FILE>) { $filtersettings{'CUSTOM_BLACK_DOMAINS'} .= $_ };
2584 close(FILE);
2585 }
2586
2587 if (-e "$dbdir/custom/blocked/urls") {
2588 open(FILE,"$dbdir/custom/blocked/urls");
2589 delete $filtersettings{'CUSTOM_BLACK_URLS'};
2590 while (<FILE>) { $filtersettings{'CUSTOM_BLACK_URLS'} .= $_ };
2591 close(FILE);
2592 }
2593
2594 if (-e "$dbdir/custom/blocked/expressions") {
2595 open(FILE,"$dbdir/custom/blocked/expressions");
2596 delete $filtersettings{'CUSTOM_EXPRESSIONS'};
2597 while (<FILE>) { $filtersettings{'CUSTOM_EXPRESSIONS'} .= $_ };
2598 close(FILE);
2599 }
2600
2601 if (-e "$dbdir/custom/allowed/domains") {
2602 open(FILE,"$dbdir/custom/allowed/domains");
2603 delete $filtersettings{'CUSTOM_WHITE_DOMAINS'};
2604 while (<FILE>) { $filtersettings{'CUSTOM_WHITE_DOMAINS'} .= $_ };
2605 close(FILE);
2606 }
2607 if (-e "$dbdir/custom/allowed/urls") {
2608 open(FILE,"$dbdir/custom/allowed/urls");
2609 delete $filtersettings{'CUSTOM_WHITE_URLS'};
2610 while (<FILE>) { $filtersettings{'CUSTOM_WHITE_URLS'} .= $_ };
2611 close(FILE);
2612 }
2613 }
2614
2615 # -------------------------------------------------------------------
2616
2617 sub aggregatedconstraints
2618 {
2619 my $aggregated;
2620 my @old;
2621 my @new;
2622 my @tmp1;
2623 my @tmp2;
2624 my $x;
2625
2626 if (-e $tcfile)
2627 {
2628 open(TC, $tcfile);
2629 @old = <TC>;
2630 close(TC);
2631
2632 while (@old > 0)
2633 {
2634 $aggregated = 0;
2635 $x = shift(@old);
2636 chomp($x);
2637 @tmp1 = split(/\,/,$x);
2638 $tmp1[16] = '';
2639 foreach (@new)
2640 {
2641 @tmp2 = split(/\,/);
2642 if (($tmp1[15] eq 'on') && ($tmp2[15] eq 'on'))
2643 {
2644 if (($tmp1[0] eq $tmp2[0]) && ($tmp1[12] eq $tmp2[12]) && ($tmp1[13] eq $tmp2[13]) && ($tmp1[14] eq $tmp2[14]))
2645 {
2646 $aggregated = 1;
2647 $tmp2[16] .= " weekly ";
2648 if ($tmp1[1] eq 'on') { $tmp2[16] .= "m"; }
2649 if ($tmp1[2] eq 'on') { $tmp2[16] .= "t"; }
2650 if ($tmp1[3] eq 'on') { $tmp2[16] .= "w"; }
2651 if ($tmp1[4] eq 'on') { $tmp2[16] .= "h"; }
2652 if ($tmp1[5] eq 'on') { $tmp2[16] .= "f"; }
2653 if ($tmp1[6] eq 'on') { $tmp2[16] .= "a"; }
2654 if ($tmp1[7] eq 'on') { $tmp2[16] .= "s"; }
2655 $tmp2[16] .= " $tmp1[8]:$tmp1[9]-$tmp1[10]:$tmp1[11]\n";
2656 $_ = join(",",@tmp2);