]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/urlfilter.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2005-2010 IPFire Team #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
24 # enable only the following on debugging purpose
26 #use CGI::Carp 'fatalsToBrowser';
31 require '/var/ipfire/general-functions.pl' ;
32 require "${General::swroot}/lang.pl" ;
33 require "${General::swroot}/header.pl" ;
39 my %filtersettings =();
43 my %updatesettings =();
58 my $tcfile = "${General::swroot}/urlfilter/timeconst" ;
59 my $uqfile = "${General::swroot}/urlfilter/userquota" ;
60 my $dbdir = "${General::swroot}/urlfilter/blacklists" ;
61 my $editdir = "${General::swroot}/urlfilter/editor" ;
62 my $repository = "/var/urlrepo" ;
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" ;
71 my $restoremessage = '' ;
77 my @repositorylist =();
78 my @repositoryfiles =();
80 my @selectedcategories =();
84 my @source_urllist =();
96 if (! - d
$dbdir ) { mkdir ( " $dbdir " ); }
97 if (! - e
$tcfile ) { system ( "touch $tcfile " ); }
98 if (! - e
$uqfile ) { system ( "touch $uqfile " ); }
99 if (! - e
$sourceurlfile ) { system ( "touch $sourceurlfile " ); }
101 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%netsettings );
102 & General
:: readhash
( "${General::swroot}/main/settings" , \
%mainsettings );
103 & General
:: readhash
( "${General::swroot}/proxy/settings" , \
%proxysettings );
105 & readblockcategories
;
113 open ( FILE
, $sourceurlfile );
114 @source_urllist = < FILE
>;
117 $filtersettings { 'ENABLE_CUSTOM_BLACKLIST' } = 'off' ;
118 $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } = 'off' ;
119 $filtersettings { 'ENABLE_CUSTOM_EXPRESSIONS' } = 'off' ;
120 $filtersettings { 'BLOCK_EXECUTABLES' } = 'off' ;
121 $filtersettings { 'BLOCK_AUDIO-VIDEO' } = 'off' ;
122 $filtersettings { 'BLOCK_ARCHIVES' } = 'off' ;
123 $filtersettings { 'ENABLE_REWRITE' } = 'off' ;
124 $filtersettings { 'UNFILTERED_CLIENTS' } = '' ;
125 $filtersettings { 'BANNED_CLIENTS' } = '' ;
126 $filtersettings { 'SHOW_CATEGORY' } = 'off' ;
127 $filtersettings { 'SHOW_URL' } = 'off' ;
128 $filtersettings { 'SHOW_IP' } = 'off' ;
129 $filtersettings { 'ENABLE_DNSERROR' } = 'off' ;
130 $filtersettings { 'ENABLE_JPEG' } = 'off' ;
131 $filtersettings { 'REDIRECT_PAGE' } = '' ;
132 $filtersettings { 'MSG_TEXT_1' } = '' ;
133 $filtersettings { 'MSG_TEXT_2' } = '' ;
134 $filtersettings { 'MSG_TEXT_3' } = '' ;
135 $filtersettings { 'ENABLE_EXPR_LISTS' } = 'off' ;
136 $filtersettings { 'BLOCK_IP_ADDR' } = 'off' ;
137 $filtersettings { 'BLOCK_ALL' } = 'off' ;
138 $filtersettings { 'ENABLE_EMPTY_ADS' } = 'off' ;
139 $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } = 'off' ;
140 $filtersettings { 'ENABLE_SAFESEARCH' } = 'off' ;
141 $filtersettings { 'ENABLE_LOG' } = 'off' ;
142 $filtersettings { 'ENABLE_USERNAME_LOG' } = 'off' ;
143 $filtersettings { 'ENABLE_CATEGORY_LOG' } = 'off' ;
144 $filtersettings { 'ENABLE_AUTOUPDATE' } = 'off' ;
146 $filtersettings { 'ACTION' } = '' ;
147 $filtersettings { 'VALID' } = '' ;
149 & Header
:: getcgihash
( \
%filtersettings );
150 & Header
:: getcgihash
( \
%tcsettings );
151 & Header
:: getcgihash
( \
%uqsettings );
152 & Header
:: getcgihash
( \
%besettings );
154 if (( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'save' }) ||
155 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter save and restart' }) ||
156 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload file' }) ||
157 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter remove file' }) ||
158 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload blacklist' }) ||
159 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter backup' }) ||
160 ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter restore' }))
163 @clients = split ( /\n/ , $filtersettings { 'UNFILTERED_CLIENTS' });
166 s/^\s+//g ; s/\s+$//g ; s/\s+-\s+/-/g ; s/\s+/ /g ; s/\n//g ;
167 if ( /.*-.*-.*/ ) { $errormessage = $Lang :: tr
{ 'urlfilter invalid ip or mask error' }; }
169 foreach ( @temp ) { unless ((& General
:: validipormask
( $_ )) || (& General
:: validipandmask
( $_ ))) { $errormessage = $Lang :: tr
{ 'urlfilter invalid ip or mask error' }; } }
171 @clients = split ( /\n/ , $filtersettings { 'BANNED_CLIENTS' });
174 s/^\s+//g ; s/\s+$//g ; s/\s+-\s+/-/g ; s/\s+/ /g ; s/\n//g ;
175 if ( /.*-.*-.*/ ) { $errormessage = $Lang :: tr
{ 'urlfilter invalid ip or mask error' }; }
177 foreach ( @temp ) { unless ((& General
:: validipormask
( $_ )) || (& General
:: validipandmask
( $_ ))) { $errormessage = $Lang :: tr
{ 'urlfilter invalid ip or mask error' }; } }
179 if ( $errormessage ) { goto ERROR
; }
181 if ((!( $filtersettings { 'REDIRECT_PAGE' } eq '' )) && (!( $filtersettings { 'REDIRECT_PAGE' } =~ /^https?:\/ \
// )))
183 $filtersettings { 'REDIRECT_PAGE' } = "http://" . $filtersettings { 'REDIRECT_PAGE' };
186 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter remove file' })
188 if (- e
" $repository / $filtersettings {'ID'}" ) { unlink ( " $repository / $filtersettings {'ID'}" ); }
189 $filtersettings { 'ACTION' } = $Lang :: tr
{ 'urlfilter manage repository' };
192 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload file' })
194 & Header
:: getcgihash
( \
%filtersettings , { 'wantfile' => 1 , 'filevar' => 'UPLOADFILE' });
196 $filtersettings { 'ACTION' } = $Lang :: tr
{ 'urlfilter manage repository' };
197 $_ = $filtersettings { 'UPLOADFILE' };
199 $_ = substr ( $_ , rindex ( $_ , "/" )+ 1 );
201 if ( copy
( $filtersettings { 'UPLOADFILE' }, " $repository / $_ " ) != 1 )
210 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter upload blacklist' })
212 & Header
:: getcgihash
( \
%filtersettings , { 'wantfile' => 1 , 'filevar' => 'UPDATEFILE' });
214 if (!( $filtersettings { 'UPDATEFILE' } =~ /.tar.gz$/ ))
216 $errormessage = $Lang :: tr
{ 'urlfilter wrong filetype' };
220 if ( copy
( $filtersettings { 'UPDATEFILE' }, "${General::swroot}/urlfilter/blacklists.tar.gz" ) != 1 )
226 if (!(- d
"${General::swroot}/urlfilter/update" )) { mkdir ( "${General::swroot}/urlfilter/update" ); }
228 my $exitcode = system ( "/bin/tar --no-same-owner -xzf ${General::swroot}/urlfilter/blacklists.tar.gz -C ${General::swroot}/urlfilter/update" );
232 $errormessage = $Lang :: tr
{ 'urlfilter tar error' };
235 if (- d
"${General::swroot}/urlfilter/update/BL" )
237 system ( "mv ${General::swroot}/urlfilter/update/BL ${General::swroot}/urlfilter/update/blacklists" );
240 if (- d
"${General::swroot}/urlfilter/update/category" )
242 system ( "mv ${General::swroot}/urlfilter/update/category ${General::swroot}/urlfilter/update/blacklists" );
245 if (!(- d
"${General::swroot}/urlfilter/update/blacklists" ))
247 $errormessage = $Lang :: tr
{ 'urlfilter invalid content' };
249 system ( "cp -r ${General::swroot}/urlfilter/update/blacklists/* $dbdir " );
251 & readblockcategories
;
256 $updatemessage = $Lang :: tr
{ 'urlfilter upload success' };
257 system ( "${General::swroot}/urlfilter/bin/prebuild.pl &" );
258 system ( "logger -t installpackage[urlfilter] \" URL filter blacklist - Blacklist update from local source completed \" " );
261 if (- d
"${General::swroot}/urlfilter/update" ) { system ( "rm -rf ${General::swroot}/urlfilter/update" ); }
262 if (- e
"${General::swroot}/urlfilter/blacklists.tar.gz" ) { unlink ( "${General::swroot}/urlfilter/blacklists.tar.gz" ); }
263 if ( $errormessage ) { goto ERROR
; }
266 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter backup' })
268 $blistbackup = ( $filtersettings { 'ENABLE_FULLBACKUP' } eq 'on' ) ?
"blacklists" : "blacklists/custom" ;
269 if ( system ( "/bin/tar -C ${General::swroot}/urlfilter -czf ${General::swroot}/urlfilter/backup.tar.gz settings timeconst userquota autoupdate $blistbackup " ))
271 $errormessage = $Lang :: tr
{ 'urlfilter backup error' };
276 print "Content-type: application/gzip \n " ;
277 print "Content-length: " ;
278 print (- s
"${General::swroot}/urlfilter/backup.tar.gz" );
280 print "Content-disposition: attachment; filename=urlfilter-backup.tar.gz \n\n " ;
282 open ( FILE
, "${General::swroot}/urlfilter/backup.tar.gz" );
283 while (< FILE
>) { print ; }
286 if (- e
"${General::swroot}/urlfilter/backup.tar.gz" ) { unlink ( "${General::swroot}/urlfilter/backup.tar.gz" ); }
291 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter restore' })
293 & Header
:: getcgihash
( \
%filtersettings , { 'wantfile' => 1 , 'filevar' => 'UPDATEFILE' });
295 if (!( $filtersettings { 'UPDATEFILE' } =~ /.tar.gz$/ ))
297 $errormessage = $Lang :: tr
{ 'urlfilter wrong filetype' };
301 if (!(- d
"${General::swroot}/urlfilter/restore" )) { mkdir ( "${General::swroot}/urlfilter/restore" ); }
303 if ( copy
( $filtersettings { 'UPDATEFILE' }, "${General::swroot}/urlfilter/backup.tar.gz" ) != 1 )
308 my $exitcode = system ( "/bin/tar --no-same-owner --preserve-permissions -xzf ${General::swroot}/urlfilter/backup.tar.gz -C ${General::swroot}/urlfilter/restore" );
311 $errormessage = $Lang :: tr
{ 'urlfilter tar error' };
313 if (!(- e
"${General::swroot}/urlfilter/restore/settings" ))
315 $errormessage = $Lang :: tr
{ 'urlfilter invalid restore file' };
317 system ( "cp -rp ${General::swroot}/urlfilter/restore/* ${General::swroot}/urlfilter/" );
318 & readblockcategories
;
322 $restoremessage = $Lang :: tr
{ 'urlfilter restore success' };
326 if (- e
"${General::swroot}/urlfilter/backup.tar.gz" ) { unlink ( "${General::swroot}/urlfilter/backup.tar.gz" ); }
327 if (- d
"${General::swroot}/urlfilter/restore" ) { system ( "rm -rf ${General::swroot}/urlfilter/restore" ); }
328 if ( $errormessage ) { goto ERROR
; }
331 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'save' })
333 $filtersettings { 'VALID' } = 'yes' ;
337 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter save and restart' })
339 if ((!(- e
"${General::swroot}/proxy/enable" )) && (!(- e
"${General::swroot}/proxy/enable_blue" )))
341 $errormessage = $Lang :: tr
{ 'urlfilter web proxy service required' };
344 if (!( $proxysettings { 'ENABLE_FILTER' } eq 'on' ))
346 $errormessage = $Lang :: tr
{ 'urlfilter not enabled' };
350 $filtersettings { 'VALID' } = 'yes' ;
353 system ( '/usr/local/bin/squidctrl restart >/dev/null 2>&1' );
357 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter set time constraints' }) { $tcsettings { 'TCMODE' } = 'on' }
359 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'add' }))
361 $tcsettings { 'TCMODE' }= 'on' ;
363 if (! $tcsettings { 'DST' })
365 $errormessage = $Lang :: tr
{ 'urlfilter dst error' };
368 if (! $tcsettings { 'SRC' })
370 $errormessage = $Lang :: tr
{ 'urlfilter src error' };
373 if (!( $tcsettings { 'TO_HOUR' }. $tcsettings { 'TO_MINUTE' } gt $tcsettings { 'FROM_HOUR' }. $tcsettings { 'FROM_MINUTE' }))
375 $errormessage = $Lang :: tr
{ 'urlfilter timespace error' };
378 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' )))
380 $errormessage = $Lang :: tr
{ 'urlfilter weekday error' };
385 # transform to pre1.8 client definitions
386 @clients = split ( /\n/ , $tcsettings { 'SRC' });
387 undef $tcsettings { 'SRC' };
390 s/^\s+//g ; s/\s+$//g ; s/\s+-\s+/-/g ; s/\s+/ /g ; s/\n//g ;
391 $tcsettings { 'SRC' } .= " $_ " ;
393 $tcsettings { 'SRC' } =~ s/\s+$// ;
395 if ( $tcsettings { 'DST' } =~ /^any/ ) { $tcsettings { 'DST' } = 'any' ; }
396 if ( $tcsettings { 'ENABLERULE' } eq 'on' ) { $tcsettings { 'ACTIVE' } = $tcsettings { 'ENABLERULE' }; } else { $tcsettings { 'ACTIVE' } = 'off' }
398 $tcsettings { 'ENABLERULE' } = 'on' ;
399 if ( $tcsettings { 'EDITING' } eq 'no' ) {
400 open ( FILE
, ">> $tcfile " );
402 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 " ;
404 open ( FILE
, "> $tcfile " );
407 foreach $line ( @tclist )
410 if ( $tcsettings { 'EDITING' } eq $id ) {
411 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 " ;
412 } else { print FILE
" $line " ; }
417 $tcsettings { 'CHANGED' }= 'yes' ;
418 $tcsettings { 'TCMODE' }= 'on' ;
421 if ( $tcsettings { 'EDITING' } ne 'no' )
423 $tcsettings { 'ACTION' } = $Lang :: tr
{ 'edit' };
424 $tcsettings { 'ID' } = $tcsettings { 'EDITING' };
429 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter copy rule' }) && (! $errormessage ))
432 foreach $line ( @tclist )
435 if ( $tcsettings { 'ID' } eq $id )
438 @temp = split ( /\,/ , $line );
439 $tcsettings { 'DEFINITION' } = $temp [ 0 ];
440 $tcsettings { 'MON' } = $temp [ 1 ];
441 $tcsettings { 'TUE' } = $temp [ 2 ];
442 $tcsettings { 'WED' } = $temp [ 3 ];
443 $tcsettings { 'THU' } = $temp [ 4 ];
444 $tcsettings { 'FRI' } = $temp [ 5 ];
445 $tcsettings { 'SAT' } = $temp [ 6 ];
446 $tcsettings { 'SUN' } = $temp [ 7 ];
447 $tcsettings { 'FROM_HOUR' } = $temp [ 8 ];
448 $tcsettings { 'FROM_MINUTE' } = $temp [ 9 ];
449 $tcsettings { 'TO_HOUR' } = $temp [ 10 ];
450 $tcsettings { 'TO_MINUTE' } = $temp [ 11 ];
451 $tcsettings { 'SRC' } = $temp [ 12 ];
452 $tcsettings { 'DST' } = $temp [ 13 ];
453 $tcsettings { 'ACCESS' } = $temp [ 14 ];
454 $tcsettings { 'ENABLERULE' } = $temp [ 15 ];
455 $tcsettings { 'COMMENT' } = $temp [ 16 ];
458 $tcsettings { 'TCMODE' }= 'on' ;
461 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'remove' }))
464 open ( FILE
, "> $tcfile " );
466 foreach $line ( @tclist )
469 unless ( $tcsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
472 $tcsettings { 'CHANGED' }= 'yes' ;
473 $tcsettings { 'TCMODE' }= 'on' ;
476 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter restart' }))
478 if (!( $proxysettings { 'ENABLE_FILTER' } eq 'on' ))
480 $errormessage = $Lang :: tr
{ 'urlfilter not enabled' };
482 if ((!(- e
"${General::swroot}/proxy/enable" )) && (!(- e
"${General::swroot}/proxy/enable_blue" )))
484 $errormessage = $Lang :: tr
{ 'urlfilter web proxy service required' };
487 if (! $errormessage ) { system ( '/usr/local/bin/squidctrl restart >/dev/null 2>&1' ); }
488 $tcsettings { 'TCMODE' }= 'on' ;
491 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }))
493 open ( FILE
, "> $tcfile " );
496 foreach $line ( @tclist )
499 unless ( $tcsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
503 @temp = split ( /\,/ , $line );
504 if ( $temp [ 15 ] eq 'on' ) { $temp [ 15 ] = 'off' ; } else { $temp [ 15 ] = 'on' }
505 print FILE
" $temp [0], $temp [1], $temp [2], $temp [3], $temp [4], $temp [5], $temp [6], $temp [7], $temp [8], $temp [9], $temp [10], $temp [11], $temp [12], $temp [13], $temp [14], $temp [15], $temp [16] \n " ;
509 $tcsettings { 'CHANGED' }= 'yes' ;
510 $tcsettings { 'TCMODE' }= 'on' ;
513 if (( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) && ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) && (! $errormessage ))
516 foreach $line ( @tclist )
519 if ( $tcsettings { 'ID' } eq $id )
522 @temp = split ( /\,/ , $line );
523 $tcsettings { 'DEFINITION' } = $temp [ 0 ];
524 $tcsettings { 'MON' } = $temp [ 1 ];
525 $tcsettings { 'TUE' } = $temp [ 2 ];
526 $tcsettings { 'WED' } = $temp [ 3 ];
527 $tcsettings { 'THU' } = $temp [ 4 ];
528 $tcsettings { 'FRI' } = $temp [ 5 ];
529 $tcsettings { 'SAT' } = $temp [ 6 ];
530 $tcsettings { 'SUN' } = $temp [ 7 ];
531 $tcsettings { 'FROM_HOUR' } = $temp [ 8 ];
532 $tcsettings { 'FROM_MINUTE' } = $temp [ 9 ];
533 $tcsettings { 'TO_HOUR' } = $temp [ 10 ];
534 $tcsettings { 'TO_MINUTE' } = $temp [ 11 ];
535 $tcsettings { 'SRC' } = $temp [ 12 ];
536 $tcsettings { 'DST' } = $temp [ 13 ];
537 $tcsettings { 'ACCESS' } = $temp [ 14 ];
538 $tcsettings { 'ENABLERULE' } = $temp [ 15 ];
539 $tcsettings { 'COMMENT' } = $temp [ 16 ];
542 $tcsettings { 'TCMODE' }= 'on' ;
545 if ((! $errormessage ) && (!( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter copy rule' })) && (!( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }))) {
546 $tcsettings { 'ENABLERULE' }= 'on' ;
547 $tcsettings { 'TO_HOUR' }= '24' ;
550 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter set user quota' }) { $uqsettings { 'UQMODE' } = 'on' }
552 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'add' }))
554 $uqsettings { 'UQMODE' }= 'on' ;
556 if ((!( $uqsettings { 'TIME_QUOTA' } =~ /^\d+/ )) || ( $uqsettings { 'TIME_QUOTA' } < '1' ))
558 $errormessage = $Lang :: tr
{ 'urlfilter quota time error' };
561 @temp = split ( /\n/ , $uqsettings { 'QUOTA_USERS' });
562 undef $uqsettings { 'QUOTA_USERS' };
565 s/^\s+//g ; s/\s+$//g ;
566 if ( $_ ) { $uqsettings { 'QUOTA_USERS' } .= $_ . " \n " ; }
569 if ( $uqsettings { 'QUOTA_USERS' } eq '' )
571 $errormessage = $Lang :: tr
{ 'urlfilter quota user error' };
574 $_ = $uqsettings { 'QUOTA_USERS' };
576 my $quota_users = $_ ;
578 if ( $uqsettings { 'QUOTA_USERS' } =~ /\\/ )
580 $errormessage = $Lang :: tr
{ 'urlfilter invalid user error' };
583 if (! $errormessage ) {
584 if ( $uqsettings { 'ENABLEQUOTA' } eq 'on' ) { $uqsettings { 'ACTIVE' } = $uqsettings { 'ENABLEQUOTA' }; } else { $uqsettings { 'ACTIVE' } = 'off' }
586 $uqsettings { 'ENABLERULE' } = 'on' ;
587 if ( $uqsettings { 'EDITING' } eq 'no' ) {
588 open ( FILE
, ">> $uqfile " );
590 print FILE
" $uqsettings {'TIME_QUOTA'}, $uqsettings {'SPORADIC'}, $uqsettings {'RENEWAL'}, $quota_users , $uqsettings {'ACTIVE'} \n " ;
592 open ( FILE
, "> $uqfile " );
595 foreach $line ( @uqlist )
598 if ( $uqsettings { 'EDITING' } eq $id ) {
599 print FILE
" $uqsettings {'TIME_QUOTA'}, $uqsettings {'SPORADIC'}, $uqsettings {'RENEWAL'}, $quota_users , $uqsettings {'ACTIVE'} \n " ;
600 } else { print FILE
" $line " ; }
605 $uqsettings { 'CHANGED' }= 'yes' ;
606 $uqsettings { 'MODE' }= 'USERQUOTA' ;
607 $uqsettings { 'UQMODE' }= 'on' ;
610 if ( $uqsettings { 'EDITING' } ne 'no' )
612 $uqsettings { 'ACTION' } = $Lang :: tr
{ 'edit' };
613 $uqsettings { 'ID' } = $uqsettings { 'EDITING' };
618 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'remove' }))
621 open ( FILE
, "> $uqfile " );
623 foreach $line ( @uqlist )
626 unless ( $uqsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
629 $uqsettings { 'CHANGED' }= 'yes' ;
630 $uqsettings { 'UQMODE' }= 'on' ;
633 if (! $errormessage ) {
634 $uqsettings { 'ENABLEQUOTA' }= 'on' ;
637 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) && (! $errormessage ))
640 foreach $line ( @uqlist )
643 if ( $uqsettings { 'ID' } eq $id )
646 @temp = split ( /\,/ , $line );
647 $uqsettings { 'TIME_QUOTA' } = $temp [ 0 ];
648 $uqsettings { 'SPORADIC' } = $temp [ 1 ];
649 $uqsettings { 'RENEWAL' } = $temp [ 2 ];
650 $uqsettings { 'QUOTA_USERS' } = $temp [ 3 ];
651 $uqsettings { 'ENABLEQUOTA' } = $temp [ 4 ];
654 $uqsettings { 'UQMODE' }= 'on' ;
657 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }))
659 open ( FILE
, "> $uqfile " );
662 foreach $line ( @uqlist )
665 unless ( $uqsettings { 'ID' } eq $id ) { print FILE
" $line " ; }
669 @temp = split ( /\,/ , $line );
670 if ( $temp [ 4 ] eq 'on' ) { $temp [ 4 ] = 'off' ; } else { $temp [ 4 ] = 'on' }
671 print FILE
" $temp [0], $temp [1], $temp [2], $temp [3], $temp [4] \n " ;
675 $uqsettings { 'CHANGED' }= 'yes' ;
676 $uqsettings { 'UQMODE' }= 'on' ;
679 if (( $uqsettings { 'MODE' } eq 'USERQUOTA' ) && ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter restart' }))
681 if (!( $proxysettings { 'ENABLE_FILTER' } eq 'on' ))
683 $errormessage = $Lang :: tr
{ 'urlfilter not enabled' };
685 if ((!(- e
"${General::swroot}/proxy/enable" )) && (!(- e
"${General::swroot}/proxy/enable_blue" )))
687 $errormessage = $Lang :: tr
{ 'urlfilter web proxy service required' };
690 if (! $errormessage ) { system ( '/usr/local/bin/squidctrl restart >/dev/null 2>&1' ); }
691 $uqsettings { 'UQMODE' }= 'on' ;
694 if ( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter blacklist editor' }) { $besettings { 'BEMODE' } = 'on' ; }
696 if ( $besettings { 'MODE' } eq 'BLACKLIST_EDITOR' )
698 @temp = split ( /\n/ , $besettings { 'BE_DOMAINS' });
699 undef $besettings { 'BE_DOMAINS' };
702 s/^\s+//g ; s/\s+$//g ;
703 if ( $_ ) { $besettings { 'BE_DOMAINS' } .= $_ . " \n " ; }
705 chomp ( $besettings { 'BE_DOMAINS' });
706 @temp = split ( /\n/ , $besettings { 'BE_URLS' });
707 undef $besettings { 'BE_URLS' };
710 s/^\s+//g ; s/\s+$//g ;
711 if ( $_ ) { $besettings { 'BE_URLS' } .= $_ . " \n " ; }
713 chomp ( $besettings { 'BE_URLS' });
714 @temp = split ( /\n/ , $besettings { 'BE_EXPRESSIONS' });
715 undef $besettings { 'BE_EXPRESSIONS' };
718 s/^\s+//g ; s/\s+$//g ;
719 if ( $_ ) { $besettings { 'BE_EXPRESSIONS' } .= $_ . " \n " ; }
721 chomp ( $besettings { 'BE_EXPRESSIONS' });
724 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter load blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
726 $besettings { 'BEMODE' } = 'on' ;
728 $besettings { 'BE_NAME' } = $besettings { 'BE_BLACKLIST' };
730 delete $besettings { 'BE_DOMAINS' };
731 delete $besettings { 'BE_URLS' };
732 delete $besettings { 'BE_EXPRESSIONS' };
734 if (- e
" $dbdir / $besettings {'BE_NAME'}/domains" )
736 open ( FILE
, " $dbdir / $besettings {'BE_NAME'}/domains" );
737 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_DOMAINS' } .= $_ } };
739 chomp ( $besettings { 'BE_DOMAINS' });
741 if (- e
" $dbdir / $besettings {'BE_NAME'}/urls" )
743 open ( FILE
, " $dbdir / $besettings {'BE_NAME'}/urls" );
744 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_URLS' } .= $_ } };
746 chomp ( $besettings { 'BE_URLS' });
748 if (- e
" $dbdir / $besettings {'BE_NAME'}/expressions" )
750 open ( FILE
, " $dbdir / $besettings {'BE_NAME'}/expressions" );
751 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_EXPRESSIONS' } .= $_ } };
753 chomp ( $besettings { 'BE_EXPRESSIONS' });
757 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter import blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
759 $besettings { 'BEMODE' } = 'on' ;
761 & Header
:: getcgihash
( \
%besettings , { 'wantfile' => 1 , 'filevar' => 'IMPORTFILE' });
763 if (!( $besettings { 'IMPORTFILE' } =~ /.tar.gz$/ ))
765 $errormessage = $Lang :: tr
{ 'urlfilter wrong filetype' };
767 if (!- d
" $editdir " ) { mkdir ( " $editdir " ); }
769 if ( copy
( $besettings { 'IMPORTFILE' }, " $editdir /blacklist.tar.gz" ) != 1 )
774 my $exitcode = system ( "/bin/tar --no-same-owner --preserve-permissions -xzf $editdir /blacklist.tar.gz -C $editdir " );
777 $errormessage = $Lang :: tr
{ 'urlfilter tar error' };
780 foreach (< $editdir /blacklists/ *>)
785 $besettings { 'BE_NAME' } = substr ( $_ , rindex ( $_ , "/" )+ 1 );
791 $errormessage = $Lang :: tr
{ 'urlfilter invalid import file' };
793 delete $besettings { 'BE_DOMAINS' };
794 delete $besettings { 'BE_URLS' };
795 delete $besettings { 'BE_EXPRESSIONS' };
797 if (- e
" $editdir /blacklists/ $besettings {'BE_NAME'}/domains" )
799 open ( FILE
, " $editdir /blacklists/ $besettings {'BE_NAME'}/domains" );
800 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_DOMAINS' } .= $_ } };
802 chomp ( $besettings { 'BE_DOMAINS' });
804 if (- e
" $editdir /blacklists/ $besettings {'BE_NAME'}/urls" )
806 open ( FILE
, " $editdir /blacklists/ $besettings {'BE_NAME'}/urls" );
807 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_URLS' } .= $_ } };
809 chomp ( $besettings { 'BE_URLS' });
811 if (- e
" $editdir /blacklists/ $besettings {'BE_NAME'}/expressions" )
813 open ( FILE
, " $editdir /blacklists/ $besettings {'BE_NAME'}/expressions" );
814 while (< FILE
>) { unless ( $_ eq ' \n ' ) { $besettings { 'BE_EXPRESSIONS' } .= $_ } };
816 chomp ( $besettings { 'BE_EXPRESSIONS' });
821 if (- d
$editdir ) { system ( "rm -rf $editdir " ); }
827 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter export blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
829 $besettings { 'BEMODE' } = 'on' ;
831 if ( $besettings { 'BE_NAME' } eq '' )
833 $errormessage = $Lang :: tr
{ 'urlfilter category name error' };
834 } elsif ( $besettings { 'BE_DOMAINS' } || $besettings { 'BE_URLS' } || $besettings { 'BE_EXPRESSIONS' }) {
836 $_ = $besettings { 'BE_NAME' }; tr/A-Z/a-z/ ; $besettings { 'BE_NAME' } = $_ ;
838 if (!(- d
" $editdir " )) { mkdir ( " $editdir " ); }
839 if (!(- d
" $editdir /blacklists" )) { mkdir ( " $editdir /blacklists" ); }
840 if (!(- d
" $editdir /blacklists/ $besettings {'BE_NAME'}" )) { mkdir ( " $editdir /blacklists/ $besettings {'BE_NAME'}" ); }
842 open ( FILE
, "> $editdir /blacklists/ $besettings {'BE_NAME'}/domains" );
844 print FILE
" $besettings {'BE_DOMAINS'} \n " ;
846 open ( FILE
, "> $editdir /blacklists/ $besettings {'BE_NAME'}/urls" );
848 print FILE
" $besettings {'BE_URLS'} \n " ;
850 open ( FILE
, "> $editdir /blacklists/ $besettings {'BE_NAME'}/expressions" );
852 print FILE
" $besettings {'BE_EXPRESSIONS'} \n " ;
855 if ( system ( "/bin/tar -C $editdir -czf $editdir / $besettings {'BE_NAME'}.tar.gz blacklists" ))
857 $errormessage = $Lang :: tr
{ 'urlfilter export error' };
861 print "Content-type: application/gzip \n " ;
862 print "Content-length: " ;
863 print (- s
" $editdir / $besettings {'BE_NAME'}.tar.gz" );
865 print "Content-disposition: attachment; filename= $besettings {'BE_NAME'}.tar.gz \n\n " ;
867 open ( FILE
, " $editdir / $besettings {'BE_NAME'}.tar.gz" );
868 while (< FILE
>) { print ; }
871 if (- d
$editdir ) { system ( "rm -rf $editdir " ); }
875 $errormessage = $Lang :: tr
{ 'urlfilter category data error' };
879 if (( $besettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter install blacklist' }) && ( $besettings { 'MODE' } = 'BLACKLIST_EDITOR' ))
881 $besettings { 'BEMODE' } = 'on' ;
883 if ( $besettings { 'BE_NAME' } eq '' )
885 $errormessage = $Lang :: tr
{ 'urlfilter category name error' };
886 } elsif ( $besettings { 'BE_DOMAINS' } || $besettings { 'BE_URLS' } || $besettings { 'BE_EXPRESSIONS' }) {
888 $_ = $besettings { 'BE_NAME' }; tr/A-Z/a-z/ ; $besettings { 'BE_NAME' } = $_ ;
890 if (!- d
" $editdir " ) { mkdir ( " $editdir " ); }
892 if (!- d
" $dbdir / $besettings {'BE_NAME'}" ) { mkdir ( " $dbdir / $besettings {'BE_NAME'}" ); }
894 if (- e
" $dbdir / $besettings {'BE_NAME'}/domains" ) { unlink ( " $dbdir / $besettings {'BE_NAME'}/domains" ); }
895 if ( $besettings { 'BE_DOMAINS' })
897 open ( FILE
, "> $dbdir / $besettings {'BE_NAME'}/domains" );
899 print FILE
" $besettings {'BE_DOMAINS'} \n " ;
902 if (- e
" $dbdir / $besettings {'BE_NAME'}/urls" ) { unlink ( " $dbdir / $besettings {'BE_NAME'}/urls" ); }
903 if ( $besettings { 'BE_URLS' })
905 open ( FILE
, "> $dbdir / $besettings {'BE_NAME'}/urls" );
907 print FILE
" $besettings {'BE_URLS'} \n " ;
910 if (- e
" $dbdir / $besettings {'BE_NAME'}/expressions" ) { unlink ( " $dbdir / $besettings {'BE_NAME'}/expressions" ); }
911 if ( $besettings { 'BE_EXPRESSIONS' })
913 open ( FILE
, "> $dbdir / $besettings {'BE_NAME'}/expressions" );
915 print FILE
" $besettings {'BE_EXPRESSIONS'} \n " ;
919 open ( FILE
, "> $editdir /install.conf" );
921 print FILE
"logdir /var/log/squidGuard \n " ;
922 print FILE
"dbhome $dbdir / $besettings {'BE_NAME'} \n\n " ;
923 print FILE
"dest $besettings {'BE_NAME'} { \n " ;
924 if ( $besettings { 'BE_DOMAINS' }) { print FILE
" domainlist domains \n " ; }
925 if ( $besettings { 'BE_URLS' }) { print FILE
" urllist urls \n " ; }
926 if ( $besettings { 'BE_EXPRESSIONS' }) { print FILE
" expressions expressions \n " ; }
928 print FILE
"acl { \n " ;
929 print FILE
" default { \n " ;
930 print FILE
" pass none \n " ;
935 system ( "rm -f $dbdir / $besettings {'BE_NAME'}/*.db" );
936 system ( "/usr/sbin/squidGuard -c $editdir /install.conf -C all" );
937 system ( "chmod a+w $dbdir / $besettings {'BE_NAME'}/*.db" );
939 & readblockcategories
;
944 system ( '/usr/local/bin/squidctrl restart >/dev/null 2>&1' ) unless ( $besettings { 'NORESTART' } eq 'on' );
946 if (- d
$editdir ) { system ( "rm -rf $editdir " ); }
948 $errormessage = $Lang :: tr
{ 'urlfilter category data error' };
952 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter save schedule' })
954 if (( $filtersettings { 'UPDATE_SOURCE' } eq 'custom' ) && ( $filtersettings { 'CUSTOM_UPDATE_URL' } eq '' ))
956 $errormessage = $Lang :: tr
{ 'urlfilter custom url required' };
958 open ( FILE
, "> $updconffile " );
959 print FILE
"ENABLE_AUTOUPDATE= $filtersettings {'ENABLE_AUTOUPDATE'} \n " ;
960 print FILE
"UPDATE_SCHEDULE= $filtersettings {'UPDATE_SCHEDULE'} \n " ;
961 print FILE
"UPDATE_SOURCE= $filtersettings {'UPDATE_SOURCE'} \n " ;
962 print FILE
"CUSTOM_UPDATE_URL= $filtersettings {'CUSTOM_UPDATE_URL'} \n " ;
966 if (( $filtersettings { 'ENABLE_AUTOUPDATE' } eq 'on' ) && ( $filtersettings { 'UPDATE_SCHEDULE' } eq 'daily' ))
968 system ( '/usr/local/bin/urlfilterctrl cron daily >/dev/null 2>&1' );
971 if (( $filtersettings { 'ENABLE_AUTOUPDATE' } eq 'on' ) && ( $filtersettings { 'UPDATE_SCHEDULE' } eq 'weekly' ))
973 system ( '/usr/local/bin/urlfilterctrl cron weekly >/dev/null 2>&1' );
976 if (( $filtersettings { 'ENABLE_AUTOUPDATE' } eq 'on' ) && ( $filtersettings { 'UPDATE_SCHEDULE' } eq 'monthly' ))
978 system ( '/usr/local/bin/urlfilterctrl cron monthly >/dev/null 2>&1' );
983 if ( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter update now' })
985 if ( $filtersettings { 'UPDATE_SOURCE' } eq 'custom' )
987 if ( $filtersettings { 'CUSTOM_UPDATE_URL' } eq '' )
989 $errormessage = $Lang :: tr
{ 'urlfilter custom url required' };
991 system ( "${General::swroot}/urlfilter/bin/autoupdate.pl $filtersettings {'CUSTOM_UPDATE_URL'} &" );
994 system ( "${General::swroot}/urlfilter/bin/autoupdate.pl $filtersettings {'UPDATE_SOURCE'} &" );
999 if (- e
"${General::swroot}/urlfilter/settings" ) { & General
:: readhash
( "${General::swroot}/urlfilter/settings" , \
%filtersettings ); }
1005 if ( $errormessage ) { $filtersettings { 'VALID' } = 'no' ; }
1007 $checked { 'ENABLE_CUSTOM_BLACKLIST' }{ 'off' } = '' ;
1008 $checked { 'ENABLE_CUSTOM_BLACKLIST' }{ 'on' } = '' ;
1009 $checked { 'ENABLE_CUSTOM_BLACKLIST' }{ $filtersettings { 'ENABLE_CUSTOM_BLACKLIST' }} = "checked='checked'" ;
1010 $checked { 'ENABLE_CUSTOM_WHITELIST' }{ 'off' } = '' ;
1011 $checked { 'ENABLE_CUSTOM_WHITELIST' }{ 'on' } = '' ;
1012 $checked { 'ENABLE_CUSTOM_WHITELIST' }{ $filtersettings { 'ENABLE_CUSTOM_WHITELIST' }} = "checked='checked'" ;
1013 $checked { 'ENABLE_CUSTOM_EXPRESSIONS' }{ 'off' } = '' ;
1014 $checked { 'ENABLE_CUSTOM_EXPRESSIONS' }{ 'on' } = '' ;
1015 $checked { 'ENABLE_CUSTOM_EXPRESSIONS' }{ $filtersettings { 'ENABLE_CUSTOM_EXPRESSIONS' }} = "checked='checked'" ;
1016 $checked { 'BLOCK_EXECUTABLES' }{ 'off' } = '' ;
1017 $checked { 'BLOCK_EXECUTABLES' }{ 'on' } = '' ;
1018 $checked { 'BLOCK_EXECUTABLES' }{ $filtersettings { 'BLOCK_EXECUTABLES' }} = "checked='checked'" ;
1019 $checked { 'BLOCK_AUDIO-VIDEO' }{ 'off' } = '' ;
1020 $checked { 'BLOCK_AUDIO-VIDEO' }{ 'on' } = '' ;
1021 $checked { 'BLOCK_AUDIO-VIDEO' }{ $filtersettings { 'BLOCK_AUDIO-VIDEO' }} = "checked='checked'" ;
1022 $checked { 'BLOCK_ARCHIVES' }{ 'off' } = '' ;
1023 $checked { 'BLOCK_ARCHIVES' }{ 'on' } = '' ;
1024 $checked { 'BLOCK_ARCHIVES' }{ $filtersettings { 'BLOCK_ARCHIVES' }} = "checked='checked'" ;
1025 $checked { 'ENABLE_REWRITE' }{ 'off' } = '' ;
1026 $checked { 'ENABLE_REWRITE' }{ 'on' } = '' ;
1027 $checked { 'ENABLE_REWRITE' }{ $filtersettings { 'ENABLE_REWRITE' }} = "checked='checked'" ;
1028 $checked { 'SHOW_CATEGORY' }{ 'off' } = '' ;
1029 $checked { 'SHOW_CATEGORY' }{ 'on' } = '' ;
1030 $checked { 'SHOW_CATEGORY' }{ $filtersettings { 'SHOW_CATEGORY' }} = "checked='checked'" ;
1031 $checked { 'SHOW_URL' }{ 'off' } = '' ;
1032 $checked { 'SHOW_URL' }{ 'on' } = '' ;
1033 $checked { 'SHOW_URL' }{ $filtersettings { 'SHOW_URL' }} = "checked='checked'" ;
1034 $checked { 'SHOW_IP' }{ 'off' } = '' ;
1035 $checked { 'SHOW_IP' }{ 'on' } = '' ;
1036 $checked { 'SHOW_IP' }{ $filtersettings { 'SHOW_IP' }} = "checked='checked'" ;
1037 $checked { 'ENABLE_DNSERROR' }{ 'off' } = '' ;
1038 $checked { 'ENABLE_DNSERROR' }{ 'on' } = '' ;
1039 $checked { 'ENABLE_DNSERROR' }{ $filtersettings { 'ENABLE_DNSERROR' }} = "checked='checked'" ;
1040 $checked { 'ENABLE_JPEG' }{ 'off' } = '' ;
1041 $checked { 'ENABLE_JPEG' }{ 'on' } = '' ;
1042 $checked { 'ENABLE_JPEG' }{ $filtersettings { 'ENABLE_JPEG' }} = "checked='checked'" ;
1043 $checked { 'ENABLE_EXPR_LISTS' }{ 'off' } = '' ;
1044 $checked { 'ENABLE_EXPR_LISTS' }{ 'on' } = '' ;
1045 $checked { 'ENABLE_EXPR_LISTS' }{ $filtersettings { 'ENABLE_EXPR_LISTS' }} = "checked='checked'" ;
1046 $checked { 'BLOCK_IP_ADDR' }{ 'off' } = '' ;
1047 $checked { 'BLOCK_IP_ADDR' }{ 'on' } = '' ;
1048 $checked { 'BLOCK_IP_ADDR' }{ $filtersettings { 'BLOCK_IP_ADDR' }} = "checked='checked'" ;
1049 $checked { 'BLOCK_ALL' }{ 'off' } = '' ;
1050 $checked { 'BLOCK_ALL' }{ 'on' } = '' ;
1051 $checked { 'BLOCK_ALL' }{ $filtersettings { 'BLOCK_ALL' }} = "checked='checked'" ;
1052 $checked { 'ENABLE_EMPTY_ADS' }{ 'off' } = '' ;
1053 $checked { 'ENABLE_EMPTY_ADS' }{ 'on' } = '' ;
1054 $checked { 'ENABLE_EMPTY_ADS' }{ $filtersettings { 'ENABLE_EMPTY_ADS' }} = "checked='checked'" ;
1055 $checked { 'ENABLE_GLOBAL_WHITELIST' }{ 'off' } = '' ;
1056 $checked { 'ENABLE_GLOBAL_WHITELIST' }{ 'on' } = '' ;
1057 $checked { 'ENABLE_GLOBAL_WHITELIST' }{ $filtersettings { 'ENABLE_GLOBAL_WHITELIST' }} = "checked='checked'" ;
1058 $checked { 'ENABLE_SAFESEARCH' }{ 'off' } = '' ;
1059 $checked { 'ENABLE_SAFESEARCH' }{ 'on' } = '' ;
1060 $checked { 'ENABLE_SAFESEARCH' }{ $filtersettings { 'ENABLE_SAFESEARCH' }} = "checked='checked'" ;
1061 $checked { 'ENABLE_LOG' }{ 'off' } = '' ;
1062 $checked { 'ENABLE_LOG' }{ 'on' } = '' ;
1063 $checked { 'ENABLE_LOG' }{ $filtersettings { 'ENABLE_LOG' }} = "checked='checked'" ;
1064 $checked { 'ENABLE_USERNAME_LOG' }{ 'off' } = '' ;
1065 $checked { 'ENABLE_USERNAME_LOG' }{ 'on' } = '' ;
1066 $checked { 'ENABLE_USERNAME_LOG' }{ $filtersettings { 'ENABLE_USERNAME_LOG' }} = "checked='checked'" ;
1067 $checked { 'ENABLE_CATEGORY_LOG' }{ 'off' } = '' ;
1068 $checked { 'ENABLE_CATEGORY_LOG' }{ 'on' } = '' ;
1069 $checked { 'ENABLE_CATEGORY_LOG' }{ $filtersettings { 'ENABLE_CATEGORY_LOG' }} = "checked='checked'" ;
1071 foreach $category ( @filtergroups ) {
1072 $checked { $category }{ 'off' } = '' ;
1073 $checked { $category }{ 'on' } = '' ;
1074 $checked { $category }{ $filtersettings { $category }} = "checked='checked'" ;
1077 $selected { 'DEFINITION' }{ $tcsettings { 'DEFINITION' }} = "selected='selected'" ;
1078 $selected { 'FROM_HOUR' }{ $tcsettings { 'FROM_HOUR' }} = "selected='selected'" ;
1079 $selected { 'FROM_MINUTE' }{ $tcsettings { 'FROM_MINUTE' }} = "selected='selected'" ;
1080 $selected { 'TO_HOUR' }{ $tcsettings { 'TO_HOUR' }} = "selected='selected'" ;
1081 $selected { 'TO_MINUTE' }{ $tcsettings { 'TO_MINUTE' }} = "selected='selected'" ;
1083 @selectedcategories = split ( /\|/ , $tcsettings { 'DST' });
1084 foreach ( @selectedcategories )
1086 $selected { 'DST' }{ $_ } = "selected='selected'" ;
1089 $selected { 'ACCESS' }{ $tcsettings { 'ACCESS' }} = "selected='selected'" ;
1091 $checked { 'ENABLERULE' }{ 'off' } = '' ;
1092 $checked { 'ENABLERULE' }{ 'on' } = '' ;
1093 $checked { 'ENABLERULE' }{ $tcsettings { 'ENABLERULE' }} = "checked='checked'" ;
1094 $checked { 'MON' }{ 'off' } = '' ;
1095 $checked { 'MON' }{ 'on' } = '' ;
1096 $checked { 'MON' }{ $tcsettings { 'MON' }} = "checked='checked'" ;
1097 $checked { 'TUE' }{ 'off' } = '' ;
1098 $checked { 'TUE' }{ 'on' } = '' ;
1099 $checked { 'TUE' }{ $tcsettings { 'TUE' }} = "checked='checked'" ;
1100 $checked { 'WED' }{ 'off' } = '' ;
1101 $checked { 'WED' }{ 'on' } = '' ;
1102 $checked { 'WED' }{ $tcsettings { 'WED' }} = "checked='checked'" ;
1103 $checked { 'THU' }{ 'off' } = '' ;
1104 $checked { 'THU' }{ 'on' } = '' ;
1105 $checked { 'THU' }{ $tcsettings { 'THU' }} = "checked='checked'" ;
1106 $checked { 'FRI' }{ 'off' } = '' ;
1107 $checked { 'FRI' }{ 'on' } = '' ;
1108 $checked { 'FRI' }{ $tcsettings { 'FRI' }} = "checked='checked'" ;
1109 $checked { 'SAT' }{ 'off' } = '' ;
1110 $checked { 'SAT' }{ 'on' } = '' ;
1111 $checked { 'SAT' }{ $tcsettings { 'SAT' }} = "checked='checked'" ;
1112 $checked { 'SUN' }{ 'off' } = '' ;
1113 $checked { 'SUN' }{ 'on' } = '' ;
1114 $checked { 'SUN' }{ $tcsettings { 'SUN' }} = "checked='checked'" ;
1116 $selected { 'SPORADIC' }{ $uqsettings { 'SPORADIC' }} = "selected='selected'" ;
1117 $selected { 'RENEWAL' } { $uqsettings { 'RENEWAL' }} = "selected='selected'" ;
1119 $checked { 'ENABLEQUOTA' }{ 'off' } = '' ;
1120 $checked { 'ENABLEQUOTA' }{ 'on' } = '' ;
1121 $checked { 'ENABLEQUOTA' }{ $uqsettings { 'ENABLEQUOTA' }} = "checked='checked'" ;
1123 $selected { 'BE_BLACKLIST' }{ $besettings { 'BE_BLACKLIST' }} = "selected='selected'" ;
1126 & Header
:: showhttpheaders
();
1128 & Header
:: openpage
( $Lang :: tr
{ 'urlfilter configuration' }, 1 , '' );
1130 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
1132 if ( $errormessage ) {
1133 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
1134 print "<font class='base'> $errormessage </font> \n " ;
1135 & Header
:: closebox
();
1136 } elsif (( $tcsettings { 'CHANGED' } eq 'yes' ) || ( $uqsettings { 'CHANGED' } eq 'yes' ) ) {
1138 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}'> \n " ;
1139 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter restart notification'}:" );
1140 print "<class name='base'> $Lang ::tr{'urlfilter restart message'} \n " ;
1141 if ( $uqsettings { 'MODE' } eq 'USERQUOTA' ) { print "<p><class name='base'> $Lang ::tr{'urlfilter quota restart message'} \n " ; }
1143 print "<p><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter restart'}' />" ;
1144 if ( $tcsettings { 'MODE' } eq 'TIMECONSTRAINT' ) { print "<input type='hidden' name='MODE' value='TIMECONSTRAINT' />" ; }
1145 if ( $uqsettings { 'MODE' } eq 'USERQUOTA' ) { print "<input type='hidden' name='MODE' value='USERQUOTA' />" ; }
1146 & Header
:: closebox
();
1150 if ( $restoremessage ) {
1151 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter restore results'}:" );
1152 print "<class name='base'> $restoremessage \n " ;
1153 print " </class> \n " ;
1154 & Header
:: closebox
();
1157 if ((! $tcsettings { 'TCMODE' }) && (! $uqsettings { 'UQMODE' }) && (! $besettings { 'BEMODE' })) {
1159 if (!( $filtersettings { 'ACTION' } eq $Lang :: tr
{ 'urlfilter manage repository' })) {
1161 #==========================================================
1163 # Section: Main Configuration
1165 #==========================================================
1167 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
1169 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter filter settings'}:" );
1171 <table width='100%'>
1173 <td colspan='4'><b> $Lang ::tr{'urlfilter block categories'}</b></td>
1178 if ( @categories == 0 ) {
1181 <td><i> $Lang ::tr{'urlfilter no categories'}</i></td>
1191 for ( $n = 0 ; $n <= @categories ; $n = $n + $i ) {
1192 for ( $i = 0 ; $i <= 3 ; $i ++) {
1193 if ( $i eq 0 ) { print "<tr> \n " ; }
1194 if (( $n + $i ) < @categories ) {
1195 print "<td width='15%'> @categories [ $n + $i ]:<\/td> \n " ;
1196 print "<td width='10%'><input type='checkbox' name= @filtergroups [ $n + $i ] $checked { @filtergroups [ $n + $i ]}{'on'} /></td> \n " ;
1198 if ( $i eq 3 ) { print "<\/tr> \n " ; }
1205 <table width='100%'>
1207 <td><b> $Lang ::tr{'urlfilter custom blacklist'}</b></td>
1213 <td colspan='2'> $Lang ::tr{'urlfilter blocked domains'} <img src='/blob.gif' alt='*' /></td>
1214 <td colspan='2'> $Lang ::tr{'urlfilter blocked urls'} <img src='/blob.gif' alt='*' /></td>
1217 <td colspan='2'> $Lang ::tr{'urlfilter example'}</td>
1218 <td colspan='2'> $Lang ::tr{'urlfilter example ads'}</td>
1221 <td colspan='2' width='50%'><textarea name='CUSTOM_BLACK_DOMAINS' cols='32' rows='6' wrap='off'>
1225 print $filtersettings { 'CUSTOM_BLACK_DOMAINS' };
1229 <td colspan='2' width='50%'><textarea name='CUSTOM_BLACK_URLS' cols='32' rows='6' wrap='off'>
1233 print $filtersettings { 'CUSTOM_BLACK_URLS' };
1239 <table width='100%'>
1241 <td class='base' width='25%'> $Lang ::tr{'urlfilter enable custom blacklist'}:</td>
1242 <td><input type='checkbox' name='ENABLE_CUSTOM_BLACKLIST' $checked {'ENABLE_CUSTOM_BLACKLIST'}{'on'} /></td>
1248 <table width='100%'>
1250 <td><b> $Lang ::tr{'urlfilter custom whitelist'}</b></td>
1256 <td colspan='2'> $Lang ::tr{'urlfilter allowed domains'} <img src='/blob.gif' alt='*' /></td>
1257 <td colspan='2'> $Lang ::tr{'urlfilter allowed urls'} <img src='/blob.gif' alt='*' /></td>
1260 <td colspan='2' width='50%'><textarea name='CUSTOM_WHITE_DOMAINS' cols='32' rows='6' wrap='off'>
1264 print $filtersettings { 'CUSTOM_WHITE_DOMAINS' };
1268 <td colspan='2' width='50%'><textarea name='CUSTOM_WHITE_URLS' cols='32' rows='6' wrap='off'>
1272 print $filtersettings { 'CUSTOM_WHITE_URLS' };
1278 <table width='100%'>
1280 <td class='base' width='25%'> $Lang ::tr{'urlfilter enable custom whitelist'}:</td>
1281 <td><input type='checkbox' name='ENABLE_CUSTOM_WHITELIST' $checked {'ENABLE_CUSTOM_WHITELIST'}{'on'} /></td>
1287 <table width='100%'>
1289 <td colspan='4'><b> $Lang ::tr{'urlfilter custom expression list'}</b></td>
1292 <td colspan='4'> $Lang ::tr{'urlfilter blocked expressions'} <img src='/blob.gif' alt='*' /></td>
1295 <td colspan='4'><textarea name='CUSTOM_EXPRESSIONS' cols='70' rows='3' wrap='off'>
1299 print $filtersettings { 'CUSTOM_EXPRESSIONS' };
1305 <td class='base' width='25%'> $Lang ::tr{'urlfilter enable custom expression list'}:</td>
1306 <td><input type='checkbox' name='ENABLE_CUSTOM_EXPRESSIONS' $checked {'ENABLE_CUSTOM_EXPRESSIONS'}{'on'} /></td>
1312 <table width='100%'>
1314 <td colspan='4'><b> $Lang ::tr{'urlfilter file ext block'}</b></td>
1317 <td width='25%' class='base'> $Lang ::tr{'urlfilter block executables'}:</td>
1318 <td width='12%'><input type='checkbox' name='BLOCK_EXECUTABLES' $checked {'BLOCK_EXECUTABLES'}{'on'} /></td>
1319 <td width='25%' class='base'> $Lang ::tr{'urlfilter block audio-video'}:</td>
1320 <td><input type='checkbox' name='BLOCK_AUDIO-VIDEO' $checked {'BLOCK_AUDIO-VIDEO'}{'on'} /></td>
1323 <td class='base'> $Lang ::tr{'urlfilter block archives'}:</td>
1324 <td><input type='checkbox' name='BLOCK_ARCHIVES' $checked {'BLOCK_ARCHIVES'}{'on'} /></td>
1330 <table width='100%'>
1332 <td colspan='4'><b> $Lang ::tr{'urlfilter local file redirection'}</b></td>
1335 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable rewrite rules'}:</td>
1336 <td width='12%'><input type='checkbox' name='ENABLE_REWRITE' $checked {'ENABLE_REWRITE'}{'on'} /></td>
1341 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter manage repository'}'></td>
1348 <table width='100%'>
1350 <td colspan='2'><b> $Lang ::tr{'urlfilter network access control'}</b></td>
1355 <td colspan='2'> $Lang ::tr{'urlfilter unfiltered clients'} <img src='/blob.gif' alt='*' /></td>
1356 <td colspan='2'> $Lang ::tr{'urlfilter banned clients'} <img src='/blob.gif' alt='*' /></td>
1359 <td colspan='2' width='50%'><textarea name='UNFILTERED_CLIENTS' cols='32' rows='6' wrap='off'>
1363 # transform from pre1.8 client definitions
1364 $filtersettings { 'UNFILTERED_CLIENTS' } =~ s/^\s+//g ;
1365 $filtersettings { 'UNFILTERED_CLIENTS' } =~ s/\s+$//g ;
1366 $filtersettings { 'UNFILTERED_CLIENTS' } =~ s/\s+-\s+/-/g ;
1367 $filtersettings { 'UNFILTERED_CLIENTS' } =~ s/\s+/ /g ;
1369 @clients = split ( / / , $filtersettings { 'UNFILTERED_CLIENTS' });
1370 undef $filtersettings { 'UNFILTERED_CLIENTS' };
1371 foreach ( @clients ) { $filtersettings { 'UNFILTERED_CLIENTS' } .= " $_ \n " ; }
1373 print $filtersettings { 'UNFILTERED_CLIENTS' };
1377 <td colspan='2' width='50%'><textarea name='BANNED_CLIENTS' cols='32' rows='6' wrap='off'>
1381 # transform from pre1.8 client definitions
1382 $filtersettings { 'BANNED_CLIENTS' } =~ s/^\s+//g ;
1383 $filtersettings { 'BANNED_CLIENTS' } =~ s/\s+$//g ;
1384 $filtersettings { 'BANNED_CLIENTS' } =~ s/\s+-\s+/-/g ;
1385 $filtersettings { 'BANNED_CLIENTS' } =~ s/\s+/ /g ;
1387 @clients = split ( / / , $filtersettings { 'BANNED_CLIENTS' });
1388 undef $filtersettings { 'BANNED_CLIENTS' };
1389 foreach ( @clients ) { $filtersettings { 'BANNED_CLIENTS' } .= " $_ \n " ; }
1391 print $filtersettings { 'BANNED_CLIENTS' };
1398 <table width='100%'>
1400 <td colspan='4'><b> $Lang ::tr{'urlfilter timebased access control'}</b></td>
1403 <td width='25%'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter set time constraints'}'></td>
1404 <td width='25%'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter set user quota'}'></td>
1410 <table width='100%'>
1412 <td colspan='4'><b> $Lang ::tr{'urlfilter block settings'}</b></td>
1415 <td width='25%' class='base'> $Lang ::tr{'urlfilter show category'}:</td>
1416 <td width='12%'><input type='checkbox' name='SHOW_CATEGORY' $checked {'SHOW_CATEGORY'}{'on'} /></td>
1417 <td width='25%' class='base'> $Lang ::tr{'urlfilter redirectpage'}: <img src='/blob.gif' alt='*' /></td>
1418 <td><input type='text' name='REDIRECT_PAGE' value=' $filtersettings {'REDIRECT_PAGE'}' size='40' /></td>
1421 <td class='base'> $Lang ::tr{'urlfilter show url'}:</td>
1422 <td><input type='checkbox' name='SHOW_URL' $checked {'SHOW_URL'}{'on'} /></td>
1423 <td class='base'> $Lang ::tr{'urlfilter msg text 1'}: <img src='/blob.gif' alt='*' /></td>
1424 <td><input type='text' name='MSG_TEXT_1' value=' $filtersettings {'MSG_TEXT_1'}' size='40' /></td>
1427 <td class='base'> $Lang ::tr{'urlfilter show ip'}:</td>
1428 <td><input type='checkbox' name='SHOW_IP' $checked {'SHOW_IP'}{'on'} /></td>
1429 <td class='base'> $Lang ::tr{'urlfilter msg text 2'}: <img src='/blob.gif' alt='*' /></td>
1430 <td><input type='text' name='MSG_TEXT_2' value=' $filtersettings {'MSG_TEXT_2'}' size='40' /></td>
1433 <td class='base'> $Lang ::tr{'urlfilter show dnserror'}:</td>
1434 <td><input type='checkbox' name='ENABLE_DNSERROR' $checked {'ENABLE_DNSERROR'}{'on'} /></td>
1435 <td class='base'> $Lang ::tr{'urlfilter msg text 3'}: <img src='/blob.gif' alt='*' /></td>
1436 <td><input type='text' name='MSG_TEXT_3' value=' $filtersettings {'MSG_TEXT_3'}' size='40' /></td>
1440 <table width='100%'>
1442 <td colspan='4'><b> $Lang ::tr{'urlfilter advanced settings'}</b></td>
1445 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable expression lists'}:</td>
1446 <td width='12%'><input type='checkbox' name='ENABLE_EXPR_LISTS' $checked {'ENABLE_EXPR_LISTS'}{'on'} /></td>
1447 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable log'}:</td>
1448 <td><input type='checkbox' name='ENABLE_LOG' $checked {'ENABLE_LOG'}{'on'} /></td>
1451 <td class='base'> $Lang ::tr{'urlfilter safesearch'}:</td>
1452 <td><input type='checkbox' name='ENABLE_SAFESEARCH' $checked {'ENABLE_SAFESEARCH'}{'on'} /></td>
1453 <td class='base'> $Lang ::tr{'urlfilter username log'}:</td>
1454 <td><input type='checkbox' name='ENABLE_USERNAME_LOG' $checked {'ENABLE_USERNAME_LOG'}{'on'} /></td>
1457 <td class='base'> $Lang ::tr{'urlfilter empty ads'}:</td>
1458 <td><input type='checkbox' name='ENABLE_EMPTY_ADS' $checked {'ENABLE_EMPTY_ADS'}{'on'} /></td>
1459 <td class='base'> $Lang ::tr{'urlfilter category log'}:</td>
1460 <td><input type='checkbox' name='ENABLE_CATEGORY_LOG' $checked {'ENABLE_CATEGORY_LOG'}{'on'} /></td>
1463 <td class='base'> $Lang ::tr{'urlfilter block ip'}:</td>
1464 <td><input type='checkbox' name='BLOCK_IP_ADDR' $checked {'BLOCK_IP_ADDR'}{'on'} /></td>
1467 <td class='base'> $Lang ::tr{'urlfilter block all'}:</td>
1468 <td><input type='checkbox' name='BLOCK_ALL' $checked {'BLOCK_ALL'}{'on'} /></td>
1469 <td class='base'> $Lang ::tr{'urlfilter whitelist always allowed'}:</td>
1470 <td><input type='checkbox' name='ENABLE_GLOBAL_WHITELIST' $checked {'ENABLE_GLOBAL_WHITELIST'}{'on'} /></td>
1474 <table width='100%'>
1477 <img src='/blob.gif' align='top' alt='*' />
1478 <font class='base'> $Lang ::tr{'this field may be blank'}</font>
1480 <td align='right'>
1484 <table width='100%'>
1487 <td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' /></td>
1488 <td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter save and restart'}' /></td>
1495 & Header
:: closebox
();
1499 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
1501 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter maintenance'}:" );
1504 <table width='100%'>
1506 <td class='base'><b> $Lang ::tr{'urlfilter blacklist update'}</b></td>
1509 <td> $Lang ::tr{'urlfilter upload information'}<p> $Lang ::tr{'urlfilter upload text'}:</td>
1512 <td><input type='file' name='UPDATEFILE' size='40' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter upload blacklist'}' /></td>
1518 <table width='100%'>
1520 <td colspan='2' class='base'><b> $Lang ::tr{'urlfilter automatic blacklist update'}</b>
1523 if (- e
" $updflagfile " )
1525 $blacklistage = int (- M
" $updflagfile " );
1526 print " <b>[</b> <small><i> $Lang ::tr{'urlfilter blacklist age 1'} <b> $blacklistage </b> $Lang ::tr{'urlfilter blacklist age 2'}</i></small> <b>]</b>" ;
1529 $updatesettings { 'UPDATE_SCHEDULE' } = 'monthly' ;
1530 $updatesettings { 'CUSTOM_UPDATE_URL' } = '' ;
1532 if (- e
" $updconffile " ) { & General
:: readhash
( " $updconffile " , \
%updatesettings ); }
1534 $checked { 'ENABLE_AUTOUPDATE' }{ 'off' } = '' ;
1535 $checked { 'ENABLE_AUTOUPDATE' }{ 'on' } = '' ;
1536 $checked { 'ENABLE_AUTOUPDATE' }{ $updatesettings { 'ENABLE_AUTOUPDATE' }} = "checked='checked'" ;
1538 $selected { 'UPDATE_SCHEDULE' }{ $updatesettings { 'UPDATE_SCHEDULE' }} = "selected='selected'" ;
1540 $selected { 'UPDATE_SOURCE' }{ $updatesettings { 'UPDATE_SOURCE' }} = "selected='selected'" ;
1546 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable automatic blacklist update'}:</td>
1547 <td width='75%' class='base'><input type='checkbox' name='ENABLE_AUTOUPDATE' $checked {'ENABLE_AUTOUPDATE'}{'on'} /></td>
1550 <td class='base'> $Lang ::tr{'urlfilter automatic update schedule'}:</td>
1552 <select name='UPDATE_SCHEDULE'>
1553 <option value='daily' $selected {'UPDATE_SCHEDULE'}{'daily'}> $Lang ::tr{'urlfilter daily'}</option>
1554 <option value='weekly' $selected {'UPDATE_SCHEDULE'}{'weekly'}> $Lang ::tr{'urlfilter weekly'}</option>
1555 <option value='monthly' $selected {'UPDATE_SCHEDULE'}{'monthly'}> $Lang ::tr{'urlfilter monthly'}</option>
1560 <td class='base'> $Lang ::tr{'urlfilter select source'}:</td>
1561 <td class='base' colspan='2'>
1562 <select name='UPDATE_SOURCE'>
1566 foreach ( @source_urllist ) {
1568 $source_name = substr ( $_ , 0 , rindex ( $_ , "," ));
1569 $source_url = substr ( $_ , index ( $_ , "," )+ 1 );
1570 print " \t <option value=' $source_url ' $selected {'UPDATE_SOURCE'}{ $source_url }> $source_name </option> \n " ;
1574 <option value='custom' $selected {'UPDATE_SOURCE'}{'custom'}> $Lang ::tr{'urlfilter custom url'}</option>
1579 <td> $Lang ::tr{'urlfilter custom url'}:</td>
1580 <td><input type='text' name='CUSTOM_UPDATE_URL' value=' $updatesettings {'CUSTOM_UPDATE_URL'}' size='72' /></td>
1583 <table width='100%'>
1585 <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>
1591 <table width='100%'>
1593 <td class='base'><b> $Lang ::tr{'urlfilter blacklist editor'}</b></td>
1596 <td> $Lang ::tr{'urlfilter blacklist editor info'}</td>
1599 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter blacklist editor'}' /></td>
1605 <table width='100%'>
1607 <td colspan='4' class='base'><b> $Lang ::tr{'urlfilter backup settings'}</b></td>
1610 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable full backup'}:</td>
1611 <td width='12%' class='base'><input type='checkbox' name='ENABLE_FULLBACKUP' $checked {'ENABLE_FULLBACKUP'}{'on'} /></td>
1616 <td colspan='4' class='base'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter backup'}' /></td>
1622 <table width='100%'>
1624 <td class='base'><b> $Lang ::tr{'urlfilter restore settings'}</b></td>
1627 <td> $Lang ::tr{'urlfilter restore text'}:</td>
1630 <td><input type='file' name='UPDATEFILE' size='40' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter restore'}' /></td>
1637 & Header
:: closebox
();
1641 #==========================================================
1643 # Section: Manage Repository
1645 #==========================================================
1647 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
1649 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter manage local file repository'}:" );
1651 <table width='100%'>
1653 <td> $Lang ::tr{'urlfilter repository information'}<br><br></td>
1656 <td> $Lang ::tr{'urlfilter upload file text'}:</td>
1659 <td><input type='file' name='UPLOADFILE' size='50' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter upload file'}' /></td>
1662 <td><br><b> $Lang ::tr{'urlfilter upload file information 1'}:</b> $Lang ::tr{'urlfilter upload file information 2'}</td>
1666 <table width='100%'>
1668 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
1675 & Header
:: closebox
();
1677 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter current files'}: </b>[ $repository ]" );
1679 @repositorylist = < $repository /*>;
1681 undef @repositoryfiles ;
1682 foreach ( @repositorylist )
1684 if (!- d
) { push ( @repositoryfiles , substr ( $_ , rindex ( $_ , "/" )+ 1 )); }
1687 if ( @repositoryfiles )
1690 <table width='100%'>
1692 <td align='center'><b> $Lang ::tr{'urlfilter filename'}</b></td>
1693 <td width='15%' align='center'><b> $Lang ::tr{'urlfilter filesize'}</b></td>
1694 <td width='10%'></td>
1699 foreach $line ( @repositoryfiles )
1703 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
1705 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
1706 $filesize = (- s
" $repository / $line " );
1707 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/ ;
1710 <td> $line </td>
1711 <td align='right'> $filesize </td>
1714 <form method='post' name='frma $id ' action=' $ENV {'SCRIPT_NAME'}'>
1715 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' title=' $Lang ::tr{'remove'}' alt=' $Lang ::tr{'remove'}' />
1716 <input type='hidden' name='ID' value=' $line ' />
1717 <input type='hidden' name='ACTION' value=' $Lang ::tr{'urlfilter remove file'}' />
1734 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
1735 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
1736 <td class='base'> $Lang ::tr{'remove'}</td>
1743 print "<i> $Lang ::tr{'urlfilter empty repository'}</i> \n " ;
1746 & Header
:: closebox
();
1750 } elsif ( $tcsettings { 'TCMODE' }) {
1752 #==========================================================
1754 # Section: Set Time Constraints
1756 #==========================================================
1758 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}'> \n " ;
1760 $buttontext = $Lang :: tr
{ 'urlfilter add rule' };
1761 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
1762 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter edit time constraint rule' }. ':' );
1763 $buttontext = $Lang :: tr
{ 'urlfilter update rule' };
1765 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter add new time constraint rule' }. ':' );
1769 <table width='100%'>
1771 <td width='2%'> $Lang ::tr{'urlfilter constraint definition'}</td>
1772 <td width='1%'> </td>
1773 <td width='2%' align='center'> $Lang ::tr{'urlfilter monday'}</td>
1774 <td width='2%' align='center'> $Lang ::tr{'urlfilter tuesday'}</td>
1775 <td width='2%' align='center'> $Lang ::tr{'urlfilter wednesday'}</td>
1776 <td width='2%' align='center'> $Lang ::tr{'urlfilter thursday'}</td>
1777 <td width='2%' align='center'> $Lang ::tr{'urlfilter friday'}</td>
1778 <td width='2%' align='center'> $Lang ::tr{'urlfilter saturday'}</td>
1779 <td width='2%' align='center'> $Lang ::tr{'urlfilter sunday'}</td>
1780 <td width='1%'> </td>
1781 <td width='7%' colspan=3> $Lang ::tr{'urlfilter from'}</td>
1782 <td width='1%'> </td>
1783 <td width='7%' colspan=3> $Lang ::tr{'urlfilter to'}</td>
1788 <select name='DEFINITION'>
1789 <option value='within' $selected {'DEFINITION'}{'within'}> $Lang ::tr{'urlfilter constraint within'}</option>
1790 <option value='outside' $selected {'DEFINITION'}{'outside'}> $Lang ::tr{'urlfilter constraint outside'}</option>
1794 <td class='base'><input type='checkbox' name='MON' $checked {'MON'}{'on'} /></td>
1795 <td class='base'><input type='checkbox' name='TUE' $checked {'TUE'}{'on'} /></td>
1796 <td class='base'><input type='checkbox' name='WED' $checked {'WED'}{'on'} /></td>
1797 <td class='base'><input type='checkbox' name='THU' $checked {'THU'}{'on'} /></td>
1798 <td class='base'><input type='checkbox' name='FRI' $checked {'FRI'}{'on'} /></td>
1799 <td class='base'><input type='checkbox' name='SAT' $checked {'SAT'}{'on'} /></td>
1800 <td class='base'><input type='checkbox' name='SUN' $checked {'SUN'}{'on'} /></td>
1803 <select name='FROM_HOUR'>
1806 for ( $i = 0 ; $i <= 24 ; $i ++) {
1807 $_ = sprintf ( " %02s " , $i );
1808 print "<option $selected {'FROM_HOUR'}{ $_ }> $_ </option> \n " ;
1815 <select name='FROM_MINUTE'>
1818 for ( $i = 0 ; $i <= 45 ; $i += 15 ) {
1819 $_ = sprintf ( " %02s " , $i );
1820 print "<option $selected {'FROM_MINUTE'}{ $_ }> $_ </option> \n " ;
1827 <select name='TO_HOUR'>
1830 for ( $i = 0 ; $i <= 24 ; $i ++) {
1831 $_ = sprintf ( " %02s " , $i );
1832 print "<option $selected {'TO_HOUR'}{ $_ }> $_ </option> \n " ;
1839 <select name='TO_MINUTE'>
1842 for ( $i = 0 ; $i <= 45 ; $i += 15 ) {
1843 $_ = sprintf ( " %02s " , $i );
1844 print "<option $selected {'TO_MINUTE'}{ $_ }> $_ </option> \n " ;
1855 <table width='100%'>
1857 <td width='5%'> $Lang ::tr{'urlfilter source'}</td>
1858 <td width='1%'> </td>
1859 <td width='5%'> $Lang ::tr{'urlfilter dst'} <img src='/blob.gif' alt='*'><img src='/blob.gif' alt='*'></td>
1860 <td width='1%'> </td>
1861 <td width='5%'> $Lang ::tr{'urlfilter access'}</td>
1865 <td rowspan='2'><textarea name='SRC' cols='28' rows='5' wrap='off'>
1869 # transform from pre1.8 client definitions
1870 $tcsettings { 'SRC' } =~ s/^\s+//g ;
1871 $tcsettings { 'SRC' } =~ s/\s+$//g ;
1872 $tcsettings { 'SRC' } =~ s/\s+-\s+/-/g ;
1873 $tcsettings { 'SRC' } =~ s/\s+/ /g ;
1875 @clients = split ( / / , $tcsettings { 'SRC' });
1876 undef $tcsettings { 'SRC' };
1877 foreach ( @clients ) { $tcsettings { 'SRC' } .= " $_ \n " ; }
1879 print $tcsettings { 'SRC' };
1885 <td class='base' rowspan='2' valign='top'>
1886 <select name='DST' size='6' multiple>
1887 <option value='any' $selected {'DST'}{'any'} = "selected='selected'"> $Lang ::tr{'urlfilter category all'}</option>
1888 <option value='in-addr' $selected {'DST'}{'in-addr'} = "selected='selected'">in-addr</option>
1892 & readblockcategories
;
1893 foreach ( @categories )
1895 print "<option value=' $_ ' $selected {'DST'}{ $_ }> $_ </option> \n " ;
1899 <option value='files' $selected {'DST'}{'files'} = "selected='selected'">files</option>
1900 <option value='custom-blocked' $selected {'DST'}{'custom-blocked'} = "selected='selected'">custom-blocked</option>
1901 <option value='custom-expressions' $selected {'DST'}{'custom-expressions'} = "selected='selected'">custom-expressions</option>
1905 <td class='base' valign='top'>
1906 <select name='ACCESS'>
1907 <option value='block' $selected {'ACCESS'}{'block'}> $Lang ::tr{'urlfilter mode block'}</option>
1908 <option value='allow' $selected {'ACCESS'}{'allow'}> $Lang ::tr{'urlfilter mode allow'}</option>
1920 <td> $Lang ::tr{'remark'} <img src='/blob.gif' alt='*'></td>
1928 <td><input type='text' name='COMMENT' value=' $tcsettings {'COMMENT'}' size='32' /></td>
1937 <table width='100%'>
1939 <td class='base'> $Lang ::tr{'urlfilter enabled'}<input type='checkbox' name='ENABLERULE' $checked{'ENABLERULE'}{'on'} /></td>
1947 <td><input type='hidden' name='ACTION' value=' $Lang ::tr{'add'}' /></td>
1948 <td><input type='hidden' name='MODE' value='TIMECONSTRAINT' /></td>
1949 <td><input type='submit' name='SUBMIT' value=' $buttontext ' /></td>
1950 <td><input type='reset' name='ACTION' value=' $Lang ::tr{'urlfilter reset'}' /></td>
1952 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
1956 <table width='100%'>
1958 <td width='1%' align='right'> <img src='/blob.gif' align='top' alt='*' /> </td>
1959 <td><font class='base'> $Lang ::tr{'this field may be blank'}</font></td>
1962 <td width='1%' align='right'><img src='/blob.gif' align='top' alt='*' /><img src='/blob.gif' align='top' alt='*' /> </td>
1963 <td><font class='base'> $Lang ::tr{'urlfilter select multi'}</font></td>
1969 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
1970 print "<input type='hidden' name='EDITING' value=' $tcsettings {'ID'}' /> \n " ;
1972 print "<input type='hidden' name='EDITING' value='no' /> \n " ;
1975 & Header
:: closebox
();
1978 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'current rules' });
1980 <table width='100%'>
1982 <td width='5%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter constraint definition'}</b></td>
1983 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter time space'}</b></td>
1984 <td width='15%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter src'}</b></td>
1985 <td width='5%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter dst'}</b></td>
1986 <td width='10%' class='boldbase' colspan='5' align='center'> </td>
1991 if ( $tcsettings { 'ACTION' } ne '' or $changed ne 'no' )
1993 open ( FILE
, $tcfile );
1999 foreach $line ( @tclist )
2003 @temp = split ( /\,/ , $line );
2004 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' } && $tcsettings { 'ID' } eq $id ) {
2005 print "<tr bgcolor=' $Header ::colouryellow'> \n " ; }
2007 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
2009 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
2010 if ( $temp [ 0 ] eq 'within' ) { $temp [ 0 ]= $Lang :: tr
{ 'urlfilter constraint within' }; } else { $temp [ 0 ]= $Lang :: tr
{ 'urlfilter constraint outside' }; }
2011 if ( $temp [ 13 ] eq 'any' ) { $temp [ 13 ]= $Lang :: tr
{ 'urlfilter category all' }; }
2012 if ( $temp [ 15 ] eq 'on' ) { $gif = 'on.gif' ; $toggle = 'off' ; $gdesc = $Lang :: tr
{ 'click to disable' };}
2013 else { $gif = 'off.gif' ; $toggle = 'on' ; $gdesc = $Lang :: tr
{ 'click to enable' }; }
2014 if ( $temp [ 14 ] eq 'block' ) { $led = 'led-red.gif' ; $ldesc = $Lang :: tr
{ 'urlfilter block access' };}
2015 else { $led = 'led-green.gif' ; $ldesc = $Lang :: tr
{ 'urlfilter allow access' }; }
2018 if ( $temp [ 1 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter mon' }; } else { $time .= '=' ; }
2019 if ( $temp [ 2 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter tue' }; } else { $time .= '=' ; }
2020 if ( $temp [ 3 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter wed' }; } else { $time .= '=' ; }
2021 if ( $temp [ 4 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter thu' }; } else { $time .= '=' ; }
2022 if ( $temp [ 5 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter fri' }; } else { $time .= '=' ; }
2023 if ( $temp [ 6 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter sat' }; } else { $time .= '=' ; }
2024 if ( $temp [ 7 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter sun' }; } else { $time .= '=' ; }
2025 $time = $time . ' ' . $temp [ 8 ]. ':' . $temp [ 9 ]. ' to ' . $temp [ 10 ]. ':' . $temp [ 11 ];
2028 <td align='center'> $temp [0]</td>
2029 <td align='center' nowrap> $time </td>
2030 <td align='center'> $temp [12]</td>
2031 <td align='center'> $temp [13]</td>
2032 <td align='center'><image src='/images/urlfilter/ $led ' alt=' $ldesc '></td>
2035 <form method='post' name='frma $id ' action=' $ENV {'SCRIPT_NAME'}'>
2036 <input type='image' name=' $Lang ::tr{'toggle enable disable'}' src='/images/ $gif ' title=' $gdesc ' alt=' $gdesc ' />
2037 <input type='hidden' name='MODE' value='TIMECONSTRAINT' />
2038 <input type='hidden' name='ID' value=' $id ' />
2039 <input type='hidden' name='ACTIVE' value=' $toggle ' />
2040 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
2045 <form method='post' name='frmb $id ' action=' $ENV {'SCRIPT_NAME'}'>
2046 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/edit.gif' title=' $Lang ::tr{'edit'}' alt=' $Lang ::tr{'edit'}' />
2047 <input type='hidden' name='MODE' value='TIMECONSTRAINT' />
2048 <input type='hidden' name='ID' value=' $id ' />
2049 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
2054 <form method='post' name='frmc $id ' action=' $ENV {'SCRIPT_NAME'}'>
2055 <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'}' />
2056 <input type='hidden' name='MODE' value='TIMECONSTRAINT' />
2057 <input type='hidden' name='ID' value=' $id ' />
2058 <input type='hidden' name='ACTION' value=' $Lang ::tr{'urlfilter copy rule'}' />
2063 <form method='post' name='frmd $id ' action=' $ENV {'SCRIPT_NAME'}'>
2064 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' title=' $Lang ::tr{'remove'}' alt=' $Lang ::tr{'remove'}' />
2065 <input type='hidden' name='MODE' value='TIMECONSTRAINT' />
2066 <input type='hidden' name='ID' value=' $id ' />
2067 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove'}' />
2074 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' } && $tcsettings { 'ID' } eq $id ) {
2075 print "<tr bgcolor=' $Header ::colouryellow'> \n " ; }
2077 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
2079 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
2081 <td align='center' colspan='4'> $temp [16]
2083 <td align='center' colspan='5'>
2092 # If the time constraint file contains entries, print entries and action icons
2093 if (! - z
" $tcfile " ) {
2098 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
2099 <td> <img src='/images/urlfilter/led-green.gif' alt=' $Lang ::tr{'urlfilter allow access'}' /></td>
2100 <td class='base'> $Lang ::tr{'urlfilter allow'}</td>
2101 <td> <img src='/images/urlfilter/led-red.gif' alt=' $Lang ::tr{'urlfilter block access'}' /></td>
2102 <td class='base'> $Lang ::tr{'urlfilter block'}</td>
2103 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
2104 <td class='base'> $Lang ::tr{'click to disable'}</td>
2105 <td> <img src='/images/off.gif' alt=' $Lang ::tr{'click to enable'}' /></td>
2106 <td class='base'> $Lang ::tr{'click to enable'}</td>
2107 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
2108 <td class='base'> $Lang ::tr{'edit'}</td>
2109 <td> <img src='/images/urlfilter/copy.gif' alt=' $Lang ::tr{'urlfilter copy rule'}' /></td>
2110 <td class='base'> $Lang ::tr{'urlfilter copy rule'}</td>
2111 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
2112 <td class='base'> $Lang ::tr{'remove'}</td>
2119 & Header
:: closebox
();
2121 } elsif ( $uqsettings { 'UQMODE' }) {
2123 #==========================================================
2125 # Section: Set User Quota
2127 #==========================================================
2129 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}'> \n " ;
2131 $buttontext = $Lang :: tr
{ 'urlfilter add rule' };
2132 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
2133 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter edit user quota rule' }. ':' );
2134 $buttontext = $Lang :: tr
{ 'urlfilter update rule' };
2136 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter add new user quota rule' }. ':' );
2140 <table width='100%'>
2142 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
2145 <td class='base'> $Lang ::tr{'urlfilter user time quota'}:</td>
2146 <td><input type='text' name='TIME_QUOTA' value=' $uqsettings {'TIME_QUOTA'}' size='5' /></td>
2147 <td colspan='2' rowspan= '5' valign='top' class='base'>
2148 <table cellpadding='0' cellspacing='0'>
2150 <!-- intentionally left empty -->
2153 <td> $Lang ::tr{'urlfilter assigned quota users'}:</td>
2156 <!-- intentionally left empty -->
2159 <!-- intentionally left empty -->
2162 <td><textarea name='QUOTA_USERS' cols='32' rows='6' wrap='off'>
2166 $uqsettings { 'QUOTA_USERS' } =~ s/\|/\n/g ;
2167 print $uqsettings { 'QUOTA_USERS' };
2176 <td class='base'> $Lang ::tr{'urlfilter activity detection'}:</td>
2177 <td class='base'><select name='SPORADIC'>
2178 <option value='0' $selected {'SPORADIC'}{'0'}> $Lang ::tr{'urlfilter disabled'}</option>
2179 <option value='300' $selected {'SPORADIC'}{'300'}>5 $Lang ::tr{'urlfilter minutes'}</option>
2180 <option value='900' $selected {'SPORADIC'}{'900'}>15 $Lang ::tr{'urlfilter minutes'}</option>
2184 <td class='base'> $Lang ::tr{'urlfilter renewal period'}:</td>
2185 <td class='base'><select name='RENEWAL'>
2186 <option value='hourly' $selected {'RENEWAL'}{'hourly'}> $Lang ::tr{'urlfilter hourly'}</option>
2187 <option value='daily' $selected {'RENEWAL'}{'daily'}> $Lang ::tr{'urlfilter daily'}</option>
2188 <option value='weekly' $selected {'RENEWAL'}{'weekly'}> $Lang ::tr{'urlfilter weekly'}</option>
2192 <td colspan='2'> </td>
2195 <td class='base'> $Lang ::tr{'urlfilter enabled'}</td>
2196 <td class='base'><input type='checkbox' name='ENABLEQUOTA' $checked {'ENABLEQUOTA'}{'on'} /></td>
2204 <td><input type='hidden' name='ACTION' value=' $Lang ::tr{'add'}' /></td>
2205 <td><input type='hidden' name='MODE' value='USERQUOTA' /></td>
2206 <td><input type='submit' name='SUBMIT' value=' $buttontext ' /></td>
2207 <td><input type='reset' name='ACTION' value=' $Lang ::tr{'urlfilter reset'}' /></td>
2209 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
2217 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
2218 print "<input type='hidden' name='EDITING' value=' $uqsettings {'ID'}' /> \n " ;
2220 print "<input type='hidden' name='EDITING' value='no' /> \n " ;
2223 & Header
:: closebox
();
2226 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'current rules' });
2228 <table width='100%'>
2230 <td width='15%' class='boldbase' align='center'><b><nobr> $Lang ::tr{'urlfilter time quota'}</nobr></b></td>
2231 <td width='15%' class='boldbase' align='center'><b><nobr> $Lang ::tr{'urlfilter activity detection'}</nobr></b></td>
2232 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter renewal'}</b></td>
2233 <td class='boldbase' align='center'><b> $Lang ::tr{'urlfilter assigned users'}</b></td>
2234 <td width='20%' class='boldbase' colspan='4' align='center'> </td>
2239 if ( $uqsettings { 'ACTION' } ne '' or $changed ne 'no' )
2241 open ( FILE
, $uqfile );
2247 foreach $line ( @uqlist )
2251 @temp = split ( /\,/ , $line );
2252 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' } && $uqsettings { 'ID' } eq $id ) {
2253 print "<tr bgcolor=' $Header ::colouryellow'> \n " ; }
2255 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
2257 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
2258 if ( $temp [ 4 ] eq 'on' ) { $gif = 'on.gif' ; $toggle = 'off' ; $gdesc = $Lang :: tr
{ 'click to disable' };}
2259 else { $gif = 'off.gif' ; $toggle = 'on' ; $gdesc = $Lang :: tr
{ 'click to enable' }; }
2261 $temp [ 5 ] = $temp [ 1 ];
2262 if ( $temp [ 1 ] eq '0' ) { $temp [ 5 ] = $Lang :: tr
{ 'urlfilter disabled' } } else { $temp [ 5 ] = ( $temp [ 5 ]/ 60 ). ' ' . $Lang :: tr
{ 'urlfilter minutes' } }
2263 $_ = $temp [ 3 ]; s/\|/, /g ; $temp [ 6 ] = $_ ;
2266 <td align='center'> $temp [0] $Lang ::tr{'urlfilter minutes'}</td>
2267 <td align='center'> $temp [5]</td>
2268 <td align='center'> $Lang ::tr{'urlfilter '. $temp [2]}</td>
2269 <td align='center'> $temp [6]</td>
2272 <form method='post' name='frma $id ' action=' $ENV {'SCRIPT_NAME'}'>
2273 <input type='image' name=' $Lang ::tr{'toggle enable disable'}' src='/images/ $gif ' title=' $gdesc ' alt=' $gdesc ' />
2274 <input type='hidden' name='MODE' value='USERQUOTA' />
2275 <input type='hidden' name='ID' value=' $id ' />
2276 <input type='hidden' name='ACTIVE' value=' $toggle ' />
2277 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
2282 <form method='post' name='frmb $id ' action=' $ENV {'SCRIPT_NAME'}'>
2283 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/edit.gif' title=' $Lang ::tr{'edit'}' alt=' $Lang ::tr{'edit'}' />
2284 <input type='hidden' name='MODE' value='USERQUOTA' />
2285 <input type='hidden' name='ID' value=' $id ' />
2286 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
2291 <form method='post' name='frmc $id ' action=' $ENV {'SCRIPT_NAME'}'>
2292 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' title=' $Lang ::tr{'remove'}' alt=' $Lang ::tr{'remove'}' />
2293 <input type='hidden' name='MODE' value='USERQUOTA' />
2294 <input type='hidden' name='ID' value=' $id ' />
2295 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove'}' />
2306 # If the user quota file contains entries, print entries and action icons
2307 if (! - z
" $uqfile " ) {
2312 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
2313 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
2314 <td class='base'> $Lang ::tr{'click to disable'}</td>
2315 <td> <img src='/images/off.gif' alt=' $Lang ::tr{'click to enable'}' /></td>
2316 <td class='base'> $Lang ::tr{'click to enable'}</td>
2317 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
2318 <td class='base'> $Lang ::tr{'edit'}</td>
2319 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
2320 <td class='base'> $Lang ::tr{'remove'}</td>
2327 & Header
:: closebox
();
2331 #==========================================================
2333 # Section: Blacklist editor
2335 #==========================================================
2337 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
2339 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter urlfilter blacklist editor' }. ':' );
2343 <table width='100%'>
2345 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
2348 <td class='base'><b> $Lang ::tr{'urlfilter blacklist name'}</b></td>
2351 <td class='base'> $Lang ::tr{'urlfilter blacklist category name'}:</td>
2352 <td><input type='text' name='BE_NAME' value=' $besettings {'BE_NAME'}' size='12' /></td>
2356 <table width='100%'>
2358 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='20%'></td>
2361 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter edit domains urls expressions'}</b></td>
2364 <td colspan='2'> $Lang ::tr{'urlfilter domains'}</td>
2365 <td colspan='2'> $Lang ::tr{'urlfilter urls'}</td>
2368 <td colspan='2'><textarea name='BE_DOMAINS' cols='38' rows='10' wrap='off'>
2372 print $besettings { 'BE_DOMAINS' };
2376 <td colspan='2'><textarea name='BE_URLS' cols='38' rows='10' wrap='off'>
2380 print $besettings { 'BE_URLS' };
2386 <td colspan='4'> $Lang ::tr{'urlfilter expressions'}</td>
2389 <td colspan='4'><textarea name='BE_EXPRESSIONS' cols='80' rows='3' wrap='off'>
2393 print $besettings { 'BE_EXPRESSIONS' };
2400 <table width='100%'>
2402 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter load blacklist'}</b></td>
2405 <td width='25%' class='base'> $Lang ::tr{'urlfilter select blacklist'}:</td>
2406 <td width='20%' class='base'>
2407 <select name='BE_BLACKLIST'>
2411 & readblockcategories
;
2412 foreach ( @categories )
2414 print "<option value=' $_ ' $selected {'BE_BLACKLIST'}{ $_ }> $_ </option> \n " ;
2423 <td colpsan='4'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter load blacklist'}' /></td>
2428 <table width='100%'>
2430 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter import blacklist'}</b></td>
2433 <td colspan='4'> $Lang ::tr{'urlfilter import text'}:</td>
2436 <td nowrap><input type='file' name='IMPORTFILE' size='40' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter import blacklist'}' /></td>
2437 <td><input type='hidden' name='MODE' value='BLACKLIST_EDITOR' /></td>
2441 <table width='100%'>
2443 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter export blacklist'}</b></td>
2446 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter export blacklist'}' /></td>
2450 <table width='100%'>
2452 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter install blacklist'}</b></td>
2455 <td width='25%' class='base'> $Lang ::tr{'urlfilter dont restart urlfilter'}:</td>
2456 <td width='20%' class='base'><input type='checkbox' name='NORESTART' $checked {'NORESTART'}{'on'} /></td>
2461 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter install blacklist'}' /></td>
2464 <td class='base' colspan='4'><br> $Lang ::tr{'urlfilter install information'}</td>
2470 <td><input type='reset' name='ACTION' value=' $Lang ::tr{'urlfilter reset'}' /></td>
2472 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
2479 & Header
:: closebox
();
2484 & Header
:: closebigbox
();
2486 & Header
:: closepage
();
2488 # -------------------------------------------------------------------
2492 # transform to pre1.8 client definitions
2493 @clients = split ( /\n/ , $filtersettings { 'UNFILTERED_CLIENTS' });
2494 undef $filtersettings { 'UNFILTERED_CLIENTS' };
2497 s/^\s+//g ; s/\s+$//g ; s/\s+-\s+/-/g ; s/\s+/ /g ; s/\n//g ;
2498 $filtersettings { 'UNFILTERED_CLIENTS' } .= " $_ " ;
2500 $filtersettings { 'UNFILTERED_CLIENTS' } =~ s/\s+$// ;
2502 # transform to pre1.8 client definitions
2503 @clients = split ( /\n/ , $filtersettings { 'BANNED_CLIENTS' });
2504 undef $filtersettings { 'BANNED_CLIENTS' };
2507 s/^\s+//g ; s/\s+$//g ; s/\s+-\s+/-/g ; s/\s+/ /g ; s/\n//g ;
2508 $filtersettings { 'BANNED_CLIENTS' } .= " $_ " ;
2510 $filtersettings { 'BANNED_CLIENTS' } =~ s/\s+$// ;
2514 delete $filtersettings { 'CUSTOM_BLACK_DOMAINS' };
2515 delete $filtersettings { 'CUSTOM_BLACK_URLS' };
2516 delete $filtersettings { 'CUSTOM_WHITE_DOMAINS' };
2517 delete $filtersettings { 'CUSTOM_WHITE_URLS' };
2518 delete $filtersettings { 'CUSTOM_EXPRESSIONS' };
2519 delete $filtersettings { 'BACKGROUND' };
2520 delete $filtersettings { 'UPDATEFILE' };
2522 system ( "chown -R nobody.nobody $dbdir " );
2523 system ( '/usr/bin/squidGuard -C custom/allowed/domains >/dev/null 2>&1' );
2524 system ( '/usr/bin/squidGuard -C custom/allowed/urls >/dev/null 2>&1' );
2525 system ( '/usr/bin/squidGuard -C custom/blocked/domains >/dev/null 2>&1' );
2526 system ( '/usr/bin/squidGuard -C custom/blocked/urls >/dev/null 2>&1 ' );
2527 & setpermissions
( $dbdir );
2529 & General
:: writehash
( "${General::swroot}/urlfilter/settings" , \
%filtersettings );
2532 # -------------------------------------------------------------------
2534 sub readblockcategories
2538 & getblockcategory
( $dbdir );
2540 foreach ( @categories ) { $_ = substr ( $_ , length ( $dbdir )+ 1 ); }
2542 @filtergroups = @categories ;
2544 foreach ( @filtergroups ) {
2551 # -------------------------------------------------------------------
2553 sub getblockcategory
2555 foreach $category (< $_ [ 0 ]/*>)
2559 if ((- e
" $category /domains" ) || (- e
" $category /urls" ))
2561 unless ( $category =~ /\bcustom\b/ ) { push ( @categories , $category ); }
2563 & getblockcategory
( $category );
2568 # -------------------------------------------------------------------
2572 if (- e
" $dbdir /custom/blocked/domains" ) {
2573 open ( FILE
, " $dbdir /custom/blocked/domains" );
2574 delete $filtersettings { 'CUSTOM_BLACK_DOMAINS' };
2575 while (< FILE
>) { $filtersettings { 'CUSTOM_BLACK_DOMAINS' } .= $_ };
2579 if (- e
" $dbdir /custom/blocked/urls" ) {
2580 open ( FILE
, " $dbdir /custom/blocked/urls" );
2581 delete $filtersettings { 'CUSTOM_BLACK_URLS' };
2582 while (< FILE
>) { $filtersettings { 'CUSTOM_BLACK_URLS' } .= $_ };
2586 if (- e
" $dbdir /custom/blocked/expressions" ) {
2587 open ( FILE
, " $dbdir /custom/blocked/expressions" );
2588 delete $filtersettings { 'CUSTOM_EXPRESSIONS' };
2589 while (< FILE
>) { $filtersettings { 'CUSTOM_EXPRESSIONS' } .= $_ };
2593 if (- e
" $dbdir /custom/allowed/domains" ) {
2594 open ( FILE
, " $dbdir /custom/allowed/domains" );
2595 delete $filtersettings { 'CUSTOM_WHITE_DOMAINS' };
2596 while (< FILE
>) { $filtersettings { 'CUSTOM_WHITE_DOMAINS' } .= $_ };
2599 if (- e
" $dbdir /custom/allowed/urls" ) {
2600 open ( FILE
, " $dbdir /custom/allowed/urls" );
2601 delete $filtersettings { 'CUSTOM_WHITE_URLS' };
2602 while (< FILE
>) { $filtersettings { 'CUSTOM_WHITE_URLS' } .= $_ };
2607 # -------------------------------------------------------------------
2609 sub aggregatedconstraints
2629 @tmp1 = split ( /\,/ , $x );
2633 @tmp2 = split ( /\,/ );
2634 if (( $tmp1 [ 15 ] eq 'on' ) && ( $tmp2 [ 15 ] eq 'on' ))
2636 if (( $tmp1 [ 0 ] eq $tmp2 [ 0 ]) && ( $tmp1 [ 12 ] eq $tmp2 [ 12 ]) && ( $tmp1 [ 13 ] eq $tmp2 [ 13 ]) && ( $tmp1 [ 14 ] eq $tmp2 [ 14 ]))
2639 $tmp2 [ 16 ] .= " weekly " ;
2640 if ( $tmp1 [ 1 ] eq 'on' ) { $tmp2 [ 16 ] .= "m" ; }
2641 if ( $tmp1 [ 2 ] eq 'on' ) { $tmp2 [ 16 ] .= "t" ; }
2642 if ( $tmp1 [ 3 ] eq 'on' ) { $tmp2 [ 16 ] .= "w" ; }
2643 if ( $tmp1 [ 4 ] eq 'on' ) { $tmp2 [ 16 ] .= "h" ; }
2644 if ( $tmp1 [ 5 ] eq 'on' ) { $tmp2 [ 16 ] .= "f" ; }
2645 if ( $tmp1 [ 6 ] eq 'on' ) { $tmp2 [ 16 ] .= "a" ; }
2646 if ( $tmp1 [ 7 ] eq 'on' ) { $tmp2 [ 16 ] .= "s" ; }
2647 $tmp2 [ 16 ] .= " $tmp1 [8]: $tmp1 [9]- $tmp1 [10]: $tmp1 [11] \n " ;
2648 $_ = join ( "," , @tmp2 );
2655 $tmp1 [ 16 ] .= " weekly " ;
2656 if ( $tmp1 [ 1 ] eq 'on' ) { $tmp1 [ 16 ] .= "m" ; }
2657 if ( $tmp1 [ 2 ] eq 'on' ) { $tmp1 [ 16 ] .= "t" ; }
2658 if ( $tmp1 [ 3 ] eq 'on' ) { $tmp1 [ 16 ] .= "w" ; }
2659 if ( $tmp1 [ 4 ] eq 'on' ) { $tmp1 [ 16 ] .= "h" ; }
2660 if ( $tmp1 [ 5 ] eq 'on' ) { $tmp1 [ 16 ] .= "f" ; }
2661 if ( $tmp1 [ 6 ] eq 'on' ) { $tmp1 [ 16 ] .= "a" ; }
2662 if ( $tmp1 [ 7 ] eq 'on' ) { $tmp1 [ 16 ] .= "s" ; }
2663 $tmp1 [ 16 ] .= " $tmp1 [8]: $tmp1 [9]- $tmp1 [10]: $tmp1 [11] \n " ;
2664 $x = join ( "," , @tmp1 );
2674 # -------------------------------------------------------------------
2680 foreach $category (< $bldir /*>)
2683 system ( "chmod 755 $category &> /dev/null" );
2684 foreach $blacklist (< $category /*>)
2686 if (- f
$blacklist ) { system ( "chmod 644 $blacklist &> /dev/null" ); }
2687 if (- d
$blacklist ) { system ( "chmod 755 $blacklist &> /dev/null" ); }
2689 system ( "chmod 666 $category /*.db &> /dev/null" );
2690 & setpermissions
( $category );
2695 # -------------------------------------------------------------------
2699 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\)\$" ;
2700 my $audiovideo = " \\ .\(aiff|asf|avi|dif|divx|mov|movie|mp3|mpe?g?|mpv2|ogg|ra?m|snd|qt|wav|wma|wmf|wmv\)\$" ;
2701 my $archives = " \\ .\(bin|bz2|cab|cdr|dmg|gz|hqx|rar|smi|sit|sea|tar|tgz|zip\)\$" ;
2703 my $ident = " anonymous" ;
2716 if (!(- d
" $dbdir /custom" )) { mkdir ( " $dbdir /custom" ) }
2717 if (!(- d
" $dbdir /custom/blocked" )) { mkdir ( " $dbdir /custom/blocked" ) }
2718 if (!(- d
" $dbdir /custom/allowed" )) { mkdir ( " $dbdir /custom/allowed" ) }
2720 open ( FILE
, ">/ $dbdir /custom/blocked/domains" );
2721 print FILE
$filtersettings { 'CUSTOM_BLACK_DOMAINS' };
2723 open ( FILE
, ">/ $dbdir /custom/blocked/urls" );
2724 print FILE
$filtersettings { 'CUSTOM_BLACK_URLS' };
2726 open ( FILE
, ">/ $dbdir /custom/blocked/expressions" );
2727 print FILE
$filtersettings { 'CUSTOM_EXPRESSIONS' };
2729 open ( FILE
, ">/ $dbdir /custom/blocked/files" );
2730 if ( $filtersettings { 'BLOCK_EXECUTABLES' } eq 'on' ) { print FILE
" $executables \n " ; }
2731 if ( $filtersettings { 'BLOCK_AUDIO-VIDEO' } eq 'on' ) { print FILE
" $audiovideo \n " ; }
2732 if ( $filtersettings { 'BLOCK_ARCHIVES' } eq 'on' ) { print FILE
" $archives \n " ; }
2734 open ( FILE
, ">/ $dbdir /custom/allowed/domains" );
2735 print FILE
$filtersettings { 'CUSTOM_WHITE_DOMAINS' };
2737 open ( FILE
, ">/ $dbdir /custom/allowed/urls" );
2738 print FILE
$filtersettings { 'CUSTOM_WHITE_URLS' };
2741 if ( $filtersettings { 'ENABLE_USERNAME_LOG' } eq 'on' ) { $ident = "" ; }
2743 if ( $filtersettings { 'REDIRECT_PAGE' } eq '' )
2745 if (( $filtersettings { 'SHOW_CATEGORY' } eq 'on' ) || ( $filtersettings { 'SHOW_URL' } eq 'on' ) || ( $filtersettings { 'SHOW_IP' } eq 'on' )) {
2746 if ( $filtersettings { 'SHOW_CATEGORY' } eq 'on' ) { $redirect .= "&category= %t " ; }
2747 if ( $filtersettings { 'SHOW_URL' } eq 'on' ) { $redirect .= "&url= %u " ; }
2748 if ( $filtersettings { 'SHOW_IP' } eq 'on' ) { $redirect .= "&ip= %a " ; }
2749 $redirect =~ s/^&/?/ ;
2750 $redirect = "http:\/\/ $netsettings {'GREEN_ADDRESS'}: $http_port \/redirect.cgi" . $redirect ;
2752 $redirect = "http:\/\/ $netsettings {'GREEN_ADDRESS'}: $http_port \/redirect.cgi" ;
2754 } else { $redirect = $filtersettings { 'REDIRECT_PAGE' }; }
2756 if ( $filtersettings { 'ENABLE_DNSERROR' } eq 'on' ) { $redirect = "302:http://0.0.0.0" ; }
2760 if ( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' )
2762 $defaultrule .= "custom-allowed " ;
2764 if ( $filtersettings { 'BLOCK_ALL' } eq 'on' )
2766 $defaultrule .= "none" ;
2770 if ( $filtersettings { 'BLOCK_IP_ADDR' } eq 'on' )
2772 $defaultrule .= "!in-addr " ;
2774 for ( $i = 0 ; $i <= @filtergroups ; $i ++) {
2775 if ( $filtersettings { @filtergroups [ $i ]} eq 'on' )
2777 $defaultrule .= "! @categories [ $i ] " ;
2780 if ( $filtersettings { 'ENABLE_CUSTOM_BLACKLIST' } eq 'on' )
2782 $defaultrule .= "!custom-blocked " ;
2784 if ( $filtersettings { 'ENABLE_CUSTOM_EXPRESSIONS' } eq 'on' )
2786 $defaultrule .= "!custom-expressions " ;
2788 if (( $filtersettings { 'BLOCK_EXECUTABLES' } eq 'on' ) ||
2789 ( $filtersettings { 'BLOCK_AUDIO-VIDEO' } eq 'on' ) ||
2790 ( $filtersettings { 'BLOCK_ARCHIVES' } eq 'on' ))
2792 $defaultrule .= "!files " ;
2794 $defaultrule .= "any" ;
2797 $defaultrule =~ s/\// _
/ g
;
2799 open ( FILE
, ">${General::swroot}/urlfilter/squidGuard.conf" ) or die "Unable to write squidGuard.conf file" ;
2802 print FILE
"logdir /var/log/squidGuard \n " ;
2803 print FILE
"dbhome $dbdir \n\n " ;
2805 undef @repositoryfiles ;
2806 if ( $filtersettings { 'ENABLE_REWRITE' } eq 'on' )
2808 @repositorylist = < $repository /*>;
2809 foreach ( @repositorylist )
2811 if (!- d
) { push ( @repositoryfiles , substr ( $_ , rindex ( $_ , "/" )+ 1 )); }
2815 if ((( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles )) || ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' ))
2817 print FILE
"rewrite rew-rule-1 { \n " ;
2819 if (( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles ))
2821 print FILE
" # rewrite localfiles \n " ;
2822 foreach ( @repositoryfiles )
2824 print FILE
" s@.*/ $_ \$\ @http :// $netsettings {'GREEN_ADDRESS'}: $http_port /repository/ $_ \ @i \n " ;
2828 if ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' )
2830 print FILE
" # rewrite safesearch \n " ;
2831 print FILE
" s@(.* \\ Wgoogle \\ . \\ w+/(webhp|search|imghp|images|grphp|groups|frghp|froogle) \\ ?)(.*)( \\ bsafe= \\ w+)(.*)\@ \\ 1 \\ 3safe=strict \\ 5\ @i \n " ;
2832 print FILE
" s@(.* \\ Wgoogle \\ . \\ w+/(webhp|search|imghp|images|grphp|groups|frghp|froogle) \\ ?)(.*)\@ \\ 1safe=strict \\ \& \\ 3\ @i \n " ;
2833 print FILE
" s@(.* \\ Wsearch \\ .yahoo \\ . \\ w+/search \\ W)(.*)( \\ bvm= \\ w+)(.*)\@ \\ 1 \\ 2vm=r \\ 4\ @i \n " ;
2834 print FILE
" s@(.* \\ Wsearch \\ .yahoo \\ . \\ w+/search \\ W.*)\@ \\ 1 \\ \&vm=r\ @i \n " ;
2835 print FILE
" s@(.* \\ Walltheweb \\ .com/customize \\ ?)(.*)( \\ bcopt_offensive= \\ w+)(.*)\@ \\ 1 \\ 2copt_offensive=on \\ 4\ @i \n " ;
2840 if ((!( $filtersettings { 'UNFILTERED_CLIENTS' } eq '' )) && ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' )) {
2841 print FILE
"rewrite rew-rule-2 { \n " ;
2842 if (( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles ))
2844 print FILE
" # rewrite localfiles \n " ;
2845 foreach ( @repositoryfiles )
2847 print FILE
" s@.*/ $_ \$\ @http :// $netsettings {'GREEN_ADDRESS'}: $http_port /repository/ $_ \ @i \n " ;
2850 print FILE
" # rewrite nothing \n " ;
2856 if (!( $filtersettings { 'UNFILTERED_CLIENTS' } eq '' )) {
2857 print FILE
"src unfiltered { \n " ;
2858 print FILE
" ip $filtersettings {'UNFILTERED_CLIENTS'} \n " ;
2861 if (!( $filtersettings { 'BANNED_CLIENTS' } eq '' )) {
2862 print FILE
"src banned { \n " ;
2863 print FILE
" ip $filtersettings {'BANNED_CLIENTS'} \n " ;
2864 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
2866 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
2868 print FILE
" logfile " . $ident . " banned.log \n " ;
2870 print FILE
" logfile " . $ident . " urlfilter.log \n " ;
2892 $uq [ 0 ] = $uq [ 0 ] * 60 ;
2893 if ( $uq [ 1 ] eq '0' ) {
2894 if ( $uq [ 2 ] eq 'hourly' ) { $uq [ 1 ] = 3600 }
2895 if ( $uq [ 2 ] eq 'daily' ) { $uq [ 1 ] = 86400 }
2896 if ( $uq [ 2 ] eq 'weekly' ) { $uq [ 1 ] = 604800 }
2899 print FILE
"src quota- $idx { \n " ;
2900 print FILE
" user $uq [3] \n " ;
2901 print FILE
" userquota $uq [0] $uq [1] $uq [2] \n " ;
2909 @tclist = & aggregatedconstraints
;
2918 if ( $tc [ 15 ] eq 'on' )
2921 print FILE
"src network- $idx { \n " ;
2922 @clients = split ( / / , $tc [ 12 ]);
2923 @temp = split ( /-/ , $clients [ 0 ]);
2924 if ( (& General
:: validipormask
( $temp [ 0 ])) || (& General
:: validipandmask
( $temp [ 0 ])))
2926 print FILE
" ip $tc [12] \n " ;
2929 @clients = split ( / / , $tc [ 12 ]);
2930 foreach $line ( @clients )
2932 $line =~ s/(^\w+)\\(\w+$)/$1%5c$2/ ;
2933 print FILE
" $line " ;
2937 if (( $filtersettings { 'ENABLE_LOG' } eq 'on' ) && ( $tc [ 14 ] eq 'block' ) && ( $tc [ 13 ] eq 'any' ))
2939 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
2941 print FILE
" logfile " . $ident . " timeconst.log \n " ;
2943 print FILE
" logfile " . $ident . " urlfilter.log \n " ;
2955 if ( $tc [ 15 ] eq 'on' )
2958 print FILE
"time constraint- $idx { \n " ;
2959 print FILE
" $tc [16] \n " ;
2965 foreach $category ( @categories ) {
2966 $blacklist = $category ;
2967 $category =~ s/\// _
/ g
;
2969 if ( $filtersettings { "FILTER_" . uc ( $category )} ne "on" ){
2970 my $constraintrule = "false" ;
2975 $tc [ 13 ] =~ s/\// _
/ g
;
2976 if ( $tc [ 15 ] eq 'on' && $tc [ 13 ] =~ $category ){
2977 $constraintrule = "true" ;
2981 if ( $constraintrule eq "false" ){
2986 print FILE
"dest $category { \n " ;
2987 if (- e
" $dbdir / $blacklist /domains" ) {
2988 print FILE
" domainlist $blacklist \/domains \n " ;
2990 if (- e
" $dbdir / $blacklist /urls" ) {
2991 print FILE
" urllist $blacklist \/urls \n " ;
2993 if ((- e
" $dbdir / $blacklist /expressions" ) && ( $filtersettings { 'ENABLE_EXPR_LISTS' } eq 'on' )) {
2994 print FILE
" expressionlist $blacklist \/expressions \n " ;
2996 if ((( $category eq 'ads' ) || ( $category eq 'adv' )) && ( $filtersettings { 'ENABLE_EMPTY_ADS' } eq 'on' ))
2998 print FILE
" redirect http:\/\/ $netsettings {'GREEN_ADDRESS'}: $http_port \/images/urlfilter/1x1.gif \n " ;
3000 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
3002 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
3004 print FILE
" logfile $ident $category .log \n " ;
3006 print FILE
" logfile $ident urlfilter.log \n " ;
3010 $category = $blacklist ;
3013 print FILE
"dest files { \n " ;
3014 print FILE
" expressionlist custom\/blocked\/files \n " ;
3015 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
3017 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
3019 print FILE
" logfile $ident files.log \n " ;
3021 print FILE
" logfile $ident urlfilter.log \n " ;
3026 print FILE
"dest custom-allowed { \n " ;
3027 print FILE
" domainlist custom\/allowed\/domains \n " ;
3028 print FILE
" urllist custom\/allowed\/urls \n " ;
3031 print FILE
"dest custom-blocked { \n " ;
3032 print FILE
" domainlist custom\/blocked\/domains \n " ;
3033 print FILE
" urllist custom\/blocked\/urls \n " ;
3034 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
3036 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
3038 print FILE
" logfile $ident custom.log \n " ;
3040 print FILE
" logfile $ident urlfilter.log \n " ;
3045 print FILE
"dest custom-expressions { \n " ;
3046 print FILE
" expressionlist custom\/blocked\/expressions \n " ;
3047 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
3049 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
3051 print FILE
" logfile $ident custom.log \n " ;
3053 print FILE
" logfile $ident urlfilter.log \n " ;
3058 print FILE
"acl { \n " ;
3059 if (!( $filtersettings { 'UNFILTERED_CLIENTS' } eq '' )) {
3060 print FILE
" unfiltered { \n " ;
3061 print FILE
" pass all \n " ;
3062 if ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' )
3064 print FILE
" rewrite rew-rule-2 \n " ;
3066 print FILE
" } \n\n " ;
3068 if (!( $filtersettings { 'BANNED_CLIENTS' } eq '' )) {
3069 print FILE
" banned { \n " ;
3070 print FILE
" pass " ;
3071 if (( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'on' ))
3073 print FILE
"custom-allowed " ;
3075 print FILE
"none \n " ;
3076 print FILE
" } \n\n " ;
3093 $qredirect = $redirect ;
3094 $qredirect =~ s/\%t/\%q\%20-\%20\%i/ ;
3095 print FILE
" quota- $idx { \n " ;
3096 print FILE
" pass " ;
3097 if (( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'on' ))
3099 print FILE
"custom-allowed " ;
3101 print FILE
"none \n " ;
3102 unless ( $redirect eq $qredirect ) { print FILE
" redirect $qredirect \n " ; }
3103 print FILE
" } \n\n " ;
3115 @ec = split ( /\|/ , $tc [ 13 ]);
3116 foreach ( @ec ) { s/\// _
/ g
; }
3117 if ( $tc [ 15 ] eq 'on' )
3120 print FILE
" network- $idx $tc [0] constraint- $idx { \n " ;
3121 print FILE
" pass " ;
3123 if ( $filtersettings { 'BLOCK_ALL' } eq 'on' )
3125 if ( $tc [ 14 ] eq 'block' )
3127 if (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' )) {
3128 if (( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'on' ))
3130 print FILE
"custom-allowed " ;
3134 print FILE
$defaultrule ;
3141 print FILE
$defaultrule unless (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ));
3144 if ( $tc [ 14 ] eq 'block' )
3146 $tcrule = $defaultrule ;
3147 if ( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) {
3148 $tcrule =~ s/custom-allowed // ;
3149 print FILE
"custom-allowed " unless (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'off' ));
3151 if (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' )) {
3156 print FILE
"! $_ " unless ( index ( $defaultrule , "!" . $_ . " " ) ge 0 );
3159 print FILE
$tcrule unless (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ));
3161 $tcrule = $defaultrule ;
3162 if (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ))
3168 $tcrule = " $_ " . $tcrule unless ( index ( $defaultrule , "!" . $_ . " " ) ge 0 );
3169 $tcrule =~ s/!$_ // ;
3178 print FILE
" } \n\n " ;
3183 print FILE
" default { \n " ;
3184 print FILE
" pass $defaultrule \n " ;
3185 if (( $filtersettings { 'ENABLE_LOG' } eq 'on' ) && ( $filtersettings { 'BLOCK_ALL' } eq 'on' ))
3187 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
3189 print FILE
" logfile" . $ident . " default.log \n " ;
3191 print FILE
" logfile" . $ident . " urlfilter.log \n " ;
3194 if ((( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles )) || ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' ))
3196 print FILE
" rewrite rew-rule-1 \n " ;
3198 print FILE
" redirect $redirect \n " ;
3205 # -------------------------------------------------------------------