]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/urlfilter.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2005-2010 IPFire Team #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
24 # enable only the following on debugging purpose
26 #use CGI::Carp 'fatalsToBrowser';
31 require '/var/ipfire/general-functions.pl' ;
32 require "${General::swroot}/lang.pl" ;
33 require "${General::swroot}/header.pl" ;
39 my %filtersettings =();
43 my %updatesettings =();
58 my $tcfile = "${General::swroot}/urlfilter/timeconst" ;
59 my $uqfile = "${General::swroot}/urlfilter/userquota" ;
60 my $dbdir = "${General::swroot}/urlfilter/blacklists" ;
61 my $editdir = "${General::swroot}/urlfilter/editor" ;
62 my $templatedir = "/srv/web/ipfire/html/redirect-templates" ;
63 my $repository = "/var/urlrepo" ;
64 my $hintcolour = '#FFFFCC' ;
66 my $sourceurlfile = "${General::swroot}/urlfilter/autoupdate/autoupdate.urls" ;
67 my $updconffile = "${General::swroot}/urlfilter/autoupdate/autoupdate.conf" ;
68 my $updflagfile = "${General::swroot}/urlfilter/blacklists/.autoupdate.last" ;
72 my $restoremessage = '' ;
78 my @repositorylist =();
79 my @repositoryfiles =();
81 my @selectedcategories =();
85 my @source_urllist =();
97 if (! - d
$dbdir ) { mkdir ( " $dbdir " ); }
98 if (! - e
$tcfile ) { & General
:: system ( "touch" , " $tcfile " ); }
99 if (! - e
$uqfile ) { & General
:: system ( "touch" , " $uqfile " ); }
100 if (! - e
$sourceurlfile ) { & General
:: system ( "touch" , " $sourceurlfile " ); }
102 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%netsettings );
103 & General
:: readhash
( "${General::swroot}/main/settings" , \
%mainsettings );
104 & General
:: readhash
( "${General::swroot}/proxy/settings" , \
%proxysettings );
106 & readblockcategories
;
114 open ( FILE
, $sourceurlfile );
115 @source_urllist = < FILE
>;
118 $filtersettings { 'ENABLE_CUSTOM_BLACKLIST' } = 'off' ;
119 $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } = 'off' ;
120 $filtersettings { 'ENABLE_CUSTOM_EXPRESSIONS' } = 'off' ;
121 $filtersettings { 'BLOCK_EXECUTABLES' } = 'off' ;
122 $filtersettings { 'BLOCK_AUDIO-VIDEO' } = 'off' ;
123 $filtersettings { 'BLOCK_ARCHIVES' } = 'off' ;
124 $filtersettings { 'ENABLE_REWRITE' } = 'off' ;
125 $filtersettings { 'UNFILTERED_CLIENTS' } = '' ;
126 $filtersettings { 'BANNED_CLIENTS' } = '' ;
127 $filtersettings { 'SHOW_CATEGORY' } = 'off' ;
128 $filtersettings { 'SHOW_URL' } = 'off' ;
129 $filtersettings { 'SHOW_IP' } = 'off' ;
130 $filtersettings { 'ENABLE_DNSERROR' } = 'off' ;
131 $filtersettings { 'ENABLE_JPEG' } = 'off' ;
132 $filtersettings { 'REDIRECT_PAGE' } = '' ;
133 $filtersettings { 'MSG_TEXT_1' } = '' ;
134 $filtersettings { 'MSG_TEXT_2' } = '' ;
135 $filtersettings { 'MSG_TEXT_3' } = '' ;
136 $filtersettings { 'ENABLE_EXPR_LISTS' } = 'off' ;
137 $filtersettings { 'BLOCK_IP_ADDR' } = 'off' ;
138 $filtersettings { 'BLOCK_ALL' } = 'off' ;
139 $filtersettings { 'ENABLE_EMPTY_ADS' } = 'off' ;
140 $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } = 'off' ;
141 $filtersettings { 'ENABLE_LOG' } = 'off' ;
142 $filtersettings { 'ENABLE_USERNAME_LOG' } = 'off' ;
143 $filtersettings { 'ENABLE_CATEGORY_LOG' } = 'off' ;
144 $filtersettings { 'ENABLE_AUTOUPDATE' } = 'off' ;
145 $filtersettings { 'REDIRECT_TEMPLATE' } = 'legacy' ;
147 $filtersettings { 'ACTION' } = '' ;
148 $filtersettings { 'VALID' } = '' ;
150 & Header
:: getcgihash
( \
%filtersettings );
151 & Header
:: getcgihash
( \
%tcsettings );
152 & Header
:: getcgihash
( \
%uqsettings );
153 & Header
:: getcgihash
( \
%besettings );
155 if (( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'save' }) ||
156 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter save and restart' }) ||
157 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload file' }) ||
158 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter remove file' }) ||
159 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload blacklist' }) ||
160 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter backup' }) ||
161 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter restore' }))
164 @clients = split ( /\n/ , $filtersettings { 'UNFILTERED_CLIENTS' });
167 s/^\s+//g ; s/\s+$//g ; s/\s+-\s+/-/g ; s/\s+/ /g ; s/\n//g ;
168 if ( /.*-.*-.*/ ) { $errormessage = $Lang :: tr
{ 'urlfilter invalid ip or mask error' }; }
170 foreach ( @temp ) { unless ((& General
:: validipormask
( $_ )) || (& General
:: validipandmask
( $_ ))) { $errormessage = $Lang :: tr
{ 'urlfilter invalid ip or mask error' }; } }
172 @clients = split ( /\n/ , $filtersettings { 'BANNED_CLIENTS' });
175 s/^\s+//g ; s/\s+$//g ; s/\s+-\s+/-/g ; s/\s+/ /g ; s/\n//g ;
176 if ( /.*-.*-.*/ ) { $errormessage = $Lang :: tr
{ 'urlfilter invalid ip or mask error' }; }
178 foreach ( @temp ) { unless ((& General
:: validipormask
( $_ )) || (& General
:: validipandmask
( $_ ))) { $errormessage = $Lang :: tr
{ 'urlfilter invalid ip or mask error' }; } }
180 if ( $errormessage ) { goto ERROR
; }
182 if ((!( $filtersettings { 'REDIRECT_PAGE' } eq '' )) && (!( $filtersettings { 'REDIRECT_PAGE' } =~ /^https?:\/ \
// )))
184 $filtersettings { 'REDIRECT_PAGE' } = "http://" . $filtersettings { 'REDIRECT_PAGE' };
187 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter remove file' })
189 if (- e
" $repository / $filtersettings {'ID'}" ) { unlink ( " $repository / $filtersettings {'ID'}" ); }
190 $filtersettings { 'ACTION' } = $Lang :: tr
{ 'urlfilter manage repository' };
193 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload file' })
195 & Header
:: getcgihash
( \
%filtersettings , { 'wantfile' => 1 , 'filevar' => 'UPLOADFILE' });
197 $filtersettings { 'ACTION' } = $Lang :: tr
{ 'urlfilter manage repository' };
198 $_ = $filtersettings { 'UPLOADFILE' };
200 $_ = substr ( $_ , rindex ( $_ , "/" )+ 1 );
202 if ( copy
( $filtersettings { 'UPLOADFILE' }, " $repository / $_ " ) != 1 )
211 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload blacklist' })
213 & Header
:: getcgihash
( \
%filtersettings , { 'wantfile' => 1 , 'filevar' => 'UPDATEFILE' });
215 if (!( $filtersettings { 'UPDATEFILE' } =~ /.tar.gz$/ ))
217 $errormessage = $Lang :: tr
{ 'urlfilter wrong filetype' };
221 if ( copy
( $filtersettings { 'UPDATEFILE' }, "${General::swroot}/urlfilter/blacklists.tar.gz" ) != 1 )
227 if (!(- d
"${General::swroot}/urlfilter/update" )) { mkdir ( "${General::swroot}/urlfilter/update" ); }
229 my $exitcode = & General
:: system ( "/bin/tar" , "--no-same-owner" , "-xzf" , "${General::swroot}/urlfilter/blacklists.tar.gz" , "-C" , "${General::swroot}/urlfilter/update" );
233 $errormessage = $Lang :: tr
{ 'urlfilter tar error' };
236 if (- d
"${General::swroot}/urlfilter/update/BL" )
238 & General
:: system ( "mv" , "${General::swroot}/urlfilter/update/BL" , "${General::swroot}/urlfilter/update/blacklists" );
241 if (- d
"${General::swroot}/urlfilter/update/category" )
243 & General
:: system ( "mv" , "${General::swroot}/urlfilter/update/category" , "${General::swroot}/urlfilter/update/blacklists" );
246 if (!(- d
"${General::swroot}/urlfilter/update/blacklists" ))
248 $errormessage = $Lang :: tr
{ 'urlfilter invalid content' };
251 system ( "cp -r ${General::swroot}/urlfilter/update/blacklists/* $dbdir " );
253 & readblockcategories
;
258 $updatemessage = $Lang :: tr
{ 'urlfilter upload success' };
259 & General
:: system_background
( "${General::swroot}/urlfilter/bin/prebuild.pl" );
260 & General
:: system ( "logger" , "-t" , "installpackage[urlfilter]" , "URL filter blacklist - Blacklist update from local source completed" );
263 if (- d
"${General::swroot}/urlfilter/update" ) { & General
:: system ( "rm" , "-rf" , "${General::swroot}/urlfilter/update" ); }
264 if (- e
"${General::swroot}/urlfilter/blacklists.tar.gz" ) { unlink ( "${General::swroot}/urlfilter/blacklists.tar.gz" ); }
265 if ( $errormessage ) { goto ERROR
; }
268 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter backup' })
270 $blistbackup = ( $filtersettings { 'ENABLE_FULLBACKUP' } eq 'on' ) ?
"blacklists" : "blacklists/custom" ;
271 if (& General
:: system ( "/bin/tar" , "-C" , "${General::swroot}/urlfilter" , "-czf" , "${General::swroot}/urlfilter/backup.tar.gz" , "settings" , "timeconst" , "userquota" , "autoupdate" , " $blistbackup " ))
273 $errormessage = $Lang :: tr
{ 'urlfilter backup error' };
278 print "Content-type: application/gzip \n " ;
279 print "Content-length: " ;
280 print (- s
"${General::swroot}/urlfilter/backup.tar.gz" );
282 print "Content-disposition: attachment; filename=urlfilter-backup.tar.gz \n\n " ;
284 open ( FILE
, "${General::swroot}/urlfilter/backup.tar.gz" );
285 while (< FILE
>) { print ; }
288 if (- e
"${General::swroot}/urlfilter/backup.tar.gz" ) { unlink ( "${General::swroot}/urlfilter/backup.tar.gz" ); }
293 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter restore' })
295 & Header
:: getcgihash
( \
%filtersettings , { 'wantfile' => 1 , 'filevar' => 'UPDATEFILE' });
297 if (!( $filtersettings { 'UPDATEFILE' } =~ /.tar.gz$/ ))
299 $errormessage = $Lang :: tr
{ 'urlfilter wrong filetype' };
303 if (!(- d
"${General::swroot}/urlfilter/restore" )) { mkdir ( "${General::swroot}/urlfilter/restore" ); }
305 if ( copy
( $filtersettings { 'UPDATEFILE' }, "${General::swroot}/urlfilter/backup.tar.gz" ) != 1 )
310 my $exitcode = & General
:: system ( "/bin/tar" , "--no-same-owner" , "--preserve-permissions" , "-xzf" , "${General::swroot}/urlfilter/backup.tar.gz" , "-C" , "${General::swroot}/urlfilter/restore" );
313 $errormessage = $Lang :: tr
{ 'urlfilter tar error' };
315 if (!(- e
"${General::swroot}/urlfilter/restore/settings" ))
317 $errormessage = $Lang :: tr
{ 'urlfilter invalid restore file' };
320 system ( "cp -rp ${General::swroot}/urlfilter/restore/* ${General::swroot}/urlfilter/" );
321 & readblockcategories
;
325 $restoremessage = $Lang :: tr
{ 'urlfilter restore success' };
329 if (- e
"${General::swroot}/urlfilter/backup.tar.gz" ) { unlink ( "${General::swroot}/urlfilter/backup.tar.gz" ); }
330 if (- d
"${General::swroot}/urlfilter/restore" ) { & General
:: system ( "rm" , "-rf" , "${General::swroot}/urlfilter/restore" ); }
331 if ( $errormessage ) { goto ERROR
; }
334 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'save' })
336 $filtersettings { 'VALID' } = 'yes' ;
340 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter save and restart' })
342 if ((!(- e
"${General::swroot}/proxy/enable" )) && (!(- e
"${General::swroot}/proxy/enable_blue" )))
344 $errormessage = $Lang :: tr
{ 'urlfilter web proxy service required' };
347 if (!( $proxysettings { 'ENABLE_FILTER' } eq 'on' ))
349 $errormessage = $Lang :: tr
{ 'urlfilter not enabled' };
353 $filtersettings { 'VALID' } = 'yes' ;
356 & General
:: system ( '/usr/local/bin/squidctrl' , 'restart' );
360 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter set time constraints' }) { $tcsettings { 'TCMODE' } = 'on' }
362 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'add' }))
364 $tcsettings { 'TCMODE' }= 'on' ;
366 if (! $tcsettings { 'DST' })
368 $errormessage = $Lang :: tr
{ 'urlfilter dst error' };
371 if (! $tcsettings { 'SRC' })
373 $errormessage = $Lang :: tr
{ 'urlfilter src error' };
376 if (!( $tcsettings { 'TO_HOUR' }. $tcsettings { 'TO_MINUTE' } gt $tcsettings { 'FROM_HOUR' }. $tcsettings { 'FROM_MINUTE' }))
378 $errormessage = $Lang :: tr
{ 'urlfilter timespace error' };
381 if (!(( $tcsettings { 'MON' } eq 'on' ) || ( $tcsettings { 'TUE' } eq 'on' ) || ( $tcsettings { 'WED' } eq 'on' ) || ( $tcsettings { 'THU' } eq 'on' ) || ( $tcsettings { 'FRI' } eq 'on' ) || ( $tcsettings { 'SAT' } eq 'on' ) || ( $tcsettings { 'SUN' } eq 'on' )))
383 $errormessage = $Lang :: tr
{ 'urlfilter weekday error' };
388 # transform to pre1.8 client definitions
389 @clients = split ( /\n/ , $tcsettings { 'SRC' });
390 undef $tcsettings { 'SRC' };
393 s/^\s+//g ; s/\s+$//g ; s/\s+-\s+/-/g ; s/\s+/ /g ; s/\n//g ;
394 $tcsettings { 'SRC' } .= " $_ " ;
396 $tcsettings { 'SRC' } =~ s/\s+$// ;
398 if ( $tcsettings { 'DST' } =~ /^any/ ) { $tcsettings { 'DST' } = 'any' ; }
399 if ( $tcsettings { 'ENABLERULE' } eq 'on' ) { $tcsettings { 'ACTIVE' } = $tcsettings { 'ENABLERULE' }; } else { $tcsettings { 'ACTIVE' } = 'off' }
401 $tcsettings { 'ENABLERULE' } = 'on' ;
402 if ( $tcsettings { 'EDITING' } eq 'no' ) {
403 open ( FILE
, ">> $tcfile " );
405 print FILE
" $tcsettings {'DEFINITION'}, $tcsettings {'MON'}, $tcsettings {'TUE'}, $tcsettings {'WED'}, $tcsettings {'THU'}, $tcsettings {'FRI'}, $tcsettings {'SAT'}, $tcsettings {'SUN'}, $tcsettings {'FROM_HOUR'}, $tcsettings {'FROM_MINUTE'}, $tcsettings {'TO_HOUR'}, $tcsettings {'TO_MINUTE'}, $tcsettings {'SRC'}, $tcsettings {'DST'}, $tcsettings {'ACCESS'}, $tcsettings {'ACTIVE'}, $tcsettings {'COMMENT'} \n " ;
407 open ( FILE
, "> $tcfile " );
410 foreach $line ( @tclist )
413 if ( $tcsettings { 'EDITING' } eq $id ) {
414 print FILE
" $tcsettings {'DEFINITION'}, $tcsettings {'MON'}, $tcsettings {'TUE'}, $tcsettings {'WED'}, $tcsettings {'THU'}, $tcsettings {'FRI'}, $tcsettings {'SAT'}, $tcsettings {'SUN'}, $tcsettings {'FROM_HOUR'}, $tcsettings {'FROM_MINUTE'}, $tcsettings {'TO_HOUR'}, $tcsettings {'TO_MINUTE'}, $tcsettings {'SRC'}, $tcsettings {'DST'}, $tcsettings {'ACCESS'}, $tcsettings {'ACTIVE'}, $tcsettings {'COMMENT'} \n " ;
415 } else { print FILE
" $line " ; }
420 $tcsettings { 'CHANGED' }= 'yes' ;
421 $tcsettings { 'TCMODE' }= 'on' ;
424 if ( $tcsettings { 'EDITING' } ne 'no' )
426 $tcsettings { 'ACTION' } = $Lang :: tr
{ 'edit' };
427 $tcsettings { 'ID' } = $tcsettings { 'EDITING' };
432 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter copy rule' }) && (! $errormessage ))
435 foreach $line ( @tclist )
438 if ( $tcsettings { 'ID' } eq $id )
441 @temp = split ( /\,/ , $line );
442 $tcsettings { 'DEFINITION' } = $temp [ 0 ];
443 $tcsettings { 'MON' } = $temp [ 1 ];
444 $tcsettings { 'TUE' } = $temp [ 2 ];
445 $tcsettings { 'WED' } = $temp [ 3 ];
446 $tcsettings { 'THU' } = $temp [ 4 ];
447 $tcsettings { 'FRI' } = $temp [ 5 ];
448 $tcsettings { 'SAT' } = $temp [ 6 ];
449 $tcsettings { 'SUN' } = $temp [ 7 ];
450 $tcsettings { 'FROM_HOUR' } = $temp [ 8 ];
451 $tcsettings { 'FROM_MINUTE' } = $temp [ 9 ];
452 $tcsettings { 'TO_HOUR' } = $temp [ 10 ];
453 $tcsettings { 'TO_MINUTE' } = $temp [ 11 ];
454 $tcsettings { 'SRC' } = $temp [ 12 ];
455 $tcsettings { 'DST' } = $temp [ 13 ];
456 $tcsettings { 'ACCESS' } = $temp [ 14 ];
457 $tcsettings { 'ENABLERULE' } = $temp [ 15 ];
458 $tcsettings { 'COMMENT' } = $temp [ 16 ];
461 $tcsettings { 'TCMODE' }= 'on' ;
464 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'remove' }))
467 open ( FILE
, "> $tcfile " );
469 foreach $line ( @tclist )
472 unless ( $tcsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
475 $tcsettings { 'CHANGED' }= 'yes' ;
476 $tcsettings { 'TCMODE' }= 'on' ;
479 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter restart' }))
481 if (!( $proxysettings { 'ENABLE_FILTER' } eq 'on' ))
483 $errormessage = $Lang :: tr
{ 'urlfilter not enabled' };
485 if ((!(- e
"${General::swroot}/proxy/enable" )) && (!(- e
"${General::swroot}/proxy/enable_blue" )))
487 $errormessage = $Lang :: tr
{ 'urlfilter web proxy service required' };
490 if (! $errormessage ) { & General
:: system ( '/usr/local/bin/squidctrl' , 'restart' ); }
491 $tcsettings { 'TCMODE' }= 'on' ;
494 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }))
496 open ( FILE
, "> $tcfile " );
499 foreach $line ( @tclist )
502 unless ( $tcsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
506 @temp = split ( /\,/ , $line );
507 if ( $temp [ 15 ] eq 'on' ) { $temp [ 15 ] = 'off' ; } else { $temp [ 15 ] = 'on' }
508 print FILE
" $temp [0], $temp [1], $temp [2], $temp [3], $temp [4], $temp [5], $temp [6], $temp [7], $temp [8], $temp [9], $temp [10], $temp [11], $temp [12], $temp [13], $temp [14], $temp [15], $temp [16] \n " ;
512 $tcsettings { 'CHANGED' }= 'yes' ;
513 $tcsettings { 'TCMODE' }= 'on' ;
516 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) && (! $errormessage ))
519 foreach $line ( @tclist )
522 if ( $tcsettings { 'ID' } eq $id )
525 @temp = split ( /\,/ , $line );
526 $tcsettings { 'DEFINITION' } = $temp [ 0 ];
527 $tcsettings { 'MON' } = $temp [ 1 ];
528 $tcsettings { 'TUE' } = $temp [ 2 ];
529 $tcsettings { 'WED' } = $temp [ 3 ];
530 $tcsettings { 'THU' } = $temp [ 4 ];
531 $tcsettings { 'FRI' } = $temp [ 5 ];
532 $tcsettings { 'SAT' } = $temp [ 6 ];
533 $tcsettings { 'SUN' } = $temp [ 7 ];
534 $tcsettings { 'FROM_HOUR' } = $temp [ 8 ];
535 $tcsettings { 'FROM_MINUTE' } = $temp [ 9 ];
536 $tcsettings { 'TO_HOUR' } = $temp [ 10 ];
537 $tcsettings { 'TO_MINUTE' } = $temp [ 11 ];
538 $tcsettings { 'SRC' } = $temp [ 12 ];
539 $tcsettings { 'DST' } = $temp [ 13 ];
540 $tcsettings { 'ACCESS' } = $temp [ 14 ];
541 $tcsettings { 'ENABLERULE' } = $temp [ 15 ];
542 $tcsettings { 'COMMENT' } = $temp [ 16 ];
545 $tcsettings { 'TCMODE' }= 'on' ;
548 if ((! $errormessage ) && (!( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter copy rule' })) && (!( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }))) {
549 $tcsettings { 'ENABLERULE' }= 'on' ;
550 $tcsettings { 'TO_HOUR' }= '24' ;
553 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter set user quota' }) { $uqsettings { 'UQMODE' } = 'on' }
555 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'add' }))
557 $uqsettings { 'UQMODE' }= 'on' ;
559 if ((!( $uqsettings { 'TIME_QUOTA' } =~ /^\d+/ )) || ( $uqsettings { 'TIME_QUOTA' } < '1' ))
561 $errormessage = $Lang :: tr
{ 'urlfilter quota time error' };
564 @temp = split ( /\n/ , $uqsettings { 'QUOTA_USERS' });
565 undef $uqsettings { 'QUOTA_USERS' };
568 s/^\s+//g ; s/\s+$//g ;
569 if ( $_ ) { $uqsettings { 'QUOTA_USERS' } .= $_ . " \n " ; }
572 if ( $uqsettings { 'QUOTA_USERS' } eq '' )
574 $errormessage = $Lang :: tr
{ 'urlfilter quota user error' };
577 $_ = $uqsettings { 'QUOTA_USERS' };
579 my $quota_users = $_ ;
581 if ( $uqsettings { 'QUOTA_USERS' } =~ /\\/ )
583 $errormessage = $Lang :: tr
{ 'urlfilter invalid user error' };
586 if (! $errormessage ) {
587 if ( $uqsettings { 'ENABLEQUOTA' } eq 'on' ) { $uqsettings { 'ACTIVE' } = $uqsettings { 'ENABLEQUOTA' }; } else { $uqsettings { 'ACTIVE' } = 'off' }
589 $uqsettings { 'ENABLERULE' } = 'on' ;
590 if ( $uqsettings { 'EDITING' } eq 'no' ) {
591 open ( FILE
, ">> $uqfile " );
593 print FILE
" $uqsettings {'TIME_QUOTA'}, $uqsettings {'SPORADIC'}, $uqsettings {'RENEWAL'}, $quota_users , $uqsettings {'ACTIVE'} \n " ;
595 open ( FILE
, "> $uqfile " );
598 foreach $line ( @uqlist )
601 if ( $uqsettings { 'EDITING' } eq $id ) {
602 print FILE
" $uqsettings {'TIME_QUOTA'}, $uqsettings {'SPORADIC'}, $uqsettings {'RENEWAL'}, $quota_users , $uqsettings {'ACTIVE'} \n " ;
603 } else { print FILE
" $line " ; }
608 $uqsettings { 'CHANGED' }= 'yes' ;
609 $uqsettings { 'MODE' }= 'USERQUOTA' ;
610 $uqsettings { 'UQMODE' }= 'on' ;
613 if ( $uqsettings { 'EDITING' } ne 'no' )
615 $uqsettings { 'ACTION' } = $Lang :: tr
{ 'edit' };
616 $uqsettings { 'ID' } = $uqsettings { 'EDITING' };
621 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'remove' }))
624 open ( FILE
, "> $uqfile " );
626 foreach $line ( @uqlist )
629 unless ( $uqsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
632 $uqsettings { 'CHANGED' }= 'yes' ;
633 $uqsettings { 'UQMODE' }= 'on' ;
636 if (! $errormessage ) {
637 $uqsettings { 'ENABLEQUOTA' }= 'on' ;
640 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) && (! $errormessage ))
643 foreach $line ( @uqlist )
646 if ( $uqsettings { 'ID' } eq $id )
649 @temp = split ( /\,/ , $line );
650 $uqsettings { 'TIME_QUOTA' } = $temp [ 0 ];
651 $uqsettings { 'SPORADIC' } = $temp [ 1 ];
652 $uqsettings { 'RENEWAL' } = $temp [ 2 ];
653 $uqsettings { 'QUOTA_USERS' } = $temp [ 3 ];
654 $uqsettings { 'ENABLEQUOTA' } = $temp [ 4 ];
657 $uqsettings { 'UQMODE' }= 'on' ;
660 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }))
662 open ( FILE
, "> $uqfile " );
665 foreach $line ( @uqlist )
668 unless ( $uqsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
672 @temp = split ( /\,/ , $line );
673 if ( $temp [ 4 ] eq 'on' ) { $temp [ 4 ] = 'off' ; } else { $temp [ 4 ] = 'on' }
674 print FILE
" $temp [0], $temp [1], $temp [2], $temp [3], $temp [4] \n " ;
678 $uqsettings { 'CHANGED' }= 'yes' ;
679 $uqsettings { 'UQMODE' }= 'on' ;
682 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter restart' }))
684 if (!( $proxysettings { 'ENABLE_FILTER' } eq 'on' ))
686 $errormessage = $Lang :: tr
{ 'urlfilter not enabled' };
688 if ((!(- e
"${General::swroot}/proxy/enable" )) && (!(- e
"${General::swroot}/proxy/enable_blue" )))
690 $errormessage = $Lang :: tr
{ 'urlfilter web proxy service required' };
693 if (! $errormessage ) { & General
:: system ( '/usr/local/bin/squidctrl' , 'restart' ); }
694 $uqsettings { 'UQMODE' }= 'on' ;
697 if ( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter blacklist editor' }) { $besettings { 'BEMODE' } = 'on' ; }
699 if ( $besettings { 'MODE' } eq 'BLACKLIST_EDITOR' )
701 @temp = split ( /\n/ , $besettings { 'BE_DOMAINS' });
702 undef $besettings { 'BE_DOMAINS' };
705 s/^\s+//g ; s/\s+$//g ;
706 if ( $_ ) { $besettings { 'BE_DOMAINS' } .= $_ . " \n " ; }
708 chomp ( $besettings { 'BE_DOMAINS' });
709 @temp = split ( /\n/ , $besettings { 'BE_URLS' });
710 undef $besettings { 'BE_URLS' };
713 s/^\s+//g ; s/\s+$//g ;
714 if ( $_ ) { $besettings { 'BE_URLS' } .= $_ . " \n " ; }
716 chomp ( $besettings { 'BE_URLS' });
717 @temp = split ( /\n/ , $besettings { 'BE_EXPRESSIONS' });
718 undef $besettings { 'BE_EXPRESSIONS' };
721 s/^\s+//g ; s/\s+$//g ;
722 if ( $_ ) { $besettings { 'BE_EXPRESSIONS' } .= $_ . " \n " ; }
724 chomp ( $besettings { 'BE_EXPRESSIONS' });
727 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter load blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
729 $besettings { 'BEMODE' } = 'on' ;
731 $besettings { 'BE_NAME' } = $besettings { 'BE_BLACKLIST' };
733 delete $besettings { 'BE_DOMAINS' };
734 delete $besettings { 'BE_URLS' };
735 delete $besettings { 'BE_EXPRESSIONS' };
737 if (- e
" $dbdir / $besettings {'BE_NAME'}/domains" )
739 open ( FILE
, " $dbdir / $besettings {'BE_NAME'}/domains" );
740 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_DOMAINS' } .= $_ } };
742 chomp ( $besettings { 'BE_DOMAINS' });
744 if (- e
" $dbdir / $besettings {'BE_NAME'}/urls" )
746 open ( FILE
, " $dbdir / $besettings {'BE_NAME'}/urls" );
747 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_URLS' } .= $_ } };
749 chomp ( $besettings { 'BE_URLS' });
751 if (- e
" $dbdir / $besettings {'BE_NAME'}/expressions" )
753 open ( FILE
, " $dbdir / $besettings {'BE_NAME'}/expressions" );
754 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_EXPRESSIONS' } .= $_ } };
756 chomp ( $besettings { 'BE_EXPRESSIONS' });
760 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter import blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
762 $besettings { 'BEMODE' } = 'on' ;
764 & Header
:: getcgihash
( \
%besettings , { 'wantfile' => 1 , 'filevar' => 'IMPORTFILE' });
766 if (!( $besettings { 'IMPORTFILE' } =~ /.tar.gz$/ ))
768 $errormessage = $Lang :: tr
{ 'urlfilter wrong filetype' };
770 if (!- d
" $editdir " ) { mkdir ( " $editdir " ); }
772 if ( copy
( $besettings { 'IMPORTFILE' }, " $editdir /blacklist.tar.gz" ) != 1 )
777 my $exitcode = & General
:: system ( "/bin/tar" , "--no-same-owner" , "--preserve-permissions" , "-xzf" , " $editdir /blacklist.tar.gz" , "-C" , " $editdir " );
780 $errormessage = $Lang :: tr
{ 'urlfilter tar error' };
783 foreach (< $editdir /blacklists/ *>)
788 $besettings { 'BE_NAME' } = substr ( $_ , rindex ( $_ , "/" )+ 1 );
794 $errormessage = $Lang :: tr
{ 'urlfilter invalid import file' };
796 delete $besettings { 'BE_DOMAINS' };
797 delete $besettings { 'BE_URLS' };
798 delete $besettings { 'BE_EXPRESSIONS' };
800 if (- e
" $editdir /blacklists/ $besettings {'BE_NAME'}/domains" )
802 open ( FILE
, " $editdir /blacklists/ $besettings {'BE_NAME'}/domains" );
803 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_DOMAINS' } .= $_ } };
805 chomp ( $besettings { 'BE_DOMAINS' });
807 if (- e
" $editdir /blacklists/ $besettings {'BE_NAME'}/urls" )
809 open ( FILE
, " $editdir /blacklists/ $besettings {'BE_NAME'}/urls" );
810 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_URLS' } .= $_ } };
812 chomp ( $besettings { 'BE_URLS' });
814 if (- e
" $editdir /blacklists/ $besettings {'BE_NAME'}/expressions" )
816 open ( FILE
, " $editdir /blacklists/ $besettings {'BE_NAME'}/expressions" );
817 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_EXPRESSIONS' } .= $_ } };
819 chomp ( $besettings { 'BE_EXPRESSIONS' });
824 if (- d
$editdir ) { & General
:: system ( "rm" , "-rf" , " $editdir " ); }
830 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter export blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
832 $besettings { 'BEMODE' } = 'on' ;
834 if ( $besettings { 'BE_NAME' } eq '' )
836 $errormessage = $Lang :: tr
{ 'urlfilter category name error' };
837 } elsif ( $besettings { 'BE_DOMAINS' } || $besettings { 'BE_URLS' } || $besettings { 'BE_EXPRESSIONS' }) {
839 $_ = $besettings { 'BE_NAME' }; tr/A-Z/a-z/ ; $besettings { 'BE_NAME' } = $_ ;
841 if (!(- d
" $editdir " )) { mkdir ( " $editdir " ); }
842 if (!(- d
" $editdir /blacklists" )) { mkdir ( " $editdir /blacklists" ); }
843 if (!(- d
" $editdir /blacklists/ $besettings {'BE_NAME'}" )) { mkdir ( " $editdir /blacklists/ $besettings {'BE_NAME'}" ); }
845 open ( FILE
, "> $editdir /blacklists/ $besettings {'BE_NAME'}/domains" );
847 print FILE
" $besettings {'BE_DOMAINS'} \n " ;
849 open ( FILE
, "> $editdir /blacklists/ $besettings {'BE_NAME'}/urls" );
851 print FILE
" $besettings {'BE_URLS'} \n " ;
853 open ( FILE
, "> $editdir /blacklists/ $besettings {'BE_NAME'}/expressions" );
855 print FILE
" $besettings {'BE_EXPRESSIONS'} \n " ;
858 if (& General
:: system ( "/bin/tar" , "-C" , " $editdir " , "-czf" , " $editdir / $besettings {'BE_NAME'}.tar.gz" , "blacklists" ))
860 $errormessage = $Lang :: tr
{ 'urlfilter export error' };
864 print "Content-type: application/gzip \n " ;
865 print "Content-length: " ;
866 print (- s
" $editdir / $besettings {'BE_NAME'}.tar.gz" );
868 print "Content-disposition: attachment; filename= $besettings {'BE_NAME'}.tar.gz \n\n " ;
870 open ( FILE
, " $editdir / $besettings {'BE_NAME'}.tar.gz" );
871 while (< FILE
>) { print ; }
874 if (- d
$editdir ) { & General
:: system ( "rm" , "-rf" , " $editdir " ); }
878 $errormessage = $Lang :: tr
{ 'urlfilter category data error' };
882 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter install blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
884 $besettings { 'BEMODE' } = 'on' ;
886 if ( $besettings { 'BE_NAME' } eq '' )
888 $errormessage = $Lang :: tr
{ 'urlfilter category name error' };
889 } elsif ( $besettings { 'BE_DOMAINS' } || $besettings { 'BE_URLS' } || $besettings { 'BE_EXPRESSIONS' }) {
891 $_ = $besettings { 'BE_NAME' }; tr/A-Z/a-z/ ; $besettings { 'BE_NAME' } = $_ ;
893 if (!- d
" $editdir " ) { mkdir ( " $editdir " ); }
895 if (!- d
" $dbdir / $besettings {'BE_NAME'}" ) { mkdir ( " $dbdir / $besettings {'BE_NAME'}" ); }
897 if (- e
" $dbdir / $besettings {'BE_NAME'}/domains" ) { unlink ( " $dbdir / $besettings {'BE_NAME'}/domains" ); }
898 if ( $besettings { 'BE_DOMAINS' })
900 open ( FILE
, "> $dbdir / $besettings {'BE_NAME'}/domains" );
902 print FILE
" $besettings {'BE_DOMAINS'} \n " ;
905 if (- e
" $dbdir / $besettings {'BE_NAME'}/urls" ) { unlink ( " $dbdir / $besettings {'BE_NAME'}/urls" ); }
906 if ( $besettings { 'BE_URLS' })
908 open ( FILE
, "> $dbdir / $besettings {'BE_NAME'}/urls" );
910 print FILE
" $besettings {'BE_URLS'} \n " ;
913 if (- e
" $dbdir / $besettings {'BE_NAME'}/expressions" ) { unlink ( " $dbdir / $besettings {'BE_NAME'}/expressions" ); }
914 if ( $besettings { 'BE_EXPRESSIONS' })
916 open ( FILE
, "> $dbdir / $besettings {'BE_NAME'}/expressions" );
918 print FILE
" $besettings {'BE_EXPRESSIONS'} \n " ;
922 open ( FILE
, "> $editdir /install.conf" );
924 print FILE
"logdir /var/log/squidGuard \n " ;
925 print FILE
"dbhome $dbdir / $besettings {'BE_NAME'} \n\n " ;
926 print FILE
"dest $besettings {'BE_NAME'} { \n " ;
927 if ( $besettings { 'BE_DOMAINS' }) { print FILE
" domainlist domains \n " ; }
928 if ( $besettings { 'BE_URLS' }) { print FILE
" urllist urls \n " ; }
929 if ( $besettings { 'BE_EXPRESSIONS' }) { print FILE
" expressions expressions \n " ; }
931 print FILE
"acl { \n " ;
932 print FILE
" default { \n " ;
933 print FILE
" pass none \n " ;
939 system ( "rm -f $dbdir / $besettings {'BE_NAME'}/*.db" );
940 & General
:: system ( "/usr/bin/squidGuard" , "-c" , " $editdir /install.conf" , "-C" , "all" );
942 system ( "chmod a+w $dbdir / $besettings {'BE_NAME'}/*.db" );
944 & readblockcategories
;
949 & General
:: system ( '/usr/local/bin/squidctrl' , 'restart' ) unless ( $besettings { 'NORESTART' } eq 'on' );
951 if (- d
$editdir ) { & General
:: system ( "rm" , "-rf" , " $editdir " ); }
953 $errormessage = $Lang :: tr
{ 'urlfilter category data error' };
957 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter save schedule' })
959 if (( $filtersettings { 'UPDATE_SOURCE' } eq 'custom' ) && ( $filtersettings { 'CUSTOM_UPDATE_URL' } eq '' ))
961 $errormessage = $Lang :: tr
{ 'urlfilter custom url required' };
963 open ( FILE
, "> $updconffile " );
964 print FILE
"ENABLE_AUTOUPDATE= $filtersettings {'ENABLE_AUTOUPDATE'} \n " ;
965 print FILE
"UPDATE_SCHEDULE= $filtersettings {'UPDATE_SCHEDULE'} \n " ;
966 print FILE
"UPDATE_SOURCE= $filtersettings {'UPDATE_SOURCE'} \n " ;
967 print FILE
"CUSTOM_UPDATE_URL= $filtersettings {'CUSTOM_UPDATE_URL'} \n " ;
971 if (( $filtersettings { 'ENABLE_AUTOUPDATE' } eq 'on' ) && ( $filtersettings { 'UPDATE_SCHEDULE' } eq 'daily' ))
973 & General
:: system ( '/usr/local/bin/urlfilterctrl' , 'cron' , 'daily' );
976 if (( $filtersettings { 'ENABLE_AUTOUPDATE' } eq 'on' ) && ( $filtersettings { 'UPDATE_SCHEDULE' } eq 'weekly' ))
978 & General
:: system ( '/usr/local/bin/urlfilterctrl' , 'cron' , 'weekly' );
981 if (( $filtersettings { 'ENABLE_AUTOUPDATE' } eq 'on' ) && ( $filtersettings { 'UPDATE_SCHEDULE' } eq 'monthly' ))
983 & General
:: system ( '/usr/local/bin/urlfilterctrl' , 'cron' , 'monthly' );
986 if ( $filtersettings { 'ENABLE_AUTOUPDATE' } eq 'off' )
988 & General
:: system ( '/usr/local/bin/urlfilterctrl' , 'cron' , 'remove' );
993 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter update now' })
995 if ( $filtersettings { 'UPDATE_SOURCE' } eq 'custom' )
997 if ( $filtersettings { 'CUSTOM_UPDATE_URL' } eq '' )
999 $errormessage = $Lang :: tr
{ 'urlfilter custom url required' };
1001 & General
:: system_background
( "${General::swroot}/urlfilter/bin/autoupdate.pl" , " $filtersettings {'CUSTOM_UPDATE_URL'}" );
1004 & General
:: system_background
( "${General::swroot}/urlfilter/bin/autoupdate.pl" , " $filtersettings {'UPDATE_SOURCE'}" );
1009 if (- e
"${General::swroot}/urlfilter/settings" ) { & General
:: readhash
( "${General::swroot}/urlfilter/settings" , \
%filtersettings ); }
1015 if ( $errormessage ) { $filtersettings { 'VALID' } = 'no' ; }
1017 $checked { 'ENABLE_CUSTOM_BLACKLIST' }{ 'off' } = '' ;
1018 $checked { 'ENABLE_CUSTOM_BLACKLIST' }{ 'on' } = '' ;
1019 $checked { 'ENABLE_CUSTOM_BLACKLIST' }{ $filtersettings { 'ENABLE_CUSTOM_BLACKLIST' }} = "checked='checked'" ;
1020 $checked { 'ENABLE_CUSTOM_WHITELIST' }{ 'off' } = '' ;
1021 $checked { 'ENABLE_CUSTOM_WHITELIST' }{ 'on' } = '' ;
1022 $checked { 'ENABLE_CUSTOM_WHITELIST' }{ $filtersettings { 'ENABLE_CUSTOM_WHITELIST' }} = "checked='checked'" ;
1023 $checked { 'ENABLE_CUSTOM_EXPRESSIONS' }{ 'off' } = '' ;
1024 $checked { 'ENABLE_CUSTOM_EXPRESSIONS' }{ 'on' } = '' ;
1025 $checked { 'ENABLE_CUSTOM_EXPRESSIONS' }{ $filtersettings { 'ENABLE_CUSTOM_EXPRESSIONS' }} = "checked='checked'" ;
1026 $checked { 'BLOCK_EXECUTABLES' }{ 'off' } = '' ;
1027 $checked { 'BLOCK_EXECUTABLES' }{ 'on' } = '' ;
1028 $checked { 'BLOCK_EXECUTABLES' }{ $filtersettings { 'BLOCK_EXECUTABLES' }} = "checked='checked'" ;
1029 $checked { 'BLOCK_AUDIO-VIDEO' }{ 'off' } = '' ;
1030 $checked { 'BLOCK_AUDIO-VIDEO' }{ 'on' } = '' ;
1031 $checked { 'BLOCK_AUDIO-VIDEO' }{ $filtersettings { 'BLOCK_AUDIO-VIDEO' }} = "checked='checked'" ;
1032 $checked { 'BLOCK_ARCHIVES' }{ 'off' } = '' ;
1033 $checked { 'BLOCK_ARCHIVES' }{ 'on' } = '' ;
1034 $checked { 'BLOCK_ARCHIVES' }{ $filtersettings { 'BLOCK_ARCHIVES' }} = "checked='checked'" ;
1035 $checked { 'ENABLE_REWRITE' }{ 'off' } = '' ;
1036 $checked { 'ENABLE_REWRITE' }{ 'on' } = '' ;
1037 $checked { 'ENABLE_REWRITE' }{ $filtersettings { 'ENABLE_REWRITE' }} = "checked='checked'" ;
1038 $checked { 'SHOW_CATEGORY' }{ 'off' } = '' ;
1039 $checked { 'SHOW_CATEGORY' }{ 'on' } = '' ;
1040 $checked { 'SHOW_CATEGORY' }{ $filtersettings { 'SHOW_CATEGORY' }} = "checked='checked'" ;
1041 $checked { 'SHOW_URL' }{ 'off' } = '' ;
1042 $checked { 'SHOW_URL' }{ 'on' } = '' ;
1043 $checked { 'SHOW_URL' }{ $filtersettings { 'SHOW_URL' }} = "checked='checked'" ;
1044 $checked { 'SHOW_IP' }{ 'off' } = '' ;
1045 $checked { 'SHOW_IP' }{ 'on' } = '' ;
1046 $checked { 'SHOW_IP' }{ $filtersettings { 'SHOW_IP' }} = "checked='checked'" ;
1047 $checked { 'ENABLE_DNSERROR' }{ 'off' } = '' ;
1048 $checked { 'ENABLE_DNSERROR' }{ 'on' } = '' ;
1049 $checked { 'ENABLE_DNSERROR' }{ $filtersettings { 'ENABLE_DNSERROR' }} = "checked='checked'" ;
1050 $checked { 'ENABLE_JPEG' }{ 'off' } = '' ;
1051 $checked { 'ENABLE_JPEG' }{ 'on' } = '' ;
1052 $checked { 'ENABLE_JPEG' }{ $filtersettings { 'ENABLE_JPEG' }} = "checked='checked'" ;
1053 $checked { 'ENABLE_EXPR_LISTS' }{ 'off' } = '' ;
1054 $checked { 'ENABLE_EXPR_LISTS' }{ 'on' } = '' ;
1055 $checked { 'ENABLE_EXPR_LISTS' }{ $filtersettings { 'ENABLE_EXPR_LISTS' }} = "checked='checked'" ;
1056 $checked { 'BLOCK_IP_ADDR' }{ 'off' } = '' ;
1057 $checked { 'BLOCK_IP_ADDR' }{ 'on' } = '' ;
1058 $checked { 'BLOCK_IP_ADDR' }{ $filtersettings { 'BLOCK_IP_ADDR' }} = "checked='checked'" ;
1059 $checked { 'BLOCK_ALL' }{ 'off' } = '' ;
1060 $checked { 'BLOCK_ALL' }{ 'on' } = '' ;
1061 $checked { 'BLOCK_ALL' }{ $filtersettings { 'BLOCK_ALL' }} = "checked='checked'" ;
1062 $checked { 'ENABLE_EMPTY_ADS' }{ 'off' } = '' ;
1063 $checked { 'ENABLE_EMPTY_ADS' }{ 'on' } = '' ;
1064 $checked { 'ENABLE_EMPTY_ADS' }{ $filtersettings { 'ENABLE_EMPTY_ADS' }} = "checked='checked'" ;
1065 $checked { 'ENABLE_GLOBAL_WHITELIST' }{ 'off' } = '' ;
1066 $checked { 'ENABLE_GLOBAL_WHITELIST' }{ 'on' } = '' ;
1067 $checked { 'ENABLE_GLOBAL_WHITELIST' }{ $filtersettings { 'ENABLE_GLOBAL_WHITELIST' }} = "checked='checked'" ;
1068 $checked { 'ENABLE_LOG' }{ 'off' } = '' ;
1069 $checked { 'ENABLE_LOG' }{ 'on' } = '' ;
1070 $checked { 'ENABLE_LOG' }{ $filtersettings { 'ENABLE_LOG' }} = "checked='checked'" ;
1071 $checked { 'ENABLE_USERNAME_LOG' }{ 'off' } = '' ;
1072 $checked { 'ENABLE_USERNAME_LOG' }{ 'on' } = '' ;
1073 $checked { 'ENABLE_USERNAME_LOG' }{ $filtersettings { 'ENABLE_USERNAME_LOG' }} = "checked='checked'" ;
1074 $checked { 'ENABLE_CATEGORY_LOG' }{ 'off' } = '' ;
1075 $checked { 'ENABLE_CATEGORY_LOG' }{ 'on' } = '' ;
1076 $checked { 'ENABLE_CATEGORY_LOG' }{ $filtersettings { 'ENABLE_CATEGORY_LOG' }} = "checked='checked'" ;
1078 foreach $category ( @filtergroups ) {
1079 $checked { $category }{ 'off' } = '' ;
1080 $checked { $category }{ 'on' } = '' ;
1081 $checked { $category }{ $filtersettings { $category }} = "checked='checked'" ;
1084 $selected { 'REDIRECT_TEMPLATE' }{ $filtersettings { 'REDIRECT_TEMPLATE' }} = "selected='selected'" ;
1086 $selected { 'DEFINITION' }{ $tcsettings { 'DEFINITION' }} = "selected='selected'" ;
1087 $selected { 'FROM_HOUR' }{ $tcsettings { 'FROM_HOUR' }} = "selected='selected'" ;
1088 $selected { 'FROM_MINUTE' }{ $tcsettings { 'FROM_MINUTE' }} = "selected='selected'" ;
1089 $selected { 'TO_HOUR' }{ $tcsettings { 'TO_HOUR' }} = "selected='selected'" ;
1090 $selected { 'TO_MINUTE' }{ $tcsettings { 'TO_MINUTE' }} = "selected='selected'" ;
1092 @selectedcategories = split ( /\|/ , $tcsettings { 'DST' });
1093 foreach ( @selectedcategories )
1095 $selected { 'DST' }{ $_ } = "selected='selected'" ;
1098 $selected { 'ACCESS' }{ $tcsettings { 'ACCESS' }} = "selected='selected'" ;
1100 $checked { 'ENABLERULE' }{ 'off' } = '' ;
1101 $checked { 'ENABLERULE' }{ 'on' } = '' ;
1102 $checked { 'ENABLERULE' }{ $tcsettings { 'ENABLERULE' }} = "checked='checked'" ;
1103 $checked { 'MON' }{ 'off' } = '' ;
1104 $checked { 'MON' }{ 'on' } = '' ;
1105 $checked { 'MON' }{ $tcsettings { 'MON' }} = "checked='checked'" ;
1106 $checked { 'TUE' }{ 'off' } = '' ;
1107 $checked { 'TUE' }{ 'on' } = '' ;
1108 $checked { 'TUE' }{ $tcsettings { 'TUE' }} = "checked='checked'" ;
1109 $checked { 'WED' }{ 'off' } = '' ;
1110 $checked { 'WED' }{ 'on' } = '' ;
1111 $checked { 'WED' }{ $tcsettings { 'WED' }} = "checked='checked'" ;
1112 $checked { 'THU' }{ 'off' } = '' ;
1113 $checked { 'THU' }{ 'on' } = '' ;
1114 $checked { 'THU' }{ $tcsettings { 'THU' }} = "checked='checked'" ;
1115 $checked { 'FRI' }{ 'off' } = '' ;
1116 $checked { 'FRI' }{ 'on' } = '' ;
1117 $checked { 'FRI' }{ $tcsettings { 'FRI' }} = "checked='checked'" ;
1118 $checked { 'SAT' }{ 'off' } = '' ;
1119 $checked { 'SAT' }{ 'on' } = '' ;
1120 $checked { 'SAT' }{ $tcsettings { 'SAT' }} = "checked='checked'" ;
1121 $checked { 'SUN' }{ 'off' } = '' ;
1122 $checked { 'SUN' }{ 'on' } = '' ;
1123 $checked { 'SUN' }{ $tcsettings { 'SUN' }} = "checked='checked'" ;
1125 $selected { 'SPORADIC' }{ $uqsettings { 'SPORADIC' }} = "selected='selected'" ;
1126 $selected { 'RENEWAL' } { $uqsettings { 'RENEWAL' }} = "selected='selected'" ;
1128 $checked { 'ENABLEQUOTA' }{ 'off' } = '' ;
1129 $checked { 'ENABLEQUOTA' }{ 'on' } = '' ;
1130 $checked { 'ENABLEQUOTA' }{ $uqsettings { 'ENABLEQUOTA' }} = "checked='checked'" ;
1132 $selected { 'BE_BLACKLIST' }{ $besettings { 'BE_BLACKLIST' }} = "selected='selected'" ;
1135 & Header
:: showhttpheaders
();
1137 & Header
:: openpage
( $Lang :: tr
{ 'urlfilter configuration' }, 1 , '' );
1139 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
1141 if ( $errormessage ) {
1142 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
1143 print "<font class='base'> $errormessage </font> \n " ;
1144 & Header
:: closebox
();
1145 } elsif (( $tcsettings { 'CHANGED' } eq 'yes' ) || ( $uqsettings { 'CHANGED' } eq 'yes' ) ) {
1147 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}'> \n " ;
1148 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter restart notification'}:" );
1149 print "<class name='base'> $Lang ::tr{'urlfilter restart message'} \n " ;
1150 if ( $uqsettings { 'MODE' } eq 'USERQUOTA' ) { print "<p><class name='base'> $Lang ::tr{'urlfilter quota restart message'} \n " ; }
1152 print "<p><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter restart'}' />" ;
1153 if ( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) { print "<input type='hidden' name='MODE' value='TIMECONSTRAINT' />" ; }
1154 if ( $uqsettings { 'MODE' } eq 'USERQUOTA' ) { print "<input type='hidden' name='MODE' value='USERQUOTA' />" ; }
1155 & Header
:: closebox
();
1159 if ( $restoremessage ) {
1160 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter restore results'}:" );
1161 print "<class name='base'> $restoremessage \n " ;
1162 print " </class> \n " ;
1163 & Header
:: closebox
();
1166 if ((! $tcsettings { 'TCMODE' }) && (! $uqsettings { 'UQMODE' }) && (! $besettings { 'BEMODE' })) {
1168 if (!( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter manage repository' })) {
1170 #==========================================================
1172 # Section: Main Configuration
1174 #==========================================================
1176 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
1178 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter filter settings'}" );
1180 <table width='100%'>
1182 <td colspan='4'><b> $Lang ::tr{'urlfilter block categories'}</b></td>
1187 if ( @categories == 0 ) {
1190 <td><i> $Lang ::tr{'urlfilter no categories'}</i></td>
1200 for ( $n = 0 ; $n <= @categories ; $n = $n + $i ) {
1201 for ( $i = 0 ; $i <= 3 ; $i ++) {
1202 if ( $i eq 0 ) { print "<tr> \n " ; }
1203 if (( $n + $i ) < @categories ) {
1204 print "<td width='15%'> @categories [ $n + $i ]:<\/td> \n " ;
1205 print "<td width='10%'><input type='checkbox' name= @filtergroups [ $n + $i ] $checked { @filtergroups [ $n + $i ]}{'on'} /></td> \n " ;
1207 if ( $i eq 3 ) { print "<\/tr> \n " ; }
1214 <table width='100%'>
1216 <td><b> $Lang ::tr{'urlfilter custom blacklist'}</b></td>
1222 <td colspan='2'> $Lang ::tr{'urlfilter blocked domains'}</td>
1223 <td colspan='2'> $Lang ::tr{'urlfilter blocked urls'}</td>
1226 <td colspan='2'> $Lang ::tr{'urlfilter example'}</td>
1227 <td colspan='2'> $Lang ::tr{'urlfilter example ads'}</td>
1230 <td colspan='2' width='50%'><textarea name='CUSTOM_BLACK_DOMAINS' cols='32' rows='6' wrap='off'>
1234 print $filtersettings { 'CUSTOM_BLACK_DOMAINS' };
1238 <td colspan='2' width='50%'><textarea name='CUSTOM_BLACK_URLS' cols='32' rows='6' wrap='off'>
1242 print $filtersettings { 'CUSTOM_BLACK_URLS' };
1248 <table width='100%'>
1250 <td class='base' width='25%'> $Lang ::tr{'urlfilter enable custom blacklist'}:</td>
1251 <td><input type='checkbox' name='ENABLE_CUSTOM_BLACKLIST' $checked {'ENABLE_CUSTOM_BLACKLIST'}{'on'} /></td>
1257 <table width='100%'>
1259 <td><b> $Lang ::tr{'urlfilter custom whitelist'}</b></td>
1265 <td colspan='2'> $Lang ::tr{'urlfilter allowed domains'}</td>
1266 <td colspan='2'> $Lang ::tr{'urlfilter allowed urls'}</td>
1269 <td colspan='2'> $Lang ::tr{'urlfilter example'}</td>
1270 <td colspan='2'> $Lang ::tr{'urlfilter example ads'}</td>
1273 <td colspan='2' width='50%'><textarea name='CUSTOM_WHITE_DOMAINS' cols='32' rows='6' wrap='off'>
1277 print $filtersettings { 'CUSTOM_WHITE_DOMAINS' };
1281 <td colspan='2' width='50%'><textarea name='CUSTOM_WHITE_URLS' cols='32' rows='6' wrap='off'>
1285 print $filtersettings { 'CUSTOM_WHITE_URLS' };
1291 <table width='100%'>
1293 <td class='base' width='25%'> $Lang ::tr{'urlfilter enable custom whitelist'}:</td>
1294 <td><input type='checkbox' name='ENABLE_CUSTOM_WHITELIST' $checked {'ENABLE_CUSTOM_WHITELIST'}{'on'} /></td>
1300 <table width='100%'>
1302 <td colspan='4'><b> $Lang ::tr{'urlfilter custom expression list'}</b></td>
1305 <td colspan='4'> $Lang ::tr{'urlfilter blocked expressions'}</td>
1308 <td colspan='4'><textarea name='CUSTOM_EXPRESSIONS' cols='70' rows='3' wrap='off'>
1312 print $filtersettings { 'CUSTOM_EXPRESSIONS' };
1318 <td class='base' width='25%'> $Lang ::tr{'urlfilter enable custom expression list'}:</td>
1319 <td><input type='checkbox' name='ENABLE_CUSTOM_EXPRESSIONS' $checked {'ENABLE_CUSTOM_EXPRESSIONS'}{'on'} /></td>
1325 <table width='100%'>
1327 <td colspan='4'><b> $Lang ::tr{'urlfilter file ext block'}</b></td>
1330 <td width='25%' class='base'> $Lang ::tr{'urlfilter block executables'}:</td>
1331 <td width='12%'><input type='checkbox' name='BLOCK_EXECUTABLES' $checked {'BLOCK_EXECUTABLES'}{'on'} /></td>
1332 <td width='25%' class='base'> $Lang ::tr{'urlfilter block audio-video'}:</td>
1333 <td><input type='checkbox' name='BLOCK_AUDIO-VIDEO' $checked {'BLOCK_AUDIO-VIDEO'}{'on'} /></td>
1336 <td class='base'> $Lang ::tr{'urlfilter block archives'}:</td>
1337 <td><input type='checkbox' name='BLOCK_ARCHIVES' $checked {'BLOCK_ARCHIVES'}{'on'} /></td>
1343 <table width='100%'>
1345 <td colspan='4'><b> $Lang ::tr{'urlfilter local file redirection'}</b></td>
1348 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable rewrite rules'}:</td>
1349 <td width='12%'><input type='checkbox' name='ENABLE_REWRITE' $checked {'ENABLE_REWRITE'}{'on'} /></td>
1354 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter manage repository'}'></td>
1361 <table width='100%'>
1363 <td colspan='2'><b> $Lang ::tr{'urlfilter network access control'}</b></td>
1368 <td colspan='2'> $Lang ::tr{'urlfilter unfiltered clients'}</td>
1369 <td colspan='2'> $Lang ::tr{'urlfilter banned clients'}</td>
1372 <td colspan='2' width='50%'><textarea name='UNFILTERED_CLIENTS' cols='32' rows='6' wrap='off'>
1376 # transform from pre1.8 client definitions
1377 $filtersettings { 'UNFILTERED_CLIENTS' } =~ s/^\s+//g ;
1378 $filtersettings { 'UNFILTERED_CLIENTS' } =~ s/\s+$//g ;
1379 $filtersettings { 'UNFILTERED_CLIENTS' } =~ s/\s+-\s+/-/g ;
1380 $filtersettings { 'UNFILTERED_CLIENTS' } =~ s/\s+/ /g ;
1382 @clients = split ( / / , $filtersettings { 'UNFILTERED_CLIENTS' });
1383 undef $filtersettings { 'UNFILTERED_CLIENTS' };
1384 foreach ( @clients ) { $filtersettings { 'UNFILTERED_CLIENTS' } .= " $_ \n " ; }
1386 print $filtersettings { 'UNFILTERED_CLIENTS' };
1390 <td colspan='2' width='50%'><textarea name='BANNED_CLIENTS' cols='32' rows='6' wrap='off'>
1394 # transform from pre1.8 client definitions
1395 $filtersettings { 'BANNED_CLIENTS' } =~ s/^\s+//g ;
1396 $filtersettings { 'BANNED_CLIENTS' } =~ s/\s+$//g ;
1397 $filtersettings { 'BANNED_CLIENTS' } =~ s/\s+-\s+/-/g ;
1398 $filtersettings { 'BANNED_CLIENTS' } =~ s/\s+/ /g ;
1400 @clients = split ( / / , $filtersettings { 'BANNED_CLIENTS' });
1401 undef $filtersettings { 'BANNED_CLIENTS' };
1402 foreach ( @clients ) { $filtersettings { 'BANNED_CLIENTS' } .= " $_ \n " ; }
1404 print $filtersettings { 'BANNED_CLIENTS' };
1411 <table width='100%'>
1413 <td colspan='4'><b> $Lang ::tr{'urlfilter timebased access control'}</b></td>
1416 <td width='25%'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter set time constraints'}'></td>
1417 <td width='25%'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter set user quota'}'></td>
1423 <table width='100%'>
1425 <td colspan='4'><b> $Lang ::tr{'urlfilter block settings'}</b></td>
1428 <td width='25%' class='base'> $Lang ::tr{'urlfilter redirect template'}</td>
1429 <td width='75%' colspan='2'>
1430 <select name='REDIRECT_TEMPLATE'>
1434 foreach (< $templatedir /*>) {
1435 if ((- d
" $_ " ) && (- e
" $_ /template.html" )) {
1436 my $template = substr ( $_ , rindex ( $_ , "/" )+ 1 );
1437 print "<option value=' $template ' $selected {'REDIRECT_TEMPLATE'}{ $template }> $template </option> \n " ;
1446 <td width='25%' class='base'> $Lang ::tr{'urlfilter show category'}:</td>
1447 <td width='12%'><input type='checkbox' name='SHOW_CATEGORY' $checked {'SHOW_CATEGORY'}{'on'} /></td>
1448 <td width='25%' class='base'> $Lang ::tr{'urlfilter redirectpage'}:</td>
1449 <td><input type='text' name='REDIRECT_PAGE' value=' $filtersettings {'REDIRECT_PAGE'}' size='40' /></td>
1452 <td class='base'> $Lang ::tr{'urlfilter show url'}:</td>
1453 <td><input type='checkbox' name='SHOW_URL' $checked {'SHOW_URL'}{'on'} /></td>
1454 <td class='base'> $Lang ::tr{'urlfilter msg text 1'}:</td>
1455 <td><input type='text' name='MSG_TEXT_1' value=' $filtersettings {'MSG_TEXT_1'}' size='40' /></td>
1458 <td class='base'> $Lang ::tr{'urlfilter show ip'}:</td>
1459 <td><input type='checkbox' name='SHOW_IP' $checked {'SHOW_IP'}{'on'} /></td>
1460 <td class='base'> $Lang ::tr{'urlfilter msg text 2'}:</td>
1461 <td><input type='text' name='MSG_TEXT_2' value=' $filtersettings {'MSG_TEXT_2'}' size='40' /></td>
1464 <td class='base'> $Lang ::tr{'urlfilter show dnserror'}:</td>
1465 <td><input type='checkbox' name='ENABLE_DNSERROR' $checked {'ENABLE_DNSERROR'}{'on'} /></td>
1466 <td class='base'> $Lang ::tr{'urlfilter msg text 3'}:</td>
1467 <td><input type='text' name='MSG_TEXT_3' value=' $filtersettings {'MSG_TEXT_3'}' size='40' /></td>
1471 <table width='100%'>
1473 <td colspan='4'><b> $Lang ::tr{'urlfilter advanced settings'}</b></td>
1476 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable expression lists'}:</td>
1477 <td width='12%'><input type='checkbox' name='ENABLE_EXPR_LISTS' $checked {'ENABLE_EXPR_LISTS'}{'on'} /></td>
1478 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable log'}:</td>
1479 <td><input type='checkbox' name='ENABLE_LOG' $checked {'ENABLE_LOG'}{'on'} /></td>
1482 <td class='base'> $Lang ::tr{'urlfilter empty ads'}:</td>
1483 <td><input type='checkbox' name='ENABLE_EMPTY_ADS' $checked {'ENABLE_EMPTY_ADS'}{'on'} /></td>
1484 <td class='base'> $Lang ::tr{'urlfilter username log'}:</td>
1485 <td><input type='checkbox' name='ENABLE_USERNAME_LOG' $checked {'ENABLE_USERNAME_LOG'}{'on'} /></td>
1488 <td class='base'> $Lang ::tr{'urlfilter block ip'}:</td>
1489 <td><input type='checkbox' name='BLOCK_IP_ADDR' $checked {'BLOCK_IP_ADDR'}{'on'} /></td>
1490 <td class='base'> $Lang ::tr{'urlfilter category log'}:</td>
1491 <td><input type='checkbox' name='ENABLE_CATEGORY_LOG' $checked {'ENABLE_CATEGORY_LOG'}{'on'} /></td>
1494 <td class='base'> $Lang ::tr{'urlfilter block all'}:</td>
1495 <td><input type='checkbox' name='BLOCK_ALL' $checked {'BLOCK_ALL'}{'on'} /></td>
1496 <td class='base'> $Lang ::tr{'urlfilter whitelist always allowed'}:</td>
1497 <td><input type='checkbox' name='ENABLE_GLOBAL_WHITELIST' $checked {'ENABLE_GLOBAL_WHITELIST'}{'on'} /></td>
1501 <table width='100%'>
1503 <td><img src='/blob.gif' align='top' alt='*' /> <font class='base'> $Lang ::tr{'required field'}</font></td>
1504 <td align='right'> </td>
1507 <table width='100%'>
1510 <td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' /></td>
1511 <td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter save and restart'}' /></td>
1518 & Header
:: closebox
();
1522 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
1524 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter maintenance'}" );
1527 <table width='100%'>
1529 <td class='base'><b> $Lang ::tr{'urlfilter blacklist update'}</b></td>
1532 <td> $Lang ::tr{'urlfilter upload information'}<p> $Lang ::tr{'urlfilter upload text'}:</td>
1535 <td><input type='file' name='UPDATEFILE' size='40' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter upload blacklist'}' /></td>
1541 <table width='100%'>
1543 <td colspan='2' class='base'><b> $Lang ::tr{'urlfilter automatic blacklist update'}</b>
1546 if (- e
" $updflagfile " )
1548 $blacklistage = int (- M
" $updflagfile " );
1549 print " <b>[</b> <small><i> $Lang ::tr{'urlfilter blacklist age 1'} <b> $blacklistage </b> $Lang ::tr{'urlfilter blacklist age 2'}</i></small> <b>]</b>" ;
1552 $updatesettings { 'UPDATE_SCHEDULE' } = 'monthly' ;
1553 $updatesettings { 'CUSTOM_UPDATE_URL' } = '' ;
1555 if (- e
" $updconffile " ) { & General
:: readhash
( " $updconffile " , \
%updatesettings ); }
1557 $checked { 'ENABLE_AUTOUPDATE' }{ 'off' } = '' ;
1558 $checked { 'ENABLE_AUTOUPDATE' }{ 'on' } = '' ;
1559 $checked { 'ENABLE_AUTOUPDATE' }{ $updatesettings { 'ENABLE_AUTOUPDATE' }} = "checked='checked'" ;
1561 $selected { 'UPDATE_SCHEDULE' }{ $updatesettings { 'UPDATE_SCHEDULE' }} = "selected='selected'" ;
1563 $selected { 'UPDATE_SOURCE' }{ $updatesettings { 'UPDATE_SOURCE' }} = "selected='selected'" ;
1569 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable automatic blacklist update'}:</td>
1570 <td width='75%' class='base'><input type='checkbox' name='ENABLE_AUTOUPDATE' $checked {'ENABLE_AUTOUPDATE'}{'on'} /></td>
1573 <td class='base'> $Lang ::tr{'urlfilter automatic update schedule'}:</td>
1575 <select name='UPDATE_SCHEDULE'>
1576 <option value='daily' $selected {'UPDATE_SCHEDULE'}{'daily'}> $Lang ::tr{'urlfilter daily'}</option>
1577 <option value='weekly' $selected {'UPDATE_SCHEDULE'}{'weekly'}> $Lang ::tr{'urlfilter weekly'}</option>
1578 <option value='monthly' $selected {'UPDATE_SCHEDULE'}{'monthly'}> $Lang ::tr{'urlfilter monthly'}</option>
1583 <td class='base'> $Lang ::tr{'urlfilter select source'}:</td>
1584 <td class='base' colspan='2'>
1585 <select name='UPDATE_SOURCE'>
1589 foreach ( @source_urllist ) {
1591 $source_name = substr ( $_ , 0 , rindex ( $_ , "," ));
1592 $source_url = substr ( $_ , index ( $_ , "," )+ 1 );
1593 print " \t <option value=' $source_url ' $selected {'UPDATE_SOURCE'}{ $source_url }> $source_name </option> \n " ;
1597 <option value='custom' $selected {'UPDATE_SOURCE'}{'custom'}> $Lang ::tr{'urlfilter custom url'}</option>
1602 <td> $Lang ::tr{'urlfilter custom url'}:</td>
1603 <td><input type='text' name='CUSTOM_UPDATE_URL' value=' $updatesettings {'CUSTOM_UPDATE_URL'}' size='72' /></td>
1606 <table width='100%'>
1608 <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>
1614 <table width='100%'>
1616 <td class='base'><b> $Lang ::tr{'urlfilter blacklist editor'}</b></td>
1619 <td> $Lang ::tr{'urlfilter blacklist editor info'}</td>
1622 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter blacklist editor'}' /></td>
1628 <table width='100%'>
1630 <td colspan='4' class='base'><b> $Lang ::tr{'urlfilter backup settings'}</b></td>
1633 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable full backup'}:</td>
1634 <td width='12%' class='base'><input type='checkbox' name='ENABLE_FULLBACKUP' $checked {'ENABLE_FULLBACKUP'}{'on'} /></td>
1639 <td colspan='4' class='base'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter backup'}' /></td>
1645 <table width='100%'>
1647 <td class='base'><b> $Lang ::tr{'urlfilter restore settings'}</b></td>
1650 <td> $Lang ::tr{'urlfilter restore text'}:</td>
1653 <td><input type='file' name='UPDATEFILE' size='40' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter restore'}' /></td>
1660 & Header
:: closebox
();
1664 #==========================================================
1666 # Section: Manage Repository
1668 #==========================================================
1670 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
1672 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter manage local file repository'}:" );
1674 <table width='100%'>
1676 <td> $Lang ::tr{'urlfilter repository information'}<br><br></td>
1679 <td> $Lang ::tr{'urlfilter upload file text'}:</td>
1682 <td><input type='file' name='UPLOADFILE' size='50' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter upload file'}' /></td>
1685 <td><br><b> $Lang ::tr{'urlfilter upload file information 1'}:</b> $Lang ::tr{'urlfilter upload file information 2'}</td>
1689 <table width='100%'>
1691 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
1698 & Header
:: closebox
();
1700 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter current files'}: </b>[ $repository ]" );
1702 @repositorylist = < $repository /*>;
1704 undef @repositoryfiles ;
1705 foreach ( @repositorylist )
1707 if (!- d
) { push ( @repositoryfiles , substr ( $_ , rindex ( $_ , "/" )+ 1 )); }
1710 if ( @repositoryfiles )
1713 <table width='100%'>
1715 <td align='center'><b> $Lang ::tr{'urlfilter filename'}</b></td>
1716 <td width='15%' align='center'><b> $Lang ::tr{'urlfilter filesize'}</b></td>
1717 <td width='10%'></td>
1722 foreach $line ( @repositoryfiles )
1726 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
1728 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
1729 $filesize = (- s
" $repository / $line " );
1730 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/ ;
1733 <td> $line </td>
1734 <td align='right'> $filesize </td>
1737 <form method='post' name='frma $id ' action=' $ENV {'SCRIPT_NAME'}'>
1738 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' title=' $Lang ::tr{'remove'}' alt=' $Lang ::tr{'remove'}' />
1739 <input type='hidden' name='ID' value=' $line ' />
1740 <input type='hidden' name='ACTION' value=' $Lang ::tr{'urlfilter remove file'}' />
1757 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
1758 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
1759 <td class='base'> $Lang ::tr{'remove'}</td>
1766 print "<i> $Lang ::tr{'urlfilter empty repository'}</i> \n " ;
1769 & Header
:: closebox
();
1773 } elsif ( $tcsettings { 'TCMODE' }) {
1775 #==========================================================
1777 # Section: Set Time Constraints
1779 #==========================================================
1781 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}'> \n " ;
1783 $buttontext = $Lang :: tr
{ 'urlfilter add rule' };
1784 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
1785 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter edit time constraint rule' }. ':' );
1786 $buttontext = $Lang :: tr
{ 'urlfilter update rule' };
1788 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter add new time constraint rule' }. ':' );
1792 <table width='100%'>
1794 <td width='2%'> $Lang ::tr{'urlfilter constraint definition'}</td>
1795 <td width='1%'> </td>
1796 <td width='2%' align='center'> $Lang ::tr{'urlfilter monday'}</td>
1797 <td width='2%' align='center'> $Lang ::tr{'urlfilter tuesday'}</td>
1798 <td width='2%' align='center'> $Lang ::tr{'urlfilter wednesday'}</td>
1799 <td width='2%' align='center'> $Lang ::tr{'urlfilter thursday'}</td>
1800 <td width='2%' align='center'> $Lang ::tr{'urlfilter friday'}</td>
1801 <td width='2%' align='center'> $Lang ::tr{'urlfilter saturday'}</td>
1802 <td width='2%' align='center'> $Lang ::tr{'urlfilter sunday'}</td>
1803 <td width='1%'> </td>
1804 <td width='7%' colspan=3> $Lang ::tr{'urlfilter from'}</td>
1805 <td width='1%'> </td>
1806 <td width='7%' colspan=3> $Lang ::tr{'urlfilter to'}</td>
1811 <select name='DEFINITION'>
1812 <option value='within' $selected {'DEFINITION'}{'within'}> $Lang ::tr{'urlfilter constraint within'}</option>
1813 <option value='outside' $selected {'DEFINITION'}{'outside'}> $Lang ::tr{'urlfilter constraint outside'}</option>
1817 <td class='base'><input type='checkbox' name='MON' $checked {'MON'}{'on'} /></td>
1818 <td class='base'><input type='checkbox' name='TUE' $checked {'TUE'}{'on'} /></td>
1819 <td class='base'><input type='checkbox' name='WED' $checked {'WED'}{'on'} /></td>
1820 <td class='base'><input type='checkbox' name='THU' $checked {'THU'}{'on'} /></td>
1821 <td class='base'><input type='checkbox' name='FRI' $checked {'FRI'}{'on'} /></td>
1822 <td class='base'><input type='checkbox' name='SAT' $checked {'SAT'}{'on'} /></td>
1823 <td class='base'><input type='checkbox' name='SUN' $checked {'SUN'}{'on'} /></td>
1826 <select name='FROM_HOUR'>
1829 for ( $i = 0 ; $i <= 24 ; $i ++) {
1830 $_ = sprintf ( " %02s " , $i );
1831 print "<option $selected {'FROM_HOUR'}{ $_ }> $_ </option> \n " ;
1838 <select name='FROM_MINUTE'>
1841 for ( $i = 0 ; $i <= 45 ; $i += 15 ) {
1842 $_ = sprintf ( " %02s " , $i );
1843 print "<option $selected {'FROM_MINUTE'}{ $_ }> $_ </option> \n " ;
1850 <select name='TO_HOUR'>
1853 for ( $i = 0 ; $i <= 24 ; $i ++) {
1854 $_ = sprintf ( " %02s " , $i );
1855 print "<option $selected {'TO_HOUR'}{ $_ }> $_ </option> \n " ;
1862 <select name='TO_MINUTE'>
1865 for ( $i = 0 ; $i <= 45 ; $i += 15 ) {
1866 $_ = sprintf ( " %02s " , $i );
1867 print "<option $selected {'TO_MINUTE'}{ $_ }> $_ </option> \n " ;
1878 <table width='100%'>
1880 <td width='5%'> $Lang ::tr{'urlfilter source'} <img src='/blob.gif' alt='*' /></td>
1881 <td width='1%'> </td>
1882 <td width='5%'> $Lang ::tr{'urlfilter dst'} <img src='/blob.gif' alt='*' /></td>
1883 <td width='1%'> </td>
1884 <td width='5%'> $Lang ::tr{'urlfilter access'}</td>
1888 <td rowspan='2'><textarea name='SRC' cols='28' rows='5' wrap='off'>
1892 # transform from pre1.8 client definitions
1893 $tcsettings { 'SRC' } =~ s/^\s+//g ;
1894 $tcsettings { 'SRC' } =~ s/\s+$//g ;
1895 $tcsettings { 'SRC' } =~ s/\s+-\s+/-/g ;
1896 $tcsettings { 'SRC' } =~ s/\s+/ /g ;
1898 @clients = split ( / / , $tcsettings { 'SRC' });
1899 undef $tcsettings { 'SRC' };
1900 foreach ( @clients ) { $tcsettings { 'SRC' } .= " $_ \n " ; }
1902 print $tcsettings { 'SRC' };
1908 <td class='base' rowspan='2' valign='top'>
1909 <select name='DST' size='6' multiple>
1910 <option value='any' $selected {'DST'}{'any'} = "selected='selected'"> $Lang ::tr{'urlfilter category all'}</option>
1911 <option value='in-addr' $selected {'DST'}{'in-addr'} = "selected='selected'">in-addr</option>
1915 & readblockcategories
;
1916 foreach ( @categories )
1918 print "<option value=' $_ ' $selected {'DST'}{ $_ }> $_ </option> \n " ;
1922 <option value='files' $selected {'DST'}{'files'} = "selected='selected'">files</option>
1923 <option value='custom-blocked' $selected {'DST'}{'custom-blocked'} = "selected='selected'">custom-blocked</option>
1924 <option value='custom-expressions' $selected {'DST'}{'custom-expressions'} = "selected='selected'">custom-expressions</option>
1928 <td class='base' valign='top'>
1929 <select name='ACCESS'>
1930 <option value='block' $selected {'ACCESS'}{'block'}> $Lang ::tr{'urlfilter mode block'}</option>
1931 <option value='allow' $selected {'ACCESS'}{'allow'}> $Lang ::tr{'urlfilter mode allow'}</option>
1943 <td> $Lang ::tr{'remark'}</td>
1951 <td><input type='text' name='COMMENT' value=' $tcsettings {'COMMENT'}' size='32' /></td>
1960 <table width='100%'>
1962 <td class='base'> $Lang ::tr{'urlfilter enabled'}<input type='checkbox' name='ENABLERULE' $checked{'ENABLERULE'}{'on'} /></td>
1970 <td><input type='hidden' name='ACTION' value=' $Lang ::tr{'add'}' /></td>
1971 <td><input type='hidden' name='MODE' value='TIMECONSTRAINT' /></td>
1972 <td><input type='submit' name='SUBMIT' value=' $buttontext ' /></td>
1973 <td><input type='reset' name='ACTION' value=' $Lang ::tr{'urlfilter reset'}' /></td>
1975 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
1979 <table width='100%'>
1981 <td width='1%' align='right'> <img src='/blob.gif' align='top' alt='*' /> </td>
1982 <td><font class='base'> $Lang ::tr{'required field'}</font></td>
1985 <td width='1%' align='right'> </td>
1986 <td><font class='base'> $Lang ::tr{'urlfilter select multi'}</font></td>
1992 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
1993 print "<input type='hidden' name='EDITING' value=' $tcsettings {'ID'}' /> \n " ;
1995 print "<input type='hidden' name='EDITING' value='no' /> \n " ;
1998 & Header
:: closebox
();
2001 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'current rules' });
2003 <table width='100%'>
2005 <td width='5%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter constraint definition'}</b></td>
2006 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter time space'}</b></td>
2007 <td width='15%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter src'}</b></td>
2008 <td width='5%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter dst'}</b></td>
2009 <td width='10%' class='boldbase' colspan='5' align='center'> </td>
2014 if ( $tcsettings { 'ACTION' } ne '' or $changed ne 'no' )
2016 open ( FILE
, $tcfile );
2022 foreach $line ( @tclist )
2026 @temp = split ( /\,/ , $line );
2027 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' } && $tcsettings { 'ID' } eq $id ) {
2028 print "<tr bgcolor=' $Header ::colouryellow'> \n " ; }
2030 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
2032 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
2033 if ( $temp [ 0 ] eq 'within' ) { $temp [ 0 ]= $Lang :: tr
{ 'urlfilter constraint within' }; } else { $temp [ 0 ]= $Lang :: tr
{ 'urlfilter constraint outside' }; }
2034 if ( $temp [ 13 ] eq 'any' ) { $temp [ 13 ]= $Lang :: tr
{ 'urlfilter category all' }; }
2035 if ( $temp [ 15 ] eq 'on' ) { $gif = 'on.gif' ; $toggle = 'off' ; $gdesc = $Lang :: tr
{ 'click to disable' };}
2036 else { $gif = 'off.gif' ; $toggle = 'on' ; $gdesc = $Lang :: tr
{ 'click to enable' }; }
2037 if ( $temp [ 14 ] eq 'block' ) { $led = 'led-red.gif' ; $ldesc = $Lang :: tr
{ 'urlfilter block access' };}
2038 else { $led = 'led-green.gif' ; $ldesc = $Lang :: tr
{ 'urlfilter allow access' }; }
2041 if ( $temp [ 1 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter mon' }; } else { $time .= '=' ; }
2042 if ( $temp [ 2 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter tue' }; } else { $time .= '=' ; }
2043 if ( $temp [ 3 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter wed' }; } else { $time .= '=' ; }
2044 if ( $temp [ 4 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter thu' }; } else { $time .= '=' ; }
2045 if ( $temp [ 5 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter fri' }; } else { $time .= '=' ; }
2046 if ( $temp [ 6 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter sat' }; } else { $time .= '=' ; }
2047 if ( $temp [ 7 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter sun' }; } else { $time .= '=' ; }
2048 $time = $time . ' ' . $temp [ 8 ]. ':' . $temp [ 9 ]. ' to ' . $temp [ 10 ]. ':' . $temp [ 11 ];
2051 <td align='center'> $temp [0]</td>
2052 <td align='center' nowrap> $time </td>
2053 <td align='center'> $temp [12]</td>
2054 <td align='center'> $temp [13]</td>
2055 <td align='center'><image src='/images/urlfilter/ $led ' alt=' $ldesc '></td>
2058 <form method='post' name='frma $id ' action=' $ENV {'SCRIPT_NAME'}'>
2059 <input type='image' name=' $Lang ::tr{'toggle enable disable'}' src='/images/ $gif ' title=' $gdesc ' alt=' $gdesc ' />
2060 <input type='hidden' name='MODE' value='TIMECONSTRAINT' />
2061 <input type='hidden' name='ID' value=' $id ' />
2062 <input type='hidden' name='ACTIVE' value=' $toggle ' />
2063 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
2068 <form method='post' name='frmb $id ' action=' $ENV {'SCRIPT_NAME'}'>
2069 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/edit.gif' title=' $Lang ::tr{'edit'}' alt=' $Lang ::tr{'edit'}' />
2070 <input type='hidden' name='MODE' value='TIMECONSTRAINT' />
2071 <input type='hidden' name='ID' value=' $id ' />
2072 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
2077 <form method='post' name='frmc $id ' action=' $ENV {'SCRIPT_NAME'}'>
2078 <input type='image' name=' $Lang ::tr{'urlfilter copy rule'}' src='/images/urlfilter/copy.gif' title=' $Lang ::tr{'urlfilter copy rule'}' alt=' $Lang ::tr{'urlfilter copy rule'}' />
2079 <input type='hidden' name='MODE' value='TIMECONSTRAINT' />
2080 <input type='hidden' name='ID' value=' $id ' />
2081 <input type='hidden' name='ACTION' value=' $Lang ::tr{'urlfilter copy rule'}' />
2086 <form method='post' name='frmd $id ' action=' $ENV {'SCRIPT_NAME'}'>
2087 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' title=' $Lang ::tr{'remove'}' alt=' $Lang ::tr{'remove'}' />
2088 <input type='hidden' name='MODE' value='TIMECONSTRAINT' />
2089 <input type='hidden' name='ID' value=' $id ' />
2090 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove'}' />
2097 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' } && $tcsettings { 'ID' } eq $id ) {
2098 print "<tr bgcolor=' $Header ::colouryellow'> \n " ; }
2100 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
2102 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
2104 <td align='center' colspan='4'> $temp [16]
2106 <td align='center' colspan='5'>
2115 # If the time constraint file contains entries, print entries and action icons
2116 if (! - z
" $tcfile " ) {
2121 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
2122 <td> <img src='/images/urlfilter/led-green.gif' alt=' $Lang ::tr{'urlfilter allow access'}' /></td>
2123 <td class='base'> $Lang ::tr{'urlfilter allow'}</td>
2124 <td> <img src='/images/urlfilter/led-red.gif' alt=' $Lang ::tr{'urlfilter block access'}' /></td>
2125 <td class='base'> $Lang ::tr{'urlfilter block'}</td>
2126 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
2127 <td class='base'> $Lang ::tr{'click to disable'}</td>
2128 <td> <img src='/images/off.gif' alt=' $Lang ::tr{'click to enable'}' /></td>
2129 <td class='base'> $Lang ::tr{'click to enable'}</td>
2130 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
2131 <td class='base'> $Lang ::tr{'edit'}</td>
2132 <td> <img src='/images/urlfilter/copy.gif' alt=' $Lang ::tr{'urlfilter copy rule'}' /></td>
2133 <td class='base'> $Lang ::tr{'urlfilter copy rule'}</td>
2134 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
2135 <td class='base'> $Lang ::tr{'remove'}</td>
2142 & Header
:: closebox
();
2144 } elsif ( $uqsettings { 'UQMODE' }) {
2146 #==========================================================
2148 # Section: Set User Quota
2150 #==========================================================
2152 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}'> \n " ;
2154 $buttontext = $Lang :: tr
{ 'urlfilter add rule' };
2155 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
2156 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter edit user quota rule' }. ':' );
2157 $buttontext = $Lang :: tr
{ 'urlfilter update rule' };
2159 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter add new user quota rule' }. ':' );
2163 <table width='100%'>
2165 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
2168 <td class='base'> $Lang ::tr{'urlfilter user time quota'}: <img src='/blob.gif' alt='*' /></td>
2169 <td><input type='text' name='TIME_QUOTA' value=' $uqsettings {'TIME_QUOTA'}' size='5' /></td>
2170 <td colspan='2' rowspan= '5' valign='top' class='base'>
2171 <table cellpadding='0' cellspacing='0'>
2173 <!-- intentionally left empty -->
2176 <td> $Lang ::tr{'urlfilter assigned quota users'}: <img src='/blob.gif' alt='*' /></td>
2179 <!-- intentionally left empty -->
2182 <!-- intentionally left empty -->
2185 <td><textarea name='QUOTA_USERS' cols='32' rows='6' wrap='off'>
2189 $uqsettings { 'QUOTA_USERS' } =~ s/\|/\n/g ;
2190 print $uqsettings { 'QUOTA_USERS' };
2199 <td class='base'> $Lang ::tr{'urlfilter activity detection'}:</td>
2200 <td class='base'><select name='SPORADIC'>
2201 <option value='0' $selected {'SPORADIC'}{'0'}> $Lang ::tr{'urlfilter disabled'}</option>
2202 <option value='300' $selected {'SPORADIC'}{'300'}>5 $Lang ::tr{'urlfilter minutes'}</option>
2203 <option value='900' $selected {'SPORADIC'}{'900'}>15 $Lang ::tr{'urlfilter minutes'}</option>
2207 <td class='base'> $Lang ::tr{'urlfilter renewal period'}:</td>
2208 <td class='base'><select name='RENEWAL'>
2209 <option value='hourly' $selected {'RENEWAL'}{'hourly'}> $Lang ::tr{'urlfilter hourly'}</option>
2210 <option value='daily' $selected {'RENEWAL'}{'daily'}> $Lang ::tr{'urlfilter daily'}</option>
2211 <option value='weekly' $selected {'RENEWAL'}{'weekly'}> $Lang ::tr{'urlfilter weekly'}</option>
2215 <td colspan='2'> </td>
2218 <td class='base'> $Lang ::tr{'urlfilter enabled'}</td>
2219 <td class='base'><input type='checkbox' name='ENABLEQUOTA' $checked {'ENABLEQUOTA'}{'on'} /></td>
2227 <td><input type='hidden' name='ACTION' value=' $Lang ::tr{'add'}' /></td>
2228 <td><input type='hidden' name='MODE' value='USERQUOTA' /></td>
2229 <td><input type='submit' name='SUBMIT' value=' $buttontext ' /></td>
2230 <td><input type='reset' name='ACTION' value=' $Lang ::tr{'urlfilter reset'}' /></td>
2232 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
2240 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
2241 print "<input type='hidden' name='EDITING' value=' $uqsettings {'ID'}' /> \n " ;
2243 print "<input type='hidden' name='EDITING' value='no' /> \n " ;
2246 & Header
:: closebox
();
2249 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'current rules' });
2251 <table width='100%'>
2253 <td width='15%' class='boldbase' align='center'><b><nobr> $Lang ::tr{'urlfilter time quota'}</nobr></b></td>
2254 <td width='15%' class='boldbase' align='center'><b><nobr> $Lang ::tr{'urlfilter activity detection'}</nobr></b></td>
2255 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter renewal'}</b></td>
2256 <td class='boldbase' align='center'><b> $Lang ::tr{'urlfilter assigned users'}</b></td>
2257 <td width='20%' class='boldbase' colspan='4' align='center'> </td>
2262 if ( $uqsettings { 'ACTION' } ne '' or $changed ne 'no' )
2264 open ( FILE
, $uqfile );
2270 foreach $line ( @uqlist )
2274 @temp = split ( /\,/ , $line );
2275 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' } && $uqsettings { 'ID' } eq $id ) {
2276 print "<tr bgcolor=' $Header ::colouryellow'> \n " ; }
2278 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
2280 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
2281 if ( $temp [ 4 ] eq 'on' ) { $gif = 'on.gif' ; $toggle = 'off' ; $gdesc = $Lang :: tr
{ 'click to disable' };}
2282 else { $gif = 'off.gif' ; $toggle = 'on' ; $gdesc = $Lang :: tr
{ 'click to enable' }; }
2284 $temp [ 5 ] = $temp [ 1 ];
2285 if ( $temp [ 1 ] eq '0' ) { $temp [ 5 ] = $Lang :: tr
{ 'urlfilter disabled' } } else { $temp [ 5 ] = ( $temp [ 5 ]/ 60 ). ' ' . $Lang :: tr
{ 'urlfilter minutes' } }
2286 $_ = $temp [ 3 ]; s/\|/, /g ; $temp [ 6 ] = $_ ;
2289 <td align='center'> $temp [0] $Lang ::tr{'urlfilter minutes'}</td>
2290 <td align='center'> $temp [5]</td>
2291 <td align='center'> $Lang ::tr{'urlfilter '. $temp [2]}</td>
2292 <td align='center'> $temp [6]</td>
2295 <form method='post' name='frma $id ' action=' $ENV {'SCRIPT_NAME'}'>
2296 <input type='image' name=' $Lang ::tr{'toggle enable disable'}' src='/images/ $gif ' title=' $gdesc ' alt=' $gdesc ' />
2297 <input type='hidden' name='MODE' value='USERQUOTA' />
2298 <input type='hidden' name='ID' value=' $id ' />
2299 <input type='hidden' name='ACTIVE' value=' $toggle ' />
2300 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
2305 <form method='post' name='frmb $id ' action=' $ENV {'SCRIPT_NAME'}'>
2306 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/edit.gif' title=' $Lang ::tr{'edit'}' alt=' $Lang ::tr{'edit'}' />
2307 <input type='hidden' name='MODE' value='USERQUOTA' />
2308 <input type='hidden' name='ID' value=' $id ' />
2309 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
2314 <form method='post' name='frmc $id ' action=' $ENV {'SCRIPT_NAME'}'>
2315 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' title=' $Lang ::tr{'remove'}' alt=' $Lang ::tr{'remove'}' />
2316 <input type='hidden' name='MODE' value='USERQUOTA' />
2317 <input type='hidden' name='ID' value=' $id ' />
2318 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove'}' />
2329 # If the user quota file contains entries, print entries and action icons
2330 if (! - z
" $uqfile " ) {
2335 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
2336 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
2337 <td class='base'> $Lang ::tr{'click to disable'}</td>
2338 <td> <img src='/images/off.gif' alt=' $Lang ::tr{'click to enable'}' /></td>
2339 <td class='base'> $Lang ::tr{'click to enable'}</td>
2340 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
2341 <td class='base'> $Lang ::tr{'edit'}</td>
2342 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
2343 <td class='base'> $Lang ::tr{'remove'}</td>
2350 & Header
:: closebox
();
2354 #==========================================================
2356 # Section: Blacklist editor
2358 #==========================================================
2360 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
2362 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter urlfilter blacklist editor' }. ':' );
2366 <table width='100%'>
2368 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
2371 <td class='base'><b> $Lang ::tr{'urlfilter blacklist name'}</b></td>
2374 <td class='base'> $Lang ::tr{'urlfilter blacklist category name'}: <img src='/blob.gif' alt='*' /></td>
2375 <td><input type='text' name='BE_NAME' value=' $besettings {'BE_NAME'}' size='12' /></td>
2379 <table width='100%'>
2381 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='20%'></td>
2384 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter edit domains urls expressions'}</b> <img src='/blob.gif' alt='*' /></td>
2387 <td colspan='2'> $Lang ::tr{'urlfilter domains'}</td>
2388 <td colspan='2'> $Lang ::tr{'urlfilter urls'}</td>
2391 <td colspan='2'><textarea name='BE_DOMAINS' cols='38' rows='10' wrap='off'>
2395 print $besettings { 'BE_DOMAINS' };
2399 <td colspan='2'><textarea name='BE_URLS' cols='38' rows='10' wrap='off'>
2403 print $besettings { 'BE_URLS' };
2409 <td colspan='4'> $Lang ::tr{'urlfilter expressions'}</td>
2412 <td colspan='4'><textarea name='BE_EXPRESSIONS' cols='80' rows='3' wrap='off'>
2416 print $besettings { 'BE_EXPRESSIONS' };
2423 <table width='100%'>
2425 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter load blacklist'}</b></td>
2428 <td width='25%' class='base'> $Lang ::tr{'urlfilter select blacklist'}:</td>
2429 <td width='20%' class='base'>
2430 <select name='BE_BLACKLIST'>
2434 & readblockcategories
;
2435 foreach ( @categories )
2437 print "<option value=' $_ ' $selected {'BE_BLACKLIST'}{ $_ }> $_ </option> \n " ;
2446 <td colpsan='4'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter load blacklist'}' /></td>
2451 <table width='100%'>
2453 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter import blacklist'}</b></td>
2456 <td colspan='4'> $Lang ::tr{'urlfilter import text'}:</td>
2459 <td nowrap><input type='file' name='IMPORTFILE' size='40' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter import blacklist'}' /></td>
2460 <td><input type='hidden' name='MODE' value='BLACKLIST_EDITOR' /></td>
2464 <table width='100%'>
2466 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter export blacklist'}</b></td>
2469 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter export blacklist'}' /></td>
2473 <table width='100%'>
2475 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter install blacklist'}</b></td>
2478 <td width='25%' class='base'> $Lang ::tr{'urlfilter dont restart urlfilter'}:</td>
2479 <td width='20%' class='base'><input type='checkbox' name='NORESTART' $checked {'NORESTART'}{'on'} /></td>
2484 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter install blacklist'}' /></td>
2487 <td class='base' colspan='4'><br> $Lang ::tr{'urlfilter install information'}</td>
2493 <td><input type='reset' name='ACTION' value=' $Lang ::tr{'urlfilter reset'}' /></td>
2495 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
2502 & Header
:: closebox
();
2507 & Header
:: closebigbox
();
2509 & Header
:: closepage
();
2511 # -------------------------------------------------------------------
2515 # transform to pre1.8 client definitions
2516 @clients = split ( /\n/ , $filtersettings { 'UNFILTERED_CLIENTS' });
2517 undef $filtersettings { 'UNFILTERED_CLIENTS' };
2520 s/^\s+//g ; s/\s+$//g ; s/\s+-\s+/-/g ; s/\s+/ /g ; s/\n//g ;
2521 $filtersettings { 'UNFILTERED_CLIENTS' } .= " $_ " ;
2523 $filtersettings { 'UNFILTERED_CLIENTS' } =~ s/\s+$// ;
2525 # transform to pre1.8 client definitions
2526 @clients = split ( /\n/ , $filtersettings { 'BANNED_CLIENTS' });
2527 undef $filtersettings { 'BANNED_CLIENTS' };
2530 s/^\s+//g ; s/\s+$//g ; s/\s+-\s+/-/g ; s/\s+/ /g ; s/\n//g ;
2531 $filtersettings { 'BANNED_CLIENTS' } .= " $_ " ;
2533 $filtersettings { 'BANNED_CLIENTS' } =~ s/\s+$// ;
2537 delete $filtersettings { 'CUSTOM_BLACK_DOMAINS' };
2538 delete $filtersettings { 'CUSTOM_BLACK_URLS' };
2539 delete $filtersettings { 'CUSTOM_WHITE_DOMAINS' };
2540 delete $filtersettings { 'CUSTOM_WHITE_URLS' };
2541 delete $filtersettings { 'CUSTOM_EXPRESSIONS' };
2542 delete $filtersettings { 'BACKGROUND' };
2543 delete $filtersettings { 'UPDATEFILE' };
2545 & General
:: system ( "chown" , "-R" , "nobody.nobody" , " $dbdir " );
2546 & General
:: system ( '/usr/bin/squidGuard' , '-C' , 'custom/allowed/domains' );
2547 & General
:: system ( '/usr/bin/squidGuard' , '-C' , 'custom/allowed/urls' );
2548 & General
:: system ( '/usr/bin/squidGuard' , '-C' , 'custom/blocked/domains' );
2549 & General
:: system ( '/usr/bin/squidGuard' , '-C' , 'custom/blocked/urls' );
2550 & setpermissions
( $dbdir );
2552 & General
:: writehash
( "${General::swroot}/urlfilter/settings" , \
%filtersettings );
2555 # -------------------------------------------------------------------
2557 sub readblockcategories
2561 & getblockcategory
( $dbdir );
2563 foreach ( @categories ) { $_ = substr ( $_ , length ( $dbdir )+ 1 ); }
2565 @filtergroups = @categories ;
2567 foreach ( @filtergroups ) {
2574 # -------------------------------------------------------------------
2576 sub getblockcategory
2578 foreach $category (< $_ [ 0 ]/*>)
2582 if ((- e
" $category /domains" ) || (- e
" $category /urls" ))
2584 unless ( $category =~ /\bcustom\b/ ) { push ( @categories , $category ); }
2586 & getblockcategory
( $category );
2591 # -------------------------------------------------------------------
2595 if (- e
" $dbdir /custom/blocked/domains" ) {
2596 open ( FILE
, " $dbdir /custom/blocked/domains" );
2597 delete $filtersettings { 'CUSTOM_BLACK_DOMAINS' };
2598 while (< FILE
>) { $filtersettings { 'CUSTOM_BLACK_DOMAINS' } .= $_ };
2602 if (- e
" $dbdir /custom/blocked/urls" ) {
2603 open ( FILE
, " $dbdir /custom/blocked/urls" );
2604 delete $filtersettings { 'CUSTOM_BLACK_URLS' };
2605 while (< FILE
>) { $filtersettings { 'CUSTOM_BLACK_URLS' } .= $_ };
2609 if (- e
" $dbdir /custom/blocked/expressions" ) {
2610 open ( FILE
, " $dbdir /custom/blocked/expressions" );
2611 delete $filtersettings { 'CUSTOM_EXPRESSIONS' };
2612 while (< FILE
>) { $filtersettings { 'CUSTOM_EXPRESSIONS' } .= $_ };
2616 if (- e
" $dbdir /custom/allowed/domains" ) {
2617 open ( FILE
, " $dbdir /custom/allowed/domains" );
2618 delete $filtersettings { 'CUSTOM_WHITE_DOMAINS' };
2619 while (< FILE
>) { $filtersettings { 'CUSTOM_WHITE_DOMAINS' } .= $_ };
2622 if (- e
" $dbdir /custom/allowed/urls" ) {
2623 open ( FILE
, " $dbdir /custom/allowed/urls" );
2624 delete $filtersettings { 'CUSTOM_WHITE_URLS' };
2625 while (< FILE
>) { $filtersettings { 'CUSTOM_WHITE_URLS' } .= $_ };
2630 # -------------------------------------------------------------------
2632 sub aggregatedconstraints
2652 @tmp1 = split ( /\,/ , $x );
2656 @tmp2 = split ( /\,/ );
2657 if (( $tmp1 [ 15 ] eq 'on' ) && ( $tmp2 [ 15 ] eq 'on' ))
2659 if (( $tmp1 [ 0 ] eq $tmp2 [ 0 ]) && ( $tmp1 [ 12 ] eq $tmp2 [ 12 ]) && ( $tmp1 [ 13 ] eq $tmp2 [ 13 ]) && ( $tmp1 [ 14 ] eq $tmp2 [ 14 ]))
2662 $tmp2 [ 16 ] .= " weekly " ;
2663 if ( $tmp1 [ 1 ] eq 'on' ) { $tmp2 [ 16 ] .= "m" ; }
2664 if ( $tmp1 [ 2 ] eq 'on' ) { $tmp2 [ 16 ] .= "t" ; }
2665 if ( $tmp1 [ 3 ] eq 'on' ) { $tmp2 [ 16 ] .= "w" ; }
2666 if ( $tmp1 [ 4 ] eq 'on' ) { $tmp2 [ 16 ] .= "h" ; }
2667 if ( $tmp1 [ 5 ] eq 'on' ) { $tmp2 [ 16 ] .= "f" ; }
2668 if ( $tmp1 [ 6 ] eq 'on' ) { $tmp2 [ 16 ] .= "a" ; }
2669 if ( $tmp1 [ 7 ] eq 'on' ) { $tmp2 [ 16 ] .= "s" ; }
2670 $tmp2 [ 16 ] .= " $tmp1 [8]: $tmp1 [9]- $tmp1 [10]: $tmp1 [11] \n " ;
2671 $_ = join ( "," , @tmp2 );
2678 $tmp1 [ 16 ] .= " weekly " ;
2679 if ( $tmp1 [ 1 ] eq 'on' ) { $tmp1 [ 16 ] .= "m" ; }
2680 if ( $tmp1 [ 2 ] eq 'on' ) { $tmp1 [ 16 ] .= "t" ; }
2681 if ( $tmp1 [ 3 ] eq 'on' ) { $tmp1 [ 16 ] .= "w" ; }
2682 if ( $tmp1 [ 4 ] eq 'on' ) { $tmp1 [ 16 ] .= "h" ; }
2683 if ( $tmp1 [ 5 ] eq 'on' ) { $tmp1 [ 16 ] .= "f" ; }
2684 if ( $tmp1 [ 6 ] eq 'on' ) { $tmp1 [ 16 ] .= "a" ; }
2685 if ( $tmp1 [ 7 ] eq 'on' ) { $tmp1 [ 16 ] .= "s" ; }
2686 $tmp1 [ 16 ] .= " $tmp1 [8]: $tmp1 [9]- $tmp1 [10]: $tmp1 [11] \n " ;
2687 $x = join ( "," , @tmp1 );
2697 # -------------------------------------------------------------------
2703 foreach $category (< $bldir /*>)
2706 & General
:: system ( "chmod" , "755" , " $category " );
2707 foreach $blacklist (< $category /*>)
2709 if (- f
$blacklist ) { & General
:: system ( "chmod" , "644" , " $blacklist " ); }
2710 if (- d
$blacklist ) { & General
:: system ( "chmod" , "755" , " $blacklist " ); }
2713 system ( "chmod 666 $category /*.db &> /dev/null" );
2714 & setpermissions
( $category );
2719 # -------------------------------------------------------------------
2723 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\)\$" ;
2724 my $audiovideo = "/[^/]* \\ .\(aiff|asf|avi|dif|divx|flv|mkv|mov|movie|mp3|mp4|mpe?g?|mpv2|ogg|ra?m|snd|qt|wav|wma|wmf|wmv\)\$" ;
2725 my $archives = "/[^/]* \\ .\(7z|bin|bz2|cab|cdr|dmg|gz|hqx|rar|smi|sit|sea|tar|tgz|zip\)\$" ;
2727 my $ident = " anonymous" ;
2740 if (!(- d
" $dbdir /custom" )) { mkdir ( " $dbdir /custom" ) }
2741 if (!(- d
" $dbdir /custom/blocked" )) { mkdir ( " $dbdir /custom/blocked" ) }
2742 if (!(- d
" $dbdir /custom/allowed" )) { mkdir ( " $dbdir /custom/allowed" ) }
2744 open ( FILE
, ">/ $dbdir /custom/blocked/domains" );
2745 print FILE
$filtersettings { 'CUSTOM_BLACK_DOMAINS' };
2747 open ( FILE
, ">/ $dbdir /custom/blocked/urls" );
2748 print FILE
$filtersettings { 'CUSTOM_BLACK_URLS' };
2750 open ( FILE
, ">/ $dbdir /custom/blocked/expressions" );
2751 print FILE
$filtersettings { 'CUSTOM_EXPRESSIONS' };
2753 open ( FILE
, ">/ $dbdir /custom/blocked/files" );
2754 if ( $filtersettings { 'BLOCK_EXECUTABLES' } eq 'on' ) { print FILE
" $executables \n " ; }
2755 if ( $filtersettings { 'BLOCK_AUDIO-VIDEO' } eq 'on' ) { print FILE
" $audiovideo \n " ; }
2756 if ( $filtersettings { 'BLOCK_ARCHIVES' } eq 'on' ) { print FILE
" $archives \n " ; }
2758 open ( FILE
, ">/ $dbdir /custom/allowed/domains" );
2759 print FILE
$filtersettings { 'CUSTOM_WHITE_DOMAINS' };
2761 open ( FILE
, ">/ $dbdir /custom/allowed/urls" );
2762 print FILE
$filtersettings { 'CUSTOM_WHITE_URLS' };
2765 if ( $filtersettings { 'ENABLE_USERNAME_LOG' } eq 'on' ) { $ident = "" ; }
2767 if ( $filtersettings { 'REDIRECT_PAGE' } eq '' )
2769 if (( $filtersettings { 'SHOW_CATEGORY' } eq 'on' ) || ( $filtersettings { 'SHOW_URL' } eq 'on' ) || ( $filtersettings { 'SHOW_IP' } eq 'on' )) {
2770 if ( $filtersettings { 'SHOW_CATEGORY' } eq 'on' ) { $redirect .= "&category= %t " ; }
2771 if ( $filtersettings { 'SHOW_URL' } eq 'on' ) { $redirect .= "&url= %u " ; }
2772 if ( $filtersettings { 'SHOW_IP' } eq 'on' ) { $redirect .= "&ip= %a " ; }
2773 $redirect =~ s/^&/?/ ;
2774 $redirect = "http:\/\/ $netsettings {'GREEN_ADDRESS'}: $http_port \/redirect.cgi" . $redirect ;
2776 $redirect = "http:\/\/ $netsettings {'GREEN_ADDRESS'}: $http_port \/redirect.cgi" ;
2778 } else { $redirect = $filtersettings { 'REDIRECT_PAGE' }; }
2780 if ( $filtersettings { 'ENABLE_DNSERROR' } eq 'on' ) { $redirect = "302:http://0.0.0.0" ; }
2784 if ( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' )
2786 $defaultrule .= "custom-allowed " ;
2788 if ( $filtersettings { 'BLOCK_ALL' } eq 'on' )
2790 $defaultrule .= "none" ;
2794 if ( $filtersettings { 'BLOCK_IP_ADDR' } eq 'on' )
2796 $defaultrule .= "!in-addr " ;
2798 for ( $i = 0 ; $i <= @filtergroups ; $i ++) {
2799 if ( $filtersettings { @filtergroups [ $i ]} eq 'on' )
2801 $defaultrule .= "! @categories [ $i ] " ;
2804 if ( $filtersettings { 'ENABLE_CUSTOM_BLACKLIST' } eq 'on' )
2806 $defaultrule .= "!custom-blocked " ;
2808 if ( $filtersettings { 'ENABLE_CUSTOM_EXPRESSIONS' } eq 'on' )
2810 $defaultrule .= "!custom-expressions " ;
2812 if (( $filtersettings { 'BLOCK_EXECUTABLES' } eq 'on' ) ||
2813 ( $filtersettings { 'BLOCK_AUDIO-VIDEO' } eq 'on' ) ||
2814 ( $filtersettings { 'BLOCK_ARCHIVES' } eq 'on' ))
2816 $defaultrule .= "!files " ;
2818 $defaultrule .= "any" ;
2821 $defaultrule =~ s/\// _
/ g
;
2823 open ( FILE
, ">${General::swroot}/urlfilter/squidGuard.conf" ) or die "Unable to write squidGuard.conf file" ;
2826 print FILE
"logdir /var/log/squidGuard \n " ;
2827 print FILE
"dbhome $dbdir \n\n " ;
2829 undef @repositoryfiles ;
2830 if ( $filtersettings { 'ENABLE_REWRITE' } eq 'on' )
2832 @repositorylist = < $repository /*>;
2833 foreach ( @repositorylist )
2835 if (!- d
) { push ( @repositoryfiles , substr ( $_ , rindex ( $_ , "/" )+ 1 )); }
2839 if (( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles )) {
2840 print FILE
"rewrite rew-rule-1 { \n " ;
2842 print FILE
" # rewrite localfiles \n " ;
2843 foreach ( @repositoryfiles )
2845 print FILE
" s@.*/ $_ \$\ @http :// $netsettings {'GREEN_ADDRESS'}: $http_port /repository/ $_ \ @i \n " ;
2850 if (!( $filtersettings { 'UNFILTERED_CLIENTS' } eq '' )) {
2851 print FILE
"src unfiltered { \n " ;
2852 print FILE
" ip $filtersettings {'UNFILTERED_CLIENTS'} \n " ;
2855 if (!( $filtersettings { 'BANNED_CLIENTS' } eq '' )) {
2856 print FILE
"src banned { \n " ;
2857 print FILE
" ip $filtersettings {'BANNED_CLIENTS'} \n " ;
2858 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
2860 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
2862 print FILE
" logfile " . $ident . " banned.log \n " ;
2864 print FILE
" logfile " . $ident . " urlfilter.log \n " ;
2886 $uq [ 0 ] = $uq [ 0 ] * 60 ;
2887 if ( $uq [ 1 ] eq '0' ) {
2888 if ( $uq [ 2 ] eq 'hourly' ) { $uq [ 1 ] = 3600 }
2889 if ( $uq [ 2 ] eq 'daily' ) { $uq [ 1 ] = 86400 }
2890 if ( $uq [ 2 ] eq 'weekly' ) { $uq [ 1 ] = 604800 }
2893 print FILE
"src quota- $idx { \n " ;
2894 print FILE
" user $uq [3] \n " ;
2895 print FILE
" userquota $uq [0] $uq [1] $uq [2] \n " ;
2903 @tclist = & aggregatedconstraints
;
2912 if ( $tc [ 15 ] eq 'on' )
2915 print FILE
"src network- $idx { \n " ;
2916 @clients = split ( / / , $tc [ 12 ]);
2917 @temp = split ( /-/ , $clients [ 0 ]);
2918 if ( (& General
:: validipormask
( $temp [ 0 ])) || (& General
:: validipandmask
( $temp [ 0 ])))
2920 print FILE
" ip $tc [12] \n " ;
2923 @clients = split ( / / , $tc [ 12 ]);
2924 foreach $line ( @clients )
2926 $line =~ s/(^\w+)\\(\w+$)/$1%5c$2/ ;
2927 print FILE
" $line " ;
2931 if (( $filtersettings { 'ENABLE_LOG' } eq 'on' ) && ( $tc [ 14 ] eq 'block' ) && ( $tc [ 13 ] eq 'any' ))
2933 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
2935 print FILE
" logfile " . $ident . " timeconst.log \n " ;
2937 print FILE
" logfile " . $ident . " urlfilter.log \n " ;
2949 if ( $tc [ 15 ] eq 'on' )
2952 print FILE
"time constraint- $idx { \n " ;
2953 print FILE
" $tc [16] \n " ;
2959 foreach $category ( @categories ) {
2960 $blacklist = $category ;
2961 $category =~ s/\// _
/ g
;
2963 if ( $filtersettings { "FILTER_" . uc ( $category )} ne "on" ){
2964 my $constraintrule = "false" ;
2969 $tc [ 13 ] =~ s/\// _
/ g
;
2970 if ( $tc [ 15 ] eq 'on' && $tc [ 13 ] =~ $category ){
2971 $constraintrule = "true" ;
2975 if ( $constraintrule eq "false" ){
2980 print FILE
"dest $category { \n " ;
2981 if (- e
" $dbdir / $blacklist /domains" ) {
2982 print FILE
" domainlist $blacklist \/domains \n " ;
2984 if (- e
" $dbdir / $blacklist /urls" ) {
2985 print FILE
" urllist $blacklist \/urls \n " ;
2987 if ((- e
" $dbdir / $blacklist /expressions" ) && ( $filtersettings { 'ENABLE_EXPR_LISTS' } eq 'on' )) {
2988 print FILE
" expressionlist $blacklist \/expressions \n " ;
2990 if ((( $category eq 'ads' ) || ( $category eq 'adv' )) && ( $filtersettings { 'ENABLE_EMPTY_ADS' } eq 'on' ))
2992 print FILE
" redirect http:\/\/ $netsettings {'GREEN_ADDRESS'}: $http_port \/images/urlfilter/1x1.gif \n " ;
2994 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
2996 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
2998 print FILE
" logfile $ident $category .log \n " ;
3000 print FILE
" logfile $ident urlfilter.log \n " ;
3004 $category = $blacklist ;
3007 print FILE
"dest files { \n " ;
3008 print FILE
" expressionlist custom\/blocked\/files \n " ;
3009 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
3011 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
3013 print FILE
" logfile $ident files.log \n " ;
3015 print FILE
" logfile $ident urlfilter.log \n " ;
3020 print FILE
"dest custom-allowed { \n " ;
3021 print FILE
" domainlist custom\/allowed\/domains \n " ;
3022 print FILE
" urllist custom\/allowed\/urls \n " ;
3025 print FILE
"dest custom-blocked { \n " ;
3026 print FILE
" domainlist custom\/blocked\/domains \n " ;
3027 print FILE
" urllist custom\/blocked\/urls \n " ;
3028 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
3030 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
3032 print FILE
" logfile $ident custom.log \n " ;
3034 print FILE
" logfile $ident urlfilter.log \n " ;
3039 print FILE
"dest custom-expressions { \n " ;
3040 print FILE
" expressionlist custom\/blocked\/expressions \n " ;
3041 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
3043 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
3045 print FILE
" logfile $ident custom.log \n " ;
3047 print FILE
" logfile $ident urlfilter.log \n " ;
3052 print FILE
"acl { \n " ;
3053 if (!( $filtersettings { 'UNFILTERED_CLIENTS' } eq '' )) {
3054 print FILE
" unfiltered { \n " ;
3055 print FILE
" pass all \n " ;
3056 print FILE
" } \n\n " ;
3058 if (!( $filtersettings { 'BANNED_CLIENTS' } eq '' )) {
3059 print FILE
" banned { \n " ;
3060 print FILE
" pass " ;
3061 if (( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'on' ))
3063 print FILE
"custom-allowed " ;
3065 print FILE
"none \n " ;
3066 print FILE
" } \n\n " ;
3083 $qredirect = $redirect ;
3084 $qredirect =~ s/\%t/\%q\%20-\%20\%i/ ;
3085 print FILE
" quota- $idx { \n " ;
3086 print FILE
" pass " ;
3087 if (( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'on' ))
3089 print FILE
"custom-allowed " ;
3091 print FILE
"none \n " ;
3092 unless ( $redirect eq $qredirect ) { print FILE
" redirect $qredirect \n " ; }
3093 print FILE
" } \n\n " ;
3105 @ec = split ( /\|/ , $tc [ 13 ]);
3106 foreach ( @ec ) { s/\// _
/ g
; }
3107 if ( $tc [ 15 ] eq 'on' )
3110 print FILE
" network- $idx $tc [0] constraint- $idx { \n " ;
3111 print FILE
" pass " ;
3113 if ( $filtersettings { 'BLOCK_ALL' } eq 'on' )
3115 if ( $tc [ 14 ] eq 'block' )
3117 if (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' )) {
3118 if (( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'on' ))
3120 print FILE
"custom-allowed " ;
3124 print FILE
$defaultrule ;
3131 print FILE
$defaultrule unless (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ));
3134 if ( $tc [ 14 ] eq 'block' )
3136 $tcrule = $defaultrule ;
3137 if ( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) {
3138 $tcrule =~ s/custom-allowed // ;
3139 print FILE
"custom-allowed " unless (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'off' ));
3141 if (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' )) {
3146 print FILE
"! $_ " unless ( index ( $defaultrule , "!" . $_ . " " ) ge 0 );
3149 print FILE
$tcrule unless (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ));
3151 $tcrule = $defaultrule ;
3152 if (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ))
3158 $tcrule = " $_ " . $tcrule unless ( index ( $defaultrule , "!" . $_ . " " ) ge 0 );
3159 $tcrule =~ s/!$_ // ;
3168 print FILE
" } \n\n " ;
3173 print FILE
" default { \n " ;
3174 print FILE
" pass $defaultrule \n " ;
3175 if (( $filtersettings { 'ENABLE_LOG' } eq 'on' ) && ( $filtersettings { 'BLOCK_ALL' } eq 'on' ))
3177 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
3179 print FILE
" logfile" . $ident . " default.log \n " ;
3181 print FILE
" logfile" . $ident . " urlfilter.log \n " ;
3184 if (( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles ))
3186 print FILE
" rewrite rew-rule-1 \n " ;
3188 print FILE
" redirect $redirect \n " ;
3195 # -------------------------------------------------------------------