]>
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 ( '/usr/local/bin/squidctrl restart >/dev/null 2>&1' );
360 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter set time constraints' }) { $tcsettings { 'TCMODE' } = 'on' }
362 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'add' }))
364 $tcsettings { 'TCMODE' }= 'on' ;
366 if (! $tcsettings { 'DST' })
368 $errormessage = $Lang :: tr
{ 'urlfilter dst error' };
371 if (! $tcsettings { 'SRC' })
373 $errormessage = $Lang :: tr
{ 'urlfilter src error' };
376 if (!( $tcsettings { 'TO_HOUR' }. $tcsettings { 'TO_MINUTE' } gt $tcsettings { 'FROM_HOUR' }. $tcsettings { 'FROM_MINUTE' }))
378 $errormessage = $Lang :: tr
{ 'urlfilter timespace error' };
381 if (!(( $tcsettings { 'MON' } eq 'on' ) || ( $tcsettings { 'TUE' } eq 'on' ) || ( $tcsettings { 'WED' } eq 'on' ) || ( $tcsettings { 'THU' } eq 'on' ) || ( $tcsettings { 'FRI' } eq 'on' ) || ( $tcsettings { 'SAT' } eq 'on' ) || ( $tcsettings { 'SUN' } eq 'on' )))
383 $errormessage = $Lang :: tr
{ 'urlfilter weekday error' };
388 # transform to pre1.8 client definitions
389 @clients = split ( /\n/ , $tcsettings { 'SRC' });
390 undef $tcsettings { 'SRC' };
393 s/^\s+//g ; s/\s+$//g ; s/\s+-\s+/-/g ; s/\s+/ /g ; s/\n//g ;
394 $tcsettings { 'SRC' } .= " $_ " ;
396 $tcsettings { 'SRC' } =~ s/\s+$// ;
398 if ( $tcsettings { 'DST' } =~ /^any/ ) { $tcsettings { 'DST' } = 'any' ; }
399 if ( $tcsettings { 'ENABLERULE' } eq 'on' ) { $tcsettings { 'ACTIVE' } = $tcsettings { 'ENABLERULE' }; } else { $tcsettings { 'ACTIVE' } = 'off' }
401 $tcsettings { 'ENABLERULE' } = 'on' ;
402 if ( $tcsettings { 'EDITING' } eq 'no' ) {
403 open ( FILE
, ">> $tcfile " );
405 print FILE
" $tcsettings {'DEFINITION'}, $tcsettings {'MON'}, $tcsettings {'TUE'}, $tcsettings {'WED'}, $tcsettings {'THU'}, $tcsettings {'FRI'}, $tcsettings {'SAT'}, $tcsettings {'SUN'}, $tcsettings {'FROM_HOUR'}, $tcsettings {'FROM_MINUTE'}, $tcsettings {'TO_HOUR'}, $tcsettings {'TO_MINUTE'}, $tcsettings {'SRC'}, $tcsettings {'DST'}, $tcsettings {'ACCESS'}, $tcsettings {'ACTIVE'}, $tcsettings {'COMMENT'} \n " ;
407 open ( FILE
, "> $tcfile " );
410 foreach $line ( @tclist )
413 if ( $tcsettings { 'EDITING' } eq $id ) {
414 print FILE
" $tcsettings {'DEFINITION'}, $tcsettings {'MON'}, $tcsettings {'TUE'}, $tcsettings {'WED'}, $tcsettings {'THU'}, $tcsettings {'FRI'}, $tcsettings {'SAT'}, $tcsettings {'SUN'}, $tcsettings {'FROM_HOUR'}, $tcsettings {'FROM_MINUTE'}, $tcsettings {'TO_HOUR'}, $tcsettings {'TO_MINUTE'}, $tcsettings {'SRC'}, $tcsettings {'DST'}, $tcsettings {'ACCESS'}, $tcsettings {'ACTIVE'}, $tcsettings {'COMMENT'} \n " ;
415 } else { print FILE
" $line " ; }
420 $tcsettings { 'CHANGED' }= 'yes' ;
421 $tcsettings { 'TCMODE' }= 'on' ;
424 if ( $tcsettings { 'EDITING' } ne 'no' )
426 $tcsettings { 'ACTION' } = $Lang :: tr
{ 'edit' };
427 $tcsettings { 'ID' } = $tcsettings { 'EDITING' };
432 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter copy rule' }) && (! $errormessage ))
435 foreach $line ( @tclist )
438 if ( $tcsettings { 'ID' } eq $id )
441 @temp = split ( /\,/ , $line );
442 $tcsettings { 'DEFINITION' } = $temp [ 0 ];
443 $tcsettings { 'MON' } = $temp [ 1 ];
444 $tcsettings { 'TUE' } = $temp [ 2 ];
445 $tcsettings { 'WED' } = $temp [ 3 ];
446 $tcsettings { 'THU' } = $temp [ 4 ];
447 $tcsettings { 'FRI' } = $temp [ 5 ];
448 $tcsettings { 'SAT' } = $temp [ 6 ];
449 $tcsettings { 'SUN' } = $temp [ 7 ];
450 $tcsettings { 'FROM_HOUR' } = $temp [ 8 ];
451 $tcsettings { 'FROM_MINUTE' } = $temp [ 9 ];
452 $tcsettings { 'TO_HOUR' } = $temp [ 10 ];
453 $tcsettings { 'TO_MINUTE' } = $temp [ 11 ];
454 $tcsettings { 'SRC' } = $temp [ 12 ];
455 $tcsettings { 'DST' } = $temp [ 13 ];
456 $tcsettings { 'ACCESS' } = $temp [ 14 ];
457 $tcsettings { 'ENABLERULE' } = $temp [ 15 ];
458 $tcsettings { 'COMMENT' } = $temp [ 16 ];
461 $tcsettings { 'TCMODE' }= 'on' ;
464 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'remove' }))
467 open ( FILE
, "> $tcfile " );
469 foreach $line ( @tclist )
472 unless ( $tcsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
475 $tcsettings { 'CHANGED' }= 'yes' ;
476 $tcsettings { 'TCMODE' }= 'on' ;
479 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter restart' }))
481 if (!( $proxysettings { 'ENABLE_FILTER' } eq 'on' ))
483 $errormessage = $Lang :: tr
{ 'urlfilter not enabled' };
485 if ((!(- e
"${General::swroot}/proxy/enable" )) && (!(- e
"${General::swroot}/proxy/enable_blue" )))
487 $errormessage = $Lang :: tr
{ 'urlfilter web proxy service required' };
490 if (! $errormessage ) { system ( '/usr/local/bin/squidctrl restart >/dev/null 2>&1' ); }
491 $tcsettings { 'TCMODE' }= 'on' ;
494 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }))
496 open ( FILE
, "> $tcfile " );
499 foreach $line ( @tclist )
502 unless ( $tcsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
506 @temp = split ( /\,/ , $line );
507 if ( $temp [ 15 ] eq 'on' ) { $temp [ 15 ] = 'off' ; } else { $temp [ 15 ] = 'on' }
508 print FILE
" $temp [0], $temp [1], $temp [2], $temp [3], $temp [4], $temp [5], $temp [6], $temp [7], $temp [8], $temp [9], $temp [10], $temp [11], $temp [12], $temp [13], $temp [14], $temp [15], $temp [16] \n " ;
512 $tcsettings { 'CHANGED' }= 'yes' ;
513 $tcsettings { 'TCMODE' }= 'on' ;
516 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) && (! $errormessage ))
519 foreach $line ( @tclist )
522 if ( $tcsettings { 'ID' } eq $id )
525 @temp = split ( /\,/ , $line );
526 $tcsettings { 'DEFINITION' } = $temp [ 0 ];
527 $tcsettings { 'MON' } = $temp [ 1 ];
528 $tcsettings { 'TUE' } = $temp [ 2 ];
529 $tcsettings { 'WED' } = $temp [ 3 ];
530 $tcsettings { 'THU' } = $temp [ 4 ];
531 $tcsettings { 'FRI' } = $temp [ 5 ];
532 $tcsettings { 'SAT' } = $temp [ 6 ];
533 $tcsettings { 'SUN' } = $temp [ 7 ];
534 $tcsettings { 'FROM_HOUR' } = $temp [ 8 ];
535 $tcsettings { 'FROM_MINUTE' } = $temp [ 9 ];
536 $tcsettings { 'TO_HOUR' } = $temp [ 10 ];
537 $tcsettings { 'TO_MINUTE' } = $temp [ 11 ];
538 $tcsettings { 'SRC' } = $temp [ 12 ];
539 $tcsettings { 'DST' } = $temp [ 13 ];
540 $tcsettings { 'ACCESS' } = $temp [ 14 ];
541 $tcsettings { 'ENABLERULE' } = $temp [ 15 ];
542 $tcsettings { 'COMMENT' } = $temp [ 16 ];
545 $tcsettings { 'TCMODE' }= 'on' ;
548 if ((! $errormessage ) && (!( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter copy rule' })) && (!( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }))) {
549 $tcsettings { 'ENABLERULE' }= 'on' ;
550 $tcsettings { 'TO_HOUR' }= '24' ;
553 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter set user quota' }) { $uqsettings { 'UQMODE' } = 'on' }
555 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'add' }))
557 $uqsettings { 'UQMODE' }= 'on' ;
559 if ((!( $uqsettings { 'TIME_QUOTA' } =~ /^\d+/ )) || ( $uqsettings { 'TIME_QUOTA' } < '1' ))
561 $errormessage = $Lang :: tr
{ 'urlfilter quota time error' };
564 @temp = split ( /\n/ , $uqsettings { 'QUOTA_USERS' });
565 undef $uqsettings { 'QUOTA_USERS' };
568 s/^\s+//g ; s/\s+$//g ;
569 if ( $_ ) { $uqsettings { 'QUOTA_USERS' } .= $_ . " \n " ; }
572 if ( $uqsettings { 'QUOTA_USERS' } eq '' )
574 $errormessage = $Lang :: tr
{ 'urlfilter quota user error' };
577 $_ = $uqsettings { 'QUOTA_USERS' };
579 my $quota_users = $_ ;
581 if ( $uqsettings { 'QUOTA_USERS' } =~ /\\/ )
583 $errormessage = $Lang :: tr
{ 'urlfilter invalid user error' };
586 if (! $errormessage ) {
587 if ( $uqsettings { 'ENABLEQUOTA' } eq 'on' ) { $uqsettings { 'ACTIVE' } = $uqsettings { 'ENABLEQUOTA' }; } else { $uqsettings { 'ACTIVE' } = 'off' }
589 $uqsettings { 'ENABLERULE' } = 'on' ;
590 if ( $uqsettings { 'EDITING' } eq 'no' ) {
591 open ( FILE
, ">> $uqfile " );
593 print FILE
" $uqsettings {'TIME_QUOTA'}, $uqsettings {'SPORADIC'}, $uqsettings {'RENEWAL'}, $quota_users , $uqsettings {'ACTIVE'} \n " ;
595 open ( FILE
, "> $uqfile " );
598 foreach $line ( @uqlist )
601 if ( $uqsettings { 'EDITING' } eq $id ) {
602 print FILE
" $uqsettings {'TIME_QUOTA'}, $uqsettings {'SPORADIC'}, $uqsettings {'RENEWAL'}, $quota_users , $uqsettings {'ACTIVE'} \n " ;
603 } else { print FILE
" $line " ; }
608 $uqsettings { 'CHANGED' }= 'yes' ;
609 $uqsettings { 'MODE' }= 'USERQUOTA' ;
610 $uqsettings { 'UQMODE' }= 'on' ;
613 if ( $uqsettings { 'EDITING' } ne 'no' )
615 $uqsettings { 'ACTION' } = $Lang :: tr
{ 'edit' };
616 $uqsettings { 'ID' } = $uqsettings { 'EDITING' };
621 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'remove' }))
624 open ( FILE
, "> $uqfile " );
626 foreach $line ( @uqlist )
629 unless ( $uqsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
632 $uqsettings { 'CHANGED' }= 'yes' ;
633 $uqsettings { 'UQMODE' }= 'on' ;
636 if (! $errormessage ) {
637 $uqsettings { 'ENABLEQUOTA' }= 'on' ;
640 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) && (! $errormessage ))
643 foreach $line ( @uqlist )
646 if ( $uqsettings { 'ID' } eq $id )
649 @temp = split ( /\,/ , $line );
650 $uqsettings { 'TIME_QUOTA' } = $temp [ 0 ];
651 $uqsettings { 'SPORADIC' } = $temp [ 1 ];
652 $uqsettings { 'RENEWAL' } = $temp [ 2 ];
653 $uqsettings { 'QUOTA_USERS' } = $temp [ 3 ];
654 $uqsettings { 'ENABLEQUOTA' } = $temp [ 4 ];
657 $uqsettings { 'UQMODE' }= 'on' ;
660 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }))
662 open ( FILE
, "> $uqfile " );
665 foreach $line ( @uqlist )
668 unless ( $uqsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
672 @temp = split ( /\,/ , $line );
673 if ( $temp [ 4 ] eq 'on' ) { $temp [ 4 ] = 'off' ; } else { $temp [ 4 ] = 'on' }
674 print FILE
" $temp [0], $temp [1], $temp [2], $temp [3], $temp [4] \n " ;
678 $uqsettings { 'CHANGED' }= 'yes' ;
679 $uqsettings { 'UQMODE' }= 'on' ;
682 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter restart' }))
684 if (!( $proxysettings { 'ENABLE_FILTER' } eq 'on' ))
686 $errormessage = $Lang :: tr
{ 'urlfilter not enabled' };
688 if ((!(- e
"${General::swroot}/proxy/enable" )) && (!(- e
"${General::swroot}/proxy/enable_blue" )))
690 $errormessage = $Lang :: tr
{ 'urlfilter web proxy service required' };
693 if (! $errormessage ) { system ( '/usr/local/bin/squidctrl restart >/dev/null 2>&1' ); }
694 $uqsettings { 'UQMODE' }= 'on' ;
697 if ( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter blacklist editor' }) { $besettings { 'BEMODE' } = 'on' ; }
699 if ( $besettings { 'MODE' } eq 'BLACKLIST_EDITOR' )
701 @temp = split ( /\n/ , $besettings { 'BE_DOMAINS' });
702 undef $besettings { 'BE_DOMAINS' };
705 s/^\s+//g ; s/\s+$//g ;
706 if ( $_ ) { $besettings { 'BE_DOMAINS' } .= $_ . " \n " ; }
708 chomp ( $besettings { 'BE_DOMAINS' });
709 @temp = split ( /\n/ , $besettings { 'BE_URLS' });
710 undef $besettings { 'BE_URLS' };
713 s/^\s+//g ; s/\s+$//g ;
714 if ( $_ ) { $besettings { 'BE_URLS' } .= $_ . " \n " ; }
716 chomp ( $besettings { 'BE_URLS' });
717 @temp = split ( /\n/ , $besettings { 'BE_EXPRESSIONS' });
718 undef $besettings { 'BE_EXPRESSIONS' };
721 s/^\s+//g ; s/\s+$//g ;
722 if ( $_ ) { $besettings { 'BE_EXPRESSIONS' } .= $_ . " \n " ; }
724 chomp ( $besettings { 'BE_EXPRESSIONS' });
727 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter load blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
729 $besettings { 'BEMODE' } = 'on' ;
731 $besettings { 'BE_NAME' } = $besettings { 'BE_BLACKLIST' };
733 delete $besettings { 'BE_DOMAINS' };
734 delete $besettings { 'BE_URLS' };
735 delete $besettings { 'BE_EXPRESSIONS' };
737 if (- e
" $dbdir / $besettings {'BE_NAME'}/domains" )
739 open ( FILE
, " $dbdir / $besettings {'BE_NAME'}/domains" );
740 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_DOMAINS' } .= $_ } };
742 chomp ( $besettings { 'BE_DOMAINS' });
744 if (- e
" $dbdir / $besettings {'BE_NAME'}/urls" )
746 open ( FILE
, " $dbdir / $besettings {'BE_NAME'}/urls" );
747 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_URLS' } .= $_ } };
749 chomp ( $besettings { 'BE_URLS' });
751 if (- e
" $dbdir / $besettings {'BE_NAME'}/expressions" )
753 open ( FILE
, " $dbdir / $besettings {'BE_NAME'}/expressions" );
754 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_EXPRESSIONS' } .= $_ } };
756 chomp ( $besettings { 'BE_EXPRESSIONS' });
760 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter import blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
762 $besettings { 'BEMODE' } = 'on' ;
764 & Header
:: getcgihash
( \
%besettings , { 'wantfile' => 1 , 'filevar' => 'IMPORTFILE' });
766 if (!( $besettings { 'IMPORTFILE' } =~ /.tar.gz$/ ))
768 $errormessage = $Lang :: tr
{ 'urlfilter wrong filetype' };
770 if (!- d
" $editdir " ) { mkdir ( " $editdir " ); }
772 if ( copy
( $besettings { 'IMPORTFILE' }, " $editdir /blacklist.tar.gz" ) != 1 )
777 my $exitcode = system ( "/bin/tar --no-same-owner --preserve-permissions -xzf $editdir /blacklist.tar.gz -C $editdir " );
780 $errormessage = $Lang :: tr
{ 'urlfilter tar error' };
783 foreach (< $editdir /blacklists/ *>)
788 $besettings { 'BE_NAME' } = substr ( $_ , rindex ( $_ , "/" )+ 1 );
794 $errormessage = $Lang :: tr
{ 'urlfilter invalid import file' };
796 delete $besettings { 'BE_DOMAINS' };
797 delete $besettings { 'BE_URLS' };
798 delete $besettings { 'BE_EXPRESSIONS' };
800 if (- e
" $editdir /blacklists/ $besettings {'BE_NAME'}/domains" )
802 open ( FILE
, " $editdir /blacklists/ $besettings {'BE_NAME'}/domains" );
803 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_DOMAINS' } .= $_ } };
805 chomp ( $besettings { 'BE_DOMAINS' });
807 if (- e
" $editdir /blacklists/ $besettings {'BE_NAME'}/urls" )
809 open ( FILE
, " $editdir /blacklists/ $besettings {'BE_NAME'}/urls" );
810 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_URLS' } .= $_ } };
812 chomp ( $besettings { 'BE_URLS' });
814 if (- e
" $editdir /blacklists/ $besettings {'BE_NAME'}/expressions" )
816 open ( FILE
, " $editdir /blacklists/ $besettings {'BE_NAME'}/expressions" );
817 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_EXPRESSIONS' } .= $_ } };
819 chomp ( $besettings { 'BE_EXPRESSIONS' });
824 if (- d
$editdir ) { system ( "rm -rf $editdir " ); }
830 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter export blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
832 $besettings { 'BEMODE' } = 'on' ;
834 if ( $besettings { 'BE_NAME' } eq '' )
836 $errormessage = $Lang :: tr
{ 'urlfilter category name error' };
837 } elsif ( $besettings { 'BE_DOMAINS' } || $besettings { 'BE_URLS' } || $besettings { 'BE_EXPRESSIONS' }) {
839 $_ = $besettings { 'BE_NAME' }; tr/A-Z/a-z/ ; $besettings { 'BE_NAME' } = $_ ;
841 if (!(- d
" $editdir " )) { mkdir ( " $editdir " ); }
842 if (!(- d
" $editdir /blacklists" )) { mkdir ( " $editdir /blacklists" ); }
843 if (!(- d
" $editdir /blacklists/ $besettings {'BE_NAME'}" )) { mkdir ( " $editdir /blacklists/ $besettings {'BE_NAME'}" ); }
845 open ( FILE
, "> $editdir /blacklists/ $besettings {'BE_NAME'}/domains" );
847 print FILE
" $besettings {'BE_DOMAINS'} \n " ;
849 open ( FILE
, "> $editdir /blacklists/ $besettings {'BE_NAME'}/urls" );
851 print FILE
" $besettings {'BE_URLS'} \n " ;
853 open ( FILE
, "> $editdir /blacklists/ $besettings {'BE_NAME'}/expressions" );
855 print FILE
" $besettings {'BE_EXPRESSIONS'} \n " ;
858 if ( system ( "/bin/tar -C $editdir -czf $editdir / $besettings {'BE_NAME'}.tar.gz blacklists" ))
860 $errormessage = $Lang :: tr
{ 'urlfilter export error' };
864 print "Content-type: application/gzip \n " ;
865 print "Content-length: " ;
866 print (- s
" $editdir / $besettings {'BE_NAME'}.tar.gz" );
868 print "Content-disposition: attachment; filename= $besettings {'BE_NAME'}.tar.gz \n\n " ;
870 open ( FILE
, " $editdir / $besettings {'BE_NAME'}.tar.gz" );
871 while (< FILE
>) { print ; }
874 if (- d
$editdir ) { system ( "rm -rf $editdir " ); }
878 $errormessage = $Lang :: tr
{ 'urlfilter category data error' };
882 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter install blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
884 $besettings { 'BEMODE' } = 'on' ;
886 if ( $besettings { 'BE_NAME' } eq '' )
888 $errormessage = $Lang :: tr
{ 'urlfilter category name error' };
889 } elsif ( $besettings { 'BE_DOMAINS' } || $besettings { 'BE_URLS' } || $besettings { 'BE_EXPRESSIONS' }) {
891 $_ = $besettings { 'BE_NAME' }; tr/A-Z/a-z/ ; $besettings { 'BE_NAME' } = $_ ;
893 if (!- d
" $editdir " ) { mkdir ( " $editdir " ); }
895 if (!- d
" $dbdir / $besettings {'BE_NAME'}" ) { mkdir ( " $dbdir / $besettings {'BE_NAME'}" ); }
897 if (- e
" $dbdir / $besettings {'BE_NAME'}/domains" ) { unlink ( " $dbdir / $besettings {'BE_NAME'}/domains" ); }
898 if ( $besettings { 'BE_DOMAINS' })
900 open ( FILE
, "> $dbdir / $besettings {'BE_NAME'}/domains" );
902 print FILE
" $besettings {'BE_DOMAINS'} \n " ;
905 if (- e
" $dbdir / $besettings {'BE_NAME'}/urls" ) { unlink ( " $dbdir / $besettings {'BE_NAME'}/urls" ); }
906 if ( $besettings { 'BE_URLS' })
908 open ( FILE
, "> $dbdir / $besettings {'BE_NAME'}/urls" );
910 print FILE
" $besettings {'BE_URLS'} \n " ;
913 if (- e
" $dbdir / $besettings {'BE_NAME'}/expressions" ) { unlink ( " $dbdir / $besettings {'BE_NAME'}/expressions" ); }
914 if ( $besettings { 'BE_EXPRESSIONS' })
916 open ( FILE
, "> $dbdir / $besettings {'BE_NAME'}/expressions" );
918 print FILE
" $besettings {'BE_EXPRESSIONS'} \n " ;
922 open ( FILE
, "> $editdir /install.conf" );
924 print FILE
"logdir /var/log/squidGuard \n " ;
925 print FILE
"dbhome $dbdir / $besettings {'BE_NAME'} \n\n " ;
926 print FILE
"dest $besettings {'BE_NAME'} { \n " ;
927 if ( $besettings { 'BE_DOMAINS' }) { print FILE
" domainlist domains \n " ; }
928 if ( $besettings { 'BE_URLS' }) { print FILE
" urllist urls \n " ; }
929 if ( $besettings { 'BE_EXPRESSIONS' }) { print FILE
" expressions expressions \n " ; }
931 print FILE
"acl { \n " ;
932 print FILE
" default { \n " ;
933 print FILE
" pass none \n " ;
938 system ( "rm -f $dbdir / $besettings {'BE_NAME'}/*.db" );
939 system ( "/usr/sbin/squidGuard -c $editdir /install.conf -C all" );
940 system ( "chmod a+w $dbdir / $besettings {'BE_NAME'}/*.db" );
942 & readblockcategories
;
947 system ( '/usr/local/bin/squidctrl restart >/dev/null 2>&1' ) unless ( $besettings { 'NORESTART' } eq 'on' );
949 if (- d
$editdir ) { system ( "rm -rf $editdir " ); }
951 $errormessage = $Lang :: tr
{ 'urlfilter category data error' };
955 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter save schedule' })
957 if (( $filtersettings { 'UPDATE_SOURCE' } eq 'custom' ) && ( $filtersettings { 'CUSTOM_UPDATE_URL' } eq '' ))
959 $errormessage = $Lang :: tr
{ 'urlfilter custom url required' };
961 open ( FILE
, "> $updconffile " );
962 print FILE
"ENABLE_AUTOUPDATE= $filtersettings {'ENABLE_AUTOUPDATE'} \n " ;
963 print FILE
"UPDATE_SCHEDULE= $filtersettings {'UPDATE_SCHEDULE'} \n " ;
964 print FILE
"UPDATE_SOURCE= $filtersettings {'UPDATE_SOURCE'} \n " ;
965 print FILE
"CUSTOM_UPDATE_URL= $filtersettings {'CUSTOM_UPDATE_URL'} \n " ;
968 if (- e
$upd_cron_dly ) { unlink ( $upd_cron_dly ); }
969 if (- e
$upd_cron_wly ) { unlink ( $upd_cron_wly ); }
970 if (- e
$upd_cron_mly ) { unlink ( $upd_cron_mly ); }
972 if (( $filtersettings { 'ENABLE_AUTOUPDATE' } eq 'on' ) && ( $filtersettings { 'UPDATE_SCHEDULE' } eq 'daily' ))
974 symlink ( "../bin/autoupdate.pl" , $upd_cron_dly )
976 symlink ( "/bin/false" , $upd_cron_dly )
979 if (( $filtersettings { 'ENABLE_AUTOUPDATE' } eq 'on' ) && ( $filtersettings { 'UPDATE_SCHEDULE' } eq 'weekly' ))
981 symlink ( "../bin/autoupdate.pl" , $upd_cron_wly )
983 symlink ( "/bin/false" , $upd_cron_wly )
986 if (( $filtersettings { 'ENABLE_AUTOUPDATE' } eq 'on' ) && ( $filtersettings { 'UPDATE_SCHEDULE' } eq 'monthly' ))
988 symlink ( "../bin/autoupdate.pl" , $upd_cron_mly )
990 symlink ( "/bin/false" , $upd_cron_mly )
995 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter update now' })
997 if ( $filtersettings { 'UPDATE_SOURCE' } eq 'custom' )
999 if ( $filtersettings { 'CUSTOM_UPDATE_URL' } eq '' )
1001 $errormessage = $Lang :: tr
{ 'urlfilter custom url required' };
1003 system ( "${General::swroot}/urlfilter/bin/autoupdate.pl $filtersettings {'CUSTOM_UPDATE_URL'} &" );
1006 system ( "${General::swroot}/urlfilter/bin/autoupdate.pl $filtersettings {'UPDATE_SOURCE'} &" );
1011 if (- e
"${General::swroot}/urlfilter/settings" ) { & General
:: readhash
( "${General::swroot}/urlfilter/settings" , \
%filtersettings ); }
1017 if ( $errormessage ) { $filtersettings { 'VALID' } = 'no' ; }
1019 $checked { 'ENABLE_CUSTOM_BLACKLIST' }{ 'off' } = '' ;
1020 $checked { 'ENABLE_CUSTOM_BLACKLIST' }{ 'on' } = '' ;
1021 $checked { 'ENABLE_CUSTOM_BLACKLIST' }{ $filtersettings { 'ENABLE_CUSTOM_BLACKLIST' }} = "checked='checked'" ;
1022 $checked { 'ENABLE_CUSTOM_WHITELIST' }{ 'off' } = '' ;
1023 $checked { 'ENABLE_CUSTOM_WHITELIST' }{ 'on' } = '' ;
1024 $checked { 'ENABLE_CUSTOM_WHITELIST' }{ $filtersettings { 'ENABLE_CUSTOM_WHITELIST' }} = "checked='checked'" ;
1025 $checked { 'ENABLE_CUSTOM_EXPRESSIONS' }{ 'off' } = '' ;
1026 $checked { 'ENABLE_CUSTOM_EXPRESSIONS' }{ 'on' } = '' ;
1027 $checked { 'ENABLE_CUSTOM_EXPRESSIONS' }{ $filtersettings { 'ENABLE_CUSTOM_EXPRESSIONS' }} = "checked='checked'" ;
1028 $checked { 'BLOCK_EXECUTABLES' }{ 'off' } = '' ;
1029 $checked { 'BLOCK_EXECUTABLES' }{ 'on' } = '' ;
1030 $checked { 'BLOCK_EXECUTABLES' }{ $filtersettings { 'BLOCK_EXECUTABLES' }} = "checked='checked'" ;
1031 $checked { 'BLOCK_AUDIO-VIDEO' }{ 'off' } = '' ;
1032 $checked { 'BLOCK_AUDIO-VIDEO' }{ 'on' } = '' ;
1033 $checked { 'BLOCK_AUDIO-VIDEO' }{ $filtersettings { 'BLOCK_AUDIO-VIDEO' }} = "checked='checked'" ;
1034 $checked { 'BLOCK_ARCHIVES' }{ 'off' } = '' ;
1035 $checked { 'BLOCK_ARCHIVES' }{ 'on' } = '' ;
1036 $checked { 'BLOCK_ARCHIVES' }{ $filtersettings { 'BLOCK_ARCHIVES' }} = "checked='checked'" ;
1037 $checked { 'ENABLE_REWRITE' }{ 'off' } = '' ;
1038 $checked { 'ENABLE_REWRITE' }{ 'on' } = '' ;
1039 $checked { 'ENABLE_REWRITE' }{ $filtersettings { 'ENABLE_REWRITE' }} = "checked='checked'" ;
1040 $checked { 'SHOW_CATEGORY' }{ 'off' } = '' ;
1041 $checked { 'SHOW_CATEGORY' }{ 'on' } = '' ;
1042 $checked { 'SHOW_CATEGORY' }{ $filtersettings { 'SHOW_CATEGORY' }} = "checked='checked'" ;
1043 $checked { 'SHOW_URL' }{ 'off' } = '' ;
1044 $checked { 'SHOW_URL' }{ 'on' } = '' ;
1045 $checked { 'SHOW_URL' }{ $filtersettings { 'SHOW_URL' }} = "checked='checked'" ;
1046 $checked { 'SHOW_IP' }{ 'off' } = '' ;
1047 $checked { 'SHOW_IP' }{ 'on' } = '' ;
1048 $checked { 'SHOW_IP' }{ $filtersettings { 'SHOW_IP' }} = "checked='checked'" ;
1049 $checked { 'ENABLE_DNSERROR' }{ 'off' } = '' ;
1050 $checked { 'ENABLE_DNSERROR' }{ 'on' } = '' ;
1051 $checked { 'ENABLE_DNSERROR' }{ $filtersettings { 'ENABLE_DNSERROR' }} = "checked='checked'" ;
1052 $checked { 'ENABLE_JPEG' }{ 'off' } = '' ;
1053 $checked { 'ENABLE_JPEG' }{ 'on' } = '' ;
1054 $checked { 'ENABLE_JPEG' }{ $filtersettings { 'ENABLE_JPEG' }} = "checked='checked'" ;
1055 $checked { 'ENABLE_EXPR_LISTS' }{ 'off' } = '' ;
1056 $checked { 'ENABLE_EXPR_LISTS' }{ 'on' } = '' ;
1057 $checked { 'ENABLE_EXPR_LISTS' }{ $filtersettings { 'ENABLE_EXPR_LISTS' }} = "checked='checked'" ;
1058 $checked { 'BLOCK_IP_ADDR' }{ 'off' } = '' ;
1059 $checked { 'BLOCK_IP_ADDR' }{ 'on' } = '' ;
1060 $checked { 'BLOCK_IP_ADDR' }{ $filtersettings { 'BLOCK_IP_ADDR' }} = "checked='checked'" ;
1061 $checked { 'BLOCK_ALL' }{ 'off' } = '' ;
1062 $checked { 'BLOCK_ALL' }{ 'on' } = '' ;
1063 $checked { 'BLOCK_ALL' }{ $filtersettings { 'BLOCK_ALL' }} = "checked='checked'" ;
1064 $checked { 'ENABLE_EMPTY_ADS' }{ 'off' } = '' ;
1065 $checked { 'ENABLE_EMPTY_ADS' }{ 'on' } = '' ;
1066 $checked { 'ENABLE_EMPTY_ADS' }{ $filtersettings { 'ENABLE_EMPTY_ADS' }} = "checked='checked'" ;
1067 $checked { 'ENABLE_GLOBAL_WHITELIST' }{ 'off' } = '' ;
1068 $checked { 'ENABLE_GLOBAL_WHITELIST' }{ 'on' } = '' ;
1069 $checked { 'ENABLE_GLOBAL_WHITELIST' }{ $filtersettings { 'ENABLE_GLOBAL_WHITELIST' }} = "checked='checked'" ;
1070 $checked { 'ENABLE_SAFESEARCH' }{ 'off' } = '' ;
1071 $checked { 'ENABLE_SAFESEARCH' }{ 'on' } = '' ;
1072 $checked { 'ENABLE_SAFESEARCH' }{ $filtersettings { 'ENABLE_SAFESEARCH' }} = "checked='checked'" ;
1073 $checked { 'ENABLE_LOG' }{ 'off' } = '' ;
1074 $checked { 'ENABLE_LOG' }{ 'on' } = '' ;
1075 $checked { 'ENABLE_LOG' }{ $filtersettings { 'ENABLE_LOG' }} = "checked='checked'" ;
1076 $checked { 'ENABLE_USERNAME_LOG' }{ 'off' } = '' ;
1077 $checked { 'ENABLE_USERNAME_LOG' }{ 'on' } = '' ;
1078 $checked { 'ENABLE_USERNAME_LOG' }{ $filtersettings { 'ENABLE_USERNAME_LOG' }} = "checked='checked'" ;
1079 $checked { 'ENABLE_CATEGORY_LOG' }{ 'off' } = '' ;
1080 $checked { 'ENABLE_CATEGORY_LOG' }{ 'on' } = '' ;
1081 $checked { 'ENABLE_CATEGORY_LOG' }{ $filtersettings { 'ENABLE_CATEGORY_LOG' }} = "checked='checked'" ;
1083 foreach $category ( @filtergroups ) {
1084 $checked { $category }{ 'off' } = '' ;
1085 $checked { $category }{ 'on' } = '' ;
1086 $checked { $category }{ $filtersettings { $category }} = "checked='checked'" ;
1089 $selected { 'DEFINITION' }{ $tcsettings { 'DEFINITION' }} = "selected='selected'" ;
1090 $selected { 'FROM_HOUR' }{ $tcsettings { 'FROM_HOUR' }} = "selected='selected'" ;
1091 $selected { 'FROM_MINUTE' }{ $tcsettings { 'FROM_MINUTE' }} = "selected='selected'" ;
1092 $selected { 'TO_HOUR' }{ $tcsettings { 'TO_HOUR' }} = "selected='selected'" ;
1093 $selected { 'TO_MINUTE' }{ $tcsettings { 'TO_MINUTE' }} = "selected='selected'" ;
1095 @selectedcategories = split ( /\|/ , $tcsettings { 'DST' });
1096 foreach ( @selectedcategories )
1098 $selected { 'DST' }{ $_ } = "selected='selected'" ;
1101 $selected { 'ACCESS' }{ $tcsettings { 'ACCESS' }} = "selected='selected'" ;
1103 $checked { 'ENABLERULE' }{ 'off' } = '' ;
1104 $checked { 'ENABLERULE' }{ 'on' } = '' ;
1105 $checked { 'ENABLERULE' }{ $tcsettings { 'ENABLERULE' }} = "checked='checked'" ;
1106 $checked { 'MON' }{ 'off' } = '' ;
1107 $checked { 'MON' }{ 'on' } = '' ;
1108 $checked { 'MON' }{ $tcsettings { 'MON' }} = "checked='checked'" ;
1109 $checked { 'TUE' }{ 'off' } = '' ;
1110 $checked { 'TUE' }{ 'on' } = '' ;
1111 $checked { 'TUE' }{ $tcsettings { 'TUE' }} = "checked='checked'" ;
1112 $checked { 'WED' }{ 'off' } = '' ;
1113 $checked { 'WED' }{ 'on' } = '' ;
1114 $checked { 'WED' }{ $tcsettings { 'WED' }} = "checked='checked'" ;
1115 $checked { 'THU' }{ 'off' } = '' ;
1116 $checked { 'THU' }{ 'on' } = '' ;
1117 $checked { 'THU' }{ $tcsettings { 'THU' }} = "checked='checked'" ;
1118 $checked { 'FRI' }{ 'off' } = '' ;
1119 $checked { 'FRI' }{ 'on' } = '' ;
1120 $checked { 'FRI' }{ $tcsettings { 'FRI' }} = "checked='checked'" ;
1121 $checked { 'SAT' }{ 'off' } = '' ;
1122 $checked { 'SAT' }{ 'on' } = '' ;
1123 $checked { 'SAT' }{ $tcsettings { 'SAT' }} = "checked='checked'" ;
1124 $checked { 'SUN' }{ 'off' } = '' ;
1125 $checked { 'SUN' }{ 'on' } = '' ;
1126 $checked { 'SUN' }{ $tcsettings { 'SUN' }} = "checked='checked'" ;
1128 $selected { 'SPORADIC' }{ $uqsettings { 'SPORADIC' }} = "selected='selected'" ;
1129 $selected { 'RENEWAL' } { $uqsettings { 'RENEWAL' }} = "selected='selected'" ;
1131 $checked { 'ENABLEQUOTA' }{ 'off' } = '' ;
1132 $checked { 'ENABLEQUOTA' }{ 'on' } = '' ;
1133 $checked { 'ENABLEQUOTA' }{ $uqsettings { 'ENABLEQUOTA' }} = "checked='checked'" ;
1135 $selected { 'BE_BLACKLIST' }{ $besettings { 'BE_BLACKLIST' }} = "selected='selected'" ;
1138 & Header
:: showhttpheaders
();
1140 & Header
:: openpage
( $Lang :: tr
{ 'urlfilter configuration' }, 1 , '' );
1142 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
1144 if ( $errormessage ) {
1145 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
1146 print "<font class='base'> $errormessage </font> \n " ;
1147 & Header
:: closebox
();
1148 } elsif (( $tcsettings { 'CHANGED' } eq 'yes' ) || ( $uqsettings { 'CHANGED' } eq 'yes' ) ) {
1150 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}'> \n " ;
1151 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter restart notification'}:" );
1152 print "<class name='base'> $Lang ::tr{'urlfilter restart message'} \n " ;
1153 if ( $uqsettings { 'MODE' } eq 'USERQUOTA' ) { print "<p><class name='base'> $Lang ::tr{'urlfilter quota restart message'} \n " ; }
1155 print "<p><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter restart'}' />" ;
1156 if ( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) { print "<input type='hidden' name='MODE' value='TIMECONSTRAINT' />" ; }
1157 if ( $uqsettings { 'MODE' } eq 'USERQUOTA' ) { print "<input type='hidden' name='MODE' value='USERQUOTA' />" ; }
1158 & Header
:: closebox
();
1162 if ( $restoremessage ) {
1163 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter restore results'}:" );
1164 print "<class name='base'> $restoremessage \n " ;
1165 print " </class> \n " ;
1166 & Header
:: closebox
();
1169 if ((! $tcsettings { 'TCMODE' }) && (! $uqsettings { 'UQMODE' }) && (! $besettings { 'BEMODE' })) {
1171 if (!( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter manage repository' })) {
1173 #==========================================================
1175 # Section: Main Configuration
1177 #==========================================================
1179 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
1181 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter filter settings'}:" );
1183 <table width='100%'>
1185 <td colspan='4'><b> $Lang ::tr{'urlfilter block categories'}</b></td>
1190 if ( @categories == 0 ) {
1193 <td><i> $Lang ::tr{'urlfilter no categories'}</i></td>
1203 for ( $n = 0 ; $n <= @categories ; $n = $n + $i ) {
1204 for ( $i = 0 ; $i <= 3 ; $i ++) {
1205 if ( $i eq 0 ) { print "<tr> \n " ; }
1206 if (( $n + $i ) < @categories ) {
1207 print "<td width='15%'> @categories [ $n + $i ]:<\/td> \n " ;
1208 print "<td width='10%'><input type='checkbox' name= @filtergroups [ $n + $i ] $checked { @filtergroups [ $n + $i ]}{'on'} /></td> \n " ;
1210 if ( $i eq 3 ) { print "<\/tr> \n " ; }
1217 <table width='100%'>
1219 <td><b> $Lang ::tr{'urlfilter custom blacklist'}</b></td>
1225 <td colspan='2'> $Lang ::tr{'urlfilter blocked domains'} <img src='/blob.gif' alt='*' /></td>
1226 <td colspan='2'> $Lang ::tr{'urlfilter blocked urls'} <img src='/blob.gif' alt='*' /></td>
1229 <td colspan='2' width='50%'><textarea name='CUSTOM_BLACK_DOMAINS' cols='32' rows='6' wrap='off'>
1233 print $filtersettings { 'CUSTOM_BLACK_DOMAINS' };
1237 <td colspan='2' width='50%'><textarea name='CUSTOM_BLACK_URLS' cols='32' rows='6' wrap='off'>
1241 print $filtersettings { 'CUSTOM_BLACK_URLS' };
1247 <table width='100%'>
1249 <td class='base' width='25%'> $Lang ::tr{'urlfilter enable custom blacklist'}:</td>
1250 <td><input type='checkbox' name='ENABLE_CUSTOM_BLACKLIST' $checked {'ENABLE_CUSTOM_BLACKLIST'}{'on'} /></td>
1256 <table width='100%'>
1258 <td><b> $Lang ::tr{'urlfilter custom whitelist'}</b></td>
1264 <td colspan='2'> $Lang ::tr{'urlfilter allowed domains'} <img src='/blob.gif' alt='*' /></td>
1265 <td colspan='2'> $Lang ::tr{'urlfilter allowed urls'} <img src='/blob.gif' alt='*' /></td>
1268 <td colspan='2' width='50%'><textarea name='CUSTOM_WHITE_DOMAINS' cols='32' rows='6' wrap='off'>
1272 print $filtersettings { 'CUSTOM_WHITE_DOMAINS' };
1276 <td colspan='2' width='50%'><textarea name='CUSTOM_WHITE_URLS' cols='32' rows='6' wrap='off'>
1280 print $filtersettings { 'CUSTOM_WHITE_URLS' };
1286 <table width='100%'>
1288 <td class='base' width='25%'> $Lang ::tr{'urlfilter enable custom whitelist'}:</td>
1289 <td><input type='checkbox' name='ENABLE_CUSTOM_WHITELIST' $checked {'ENABLE_CUSTOM_WHITELIST'}{'on'} /></td>
1295 <table width='100%'>
1297 <td colspan='4'><b> $Lang ::tr{'urlfilter custom expression list'}</b></td>
1300 <td colspan='4'> $Lang ::tr{'urlfilter blocked expressions'} <img src='/blob.gif' alt='*' /></td>
1303 <td colspan='4'><textarea name='CUSTOM_EXPRESSIONS' cols='70' rows='3' wrap='off'>
1307 print $filtersettings { 'CUSTOM_EXPRESSIONS' };
1313 <td class='base' width='25%'> $Lang ::tr{'urlfilter enable custom expression list'}:</td>
1314 <td><input type='checkbox' name='ENABLE_CUSTOM_EXPRESSIONS' $checked {'ENABLE_CUSTOM_EXPRESSIONS'}{'on'} /></td>
1320 <table width='100%'>
1322 <td colspan='4'><b> $Lang ::tr{'urlfilter file ext block'}</b></td>
1325 <td width='25%' class='base'> $Lang ::tr{'urlfilter block executables'}:</td>
1326 <td width='12%'><input type='checkbox' name='BLOCK_EXECUTABLES' $checked {'BLOCK_EXECUTABLES'}{'on'} /></td>
1327 <td width='25%' class='base'> $Lang ::tr{'urlfilter block audio-video'}:</td>
1328 <td><input type='checkbox' name='BLOCK_AUDIO-VIDEO' $checked {'BLOCK_AUDIO-VIDEO'}{'on'} /></td>
1331 <td class='base'> $Lang ::tr{'urlfilter block archives'}:</td>
1332 <td><input type='checkbox' name='BLOCK_ARCHIVES' $checked {'BLOCK_ARCHIVES'}{'on'} /></td>
1338 <table width='100%'>
1340 <td colspan='4'><b> $Lang ::tr{'urlfilter local file redirection'}</b></td>
1343 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable rewrite rules'}:</td>
1344 <td width='12%'><input type='checkbox' name='ENABLE_REWRITE' $checked {'ENABLE_REWRITE'}{'on'} /></td>
1349 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter manage repository'}'></td>
1356 <table width='100%'>
1358 <td colspan='2'><b> $Lang ::tr{'urlfilter network access control'}</b></td>
1363 <td colspan='2'> $Lang ::tr{'urlfilter unfiltered clients'} <img src='/blob.gif' alt='*' /></td>
1364 <td colspan='2'> $Lang ::tr{'urlfilter banned clients'} <img src='/blob.gif' alt='*' /></td>
1367 <td colspan='2' width='50%'><textarea name='UNFILTERED_CLIENTS' cols='32' rows='6' wrap='off'>
1371 # transform from pre1.8 client definitions
1372 $filtersettings { 'UNFILTERED_CLIENTS' } =~ s/^\s+//g ;
1373 $filtersettings { 'UNFILTERED_CLIENTS' } =~ s/\s+$//g ;
1374 $filtersettings { 'UNFILTERED_CLIENTS' } =~ s/\s+-\s+/-/g ;
1375 $filtersettings { 'UNFILTERED_CLIENTS' } =~ s/\s+/ /g ;
1377 @clients = split ( / / , $filtersettings { 'UNFILTERED_CLIENTS' });
1378 undef $filtersettings { 'UNFILTERED_CLIENTS' };
1379 foreach ( @clients ) { $filtersettings { 'UNFILTERED_CLIENTS' } .= " $_ \n " ; }
1381 print $filtersettings { 'UNFILTERED_CLIENTS' };
1385 <td colspan='2' width='50%'><textarea name='BANNED_CLIENTS' cols='32' rows='6' wrap='off'>
1389 # transform from pre1.8 client definitions
1390 $filtersettings { 'BANNED_CLIENTS' } =~ s/^\s+//g ;
1391 $filtersettings { 'BANNED_CLIENTS' } =~ s/\s+$//g ;
1392 $filtersettings { 'BANNED_CLIENTS' } =~ s/\s+-\s+/-/g ;
1393 $filtersettings { 'BANNED_CLIENTS' } =~ s/\s+/ /g ;
1395 @clients = split ( / / , $filtersettings { 'BANNED_CLIENTS' });
1396 undef $filtersettings { 'BANNED_CLIENTS' };
1397 foreach ( @clients ) { $filtersettings { 'BANNED_CLIENTS' } .= " $_ \n " ; }
1399 print $filtersettings { 'BANNED_CLIENTS' };
1406 <table width='100%'>
1408 <td colspan='4'><b> $Lang ::tr{'urlfilter timebased access control'}</b></td>
1411 <td width='25%'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter set time constraints'}'></td>
1412 <td width='25%'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter set user quota'}'></td>
1418 <table width='100%'>
1420 <td colspan='4'><b> $Lang ::tr{'urlfilter block settings'}</b></td>
1423 <td width='25%' class='base'> $Lang ::tr{'urlfilter show category'}:</td>
1424 <td width='12%'><input type='checkbox' name='SHOW_CATEGORY' $checked {'SHOW_CATEGORY'}{'on'} /></td>
1425 <td width='25%' class='base'> $Lang ::tr{'urlfilter redirectpage'}: <img src='/blob.gif' alt='*' /></td>
1426 <td><input type='text' name='REDIRECT_PAGE' value=' $filtersettings {'REDIRECT_PAGE'}' size='40' /></td>
1429 <td class='base'> $Lang ::tr{'urlfilter show url'}:</td>
1430 <td><input type='checkbox' name='SHOW_URL' $checked {'SHOW_URL'}{'on'} /></td>
1431 <td class='base'> $Lang ::tr{'urlfilter msg text 1'}: <img src='/blob.gif' alt='*' /></td>
1432 <td><input type='text' name='MSG_TEXT_1' value=' $filtersettings {'MSG_TEXT_1'}' size='40' /></td>
1435 <td class='base'> $Lang ::tr{'urlfilter show ip'}:</td>
1436 <td><input type='checkbox' name='SHOW_IP' $checked {'SHOW_IP'}{'on'} /></td>
1437 <td class='base'> $Lang ::tr{'urlfilter msg text 2'}: <img src='/blob.gif' alt='*' /></td>
1438 <td><input type='text' name='MSG_TEXT_2' value=' $filtersettings {'MSG_TEXT_2'}' size='40' /></td>
1441 <td class='base'> $Lang ::tr{'urlfilter show dnserror'}:</td>
1442 <td><input type='checkbox' name='ENABLE_DNSERROR' $checked {'ENABLE_DNSERROR'}{'on'} /></td>
1443 <td class='base'> $Lang ::tr{'urlfilter msg text 3'}: <img src='/blob.gif' alt='*' /></td>
1444 <td><input type='text' name='MSG_TEXT_3' value=' $filtersettings {'MSG_TEXT_3'}' size='40' /></td>
1447 <td class='base'> $Lang ::tr{'urlfilter enable jpeg'}:</td>
1448 <td><input type='checkbox' name='ENABLE_JPEG' $checked {'ENABLE_JPEG'}{'on'} /></td>
1454 <table width='100%'>
1456 <td colspan='4'><b> $Lang ::tr{'urlfilter advanced settings'}</b></td>
1459 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable expression lists'}:</td>
1460 <td width='12%'><input type='checkbox' name='ENABLE_EXPR_LISTS' $checked {'ENABLE_EXPR_LISTS'}{'on'} /></td>
1461 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable log'}:</td>
1462 <td><input type='checkbox' name='ENABLE_LOG' $checked {'ENABLE_LOG'}{'on'} /></td>
1465 <td class='base'> $Lang ::tr{'urlfilter safesearch'}:</td>
1466 <td><input type='checkbox' name='ENABLE_SAFESEARCH' $checked {'ENABLE_SAFESEARCH'}{'on'} /></td>
1467 <td class='base'> $Lang ::tr{'urlfilter username log'}:</td>
1468 <td><input type='checkbox' name='ENABLE_USERNAME_LOG' $checked {'ENABLE_USERNAME_LOG'}{'on'} /></td>
1471 <td class='base'> $Lang ::tr{'urlfilter empty ads'}:</td>
1472 <td><input type='checkbox' name='ENABLE_EMPTY_ADS' $checked {'ENABLE_EMPTY_ADS'}{'on'} /></td>
1473 <td class='base'> $Lang ::tr{'urlfilter category log'}:</td>
1474 <td><input type='checkbox' name='ENABLE_CATEGORY_LOG' $checked {'ENABLE_CATEGORY_LOG'}{'on'} /></td>
1477 <td class='base'> $Lang ::tr{'urlfilter block ip'}:</td>
1478 <td><input type='checkbox' name='BLOCK_IP_ADDR' $checked {'BLOCK_IP_ADDR'}{'on'} /></td>
1481 <td class='base'> $Lang ::tr{'urlfilter block all'}:</td>
1482 <td><input type='checkbox' name='BLOCK_ALL' $checked {'BLOCK_ALL'}{'on'} /></td>
1483 <td class='base'> $Lang ::tr{'urlfilter whitelist always allowed'}:</td>
1484 <td><input type='checkbox' name='ENABLE_GLOBAL_WHITELIST' $checked {'ENABLE_GLOBAL_WHITELIST'}{'on'} /></td>
1488 <table width='100%'>
1491 <img src='/blob.gif' align='top' alt='*' />
1492 <font class='base'> $Lang ::tr{'this field may be blank'}</font>
1494 <td align='right'>
1498 <table width='100%'>
1501 <td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' /></td>
1502 <td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter save and restart'}' /></td>
1509 & Header
:: closebox
();
1513 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
1515 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter maintenance'}:" );
1518 <table width='100%'>
1520 <td class='base'><b> $Lang ::tr{'urlfilter blacklist update'}</b></td>
1523 <td> $Lang ::tr{'urlfilter upload information'}<p> $Lang ::tr{'urlfilter upload text'}:</td>
1526 <td><input type='file' name='UPDATEFILE' size='40' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter upload blacklist'}' /></td>
1532 <table width='100%'>
1534 <td colspan='2' class='base'><b> $Lang ::tr{'urlfilter automatic blacklist update'}</b>
1537 if (- e
" $updflagfile " )
1539 $blacklistage = int (- M
" $updflagfile " );
1540 print " <b>[</b> <small><i> $Lang ::tr{'urlfilter blacklist age 1'} <b> $blacklistage </b> $Lang ::tr{'urlfilter blacklist age 2'}</i></small> <b>]</b>" ;
1543 $updatesettings { 'UPDATE_SCHEDULE' } = 'monthly' ;
1544 $updatesettings { 'CUSTOM_UPDATE_URL' } = '' ;
1546 if (- e
" $updconffile " ) { & General
:: readhash
( " $updconffile " , \
%updatesettings ); }
1548 $checked { 'ENABLE_AUTOUPDATE' }{ 'off' } = '' ;
1549 $checked { 'ENABLE_AUTOUPDATE' }{ 'on' } = '' ;
1550 $checked { 'ENABLE_AUTOUPDATE' }{ $updatesettings { 'ENABLE_AUTOUPDATE' }} = "checked='checked'" ;
1552 $selected { 'UPDATE_SCHEDULE' }{ $updatesettings { 'UPDATE_SCHEDULE' }} = "selected='selected'" ;
1554 $selected { 'UPDATE_SOURCE' }{ $updatesettings { 'UPDATE_SOURCE' }} = "selected='selected'" ;
1560 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable automatic blacklist update'}:</td>
1561 <td width='75%' class='base'><input type='checkbox' name='ENABLE_AUTOUPDATE' $checked {'ENABLE_AUTOUPDATE'}{'on'} /></td>
1564 <td class='base'> $Lang ::tr{'urlfilter automatic update schedule'}:</td>
1566 <select name='UPDATE_SCHEDULE'>
1567 <option value='daily' $selected {'UPDATE_SCHEDULE'}{'daily'}> $Lang ::tr{'urlfilter daily'}</option>
1568 <option value='weekly' $selected {'UPDATE_SCHEDULE'}{'weekly'}> $Lang ::tr{'urlfilter weekly'}</option>
1569 <option value='monthly' $selected {'UPDATE_SCHEDULE'}{'monthly'}> $Lang ::tr{'urlfilter monthly'}</option>
1574 <td class='base'> $Lang ::tr{'urlfilter select source'}:</td>
1575 <td class='base' colspan='2'>
1576 <select name='UPDATE_SOURCE'>
1580 foreach ( @source_urllist ) {
1582 $source_name = substr ( $_ , 0 , rindex ( $_ , "," ));
1583 $source_url = substr ( $_ , index ( $_ , "," )+ 1 );
1584 print " \t <option value=' $source_url ' $selected {'UPDATE_SOURCE'}{ $source_url }> $source_name </option> \n " ;
1588 <option value='custom' $selected {'UPDATE_SOURCE'}{'custom'}> $Lang ::tr{'urlfilter custom url'}</option>
1593 <td> $Lang ::tr{'urlfilter custom url'}:</td>
1594 <td><input type='text' name='CUSTOM_UPDATE_URL' value=' $updatesettings {'CUSTOM_UPDATE_URL'}' size='72' /></td>
1597 <table width='100%'>
1599 <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>
1605 <table width='100%'>
1607 <td class='base'><b> $Lang ::tr{'urlfilter blacklist editor'}</b></td>
1610 <td> $Lang ::tr{'urlfilter blacklist editor info'}</td>
1613 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter blacklist editor'}' /></td>
1619 <table width='100%'>
1621 <td colspan='4' class='base'><b> $Lang ::tr{'urlfilter backup settings'}</b></td>
1624 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable full backup'}:</td>
1625 <td width='12%' class='base'><input type='checkbox' name='ENABLE_FULLBACKUP' $checked {'ENABLE_FULLBACKUP'}{'on'} /></td>
1630 <td colspan='4' class='base'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter backup'}' /></td>
1636 <table width='100%'>
1638 <td class='base'><b> $Lang ::tr{'urlfilter restore settings'}</b></td>
1641 <td> $Lang ::tr{'urlfilter restore text'}:</td>
1644 <td><input type='file' name='UPDATEFILE' size='40' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter restore'}' /></td>
1651 & Header
:: closebox
();
1655 #==========================================================
1657 # Section: Manage Repository
1659 #==========================================================
1661 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
1663 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter manage local file repository'}:" );
1665 <table width='100%'>
1667 <td> $Lang ::tr{'urlfilter repository information'}<br><br></td>
1670 <td> $Lang ::tr{'urlfilter upload file text'}:</td>
1673 <td><input type='file' name='UPLOADFILE' size='50' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter upload file'}' /></td>
1676 <td><br><b> $Lang ::tr{'urlfilter upload file information 1'}:</b> $Lang ::tr{'urlfilter upload file information 2'}</td>
1680 <table width='100%'>
1682 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
1689 & Header
:: closebox
();
1691 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter current files'}: </b>[ $repository ]" );
1693 @repositorylist = < $repository /*>;
1695 undef @repositoryfiles ;
1696 foreach ( @repositorylist )
1698 if (!- d
) { push ( @repositoryfiles , substr ( $_ , rindex ( $_ , "/" )+ 1 )); }
1701 if ( @repositoryfiles )
1704 <table width='100%'>
1706 <td align='center'><b> $Lang ::tr{'urlfilter filename'}</b></td>
1707 <td width='15%' align='center'><b> $Lang ::tr{'urlfilter filesize'}</b></td>
1708 <td width='10%'></td>
1713 foreach $line ( @repositoryfiles )
1717 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
1719 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
1720 $filesize = (- s
" $repository / $line " );
1721 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/ ;
1724 <td> $line </td>
1725 <td align='right'> $filesize </td>
1728 <form method='post' name='frma $id ' action=' $ENV {'SCRIPT_NAME'}'>
1729 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' title=' $Lang ::tr{'remove'}' alt=' $Lang ::tr{'remove'}' />
1730 <input type='hidden' name='ID' value=' $line ' />
1731 <input type='hidden' name='ACTION' value=' $Lang ::tr{'urlfilter remove file'}' />
1748 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
1749 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
1750 <td class='base'> $Lang ::tr{'remove'}</td>
1757 print "<i> $Lang ::tr{'urlfilter empty repository'}</i> \n " ;
1760 & Header
:: closebox
();
1764 } elsif ( $tcsettings { 'TCMODE' }) {
1766 #==========================================================
1768 # Section: Set Time Constraints
1770 #==========================================================
1772 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}'> \n " ;
1774 $buttontext = $Lang :: tr
{ 'urlfilter add rule' };
1775 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
1776 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter edit time constraint rule' }. ':' );
1777 $buttontext = $Lang :: tr
{ 'urlfilter update rule' };
1779 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter add new time constraint rule' }. ':' );
1783 <table width='100%'>
1785 <td width='2%'> $Lang ::tr{'urlfilter constraint definition'}</td>
1786 <td width='1%'> </td>
1787 <td width='2%' align='center'> $Lang ::tr{'urlfilter monday'}</td>
1788 <td width='2%' align='center'> $Lang ::tr{'urlfilter tuesday'}</td>
1789 <td width='2%' align='center'> $Lang ::tr{'urlfilter wednesday'}</td>
1790 <td width='2%' align='center'> $Lang ::tr{'urlfilter thursday'}</td>
1791 <td width='2%' align='center'> $Lang ::tr{'urlfilter friday'}</td>
1792 <td width='2%' align='center'> $Lang ::tr{'urlfilter saturday'}</td>
1793 <td width='2%' align='center'> $Lang ::tr{'urlfilter sunday'}</td>
1794 <td width='1%'> </td>
1795 <td width='7%' colspan=3> $Lang ::tr{'urlfilter from'}</td>
1796 <td width='1%'> </td>
1797 <td width='7%' colspan=3> $Lang ::tr{'urlfilter to'}</td>
1802 <select name='DEFINITION'>
1803 <option value='within' $selected {'DEFINITION'}{'within'}> $Lang ::tr{'urlfilter constraint within'}</option>
1804 <option value='outside' $selected {'DEFINITION'}{'outside'}> $Lang ::tr{'urlfilter constraint outside'}</option>
1808 <td class='base'><input type='checkbox' name='MON' $checked {'MON'}{'on'} /></td>
1809 <td class='base'><input type='checkbox' name='TUE' $checked {'TUE'}{'on'} /></td>
1810 <td class='base'><input type='checkbox' name='WED' $checked {'WED'}{'on'} /></td>
1811 <td class='base'><input type='checkbox' name='THU' $checked {'THU'}{'on'} /></td>
1812 <td class='base'><input type='checkbox' name='FRI' $checked {'FRI'}{'on'} /></td>
1813 <td class='base'><input type='checkbox' name='SAT' $checked {'SAT'}{'on'} /></td>
1814 <td class='base'><input type='checkbox' name='SUN' $checked {'SUN'}{'on'} /></td>
1817 <select name='FROM_HOUR'>
1820 for ( $i = 0 ; $i <= 24 ; $i ++) {
1821 $_ = sprintf ( " %02s " , $i );
1822 print "<option $selected {'FROM_HOUR'}{ $_ }> $_ </option> \n " ;
1829 <select name='FROM_MINUTE'>
1832 for ( $i = 0 ; $i <= 45 ; $i += 15 ) {
1833 $_ = sprintf ( " %02s " , $i );
1834 print "<option $selected {'FROM_MINUTE'}{ $_ }> $_ </option> \n " ;
1841 <select name='TO_HOUR'>
1844 for ( $i = 0 ; $i <= 24 ; $i ++) {
1845 $_ = sprintf ( " %02s " , $i );
1846 print "<option $selected {'TO_HOUR'}{ $_ }> $_ </option> \n " ;
1853 <select name='TO_MINUTE'>
1856 for ( $i = 0 ; $i <= 45 ; $i += 15 ) {
1857 $_ = sprintf ( " %02s " , $i );
1858 print "<option $selected {'TO_MINUTE'}{ $_ }> $_ </option> \n " ;
1869 <table width='100%'>
1871 <td width='5%'> $Lang ::tr{'urlfilter source'}</td>
1872 <td width='1%'> </td>
1873 <td width='5%'> $Lang ::tr{'urlfilter dst'} <img src='/blob.gif' alt='*'><img src='/blob.gif' alt='*'></td>
1874 <td width='1%'> </td>
1875 <td width='5%'> $Lang ::tr{'urlfilter access'}</td>
1879 <td rowspan='2'><textarea name='SRC' cols='28' rows='5' wrap='off'>
1883 # transform from pre1.8 client definitions
1884 $tcsettings { 'SRC' } =~ s/^\s+//g ;
1885 $tcsettings { 'SRC' } =~ s/\s+$//g ;
1886 $tcsettings { 'SRC' } =~ s/\s+-\s+/-/g ;
1887 $tcsettings { 'SRC' } =~ s/\s+/ /g ;
1889 @clients = split ( / / , $tcsettings { 'SRC' });
1890 undef $tcsettings { 'SRC' };
1891 foreach ( @clients ) { $tcsettings { 'SRC' } .= " $_ \n " ; }
1893 print $tcsettings { 'SRC' };
1899 <td class='base' rowspan='2' valign='top'>
1900 <select name='DST' size='6' multiple>
1901 <option value='any' $selected {'DST'}{'any'} = "selected='selected'"> $Lang ::tr{'urlfilter category all'}</option>
1902 <option value='in-addr' $selected {'DST'}{'in-addr'} = "selected='selected'">in-addr</option>
1906 & readblockcategories
;
1907 foreach ( @categories )
1909 print "<option value=' $_ ' $selected {'DST'}{ $_ }> $_ </option> \n " ;
1913 <option value='files' $selected {'DST'}{'files'} = "selected='selected'">files</option>
1914 <option value='custom-blocked' $selected {'DST'}{'custom-blocked'} = "selected='selected'">custom-blocked</option>
1915 <option value='custom-expressions' $selected {'DST'}{'custom-expressions'} = "selected='selected'">custom-expressions</option>
1919 <td class='base' valign='top'>
1920 <select name='ACCESS'>
1921 <option value='block' $selected {'ACCESS'}{'block'}> $Lang ::tr{'urlfilter mode block'}</option>
1922 <option value='allow' $selected {'ACCESS'}{'allow'}> $Lang ::tr{'urlfilter mode allow'}</option>
1934 <td> $Lang ::tr{'remark'} <img src='/blob.gif' alt='*'></td>
1942 <td><input type='text' name='COMMENT' value=' $tcsettings {'COMMENT'}' size='32' /></td>
1951 <table width='100%'>
1953 <td class='base'> $Lang ::tr{'urlfilter enabled'}<input type='checkbox' name='ENABLERULE' $checked{'ENABLERULE'}{'on'} /></td>
1961 <td><input type='hidden' name='ACTION' value=' $Lang ::tr{'add'}' /></td>
1962 <td><input type='hidden' name='MODE' value='TIMECONSTRAINT' /></td>
1963 <td><input type='submit' name='SUBMIT' value=' $buttontext ' /></td>
1964 <td><input type='reset' name='ACTION' value=' $Lang ::tr{'urlfilter reset'}' /></td>
1966 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
1970 <table width='100%'>
1972 <td width='1%' align='right'> <img src='/blob.gif' align='top' alt='*' /> </td>
1973 <td><font class='base'> $Lang ::tr{'this field may be blank'}</font></td>
1976 <td width='1%' align='right'><img src='/blob.gif' align='top' alt='*' /><img src='/blob.gif' align='top' alt='*' /> </td>
1977 <td><font class='base'> $Lang ::tr{'urlfilter select multi'}</font></td>
1983 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
1984 print "<input type='hidden' name='EDITING' value=' $tcsettings {'ID'}' /> \n " ;
1986 print "<input type='hidden' name='EDITING' value='no' /> \n " ;
1989 & Header
:: closebox
();
1992 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'current rules' });
1994 <table width='100%'>
1996 <td width='5%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter constraint definition'}</b></td>
1997 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter time space'}</b></td>
1998 <td width='15%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter src'}</b></td>
1999 <td width='5%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter dst'}</b></td>
2000 <td width='10%' class='boldbase' colspan='5' align='center'> </td>
2005 if ( $tcsettings { 'ACTION' } ne '' or $changed ne 'no' )
2007 open ( FILE
, $tcfile );
2013 foreach $line ( @tclist )
2017 @temp = split ( /\,/ , $line );
2018 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' } && $tcsettings { 'ID' } eq $id ) {
2019 print "<tr bgcolor=' $Header ::colouryellow'> \n " ; }
2021 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
2023 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
2024 if ( $temp [ 0 ] eq 'within' ) { $temp [ 0 ]= $Lang :: tr
{ 'urlfilter constraint within' }; } else { $temp [ 0 ]= $Lang :: tr
{ 'urlfilter constraint outside' }; }
2025 if ( $temp [ 13 ] eq 'any' ) { $temp [ 13 ]= $Lang :: tr
{ 'urlfilter category all' }; }
2026 if ( $temp [ 15 ] eq 'on' ) { $gif = 'on.gif' ; $toggle = 'off' ; $gdesc = $Lang :: tr
{ 'click to disable' };}
2027 else { $gif = 'off.gif' ; $toggle = 'on' ; $gdesc = $Lang :: tr
{ 'click to enable' }; }
2028 if ( $temp [ 14 ] eq 'block' ) { $led = 'led-red.gif' ; $ldesc = $Lang :: tr
{ 'urlfilter block access' };}
2029 else { $led = 'led-green.gif' ; $ldesc = $Lang :: tr
{ 'urlfilter allow access' }; }
2032 if ( $temp [ 1 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter mon' }; } else { $time .= '=' ; }
2033 if ( $temp [ 2 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter tue' }; } else { $time .= '=' ; }
2034 if ( $temp [ 3 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter wed' }; } else { $time .= '=' ; }
2035 if ( $temp [ 4 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter thu' }; } else { $time .= '=' ; }
2036 if ( $temp [ 5 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter fri' }; } else { $time .= '=' ; }
2037 if ( $temp [ 6 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter sat' }; } else { $time .= '=' ; }
2038 if ( $temp [ 7 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter sun' }; } else { $time .= '=' ; }
2039 $time = $time . ' ' . $temp [ 8 ]. ':' . $temp [ 9 ]. ' to ' . $temp [ 10 ]. ':' . $temp [ 11 ];
2042 <td align='center'> $temp [0]</td>
2043 <td align='center' nowrap> $time </td>
2044 <td align='center'> $temp [12]</td>
2045 <td align='center'> $temp [13]</td>
2046 <td align='center'><image src='/images/urlfilter/ $led ' alt=' $ldesc '></td>
2049 <form method='post' name='frma $id ' action=' $ENV {'SCRIPT_NAME'}'>
2050 <input type='image' name=' $Lang ::tr{'toggle enable disable'}' src='/images/ $gif ' title=' $gdesc ' alt=' $gdesc ' />
2051 <input type='hidden' name='MODE' value='TIMECONSTRAINT' />
2052 <input type='hidden' name='ID' value=' $id ' />
2053 <input type='hidden' name='ACTIVE' value=' $toggle ' />
2054 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
2059 <form method='post' name='frmb $id ' action=' $ENV {'SCRIPT_NAME'}'>
2060 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/edit.gif' title=' $Lang ::tr{'edit'}' alt=' $Lang ::tr{'edit'}' />
2061 <input type='hidden' name='MODE' value='TIMECONSTRAINT' />
2062 <input type='hidden' name='ID' value=' $id ' />
2063 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
2068 <form method='post' name='frmc $id ' action=' $ENV {'SCRIPT_NAME'}'>
2069 <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'}' />
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{'urlfilter copy rule'}' />
2077 <form method='post' name='frmd $id ' action=' $ENV {'SCRIPT_NAME'}'>
2078 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' title=' $Lang ::tr{'remove'}' alt=' $Lang ::tr{'remove'}' />
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{'remove'}' />
2088 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' } && $tcsettings { 'ID' } eq $id ) {
2089 print "<tr bgcolor=' $Header ::colouryellow'> \n " ; }
2091 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
2093 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
2095 <td align='center' colspan='4'> $temp [16]
2097 <td align='center' colspan='5'>
2106 # If the time constraint file contains entries, print entries and action icons
2107 if (! - z
" $tcfile " ) {
2112 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
2113 <td> <img src='/images/urlfilter/led-green.gif' alt=' $Lang ::tr{'urlfilter allow access'}' /></td>
2114 <td class='base'> $Lang ::tr{'urlfilter allow'}</td>
2115 <td> <img src='/images/urlfilter/led-red.gif' alt=' $Lang ::tr{'urlfilter block access'}' /></td>
2116 <td class='base'> $Lang ::tr{'urlfilter block'}</td>
2117 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
2118 <td class='base'> $Lang ::tr{'click to disable'}</td>
2119 <td> <img src='/images/off.gif' alt=' $Lang ::tr{'click to enable'}' /></td>
2120 <td class='base'> $Lang ::tr{'click to enable'}</td>
2121 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
2122 <td class='base'> $Lang ::tr{'edit'}</td>
2123 <td> <img src='/images/urlfilter/copy.gif' alt=' $Lang ::tr{'urlfilter copy rule'}' /></td>
2124 <td class='base'> $Lang ::tr{'urlfilter copy rule'}</td>
2125 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
2126 <td class='base'> $Lang ::tr{'remove'}</td>
2133 & Header
:: closebox
();
2135 } elsif ( $uqsettings { 'UQMODE' }) {
2137 #==========================================================
2139 # Section: Set User Quota
2141 #==========================================================
2143 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}'> \n " ;
2145 $buttontext = $Lang :: tr
{ 'urlfilter add rule' };
2146 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
2147 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter edit user quota rule' }. ':' );
2148 $buttontext = $Lang :: tr
{ 'urlfilter update rule' };
2150 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter add new user quota rule' }. ':' );
2154 <table width='100%'>
2156 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
2159 <td class='base'> $Lang ::tr{'urlfilter user time quota'}:</td>
2160 <td><input type='text' name='TIME_QUOTA' value=' $uqsettings {'TIME_QUOTA'}' size='5' /></td>
2161 <td colspan='2' rowspan= '5' valign='top' class='base'>
2162 <table cellpadding='0' cellspacing='0'>
2164 <!-- intentionally left empty -->
2167 <td> $Lang ::tr{'urlfilter assigned quota users'}:</td>
2170 <!-- intentionally left empty -->
2173 <!-- intentionally left empty -->
2176 <td><textarea name='QUOTA_USERS' cols='32' rows='6' wrap='off'>
2180 $uqsettings { 'QUOTA_USERS' } =~ s/\|/\n/g ;
2181 print $uqsettings { 'QUOTA_USERS' };
2190 <td class='base'> $Lang ::tr{'urlfilter activity detection'}:</td>
2191 <td class='base'><select name='SPORADIC'>
2192 <option value='0' $selected {'SPORADIC'}{'0'}> $Lang ::tr{'urlfilter disabled'}</option>
2193 <option value='300' $selected {'SPORADIC'}{'300'}>5 $Lang ::tr{'urlfilter minutes'}</option>
2194 <option value='900' $selected {'SPORADIC'}{'900'}>15 $Lang ::tr{'urlfilter minutes'}</option>
2198 <td class='base'> $Lang ::tr{'urlfilter renewal period'}:</td>
2199 <td class='base'><select name='RENEWAL'>
2200 <option value='hourly' $selected {'RENEWAL'}{'hourly'}> $Lang ::tr{'urlfilter hourly'}</option>
2201 <option value='daily' $selected {'RENEWAL'}{'daily'}> $Lang ::tr{'urlfilter daily'}</option>
2202 <option value='weekly' $selected {'RENEWAL'}{'weekly'}> $Lang ::tr{'urlfilter weekly'}</option>
2206 <td colspan='2'> </td>
2209 <td class='base'> $Lang ::tr{'urlfilter enabled'}</td>
2210 <td class='base'><input type='checkbox' name='ENABLEQUOTA' $checked {'ENABLEQUOTA'}{'on'} /></td>
2218 <td><input type='hidden' name='ACTION' value=' $Lang ::tr{'add'}' /></td>
2219 <td><input type='hidden' name='MODE' value='USERQUOTA' /></td>
2220 <td><input type='submit' name='SUBMIT' value=' $buttontext ' /></td>
2221 <td><input type='reset' name='ACTION' value=' $Lang ::tr{'urlfilter reset'}' /></td>
2223 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
2231 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
2232 print "<input type='hidden' name='EDITING' value=' $uqsettings {'ID'}' /> \n " ;
2234 print "<input type='hidden' name='EDITING' value='no' /> \n " ;
2237 & Header
:: closebox
();
2240 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'current rules' });
2242 <table width='100%'>
2244 <td width='15%' class='boldbase' align='center'><b><nobr> $Lang ::tr{'urlfilter time quota'}</nobr></b></td>
2245 <td width='15%' class='boldbase' align='center'><b><nobr> $Lang ::tr{'urlfilter activity detection'}</nobr></b></td>
2246 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter renewal'}</b></td>
2247 <td class='boldbase' align='center'><b> $Lang ::tr{'urlfilter assigned users'}</b></td>
2248 <td width='20%' class='boldbase' colspan='4' align='center'> </td>
2253 if ( $uqsettings { 'ACTION' } ne '' or $changed ne 'no' )
2255 open ( FILE
, $uqfile );
2261 foreach $line ( @uqlist )
2265 @temp = split ( /\,/ , $line );
2266 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' } && $uqsettings { 'ID' } eq $id ) {
2267 print "<tr bgcolor=' $Header ::colouryellow'> \n " ; }
2269 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
2271 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
2272 if ( $temp [ 4 ] eq 'on' ) { $gif = 'on.gif' ; $toggle = 'off' ; $gdesc = $Lang :: tr
{ 'click to disable' };}
2273 else { $gif = 'off.gif' ; $toggle = 'on' ; $gdesc = $Lang :: tr
{ 'click to enable' }; }
2275 $temp [ 5 ] = $temp [ 1 ];
2276 if ( $temp [ 1 ] eq '0' ) { $temp [ 5 ] = $Lang :: tr
{ 'urlfilter disabled' } } else { $temp [ 5 ] = ( $temp [ 5 ]/ 60 ). ' ' . $Lang :: tr
{ 'urlfilter minutes' } }
2277 $_ = $temp [ 3 ]; s/\|/, /g ; $temp [ 6 ] = $_ ;
2280 <td align='center'> $temp [0] $Lang ::tr{'urlfilter minutes'}</td>
2281 <td align='center'> $temp [5]</td>
2282 <td align='center'> $Lang ::tr{'urlfilter '. $temp [2]}</td>
2283 <td align='center'> $temp [6]</td>
2286 <form method='post' name='frma $id ' action=' $ENV {'SCRIPT_NAME'}'>
2287 <input type='image' name=' $Lang ::tr{'toggle enable disable'}' src='/images/ $gif ' title=' $gdesc ' alt=' $gdesc ' />
2288 <input type='hidden' name='MODE' value='USERQUOTA' />
2289 <input type='hidden' name='ID' value=' $id ' />
2290 <input type='hidden' name='ACTIVE' value=' $toggle ' />
2291 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
2296 <form method='post' name='frmb $id ' action=' $ENV {'SCRIPT_NAME'}'>
2297 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/edit.gif' title=' $Lang ::tr{'edit'}' alt=' $Lang ::tr{'edit'}' />
2298 <input type='hidden' name='MODE' value='USERQUOTA' />
2299 <input type='hidden' name='ID' value=' $id ' />
2300 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
2305 <form method='post' name='frmc $id ' action=' $ENV {'SCRIPT_NAME'}'>
2306 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' title=' $Lang ::tr{'remove'}' alt=' $Lang ::tr{'remove'}' />
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{'remove'}' />
2320 # If the user quota file contains entries, print entries and action icons
2321 if (! - z
" $uqfile " ) {
2326 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
2327 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
2328 <td class='base'> $Lang ::tr{'click to disable'}</td>
2329 <td> <img src='/images/off.gif' alt=' $Lang ::tr{'click to enable'}' /></td>
2330 <td class='base'> $Lang ::tr{'click to enable'}</td>
2331 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
2332 <td class='base'> $Lang ::tr{'edit'}</td>
2333 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
2334 <td class='base'> $Lang ::tr{'remove'}</td>
2341 & Header
:: closebox
();
2345 #==========================================================
2347 # Section: Blacklist editor
2349 #==========================================================
2351 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
2353 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter urlfilter blacklist editor' }. ':' );
2357 <table width='100%'>
2359 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
2362 <td class='base'><b> $Lang ::tr{'urlfilter blacklist name'}</b></td>
2365 <td class='base'> $Lang ::tr{'urlfilter blacklist category name'}:</td>
2366 <td><input type='text' name='BE_NAME' value=' $besettings {'BE_NAME'}' size='12' /></td>
2370 <table width='100%'>
2372 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='20%'></td>
2375 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter edit domains urls expressions'}</b></td>
2378 <td colspan='2'> $Lang ::tr{'urlfilter domains'}</td>
2379 <td colspan='2'> $Lang ::tr{'urlfilter urls'}</td>
2382 <td colspan='2'><textarea name='BE_DOMAINS' cols='38' rows='10' wrap='off'>
2386 print $besettings { 'BE_DOMAINS' };
2390 <td colspan='2'><textarea name='BE_URLS' cols='38' rows='10' wrap='off'>
2394 print $besettings { 'BE_URLS' };
2400 <td colspan='4'> $Lang ::tr{'urlfilter expressions'}</td>
2403 <td colspan='4'><textarea name='BE_EXPRESSIONS' cols='80' rows='3' wrap='off'>
2407 print $besettings { 'BE_EXPRESSIONS' };
2414 <table width='100%'>
2416 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter load blacklist'}</b></td>
2419 <td width='25%' class='base'> $Lang ::tr{'urlfilter select blacklist'}:</td>
2420 <td width='20%' class='base'>
2421 <select name='BE_BLACKLIST'>
2425 & readblockcategories
;
2426 foreach ( @categories )
2428 print "<option value=' $_ ' $selected {'BE_BLACKLIST'}{ $_ }> $_ </option> \n " ;
2437 <td colpsan='4'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter load blacklist'}' /></td>
2442 <table width='100%'>
2444 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter import blacklist'}</b></td>
2447 <td colspan='4'> $Lang ::tr{'urlfilter import text'}:</td>
2450 <td nowrap><input type='file' name='IMPORTFILE' size='40' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter import blacklist'}' /></td>
2451 <td><input type='hidden' name='MODE' value='BLACKLIST_EDITOR' /></td>
2455 <table width='100%'>
2457 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter export blacklist'}</b></td>
2460 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter export blacklist'}' /></td>
2464 <table width='100%'>
2466 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter install blacklist'}</b></td>
2469 <td width='25%' class='base'> $Lang ::tr{'urlfilter dont restart urlfilter'}:</td>
2470 <td width='20%' class='base'><input type='checkbox' name='NORESTART' $checked {'NORESTART'}{'on'} /></td>
2475 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter install blacklist'}' /></td>
2478 <td class='base' colspan='4'><br> $Lang ::tr{'urlfilter install information'}</td>
2484 <td><input type='reset' name='ACTION' value=' $Lang ::tr{'urlfilter reset'}' /></td>
2486 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
2493 & Header
:: closebox
();
2498 & Header
:: closebigbox
();
2500 & Header
:: closepage
();
2502 # -------------------------------------------------------------------
2506 # transform to pre1.8 client definitions
2507 @clients = split ( /\n/ , $filtersettings { 'UNFILTERED_CLIENTS' });
2508 undef $filtersettings { 'UNFILTERED_CLIENTS' };
2511 s/^\s+//g ; s/\s+$//g ; s/\s+-\s+/-/g ; s/\s+/ /g ; s/\n//g ;
2512 $filtersettings { 'UNFILTERED_CLIENTS' } .= " $_ " ;
2514 $filtersettings { 'UNFILTERED_CLIENTS' } =~ s/\s+$// ;
2516 # transform to pre1.8 client definitions
2517 @clients = split ( /\n/ , $filtersettings { 'BANNED_CLIENTS' });
2518 undef $filtersettings { 'BANNED_CLIENTS' };
2521 s/^\s+//g ; s/\s+$//g ; s/\s+-\s+/-/g ; s/\s+/ /g ; s/\n//g ;
2522 $filtersettings { 'BANNED_CLIENTS' } .= " $_ " ;
2524 $filtersettings { 'BANNED_CLIENTS' } =~ s/\s+$// ;
2528 delete $filtersettings { 'CUSTOM_BLACK_DOMAINS' };
2529 delete $filtersettings { 'CUSTOM_BLACK_URLS' };
2530 delete $filtersettings { 'CUSTOM_WHITE_DOMAINS' };
2531 delete $filtersettings { 'CUSTOM_WHITE_URLS' };
2532 delete $filtersettings { 'CUSTOM_EXPRESSIONS' };
2533 delete $filtersettings { 'BACKGROUND' };
2534 delete $filtersettings { 'UPDATEFILE' };
2536 system ( "chown -R nobody.nobody $dbdir " );
2537 system ( '/usr/bin/squidGuard -C custom/allowed/domains >/dev/null 2>&1' );
2538 system ( '/usr/bin/squidGuard -C custom/allowed/urls >/dev/null 2>&1' );
2539 system ( '/usr/bin/squidGuard -C custom/blocked/domains >/dev/null 2>&1' );
2540 system ( '/usr/bin/squidGuard -C custom/blocked/urls >/dev/null 2>&1 ' );
2541 & setpermissions
( $dbdir );
2543 & General
:: writehash
( "${General::swroot}/urlfilter/settings" , \
%filtersettings );
2546 # -------------------------------------------------------------------
2548 sub readblockcategories
2552 & getblockcategory
( $dbdir );
2554 foreach ( @categories ) { $_ = substr ( $_ , length ( $dbdir )+ 1 ); }
2556 @filtergroups = @categories ;
2558 foreach ( @filtergroups ) {
2565 # -------------------------------------------------------------------
2567 sub getblockcategory
2569 foreach $category (< $_ [ 0 ]/*>)
2573 if ((- e
" $category /domains" ) || (- e
" $category /urls" ))
2575 unless ( $category =~ /\bcustom\b/ ) { push ( @categories , $category ); }
2577 & getblockcategory
( $category );
2582 # -------------------------------------------------------------------
2586 if (- e
" $dbdir /custom/blocked/domains" ) {
2587 open ( FILE
, " $dbdir /custom/blocked/domains" );
2588 delete $filtersettings { 'CUSTOM_BLACK_DOMAINS' };
2589 while (< FILE
>) { $filtersettings { 'CUSTOM_BLACK_DOMAINS' } .= $_ };
2593 if (- e
" $dbdir /custom/blocked/urls" ) {
2594 open ( FILE
, " $dbdir /custom/blocked/urls" );
2595 delete $filtersettings { 'CUSTOM_BLACK_URLS' };
2596 while (< FILE
>) { $filtersettings { 'CUSTOM_BLACK_URLS' } .= $_ };
2600 if (- e
" $dbdir /custom/blocked/expressions" ) {
2601 open ( FILE
, " $dbdir /custom/blocked/expressions" );
2602 delete $filtersettings { 'CUSTOM_EXPRESSIONS' };
2603 while (< FILE
>) { $filtersettings { 'CUSTOM_EXPRESSIONS' } .= $_ };
2607 if (- e
" $dbdir /custom/allowed/domains" ) {
2608 open ( FILE
, " $dbdir /custom/allowed/domains" );
2609 delete $filtersettings { 'CUSTOM_WHITE_DOMAINS' };
2610 while (< FILE
>) { $filtersettings { 'CUSTOM_WHITE_DOMAINS' } .= $_ };
2613 if (- e
" $dbdir /custom/allowed/urls" ) {
2614 open ( FILE
, " $dbdir /custom/allowed/urls" );
2615 delete $filtersettings { 'CUSTOM_WHITE_URLS' };
2616 while (< FILE
>) { $filtersettings { 'CUSTOM_WHITE_URLS' } .= $_ };
2621 # -------------------------------------------------------------------
2623 sub aggregatedconstraints
2643 @tmp1 = split ( /\,/ , $x );
2647 @tmp2 = split ( /\,/ );
2648 if (( $tmp1 [ 15 ] eq 'on' ) && ( $tmp2 [ 15 ] eq 'on' ))
2650 if (( $tmp1 [ 0 ] eq $tmp2 [ 0 ]) && ( $tmp1 [ 12 ] eq $tmp2 [ 12 ]) && ( $tmp1 [ 13 ] eq $tmp2 [ 13 ]) && ( $tmp1 [ 14 ] eq $tmp2 [ 14 ]))
2653 $tmp2 [ 16 ] .= " weekly " ;
2654 if ( $tmp1 [ 1 ] eq 'on' ) { $tmp2 [ 16 ] .= "m" ; }
2655 if ( $tmp1 [ 2 ] eq 'on' ) { $tmp2 [ 16 ] .= "t" ; }
2656 if ( $tmp1 [ 3 ] eq 'on' ) { $tmp2 [ 16 ] .= "w" ; }
2657 if ( $tmp1 [ 4 ] eq 'on' ) { $tmp2 [ 16 ] .= "h" ; }
2658 if ( $tmp1 [ 5 ] eq 'on' ) { $tmp2 [ 16 ] .= "f" ; }
2659 if ( $tmp1 [ 6 ] eq 'on' ) { $tmp2 [ 16 ] .= "a" ; }
2660 if ( $tmp1 [ 7 ] eq 'on' ) { $tmp2 [ 16 ] .= "s" ; }
2661 $tmp2 [ 16 ] .= " $tmp1 [8]: $tmp1 [9]- $tmp1 [10]: $tmp1 [11] \n " ;
2662 $_ = join ( "," , @tmp2 );
2669 $tmp1 [ 16 ] .= " weekly " ;
2670 if ( $tmp1 [ 1 ] eq 'on' ) { $tmp1 [ 16 ] .= "m" ; }
2671 if ( $tmp1 [ 2 ] eq 'on' ) { $tmp1 [ 16 ] .= "t" ; }
2672 if ( $tmp1 [ 3 ] eq 'on' ) { $tmp1 [ 16 ] .= "w" ; }
2673 if ( $tmp1 [ 4 ] eq 'on' ) { $tmp1 [ 16 ] .= "h" ; }
2674 if ( $tmp1 [ 5 ] eq 'on' ) { $tmp1 [ 16 ] .= "f" ; }
2675 if ( $tmp1 [ 6 ] eq 'on' ) { $tmp1 [ 16 ] .= "a" ; }
2676 if ( $tmp1 [ 7 ] eq 'on' ) { $tmp1 [ 16 ] .= "s" ; }
2677 $tmp1 [ 16 ] .= " $tmp1 [8]: $tmp1 [9]- $tmp1 [10]: $tmp1 [11] \n " ;
2678 $x = join ( "," , @tmp1 );
2688 # -------------------------------------------------------------------
2694 foreach $category (< $bldir /*>)
2697 system ( "chmod 755 $category &> /dev/null" );
2698 foreach $blacklist (< $category /*>)
2700 if (- f
$blacklist ) { system ( "chmod 644 $blacklist &> /dev/null" ); }
2701 if (- d
$blacklist ) { system ( "chmod 755 $blacklist &> /dev/null" ); }
2703 system ( "chmod 666 $category /*.db &> /dev/null" );
2704 & setpermissions
( $category );
2709 # -------------------------------------------------------------------
2713 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\)\$" ;
2714 my $audiovideo = " \\ .\(aiff|asf|avi|dif|divx|mov|movie|mp3|mpe?g?|mpv2|ogg|ra?m|snd|qt|wav|wma|wmf|wmv\)\$" ;
2715 my $archives = " \\ .\(bin|bz2|cab|cdr|dmg|gz|hqx|rar|smi|sit|sea|tar|tgz|zip\)\$" ;
2717 my $ident = " anonymous" ;
2730 if (!(- d
" $dbdir /custom" )) { mkdir ( " $dbdir /custom" ) }
2731 if (!(- d
" $dbdir /custom/blocked" )) { mkdir ( " $dbdir /custom/blocked" ) }
2732 if (!(- d
" $dbdir /custom/allowed" )) { mkdir ( " $dbdir /custom/allowed" ) }
2734 open ( FILE
, ">/ $dbdir /custom/blocked/domains" );
2735 print FILE
$filtersettings { 'CUSTOM_BLACK_DOMAINS' };
2737 open ( FILE
, ">/ $dbdir /custom/blocked/urls" );
2738 print FILE
$filtersettings { 'CUSTOM_BLACK_URLS' };
2740 open ( FILE
, ">/ $dbdir /custom/blocked/expressions" );
2741 print FILE
$filtersettings { 'CUSTOM_EXPRESSIONS' };
2743 open ( FILE
, ">/ $dbdir /custom/blocked/files" );
2744 if ( $filtersettings { 'BLOCK_EXECUTABLES' } eq 'on' ) { print FILE
" $executables \n " ; }
2745 if ( $filtersettings { 'BLOCK_AUDIO-VIDEO' } eq 'on' ) { print FILE
" $audiovideo \n " ; }
2746 if ( $filtersettings { 'BLOCK_ARCHIVES' } eq 'on' ) { print FILE
" $archives \n " ; }
2748 open ( FILE
, ">/ $dbdir /custom/allowed/domains" );
2749 print FILE
$filtersettings { 'CUSTOM_WHITE_DOMAINS' };
2751 open ( FILE
, ">/ $dbdir /custom/allowed/urls" );
2752 print FILE
$filtersettings { 'CUSTOM_WHITE_URLS' };
2755 if ( $filtersettings { 'ENABLE_USERNAME_LOG' } eq 'on' ) { $ident = "" ; }
2757 if ( $filtersettings { 'REDIRECT_PAGE' } eq '' )
2759 if (( $filtersettings { 'SHOW_CATEGORY' } eq 'on' ) || ( $filtersettings { 'SHOW_URL' } eq 'on' ) || ( $filtersettings { 'SHOW_IP' } eq 'on' )) {
2760 if ( $filtersettings { 'SHOW_CATEGORY' } eq 'on' ) { $redirect .= "&category= %t " ; }
2761 if ( $filtersettings { 'SHOW_URL' } eq 'on' ) { $redirect .= "&url= %u " ; }
2762 if ( $filtersettings { 'SHOW_IP' } eq 'on' ) { $redirect .= "&ip= %a " ; }
2763 $redirect =~ s/^&/?/ ;
2764 $redirect = "http:\/\/ $netsettings {'GREEN_ADDRESS'}: $http_port \/redirect.cgi" . $redirect ;
2766 $redirect = "http:\/\/ $netsettings {'GREEN_ADDRESS'}: $http_port \/redirect.cgi" ;
2768 } else { $redirect = $filtersettings { 'REDIRECT_PAGE' }; }
2770 if ( $filtersettings { 'ENABLE_DNSERROR' } eq 'on' ) { $redirect = "302:http://0.0.0.0" ; }
2774 if ( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' )
2776 $defaultrule .= "custom-allowed " ;
2778 if ( $filtersettings { 'BLOCK_ALL' } eq 'on' )
2780 $defaultrule .= "none" ;
2784 if ( $filtersettings { 'BLOCK_IP_ADDR' } eq 'on' )
2786 $defaultrule .= "!in-addr " ;
2788 for ( $i = 0 ; $i <= @filtergroups ; $i ++) {
2789 if ( $filtersettings { @filtergroups [ $i ]} eq 'on' )
2791 $defaultrule .= "! @categories [ $i ] " ;
2794 if ( $filtersettings { 'ENABLE_CUSTOM_BLACKLIST' } eq 'on' )
2796 $defaultrule .= "!custom-blocked " ;
2798 if ( $filtersettings { 'ENABLE_CUSTOM_EXPRESSIONS' } eq 'on' )
2800 $defaultrule .= "!custom-expressions " ;
2802 if (( $filtersettings { 'BLOCK_EXECUTABLES' } eq 'on' ) ||
2803 ( $filtersettings { 'BLOCK_AUDIO-VIDEO' } eq 'on' ) ||
2804 ( $filtersettings { 'BLOCK_ARCHIVES' } eq 'on' ))
2806 $defaultrule .= "!files " ;
2808 $defaultrule .= "any" ;
2811 $defaultrule =~ s/\// _
/ g
;
2813 open ( FILE
, ">${General::swroot}/urlfilter/squidGuard.conf" ) or die "Unable to write squidGuard.conf file" ;
2816 print FILE
"logdir /var/log/squidGuard \n " ;
2817 print FILE
"dbhome $dbdir \n\n " ;
2819 undef @repositoryfiles ;
2820 if ( $filtersettings { 'ENABLE_REWRITE' } eq 'on' )
2822 @repositorylist = < $repository /*>;
2823 foreach ( @repositorylist )
2825 if (!- d
) { push ( @repositoryfiles , substr ( $_ , rindex ( $_ , "/" )+ 1 )); }
2829 if ((( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles )) || ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' ))
2831 print FILE
"rewrite rew-rule-1 { \n " ;
2833 if (( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles ))
2835 print FILE
" # rewrite localfiles \n " ;
2836 foreach ( @repositoryfiles )
2838 print FILE
" s@.*/ $_ \$\ @http :// $netsettings {'GREEN_ADDRESS'}: $http_port /repository/ $_ \ @i \n " ;
2842 if ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' )
2844 print FILE
" # rewrite safesearch \n " ;
2845 print FILE
" s@(.* \\ Wgoogle \\ . \\ w+/(webhp|search|imghp|images|grphp|groups|frghp|froogle) \\ ?)(.*)( \\ bsafe= \\ w+)(.*)\@ \\ 1 \\ 3safe=strict \\ 5\ @i \n " ;
2846 print FILE
" s@(.* \\ Wgoogle \\ . \\ w+/(webhp|search|imghp|images|grphp|groups|frghp|froogle) \\ ?)(.*)\@ \\ 1safe=strict \\ \& \\ 3\ @i \n " ;
2847 print FILE
" s@(.* \\ Wsearch \\ .yahoo \\ . \\ w+/search \\ W)(.*)( \\ bvm= \\ w+)(.*)\@ \\ 1 \\ 2vm=r \\ 4\ @i \n " ;
2848 print FILE
" s@(.* \\ Wsearch \\ .yahoo \\ . \\ w+/search \\ W.*)\@ \\ 1 \\ \&vm=r\ @i \n " ;
2849 print FILE
" s@(.* \\ Walltheweb \\ .com/customize \\ ?)(.*)( \\ bcopt_offensive= \\ w+)(.*)\@ \\ 1 \\ 2copt_offensive=on \\ 4\ @i \n " ;
2854 if ((!( $filtersettings { 'UNFILTERED_CLIENTS' } eq '' )) && ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' )) {
2855 print FILE
"rewrite rew-rule-2 { \n " ;
2856 if (( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles ))
2858 print FILE
" # rewrite localfiles \n " ;
2859 foreach ( @repositoryfiles )
2861 print FILE
" s@.*/ $_ \$\ @http :// $netsettings {'GREEN_ADDRESS'}: $http_port /repository/ $_ \ @i \n " ;
2864 print FILE
" # rewrite nothing \n " ;
2870 if (!( $filtersettings { 'UNFILTERED_CLIENTS' } eq '' )) {
2871 print FILE
"src unfiltered { \n " ;
2872 print FILE
" ip $filtersettings {'UNFILTERED_CLIENTS'} \n " ;
2875 if (!( $filtersettings { 'BANNED_CLIENTS' } eq '' )) {
2876 print FILE
"src banned { \n " ;
2877 print FILE
" ip $filtersettings {'BANNED_CLIENTS'} \n " ;
2878 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
2880 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
2882 print FILE
" logfile " . $ident . " banned.log \n " ;
2884 print FILE
" logfile " . $ident . " urlfilter.log \n " ;
2906 $uq [ 0 ] = $uq [ 0 ] * 60 ;
2907 if ( $uq [ 1 ] eq '0' ) {
2908 if ( $uq [ 2 ] eq 'hourly' ) { $uq [ 1 ] = 3600 }
2909 if ( $uq [ 2 ] eq 'daily' ) { $uq [ 1 ] = 86400 }
2910 if ( $uq [ 2 ] eq 'weekly' ) { $uq [ 1 ] = 604800 }
2913 print FILE
"src quota- $idx { \n " ;
2914 print FILE
" user $uq [3] \n " ;
2915 print FILE
" userquota $uq [0] $uq [1] $uq [2] \n " ;
2923 @tclist = & aggregatedconstraints
;
2932 if ( $tc [ 15 ] eq 'on' )
2935 print FILE
"src network- $idx { \n " ;
2936 @clients = split ( / / , $tc [ 12 ]);
2937 @temp = split ( /-/ , $clients [ 0 ]);
2938 if ( (& General
:: validipormask
( $temp [ 0 ])) || (& General
:: validipandmask
( $temp [ 0 ])))
2940 print FILE
" ip $tc [12] \n " ;
2943 @clients = split ( / / , $tc [ 12 ]);
2944 foreach $line ( @clients )
2946 $line =~ s/(^\w+)\\(\w+$)/$1%5c$2/ ;
2947 print FILE
" $line " ;
2951 if (( $filtersettings { 'ENABLE_LOG' } eq 'on' ) && ( $tc [ 14 ] eq 'block' ) && ( $tc [ 13 ] eq 'any' ))
2953 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
2955 print FILE
" logfile " . $ident . " timeconst.log \n " ;
2957 print FILE
" logfile " . $ident . " urlfilter.log \n " ;
2969 if ( $tc [ 15 ] eq 'on' )
2972 print FILE
"time constraint- $idx { \n " ;
2973 print FILE
" $tc [16] \n " ;
2979 foreach $category ( @categories ) {
2980 $blacklist = $category ;
2981 $category =~ s/\// _
/ g
;
2982 if ( $filtersettings { "FILTER_" . uc ( $category )} ne "on" ){ next ;}
2983 print FILE
"dest $category { \n " ;
2984 if (- e
" $dbdir / $blacklist /domains" ) {
2985 print FILE
" domainlist $blacklist \/domains \n " ;
2987 if (- e
" $dbdir / $blacklist /urls" ) {
2988 print FILE
" urllist $blacklist \/urls \n " ;
2990 if ((- e
" $dbdir / $blacklist /expressions" ) && ( $filtersettings { 'ENABLE_EXPR_LISTS' } eq 'on' )) {
2991 print FILE
" expressionlist $blacklist \/expressions \n " ;
2993 if ((( $category eq 'ads' ) || ( $category eq 'adv' )) && ( $filtersettings { 'ENABLE_EMPTY_ADS' } eq 'on' ))
2995 print FILE
" redirect http:\/\/ $netsettings {'GREEN_ADDRESS'}: $http_port \/images/urlfilter/1x1.gif \n " ;
2997 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
2999 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
3001 print FILE
" logfile $ident $category .log \n " ;
3003 print FILE
" logfile $ident urlfilter.log \n " ;
3007 $category = $blacklist ;
3010 print FILE
"dest files { \n " ;
3011 print FILE
" expressionlist custom\/blocked\/files \n " ;
3012 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
3014 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
3016 print FILE
" logfile $ident files.log \n " ;
3018 print FILE
" logfile $ident urlfilter.log \n " ;
3023 print FILE
"dest custom-allowed { \n " ;
3024 print FILE
" domainlist custom\/allowed\/domains \n " ;
3025 print FILE
" urllist custom\/allowed\/urls \n " ;
3028 print FILE
"dest custom-blocked { \n " ;
3029 print FILE
" domainlist custom\/blocked\/domains \n " ;
3030 print FILE
" urllist custom\/blocked\/urls \n " ;
3031 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
3033 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
3035 print FILE
" logfile $ident custom.log \n " ;
3037 print FILE
" logfile $ident urlfilter.log \n " ;
3042 print FILE
"dest custom-expressions { \n " ;
3043 print FILE
" expressionlist custom\/blocked\/expressions \n " ;
3044 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
3046 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
3048 print FILE
" logfile $ident custom.log \n " ;
3050 print FILE
" logfile $ident urlfilter.log \n " ;
3055 print FILE
"acl { \n " ;
3056 if (!( $filtersettings { 'UNFILTERED_CLIENTS' } eq '' )) {
3057 print FILE
" unfiltered { \n " ;
3058 print FILE
" pass all \n " ;
3059 if ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' )
3061 print FILE
" rewrite rew-rule-2 \n " ;
3063 print FILE
" } \n\n " ;
3065 if (!( $filtersettings { 'BANNED_CLIENTS' } eq '' )) {
3066 print FILE
" banned { \n " ;
3067 print FILE
" pass " ;
3068 if (( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'on' ))
3070 print FILE
"custom-allowed " ;
3072 print FILE
"none \n " ;
3073 print FILE
" } \n\n " ;
3090 $qredirect = $redirect ;
3091 $qredirect =~ s/\%t/\%q\%20-\%20\%i/ ;
3092 print FILE
" quota- $idx { \n " ;
3093 print FILE
" pass " ;
3094 if (( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'on' ))
3096 print FILE
"custom-allowed " ;
3098 print FILE
"none \n " ;
3099 unless ( $redirect eq $qredirect ) { print FILE
" redirect $qredirect \n " ; }
3100 print FILE
" } \n\n " ;
3112 @ec = split ( /\|/ , $tc [ 13 ]);
3113 foreach ( @ec ) { s/\// _
/ g
; }
3114 if ( $tc [ 15 ] eq 'on' )
3117 print FILE
" network- $idx $tc [0] constraint- $idx { \n " ;
3118 print FILE
" pass " ;
3120 if ( $filtersettings { 'BLOCK_ALL' } eq 'on' )
3122 if ( $tc [ 14 ] eq 'block' )
3124 if (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' )) {
3125 if (( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'on' ))
3127 print FILE
"custom-allowed " ;
3131 print FILE
$defaultrule ;
3138 print FILE
$defaultrule unless (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ));
3141 if ( $tc [ 14 ] eq 'block' )
3143 $tcrule = $defaultrule ;
3144 if ( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) {
3145 $tcrule =~ s/custom-allowed // ;
3146 print FILE
"custom-allowed " unless (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'off' ));
3148 if (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' )) {
3153 print FILE
"! $_ " unless ( index ( $defaultrule , "!" . $_ . " " ) ge 0 );
3156 print FILE
$tcrule unless (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ));
3158 $tcrule = $defaultrule ;
3159 if (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ))
3165 $tcrule = " $_ " . $tcrule unless ( index ( $defaultrule , "!" . $_ . " " ) ge 0 );
3166 $tcrule =~ s/!$_ // ;
3175 print FILE
" } \n\n " ;
3180 print FILE
" default { \n " ;
3181 print FILE
" pass $defaultrule \n " ;
3182 if (( $filtersettings { 'ENABLE_LOG' } eq 'on' ) && ( $filtersettings { 'BLOCK_ALL' } eq 'on' ))
3184 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
3186 print FILE
" logfile" . $ident . " default.log \n " ;
3188 print FILE
" logfile" . $ident . " urlfilter.log \n " ;
3191 if ((( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles )) || ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' ))
3193 print FILE
" rewrite rew-rule-1 \n " ;
3195 print FILE
" redirect $redirect \n " ;
3202 # -------------------------------------------------------------------