]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/urlfilter.cgi
5 # This code is distributed under the terms of the GPL
7 # (c) written from scratch
9 # $Id: urlfilter.cgi,v 1.7 2006/05/08 00:00:00 marco Exp $
14 # enable only the following on debugging purpose
16 #use CGI::Carp 'fatalsToBrowser';
21 require '/var/ipfire/general-functions.pl' ;
22 require "${General::swroot}/lang.pl" ;
23 require "${General::swroot}/header.pl" ;
28 my %filtersettings =();
32 my %updatesettings =();
47 my $tcfile = "${General::swroot}/urlfilter/timeconst" ;
48 my $uqfile = "${General::swroot}/urlfilter/userquota" ;
49 my $dbdir = "${General::swroot}/urlfilter/blacklists" ;
50 my $editdir = "${General::swroot}/urlfilter/editor" ;
51 my $repository = "/home/httpd/html/repository" ;
52 my $hintcolour = '#FFFFCC' ;
54 my $sourceurlfile = "${General::swroot}/urlfilter/autoupdate/autoupdate.urls" ;
55 my $updconffile = "${General::swroot}/urlfilter/autoupdate/autoupdate.conf" ;
56 my $updflagfile = "${General::swroot}/urlfilter/blacklists/.autoupdate.last" ;
57 my $upd_cron_dly = "${General::swroot}/urlfilter/autoupdate/cron.daily" ;
58 my $upd_cron_wly = "${General::swroot}/urlfilter/autoupdate/cron.weekly" ;
59 my $upd_cron_mly = "${General::swroot}/urlfilter/autoupdate/cron.monthly" ;
63 my $restoremessage = '' ;
69 my @repositorylist =();
70 my @repositoryfiles =();
72 my @selectedcategories =();
76 my @source_urllist =();
87 if (! - d
$dbdir ) { mkdir ( " $dbdir " ); }
88 if (! - e
$tcfile ) { system ( "touch $tcfile " ); }
89 if (! - e
$uqfile ) { system ( "touch $uqfile " ); }
90 if (! - e
$sourceurlfile ) { system ( "touch $sourceurlfile " ); }
92 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%netsettings );
93 & General
:: readhash
( "${General::swroot}/main/settings" , \
%mainsettings );
94 & General
:: readhash
( "${General::swroot}/proxy/settings" , \
%proxysettings );
104 open ( FILE
, $sourceurlfile );
105 @source_urllist = < FILE
>;
108 $filtersettings { 'ENABLE_CUSTOM_BLACKLIST' } = 'off' ;
109 $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } = 'off' ;
110 $filtersettings { 'ENABLE_CUSTOM_EXPRESSIONS' } = 'off' ;
111 $filtersettings { 'BLOCK_EXECUTABLES' } = 'off' ;
112 $filtersettings { 'BLOCK_AUDIO-VIDEO' } = 'off' ;
113 $filtersettings { 'BLOCK_ARCHIVES' } = 'off' ;
114 $filtersettings { 'ENABLE_REWRITE' } = 'off' ;
115 $filtersettings { 'UNFILTERED_CLIENTS' } = '' ;
116 $filtersettings { 'BANNED_CLIENTS' } = '' ;
117 $filtersettings { 'SHOW_CATEGORY' } = 'off' ;
118 $filtersettings { 'SHOW_URL' } = 'off' ;
119 $filtersettings { 'SHOW_IP' } = 'off' ;
120 $filtersettings { 'ENABLE_DNSERROR' } = 'off' ;
121 $filtersettings { 'ENABLE_JPEG' } = 'off' ;
122 $filtersettings { 'REDIRECT_PAGE' } = '' ;
123 $filtersettings { 'MSG_TEXT_1' } = '' ;
124 $filtersettings { 'MSG_TEXT_2' } = '' ;
125 $filtersettings { 'MSG_TEXT_3' } = '' ;
126 $filtersettings { 'ENABLE_EXPR_LISTS' } = 'off' ;
127 $filtersettings { 'BLOCK_IP_ADDR' } = 'off' ;
128 $filtersettings { 'BLOCK_ALL' } = 'off' ;
129 $filtersettings { 'ENABLE_EMPTY_ADS' } = 'off' ;
130 $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } = 'off' ;
131 $filtersettings { 'ENABLE_SAFESEARCH' } = 'off' ;
132 $filtersettings { 'ENABLE_LOG' } = 'off' ;
133 $filtersettings { 'ENABLE_USERNAME_LOG' } = 'off' ;
134 $filtersettings { 'ENABLE_CATEGORY_LOG' } = 'off' ;
135 $filtersettings { 'CHILDREN' } = '5' ;
136 $filtersettings { 'ENABLE_AUTOUPDATE' } = 'off' ;
138 $filtersettings { 'ACTION' } = '' ;
139 $filtersettings { 'VALID' } = '' ;
141 & Header
:: getcgihash
( \
%filtersettings );
142 & Header
:: getcgihash
( \
%tcsettings );
143 & Header
:: getcgihash
( \
%uqsettings );
144 & Header
:: getcgihash
( \
%besettings );
146 if (( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'save' }) ||
147 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter save and restart' }) ||
148 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload file' }) ||
149 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter remove file' }) ||
150 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload background' }) ||
151 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload blacklist' }) ||
152 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter backup' }) ||
153 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter restore' }))
155 if (!( $filtersettings { 'CHILDREN' } =~ /^\d+$/ ) || ( $filtersettings { 'CHILDREN' } < 1 ))
157 $errormessage = $Lang :: tr
{ 'urlfilter invalid num of children' };
161 if ((!( $filtersettings { 'REDIRECT_PAGE' } eq '' )) && (!( $filtersettings { 'REDIRECT_PAGE' } =~ /^https?:\/ \
// )))
163 $filtersettings { 'REDIRECT_PAGE' } = "http://" . $filtersettings { 'REDIRECT_PAGE' };
166 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter remove file' })
168 if (- e
" $repository / $filtersettings {'ID'}" ) { unlink ( " $repository / $filtersettings {'ID'}" ); }
169 $filtersettings { 'ACTION' } = $Lang :: tr
{ 'urlfilter manage repository' };
172 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload file' })
174 & Header
:: getcgihash
( \
%filtersettings , { 'wantfile' => 1 , 'filevar' => 'UPLOADFILE' });
176 $filtersettings { 'ACTION' } = $Lang :: tr
{ 'urlfilter manage repository' };
177 $_ = $filtersettings { 'UPLOADFILE' };
179 $_ = substr ( $_ , rindex ( $_ , "/" )+ 1 );
181 if ( copy
( $filtersettings { 'UPLOADFILE' }, " $repository / $_ " ) != 1 )
190 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload background' })
192 & Header
:: getcgihash
( \
%filtersettings , { 'wantfile' => 1 , 'filevar' => 'BACKGROUND' });
194 if ( copy
( $filtersettings { 'BACKGROUND' }, "/home/httpd/html/images/urlfilter/background.jpg" ) != 1 )
201 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload blacklist' })
203 & Header
:: getcgihash
( \
%filtersettings , { 'wantfile' => 1 , 'filevar' => 'UPDATEFILE' });
205 if (!( $filtersettings { 'UPDATEFILE' } =~ /.tar.gz$/ ))
207 $errormessage = $Lang :: tr
{ 'urlfilter wrong filetype' };
211 if ( copy
( $filtersettings { 'UPDATEFILE' }, "${General::swroot}/urlfilter/blacklists.tar.gz" ) != 1 )
217 if (!(- d
"${General::swroot}/urlfilter/update" )) { mkdir ( "${General::swroot}/urlfilter/update" ); }
219 my $exitcode = system ( "/bin/tar --no-same-owner -xzf ${General::swroot}/urlfilter/blacklists.tar.gz -C ${General::swroot}/urlfilter/update" );
223 $errormessage = $Lang :: tr
{ 'urlfilter tar error' };
226 if (- d
"${General::swroot}/urlfilter/update/category" )
228 system ( "mv ${General::swroot}/urlfilter/update/category ${General::swroot}/urlfilter/update/blacklists" );
231 if (!(- d
"${General::swroot}/urlfilter/update/blacklists" ))
233 $errormessage = $Lang :: tr
{ 'urlfilter invalid content' };
235 system ( "cp -r ${General::swroot}/urlfilter/update/blacklists/* $dbdir " );
237 & readblockcategories
;
242 $updatemessage = $Lang :: tr
{ 'urlfilter upload success' };
243 system ( "${General::swroot}/urlfilter/bin/prebuild.pl &" );
244 system ( "logger -t installpackage[urlfilter] \" URL filter blacklist - Blacklist update from local source completed \" " );
247 if (- d
"${General::swroot}/urlfilter/update" ) { system ( "rm -rf ${General::swroot}/urlfilter/update" ); }
248 if (- e
"${General::swroot}/urlfilter/blacklists.tar.gz" ) { unlink ( "${General::swroot}/urlfilter/blacklists.tar.gz" ); }
249 if ( $errormessage ) { goto ERROR
; }
252 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter backup' })
254 $blistbackup = ( $filtersettings { 'ENABLE_FULLBACKUP' } eq 'on' ) ?
"blacklists" : "blacklists/custom" ;
255 if ( system ( "/bin/tar -C ${General::swroot}/urlfilter -czf ${General::swroot}/urlfilter/backup.tar.gz settings timeconst userquota autoupdate $blistbackup " ))
257 $errormessage = $Lang :: tr
{ 'urlfilter backup error' };
262 print "Content-type: application/gzip \n " ;
263 print "Content-length: " ;
264 print (- s
"${General::swroot}/urlfilter/backup.tar.gz" );
266 print "Content-disposition: attachment; filename=urlfilter-backup.tar.gz \n\n " ;
268 open ( FILE
, "${General::swroot}/urlfilter/backup.tar.gz" );
269 while (< FILE
>) { print ; }
272 if (- e
"${General::swroot}/urlfilter/backup.tar.gz" ) { unlink ( "${General::swroot}/urlfilter/backup.tar.gz" ); }
277 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter restore' })
279 & Header
:: getcgihash
( \
%filtersettings , { 'wantfile' => 1 , 'filevar' => 'UPDATEFILE' });
281 if (!( $filtersettings { 'UPDATEFILE' } =~ /.tar.gz$/ ))
283 $errormessage = $Lang :: tr
{ 'urlfilter wrong filetype' };
287 if (!(- d
"${General::swroot}/urlfilter/restore" )) { mkdir ( "${General::swroot}/urlfilter/restore" ); }
289 if ( copy
( $filtersettings { 'UPDATEFILE' }, "${General::swroot}/urlfilter/backup.tar.gz" ) != 1 )
294 my $exitcode = system ( "/bin/tar --no-same-owner --preserve-permissions -xzf ${General::swroot}/urlfilter/backup.tar.gz -C ${General::swroot}/urlfilter/restore" );
297 $errormessage = $Lang :: tr
{ 'urlfilter tar error' };
299 if (!(- e
"${General::swroot}/urlfilter/restore/settings" ))
301 $errormessage = $Lang :: tr
{ 'urlfilter invalid restore file' };
303 system ( "cp -rp ${General::swroot}/urlfilter/restore/* ${General::swroot}/urlfilter/" );
304 & readblockcategories
;
308 $restoremessage = $Lang :: tr
{ 'urlfilter restore success' };
312 if (- e
"${General::swroot}/urlfilter/backup.tar.gz" ) { unlink ( "${General::swroot}/urlfilter/backup.tar.gz" ); }
313 if (- d
"${General::swroot}/urlfilter/restore" ) { system ( "rm -rf ${General::swroot}/urlfilter/restore" ); }
314 if ( $errormessage ) { goto ERROR
; }
317 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'save' })
319 $filtersettings { 'VALID' } = 'yes' ;
323 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter save and restart' })
325 if (!(- e
"${General::swroot}/proxy/enable" ))
327 $errormessage = $Lang :: tr
{ 'urlfilter web proxy service required' };
330 if (!( $proxysettings { 'ENABLE_FILTER' } eq 'on' ))
332 $errormessage = $Lang :: tr
{ 'urlfilter not enabled' };
336 $filtersettings { 'VALID' } = 'yes' ;
339 system ( "chown -R nobody.nobody $dbdir " );
341 if (- e
" $dbdir /custom/allowed/domains.db" ) { unlink ( " $dbdir /custom/allowed/domains.db" ); }
342 if (- e
" $dbdir /custom/allowed/urls.db" ) { unlink ( " $dbdir /custom/allowed/urls.db" ); }
343 if (- e
" $dbdir /custom/blocked/domains.db" ) { unlink ( " $dbdir /custom/blocked/domains.db" ); }
344 if (- e
" $dbdir /custom/blocked/urls.db" ) { unlink ( " $dbdir /custom/blocked/urls.db" ); }
348 if (- d
$_ ){ system ( "chmod 644 $_ /*" ); }
349 if (- d
$_ ){ system ( "chmod 666 $_ /*.db" ); }
351 if (- d
" $dbdir /custom/allowed" )
353 system ( "chmod 755 $dbdir /custom/allowed" );
354 system ( "chmod 644 $dbdir /custom/allowed/*" );
356 if (- d
" $dbdir /custom/blocked" )
358 system ( "chmod 755 $dbdir /custom/blocked" );
359 system ( "chmod 644 $dbdir /custom/blocked/*" );
362 system ( '/usr/local/bin/restartsquid' );
367 if ( $errormessage ) { $filtersettings { 'VALID' } = 'no' ; }
371 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter set time constraints' }) { $tcsettings { 'TCMODE' } = 'on' }
373 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'add' }))
375 $tcsettings { 'TCMODE' }= 'on' ;
377 if (! $tcsettings { 'DST' })
379 $errormessage = $Lang :: tr
{ 'urlfilter dst error' };
382 if (! $tcsettings { 'SRC' })
384 $errormessage = $Lang :: tr
{ 'urlfilter src error' };
387 if (!( $tcsettings { 'TO_HOUR' }. $tcsettings { 'TO_MINUTE' } gt $tcsettings { 'FROM_HOUR' }. $tcsettings { 'FROM_MINUTE' }))
389 $errormessage = $Lang :: tr
{ 'urlfilter timespace error' };
392 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' )))
394 $errormessage = $Lang :: tr
{ 'urlfilter weekday error' };
399 if ( $tcsettings { 'DST' } =~ /^any/ ) { $tcsettings { 'DST' } = 'any' ; }
400 if ( $tcsettings { 'ENABLERULE' } eq 'on' ) { $tcsettings { 'ACTIVE' } = $tcsettings { 'ENABLERULE' }; } else { $tcsettings { 'ACTIVE' } = 'off' }
402 $tcsettings { 'ENABLERULE' } = 'on' ;
403 if ( $tcsettings { 'EDITING' } eq 'no' ) {
404 open ( FILE
, ">> $tcfile " );
406 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 " ;
408 open ( FILE
, "> $tcfile " );
411 foreach $line ( @tclist )
414 if ( $tcsettings { 'EDITING' } eq $id ) {
415 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 " ;
416 } else { print FILE
" $line " ; }
421 $tcsettings { 'CHANGED' }= 'yes' ;
422 $tcsettings { 'TCMODE' }= 'on' ;
425 if ( $tcsettings { 'EDITING' } ne 'no' )
427 $tcsettings { 'ACTION' } = $Lang :: tr
{ 'edit' };
428 $tcsettings { 'ID' } = $tcsettings { 'EDITING' };
433 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'remove' }))
436 open ( FILE
, "> $tcfile " );
438 foreach $line ( @tclist )
441 unless ( $tcsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
444 $tcsettings { 'CHANGED' }= 'yes' ;
445 $tcsettings { 'TCMODE' }= 'on' ;
448 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter restart' }))
450 if (!( $proxysettings { 'ENABLE_FILTER' } eq 'on' ))
452 $errormessage = $Lang :: tr
{ 'urlfilter not enabled' };
454 if (!(- e
"${General::swroot}/proxy/enable" ))
456 $errormessage = $Lang :: tr
{ 'urlfilter web proxy service required' };
459 if (! $errormessage ) { system ( '/usr/local/bin/restartsquid' ); }
460 $tcsettings { 'TCMODE' }= 'on' ;
463 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }))
465 open ( FILE
, "> $tcfile " );
468 foreach $line ( @tclist )
471 unless ( $tcsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
475 @temp = split ( /\,/ , $line );
476 if ( $temp [ 15 ] eq 'on' ) { $temp [ 15 ] = 'off' ; } else { $temp [ 15 ] = 'on' }
477 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 " ;
481 $tcsettings { 'CHANGED' }= 'yes' ;
482 $tcsettings { 'TCMODE' }= 'on' ;
485 if (! $errormessage ) {
486 $tcsettings { 'ENABLERULE' }= 'on' ;
487 $tcsettings { 'TO_HOUR' }= '24' ;
490 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) && (! $errormessage ))
493 foreach $line ( @tclist )
496 if ( $tcsettings { 'ID' } eq $id )
499 @temp = split ( /\,/ , $line );
500 $tcsettings { 'DEFINITION' } = $temp [ 0 ];
501 $tcsettings { 'MON' } = $temp [ 1 ];
502 $tcsettings { 'TUE' } = $temp [ 2 ];
503 $tcsettings { 'WED' } = $temp [ 3 ];
504 $tcsettings { 'THU' } = $temp [ 4 ];
505 $tcsettings { 'FRI' } = $temp [ 5 ];
506 $tcsettings { 'SAT' } = $temp [ 6 ];
507 $tcsettings { 'SUN' } = $temp [ 7 ];
508 $tcsettings { 'FROM_HOUR' } = $temp [ 8 ];
509 $tcsettings { 'FROM_MINUTE' } = $temp [ 9 ];
510 $tcsettings { 'TO_HOUR' } = $temp [ 10 ];
511 $tcsettings { 'TO_MINUTE' } = $temp [ 11 ];
512 $tcsettings { 'SRC' } = $temp [ 12 ];
513 $tcsettings { 'DST' } = $temp [ 13 ];
514 $tcsettings { 'ACCESS' } = $temp [ 14 ];
515 $tcsettings { 'ENABLERULE' } = $temp [ 15 ];
516 $tcsettings { 'COMMENT' } = $temp [ 16 ];
519 $tcsettings { 'TCMODE' }= 'on' ;
522 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter set user quota' }) { $uqsettings { 'UQMODE' } = 'on' }
524 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'add' }))
526 $uqsettings { 'UQMODE' }= 'on' ;
528 if ((!( $uqsettings { 'TIME_QUOTA' } =~ /^\d+/ )) || ( $uqsettings { 'TIME_QUOTA' } < '1' ))
530 $errormessage = $Lang :: tr
{ 'urlfilter quota time error' };
533 @temp = split ( /\n/ , $uqsettings { 'QUOTA_USERS' });
534 undef $uqsettings { 'QUOTA_USERS' };
537 s/^\s+//g ; s/\s+$//g ;
538 if ( $_ ) { $uqsettings { 'QUOTA_USERS' } .= $_ . " \n " ; }
541 if ( $uqsettings { 'QUOTA_USERS' } eq '' )
543 $errormessage = $Lang :: tr
{ 'urlfilter quota user error' };
546 $_ = $uqsettings { 'QUOTA_USERS' };
548 my $quota_users = $_ ;
550 if ( $uqsettings { 'QUOTA_USERS' } =~ /\\/ )
552 $errormessage = $Lang :: tr
{ 'urlfilter invalid user error' };
555 if (! $errormessage ) {
556 if ( $uqsettings { 'ENABLEQUOTA' } eq 'on' ) { $uqsettings { 'ACTIVE' } = $uqsettings { 'ENABLEQUOTA' }; } else { $uqsettings { 'ACTIVE' } = 'off' }
558 $uqsettings { 'ENABLERULE' } = 'on' ;
559 if ( $uqsettings { 'EDITING' } eq 'no' ) {
560 open ( FILE
, ">> $uqfile " );
562 print FILE
" $uqsettings {'TIME_QUOTA'}, $uqsettings {'SPORADIC'}, $uqsettings {'RENEWAL'}, $quota_users , $uqsettings {'ACTIVE'} \n " ;
564 open ( FILE
, "> $uqfile " );
567 foreach $line ( @uqlist )
570 if ( $uqsettings { 'EDITING' } eq $id ) {
571 print FILE
" $uqsettings {'TIME_QUOTA'}, $uqsettings {'SPORADIC'}, $uqsettings {'RENEWAL'}, $quota_users , $uqsettings {'ACTIVE'} \n " ;
572 } else { print FILE
" $line " ; }
577 $uqsettings { 'CHANGED' }= 'yes' ;
578 $uqsettings { 'MODE' }= 'USERQUOTA' ;
579 $uqsettings { 'UQMODE' }= 'on' ;
582 if ( $uqsettings { 'EDITING' } ne 'no' )
584 $uqsettings { 'ACTION' } = $Lang :: tr
{ 'edit' };
585 $uqsettings { 'ID' } = $uqsettings { 'EDITING' };
590 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'remove' }))
593 open ( FILE
, "> $uqfile " );
595 foreach $line ( @uqlist )
598 unless ( $uqsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
601 $uqsettings { 'CHANGED' }= 'yes' ;
602 $uqsettings { 'UQMODE' }= 'on' ;
605 if (! $errormessage ) {
606 $uqsettings { 'ENABLEQUOTA' }= 'on' ;
609 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) && (! $errormessage ))
612 foreach $line ( @uqlist )
615 if ( $uqsettings { 'ID' } eq $id )
618 @temp = split ( /\,/ , $line );
619 $uqsettings { 'TIME_QUOTA' } = $temp [ 0 ];
620 $uqsettings { 'SPORADIC' } = $temp [ 1 ];
621 $uqsettings { 'RENEWAL' } = $temp [ 2 ];
622 $uqsettings { 'QUOTA_USERS' } = $temp [ 3 ];
623 $uqsettings { 'ENABLEQUOTA' } = $temp [ 4 ];
626 $uqsettings { 'UQMODE' }= 'on' ;
629 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }))
631 open ( FILE
, "> $uqfile " );
634 foreach $line ( @uqlist )
637 unless ( $uqsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
641 @temp = split ( /\,/ , $line );
642 if ( $temp [ 4 ] eq 'on' ) { $temp [ 4 ] = 'off' ; } else { $temp [ 4 ] = 'on' }
643 print FILE
" $temp [0], $temp [1], $temp [2], $temp [3], $temp [4] \n " ;
647 $uqsettings { 'CHANGED' }= 'yes' ;
648 $uqsettings { 'UQMODE' }= 'on' ;
651 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter restart' }))
653 if (!( $proxysettings { 'ENABLE_FILTER' } eq 'on' ))
655 $errormessage = $Lang :: tr
{ 'urlfilter not enabled' };
657 if (!(- e
"${General::swroot}/proxy/enable" ))
659 $errormessage = $Lang :: tr
{ 'urlfilter web proxy service required' };
662 if (! $errormessage ) { system ( '/usr/local/bin/restartsquid' ); }
663 $uqsettings { 'UQMODE' }= 'on' ;
666 if ( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter blacklist editor' }) { $besettings { 'BEMODE' } = 'on' ; }
668 if ( $besettings { 'MODE' } eq 'BLACKLIST_EDITOR' )
670 @temp = split ( /\n/ , $besettings { 'BE_DOMAINS' });
671 undef $besettings { 'BE_DOMAINS' };
674 s/^\s+//g ; s/\s+$//g ;
675 if ( $_ ) { $besettings { 'BE_DOMAINS' } .= $_ . " \n " ; }
677 chomp ( $besettings { 'BE_DOMAINS' });
678 @temp = split ( /\n/ , $besettings { 'BE_URLS' });
679 undef $besettings { 'BE_URLS' };
682 s/^\s+//g ; s/\s+$//g ;
683 if ( $_ ) { $besettings { 'BE_URLS' } .= $_ . " \n " ; }
685 chomp ( $besettings { 'BE_URLS' });
686 @temp = split ( /\n/ , $besettings { 'BE_EXPRESSIONS' });
687 undef $besettings { 'BE_EXPRESSIONS' };
690 s/^\s+//g ; s/\s+$//g ;
691 if ( $_ ) { $besettings { 'BE_EXPRESSIONS' } .= $_ . " \n " ; }
693 chomp ( $besettings { 'BE_EXPRESSIONS' });
696 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter load blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
698 $besettings { 'BEMODE' } = 'on' ;
700 $besettings { 'BE_NAME' } = $besettings { 'BE_BLACKLIST' };
702 delete $besettings { 'BE_DOMAINS' };
703 delete $besettings { 'BE_URLS' };
704 delete $besettings { 'BE_EXPRESSIONS' };
706 if (- e
" $dbdir / $besettings {'BE_NAME'}/domains" )
708 open ( FILE
, " $dbdir / $besettings {'BE_NAME'}/domains" );
709 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_DOMAINS' } .= $_ } };
711 chomp ( $besettings { 'BE_DOMAINS' });
713 if (- e
" $dbdir / $besettings {'BE_NAME'}/urls" )
715 open ( FILE
, " $dbdir / $besettings {'BE_NAME'}/urls" );
716 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_URLS' } .= $_ } };
718 chomp ( $besettings { 'BE_URLS' });
720 if (- e
" $dbdir / $besettings {'BE_NAME'}/expressions" )
722 open ( FILE
, " $dbdir / $besettings {'BE_NAME'}/expressions" );
723 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_EXPRESSIONS' } .= $_ } };
725 chomp ( $besettings { 'BE_EXPRESSIONS' });
729 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter import blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
731 $besettings { 'BEMODE' } = 'on' ;
733 & Header
:: getcgihash
( \
%besettings , { 'wantfile' => 1 , 'filevar' => 'IMPORTFILE' });
735 if (!( $besettings { 'IMPORTFILE' } =~ /.tar.gz$/ ))
737 $errormessage = $Lang :: tr
{ 'urlfilter wrong filetype' };
739 if (!- d
" $editdir " ) { mkdir ( " $editdir " ); }
741 if ( copy
( $besettings { 'IMPORTFILE' }, " $editdir /blacklist.tar.gz" ) != 1 )
746 my $exitcode = system ( "/bin/tar --no-same-owner --preserve-permissions -xzf $editdir /blacklist.tar.gz -C $editdir " );
749 $errormessage = $Lang :: tr
{ 'urlfilter tar error' };
752 foreach (< $editdir /blacklists/ *>)
757 $besettings { 'BE_NAME' } = substr ( $_ , rindex ( $_ , "/" )+ 1 );
763 $errormessage = $Lang :: tr
{ 'urlfilter invalid import file' };
765 delete $besettings { 'BE_DOMAINS' };
766 delete $besettings { 'BE_URLS' };
767 delete $besettings { 'BE_EXPRESSIONS' };
769 if (- e
" $editdir /blacklists/ $besettings {'BE_NAME'}/domains" )
771 open ( FILE
, " $editdir /blacklists/ $besettings {'BE_NAME'}/domains" );
772 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_DOMAINS' } .= $_ } };
774 chomp ( $besettings { 'BE_DOMAINS' });
776 if (- e
" $editdir /blacklists/ $besettings {'BE_NAME'}/urls" )
778 open ( FILE
, " $editdir /blacklists/ $besettings {'BE_NAME'}/urls" );
779 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_URLS' } .= $_ } };
781 chomp ( $besettings { 'BE_URLS' });
783 if (- e
" $editdir /blacklists/ $besettings {'BE_NAME'}/expressions" )
785 open ( FILE
, " $editdir /blacklists/ $besettings {'BE_NAME'}/expressions" );
786 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_EXPRESSIONS' } .= $_ } };
788 chomp ( $besettings { 'BE_EXPRESSIONS' });
793 if (- d
$editdir ) { system ( "rm -rf $editdir " ); }
799 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter export blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
801 $besettings { 'BEMODE' } = 'on' ;
803 if ( $besettings { 'BE_NAME' } eq '' )
805 $errormessage = $Lang :: tr
{ 'urlfilter category name error' };
806 } elsif ( $besettings { 'BE_DOMAINS' } || $besettings { 'BE_URLS' } || $besettings { 'BE_EXPRESSIONS' }) {
808 $_ = $besettings { 'BE_NAME' }; tr/A-Z/a-z/ ; $besettings { 'BE_NAME' } = $_ ;
810 if (!(- d
" $editdir " )) { mkdir ( " $editdir " ); }
811 if (!(- d
" $editdir /blacklists" )) { mkdir ( " $editdir /blacklists" ); }
812 if (!(- d
" $editdir /blacklists/ $besettings {'BE_NAME'}" )) { mkdir ( " $editdir /blacklists/ $besettings {'BE_NAME'}" ); }
814 open ( FILE
, "> $editdir /blacklists/ $besettings {'BE_NAME'}/domains" );
816 print FILE
" $besettings {'BE_DOMAINS'} \n " ;
818 open ( FILE
, "> $editdir /blacklists/ $besettings {'BE_NAME'}/urls" );
820 print FILE
" $besettings {'BE_URLS'} \n " ;
822 open ( FILE
, "> $editdir /blacklists/ $besettings {'BE_NAME'}/expressions" );
824 print FILE
" $besettings {'BE_EXPRESSIONS'} \n " ;
827 if ( system ( "/bin/tar -C $editdir -czf $editdir / $besettings {'BE_NAME'}.tar.gz blacklists" ))
829 $errormessage = $Lang :: tr
{ 'urlfilter export error' };
833 print "Content-type: application/gzip \n " ;
834 print "Content-length: " ;
835 print (- s
" $editdir / $besettings {'BE_NAME'}.tar.gz" );
837 print "Content-disposition: attachment; filename= $besettings {'BE_NAME'}.tar.gz \n\n " ;
839 open ( FILE
, " $editdir / $besettings {'BE_NAME'}.tar.gz" );
840 while (< FILE
>) { print ; }
843 if (- d
$editdir ) { system ( "rm -rf $editdir " ); }
847 $errormessage = $Lang :: tr
{ 'urlfilter category data error' };
851 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter install blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
853 $besettings { 'BEMODE' } = 'on' ;
855 if ( $besettings { 'BE_NAME' } eq '' )
857 $errormessage = $Lang :: tr
{ 'urlfilter category name error' };
858 } elsif ( $besettings { 'BE_DOMAINS' } || $besettings { 'BE_URLS' } || $besettings { 'BE_EXPRESSIONS' }) {
860 $_ = $besettings { 'BE_NAME' }; tr/A-Z/a-z/ ; $besettings { 'BE_NAME' } = $_ ;
862 if (!- d
" $editdir " ) { mkdir ( " $editdir " ); }
864 if (!- d
" $dbdir / $besettings {'BE_NAME'}" ) { mkdir ( " $dbdir / $besettings {'BE_NAME'}" ); }
866 if (- e
" $dbdir / $besettings {'BE_NAME'}/domains" ) { unlink ( " $dbdir / $besettings {'BE_NAME'}/domains" ); }
867 if ( $besettings { 'BE_DOMAINS' })
869 open ( FILE
, "> $dbdir / $besettings {'BE_NAME'}/domains" );
871 print FILE
" $besettings {'BE_DOMAINS'} \n " ;
874 if (- e
" $dbdir / $besettings {'BE_NAME'}/urls" ) { unlink ( " $dbdir / $besettings {'BE_NAME'}/urls" ); }
875 if ( $besettings { 'BE_URLS' })
877 open ( FILE
, "> $dbdir / $besettings {'BE_NAME'}/urls" );
879 print FILE
" $besettings {'BE_URLS'} \n " ;
882 if (- e
" $dbdir / $besettings {'BE_NAME'}/expressions" ) { unlink ( " $dbdir / $besettings {'BE_NAME'}/expressions" ); }
883 if ( $besettings { 'BE_EXPRESSIONS' })
885 open ( FILE
, "> $dbdir / $besettings {'BE_NAME'}/expressions" );
887 print FILE
" $besettings {'BE_EXPRESSIONS'} \n " ;
891 open ( FILE
, "> $editdir /install.conf" );
893 print FILE
"logdir /var/log/squidGuard \n " ;
894 print FILE
"dbhome $dbdir / $besettings {'BE_NAME'} \n\n " ;
895 print FILE
"dest $besettings {'BE_NAME'} { \n " ;
896 if ( $besettings { 'BE_DOMAINS' }) { print FILE
" domainlist domains \n " ; }
897 if ( $besettings { 'BE_URLS' }) { print FILE
" urllist urls \n " ; }
898 if ( $besettings { 'BE_EXPRESSIONS' }) { print FILE
" expressions expressions \n " ; }
900 print FILE
"acl { \n " ;
901 print FILE
" default { \n " ;
902 print FILE
" pass none \n " ;
907 system ( "rm -f $dbdir / $besettings {'BE_NAME'}/*.db" );
908 system ( "/usr/sbin/squidGuard -c $editdir /install.conf -C all" );
909 system ( "chmod a+w $dbdir / $besettings {'BE_NAME'}/*.db" );
911 & readblockcategories
;
916 system ( '/usr/local/bin/restartsquid' ) unless ( $besettings { 'NORESTART' } eq 'on' );
918 if (- d
$editdir ) { system ( "rm -rf $editdir " ); }
920 $errormessage = $Lang :: tr
{ 'urlfilter category data error' };
924 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter save schedule' })
926 if (( $filtersettings { 'UPDATE_SOURCE' } eq 'custom' ) && ( $filtersettings { 'CUSTOM_UPDATE_URL' } eq '' ))
928 $errormessage = $Lang :: tr
{ 'urlfilter custom url required' };
930 open ( FILE
, "> $updconffile " );
931 print FILE
"ENABLE_AUTOUPDATE= $filtersettings {'ENABLE_AUTOUPDATE'} \n " ;
932 print FILE
"UPDATE_SCHEDULE= $filtersettings {'UPDATE_SCHEDULE'} \n " ;
933 print FILE
"UPDATE_SOURCE= $filtersettings {'UPDATE_SOURCE'} \n " ;
934 print FILE
"CUSTOM_UPDATE_URL= $filtersettings {'CUSTOM_UPDATE_URL'} \n " ;
937 if (- e
$upd_cron_dly ) { unlink ( $upd_cron_dly ); }
938 if (- e
$upd_cron_wly ) { unlink ( $upd_cron_wly ); }
939 if (- e
$upd_cron_mly ) { unlink ( $upd_cron_mly ); }
941 if (( $filtersettings { 'ENABLE_AUTOUPDATE' } eq 'on' ) && ( $filtersettings { 'UPDATE_SCHEDULE' } eq 'daily' ))
943 symlink ( "../bin/autoupdate.pl" , $upd_cron_dly )
945 symlink ( "/bin/false" , $upd_cron_dly )
948 if (( $filtersettings { 'ENABLE_AUTOUPDATE' } eq 'on' ) && ( $filtersettings { 'UPDATE_SCHEDULE' } eq 'weekly' ))
950 symlink ( "../bin/autoupdate.pl" , $upd_cron_wly )
952 symlink ( "/bin/false" , $upd_cron_wly )
955 if (( $filtersettings { 'ENABLE_AUTOUPDATE' } eq 'on' ) && ( $filtersettings { 'UPDATE_SCHEDULE' } eq 'monthly' ))
957 symlink ( "../bin/autoupdate.pl" , $upd_cron_mly )
959 symlink ( "/bin/false" , $upd_cron_mly )
964 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter update now' })
966 if ( $filtersettings { 'UPDATE_SOURCE' } eq 'custom' )
968 if ( $filtersettings { 'CUSTOM_UPDATE_URL' } eq '' )
970 $errormessage = $Lang :: tr
{ 'urlfilter custom url required' };
972 system ( "${General::swroot}/urlfilter/bin/autoupdate.pl $filtersettings {'CUSTOM_UPDATE_URL'} &" );
975 system ( "${General::swroot}/urlfilter/bin/autoupdate.pl $filtersettings {'UPDATE_SOURCE'} &" );
980 if (- e
"${General::swroot}/urlfilter/settings" ) { & General
:: readhash
( "${General::swroot}/urlfilter/settings" , \
%filtersettings ); }
984 $checked { 'ENABLE_CUSTOM_BLACKLIST' }{ 'off' } = '' ;
985 $checked { 'ENABLE_CUSTOM_BLACKLIST' }{ 'on' } = '' ;
986 $checked { 'ENABLE_CUSTOM_BLACKLIST' }{ $filtersettings { 'ENABLE_CUSTOM_BLACKLIST' }} = "checked='checked'" ;
987 $checked { 'ENABLE_CUSTOM_WHITELIST' }{ 'off' } = '' ;
988 $checked { 'ENABLE_CUSTOM_WHITELIST' }{ 'on' } = '' ;
989 $checked { 'ENABLE_CUSTOM_WHITELIST' }{ $filtersettings { 'ENABLE_CUSTOM_WHITELIST' }} = "checked='checked'" ;
990 $checked { 'ENABLE_CUSTOM_EXPRESSIONS' }{ 'off' } = '' ;
991 $checked { 'ENABLE_CUSTOM_EXPRESSIONS' }{ 'on' } = '' ;
992 $checked { 'ENABLE_CUSTOM_EXPRESSIONS' }{ $filtersettings { 'ENABLE_CUSTOM_EXPRESSIONS' }} = "checked='checked'" ;
993 $checked { 'BLOCK_EXECUTABLES' }{ 'off' } = '' ;
994 $checked { 'BLOCK_EXECUTABLES' }{ 'on' } = '' ;
995 $checked { 'BLOCK_EXECUTABLES' }{ $filtersettings { 'BLOCK_EXECUTABLES' }} = "checked='checked'" ;
996 $checked { 'BLOCK_AUDIO-VIDEO' }{ 'off' } = '' ;
997 $checked { 'BLOCK_AUDIO-VIDEO' }{ 'on' } = '' ;
998 $checked { 'BLOCK_AUDIO-VIDEO' }{ $filtersettings { 'BLOCK_AUDIO-VIDEO' }} = "checked='checked'" ;
999 $checked { 'BLOCK_ARCHIVES' }{ 'off' } = '' ;
1000 $checked { 'BLOCK_ARCHIVES' }{ 'on' } = '' ;
1001 $checked { 'BLOCK_ARCHIVES' }{ $filtersettings { 'BLOCK_ARCHIVES' }} = "checked='checked'" ;
1002 $checked { 'ENABLE_REWRITE' }{ 'off' } = '' ;
1003 $checked { 'ENABLE_REWRITE' }{ 'on' } = '' ;
1004 $checked { 'ENABLE_REWRITE' }{ $filtersettings { 'ENABLE_REWRITE' }} = "checked='checked'" ;
1005 $checked { 'SHOW_CATEGORY' }{ 'off' } = '' ;
1006 $checked { 'SHOW_CATEGORY' }{ 'on' } = '' ;
1007 $checked { 'SHOW_CATEGORY' }{ $filtersettings { 'SHOW_CATEGORY' }} = "checked='checked'" ;
1008 $checked { 'SHOW_URL' }{ 'off' } = '' ;
1009 $checked { 'SHOW_URL' }{ 'on' } = '' ;
1010 $checked { 'SHOW_URL' }{ $filtersettings { 'SHOW_URL' }} = "checked='checked'" ;
1011 $checked { 'SHOW_IP' }{ 'off' } = '' ;
1012 $checked { 'SHOW_IP' }{ 'on' } = '' ;
1013 $checked { 'SHOW_IP' }{ $filtersettings { 'SHOW_IP' }} = "checked='checked'" ;
1014 $checked { 'ENABLE_DNSERROR' }{ 'off' } = '' ;
1015 $checked { 'ENABLE_DNSERROR' }{ 'on' } = '' ;
1016 $checked { 'ENABLE_DNSERROR' }{ $filtersettings { 'ENABLE_DNSERROR' }} = "checked='checked'" ;
1017 $checked { 'ENABLE_JPEG' }{ 'off' } = '' ;
1018 $checked { 'ENABLE_JPEG' }{ 'on' } = '' ;
1019 $checked { 'ENABLE_JPEG' }{ $filtersettings { 'ENABLE_JPEG' }} = "checked='checked'" ;
1020 $checked { 'ENABLE_EXPR_LISTS' }{ 'off' } = '' ;
1021 $checked { 'ENABLE_EXPR_LISTS' }{ 'on' } = '' ;
1022 $checked { 'ENABLE_EXPR_LISTS' }{ $filtersettings { 'ENABLE_EXPR_LISTS' }} = "checked='checked'" ;
1023 $checked { 'BLOCK_IP_ADDR' }{ 'off' } = '' ;
1024 $checked { 'BLOCK_IP_ADDR' }{ 'on' } = '' ;
1025 $checked { 'BLOCK_IP_ADDR' }{ $filtersettings { 'BLOCK_IP_ADDR' }} = "checked='checked'" ;
1026 $checked { 'BLOCK_ALL' }{ 'off' } = '' ;
1027 $checked { 'BLOCK_ALL' }{ 'on' } = '' ;
1028 $checked { 'BLOCK_ALL' }{ $filtersettings { 'BLOCK_ALL' }} = "checked='checked'" ;
1029 $checked { 'ENABLE_EMPTY_ADS' }{ 'off' } = '' ;
1030 $checked { 'ENABLE_EMPTY_ADS' }{ 'on' } = '' ;
1031 $checked { 'ENABLE_EMPTY_ADS' }{ $filtersettings { 'ENABLE_EMPTY_ADS' }} = "checked='checked'" ;
1032 $checked { 'ENABLE_GLOBAL_WHITELIST' }{ 'off' } = '' ;
1033 $checked { 'ENABLE_GLOBAL_WHITELIST' }{ 'on' } = '' ;
1034 $checked { 'ENABLE_GLOBAL_WHITELIST' }{ $filtersettings { 'ENABLE_GLOBAL_WHITELIST' }} = "checked='checked'" ;
1035 $checked { 'ENABLE_SAFESEARCH' }{ 'off' } = '' ;
1036 $checked { 'ENABLE_SAFESEARCH' }{ 'on' } = '' ;
1037 $checked { 'ENABLE_SAFESEARCH' }{ $filtersettings { 'ENABLE_SAFESEARCH' }} = "checked='checked'" ;
1038 $checked { 'ENABLE_LOG' }{ 'off' } = '' ;
1039 $checked { 'ENABLE_LOG' }{ 'on' } = '' ;
1040 $checked { 'ENABLE_LOG' }{ $filtersettings { 'ENABLE_LOG' }} = "checked='checked'" ;
1041 $checked { 'ENABLE_USERNAME_LOG' }{ 'off' } = '' ;
1042 $checked { 'ENABLE_USERNAME_LOG' }{ 'on' } = '' ;
1043 $checked { 'ENABLE_USERNAME_LOG' }{ $filtersettings { 'ENABLE_USERNAME_LOG' }} = "checked='checked'" ;
1044 $checked { 'ENABLE_CATEGORY_LOG' }{ 'off' } = '' ;
1045 $checked { 'ENABLE_CATEGORY_LOG' }{ 'on' } = '' ;
1046 $checked { 'ENABLE_CATEGORY_LOG' }{ $filtersettings { 'ENABLE_CATEGORY_LOG' }} = "checked='checked'" ;
1048 foreach $category ( @filtergroups ) {
1049 $checked { $category }{ 'off' } = '' ;
1050 $checked { $category }{ 'on' } = '' ;
1051 $checked { $category }{ $filtersettings { $category }} = "checked='checked'" ;
1054 $selected { 'DEFINITION' }{ $tcsettings { 'DEFINITION' }} = "selected='selected'" ;
1055 $selected { 'FROM_HOUR' }{ $tcsettings { 'FROM_HOUR' }} = "selected='selected'" ;
1056 $selected { 'FROM_MINUTE' }{ $tcsettings { 'FROM_MINUTE' }} = "selected='selected'" ;
1057 $selected { 'TO_HOUR' }{ $tcsettings { 'TO_HOUR' }} = "selected='selected'" ;
1058 $selected { 'TO_MINUTE' }{ $tcsettings { 'TO_MINUTE' }} = "selected='selected'" ;
1060 @selectedcategories = split ( /\|/ , $tcsettings { 'DST' });
1061 foreach ( @selectedcategories )
1063 $selected { 'DST' }{ $_ } = "selected='selected'" ;
1066 $selected { 'ACCESS' }{ $tcsettings { 'ACCESS' }} = "selected='selected'" ;
1068 $checked { 'ENABLERULE' }{ 'off' } = '' ;
1069 $checked { 'ENABLERULE' }{ 'on' } = '' ;
1070 $checked { 'ENABLERULE' }{ $tcsettings { 'ENABLERULE' }} = "checked='checked'" ;
1071 $checked { 'MON' }{ 'off' } = '' ;
1072 $checked { 'MON' }{ 'on' } = '' ;
1073 $checked { 'MON' }{ $tcsettings { 'MON' }} = "checked='checked'" ;
1074 $checked { 'TUE' }{ 'off' } = '' ;
1075 $checked { 'TUE' }{ 'on' } = '' ;
1076 $checked { 'TUE' }{ $tcsettings { 'TUE' }} = "checked='checked'" ;
1077 $checked { 'WED' }{ 'off' } = '' ;
1078 $checked { 'WED' }{ 'on' } = '' ;
1079 $checked { 'WED' }{ $tcsettings { 'WED' }} = "checked='checked'" ;
1080 $checked { 'THU' }{ 'off' } = '' ;
1081 $checked { 'THU' }{ 'on' } = '' ;
1082 $checked { 'THU' }{ $tcsettings { 'THU' }} = "checked='checked'" ;
1083 $checked { 'FRI' }{ 'off' } = '' ;
1084 $checked { 'FRI' }{ 'on' } = '' ;
1085 $checked { 'FRI' }{ $tcsettings { 'FRI' }} = "checked='checked'" ;
1086 $checked { 'SAT' }{ 'off' } = '' ;
1087 $checked { 'SAT' }{ 'on' } = '' ;
1088 $checked { 'SAT' }{ $tcsettings { 'SAT' }} = "checked='checked'" ;
1089 $checked { 'SUN' }{ 'off' } = '' ;
1090 $checked { 'SUN' }{ 'on' } = '' ;
1091 $checked { 'SUN' }{ $tcsettings { 'SUN' }} = "checked='checked'" ;
1093 $selected { 'SPORADIC' }{ $uqsettings { 'SPORADIC' }} = "selected='selected'" ;
1094 $selected { 'RENEWAL' } { $uqsettings { 'RENEWAL' }} = "selected='selected'" ;
1096 $checked { 'ENABLEQUOTA' }{ 'off' } = '' ;
1097 $checked { 'ENABLEQUOTA' }{ 'on' } = '' ;
1098 $checked { 'ENABLEQUOTA' }{ $uqsettings { 'ENABLEQUOTA' }} = "checked='checked'" ;
1100 $selected { 'BE_BLACKLIST' }{ $besettings { 'BE_BLACKLIST' }} = "selected='selected'" ;
1103 & Header
:: showhttpheaders
();
1105 & Header
:: openpage
( $Lang :: tr
{ 'urlfilter configuration' }, 1 , '' );
1107 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
1109 if ( $errormessage ) {
1110 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
1111 print "<font class='base'> $errormessage </font> \n " ;
1112 & Header
:: closebox
();
1113 } elsif (( $tcsettings { 'CHANGED' } eq 'yes' ) || ( $uqsettings { 'CHANGED' } eq 'yes' ) ) {
1115 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}'> \n " ;
1116 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter restart notification'}:" );
1117 print "<class name='base'> $Lang ::tr{'urlfilter restart message'} \n " ;
1118 if ( $uqsettings { 'MODE' } eq 'USERQUOTA' ) { print "<p><class name='base'> $Lang ::tr{'urlfilter quota restart message'} \n " ; }
1120 print "<p><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter restart'}' />" ;
1121 if ( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) { print "<input type='hidden' name='MODE' value='TIMECONSTRAINT' />" ; }
1122 if ( $uqsettings { 'MODE' } eq 'USERQUOTA' ) { print "<input type='hidden' name='MODE' value='USERQUOTA' />" ; }
1123 & Header
:: closebox
();
1127 if ( $restoremessage ) {
1128 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter restore results'}:" );
1129 print "<class name='base'> $restoremessage \n " ;
1130 print " </class> \n " ;
1131 & Header
:: closebox
();
1134 if ((! $tcsettings { 'TCMODE' }) && (! $uqsettings { 'UQMODE' }) && (! $besettings { 'BEMODE' })) {
1136 if (!( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter manage repository' })) {
1138 #==========================================================
1140 # Section: Main Configuration
1142 #==========================================================
1144 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
1146 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter filter settings'}:" );
1148 <table width='100%'>
1150 <td colspan='4'><b> $Lang ::tr{'urlfilter block categories'}</b></td>
1155 if ( @categories == 0 ) {
1158 <td><i> $Lang ::tr{'urlfilter no categories'}</i></td>
1168 for ( $n = 0 ; $n <= @categories ; $n = $n + $i ) {
1169 for ( $i = 0 ; $i <= 3 ; $i ++) {
1170 if ( $i eq 0 ) { print "<tr> \n " ; }
1171 if (( $n + $i ) < @categories ) {
1172 print "<td width='15%'> @categories [ $n + $i ]:<\/td> \n " ;
1173 print "<td width='10%'><input type='checkbox' name= @filtergroups [ $n + $i ] $checked { @filtergroups [ $n + $i ]}{'on'} /></td> \n " ;
1175 if ( $i eq 3 ) { print "<\/tr> \n " ; }
1182 <table width='100%'>
1184 <td><b> $Lang ::tr{'urlfilter custom blacklist'}</b></td>
1190 <td colspan='2'> $Lang ::tr{'urlfilter blocked domains'} <img src='/blob.gif' alt='*' /></td>
1191 <td colspan='2'> $Lang ::tr{'urlfilter blocked urls'} <img src='/blob.gif' alt='*' /></td>
1194 <td colspan='2' width='50%'><textarea name='CUSTOM_BLACK_DOMAINS' cols='32' rows='6' wrap='off'>
1198 print $filtersettings { 'CUSTOM_BLACK_DOMAINS' };
1202 <td colspan='2' width='50%'><textarea name='CUSTOM_BLACK_URLS' cols='32' rows='6' wrap='off'>
1206 print $filtersettings { 'CUSTOM_BLACK_URLS' };
1212 <table width='100%'>
1214 <td class='base' width='25%'> $Lang ::tr{'urlfilter enable custom blacklist'}:</td>
1215 <td><input type='checkbox' name='ENABLE_CUSTOM_BLACKLIST' $checked {'ENABLE_CUSTOM_BLACKLIST'}{'on'} /></td>
1221 <table width='100%'>
1223 <td><b> $Lang ::tr{'urlfilter custom whitelist'}</b></td>
1229 <td colspan='2'> $Lang ::tr{'urlfilter allowed domains'} <img src='/blob.gif' alt='*' /></td>
1230 <td colspan='2'> $Lang ::tr{'urlfilter allowed urls'} <img src='/blob.gif' alt='*' /></td>
1233 <td colspan='2' width='50%'><textarea name='CUSTOM_WHITE_DOMAINS' cols='32' rows='6' wrap='off'>
1237 print $filtersettings { 'CUSTOM_WHITE_DOMAINS' };
1241 <td colspan='2' width='50%'><textarea name='CUSTOM_WHITE_URLS' cols='32' rows='6' wrap='off'>
1245 print $filtersettings { 'CUSTOM_WHITE_URLS' };
1251 <table width='100%'>
1253 <td class='base' width='25%'> $Lang ::tr{'urlfilter enable custom whitelist'}:</td>
1254 <td><input type='checkbox' name='ENABLE_CUSTOM_WHITELIST' $checked {'ENABLE_CUSTOM_WHITELIST'}{'on'} /></td>
1260 <table width='100%'>
1262 <td colspan='4'><b> $Lang ::tr{'urlfilter custom expression list'}</b></td>
1265 <td colspan='4'> $Lang ::tr{'urlfilter blocked expressions'} <img src='/blob.gif' alt='*' /></td>
1268 <td colspan='4'><textarea name='CUSTOM_EXPRESSIONS' cols='70' rows='3' wrap='off'>
1272 print $filtersettings { 'CUSTOM_EXPRESSIONS' };
1278 <td class='base' width='25%'> $Lang ::tr{'urlfilter enable custom expression list'}:</td>
1279 <td><input type='checkbox' name='ENABLE_CUSTOM_EXPRESSIONS' $checked {'ENABLE_CUSTOM_EXPRESSIONS'}{'on'} /></td>
1285 <table width='100%'>
1287 <td colspan='4'><b> $Lang ::tr{'urlfilter file ext block'}</b></td>
1290 <td width='25%' class='base'> $Lang ::tr{'urlfilter block executables'}:</td>
1291 <td width='12%'><input type='checkbox' name='BLOCK_EXECUTABLES' $checked {'BLOCK_EXECUTABLES'}{'on'} /></td>
1292 <td width='25%' class='base'> $Lang ::tr{'urlfilter block audio-video'}:</td>
1293 <td><input type='checkbox' name='BLOCK_AUDIO-VIDEO' $checked {'BLOCK_AUDIO-VIDEO'}{'on'} /></td>
1296 <td class='base'> $Lang ::tr{'urlfilter block archives'}:</td>
1297 <td><input type='checkbox' name='BLOCK_ARCHIVES' $checked {'BLOCK_ARCHIVES'}{'on'} /></td>
1303 <table width='100%'>
1305 <td colspan='4'><b> $Lang ::tr{'urlfilter local file redirection'}</b></td>
1308 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable rewrite rules'}:</td>
1309 <td width='12%'><input type='checkbox' name='ENABLE_REWRITE' $checked {'ENABLE_REWRITE'}{'on'} /></td>
1314 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter manage repository'}'></td>
1321 <table width='100%'>
1323 <td colspan='2'><b> $Lang ::tr{'urlfilter network access control'}</b></td>
1328 <td class='base'> $Lang ::tr{'urlfilter unfiltered clients'}: <img src='/blob.gif' alt='*' /></td>
1329 <td><input type='text' name='UNFILTERED_CLIENTS' value=' $filtersettings {'UNFILTERED_CLIENTS'}' size='30' /></td>
1330 <td class='base'> $Lang ::tr{'urlfilter banned clients'}: <img src='/blob.gif' alt='*' /></td>
1331 <td><input type='text' name='BANNED_CLIENTS' value=' $filtersettings {'BANNED_CLIENTS'}' size='30' /></td>
1335 <table width='100%'>
1337 <td colspan='4'><b> $Lang ::tr{'urlfilter timebased access control'}</b></td>
1340 <td width='25%'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter set time constraints'}'></td>
1341 <td width='25%'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter set user quota'}'></td>
1347 <table width='100%'>
1349 <td colspan='4'><b> $Lang ::tr{'urlfilter block settings'}</b></td>
1352 <td width='25%' class='base'> $Lang ::tr{'urlfilter show category'}:</td>
1353 <td width='12%'><input type='checkbox' name='SHOW_CATEGORY' $checked {'SHOW_CATEGORY'}{'on'} /></td>
1354 <td width='25%' class='base'> $Lang ::tr{'urlfilter redirectpage'}: <img src='/blob.gif' alt='*' /></td>
1355 <td><input type='text' name='REDIRECT_PAGE' value=' $filtersettings {'REDIRECT_PAGE'}' size='40' /></td>
1358 <td class='base'> $Lang ::tr{'urlfilter show url'}:</td>
1359 <td><input type='checkbox' name='SHOW_URL' $checked {'SHOW_URL'}{'on'} /></td>
1360 <td class='base'> $Lang ::tr{'urlfilter msg text 1'}: <img src='/blob.gif' alt='*' /></td>
1361 <td><input type='text' name='MSG_TEXT_1' value=' $filtersettings {'MSG_TEXT_1'}' size='40' /></td>
1364 <td class='base'> $Lang ::tr{'urlfilter show ip'}:</td>
1365 <td><input type='checkbox' name='SHOW_IP' $checked {'SHOW_IP'}{'on'} /></td>
1366 <td class='base'> $Lang ::tr{'urlfilter msg text 2'}: <img src='/blob.gif' alt='*' /></td>
1367 <td><input type='text' name='MSG_TEXT_2' value=' $filtersettings {'MSG_TEXT_2'}' size='40' /></td>
1370 <td class='base'> $Lang ::tr{'urlfilter show dnserror'}:</td>
1371 <td><input type='checkbox' name='ENABLE_DNSERROR' $checked {'ENABLE_DNSERROR'}{'on'} /></td>
1372 <td class='base'> $Lang ::tr{'urlfilter msg text 3'}: <img src='/blob.gif' alt='*' /></td>
1373 <td><input type='text' name='MSG_TEXT_3' value=' $filtersettings {'MSG_TEXT_3'}' size='40' /></td>
1376 <td class='base'> $Lang ::tr{'urlfilter enable jpeg'}:</td>
1377 <td><input type='checkbox' name='ENABLE_JPEG' $checked {'ENABLE_JPEG'}{'on'} /></td>
1382 <table width='100%'>
1384 <td class='base'><b> $Lang ::tr{'urlfilter background image'}</b></td>
1387 <td><br> $Lang ::tr{'urlfilter background text'}:</td>
1390 <td><input type='file' name='BACKGROUND' size='40' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter upload background'}' /></td>
1394 <table width='100%'>
1396 <td colspan='4'><b> $Lang ::tr{'urlfilter advanced settings'}</b></td>
1399 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable expression lists'}:</td>
1400 <td width='12%'><input type='checkbox' name='ENABLE_EXPR_LISTS' $checked {'ENABLE_EXPR_LISTS'}{'on'} /></td>
1401 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable log'}:</td>
1402 <td><input type='checkbox' name='ENABLE_LOG' $checked {'ENABLE_LOG'}{'on'} /></td>
1405 <td class='base'> $Lang ::tr{'urlfilter safesearch'}:</td>
1406 <td><input type='checkbox' name='ENABLE_SAFESEARCH' $checked {'ENABLE_SAFESEARCH'}{'on'} /></td>
1407 <td class='base'> $Lang ::tr{'urlfilter username log'}:</td>
1408 <td><input type='checkbox' name='ENABLE_USERNAME_LOG' $checked {'ENABLE_USERNAME_LOG'}{'on'} /></td>
1411 <td class='base'> $Lang ::tr{'urlfilter empty ads'}:</td>
1412 <td><input type='checkbox' name='ENABLE_EMPTY_ADS' $checked {'ENABLE_EMPTY_ADS'}{'on'} /></td>
1413 <td class='base'> $Lang ::tr{'urlfilter category log'}:</td>
1414 <td><input type='checkbox' name='ENABLE_CATEGORY_LOG' $checked {'ENABLE_CATEGORY_LOG'}{'on'} /></td>
1417 <td class='base'> $Lang ::tr{'urlfilter block ip'}:</td>
1418 <td><input type='checkbox' name='BLOCK_IP_ADDR' $checked {'BLOCK_IP_ADDR'}{'on'} /></td>
1419 <td class='base'> $Lang ::tr{'urlfilter children'}:</td>
1420 <td><input type='text' name='CHILDREN' value=' $filtersettings {'CHILDREN'}' size='5' /></td>
1423 <td class='base'> $Lang ::tr{'urlfilter block all'}:</td>
1424 <td><input type='checkbox' name='BLOCK_ALL' $checked {'BLOCK_ALL'}{'on'} /></td>
1425 <td class='base'> $Lang ::tr{'urlfilter whitelist always allowed'}:</td>
1426 <td><input type='checkbox' name='ENABLE_GLOBAL_WHITELIST' $checked {'ENABLE_GLOBAL_WHITELIST'}{'on'} /></td>
1430 <table width='100%'>
1433 <img src='/blob.gif' align='top' alt='*' />
1434 <font class='base'> $Lang ::tr{'this field may be blank'}</font>
1437 <sup><small><a href='http://www.urlfilter.net' target='_blank'>URL filter</a></small></sup>
1441 <table width='100%'>
1444 <td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' /></td>
1445 <td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter save and restart'}' /></td>
1452 & Header
:: closebox
();
1456 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
1458 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter maintenance'}:" );
1461 <table width='100%'>
1463 <td class='base'><b> $Lang ::tr{'urlfilter blacklist update'}</b></td>
1466 <td> $Lang ::tr{'urlfilter upload information'}<p> $Lang ::tr{'urlfilter upload text'}:</td>
1469 <td><input type='file' name='UPDATEFILE' size='40' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter upload blacklist'}' /></td>
1475 <table width='100%'>
1477 <td colspan='2' class='base'><b> $Lang ::tr{'urlfilter automatic blacklist update'}</b>
1480 if (- e
" $updflagfile " )
1482 $blacklistage = int (- M
" $updflagfile " );
1483 print " <b>[</b> <small><i> $Lang ::tr{'urlfilter blacklist age 1'} <b> $blacklistage </b> $Lang ::tr{'urlfilter blacklist age 2'}</i></small> <b>]</b>" ;
1486 $updatesettings { 'UPDATE_SCHEDULE' } = 'monthly' ;
1487 $updatesettings { 'CUSTOM_UPDATE_URL' } = '' ;
1489 if (- e
" $updconffile " ) { & General
:: readhash
( " $updconffile " , \
%updatesettings ); }
1491 $checked { 'ENABLE_AUTOUPDATE' }{ 'off' } = '' ;
1492 $checked { 'ENABLE_AUTOUPDATE' }{ 'on' } = '' ;
1493 $checked { 'ENABLE_AUTOUPDATE' }{ $updatesettings { 'ENABLE_AUTOUPDATE' }} = "checked='checked'" ;
1495 $selected { 'UPDATE_SCHEDULE' }{ $updatesettings { 'UPDATE_SCHEDULE' }} = "selected='selected'" ;
1497 $selected { 'UPDATE_SOURCE' }{ $updatesettings { 'UPDATE_SOURCE' }} = "selected='selected'" ;
1503 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable automatic blacklist update'}:</td>
1504 <td width='75%' class='base'><input type='checkbox' name='ENABLE_AUTOUPDATE' $checked {'ENABLE_AUTOUPDATE'}{'on'} /></td>
1507 <td class='base'> $Lang ::tr{'urlfilter automatic update schedule'}:</td>
1509 <select name='UPDATE_SCHEDULE'>
1510 <option value='daily' $selected {'UPDATE_SCHEDULE'}{'daily'}> $Lang ::tr{'urlfilter daily'}</option>
1511 <option value='weekly' $selected {'UPDATE_SCHEDULE'}{'weekly'}> $Lang ::tr{'urlfilter weekly'}</option>
1512 <option value='monthly' $selected {'UPDATE_SCHEDULE'}{'monthly'}> $Lang ::tr{'urlfilter monthly'}</option>
1517 <td class='base'> $Lang ::tr{'urlfilter select source'}:</td>
1518 <td class='base' colspan='2'>
1519 <select name='UPDATE_SOURCE'>
1523 foreach ( @source_urllist ) {
1525 $source_name = substr ( $_ , 0 , rindex ( $_ , "," ));
1526 $source_url = substr ( $_ , index ( $_ , "," )+ 1 );
1527 print " \t <option value=' $source_url ' $selected {'UPDATE_SOURCE'}{ $source_url }> $source_name </option> \n " ;
1531 <option value='custom' $selected {'UPDATE_SOURCE'}{'custom'}> $Lang ::tr{'urlfilter custom url'}</option>
1536 <td> $Lang ::tr{'urlfilter custom url'}:</td>
1537 <td><input type='text' name='CUSTOM_UPDATE_URL' value=' $updatesettings {'CUSTOM_UPDATE_URL'}' size='72' /></td>
1540 <table width='100%'>
1542 <td width='25%'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter save schedule'}'> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter update now'}'></td>
1548 <table width='100%'>
1550 <td class='base'><b> $Lang ::tr{'urlfilter blacklist editor'}</b></td>
1553 <td> $Lang ::tr{'urlfilter blacklist editor info'}</td>
1556 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter blacklist editor'}' /></td>
1562 <table width='100%'>
1564 <td colspan='4' class='base'><b> $Lang ::tr{'urlfilter backup settings'}</b></td>
1567 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable full backup'}:</td>
1568 <td width='12%' class='base'><input type='checkbox' name='ENABLE_FULLBACKUP' $checked {'ENABLE_FULLBACKUP'}{'on'} /></td>
1573 <td colspan='4' class='base'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter backup'}' /></td>
1579 <table width='100%'>
1581 <td class='base'><b> $Lang ::tr{'urlfilter restore settings'}</b></td>
1584 <td> $Lang ::tr{'urlfilter restore text'}:</td>
1587 <td><input type='file' name='UPDATEFILE' size='40' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter restore'}' /></td>
1594 & Header
:: closebox
();
1598 #==========================================================
1600 # Section: Manage Repository
1602 #==========================================================
1604 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
1606 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter manage local file repository'}:" );
1608 <table width='100%'>
1610 <td> $Lang ::tr{'urlfilter repository information'}<br><br></td>
1613 <td> $Lang ::tr{'urlfilter upload file text'}:</td>
1616 <td><input type='file' name='UPLOADFILE' size='50' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter upload file'}' /></td>
1619 <td><br><b> $Lang ::tr{'urlfilter upload file information 1'}:</b> $Lang ::tr{'urlfilter upload file information 2'}</td>
1623 <table width='100%'>
1625 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
1632 & Header
:: closebox
();
1634 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter current files'}: </b>[ $repository ]" );
1636 @repositorylist = < $repository /*>;
1638 undef @repositoryfiles ;
1639 foreach ( @repositorylist )
1641 if (!- d
) { push ( @repositoryfiles , substr ( $_ , rindex ( $_ , "/" )+ 1 )); }
1644 if ( @repositoryfiles )
1647 <table width='100%'>
1649 <td align='center'><b> $Lang ::tr{'urlfilter filename'}</b></td>
1650 <td width='15%' align='center'><b> $Lang ::tr{'urlfilter filesize'}</b></td>
1651 <td width='10%'></td>
1656 foreach $line ( @repositoryfiles )
1660 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
1662 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
1663 $filesize = (- s
" $repository / $line " );
1664 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/ ;
1667 <td> $line </td>
1668 <td align='right'> $filesize </td>
1671 <form method='post' name='frma $id ' action=' $ENV {'SCRIPT_NAME'}'>
1672 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' title=' $Lang ::tr{'remove'}' alt=' $Lang ::tr{'remove'}' />
1673 <input type='hidden' name='ID' value=' $line ' />
1674 <input type='hidden' name='ACTION' value=' $Lang ::tr{'urlfilter remove file'}' />
1691 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
1692 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
1693 <td class='base'> $Lang ::tr{'remove'}</td>
1700 print "<i> $Lang ::tr{'urlfilter empty repository'}</i> \n " ;
1703 & Header
:: closebox
();
1707 } elsif ( $tcsettings { 'TCMODE' }) {
1709 #==========================================================
1711 # Section: Set Time Constraints
1713 #==========================================================
1715 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}'> \n " ;
1717 $buttontext = $Lang :: tr
{ 'urlfilter add rule' };
1718 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
1719 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter edit time constraint rule' }. ':' );
1720 $buttontext = $Lang :: tr
{ 'urlfilter update rule' };
1722 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter add new time constraint rule' }. ':' );
1726 <table width='100%'>
1728 <td width='2%'> $Lang ::tr{'urlfilter constraint definition'}</td>
1729 <td width='1%'> </td>
1730 <td width='2%' align='center'> $Lang ::tr{'urlfilter monday'}</td>
1731 <td width='2%' align='center'> $Lang ::tr{'urlfilter tuesday'}</td>
1732 <td width='2%' align='center'> $Lang ::tr{'urlfilter wednesday'}</td>
1733 <td width='2%' align='center'> $Lang ::tr{'urlfilter thursday'}</td>
1734 <td width='2%' align='center'> $Lang ::tr{'urlfilter friday'}</td>
1735 <td width='2%' align='center'> $Lang ::tr{'urlfilter saturday'}</td>
1736 <td width='2%' align='center'> $Lang ::tr{'urlfilter sunday'}</td>
1737 <td width='1%'> </td>
1738 <td width='7%' colspan=3> $Lang ::tr{'urlfilter from'}</td>
1739 <td width='1%'> </td>
1740 <td width='7%' colspan=3> $Lang ::tr{'urlfilter to'}</td>
1745 <select name='DEFINITION'>
1746 <option value='within' $selected {'DEFINITION'}{'within'}> $Lang ::tr{'urlfilter constraint within'}</option>
1747 <option value='outside' $selected {'DEFINITION'}{'outside'}> $Lang ::tr{'urlfilter constraint outside'}</option>
1751 <td class='base'><input type='checkbox' name='MON' $checked {'MON'}{'on'} /></td>
1752 <td class='base'><input type='checkbox' name='TUE' $checked {'TUE'}{'on'} /></td>
1753 <td class='base'><input type='checkbox' name='WED' $checked {'WED'}{'on'} /></td>
1754 <td class='base'><input type='checkbox' name='THU' $checked {'THU'}{'on'} /></td>
1755 <td class='base'><input type='checkbox' name='FRI' $checked {'FRI'}{'on'} /></td>
1756 <td class='base'><input type='checkbox' name='SAT' $checked {'SAT'}{'on'} /></td>
1757 <td class='base'><input type='checkbox' name='SUN' $checked {'SUN'}{'on'} /></td>
1760 <select name='FROM_HOUR'>
1763 for ( $i = 0 ; $i <= 24 ; $i ++) {
1764 $_ = sprintf ( " %02s " , $i );
1765 print "<option $selected {'FROM_HOUR'}{ $_ }> $_ </option> \n " ;
1772 <select name='FROM_MINUTE'>
1775 for ( $i = 0 ; $i <= 45 ; $i += 15 ) {
1776 $_ = sprintf ( " %02s " , $i );
1777 print "<option $selected {'FROM_MINUTE'}{ $_ }> $_ </option> \n " ;
1784 <select name='TO_HOUR'>
1787 for ( $i = 0 ; $i <= 24 ; $i ++) {
1788 $_ = sprintf ( " %02s " , $i );
1789 print "<option $selected {'TO_HOUR'}{ $_ }> $_ </option> \n " ;
1796 <select name='TO_MINUTE'>
1799 for ( $i = 0 ; $i <= 45 ; $i += 15 ) {
1800 $_ = sprintf ( " %02s " , $i );
1801 print "<option $selected {'TO_MINUTE'}{ $_ }> $_ </option> \n " ;
1812 <table width='100%'>
1814 <td width='5%'> $Lang ::tr{'urlfilter source'}</td>
1815 <td width='1%'> </td>
1816 <td width='5%'> $Lang ::tr{'urlfilter dst'} <img src='/blob.gif' alt='*'><img src='/blob.gif' alt='*'></td>
1817 <td width='1%'> </td>
1818 <td width='5%'> $Lang ::tr{'urlfilter access'}</td>
1822 <td valign='top'><input type='text' name='SRC' value=' $tcsettings {'SRC'}' size='32' /></td>
1824 <td class='base' rowspan='3' valign='top'>
1825 <select name='DST' size='4' multiple>
1826 <option value='any' $selected {'DST'}{'any'} = "selected='selected'"> $Lang ::tr{'urlfilter category all'}</option>
1827 <option value='in-addr' $selected {'DST'}{'in-addr'} = "selected='selected'">in-addr</option>
1831 & readblockcategories
;
1832 foreach ( @categories )
1834 print "<option value=' $_ ' $selected {'DST'}{ $_ }> $_ </option> \n " ;
1838 <option value='files' $selected {'DST'}{'files'} = "selected='selected'">files</option>
1839 <option value='custom-blocked' $selected {'DST'}{'custom-blocked'} = "selected='selected'">custom-blocked</option>
1840 <option value='custom-expressions' $selected {'DST'}{'custom-expressions'} = "selected='selected'">custom-expressions</option>
1844 <td class='base' valign='top'>
1845 <select name='ACCESS'>
1846 <option value='block' $selected {'ACCESS'}{'block'}> $Lang ::tr{'urlfilter mode block'}</option>
1847 <option value='allow' $selected {'ACCESS'}{'allow'}> $Lang ::tr{'urlfilter mode allow'}</option>
1853 <td> $Lang ::tr{'remark'} <img src='/blob.gif' alt='*'></td>
1860 <td><input type='text' name='COMMENT' value=' $tcsettings {'COMMENT'}' size='32' /></td>
1868 <table width='100%'>
1870 <td class='base'> $Lang ::tr{'urlfilter enabled'}<input type='checkbox' name='ENABLERULE' $checked{'ENABLERULE'}{'on'} /></td>
1878 <td><input type='hidden' name='ACTION' value=' $Lang ::tr{'add'}' /></td>
1879 <td><input type='hidden' name='MODE' value='TIMECONSTRAINT' /></td>
1880 <td><input type='submit' name='SUBMIT' value=' $buttontext ' /></td>
1881 <td><input type='reset' name='ACTION' value=' $Lang ::tr{'urlfilter reset'}' /></td>
1883 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
1887 <table width='100%'>
1889 <td width='1%' align='right'> <img src='/blob.gif' align='top' alt='*' /> </td>
1890 <td><font class='base'> $Lang ::tr{'this field may be blank'}</font></td>
1893 <td width='1%' align='right'><img src='/blob.gif' align='top' alt='*' /><img src='/blob.gif' align='top' alt='*' /> </td>
1894 <td><font class='base'> $Lang ::tr{'urlfilter select multi'}</font></td>
1900 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
1901 print "<input type='hidden' name='EDITING' value=' $tcsettings {'ID'}' /> \n " ;
1903 print "<input type='hidden' name='EDITING' value='no' /> \n " ;
1906 & Header
:: closebox
();
1909 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'current rules' });
1911 <table width='100%'>
1913 <td width='5%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter constraint definition'}</b></td>
1914 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter time space'}</b></td>
1915 <td width='15%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter src'}</b></td>
1916 <td width='5%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter dst'}</b></td>
1917 <td width='10%' class='boldbase' colspan='4' align='center'> </td>
1922 if ( $tcsettings { 'ACTION' } ne '' or $changed ne 'no' )
1924 open ( FILE
, $tcfile );
1930 foreach $line ( @tclist )
1934 @temp = split ( /\,/ , $line );
1935 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' } && $tcsettings { 'ID' } eq $id ) {
1936 print "<tr bgcolor=' $Header ::colouryellow'> \n " ; }
1938 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
1940 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
1941 if ( $temp [ 0 ] eq 'within' ) { $temp [ 0 ]= $Lang :: tr
{ 'urlfilter constraint within' }; } else { $temp [ 0 ]= $Lang :: tr
{ 'urlfilter constraint outside' }; }
1942 if ( $temp [ 13 ] eq 'any' ) { $temp [ 13 ]= $Lang :: tr
{ 'urlfilter category all' }; }
1943 if ( $temp [ 15 ] eq 'on' ) { $gif = 'on.gif' ; $toggle = 'off' ; $gdesc = $Lang :: tr
{ 'click to disable' };}
1944 else { $gif = 'off.gif' ; $toggle = 'on' ; $gdesc = $Lang :: tr
{ 'click to enable' }; }
1945 if ( $temp [ 14 ] eq 'block' ) { $led = 'led-red.gif' ; $ldesc = $Lang :: tr
{ 'urlfilter block access' };}
1946 else { $led = 'led-green.gif' ; $ldesc = $Lang :: tr
{ 'urlfilter allow access' }; }
1949 if ( $temp [ 1 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter mon' }; } else { $time .= '=' ; }
1950 if ( $temp [ 2 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter tue' }; } else { $time .= '=' ; }
1951 if ( $temp [ 3 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter wed' }; } else { $time .= '=' ; }
1952 if ( $temp [ 4 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter thu' }; } else { $time .= '=' ; }
1953 if ( $temp [ 5 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter fri' }; } else { $time .= '=' ; }
1954 if ( $temp [ 6 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter sat' }; } else { $time .= '=' ; }
1955 if ( $temp [ 7 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter sun' }; } else { $time .= '=' ; }
1956 $time = $time . ' ' . $temp [ 8 ]. ':' . $temp [ 9 ]. ' to ' . $temp [ 10 ]. ':' . $temp [ 11 ];
1959 <td align='center'> $temp [0]</td>
1960 <td align='center' nowrap> $time </td>
1961 <td align='center'> $temp [12]</td>
1962 <td align='center'> $temp [13]</td>
1963 <td align='center'><image src='/images/urlfilter/ $led ' alt=' $ldesc '></td>
1966 <form method='post' name='frma $id ' action=' $ENV {'SCRIPT_NAME'}'>
1967 <input type='image' name=' $Lang ::tr{'toggle enable disable'}' src='/images/ $gif ' title=' $gdesc ' alt=' $gdesc ' />
1968 <input type='hidden' name='MODE' value='TIMECONSTRAINT' />
1969 <input type='hidden' name='ID' value=' $id ' />
1970 <input type='hidden' name='ACTIVE' value=' $toggle ' />
1971 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
1976 <form method='post' name='frmb $id ' action=' $ENV {'SCRIPT_NAME'}'>
1977 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/edit.gif' title=' $Lang ::tr{'edit'}' alt=' $Lang ::tr{'edit'}' />
1978 <input type='hidden' name='MODE' value='TIMECONSTRAINT' />
1979 <input type='hidden' name='ID' value=' $id ' />
1980 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
1985 <form method='post' name='frmc $id ' action=' $ENV {'SCRIPT_NAME'}'>
1986 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' title=' $Lang ::tr{'remove'}' alt=' $Lang ::tr{'remove'}' />
1987 <input type='hidden' name='MODE' value='TIMECONSTRAINT' />
1988 <input type='hidden' name='ID' value=' $id ' />
1989 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove'}' />
1996 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' } && $tcsettings { 'ID' } eq $id ) {
1997 print "<tr bgcolor=' $Header ::colouryellow'> \n " ; }
1999 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
2001 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
2003 <td align='center' colspan='4'> $temp [16]
2005 <td align='center' colspan='4'>
2014 # If the time constraint file contains entries, print entries and action icons
2015 if (! - z
" $tcfile " ) {
2020 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
2021 <td> <img src='/images/urlfilter/led-green.gif' alt=' $Lang ::tr{'urlfilter allow access'}' /></td>
2022 <td class='base'> $Lang ::tr{'urlfilter allow'}</td>
2023 <td> <img src='/images/urlfilter/led-red.gif' alt=' $Lang ::tr{'urlfilter block access'}' /></td>
2024 <td class='base'> $Lang ::tr{'urlfilter block'}</td>
2025 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
2026 <td class='base'> $Lang ::tr{'click to disable'}</td>
2027 <td> <img src='/images/off.gif' alt=' $Lang ::tr{'click to enable'}' /></td>
2028 <td class='base'> $Lang ::tr{'click to enable'}</td>
2029 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
2030 <td class='base'> $Lang ::tr{'edit'}</td>
2031 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
2032 <td class='base'> $Lang ::tr{'remove'}</td>
2039 & Header
:: closebox
();
2041 } elsif ( $uqsettings { 'UQMODE' }) {
2043 #==========================================================
2045 # Section: Set User Quota
2047 #==========================================================
2049 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}'> \n " ;
2051 $buttontext = $Lang :: tr
{ 'urlfilter add rule' };
2052 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
2053 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter edit user quota rule' }. ':' );
2054 $buttontext = $Lang :: tr
{ 'urlfilter update rule' };
2056 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter add new user quota rule' }. ':' );
2060 <table width='100%'>
2062 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
2065 <td class='base'> $Lang ::tr{'urlfilter user time quota'}:</td>
2066 <td><input type='text' name='TIME_QUOTA' value=' $uqsettings {'TIME_QUOTA'}' size='5' /></td>
2067 <td colspan='2' rowspan= '5' valign='top' class='base'>
2068 <table cellpadding='0' cellspacing='0'>
2070 <!-- intentionally left empty -->
2073 <td> $Lang ::tr{'urlfilter assigned quota users'}:</td>
2076 <!-- intentionally left empty -->
2079 <!-- intentionally left empty -->
2082 <td><textarea name='QUOTA_USERS' cols='32' rows='6' wrap='off'>
2086 $uqsettings { 'QUOTA_USERS' } =~ s/\|/\n/g ;
2087 print $uqsettings { 'QUOTA_USERS' };
2096 <td class='base'> $Lang ::tr{'urlfilter activity detection'}:</td>
2097 <td class='base'><select name='SPORADIC'>
2098 <option value='0' $selected {'SPORADIC'}{'0'}> $Lang ::tr{'urlfilter disabled'}</option>
2099 <option value='300' $selected {'SPORADIC'}{'300'}>5 $Lang ::tr{'urlfilter minutes'}</option>
2100 <option value='900' $selected {'SPORADIC'}{'900'}>15 $Lang ::tr{'urlfilter minutes'}</option>
2104 <td class='base'> $Lang ::tr{'urlfilter renewal period'}:</td>
2105 <td class='base'><select name='RENEWAL'>
2106 <option value='hourly' $selected {'RENEWAL'}{'hourly'}> $Lang ::tr{'urlfilter hourly'}</option>
2107 <option value='daily' $selected {'RENEWAL'}{'daily'}> $Lang ::tr{'urlfilter daily'}</option>
2108 <option value='weekly' $selected {'RENEWAL'}{'weekly'}> $Lang ::tr{'urlfilter weekly'}</option>
2112 <td colspan='2'> </td>
2115 <td class='base'> $Lang ::tr{'urlfilter enabled'}</td>
2116 <td class='base'><input type='checkbox' name='ENABLEQUOTA' $checked {'ENABLEQUOTA'}{'on'} /></td>
2124 <td><input type='hidden' name='ACTION' value=' $Lang ::tr{'add'}' /></td>
2125 <td><input type='hidden' name='MODE' value='USERQUOTA' /></td>
2126 <td><input type='submit' name='SUBMIT' value=' $buttontext ' /></td>
2127 <td><input type='reset' name='ACTION' value=' $Lang ::tr{'urlfilter reset'}' /></td>
2129 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
2137 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
2138 print "<input type='hidden' name='EDITING' value=' $uqsettings {'ID'}' /> \n " ;
2140 print "<input type='hidden' name='EDITING' value='no' /> \n " ;
2143 & Header
:: closebox
();
2146 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'current rules' });
2148 <table width='100%'>
2150 <td width='15%' class='boldbase' align='center'><b><nobr> $Lang ::tr{'urlfilter time quota'}</nobr></b></td>
2151 <td width='15%' class='boldbase' align='center'><b><nobr> $Lang ::tr{'urlfilter activity detection'}</nobr></b></td>
2152 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter renewal'}</b></td>
2153 <td class='boldbase' align='center'><b> $Lang ::tr{'urlfilter assigned users'}</b></td>
2154 <td width='20%' class='boldbase' colspan='4' align='center'> </td>
2159 if ( $uqsettings { 'ACTION' } ne '' or $changed ne 'no' )
2161 open ( FILE
, $uqfile );
2167 foreach $line ( @uqlist )
2171 @temp = split ( /\,/ , $line );
2172 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' } && $uqsettings { 'ID' } eq $id ) {
2173 print "<tr bgcolor=' $Header ::colouryellow'> \n " ; }
2175 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
2177 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
2178 if ( $temp [ 4 ] eq 'on' ) { $gif = 'on.gif' ; $toggle = 'off' ; $gdesc = $Lang :: tr
{ 'click to disable' };}
2179 else { $gif = 'off.gif' ; $toggle = 'on' ; $gdesc = $Lang :: tr
{ 'click to enable' }; }
2181 $temp [ 5 ] = $temp [ 1 ];
2182 if ( $temp [ 1 ] eq '0' ) { $temp [ 5 ] = $Lang :: tr
{ 'urlfilter disabled' } } else { $temp [ 5 ] = ( $temp [ 5 ]/ 60 ). ' ' . $Lang :: tr
{ 'urlfilter minutes' } }
2183 $_ = $temp [ 3 ]; s/\|/, /g ; $temp [ 6 ] = $_ ;
2186 <td align='center'> $temp [0] $Lang ::tr{'urlfilter minutes'}</td>
2187 <td align='center'> $temp [5]</td>
2188 <td align='center'> $Lang ::tr{'urlfilter '. $temp [2]}</td>
2189 <td align='center'> $temp [6]</td>
2192 <form method='post' name='frma $id ' action=' $ENV {'SCRIPT_NAME'}'>
2193 <input type='image' name=' $Lang ::tr{'toggle enable disable'}' src='/images/ $gif ' title=' $gdesc ' alt=' $gdesc ' />
2194 <input type='hidden' name='MODE' value='USERQUOTA' />
2195 <input type='hidden' name='ID' value=' $id ' />
2196 <input type='hidden' name='ACTIVE' value=' $toggle ' />
2197 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
2202 <form method='post' name='frmb $id ' action=' $ENV {'SCRIPT_NAME'}'>
2203 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/edit.gif' title=' $Lang ::tr{'edit'}' alt=' $Lang ::tr{'edit'}' />
2204 <input type='hidden' name='MODE' value='USERQUOTA' />
2205 <input type='hidden' name='ID' value=' $id ' />
2206 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
2211 <form method='post' name='frmc $id ' action=' $ENV {'SCRIPT_NAME'}'>
2212 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' title=' $Lang ::tr{'remove'}' alt=' $Lang ::tr{'remove'}' />
2213 <input type='hidden' name='MODE' value='USERQUOTA' />
2214 <input type='hidden' name='ID' value=' $id ' />
2215 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove'}' />
2226 # If the user quota file contains entries, print entries and action icons
2227 if (! - z
" $uqfile " ) {
2232 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
2233 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
2234 <td class='base'> $Lang ::tr{'click to disable'}</td>
2235 <td> <img src='/images/off.gif' alt=' $Lang ::tr{'click to enable'}' /></td>
2236 <td class='base'> $Lang ::tr{'click to enable'}</td>
2237 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
2238 <td class='base'> $Lang ::tr{'edit'}</td>
2239 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
2240 <td class='base'> $Lang ::tr{'remove'}</td>
2247 & Header
:: closebox
();
2251 #==========================================================
2253 # Section: Blacklist editor
2255 #==========================================================
2257 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
2259 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter urlfilter blacklist editor' }. ':' );
2263 <table width='100%'>
2265 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
2268 <td class='base'><b> $Lang ::tr{'urlfilter blacklist name'}</b></td>
2271 <td class='base'> $Lang ::tr{'urlfilter blacklist category name'}:</td>
2272 <td><input type='text' name='BE_NAME' value=' $besettings {'BE_NAME'}' size='12' /></td>
2276 <table width='100%'>
2278 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='20%'></td>
2281 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter edit domains urls expressions'}</b></td>
2284 <td colspan='2'> $Lang ::tr{'urlfilter domains'}</td>
2285 <td colspan='2'> $Lang ::tr{'urlfilter urls'}</td>
2288 <td colspan='2'><textarea name='BE_DOMAINS' cols='38' rows='10' wrap='off'>
2292 print $besettings { 'BE_DOMAINS' };
2296 <td colspan='2'><textarea name='BE_URLS' cols='38' rows='10' wrap='off'>
2300 print $besettings { 'BE_URLS' };
2306 <td colspan='4'> $Lang ::tr{'urlfilter expressions'}</td>
2309 <td colspan='4'><textarea name='BE_EXPRESSIONS' cols='80' rows='3' wrap='off'>
2313 print $besettings { 'BE_EXPRESSIONS' };
2320 <table width='100%'>
2322 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter load blacklist'}</b></td>
2325 <td width='25%' class='base'> $Lang ::tr{'urlfilter select blacklist'}:</td>
2326 <td width='20%' class='base'>
2327 <select name='BE_BLACKLIST'>
2331 & readblockcategories
;
2332 foreach ( @categories )
2334 print "<option value=' $_ ' $selected {'BE_BLACKLIST'}{ $_ }> $_ </option> \n " ;
2343 <td colpsan='4'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter load blacklist'}' /></td>
2348 <table width='100%'>
2350 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter import blacklist'}</b></td>
2353 <td colspan='4'> $Lang ::tr{'urlfilter import text'}:</td>
2356 <td nowrap><input type='file' name='IMPORTFILE' size='40' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter import blacklist'}' /></td>
2357 <td><input type='hidden' name='MODE' value='BLACKLIST_EDITOR' /></td>
2361 <table width='100%'>
2363 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter export blacklist'}</b></td>
2366 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter export blacklist'}' /></td>
2370 <table width='100%'>
2372 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter install blacklist'}</b></td>
2375 <td width='25%' class='base'> $Lang ::tr{'urlfilter dont restart urlfilter'}:</td>
2376 <td width='20%' class='base'><input type='checkbox' name='NORESTART' $checked {'NORESTART'}{'on'} /></td>
2381 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter install blacklist'}' /></td>
2384 <td class='base' colspan='4'><br> $Lang ::tr{'urlfilter install information'}</td>
2390 <td><input type='reset' name='ACTION' value=' $Lang ::tr{'urlfilter reset'}' /></td>
2392 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
2399 & Header
:: closebox
();
2404 & Header
:: closebigbox
();
2406 & Header
:: closepage
();
2408 # -------------------------------------------------------------------
2414 delete $filtersettings { 'CUSTOM_BLACK_DOMAINS' };
2415 delete $filtersettings { 'CUSTOM_BLACK_URLS' };
2416 delete $filtersettings { 'CUSTOM_WHITE_DOMAINS' };
2417 delete $filtersettings { 'CUSTOM_WHITE_URLS' };
2418 delete $filtersettings { 'CUSTOM_EXPRESSIONS' };
2419 delete $filtersettings { 'BACKGROUND' };
2420 delete $filtersettings { 'UPDATEFILE' };
2422 & General
:: writehash
( "${General::swroot}/urlfilter/settings" , \
%filtersettings );
2425 # -------------------------------------------------------------------
2427 sub readblockcategories
2430 foreach $blacklist (< $dbdir /*>) {
2431 if (- d
$blacklist ) {
2432 $lastslashpos = rindex ( $blacklist , "/" );
2433 if ( $lastslashpos > - 1 ) {
2434 $section = substr ( $blacklist , $lastslashpos + 1 );
2436 $section = $blacklist ;
2438 if (!( $section eq 'custom' )) { push ( @categories , $section ) };
2442 @filtergroups = @categories ;
2443 foreach ( @filtergroups ) {
2449 # -------------------------------------------------------------------
2453 if (- e
" $dbdir /custom/blocked/domains" ) {
2454 open ( FILE
, " $dbdir /custom/blocked/domains" );
2455 delete $filtersettings { 'CUSTOM_BLACK_DOMAINS' };
2456 while (< FILE
>) { $filtersettings { 'CUSTOM_BLACK_DOMAINS' } .= $_ };
2460 if (- e
" $dbdir /custom/blocked/urls" ) {
2461 open ( FILE
, " $dbdir /custom/blocked/urls" );
2462 delete $filtersettings { 'CUSTOM_BLACK_URLS' };
2463 while (< FILE
>) { $filtersettings { 'CUSTOM_BLACK_URLS' } .= $_ };
2467 if (- e
" $dbdir /custom/blocked/expressions" ) {
2468 open ( FILE
, " $dbdir /custom/blocked/expressions" );
2469 delete $filtersettings { 'CUSTOM_EXPRESSIONS' };
2470 while (< FILE
>) { $filtersettings { 'CUSTOM_EXPRESSIONS' } .= $_ };
2474 if (- e
" $dbdir /custom/allowed/domains" ) {
2475 open ( FILE
, " $dbdir /custom/allowed/domains" );
2476 delete $filtersettings { 'CUSTOM_WHITE_DOMAINS' };
2477 while (< FILE
>) { $filtersettings { 'CUSTOM_WHITE_DOMAINS' } .= $_ };
2480 if (- e
" $dbdir /custom/allowed/urls" ) {
2481 open ( FILE
, " $dbdir /custom/allowed/urls" );
2482 delete $filtersettings { 'CUSTOM_WHITE_URLS' };
2483 while (< FILE
>) { $filtersettings { 'CUSTOM_WHITE_URLS' } .= $_ };
2488 # -------------------------------------------------------------------
2490 sub aggregatedconstraints
2510 @tmp1 = split ( /\,/ , $x );
2514 @tmp2 = split ( /\,/ );
2515 if ( $tmp2 [ 15 ] eq 'on' )
2517 if (( $tmp1 [ 0 ] eq $tmp2 [ 0 ]) && ( $tmp1 [ 12 ] eq $tmp2 [ 12 ]) && ( $tmp1 [ 13 ] eq $tmp2 [ 13 ]) && ( $tmp1 [ 14 ] eq $tmp2 [ 14 ]))
2520 $tmp2 [ 16 ] .= " weekly " ;
2521 if ( $tmp1 [ 1 ] eq 'on' ) { $tmp2 [ 16 ] .= "m" ; }
2522 if ( $tmp1 [ 2 ] eq 'on' ) { $tmp2 [ 16 ] .= "t" ; }
2523 if ( $tmp1 [ 3 ] eq 'on' ) { $tmp2 [ 16 ] .= "w" ; }
2524 if ( $tmp1 [ 4 ] eq 'on' ) { $tmp2 [ 16 ] .= "h" ; }
2525 if ( $tmp1 [ 5 ] eq 'on' ) { $tmp2 [ 16 ] .= "f" ; }
2526 if ( $tmp1 [ 6 ] eq 'on' ) { $tmp2 [ 16 ] .= "a" ; }
2527 if ( $tmp1 [ 7 ] eq 'on' ) { $tmp2 [ 16 ] .= "s" ; }
2528 $tmp2 [ 16 ] .= " $tmp1 [8]: $tmp1 [9]- $tmp1 [10]: $tmp1 [11] \n " ;
2529 $_ = join ( "," , @tmp2 );
2536 $tmp1 [ 16 ] .= " weekly " ;
2537 if ( $tmp1 [ 1 ] eq 'on' ) { $tmp1 [ 16 ] .= "m" ; }
2538 if ( $tmp1 [ 2 ] eq 'on' ) { $tmp1 [ 16 ] .= "t" ; }
2539 if ( $tmp1 [ 3 ] eq 'on' ) { $tmp1 [ 16 ] .= "w" ; }
2540 if ( $tmp1 [ 4 ] eq 'on' ) { $tmp1 [ 16 ] .= "h" ; }
2541 if ( $tmp1 [ 5 ] eq 'on' ) { $tmp1 [ 16 ] .= "f" ; }
2542 if ( $tmp1 [ 6 ] eq 'on' ) { $tmp1 [ 16 ] .= "a" ; }
2543 if ( $tmp1 [ 7 ] eq 'on' ) { $tmp1 [ 16 ] .= "s" ; }
2544 $tmp1 [ 16 ] .= " $tmp1 [8]: $tmp1 [9]- $tmp1 [10]: $tmp1 [11] \n " ;
2545 $x = join ( "," , @tmp1 );
2555 # -------------------------------------------------------------------
2559 my $executables = " \\ .\(ade|adp|asx|bas|bat|chm|com|cmd|cpl|crt|dll|eml|exe|hiv|hlp|hta|inc|inf|ins|isp|jse|jtd|lnk|msc|msh|msi|msp|mst|nws|ocx|oft|ops|pcd|pif|plx|reg|scr|sct|sha|shb|shm|shs|sys|tlb|tsp|url|vbe|vbs|vxd|wsc|wsf|wsh\)\$" ;
2560 my $audiovideo = " \\ .\(aiff|asf|avi|dif|divx|mov|movie|mp3|mpe?g?|mpv2|ogg|ra?m|snd|qt|wav|wmf|wmv\)\$" ;
2561 my $archives = " \\ .\(bin|bz2|cab|cdr|dmg|gz|hqx|rar|smi|sit|sea|tar|tgz|zip\)\$" ;
2563 my $ident = " anonymous" ;
2576 if (!(- d
" $dbdir /custom" )) { mkdir ( " $dbdir /custom" ) }
2577 if (!(- d
" $dbdir /custom/blocked" )) { mkdir ( " $dbdir /custom/blocked" ) }
2578 if (!(- d
" $dbdir /custom/allowed" )) { mkdir ( " $dbdir /custom/allowed" ) }
2580 open ( FILE
, ">/ $dbdir /custom/blocked/domains" );
2581 print FILE
$filtersettings { 'CUSTOM_BLACK_DOMAINS' };
2583 open ( FILE
, ">/ $dbdir /custom/blocked/urls" );
2584 print FILE
$filtersettings { 'CUSTOM_BLACK_URLS' };
2586 open ( FILE
, ">/ $dbdir /custom/blocked/expressions" );
2587 print FILE
$filtersettings { 'CUSTOM_EXPRESSIONS' };
2589 open ( FILE
, ">/ $dbdir /custom/blocked/files" );
2590 if ( $filtersettings { 'BLOCK_EXECUTABLES' } eq 'on' ) { print FILE
" $executables \n " ; }
2591 if ( $filtersettings { 'BLOCK_AUDIO-VIDEO' } eq 'on' ) { print FILE
" $audiovideo \n " ; }
2592 if ( $filtersettings { 'BLOCK_ARCHIVES' } eq 'on' ) { print FILE
" $archives \n " ; }
2594 open ( FILE
, ">/ $dbdir /custom/allowed/domains" );
2595 print FILE
$filtersettings { 'CUSTOM_WHITE_DOMAINS' };
2597 open ( FILE
, ">/ $dbdir /custom/allowed/urls" );
2598 print FILE
$filtersettings { 'CUSTOM_WHITE_URLS' };
2601 if ( $filtersettings { 'ENABLE_USERNAME_LOG' } eq 'on' ) { $ident = "" ; }
2603 if ( $filtersettings { 'REDIRECT_PAGE' } eq '' )
2605 if (( $filtersettings { 'SHOW_CATEGORY' } eq 'on' ) || ( $filtersettings { 'SHOW_URL' } eq 'on' ) || ( $filtersettings { 'SHOW_IP' } eq 'on' )) {
2606 if ( $filtersettings { 'SHOW_CATEGORY' } eq 'on' ) { $redirect .= "&category= %t " ; }
2607 if ( $filtersettings { 'SHOW_URL' } eq 'on' ) { $redirect .= "&url= %u " ; }
2608 if ( $filtersettings { 'SHOW_IP' } eq 'on' ) { $redirect .= "&ip= %a " ; }
2609 $redirect =~ s/^&/?/ ;
2610 $redirect = "http:\/\/ $netsettings {'GREEN_ADDRESS'}:81\/redirect.cgi" . $redirect ;
2612 $redirect = "http:\/\/ $netsettings {'GREEN_ADDRESS'}:81\/redirect.cgi" ;
2614 } else { $redirect = $filtersettings { 'REDIRECT_PAGE' }; }
2616 if ( $filtersettings { 'ENABLE_DNSERROR' } eq 'on' ) { $redirect = "302:http://0.0.0.0" ; }
2620 if ( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' )
2622 $defaultrule .= "custom-allowed " ;
2624 if ( $filtersettings { 'BLOCK_ALL' } eq 'on' )
2626 $defaultrule .= "none" ;
2630 if ( $filtersettings { 'BLOCK_IP_ADDR' } eq 'on' )
2632 $defaultrule .= "!in-addr " ;
2634 for ( $i = 0 ; $i <= @filtergroups ; $i ++) {
2635 if ( $filtersettings { @filtergroups [ $i ]} eq 'on' )
2637 $defaultrule .= "! @categories [ $i ] " ;
2640 if ( $filtersettings { 'ENABLE_CUSTOM_BLACKLIST' } eq 'on' )
2642 $defaultrule .= "!custom-blocked " ;
2644 if ( $filtersettings { 'ENABLE_CUSTOM_EXPRESSIONS' } eq 'on' )
2646 $defaultrule .= "!custom-expressions " ;
2648 if (( $filtersettings { 'BLOCK_EXECUTABLES' } eq 'on' ) ||
2649 ( $filtersettings { 'BLOCK_AUDIO-VIDEO' } eq 'on' ) ||
2650 ( $filtersettings { 'BLOCK_ARCHIVES' } eq 'on' ))
2652 $defaultrule .= "!files " ;
2654 $defaultrule .= "any" ;
2657 open ( FILE
, ">${General::swroot}/urlfilter/squidGuard.conf" ) or die "Unable to write squidGuard.conf file" ;
2660 print FILE
"logdir /var/log/squidGuard \n " ;
2661 print FILE
"dbhome $dbdir \n\n " ;
2663 undef @repositoryfiles ;
2664 if ( $filtersettings { 'ENABLE_REWRITE' } eq 'on' )
2666 @repositorylist = < $repository /*>;
2667 foreach ( @repositorylist )
2669 if (!- d
) { push ( @repositoryfiles , substr ( $_ , rindex ( $_ , "/" )+ 1 )); }
2673 if ((( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles )) || ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' ))
2675 print FILE
"rewrite rew-rule-0 { \n " ;
2677 if (( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles ))
2679 print FILE
" # rewrite localfiles \n " ;
2680 foreach ( @repositoryfiles )
2682 print FILE
" s@.*/ $_ \$\ @http :// $netsettings {'GREEN_ADDRESS'}:81/repository/ $_ \ @i \n " ;
2686 if ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' )
2688 print FILE
" # rewrite safesearch \n " ;
2689 print FILE
" s@(.* \\ Wgoogle \\ . \\ w+/(webhp|search|imghp|images|grphp|groups|frghp|froogle) \\ ?)(.*)( \\ bsafe= \\ w+)(.*)\@ \\ 1 \\ 3safe=strict \\ 5\ @i \n " ;
2690 print FILE
" s@(.* \\ Wgoogle \\ . \\ w+/(webhp|search|imghp|images|grphp|groups|frghp|froogle) \\ ?)(.*)\@ \\ 1safe=strict \\ \& \\ 3\ @i \n " ;
2691 print FILE
" s@(.* \\ Wsearch \\ .yahoo \\ . \\ w+/search \\ W)(.*)( \\ bvm= \\ w+)(.*)\@ \\ 1 \\ 2vm=r \\ 4\ @i \n " ;
2692 print FILE
" s@(.* \\ Wsearch \\ .yahoo \\ . \\ w+/search \\ W.*)\@ \\ 1 \\ \&vm=r\ @i \n " ;
2693 print FILE
" s@(.* \\ Walltheweb \\ .com/customize \\ ?)(.*)( \\ bcopt_offensive= \\ w+)(.*)\@ \\ 1 \\ 2copt_offensive=on \\ 4\ @i \n " ;
2698 if ((!( $filtersettings { 'UNFILTERED_CLIENTS' } eq '' )) && ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' )) {
2699 print FILE
"rewrite rew-rule-1 { \n " ;
2700 if (( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles ))
2702 print FILE
" # rewrite localfiles \n " ;
2703 foreach ( @repositoryfiles )
2705 print FILE
" s@.*/ $_ \$\ @http :// $netsettings {'GREEN_ADDRESS'}:81/repository/ $_ \ @i \n " ;
2708 print FILE
" # rewrite nothing \n " ;
2730 $uq [ 0 ] = $uq [ 0 ] * 60 ;
2731 if ( $uq [ 1 ] eq '0' ) {
2732 if ( $uq [ 2 ] eq 'hourly' ) { $uq [ 1 ] = 3600 }
2733 if ( $uq [ 2 ] eq 'daily' ) { $uq [ 1 ] = 86400 }
2734 if ( $uq [ 2 ] eq 'weekly' ) { $uq [ 1 ] = 604800 }
2737 print FILE
"src quota- $idx { \n " ;
2738 print FILE
" user $uq [3] \n " ;
2739 print FILE
" userquota $uq [0] $uq [1] $uq [2] \n " ;
2747 @tclist = & aggregatedconstraints
;
2756 if ( $tc [ 15 ] eq 'on' )
2759 print FILE
"src network- $idx { \n " ;
2760 print FILE
" ip $tc [12] \n " ;
2770 if ( $tc [ 15 ] eq 'on' )
2773 print FILE
"time constraint- $idx { \n " ;
2774 print FILE
" $tc [16] \n " ;
2780 if (!( $filtersettings { 'UNFILTERED_CLIENTS' } eq '' )) {
2781 print FILE
"src unfiltered { \n " ;
2782 print FILE
" ip $filtersettings {'UNFILTERED_CLIENTS'} \n " ;
2785 if (!( $filtersettings { 'BANNED_CLIENTS' } eq '' )) {
2786 print FILE
"src banned { \n " ;
2787 print FILE
" ip $filtersettings {'BANNED_CLIENTS'} \n " ;
2791 foreach $category ( @categories ) {
2792 print FILE
"dest $category { \n " ;
2793 if (- e
" $dbdir / $category /domains" ) {
2794 print FILE
" domainlist $category \/domains \n " ;
2796 if (- e
" $dbdir / $category /urls" ) {
2797 print FILE
" urllist $category \/urls \n " ;
2799 if ((- e
" $dbdir / $category /expressions" ) && ( $filtersettings { 'ENABLE_EXPR_LISTS' } eq 'on' )) {
2800 print FILE
" expressionlist $category \/expressions \n " ;
2802 if (( $category eq 'ads' ) && ( $filtersettings { 'ENABLE_EMPTY_ADS' } eq 'on' ))
2804 print FILE
" redirect http:\/\/ $netsettings {'GREEN_ADDRESS'}:81\/images/urlfilter/1x1.gif \n " ;
2806 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
2808 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
2810 print FILE
" logfile $ident $category .log \n " ;
2812 print FILE
" logfile $ident urlfilter.log \n " ;
2818 print FILE
"dest files { \n " ;
2819 print FILE
" expressionlist custom\/blocked\/files \n " ;
2820 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
2822 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
2824 print FILE
" logfile $ident files.log \n " ;
2826 print FILE
" logfile $ident urlfilter.log \n " ;
2831 print FILE
"dest custom-allowed { \n " ;
2832 print FILE
" domainlist custom\/allowed\/domains \n " ;
2833 print FILE
" urllist custom\/allowed\/urls \n " ;
2836 print FILE
"dest custom-blocked { \n " ;
2837 print FILE
" domainlist custom\/blocked\/domains \n " ;
2838 print FILE
" urllist custom\/blocked\/urls \n " ;
2839 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
2841 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
2843 print FILE
" logfile $ident custom.log \n " ;
2845 print FILE
" logfile $ident urlfilter.log \n " ;
2850 print FILE
"dest custom-expressions { \n " ;
2851 print FILE
" expressionlist custom\/blocked\/expressions \n " ;
2852 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
2854 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
2856 print FILE
" logfile $ident custom.log \n " ;
2858 print FILE
" logfile $ident urlfilter.log \n " ;
2863 print FILE
"acl { \n " ;
2864 if (!( $filtersettings { 'UNFILTERED_CLIENTS' } eq '' )) {
2865 print FILE
" unfiltered { \n " ;
2866 print FILE
" pass all \n " ;
2867 if ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' )
2869 print FILE
" rewrite rew-rule-1 \n " ;
2871 print FILE
" } \n\n " ;
2873 if (!( $filtersettings { 'BANNED_CLIENTS' } eq '' )) {
2874 print FILE
" banned { \n " ;
2875 print FILE
" pass " ;
2876 if (( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'on' ))
2878 print FILE
"custom-allowed " ;
2880 print FILE
"none \n " ;
2881 print FILE
" } \n\n " ;
2898 $qredirect = $redirect ;
2899 $qredirect =~ s/\%t/\%q\%20-\%20\%i/ ;
2900 print FILE
" quota- $idx { \n " ;
2901 print FILE
" pass " ;
2902 if (( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'on' ))
2904 print FILE
"custom-allowed " ;
2906 print FILE
"none \n " ;
2907 unless ( $redirect eq $qredirect ) { print FILE
" redirect $qredirect \n " ; }
2908 print FILE
" } \n\n " ;
2920 @ec = split ( /\|/ , $tc [ 13 ]);
2921 if ( $tc [ 15 ] eq 'on' )
2924 print FILE
" network- $idx $tc [0] constraint- $idx { \n " ;
2925 print FILE
" pass " ;
2927 if ( $filtersettings { 'BLOCK_ALL' } eq 'on' )
2929 if ( $tc [ 14 ] eq 'block' )
2931 if (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' )) {
2932 if (( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'on' ))
2934 print FILE
"custom-allowed " ;
2938 print FILE
$defaultrule ;
2945 print FILE
$defaultrule unless (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ));
2948 if ( $tc [ 14 ] eq 'block' )
2950 $tcrule = $defaultrule ;
2951 if ( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) {
2952 $tcrule =~ s/custom-allowed // ;
2953 print FILE
"custom-allowed " unless (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'off' ));
2955 if (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' )) {
2960 print FILE
"! $_ " unless ( index ( $defaultrule , "!" . $_ . " " ) ge 0 );
2963 print FILE
$tcrule unless (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ));
2965 $tcrule = $defaultrule ;
2968 $tcrule =~ s/!$_ // ;
2969 print FILE
" $_ " if ( $_ eq 'any' );
2971 print FILE
$tcrule unless (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ));
2977 print FILE
" } \n\n " ;
2982 print FILE
" default { \n " ;
2983 print FILE
" pass $defaultrule \n " ;
2984 if (( $filtersettings { 'ENABLE_LOG' } eq 'on' ) && ( $filtersettings { 'BLOCK_ALL' } eq 'on' ))
2986 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
2988 print FILE
" logfile" . $ident . " default.log \n " ;
2990 print FILE
" logfile" . $ident . " urlfilter.log \n " ;
2993 if ((( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles )) || ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' ))
2995 print FILE
" rewrite rew-rule-0 \n " ;
2997 print FILE
" redirect $redirect \n " ;
3004 # -------------------------------------------------------------------
3009 # This code is distributed under the terms of the GPL
3011 # (c) written from scratch
3013 # $Id: urlfilter.cgi,v 1.7 2006/05/08 00:00:00 marco Exp $
3018 # enable only the following on debugging purpose
3020 #use CGI::Carp 'fatalsToBrowser';
3025 require '/var/ipfire/general-functions.pl' ;
3026 require "${General::swroot}/lang.pl" ;
3027 require "${General::swroot}/header.pl" ;
3030 my %mainsettings =();
3031 my %proxysettings =();
3032 my %filtersettings =();
3036 my %updatesettings =();
3051 my $tcfile = "${General::swroot}/urlfilter/timeconst" ;
3052 my $uqfile = "${General::swroot}/urlfilter/userquota" ;
3053 my $dbdir = "${General::swroot}/urlfilter/blacklists" ;
3054 my $editdir = "${General::swroot}/urlfilter/editor" ;
3055 my $repository = "/home/httpd/html/repository" ;
3056 my $hintcolour = '#FFFFCC' ;
3058 my $sourceurlfile = "${General::swroot}/urlfilter/autoupdate/autoupdate.urls" ;
3059 my $updconffile = "${General::swroot}/urlfilter/autoupdate/autoupdate.conf" ;
3060 my $updflagfile = "${General::swroot}/urlfilter/blacklists/.autoupdate.last" ;
3061 my $upd_cron_dly = "${General::swroot}/urlfilter/autoupdate/cron.daily" ;
3062 my $upd_cron_wly = "${General::swroot}/urlfilter/autoupdate/cron.weekly" ;
3063 my $upd_cron_mly = "${General::swroot}/urlfilter/autoupdate/cron.monthly" ;
3065 my $errormessage = '' ;
3066 my $updatemessage = '' ;
3067 my $restoremessage = '' ;
3073 my @repositorylist =();
3074 my @repositoryfiles =();
3076 my @selectedcategories =();
3077 my @filtergroups =();
3080 my @source_urllist =();
3091 if (! - d
$dbdir ) { mkdir ( " $dbdir " ); }
3092 if (! - e
$tcfile ) { system ( "touch $tcfile " ); }
3093 if (! - e
$uqfile ) { system ( "touch $uqfile " ); }
3094 if (! - e
$sourceurlfile ) { system ( "touch $sourceurlfile " ); }
3096 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%netsettings );
3097 & General
:: readhash
( "${General::swroot}/main/settings" , \
%mainsettings );
3098 & General
:: readhash
( "${General::swroot}/proxy/settings" , \
%proxysettings );
3100 & readblockcategories
;
3102 open ( FILE
, $tcfile );
3105 open ( FILE
, $uqfile );
3108 open ( FILE
, $sourceurlfile );
3109 @source_urllist = < FILE
>;
3112 $filtersettings { 'ENABLE_CUSTOM_BLACKLIST' } = 'off' ;
3113 $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } = 'off' ;
3114 $filtersettings { 'ENABLE_CUSTOM_EXPRESSIONS' } = 'off' ;
3115 $filtersettings { 'BLOCK_EXECUTABLES' } = 'off' ;
3116 $filtersettings { 'BLOCK_AUDIO-VIDEO' } = 'off' ;
3117 $filtersettings { 'BLOCK_ARCHIVES' } = 'off' ;
3118 $filtersettings { 'ENABLE_REWRITE' } = 'off' ;
3119 $filtersettings { 'UNFILTERED_CLIENTS' } = '' ;
3120 $filtersettings { 'BANNED_CLIENTS' } = '' ;
3121 $filtersettings { 'SHOW_CATEGORY' } = 'off' ;
3122 $filtersettings { 'SHOW_URL' } = 'off' ;
3123 $filtersettings { 'SHOW_IP' } = 'off' ;
3124 $filtersettings { 'ENABLE_DNSERROR' } = 'off' ;
3125 $filtersettings { 'ENABLE_JPEG' } = 'off' ;
3126 $filtersettings { 'REDIRECT_PAGE' } = '' ;
3127 $filtersettings { 'MSG_TEXT_1' } = '' ;
3128 $filtersettings { 'MSG_TEXT_2' } = '' ;
3129 $filtersettings { 'MSG_TEXT_3' } = '' ;
3130 $filtersettings { 'ENABLE_EXPR_LISTS' } = 'off' ;
3131 $filtersettings { 'BLOCK_IP_ADDR' } = 'off' ;
3132 $filtersettings { 'BLOCK_ALL' } = 'off' ;
3133 $filtersettings { 'ENABLE_EMPTY_ADS' } = 'off' ;
3134 $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } = 'off' ;
3135 $filtersettings { 'ENABLE_SAFESEARCH' } = 'off' ;
3136 $filtersettings { 'ENABLE_LOG' } = 'off' ;
3137 $filtersettings { 'ENABLE_USERNAME_LOG' } = 'off' ;
3138 $filtersettings { 'ENABLE_CATEGORY_LOG' } = 'off' ;
3139 $filtersettings { 'CHILDREN' } = '5' ;
3140 $filtersettings { 'ENABLE_AUTOUPDATE' } = 'off' ;
3142 $filtersettings { 'ACTION' } = '' ;
3143 $filtersettings { 'VALID' } = '' ;
3145 & Header
:: getcgihash
( \
%filtersettings );
3146 & Header
:: getcgihash
( \
%tcsettings );
3147 & Header
:: getcgihash
( \
%uqsettings );
3148 & Header
:: getcgihash
( \
%besettings );
3150 if (( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'save' }) ||
3151 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter save and restart' }) ||
3152 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload file' }) ||
3153 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter remove file' }) ||
3154 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload background' }) ||
3155 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload blacklist' }) ||
3156 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter backup' }) ||
3157 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter restore' }))
3159 if (!( $filtersettings { 'CHILDREN' } =~ /^\d+$/ ) || ( $filtersettings { 'CHILDREN' } < 1 ))
3161 $errormessage = $Lang :: tr
{ 'urlfilter invalid num of children' };
3165 if ((!( $filtersettings { 'REDIRECT_PAGE' } eq '' )) && (!( $filtersettings { 'REDIRECT_PAGE' } =~ /^https?:\/ \
// )))
3167 $filtersettings { 'REDIRECT_PAGE' } = "http://" . $filtersettings { 'REDIRECT_PAGE' };
3170 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter remove file' })
3172 if (- e
" $repository / $filtersettings {'ID'}" ) { unlink ( " $repository / $filtersettings {'ID'}" ); }
3173 $filtersettings { 'ACTION' } = $Lang :: tr
{ 'urlfilter manage repository' };
3176 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload file' })
3178 & Header
:: getcgihash
( \
%filtersettings , { 'wantfile' => 1 , 'filevar' => 'UPLOADFILE' });
3180 $filtersettings { 'ACTION' } = $Lang :: tr
{ 'urlfilter manage repository' };
3181 $_ = $filtersettings { 'UPLOADFILE' };
3183 $_ = substr ( $_ , rindex ( $_ , "/" )+ 1 );
3185 if ( copy
( $filtersettings { 'UPLOADFILE' }, " $repository / $_ " ) != 1 )
3194 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload background' })
3196 & Header
:: getcgihash
( \
%filtersettings , { 'wantfile' => 1 , 'filevar' => 'BACKGROUND' });
3198 if ( copy
( $filtersettings { 'BACKGROUND' }, "/home/httpd/html/images/urlfilter/background.jpg" ) != 1 )
3205 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload blacklist' })
3207 & Header
:: getcgihash
( \
%filtersettings , { 'wantfile' => 1 , 'filevar' => 'UPDATEFILE' });
3209 if (!( $filtersettings { 'UPDATEFILE' } =~ /.tar.gz$/ ))
3211 $errormessage = $Lang :: tr
{ 'urlfilter wrong filetype' };
3215 if ( copy
( $filtersettings { 'UPDATEFILE' }, "${General::swroot}/urlfilter/blacklists.tar.gz" ) != 1 )
3221 if (!(- d
"${General::swroot}/urlfilter/update" )) { mkdir ( "${General::swroot}/urlfilter/update" ); }
3223 my $exitcode = system ( "/bin/tar --no-same-owner -xzf ${General::swroot}/urlfilter/blacklists.tar.gz -C ${General::swroot}/urlfilter/update" );
3227 $errormessage = $Lang :: tr
{ 'urlfilter tar error' };
3230 if (- d
"${General::swroot}/urlfilter/update/category" )
3232 system ( "mv ${General::swroot}/urlfilter/update/category ${General::swroot}/urlfilter/update/blacklists" );
3235 if (!(- d
"${General::swroot}/urlfilter/update/blacklists" ))
3237 $errormessage = $Lang :: tr
{ 'urlfilter invalid content' };
3239 system ( "cp -r ${General::swroot}/urlfilter/update/blacklists/* $dbdir " );
3241 & readblockcategories
;
3246 $updatemessage = $Lang :: tr
{ 'urlfilter upload success' };
3247 system ( "${General::swroot}/urlfilter/bin/prebuild.pl &" );
3248 system ( "logger -t installpackage[urlfilter] \" URL filter blacklist - Blacklist update from local source completed \" " );
3251 if (- d
"${General::swroot}/urlfilter/update" ) { system ( "rm -rf ${General::swroot}/urlfilter/update" ); }
3252 if (- e
"${General::swroot}/urlfilter/blacklists.tar.gz" ) { unlink ( "${General::swroot}/urlfilter/blacklists.tar.gz" ); }
3253 if ( $errormessage ) { goto ERROR
; }
3256 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter backup' })
3258 $blistbackup = ( $filtersettings { 'ENABLE_FULLBACKUP' } eq 'on' ) ?
"blacklists" : "blacklists/custom" ;
3259 if ( system ( "/bin/tar -C ${General::swroot}/urlfilter -czf ${General::swroot}/urlfilter/backup.tar.gz settings timeconst userquota autoupdate $blistbackup " ))
3261 $errormessage = $Lang :: tr
{ 'urlfilter backup error' };
3266 print "Content-type: application/gzip \n " ;
3267 print "Content-length: " ;
3268 print (- s
"${General::swroot}/urlfilter/backup.tar.gz" );
3270 print "Content-disposition: attachment; filename=urlfilter-backup.tar.gz \n\n " ;
3272 open ( FILE
, "${General::swroot}/urlfilter/backup.tar.gz" );
3273 while (< FILE
>) { print ; }
3276 if (- e
"${General::swroot}/urlfilter/backup.tar.gz" ) { unlink ( "${General::swroot}/urlfilter/backup.tar.gz" ); }
3281 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter restore' })
3283 & Header
:: getcgihash
( \
%filtersettings , { 'wantfile' => 1 , 'filevar' => 'UPDATEFILE' });
3285 if (!( $filtersettings { 'UPDATEFILE' } =~ /.tar.gz$/ ))
3287 $errormessage = $Lang :: tr
{ 'urlfilter wrong filetype' };
3291 if (!(- d
"${General::swroot}/urlfilter/restore" )) { mkdir ( "${General::swroot}/urlfilter/restore" ); }
3293 if ( copy
( $filtersettings { 'UPDATEFILE' }, "${General::swroot}/urlfilter/backup.tar.gz" ) != 1 )
3298 my $exitcode = system ( "/bin/tar --no-same-owner --preserve-permissions -xzf ${General::swroot}/urlfilter/backup.tar.gz -C ${General::swroot}/urlfilter/restore" );
3301 $errormessage = $Lang :: tr
{ 'urlfilter tar error' };
3303 if (!(- e
"${General::swroot}/urlfilter/restore/settings" ))
3305 $errormessage = $Lang :: tr
{ 'urlfilter invalid restore file' };
3307 system ( "cp -rp ${General::swroot}/urlfilter/restore/* ${General::swroot}/urlfilter/" );
3308 & readblockcategories
;
3312 $restoremessage = $Lang :: tr
{ 'urlfilter restore success' };
3316 if (- e
"${General::swroot}/urlfilter/backup.tar.gz" ) { unlink ( "${General::swroot}/urlfilter/backup.tar.gz" ); }
3317 if (- d
"${General::swroot}/urlfilter/restore" ) { system ( "rm -rf ${General::swroot}/urlfilter/restore" ); }
3318 if ( $errormessage ) { goto ERROR
; }
3321 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'save' })
3323 $filtersettings { 'VALID' } = 'yes' ;
3327 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter save and restart' })
3329 if (!(- e
"${General::swroot}/proxy/enable" ))
3331 $errormessage = $Lang :: tr
{ 'urlfilter web proxy service required' };
3334 if (!( $proxysettings { 'ENABLE_FILTER' } eq 'on' ))
3336 $errormessage = $Lang :: tr
{ 'urlfilter not enabled' };
3340 $filtersettings { 'VALID' } = 'yes' ;
3343 system ( "chown -R nobody.nobody $dbdir " );
3345 if (- e
" $dbdir /custom/allowed/domains.db" ) { unlink ( " $dbdir /custom/allowed/domains.db" ); }
3346 if (- e
" $dbdir /custom/allowed/urls.db" ) { unlink ( " $dbdir /custom/allowed/urls.db" ); }
3347 if (- e
" $dbdir /custom/blocked/domains.db" ) { unlink ( " $dbdir /custom/blocked/domains.db" ); }
3348 if (- e
" $dbdir /custom/blocked/urls.db" ) { unlink ( " $dbdir /custom/blocked/urls.db" ); }
3350 foreach (< $dbdir /*>)
3352 if (- d
$_ ){ system ( "chmod 644 $_ /*" ); }
3353 if (- d
$_ ){ system ( "chmod 666 $_ /*.db" ); }
3355 if (- d
" $dbdir /custom/allowed" )
3357 system ( "chmod 755 $dbdir /custom/allowed" );
3358 system ( "chmod 644 $dbdir /custom/allowed/*" );
3360 if (- d
" $dbdir /custom/blocked" )
3362 system ( "chmod 755 $dbdir /custom/blocked" );
3363 system ( "chmod 644 $dbdir /custom/blocked/*" );
3366 system ( '/usr/local/bin/restartsquid' );
3371 if ( $errormessage ) { $filtersettings { 'VALID' } = 'no' ; }
3375 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter set time constraints' }) { $tcsettings { 'TCMODE' } = 'on' }
3377 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'add' }))
3379 $tcsettings { 'TCMODE' }= 'on' ;
3381 if (! $tcsettings { 'DST' })
3383 $errormessage = $Lang :: tr
{ 'urlfilter dst error' };
3386 if (! $tcsettings { 'SRC' })
3388 $errormessage = $Lang :: tr
{ 'urlfilter src error' };
3391 if (!( $tcsettings { 'TO_HOUR' }. $tcsettings { 'TO_MINUTE' } gt $tcsettings { 'FROM_HOUR' }. $tcsettings { 'FROM_MINUTE' }))
3393 $errormessage = $Lang :: tr
{ 'urlfilter timespace error' };
3396 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' )))
3398 $errormessage = $Lang :: tr
{ 'urlfilter weekday error' };
3403 if ( $tcsettings { 'DST' } =~ /^any/ ) { $tcsettings { 'DST' } = 'any' ; }
3404 if ( $tcsettings { 'ENABLERULE' } eq 'on' ) { $tcsettings { 'ACTIVE' } = $tcsettings { 'ENABLERULE' }; } else { $tcsettings { 'ACTIVE' } = 'off' }
3406 $tcsettings { 'ENABLERULE' } = 'on' ;
3407 if ( $tcsettings { 'EDITING' } eq 'no' ) {
3408 open ( FILE
, ">> $tcfile " );
3410 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 " ;
3412 open ( FILE
, "> $tcfile " );
3415 foreach $line ( @tclist )
3418 if ( $tcsettings { 'EDITING' } eq $id ) {
3419 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 " ;
3420 } else { print FILE
" $line " ; }
3425 $tcsettings { 'CHANGED' }= 'yes' ;
3426 $tcsettings { 'TCMODE' }= 'on' ;
3429 if ( $tcsettings { 'EDITING' } ne 'no' )
3431 $tcsettings { 'ACTION' } = $Lang :: tr
{ 'edit' };
3432 $tcsettings { 'ID' } = $tcsettings { 'EDITING' };
3437 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'remove' }))
3440 open ( FILE
, "> $tcfile " );
3442 foreach $line ( @tclist )
3445 unless ( $tcsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
3448 $tcsettings { 'CHANGED' }= 'yes' ;
3449 $tcsettings { 'TCMODE' }= 'on' ;
3452 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter restart' }))
3454 if (!( $proxysettings { 'ENABLE_FILTER' } eq 'on' ))
3456 $errormessage = $Lang :: tr
{ 'urlfilter not enabled' };
3458 if (!(- e
"${General::swroot}/proxy/enable" ))
3460 $errormessage = $Lang :: tr
{ 'urlfilter web proxy service required' };
3463 if (! $errormessage ) { system ( '/usr/local/bin/restartsquid' ); }
3464 $tcsettings { 'TCMODE' }= 'on' ;
3467 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }))
3469 open ( FILE
, "> $tcfile " );
3472 foreach $line ( @tclist )
3475 unless ( $tcsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
3479 @temp = split ( /\,/ , $line );
3480 if ( $temp [ 15 ] eq 'on' ) { $temp [ 15 ] = 'off' ; } else { $temp [ 15 ] = 'on' }
3481 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 " ;
3485 $tcsettings { 'CHANGED' }= 'yes' ;
3486 $tcsettings { 'TCMODE' }= 'on' ;
3489 if (! $errormessage ) {
3490 $tcsettings { 'ENABLERULE' }= 'on' ;
3491 $tcsettings { 'TO_HOUR' }= '24' ;
3494 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) && (! $errormessage ))
3497 foreach $line ( @tclist )
3500 if ( $tcsettings { 'ID' } eq $id )
3503 @temp = split ( /\,/ , $line );
3504 $tcsettings { 'DEFINITION' } = $temp [ 0 ];
3505 $tcsettings { 'MON' } = $temp [ 1 ];
3506 $tcsettings { 'TUE' } = $temp [ 2 ];
3507 $tcsettings { 'WED' } = $temp [ 3 ];
3508 $tcsettings { 'THU' } = $temp [ 4 ];
3509 $tcsettings { 'FRI' } = $temp [ 5 ];
3510 $tcsettings { 'SAT' } = $temp [ 6 ];
3511 $tcsettings { 'SUN' } = $temp [ 7 ];
3512 $tcsettings { 'FROM_HOUR' } = $temp [ 8 ];
3513 $tcsettings { 'FROM_MINUTE' } = $temp [ 9 ];
3514 $tcsettings { 'TO_HOUR' } = $temp [ 10 ];
3515 $tcsettings { 'TO_MINUTE' } = $temp [ 11 ];
3516 $tcsettings { 'SRC' } = $temp [ 12 ];
3517 $tcsettings { 'DST' } = $temp [ 13 ];
3518 $tcsettings { 'ACCESS' } = $temp [ 14 ];
3519 $tcsettings { 'ENABLERULE' } = $temp [ 15 ];
3520 $tcsettings { 'COMMENT' } = $temp [ 16 ];
3523 $tcsettings { 'TCMODE' }= 'on' ;
3526 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter set user quota' }) { $uqsettings { 'UQMODE' } = 'on' }
3528 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'add' }))
3530 $uqsettings { 'UQMODE' }= 'on' ;
3532 if ((!( $uqsettings { 'TIME_QUOTA' } =~ /^\d+/ )) || ( $uqsettings { 'TIME_QUOTA' } < '1' ))
3534 $errormessage = $Lang :: tr
{ 'urlfilter quota time error' };
3537 @temp = split ( /\n/ , $uqsettings { 'QUOTA_USERS' });
3538 undef $uqsettings { 'QUOTA_USERS' };
3541 s/^\s+//g ; s/\s+$//g ;
3542 if ( $_ ) { $uqsettings { 'QUOTA_USERS' } .= $_ . " \n " ; }
3545 if ( $uqsettings { 'QUOTA_USERS' } eq '' )
3547 $errormessage = $Lang :: tr
{ 'urlfilter quota user error' };
3550 $_ = $uqsettings { 'QUOTA_USERS' };
3552 my $quota_users = $_ ;
3554 if ( $uqsettings { 'QUOTA_USERS' } =~ /\\/ )
3556 $errormessage = $Lang :: tr
{ 'urlfilter invalid user error' };
3559 if (! $errormessage ) {
3560 if ( $uqsettings { 'ENABLEQUOTA' } eq 'on' ) { $uqsettings { 'ACTIVE' } = $uqsettings { 'ENABLEQUOTA' }; } else { $uqsettings { 'ACTIVE' } = 'off' }
3562 $uqsettings { 'ENABLERULE' } = 'on' ;
3563 if ( $uqsettings { 'EDITING' } eq 'no' ) {
3564 open ( FILE
, ">> $uqfile " );
3566 print FILE
" $uqsettings {'TIME_QUOTA'}, $uqsettings {'SPORADIC'}, $uqsettings {'RENEWAL'}, $quota_users , $uqsettings {'ACTIVE'} \n " ;
3568 open ( FILE
, "> $uqfile " );
3571 foreach $line ( @uqlist )
3574 if ( $uqsettings { 'EDITING' } eq $id ) {
3575 print FILE
" $uqsettings {'TIME_QUOTA'}, $uqsettings {'SPORADIC'}, $uqsettings {'RENEWAL'}, $quota_users , $uqsettings {'ACTIVE'} \n " ;
3576 } else { print FILE
" $line " ; }
3581 $uqsettings { 'CHANGED' }= 'yes' ;
3582 $uqsettings { 'MODE' }= 'USERQUOTA' ;
3583 $uqsettings { 'UQMODE' }= 'on' ;
3586 if ( $uqsettings { 'EDITING' } ne 'no' )
3588 $uqsettings { 'ACTION' } = $Lang :: tr
{ 'edit' };
3589 $uqsettings { 'ID' } = $uqsettings { 'EDITING' };
3594 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'remove' }))
3597 open ( FILE
, "> $uqfile " );
3599 foreach $line ( @uqlist )
3602 unless ( $uqsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
3605 $uqsettings { 'CHANGED' }= 'yes' ;
3606 $uqsettings { 'UQMODE' }= 'on' ;
3609 if (! $errormessage ) {
3610 $uqsettings { 'ENABLEQUOTA' }= 'on' ;
3613 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) && (! $errormessage ))
3616 foreach $line ( @uqlist )
3619 if ( $uqsettings { 'ID' } eq $id )
3622 @temp = split ( /\,/ , $line );
3623 $uqsettings { 'TIME_QUOTA' } = $temp [ 0 ];
3624 $uqsettings { 'SPORADIC' } = $temp [ 1 ];
3625 $uqsettings { 'RENEWAL' } = $temp [ 2 ];
3626 $uqsettings { 'QUOTA_USERS' } = $temp [ 3 ];
3627 $uqsettings { 'ENABLEQUOTA' } = $temp [ 4 ];
3630 $uqsettings { 'UQMODE' }= 'on' ;
3633 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }))
3635 open ( FILE
, "> $uqfile " );
3638 foreach $line ( @uqlist )
3641 unless ( $uqsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
3645 @temp = split ( /\,/ , $line );
3646 if ( $temp [ 4 ] eq 'on' ) { $temp [ 4 ] = 'off' ; } else { $temp [ 4 ] = 'on' }
3647 print FILE
" $temp [0], $temp [1], $temp [2], $temp [3], $temp [4] \n " ;
3651 $uqsettings { 'CHANGED' }= 'yes' ;
3652 $uqsettings { 'UQMODE' }= 'on' ;
3655 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter restart' }))
3657 if (!( $proxysettings { 'ENABLE_FILTER' } eq 'on' ))
3659 $errormessage = $Lang :: tr
{ 'urlfilter not enabled' };
3661 if (!(- e
"${General::swroot}/proxy/enable" ))
3663 $errormessage = $Lang :: tr
{ 'urlfilter web proxy service required' };
3666 if (! $errormessage ) { system ( '/usr/local/bin/restartsquid' ); }
3667 $uqsettings { 'UQMODE' }= 'on' ;
3670 if ( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter blacklist editor' }) { $besettings { 'BEMODE' } = 'on' ; }
3672 if ( $besettings { 'MODE' } eq 'BLACKLIST_EDITOR' )
3674 @temp = split ( /\n/ , $besettings { 'BE_DOMAINS' });
3675 undef $besettings { 'BE_DOMAINS' };
3678 s/^\s+//g ; s/\s+$//g ;
3679 if ( $_ ) { $besettings { 'BE_DOMAINS' } .= $_ . " \n " ; }
3681 chomp ( $besettings { 'BE_DOMAINS' });
3682 @temp = split ( /\n/ , $besettings { 'BE_URLS' });
3683 undef $besettings { 'BE_URLS' };
3686 s/^\s+//g ; s/\s+$//g ;
3687 if ( $_ ) { $besettings { 'BE_URLS' } .= $_ . " \n " ; }
3689 chomp ( $besettings { 'BE_URLS' });
3690 @temp = split ( /\n/ , $besettings { 'BE_EXPRESSIONS' });
3691 undef $besettings { 'BE_EXPRESSIONS' };
3694 s/^\s+//g ; s/\s+$//g ;
3695 if ( $_ ) { $besettings { 'BE_EXPRESSIONS' } .= $_ . " \n " ; }
3697 chomp ( $besettings { 'BE_EXPRESSIONS' });
3700 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter load blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
3702 $besettings { 'BEMODE' } = 'on' ;
3704 $besettings { 'BE_NAME' } = $besettings { 'BE_BLACKLIST' };
3706 delete $besettings { 'BE_DOMAINS' };
3707 delete $besettings { 'BE_URLS' };
3708 delete $besettings { 'BE_EXPRESSIONS' };
3710 if (- e
" $dbdir / $besettings {'BE_NAME'}/domains" )
3712 open ( FILE
, " $dbdir / $besettings {'BE_NAME'}/domains" );
3713 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_DOMAINS' } .= $_ } };
3715 chomp ( $besettings { 'BE_DOMAINS' });
3717 if (- e
" $dbdir / $besettings {'BE_NAME'}/urls" )
3719 open ( FILE
, " $dbdir / $besettings {'BE_NAME'}/urls" );
3720 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_URLS' } .= $_ } };
3722 chomp ( $besettings { 'BE_URLS' });
3724 if (- e
" $dbdir / $besettings {'BE_NAME'}/expressions" )
3726 open ( FILE
, " $dbdir / $besettings {'BE_NAME'}/expressions" );
3727 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_EXPRESSIONS' } .= $_ } };
3729 chomp ( $besettings { 'BE_EXPRESSIONS' });
3733 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter import blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
3735 $besettings { 'BEMODE' } = 'on' ;
3737 & Header
:: getcgihash
( \
%besettings , { 'wantfile' => 1 , 'filevar' => 'IMPORTFILE' });
3739 if (!( $besettings { 'IMPORTFILE' } =~ /.tar.gz$/ ))
3741 $errormessage = $Lang :: tr
{ 'urlfilter wrong filetype' };
3743 if (!- d
" $editdir " ) { mkdir ( " $editdir " ); }
3745 if ( copy
( $besettings { 'IMPORTFILE' }, " $editdir /blacklist.tar.gz" ) != 1 )
3750 my $exitcode = system ( "/bin/tar --no-same-owner --preserve-permissions -xzf $editdir /blacklist.tar.gz -C $editdir " );
3753 $errormessage = $Lang :: tr
{ 'urlfilter tar error' };
3756 foreach (< $editdir /blacklists/ *>)
3761 $besettings { 'BE_NAME' } = substr ( $_ , rindex ( $_ , "/" )+ 1 );
3767 $errormessage = $Lang :: tr
{ 'urlfilter invalid import file' };
3769 delete $besettings { 'BE_DOMAINS' };
3770 delete $besettings { 'BE_URLS' };
3771 delete $besettings { 'BE_EXPRESSIONS' };
3773 if (- e
" $editdir /blacklists/ $besettings {'BE_NAME'}/domains" )
3775 open ( FILE
, " $editdir /blacklists/ $besettings {'BE_NAME'}/domains" );
3776 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_DOMAINS' } .= $_ } };
3778 chomp ( $besettings { 'BE_DOMAINS' });
3780 if (- e
" $editdir /blacklists/ $besettings {'BE_NAME'}/urls" )
3782 open ( FILE
, " $editdir /blacklists/ $besettings {'BE_NAME'}/urls" );
3783 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_URLS' } .= $_ } };
3785 chomp ( $besettings { 'BE_URLS' });
3787 if (- e
" $editdir /blacklists/ $besettings {'BE_NAME'}/expressions" )
3789 open ( FILE
, " $editdir /blacklists/ $besettings {'BE_NAME'}/expressions" );
3790 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_EXPRESSIONS' } .= $_ } };
3792 chomp ( $besettings { 'BE_EXPRESSIONS' });
3797 if (- d
$editdir ) { system ( "rm -rf $editdir " ); }
3803 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter export blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
3805 $besettings { 'BEMODE' } = 'on' ;
3807 if ( $besettings { 'BE_NAME' } eq '' )
3809 $errormessage = $Lang :: tr
{ 'urlfilter category name error' };
3810 } elsif ( $besettings { 'BE_DOMAINS' } || $besettings { 'BE_URLS' } || $besettings { 'BE_EXPRESSIONS' }) {
3812 $_ = $besettings { 'BE_NAME' }; tr/A-Z/a-z/ ; $besettings { 'BE_NAME' } = $_ ;
3814 if (!(- d
" $editdir " )) { mkdir ( " $editdir " ); }
3815 if (!(- d
" $editdir /blacklists" )) { mkdir ( " $editdir /blacklists" ); }
3816 if (!(- d
" $editdir /blacklists/ $besettings {'BE_NAME'}" )) { mkdir ( " $editdir /blacklists/ $besettings {'BE_NAME'}" ); }
3818 open ( FILE
, "> $editdir /blacklists/ $besettings {'BE_NAME'}/domains" );
3820 print FILE
" $besettings {'BE_DOMAINS'} \n " ;
3822 open ( FILE
, "> $editdir /blacklists/ $besettings {'BE_NAME'}/urls" );
3824 print FILE
" $besettings {'BE_URLS'} \n " ;
3826 open ( FILE
, "> $editdir /blacklists/ $besettings {'BE_NAME'}/expressions" );
3828 print FILE
" $besettings {'BE_EXPRESSIONS'} \n " ;
3831 if ( system ( "/bin/tar -C $editdir -czf $editdir / $besettings {'BE_NAME'}.tar.gz blacklists" ))
3833 $errormessage = $Lang :: tr
{ 'urlfilter export error' };
3837 print "Content-type: application/gzip \n " ;
3838 print "Content-length: " ;
3839 print (- s
" $editdir / $besettings {'BE_NAME'}.tar.gz" );
3841 print "Content-disposition: attachment; filename= $besettings {'BE_NAME'}.tar.gz \n\n " ;
3843 open ( FILE
, " $editdir / $besettings {'BE_NAME'}.tar.gz" );
3844 while (< FILE
>) { print ; }
3847 if (- d
$editdir ) { system ( "rm -rf $editdir " ); }
3851 $errormessage = $Lang :: tr
{ 'urlfilter category data error' };
3855 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter install blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
3857 $besettings { 'BEMODE' } = 'on' ;
3859 if ( $besettings { 'BE_NAME' } eq '' )
3861 $errormessage = $Lang :: tr
{ 'urlfilter category name error' };
3862 } elsif ( $besettings { 'BE_DOMAINS' } || $besettings { 'BE_URLS' } || $besettings { 'BE_EXPRESSIONS' }) {
3864 $_ = $besettings { 'BE_NAME' }; tr/A-Z/a-z/ ; $besettings { 'BE_NAME' } = $_ ;
3866 if (!- d
" $editdir " ) { mkdir ( " $editdir " ); }
3868 if (!- d
" $dbdir / $besettings {'BE_NAME'}" ) { mkdir ( " $dbdir / $besettings {'BE_NAME'}" ); }
3870 if (- e
" $dbdir / $besettings {'BE_NAME'}/domains" ) { unlink ( " $dbdir / $besettings {'BE_NAME'}/domains" ); }
3871 if ( $besettings { 'BE_DOMAINS' })
3873 open ( FILE
, "> $dbdir / $besettings {'BE_NAME'}/domains" );
3875 print FILE
" $besettings {'BE_DOMAINS'} \n " ;
3878 if (- e
" $dbdir / $besettings {'BE_NAME'}/urls" ) { unlink ( " $dbdir / $besettings {'BE_NAME'}/urls" ); }
3879 if ( $besettings { 'BE_URLS' })
3881 open ( FILE
, "> $dbdir / $besettings {'BE_NAME'}/urls" );
3883 print FILE
" $besettings {'BE_URLS'} \n " ;
3886 if (- e
" $dbdir / $besettings {'BE_NAME'}/expressions" ) { unlink ( " $dbdir / $besettings {'BE_NAME'}/expressions" ); }
3887 if ( $besettings { 'BE_EXPRESSIONS' })
3889 open ( FILE
, "> $dbdir / $besettings {'BE_NAME'}/expressions" );
3891 print FILE
" $besettings {'BE_EXPRESSIONS'} \n " ;
3895 open ( FILE
, "> $editdir /install.conf" );
3897 print FILE
"logdir /var/log/squidGuard \n " ;
3898 print FILE
"dbhome $dbdir / $besettings {'BE_NAME'} \n\n " ;
3899 print FILE
"dest $besettings {'BE_NAME'} { \n " ;
3900 if ( $besettings { 'BE_DOMAINS' }) { print FILE
" domainlist domains \n " ; }
3901 if ( $besettings { 'BE_URLS' }) { print FILE
" urllist urls \n " ; }
3902 if ( $besettings { 'BE_EXPRESSIONS' }) { print FILE
" expressions expressions \n " ; }
3904 print FILE
"acl { \n " ;
3905 print FILE
" default { \n " ;
3906 print FILE
" pass none \n " ;
3911 system ( "rm -f $dbdir / $besettings {'BE_NAME'}/*.db" );
3912 system ( "/usr/sbin/squidGuard -c $editdir /install.conf -C all" );
3913 system ( "chmod a+w $dbdir / $besettings {'BE_NAME'}/*.db" );
3915 & readblockcategories
;
3920 system ( '/usr/local/bin/restartsquid' ) unless ( $besettings { 'NORESTART' } eq 'on' );
3922 if (- d
$editdir ) { system ( "rm -rf $editdir " ); }
3924 $errormessage = $Lang :: tr
{ 'urlfilter category data error' };
3928 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter save schedule' })
3930 if (( $filtersettings { 'UPDATE_SOURCE' } eq 'custom' ) && ( $filtersettings { 'CUSTOM_UPDATE_URL' } eq '' ))
3932 $errormessage = $Lang :: tr
{ 'urlfilter custom url required' };
3934 open ( FILE
, "> $updconffile " );
3935 print FILE
"ENABLE_AUTOUPDATE= $filtersettings {'ENABLE_AUTOUPDATE'} \n " ;
3936 print FILE
"UPDATE_SCHEDULE= $filtersettings {'UPDATE_SCHEDULE'} \n " ;
3937 print FILE
"UPDATE_SOURCE= $filtersettings {'UPDATE_SOURCE'} \n " ;
3938 print FILE
"CUSTOM_UPDATE_URL= $filtersettings {'CUSTOM_UPDATE_URL'} \n " ;
3941 if (- e
$upd_cron_dly ) { unlink ( $upd_cron_dly ); }
3942 if (- e
$upd_cron_wly ) { unlink ( $upd_cron_wly ); }
3943 if (- e
$upd_cron_mly ) { unlink ( $upd_cron_mly ); }
3945 if (( $filtersettings { 'ENABLE_AUTOUPDATE' } eq 'on' ) && ( $filtersettings { 'UPDATE_SCHEDULE' } eq 'daily' ))
3947 symlink ( "../bin/autoupdate.pl" , $upd_cron_dly )
3949 symlink ( "/bin/false" , $upd_cron_dly )
3952 if (( $filtersettings { 'ENABLE_AUTOUPDATE' } eq 'on' ) && ( $filtersettings { 'UPDATE_SCHEDULE' } eq 'weekly' ))
3954 symlink ( "../bin/autoupdate.pl" , $upd_cron_wly )
3956 symlink ( "/bin/false" , $upd_cron_wly )
3959 if (( $filtersettings { 'ENABLE_AUTOUPDATE' } eq 'on' ) && ( $filtersettings { 'UPDATE_SCHEDULE' } eq 'monthly' ))
3961 symlink ( "../bin/autoupdate.pl" , $upd_cron_mly )
3963 symlink ( "/bin/false" , $upd_cron_mly )
3968 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter update now' })
3970 if ( $filtersettings { 'UPDATE_SOURCE' } eq 'custom' )
3972 if ( $filtersettings { 'CUSTOM_UPDATE_URL' } eq '' )
3974 $errormessage = $Lang :: tr
{ 'urlfilter custom url required' };
3976 system ( "${General::swroot}/urlfilter/bin/autoupdate.pl $filtersettings {'CUSTOM_UPDATE_URL'} &" );
3979 system ( "${General::swroot}/urlfilter/bin/autoupdate.pl $filtersettings {'UPDATE_SOURCE'} &" );
3984 if (- e
"${General::swroot}/urlfilter/settings" ) { & General
:: readhash
( "${General::swroot}/urlfilter/settings" , \
%filtersettings ); }
3988 $checked { 'ENABLE_CUSTOM_BLACKLIST' }{ 'off' } = '' ;
3989 $checked { 'ENABLE_CUSTOM_BLACKLIST' }{ 'on' } = '' ;
3990 $checked { 'ENABLE_CUSTOM_BLACKLIST' }{ $filtersettings { 'ENABLE_CUSTOM_BLACKLIST' }} = "checked='checked'" ;
3991 $checked { 'ENABLE_CUSTOM_WHITELIST' }{ 'off' } = '' ;
3992 $checked { 'ENABLE_CUSTOM_WHITELIST' }{ 'on' } = '' ;
3993 $checked { 'ENABLE_CUSTOM_WHITELIST' }{ $filtersettings { 'ENABLE_CUSTOM_WHITELIST' }} = "checked='checked'" ;
3994 $checked { 'ENABLE_CUSTOM_EXPRESSIONS' }{ 'off' } = '' ;
3995 $checked { 'ENABLE_CUSTOM_EXPRESSIONS' }{ 'on' } = '' ;
3996 $checked { 'ENABLE_CUSTOM_EXPRESSIONS' }{ $filtersettings { 'ENABLE_CUSTOM_EXPRESSIONS' }} = "checked='checked'" ;
3997 $checked { 'BLOCK_EXECUTABLES' }{ 'off' } = '' ;
3998 $checked { 'BLOCK_EXECUTABLES' }{ 'on' } = '' ;
3999 $checked { 'BLOCK_EXECUTABLES' }{ $filtersettings { 'BLOCK_EXECUTABLES' }} = "checked='checked'" ;
4000 $checked { 'BLOCK_AUDIO-VIDEO' }{ 'off' } = '' ;
4001 $checked { 'BLOCK_AUDIO-VIDEO' }{ 'on' } = '' ;
4002 $checked { 'BLOCK_AUDIO-VIDEO' }{ $filtersettings { 'BLOCK_AUDIO-VIDEO' }} = "checked='checked'" ;
4003 $checked { 'BLOCK_ARCHIVES' }{ 'off' } = '' ;
4004 $checked { 'BLOCK_ARCHIVES' }{ 'on' } = '' ;
4005 $checked { 'BLOCK_ARCHIVES' }{ $filtersettings { 'BLOCK_ARCHIVES' }} = "checked='checked'" ;
4006 $checked { 'ENABLE_REWRITE' }{ 'off' } = '' ;
4007 $checked { 'ENABLE_REWRITE' }{ 'on' } = '' ;
4008 $checked { 'ENABLE_REWRITE' }{ $filtersettings { 'ENABLE_REWRITE' }} = "checked='checked'" ;
4009 $checked { 'SHOW_CATEGORY' }{ 'off' } = '' ;
4010 $checked { 'SHOW_CATEGORY' }{ 'on' } = '' ;
4011 $checked { 'SHOW_CATEGORY' }{ $filtersettings { 'SHOW_CATEGORY' }} = "checked='checked'" ;
4012 $checked { 'SHOW_URL' }{ 'off' } = '' ;
4013 $checked { 'SHOW_URL' }{ 'on' } = '' ;
4014 $checked { 'SHOW_URL' }{ $filtersettings { 'SHOW_URL' }} = "checked='checked'" ;
4015 $checked { 'SHOW_IP' }{ 'off' } = '' ;
4016 $checked { 'SHOW_IP' }{ 'on' } = '' ;
4017 $checked { 'SHOW_IP' }{ $filtersettings { 'SHOW_IP' }} = "checked='checked'" ;
4018 $checked { 'ENABLE_DNSERROR' }{ 'off' } = '' ;
4019 $checked { 'ENABLE_DNSERROR' }{ 'on' } = '' ;
4020 $checked { 'ENABLE_DNSERROR' }{ $filtersettings { 'ENABLE_DNSERROR' }} = "checked='checked'" ;
4021 $checked { 'ENABLE_JPEG' }{ 'off' } = '' ;
4022 $checked { 'ENABLE_JPEG' }{ 'on' } = '' ;
4023 $checked { 'ENABLE_JPEG' }{ $filtersettings { 'ENABLE_JPEG' }} = "checked='checked'" ;
4024 $checked { 'ENABLE_EXPR_LISTS' }{ 'off' } = '' ;
4025 $checked { 'ENABLE_EXPR_LISTS' }{ 'on' } = '' ;
4026 $checked { 'ENABLE_EXPR_LISTS' }{ $filtersettings { 'ENABLE_EXPR_LISTS' }} = "checked='checked'" ;
4027 $checked { 'BLOCK_IP_ADDR' }{ 'off' } = '' ;
4028 $checked { 'BLOCK_IP_ADDR' }{ 'on' } = '' ;
4029 $checked { 'BLOCK_IP_ADDR' }{ $filtersettings { 'BLOCK_IP_ADDR' }} = "checked='checked'" ;
4030 $checked { 'BLOCK_ALL' }{ 'off' } = '' ;
4031 $checked { 'BLOCK_ALL' }{ 'on' } = '' ;
4032 $checked { 'BLOCK_ALL' }{ $filtersettings { 'BLOCK_ALL' }} = "checked='checked'" ;
4033 $checked { 'ENABLE_EMPTY_ADS' }{ 'off' } = '' ;
4034 $checked { 'ENABLE_EMPTY_ADS' }{ 'on' } = '' ;
4035 $checked { 'ENABLE_EMPTY_ADS' }{ $filtersettings { 'ENABLE_EMPTY_ADS' }} = "checked='checked'" ;
4036 $checked { 'ENABLE_GLOBAL_WHITELIST' }{ 'off' } = '' ;
4037 $checked { 'ENABLE_GLOBAL_WHITELIST' }{ 'on' } = '' ;
4038 $checked { 'ENABLE_GLOBAL_WHITELIST' }{ $filtersettings { 'ENABLE_GLOBAL_WHITELIST' }} = "checked='checked'" ;
4039 $checked { 'ENABLE_SAFESEARCH' }{ 'off' } = '' ;
4040 $checked { 'ENABLE_SAFESEARCH' }{ 'on' } = '' ;
4041 $checked { 'ENABLE_SAFESEARCH' }{ $filtersettings { 'ENABLE_SAFESEARCH' }} = "checked='checked'" ;
4042 $checked { 'ENABLE_LOG' }{ 'off' } = '' ;
4043 $checked { 'ENABLE_LOG' }{ 'on' } = '' ;
4044 $checked { 'ENABLE_LOG' }{ $filtersettings { 'ENABLE_LOG' }} = "checked='checked'" ;
4045 $checked { 'ENABLE_USERNAME_LOG' }{ 'off' } = '' ;
4046 $checked { 'ENABLE_USERNAME_LOG' }{ 'on' } = '' ;
4047 $checked { 'ENABLE_USERNAME_LOG' }{ $filtersettings { 'ENABLE_USERNAME_LOG' }} = "checked='checked'" ;
4048 $checked { 'ENABLE_CATEGORY_LOG' }{ 'off' } = '' ;
4049 $checked { 'ENABLE_CATEGORY_LOG' }{ 'on' } = '' ;
4050 $checked { 'ENABLE_CATEGORY_LOG' }{ $filtersettings { 'ENABLE_CATEGORY_LOG' }} = "checked='checked'" ;
4052 foreach $category ( @filtergroups ) {
4053 $checked { $category }{ 'off' } = '' ;
4054 $checked { $category }{ 'on' } = '' ;
4055 $checked { $category }{ $filtersettings { $category }} = "checked='checked'" ;
4058 $selected { 'DEFINITION' }{ $tcsettings { 'DEFINITION' }} = "selected='selected'" ;
4059 $selected { 'FROM_HOUR' }{ $tcsettings { 'FROM_HOUR' }} = "selected='selected'" ;
4060 $selected { 'FROM_MINUTE' }{ $tcsettings { 'FROM_MINUTE' }} = "selected='selected'" ;
4061 $selected { 'TO_HOUR' }{ $tcsettings { 'TO_HOUR' }} = "selected='selected'" ;
4062 $selected { 'TO_MINUTE' }{ $tcsettings { 'TO_MINUTE' }} = "selected='selected'" ;
4064 @selectedcategories = split ( /\|/ , $tcsettings { 'DST' });
4065 foreach ( @selectedcategories )
4067 $selected { 'DST' }{ $_ } = "selected='selected'" ;
4070 $selected { 'ACCESS' }{ $tcsettings { 'ACCESS' }} = "selected='selected'" ;
4072 $checked { 'ENABLERULE' }{ 'off' } = '' ;
4073 $checked { 'ENABLERULE' }{ 'on' } = '' ;
4074 $checked { 'ENABLERULE' }{ $tcsettings { 'ENABLERULE' }} = "checked='checked'" ;
4075 $checked { 'MON' }{ 'off' } = '' ;
4076 $checked { 'MON' }{ 'on' } = '' ;
4077 $checked { 'MON' }{ $tcsettings { 'MON' }} = "checked='checked'" ;
4078 $checked { 'TUE' }{ 'off' } = '' ;
4079 $checked { 'TUE' }{ 'on' } = '' ;
4080 $checked { 'TUE' }{ $tcsettings { 'TUE' }} = "checked='checked'" ;
4081 $checked { 'WED' }{ 'off' } = '' ;
4082 $checked { 'WED' }{ 'on' } = '' ;
4083 $checked { 'WED' }{ $tcsettings { 'WED' }} = "checked='checked'" ;
4084 $checked { 'THU' }{ 'off' } = '' ;
4085 $checked { 'THU' }{ 'on' } = '' ;
4086 $checked { 'THU' }{ $tcsettings { 'THU' }} = "checked='checked'" ;
4087 $checked { 'FRI' }{ 'off' } = '' ;
4088 $checked { 'FRI' }{ 'on' } = '' ;
4089 $checked { 'FRI' }{ $tcsettings { 'FRI' }} = "checked='checked'" ;
4090 $checked { 'SAT' }{ 'off' } = '' ;
4091 $checked { 'SAT' }{ 'on' } = '' ;
4092 $checked { 'SAT' }{ $tcsettings { 'SAT' }} = "checked='checked'" ;
4093 $checked { 'SUN' }{ 'off' } = '' ;
4094 $checked { 'SUN' }{ 'on' } = '' ;
4095 $checked { 'SUN' }{ $tcsettings { 'SUN' }} = "checked='checked'" ;
4097 $selected { 'SPORADIC' }{ $uqsettings { 'SPORADIC' }} = "selected='selected'" ;
4098 $selected { 'RENEWAL' } { $uqsettings { 'RENEWAL' }} = "selected='selected'" ;
4100 $checked { 'ENABLEQUOTA' }{ 'off' } = '' ;
4101 $checked { 'ENABLEQUOTA' }{ 'on' } = '' ;
4102 $checked { 'ENABLEQUOTA' }{ $uqsettings { 'ENABLEQUOTA' }} = "checked='checked'" ;
4104 $selected { 'BE_BLACKLIST' }{ $besettings { 'BE_BLACKLIST' }} = "selected='selected'" ;
4107 & Header
:: showhttpheaders
();
4109 & Header
:: openpage
( $Lang :: tr
{ 'urlfilter configuration' }, 1 , '' );
4111 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
4113 if ( $errormessage ) {
4114 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
4115 print "<font class='base'> $errormessage </font> \n " ;
4116 & Header
:: closebox
();
4117 } elsif (( $tcsettings { 'CHANGED' } eq 'yes' ) || ( $uqsettings { 'CHANGED' } eq 'yes' ) ) {
4119 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}'> \n " ;
4120 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter restart notification'}:" );
4121 print "<class name='base'> $Lang ::tr{'urlfilter restart message'} \n " ;
4122 if ( $uqsettings { 'MODE' } eq 'USERQUOTA' ) { print "<p><class name='base'> $Lang ::tr{'urlfilter quota restart message'} \n " ; }
4124 print "<p><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter restart'}' />" ;
4125 if ( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) { print "<input type='hidden' name='MODE' value='TIMECONSTRAINT' />" ; }
4126 if ( $uqsettings { 'MODE' } eq 'USERQUOTA' ) { print "<input type='hidden' name='MODE' value='USERQUOTA' />" ; }
4127 & Header
:: closebox
();
4131 if ( $restoremessage ) {
4132 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter restore results'}:" );
4133 print "<class name='base'> $restoremessage \n " ;
4134 print " </class> \n " ;
4135 & Header
:: closebox
();
4138 if ((! $tcsettings { 'TCMODE' }) && (! $uqsettings { 'UQMODE' }) && (! $besettings { 'BEMODE' })) {
4140 if (!( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter manage repository' })) {
4142 #==========================================================
4144 # Section: Main Configuration
4146 #==========================================================
4148 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
4150 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter filter settings'}:" );
4152 <table width='100%'>
4154 <td colspan='4'><b> $Lang ::tr{'urlfilter block categories'}</b></td>
4159 if ( @categories == 0 ) {
4162 <td><i> $Lang ::tr{'urlfilter no categories'}</i></td>
4172 for ( $n = 0 ; $n <= @categories ; $n = $n + $i ) {
4173 for ( $i = 0 ; $i <= 3 ; $i ++) {
4174 if ( $i eq 0 ) { print "<tr> \n " ; }
4175 if (( $n + $i ) < @categories ) {
4176 print "<td width='15%'> @categories [ $n + $i ]:<\/td> \n " ;
4177 print "<td width='10%'><input type='checkbox' name= @filtergroups [ $n + $i ] $checked { @filtergroups [ $n + $i ]}{'on'} /></td> \n " ;
4179 if ( $i eq 3 ) { print "<\/tr> \n " ; }
4186 <table width='100%'>
4188 <td><b> $Lang ::tr{'urlfilter custom blacklist'}</b></td>
4194 <td colspan='2'> $Lang ::tr{'urlfilter blocked domains'} <img src='/blob.gif' alt='*' /></td>
4195 <td colspan='2'> $Lang ::tr{'urlfilter blocked urls'} <img src='/blob.gif' alt='*' /></td>
4198 <td colspan='2' width='50%'><textarea name='CUSTOM_BLACK_DOMAINS' cols='32' rows='6' wrap='off'>
4202 print $filtersettings { 'CUSTOM_BLACK_DOMAINS' };
4206 <td colspan='2' width='50%'><textarea name='CUSTOM_BLACK_URLS' cols='32' rows='6' wrap='off'>
4210 print $filtersettings { 'CUSTOM_BLACK_URLS' };
4216 <table width='100%'>
4218 <td class='base' width='25%'> $Lang ::tr{'urlfilter enable custom blacklist'}:</td>
4219 <td><input type='checkbox' name='ENABLE_CUSTOM_BLACKLIST' $checked {'ENABLE_CUSTOM_BLACKLIST'}{'on'} /></td>
4225 <table width='100%'>
4227 <td><b> $Lang ::tr{'urlfilter custom whitelist'}</b></td>
4233 <td colspan='2'> $Lang ::tr{'urlfilter allowed domains'} <img src='/blob.gif' alt='*' /></td>
4234 <td colspan='2'> $Lang ::tr{'urlfilter allowed urls'} <img src='/blob.gif' alt='*' /></td>
4237 <td colspan='2' width='50%'><textarea name='CUSTOM_WHITE_DOMAINS' cols='32' rows='6' wrap='off'>
4241 print $filtersettings { 'CUSTOM_WHITE_DOMAINS' };
4245 <td colspan='2' width='50%'><textarea name='CUSTOM_WHITE_URLS' cols='32' rows='6' wrap='off'>
4249 print $filtersettings { 'CUSTOM_WHITE_URLS' };
4255 <table width='100%'>
4257 <td class='base' width='25%'> $Lang ::tr{'urlfilter enable custom whitelist'}:</td>
4258 <td><input type='checkbox' name='ENABLE_CUSTOM_WHITELIST' $checked {'ENABLE_CUSTOM_WHITELIST'}{'on'} /></td>
4264 <table width='100%'>
4266 <td colspan='4'><b> $Lang ::tr{'urlfilter custom expression list'}</b></td>
4269 <td colspan='4'> $Lang ::tr{'urlfilter blocked expressions'} <img src='/blob.gif' alt='*' /></td>
4272 <td colspan='4'><textarea name='CUSTOM_EXPRESSIONS' cols='70' rows='3' wrap='off'>
4276 print $filtersettings { 'CUSTOM_EXPRESSIONS' };
4282 <td class='base' width='25%'> $Lang ::tr{'urlfilter enable custom expression list'}:</td>
4283 <td><input type='checkbox' name='ENABLE_CUSTOM_EXPRESSIONS' $checked {'ENABLE_CUSTOM_EXPRESSIONS'}{'on'} /></td>
4289 <table width='100%'>
4291 <td colspan='4'><b> $Lang ::tr{'urlfilter file ext block'}</b></td>
4294 <td width='25%' class='base'> $Lang ::tr{'urlfilter block executables'}:</td>
4295 <td width='12%'><input type='checkbox' name='BLOCK_EXECUTABLES' $checked {'BLOCK_EXECUTABLES'}{'on'} /></td>
4296 <td width='25%' class='base'> $Lang ::tr{'urlfilter block audio-video'}:</td>
4297 <td><input type='checkbox' name='BLOCK_AUDIO-VIDEO' $checked {'BLOCK_AUDIO-VIDEO'}{'on'} /></td>
4300 <td class='base'> $Lang ::tr{'urlfilter block archives'}:</td>
4301 <td><input type='checkbox' name='BLOCK_ARCHIVES' $checked {'BLOCK_ARCHIVES'}{'on'} /></td>
4307 <table width='100%'>
4309 <td colspan='4'><b> $Lang ::tr{'urlfilter local file redirection'}</b></td>
4312 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable rewrite rules'}:</td>
4313 <td width='12%'><input type='checkbox' name='ENABLE_REWRITE' $checked {'ENABLE_REWRITE'}{'on'} /></td>
4318 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter manage repository'}'></td>
4325 <table width='100%'>
4327 <td colspan='2'><b> $Lang ::tr{'urlfilter network access control'}</b></td>
4332 <td class='base'> $Lang ::tr{'urlfilter unfiltered clients'}: <img src='/blob.gif' alt='*' /></td>
4333 <td><input type='text' name='UNFILTERED_CLIENTS' value=' $filtersettings {'UNFILTERED_CLIENTS'}' size='30' /></td>
4334 <td class='base'> $Lang ::tr{'urlfilter banned clients'}: <img src='/blob.gif' alt='*' /></td>
4335 <td><input type='text' name='BANNED_CLIENTS' value=' $filtersettings {'BANNED_CLIENTS'}' size='30' /></td>
4339 <table width='100%'>
4341 <td colspan='4'><b> $Lang ::tr{'urlfilter timebased access control'}</b></td>
4344 <td width='25%'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter set time constraints'}'></td>
4345 <td width='25%'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter set user quota'}'></td>
4351 <table width='100%'>
4353 <td colspan='4'><b> $Lang ::tr{'urlfilter block settings'}</b></td>
4356 <td width='25%' class='base'> $Lang ::tr{'urlfilter show category'}:</td>
4357 <td width='12%'><input type='checkbox' name='SHOW_CATEGORY' $checked {'SHOW_CATEGORY'}{'on'} /></td>
4358 <td width='25%' class='base'> $Lang ::tr{'urlfilter redirectpage'}: <img src='/blob.gif' alt='*' /></td>
4359 <td><input type='text' name='REDIRECT_PAGE' value=' $filtersettings {'REDIRECT_PAGE'}' size='40' /></td>
4362 <td class='base'> $Lang ::tr{'urlfilter show url'}:</td>
4363 <td><input type='checkbox' name='SHOW_URL' $checked {'SHOW_URL'}{'on'} /></td>
4364 <td class='base'> $Lang ::tr{'urlfilter msg text 1'}: <img src='/blob.gif' alt='*' /></td>
4365 <td><input type='text' name='MSG_TEXT_1' value=' $filtersettings {'MSG_TEXT_1'}' size='40' /></td>
4368 <td class='base'> $Lang ::tr{'urlfilter show ip'}:</td>
4369 <td><input type='checkbox' name='SHOW_IP' $checked {'SHOW_IP'}{'on'} /></td>
4370 <td class='base'> $Lang ::tr{'urlfilter msg text 2'}: <img src='/blob.gif' alt='*' /></td>
4371 <td><input type='text' name='MSG_TEXT_2' value=' $filtersettings {'MSG_TEXT_2'}' size='40' /></td>
4374 <td class='base'> $Lang ::tr{'urlfilter show dnserror'}:</td>
4375 <td><input type='checkbox' name='ENABLE_DNSERROR' $checked {'ENABLE_DNSERROR'}{'on'} /></td>
4376 <td class='base'> $Lang ::tr{'urlfilter msg text 3'}: <img src='/blob.gif' alt='*' /></td>
4377 <td><input type='text' name='MSG_TEXT_3' value=' $filtersettings {'MSG_TEXT_3'}' size='40' /></td>
4380 <td class='base'> $Lang ::tr{'urlfilter enable jpeg'}:</td>
4381 <td><input type='checkbox' name='ENABLE_JPEG' $checked {'ENABLE_JPEG'}{'on'} /></td>
4386 <table width='100%'>
4388 <td class='base'><b> $Lang ::tr{'urlfilter background image'}</b></td>
4391 <td><br> $Lang ::tr{'urlfilter background text'}:</td>
4394 <td><input type='file' name='BACKGROUND' size='40' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter upload background'}' /></td>
4398 <table width='100%'>
4400 <td colspan='4'><b> $Lang ::tr{'urlfilter advanced settings'}</b></td>
4403 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable expression lists'}:</td>
4404 <td width='12%'><input type='checkbox' name='ENABLE_EXPR_LISTS' $checked {'ENABLE_EXPR_LISTS'}{'on'} /></td>
4405 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable log'}:</td>
4406 <td><input type='checkbox' name='ENABLE_LOG' $checked {'ENABLE_LOG'}{'on'} /></td>
4409 <td class='base'> $Lang ::tr{'urlfilter safesearch'}:</td>
4410 <td><input type='checkbox' name='ENABLE_SAFESEARCH' $checked {'ENABLE_SAFESEARCH'}{'on'} /></td>
4411 <td class='base'> $Lang ::tr{'urlfilter username log'}:</td>
4412 <td><input type='checkbox' name='ENABLE_USERNAME_LOG' $checked {'ENABLE_USERNAME_LOG'}{'on'} /></td>
4415 <td class='base'> $Lang ::tr{'urlfilter empty ads'}:</td>
4416 <td><input type='checkbox' name='ENABLE_EMPTY_ADS' $checked {'ENABLE_EMPTY_ADS'}{'on'} /></td>
4417 <td class='base'> $Lang ::tr{'urlfilter category log'}:</td>
4418 <td><input type='checkbox' name='ENABLE_CATEGORY_LOG' $checked {'ENABLE_CATEGORY_LOG'}{'on'} /></td>
4421 <td class='base'> $Lang ::tr{'urlfilter block ip'}:</td>
4422 <td><input type='checkbox' name='BLOCK_IP_ADDR' $checked {'BLOCK_IP_ADDR'}{'on'} /></td>
4423 <td class='base'> $Lang ::tr{'urlfilter children'}:</td>
4424 <td><input type='text' name='CHILDREN' value=' $filtersettings {'CHILDREN'}' size='5' /></td>
4427 <td class='base'> $Lang ::tr{'urlfilter block all'}:</td>
4428 <td><input type='checkbox' name='BLOCK_ALL' $checked {'BLOCK_ALL'}{'on'} /></td>
4429 <td class='base'> $Lang ::tr{'urlfilter whitelist always allowed'}:</td>
4430 <td><input type='checkbox' name='ENABLE_GLOBAL_WHITELIST' $checked {'ENABLE_GLOBAL_WHITELIST'}{'on'} /></td>
4434 <table width='100%'>
4437 <img src='/blob.gif' align='top' alt='*' />
4438 <font class='base'> $Lang ::tr{'this field may be blank'}</font>
4441 <sup><small><a href='http://www.urlfilter.net' target='_blank'>URL filter</a></small></sup>
4445 <table width='100%'>
4448 <td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' /></td>
4449 <td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter save and restart'}' /></td>
4456 & Header
:: closebox
();
4460 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
4462 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter maintenance'}:" );
4465 <table width='100%'>
4467 <td class='base'><b> $Lang ::tr{'urlfilter blacklist update'}</b></td>
4470 <td> $Lang ::tr{'urlfilter upload information'}<p> $Lang ::tr{'urlfilter upload text'}:</td>
4473 <td><input type='file' name='UPDATEFILE' size='40' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter upload blacklist'}' /></td>
4479 <table width='100%'>
4481 <td colspan='2' class='base'><b> $Lang ::tr{'urlfilter automatic blacklist update'}</b>
4484 if (- e
" $updflagfile " )
4486 $blacklistage = int (- M
" $updflagfile " );
4487 print " <b>[</b> <small><i> $Lang ::tr{'urlfilter blacklist age 1'} <b> $blacklistage </b> $Lang ::tr{'urlfilter blacklist age 2'}</i></small> <b>]</b>" ;
4490 $updatesettings { 'UPDATE_SCHEDULE' } = 'monthly' ;
4491 $updatesettings { 'CUSTOM_UPDATE_URL' } = '' ;
4493 if (- e
" $updconffile " ) { & General
:: readhash
( " $updconffile " , \
%updatesettings ); }
4495 $checked { 'ENABLE_AUTOUPDATE' }{ 'off' } = '' ;
4496 $checked { 'ENABLE_AUTOUPDATE' }{ 'on' } = '' ;
4497 $checked { 'ENABLE_AUTOUPDATE' }{ $updatesettings { 'ENABLE_AUTOUPDATE' }} = "checked='checked'" ;
4499 $selected { 'UPDATE_SCHEDULE' }{ $updatesettings { 'UPDATE_SCHEDULE' }} = "selected='selected'" ;
4501 $selected { 'UPDATE_SOURCE' }{ $updatesettings { 'UPDATE_SOURCE' }} = "selected='selected'" ;
4507 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable automatic blacklist update'}:</td>
4508 <td width='75%' class='base'><input type='checkbox' name='ENABLE_AUTOUPDATE' $checked {'ENABLE_AUTOUPDATE'}{'on'} /></td>
4511 <td class='base'> $Lang ::tr{'urlfilter automatic update schedule'}:</td>
4513 <select name='UPDATE_SCHEDULE'>
4514 <option value='daily' $selected {'UPDATE_SCHEDULE'}{'daily'}> $Lang ::tr{'urlfilter daily'}</option>
4515 <option value='weekly' $selected {'UPDATE_SCHEDULE'}{'weekly'}> $Lang ::tr{'urlfilter weekly'}</option>
4516 <option value='monthly' $selected {'UPDATE_SCHEDULE'}{'monthly'}> $Lang ::tr{'urlfilter monthly'}</option>
4521 <td class='base'> $Lang ::tr{'urlfilter select source'}:</td>
4522 <td class='base' colspan='2'>
4523 <select name='UPDATE_SOURCE'>
4527 foreach ( @source_urllist ) {
4529 $source_name = substr ( $_ , 0 , rindex ( $_ , "," ));
4530 $source_url = substr ( $_ , index ( $_ , "," )+ 1 );
4531 print " \t <option value=' $source_url ' $selected {'UPDATE_SOURCE'}{ $source_url }> $source_name </option> \n " ;
4535 <option value='custom' $selected {'UPDATE_SOURCE'}{'custom'}> $Lang ::tr{'urlfilter custom url'}</option>
4540 <td> $Lang ::tr{'urlfilter custom url'}:</td>
4541 <td><input type='text' name='CUSTOM_UPDATE_URL' value=' $updatesettings {'CUSTOM_UPDATE_URL'}' size='72' /></td>
4544 <table width='100%'>
4546 <td width='25%'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter save schedule'}'> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter update now'}'></td>
4552 <table width='100%'>
4554 <td class='base'><b> $Lang ::tr{'urlfilter blacklist editor'}</b></td>
4557 <td> $Lang ::tr{'urlfilter blacklist editor info'}</td>
4560 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter blacklist editor'}' /></td>
4566 <table width='100%'>
4568 <td colspan='4' class='base'><b> $Lang ::tr{'urlfilter backup settings'}</b></td>
4571 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable full backup'}:</td>
4572 <td width='12%' class='base'><input type='checkbox' name='ENABLE_FULLBACKUP' $checked {'ENABLE_FULLBACKUP'}{'on'} /></td>
4577 <td colspan='4' class='base'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter backup'}' /></td>
4583 <table width='100%'>
4585 <td class='base'><b> $Lang ::tr{'urlfilter restore settings'}</b></td>
4588 <td> $Lang ::tr{'urlfilter restore text'}:</td>
4591 <td><input type='file' name='UPDATEFILE' size='40' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter restore'}' /></td>
4598 & Header
:: closebox
();
4602 #==========================================================
4604 # Section: Manage Repository
4606 #==========================================================
4608 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
4610 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter manage local file repository'}:" );
4612 <table width='100%'>
4614 <td> $Lang ::tr{'urlfilter repository information'}<br><br></td>
4617 <td> $Lang ::tr{'urlfilter upload file text'}:</td>
4620 <td><input type='file' name='UPLOADFILE' size='50' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter upload file'}' /></td>
4623 <td><br><b> $Lang ::tr{'urlfilter upload file information 1'}:</b> $Lang ::tr{'urlfilter upload file information 2'}</td>
4627 <table width='100%'>
4629 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
4636 & Header
:: closebox
();
4638 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter current files'}: </b>[ $repository ]" );
4640 @repositorylist = < $repository /*>;
4642 undef @repositoryfiles ;
4643 foreach ( @repositorylist )
4645 if (!- d
) { push ( @repositoryfiles , substr ( $_ , rindex ( $_ , "/" )+ 1 )); }
4648 if ( @repositoryfiles )
4651 <table width='100%'>
4653 <td align='center'><b> $Lang ::tr{'urlfilter filename'}</b></td>
4654 <td width='15%' align='center'><b> $Lang ::tr{'urlfilter filesize'}</b></td>
4655 <td width='10%'></td>
4660 foreach $line ( @repositoryfiles )
4664 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
4666 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
4667 $filesize = (- s
" $repository / $line " );
4668 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/ ;
4671 <td> $line </td>
4672 <td align='right'> $filesize </td>
4675 <form method='post' name='frma $id ' action=' $ENV {'SCRIPT_NAME'}'>
4676 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' title=' $Lang ::tr{'remove'}' alt=' $Lang ::tr{'remove'}' />
4677 <input type='hidden' name='ID' value=' $line ' />
4678 <input type='hidden' name='ACTION' value=' $Lang ::tr{'urlfilter remove file'}' />
4695 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
4696 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
4697 <td class='base'> $Lang ::tr{'remove'}</td>
4704 print "<i> $Lang ::tr{'urlfilter empty repository'}</i> \n " ;
4707 & Header
:: closebox
();
4711 } elsif ( $tcsettings { 'TCMODE' }) {
4713 #==========================================================
4715 # Section: Set Time Constraints
4717 #==========================================================
4719 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}'> \n " ;
4721 $buttontext = $Lang :: tr
{ 'urlfilter add rule' };
4722 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
4723 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter edit time constraint rule' }. ':' );
4724 $buttontext = $Lang :: tr
{ 'urlfilter update rule' };
4726 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter add new time constraint rule' }. ':' );
4730 <table width='100%'>
4732 <td width='2%'> $Lang ::tr{'urlfilter constraint definition'}</td>
4733 <td width='1%'> </td>
4734 <td width='2%' align='center'> $Lang ::tr{'urlfilter monday'}</td>
4735 <td width='2%' align='center'> $Lang ::tr{'urlfilter tuesday'}</td>
4736 <td width='2%' align='center'> $Lang ::tr{'urlfilter wednesday'}</td>
4737 <td width='2%' align='center'> $Lang ::tr{'urlfilter thursday'}</td>
4738 <td width='2%' align='center'> $Lang ::tr{'urlfilter friday'}</td>
4739 <td width='2%' align='center'> $Lang ::tr{'urlfilter saturday'}</td>
4740 <td width='2%' align='center'> $Lang ::tr{'urlfilter sunday'}</td>
4741 <td width='1%'> </td>
4742 <td width='7%' colspan=3> $Lang ::tr{'urlfilter from'}</td>
4743 <td width='1%'> </td>
4744 <td width='7%' colspan=3> $Lang ::tr{'urlfilter to'}</td>
4749 <select name='DEFINITION'>
4750 <option value='within' $selected {'DEFINITION'}{'within'}> $Lang ::tr{'urlfilter constraint within'}</option>
4751 <option value='outside' $selected {'DEFINITION'}{'outside'}> $Lang ::tr{'urlfilter constraint outside'}</option>
4755 <td class='base'><input type='checkbox' name='MON' $checked {'MON'}{'on'} /></td>
4756 <td class='base'><input type='checkbox' name='TUE' $checked {'TUE'}{'on'} /></td>
4757 <td class='base'><input type='checkbox' name='WED' $checked {'WED'}{'on'} /></td>
4758 <td class='base'><input type='checkbox' name='THU' $checked {'THU'}{'on'} /></td>
4759 <td class='base'><input type='checkbox' name='FRI' $checked {'FRI'}{'on'} /></td>
4760 <td class='base'><input type='checkbox' name='SAT' $checked {'SAT'}{'on'} /></td>
4761 <td class='base'><input type='checkbox' name='SUN' $checked {'SUN'}{'on'} /></td>
4764 <select name='FROM_HOUR'>
4767 for ( $i = 0 ; $i <= 24 ; $i ++) {
4768 $_ = sprintf ( " %02s " , $i );
4769 print "<option $selected {'FROM_HOUR'}{ $_ }> $_ </option> \n " ;
4776 <select name='FROM_MINUTE'>
4779 for ( $i = 0 ; $i <= 45 ; $i += 15 ) {
4780 $_ = sprintf ( " %02s " , $i );
4781 print "<option $selected {'FROM_MINUTE'}{ $_ }> $_ </option> \n " ;
4788 <select name='TO_HOUR'>
4791 for ( $i = 0 ; $i <= 24 ; $i ++) {
4792 $_ = sprintf ( " %02s " , $i );
4793 print "<option $selected {'TO_HOUR'}{ $_ }> $_ </option> \n " ;
4800 <select name='TO_MINUTE'>
4803 for ( $i = 0 ; $i <= 45 ; $i += 15 ) {
4804 $_ = sprintf ( " %02s " , $i );
4805 print "<option $selected {'TO_MINUTE'}{ $_ }> $_ </option> \n " ;
4816 <table width='100%'>
4818 <td width='5%'> $Lang ::tr{'urlfilter source'}</td>
4819 <td width='1%'> </td>
4820 <td width='5%'> $Lang ::tr{'urlfilter dst'} <img src='/blob.gif' alt='*'><img src='/blob.gif' alt='*'></td>
4821 <td width='1%'> </td>
4822 <td width='5%'> $Lang ::tr{'urlfilter access'}</td>
4826 <td valign='top'><input type='text' name='SRC' value=' $tcsettings {'SRC'}' size='32' /></td>
4828 <td class='base' rowspan='3' valign='top'>
4829 <select name='DST' size='4' multiple>
4830 <option value='any' $selected {'DST'}{'any'} = "selected='selected'"> $Lang ::tr{'urlfilter category all'}</option>
4831 <option value='in-addr' $selected {'DST'}{'in-addr'} = "selected='selected'">in-addr</option>
4835 & readblockcategories
;
4836 foreach ( @categories )
4838 print "<option value=' $_ ' $selected {'DST'}{ $_ }> $_ </option> \n " ;
4842 <option value='files' $selected {'DST'}{'files'} = "selected='selected'">files</option>
4843 <option value='custom-blocked' $selected {'DST'}{'custom-blocked'} = "selected='selected'">custom-blocked</option>
4844 <option value='custom-expressions' $selected {'DST'}{'custom-expressions'} = "selected='selected'">custom-expressions</option>
4848 <td class='base' valign='top'>
4849 <select name='ACCESS'>
4850 <option value='block' $selected {'ACCESS'}{'block'}> $Lang ::tr{'urlfilter mode block'}</option>
4851 <option value='allow' $selected {'ACCESS'}{'allow'}> $Lang ::tr{'urlfilter mode allow'}</option>
4857 <td> $Lang ::tr{'remark'} <img src='/blob.gif' alt='*'></td>
4864 <td><input type='text' name='COMMENT' value=' $tcsettings {'COMMENT'}' size='32' /></td>
4872 <table width='100%'>
4874 <td class='base'> $Lang ::tr{'urlfilter enabled'}<input type='checkbox' name='ENABLERULE' $checked{'ENABLERULE'}{'on'} /></td>
4882 <td><input type='hidden' name='ACTION' value=' $Lang ::tr{'add'}' /></td>
4883 <td><input type='hidden' name='MODE' value='TIMECONSTRAINT' /></td>
4884 <td><input type='submit' name='SUBMIT' value=' $buttontext ' /></td>
4885 <td><input type='reset' name='ACTION' value=' $Lang ::tr{'urlfilter reset'}' /></td>
4887 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
4891 <table width='100%'>
4893 <td width='1%' align='right'> <img src='/blob.gif' align='top' alt='*' /> </td>
4894 <td><font class='base'> $Lang ::tr{'this field may be blank'}</font></td>
4897 <td width='1%' align='right'><img src='/blob.gif' align='top' alt='*' /><img src='/blob.gif' align='top' alt='*' /> </td>
4898 <td><font class='base'> $Lang ::tr{'urlfilter select multi'}</font></td>
4904 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
4905 print "<input type='hidden' name='EDITING' value=' $tcsettings {'ID'}' /> \n " ;
4907 print "<input type='hidden' name='EDITING' value='no' /> \n " ;
4910 & Header
:: closebox
();
4913 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'current rules' });
4915 <table width='100%'>
4917 <td width='5%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter constraint definition'}</b></td>
4918 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter time space'}</b></td>
4919 <td width='15%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter src'}</b></td>
4920 <td width='5%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter dst'}</b></td>
4921 <td width='10%' class='boldbase' colspan='4' align='center'> </td>
4926 if ( $tcsettings { 'ACTION' } ne '' or $changed ne 'no' )
4928 open ( FILE
, $tcfile );
4934 foreach $line ( @tclist )
4938 @temp = split ( /\,/ , $line );
4939 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' } && $tcsettings { 'ID' } eq $id ) {
4940 print "<tr bgcolor=' $Header ::colouryellow'> \n " ; }
4942 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
4944 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
4945 if ( $temp [ 0 ] eq 'within' ) { $temp [ 0 ]= $Lang :: tr
{ 'urlfilter constraint within' }; } else { $temp [ 0 ]= $Lang :: tr
{ 'urlfilter constraint outside' }; }
4946 if ( $temp [ 13 ] eq 'any' ) { $temp [ 13 ]= $Lang :: tr
{ 'urlfilter category all' }; }
4947 if ( $temp [ 15 ] eq 'on' ) { $gif = 'on.gif' ; $toggle = 'off' ; $gdesc = $Lang :: tr
{ 'click to disable' };}
4948 else { $gif = 'off.gif' ; $toggle = 'on' ; $gdesc = $Lang :: tr
{ 'click to enable' }; }
4949 if ( $temp [ 14 ] eq 'block' ) { $led = 'led-red.gif' ; $ldesc = $Lang :: tr
{ 'urlfilter block access' };}
4950 else { $led = 'led-green.gif' ; $ldesc = $Lang :: tr
{ 'urlfilter allow access' }; }
4953 if ( $temp [ 1 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter mon' }; } else { $time .= '=' ; }
4954 if ( $temp [ 2 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter tue' }; } else { $time .= '=' ; }
4955 if ( $temp [ 3 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter wed' }; } else { $time .= '=' ; }
4956 if ( $temp [ 4 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter thu' }; } else { $time .= '=' ; }
4957 if ( $temp [ 5 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter fri' }; } else { $time .= '=' ; }
4958 if ( $temp [ 6 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter sat' }; } else { $time .= '=' ; }
4959 if ( $temp [ 7 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter sun' }; } else { $time .= '=' ; }
4960 $time = $time . ' ' . $temp [ 8 ]. ':' . $temp [ 9 ]. ' to ' . $temp [ 10 ]. ':' . $temp [ 11 ];
4963 <td align='center'> $temp [0]</td>
4964 <td align='center' nowrap> $time </td>
4965 <td align='center'> $temp [12]</td>
4966 <td align='center'> $temp [13]</td>
4967 <td align='center'><image src='/images/urlfilter/ $led ' alt=' $ldesc '></td>
4970 <form method='post' name='frma $id ' action=' $ENV {'SCRIPT_NAME'}'>
4971 <input type='image' name=' $Lang ::tr{'toggle enable disable'}' src='/images/ $gif ' title=' $gdesc ' alt=' $gdesc ' />
4972 <input type='hidden' name='MODE' value='TIMECONSTRAINT' />
4973 <input type='hidden' name='ID' value=' $id ' />
4974 <input type='hidden' name='ACTIVE' value=' $toggle ' />
4975 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
4980 <form method='post' name='frmb $id ' action=' $ENV {'SCRIPT_NAME'}'>
4981 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/edit.gif' title=' $Lang ::tr{'edit'}' alt=' $Lang ::tr{'edit'}' />
4982 <input type='hidden' name='MODE' value='TIMECONSTRAINT' />
4983 <input type='hidden' name='ID' value=' $id ' />
4984 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
4989 <form method='post' name='frmc $id ' action=' $ENV {'SCRIPT_NAME'}'>
4990 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' title=' $Lang ::tr{'remove'}' alt=' $Lang ::tr{'remove'}' />
4991 <input type='hidden' name='MODE' value='TIMECONSTRAINT' />
4992 <input type='hidden' name='ID' value=' $id ' />
4993 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove'}' />
5000 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' } && $tcsettings { 'ID' } eq $id ) {
5001 print "<tr bgcolor=' $Header ::colouryellow'> \n " ; }
5003 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
5005 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
5007 <td align='center' colspan='4'> $temp [16]
5009 <td align='center' colspan='4'>
5018 # If the time constraint file contains entries, print entries and action icons
5019 if (! - z
" $tcfile " ) {
5024 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
5025 <td> <img src='/images/urlfilter/led-green.gif' alt=' $Lang ::tr{'urlfilter allow access'}' /></td>
5026 <td class='base'> $Lang ::tr{'urlfilter allow'}</td>
5027 <td> <img src='/images/urlfilter/led-red.gif' alt=' $Lang ::tr{'urlfilter block access'}' /></td>
5028 <td class='base'> $Lang ::tr{'urlfilter block'}</td>
5029 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
5030 <td class='base'> $Lang ::tr{'click to disable'}</td>
5031 <td> <img src='/images/off.gif' alt=' $Lang ::tr{'click to enable'}' /></td>
5032 <td class='base'> $Lang ::tr{'click to enable'}</td>
5033 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
5034 <td class='base'> $Lang ::tr{'edit'}</td>
5035 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
5036 <td class='base'> $Lang ::tr{'remove'}</td>
5043 & Header
:: closebox
();
5045 } elsif ( $uqsettings { 'UQMODE' }) {
5047 #==========================================================
5049 # Section: Set User Quota
5051 #==========================================================
5053 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}'> \n " ;
5055 $buttontext = $Lang :: tr
{ 'urlfilter add rule' };
5056 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
5057 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter edit user quota rule' }. ':' );
5058 $buttontext = $Lang :: tr
{ 'urlfilter update rule' };
5060 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter add new user quota rule' }. ':' );
5064 <table width='100%'>
5066 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
5069 <td class='base'> $Lang ::tr{'urlfilter user time quota'}:</td>
5070 <td><input type='text' name='TIME_QUOTA' value=' $uqsettings {'TIME_QUOTA'}' size='5' /></td>
5071 <td colspan='2' rowspan= '5' valign='top' class='base'>
5072 <table cellpadding='0' cellspacing='0'>
5074 <!-- intentionally left empty -->
5077 <td> $Lang ::tr{'urlfilter assigned quota users'}:</td>
5080 <!-- intentionally left empty -->
5083 <!-- intentionally left empty -->
5086 <td><textarea name='QUOTA_USERS' cols='32' rows='6' wrap='off'>
5090 $uqsettings { 'QUOTA_USERS' } =~ s/\|/\n/g ;
5091 print $uqsettings { 'QUOTA_USERS' };
5100 <td class='base'> $Lang ::tr{'urlfilter activity detection'}:</td>
5101 <td class='base'><select name='SPORADIC'>
5102 <option value='0' $selected {'SPORADIC'}{'0'}> $Lang ::tr{'urlfilter disabled'}</option>
5103 <option value='300' $selected {'SPORADIC'}{'300'}>5 $Lang ::tr{'urlfilter minutes'}</option>
5104 <option value='900' $selected {'SPORADIC'}{'900'}>15 $Lang ::tr{'urlfilter minutes'}</option>
5108 <td class='base'> $Lang ::tr{'urlfilter renewal period'}:</td>
5109 <td class='base'><select name='RENEWAL'>
5110 <option value='hourly' $selected {'RENEWAL'}{'hourly'}> $Lang ::tr{'urlfilter hourly'}</option>
5111 <option value='daily' $selected {'RENEWAL'}{'daily'}> $Lang ::tr{'urlfilter daily'}</option>
5112 <option value='weekly' $selected {'RENEWAL'}{'weekly'}> $Lang ::tr{'urlfilter weekly'}</option>
5116 <td colspan='2'> </td>
5119 <td class='base'> $Lang ::tr{'urlfilter enabled'}</td>
5120 <td class='base'><input type='checkbox' name='ENABLEQUOTA' $checked {'ENABLEQUOTA'}{'on'} /></td>
5128 <td><input type='hidden' name='ACTION' value=' $Lang ::tr{'add'}' /></td>
5129 <td><input type='hidden' name='MODE' value='USERQUOTA' /></td>
5130 <td><input type='submit' name='SUBMIT' value=' $buttontext ' /></td>
5131 <td><input type='reset' name='ACTION' value=' $Lang ::tr{'urlfilter reset'}' /></td>
5133 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
5141 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
5142 print "<input type='hidden' name='EDITING' value=' $uqsettings {'ID'}' /> \n " ;
5144 print "<input type='hidden' name='EDITING' value='no' /> \n " ;
5147 & Header
:: closebox
();
5150 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'current rules' });
5152 <table width='100%'>
5154 <td width='15%' class='boldbase' align='center'><b><nobr> $Lang ::tr{'urlfilter time quota'}</nobr></b></td>
5155 <td width='15%' class='boldbase' align='center'><b><nobr> $Lang ::tr{'urlfilter activity detection'}</nobr></b></td>
5156 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter renewal'}</b></td>
5157 <td class='boldbase' align='center'><b> $Lang ::tr{'urlfilter assigned users'}</b></td>
5158 <td width='20%' class='boldbase' colspan='4' align='center'> </td>
5163 if ( $uqsettings { 'ACTION' } ne '' or $changed ne 'no' )
5165 open ( FILE
, $uqfile );
5171 foreach $line ( @uqlist )
5175 @temp = split ( /\,/ , $line );
5176 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' } && $uqsettings { 'ID' } eq $id ) {
5177 print "<tr bgcolor=' $Header ::colouryellow'> \n " ; }
5179 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
5181 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
5182 if ( $temp [ 4 ] eq 'on' ) { $gif = 'on.gif' ; $toggle = 'off' ; $gdesc = $Lang :: tr
{ 'click to disable' };}
5183 else { $gif = 'off.gif' ; $toggle = 'on' ; $gdesc = $Lang :: tr
{ 'click to enable' }; }
5185 $temp [ 5 ] = $temp [ 1 ];
5186 if ( $temp [ 1 ] eq '0' ) { $temp [ 5 ] = $Lang :: tr
{ 'urlfilter disabled' } } else { $temp [ 5 ] = ( $temp [ 5 ]/ 60 ). ' ' . $Lang :: tr
{ 'urlfilter minutes' } }
5187 $_ = $temp [ 3 ]; s/\|/, /g ; $temp [ 6 ] = $_ ;
5190 <td align='center'> $temp [0] $Lang ::tr{'urlfilter minutes'}</td>
5191 <td align='center'> $temp [5]</td>
5192 <td align='center'> $Lang ::tr{'urlfilter '. $temp [2]}</td>
5193 <td align='center'> $temp [6]</td>
5196 <form method='post' name='frma $id ' action=' $ENV {'SCRIPT_NAME'}'>
5197 <input type='image' name=' $Lang ::tr{'toggle enable disable'}' src='/images/ $gif ' title=' $gdesc ' alt=' $gdesc ' />
5198 <input type='hidden' name='MODE' value='USERQUOTA' />
5199 <input type='hidden' name='ID' value=' $id ' />
5200 <input type='hidden' name='ACTIVE' value=' $toggle ' />
5201 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
5206 <form method='post' name='frmb $id ' action=' $ENV {'SCRIPT_NAME'}'>
5207 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/edit.gif' title=' $Lang ::tr{'edit'}' alt=' $Lang ::tr{'edit'}' />
5208 <input type='hidden' name='MODE' value='USERQUOTA' />
5209 <input type='hidden' name='ID' value=' $id ' />
5210 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
5215 <form method='post' name='frmc $id ' action=' $ENV {'SCRIPT_NAME'}'>
5216 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' title=' $Lang ::tr{'remove'}' alt=' $Lang ::tr{'remove'}' />
5217 <input type='hidden' name='MODE' value='USERQUOTA' />
5218 <input type='hidden' name='ID' value=' $id ' />
5219 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove'}' />
5230 # If the user quota file contains entries, print entries and action icons
5231 if (! - z
" $uqfile " ) {
5236 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
5237 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
5238 <td class='base'> $Lang ::tr{'click to disable'}</td>
5239 <td> <img src='/images/off.gif' alt=' $Lang ::tr{'click to enable'}' /></td>
5240 <td class='base'> $Lang ::tr{'click to enable'}</td>
5241 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
5242 <td class='base'> $Lang ::tr{'edit'}</td>
5243 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
5244 <td class='base'> $Lang ::tr{'remove'}</td>
5251 & Header
:: closebox
();
5255 #==========================================================
5257 # Section: Blacklist editor
5259 #==========================================================
5261 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
5263 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter urlfilter blacklist editor' }. ':' );
5267 <table width='100%'>
5269 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
5272 <td class='base'><b> $Lang ::tr{'urlfilter blacklist name'}</b></td>
5275 <td class='base'> $Lang ::tr{'urlfilter blacklist category name'}:</td>
5276 <td><input type='text' name='BE_NAME' value=' $besettings {'BE_NAME'}' size='12' /></td>
5280 <table width='100%'>
5282 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='20%'></td>
5285 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter edit domains urls expressions'}</b></td>
5288 <td colspan='2'> $Lang ::tr{'urlfilter domains'}</td>
5289 <td colspan='2'> $Lang ::tr{'urlfilter urls'}</td>
5292 <td colspan='2'><textarea name='BE_DOMAINS' cols='38' rows='10' wrap='off'>
5296 print $besettings { 'BE_DOMAINS' };
5300 <td colspan='2'><textarea name='BE_URLS' cols='38' rows='10' wrap='off'>
5304 print $besettings { 'BE_URLS' };
5310 <td colspan='4'> $Lang ::tr{'urlfilter expressions'}</td>
5313 <td colspan='4'><textarea name='BE_EXPRESSIONS' cols='80' rows='3' wrap='off'>
5317 print $besettings { 'BE_EXPRESSIONS' };
5324 <table width='100%'>
5326 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter load blacklist'}</b></td>
5329 <td width='25%' class='base'> $Lang ::tr{'urlfilter select blacklist'}:</td>
5330 <td width='20%' class='base'>
5331 <select name='BE_BLACKLIST'>
5335 & readblockcategories
;
5336 foreach ( @categories )
5338 print "<option value=' $_ ' $selected {'BE_BLACKLIST'}{ $_ }> $_ </option> \n " ;
5347 <td colpsan='4'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter load blacklist'}' /></td>
5352 <table width='100%'>
5354 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter import blacklist'}</b></td>
5357 <td colspan='4'> $Lang ::tr{'urlfilter import text'}:</td>
5360 <td nowrap><input type='file' name='IMPORTFILE' size='40' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter import blacklist'}' /></td>
5361 <td><input type='hidden' name='MODE' value='BLACKLIST_EDITOR' /></td>
5365 <table width='100%'>
5367 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter export blacklist'}</b></td>
5370 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter export blacklist'}' /></td>
5374 <table width='100%'>
5376 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter install blacklist'}</b></td>
5379 <td width='25%' class='base'> $Lang ::tr{'urlfilter dont restart urlfilter'}:</td>
5380 <td width='20%' class='base'><input type='checkbox' name='NORESTART' $checked {'NORESTART'}{'on'} /></td>
5385 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter install blacklist'}' /></td>
5388 <td class='base' colspan='4'><br> $Lang ::tr{'urlfilter install information'}</td>
5394 <td><input type='reset' name='ACTION' value=' $Lang ::tr{'urlfilter reset'}' /></td>
5396 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
5403 & Header
:: closebox
();
5408 & Header
:: closebigbox
();
5410 & Header
:: closepage
();
5412 # -------------------------------------------------------------------
5418 delete $filtersettings { 'CUSTOM_BLACK_DOMAINS' };
5419 delete $filtersettings { 'CUSTOM_BLACK_URLS' };
5420 delete $filtersettings { 'CUSTOM_WHITE_DOMAINS' };
5421 delete $filtersettings { 'CUSTOM_WHITE_URLS' };
5422 delete $filtersettings { 'CUSTOM_EXPRESSIONS' };
5423 delete $filtersettings { 'BACKGROUND' };
5424 delete $filtersettings { 'UPDATEFILE' };
5426 & General
:: writehash
( "${General::swroot}/urlfilter/settings" , \
%filtersettings );
5429 # -------------------------------------------------------------------
5431 sub readblockcategories
5434 foreach $blacklist (< $dbdir /*>) {
5435 if (- d
$blacklist ) {
5436 $lastslashpos = rindex ( $blacklist , "/" );
5437 if ( $lastslashpos > - 1 ) {
5438 $section = substr ( $blacklist , $lastslashpos + 1 );
5440 $section = $blacklist ;
5442 if (!( $section eq 'custom' )) { push ( @categories , $section ) };
5446 @filtergroups = @categories ;
5447 foreach ( @filtergroups ) {
5453 # -------------------------------------------------------------------
5457 if (- e
" $dbdir /custom/blocked/domains" ) {
5458 open ( FILE
, " $dbdir /custom/blocked/domains" );
5459 delete $filtersettings { 'CUSTOM_BLACK_DOMAINS' };
5460 while (< FILE
>) { $filtersettings { 'CUSTOM_BLACK_DOMAINS' } .= $_ };
5464 if (- e
" $dbdir /custom/blocked/urls" ) {
5465 open ( FILE
, " $dbdir /custom/blocked/urls" );
5466 delete $filtersettings { 'CUSTOM_BLACK_URLS' };
5467 while (< FILE
>) { $filtersettings { 'CUSTOM_BLACK_URLS' } .= $_ };
5471 if (- e
" $dbdir /custom/blocked/expressions" ) {
5472 open ( FILE
, " $dbdir /custom/blocked/expressions" );
5473 delete $filtersettings { 'CUSTOM_EXPRESSIONS' };
5474 while (< FILE
>) { $filtersettings { 'CUSTOM_EXPRESSIONS' } .= $_ };
5478 if (- e
" $dbdir /custom/allowed/domains" ) {
5479 open ( FILE
, " $dbdir /custom/allowed/domains" );
5480 delete $filtersettings { 'CUSTOM_WHITE_DOMAINS' };
5481 while (< FILE
>) { $filtersettings { 'CUSTOM_WHITE_DOMAINS' } .= $_ };
5484 if (- e
" $dbdir /custom/allowed/urls" ) {
5485 open ( FILE
, " $dbdir /custom/allowed/urls" );
5486 delete $filtersettings { 'CUSTOM_WHITE_URLS' };
5487 while (< FILE
>) { $filtersettings { 'CUSTOM_WHITE_URLS' } .= $_ };
5492 # -------------------------------------------------------------------
5494 sub aggregatedconstraints
5514 @tmp1 = split ( /\,/ , $x );
5518 @tmp2 = split ( /\,/ );
5519 if ( $tmp2 [ 15 ] eq 'on' )
5521 if (( $tmp1 [ 0 ] eq $tmp2 [ 0 ]) && ( $tmp1 [ 12 ] eq $tmp2 [ 12 ]) && ( $tmp1 [ 13 ] eq $tmp2 [ 13 ]) && ( $tmp1 [ 14 ] eq $tmp2 [ 14 ]))
5524 $tmp2 [ 16 ] .= " weekly " ;
5525 if ( $tmp1 [ 1 ] eq 'on' ) { $tmp2 [ 16 ] .= "m" ; }
5526 if ( $tmp1 [ 2 ] eq 'on' ) { $tmp2 [ 16 ] .= "t" ; }
5527 if ( $tmp1 [ 3 ] eq 'on' ) { $tmp2 [ 16 ] .= "w" ; }
5528 if ( $tmp1 [ 4 ] eq 'on' ) { $tmp2 [ 16 ] .= "h" ; }
5529 if ( $tmp1 [ 5 ] eq 'on' ) { $tmp2 [ 16 ] .= "f" ; }
5530 if ( $tmp1 [ 6 ] eq 'on' ) { $tmp2 [ 16 ] .= "a" ; }
5531 if ( $tmp1 [ 7 ] eq 'on' ) { $tmp2 [ 16 ] .= "s" ; }
5532 $tmp2 [ 16 ] .= " $tmp1 [8]: $tmp1 [9]- $tmp1 [10]: $tmp1 [11] \n " ;
5533 $_ = join ( "," , @tmp2 );
5540 $tmp1 [ 16 ] .= " weekly " ;
5541 if ( $tmp1 [ 1 ] eq 'on' ) { $tmp1 [ 16 ] .= "m" ; }
5542 if ( $tmp1 [ 2 ] eq 'on' ) { $tmp1 [ 16 ] .= "t" ; }
5543 if ( $tmp1 [ 3 ] eq 'on' ) { $tmp1 [ 16 ] .= "w" ; }
5544 if ( $tmp1 [ 4 ] eq 'on' ) { $tmp1 [ 16 ] .= "h" ; }
5545 if ( $tmp1 [ 5 ] eq 'on' ) { $tmp1 [ 16 ] .= "f" ; }
5546 if ( $tmp1 [ 6 ] eq 'on' ) { $tmp1 [ 16 ] .= "a" ; }
5547 if ( $tmp1 [ 7 ] eq 'on' ) { $tmp1 [ 16 ] .= "s" ; }
5548 $tmp1 [ 16 ] .= " $tmp1 [8]: $tmp1 [9]- $tmp1 [10]: $tmp1 [11] \n " ;
5549 $x = join ( "," , @tmp1 );
5559 # -------------------------------------------------------------------
5563 my $executables = " \\ .\(ade|adp|asx|bas|bat|chm|com|cmd|cpl|crt|dll|eml|exe|hiv|hlp|hta|inc|inf|ins|isp|jse|jtd|lnk|msc|msh|msi|msp|mst|nws|ocx|oft|ops|pcd|pif|plx|reg|scr|sct|sha|shb|shm|shs|sys|tlb|tsp|url|vbe|vbs|vxd|wsc|wsf|wsh\)\$" ;
5564 my $audiovideo = " \\ .\(aiff|asf|avi|dif|divx|mov|movie|mp3|mpe?g?|mpv2|ogg|ra?m|snd|qt|wav|wmf|wmv\)\$" ;
5565 my $archives = " \\ .\(bin|bz2|cab|cdr|dmg|gz|hqx|rar|smi|sit|sea|tar|tgz|zip\)\$" ;
5567 my $ident = " anonymous" ;
5580 if (!(- d
" $dbdir /custom" )) { mkdir ( " $dbdir /custom" ) }
5581 if (!(- d
" $dbdir /custom/blocked" )) { mkdir ( " $dbdir /custom/blocked" ) }
5582 if (!(- d
" $dbdir /custom/allowed" )) { mkdir ( " $dbdir /custom/allowed" ) }
5584 open ( FILE
, ">/ $dbdir /custom/blocked/domains" );
5585 print FILE
$filtersettings { 'CUSTOM_BLACK_DOMAINS' };
5587 open ( FILE
, ">/ $dbdir /custom/blocked/urls" );
5588 print FILE
$filtersettings { 'CUSTOM_BLACK_URLS' };
5590 open ( FILE
, ">/ $dbdir /custom/blocked/expressions" );
5591 print FILE
$filtersettings { 'CUSTOM_EXPRESSIONS' };
5593 open ( FILE
, ">/ $dbdir /custom/blocked/files" );
5594 if ( $filtersettings { 'BLOCK_EXECUTABLES' } eq 'on' ) { print FILE
" $executables \n " ; }
5595 if ( $filtersettings { 'BLOCK_AUDIO-VIDEO' } eq 'on' ) { print FILE
" $audiovideo \n " ; }
5596 if ( $filtersettings { 'BLOCK_ARCHIVES' } eq 'on' ) { print FILE
" $archives \n " ; }
5598 open ( FILE
, ">/ $dbdir /custom/allowed/domains" );
5599 print FILE
$filtersettings { 'CUSTOM_WHITE_DOMAINS' };
5601 open ( FILE
, ">/ $dbdir /custom/allowed/urls" );
5602 print FILE
$filtersettings { 'CUSTOM_WHITE_URLS' };
5605 if ( $filtersettings { 'ENABLE_USERNAME_LOG' } eq 'on' ) { $ident = "" ; }
5607 if ( $filtersettings { 'REDIRECT_PAGE' } eq '' )
5609 if (( $filtersettings { 'SHOW_CATEGORY' } eq 'on' ) || ( $filtersettings { 'SHOW_URL' } eq 'on' ) || ( $filtersettings { 'SHOW_IP' } eq 'on' )) {
5610 if ( $filtersettings { 'SHOW_CATEGORY' } eq 'on' ) { $redirect .= "&category= %t " ; }
5611 if ( $filtersettings { 'SHOW_URL' } eq 'on' ) { $redirect .= "&url= %u " ; }
5612 if ( $filtersettings { 'SHOW_IP' } eq 'on' ) { $redirect .= "&ip= %a " ; }
5613 $redirect =~ s/^&/?/ ;
5614 $redirect = "http:\/\/ $netsettings {'GREEN_ADDRESS'}:81\/redirect.cgi" . $redirect ;
5616 $redirect = "http:\/\/ $netsettings {'GREEN_ADDRESS'}:81\/redirect.cgi" ;
5618 } else { $redirect = $filtersettings { 'REDIRECT_PAGE' }; }
5620 if ( $filtersettings { 'ENABLE_DNSERROR' } eq 'on' ) { $redirect = "302:http://0.0.0.0" ; }
5624 if ( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' )
5626 $defaultrule .= "custom-allowed " ;
5628 if ( $filtersettings { 'BLOCK_ALL' } eq 'on' )
5630 $defaultrule .= "none" ;
5634 if ( $filtersettings { 'BLOCK_IP_ADDR' } eq 'on' )
5636 $defaultrule .= "!in-addr " ;
5638 for ( $i = 0 ; $i <= @filtergroups ; $i ++) {
5639 if ( $filtersettings { @filtergroups [ $i ]} eq 'on' )
5641 $defaultrule .= "! @categories [ $i ] " ;
5644 if ( $filtersettings { 'ENABLE_CUSTOM_BLACKLIST' } eq 'on' )
5646 $defaultrule .= "!custom-blocked " ;
5648 if ( $filtersettings { 'ENABLE_CUSTOM_EXPRESSIONS' } eq 'on' )
5650 $defaultrule .= "!custom-expressions " ;
5652 if (( $filtersettings { 'BLOCK_EXECUTABLES' } eq 'on' ) ||
5653 ( $filtersettings { 'BLOCK_AUDIO-VIDEO' } eq 'on' ) ||
5654 ( $filtersettings { 'BLOCK_ARCHIVES' } eq 'on' ))
5656 $defaultrule .= "!files " ;
5658 $defaultrule .= "any" ;
5661 open ( FILE
, ">${General::swroot}/urlfilter/squidGuard.conf" ) or die "Unable to write squidGuard.conf file" ;
5664 print FILE
"logdir /var/log/squidGuard \n " ;
5665 print FILE
"dbhome $dbdir \n\n " ;
5667 undef @repositoryfiles ;
5668 if ( $filtersettings { 'ENABLE_REWRITE' } eq 'on' )
5670 @repositorylist = < $repository /*>;
5671 foreach ( @repositorylist )
5673 if (!- d
) { push ( @repositoryfiles , substr ( $_ , rindex ( $_ , "/" )+ 1 )); }
5677 if ((( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles )) || ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' ))
5679 print FILE
"rewrite rew-rule-0 { \n " ;
5681 if (( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles ))
5683 print FILE
" # rewrite localfiles \n " ;
5684 foreach ( @repositoryfiles )
5686 print FILE
" s@.*/ $_ \$\ @http :// $netsettings {'GREEN_ADDRESS'}:81/repository/ $_ \ @i \n " ;
5690 if ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' )
5692 print FILE
" # rewrite safesearch \n " ;
5693 print FILE
" s@(.* \\ Wgoogle \\ . \\ w+/(webhp|search|imghp|images|grphp|groups|frghp|froogle) \\ ?)(.*)( \\ bsafe= \\ w+)(.*)\@ \\ 1 \\ 3safe=strict \\ 5\ @i \n " ;
5694 print FILE
" s@(.* \\ Wgoogle \\ . \\ w+/(webhp|search|imghp|images|grphp|groups|frghp|froogle) \\ ?)(.*)\@ \\ 1safe=strict \\ \& \\ 3\ @i \n " ;
5695 print FILE
" s@(.* \\ Wsearch \\ .yahoo \\ . \\ w+/search \\ W)(.*)( \\ bvm= \\ w+)(.*)\@ \\ 1 \\ 2vm=r \\ 4\ @i \n " ;
5696 print FILE
" s@(.* \\ Wsearch \\ .yahoo \\ . \\ w+/search \\ W.*)\@ \\ 1 \\ \&vm=r\ @i \n " ;
5697 print FILE
" s@(.* \\ Walltheweb \\ .com/customize \\ ?)(.*)( \\ bcopt_offensive= \\ w+)(.*)\@ \\ 1 \\ 2copt_offensive=on \\ 4\ @i \n " ;
5702 if ((!( $filtersettings { 'UNFILTERED_CLIENTS' } eq '' )) && ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' )) {
5703 print FILE
"rewrite rew-rule-1 { \n " ;
5704 if (( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles ))
5706 print FILE
" # rewrite localfiles \n " ;
5707 foreach ( @repositoryfiles )
5709 print FILE
" s@.*/ $_ \$\ @http :// $netsettings {'GREEN_ADDRESS'}:81/repository/ $_ \ @i \n " ;
5712 print FILE
" # rewrite nothing \n " ;
5734 $uq [ 0 ] = $uq [ 0 ] * 60 ;
5735 if ( $uq [ 1 ] eq '0' ) {
5736 if ( $uq [ 2 ] eq 'hourly' ) { $uq [ 1 ] = 3600 }
5737 if ( $uq [ 2 ] eq 'daily' ) { $uq [ 1 ] = 86400 }
5738 if ( $uq [ 2 ] eq 'weekly' ) { $uq [ 1 ] = 604800 }
5741 print FILE
"src quota- $idx { \n " ;
5742 print FILE
" user $uq [3] \n " ;
5743 print FILE
" userquota $uq [0] $uq [1] $uq [2] \n " ;
5751 @tclist = & aggregatedconstraints
;
5760 if ( $tc [ 15 ] eq 'on' )
5763 print FILE
"src network- $idx { \n " ;
5764 print FILE
" ip $tc [12] \n " ;
5774 if ( $tc [ 15 ] eq 'on' )
5777 print FILE
"time constraint- $idx { \n " ;
5778 print FILE
" $tc [16] \n " ;
5784 if (!( $filtersettings { 'UNFILTERED_CLIENTS' } eq '' )) {
5785 print FILE
"src unfiltered { \n " ;
5786 print FILE
" ip $filtersettings {'UNFILTERED_CLIENTS'} \n " ;
5789 if (!( $filtersettings { 'BANNED_CLIENTS' } eq '' )) {
5790 print FILE
"src banned { \n " ;
5791 print FILE
" ip $filtersettings {'BANNED_CLIENTS'} \n " ;
5795 foreach $category ( @categories ) {
5796 print FILE
"dest $category { \n " ;
5797 if (- e
" $dbdir / $category /domains" ) {
5798 print FILE
" domainlist $category \/domains \n " ;
5800 if (- e
" $dbdir / $category /urls" ) {
5801 print FILE
" urllist $category \/urls \n " ;
5803 if ((- e
" $dbdir / $category /expressions" ) && ( $filtersettings { 'ENABLE_EXPR_LISTS' } eq 'on' )) {
5804 print FILE
" expressionlist $category \/expressions \n " ;
5806 if (( $category eq 'ads' ) && ( $filtersettings { 'ENABLE_EMPTY_ADS' } eq 'on' ))
5808 print FILE
" redirect http:\/\/ $netsettings {'GREEN_ADDRESS'}:81\/images/urlfilter/1x1.gif \n " ;
5810 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
5812 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
5814 print FILE
" logfile $ident $category .log \n " ;
5816 print FILE
" logfile $ident urlfilter.log \n " ;
5822 print FILE
"dest files { \n " ;
5823 print FILE
" expressionlist custom\/blocked\/files \n " ;
5824 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
5826 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
5828 print FILE
" logfile $ident files.log \n " ;
5830 print FILE
" logfile $ident urlfilter.log \n " ;
5835 print FILE
"dest custom-allowed { \n " ;
5836 print FILE
" domainlist custom\/allowed\/domains \n " ;
5837 print FILE
" urllist custom\/allowed\/urls \n " ;
5840 print FILE
"dest custom-blocked { \n " ;
5841 print FILE
" domainlist custom\/blocked\/domains \n " ;
5842 print FILE
" urllist custom\/blocked\/urls \n " ;
5843 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
5845 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
5847 print FILE
" logfile $ident custom.log \n " ;
5849 print FILE
" logfile $ident urlfilter.log \n " ;
5854 print FILE
"dest custom-expressions { \n " ;
5855 print FILE
" expressionlist custom\/blocked\/expressions \n " ;
5856 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
5858 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
5860 print FILE
" logfile $ident custom.log \n " ;
5862 print FILE
" logfile $ident urlfilter.log \n " ;
5867 print FILE
"acl { \n " ;
5868 if (!( $filtersettings { 'UNFILTERED_CLIENTS' } eq '' )) {
5869 print FILE
" unfiltered { \n " ;
5870 print FILE
" pass all \n " ;
5871 if ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' )
5873 print FILE
" rewrite rew-rule-1 \n " ;
5875 print FILE
" } \n\n " ;
5877 if (!( $filtersettings { 'BANNED_CLIENTS' } eq '' )) {
5878 print FILE
" banned { \n " ;
5879 print FILE
" pass " ;
5880 if (( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'on' ))
5882 print FILE
"custom-allowed " ;
5884 print FILE
"none \n " ;
5885 print FILE
" } \n\n " ;
5902 $qredirect = $redirect ;
5903 $qredirect =~ s/\%t/\%q\%20-\%20\%i/ ;
5904 print FILE
" quota- $idx { \n " ;
5905 print FILE
" pass " ;
5906 if (( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'on' ))
5908 print FILE
"custom-allowed " ;
5910 print FILE
"none \n " ;
5911 unless ( $redirect eq $qredirect ) { print FILE
" redirect $qredirect \n " ; }
5912 print FILE
" } \n\n " ;
5924 @ec = split ( /\|/ , $tc [ 13 ]);
5925 if ( $tc [ 15 ] eq 'on' )
5928 print FILE
" network- $idx $tc [0] constraint- $idx { \n " ;
5929 print FILE
" pass " ;
5931 if ( $filtersettings { 'BLOCK_ALL' } eq 'on' )
5933 if ( $tc [ 14 ] eq 'block' )
5935 if (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' )) {
5936 if (( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'on' ))
5938 print FILE
"custom-allowed " ;
5942 print FILE
$defaultrule ;
5949 print FILE
$defaultrule unless (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ));
5952 if ( $tc [ 14 ] eq 'block' )
5954 $tcrule = $defaultrule ;
5955 if ( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) {
5956 $tcrule =~ s/custom-allowed // ;
5957 print FILE
"custom-allowed " unless (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'off' ));
5959 if (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' )) {
5964 print FILE
"! $_ " unless ( index ( $defaultrule , "!" . $_ . " " ) ge 0 );
5967 print FILE
$tcrule unless (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ));
5969 $tcrule = $defaultrule ;
5972 $tcrule =~ s/!$_ // ;
5973 print FILE
" $_ " if ( $_ eq 'any' );
5975 print FILE
$tcrule unless (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ));
5981 print FILE
" } \n\n " ;
5986 print FILE
" default { \n " ;
5987 print FILE
" pass $defaultrule \n " ;
5988 if (( $filtersettings { 'ENABLE_LOG' } eq 'on' ) && ( $filtersettings { 'BLOCK_ALL' } eq 'on' ))
5990 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
5992 print FILE
" logfile" . $ident . " default.log \n " ;
5994 print FILE
" logfile" . $ident . " urlfilter.log \n " ;
5997 if ((( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles )) || ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' ))
5999 print FILE
" rewrite rew-rule-0 \n " ;
6001 print FILE
" redirect $redirect \n " ;
6008 # -------------------------------------------------------------------
6013 # This code is distributed under the terms of the GPL
6015 # (c) written from scratch
6017 # $Id: urlfilter.cgi,v 1.7 2006/05/08 00:00:00 marco Exp $
6022 # enable only the following on debugging purpose
6024 #use CGI::Carp 'fatalsToBrowser';
6029 require '/var/ipfire/general-functions.pl' ;
6030 require "${General::swroot}/lang.pl" ;
6031 require "${General::swroot}/header.pl" ;
6034 my %mainsettings =();
6035 my %proxysettings =();
6036 my %filtersettings =();
6040 my %updatesettings =();
6055 my $tcfile = "${General::swroot}/urlfilter/timeconst" ;
6056 my $uqfile = "${General::swroot}/urlfilter/userquota" ;
6057 my $dbdir = "${General::swroot}/urlfilter/blacklists" ;
6058 my $editdir = "${General::swroot}/urlfilter/editor" ;
6059 my $repository = "/home/httpd/html/repository" ;
6060 my $hintcolour = '#FFFFCC' ;
6062 my $sourceurlfile = "${General::swroot}/urlfilter/autoupdate/autoupdate.urls" ;
6063 my $updconffile = "${General::swroot}/urlfilter/autoupdate/autoupdate.conf" ;
6064 my $updflagfile = "${General::swroot}/urlfilter/blacklists/.autoupdate.last" ;
6065 my $upd_cron_dly = "${General::swroot}/urlfilter/autoupdate/cron.daily" ;
6066 my $upd_cron_wly = "${General::swroot}/urlfilter/autoupdate/cron.weekly" ;
6067 my $upd_cron_mly = "${General::swroot}/urlfilter/autoupdate/cron.monthly" ;
6069 my $errormessage = '' ;
6070 my $updatemessage = '' ;
6071 my $restoremessage = '' ;
6077 my @repositorylist =();
6078 my @repositoryfiles =();
6080 my @selectedcategories =();
6081 my @filtergroups =();
6084 my @source_urllist =();
6095 if (! - d
$dbdir ) { mkdir ( " $dbdir " ); }
6096 if (! - e
$tcfile ) { system ( "touch $tcfile " ); }
6097 if (! - e
$uqfile ) { system ( "touch $uqfile " ); }
6098 if (! - e
$sourceurlfile ) { system ( "touch $sourceurlfile " ); }
6100 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%netsettings );
6101 & General
:: readhash
( "${General::swroot}/main/settings" , \
%mainsettings );
6102 & General
:: readhash
( "${General::swroot}/proxy/settings" , \
%proxysettings );
6104 & readblockcategories
;
6106 open ( FILE
, $tcfile );
6109 open ( FILE
, $uqfile );
6112 open ( FILE
, $sourceurlfile );
6113 @source_urllist = < FILE
>;
6116 $filtersettings { 'ENABLE_CUSTOM_BLACKLIST' } = 'off' ;
6117 $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } = 'off' ;
6118 $filtersettings { 'ENABLE_CUSTOM_EXPRESSIONS' } = 'off' ;
6119 $filtersettings { 'BLOCK_EXECUTABLES' } = 'off' ;
6120 $filtersettings { 'BLOCK_AUDIO-VIDEO' } = 'off' ;
6121 $filtersettings { 'BLOCK_ARCHIVES' } = 'off' ;
6122 $filtersettings { 'ENABLE_REWRITE' } = 'off' ;
6123 $filtersettings { 'UNFILTERED_CLIENTS' } = '' ;
6124 $filtersettings { 'BANNED_CLIENTS' } = '' ;
6125 $filtersettings { 'SHOW_CATEGORY' } = 'off' ;
6126 $filtersettings { 'SHOW_URL' } = 'off' ;
6127 $filtersettings { 'SHOW_IP' } = 'off' ;
6128 $filtersettings { 'ENABLE_DNSERROR' } = 'off' ;
6129 $filtersettings { 'ENABLE_JPEG' } = 'off' ;
6130 $filtersettings { 'REDIRECT_PAGE' } = '' ;
6131 $filtersettings { 'MSG_TEXT_1' } = '' ;
6132 $filtersettings { 'MSG_TEXT_2' } = '' ;
6133 $filtersettings { 'MSG_TEXT_3' } = '' ;
6134 $filtersettings { 'ENABLE_EXPR_LISTS' } = 'off' ;
6135 $filtersettings { 'BLOCK_IP_ADDR' } = 'off' ;
6136 $filtersettings { 'BLOCK_ALL' } = 'off' ;
6137 $filtersettings { 'ENABLE_EMPTY_ADS' } = 'off' ;
6138 $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } = 'off' ;
6139 $filtersettings { 'ENABLE_SAFESEARCH' } = 'off' ;
6140 $filtersettings { 'ENABLE_LOG' } = 'off' ;
6141 $filtersettings { 'ENABLE_USERNAME_LOG' } = 'off' ;
6142 $filtersettings { 'ENABLE_CATEGORY_LOG' } = 'off' ;
6143 $filtersettings { 'CHILDREN' } = '5' ;
6144 $filtersettings { 'ENABLE_AUTOUPDATE' } = 'off' ;
6146 $filtersettings { 'ACTION' } = '' ;
6147 $filtersettings { 'VALID' } = '' ;
6149 & Header
:: getcgihash
( \
%filtersettings );
6150 & Header
:: getcgihash
( \
%tcsettings );
6151 & Header
:: getcgihash
( \
%uqsettings );
6152 & Header
:: getcgihash
( \
%besettings );
6154 if (( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'save' }) ||
6155 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter save and restart' }) ||
6156 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload file' }) ||
6157 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter remove file' }) ||
6158 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload background' }) ||
6159 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload blacklist' }) ||
6160 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter backup' }) ||
6161 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter restore' }))
6163 if (!( $filtersettings { 'CHILDREN' } =~ /^\d+$/ ) || ( $filtersettings { 'CHILDREN' } < 1 ))
6165 $errormessage = $Lang :: tr
{ 'urlfilter invalid num of children' };
6169 if ((!( $filtersettings { 'REDIRECT_PAGE' } eq '' )) && (!( $filtersettings { 'REDIRECT_PAGE' } =~ /^https?:\/ \
// )))
6171 $filtersettings { 'REDIRECT_PAGE' } = "http://" . $filtersettings { 'REDIRECT_PAGE' };
6174 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter remove file' })
6176 if (- e
" $repository / $filtersettings {'ID'}" ) { unlink ( " $repository / $filtersettings {'ID'}" ); }
6177 $filtersettings { 'ACTION' } = $Lang :: tr
{ 'urlfilter manage repository' };
6180 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload file' })
6182 & Header
:: getcgihash
( \
%filtersettings , { 'wantfile' => 1 , 'filevar' => 'UPLOADFILE' });
6184 $filtersettings { 'ACTION' } = $Lang :: tr
{ 'urlfilter manage repository' };
6185 $_ = $filtersettings { 'UPLOADFILE' };
6187 $_ = substr ( $_ , rindex ( $_ , "/" )+ 1 );
6189 if ( copy
( $filtersettings { 'UPLOADFILE' }, " $repository / $_ " ) != 1 )
6198 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload background' })
6200 & Header
:: getcgihash
( \
%filtersettings , { 'wantfile' => 1 , 'filevar' => 'BACKGROUND' });
6202 if ( copy
( $filtersettings { 'BACKGROUND' }, "/home/httpd/html/images/urlfilter/background.jpg" ) != 1 )
6209 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload blacklist' })
6211 & Header
:: getcgihash
( \
%filtersettings , { 'wantfile' => 1 , 'filevar' => 'UPDATEFILE' });
6213 if (!( $filtersettings { 'UPDATEFILE' } =~ /.tar.gz$/ ))
6215 $errormessage = $Lang :: tr
{ 'urlfilter wrong filetype' };
6219 if ( copy
( $filtersettings { 'UPDATEFILE' }, "${General::swroot}/urlfilter/blacklists.tar.gz" ) != 1 )
6225 if (!(- d
"${General::swroot}/urlfilter/update" )) { mkdir ( "${General::swroot}/urlfilter/update" ); }
6227 my $exitcode = system ( "/bin/tar --no-same-owner -xzf ${General::swroot}/urlfilter/blacklists.tar.gz -C ${General::swroot}/urlfilter/update" );
6231 $errormessage = $Lang :: tr
{ 'urlfilter tar error' };
6234 if (- d
"${General::swroot}/urlfilter/update/category" )
6236 system ( "mv ${General::swroot}/urlfilter/update/category ${General::swroot}/urlfilter/update/blacklists" );
6239 if (!(- d
"${General::swroot}/urlfilter/update/blacklists" ))
6241 $errormessage = $Lang :: tr
{ 'urlfilter invalid content' };
6243 system ( "cp -r ${General::swroot}/urlfilter/update/blacklists/* $dbdir " );
6245 & readblockcategories
;
6250 $updatemessage = $Lang :: tr
{ 'urlfilter upload success' };
6251 system ( "${General::swroot}/urlfilter/bin/prebuild.pl &" );
6252 system ( "logger -t installpackage[urlfilter] \" URL filter blacklist - Blacklist update from local source completed \" " );
6255 if (- d
"${General::swroot}/urlfilter/update" ) { system ( "rm -rf ${General::swroot}/urlfilter/update" ); }
6256 if (- e
"${General::swroot}/urlfilter/blacklists.tar.gz" ) { unlink ( "${General::swroot}/urlfilter/blacklists.tar.gz" ); }
6257 if ( $errormessage ) { goto ERROR
; }
6260 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter backup' })
6262 $blistbackup = ( $filtersettings { 'ENABLE_FULLBACKUP' } eq 'on' ) ?
"blacklists" : "blacklists/custom" ;
6263 if ( system ( "/bin/tar -C ${General::swroot}/urlfilter -czf ${General::swroot}/urlfilter/backup.tar.gz settings timeconst userquota autoupdate $blistbackup " ))
6265 $errormessage = $Lang :: tr
{ 'urlfilter backup error' };
6270 print "Content-type: application/gzip \n " ;
6271 print "Content-length: " ;
6272 print (- s
"${General::swroot}/urlfilter/backup.tar.gz" );
6274 print "Content-disposition: attachment; filename=urlfilter-backup.tar.gz \n\n " ;
6276 open ( FILE
, "${General::swroot}/urlfilter/backup.tar.gz" );
6277 while (< FILE
>) { print ; }
6280 if (- e
"${General::swroot}/urlfilter/backup.tar.gz" ) { unlink ( "${General::swroot}/urlfilter/backup.tar.gz" ); }
6285 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter restore' })
6287 & Header
:: getcgihash
( \
%filtersettings , { 'wantfile' => 1 , 'filevar' => 'UPDATEFILE' });
6289 if (!( $filtersettings { 'UPDATEFILE' } =~ /.tar.gz$/ ))
6291 $errormessage = $Lang :: tr
{ 'urlfilter wrong filetype' };
6295 if (!(- d
"${General::swroot}/urlfilter/restore" )) { mkdir ( "${General::swroot}/urlfilter/restore" ); }
6297 if ( copy
( $filtersettings { 'UPDATEFILE' }, "${General::swroot}/urlfilter/backup.tar.gz" ) != 1 )
6302 my $exitcode = system ( "/bin/tar --no-same-owner --preserve-permissions -xzf ${General::swroot}/urlfilter/backup.tar.gz -C ${General::swroot}/urlfilter/restore" );
6305 $errormessage = $Lang :: tr
{ 'urlfilter tar error' };
6307 if (!(- e
"${General::swroot}/urlfilter/restore/settings" ))
6309 $errormessage = $Lang :: tr
{ 'urlfilter invalid restore file' };
6311 system ( "cp -rp ${General::swroot}/urlfilter/restore/* ${General::swroot}/urlfilter/" );
6312 & readblockcategories
;
6316 $restoremessage = $Lang :: tr
{ 'urlfilter restore success' };
6320 if (- e
"${General::swroot}/urlfilter/backup.tar.gz" ) { unlink ( "${General::swroot}/urlfilter/backup.tar.gz" ); }
6321 if (- d
"${General::swroot}/urlfilter/restore" ) { system ( "rm -rf ${General::swroot}/urlfilter/restore" ); }
6322 if ( $errormessage ) { goto ERROR
; }
6325 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'save' })
6327 $filtersettings { 'VALID' } = 'yes' ;
6331 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter save and restart' })
6333 if (!(- e
"${General::swroot}/proxy/enable" ))
6335 $errormessage = $Lang :: tr
{ 'urlfilter web proxy service required' };
6338 if (!( $proxysettings { 'ENABLE_FILTER' } eq 'on' ))
6340 $errormessage = $Lang :: tr
{ 'urlfilter not enabled' };
6344 $filtersettings { 'VALID' } = 'yes' ;
6347 system ( "chown -R nobody.nobody $dbdir " );
6349 if (- e
" $dbdir /custom/allowed/domains.db" ) { unlink ( " $dbdir /custom/allowed/domains.db" ); }
6350 if (- e
" $dbdir /custom/allowed/urls.db" ) { unlink ( " $dbdir /custom/allowed/urls.db" ); }
6351 if (- e
" $dbdir /custom/blocked/domains.db" ) { unlink ( " $dbdir /custom/blocked/domains.db" ); }
6352 if (- e
" $dbdir /custom/blocked/urls.db" ) { unlink ( " $dbdir /custom/blocked/urls.db" ); }
6354 foreach (< $dbdir /*>)
6356 if (- d
$_ ){ system ( "chmod 644 $_ /*" ); }
6357 if (- d
$_ ){ system ( "chmod 666 $_ /*.db" ); }
6359 if (- d
" $dbdir /custom/allowed" )
6361 system ( "chmod 755 $dbdir /custom/allowed" );
6362 system ( "chmod 644 $dbdir /custom/allowed/*" );
6364 if (- d
" $dbdir /custom/blocked" )
6366 system ( "chmod 755 $dbdir /custom/blocked" );
6367 system ( "chmod 644 $dbdir /custom/blocked/*" );
6370 system ( '/usr/local/bin/restartsquid' );
6375 if ( $errormessage ) { $filtersettings { 'VALID' } = 'no' ; }
6379 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter set time constraints' }) { $tcsettings { 'TCMODE' } = 'on' }
6381 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'add' }))
6383 $tcsettings { 'TCMODE' }= 'on' ;
6385 if (! $tcsettings { 'DST' })
6387 $errormessage = $Lang :: tr
{ 'urlfilter dst error' };
6390 if (! $tcsettings { 'SRC' })
6392 $errormessage = $Lang :: tr
{ 'urlfilter src error' };
6395 if (!( $tcsettings { 'TO_HOUR' }. $tcsettings { 'TO_MINUTE' } gt $tcsettings { 'FROM_HOUR' }. $tcsettings { 'FROM_MINUTE' }))
6397 $errormessage = $Lang :: tr
{ 'urlfilter timespace error' };
6400 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' )))
6402 $errormessage = $Lang :: tr
{ 'urlfilter weekday error' };
6407 if ( $tcsettings { 'DST' } =~ /^any/ ) { $tcsettings { 'DST' } = 'any' ; }
6408 if ( $tcsettings { 'ENABLERULE' } eq 'on' ) { $tcsettings { 'ACTIVE' } = $tcsettings { 'ENABLERULE' }; } else { $tcsettings { 'ACTIVE' } = 'off' }
6410 $tcsettings { 'ENABLERULE' } = 'on' ;
6411 if ( $tcsettings { 'EDITING' } eq 'no' ) {
6412 open ( FILE
, ">> $tcfile " );
6414 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 " ;
6416 open ( FILE
, "> $tcfile " );
6419 foreach $line ( @tclist )
6422 if ( $tcsettings { 'EDITING' } eq $id ) {
6423 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 " ;
6424 } else { print FILE
" $line " ; }
6429 $tcsettings { 'CHANGED' }= 'yes' ;
6430 $tcsettings { 'TCMODE' }= 'on' ;
6433 if ( $tcsettings { 'EDITING' } ne 'no' )
6435 $tcsettings { 'ACTION' } = $Lang :: tr
{ 'edit' };
6436 $tcsettings { 'ID' } = $tcsettings { 'EDITING' };
6441 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'remove' }))
6444 open ( FILE
, "> $tcfile " );
6446 foreach $line ( @tclist )
6449 unless ( $tcsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
6452 $tcsettings { 'CHANGED' }= 'yes' ;
6453 $tcsettings { 'TCMODE' }= 'on' ;
6456 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter restart' }))
6458 if (!( $proxysettings { 'ENABLE_FILTER' } eq 'on' ))
6460 $errormessage = $Lang :: tr
{ 'urlfilter not enabled' };
6462 if (!(- e
"${General::swroot}/proxy/enable" ))
6464 $errormessage = $Lang :: tr
{ 'urlfilter web proxy service required' };
6467 if (! $errormessage ) { system ( '/usr/local/bin/restartsquid' ); }
6468 $tcsettings { 'TCMODE' }= 'on' ;
6471 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }))
6473 open ( FILE
, "> $tcfile " );
6476 foreach $line ( @tclist )
6479 unless ( $tcsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
6483 @temp = split ( /\,/ , $line );
6484 if ( $temp [ 15 ] eq 'on' ) { $temp [ 15 ] = 'off' ; } else { $temp [ 15 ] = 'on' }
6485 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 " ;
6489 $tcsettings { 'CHANGED' }= 'yes' ;
6490 $tcsettings { 'TCMODE' }= 'on' ;
6493 if (! $errormessage ) {
6494 $tcsettings { 'ENABLERULE' }= 'on' ;
6495 $tcsettings { 'TO_HOUR' }= '24' ;
6498 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) && (! $errormessage ))
6501 foreach $line ( @tclist )
6504 if ( $tcsettings { 'ID' } eq $id )
6507 @temp = split ( /\,/ , $line );
6508 $tcsettings { 'DEFINITION' } = $temp [ 0 ];
6509 $tcsettings { 'MON' } = $temp [ 1 ];
6510 $tcsettings { 'TUE' } = $temp [ 2 ];
6511 $tcsettings { 'WED' } = $temp [ 3 ];
6512 $tcsettings { 'THU' } = $temp [ 4 ];
6513 $tcsettings { 'FRI' } = $temp [ 5 ];
6514 $tcsettings { 'SAT' } = $temp [ 6 ];
6515 $tcsettings { 'SUN' } = $temp [ 7 ];
6516 $tcsettings { 'FROM_HOUR' } = $temp [ 8 ];
6517 $tcsettings { 'FROM_MINUTE' } = $temp [ 9 ];
6518 $tcsettings { 'TO_HOUR' } = $temp [ 10 ];
6519 $tcsettings { 'TO_MINUTE' } = $temp [ 11 ];
6520 $tcsettings { 'SRC' } = $temp [ 12 ];
6521 $tcsettings { 'DST' } = $temp [ 13 ];
6522 $tcsettings { 'ACCESS' } = $temp [ 14 ];
6523 $tcsettings { 'ENABLERULE' } = $temp [ 15 ];
6524 $tcsettings { 'COMMENT' } = $temp [ 16 ];
6527 $tcsettings { 'TCMODE' }= 'on' ;
6530 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter set user quota' }) { $uqsettings { 'UQMODE' } = 'on' }
6532 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'add' }))
6534 $uqsettings { 'UQMODE' }= 'on' ;
6536 if ((!( $uqsettings { 'TIME_QUOTA' } =~ /^\d+/ )) || ( $uqsettings { 'TIME_QUOTA' } < '1' ))
6538 $errormessage = $Lang :: tr
{ 'urlfilter quota time error' };
6541 @temp = split ( /\n/ , $uqsettings { 'QUOTA_USERS' });
6542 undef $uqsettings { 'QUOTA_USERS' };
6545 s/^\s+//g ; s/\s+$//g ;
6546 if ( $_ ) { $uqsettings { 'QUOTA_USERS' } .= $_ . " \n " ; }
6549 if ( $uqsettings { 'QUOTA_USERS' } eq '' )
6551 $errormessage = $Lang :: tr
{ 'urlfilter quota user error' };
6554 $_ = $uqsettings { 'QUOTA_USERS' };
6556 my $quota_users = $_ ;
6558 if ( $uqsettings { 'QUOTA_USERS' } =~ /\\/ )
6560 $errormessage = $Lang :: tr
{ 'urlfilter invalid user error' };
6563 if (! $errormessage ) {
6564 if ( $uqsettings { 'ENABLEQUOTA' } eq 'on' ) { $uqsettings { 'ACTIVE' } = $uqsettings { 'ENABLEQUOTA' }; } else { $uqsettings { 'ACTIVE' } = 'off' }
6566 $uqsettings { 'ENABLERULE' } = 'on' ;
6567 if ( $uqsettings { 'EDITING' } eq 'no' ) {
6568 open ( FILE
, ">> $uqfile " );
6570 print FILE
" $uqsettings {'TIME_QUOTA'}, $uqsettings {'SPORADIC'}, $uqsettings {'RENEWAL'}, $quota_users , $uqsettings {'ACTIVE'} \n " ;
6572 open ( FILE
, "> $uqfile " );
6575 foreach $line ( @uqlist )
6578 if ( $uqsettings { 'EDITING' } eq $id ) {
6579 print FILE
" $uqsettings {'TIME_QUOTA'}, $uqsettings {'SPORADIC'}, $uqsettings {'RENEWAL'}, $quota_users , $uqsettings {'ACTIVE'} \n " ;
6580 } else { print FILE
" $line " ; }
6585 $uqsettings { 'CHANGED' }= 'yes' ;
6586 $uqsettings { 'MODE' }= 'USERQUOTA' ;
6587 $uqsettings { 'UQMODE' }= 'on' ;
6590 if ( $uqsettings { 'EDITING' } ne 'no' )
6592 $uqsettings { 'ACTION' } = $Lang :: tr
{ 'edit' };
6593 $uqsettings { 'ID' } = $uqsettings { 'EDITING' };
6598 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'remove' }))
6601 open ( FILE
, "> $uqfile " );
6603 foreach $line ( @uqlist )
6606 unless ( $uqsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
6609 $uqsettings { 'CHANGED' }= 'yes' ;
6610 $uqsettings { 'UQMODE' }= 'on' ;
6613 if (! $errormessage ) {
6614 $uqsettings { 'ENABLEQUOTA' }= 'on' ;
6617 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) && (! $errormessage ))
6620 foreach $line ( @uqlist )
6623 if ( $uqsettings { 'ID' } eq $id )
6626 @temp = split ( /\,/ , $line );
6627 $uqsettings { 'TIME_QUOTA' } = $temp [ 0 ];
6628 $uqsettings { 'SPORADIC' } = $temp [ 1 ];
6629 $uqsettings { 'RENEWAL' } = $temp [ 2 ];
6630 $uqsettings { 'QUOTA_USERS' } = $temp [ 3 ];
6631 $uqsettings { 'ENABLEQUOTA' } = $temp [ 4 ];
6634 $uqsettings { 'UQMODE' }= 'on' ;
6637 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }))
6639 open ( FILE
, "> $uqfile " );
6642 foreach $line ( @uqlist )
6645 unless ( $uqsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
6649 @temp = split ( /\,/ , $line );
6650 if ( $temp [ 4 ] eq 'on' ) { $temp [ 4 ] = 'off' ; } else { $temp [ 4 ] = 'on' }
6651 print FILE
" $temp [0], $temp [1], $temp [2], $temp [3], $temp [4] \n " ;
6655 $uqsettings { 'CHANGED' }= 'yes' ;
6656 $uqsettings { 'UQMODE' }= 'on' ;
6659 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter restart' }))
6661 if (!( $proxysettings { 'ENABLE_FILTER' } eq 'on' ))
6663 $errormessage = $Lang :: tr
{ 'urlfilter not enabled' };
6665 if (!(- e
"${General::swroot}/proxy/enable" ))
6667 $errormessage = $Lang :: tr
{ 'urlfilter web proxy service required' };
6670 if (! $errormessage ) { system ( '/usr/local/bin/restartsquid' ); }
6671 $uqsettings { 'UQMODE' }= 'on' ;
6674 if ( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter blacklist editor' }) { $besettings { 'BEMODE' } = 'on' ; }
6676 if ( $besettings { 'MODE' } eq 'BLACKLIST_EDITOR' )
6678 @temp = split ( /\n/ , $besettings { 'BE_DOMAINS' });
6679 undef $besettings { 'BE_DOMAINS' };
6682 s/^\s+//g ; s/\s+$//g ;
6683 if ( $_ ) { $besettings { 'BE_DOMAINS' } .= $_ . " \n " ; }
6685 chomp ( $besettings { 'BE_DOMAINS' });
6686 @temp = split ( /\n/ , $besettings { 'BE_URLS' });
6687 undef $besettings { 'BE_URLS' };
6690 s/^\s+//g ; s/\s+$//g ;
6691 if ( $_ ) { $besettings { 'BE_URLS' } .= $_ . " \n " ; }
6693 chomp ( $besettings { 'BE_URLS' });
6694 @temp = split ( /\n/ , $besettings { 'BE_EXPRESSIONS' });
6695 undef $besettings { 'BE_EXPRESSIONS' };
6698 s/^\s+//g ; s/\s+$//g ;
6699 if ( $_ ) { $besettings { 'BE_EXPRESSIONS' } .= $_ . " \n " ; }
6701 chomp ( $besettings { 'BE_EXPRESSIONS' });
6704 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter load blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
6706 $besettings { 'BEMODE' } = 'on' ;
6708 $besettings { 'BE_NAME' } = $besettings { 'BE_BLACKLIST' };
6710 delete $besettings { 'BE_DOMAINS' };
6711 delete $besettings { 'BE_URLS' };
6712 delete $besettings { 'BE_EXPRESSIONS' };
6714 if (- e
" $dbdir / $besettings {'BE_NAME'}/domains" )
6716 open ( FILE
, " $dbdir / $besettings {'BE_NAME'}/domains" );
6717 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_DOMAINS' } .= $_ } };
6719 chomp ( $besettings { 'BE_DOMAINS' });
6721 if (- e
" $dbdir / $besettings {'BE_NAME'}/urls" )
6723 open ( FILE
, " $dbdir / $besettings {'BE_NAME'}/urls" );
6724 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_URLS' } .= $_ } };
6726 chomp ( $besettings { 'BE_URLS' });
6728 if (- e
" $dbdir / $besettings {'BE_NAME'}/expressions" )
6730 open ( FILE
, " $dbdir / $besettings {'BE_NAME'}/expressions" );
6731 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_EXPRESSIONS' } .= $_ } };
6733 chomp ( $besettings { 'BE_EXPRESSIONS' });
6737 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter import blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
6739 $besettings { 'BEMODE' } = 'on' ;
6741 & Header
:: getcgihash
( \
%besettings , { 'wantfile' => 1 , 'filevar' => 'IMPORTFILE' });
6743 if (!( $besettings { 'IMPORTFILE' } =~ /.tar.gz$/ ))
6745 $errormessage = $Lang :: tr
{ 'urlfilter wrong filetype' };
6747 if (!- d
" $editdir " ) { mkdir ( " $editdir " ); }
6749 if ( copy
( $besettings { 'IMPORTFILE' }, " $editdir /blacklist.tar.gz" ) != 1 )
6754 my $exitcode = system ( "/bin/tar --no-same-owner --preserve-permissions -xzf $editdir /blacklist.tar.gz -C $editdir " );
6757 $errormessage = $Lang :: tr
{ 'urlfilter tar error' };
6760 foreach (< $editdir /blacklists/ *>)
6765 $besettings { 'BE_NAME' } = substr ( $_ , rindex ( $_ , "/" )+ 1 );
6771 $errormessage = $Lang :: tr
{ 'urlfilter invalid import file' };
6773 delete $besettings { 'BE_DOMAINS' };
6774 delete $besettings { 'BE_URLS' };
6775 delete $besettings { 'BE_EXPRESSIONS' };
6777 if (- e
" $editdir /blacklists/ $besettings {'BE_NAME'}/domains" )
6779 open ( FILE
, " $editdir /blacklists/ $besettings {'BE_NAME'}/domains" );
6780 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_DOMAINS' } .= $_ } };
6782 chomp ( $besettings { 'BE_DOMAINS' });
6784 if (- e
" $editdir /blacklists/ $besettings {'BE_NAME'}/urls" )
6786 open ( FILE
, " $editdir /blacklists/ $besettings {'BE_NAME'}/urls" );
6787 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_URLS' } .= $_ } };
6789 chomp ( $besettings { 'BE_URLS' });
6791 if (- e
" $editdir /blacklists/ $besettings {'BE_NAME'}/expressions" )
6793 open ( FILE
, " $editdir /blacklists/ $besettings {'BE_NAME'}/expressions" );
6794 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_EXPRESSIONS' } .= $_ } };
6796 chomp ( $besettings { 'BE_EXPRESSIONS' });
6801 if (- d
$editdir ) { system ( "rm -rf $editdir " ); }
6807 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter export blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
6809 $besettings { 'BEMODE' } = 'on' ;
6811 if ( $besettings { 'BE_NAME' } eq '' )
6813 $errormessage = $Lang :: tr
{ 'urlfilter category name error' };
6814 } elsif ( $besettings { 'BE_DOMAINS' } || $besettings { 'BE_URLS' } || $besettings { 'BE_EXPRESSIONS' }) {
6816 $_ = $besettings { 'BE_NAME' }; tr/A-Z/a-z/ ; $besettings { 'BE_NAME' } = $_ ;
6818 if (!(- d
" $editdir " )) { mkdir ( " $editdir " ); }
6819 if (!(- d
" $editdir /blacklists" )) { mkdir ( " $editdir /blacklists" ); }
6820 if (!(- d
" $editdir /blacklists/ $besettings {'BE_NAME'}" )) { mkdir ( " $editdir /blacklists/ $besettings {'BE_NAME'}" ); }
6822 open ( FILE
, "> $editdir /blacklists/ $besettings {'BE_NAME'}/domains" );
6824 print FILE
" $besettings {'BE_DOMAINS'} \n " ;
6826 open ( FILE
, "> $editdir /blacklists/ $besettings {'BE_NAME'}/urls" );
6828 print FILE
" $besettings {'BE_URLS'} \n " ;
6830 open ( FILE
, "> $editdir /blacklists/ $besettings {'BE_NAME'}/expressions" );
6832 print FILE
" $besettings {'BE_EXPRESSIONS'} \n " ;
6835 if ( system ( "/bin/tar -C $editdir -czf $editdir / $besettings {'BE_NAME'}.tar.gz blacklists" ))
6837 $errormessage = $Lang :: tr
{ 'urlfilter export error' };
6841 print "Content-type: application/gzip \n " ;
6842 print "Content-length: " ;
6843 print (- s
" $editdir / $besettings {'BE_NAME'}.tar.gz" );
6845 print "Content-disposition: attachment; filename= $besettings {'BE_NAME'}.tar.gz \n\n " ;
6847 open ( FILE
, " $editdir / $besettings {'BE_NAME'}.tar.gz" );
6848 while (< FILE
>) { print ; }
6851 if (- d
$editdir ) { system ( "rm -rf $editdir " ); }
6855 $errormessage = $Lang :: tr
{ 'urlfilter category data error' };
6859 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter install blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
6861 $besettings { 'BEMODE' } = 'on' ;
6863 if ( $besettings { 'BE_NAME' } eq '' )
6865 $errormessage = $Lang :: tr
{ 'urlfilter category name error' };
6866 } elsif ( $besettings { 'BE_DOMAINS' } || $besettings { 'BE_URLS' } || $besettings { 'BE_EXPRESSIONS' }) {
6868 $_ = $besettings { 'BE_NAME' }; tr/A-Z/a-z/ ; $besettings { 'BE_NAME' } = $_ ;
6870 if (!- d
" $editdir " ) { mkdir ( " $editdir " ); }
6872 if (!- d
" $dbdir / $besettings {'BE_NAME'}" ) { mkdir ( " $dbdir / $besettings {'BE_NAME'}" ); }
6874 if (- e
" $dbdir / $besettings {'BE_NAME'}/domains" ) { unlink ( " $dbdir / $besettings {'BE_NAME'}/domains" ); }
6875 if ( $besettings { 'BE_DOMAINS' })
6877 open ( FILE
, "> $dbdir / $besettings {'BE_NAME'}/domains" );
6879 print FILE
" $besettings {'BE_DOMAINS'} \n " ;
6882 if (- e
" $dbdir / $besettings {'BE_NAME'}/urls" ) { unlink ( " $dbdir / $besettings {'BE_NAME'}/urls" ); }
6883 if ( $besettings { 'BE_URLS' })
6885 open ( FILE
, "> $dbdir / $besettings {'BE_NAME'}/urls" );
6887 print FILE
" $besettings {'BE_URLS'} \n " ;
6890 if (- e
" $dbdir / $besettings {'BE_NAME'}/expressions" ) { unlink ( " $dbdir / $besettings {'BE_NAME'}/expressions" ); }
6891 if ( $besettings { 'BE_EXPRESSIONS' })
6893 open ( FILE
, "> $dbdir / $besettings {'BE_NAME'}/expressions" );
6895 print FILE
" $besettings {'BE_EXPRESSIONS'} \n " ;
6899 open ( FILE
, "> $editdir /install.conf" );
6901 print FILE
"logdir /var/log/squidGuard \n " ;
6902 print FILE
"dbhome $dbdir / $besettings {'BE_NAME'} \n\n " ;
6903 print FILE
"dest $besettings {'BE_NAME'} { \n " ;
6904 if ( $besettings { 'BE_DOMAINS' }) { print FILE
" domainlist domains \n " ; }
6905 if ( $besettings { 'BE_URLS' }) { print FILE
" urllist urls \n " ; }
6906 if ( $besettings { 'BE_EXPRESSIONS' }) { print FILE
" expressions expressions \n " ; }
6908 print FILE
"acl { \n " ;
6909 print FILE
" default { \n " ;
6910 print FILE
" pass none \n " ;
6915 system ( "rm -f $dbdir / $besettings {'BE_NAME'}/*.db" );
6916 system ( "/usr/sbin/squidGuard -c $editdir /install.conf -C all" );
6917 system ( "chmod a+w $dbdir / $besettings {'BE_NAME'}/*.db" );
6919 & readblockcategories
;
6924 system ( '/usr/local/bin/restartsquid' ) unless ( $besettings { 'NORESTART' } eq 'on' );
6926 if (- d
$editdir ) { system ( "rm -rf $editdir " ); }
6928 $errormessage = $Lang :: tr
{ 'urlfilter category data error' };
6932 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter save schedule' })
6934 if (( $filtersettings { 'UPDATE_SOURCE' } eq 'custom' ) && ( $filtersettings { 'CUSTOM_UPDATE_URL' } eq '' ))
6936 $errormessage = $Lang :: tr
{ 'urlfilter custom url required' };
6938 open ( FILE
, "> $updconffile " );
6939 print FILE
"ENABLE_AUTOUPDATE= $filtersettings {'ENABLE_AUTOUPDATE'} \n " ;
6940 print FILE
"UPDATE_SCHEDULE= $filtersettings {'UPDATE_SCHEDULE'} \n " ;
6941 print FILE
"UPDATE_SOURCE= $filtersettings {'UPDATE_SOURCE'} \n " ;
6942 print FILE
"CUSTOM_UPDATE_URL= $filtersettings {'CUSTOM_UPDATE_URL'} \n " ;
6945 if (- e
$upd_cron_dly ) { unlink ( $upd_cron_dly ); }
6946 if (- e
$upd_cron_wly ) { unlink ( $upd_cron_wly ); }
6947 if (- e
$upd_cron_mly ) { unlink ( $upd_cron_mly ); }
6949 if (( $filtersettings { 'ENABLE_AUTOUPDATE' } eq 'on' ) && ( $filtersettings { 'UPDATE_SCHEDULE' } eq 'daily' ))
6951 symlink ( "../bin/autoupdate.pl" , $upd_cron_dly )
6953 symlink ( "/bin/false" , $upd_cron_dly )
6956 if (( $filtersettings { 'ENABLE_AUTOUPDATE' } eq 'on' ) && ( $filtersettings { 'UPDATE_SCHEDULE' } eq 'weekly' ))
6958 symlink ( "../bin/autoupdate.pl" , $upd_cron_wly )
6960 symlink ( "/bin/false" , $upd_cron_wly )
6963 if (( $filtersettings { 'ENABLE_AUTOUPDATE' } eq 'on' ) && ( $filtersettings { 'UPDATE_SCHEDULE' } eq 'monthly' ))
6965 symlink ( "../bin/autoupdate.pl" , $upd_cron_mly )
6967 symlink ( "/bin/false" , $upd_cron_mly )
6972 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter update now' })
6974 if ( $filtersettings { 'UPDATE_SOURCE' } eq 'custom' )
6976 if ( $filtersettings { 'CUSTOM_UPDATE_URL' } eq '' )
6978 $errormessage = $Lang :: tr
{ 'urlfilter custom url required' };
6980 system ( "${General::swroot}/urlfilter/bin/autoupdate.pl $filtersettings {'CUSTOM_UPDATE_URL'} &" );
6983 system ( "${General::swroot}/urlfilter/bin/autoupdate.pl $filtersettings {'UPDATE_SOURCE'} &" );
6988 if (- e
"${General::swroot}/urlfilter/settings" ) { & General
:: readhash
( "${General::swroot}/urlfilter/settings" , \
%filtersettings ); }
6992 $checked { 'ENABLE_CUSTOM_BLACKLIST' }{ 'off' } = '' ;
6993 $checked { 'ENABLE_CUSTOM_BLACKLIST' }{ 'on' } = '' ;
6994 $checked { 'ENABLE_CUSTOM_BLACKLIST' }{ $filtersettings { 'ENABLE_CUSTOM_BLACKLIST' }} = "checked='checked'" ;
6995 $checked { 'ENABLE_CUSTOM_WHITELIST' }{ 'off' } = '' ;
6996 $checked { 'ENABLE_CUSTOM_WHITELIST' }{ 'on' } = '' ;
6997 $checked { 'ENABLE_CUSTOM_WHITELIST' }{ $filtersettings { 'ENABLE_CUSTOM_WHITELIST' }} = "checked='checked'" ;
6998 $checked { 'ENABLE_CUSTOM_EXPRESSIONS' }{ 'off' } = '' ;
6999 $checked { 'ENABLE_CUSTOM_EXPRESSIONS' }{ 'on' } = '' ;
7000 $checked { 'ENABLE_CUSTOM_EXPRESSIONS' }{ $filtersettings { 'ENABLE_CUSTOM_EXPRESSIONS' }} = "checked='checked'" ;
7001 $checked { 'BLOCK_EXECUTABLES' }{ 'off' } = '' ;
7002 $checked { 'BLOCK_EXECUTABLES' }{ 'on' } = '' ;
7003 $checked { 'BLOCK_EXECUTABLES' }{ $filtersettings { 'BLOCK_EXECUTABLES' }} = "checked='checked'" ;
7004 $checked { 'BLOCK_AUDIO-VIDEO' }{ 'off' } = '' ;
7005 $checked { 'BLOCK_AUDIO-VIDEO' }{ 'on' } = '' ;
7006 $checked { 'BLOCK_AUDIO-VIDEO' }{ $filtersettings { 'BLOCK_AUDIO-VIDEO' }} = "checked='checked'" ;
7007 $checked { 'BLOCK_ARCHIVES' }{ 'off' } = '' ;
7008 $checked { 'BLOCK_ARCHIVES' }{ 'on' } = '' ;
7009 $checked { 'BLOCK_ARCHIVES' }{ $filtersettings { 'BLOCK_ARCHIVES' }} = "checked='checked'" ;
7010 $checked { 'ENABLE_REWRITE' }{ 'off' } = '' ;
7011 $checked { 'ENABLE_REWRITE' }{ 'on' } = '' ;
7012 $checked { 'ENABLE_REWRITE' }{ $filtersettings { 'ENABLE_REWRITE' }} = "checked='checked'" ;
7013 $checked { 'SHOW_CATEGORY' }{ 'off' } = '' ;
7014 $checked { 'SHOW_CATEGORY' }{ 'on' } = '' ;
7015 $checked { 'SHOW_CATEGORY' }{ $filtersettings { 'SHOW_CATEGORY' }} = "checked='checked'" ;
7016 $checked { 'SHOW_URL' }{ 'off' } = '' ;
7017 $checked { 'SHOW_URL' }{ 'on' } = '' ;
7018 $checked { 'SHOW_URL' }{ $filtersettings { 'SHOW_URL' }} = "checked='checked'" ;
7019 $checked { 'SHOW_IP' }{ 'off' } = '' ;
7020 $checked { 'SHOW_IP' }{ 'on' } = '' ;
7021 $checked { 'SHOW_IP' }{ $filtersettings { 'SHOW_IP' }} = "checked='checked'" ;
7022 $checked { 'ENABLE_DNSERROR' }{ 'off' } = '' ;
7023 $checked { 'ENABLE_DNSERROR' }{ 'on' } = '' ;
7024 $checked { 'ENABLE_DNSERROR' }{ $filtersettings { 'ENABLE_DNSERROR' }} = "checked='checked'" ;
7025 $checked { 'ENABLE_JPEG' }{ 'off' } = '' ;
7026 $checked { 'ENABLE_JPEG' }{ 'on' } = '' ;
7027 $checked { 'ENABLE_JPEG' }{ $filtersettings { 'ENABLE_JPEG' }} = "checked='checked'" ;
7028 $checked { 'ENABLE_EXPR_LISTS' }{ 'off' } = '' ;
7029 $checked { 'ENABLE_EXPR_LISTS' }{ 'on' } = '' ;
7030 $checked { 'ENABLE_EXPR_LISTS' }{ $filtersettings { 'ENABLE_EXPR_LISTS' }} = "checked='checked'" ;
7031 $checked { 'BLOCK_IP_ADDR' }{ 'off' } = '' ;
7032 $checked { 'BLOCK_IP_ADDR' }{ 'on' } = '' ;
7033 $checked { 'BLOCK_IP_ADDR' }{ $filtersettings { 'BLOCK_IP_ADDR' }} = "checked='checked'" ;
7034 $checked { 'BLOCK_ALL' }{ 'off' } = '' ;
7035 $checked { 'BLOCK_ALL' }{ 'on' } = '' ;
7036 $checked { 'BLOCK_ALL' }{ $filtersettings { 'BLOCK_ALL' }} = "checked='checked'" ;
7037 $checked { 'ENABLE_EMPTY_ADS' }{ 'off' } = '' ;
7038 $checked { 'ENABLE_EMPTY_ADS' }{ 'on' } = '' ;
7039 $checked { 'ENABLE_EMPTY_ADS' }{ $filtersettings { 'ENABLE_EMPTY_ADS' }} = "checked='checked'" ;
7040 $checked { 'ENABLE_GLOBAL_WHITELIST' }{ 'off' } = '' ;
7041 $checked { 'ENABLE_GLOBAL_WHITELIST' }{ 'on' } = '' ;
7042 $checked { 'ENABLE_GLOBAL_WHITELIST' }{ $filtersettings { 'ENABLE_GLOBAL_WHITELIST' }} = "checked='checked'" ;
7043 $checked { 'ENABLE_SAFESEARCH' }{ 'off' } = '' ;
7044 $checked { 'ENABLE_SAFESEARCH' }{ 'on' } = '' ;
7045 $checked { 'ENABLE_SAFESEARCH' }{ $filtersettings { 'ENABLE_SAFESEARCH' }} = "checked='checked'" ;
7046 $checked { 'ENABLE_LOG' }{ 'off' } = '' ;
7047 $checked { 'ENABLE_LOG' }{ 'on' } = '' ;
7048 $checked { 'ENABLE_LOG' }{ $filtersettings { 'ENABLE_LOG' }} = "checked='checked'" ;
7049 $checked { 'ENABLE_USERNAME_LOG' }{ 'off' } = '' ;
7050 $checked { 'ENABLE_USERNAME_LOG' }{ 'on' } = '' ;
7051 $checked { 'ENABLE_USERNAME_LOG' }{ $filtersettings { 'ENABLE_USERNAME_LOG' }} = "checked='checked'" ;
7052 $checked { 'ENABLE_CATEGORY_LOG' }{ 'off' } = '' ;
7053 $checked { 'ENABLE_CATEGORY_LOG' }{ 'on' } = '' ;
7054 $checked { 'ENABLE_CATEGORY_LOG' }{ $filtersettings { 'ENABLE_CATEGORY_LOG' }} = "checked='checked'" ;
7056 foreach $category ( @filtergroups ) {
7057 $checked { $category }{ 'off' } = '' ;
7058 $checked { $category }{ 'on' } = '' ;
7059 $checked { $category }{ $filtersettings { $category }} = "checked='checked'" ;
7062 $selected { 'DEFINITION' }{ $tcsettings { 'DEFINITION' }} = "selected='selected'" ;
7063 $selected { 'FROM_HOUR' }{ $tcsettings { 'FROM_HOUR' }} = "selected='selected'" ;
7064 $selected { 'FROM_MINUTE' }{ $tcsettings { 'FROM_MINUTE' }} = "selected='selected'" ;
7065 $selected { 'TO_HOUR' }{ $tcsettings { 'TO_HOUR' }} = "selected='selected'" ;
7066 $selected { 'TO_MINUTE' }{ $tcsettings { 'TO_MINUTE' }} = "selected='selected'" ;
7068 @selectedcategories = split ( /\|/ , $tcsettings { 'DST' });
7069 foreach ( @selectedcategories )
7071 $selected { 'DST' }{ $_ } = "selected='selected'" ;
7074 $selected { 'ACCESS' }{ $tcsettings { 'ACCESS' }} = "selected='selected'" ;
7076 $checked { 'ENABLERULE' }{ 'off' } = '' ;
7077 $checked { 'ENABLERULE' }{ 'on' } = '' ;
7078 $checked { 'ENABLERULE' }{ $tcsettings { 'ENABLERULE' }} = "checked='checked'" ;
7079 $checked { 'MON' }{ 'off' } = '' ;
7080 $checked { 'MON' }{ 'on' } = '' ;
7081 $checked { 'MON' }{ $tcsettings { 'MON' }} = "checked='checked'" ;
7082 $checked { 'TUE' }{ 'off' } = '' ;
7083 $checked { 'TUE' }{ 'on' } = '' ;
7084 $checked { 'TUE' }{ $tcsettings { 'TUE' }} = "checked='checked'" ;
7085 $checked { 'WED' }{ 'off' } = '' ;
7086 $checked { 'WED' }{ 'on' } = '' ;
7087 $checked { 'WED' }{ $tcsettings { 'WED' }} = "checked='checked'" ;
7088 $checked { 'THU' }{ 'off' } = '' ;
7089 $checked { 'THU' }{ 'on' } = '' ;
7090 $checked { 'THU' }{ $tcsettings { 'THU' }} = "checked='checked'" ;
7091 $checked { 'FRI' }{ 'off' } = '' ;
7092 $checked { 'FRI' }{ 'on' } = '' ;
7093 $checked { 'FRI' }{ $tcsettings { 'FRI' }} = "checked='checked'" ;
7094 $checked { 'SAT' }{ 'off' } = '' ;
7095 $checked { 'SAT' }{ 'on' } = '' ;
7096 $checked { 'SAT' }{ $tcsettings { 'SAT' }} = "checked='checked'" ;
7097 $checked { 'SUN' }{ 'off' } = '' ;
7098 $checked { 'SUN' }{ 'on' } = '' ;
7099 $checked { 'SUN' }{ $tcsettings { 'SUN' }} = "checked='checked'" ;
7101 $selected { 'SPORADIC' }{ $uqsettings { 'SPORADIC' }} = "selected='selected'" ;
7102 $selected { 'RENEWAL' } { $uqsettings { 'RENEWAL' }} = "selected='selected'" ;
7104 $checked { 'ENABLEQUOTA' }{ 'off' } = '' ;
7105 $checked { 'ENABLEQUOTA' }{ 'on' } = '' ;
7106 $checked { 'ENABLEQUOTA' }{ $uqsettings { 'ENABLEQUOTA' }} = "checked='checked'" ;
7108 $selected { 'BE_BLACKLIST' }{ $besettings { 'BE_BLACKLIST' }} = "selected='selected'" ;
7111 & Header
:: showhttpheaders
();
7113 & Header
:: openpage
( $Lang :: tr
{ 'urlfilter configuration' }, 1 , '' );
7115 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
7117 if ( $errormessage ) {
7118 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
7119 print "<font class='base'> $errormessage </font> \n " ;
7120 & Header
:: closebox
();
7121 } elsif (( $tcsettings { 'CHANGED' } eq 'yes' ) || ( $uqsettings { 'CHANGED' } eq 'yes' ) ) {
7123 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}'> \n " ;
7124 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter restart notification'}:" );
7125 print "<class name='base'> $Lang ::tr{'urlfilter restart message'} \n " ;
7126 if ( $uqsettings { 'MODE' } eq 'USERQUOTA' ) { print "<p><class name='base'> $Lang ::tr{'urlfilter quota restart message'} \n " ; }
7128 print "<p><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter restart'}' />" ;
7129 if ( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) { print "<input type='hidden' name='MODE' value='TIMECONSTRAINT' />" ; }
7130 if ( $uqsettings { 'MODE' } eq 'USERQUOTA' ) { print "<input type='hidden' name='MODE' value='USERQUOTA' />" ; }
7131 & Header
:: closebox
();
7135 if ( $restoremessage ) {
7136 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter restore results'}:" );
7137 print "<class name='base'> $restoremessage \n " ;
7138 print " </class> \n " ;
7139 & Header
:: closebox
();
7142 if ((! $tcsettings { 'TCMODE' }) && (! $uqsettings { 'UQMODE' }) && (! $besettings { 'BEMODE' })) {
7144 if (!( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter manage repository' })) {
7146 #==========================================================
7148 # Section: Main Configuration
7150 #==========================================================
7152 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
7154 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter filter settings'}:" );
7156 <table width='100%'>
7158 <td colspan='4'><b> $Lang ::tr{'urlfilter block categories'}</b></td>
7163 if ( @categories == 0 ) {
7166 <td><i> $Lang ::tr{'urlfilter no categories'}</i></td>
7176 for ( $n = 0 ; $n <= @categories ; $n = $n + $i ) {
7177 for ( $i = 0 ; $i <= 3 ; $i ++) {
7178 if ( $i eq 0 ) { print "<tr> \n " ; }
7179 if (( $n + $i ) < @categories ) {
7180 print "<td width='15%'> @categories [ $n + $i ]:<\/td> \n " ;
7181 print "<td width='10%'><input type='checkbox' name= @filtergroups [ $n + $i ] $checked { @filtergroups [ $n + $i ]}{'on'} /></td> \n " ;
7183 if ( $i eq 3 ) { print "<\/tr> \n " ; }
7190 <table width='100%'>
7192 <td><b> $Lang ::tr{'urlfilter custom blacklist'}</b></td>
7198 <td colspan='2'> $Lang ::tr{'urlfilter blocked domains'} <img src='/blob.gif' alt='*' /></td>
7199 <td colspan='2'> $Lang ::tr{'urlfilter blocked urls'} <img src='/blob.gif' alt='*' /></td>
7202 <td colspan='2' width='50%'><textarea name='CUSTOM_BLACK_DOMAINS' cols='32' rows='6' wrap='off'>
7206 print $filtersettings { 'CUSTOM_BLACK_DOMAINS' };
7210 <td colspan='2' width='50%'><textarea name='CUSTOM_BLACK_URLS' cols='32' rows='6' wrap='off'>
7214 print $filtersettings { 'CUSTOM_BLACK_URLS' };
7220 <table width='100%'>
7222 <td class='base' width='25%'> $Lang ::tr{'urlfilter enable custom blacklist'}:</td>
7223 <td><input type='checkbox' name='ENABLE_CUSTOM_BLACKLIST' $checked {'ENABLE_CUSTOM_BLACKLIST'}{'on'} /></td>
7229 <table width='100%'>
7231 <td><b> $Lang ::tr{'urlfilter custom whitelist'}</b></td>
7237 <td colspan='2'> $Lang ::tr{'urlfilter allowed domains'} <img src='/blob.gif' alt='*' /></td>
7238 <td colspan='2'> $Lang ::tr{'urlfilter allowed urls'} <img src='/blob.gif' alt='*' /></td>
7241 <td colspan='2' width='50%'><textarea name='CUSTOM_WHITE_DOMAINS' cols='32' rows='6' wrap='off'>
7245 print $filtersettings { 'CUSTOM_WHITE_DOMAINS' };
7249 <td colspan='2' width='50%'><textarea name='CUSTOM_WHITE_URLS' cols='32' rows='6' wrap='off'>
7253 print $filtersettings { 'CUSTOM_WHITE_URLS' };
7259 <table width='100%'>
7261 <td class='base' width='25%'> $Lang ::tr{'urlfilter enable custom whitelist'}:</td>
7262 <td><input type='checkbox' name='ENABLE_CUSTOM_WHITELIST' $checked {'ENABLE_CUSTOM_WHITELIST'}{'on'} /></td>
7268 <table width='100%'>
7270 <td colspan='4'><b> $Lang ::tr{'urlfilter custom expression list'}</b></td>
7273 <td colspan='4'> $Lang ::tr{'urlfilter blocked expressions'} <img src='/blob.gif' alt='*' /></td>
7276 <td colspan='4'><textarea name='CUSTOM_EXPRESSIONS' cols='70' rows='3' wrap='off'>
7280 print $filtersettings { 'CUSTOM_EXPRESSIONS' };
7286 <td class='base' width='25%'> $Lang ::tr{'urlfilter enable custom expression list'}:</td>
7287 <td><input type='checkbox' name='ENABLE_CUSTOM_EXPRESSIONS' $checked {'ENABLE_CUSTOM_EXPRESSIONS'}{'on'} /></td>
7293 <table width='100%'>
7295 <td colspan='4'><b> $Lang ::tr{'urlfilter file ext block'}</b></td>
7298 <td width='25%' class='base'> $Lang ::tr{'urlfilter block executables'}:</td>
7299 <td width='12%'><input type='checkbox' name='BLOCK_EXECUTABLES' $checked {'BLOCK_EXECUTABLES'}{'on'} /></td>
7300 <td width='25%' class='base'> $Lang ::tr{'urlfilter block audio-video'}:</td>
7301 <td><input type='checkbox' name='BLOCK_AUDIO-VIDEO' $checked {'BLOCK_AUDIO-VIDEO'}{'on'} /></td>
7304 <td class='base'> $Lang ::tr{'urlfilter block archives'}:</td>
7305 <td><input type='checkbox' name='BLOCK_ARCHIVES' $checked {'BLOCK_ARCHIVES'}{'on'} /></td>
7311 <table width='100%'>
7313 <td colspan='4'><b> $Lang ::tr{'urlfilter local file redirection'}</b></td>
7316 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable rewrite rules'}:</td>
7317 <td width='12%'><input type='checkbox' name='ENABLE_REWRITE' $checked {'ENABLE_REWRITE'}{'on'} /></td>
7322 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter manage repository'}'></td>
7329 <table width='100%'>
7331 <td colspan='2'><b> $Lang ::tr{'urlfilter network access control'}</b></td>
7336 <td class='base'> $Lang ::tr{'urlfilter unfiltered clients'}: <img src='/blob.gif' alt='*' /></td>
7337 <td><input type='text' name='UNFILTERED_CLIENTS' value=' $filtersettings {'UNFILTERED_CLIENTS'}' size='30' /></td>
7338 <td class='base'> $Lang ::tr{'urlfilter banned clients'}: <img src='/blob.gif' alt='*' /></td>
7339 <td><input type='text' name='BANNED_CLIENTS' value=' $filtersettings {'BANNED_CLIENTS'}' size='30' /></td>
7343 <table width='100%'>
7345 <td colspan='4'><b> $Lang ::tr{'urlfilter timebased access control'}</b></td>
7348 <td width='25%'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter set time constraints'}'></td>
7349 <td width='25%'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter set user quota'}'></td>
7355 <table width='100%'>
7357 <td colspan='4'><b> $Lang ::tr{'urlfilter block settings'}</b></td>
7360 <td width='25%' class='base'> $Lang ::tr{'urlfilter show category'}:</td>
7361 <td width='12%'><input type='checkbox' name='SHOW_CATEGORY' $checked {'SHOW_CATEGORY'}{'on'} /></td>
7362 <td width='25%' class='base'> $Lang ::tr{'urlfilter redirectpage'}: <img src='/blob.gif' alt='*' /></td>
7363 <td><input type='text' name='REDIRECT_PAGE' value=' $filtersettings {'REDIRECT_PAGE'}' size='40' /></td>
7366 <td class='base'> $Lang ::tr{'urlfilter show url'}:</td>
7367 <td><input type='checkbox' name='SHOW_URL' $checked {'SHOW_URL'}{'on'} /></td>
7368 <td class='base'> $Lang ::tr{'urlfilter msg text 1'}: <img src='/blob.gif' alt='*' /></td>
7369 <td><input type='text' name='MSG_TEXT_1' value=' $filtersettings {'MSG_TEXT_1'}' size='40' /></td>
7372 <td class='base'> $Lang ::tr{'urlfilter show ip'}:</td>
7373 <td><input type='checkbox' name='SHOW_IP' $checked {'SHOW_IP'}{'on'} /></td>
7374 <td class='base'> $Lang ::tr{'urlfilter msg text 2'}: <img src='/blob.gif' alt='*' /></td>
7375 <td><input type='text' name='MSG_TEXT_2' value=' $filtersettings {'MSG_TEXT_2'}' size='40' /></td>
7378 <td class='base'> $Lang ::tr{'urlfilter show dnserror'}:</td>
7379 <td><input type='checkbox' name='ENABLE_DNSERROR' $checked {'ENABLE_DNSERROR'}{'on'} /></td>
7380 <td class='base'> $Lang ::tr{'urlfilter msg text 3'}: <img src='/blob.gif' alt='*' /></td>
7381 <td><input type='text' name='MSG_TEXT_3' value=' $filtersettings {'MSG_TEXT_3'}' size='40' /></td>
7384 <td class='base'> $Lang ::tr{'urlfilter enable jpeg'}:</td>
7385 <td><input type='checkbox' name='ENABLE_JPEG' $checked {'ENABLE_JPEG'}{'on'} /></td>
7390 <table width='100%'>
7392 <td class='base'><b> $Lang ::tr{'urlfilter background image'}</b></td>
7395 <td><br> $Lang ::tr{'urlfilter background text'}:</td>
7398 <td><input type='file' name='BACKGROUND' size='40' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter upload background'}' /></td>
7402 <table width='100%'>
7404 <td colspan='4'><b> $Lang ::tr{'urlfilter advanced settings'}</b></td>
7407 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable expression lists'}:</td>
7408 <td width='12%'><input type='checkbox' name='ENABLE_EXPR_LISTS' $checked {'ENABLE_EXPR_LISTS'}{'on'} /></td>
7409 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable log'}:</td>
7410 <td><input type='checkbox' name='ENABLE_LOG' $checked {'ENABLE_LOG'}{'on'} /></td>
7413 <td class='base'> $Lang ::tr{'urlfilter safesearch'}:</td>
7414 <td><input type='checkbox' name='ENABLE_SAFESEARCH' $checked {'ENABLE_SAFESEARCH'}{'on'} /></td>
7415 <td class='base'> $Lang ::tr{'urlfilter username log'}:</td>
7416 <td><input type='checkbox' name='ENABLE_USERNAME_LOG' $checked {'ENABLE_USERNAME_LOG'}{'on'} /></td>
7419 <td class='base'> $Lang ::tr{'urlfilter empty ads'}:</td>
7420 <td><input type='checkbox' name='ENABLE_EMPTY_ADS' $checked {'ENABLE_EMPTY_ADS'}{'on'} /></td>
7421 <td class='base'> $Lang ::tr{'urlfilter category log'}:</td>
7422 <td><input type='checkbox' name='ENABLE_CATEGORY_LOG' $checked {'ENABLE_CATEGORY_LOG'}{'on'} /></td>
7425 <td class='base'> $Lang ::tr{'urlfilter block ip'}:</td>
7426 <td><input type='checkbox' name='BLOCK_IP_ADDR' $checked {'BLOCK_IP_ADDR'}{'on'} /></td>
7427 <td class='base'> $Lang ::tr{'urlfilter children'}:</td>
7428 <td><input type='text' name='CHILDREN' value=' $filtersettings {'CHILDREN'}' size='5' /></td>
7431 <td class='base'> $Lang ::tr{'urlfilter block all'}:</td>
7432 <td><input type='checkbox' name='BLOCK_ALL' $checked {'BLOCK_ALL'}{'on'} /></td>
7433 <td class='base'> $Lang ::tr{'urlfilter whitelist always allowed'}:</td>
7434 <td><input type='checkbox' name='ENABLE_GLOBAL_WHITELIST' $checked {'ENABLE_GLOBAL_WHITELIST'}{'on'} /></td>
7438 <table width='100%'>
7441 <img src='/blob.gif' align='top' alt='*' />
7442 <font class='base'> $Lang ::tr{'this field may be blank'}</font>
7445 <sup><small><a href='http://www.urlfilter.net' target='_blank'>URL filter</a></small></sup>
7449 <table width='100%'>
7452 <td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' /></td>
7453 <td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter save and restart'}' /></td>
7460 & Header
:: closebox
();
7464 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
7466 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter maintenance'}:" );
7469 <table width='100%'>
7471 <td class='base'><b> $Lang ::tr{'urlfilter blacklist update'}</b></td>
7474 <td> $Lang ::tr{'urlfilter upload information'}<p> $Lang ::tr{'urlfilter upload text'}:</td>
7477 <td><input type='file' name='UPDATEFILE' size='40' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter upload blacklist'}' /></td>
7483 <table width='100%'>
7485 <td colspan='2' class='base'><b> $Lang ::tr{'urlfilter automatic blacklist update'}</b>
7488 if (- e
" $updflagfile " )
7490 $blacklistage = int (- M
" $updflagfile " );
7491 print " <b>[</b> <small><i> $Lang ::tr{'urlfilter blacklist age 1'} <b> $blacklistage </b> $Lang ::tr{'urlfilter blacklist age 2'}</i></small> <b>]</b>" ;
7494 $updatesettings { 'UPDATE_SCHEDULE' } = 'monthly' ;
7495 $updatesettings { 'CUSTOM_UPDATE_URL' } = '' ;
7497 if (- e
" $updconffile " ) { & General
:: readhash
( " $updconffile " , \
%updatesettings ); }
7499 $checked { 'ENABLE_AUTOUPDATE' }{ 'off' } = '' ;
7500 $checked { 'ENABLE_AUTOUPDATE' }{ 'on' } = '' ;
7501 $checked { 'ENABLE_AUTOUPDATE' }{ $updatesettings { 'ENABLE_AUTOUPDATE' }} = "checked='checked'" ;
7503 $selected { 'UPDATE_SCHEDULE' }{ $updatesettings { 'UPDATE_SCHEDULE' }} = "selected='selected'" ;
7505 $selected { 'UPDATE_SOURCE' }{ $updatesettings { 'UPDATE_SOURCE' }} = "selected='selected'" ;
7511 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable automatic blacklist update'}:</td>
7512 <td width='75%' class='base'><input type='checkbox' name='ENABLE_AUTOUPDATE' $checked {'ENABLE_AUTOUPDATE'}{'on'} /></td>
7515 <td class='base'> $Lang ::tr{'urlfilter automatic update schedule'}:</td>
7517 <select name='UPDATE_SCHEDULE'>
7518 <option value='daily' $selected {'UPDATE_SCHEDULE'}{'daily'}> $Lang ::tr{'urlfilter daily'}</option>
7519 <option value='weekly' $selected {'UPDATE_SCHEDULE'}{'weekly'}> $Lang ::tr{'urlfilter weekly'}</option>
7520 <option value='monthly' $selected {'UPDATE_SCHEDULE'}{'monthly'}> $Lang ::tr{'urlfilter monthly'}</option>
7525 <td class='base'> $Lang ::tr{'urlfilter select source'}:</td>
7526 <td class='base' colspan='2'>
7527 <select name='UPDATE_SOURCE'>
7531 foreach ( @source_urllist ) {
7533 $source_name = substr ( $_ , 0 , rindex ( $_ , "," ));
7534 $source_url = substr ( $_ , index ( $_ , "," )+ 1 );
7535 print " \t <option value=' $source_url ' $selected {'UPDATE_SOURCE'}{ $source_url }> $source_name </option> \n " ;
7539 <option value='custom' $selected {'UPDATE_SOURCE'}{'custom'}> $Lang ::tr{'urlfilter custom url'}</option>
7544 <td> $Lang ::tr{'urlfilter custom url'}:</td>
7545 <td><input type='text' name='CUSTOM_UPDATE_URL' value=' $updatesettings {'CUSTOM_UPDATE_URL'}' size='72' /></td>
7548 <table width='100%'>
7550 <td width='25%'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter save schedule'}'> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter update now'}'></td>
7556 <table width='100%'>
7558 <td class='base'><b> $Lang ::tr{'urlfilter blacklist editor'}</b></td>
7561 <td> $Lang ::tr{'urlfilter blacklist editor info'}</td>
7564 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter blacklist editor'}' /></td>
7570 <table width='100%'>
7572 <td colspan='4' class='base'><b> $Lang ::tr{'urlfilter backup settings'}</b></td>
7575 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable full backup'}:</td>
7576 <td width='12%' class='base'><input type='checkbox' name='ENABLE_FULLBACKUP' $checked {'ENABLE_FULLBACKUP'}{'on'} /></td>
7581 <td colspan='4' class='base'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter backup'}' /></td>
7587 <table width='100%'>
7589 <td class='base'><b> $Lang ::tr{'urlfilter restore settings'}</b></td>
7592 <td> $Lang ::tr{'urlfilter restore text'}:</td>
7595 <td><input type='file' name='UPDATEFILE' size='40' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter restore'}' /></td>
7602 & Header
:: closebox
();
7606 #==========================================================
7608 # Section: Manage Repository
7610 #==========================================================
7612 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
7614 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter manage local file repository'}:" );
7616 <table width='100%'>
7618 <td> $Lang ::tr{'urlfilter repository information'}<br><br></td>
7621 <td> $Lang ::tr{'urlfilter upload file text'}:</td>
7624 <td><input type='file' name='UPLOADFILE' size='50' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter upload file'}' /></td>
7627 <td><br><b> $Lang ::tr{'urlfilter upload file information 1'}:</b> $Lang ::tr{'urlfilter upload file information 2'}</td>
7631 <table width='100%'>
7633 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
7640 & Header
:: closebox
();
7642 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter current files'}: </b>[ $repository ]" );
7644 @repositorylist = < $repository /*>;
7646 undef @repositoryfiles ;
7647 foreach ( @repositorylist )
7649 if (!- d
) { push ( @repositoryfiles , substr ( $_ , rindex ( $_ , "/" )+ 1 )); }
7652 if ( @repositoryfiles )
7655 <table width='100%'>
7657 <td align='center'><b> $Lang ::tr{'urlfilter filename'}</b></td>
7658 <td width='15%' align='center'><b> $Lang ::tr{'urlfilter filesize'}</b></td>
7659 <td width='10%'></td>
7664 foreach $line ( @repositoryfiles )
7668 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
7670 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
7671 $filesize = (- s
" $repository / $line " );
7672 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/ ;
7675 <td> $line </td>
7676 <td align='right'> $filesize </td>
7679 <form method='post' name='frma $id ' action=' $ENV {'SCRIPT_NAME'}'>
7680 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' title=' $Lang ::tr{'remove'}' alt=' $Lang ::tr{'remove'}' />
7681 <input type='hidden' name='ID' value=' $line ' />
7682 <input type='hidden' name='ACTION' value=' $Lang ::tr{'urlfilter remove file'}' />
7699 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
7700 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
7701 <td class='base'> $Lang ::tr{'remove'}</td>
7708 print "<i> $Lang ::tr{'urlfilter empty repository'}</i> \n " ;
7711 & Header
:: closebox
();
7715 } elsif ( $tcsettings { 'TCMODE' }) {
7717 #==========================================================
7719 # Section: Set Time Constraints
7721 #==========================================================
7723 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}'> \n " ;
7725 $buttontext = $Lang :: tr
{ 'urlfilter add rule' };
7726 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
7727 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter edit time constraint rule' }. ':' );
7728 $buttontext = $Lang :: tr
{ 'urlfilter update rule' };
7730 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter add new time constraint rule' }. ':' );
7734 <table width='100%'>
7736 <td width='2%'> $Lang ::tr{'urlfilter constraint definition'}</td>
7737 <td width='1%'> </td>
7738 <td width='2%' align='center'> $Lang ::tr{'urlfilter monday'}</td>
7739 <td width='2%' align='center'> $Lang ::tr{'urlfilter tuesday'}</td>
7740 <td width='2%' align='center'> $Lang ::tr{'urlfilter wednesday'}</td>
7741 <td width='2%' align='center'> $Lang ::tr{'urlfilter thursday'}</td>
7742 <td width='2%' align='center'> $Lang ::tr{'urlfilter friday'}</td>
7743 <td width='2%' align='center'> $Lang ::tr{'urlfilter saturday'}</td>
7744 <td width='2%' align='center'> $Lang ::tr{'urlfilter sunday'}</td>
7745 <td width='1%'> </td>
7746 <td width='7%' colspan=3> $Lang ::tr{'urlfilter from'}</td>
7747 <td width='1%'> </td>
7748 <td width='7%' colspan=3> $Lang ::tr{'urlfilter to'}</td>
7753 <select name='DEFINITION'>
7754 <option value='within' $selected {'DEFINITION'}{'within'}> $Lang ::tr{'urlfilter constraint within'}</option>
7755 <option value='outside' $selected {'DEFINITION'}{'outside'}> $Lang ::tr{'urlfilter constraint outside'}</option>
7759 <td class='base'><input type='checkbox' name='MON' $checked {'MON'}{'on'} /></td>
7760 <td class='base'><input type='checkbox' name='TUE' $checked {'TUE'}{'on'} /></td>
7761 <td class='base'><input type='checkbox' name='WED' $checked {'WED'}{'on'} /></td>
7762 <td class='base'><input type='checkbox' name='THU' $checked {'THU'}{'on'} /></td>
7763 <td class='base'><input type='checkbox' name='FRI' $checked {'FRI'}{'on'} /></td>
7764 <td class='base'><input type='checkbox' name='SAT' $checked {'SAT'}{'on'} /></td>
7765 <td class='base'><input type='checkbox' name='SUN' $checked {'SUN'}{'on'} /></td>
7768 <select name='FROM_HOUR'>
7771 for ( $i = 0 ; $i <= 24 ; $i ++) {
7772 $_ = sprintf ( " %02s " , $i );
7773 print "<option $selected {'FROM_HOUR'}{ $_ }> $_ </option> \n " ;
7780 <select name='FROM_MINUTE'>
7783 for ( $i = 0 ; $i <= 45 ; $i += 15 ) {
7784 $_ = sprintf ( " %02s " , $i );
7785 print "<option $selected {'FROM_MINUTE'}{ $_ }> $_ </option> \n " ;
7792 <select name='TO_HOUR'>
7795 for ( $i = 0 ; $i <= 24 ; $i ++) {
7796 $_ = sprintf ( " %02s " , $i );
7797 print "<option $selected {'TO_HOUR'}{ $_ }> $_ </option> \n " ;
7804 <select name='TO_MINUTE'>
7807 for ( $i = 0 ; $i <= 45 ; $i += 15 ) {
7808 $_ = sprintf ( " %02s " , $i );
7809 print "<option $selected {'TO_MINUTE'}{ $_ }> $_ </option> \n " ;
7820 <table width='100%'>
7822 <td width='5%'> $Lang ::tr{'urlfilter source'}</td>
7823 <td width='1%'> </td>
7824 <td width='5%'> $Lang ::tr{'urlfilter dst'} <img src='/blob.gif' alt='*'><img src='/blob.gif' alt='*'></td>
7825 <td width='1%'> </td>
7826 <td width='5%'> $Lang ::tr{'urlfilter access'}</td>
7830 <td valign='top'><input type='text' name='SRC' value=' $tcsettings {'SRC'}' size='32' /></td>
7832 <td class='base' rowspan='3' valign='top'>
7833 <select name='DST' size='4' multiple>
7834 <option value='any' $selected {'DST'}{'any'} = "selected='selected'"> $Lang ::tr{'urlfilter category all'}</option>
7835 <option value='in-addr' $selected {'DST'}{'in-addr'} = "selected='selected'">in-addr</option>
7839 & readblockcategories
;
7840 foreach ( @categories )
7842 print "<option value=' $_ ' $selected {'DST'}{ $_ }> $_ </option> \n " ;
7846 <option value='files' $selected {'DST'}{'files'} = "selected='selected'">files</option>
7847 <option value='custom-blocked' $selected {'DST'}{'custom-blocked'} = "selected='selected'">custom-blocked</option>
7848 <option value='custom-expressions' $selected {'DST'}{'custom-expressions'} = "selected='selected'">custom-expressions</option>
7852 <td class='base' valign='top'>
7853 <select name='ACCESS'>
7854 <option value='block' $selected {'ACCESS'}{'block'}> $Lang ::tr{'urlfilter mode block'}</option>
7855 <option value='allow' $selected {'ACCESS'}{'allow'}> $Lang ::tr{'urlfilter mode allow'}</option>
7861 <td> $Lang ::tr{'remark'} <img src='/blob.gif' alt='*'></td>
7868 <td><input type='text' name='COMMENT' value=' $tcsettings {'COMMENT'}' size='32' /></td>
7876 <table width='100%'>
7878 <td class='base'> $Lang ::tr{'urlfilter enabled'}<input type='checkbox' name='ENABLERULE' $checked{'ENABLERULE'}{'on'} /></td>
7886 <td><input type='hidden' name='ACTION' value=' $Lang ::tr{'add'}' /></td>
7887 <td><input type='hidden' name='MODE' value='TIMECONSTRAINT' /></td>
7888 <td><input type='submit' name='SUBMIT' value=' $buttontext ' /></td>
7889 <td><input type='reset' name='ACTION' value=' $Lang ::tr{'urlfilter reset'}' /></td>
7891 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
7895 <table width='100%'>
7897 <td width='1%' align='right'> <img src='/blob.gif' align='top' alt='*' /> </td>
7898 <td><font class='base'> $Lang ::tr{'this field may be blank'}</font></td>
7901 <td width='1%' align='right'><img src='/blob.gif' align='top' alt='*' /><img src='/blob.gif' align='top' alt='*' /> </td>
7902 <td><font class='base'> $Lang ::tr{'urlfilter select multi'}</font></td>
7908 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
7909 print "<input type='hidden' name='EDITING' value=' $tcsettings {'ID'}' /> \n " ;
7911 print "<input type='hidden' name='EDITING' value='no' /> \n " ;
7914 & Header
:: closebox
();
7917 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'current rules' });
7919 <table width='100%'>
7921 <td width='5%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter constraint definition'}</b></td>
7922 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter time space'}</b></td>
7923 <td width='15%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter src'}</b></td>
7924 <td width='5%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter dst'}</b></td>
7925 <td width='10%' class='boldbase' colspan='4' align='center'> </td>
7930 if ( $tcsettings { 'ACTION' } ne '' or $changed ne 'no' )
7932 open ( FILE
, $tcfile );
7938 foreach $line ( @tclist )
7942 @temp = split ( /\,/ , $line );
7943 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' } && $tcsettings { 'ID' } eq $id ) {
7944 print "<tr bgcolor=' $Header ::colouryellow'> \n " ; }
7946 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
7948 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
7949 if ( $temp [ 0 ] eq 'within' ) { $temp [ 0 ]= $Lang :: tr
{ 'urlfilter constraint within' }; } else { $temp [ 0 ]= $Lang :: tr
{ 'urlfilter constraint outside' }; }
7950 if ( $temp [ 13 ] eq 'any' ) { $temp [ 13 ]= $Lang :: tr
{ 'urlfilter category all' }; }
7951 if ( $temp [ 15 ] eq 'on' ) { $gif = 'on.gif' ; $toggle = 'off' ; $gdesc = $Lang :: tr
{ 'click to disable' };}
7952 else { $gif = 'off.gif' ; $toggle = 'on' ; $gdesc = $Lang :: tr
{ 'click to enable' }; }
7953 if ( $temp [ 14 ] eq 'block' ) { $led = 'led-red.gif' ; $ldesc = $Lang :: tr
{ 'urlfilter block access' };}
7954 else { $led = 'led-green.gif' ; $ldesc = $Lang :: tr
{ 'urlfilter allow access' }; }
7957 if ( $temp [ 1 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter mon' }; } else { $time .= '=' ; }
7958 if ( $temp [ 2 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter tue' }; } else { $time .= '=' ; }
7959 if ( $temp [ 3 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter wed' }; } else { $time .= '=' ; }
7960 if ( $temp [ 4 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter thu' }; } else { $time .= '=' ; }
7961 if ( $temp [ 5 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter fri' }; } else { $time .= '=' ; }
7962 if ( $temp [ 6 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter sat' }; } else { $time .= '=' ; }
7963 if ( $temp [ 7 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter sun' }; } else { $time .= '=' ; }
7964 $time = $time . ' ' . $temp [ 8 ]. ':' . $temp [ 9 ]. ' to ' . $temp [ 10 ]. ':' . $temp [ 11 ];
7967 <td align='center'> $temp [0]</td>
7968 <td align='center' nowrap> $time </td>
7969 <td align='center'> $temp [12]</td>
7970 <td align='center'> $temp [13]</td>
7971 <td align='center'><image src='/images/urlfilter/ $led ' alt=' $ldesc '></td>
7974 <form method='post' name='frma $id ' action=' $ENV {'SCRIPT_NAME'}'>
7975 <input type='image' name=' $Lang ::tr{'toggle enable disable'}' src='/images/ $gif ' title=' $gdesc ' alt=' $gdesc ' />
7976 <input type='hidden' name='MODE' value='TIMECONSTRAINT' />
7977 <input type='hidden' name='ID' value=' $id ' />
7978 <input type='hidden' name='ACTIVE' value=' $toggle ' />
7979 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
7984 <form method='post' name='frmb $id ' action=' $ENV {'SCRIPT_NAME'}'>
7985 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/edit.gif' title=' $Lang ::tr{'edit'}' alt=' $Lang ::tr{'edit'}' />
7986 <input type='hidden' name='MODE' value='TIMECONSTRAINT' />
7987 <input type='hidden' name='ID' value=' $id ' />
7988 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
7993 <form method='post' name='frmc $id ' action=' $ENV {'SCRIPT_NAME'}'>
7994 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' title=' $Lang ::tr{'remove'}' alt=' $Lang ::tr{'remove'}' />
7995 <input type='hidden' name='MODE' value='TIMECONSTRAINT' />
7996 <input type='hidden' name='ID' value=' $id ' />
7997 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove'}' />
8004 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' } && $tcsettings { 'ID' } eq $id ) {
8005 print "<tr bgcolor=' $Header ::colouryellow'> \n " ; }
8007 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
8009 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
8011 <td align='center' colspan='4'> $temp [16]
8013 <td align='center' colspan='4'>
8022 # If the time constraint file contains entries, print entries and action icons
8023 if (! - z
" $tcfile " ) {
8028 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
8029 <td> <img src='/images/urlfilter/led-green.gif' alt=' $Lang ::tr{'urlfilter allow access'}' /></td>
8030 <td class='base'> $Lang ::tr{'urlfilter allow'}</td>
8031 <td> <img src='/images/urlfilter/led-red.gif' alt=' $Lang ::tr{'urlfilter block access'}' /></td>
8032 <td class='base'> $Lang ::tr{'urlfilter block'}</td>
8033 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
8034 <td class='base'> $Lang ::tr{'click to disable'}</td>
8035 <td> <img src='/images/off.gif' alt=' $Lang ::tr{'click to enable'}' /></td>
8036 <td class='base'> $Lang ::tr{'click to enable'}</td>
8037 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
8038 <td class='base'> $Lang ::tr{'edit'}</td>
8039 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
8040 <td class='base'> $Lang ::tr{'remove'}</td>
8047 & Header
:: closebox
();
8049 } elsif ( $uqsettings { 'UQMODE' }) {
8051 #==========================================================
8053 # Section: Set User Quota
8055 #==========================================================
8057 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}'> \n " ;
8059 $buttontext = $Lang :: tr
{ 'urlfilter add rule' };
8060 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
8061 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter edit user quota rule' }. ':' );
8062 $buttontext = $Lang :: tr
{ 'urlfilter update rule' };
8064 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter add new user quota rule' }. ':' );
8068 <table width='100%'>
8070 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
8073 <td class='base'> $Lang ::tr{'urlfilter user time quota'}:</td>
8074 <td><input type='text' name='TIME_QUOTA' value=' $uqsettings {'TIME_QUOTA'}' size='5' /></td>
8075 <td colspan='2' rowspan= '5' valign='top' class='base'>
8076 <table cellpadding='0' cellspacing='0'>
8078 <!-- intentionally left empty -->
8081 <td> $Lang ::tr{'urlfilter assigned quota users'}:</td>
8084 <!-- intentionally left empty -->
8087 <!-- intentionally left empty -->
8090 <td><textarea name='QUOTA_USERS' cols='32' rows='6' wrap='off'>
8094 $uqsettings { 'QUOTA_USERS' } =~ s/\|/\n/g ;
8095 print $uqsettings { 'QUOTA_USERS' };
8104 <td class='base'> $Lang ::tr{'urlfilter activity detection'}:</td>
8105 <td class='base'><select name='SPORADIC'>
8106 <option value='0' $selected {'SPORADIC'}{'0'}> $Lang ::tr{'urlfilter disabled'}</option>
8107 <option value='300' $selected {'SPORADIC'}{'300'}>5 $Lang ::tr{'urlfilter minutes'}</option>
8108 <option value='900' $selected {'SPORADIC'}{'900'}>15 $Lang ::tr{'urlfilter minutes'}</option>
8112 <td class='base'> $Lang ::tr{'urlfilter renewal period'}:</td>
8113 <td class='base'><select name='RENEWAL'>
8114 <option value='hourly' $selected {'RENEWAL'}{'hourly'}> $Lang ::tr{'urlfilter hourly'}</option>
8115 <option value='daily' $selected {'RENEWAL'}{'daily'}> $Lang ::tr{'urlfilter daily'}</option>
8116 <option value='weekly' $selected {'RENEWAL'}{'weekly'}> $Lang ::tr{'urlfilter weekly'}</option>
8120 <td colspan='2'> </td>
8123 <td class='base'> $Lang ::tr{'urlfilter enabled'}</td>
8124 <td class='base'><input type='checkbox' name='ENABLEQUOTA' $checked {'ENABLEQUOTA'}{'on'} /></td>
8132 <td><input type='hidden' name='ACTION' value=' $Lang ::tr{'add'}' /></td>
8133 <td><input type='hidden' name='MODE' value='USERQUOTA' /></td>
8134 <td><input type='submit' name='SUBMIT' value=' $buttontext ' /></td>
8135 <td><input type='reset' name='ACTION' value=' $Lang ::tr{'urlfilter reset'}' /></td>
8137 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
8145 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
8146 print "<input type='hidden' name='EDITING' value=' $uqsettings {'ID'}' /> \n " ;
8148 print "<input type='hidden' name='EDITING' value='no' /> \n " ;
8151 & Header
:: closebox
();
8154 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'current rules' });
8156 <table width='100%'>
8158 <td width='15%' class='boldbase' align='center'><b><nobr> $Lang ::tr{'urlfilter time quota'}</nobr></b></td>
8159 <td width='15%' class='boldbase' align='center'><b><nobr> $Lang ::tr{'urlfilter activity detection'}</nobr></b></td>
8160 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter renewal'}</b></td>
8161 <td class='boldbase' align='center'><b> $Lang ::tr{'urlfilter assigned users'}</b></td>
8162 <td width='20%' class='boldbase' colspan='4' align='center'> </td>
8167 if ( $uqsettings { 'ACTION' } ne '' or $changed ne 'no' )
8169 open ( FILE
, $uqfile );
8175 foreach $line ( @uqlist )
8179 @temp = split ( /\,/ , $line );
8180 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' } && $uqsettings { 'ID' } eq $id ) {
8181 print "<tr bgcolor=' $Header ::colouryellow'> \n " ; }
8183 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
8185 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
8186 if ( $temp [ 4 ] eq 'on' ) { $gif = 'on.gif' ; $toggle = 'off' ; $gdesc = $Lang :: tr
{ 'click to disable' };}
8187 else { $gif = 'off.gif' ; $toggle = 'on' ; $gdesc = $Lang :: tr
{ 'click to enable' }; }
8189 $temp [ 5 ] = $temp [ 1 ];
8190 if ( $temp [ 1 ] eq '0' ) { $temp [ 5 ] = $Lang :: tr
{ 'urlfilter disabled' } } else { $temp [ 5 ] = ( $temp [ 5 ]/ 60 ). ' ' . $Lang :: tr
{ 'urlfilter minutes' } }
8191 $_ = $temp [ 3 ]; s/\|/, /g ; $temp [ 6 ] = $_ ;
8194 <td align='center'> $temp [0] $Lang ::tr{'urlfilter minutes'}</td>
8195 <td align='center'> $temp [5]</td>
8196 <td align='center'> $Lang ::tr{'urlfilter '. $temp [2]}</td>
8197 <td align='center'> $temp [6]</td>
8200 <form method='post' name='frma $id ' action=' $ENV {'SCRIPT_NAME'}'>
8201 <input type='image' name=' $Lang ::tr{'toggle enable disable'}' src='/images/ $gif ' title=' $gdesc ' alt=' $gdesc ' />
8202 <input type='hidden' name='MODE' value='USERQUOTA' />
8203 <input type='hidden' name='ID' value=' $id ' />
8204 <input type='hidden' name='ACTIVE' value=' $toggle ' />
8205 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
8210 <form method='post' name='frmb $id ' action=' $ENV {'SCRIPT_NAME'}'>
8211 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/edit.gif' title=' $Lang ::tr{'edit'}' alt=' $Lang ::tr{'edit'}' />
8212 <input type='hidden' name='MODE' value='USERQUOTA' />
8213 <input type='hidden' name='ID' value=' $id ' />
8214 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
8219 <form method='post' name='frmc $id ' action=' $ENV {'SCRIPT_NAME'}'>
8220 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' title=' $Lang ::tr{'remove'}' alt=' $Lang ::tr{'remove'}' />
8221 <input type='hidden' name='MODE' value='USERQUOTA' />
8222 <input type='hidden' name='ID' value=' $id ' />
8223 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove'}' />
8234 # If the user quota file contains entries, print entries and action icons
8235 if (! - z
" $uqfile " ) {
8240 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
8241 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
8242 <td class='base'> $Lang ::tr{'click to disable'}</td>
8243 <td> <img src='/images/off.gif' alt=' $Lang ::tr{'click to enable'}' /></td>
8244 <td class='base'> $Lang ::tr{'click to enable'}</td>
8245 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
8246 <td class='base'> $Lang ::tr{'edit'}</td>
8247 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
8248 <td class='base'> $Lang ::tr{'remove'}</td>
8255 & Header
:: closebox
();
8259 #==========================================================
8261 # Section: Blacklist editor
8263 #==========================================================
8265 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
8267 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter urlfilter blacklist editor' }. ':' );
8271 <table width='100%'>
8273 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
8276 <td class='base'><b> $Lang ::tr{'urlfilter blacklist name'}</b></td>
8279 <td class='base'> $Lang ::tr{'urlfilter blacklist category name'}:</td>
8280 <td><input type='text' name='BE_NAME' value=' $besettings {'BE_NAME'}' size='12' /></td>
8284 <table width='100%'>
8286 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='20%'></td>
8289 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter edit domains urls expressions'}</b></td>
8292 <td colspan='2'> $Lang ::tr{'urlfilter domains'}</td>
8293 <td colspan='2'> $Lang ::tr{'urlfilter urls'}</td>
8296 <td colspan='2'><textarea name='BE_DOMAINS' cols='38' rows='10' wrap='off'>
8300 print $besettings { 'BE_DOMAINS' };
8304 <td colspan='2'><textarea name='BE_URLS' cols='38' rows='10' wrap='off'>
8308 print $besettings { 'BE_URLS' };
8314 <td colspan='4'> $Lang ::tr{'urlfilter expressions'}</td>
8317 <td colspan='4'><textarea name='BE_EXPRESSIONS' cols='80' rows='3' wrap='off'>
8321 print $besettings { 'BE_EXPRESSIONS' };
8328 <table width='100%'>
8330 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter load blacklist'}</b></td>
8333 <td width='25%' class='base'> $Lang ::tr{'urlfilter select blacklist'}:</td>
8334 <td width='20%' class='base'>
8335 <select name='BE_BLACKLIST'>
8339 & readblockcategories
;
8340 foreach ( @categories )
8342 print "<option value=' $_ ' $selected {'BE_BLACKLIST'}{ $_ }> $_ </option> \n " ;
8351 <td colpsan='4'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter load blacklist'}' /></td>
8356 <table width='100%'>
8358 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter import blacklist'}</b></td>
8361 <td colspan='4'> $Lang ::tr{'urlfilter import text'}:</td>
8364 <td nowrap><input type='file' name='IMPORTFILE' size='40' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter import blacklist'}' /></td>
8365 <td><input type='hidden' name='MODE' value='BLACKLIST_EDITOR' /></td>
8369 <table width='100%'>
8371 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter export blacklist'}</b></td>
8374 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter export blacklist'}' /></td>
8378 <table width='100%'>
8380 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter install blacklist'}</b></td>
8383 <td width='25%' class='base'> $Lang ::tr{'urlfilter dont restart urlfilter'}:</td>
8384 <td width='20%' class='base'><input type='checkbox' name='NORESTART' $checked {'NORESTART'}{'on'} /></td>
8389 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter install blacklist'}' /></td>
8392 <td class='base' colspan='4'><br> $Lang ::tr{'urlfilter install information'}</td>
8398 <td><input type='reset' name='ACTION' value=' $Lang ::tr{'urlfilter reset'}' /></td>
8400 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
8407 & Header
:: closebox
();
8412 & Header
:: closebigbox
();
8414 & Header
:: closepage
();
8416 # -------------------------------------------------------------------
8422 delete $filtersettings { 'CUSTOM_BLACK_DOMAINS' };
8423 delete $filtersettings { 'CUSTOM_BLACK_URLS' };
8424 delete $filtersettings { 'CUSTOM_WHITE_DOMAINS' };
8425 delete $filtersettings { 'CUSTOM_WHITE_URLS' };
8426 delete $filtersettings { 'CUSTOM_EXPRESSIONS' };
8427 delete $filtersettings { 'BACKGROUND' };
8428 delete $filtersettings { 'UPDATEFILE' };
8430 & General
:: writehash
( "${General::swroot}/urlfilter/settings" , \
%filtersettings );
8433 # -------------------------------------------------------------------
8435 sub readblockcategories
8438 foreach $blacklist (< $dbdir /*>) {
8439 if (- d
$blacklist ) {
8440 $lastslashpos = rindex ( $blacklist , "/" );
8441 if ( $lastslashpos > - 1 ) {
8442 $section = substr ( $blacklist , $lastslashpos + 1 );
8444 $section = $blacklist ;
8446 if (!( $section eq 'custom' )) { push ( @categories , $section ) };
8450 @filtergroups = @categories ;
8451 foreach ( @filtergroups ) {
8457 # -------------------------------------------------------------------
8461 if (- e
" $dbdir /custom/blocked/domains" ) {
8462 open ( FILE
, " $dbdir /custom/blocked/domains" );
8463 delete $filtersettings { 'CUSTOM_BLACK_DOMAINS' };
8464 while (< FILE
>) { $filtersettings { 'CUSTOM_BLACK_DOMAINS' } .= $_ };
8468 if (- e
" $dbdir /custom/blocked/urls" ) {
8469 open ( FILE
, " $dbdir /custom/blocked/urls" );
8470 delete $filtersettings { 'CUSTOM_BLACK_URLS' };
8471 while (< FILE
>) { $filtersettings { 'CUSTOM_BLACK_URLS' } .= $_ };
8475 if (- e
" $dbdir /custom/blocked/expressions" ) {
8476 open ( FILE
, " $dbdir /custom/blocked/expressions" );
8477 delete $filtersettings { 'CUSTOM_EXPRESSIONS' };
8478 while (< FILE
>) { $filtersettings { 'CUSTOM_EXPRESSIONS' } .= $_ };
8482 if (- e
" $dbdir /custom/allowed/domains" ) {
8483 open ( FILE
, " $dbdir /custom/allowed/domains" );
8484 delete $filtersettings { 'CUSTOM_WHITE_DOMAINS' };
8485 while (< FILE
>) { $filtersettings { 'CUSTOM_WHITE_DOMAINS' } .= $_ };
8488 if (- e
" $dbdir /custom/allowed/urls" ) {
8489 open ( FILE
, " $dbdir /custom/allowed/urls" );
8490 delete $filtersettings { 'CUSTOM_WHITE_URLS' };
8491 while (< FILE
>) { $filtersettings { 'CUSTOM_WHITE_URLS' } .= $_ };
8496 # -------------------------------------------------------------------
8498 sub aggregatedconstraints
8518 @tmp1 = split ( /\,/ , $x );
8522 @tmp2 = split ( /\,/ );
8523 if ( $tmp2 [ 15 ] eq 'on' )
8525 if (( $tmp1 [ 0 ] eq $tmp2 [ 0 ]) && ( $tmp1 [ 12 ] eq $tmp2 [ 12 ]) && ( $tmp1 [ 13 ] eq $tmp2 [ 13 ]) && ( $tmp1 [ 14 ] eq $tmp2 [ 14 ]))
8528 $tmp2 [ 16 ] .= " weekly " ;
8529 if ( $tmp1 [ 1 ] eq 'on' ) { $tmp2 [ 16 ] .= "m" ; }
8530 if ( $tmp1 [ 2 ] eq 'on' ) { $tmp2 [ 16 ] .= "t" ; }
8531 if ( $tmp1 [ 3 ] eq 'on' ) { $tmp2 [ 16 ] .= "w" ; }
8532 if ( $tmp1 [ 4 ] eq 'on' ) { $tmp2 [ 16 ] .= "h" ; }
8533 if ( $tmp1 [ 5 ] eq 'on' ) { $tmp2 [ 16 ] .= "f" ; }
8534 if ( $tmp1 [ 6 ] eq 'on' ) { $tmp2 [ 16 ] .= "a" ; }
8535 if ( $tmp1 [ 7 ] eq 'on' ) { $tmp2 [ 16 ] .= "s" ; }
8536 $tmp2 [ 16 ] .= " $tmp1 [8]: $tmp1 [9]- $tmp1 [10]: $tmp1 [11] \n " ;
8537 $_ = join ( "," , @tmp2 );
8544 $tmp1 [ 16 ] .= " weekly " ;
8545 if ( $tmp1 [ 1 ] eq 'on' ) { $tmp1 [ 16 ] .= "m" ; }
8546 if ( $tmp1 [ 2 ] eq 'on' ) { $tmp1 [ 16 ] .= "t" ; }
8547 if ( $tmp1 [ 3 ] eq 'on' ) { $tmp1 [ 16 ] .= "w" ; }
8548 if ( $tmp1 [ 4 ] eq 'on' ) { $tmp1 [ 16 ] .= "h" ; }
8549 if ( $tmp1 [ 5 ] eq 'on' ) { $tmp1 [ 16 ] .= "f" ; }
8550 if ( $tmp1 [ 6 ] eq 'on' ) { $tmp1 [ 16 ] .= "a" ; }
8551 if ( $tmp1 [ 7 ] eq 'on' ) { $tmp1 [ 16 ] .= "s" ; }
8552 $tmp1 [ 16 ] .= " $tmp1 [8]: $tmp1 [9]- $tmp1 [10]: $tmp1 [11] \n " ;
8553 $x = join ( "," , @tmp1 );
8563 # -------------------------------------------------------------------
8567 my $executables = " \\ .\(ade|adp|asx|bas|bat|chm|com|cmd|cpl|crt|dll|eml|exe|hiv|hlp|hta|inc|inf|ins|isp|jse|jtd|lnk|msc|msh|msi|msp|mst|nws|ocx|oft|ops|pcd|pif|plx|reg|scr|sct|sha|shb|shm|shs|sys|tlb|tsp|url|vbe|vbs|vxd|wsc|wsf|wsh\)\$" ;
8568 my $audiovideo = " \\ .\(aiff|asf|avi|dif|divx|mov|movie|mp3|mpe?g?|mpv2|ogg|ra?m|snd|qt|wav|wmf|wmv\)\$" ;
8569 my $archives = " \\ .\(bin|bz2|cab|cdr|dmg|gz|hqx|rar|smi|sit|sea|tar|tgz|zip\)\$" ;
8571 my $ident = " anonymous" ;
8584 if (!(- d
" $dbdir /custom" )) { mkdir ( " $dbdir /custom" ) }
8585 if (!(- d
" $dbdir /custom/blocked" )) { mkdir ( " $dbdir /custom/blocked" ) }
8586 if (!(- d
" $dbdir /custom/allowed" )) { mkdir ( " $dbdir /custom/allowed" ) }
8588 open ( FILE
, ">/ $dbdir /custom/blocked/domains" );
8589 print FILE
$filtersettings { 'CUSTOM_BLACK_DOMAINS' };
8591 open ( FILE
, ">/ $dbdir /custom/blocked/urls" );
8592 print FILE
$filtersettings { 'CUSTOM_BLACK_URLS' };
8594 open ( FILE
, ">/ $dbdir /custom/blocked/expressions" );
8595 print FILE
$filtersettings { 'CUSTOM_EXPRESSIONS' };
8597 open ( FILE
, ">/ $dbdir /custom/blocked/files" );
8598 if ( $filtersettings { 'BLOCK_EXECUTABLES' } eq 'on' ) { print FILE
" $executables \n " ; }
8599 if ( $filtersettings { 'BLOCK_AUDIO-VIDEO' } eq 'on' ) { print FILE
" $audiovideo \n " ; }
8600 if ( $filtersettings { 'BLOCK_ARCHIVES' } eq 'on' ) { print FILE
" $archives \n " ; }
8602 open ( FILE
, ">/ $dbdir /custom/allowed/domains" );
8603 print FILE
$filtersettings { 'CUSTOM_WHITE_DOMAINS' };
8605 open ( FILE
, ">/ $dbdir /custom/allowed/urls" );
8606 print FILE
$filtersettings { 'CUSTOM_WHITE_URLS' };
8609 if ( $filtersettings { 'ENABLE_USERNAME_LOG' } eq 'on' ) { $ident = "" ; }
8611 if ( $filtersettings { 'REDIRECT_PAGE' } eq '' )
8613 if (( $filtersettings { 'SHOW_CATEGORY' } eq 'on' ) || ( $filtersettings { 'SHOW_URL' } eq 'on' ) || ( $filtersettings { 'SHOW_IP' } eq 'on' )) {
8614 if ( $filtersettings { 'SHOW_CATEGORY' } eq 'on' ) { $redirect .= "&category= %t " ; }
8615 if ( $filtersettings { 'SHOW_URL' } eq 'on' ) { $redirect .= "&url= %u " ; }
8616 if ( $filtersettings { 'SHOW_IP' } eq 'on' ) { $redirect .= "&ip= %a " ; }
8617 $redirect =~ s/^&/?/ ;
8618 $redirect = "http:\/\/ $netsettings {'GREEN_ADDRESS'}:81\/redirect.cgi" . $redirect ;
8620 $redirect = "http:\/\/ $netsettings {'GREEN_ADDRESS'}:81\/redirect.cgi" ;
8622 } else { $redirect = $filtersettings { 'REDIRECT_PAGE' }; }
8624 if ( $filtersettings { 'ENABLE_DNSERROR' } eq 'on' ) { $redirect = "302:http://0.0.0.0" ; }
8628 if ( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' )
8630 $defaultrule .= "custom-allowed " ;
8632 if ( $filtersettings { 'BLOCK_ALL' } eq 'on' )
8634 $defaultrule .= "none" ;
8638 if ( $filtersettings { 'BLOCK_IP_ADDR' } eq 'on' )
8640 $defaultrule .= "!in-addr " ;
8642 for ( $i = 0 ; $i <= @filtergroups ; $i ++) {
8643 if ( $filtersettings { @filtergroups [ $i ]} eq 'on' )
8645 $defaultrule .= "! @categories [ $i ] " ;
8648 if ( $filtersettings { 'ENABLE_CUSTOM_BLACKLIST' } eq 'on' )
8650 $defaultrule .= "!custom-blocked " ;
8652 if ( $filtersettings { 'ENABLE_CUSTOM_EXPRESSIONS' } eq 'on' )
8654 $defaultrule .= "!custom-expressions " ;
8656 if (( $filtersettings { 'BLOCK_EXECUTABLES' } eq 'on' ) ||
8657 ( $filtersettings { 'BLOCK_AUDIO-VIDEO' } eq 'on' ) ||
8658 ( $filtersettings { 'BLOCK_ARCHIVES' } eq 'on' ))
8660 $defaultrule .= "!files " ;
8662 $defaultrule .= "any" ;
8665 open ( FILE
, ">${General::swroot}/urlfilter/squidGuard.conf" ) or die "Unable to write squidGuard.conf file" ;
8668 print FILE
"logdir /var/log/squidGuard \n " ;
8669 print FILE
"dbhome $dbdir \n\n " ;
8671 undef @repositoryfiles ;
8672 if ( $filtersettings { 'ENABLE_REWRITE' } eq 'on' )
8674 @repositorylist = < $repository /*>;
8675 foreach ( @repositorylist )
8677 if (!- d
) { push ( @repositoryfiles , substr ( $_ , rindex ( $_ , "/" )+ 1 )); }
8681 if ((( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles )) || ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' ))
8683 print FILE
"rewrite rew-rule-0 { \n " ;
8685 if (( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles ))
8687 print FILE
" # rewrite localfiles \n " ;
8688 foreach ( @repositoryfiles )
8690 print FILE
" s@.*/ $_ \$\ @http :// $netsettings {'GREEN_ADDRESS'}:81/repository/ $_ \ @i \n " ;
8694 if ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' )
8696 print FILE
" # rewrite safesearch \n " ;
8697 print FILE
" s@(.* \\ Wgoogle \\ . \\ w+/(webhp|search|imghp|images|grphp|groups|frghp|froogle) \\ ?)(.*)( \\ bsafe= \\ w+)(.*)\@ \\ 1 \\ 3safe=strict \\ 5\ @i \n " ;
8698 print FILE
" s@(.* \\ Wgoogle \\ . \\ w+/(webhp|search|imghp|images|grphp|groups|frghp|froogle) \\ ?)(.*)\@ \\ 1safe=strict \\ \& \\ 3\ @i \n " ;
8699 print FILE
" s@(.* \\ Wsearch \\ .yahoo \\ . \\ w+/search \\ W)(.*)( \\ bvm= \\ w+)(.*)\@ \\ 1 \\ 2vm=r \\ 4\ @i \n " ;
8700 print FILE
" s@(.* \\ Wsearch \\ .yahoo \\ . \\ w+/search \\ W.*)\@ \\ 1 \\ \&vm=r\ @i \n " ;
8701 print FILE
" s@(.* \\ Walltheweb \\ .com/customize \\ ?)(.*)( \\ bcopt_offensive= \\ w+)(.*)\@ \\ 1 \\ 2copt_offensive=on \\ 4\ @i \n " ;
8706 if ((!( $filtersettings { 'UNFILTERED_CLIENTS' } eq '' )) && ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' )) {
8707 print FILE
"rewrite rew-rule-1 { \n " ;
8708 if (( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles ))
8710 print FILE
" # rewrite localfiles \n " ;
8711 foreach ( @repositoryfiles )
8713 print FILE
" s@.*/ $_ \$\ @http :// $netsettings {'GREEN_ADDRESS'}:81/repository/ $_ \ @i \n " ;
8716 print FILE
" # rewrite nothing \n " ;
8738 $uq [ 0 ] = $uq [ 0 ] * 60 ;
8739 if ( $uq [ 1 ] eq '0' ) {
8740 if ( $uq [ 2 ] eq 'hourly' ) { $uq [ 1 ] = 3600 }
8741 if ( $uq [ 2 ] eq 'daily' ) { $uq [ 1 ] = 86400 }
8742 if ( $uq [ 2 ] eq 'weekly' ) { $uq [ 1 ] = 604800 }
8745 print FILE
"src quota- $idx { \n " ;
8746 print FILE
" user $uq [3] \n " ;
8747 print FILE
" userquota $uq [0] $uq [1] $uq [2] \n " ;
8755 @tclist = & aggregatedconstraints
;
8764 if ( $tc [ 15 ] eq 'on' )
8767 print FILE
"src network- $idx { \n " ;
8768 print FILE
" ip $tc [12] \n " ;
8778 if ( $tc [ 15 ] eq 'on' )
8781 print FILE
"time constraint- $idx { \n " ;
8782 print FILE
" $tc [16] \n " ;
8788 if (!( $filtersettings { 'UNFILTERED_CLIENTS' } eq '' )) {
8789 print FILE
"src unfiltered { \n " ;
8790 print FILE
" ip $filtersettings {'UNFILTERED_CLIENTS'} \n " ;
8793 if (!( $filtersettings { 'BANNED_CLIENTS' } eq '' )) {
8794 print FILE
"src banned { \n " ;
8795 print FILE
" ip $filtersettings {'BANNED_CLIENTS'} \n " ;
8799 foreach $category ( @categories ) {
8800 print FILE
"dest $category { \n " ;
8801 if (- e
" $dbdir / $category /domains" ) {
8802 print FILE
" domainlist $category \/domains \n " ;
8804 if (- e
" $dbdir / $category /urls" ) {
8805 print FILE
" urllist $category \/urls \n " ;
8807 if ((- e
" $dbdir / $category /expressions" ) && ( $filtersettings { 'ENABLE_EXPR_LISTS' } eq 'on' )) {
8808 print FILE
" expressionlist $category \/expressions \n " ;
8810 if (( $category eq 'ads' ) && ( $filtersettings { 'ENABLE_EMPTY_ADS' } eq 'on' ))
8812 print FILE
" redirect http:\/\/ $netsettings {'GREEN_ADDRESS'}:81\/images/urlfilter/1x1.gif \n " ;
8814 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
8816 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
8818 print FILE
" logfile $ident $category .log \n " ;
8820 print FILE
" logfile $ident urlfilter.log \n " ;
8826 print FILE
"dest files { \n " ;
8827 print FILE
" expressionlist custom\/blocked\/files \n " ;
8828 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
8830 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
8832 print FILE
" logfile $ident files.log \n " ;
8834 print FILE
" logfile $ident urlfilter.log \n " ;
8839 print FILE
"dest custom-allowed { \n " ;
8840 print FILE
" domainlist custom\/allowed\/domains \n " ;
8841 print FILE
" urllist custom\/allowed\/urls \n " ;
8844 print FILE
"dest custom-blocked { \n " ;
8845 print FILE
" domainlist custom\/blocked\/domains \n " ;
8846 print FILE
" urllist custom\/blocked\/urls \n " ;
8847 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
8849 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
8851 print FILE
" logfile $ident custom.log \n " ;
8853 print FILE
" logfile $ident urlfilter.log \n " ;
8858 print FILE
"dest custom-expressions { \n " ;
8859 print FILE
" expressionlist custom\/blocked\/expressions \n " ;
8860 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
8862 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
8864 print FILE
" logfile $ident custom.log \n " ;
8866 print FILE
" logfile $ident urlfilter.log \n " ;
8871 print FILE
"acl { \n " ;
8872 if (!( $filtersettings { 'UNFILTERED_CLIENTS' } eq '' )) {
8873 print FILE
" unfiltered { \n " ;
8874 print FILE
" pass all \n " ;
8875 if ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' )
8877 print FILE
" rewrite rew-rule-1 \n " ;
8879 print FILE
" } \n\n " ;
8881 if (!( $filtersettings { 'BANNED_CLIENTS' } eq '' )) {
8882 print FILE
" banned { \n " ;
8883 print FILE
" pass " ;
8884 if (( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'on' ))
8886 print FILE
"custom-allowed " ;
8888 print FILE
"none \n " ;
8889 print FILE
" } \n\n " ;
8906 $qredirect = $redirect ;
8907 $qredirect =~ s/\%t/\%q\%20-\%20\%i/ ;
8908 print FILE
" quota- $idx { \n " ;
8909 print FILE
" pass " ;
8910 if (( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'on' ))
8912 print FILE
"custom-allowed " ;
8914 print FILE
"none \n " ;
8915 unless ( $redirect eq $qredirect ) { print FILE
" redirect $qredirect \n " ; }
8916 print FILE
" } \n\n " ;
8928 @ec = split ( /\|/ , $tc [ 13 ]);
8929 if ( $tc [ 15 ] eq 'on' )
8932 print FILE
" network- $idx $tc [0] constraint- $idx { \n " ;
8933 print FILE
" pass " ;
8935 if ( $filtersettings { 'BLOCK_ALL' } eq 'on' )
8937 if ( $tc [ 14 ] eq 'block' )
8939 if (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' )) {
8940 if (( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'on' ))
8942 print FILE
"custom-allowed " ;
8946 print FILE
$defaultrule ;
8953 print FILE
$defaultrule unless (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ));
8956 if ( $tc [ 14 ] eq 'block' )
8958 $tcrule = $defaultrule ;
8959 if ( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) {
8960 $tcrule =~ s/custom-allowed // ;
8961 print FILE
"custom-allowed " unless (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'off' ));
8963 if (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' )) {
8968 print FILE
"! $_ " unless ( index ( $defaultrule , "!" . $_ . " " ) ge 0 );
8971 print FILE
$tcrule unless (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ));
8973 $tcrule = $defaultrule ;
8976 $tcrule =~ s/!$_ // ;
8977 print FILE
" $_ " if ( $_ eq 'any' );
8979 print FILE
$tcrule unless (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ));
8985 print FILE
" } \n\n " ;
8990 print FILE
" default { \n " ;
8991 print FILE
" pass $defaultrule \n " ;
8992 if (( $filtersettings { 'ENABLE_LOG' } eq 'on' ) && ( $filtersettings { 'BLOCK_ALL' } eq 'on' ))
8994 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
8996 print FILE
" logfile" . $ident . " default.log \n " ;
8998 print FILE
" logfile" . $ident . " urlfilter.log \n " ;
9001 if ((( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles )) || ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' ))
9003 print FILE
" rewrite rew-rule-0 \n " ;
9005 print FILE
" redirect $redirect \n " ;
9012 # -------------------------------------------------------------------