]>
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) 2007 Michael Tremer & Christian Schmidt #
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 $repository = "/home/httpd/html/repository" ;
63 my $hintcolour = '#FFFFCC' ;
65 my $sourceurlfile = "${General::swroot}/urlfilter/autoupdate/autoupdate.urls" ;
66 my $updconffile = "${General::swroot}/urlfilter/autoupdate/autoupdate.conf" ;
67 my $updflagfile = "${General::swroot}/urlfilter/blacklists/.autoupdate.last" ;
68 my $upd_cron_dly = "${General::swroot}/urlfilter/autoupdate/cron.daily" ;
69 my $upd_cron_wly = "${General::swroot}/urlfilter/autoupdate/cron.weekly" ;
70 my $upd_cron_mly = "${General::swroot}/urlfilter/autoupdate/cron.monthly" ;
74 my $restoremessage = '' ;
80 my @repositorylist =();
81 my @repositoryfiles =();
83 my @selectedcategories =();
87 my @source_urllist =();
99 if (! - d
$dbdir ) { mkdir ( " $dbdir " ); }
100 if (! - e
$tcfile ) { system ( "touch $tcfile " ); }
101 if (! - e
$uqfile ) { system ( "touch $uqfile " ); }
102 if (! - e
$sourceurlfile ) { system ( "touch $sourceurlfile " ); }
104 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%netsettings );
105 & General
:: readhash
( "${General::swroot}/main/settings" , \
%mainsettings );
106 & General
:: readhash
( "${General::swroot}/proxy/settings" , \
%proxysettings );
108 & readblockcategories
;
116 open ( FILE
, $sourceurlfile );
117 @source_urllist = < FILE
>;
120 $filtersettings { 'ENABLE_CUSTOM_BLACKLIST' } = 'off' ;
121 $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } = 'off' ;
122 $filtersettings { 'ENABLE_CUSTOM_EXPRESSIONS' } = 'off' ;
123 $filtersettings { 'BLOCK_EXECUTABLES' } = 'off' ;
124 $filtersettings { 'BLOCK_AUDIO-VIDEO' } = 'off' ;
125 $filtersettings { 'BLOCK_ARCHIVES' } = 'off' ;
126 $filtersettings { 'ENABLE_REWRITE' } = 'off' ;
127 $filtersettings { 'UNFILTERED_CLIENTS' } = '' ;
128 $filtersettings { 'BANNED_CLIENTS' } = '' ;
129 $filtersettings { 'SHOW_CATEGORY' } = 'off' ;
130 $filtersettings { 'SHOW_URL' } = 'off' ;
131 $filtersettings { 'SHOW_IP' } = 'off' ;
132 $filtersettings { 'ENABLE_DNSERROR' } = 'off' ;
133 $filtersettings { 'ENABLE_JPEG' } = 'off' ;
134 $filtersettings { 'REDIRECT_PAGE' } = '' ;
135 $filtersettings { 'MSG_TEXT_1' } = '' ;
136 $filtersettings { 'MSG_TEXT_2' } = '' ;
137 $filtersettings { 'MSG_TEXT_3' } = '' ;
138 $filtersettings { 'ENABLE_EXPR_LISTS' } = 'off' ;
139 $filtersettings { 'BLOCK_IP_ADDR' } = 'off' ;
140 $filtersettings { 'BLOCK_ALL' } = 'off' ;
141 $filtersettings { 'ENABLE_EMPTY_ADS' } = 'off' ;
142 $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } = 'off' ;
143 $filtersettings { 'ENABLE_SAFESEARCH' } = 'off' ;
144 $filtersettings { 'ENABLE_LOG' } = 'off' ;
145 $filtersettings { 'ENABLE_USERNAME_LOG' } = 'off' ;
146 $filtersettings { 'ENABLE_CATEGORY_LOG' } = 'off' ;
147 $filtersettings { 'ENABLE_AUTOUPDATE' } = 'off' ;
149 $filtersettings { 'ACTION' } = '' ;
150 $filtersettings { 'VALID' } = '' ;
152 & Header
:: getcgihash
( \
%filtersettings );
153 & Header
:: getcgihash
( \
%tcsettings );
154 & Header
:: getcgihash
( \
%uqsettings );
155 & Header
:: getcgihash
( \
%besettings );
157 if (( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'save' }) ||
158 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter save and restart' }) ||
159 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload file' }) ||
160 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter remove file' }) ||
161 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload blacklist' }) ||
162 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter backup' }) ||
163 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter restore' }))
166 @clients = split ( /\n/ , $filtersettings { 'UNFILTERED_CLIENTS' });
169 s/^\s+//g ; s/\s+$//g ; s/\s+-\s+/-/g ; s/\s+/ /g ; s/\n//g ;
170 if ( /.*-.*-.*/ ) { $errormessage = $Lang :: tr
{ 'urlfilter invalid ip or mask error' }; }
172 foreach ( @temp ) { unless ((& General
:: validipormask
( $_ )) || (& General
:: validipandmask
( $_ ))) { $errormessage = $Lang :: tr
{ 'urlfilter invalid ip or mask error' }; } }
174 @clients = split ( /\n/ , $filtersettings { 'BANNED_CLIENTS' });
177 s/^\s+//g ; s/\s+$//g ; s/\s+-\s+/-/g ; s/\s+/ /g ; s/\n//g ;
178 if ( /.*-.*-.*/ ) { $errormessage = $Lang :: tr
{ 'urlfilter invalid ip or mask error' }; }
180 foreach ( @temp ) { unless ((& General
:: validipormask
( $_ )) || (& General
:: validipandmask
( $_ ))) { $errormessage = $Lang :: tr
{ 'urlfilter invalid ip or mask error' }; } }
182 if ( $errormessage ) { goto ERROR
; }
184 if ((!( $filtersettings { 'REDIRECT_PAGE' } eq '' )) && (!( $filtersettings { 'REDIRECT_PAGE' } =~ /^https?:\/ \
// )))
186 $filtersettings { 'REDIRECT_PAGE' } = "http://" . $filtersettings { 'REDIRECT_PAGE' };
189 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter remove file' })
191 if (- e
" $repository / $filtersettings {'ID'}" ) { unlink ( " $repository / $filtersettings {'ID'}" ); }
192 $filtersettings { 'ACTION' } = $Lang :: tr
{ 'urlfilter manage repository' };
195 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload file' })
197 & Header
:: getcgihash
( \
%filtersettings , { 'wantfile' => 1 , 'filevar' => 'UPLOADFILE' });
199 $filtersettings { 'ACTION' } = $Lang :: tr
{ 'urlfilter manage repository' };
200 $_ = $filtersettings { 'UPLOADFILE' };
202 $_ = substr ( $_ , rindex ( $_ , "/" )+ 1 );
204 if ( copy
( $filtersettings { 'UPLOADFILE' }, " $repository / $_ " ) != 1 )
213 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload blacklist' })
215 & Header
:: getcgihash
( \
%filtersettings , { 'wantfile' => 1 , 'filevar' => 'UPDATEFILE' });
217 if (!( $filtersettings { 'UPDATEFILE' } =~ /.tar.gz$/ ))
219 $errormessage = $Lang :: tr
{ 'urlfilter wrong filetype' };
223 if ( copy
( $filtersettings { 'UPDATEFILE' }, "${General::swroot}/urlfilter/blacklists.tar.gz" ) != 1 )
229 if (!(- d
"${General::swroot}/urlfilter/update" )) { mkdir ( "${General::swroot}/urlfilter/update" ); }
231 my $exitcode = system ( "/bin/tar --no-same-owner -xzf ${General::swroot}/urlfilter/blacklists.tar.gz -C ${General::swroot}/urlfilter/update" );
235 $errormessage = $Lang :: tr
{ 'urlfilter tar error' };
238 if (- d
"${General::swroot}/urlfilter/update/BL" )
240 system ( "mv ${General::swroot}/urlfilter/update/BL ${General::swroot}/urlfilter/update/blacklists" );
243 if (- d
"${General::swroot}/urlfilter/update/category" )
245 system ( "mv ${General::swroot}/urlfilter/update/category ${General::swroot}/urlfilter/update/blacklists" );
248 if (!(- d
"${General::swroot}/urlfilter/update/blacklists" ))
250 $errormessage = $Lang :: tr
{ 'urlfilter invalid content' };
252 system ( "cp -r ${General::swroot}/urlfilter/update/blacklists/* $dbdir " );
254 & readblockcategories
;
259 $updatemessage = $Lang :: tr
{ 'urlfilter upload success' };
260 system ( "${General::swroot}/urlfilter/bin/prebuild.pl &" );
261 system ( "logger -t installpackage[urlfilter] \" URL filter blacklist - Blacklist update from local source completed \" " );
264 if (- d
"${General::swroot}/urlfilter/update" ) { system ( "rm -rf ${General::swroot}/urlfilter/update" ); }
265 if (- e
"${General::swroot}/urlfilter/blacklists.tar.gz" ) { unlink ( "${General::swroot}/urlfilter/blacklists.tar.gz" ); }
266 if ( $errormessage ) { goto ERROR
; }
269 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter backup' })
271 $blistbackup = ( $filtersettings { 'ENABLE_FULLBACKUP' } eq 'on' ) ?
"blacklists" : "blacklists/custom" ;
272 if ( system ( "/bin/tar -C ${General::swroot}/urlfilter -czf ${General::swroot}/urlfilter/backup.tar.gz settings timeconst userquota autoupdate $blistbackup " ))
274 $errormessage = $Lang :: tr
{ 'urlfilter backup error' };
279 print "Content-type: application/gzip \n " ;
280 print "Content-length: " ;
281 print (- s
"${General::swroot}/urlfilter/backup.tar.gz" );
283 print "Content-disposition: attachment; filename=urlfilter-backup.tar.gz \n\n " ;
285 open ( FILE
, "${General::swroot}/urlfilter/backup.tar.gz" );
286 while (< FILE
>) { print ; }
289 if (- e
"${General::swroot}/urlfilter/backup.tar.gz" ) { unlink ( "${General::swroot}/urlfilter/backup.tar.gz" ); }
294 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter restore' })
296 & Header
:: getcgihash
( \
%filtersettings , { 'wantfile' => 1 , 'filevar' => 'UPDATEFILE' });
298 if (!( $filtersettings { 'UPDATEFILE' } =~ /.tar.gz$/ ))
300 $errormessage = $Lang :: tr
{ 'urlfilter wrong filetype' };
304 if (!(- d
"${General::swroot}/urlfilter/restore" )) { mkdir ( "${General::swroot}/urlfilter/restore" ); }
306 if ( copy
( $filtersettings { 'UPDATEFILE' }, "${General::swroot}/urlfilter/backup.tar.gz" ) != 1 )
311 my $exitcode = system ( "/bin/tar --no-same-owner --preserve-permissions -xzf ${General::swroot}/urlfilter/backup.tar.gz -C ${General::swroot}/urlfilter/restore" );
314 $errormessage = $Lang :: tr
{ 'urlfilter tar error' };
316 if (!(- e
"${General::swroot}/urlfilter/restore/settings" ))
318 $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" ) { 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 system ( "chown -R nobody.nobody $dbdir " );
358 if (- e
" $dbdir /custom/allowed/domains.db" ) { unlink ( " $dbdir /custom/allowed/domains.db" ); }
359 if (- e
" $dbdir /custom/allowed/urls.db" ) { unlink ( " $dbdir /custom/allowed/urls.db" ); }
360 if (- e
" $dbdir /custom/blocked/domains.db" ) { unlink ( " $dbdir /custom/blocked/domains.db" ); }
361 if (- e
" $dbdir /custom/blocked/urls.db" ) { unlink ( " $dbdir /custom/blocked/urls.db" ); }
363 & setpermissions
( $dbdir );
365 system ( '/usr/local/bin/squidctrl restart >/dev/null 2>&1' );
369 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter set time constraints' }) { $tcsettings { 'TCMODE' } = 'on' }
371 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'add' }))
373 $tcsettings { 'TCMODE' }= 'on' ;
375 if (! $tcsettings { 'DST' })
377 $errormessage = $Lang :: tr
{ 'urlfilter dst error' };
380 if (! $tcsettings { 'SRC' })
382 $errormessage = $Lang :: tr
{ 'urlfilter src error' };
385 if (!( $tcsettings { 'TO_HOUR' }. $tcsettings { 'TO_MINUTE' } gt $tcsettings { 'FROM_HOUR' }. $tcsettings { 'FROM_MINUTE' }))
387 $errormessage = $Lang :: tr
{ 'urlfilter timespace error' };
390 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' )))
392 $errormessage = $Lang :: tr
{ 'urlfilter weekday error' };
397 # transform to pre1.8 client definitions
398 @clients = split ( /\n/ , $tcsettings { 'SRC' });
399 undef $tcsettings { 'SRC' };
402 s/^\s+//g ; s/\s+$//g ; s/\s+-\s+/-/g ; s/\s+/ /g ; s/\n//g ;
403 $tcsettings { 'SRC' } .= " $_ " ;
405 $tcsettings { 'SRC' } =~ s/\s+$// ;
407 if ( $tcsettings { 'DST' } =~ /^any/ ) { $tcsettings { 'DST' } = 'any' ; }
408 if ( $tcsettings { 'ENABLERULE' } eq 'on' ) { $tcsettings { 'ACTIVE' } = $tcsettings { 'ENABLERULE' }; } else { $tcsettings { 'ACTIVE' } = 'off' }
410 $tcsettings { 'ENABLERULE' } = 'on' ;
411 if ( $tcsettings { 'EDITING' } eq 'no' ) {
412 open ( FILE
, ">> $tcfile " );
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 " ;
416 open ( FILE
, "> $tcfile " );
419 foreach $line ( @tclist )
422 if ( $tcsettings { 'EDITING' } eq $id ) {
423 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 " ;
424 } else { print FILE
" $line " ; }
429 $tcsettings { 'CHANGED' }= 'yes' ;
430 $tcsettings { 'TCMODE' }= 'on' ;
433 if ( $tcsettings { 'EDITING' } ne 'no' )
435 $tcsettings { 'ACTION' } = $Lang :: tr
{ 'edit' };
436 $tcsettings { 'ID' } = $tcsettings { 'EDITING' };
441 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter copy rule' }) && (! $errormessage ))
444 foreach $line ( @tclist )
447 if ( $tcsettings { 'ID' } eq $id )
450 @temp = split ( /\,/ , $line );
451 $tcsettings { 'DEFINITION' } = $temp [ 0 ];
452 $tcsettings { 'MON' } = $temp [ 1 ];
453 $tcsettings { 'TUE' } = $temp [ 2 ];
454 $tcsettings { 'WED' } = $temp [ 3 ];
455 $tcsettings { 'THU' } = $temp [ 4 ];
456 $tcsettings { 'FRI' } = $temp [ 5 ];
457 $tcsettings { 'SAT' } = $temp [ 6 ];
458 $tcsettings { 'SUN' } = $temp [ 7 ];
459 $tcsettings { 'FROM_HOUR' } = $temp [ 8 ];
460 $tcsettings { 'FROM_MINUTE' } = $temp [ 9 ];
461 $tcsettings { 'TO_HOUR' } = $temp [ 10 ];
462 $tcsettings { 'TO_MINUTE' } = $temp [ 11 ];
463 $tcsettings { 'SRC' } = $temp [ 12 ];
464 $tcsettings { 'DST' } = $temp [ 13 ];
465 $tcsettings { 'ACCESS' } = $temp [ 14 ];
466 $tcsettings { 'ENABLERULE' } = $temp [ 15 ];
467 $tcsettings { 'COMMENT' } = $temp [ 16 ];
470 $tcsettings { 'TCMODE' }= 'on' ;
473 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'remove' }))
476 open ( FILE
, "> $tcfile " );
478 foreach $line ( @tclist )
481 unless ( $tcsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
484 $tcsettings { 'CHANGED' }= 'yes' ;
485 $tcsettings { 'TCMODE' }= 'on' ;
488 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter restart' }))
490 if (!( $proxysettings { 'ENABLE_FILTER' } eq 'on' ))
492 $errormessage = $Lang :: tr
{ 'urlfilter not enabled' };
494 if ((!(- e
"${General::swroot}/proxy/enable" )) && (!(- e
"${General::swroot}/proxy/enable_blue" )))
496 $errormessage = $Lang :: tr
{ 'urlfilter web proxy service required' };
499 if (! $errormessage ) { system ( '/usr/local/bin/squidctrl restart >/dev/null 2>&1' ); }
500 $tcsettings { 'TCMODE' }= 'on' ;
503 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }))
505 open ( FILE
, "> $tcfile " );
508 foreach $line ( @tclist )
511 unless ( $tcsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
515 @temp = split ( /\,/ , $line );
516 if ( $temp [ 15 ] eq 'on' ) { $temp [ 15 ] = 'off' ; } else { $temp [ 15 ] = 'on' }
517 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 " ;
521 $tcsettings { 'CHANGED' }= 'yes' ;
522 $tcsettings { 'TCMODE' }= 'on' ;
525 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) && (! $errormessage ))
528 foreach $line ( @tclist )
531 if ( $tcsettings { 'ID' } eq $id )
534 @temp = split ( /\,/ , $line );
535 $tcsettings { 'DEFINITION' } = $temp [ 0 ];
536 $tcsettings { 'MON' } = $temp [ 1 ];
537 $tcsettings { 'TUE' } = $temp [ 2 ];
538 $tcsettings { 'WED' } = $temp [ 3 ];
539 $tcsettings { 'THU' } = $temp [ 4 ];
540 $tcsettings { 'FRI' } = $temp [ 5 ];
541 $tcsettings { 'SAT' } = $temp [ 6 ];
542 $tcsettings { 'SUN' } = $temp [ 7 ];
543 $tcsettings { 'FROM_HOUR' } = $temp [ 8 ];
544 $tcsettings { 'FROM_MINUTE' } = $temp [ 9 ];
545 $tcsettings { 'TO_HOUR' } = $temp [ 10 ];
546 $tcsettings { 'TO_MINUTE' } = $temp [ 11 ];
547 $tcsettings { 'SRC' } = $temp [ 12 ];
548 $tcsettings { 'DST' } = $temp [ 13 ];
549 $tcsettings { 'ACCESS' } = $temp [ 14 ];
550 $tcsettings { 'ENABLERULE' } = $temp [ 15 ];
551 $tcsettings { 'COMMENT' } = $temp [ 16 ];
554 $tcsettings { 'TCMODE' }= 'on' ;
557 if ((! $errormessage ) && (!( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter copy rule' })) && (!( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }))) {
558 $tcsettings { 'ENABLERULE' }= 'on' ;
559 $tcsettings { 'TO_HOUR' }= '24' ;
562 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter set user quota' }) { $uqsettings { 'UQMODE' } = 'on' }
564 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'add' }))
566 $uqsettings { 'UQMODE' }= 'on' ;
568 if ((!( $uqsettings { 'TIME_QUOTA' } =~ /^\d+/ )) || ( $uqsettings { 'TIME_QUOTA' } < '1' ))
570 $errormessage = $Lang :: tr
{ 'urlfilter quota time error' };
573 @temp = split ( /\n/ , $uqsettings { 'QUOTA_USERS' });
574 undef $uqsettings { 'QUOTA_USERS' };
577 s/^\s+//g ; s/\s+$//g ;
578 if ( $_ ) { $uqsettings { 'QUOTA_USERS' } .= $_ . " \n " ; }
581 if ( $uqsettings { 'QUOTA_USERS' } eq '' )
583 $errormessage = $Lang :: tr
{ 'urlfilter quota user error' };
586 $_ = $uqsettings { 'QUOTA_USERS' };
588 my $quota_users = $_ ;
590 if ( $uqsettings { 'QUOTA_USERS' } =~ /\\/ )
592 $errormessage = $Lang :: tr
{ 'urlfilter invalid user error' };
595 if (! $errormessage ) {
596 if ( $uqsettings { 'ENABLEQUOTA' } eq 'on' ) { $uqsettings { 'ACTIVE' } = $uqsettings { 'ENABLEQUOTA' }; } else { $uqsettings { 'ACTIVE' } = 'off' }
598 $uqsettings { 'ENABLERULE' } = 'on' ;
599 if ( $uqsettings { 'EDITING' } eq 'no' ) {
600 open ( FILE
, ">> $uqfile " );
602 print FILE
" $uqsettings {'TIME_QUOTA'}, $uqsettings {'SPORADIC'}, $uqsettings {'RENEWAL'}, $quota_users , $uqsettings {'ACTIVE'} \n " ;
604 open ( FILE
, "> $uqfile " );
607 foreach $line ( @uqlist )
610 if ( $uqsettings { 'EDITING' } eq $id ) {
611 print FILE
" $uqsettings {'TIME_QUOTA'}, $uqsettings {'SPORADIC'}, $uqsettings {'RENEWAL'}, $quota_users , $uqsettings {'ACTIVE'} \n " ;
612 } else { print FILE
" $line " ; }
617 $uqsettings { 'CHANGED' }= 'yes' ;
618 $uqsettings { 'MODE' }= 'USERQUOTA' ;
619 $uqsettings { 'UQMODE' }= 'on' ;
622 if ( $uqsettings { 'EDITING' } ne 'no' )
624 $uqsettings { 'ACTION' } = $Lang :: tr
{ 'edit' };
625 $uqsettings { 'ID' } = $uqsettings { 'EDITING' };
630 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'remove' }))
633 open ( FILE
, "> $uqfile " );
635 foreach $line ( @uqlist )
638 unless ( $uqsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
641 $uqsettings { 'CHANGED' }= 'yes' ;
642 $uqsettings { 'UQMODE' }= 'on' ;
645 if (! $errormessage ) {
646 $uqsettings { 'ENABLEQUOTA' }= 'on' ;
649 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) && (! $errormessage ))
652 foreach $line ( @uqlist )
655 if ( $uqsettings { 'ID' } eq $id )
658 @temp = split ( /\,/ , $line );
659 $uqsettings { 'TIME_QUOTA' } = $temp [ 0 ];
660 $uqsettings { 'SPORADIC' } = $temp [ 1 ];
661 $uqsettings { 'RENEWAL' } = $temp [ 2 ];
662 $uqsettings { 'QUOTA_USERS' } = $temp [ 3 ];
663 $uqsettings { 'ENABLEQUOTA' } = $temp [ 4 ];
666 $uqsettings { 'UQMODE' }= 'on' ;
669 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }))
671 open ( FILE
, "> $uqfile " );
674 foreach $line ( @uqlist )
677 unless ( $uqsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
681 @temp = split ( /\,/ , $line );
682 if ( $temp [ 4 ] eq 'on' ) { $temp [ 4 ] = 'off' ; } else { $temp [ 4 ] = 'on' }
683 print FILE
" $temp [0], $temp [1], $temp [2], $temp [3], $temp [4] \n " ;
687 $uqsettings { 'CHANGED' }= 'yes' ;
688 $uqsettings { 'UQMODE' }= 'on' ;
691 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter restart' }))
693 if (!( $proxysettings { 'ENABLE_FILTER' } eq 'on' ))
695 $errormessage = $Lang :: tr
{ 'urlfilter not enabled' };
697 if ((!(- e
"${General::swroot}/proxy/enable" )) && (!(- e
"${General::swroot}/proxy/enable_blue" )))
699 $errormessage = $Lang :: tr
{ 'urlfilter web proxy service required' };
702 if (! $errormessage ) { system ( '/usr/local/bin/squidctrl restart >/dev/null 2>&1' ); }
703 $uqsettings { 'UQMODE' }= 'on' ;
706 if ( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter blacklist editor' }) { $besettings { 'BEMODE' } = 'on' ; }
708 if ( $besettings { 'MODE' } eq 'BLACKLIST_EDITOR' )
710 @temp = split ( /\n/ , $besettings { 'BE_DOMAINS' });
711 undef $besettings { 'BE_DOMAINS' };
714 s/^\s+//g ; s/\s+$//g ;
715 if ( $_ ) { $besettings { 'BE_DOMAINS' } .= $_ . " \n " ; }
717 chomp ( $besettings { 'BE_DOMAINS' });
718 @temp = split ( /\n/ , $besettings { 'BE_URLS' });
719 undef $besettings { 'BE_URLS' };
722 s/^\s+//g ; s/\s+$//g ;
723 if ( $_ ) { $besettings { 'BE_URLS' } .= $_ . " \n " ; }
725 chomp ( $besettings { 'BE_URLS' });
726 @temp = split ( /\n/ , $besettings { 'BE_EXPRESSIONS' });
727 undef $besettings { 'BE_EXPRESSIONS' };
730 s/^\s+//g ; s/\s+$//g ;
731 if ( $_ ) { $besettings { 'BE_EXPRESSIONS' } .= $_ . " \n " ; }
733 chomp ( $besettings { 'BE_EXPRESSIONS' });
736 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter load blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
738 $besettings { 'BEMODE' } = 'on' ;
740 $besettings { 'BE_NAME' } = $besettings { 'BE_BLACKLIST' };
742 delete $besettings { 'BE_DOMAINS' };
743 delete $besettings { 'BE_URLS' };
744 delete $besettings { 'BE_EXPRESSIONS' };
746 if (- e
" $dbdir / $besettings {'BE_NAME'}/domains" )
748 open ( FILE
, " $dbdir / $besettings {'BE_NAME'}/domains" );
749 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_DOMAINS' } .= $_ } };
751 chomp ( $besettings { 'BE_DOMAINS' });
753 if (- e
" $dbdir / $besettings {'BE_NAME'}/urls" )
755 open ( FILE
, " $dbdir / $besettings {'BE_NAME'}/urls" );
756 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_URLS' } .= $_ } };
758 chomp ( $besettings { 'BE_URLS' });
760 if (- e
" $dbdir / $besettings {'BE_NAME'}/expressions" )
762 open ( FILE
, " $dbdir / $besettings {'BE_NAME'}/expressions" );
763 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_EXPRESSIONS' } .= $_ } };
765 chomp ( $besettings { 'BE_EXPRESSIONS' });
769 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter import blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
771 $besettings { 'BEMODE' } = 'on' ;
773 & Header
:: getcgihash
( \
%besettings , { 'wantfile' => 1 , 'filevar' => 'IMPORTFILE' });
775 if (!( $besettings { 'IMPORTFILE' } =~ /.tar.gz$/ ))
777 $errormessage = $Lang :: tr
{ 'urlfilter wrong filetype' };
779 if (!- d
" $editdir " ) { mkdir ( " $editdir " ); }
781 if ( copy
( $besettings { 'IMPORTFILE' }, " $editdir /blacklist.tar.gz" ) != 1 )
786 my $exitcode = system ( "/bin/tar --no-same-owner --preserve-permissions -xzf $editdir /blacklist.tar.gz -C $editdir " );
789 $errormessage = $Lang :: tr
{ 'urlfilter tar error' };
792 foreach (< $editdir /blacklists/ *>)
797 $besettings { 'BE_NAME' } = substr ( $_ , rindex ( $_ , "/" )+ 1 );
803 $errormessage = $Lang :: tr
{ 'urlfilter invalid import file' };
805 delete $besettings { 'BE_DOMAINS' };
806 delete $besettings { 'BE_URLS' };
807 delete $besettings { 'BE_EXPRESSIONS' };
809 if (- e
" $editdir /blacklists/ $besettings {'BE_NAME'}/domains" )
811 open ( FILE
, " $editdir /blacklists/ $besettings {'BE_NAME'}/domains" );
812 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_DOMAINS' } .= $_ } };
814 chomp ( $besettings { 'BE_DOMAINS' });
816 if (- e
" $editdir /blacklists/ $besettings {'BE_NAME'}/urls" )
818 open ( FILE
, " $editdir /blacklists/ $besettings {'BE_NAME'}/urls" );
819 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_URLS' } .= $_ } };
821 chomp ( $besettings { 'BE_URLS' });
823 if (- e
" $editdir /blacklists/ $besettings {'BE_NAME'}/expressions" )
825 open ( FILE
, " $editdir /blacklists/ $besettings {'BE_NAME'}/expressions" );
826 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_EXPRESSIONS' } .= $_ } };
828 chomp ( $besettings { 'BE_EXPRESSIONS' });
833 if (- d
$editdir ) { system ( "rm -rf $editdir " ); }
839 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter export blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
841 $besettings { 'BEMODE' } = 'on' ;
843 if ( $besettings { 'BE_NAME' } eq '' )
845 $errormessage = $Lang :: tr
{ 'urlfilter category name error' };
846 } elsif ( $besettings { 'BE_DOMAINS' } || $besettings { 'BE_URLS' } || $besettings { 'BE_EXPRESSIONS' }) {
848 $_ = $besettings { 'BE_NAME' }; tr/A-Z/a-z/ ; $besettings { 'BE_NAME' } = $_ ;
850 if (!(- d
" $editdir " )) { mkdir ( " $editdir " ); }
851 if (!(- d
" $editdir /blacklists" )) { mkdir ( " $editdir /blacklists" ); }
852 if (!(- d
" $editdir /blacklists/ $besettings {'BE_NAME'}" )) { mkdir ( " $editdir /blacklists/ $besettings {'BE_NAME'}" ); }
854 open ( FILE
, "> $editdir /blacklists/ $besettings {'BE_NAME'}/domains" );
856 print FILE
" $besettings {'BE_DOMAINS'} \n " ;
858 open ( FILE
, "> $editdir /blacklists/ $besettings {'BE_NAME'}/urls" );
860 print FILE
" $besettings {'BE_URLS'} \n " ;
862 open ( FILE
, "> $editdir /blacklists/ $besettings {'BE_NAME'}/expressions" );
864 print FILE
" $besettings {'BE_EXPRESSIONS'} \n " ;
867 if ( system ( "/bin/tar -C $editdir -czf $editdir / $besettings {'BE_NAME'}.tar.gz blacklists" ))
869 $errormessage = $Lang :: tr
{ 'urlfilter export error' };
873 print "Content-type: application/gzip \n " ;
874 print "Content-length: " ;
875 print (- s
" $editdir / $besettings {'BE_NAME'}.tar.gz" );
877 print "Content-disposition: attachment; filename= $besettings {'BE_NAME'}.tar.gz \n\n " ;
879 open ( FILE
, " $editdir / $besettings {'BE_NAME'}.tar.gz" );
880 while (< FILE
>) { print ; }
883 if (- d
$editdir ) { system ( "rm -rf $editdir " ); }
887 $errormessage = $Lang :: tr
{ 'urlfilter category data error' };
891 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter install blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
893 $besettings { 'BEMODE' } = 'on' ;
895 if ( $besettings { 'BE_NAME' } eq '' )
897 $errormessage = $Lang :: tr
{ 'urlfilter category name error' };
898 } elsif ( $besettings { 'BE_DOMAINS' } || $besettings { 'BE_URLS' } || $besettings { 'BE_EXPRESSIONS' }) {
900 $_ = $besettings { 'BE_NAME' }; tr/A-Z/a-z/ ; $besettings { 'BE_NAME' } = $_ ;
902 if (!- d
" $editdir " ) { mkdir ( " $editdir " ); }
904 if (!- d
" $dbdir / $besettings {'BE_NAME'}" ) { mkdir ( " $dbdir / $besettings {'BE_NAME'}" ); }
906 if (- e
" $dbdir / $besettings {'BE_NAME'}/domains" ) { unlink ( " $dbdir / $besettings {'BE_NAME'}/domains" ); }
907 if ( $besettings { 'BE_DOMAINS' })
909 open ( FILE
, "> $dbdir / $besettings {'BE_NAME'}/domains" );
911 print FILE
" $besettings {'BE_DOMAINS'} \n " ;
914 if (- e
" $dbdir / $besettings {'BE_NAME'}/urls" ) { unlink ( " $dbdir / $besettings {'BE_NAME'}/urls" ); }
915 if ( $besettings { 'BE_URLS' })
917 open ( FILE
, "> $dbdir / $besettings {'BE_NAME'}/urls" );
919 print FILE
" $besettings {'BE_URLS'} \n " ;
922 if (- e
" $dbdir / $besettings {'BE_NAME'}/expressions" ) { unlink ( " $dbdir / $besettings {'BE_NAME'}/expressions" ); }
923 if ( $besettings { 'BE_EXPRESSIONS' })
925 open ( FILE
, "> $dbdir / $besettings {'BE_NAME'}/expressions" );
927 print FILE
" $besettings {'BE_EXPRESSIONS'} \n " ;
931 open ( FILE
, "> $editdir /install.conf" );
933 print FILE
"logdir /var/log/squidGuard \n " ;
934 print FILE
"dbhome $dbdir / $besettings {'BE_NAME'} \n\n " ;
935 print FILE
"dest $besettings {'BE_NAME'} { \n " ;
936 if ( $besettings { 'BE_DOMAINS' }) { print FILE
" domainlist domains \n " ; }
937 if ( $besettings { 'BE_URLS' }) { print FILE
" urllist urls \n " ; }
938 if ( $besettings { 'BE_EXPRESSIONS' }) { print FILE
" expressions expressions \n " ; }
940 print FILE
"acl { \n " ;
941 print FILE
" default { \n " ;
942 print FILE
" pass none \n " ;
947 system ( "rm -f $dbdir / $besettings {'BE_NAME'}/*.db" );
948 system ( "/usr/sbin/squidGuard -c $editdir /install.conf -C all" );
949 system ( "chmod a+w $dbdir / $besettings {'BE_NAME'}/*.db" );
951 & readblockcategories
;
956 system ( '/usr/local/bin/squidctrl restart >/dev/null 2>&1' ) unless ( $besettings { 'NORESTART' } eq 'on' );
958 if (- d
$editdir ) { system ( "rm -rf $editdir " ); }
960 $errormessage = $Lang :: tr
{ 'urlfilter category data error' };
964 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter save schedule' })
966 if (( $filtersettings { 'UPDATE_SOURCE' } eq 'custom' ) && ( $filtersettings { 'CUSTOM_UPDATE_URL' } eq '' ))
968 $errormessage = $Lang :: tr
{ 'urlfilter custom url required' };
970 open ( FILE
, "> $updconffile " );
971 print FILE
"ENABLE_AUTOUPDATE= $filtersettings {'ENABLE_AUTOUPDATE'} \n " ;
972 print FILE
"UPDATE_SCHEDULE= $filtersettings {'UPDATE_SCHEDULE'} \n " ;
973 print FILE
"UPDATE_SOURCE= $filtersettings {'UPDATE_SOURCE'} \n " ;
974 print FILE
"CUSTOM_UPDATE_URL= $filtersettings {'CUSTOM_UPDATE_URL'} \n " ;
977 if (- e
$upd_cron_dly ) { unlink ( $upd_cron_dly ); }
978 if (- e
$upd_cron_wly ) { unlink ( $upd_cron_wly ); }
979 if (- e
$upd_cron_mly ) { unlink ( $upd_cron_mly ); }
981 if (( $filtersettings { 'ENABLE_AUTOUPDATE' } eq 'on' ) && ( $filtersettings { 'UPDATE_SCHEDULE' } eq 'daily' ))
983 symlink ( "../bin/autoupdate.pl" , $upd_cron_dly )
985 symlink ( "/bin/false" , $upd_cron_dly )
988 if (( $filtersettings { 'ENABLE_AUTOUPDATE' } eq 'on' ) && ( $filtersettings { 'UPDATE_SCHEDULE' } eq 'weekly' ))
990 symlink ( "../bin/autoupdate.pl" , $upd_cron_wly )
992 symlink ( "/bin/false" , $upd_cron_wly )
995 if (( $filtersettings { 'ENABLE_AUTOUPDATE' } eq 'on' ) && ( $filtersettings { 'UPDATE_SCHEDULE' } eq 'monthly' ))
997 symlink ( "../bin/autoupdate.pl" , $upd_cron_mly )
999 symlink ( "/bin/false" , $upd_cron_mly )
1004 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter update now' })
1006 if ( $filtersettings { 'UPDATE_SOURCE' } eq 'custom' )
1008 if ( $filtersettings { 'CUSTOM_UPDATE_URL' } eq '' )
1010 $errormessage = $Lang :: tr
{ 'urlfilter custom url required' };
1012 system ( "${General::swroot}/urlfilter/bin/autoupdate.pl $filtersettings {'CUSTOM_UPDATE_URL'} &" );
1015 system ( "${General::swroot}/urlfilter/bin/autoupdate.pl $filtersettings {'UPDATE_SOURCE'} &" );
1020 if (- e
"${General::swroot}/urlfilter/settings" ) { & General
:: readhash
( "${General::swroot}/urlfilter/settings" , \
%filtersettings ); }
1026 if ( $errormessage ) { $filtersettings { 'VALID' } = 'no' ; }
1028 $checked { 'ENABLE_CUSTOM_BLACKLIST' }{ 'off' } = '' ;
1029 $checked { 'ENABLE_CUSTOM_BLACKLIST' }{ 'on' } = '' ;
1030 $checked { 'ENABLE_CUSTOM_BLACKLIST' }{ $filtersettings { 'ENABLE_CUSTOM_BLACKLIST' }} = "checked='checked'" ;
1031 $checked { 'ENABLE_CUSTOM_WHITELIST' }{ 'off' } = '' ;
1032 $checked { 'ENABLE_CUSTOM_WHITELIST' }{ 'on' } = '' ;
1033 $checked { 'ENABLE_CUSTOM_WHITELIST' }{ $filtersettings { 'ENABLE_CUSTOM_WHITELIST' }} = "checked='checked'" ;
1034 $checked { 'ENABLE_CUSTOM_EXPRESSIONS' }{ 'off' } = '' ;
1035 $checked { 'ENABLE_CUSTOM_EXPRESSIONS' }{ 'on' } = '' ;
1036 $checked { 'ENABLE_CUSTOM_EXPRESSIONS' }{ $filtersettings { 'ENABLE_CUSTOM_EXPRESSIONS' }} = "checked='checked'" ;
1037 $checked { 'BLOCK_EXECUTABLES' }{ 'off' } = '' ;
1038 $checked { 'BLOCK_EXECUTABLES' }{ 'on' } = '' ;
1039 $checked { 'BLOCK_EXECUTABLES' }{ $filtersettings { 'BLOCK_EXECUTABLES' }} = "checked='checked'" ;
1040 $checked { 'BLOCK_AUDIO-VIDEO' }{ 'off' } = '' ;
1041 $checked { 'BLOCK_AUDIO-VIDEO' }{ 'on' } = '' ;
1042 $checked { 'BLOCK_AUDIO-VIDEO' }{ $filtersettings { 'BLOCK_AUDIO-VIDEO' }} = "checked='checked'" ;
1043 $checked { 'BLOCK_ARCHIVES' }{ 'off' } = '' ;
1044 $checked { 'BLOCK_ARCHIVES' }{ 'on' } = '' ;
1045 $checked { 'BLOCK_ARCHIVES' }{ $filtersettings { 'BLOCK_ARCHIVES' }} = "checked='checked'" ;
1046 $checked { 'ENABLE_REWRITE' }{ 'off' } = '' ;
1047 $checked { 'ENABLE_REWRITE' }{ 'on' } = '' ;
1048 $checked { 'ENABLE_REWRITE' }{ $filtersettings { 'ENABLE_REWRITE' }} = "checked='checked'" ;
1049 $checked { 'SHOW_CATEGORY' }{ 'off' } = '' ;
1050 $checked { 'SHOW_CATEGORY' }{ 'on' } = '' ;
1051 $checked { 'SHOW_CATEGORY' }{ $filtersettings { 'SHOW_CATEGORY' }} = "checked='checked'" ;
1052 $checked { 'SHOW_URL' }{ 'off' } = '' ;
1053 $checked { 'SHOW_URL' }{ 'on' } = '' ;
1054 $checked { 'SHOW_URL' }{ $filtersettings { 'SHOW_URL' }} = "checked='checked'" ;
1055 $checked { 'SHOW_IP' }{ 'off' } = '' ;
1056 $checked { 'SHOW_IP' }{ 'on' } = '' ;
1057 $checked { 'SHOW_IP' }{ $filtersettings { 'SHOW_IP' }} = "checked='checked'" ;
1058 $checked { 'ENABLE_DNSERROR' }{ 'off' } = '' ;
1059 $checked { 'ENABLE_DNSERROR' }{ 'on' } = '' ;
1060 $checked { 'ENABLE_DNSERROR' }{ $filtersettings { 'ENABLE_DNSERROR' }} = "checked='checked'" ;
1061 $checked { 'ENABLE_JPEG' }{ 'off' } = '' ;
1062 $checked { 'ENABLE_JPEG' }{ 'on' } = '' ;
1063 $checked { 'ENABLE_JPEG' }{ $filtersettings { 'ENABLE_JPEG' }} = "checked='checked'" ;
1064 $checked { 'ENABLE_EXPR_LISTS' }{ 'off' } = '' ;
1065 $checked { 'ENABLE_EXPR_LISTS' }{ 'on' } = '' ;
1066 $checked { 'ENABLE_EXPR_LISTS' }{ $filtersettings { 'ENABLE_EXPR_LISTS' }} = "checked='checked'" ;
1067 $checked { 'BLOCK_IP_ADDR' }{ 'off' } = '' ;
1068 $checked { 'BLOCK_IP_ADDR' }{ 'on' } = '' ;
1069 $checked { 'BLOCK_IP_ADDR' }{ $filtersettings { 'BLOCK_IP_ADDR' }} = "checked='checked'" ;
1070 $checked { 'BLOCK_ALL' }{ 'off' } = '' ;
1071 $checked { 'BLOCK_ALL' }{ 'on' } = '' ;
1072 $checked { 'BLOCK_ALL' }{ $filtersettings { 'BLOCK_ALL' }} = "checked='checked'" ;
1073 $checked { 'ENABLE_EMPTY_ADS' }{ 'off' } = '' ;
1074 $checked { 'ENABLE_EMPTY_ADS' }{ 'on' } = '' ;
1075 $checked { 'ENABLE_EMPTY_ADS' }{ $filtersettings { 'ENABLE_EMPTY_ADS' }} = "checked='checked'" ;
1076 $checked { 'ENABLE_GLOBAL_WHITELIST' }{ 'off' } = '' ;
1077 $checked { 'ENABLE_GLOBAL_WHITELIST' }{ 'on' } = '' ;
1078 $checked { 'ENABLE_GLOBAL_WHITELIST' }{ $filtersettings { 'ENABLE_GLOBAL_WHITELIST' }} = "checked='checked'" ;
1079 $checked { 'ENABLE_SAFESEARCH' }{ 'off' } = '' ;
1080 $checked { 'ENABLE_SAFESEARCH' }{ 'on' } = '' ;
1081 $checked { 'ENABLE_SAFESEARCH' }{ $filtersettings { 'ENABLE_SAFESEARCH' }} = "checked='checked'" ;
1082 $checked { 'ENABLE_LOG' }{ 'off' } = '' ;
1083 $checked { 'ENABLE_LOG' }{ 'on' } = '' ;
1084 $checked { 'ENABLE_LOG' }{ $filtersettings { 'ENABLE_LOG' }} = "checked='checked'" ;
1085 $checked { 'ENABLE_USERNAME_LOG' }{ 'off' } = '' ;
1086 $checked { 'ENABLE_USERNAME_LOG' }{ 'on' } = '' ;
1087 $checked { 'ENABLE_USERNAME_LOG' }{ $filtersettings { 'ENABLE_USERNAME_LOG' }} = "checked='checked'" ;
1088 $checked { 'ENABLE_CATEGORY_LOG' }{ 'off' } = '' ;
1089 $checked { 'ENABLE_CATEGORY_LOG' }{ 'on' } = '' ;
1090 $checked { 'ENABLE_CATEGORY_LOG' }{ $filtersettings { 'ENABLE_CATEGORY_LOG' }} = "checked='checked'" ;
1092 foreach $category ( @filtergroups ) {
1093 $checked { $category }{ 'off' } = '' ;
1094 $checked { $category }{ 'on' } = '' ;
1095 $checked { $category }{ $filtersettings { $category }} = "checked='checked'" ;
1098 $selected { 'DEFINITION' }{ $tcsettings { 'DEFINITION' }} = "selected='selected'" ;
1099 $selected { 'FROM_HOUR' }{ $tcsettings { 'FROM_HOUR' }} = "selected='selected'" ;
1100 $selected { 'FROM_MINUTE' }{ $tcsettings { 'FROM_MINUTE' }} = "selected='selected'" ;
1101 $selected { 'TO_HOUR' }{ $tcsettings { 'TO_HOUR' }} = "selected='selected'" ;
1102 $selected { 'TO_MINUTE' }{ $tcsettings { 'TO_MINUTE' }} = "selected='selected'" ;
1104 @selectedcategories = split ( /\|/ , $tcsettings { 'DST' });
1105 foreach ( @selectedcategories )
1107 $selected { 'DST' }{ $_ } = "selected='selected'" ;
1110 $selected { 'ACCESS' }{ $tcsettings { 'ACCESS' }} = "selected='selected'" ;
1112 $checked { 'ENABLERULE' }{ 'off' } = '' ;
1113 $checked { 'ENABLERULE' }{ 'on' } = '' ;
1114 $checked { 'ENABLERULE' }{ $tcsettings { 'ENABLERULE' }} = "checked='checked'" ;
1115 $checked { 'MON' }{ 'off' } = '' ;
1116 $checked { 'MON' }{ 'on' } = '' ;
1117 $checked { 'MON' }{ $tcsettings { 'MON' }} = "checked='checked'" ;
1118 $checked { 'TUE' }{ 'off' } = '' ;
1119 $checked { 'TUE' }{ 'on' } = '' ;
1120 $checked { 'TUE' }{ $tcsettings { 'TUE' }} = "checked='checked'" ;
1121 $checked { 'WED' }{ 'off' } = '' ;
1122 $checked { 'WED' }{ 'on' } = '' ;
1123 $checked { 'WED' }{ $tcsettings { 'WED' }} = "checked='checked'" ;
1124 $checked { 'THU' }{ 'off' } = '' ;
1125 $checked { 'THU' }{ 'on' } = '' ;
1126 $checked { 'THU' }{ $tcsettings { 'THU' }} = "checked='checked'" ;
1127 $checked { 'FRI' }{ 'off' } = '' ;
1128 $checked { 'FRI' }{ 'on' } = '' ;
1129 $checked { 'FRI' }{ $tcsettings { 'FRI' }} = "checked='checked'" ;
1130 $checked { 'SAT' }{ 'off' } = '' ;
1131 $checked { 'SAT' }{ 'on' } = '' ;
1132 $checked { 'SAT' }{ $tcsettings { 'SAT' }} = "checked='checked'" ;
1133 $checked { 'SUN' }{ 'off' } = '' ;
1134 $checked { 'SUN' }{ 'on' } = '' ;
1135 $checked { 'SUN' }{ $tcsettings { 'SUN' }} = "checked='checked'" ;
1137 $selected { 'SPORADIC' }{ $uqsettings { 'SPORADIC' }} = "selected='selected'" ;
1138 $selected { 'RENEWAL' } { $uqsettings { 'RENEWAL' }} = "selected='selected'" ;
1140 $checked { 'ENABLEQUOTA' }{ 'off' } = '' ;
1141 $checked { 'ENABLEQUOTA' }{ 'on' } = '' ;
1142 $checked { 'ENABLEQUOTA' }{ $uqsettings { 'ENABLEQUOTA' }} = "checked='checked'" ;
1144 $selected { 'BE_BLACKLIST' }{ $besettings { 'BE_BLACKLIST' }} = "selected='selected'" ;
1147 & Header
:: showhttpheaders
();
1149 & Header
:: openpage
( $Lang :: tr
{ 'urlfilter configuration' }, 1 , '' );
1151 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
1153 if ( $errormessage ) {
1154 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
1155 print "<font class='base'> $errormessage </font> \n " ;
1156 & Header
:: closebox
();
1157 } elsif (( $tcsettings { 'CHANGED' } eq 'yes' ) || ( $uqsettings { 'CHANGED' } eq 'yes' ) ) {
1159 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}'> \n " ;
1160 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter restart notification'}:" );
1161 print "<class name='base'> $Lang ::tr{'urlfilter restart message'} \n " ;
1162 if ( $uqsettings { 'MODE' } eq 'USERQUOTA' ) { print "<p><class name='base'> $Lang ::tr{'urlfilter quota restart message'} \n " ; }
1164 print "<p><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter restart'}' />" ;
1165 if ( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) { print "<input type='hidden' name='MODE' value='TIMECONSTRAINT' />" ; }
1166 if ( $uqsettings { 'MODE' } eq 'USERQUOTA' ) { print "<input type='hidden' name='MODE' value='USERQUOTA' />" ; }
1167 & Header
:: closebox
();
1171 if ( $restoremessage ) {
1172 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter restore results'}:" );
1173 print "<class name='base'> $restoremessage \n " ;
1174 print " </class> \n " ;
1175 & Header
:: closebox
();
1178 if ((! $tcsettings { 'TCMODE' }) && (! $uqsettings { 'UQMODE' }) && (! $besettings { 'BEMODE' })) {
1180 if (!( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter manage repository' })) {
1182 #==========================================================
1184 # Section: Main Configuration
1186 #==========================================================
1188 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
1190 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter filter settings'}:" );
1192 <table width='100%'>
1194 <td colspan='4'><b> $Lang ::tr{'urlfilter block categories'}</b></td>
1199 if ( @categories == 0 ) {
1202 <td><i> $Lang ::tr{'urlfilter no categories'}</i></td>
1212 for ( $n = 0 ; $n <= @categories ; $n = $n + $i ) {
1213 for ( $i = 0 ; $i <= 3 ; $i ++) {
1214 if ( $i eq 0 ) { print "<tr> \n " ; }
1215 if (( $n + $i ) < @categories ) {
1216 print "<td width='15%'> @categories [ $n + $i ]:<\/td> \n " ;
1217 print "<td width='10%'><input type='checkbox' name= @filtergroups [ $n + $i ] $checked { @filtergroups [ $n + $i ]}{'on'} /></td> \n " ;
1219 if ( $i eq 3 ) { print "<\/tr> \n " ; }
1226 <table width='100%'>
1228 <td><b> $Lang ::tr{'urlfilter custom blacklist'}</b></td>
1234 <td colspan='2'> $Lang ::tr{'urlfilter blocked domains'} <img src='/blob.gif' alt='*' /></td>
1235 <td colspan='2'> $Lang ::tr{'urlfilter blocked urls'} <img src='/blob.gif' alt='*' /></td>
1238 <td colspan='2' width='50%'><textarea name='CUSTOM_BLACK_DOMAINS' cols='32' rows='6' wrap='off'>
1242 print $filtersettings { 'CUSTOM_BLACK_DOMAINS' };
1246 <td colspan='2' width='50%'><textarea name='CUSTOM_BLACK_URLS' cols='32' rows='6' wrap='off'>
1250 print $filtersettings { 'CUSTOM_BLACK_URLS' };
1256 <table width='100%'>
1258 <td class='base' width='25%'> $Lang ::tr{'urlfilter enable custom blacklist'}:</td>
1259 <td><input type='checkbox' name='ENABLE_CUSTOM_BLACKLIST' $checked {'ENABLE_CUSTOM_BLACKLIST'}{'on'} /></td>
1265 <table width='100%'>
1267 <td><b> $Lang ::tr{'urlfilter custom whitelist'}</b></td>
1273 <td colspan='2'> $Lang ::tr{'urlfilter allowed domains'} <img src='/blob.gif' alt='*' /></td>
1274 <td colspan='2'> $Lang ::tr{'urlfilter allowed urls'} <img src='/blob.gif' alt='*' /></td>
1277 <td colspan='2' width='50%'><textarea name='CUSTOM_WHITE_DOMAINS' cols='32' rows='6' wrap='off'>
1281 print $filtersettings { 'CUSTOM_WHITE_DOMAINS' };
1285 <td colspan='2' width='50%'><textarea name='CUSTOM_WHITE_URLS' cols='32' rows='6' wrap='off'>
1289 print $filtersettings { 'CUSTOM_WHITE_URLS' };
1295 <table width='100%'>
1297 <td class='base' width='25%'> $Lang ::tr{'urlfilter enable custom whitelist'}:</td>
1298 <td><input type='checkbox' name='ENABLE_CUSTOM_WHITELIST' $checked {'ENABLE_CUSTOM_WHITELIST'}{'on'} /></td>
1304 <table width='100%'>
1306 <td colspan='4'><b> $Lang ::tr{'urlfilter custom expression list'}</b></td>
1309 <td colspan='4'> $Lang ::tr{'urlfilter blocked expressions'} <img src='/blob.gif' alt='*' /></td>
1312 <td colspan='4'><textarea name='CUSTOM_EXPRESSIONS' cols='70' rows='3' wrap='off'>
1316 print $filtersettings { 'CUSTOM_EXPRESSIONS' };
1322 <td class='base' width='25%'> $Lang ::tr{'urlfilter enable custom expression list'}:</td>
1323 <td><input type='checkbox' name='ENABLE_CUSTOM_EXPRESSIONS' $checked {'ENABLE_CUSTOM_EXPRESSIONS'}{'on'} /></td>
1329 <table width='100%'>
1331 <td colspan='4'><b> $Lang ::tr{'urlfilter file ext block'}</b></td>
1334 <td width='25%' class='base'> $Lang ::tr{'urlfilter block executables'}:</td>
1335 <td width='12%'><input type='checkbox' name='BLOCK_EXECUTABLES' $checked {'BLOCK_EXECUTABLES'}{'on'} /></td>
1336 <td width='25%' class='base'> $Lang ::tr{'urlfilter block audio-video'}:</td>
1337 <td><input type='checkbox' name='BLOCK_AUDIO-VIDEO' $checked {'BLOCK_AUDIO-VIDEO'}{'on'} /></td>
1340 <td class='base'> $Lang ::tr{'urlfilter block archives'}:</td>
1341 <td><input type='checkbox' name='BLOCK_ARCHIVES' $checked {'BLOCK_ARCHIVES'}{'on'} /></td>
1347 <table width='100%'>
1349 <td colspan='4'><b> $Lang ::tr{'urlfilter local file redirection'}</b></td>
1352 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable rewrite rules'}:</td>
1353 <td width='12%'><input type='checkbox' name='ENABLE_REWRITE' $checked {'ENABLE_REWRITE'}{'on'} /></td>
1358 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter manage repository'}'></td>
1365 <table width='100%'>
1367 <td colspan='2'><b> $Lang ::tr{'urlfilter network access control'}</b></td>
1372 <td colspan='2'> $Lang ::tr{'urlfilter unfiltered clients'} <img src='/blob.gif' alt='*' /></td>
1373 <td colspan='2'> $Lang ::tr{'urlfilter banned clients'} <img src='/blob.gif' alt='*' /></td>
1376 <td colspan='2' width='50%'><textarea name='UNFILTERED_CLIENTS' cols='32' rows='6' wrap='off'>
1380 # transform from pre1.8 client definitions
1381 $filtersettings { 'UNFILTERED_CLIENTS' } =~ s/^\s+//g ;
1382 $filtersettings { 'UNFILTERED_CLIENTS' } =~ s/\s+$//g ;
1383 $filtersettings { 'UNFILTERED_CLIENTS' } =~ s/\s+-\s+/-/g ;
1384 $filtersettings { 'UNFILTERED_CLIENTS' } =~ s/\s+/ /g ;
1386 @clients = split ( / / , $filtersettings { 'UNFILTERED_CLIENTS' });
1387 undef $filtersettings { 'UNFILTERED_CLIENTS' };
1388 foreach ( @clients ) { $filtersettings { 'UNFILTERED_CLIENTS' } .= " $_ \n " ; }
1390 print $filtersettings { 'UNFILTERED_CLIENTS' };
1394 <td colspan='2' width='50%'><textarea name='BANNED_CLIENTS' cols='32' rows='6' wrap='off'>
1398 # transform from pre1.8 client definitions
1399 $filtersettings { 'BANNED_CLIENTS' } =~ s/^\s+//g ;
1400 $filtersettings { 'BANNED_CLIENTS' } =~ s/\s+$//g ;
1401 $filtersettings { 'BANNED_CLIENTS' } =~ s/\s+-\s+/-/g ;
1402 $filtersettings { 'BANNED_CLIENTS' } =~ s/\s+/ /g ;
1404 @clients = split ( / / , $filtersettings { 'BANNED_CLIENTS' });
1405 undef $filtersettings { 'BANNED_CLIENTS' };
1406 foreach ( @clients ) { $filtersettings { 'BANNED_CLIENTS' } .= " $_ \n " ; }
1408 print $filtersettings { 'BANNED_CLIENTS' };
1415 <table width='100%'>
1417 <td colspan='4'><b> $Lang ::tr{'urlfilter timebased access control'}</b></td>
1420 <td width='25%'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter set time constraints'}'></td>
1421 <td width='25%'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter set user quota'}'></td>
1427 <table width='100%'>
1429 <td colspan='4'><b> $Lang ::tr{'urlfilter block settings'}</b></td>
1432 <td width='25%' class='base'> $Lang ::tr{'urlfilter show category'}:</td>
1433 <td width='12%'><input type='checkbox' name='SHOW_CATEGORY' $checked {'SHOW_CATEGORY'}{'on'} /></td>
1434 <td width='25%' class='base'> $Lang ::tr{'urlfilter redirectpage'}: <img src='/blob.gif' alt='*' /></td>
1435 <td><input type='text' name='REDIRECT_PAGE' value=' $filtersettings {'REDIRECT_PAGE'}' size='40' /></td>
1438 <td class='base'> $Lang ::tr{'urlfilter show url'}:</td>
1439 <td><input type='checkbox' name='SHOW_URL' $checked {'SHOW_URL'}{'on'} /></td>
1440 <td class='base'> $Lang ::tr{'urlfilter msg text 1'}: <img src='/blob.gif' alt='*' /></td>
1441 <td><input type='text' name='MSG_TEXT_1' value=' $filtersettings {'MSG_TEXT_1'}' size='40' /></td>
1444 <td class='base'> $Lang ::tr{'urlfilter show ip'}:</td>
1445 <td><input type='checkbox' name='SHOW_IP' $checked {'SHOW_IP'}{'on'} /></td>
1446 <td class='base'> $Lang ::tr{'urlfilter msg text 2'}: <img src='/blob.gif' alt='*' /></td>
1447 <td><input type='text' name='MSG_TEXT_2' value=' $filtersettings {'MSG_TEXT_2'}' size='40' /></td>
1450 <td class='base'> $Lang ::tr{'urlfilter show dnserror'}:</td>
1451 <td><input type='checkbox' name='ENABLE_DNSERROR' $checked {'ENABLE_DNSERROR'}{'on'} /></td>
1452 <td class='base'> $Lang ::tr{'urlfilter msg text 3'}: <img src='/blob.gif' alt='*' /></td>
1453 <td><input type='text' name='MSG_TEXT_3' value=' $filtersettings {'MSG_TEXT_3'}' size='40' /></td>
1456 <td class='base'> $Lang ::tr{'urlfilter enable jpeg'}:</td>
1457 <td><input type='checkbox' name='ENABLE_JPEG' $checked {'ENABLE_JPEG'}{'on'} /></td>
1463 <table width='100%'>
1465 <td colspan='4'><b> $Lang ::tr{'urlfilter advanced settings'}</b></td>
1468 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable expression lists'}:</td>
1469 <td width='12%'><input type='checkbox' name='ENABLE_EXPR_LISTS' $checked {'ENABLE_EXPR_LISTS'}{'on'} /></td>
1470 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable log'}:</td>
1471 <td><input type='checkbox' name='ENABLE_LOG' $checked {'ENABLE_LOG'}{'on'} /></td>
1474 <td class='base'> $Lang ::tr{'urlfilter safesearch'}:</td>
1475 <td><input type='checkbox' name='ENABLE_SAFESEARCH' $checked {'ENABLE_SAFESEARCH'}{'on'} /></td>
1476 <td class='base'> $Lang ::tr{'urlfilter username log'}:</td>
1477 <td><input type='checkbox' name='ENABLE_USERNAME_LOG' $checked {'ENABLE_USERNAME_LOG'}{'on'} /></td>
1480 <td class='base'> $Lang ::tr{'urlfilter empty ads'}:</td>
1481 <td><input type='checkbox' name='ENABLE_EMPTY_ADS' $checked {'ENABLE_EMPTY_ADS'}{'on'} /></td>
1482 <td class='base'> $Lang ::tr{'urlfilter category log'}:</td>
1483 <td><input type='checkbox' name='ENABLE_CATEGORY_LOG' $checked {'ENABLE_CATEGORY_LOG'}{'on'} /></td>
1486 <td class='base'> $Lang ::tr{'urlfilter block ip'}:</td>
1487 <td><input type='checkbox' name='BLOCK_IP_ADDR' $checked {'BLOCK_IP_ADDR'}{'on'} /></td>
1490 <td class='base'> $Lang ::tr{'urlfilter block all'}:</td>
1491 <td><input type='checkbox' name='BLOCK_ALL' $checked {'BLOCK_ALL'}{'on'} /></td>
1492 <td class='base'> $Lang ::tr{'urlfilter whitelist always allowed'}:</td>
1493 <td><input type='checkbox' name='ENABLE_GLOBAL_WHITELIST' $checked {'ENABLE_GLOBAL_WHITELIST'}{'on'} /></td>
1497 <table width='100%'>
1500 <img src='/blob.gif' align='top' alt='*' />
1501 <font class='base'> $Lang ::tr{'this field may be blank'}</font>
1503 <td align='right'>
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'}</td>
1881 <td width='1%'> </td>
1882 <td width='5%'> $Lang ::tr{'urlfilter dst'} <img src='/blob.gif' alt='*'><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'} <img src='/blob.gif' alt='*'></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{'this field may be blank'}</font></td>
1985 <td width='1%' align='right'><img src='/blob.gif' align='top' alt='*' /><img src='/blob.gif' align='top' alt='*' /> </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'}:</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'}:</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'}:</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></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
:: writehash
( "${General::swroot}/urlfilter/settings" , \
%filtersettings );
2548 # -------------------------------------------------------------------
2550 sub readblockcategories
2554 & getblockcategory
( $dbdir );
2556 foreach ( @categories ) { $_ = substr ( $_ , length ( $dbdir )+ 1 ); }
2558 @filtergroups = @categories ;
2560 foreach ( @filtergroups ) {
2567 # -------------------------------------------------------------------
2569 sub getblockcategory
2571 foreach $category (< $_ [ 0 ]/*>)
2575 if ((- e
" $category /domains" ) || (- e
" $category /urls" ))
2577 unless ( $category =~ /\bcustom\b/ ) { push ( @categories , $category ); }
2579 & getblockcategory
( $category );
2584 # -------------------------------------------------------------------
2588 if (- e
" $dbdir /custom/blocked/domains" ) {
2589 open ( FILE
, " $dbdir /custom/blocked/domains" );
2590 delete $filtersettings { 'CUSTOM_BLACK_DOMAINS' };
2591 while (< FILE
>) { $filtersettings { 'CUSTOM_BLACK_DOMAINS' } .= $_ };
2595 if (- e
" $dbdir /custom/blocked/urls" ) {
2596 open ( FILE
, " $dbdir /custom/blocked/urls" );
2597 delete $filtersettings { 'CUSTOM_BLACK_URLS' };
2598 while (< FILE
>) { $filtersettings { 'CUSTOM_BLACK_URLS' } .= $_ };
2602 if (- e
" $dbdir /custom/blocked/expressions" ) {
2603 open ( FILE
, " $dbdir /custom/blocked/expressions" );
2604 delete $filtersettings { 'CUSTOM_EXPRESSIONS' };
2605 while (< FILE
>) { $filtersettings { 'CUSTOM_EXPRESSIONS' } .= $_ };
2609 if (- e
" $dbdir /custom/allowed/domains" ) {
2610 open ( FILE
, " $dbdir /custom/allowed/domains" );
2611 delete $filtersettings { 'CUSTOM_WHITE_DOMAINS' };
2612 while (< FILE
>) { $filtersettings { 'CUSTOM_WHITE_DOMAINS' } .= $_ };
2615 if (- e
" $dbdir /custom/allowed/urls" ) {
2616 open ( FILE
, " $dbdir /custom/allowed/urls" );
2617 delete $filtersettings { 'CUSTOM_WHITE_URLS' };
2618 while (< FILE
>) { $filtersettings { 'CUSTOM_WHITE_URLS' } .= $_ };
2623 # -------------------------------------------------------------------
2625 sub aggregatedconstraints
2645 @tmp1 = split ( /\,/ , $x );
2649 @tmp2 = split ( /\,/ );
2650 if (( $tmp1 [ 15 ] eq 'on' ) && ( $tmp2 [ 15 ] eq 'on' ))
2652 if (( $tmp1 [ 0 ] eq $tmp2 [ 0 ]) && ( $tmp1 [ 12 ] eq $tmp2 [ 12 ]) && ( $tmp1 [ 13 ] eq $tmp2 [ 13 ]) && ( $tmp1 [ 14 ] eq $tmp2 [ 14 ]))
2655 $tmp2 [ 16 ] .= " weekly " ;
2656 if ( $tmp1 [ 1 ] eq 'on' ) { $tmp2 [ 16 ] .= "m" ; }
2657 if ( $tmp1 [ 2 ] eq 'on' ) { $tmp2 [ 16 ] .= "t" ; }
2658 if ( $tmp1 [ 3 ] eq 'on' ) { $tmp2 [ 16 ] .= "w" ; }
2659 if ( $tmp1 [ 4 ] eq 'on' ) { $tmp2 [ 16 ] .= "h" ; }
2660 if ( $tmp1 [ 5 ] eq 'on' ) { $tmp2 [ 16 ] .= "f" ; }
2661 if ( $tmp1 [ 6 ] eq 'on' ) { $tmp2 [ 16 ] .= "a" ; }
2662 if ( $tmp1 [ 7 ] eq 'on' ) { $tmp2 [ 16 ] .= "s" ; }
2663 $tmp2 [ 16 ] .= " $tmp1 [8]: $tmp1 [9]- $tmp1 [10]: $tmp1 [11] \n " ;
2664 $_ = join ( "," , @tmp2 );
2671 $tmp1 [ 16 ] .= " weekly " ;
2672 if ( $tmp1 [ 1 ] eq 'on' ) { $tmp1 [ 16 ] .= "m" ; }
2673 if ( $tmp1 [ 2 ] eq 'on' ) { $tmp1 [ 16 ] .= "t" ; }
2674 if ( $tmp1 [ 3 ] eq 'on' ) { $tmp1 [ 16 ] .= "w" ; }
2675 if ( $tmp1 [ 4 ] eq 'on' ) { $tmp1 [ 16 ] .= "h" ; }
2676 if ( $tmp1 [ 5 ] eq 'on' ) { $tmp1 [ 16 ] .= "f" ; }
2677 if ( $tmp1 [ 6 ] eq 'on' ) { $tmp1 [ 16 ] .= "a" ; }
2678 if ( $tmp1 [ 7 ] eq 'on' ) { $tmp1 [ 16 ] .= "s" ; }
2679 $tmp1 [ 16 ] .= " $tmp1 [8]: $tmp1 [9]- $tmp1 [10]: $tmp1 [11] \n " ;
2680 $x = join ( "," , @tmp1 );
2690 # -------------------------------------------------------------------
2696 foreach $category (< $bldir /*>)
2699 system ( "chmod 755 $category &> /dev/null" );
2700 foreach $blacklist (< $category /*>)
2702 if (- f
$blacklist ) { system ( "chmod 644 $blacklist &> /dev/null" ); }
2703 if (- d
$blacklist ) { system ( "chmod 755 $blacklist &> /dev/null" ); }
2705 system ( "chmod 666 $category /*.db &> /dev/null" );
2706 & setpermissions
( $category );
2711 # -------------------------------------------------------------------
2715 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\)\$" ;
2716 my $audiovideo = " \\ .\(aiff|asf|avi|dif|divx|mov|movie|mp3|mpe?g?|mpv2|ogg|ra?m|snd|qt|wav|wma|wmf|wmv\)\$" ;
2717 my $archives = " \\ .\(bin|bz2|cab|cdr|dmg|gz|hqx|rar|smi|sit|sea|tar|tgz|zip\)\$" ;
2719 my $ident = " anonymous" ;
2732 if (!(- d
" $dbdir /custom" )) { mkdir ( " $dbdir /custom" ) }
2733 if (!(- d
" $dbdir /custom/blocked" )) { mkdir ( " $dbdir /custom/blocked" ) }
2734 if (!(- d
" $dbdir /custom/allowed" )) { mkdir ( " $dbdir /custom/allowed" ) }
2736 open ( FILE
, ">/ $dbdir /custom/blocked/domains" );
2737 print FILE
$filtersettings { 'CUSTOM_BLACK_DOMAINS' };
2739 open ( FILE
, ">/ $dbdir /custom/blocked/urls" );
2740 print FILE
$filtersettings { 'CUSTOM_BLACK_URLS' };
2742 open ( FILE
, ">/ $dbdir /custom/blocked/expressions" );
2743 print FILE
$filtersettings { 'CUSTOM_EXPRESSIONS' };
2745 open ( FILE
, ">/ $dbdir /custom/blocked/files" );
2746 if ( $filtersettings { 'BLOCK_EXECUTABLES' } eq 'on' ) { print FILE
" $executables \n " ; }
2747 if ( $filtersettings { 'BLOCK_AUDIO-VIDEO' } eq 'on' ) { print FILE
" $audiovideo \n " ; }
2748 if ( $filtersettings { 'BLOCK_ARCHIVES' } eq 'on' ) { print FILE
" $archives \n " ; }
2750 open ( FILE
, ">/ $dbdir /custom/allowed/domains" );
2751 print FILE
$filtersettings { 'CUSTOM_WHITE_DOMAINS' };
2753 open ( FILE
, ">/ $dbdir /custom/allowed/urls" );
2754 print FILE
$filtersettings { 'CUSTOM_WHITE_URLS' };
2757 if ( $filtersettings { 'ENABLE_USERNAME_LOG' } eq 'on' ) { $ident = "" ; }
2759 if ( $filtersettings { 'REDIRECT_PAGE' } eq '' )
2761 if (( $filtersettings { 'SHOW_CATEGORY' } eq 'on' ) || ( $filtersettings { 'SHOW_URL' } eq 'on' ) || ( $filtersettings { 'SHOW_IP' } eq 'on' )) {
2762 if ( $filtersettings { 'SHOW_CATEGORY' } eq 'on' ) { $redirect .= "&category= %t " ; }
2763 if ( $filtersettings { 'SHOW_URL' } eq 'on' ) { $redirect .= "&url= %u " ; }
2764 if ( $filtersettings { 'SHOW_IP' } eq 'on' ) { $redirect .= "&ip= %a " ; }
2765 $redirect =~ s/^&/?/ ;
2766 $redirect = "http:\/\/ $netsettings {'GREEN_ADDRESS'}: $http_port \/redirect.cgi" . $redirect ;
2768 $redirect = "http:\/\/ $netsettings {'GREEN_ADDRESS'}: $http_port \/redirect.cgi" ;
2770 } else { $redirect = $filtersettings { 'REDIRECT_PAGE' }; }
2772 if ( $filtersettings { 'ENABLE_DNSERROR' } eq 'on' ) { $redirect = "302:http://0.0.0.0" ; }
2776 if ( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' )
2778 $defaultrule .= "custom-allowed " ;
2780 if ( $filtersettings { 'BLOCK_ALL' } eq 'on' )
2782 $defaultrule .= "none" ;
2786 if ( $filtersettings { 'BLOCK_IP_ADDR' } eq 'on' )
2788 $defaultrule .= "!in-addr " ;
2790 for ( $i = 0 ; $i <= @filtergroups ; $i ++) {
2791 if ( $filtersettings { @filtergroups [ $i ]} eq 'on' )
2793 $defaultrule .= "! @categories [ $i ] " ;
2796 if ( $filtersettings { 'ENABLE_CUSTOM_BLACKLIST' } eq 'on' )
2798 $defaultrule .= "!custom-blocked " ;
2800 if ( $filtersettings { 'ENABLE_CUSTOM_EXPRESSIONS' } eq 'on' )
2802 $defaultrule .= "!custom-expressions " ;
2804 if (( $filtersettings { 'BLOCK_EXECUTABLES' } eq 'on' ) ||
2805 ( $filtersettings { 'BLOCK_AUDIO-VIDEO' } eq 'on' ) ||
2806 ( $filtersettings { 'BLOCK_ARCHIVES' } eq 'on' ))
2808 $defaultrule .= "!files " ;
2810 $defaultrule .= "any" ;
2813 $defaultrule =~ s/\// _
/ g
;
2815 open ( FILE
, ">${General::swroot}/urlfilter/squidGuard.conf" ) or die "Unable to write squidGuard.conf file" ;
2818 print FILE
"logdir /var/log/squidGuard \n " ;
2819 print FILE
"dbhome $dbdir \n\n " ;
2821 undef @repositoryfiles ;
2822 if ( $filtersettings { 'ENABLE_REWRITE' } eq 'on' )
2824 @repositorylist = < $repository /*>;
2825 foreach ( @repositorylist )
2827 if (!- d
) { push ( @repositoryfiles , substr ( $_ , rindex ( $_ , "/" )+ 1 )); }
2831 if ((( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles )) || ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' ))
2833 print FILE
"rewrite rew-rule-1 { \n " ;
2835 if (( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles ))
2837 print FILE
" # rewrite localfiles \n " ;
2838 foreach ( @repositoryfiles )
2840 print FILE
" s@.*/ $_ \$\ @http :// $netsettings {'GREEN_ADDRESS'}: $http_port /repository/ $_ \ @i \n " ;
2844 if ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' )
2846 print FILE
" # rewrite safesearch \n " ;
2847 print FILE
" s@(.* \\ Wgoogle \\ . \\ w+/(webhp|search|imghp|images|grphp|groups|frghp|froogle) \\ ?)(.*)( \\ bsafe= \\ w+)(.*)\@ \\ 1 \\ 3safe=strict \\ 5\ @i \n " ;
2848 print FILE
" s@(.* \\ Wgoogle \\ . \\ w+/(webhp|search|imghp|images|grphp|groups|frghp|froogle) \\ ?)(.*)\@ \\ 1safe=strict \\ \& \\ 3\ @i \n " ;
2849 print FILE
" s@(.* \\ Wsearch \\ .yahoo \\ . \\ w+/search \\ W)(.*)( \\ bvm= \\ w+)(.*)\@ \\ 1 \\ 2vm=r \\ 4\ @i \n " ;
2850 print FILE
" s@(.* \\ Wsearch \\ .yahoo \\ . \\ w+/search \\ W.*)\@ \\ 1 \\ \&vm=r\ @i \n " ;
2851 print FILE
" s@(.* \\ Walltheweb \\ .com/customize \\ ?)(.*)( \\ bcopt_offensive= \\ w+)(.*)\@ \\ 1 \\ 2copt_offensive=on \\ 4\ @i \n " ;
2856 if ((!( $filtersettings { 'UNFILTERED_CLIENTS' } eq '' )) && ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' )) {
2857 print FILE
"rewrite rew-rule-2 { \n " ;
2858 if (( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles ))
2860 print FILE
" # rewrite localfiles \n " ;
2861 foreach ( @repositoryfiles )
2863 print FILE
" s@.*/ $_ \$\ @http :// $netsettings {'GREEN_ADDRESS'}: $http_port /repository/ $_ \ @i \n " ;
2866 print FILE
" # rewrite nothing \n " ;
2872 if (!( $filtersettings { 'UNFILTERED_CLIENTS' } eq '' )) {
2873 print FILE
"src unfiltered { \n " ;
2874 print FILE
" ip $filtersettings {'UNFILTERED_CLIENTS'} \n " ;
2877 if (!( $filtersettings { 'BANNED_CLIENTS' } eq '' )) {
2878 print FILE
"src banned { \n " ;
2879 print FILE
" ip $filtersettings {'BANNED_CLIENTS'} \n " ;
2880 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
2882 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
2884 print FILE
" logfile " . $ident . " banned.log \n " ;
2886 print FILE
" logfile " . $ident . " urlfilter.log \n " ;
2908 $uq [ 0 ] = $uq [ 0 ] * 60 ;
2909 if ( $uq [ 1 ] eq '0' ) {
2910 if ( $uq [ 2 ] eq 'hourly' ) { $uq [ 1 ] = 3600 }
2911 if ( $uq [ 2 ] eq 'daily' ) { $uq [ 1 ] = 86400 }
2912 if ( $uq [ 2 ] eq 'weekly' ) { $uq [ 1 ] = 604800 }
2915 print FILE
"src quota- $idx { \n " ;
2916 print FILE
" user $uq [3] \n " ;
2917 print FILE
" userquota $uq [0] $uq [1] $uq [2] \n " ;
2925 @tclist = & aggregatedconstraints
;
2934 if ( $tc [ 15 ] eq 'on' )
2937 print FILE
"src network- $idx { \n " ;
2938 @clients = split ( / / , $tc [ 12 ]);
2939 @temp = split ( /-/ , $clients [ 0 ]);
2940 if ( (& General
:: validipormask
( $temp [ 0 ])) || (& General
:: validipandmask
( $temp [ 0 ])))
2942 print FILE
" ip $tc [12] \n " ;
2945 @clients = split ( / / , $tc [ 12 ]);
2946 foreach $line ( @clients )
2948 $line =~ s/(^\w+)\\(\w+$)/$1%5c$2/ ;
2949 print FILE
" $line " ;
2953 if (( $filtersettings { 'ENABLE_LOG' } eq 'on' ) && ( $tc [ 14 ] eq 'block' ) && ( $tc [ 13 ] eq 'any' ))
2955 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
2957 print FILE
" logfile " . $ident . " timeconst.log \n " ;
2959 print FILE
" logfile " . $ident . " urlfilter.log \n " ;
2971 if ( $tc [ 15 ] eq 'on' )
2974 print FILE
"time constraint- $idx { \n " ;
2975 print FILE
" $tc [16] \n " ;
2981 foreach $category ( @categories ) {
2982 $blacklist = $category ;
2983 $category =~ s/\// _
/ g
;
2984 if ( $filtersettings { "FILTER_" . uc ( $category )} ne "on" ){ next ;}
2985 print FILE
"dest $category { \n " ;
2986 if (- e
" $dbdir / $blacklist /domains" ) {
2987 print FILE
" domainlist $blacklist \/domains \n " ;
2989 if (- e
" $dbdir / $blacklist /urls" ) {
2990 print FILE
" urllist $blacklist \/urls \n " ;
2992 if ((- e
" $dbdir / $blacklist /expressions" ) && ( $filtersettings { 'ENABLE_EXPR_LISTS' } eq 'on' )) {
2993 print FILE
" expressionlist $blacklist \/expressions \n " ;
2995 if ((( $category eq 'ads' ) || ( $category eq 'adv' )) && ( $filtersettings { 'ENABLE_EMPTY_ADS' } eq 'on' ))
2997 print FILE
" redirect http:\/\/ $netsettings {'GREEN_ADDRESS'}: $http_port \/images/urlfilter/1x1.gif \n " ;
2999 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
3001 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
3003 print FILE
" logfile $ident $category .log \n " ;
3005 print FILE
" logfile $ident urlfilter.log \n " ;
3009 $category = $blacklist ;
3012 print FILE
"dest files { \n " ;
3013 print FILE
" expressionlist custom\/blocked\/files \n " ;
3014 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
3016 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
3018 print FILE
" logfile $ident files.log \n " ;
3020 print FILE
" logfile $ident urlfilter.log \n " ;
3025 print FILE
"dest custom-allowed { \n " ;
3026 print FILE
" domainlist custom\/allowed\/domains \n " ;
3027 print FILE
" urllist custom\/allowed\/urls \n " ;
3030 print FILE
"dest custom-blocked { \n " ;
3031 print FILE
" domainlist custom\/blocked\/domains \n " ;
3032 print FILE
" urllist custom\/blocked\/urls \n " ;
3033 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
3035 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
3037 print FILE
" logfile $ident custom.log \n " ;
3039 print FILE
" logfile $ident urlfilter.log \n " ;
3044 print FILE
"dest custom-expressions { \n " ;
3045 print FILE
" expressionlist custom\/blocked\/expressions \n " ;
3046 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
3048 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
3050 print FILE
" logfile $ident custom.log \n " ;
3052 print FILE
" logfile $ident urlfilter.log \n " ;
3057 print FILE
"acl { \n " ;
3058 if (!( $filtersettings { 'UNFILTERED_CLIENTS' } eq '' )) {
3059 print FILE
" unfiltered { \n " ;
3060 print FILE
" pass all \n " ;
3061 if ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' )
3063 print FILE
" rewrite rew-rule-2 \n " ;
3065 print FILE
" } \n\n " ;
3067 if (!( $filtersettings { 'BANNED_CLIENTS' } eq '' )) {
3068 print FILE
" banned { \n " ;
3069 print FILE
" pass " ;
3070 if (( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'on' ))
3072 print FILE
"custom-allowed " ;
3074 print FILE
"none \n " ;
3075 print FILE
" } \n\n " ;
3092 $qredirect = $redirect ;
3093 $qredirect =~ s/\%t/\%q\%20-\%20\%i/ ;
3094 print FILE
" quota- $idx { \n " ;
3095 print FILE
" pass " ;
3096 if (( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'on' ))
3098 print FILE
"custom-allowed " ;
3100 print FILE
"none \n " ;
3101 unless ( $redirect eq $qredirect ) { print FILE
" redirect $qredirect \n " ; }
3102 print FILE
" } \n\n " ;
3114 @ec = split ( /\|/ , $tc [ 13 ]);
3115 foreach ( @ec ) { s/\// _
/ g
; }
3116 if ( $tc [ 15 ] eq 'on' )
3119 print FILE
" network- $idx $tc [0] constraint- $idx { \n " ;
3120 print FILE
" pass " ;
3122 if ( $filtersettings { 'BLOCK_ALL' } eq 'on' )
3124 if ( $tc [ 14 ] eq 'block' )
3126 if (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' )) {
3127 if (( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'on' ))
3129 print FILE
"custom-allowed " ;
3133 print FILE
$defaultrule ;
3140 print FILE
$defaultrule unless (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ));
3143 if ( $tc [ 14 ] eq 'block' )
3145 $tcrule = $defaultrule ;
3146 if ( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) {
3147 $tcrule =~ s/custom-allowed // ;
3148 print FILE
"custom-allowed " unless (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'off' ));
3150 if (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' )) {
3155 print FILE
"! $_ " unless ( index ( $defaultrule , "!" . $_ . " " ) ge 0 );
3158 print FILE
$tcrule unless (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ));
3160 $tcrule = $defaultrule ;
3161 if (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ))
3167 $tcrule = " $_ " . $tcrule unless ( index ( $defaultrule , "!" . $_ . " " ) ge 0 );
3168 $tcrule =~ s/!$_ // ;
3177 print FILE
" } \n\n " ;
3182 print FILE
" default { \n " ;
3183 print FILE
" pass $defaultrule \n " ;
3184 if (( $filtersettings { 'ENABLE_LOG' } eq 'on' ) && ( $filtersettings { 'BLOCK_ALL' } eq 'on' ))
3186 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
3188 print FILE
" logfile" . $ident . " default.log \n " ;
3190 print FILE
" logfile" . $ident . " urlfilter.log \n " ;
3193 if ((( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles )) || ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' ))
3195 print FILE
" rewrite rew-rule-1 \n " ;
3197 print FILE
" redirect $redirect \n " ;
3204 # -------------------------------------------------------------------