]>
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' width='50%'><textarea name='CUSTOM_BLACK_DOMAINS' cols='32' rows='6' wrap='off'>
1221 print $filtersettings { 'CUSTOM_BLACK_DOMAINS' };
1225 <td colspan='2' width='50%'><textarea name='CUSTOM_BLACK_URLS' cols='32' rows='6' wrap='off'>
1229 print $filtersettings { 'CUSTOM_BLACK_URLS' };
1235 <table width='100%'>
1237 <td class='base' width='25%'> $Lang ::tr{'urlfilter enable custom blacklist'}:</td>
1238 <td><input type='checkbox' name='ENABLE_CUSTOM_BLACKLIST' $checked {'ENABLE_CUSTOM_BLACKLIST'}{'on'} /></td>
1244 <table width='100%'>
1246 <td><b> $Lang ::tr{'urlfilter custom whitelist'}</b></td>
1252 <td colspan='2'> $Lang ::tr{'urlfilter allowed domains'} <img src='/blob.gif' alt='*' /></td>
1253 <td colspan='2'> $Lang ::tr{'urlfilter allowed urls'} <img src='/blob.gif' alt='*' /></td>
1256 <td colspan='2' width='50%'><textarea name='CUSTOM_WHITE_DOMAINS' cols='32' rows='6' wrap='off'>
1260 print $filtersettings { 'CUSTOM_WHITE_DOMAINS' };
1264 <td colspan='2' width='50%'><textarea name='CUSTOM_WHITE_URLS' cols='32' rows='6' wrap='off'>
1268 print $filtersettings { 'CUSTOM_WHITE_URLS' };
1274 <table width='100%'>
1276 <td class='base' width='25%'> $Lang ::tr{'urlfilter enable custom whitelist'}:</td>
1277 <td><input type='checkbox' name='ENABLE_CUSTOM_WHITELIST' $checked {'ENABLE_CUSTOM_WHITELIST'}{'on'} /></td>
1283 <table width='100%'>
1285 <td colspan='4'><b> $Lang ::tr{'urlfilter custom expression list'}</b></td>
1288 <td colspan='4'> $Lang ::tr{'urlfilter blocked expressions'} <img src='/blob.gif' alt='*' /></td>
1291 <td colspan='4'><textarea name='CUSTOM_EXPRESSIONS' cols='70' rows='3' wrap='off'>
1295 print $filtersettings { 'CUSTOM_EXPRESSIONS' };
1301 <td class='base' width='25%'> $Lang ::tr{'urlfilter enable custom expression list'}:</td>
1302 <td><input type='checkbox' name='ENABLE_CUSTOM_EXPRESSIONS' $checked {'ENABLE_CUSTOM_EXPRESSIONS'}{'on'} /></td>
1308 <table width='100%'>
1310 <td colspan='4'><b> $Lang ::tr{'urlfilter file ext block'}</b></td>
1313 <td width='25%' class='base'> $Lang ::tr{'urlfilter block executables'}:</td>
1314 <td width='12%'><input type='checkbox' name='BLOCK_EXECUTABLES' $checked {'BLOCK_EXECUTABLES'}{'on'} /></td>
1315 <td width='25%' class='base'> $Lang ::tr{'urlfilter block audio-video'}:</td>
1316 <td><input type='checkbox' name='BLOCK_AUDIO-VIDEO' $checked {'BLOCK_AUDIO-VIDEO'}{'on'} /></td>
1319 <td class='base'> $Lang ::tr{'urlfilter block archives'}:</td>
1320 <td><input type='checkbox' name='BLOCK_ARCHIVES' $checked {'BLOCK_ARCHIVES'}{'on'} /></td>
1326 <table width='100%'>
1328 <td colspan='4'><b> $Lang ::tr{'urlfilter local file redirection'}</b></td>
1331 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable rewrite rules'}:</td>
1332 <td width='12%'><input type='checkbox' name='ENABLE_REWRITE' $checked {'ENABLE_REWRITE'}{'on'} /></td>
1337 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter manage repository'}'></td>
1344 <table width='100%'>
1346 <td colspan='2'><b> $Lang ::tr{'urlfilter network access control'}</b></td>
1351 <td colspan='2'> $Lang ::tr{'urlfilter unfiltered clients'} <img src='/blob.gif' alt='*' /></td>
1352 <td colspan='2'> $Lang ::tr{'urlfilter banned clients'} <img src='/blob.gif' alt='*' /></td>
1355 <td colspan='2' width='50%'><textarea name='UNFILTERED_CLIENTS' cols='32' rows='6' wrap='off'>
1359 # transform from pre1.8 client definitions
1360 $filtersettings { 'UNFILTERED_CLIENTS' } =~ s/^\s+//g ;
1361 $filtersettings { 'UNFILTERED_CLIENTS' } =~ s/\s+$//g ;
1362 $filtersettings { 'UNFILTERED_CLIENTS' } =~ s/\s+-\s+/-/g ;
1363 $filtersettings { 'UNFILTERED_CLIENTS' } =~ s/\s+/ /g ;
1365 @clients = split ( / / , $filtersettings { 'UNFILTERED_CLIENTS' });
1366 undef $filtersettings { 'UNFILTERED_CLIENTS' };
1367 foreach ( @clients ) { $filtersettings { 'UNFILTERED_CLIENTS' } .= " $_ \n " ; }
1369 print $filtersettings { 'UNFILTERED_CLIENTS' };
1373 <td colspan='2' width='50%'><textarea name='BANNED_CLIENTS' cols='32' rows='6' wrap='off'>
1377 # transform from pre1.8 client definitions
1378 $filtersettings { 'BANNED_CLIENTS' } =~ s/^\s+//g ;
1379 $filtersettings { 'BANNED_CLIENTS' } =~ s/\s+$//g ;
1380 $filtersettings { 'BANNED_CLIENTS' } =~ s/\s+-\s+/-/g ;
1381 $filtersettings { 'BANNED_CLIENTS' } =~ s/\s+/ /g ;
1383 @clients = split ( / / , $filtersettings { 'BANNED_CLIENTS' });
1384 undef $filtersettings { 'BANNED_CLIENTS' };
1385 foreach ( @clients ) { $filtersettings { 'BANNED_CLIENTS' } .= " $_ \n " ; }
1387 print $filtersettings { 'BANNED_CLIENTS' };
1394 <table width='100%'>
1396 <td colspan='4'><b> $Lang ::tr{'urlfilter timebased access control'}</b></td>
1399 <td width='25%'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter set time constraints'}'></td>
1400 <td width='25%'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter set user quota'}'></td>
1406 <table width='100%'>
1408 <td colspan='4'><b> $Lang ::tr{'urlfilter block settings'}</b></td>
1411 <td width='25%' class='base'> $Lang ::tr{'urlfilter show category'}:</td>
1412 <td width='12%'><input type='checkbox' name='SHOW_CATEGORY' $checked {'SHOW_CATEGORY'}{'on'} /></td>
1413 <td width='25%' class='base'> $Lang ::tr{'urlfilter redirectpage'}: <img src='/blob.gif' alt='*' /></td>
1414 <td><input type='text' name='REDIRECT_PAGE' value=' $filtersettings {'REDIRECT_PAGE'}' size='40' /></td>
1417 <td class='base'> $Lang ::tr{'urlfilter show url'}:</td>
1418 <td><input type='checkbox' name='SHOW_URL' $checked {'SHOW_URL'}{'on'} /></td>
1419 <td class='base'> $Lang ::tr{'urlfilter msg text 1'}: <img src='/blob.gif' alt='*' /></td>
1420 <td><input type='text' name='MSG_TEXT_1' value=' $filtersettings {'MSG_TEXT_1'}' size='40' /></td>
1423 <td class='base'> $Lang ::tr{'urlfilter show ip'}:</td>
1424 <td><input type='checkbox' name='SHOW_IP' $checked {'SHOW_IP'}{'on'} /></td>
1425 <td class='base'> $Lang ::tr{'urlfilter msg text 2'}: <img src='/blob.gif' alt='*' /></td>
1426 <td><input type='text' name='MSG_TEXT_2' value=' $filtersettings {'MSG_TEXT_2'}' size='40' /></td>
1429 <td class='base'> $Lang ::tr{'urlfilter show dnserror'}:</td>
1430 <td><input type='checkbox' name='ENABLE_DNSERROR' $checked {'ENABLE_DNSERROR'}{'on'} /></td>
1431 <td class='base'> $Lang ::tr{'urlfilter msg text 3'}: <img src='/blob.gif' alt='*' /></td>
1432 <td><input type='text' name='MSG_TEXT_3' value=' $filtersettings {'MSG_TEXT_3'}' size='40' /></td>
1436 <table width='100%'>
1438 <td colspan='4'><b> $Lang ::tr{'urlfilter advanced settings'}</b></td>
1441 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable expression lists'}:</td>
1442 <td width='12%'><input type='checkbox' name='ENABLE_EXPR_LISTS' $checked {'ENABLE_EXPR_LISTS'}{'on'} /></td>
1443 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable log'}:</td>
1444 <td><input type='checkbox' name='ENABLE_LOG' $checked {'ENABLE_LOG'}{'on'} /></td>
1447 <td class='base'> $Lang ::tr{'urlfilter safesearch'}:</td>
1448 <td><input type='checkbox' name='ENABLE_SAFESEARCH' $checked {'ENABLE_SAFESEARCH'}{'on'} /></td>
1449 <td class='base'> $Lang ::tr{'urlfilter username log'}:</td>
1450 <td><input type='checkbox' name='ENABLE_USERNAME_LOG' $checked {'ENABLE_USERNAME_LOG'}{'on'} /></td>
1453 <td class='base'> $Lang ::tr{'urlfilter empty ads'}:</td>
1454 <td><input type='checkbox' name='ENABLE_EMPTY_ADS' $checked {'ENABLE_EMPTY_ADS'}{'on'} /></td>
1455 <td class='base'> $Lang ::tr{'urlfilter category log'}:</td>
1456 <td><input type='checkbox' name='ENABLE_CATEGORY_LOG' $checked {'ENABLE_CATEGORY_LOG'}{'on'} /></td>
1459 <td class='base'> $Lang ::tr{'urlfilter block ip'}:</td>
1460 <td><input type='checkbox' name='BLOCK_IP_ADDR' $checked {'BLOCK_IP_ADDR'}{'on'} /></td>
1463 <td class='base'> $Lang ::tr{'urlfilter block all'}:</td>
1464 <td><input type='checkbox' name='BLOCK_ALL' $checked {'BLOCK_ALL'}{'on'} /></td>
1465 <td class='base'> $Lang ::tr{'urlfilter whitelist always allowed'}:</td>
1466 <td><input type='checkbox' name='ENABLE_GLOBAL_WHITELIST' $checked {'ENABLE_GLOBAL_WHITELIST'}{'on'} /></td>
1470 <table width='100%'>
1473 <img src='/blob.gif' align='top' alt='*' />
1474 <font class='base'> $Lang ::tr{'this field may be blank'}</font>
1476 <td align='right'>
1480 <table width='100%'>
1483 <td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' /></td>
1484 <td align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter save and restart'}' /></td>
1491 & Header
:: closebox
();
1495 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
1497 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter maintenance'}:" );
1500 <table width='100%'>
1502 <td class='base'><b> $Lang ::tr{'urlfilter blacklist update'}</b></td>
1505 <td> $Lang ::tr{'urlfilter upload information'}<p> $Lang ::tr{'urlfilter upload text'}:</td>
1508 <td><input type='file' name='UPDATEFILE' size='40' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter upload blacklist'}' /></td>
1514 <table width='100%'>
1516 <td colspan='2' class='base'><b> $Lang ::tr{'urlfilter automatic blacklist update'}</b>
1519 if (- e
" $updflagfile " )
1521 $blacklistage = int (- M
" $updflagfile " );
1522 print " <b>[</b> <small><i> $Lang ::tr{'urlfilter blacklist age 1'} <b> $blacklistage </b> $Lang ::tr{'urlfilter blacklist age 2'}</i></small> <b>]</b>" ;
1525 $updatesettings { 'UPDATE_SCHEDULE' } = 'monthly' ;
1526 $updatesettings { 'CUSTOM_UPDATE_URL' } = '' ;
1528 if (- e
" $updconffile " ) { & General
:: readhash
( " $updconffile " , \
%updatesettings ); }
1530 $checked { 'ENABLE_AUTOUPDATE' }{ 'off' } = '' ;
1531 $checked { 'ENABLE_AUTOUPDATE' }{ 'on' } = '' ;
1532 $checked { 'ENABLE_AUTOUPDATE' }{ $updatesettings { 'ENABLE_AUTOUPDATE' }} = "checked='checked'" ;
1534 $selected { 'UPDATE_SCHEDULE' }{ $updatesettings { 'UPDATE_SCHEDULE' }} = "selected='selected'" ;
1536 $selected { 'UPDATE_SOURCE' }{ $updatesettings { 'UPDATE_SOURCE' }} = "selected='selected'" ;
1542 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable automatic blacklist update'}:</td>
1543 <td width='75%' class='base'><input type='checkbox' name='ENABLE_AUTOUPDATE' $checked {'ENABLE_AUTOUPDATE'}{'on'} /></td>
1546 <td class='base'> $Lang ::tr{'urlfilter automatic update schedule'}:</td>
1548 <select name='UPDATE_SCHEDULE'>
1549 <option value='daily' $selected {'UPDATE_SCHEDULE'}{'daily'}> $Lang ::tr{'urlfilter daily'}</option>
1550 <option value='weekly' $selected {'UPDATE_SCHEDULE'}{'weekly'}> $Lang ::tr{'urlfilter weekly'}</option>
1551 <option value='monthly' $selected {'UPDATE_SCHEDULE'}{'monthly'}> $Lang ::tr{'urlfilter monthly'}</option>
1556 <td class='base'> $Lang ::tr{'urlfilter select source'}:</td>
1557 <td class='base' colspan='2'>
1558 <select name='UPDATE_SOURCE'>
1562 foreach ( @source_urllist ) {
1564 $source_name = substr ( $_ , 0 , rindex ( $_ , "," ));
1565 $source_url = substr ( $_ , index ( $_ , "," )+ 1 );
1566 print " \t <option value=' $source_url ' $selected {'UPDATE_SOURCE'}{ $source_url }> $source_name </option> \n " ;
1570 <option value='custom' $selected {'UPDATE_SOURCE'}{'custom'}> $Lang ::tr{'urlfilter custom url'}</option>
1575 <td> $Lang ::tr{'urlfilter custom url'}:</td>
1576 <td><input type='text' name='CUSTOM_UPDATE_URL' value=' $updatesettings {'CUSTOM_UPDATE_URL'}' size='72' /></td>
1579 <table width='100%'>
1581 <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>
1587 <table width='100%'>
1589 <td class='base'><b> $Lang ::tr{'urlfilter blacklist editor'}</b></td>
1592 <td> $Lang ::tr{'urlfilter blacklist editor info'}</td>
1595 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter blacklist editor'}' /></td>
1601 <table width='100%'>
1603 <td colspan='4' class='base'><b> $Lang ::tr{'urlfilter backup settings'}</b></td>
1606 <td width='25%' class='base'> $Lang ::tr{'urlfilter enable full backup'}:</td>
1607 <td width='12%' class='base'><input type='checkbox' name='ENABLE_FULLBACKUP' $checked {'ENABLE_FULLBACKUP'}{'on'} /></td>
1612 <td colspan='4' class='base'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter backup'}' /></td>
1618 <table width='100%'>
1620 <td class='base'><b> $Lang ::tr{'urlfilter restore settings'}</b></td>
1623 <td> $Lang ::tr{'urlfilter restore text'}:</td>
1626 <td><input type='file' name='UPDATEFILE' size='40' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter restore'}' /></td>
1633 & Header
:: closebox
();
1637 #==========================================================
1639 # Section: Manage Repository
1641 #==========================================================
1643 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
1645 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter manage local file repository'}:" );
1647 <table width='100%'>
1649 <td> $Lang ::tr{'urlfilter repository information'}<br><br></td>
1652 <td> $Lang ::tr{'urlfilter upload file text'}:</td>
1655 <td><input type='file' name='UPLOADFILE' size='50' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter upload file'}' /></td>
1658 <td><br><b> $Lang ::tr{'urlfilter upload file information 1'}:</b> $Lang ::tr{'urlfilter upload file information 2'}</td>
1662 <table width='100%'>
1664 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
1671 & Header
:: closebox
();
1673 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'urlfilter current files'}: </b>[ $repository ]" );
1675 @repositorylist = < $repository /*>;
1677 undef @repositoryfiles ;
1678 foreach ( @repositorylist )
1680 if (!- d
) { push ( @repositoryfiles , substr ( $_ , rindex ( $_ , "/" )+ 1 )); }
1683 if ( @repositoryfiles )
1686 <table width='100%'>
1688 <td align='center'><b> $Lang ::tr{'urlfilter filename'}</b></td>
1689 <td width='15%' align='center'><b> $Lang ::tr{'urlfilter filesize'}</b></td>
1690 <td width='10%'></td>
1695 foreach $line ( @repositoryfiles )
1699 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
1701 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
1702 $filesize = (- s
" $repository / $line " );
1703 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/ ;
1706 <td> $line </td>
1707 <td align='right'> $filesize </td>
1710 <form method='post' name='frma $id ' action=' $ENV {'SCRIPT_NAME'}'>
1711 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' title=' $Lang ::tr{'remove'}' alt=' $Lang ::tr{'remove'}' />
1712 <input type='hidden' name='ID' value=' $line ' />
1713 <input type='hidden' name='ACTION' value=' $Lang ::tr{'urlfilter remove file'}' />
1730 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
1731 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
1732 <td class='base'> $Lang ::tr{'remove'}</td>
1739 print "<i> $Lang ::tr{'urlfilter empty repository'}</i> \n " ;
1742 & Header
:: closebox
();
1746 } elsif ( $tcsettings { 'TCMODE' }) {
1748 #==========================================================
1750 # Section: Set Time Constraints
1752 #==========================================================
1754 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}'> \n " ;
1756 $buttontext = $Lang :: tr
{ 'urlfilter add rule' };
1757 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
1758 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter edit time constraint rule' }. ':' );
1759 $buttontext = $Lang :: tr
{ 'urlfilter update rule' };
1761 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter add new time constraint rule' }. ':' );
1765 <table width='100%'>
1767 <td width='2%'> $Lang ::tr{'urlfilter constraint definition'}</td>
1768 <td width='1%'> </td>
1769 <td width='2%' align='center'> $Lang ::tr{'urlfilter monday'}</td>
1770 <td width='2%' align='center'> $Lang ::tr{'urlfilter tuesday'}</td>
1771 <td width='2%' align='center'> $Lang ::tr{'urlfilter wednesday'}</td>
1772 <td width='2%' align='center'> $Lang ::tr{'urlfilter thursday'}</td>
1773 <td width='2%' align='center'> $Lang ::tr{'urlfilter friday'}</td>
1774 <td width='2%' align='center'> $Lang ::tr{'urlfilter saturday'}</td>
1775 <td width='2%' align='center'> $Lang ::tr{'urlfilter sunday'}</td>
1776 <td width='1%'> </td>
1777 <td width='7%' colspan=3> $Lang ::tr{'urlfilter from'}</td>
1778 <td width='1%'> </td>
1779 <td width='7%' colspan=3> $Lang ::tr{'urlfilter to'}</td>
1784 <select name='DEFINITION'>
1785 <option value='within' $selected {'DEFINITION'}{'within'}> $Lang ::tr{'urlfilter constraint within'}</option>
1786 <option value='outside' $selected {'DEFINITION'}{'outside'}> $Lang ::tr{'urlfilter constraint outside'}</option>
1790 <td class='base'><input type='checkbox' name='MON' $checked {'MON'}{'on'} /></td>
1791 <td class='base'><input type='checkbox' name='TUE' $checked {'TUE'}{'on'} /></td>
1792 <td class='base'><input type='checkbox' name='WED' $checked {'WED'}{'on'} /></td>
1793 <td class='base'><input type='checkbox' name='THU' $checked {'THU'}{'on'} /></td>
1794 <td class='base'><input type='checkbox' name='FRI' $checked {'FRI'}{'on'} /></td>
1795 <td class='base'><input type='checkbox' name='SAT' $checked {'SAT'}{'on'} /></td>
1796 <td class='base'><input type='checkbox' name='SUN' $checked {'SUN'}{'on'} /></td>
1799 <select name='FROM_HOUR'>
1802 for ( $i = 0 ; $i <= 24 ; $i ++) {
1803 $_ = sprintf ( " %02s " , $i );
1804 print "<option $selected {'FROM_HOUR'}{ $_ }> $_ </option> \n " ;
1811 <select name='FROM_MINUTE'>
1814 for ( $i = 0 ; $i <= 45 ; $i += 15 ) {
1815 $_ = sprintf ( " %02s " , $i );
1816 print "<option $selected {'FROM_MINUTE'}{ $_ }> $_ </option> \n " ;
1823 <select name='TO_HOUR'>
1826 for ( $i = 0 ; $i <= 24 ; $i ++) {
1827 $_ = sprintf ( " %02s " , $i );
1828 print "<option $selected {'TO_HOUR'}{ $_ }> $_ </option> \n " ;
1835 <select name='TO_MINUTE'>
1838 for ( $i = 0 ; $i <= 45 ; $i += 15 ) {
1839 $_ = sprintf ( " %02s " , $i );
1840 print "<option $selected {'TO_MINUTE'}{ $_ }> $_ </option> \n " ;
1851 <table width='100%'>
1853 <td width='5%'> $Lang ::tr{'urlfilter source'}</td>
1854 <td width='1%'> </td>
1855 <td width='5%'> $Lang ::tr{'urlfilter dst'} <img src='/blob.gif' alt='*'><img src='/blob.gif' alt='*'></td>
1856 <td width='1%'> </td>
1857 <td width='5%'> $Lang ::tr{'urlfilter access'}</td>
1861 <td rowspan='2'><textarea name='SRC' cols='28' rows='5' wrap='off'>
1865 # transform from pre1.8 client definitions
1866 $tcsettings { 'SRC' } =~ s/^\s+//g ;
1867 $tcsettings { 'SRC' } =~ s/\s+$//g ;
1868 $tcsettings { 'SRC' } =~ s/\s+-\s+/-/g ;
1869 $tcsettings { 'SRC' } =~ s/\s+/ /g ;
1871 @clients = split ( / / , $tcsettings { 'SRC' });
1872 undef $tcsettings { 'SRC' };
1873 foreach ( @clients ) { $tcsettings { 'SRC' } .= " $_ \n " ; }
1875 print $tcsettings { 'SRC' };
1881 <td class='base' rowspan='2' valign='top'>
1882 <select name='DST' size='6' multiple>
1883 <option value='any' $selected {'DST'}{'any'} = "selected='selected'"> $Lang ::tr{'urlfilter category all'}</option>
1884 <option value='in-addr' $selected {'DST'}{'in-addr'} = "selected='selected'">in-addr</option>
1888 & readblockcategories
;
1889 foreach ( @categories )
1891 print "<option value=' $_ ' $selected {'DST'}{ $_ }> $_ </option> \n " ;
1895 <option value='files' $selected {'DST'}{'files'} = "selected='selected'">files</option>
1896 <option value='custom-blocked' $selected {'DST'}{'custom-blocked'} = "selected='selected'">custom-blocked</option>
1897 <option value='custom-expressions' $selected {'DST'}{'custom-expressions'} = "selected='selected'">custom-expressions</option>
1901 <td class='base' valign='top'>
1902 <select name='ACCESS'>
1903 <option value='block' $selected {'ACCESS'}{'block'}> $Lang ::tr{'urlfilter mode block'}</option>
1904 <option value='allow' $selected {'ACCESS'}{'allow'}> $Lang ::tr{'urlfilter mode allow'}</option>
1916 <td> $Lang ::tr{'remark'} <img src='/blob.gif' alt='*'></td>
1924 <td><input type='text' name='COMMENT' value=' $tcsettings {'COMMENT'}' size='32' /></td>
1933 <table width='100%'>
1935 <td class='base'> $Lang ::tr{'urlfilter enabled'}<input type='checkbox' name='ENABLERULE' $checked{'ENABLERULE'}{'on'} /></td>
1943 <td><input type='hidden' name='ACTION' value=' $Lang ::tr{'add'}' /></td>
1944 <td><input type='hidden' name='MODE' value='TIMECONSTRAINT' /></td>
1945 <td><input type='submit' name='SUBMIT' value=' $buttontext ' /></td>
1946 <td><input type='reset' name='ACTION' value=' $Lang ::tr{'urlfilter reset'}' /></td>
1948 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
1952 <table width='100%'>
1954 <td width='1%' align='right'> <img src='/blob.gif' align='top' alt='*' /> </td>
1955 <td><font class='base'> $Lang ::tr{'this field may be blank'}</font></td>
1958 <td width='1%' align='right'><img src='/blob.gif' align='top' alt='*' /><img src='/blob.gif' align='top' alt='*' /> </td>
1959 <td><font class='base'> $Lang ::tr{'urlfilter select multi'}</font></td>
1965 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
1966 print "<input type='hidden' name='EDITING' value=' $tcsettings {'ID'}' /> \n " ;
1968 print "<input type='hidden' name='EDITING' value='no' /> \n " ;
1971 & Header
:: closebox
();
1974 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'current rules' });
1976 <table width='100%'>
1978 <td width='5%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter constraint definition'}</b></td>
1979 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter time space'}</b></td>
1980 <td width='15%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter src'}</b></td>
1981 <td width='5%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter dst'}</b></td>
1982 <td width='10%' class='boldbase' colspan='5' align='center'> </td>
1987 if ( $tcsettings { 'ACTION' } ne '' or $changed ne 'no' )
1989 open ( FILE
, $tcfile );
1995 foreach $line ( @tclist )
1999 @temp = split ( /\,/ , $line );
2000 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' } && $tcsettings { 'ID' } eq $id ) {
2001 print "<tr bgcolor=' $Header ::colouryellow'> \n " ; }
2003 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
2005 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
2006 if ( $temp [ 0 ] eq 'within' ) { $temp [ 0 ]= $Lang :: tr
{ 'urlfilter constraint within' }; } else { $temp [ 0 ]= $Lang :: tr
{ 'urlfilter constraint outside' }; }
2007 if ( $temp [ 13 ] eq 'any' ) { $temp [ 13 ]= $Lang :: tr
{ 'urlfilter category all' }; }
2008 if ( $temp [ 15 ] eq 'on' ) { $gif = 'on.gif' ; $toggle = 'off' ; $gdesc = $Lang :: tr
{ 'click to disable' };}
2009 else { $gif = 'off.gif' ; $toggle = 'on' ; $gdesc = $Lang :: tr
{ 'click to enable' }; }
2010 if ( $temp [ 14 ] eq 'block' ) { $led = 'led-red.gif' ; $ldesc = $Lang :: tr
{ 'urlfilter block access' };}
2011 else { $led = 'led-green.gif' ; $ldesc = $Lang :: tr
{ 'urlfilter allow access' }; }
2014 if ( $temp [ 1 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter mon' }; } else { $time .= '=' ; }
2015 if ( $temp [ 2 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter tue' }; } else { $time .= '=' ; }
2016 if ( $temp [ 3 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter wed' }; } else { $time .= '=' ; }
2017 if ( $temp [ 4 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter thu' }; } else { $time .= '=' ; }
2018 if ( $temp [ 5 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter fri' }; } else { $time .= '=' ; }
2019 if ( $temp [ 6 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter sat' }; } else { $time .= '=' ; }
2020 if ( $temp [ 7 ] eq 'on' ) { $time .= $Lang :: tr
{ 'urlfilter sun' }; } else { $time .= '=' ; }
2021 $time = $time . ' ' . $temp [ 8 ]. ':' . $temp [ 9 ]. ' to ' . $temp [ 10 ]. ':' . $temp [ 11 ];
2024 <td align='center'> $temp [0]</td>
2025 <td align='center' nowrap> $time </td>
2026 <td align='center'> $temp [12]</td>
2027 <td align='center'> $temp [13]</td>
2028 <td align='center'><image src='/images/urlfilter/ $led ' alt=' $ldesc '></td>
2031 <form method='post' name='frma $id ' action=' $ENV {'SCRIPT_NAME'}'>
2032 <input type='image' name=' $Lang ::tr{'toggle enable disable'}' src='/images/ $gif ' title=' $gdesc ' alt=' $gdesc ' />
2033 <input type='hidden' name='MODE' value='TIMECONSTRAINT' />
2034 <input type='hidden' name='ID' value=' $id ' />
2035 <input type='hidden' name='ACTIVE' value=' $toggle ' />
2036 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
2041 <form method='post' name='frmb $id ' action=' $ENV {'SCRIPT_NAME'}'>
2042 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/edit.gif' title=' $Lang ::tr{'edit'}' alt=' $Lang ::tr{'edit'}' />
2043 <input type='hidden' name='MODE' value='TIMECONSTRAINT' />
2044 <input type='hidden' name='ID' value=' $id ' />
2045 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
2050 <form method='post' name='frmc $id ' action=' $ENV {'SCRIPT_NAME'}'>
2051 <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'}' />
2052 <input type='hidden' name='MODE' value='TIMECONSTRAINT' />
2053 <input type='hidden' name='ID' value=' $id ' />
2054 <input type='hidden' name='ACTION' value=' $Lang ::tr{'urlfilter copy rule'}' />
2059 <form method='post' name='frmd $id ' action=' $ENV {'SCRIPT_NAME'}'>
2060 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' title=' $Lang ::tr{'remove'}' alt=' $Lang ::tr{'remove'}' />
2061 <input type='hidden' name='MODE' value='TIMECONSTRAINT' />
2062 <input type='hidden' name='ID' value=' $id ' />
2063 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove'}' />
2070 if ( $tcsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' } && $tcsettings { 'ID' } eq $id ) {
2071 print "<tr bgcolor=' $Header ::colouryellow'> \n " ; }
2073 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
2075 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
2077 <td align='center' colspan='4'> $temp [16]
2079 <td align='center' colspan='5'>
2088 # If the time constraint file contains entries, print entries and action icons
2089 if (! - z
" $tcfile " ) {
2094 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
2095 <td> <img src='/images/urlfilter/led-green.gif' alt=' $Lang ::tr{'urlfilter allow access'}' /></td>
2096 <td class='base'> $Lang ::tr{'urlfilter allow'}</td>
2097 <td> <img src='/images/urlfilter/led-red.gif' alt=' $Lang ::tr{'urlfilter block access'}' /></td>
2098 <td class='base'> $Lang ::tr{'urlfilter block'}</td>
2099 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
2100 <td class='base'> $Lang ::tr{'click to disable'}</td>
2101 <td> <img src='/images/off.gif' alt=' $Lang ::tr{'click to enable'}' /></td>
2102 <td class='base'> $Lang ::tr{'click to enable'}</td>
2103 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
2104 <td class='base'> $Lang ::tr{'edit'}</td>
2105 <td> <img src='/images/urlfilter/copy.gif' alt=' $Lang ::tr{'urlfilter copy rule'}' /></td>
2106 <td class='base'> $Lang ::tr{'urlfilter copy rule'}</td>
2107 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
2108 <td class='base'> $Lang ::tr{'remove'}</td>
2115 & Header
:: closebox
();
2117 } elsif ( $uqsettings { 'UQMODE' }) {
2119 #==========================================================
2121 # Section: Set User Quota
2123 #==========================================================
2125 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}'> \n " ;
2127 $buttontext = $Lang :: tr
{ 'urlfilter add rule' };
2128 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
2129 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter edit user quota rule' }. ':' );
2130 $buttontext = $Lang :: tr
{ 'urlfilter update rule' };
2132 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter add new user quota rule' }. ':' );
2136 <table width='100%'>
2138 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
2141 <td class='base'> $Lang ::tr{'urlfilter user time quota'}:</td>
2142 <td><input type='text' name='TIME_QUOTA' value=' $uqsettings {'TIME_QUOTA'}' size='5' /></td>
2143 <td colspan='2' rowspan= '5' valign='top' class='base'>
2144 <table cellpadding='0' cellspacing='0'>
2146 <!-- intentionally left empty -->
2149 <td> $Lang ::tr{'urlfilter assigned quota users'}:</td>
2152 <!-- intentionally left empty -->
2155 <!-- intentionally left empty -->
2158 <td><textarea name='QUOTA_USERS' cols='32' rows='6' wrap='off'>
2162 $uqsettings { 'QUOTA_USERS' } =~ s/\|/\n/g ;
2163 print $uqsettings { 'QUOTA_USERS' };
2172 <td class='base'> $Lang ::tr{'urlfilter activity detection'}:</td>
2173 <td class='base'><select name='SPORADIC'>
2174 <option value='0' $selected {'SPORADIC'}{'0'}> $Lang ::tr{'urlfilter disabled'}</option>
2175 <option value='300' $selected {'SPORADIC'}{'300'}>5 $Lang ::tr{'urlfilter minutes'}</option>
2176 <option value='900' $selected {'SPORADIC'}{'900'}>15 $Lang ::tr{'urlfilter minutes'}</option>
2180 <td class='base'> $Lang ::tr{'urlfilter renewal period'}:</td>
2181 <td class='base'><select name='RENEWAL'>
2182 <option value='hourly' $selected {'RENEWAL'}{'hourly'}> $Lang ::tr{'urlfilter hourly'}</option>
2183 <option value='daily' $selected {'RENEWAL'}{'daily'}> $Lang ::tr{'urlfilter daily'}</option>
2184 <option value='weekly' $selected {'RENEWAL'}{'weekly'}> $Lang ::tr{'urlfilter weekly'}</option>
2188 <td colspan='2'> </td>
2191 <td class='base'> $Lang ::tr{'urlfilter enabled'}</td>
2192 <td class='base'><input type='checkbox' name='ENABLEQUOTA' $checked {'ENABLEQUOTA'}{'on'} /></td>
2200 <td><input type='hidden' name='ACTION' value=' $Lang ::tr{'add'}' /></td>
2201 <td><input type='hidden' name='MODE' value='USERQUOTA' /></td>
2202 <td><input type='submit' name='SUBMIT' value=' $buttontext ' /></td>
2203 <td><input type='reset' name='ACTION' value=' $Lang ::tr{'urlfilter reset'}' /></td>
2205 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
2213 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
2214 print "<input type='hidden' name='EDITING' value=' $uqsettings {'ID'}' /> \n " ;
2216 print "<input type='hidden' name='EDITING' value='no' /> \n " ;
2219 & Header
:: closebox
();
2222 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'current rules' });
2224 <table width='100%'>
2226 <td width='15%' class='boldbase' align='center'><b><nobr> $Lang ::tr{'urlfilter time quota'}</nobr></b></td>
2227 <td width='15%' class='boldbase' align='center'><b><nobr> $Lang ::tr{'urlfilter activity detection'}</nobr></b></td>
2228 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'urlfilter renewal'}</b></td>
2229 <td class='boldbase' align='center'><b> $Lang ::tr{'urlfilter assigned users'}</b></td>
2230 <td width='20%' class='boldbase' colspan='4' align='center'> </td>
2235 if ( $uqsettings { 'ACTION' } ne '' or $changed ne 'no' )
2237 open ( FILE
, $uqfile );
2243 foreach $line ( @uqlist )
2247 @temp = split ( /\,/ , $line );
2248 if ( $uqsettings { 'ACTION' } eq $Lang :: tr
{ 'edit' } && $uqsettings { 'ID' } eq $id ) {
2249 print "<tr bgcolor=' $Header ::colouryellow'> \n " ; }
2251 print "<tr bgcolor=' $Header ::table1colour'> \n " ; }
2253 print "<tr bgcolor=' $Header ::table2colour'> \n " ; }
2254 if ( $temp [ 4 ] eq 'on' ) { $gif = 'on.gif' ; $toggle = 'off' ; $gdesc = $Lang :: tr
{ 'click to disable' };}
2255 else { $gif = 'off.gif' ; $toggle = 'on' ; $gdesc = $Lang :: tr
{ 'click to enable' }; }
2257 $temp [ 5 ] = $temp [ 1 ];
2258 if ( $temp [ 1 ] eq '0' ) { $temp [ 5 ] = $Lang :: tr
{ 'urlfilter disabled' } } else { $temp [ 5 ] = ( $temp [ 5 ]/ 60 ). ' ' . $Lang :: tr
{ 'urlfilter minutes' } }
2259 $_ = $temp [ 3 ]; s/\|/, /g ; $temp [ 6 ] = $_ ;
2262 <td align='center'> $temp [0] $Lang ::tr{'urlfilter minutes'}</td>
2263 <td align='center'> $temp [5]</td>
2264 <td align='center'> $Lang ::tr{'urlfilter '. $temp [2]}</td>
2265 <td align='center'> $temp [6]</td>
2268 <form method='post' name='frma $id ' action=' $ENV {'SCRIPT_NAME'}'>
2269 <input type='image' name=' $Lang ::tr{'toggle enable disable'}' src='/images/ $gif ' title=' $gdesc ' alt=' $gdesc ' />
2270 <input type='hidden' name='MODE' value='USERQUOTA' />
2271 <input type='hidden' name='ID' value=' $id ' />
2272 <input type='hidden' name='ACTIVE' value=' $toggle ' />
2273 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
2278 <form method='post' name='frmb $id ' action=' $ENV {'SCRIPT_NAME'}'>
2279 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/edit.gif' title=' $Lang ::tr{'edit'}' alt=' $Lang ::tr{'edit'}' />
2280 <input type='hidden' name='MODE' value='USERQUOTA' />
2281 <input type='hidden' name='ID' value=' $id ' />
2282 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
2287 <form method='post' name='frmc $id ' action=' $ENV {'SCRIPT_NAME'}'>
2288 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' title=' $Lang ::tr{'remove'}' alt=' $Lang ::tr{'remove'}' />
2289 <input type='hidden' name='MODE' value='USERQUOTA' />
2290 <input type='hidden' name='ID' value=' $id ' />
2291 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove'}' />
2302 # If the user quota file contains entries, print entries and action icons
2303 if (! - z
" $uqfile " ) {
2308 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
2309 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
2310 <td class='base'> $Lang ::tr{'click to disable'}</td>
2311 <td> <img src='/images/off.gif' alt=' $Lang ::tr{'click to enable'}' /></td>
2312 <td class='base'> $Lang ::tr{'click to enable'}</td>
2313 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
2314 <td class='base'> $Lang ::tr{'edit'}</td>
2315 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
2316 <td class='base'> $Lang ::tr{'remove'}</td>
2323 & Header
:: closebox
();
2327 #==========================================================
2329 # Section: Blacklist editor
2331 #==========================================================
2333 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}' enctype='multipart/form-data'> \n " ;
2335 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'urlfilter urlfilter blacklist editor' }. ':' );
2339 <table width='100%'>
2341 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
2344 <td class='base'><b> $Lang ::tr{'urlfilter blacklist name'}</b></td>
2347 <td class='base'> $Lang ::tr{'urlfilter blacklist category name'}:</td>
2348 <td><input type='text' name='BE_NAME' value=' $besettings {'BE_NAME'}' size='12' /></td>
2352 <table width='100%'>
2354 <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='20%'></td>
2357 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter edit domains urls expressions'}</b></td>
2360 <td colspan='2'> $Lang ::tr{'urlfilter domains'}</td>
2361 <td colspan='2'> $Lang ::tr{'urlfilter urls'}</td>
2364 <td colspan='2'><textarea name='BE_DOMAINS' cols='38' rows='10' wrap='off'>
2368 print $besettings { 'BE_DOMAINS' };
2372 <td colspan='2'><textarea name='BE_URLS' cols='38' rows='10' wrap='off'>
2376 print $besettings { 'BE_URLS' };
2382 <td colspan='4'> $Lang ::tr{'urlfilter expressions'}</td>
2385 <td colspan='4'><textarea name='BE_EXPRESSIONS' cols='80' rows='3' wrap='off'>
2389 print $besettings { 'BE_EXPRESSIONS' };
2396 <table width='100%'>
2398 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter load blacklist'}</b></td>
2401 <td width='25%' class='base'> $Lang ::tr{'urlfilter select blacklist'}:</td>
2402 <td width='20%' class='base'>
2403 <select name='BE_BLACKLIST'>
2407 & readblockcategories
;
2408 foreach ( @categories )
2410 print "<option value=' $_ ' $selected {'BE_BLACKLIST'}{ $_ }> $_ </option> \n " ;
2419 <td colpsan='4'><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter load blacklist'}' /></td>
2424 <table width='100%'>
2426 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter import blacklist'}</b></td>
2429 <td colspan='4'> $Lang ::tr{'urlfilter import text'}:</td>
2432 <td nowrap><input type='file' name='IMPORTFILE' size='40' /> <input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter import blacklist'}' /></td>
2433 <td><input type='hidden' name='MODE' value='BLACKLIST_EDITOR' /></td>
2437 <table width='100%'>
2439 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter export blacklist'}</b></td>
2442 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter export blacklist'}' /></td>
2446 <table width='100%'>
2448 <td class='base' colspan='4'><b> $Lang ::tr{'urlfilter install blacklist'}</b></td>
2451 <td width='25%' class='base'> $Lang ::tr{'urlfilter dont restart urlfilter'}:</td>
2452 <td width='20%' class='base'><input type='checkbox' name='NORESTART' $checked {'NORESTART'}{'on'} /></td>
2457 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'urlfilter install blacklist'}' /></td>
2460 <td class='base' colspan='4'><br> $Lang ::tr{'urlfilter install information'}</td>
2466 <td><input type='reset' name='ACTION' value=' $Lang ::tr{'urlfilter reset'}' /></td>
2468 <td><input type='button' name='return2main' value=' $Lang ::tr{'urlfilter back to main page'}' onClick='self.location.href=" $ENV {'SCRIPT_NAME'}"'></td>
2475 & Header
:: closebox
();
2480 & Header
:: closebigbox
();
2482 & Header
:: closepage
();
2484 # -------------------------------------------------------------------
2488 # transform to pre1.8 client definitions
2489 @clients = split ( /\n/ , $filtersettings { 'UNFILTERED_CLIENTS' });
2490 undef $filtersettings { 'UNFILTERED_CLIENTS' };
2493 s/^\s+//g ; s/\s+$//g ; s/\s+-\s+/-/g ; s/\s+/ /g ; s/\n//g ;
2494 $filtersettings { 'UNFILTERED_CLIENTS' } .= " $_ " ;
2496 $filtersettings { 'UNFILTERED_CLIENTS' } =~ s/\s+$// ;
2498 # transform to pre1.8 client definitions
2499 @clients = split ( /\n/ , $filtersettings { 'BANNED_CLIENTS' });
2500 undef $filtersettings { 'BANNED_CLIENTS' };
2503 s/^\s+//g ; s/\s+$//g ; s/\s+-\s+/-/g ; s/\s+/ /g ; s/\n//g ;
2504 $filtersettings { 'BANNED_CLIENTS' } .= " $_ " ;
2506 $filtersettings { 'BANNED_CLIENTS' } =~ s/\s+$// ;
2510 delete $filtersettings { 'CUSTOM_BLACK_DOMAINS' };
2511 delete $filtersettings { 'CUSTOM_BLACK_URLS' };
2512 delete $filtersettings { 'CUSTOM_WHITE_DOMAINS' };
2513 delete $filtersettings { 'CUSTOM_WHITE_URLS' };
2514 delete $filtersettings { 'CUSTOM_EXPRESSIONS' };
2515 delete $filtersettings { 'BACKGROUND' };
2516 delete $filtersettings { 'UPDATEFILE' };
2518 system ( "chown -R nobody.nobody $dbdir " );
2519 system ( '/usr/bin/squidGuard -C custom/allowed/domains >/dev/null 2>&1' );
2520 system ( '/usr/bin/squidGuard -C custom/allowed/urls >/dev/null 2>&1' );
2521 system ( '/usr/bin/squidGuard -C custom/blocked/domains >/dev/null 2>&1' );
2522 system ( '/usr/bin/squidGuard -C custom/blocked/urls >/dev/null 2>&1 ' );
2523 & setpermissions
( $dbdir );
2525 & General
:: writehash
( "${General::swroot}/urlfilter/settings" , \
%filtersettings );
2528 # -------------------------------------------------------------------
2530 sub readblockcategories
2534 & getblockcategory
( $dbdir );
2536 foreach ( @categories ) { $_ = substr ( $_ , length ( $dbdir )+ 1 ); }
2538 @filtergroups = @categories ;
2540 foreach ( @filtergroups ) {
2547 # -------------------------------------------------------------------
2549 sub getblockcategory
2551 foreach $category (< $_ [ 0 ]/*>)
2555 if ((- e
" $category /domains" ) || (- e
" $category /urls" ))
2557 unless ( $category =~ /\bcustom\b/ ) { push ( @categories , $category ); }
2559 & getblockcategory
( $category );
2564 # -------------------------------------------------------------------
2568 if (- e
" $dbdir /custom/blocked/domains" ) {
2569 open ( FILE
, " $dbdir /custom/blocked/domains" );
2570 delete $filtersettings { 'CUSTOM_BLACK_DOMAINS' };
2571 while (< FILE
>) { $filtersettings { 'CUSTOM_BLACK_DOMAINS' } .= $_ };
2575 if (- e
" $dbdir /custom/blocked/urls" ) {
2576 open ( FILE
, " $dbdir /custom/blocked/urls" );
2577 delete $filtersettings { 'CUSTOM_BLACK_URLS' };
2578 while (< FILE
>) { $filtersettings { 'CUSTOM_BLACK_URLS' } .= $_ };
2582 if (- e
" $dbdir /custom/blocked/expressions" ) {
2583 open ( FILE
, " $dbdir /custom/blocked/expressions" );
2584 delete $filtersettings { 'CUSTOM_EXPRESSIONS' };
2585 while (< FILE
>) { $filtersettings { 'CUSTOM_EXPRESSIONS' } .= $_ };
2589 if (- e
" $dbdir /custom/allowed/domains" ) {
2590 open ( FILE
, " $dbdir /custom/allowed/domains" );
2591 delete $filtersettings { 'CUSTOM_WHITE_DOMAINS' };
2592 while (< FILE
>) { $filtersettings { 'CUSTOM_WHITE_DOMAINS' } .= $_ };
2595 if (- e
" $dbdir /custom/allowed/urls" ) {
2596 open ( FILE
, " $dbdir /custom/allowed/urls" );
2597 delete $filtersettings { 'CUSTOM_WHITE_URLS' };
2598 while (< FILE
>) { $filtersettings { 'CUSTOM_WHITE_URLS' } .= $_ };
2603 # -------------------------------------------------------------------
2605 sub aggregatedconstraints
2625 @tmp1 = split ( /\,/ , $x );
2629 @tmp2 = split ( /\,/ );
2630 if (( $tmp1 [ 15 ] eq 'on' ) && ( $tmp2 [ 15 ] eq 'on' ))
2632 if (( $tmp1 [ 0 ] eq $tmp2 [ 0 ]) && ( $tmp1 [ 12 ] eq $tmp2 [ 12 ]) && ( $tmp1 [ 13 ] eq $tmp2 [ 13 ]) && ( $tmp1 [ 14 ] eq $tmp2 [ 14 ]))
2635 $tmp2 [ 16 ] .= " weekly " ;
2636 if ( $tmp1 [ 1 ] eq 'on' ) { $tmp2 [ 16 ] .= "m" ; }
2637 if ( $tmp1 [ 2 ] eq 'on' ) { $tmp2 [ 16 ] .= "t" ; }
2638 if ( $tmp1 [ 3 ] eq 'on' ) { $tmp2 [ 16 ] .= "w" ; }
2639 if ( $tmp1 [ 4 ] eq 'on' ) { $tmp2 [ 16 ] .= "h" ; }
2640 if ( $tmp1 [ 5 ] eq 'on' ) { $tmp2 [ 16 ] .= "f" ; }
2641 if ( $tmp1 [ 6 ] eq 'on' ) { $tmp2 [ 16 ] .= "a" ; }
2642 if ( $tmp1 [ 7 ] eq 'on' ) { $tmp2 [ 16 ] .= "s" ; }
2643 $tmp2 [ 16 ] .= " $tmp1 [8]: $tmp1 [9]- $tmp1 [10]: $tmp1 [11] \n " ;
2644 $_ = join ( "," , @tmp2 );
2651 $tmp1 [ 16 ] .= " weekly " ;
2652 if ( $tmp1 [ 1 ] eq 'on' ) { $tmp1 [ 16 ] .= "m" ; }
2653 if ( $tmp1 [ 2 ] eq 'on' ) { $tmp1 [ 16 ] .= "t" ; }
2654 if ( $tmp1 [ 3 ] eq 'on' ) { $tmp1 [ 16 ] .= "w" ; }
2655 if ( $tmp1 [ 4 ] eq 'on' ) { $tmp1 [ 16 ] .= "h" ; }
2656 if ( $tmp1 [ 5 ] eq 'on' ) { $tmp1 [ 16 ] .= "f" ; }
2657 if ( $tmp1 [ 6 ] eq 'on' ) { $tmp1 [ 16 ] .= "a" ; }
2658 if ( $tmp1 [ 7 ] eq 'on' ) { $tmp1 [ 16 ] .= "s" ; }
2659 $tmp1 [ 16 ] .= " $tmp1 [8]: $tmp1 [9]- $tmp1 [10]: $tmp1 [11] \n " ;
2660 $x = join ( "," , @tmp1 );
2670 # -------------------------------------------------------------------
2676 foreach $category (< $bldir /*>)
2679 system ( "chmod 755 $category &> /dev/null" );
2680 foreach $blacklist (< $category /*>)
2682 if (- f
$blacklist ) { system ( "chmod 644 $blacklist &> /dev/null" ); }
2683 if (- d
$blacklist ) { system ( "chmod 755 $blacklist &> /dev/null" ); }
2685 system ( "chmod 666 $category /*.db &> /dev/null" );
2686 & setpermissions
( $category );
2691 # -------------------------------------------------------------------
2695 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\)\$" ;
2696 my $audiovideo = " \\ .\(aiff|asf|avi|dif|divx|mov|movie|mp3|mpe?g?|mpv2|ogg|ra?m|snd|qt|wav|wma|wmf|wmv\)\$" ;
2697 my $archives = " \\ .\(bin|bz2|cab|cdr|dmg|gz|hqx|rar|smi|sit|sea|tar|tgz|zip\)\$" ;
2699 my $ident = " anonymous" ;
2712 if (!(- d
" $dbdir /custom" )) { mkdir ( " $dbdir /custom" ) }
2713 if (!(- d
" $dbdir /custom/blocked" )) { mkdir ( " $dbdir /custom/blocked" ) }
2714 if (!(- d
" $dbdir /custom/allowed" )) { mkdir ( " $dbdir /custom/allowed" ) }
2716 open ( FILE
, ">/ $dbdir /custom/blocked/domains" );
2717 print FILE
$filtersettings { 'CUSTOM_BLACK_DOMAINS' };
2719 open ( FILE
, ">/ $dbdir /custom/blocked/urls" );
2720 print FILE
$filtersettings { 'CUSTOM_BLACK_URLS' };
2722 open ( FILE
, ">/ $dbdir /custom/blocked/expressions" );
2723 print FILE
$filtersettings { 'CUSTOM_EXPRESSIONS' };
2725 open ( FILE
, ">/ $dbdir /custom/blocked/files" );
2726 if ( $filtersettings { 'BLOCK_EXECUTABLES' } eq 'on' ) { print FILE
" $executables \n " ; }
2727 if ( $filtersettings { 'BLOCK_AUDIO-VIDEO' } eq 'on' ) { print FILE
" $audiovideo \n " ; }
2728 if ( $filtersettings { 'BLOCK_ARCHIVES' } eq 'on' ) { print FILE
" $archives \n " ; }
2730 open ( FILE
, ">/ $dbdir /custom/allowed/domains" );
2731 print FILE
$filtersettings { 'CUSTOM_WHITE_DOMAINS' };
2733 open ( FILE
, ">/ $dbdir /custom/allowed/urls" );
2734 print FILE
$filtersettings { 'CUSTOM_WHITE_URLS' };
2737 if ( $filtersettings { 'ENABLE_USERNAME_LOG' } eq 'on' ) { $ident = "" ; }
2739 if ( $filtersettings { 'REDIRECT_PAGE' } eq '' )
2741 if (( $filtersettings { 'SHOW_CATEGORY' } eq 'on' ) || ( $filtersettings { 'SHOW_URL' } eq 'on' ) || ( $filtersettings { 'SHOW_IP' } eq 'on' )) {
2742 if ( $filtersettings { 'SHOW_CATEGORY' } eq 'on' ) { $redirect .= "&category= %t " ; }
2743 if ( $filtersettings { 'SHOW_URL' } eq 'on' ) { $redirect .= "&url= %u " ; }
2744 if ( $filtersettings { 'SHOW_IP' } eq 'on' ) { $redirect .= "&ip= %a " ; }
2745 $redirect =~ s/^&/?/ ;
2746 $redirect = "http:\/\/ $netsettings {'GREEN_ADDRESS'}: $http_port \/redirect.cgi" . $redirect ;
2748 $redirect = "http:\/\/ $netsettings {'GREEN_ADDRESS'}: $http_port \/redirect.cgi" ;
2750 } else { $redirect = $filtersettings { 'REDIRECT_PAGE' }; }
2752 if ( $filtersettings { 'ENABLE_DNSERROR' } eq 'on' ) { $redirect = "302:http://0.0.0.0" ; }
2756 if ( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' )
2758 $defaultrule .= "custom-allowed " ;
2760 if ( $filtersettings { 'BLOCK_ALL' } eq 'on' )
2762 $defaultrule .= "none" ;
2766 if ( $filtersettings { 'BLOCK_IP_ADDR' } eq 'on' )
2768 $defaultrule .= "!in-addr " ;
2770 for ( $i = 0 ; $i <= @filtergroups ; $i ++) {
2771 if ( $filtersettings { @filtergroups [ $i ]} eq 'on' )
2773 $defaultrule .= "! @categories [ $i ] " ;
2776 if ( $filtersettings { 'ENABLE_CUSTOM_BLACKLIST' } eq 'on' )
2778 $defaultrule .= "!custom-blocked " ;
2780 if ( $filtersettings { 'ENABLE_CUSTOM_EXPRESSIONS' } eq 'on' )
2782 $defaultrule .= "!custom-expressions " ;
2784 if (( $filtersettings { 'BLOCK_EXECUTABLES' } eq 'on' ) ||
2785 ( $filtersettings { 'BLOCK_AUDIO-VIDEO' } eq 'on' ) ||
2786 ( $filtersettings { 'BLOCK_ARCHIVES' } eq 'on' ))
2788 $defaultrule .= "!files " ;
2790 $defaultrule .= "any" ;
2793 $defaultrule =~ s/\// _
/ g
;
2795 open ( FILE
, ">${General::swroot}/urlfilter/squidGuard.conf" ) or die "Unable to write squidGuard.conf file" ;
2798 print FILE
"logdir /var/log/squidGuard \n " ;
2799 print FILE
"dbhome $dbdir \n\n " ;
2801 undef @repositoryfiles ;
2802 if ( $filtersettings { 'ENABLE_REWRITE' } eq 'on' )
2804 @repositorylist = < $repository /*>;
2805 foreach ( @repositorylist )
2807 if (!- d
) { push ( @repositoryfiles , substr ( $_ , rindex ( $_ , "/" )+ 1 )); }
2811 if ((( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles )) || ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' ))
2813 print FILE
"rewrite rew-rule-1 { \n " ;
2815 if (( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles ))
2817 print FILE
" # rewrite localfiles \n " ;
2818 foreach ( @repositoryfiles )
2820 print FILE
" s@.*/ $_ \$\ @http :// $netsettings {'GREEN_ADDRESS'}: $http_port /repository/ $_ \ @i \n " ;
2824 if ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' )
2826 print FILE
" # rewrite safesearch \n " ;
2827 print FILE
" s@(.* \\ Wgoogle \\ . \\ w+/(webhp|search|imghp|images|grphp|groups|frghp|froogle) \\ ?)(.*)( \\ bsafe= \\ w+)(.*)\@ \\ 1 \\ 3safe=strict \\ 5\ @i \n " ;
2828 print FILE
" s@(.* \\ Wgoogle \\ . \\ w+/(webhp|search|imghp|images|grphp|groups|frghp|froogle) \\ ?)(.*)\@ \\ 1safe=strict \\ \& \\ 3\ @i \n " ;
2829 print FILE
" s@(.* \\ Wsearch \\ .yahoo \\ . \\ w+/search \\ W)(.*)( \\ bvm= \\ w+)(.*)\@ \\ 1 \\ 2vm=r \\ 4\ @i \n " ;
2830 print FILE
" s@(.* \\ Wsearch \\ .yahoo \\ . \\ w+/search \\ W.*)\@ \\ 1 \\ \&vm=r\ @i \n " ;
2831 print FILE
" s@(.* \\ Walltheweb \\ .com/customize \\ ?)(.*)( \\ bcopt_offensive= \\ w+)(.*)\@ \\ 1 \\ 2copt_offensive=on \\ 4\ @i \n " ;
2836 if ((!( $filtersettings { 'UNFILTERED_CLIENTS' } eq '' )) && ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' )) {
2837 print FILE
"rewrite rew-rule-2 { \n " ;
2838 if (( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles ))
2840 print FILE
" # rewrite localfiles \n " ;
2841 foreach ( @repositoryfiles )
2843 print FILE
" s@.*/ $_ \$\ @http :// $netsettings {'GREEN_ADDRESS'}: $http_port /repository/ $_ \ @i \n " ;
2846 print FILE
" # rewrite nothing \n " ;
2852 if (!( $filtersettings { 'UNFILTERED_CLIENTS' } eq '' )) {
2853 print FILE
"src unfiltered { \n " ;
2854 print FILE
" ip $filtersettings {'UNFILTERED_CLIENTS'} \n " ;
2857 if (!( $filtersettings { 'BANNED_CLIENTS' } eq '' )) {
2858 print FILE
"src banned { \n " ;
2859 print FILE
" ip $filtersettings {'BANNED_CLIENTS'} \n " ;
2860 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
2862 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
2864 print FILE
" logfile " . $ident . " banned.log \n " ;
2866 print FILE
" logfile " . $ident . " urlfilter.log \n " ;
2888 $uq [ 0 ] = $uq [ 0 ] * 60 ;
2889 if ( $uq [ 1 ] eq '0' ) {
2890 if ( $uq [ 2 ] eq 'hourly' ) { $uq [ 1 ] = 3600 }
2891 if ( $uq [ 2 ] eq 'daily' ) { $uq [ 1 ] = 86400 }
2892 if ( $uq [ 2 ] eq 'weekly' ) { $uq [ 1 ] = 604800 }
2895 print FILE
"src quota- $idx { \n " ;
2896 print FILE
" user $uq [3] \n " ;
2897 print FILE
" userquota $uq [0] $uq [1] $uq [2] \n " ;
2905 @tclist = & aggregatedconstraints
;
2914 if ( $tc [ 15 ] eq 'on' )
2917 print FILE
"src network- $idx { \n " ;
2918 @clients = split ( / / , $tc [ 12 ]);
2919 @temp = split ( /-/ , $clients [ 0 ]);
2920 if ( (& General
:: validipormask
( $temp [ 0 ])) || (& General
:: validipandmask
( $temp [ 0 ])))
2922 print FILE
" ip $tc [12] \n " ;
2925 @clients = split ( / / , $tc [ 12 ]);
2926 foreach $line ( @clients )
2928 $line =~ s/(^\w+)\\(\w+$)/$1%5c$2/ ;
2929 print FILE
" $line " ;
2933 if (( $filtersettings { 'ENABLE_LOG' } eq 'on' ) && ( $tc [ 14 ] eq 'block' ) && ( $tc [ 13 ] eq 'any' ))
2935 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
2937 print FILE
" logfile " . $ident . " timeconst.log \n " ;
2939 print FILE
" logfile " . $ident . " urlfilter.log \n " ;
2951 if ( $tc [ 15 ] eq 'on' )
2954 print FILE
"time constraint- $idx { \n " ;
2955 print FILE
" $tc [16] \n " ;
2961 foreach $category ( @categories ) {
2962 $blacklist = $category ;
2963 $category =~ s/\// _
/ g
;
2965 if ( $filtersettings { "FILTER_" . uc ( $category )} ne "on" ){
2966 my $constraintrule = "false" ;
2971 $tc [ 13 ] =~ s/\// _
/ g
;
2972 if ( $tc [ 15 ] eq 'on' && $tc [ 13 ] =~ $category ){
2973 $constraintrule = "true" ;
2977 if ( $constraintrule eq "false" ){
2982 print FILE
"dest $category { \n " ;
2983 if (- e
" $dbdir / $blacklist /domains" ) {
2984 print FILE
" domainlist $blacklist \/domains \n " ;
2986 if (- e
" $dbdir / $blacklist /urls" ) {
2987 print FILE
" urllist $blacklist \/urls \n " ;
2989 if ((- e
" $dbdir / $blacklist /expressions" ) && ( $filtersettings { 'ENABLE_EXPR_LISTS' } eq 'on' )) {
2990 print FILE
" expressionlist $blacklist \/expressions \n " ;
2992 if ((( $category eq 'ads' ) || ( $category eq 'adv' )) && ( $filtersettings { 'ENABLE_EMPTY_ADS' } eq 'on' ))
2994 print FILE
" redirect http:\/\/ $netsettings {'GREEN_ADDRESS'}: $http_port \/images/urlfilter/1x1.gif \n " ;
2996 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
2998 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
3000 print FILE
" logfile $ident $category .log \n " ;
3002 print FILE
" logfile $ident urlfilter.log \n " ;
3006 $category = $blacklist ;
3009 print FILE
"dest files { \n " ;
3010 print FILE
" expressionlist custom\/blocked\/files \n " ;
3011 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
3013 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
3015 print FILE
" logfile $ident files.log \n " ;
3017 print FILE
" logfile $ident urlfilter.log \n " ;
3022 print FILE
"dest custom-allowed { \n " ;
3023 print FILE
" domainlist custom\/allowed\/domains \n " ;
3024 print FILE
" urllist custom\/allowed\/urls \n " ;
3027 print FILE
"dest custom-blocked { \n " ;
3028 print FILE
" domainlist custom\/blocked\/domains \n " ;
3029 print FILE
" urllist custom\/blocked\/urls \n " ;
3030 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
3032 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
3034 print FILE
" logfile $ident custom.log \n " ;
3036 print FILE
" logfile $ident urlfilter.log \n " ;
3041 print FILE
"dest custom-expressions { \n " ;
3042 print FILE
" expressionlist custom\/blocked\/expressions \n " ;
3043 if ( $filtersettings { 'ENABLE_LOG' } eq 'on' )
3045 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
3047 print FILE
" logfile $ident custom.log \n " ;
3049 print FILE
" logfile $ident urlfilter.log \n " ;
3054 print FILE
"acl { \n " ;
3055 if (!( $filtersettings { 'UNFILTERED_CLIENTS' } eq '' )) {
3056 print FILE
" unfiltered { \n " ;
3057 print FILE
" pass all \n " ;
3058 if ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' )
3060 print FILE
" rewrite rew-rule-2 \n " ;
3062 print FILE
" } \n\n " ;
3064 if (!( $filtersettings { 'BANNED_CLIENTS' } eq '' )) {
3065 print FILE
" banned { \n " ;
3066 print FILE
" pass " ;
3067 if (( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'on' ))
3069 print FILE
"custom-allowed " ;
3071 print FILE
"none \n " ;
3072 print FILE
" } \n\n " ;
3089 $qredirect = $redirect ;
3090 $qredirect =~ s/\%t/\%q\%20-\%20\%i/ ;
3091 print FILE
" quota- $idx { \n " ;
3092 print FILE
" pass " ;
3093 if (( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'on' ))
3095 print FILE
"custom-allowed " ;
3097 print FILE
"none \n " ;
3098 unless ( $redirect eq $qredirect ) { print FILE
" redirect $qredirect \n " ; }
3099 print FILE
" } \n\n " ;
3111 @ec = split ( /\|/ , $tc [ 13 ]);
3112 foreach ( @ec ) { s/\// _
/ g
; }
3113 if ( $tc [ 15 ] eq 'on' )
3116 print FILE
" network- $idx $tc [0] constraint- $idx { \n " ;
3117 print FILE
" pass " ;
3119 if ( $filtersettings { 'BLOCK_ALL' } eq 'on' )
3121 if ( $tc [ 14 ] eq 'block' )
3123 if (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' )) {
3124 if (( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'on' ))
3126 print FILE
"custom-allowed " ;
3130 print FILE
$defaultrule ;
3137 print FILE
$defaultrule unless (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ));
3140 if ( $tc [ 14 ] eq 'block' )
3142 $tcrule = $defaultrule ;
3143 if ( $filtersettings { 'ENABLE_CUSTOM_WHITELIST' } eq 'on' ) {
3144 $tcrule =~ s/custom-allowed // ;
3145 print FILE
"custom-allowed " unless (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ) && ( $filtersettings { 'ENABLE_GLOBAL_WHITELIST' } eq 'off' ));
3147 if (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' )) {
3152 print FILE
"! $_ " unless ( index ( $defaultrule , "!" . $_ . " " ) ge 0 );
3155 print FILE
$tcrule unless (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ));
3157 $tcrule = $defaultrule ;
3158 if (( @ec == 1 ) && ( $ec [ 0 ] eq 'any' ))
3164 $tcrule = " $_ " . $tcrule unless ( index ( $defaultrule , "!" . $_ . " " ) ge 0 );
3165 $tcrule =~ s/!$_ // ;
3174 print FILE
" } \n\n " ;
3179 print FILE
" default { \n " ;
3180 print FILE
" pass $defaultrule \n " ;
3181 if (( $filtersettings { 'ENABLE_LOG' } eq 'on' ) && ( $filtersettings { 'BLOCK_ALL' } eq 'on' ))
3183 if ( $filtersettings { 'ENABLE_CATEGORY_LOG' } eq 'on' )
3185 print FILE
" logfile" . $ident . " default.log \n " ;
3187 print FILE
" logfile" . $ident . " urlfilter.log \n " ;
3190 if ((( $filtersettings { 'ENABLE_REWRITE' } eq 'on' ) && ( @repositoryfiles )) || ( $filtersettings { 'ENABLE_SAFESEARCH' } eq 'on' ))
3192 print FILE
" rewrite rew-rule-1 \n " ;
3194 print FILE
" redirect $redirect \n " ;
3201 # -------------------------------------------------------------------