]>
Commit | Line | Data |
---|---|---|
10e4f239 | 1 | #!/usr/bin/perl |
70df8302 MT |
2 | ############################################################################### |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
5 | # Copyright (C) 2007 Michael Tremer & Christian Schmidt # | |
6 | # # | |
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. # | |
11 | # # | |
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. # | |
16 | # # | |
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/>. # | |
19 | # # | |
20 | ############################################################################### | |
10e4f239 MT |
21 | |
22 | use strict; | |
23 | ||
24 | # enable only the following on debugging purpose | |
cb5e9c6c CS |
25 | #use warnings; |
26 | #use CGI::Carp 'fatalsToBrowser'; | |
10e4f239 MT |
27 | |
28 | use File::Copy; | |
29 | use IO::Socket; | |
30 | ||
31 | require '/var/ipfire/general-functions.pl'; | |
32 | require "${General::swroot}/lang.pl"; | |
33 | require "${General::swroot}/header.pl"; | |
34 | ||
1465b127 | 35 | my $http_port='81'; |
10e4f239 MT |
36 | my %netsettings=(); |
37 | my %mainsettings=(); | |
38 | my %proxysettings=(); | |
39 | my %filtersettings=(); | |
10e4f239 MT |
40 | my %tcsettings=(); |
41 | my %uqsettings=(); | |
42 | my %besettings=(); | |
43 | my %updatesettings=(); | |
44 | my %checked=(); | |
45 | my %selected=(); | |
46 | my $id=0; | |
47 | my $line=''; | |
48 | my $i=0; | |
49 | my $n=0; | |
50 | my $time=''; | |
51 | my $filesize; | |
52 | my $category=''; | |
53 | my $section=''; | |
54 | my $blacklist=''; | |
55 | my $blistbackup=''; | |
56 | ||
57 | my $changed = 'no'; | |
58 | my $tcfile = "${General::swroot}/urlfilter/timeconst"; | |
59 | my $uqfile = "${General::swroot}/urlfilter/userquota"; | |
60 | my $dbdir = "${General::swroot}/urlfilter/blacklists"; | |
61 | my $editdir = "${General::swroot}/urlfilter/editor"; | |
62 | my $repository = "/home/httpd/html/repository"; | |
63 | my $hintcolour = '#FFFFCC'; | |
64 | ||
65 | my $sourceurlfile = "${General::swroot}/urlfilter/autoupdate/autoupdate.urls"; | |
66 | my $updconffile = "${General::swroot}/urlfilter/autoupdate/autoupdate.conf"; | |
67 | my $updflagfile = "${General::swroot}/urlfilter/blacklists/.autoupdate.last"; | |
68 | my $upd_cron_dly = "${General::swroot}/urlfilter/autoupdate/cron.daily"; | |
69 | my $upd_cron_wly = "${General::swroot}/urlfilter/autoupdate/cron.weekly"; | |
70 | my $upd_cron_mly = "${General::swroot}/urlfilter/autoupdate/cron.monthly"; | |
71 | ||
72 | my $errormessage=''; | |
73 | my $updatemessage=''; | |
74 | my $restoremessage=''; | |
75 | my $buttontext=''; | |
76 | my $source_name=''; | |
77 | my $source_url=''; | |
78 | my $blacklistage=0; | |
79 | ||
80 | my @repositorylist=(); | |
81 | my @repositoryfiles=(); | |
82 | my @categories=(); | |
83 | my @selectedcategories=(); | |
84 | my @filtergroups=(); | |
85 | my @tclist=(); | |
86 | my @uqlist=(); | |
87 | my @source_urllist=(); | |
1465b127 | 88 | my @clients=(); |
10e4f239 MT |
89 | my @temp=(); |
90 | ||
91 | my $lastslashpos=0; | |
92 | ||
93 | my $toggle=''; | |
94 | my $gif=''; | |
95 | my $led=''; | |
96 | my $ldesc=''; | |
97 | my $gdesc=''; | |
98 | ||
99 | if (! -d $dbdir) { mkdir("$dbdir"); } | |
100 | if (! -e $tcfile) { system("touch $tcfile"); } | |
101 | if (! -e $uqfile) { system("touch $uqfile"); } | |
102 | if (! -e $sourceurlfile) { system("touch $sourceurlfile"); } | |
103 | ||
104 | &General::readhash("${General::swroot}/ethernet/settings", \%netsettings); | |
105 | &General::readhash("${General::swroot}/main/settings", \%mainsettings); | |
106 | &General::readhash("${General::swroot}/proxy/settings", \%proxysettings); | |
107 | ||
108 | &readblockcategories; | |
109 | ||
110 | open(FILE, $tcfile); | |
111 | @tclist = <FILE>; | |
112 | close(FILE); | |
113 | open(FILE, $uqfile); | |
114 | @uqlist = <FILE>; | |
115 | close(FILE); | |
116 | open(FILE, $sourceurlfile); | |
117 | @source_urllist = <FILE>; | |
118 | close(FILE); | |
119 | ||
120 | $filtersettings{'ENABLE_CUSTOM_BLACKLIST'} = 'off'; | |
121 | $filtersettings{'ENABLE_CUSTOM_WHITELIST'} = 'off'; | |
122 | $filtersettings{'ENABLE_CUSTOM_EXPRESSIONS'} = 'off'; | |
123 | $filtersettings{'BLOCK_EXECUTABLES'} = 'off'; | |
124 | $filtersettings{'BLOCK_AUDIO-VIDEO'} = 'off'; | |
125 | $filtersettings{'BLOCK_ARCHIVES'} = 'off'; | |
126 | $filtersettings{'ENABLE_REWRITE'} = 'off'; | |
127 | $filtersettings{'UNFILTERED_CLIENTS'} = ''; | |
128 | $filtersettings{'BANNED_CLIENTS'} = ''; | |
129 | $filtersettings{'SHOW_CATEGORY'} = 'off'; | |
130 | $filtersettings{'SHOW_URL'} = 'off'; | |
131 | $filtersettings{'SHOW_IP'} = 'off'; | |
132 | $filtersettings{'ENABLE_DNSERROR'} = 'off'; | |
133 | $filtersettings{'ENABLE_JPEG'} = 'off'; | |
134 | $filtersettings{'REDIRECT_PAGE'} = ''; | |
135 | $filtersettings{'MSG_TEXT_1'} = ''; | |
136 | $filtersettings{'MSG_TEXT_2'} = ''; | |
137 | $filtersettings{'MSG_TEXT_3'} = ''; | |
138 | $filtersettings{'ENABLE_EXPR_LISTS'} = 'off'; | |
139 | $filtersettings{'BLOCK_IP_ADDR'} = 'off'; | |
140 | $filtersettings{'BLOCK_ALL'} = 'off'; | |
141 | $filtersettings{'ENABLE_EMPTY_ADS'} = 'off'; | |
142 | $filtersettings{'ENABLE_GLOBAL_WHITELIST'} = 'off'; | |
143 | $filtersettings{'ENABLE_SAFESEARCH'} = 'off'; | |
144 | $filtersettings{'ENABLE_LOG'} = 'off'; | |
145 | $filtersettings{'ENABLE_USERNAME_LOG'} = 'off'; | |
146 | $filtersettings{'ENABLE_CATEGORY_LOG'} = 'off'; | |
147 | $filtersettings{'CHILDREN'} = '5'; | |
148 | $filtersettings{'ENABLE_AUTOUPDATE'} = 'off'; | |
149 | ||
150 | $filtersettings{'ACTION'} = ''; | |
151 | $filtersettings{'VALID'} = ''; | |
152 | ||
153 | &Header::getcgihash(\%filtersettings); | |
154 | &Header::getcgihash(\%tcsettings); | |
155 | &Header::getcgihash(\%uqsettings); | |
156 | &Header::getcgihash(\%besettings); | |
157 | ||
158 | if (($filtersettings{'ACTION'} eq $Lang::tr{'save'}) || | |
159 | ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter save and restart'}) || | |
160 | ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter upload file'}) || | |
161 | ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter remove file'}) || | |
10e4f239 MT |
162 | ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter upload blacklist'}) || |
163 | ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter backup'}) || | |
164 | ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter restore'})) | |
1465b127 MT |
165 | { |
166 | ||
167 | @clients = split(/\n/,$filtersettings{'UNFILTERED_CLIENTS'}); | |
168 | foreach (@clients) | |
169 | { | |
170 | s/^\s+//g; s/\s+$//g; s/\s+-\s+/-/g; s/\s+/ /g; s/\n//g; | |
171 | if (/.*-.*-.*/) { $errormessage = $Lang::tr{'urlfilter invalid ip or mask error'}; } | |
172 | @temp = split(/-/); | |
173 | foreach (@temp) { unless ((&General::validipormask($_)) || (&General::validipandmask($_))) { $errormessage = $Lang::tr{'urlfilter invalid ip or mask error'}; } } | |
174 | } | |
175 | @clients = split(/\n/,$filtersettings{'BANNED_CLIENTS'}); | |
176 | foreach (@clients) | |
177 | { | |
178 | s/^\s+//g; s/\s+$//g; s/\s+-\s+/-/g; s/\s+/ /g; s/\n//g; | |
179 | if (/.*-.*-.*/) { $errormessage = $Lang::tr{'urlfilter invalid ip or mask error'}; } | |
180 | @temp = split(/-/); | |
181 | foreach (@temp) { unless ((&General::validipormask($_)) || (&General::validipandmask($_))) { $errormessage = $Lang::tr{'urlfilter invalid ip or mask error'}; } } | |
182 | } | |
183 | if ($errormessage) { goto ERROR; } | |
184 | ||
10e4f239 MT |
185 | if (!($filtersettings{'CHILDREN'} =~ /^\d+$/) || ($filtersettings{'CHILDREN'} < 1)) |
186 | { | |
187 | $errormessage = $Lang::tr{'urlfilter invalid num of children'}; | |
188 | goto ERROR; | |
189 | } | |
190 | ||
191 | if ((!($filtersettings{'REDIRECT_PAGE'} eq '')) && (!($filtersettings{'REDIRECT_PAGE'} =~ /^https?:\/\//))) | |
192 | { | |
193 | $filtersettings{'REDIRECT_PAGE'} = "http://".$filtersettings{'REDIRECT_PAGE'}; | |
194 | } | |
195 | ||
196 | if ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter remove file'}) | |
197 | { | |
198 | if (-e "$repository/$filtersettings{'ID'}") { unlink("$repository/$filtersettings{'ID'}"); } | |
199 | $filtersettings{'ACTION'} = $Lang::tr{'urlfilter manage repository'}; | |
200 | } | |
201 | ||
202 | if ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter upload file'}) | |
203 | { | |
204 | &Header::getcgihash(\%filtersettings, {'wantfile' => 1, 'filevar' => 'UPLOADFILE'}); | |
205 | ||
206 | $filtersettings{'ACTION'} = $Lang::tr{'urlfilter manage repository'}; | |
207 | $_ = $filtersettings{'UPLOADFILE'}; | |
208 | tr/\\/\//; | |
209 | $_ = substr($_,rindex($_,"/")+1); | |
210 | if ($_) { | |
211 | if (copy($filtersettings{'UPLOADFILE'}, "$repository/$_") != 1) | |
212 | { | |
213 | $errormessage = $!; | |
214 | goto ERROR; | |
215 | } | |
216 | } | |
217 | ||
218 | } | |
1465b127 | 219 | |
10e4f239 MT |
220 | if ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter upload blacklist'}) |
221 | { | |
222 | &Header::getcgihash(\%filtersettings, {'wantfile' => 1, 'filevar' => 'UPDATEFILE'}); | |
223 | ||
224 | if (!($filtersettings{'UPDATEFILE'} =~ /.tar.gz$/)) | |
225 | { | |
226 | $errormessage = $Lang::tr{'urlfilter wrong filetype'}; | |
227 | goto ERROR; | |
228 | } | |
229 | ||
230 | if (copy($filtersettings{'UPDATEFILE'}, "${General::swroot}/urlfilter/blacklists.tar.gz") != 1) | |
231 | { | |
232 | $errormessage = $!; | |
233 | goto ERROR; | |
234 | } | |
d47ad587 | 235 | |
10e4f239 MT |
236 | if (!(-d "${General::swroot}/urlfilter/update")) { mkdir("${General::swroot}/urlfilter/update"); } |
237 | ||
238 | my $exitcode = system("/bin/tar --no-same-owner -xzf ${General::swroot}/urlfilter/blacklists.tar.gz -C ${General::swroot}/urlfilter/update"); | |
d47ad587 | 239 | |
10e4f239 MT |
240 | if ($exitcode > 0) |
241 | { | |
242 | $errormessage = $Lang::tr{'urlfilter tar error'}; | |
243 | } else { | |
244 | ||
1465b127 MT |
245 | if (-d "${General::swroot}/urlfilter/update/BL") |
246 | { | |
247 | system("mv ${General::swroot}/urlfilter/update/BL ${General::swroot}/urlfilter/update/blacklists"); | |
248 | } | |
249 | ||
10e4f239 MT |
250 | if (-d "${General::swroot}/urlfilter/update/category") |
251 | { | |
252 | system("mv ${General::swroot}/urlfilter/update/category ${General::swroot}/urlfilter/update/blacklists"); | |
253 | } | |
254 | ||
255 | if (!(-d "${General::swroot}/urlfilter/update/blacklists")) | |
256 | { | |
257 | $errormessage = $Lang::tr{'urlfilter invalid content'}; | |
258 | } else { | |
259 | system("cp -r ${General::swroot}/urlfilter/update/blacklists/* $dbdir"); | |
260 | ||
261 | &readblockcategories; | |
262 | &readcustomlists; | |
263 | ||
264 | &writeconfigfile; | |
265 | ||
266 | $updatemessage = $Lang::tr{'urlfilter upload success'}; | |
267 | system("${General::swroot}/urlfilter/bin/prebuild.pl &"); | |
268 | system("logger -t installpackage[urlfilter] \"URL filter blacklist - Blacklist update from local source completed\""); | |
269 | } | |
270 | } | |
271 | if (-d "${General::swroot}/urlfilter/update") { system("rm -rf ${General::swroot}/urlfilter/update"); } | |
272 | if (-e "${General::swroot}/urlfilter/blacklists.tar.gz") { unlink("${General::swroot}/urlfilter/blacklists.tar.gz"); } | |
273 | if ($errormessage) { goto ERROR; } | |
274 | } | |
275 | ||
276 | if ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter backup'}) | |
277 | { | |
278 | $blistbackup = ($filtersettings{'ENABLE_FULLBACKUP'} eq 'on') ? "blacklists" : "blacklists/custom"; | |
279 | if (system("/bin/tar -C ${General::swroot}/urlfilter -czf ${General::swroot}/urlfilter/backup.tar.gz settings timeconst userquota autoupdate $blistbackup")) | |
280 | { | |
281 | $errormessage = $Lang::tr{'urlfilter backup error'}; | |
282 | goto ERROR; | |
283 | } | |
284 | else | |
285 | { | |
286 | print "Content-type: application/gzip\n"; | |
287 | print "Content-length: "; | |
288 | print (-s "${General::swroot}/urlfilter/backup.tar.gz"); | |
289 | print "\n"; | |
290 | print "Content-disposition: attachment; filename=urlfilter-backup.tar.gz\n\n"; | |
291 | ||
292 | open (FILE, "${General::swroot}/urlfilter/backup.tar.gz"); | |
293 | while (<FILE>) { print; } | |
294 | close (FILE); | |
295 | ||
296 | if (-e "${General::swroot}/urlfilter/backup.tar.gz") { unlink("${General::swroot}/urlfilter/backup.tar.gz"); } | |
297 | exit; | |
298 | } | |
299 | } | |
300 | ||
301 | if ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter restore'}) | |
302 | { | |
303 | &Header::getcgihash(\%filtersettings, {'wantfile' => 1, 'filevar' => 'UPDATEFILE'}); | |
304 | ||
305 | if (!($filtersettings{'UPDATEFILE'} =~ /.tar.gz$/)) | |
306 | { | |
307 | $errormessage = $Lang::tr{'urlfilter wrong filetype'}; | |
308 | goto ERROR; | |
309 | } | |
310 | ||
311 | if (!(-d "${General::swroot}/urlfilter/restore")) { mkdir("${General::swroot}/urlfilter/restore"); } | |
312 | ||
313 | if (copy($filtersettings{'UPDATEFILE'}, "${General::swroot}/urlfilter/backup.tar.gz") != 1) | |
314 | { | |
315 | $errormessage = $!; | |
316 | } | |
d47ad587 | 317 | |
10e4f239 MT |
318 | my $exitcode = system("/bin/tar --no-same-owner --preserve-permissions -xzf ${General::swroot}/urlfilter/backup.tar.gz -C ${General::swroot}/urlfilter/restore"); |
319 | if ($exitcode > 0) | |
320 | { | |
321 | $errormessage = $Lang::tr{'urlfilter tar error'}; | |
322 | } else { | |
323 | if (!(-e "${General::swroot}/urlfilter/restore/settings")) | |
324 | { | |
325 | $errormessage = $Lang::tr{'urlfilter invalid restore file'}; | |
326 | } else { | |
327 | system("cp -rp ${General::swroot}/urlfilter/restore/* ${General::swroot}/urlfilter/"); | |
328 | &readblockcategories; | |
329 | &readcustomlists; | |
330 | &writeconfigfile; | |
331 | ||
332 | $restoremessage = $Lang::tr{'urlfilter restore success'}; | |
333 | } | |
334 | } | |
335 | ||
336 | if (-e "${General::swroot}/urlfilter/backup.tar.gz") { unlink("${General::swroot}/urlfilter/backup.tar.gz"); } | |
337 | if (-d "${General::swroot}/urlfilter/restore") { system("rm -rf ${General::swroot}/urlfilter/restore"); } | |
338 | if ($errormessage) { goto ERROR; } | |
339 | } | |
340 | ||
341 | if ($filtersettings{'ACTION'} eq $Lang::tr{'save'}) | |
342 | { | |
343 | $filtersettings{'VALID'} = 'yes'; | |
344 | &savesettings; | |
345 | } | |
346 | ||
347 | if ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter save and restart'}) | |
348 | { | |
1465b127 | 349 | if ((!(-e "${General::swroot}/proxy/enable")) && (!(-e "${General::swroot}/proxy/enable_blue"))) |
10e4f239 MT |
350 | { |
351 | $errormessage = $Lang::tr{'urlfilter web proxy service required'}; | |
352 | goto ERROR; | |
353 | } | |
354 | if (!($proxysettings{'ENABLE_FILTER'} eq 'on')) | |
355 | { | |
356 | $errormessage = $Lang::tr{'urlfilter not enabled'}; | |
357 | goto ERROR; | |
358 | } | |
359 | ||
360 | $filtersettings{'VALID'} = 'yes'; | |
361 | &savesettings; | |
362 | ||
363 | system("chown -R nobody.nobody $dbdir"); | |
364 | ||
365 | if (-e "$dbdir/custom/allowed/domains.db") { unlink("$dbdir/custom/allowed/domains.db"); } | |
366 | if (-e "$dbdir/custom/allowed/urls.db") { unlink("$dbdir/custom/allowed/urls.db"); } | |
367 | if (-e "$dbdir/custom/blocked/domains.db") { unlink("$dbdir/custom/blocked/domains.db"); } | |
368 | if (-e "$dbdir/custom/blocked/urls.db") { unlink("$dbdir/custom/blocked/urls.db"); } | |
369 | ||
1465b127 | 370 | &setpermissions ($dbdir); |
10e4f239 | 371 | |
7d3af7f7 | 372 | system('/usr/local/bin/squidctrl restart >/dev/null 2>&1'); |
10e4f239 | 373 | } |
10e4f239 MT |
374 | } |
375 | ||
376 | if ($tcsettings{'ACTION'} eq $Lang::tr{'urlfilter set time constraints'}) { $tcsettings{'TCMODE'} = 'on'} | |
377 | ||
378 | if (($tcsettings{'MODE'} eq 'TIMECONSTRAINT') && ($tcsettings{'ACTION'} eq $Lang::tr{'add'})) | |
379 | { | |
380 | $tcsettings{'TCMODE'}='on'; | |
381 | ||
382 | if (!$tcsettings{'DST'}) | |
383 | { | |
384 | $errormessage=$Lang::tr{'urlfilter dst error'}; | |
385 | } | |
386 | ||
387 | if (!$tcsettings{'SRC'}) | |
388 | { | |
389 | $errormessage=$Lang::tr{'urlfilter src error'}; | |
390 | } | |
391 | ||
392 | if (!($tcsettings{'TO_HOUR'}.$tcsettings{'TO_MINUTE'} gt $tcsettings{'FROM_HOUR'}.$tcsettings{'FROM_MINUTE'})) | |
393 | { | |
394 | $errormessage=$Lang::tr{'urlfilter timespace error'}; | |
395 | } | |
396 | ||
397 | 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'))) | |
398 | { | |
399 | $errormessage=$Lang::tr{'urlfilter weekday error'}; | |
400 | } | |
401 | ||
402 | if (!$errormessage) | |
403 | { | |
1465b127 MT |
404 | # transform to pre1.8 client definitions |
405 | @clients = split(/\n/,$tcsettings{'SRC'}); | |
406 | undef $tcsettings{'SRC'}; | |
407 | foreach(@clients) | |
408 | { | |
409 | s/^\s+//g; s/\s+$//g; s/\s+-\s+/-/g; s/\s+/ /g; s/\n//g; | |
410 | $tcsettings{'SRC'} .= "$_ "; | |
411 | } | |
412 | $tcsettings{'SRC'} =~ s/\s+$//; | |
413 | ||
10e4f239 MT |
414 | if ($tcsettings{'DST'} =~ /^any/) { $tcsettings{'DST'} = 'any'; } |
415 | if ($tcsettings{'ENABLERULE'} eq 'on') { $tcsettings{'ACTIVE'} = $tcsettings{'ENABLERULE'}; } else { $tcsettings{'ACTIVE'} = 'off'} | |
416 | ||
417 | $tcsettings{'ENABLERULE'} = 'on'; | |
418 | if($tcsettings{'EDITING'} eq 'no') { | |
419 | open(FILE,">>$tcfile"); | |
420 | flock FILE, 2; | |
421 | 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"; | |
422 | } else { | |
423 | open(FILE, ">$tcfile"); | |
424 | flock FILE, 2; | |
425 | $id = 0; | |
426 | foreach $line (@tclist) | |
427 | { | |
428 | $id++; | |
429 | if ($tcsettings{'EDITING'} eq $id) { | |
430 | 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"; | |
431 | } else { print FILE "$line"; } | |
432 | } | |
433 | } | |
434 | close(FILE); | |
435 | undef %tcsettings; | |
436 | $tcsettings{'CHANGED'}='yes'; | |
437 | $tcsettings{'TCMODE'}='on'; | |
438 | $changed = 'yes'; | |
439 | } else { | |
440 | if ($tcsettings{'EDITING'} ne 'no') | |
441 | { | |
442 | $tcsettings{'ACTION'} = $Lang::tr{'edit'}; | |
443 | $tcsettings{'ID'} = $tcsettings{'EDITING'}; | |
444 | } | |
445 | } | |
446 | } | |
447 | ||
1465b127 MT |
448 | if (($tcsettings{'MODE'} eq 'TIMECONSTRAINT') && ($tcsettings{'ACTION'} eq $Lang::tr{'urlfilter copy rule'}) && (!$errormessage)) |
449 | { | |
450 | $id = 0; | |
451 | foreach $line (@tclist) | |
452 | { | |
453 | $id++; | |
454 | if ($tcsettings{'ID'} eq $id) | |
455 | { | |
456 | chomp($line); | |
457 | @temp = split(/\,/,$line); | |
458 | $tcsettings{'DEFINITION'} = $temp[0]; | |
459 | $tcsettings{'MON'} = $temp[1]; | |
460 | $tcsettings{'TUE'} = $temp[2]; | |
461 | $tcsettings{'WED'} = $temp[3]; | |
462 | $tcsettings{'THU'} = $temp[4]; | |
463 | $tcsettings{'FRI'} = $temp[5]; | |
464 | $tcsettings{'SAT'} = $temp[6]; | |
465 | $tcsettings{'SUN'} = $temp[7]; | |
466 | $tcsettings{'FROM_HOUR'} = $temp[8]; | |
467 | $tcsettings{'FROM_MINUTE'} = $temp[9]; | |
468 | $tcsettings{'TO_HOUR'} = $temp[10]; | |
469 | $tcsettings{'TO_MINUTE'} = $temp[11]; | |
470 | $tcsettings{'SRC'} = $temp[12]; | |
471 | $tcsettings{'DST'} = $temp[13]; | |
472 | $tcsettings{'ACCESS'} = $temp[14]; | |
473 | $tcsettings{'ENABLERULE'} = $temp[15]; | |
474 | $tcsettings{'COMMENT'} = $temp[16]; | |
475 | } | |
476 | } | |
477 | $tcsettings{'TCMODE'}='on'; | |
478 | } | |
479 | ||
10e4f239 MT |
480 | if (($tcsettings{'MODE'} eq 'TIMECONSTRAINT') && ($tcsettings{'ACTION'} eq $Lang::tr{'remove'})) |
481 | { | |
482 | $id = 0; | |
483 | open(FILE, ">$tcfile"); | |
484 | flock FILE, 2; | |
485 | foreach $line (@tclist) | |
486 | { | |
487 | $id++; | |
488 | unless ($tcsettings{'ID'} eq $id) { print FILE "$line"; } | |
489 | } | |
490 | close(FILE); | |
491 | $tcsettings{'CHANGED'}='yes'; | |
492 | $tcsettings{'TCMODE'}='on'; | |
493 | } | |
494 | ||
495 | if (($tcsettings{'MODE'} eq 'TIMECONSTRAINT') && ($tcsettings{'ACTION'} eq $Lang::tr{'urlfilter restart'})) | |
496 | { | |
497 | if (!($proxysettings{'ENABLE_FILTER'} eq 'on')) | |
498 | { | |
499 | $errormessage = $Lang::tr{'urlfilter not enabled'}; | |
500 | } | |
1465b127 | 501 | if ((!(-e "${General::swroot}/proxy/enable")) && (!(-e "${General::swroot}/proxy/enable_blue"))) |
10e4f239 MT |
502 | { |
503 | $errormessage = $Lang::tr{'urlfilter web proxy service required'}; | |
504 | } | |
505 | ||
7d3af7f7 | 506 | if (!$errormessage) { system('/usr/local/bin/squidctrl restart >/dev/null 2>&1'); } |
10e4f239 MT |
507 | $tcsettings{'TCMODE'}='on'; |
508 | } | |
509 | ||
510 | if (($tcsettings{'MODE'} eq 'TIMECONSTRAINT') && ($tcsettings{'ACTION'} eq $Lang::tr{'toggle enable disable'})) | |
511 | { | |
512 | open(FILE, ">$tcfile"); | |
513 | flock FILE, 2; | |
514 | $id = 0; | |
515 | foreach $line (@tclist) | |
516 | { | |
517 | $id++; | |
518 | unless ($tcsettings{'ID'} eq $id) { print FILE "$line"; } | |
519 | else | |
520 | { | |
521 | chomp($line); | |
522 | @temp = split(/\,/,$line); | |
523 | if ($temp[15] eq 'on') { $temp[15] = 'off'; } else { $temp[15] = 'on' } | |
524 | 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"; | |
525 | } | |
526 | } | |
527 | close(FILE); | |
528 | $tcsettings{'CHANGED'}='yes'; | |
529 | $tcsettings{'TCMODE'}='on'; | |
530 | } | |
531 | ||
10e4f239 MT |
532 | if (($tcsettings{'MODE'} eq 'TIMECONSTRAINT') && ($tcsettings{'ACTION'} eq $Lang::tr{'edit'}) && (!$errormessage)) |
533 | { | |
534 | $id = 0; | |
535 | foreach $line (@tclist) | |
536 | { | |
537 | $id++; | |
538 | if ($tcsettings{'ID'} eq $id) | |
539 | { | |
540 | chomp($line); | |
541 | @temp = split(/\,/,$line); | |
542 | $tcsettings{'DEFINITION'} = $temp[0]; | |
543 | $tcsettings{'MON'} = $temp[1]; | |
544 | $tcsettings{'TUE'} = $temp[2]; | |
545 | $tcsettings{'WED'} = $temp[3]; | |
546 | $tcsettings{'THU'} = $temp[4]; | |
547 | $tcsettings{'FRI'} = $temp[5]; | |
548 | $tcsettings{'SAT'} = $temp[6]; | |
549 | $tcsettings{'SUN'} = $temp[7]; | |
550 | $tcsettings{'FROM_HOUR'} = $temp[8]; | |
551 | $tcsettings{'FROM_MINUTE'} = $temp[9]; | |
552 | $tcsettings{'TO_HOUR'} = $temp[10]; | |
553 | $tcsettings{'TO_MINUTE'} = $temp[11]; | |
554 | $tcsettings{'SRC'} = $temp[12]; | |
555 | $tcsettings{'DST'} = $temp[13]; | |
556 | $tcsettings{'ACCESS'} = $temp[14]; | |
557 | $tcsettings{'ENABLERULE'} = $temp[15]; | |
558 | $tcsettings{'COMMENT'} = $temp[16]; | |
559 | } | |
560 | } | |
561 | $tcsettings{'TCMODE'}='on'; | |
562 | } | |
563 | ||
1465b127 MT |
564 | if ((!$errormessage) && (!($tcsettings{'ACTION'} eq $Lang::tr{'urlfilter copy rule'})) && (!($tcsettings{'ACTION'} eq $Lang::tr{'edit'}))) { |
565 | $tcsettings{'ENABLERULE'}='on'; | |
566 | $tcsettings{'TO_HOUR'}='24'; | |
567 | } | |
568 | ||
10e4f239 MT |
569 | if ($uqsettings{'ACTION'} eq $Lang::tr{'urlfilter set user quota'}) { $uqsettings{'UQMODE'} = 'on'} |
570 | ||
571 | if (($uqsettings{'MODE'} eq 'USERQUOTA') && ($uqsettings{'ACTION'} eq $Lang::tr{'add'})) | |
572 | { | |
573 | $uqsettings{'UQMODE'}='on'; | |
574 | ||
575 | if ((!($uqsettings{'TIME_QUOTA'} =~ /^\d+/)) || ($uqsettings{'TIME_QUOTA'} < '1')) | |
576 | { | |
577 | $errormessage=$Lang::tr{'urlfilter quota time error'}; | |
578 | } | |
579 | ||
580 | @temp = split(/\n/,$uqsettings{'QUOTA_USERS'}); | |
581 | undef $uqsettings{'QUOTA_USERS'}; | |
582 | foreach (@temp) | |
583 | { | |
584 | s/^\s+//g; s/\s+$//g; | |
585 | if ($_) { $uqsettings{'QUOTA_USERS'} .= $_."\n"; } | |
586 | } | |
587 | ||
588 | if ($uqsettings{'QUOTA_USERS'} eq '') | |
589 | { | |
590 | $errormessage=$Lang::tr{'urlfilter quota user error'}; | |
591 | } | |
592 | ||
593 | $_ = $uqsettings{'QUOTA_USERS'}; | |
594 | chomp; s/\n/|/g; | |
595 | my $quota_users = $_; | |
596 | ||
597 | if ($uqsettings{'QUOTA_USERS'} =~ /\\/) | |
598 | { | |
599 | $errormessage=$Lang::tr{'urlfilter invalid user error'}; | |
600 | } | |
601 | ||
602 | if (!$errormessage) { | |
603 | if ($uqsettings{'ENABLEQUOTA'} eq 'on') { $uqsettings{'ACTIVE'} = $uqsettings{'ENABLEQUOTA'}; } else { $uqsettings{'ACTIVE'} = 'off'} | |
604 | ||
605 | $uqsettings{'ENABLERULE'} = 'on'; | |
606 | if($uqsettings{'EDITING'} eq 'no') { | |
607 | open(FILE,">>$uqfile"); | |
608 | flock FILE, 2; | |
609 | print FILE "$uqsettings{'TIME_QUOTA'},$uqsettings{'SPORADIC'},$uqsettings{'RENEWAL'},$quota_users,$uqsettings{'ACTIVE'}\n"; | |
610 | } else { | |
611 | open(FILE, ">$uqfile"); | |
612 | flock FILE, 2; | |
613 | $id = 0; | |
614 | foreach $line (@uqlist) | |
615 | { | |
616 | $id++; | |
617 | if ($uqsettings{'EDITING'} eq $id) { | |
618 | print FILE "$uqsettings{'TIME_QUOTA'},$uqsettings{'SPORADIC'},$uqsettings{'RENEWAL'},$quota_users,$uqsettings{'ACTIVE'}\n"; | |
619 | } else { print FILE "$line"; } | |
620 | } | |
621 | } | |
622 | close(FILE); | |
623 | undef %uqsettings; | |
624 | $uqsettings{'CHANGED'}='yes'; | |
625 | $uqsettings{'MODE'}='USERQUOTA'; | |
626 | $uqsettings{'UQMODE'}='on'; | |
627 | $changed = 'yes'; | |
628 | } else { | |
629 | if ($uqsettings{'EDITING'} ne 'no') | |
630 | { | |
631 | $uqsettings{'ACTION'} = $Lang::tr{'edit'}; | |
632 | $uqsettings{'ID'} = $uqsettings{'EDITING'}; | |
633 | } | |
634 | } | |
635 | } | |
636 | ||
637 | if (($uqsettings{'MODE'} eq 'USERQUOTA') && ($uqsettings{'ACTION'} eq $Lang::tr{'remove'})) | |
638 | { | |
639 | $id = 0; | |
640 | open(FILE, ">$uqfile"); | |
641 | flock FILE, 2; | |
642 | foreach $line (@uqlist) | |
643 | { | |
644 | $id++; | |
645 | unless ($uqsettings{'ID'} eq $id) { print FILE "$line"; } | |
646 | } | |
647 | close(FILE); | |
648 | $uqsettings{'CHANGED'}='yes'; | |
649 | $uqsettings{'UQMODE'}='on'; | |
650 | } | |
651 | ||
652 | if (!$errormessage) { | |
653 | $uqsettings{'ENABLEQUOTA'}='on'; | |
654 | } | |
655 | ||
656 | if (($uqsettings{'MODE'} eq 'USERQUOTA') && ($uqsettings{'ACTION'} eq $Lang::tr{'edit'}) && (!$errormessage)) | |
657 | { | |
658 | $id = 0; | |
659 | foreach $line (@uqlist) | |
660 | { | |
661 | $id++; | |
662 | if ($uqsettings{'ID'} eq $id) | |
663 | { | |
664 | chomp($line); | |
665 | @temp = split(/\,/,$line); | |
666 | $uqsettings{'TIME_QUOTA'} = $temp[0]; | |
667 | $uqsettings{'SPORADIC'} = $temp[1]; | |
668 | $uqsettings{'RENEWAL'} = $temp[2]; | |
669 | $uqsettings{'QUOTA_USERS'} = $temp[3]; | |
670 | $uqsettings{'ENABLEQUOTA'} = $temp[4]; | |
671 | } | |
672 | } | |
673 | $uqsettings{'UQMODE'}='on'; | |
674 | } | |
675 | ||
676 | if (($uqsettings{'MODE'} eq 'USERQUOTA') && ($uqsettings{'ACTION'} eq $Lang::tr{'toggle enable disable'})) | |
677 | { | |
678 | open(FILE, ">$uqfile"); | |
679 | flock FILE, 2; | |
680 | $id = 0; | |
681 | foreach $line (@uqlist) | |
682 | { | |
683 | $id++; | |
684 | unless ($uqsettings{'ID'} eq $id) { print FILE "$line"; } | |
685 | else | |
686 | { | |
687 | chomp($line); | |
688 | @temp = split(/\,/,$line); | |
689 | if ($temp[4] eq 'on') { $temp[4] = 'off'; } else { $temp[4] = 'on' } | |
690 | print FILE "$temp[0],$temp[1],$temp[2],$temp[3],$temp[4]\n"; | |
691 | } | |
692 | } | |
693 | close(FILE); | |
694 | $uqsettings{'CHANGED'}='yes'; | |
695 | $uqsettings{'UQMODE'}='on'; | |
696 | } | |
697 | ||
698 | if (($uqsettings{'MODE'} eq 'USERQUOTA') && ($uqsettings{'ACTION'} eq $Lang::tr{'urlfilter restart'})) | |
699 | { | |
700 | if (!($proxysettings{'ENABLE_FILTER'} eq 'on')) | |
701 | { | |
702 | $errormessage = $Lang::tr{'urlfilter not enabled'}; | |
703 | } | |
1465b127 | 704 | if ((!(-e "${General::swroot}/proxy/enable")) && (!(-e "${General::swroot}/proxy/enable_blue"))) |
10e4f239 MT |
705 | { |
706 | $errormessage = $Lang::tr{'urlfilter web proxy service required'}; | |
707 | } | |
708 | ||
7d3af7f7 | 709 | if (!$errormessage) { system('/usr/local/bin/squidctrl restart >/dev/null 2>&1'); } |
10e4f239 MT |
710 | $uqsettings{'UQMODE'}='on'; |
711 | } | |
712 | ||
713 | if ($besettings{'ACTION'} eq $Lang::tr{'urlfilter blacklist editor'}) { $besettings{'BEMODE'} = 'on'; } | |
714 | ||
715 | if ($besettings{'MODE'} eq 'BLACKLIST_EDITOR') | |
716 | { | |
717 | @temp = split(/\n/,$besettings{'BE_DOMAINS'}); | |
718 | undef $besettings{'BE_DOMAINS'}; | |
719 | foreach (@temp) | |
720 | { | |
721 | s/^\s+//g; s/\s+$//g; | |
722 | if ($_) { $besettings{'BE_DOMAINS'} .= $_."\n"; } | |
723 | } | |
724 | chomp($besettings{'BE_DOMAINS'}); | |
725 | @temp = split(/\n/,$besettings{'BE_URLS'}); | |
726 | undef $besettings{'BE_URLS'}; | |
727 | foreach (@temp) | |
728 | { | |
729 | s/^\s+//g; s/\s+$//g; | |
730 | if ($_) { $besettings{'BE_URLS'} .= $_."\n"; } | |
731 | } | |
732 | chomp($besettings{'BE_URLS'}); | |
733 | @temp = split(/\n/,$besettings{'BE_EXPRESSIONS'}); | |
734 | undef $besettings{'BE_EXPRESSIONS'}; | |
735 | foreach (@temp) | |
736 | { | |
737 | s/^\s+//g; s/\s+$//g; | |
738 | if ($_) { $besettings{'BE_EXPRESSIONS'} .= $_."\n"; } | |
739 | } | |
740 | chomp($besettings{'BE_EXPRESSIONS'}); | |
741 | } | |
742 | ||
743 | if (($besettings{'ACTION'} eq $Lang::tr{'urlfilter load blacklist'}) && ($besettings{'MODE'} = 'BLACKLIST_EDITOR')) | |
744 | { | |
745 | $besettings{'BEMODE'} = 'on'; | |
746 | ||
747 | $besettings{'BE_NAME'} = $besettings{'BE_BLACKLIST'}; | |
748 | ||
749 | delete $besettings{'BE_DOMAINS'}; | |
750 | delete $besettings{'BE_URLS'}; | |
751 | delete $besettings{'BE_EXPRESSIONS'}; | |
752 | ||
753 | if (-e "$dbdir/$besettings{'BE_NAME'}/domains") | |
754 | { | |
755 | open(FILE, "$dbdir/$besettings{'BE_NAME'}/domains"); | |
756 | while (<FILE>) { unless ($_ eq '\n') { $besettings{'BE_DOMAINS'} .= $_ } }; | |
757 | close FILE; | |
758 | chomp($besettings{'BE_DOMAINS'}); | |
759 | } | |
760 | if (-e "$dbdir/$besettings{'BE_NAME'}/urls") | |
761 | { | |
762 | open(FILE, "$dbdir/$besettings{'BE_NAME'}/urls"); | |
763 | while (<FILE>) { unless ($_ eq '\n') { $besettings{'BE_URLS'} .= $_ } }; | |
764 | close FILE; | |
765 | chomp($besettings{'BE_URLS'}); | |
766 | } | |
767 | if (-e "$dbdir/$besettings{'BE_NAME'}/expressions") | |
768 | { | |
769 | open(FILE, "$dbdir/$besettings{'BE_NAME'}/expressions"); | |
770 | while (<FILE>) { unless ($_ eq '\n') { $besettings{'BE_EXPRESSIONS'} .= $_ } }; | |
771 | close FILE; | |
772 | chomp($besettings{'BE_EXPRESSIONS'}); | |
773 | } | |
774 | } | |
775 | ||
776 | if (($besettings{'ACTION'} eq $Lang::tr{'urlfilter import blacklist'}) && ($besettings{'MODE'} = 'BLACKLIST_EDITOR')) | |
777 | { | |
778 | $besettings{'BEMODE'} = 'on'; | |
779 | ||
780 | &Header::getcgihash(\%besettings, {'wantfile' => 1, 'filevar' => 'IMPORTFILE'}); | |
781 | ||
782 | if (!($besettings{'IMPORTFILE'} =~ /.tar.gz$/)) | |
783 | { | |
784 | $errormessage = $Lang::tr{'urlfilter wrong filetype'}; | |
785 | } else { | |
786 | if (!-d "$editdir") { mkdir("$editdir"); } | |
787 | ||
788 | if (copy($besettings{'IMPORTFILE'}, "$editdir/blacklist.tar.gz") != 1) | |
789 | { | |
790 | $errormessage = $!; | |
791 | } else { | |
d47ad587 | 792 | |
10e4f239 MT |
793 | my $exitcode = system("/bin/tar --no-same-owner --preserve-permissions -xzf $editdir/blacklist.tar.gz -C $editdir"); |
794 | if ($exitcode > 0) | |
795 | { | |
796 | $errormessage = $Lang::tr{'urlfilter tar error'}; | |
797 | } else { | |
798 | $i = 0; | |
799 | foreach (<$editdir/blacklists/*>) | |
800 | { | |
801 | if (-d) | |
802 | { | |
803 | $i++; | |
804 | $besettings{'BE_NAME'} = substr($_, rindex($_,"/")+1); | |
805 | } | |
806 | } | |
807 | ||
808 | if (!($i == 1)) | |
809 | { | |
810 | $errormessage = $Lang::tr{'urlfilter invalid import file'}; | |
811 | } else { | |
812 | delete $besettings{'BE_DOMAINS'}; | |
813 | delete $besettings{'BE_URLS'}; | |
814 | delete $besettings{'BE_EXPRESSIONS'}; | |
815 | ||
816 | if (-e "$editdir/blacklists/$besettings{'BE_NAME'}/domains") | |
817 | { | |
818 | open(FILE, "$editdir/blacklists/$besettings{'BE_NAME'}/domains"); | |
819 | while (<FILE>) { unless ($_ eq '\n') { $besettings{'BE_DOMAINS'} .= $_ } }; | |
820 | close FILE; | |
821 | chomp($besettings{'BE_DOMAINS'}); | |
822 | } | |
823 | if (-e "$editdir/blacklists/$besettings{'BE_NAME'}/urls") | |
824 | { | |
825 | open(FILE, "$editdir/blacklists/$besettings{'BE_NAME'}/urls"); | |
826 | while (<FILE>) { unless ($_ eq '\n') { $besettings{'BE_URLS'} .= $_ } }; | |
827 | close FILE; | |
828 | chomp($besettings{'BE_URLS'}); | |
829 | } | |
830 | if (-e "$editdir/blacklists/$besettings{'BE_NAME'}/expressions") | |
831 | { | |
832 | open(FILE, "$editdir/blacklists/$besettings{'BE_NAME'}/expressions"); | |
833 | while (<FILE>) { unless ($_ eq '\n') { $besettings{'BE_EXPRESSIONS'} .= $_ } }; | |
834 | close FILE; | |
835 | chomp($besettings{'BE_EXPRESSIONS'}); | |
836 | } | |
837 | } | |
838 | } | |
839 | ||
840 | if (-d $editdir) { system("rm -rf $editdir"); } | |
841 | ||
842 | } | |
843 | } | |
844 | } | |
845 | ||
846 | if (($besettings{'ACTION'} eq $Lang::tr{'urlfilter export blacklist'}) && ($besettings{'MODE'} = 'BLACKLIST_EDITOR')) | |
847 | { | |
848 | $besettings{'BEMODE'} = 'on'; | |
849 | ||
850 | if ($besettings{'BE_NAME'} eq '') | |
851 | { | |
852 | $errormessage = $Lang::tr{'urlfilter category name error'}; | |
853 | } elsif ($besettings{'BE_DOMAINS'} || $besettings{'BE_URLS'} || $besettings{'BE_EXPRESSIONS'}) { | |
854 | ||
855 | $_ = $besettings{'BE_NAME'}; tr/A-Z/a-z/; $besettings{'BE_NAME'} = $_; | |
856 | ||
857 | if (!(-d "$editdir")) { mkdir("$editdir"); } | |
858 | if (!(-d "$editdir/blacklists")) { mkdir("$editdir/blacklists"); } | |
859 | if (!(-d "$editdir/blacklists/$besettings{'BE_NAME'}")) { mkdir("$editdir/blacklists/$besettings{'BE_NAME'}"); } | |
860 | ||
861 | open(FILE, ">$editdir/blacklists/$besettings{'BE_NAME'}/domains"); | |
862 | flock FILE, 2; | |
863 | print FILE "$besettings{'BE_DOMAINS'}\n"; | |
864 | close FILE; | |
865 | open(FILE, ">$editdir/blacklists/$besettings{'BE_NAME'}/urls"); | |
866 | flock FILE, 2; | |
867 | print FILE "$besettings{'BE_URLS'}\n"; | |
868 | close FILE; | |
869 | open(FILE, ">$editdir/blacklists/$besettings{'BE_NAME'}/expressions"); | |
870 | flock FILE, 2; | |
871 | print FILE "$besettings{'BE_EXPRESSIONS'}\n"; | |
872 | close FILE; | |
873 | ||
874 | if (system("/bin/tar -C $editdir -czf $editdir/$besettings{'BE_NAME'}.tar.gz blacklists")) | |
875 | { | |
876 | $errormessage = $Lang::tr{'urlfilter export error'}; | |
877 | } | |
878 | else | |
879 | { | |
880 | print "Content-type: application/gzip\n"; | |
881 | print "Content-length: "; | |
882 | print (-s "$editdir/$besettings{'BE_NAME'}.tar.gz"); | |
883 | print "\n"; | |
884 | print "Content-disposition: attachment; filename=$besettings{'BE_NAME'}.tar.gz\n\n"; | |
885 | ||
886 | open (FILE, "$editdir/$besettings{'BE_NAME'}.tar.gz"); | |
887 | while (<FILE>) { print; } | |
888 | close (FILE); | |
889 | ||
890 | if (-d $editdir) { system("rm -rf $editdir"); } | |
891 | exit; | |
892 | } | |
893 | } else { | |
894 | $errormessage = $Lang::tr{'urlfilter category data error'}; | |
895 | } | |
896 | } | |
897 | ||
898 | if (($besettings{'ACTION'} eq $Lang::tr{'urlfilter install blacklist'}) && ($besettings{'MODE'} = 'BLACKLIST_EDITOR')) | |
899 | { | |
900 | $besettings{'BEMODE'} = 'on'; | |
901 | ||
902 | if ($besettings{'BE_NAME'} eq '') | |
903 | { | |
904 | $errormessage = $Lang::tr{'urlfilter category name error'}; | |
905 | } elsif ($besettings{'BE_DOMAINS'} || $besettings{'BE_URLS'} || $besettings{'BE_EXPRESSIONS'}) { | |
906 | ||
907 | $_ = $besettings{'BE_NAME'}; tr/A-Z/a-z/; $besettings{'BE_NAME'} = $_; | |
908 | ||
909 | if (!-d "$editdir") { mkdir("$editdir"); } | |
910 | ||
911 | if (!-d "$dbdir/$besettings{'BE_NAME'}") { mkdir("$dbdir/$besettings{'BE_NAME'}"); } | |
912 | ||
913 | if (-e "$dbdir/$besettings{'BE_NAME'}/domains") { unlink("$dbdir/$besettings{'BE_NAME'}/domains"); } | |
914 | if ($besettings{'BE_DOMAINS'}) | |
915 | { | |
916 | open(FILE, ">$dbdir/$besettings{'BE_NAME'}/domains"); | |
917 | flock FILE, 2; | |
918 | print FILE "$besettings{'BE_DOMAINS'}\n"; | |
919 | close FILE; | |
920 | } | |
921 | if (-e "$dbdir/$besettings{'BE_NAME'}/urls") { unlink("$dbdir/$besettings{'BE_NAME'}/urls"); } | |
922 | if ($besettings{'BE_URLS'}) | |
923 | { | |
924 | open(FILE, ">$dbdir/$besettings{'BE_NAME'}/urls"); | |
925 | flock FILE, 2; | |
926 | print FILE "$besettings{'BE_URLS'}\n"; | |
927 | close FILE; | |
928 | } | |
929 | if (-e "$dbdir/$besettings{'BE_NAME'}/expressions") { unlink("$dbdir/$besettings{'BE_NAME'}/expressions"); } | |
930 | if ($besettings{'BE_EXPRESSIONS'}) | |
931 | { | |
932 | open(FILE, ">$dbdir/$besettings{'BE_NAME'}/expressions"); | |
933 | flock FILE, 2; | |
934 | print FILE "$besettings{'BE_EXPRESSIONS'}\n"; | |
935 | close FILE; | |
936 | } | |
937 | ||
938 | open(FILE, ">$editdir/install.conf"); | |
939 | flock FILE, 2; | |
940 | print FILE "logdir /var/log/squidGuard\n"; | |
941 | print FILE "dbhome $dbdir/$besettings{'BE_NAME'}\n\n"; | |
942 | print FILE "dest $besettings{'BE_NAME'} {\n"; | |
943 | if ($besettings{'BE_DOMAINS'}) { print FILE " domainlist domains\n"; } | |
944 | if ($besettings{'BE_URLS'}) { print FILE " urllist urls\n"; } | |
945 | if ($besettings{'BE_EXPRESSIONS'}) { print FILE " expressions expressions\n"; } | |
946 | print FILE "}\n\n"; | |
947 | print FILE "acl {\n"; | |
948 | print FILE " default {\n"; | |
949 | print FILE " pass none\n"; | |
950 | print FILE " }\n"; | |
951 | print FILE "}\n"; | |
952 | close FILE; | |
953 | ||
954 | system("rm -f $dbdir/$besettings{'BE_NAME'}/*.db"); | |
955 | system("/usr/sbin/squidGuard -c $editdir/install.conf -C all"); | |
956 | system("chmod a+w $dbdir/$besettings{'BE_NAME'}/*.db"); | |
957 | ||
958 | &readblockcategories; | |
959 | &readcustomlists; | |
960 | ||
961 | &writeconfigfile; | |
962 | ||
7d3af7f7 | 963 | system('/usr/local/bin/squidctrl restart >/dev/null 2>&1') unless ($besettings{'NORESTART'} eq 'on'); |
10e4f239 MT |
964 | |
965 | if (-d $editdir) { system("rm -rf $editdir"); } | |
966 | } else { | |
967 | $errormessage = $Lang::tr{'urlfilter category data error'}; | |
968 | } | |
969 | } | |
970 | ||
971 | if ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter save schedule'}) | |
972 | { | |
973 | if (($filtersettings{'UPDATE_SOURCE'} eq 'custom') && ($filtersettings{'CUSTOM_UPDATE_URL'} eq '')) | |
974 | { | |
975 | $errormessage = $Lang::tr{'urlfilter custom url required'}; | |
976 | } else { | |
977 | open (FILE, ">$updconffile"); | |
978 | print FILE "ENABLE_AUTOUPDATE=$filtersettings{'ENABLE_AUTOUPDATE'}\n"; | |
979 | print FILE "UPDATE_SCHEDULE=$filtersettings{'UPDATE_SCHEDULE'}\n"; | |
980 | print FILE "UPDATE_SOURCE=$filtersettings{'UPDATE_SOURCE'}\n"; | |
981 | print FILE "CUSTOM_UPDATE_URL=$filtersettings{'CUSTOM_UPDATE_URL'}\n"; | |
982 | close FILE; | |
983 | ||
984 | if (-e $upd_cron_dly) { unlink($upd_cron_dly); } | |
985 | if (-e $upd_cron_wly) { unlink($upd_cron_wly); } | |
986 | if (-e $upd_cron_mly) { unlink($upd_cron_mly); } | |
987 | ||
988 | if (($filtersettings{'ENABLE_AUTOUPDATE'} eq 'on') && ($filtersettings{'UPDATE_SCHEDULE'} eq 'daily')) | |
989 | { | |
990 | symlink("../bin/autoupdate.pl",$upd_cron_dly) | |
991 | } else { | |
992 | symlink("/bin/false",$upd_cron_dly) | |
993 | } | |
994 | ||
995 | if (($filtersettings{'ENABLE_AUTOUPDATE'} eq 'on') && ($filtersettings{'UPDATE_SCHEDULE'} eq 'weekly')) | |
996 | { | |
997 | symlink("../bin/autoupdate.pl",$upd_cron_wly) | |
998 | } else { | |
999 | symlink("/bin/false",$upd_cron_wly) | |
1000 | } | |
1001 | ||
1002 | if (($filtersettings{'ENABLE_AUTOUPDATE'} eq 'on') && ($filtersettings{'UPDATE_SCHEDULE'} eq 'monthly')) | |
1003 | { | |
1004 | symlink("../bin/autoupdate.pl",$upd_cron_mly) | |
1005 | } else { | |
1006 | symlink("/bin/false",$upd_cron_mly) | |
1007 | } | |
1008 | } | |
1009 | } | |
1010 | ||
1011 | if ($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter update now'}) | |
1012 | { | |
1013 | if ($filtersettings{'UPDATE_SOURCE'} eq 'custom') | |
1014 | { | |
1015 | if ($filtersettings{'CUSTOM_UPDATE_URL'} eq '') | |
1016 | { | |
1017 | $errormessage = $Lang::tr{'urlfilter custom url required'}; | |
1018 | } else { | |
1019 | system("${General::swroot}/urlfilter/bin/autoupdate.pl $filtersettings{'CUSTOM_UPDATE_URL'} &"); | |
1020 | } | |
1021 | } else { | |
1022 | system("${General::swroot}/urlfilter/bin/autoupdate.pl $filtersettings{'UPDATE_SOURCE'} &"); | |
1023 | } | |
1024 | } | |
1025 | ||
1026 | ||
1027 | if (-e "${General::swroot}/urlfilter/settings") { &General::readhash("${General::swroot}/urlfilter/settings", \%filtersettings); } | |
1028 | ||
1029 | &readcustomlists; | |
1030 | ||
1465b127 MT |
1031 | ERROR: |
1032 | ||
1033 | if ($errormessage) { $filtersettings{'VALID'} = 'no'; } | |
1034 | ||
10e4f239 MT |
1035 | $checked{'ENABLE_CUSTOM_BLACKLIST'}{'off'} = ''; |
1036 | $checked{'ENABLE_CUSTOM_BLACKLIST'}{'on'} = ''; | |
1037 | $checked{'ENABLE_CUSTOM_BLACKLIST'}{$filtersettings{'ENABLE_CUSTOM_BLACKLIST'}} = "checked='checked'"; | |
1038 | $checked{'ENABLE_CUSTOM_WHITELIST'}{'off'} = ''; | |
1039 | $checked{'ENABLE_CUSTOM_WHITELIST'}{'on'} = ''; | |
1040 | $checked{'ENABLE_CUSTOM_WHITELIST'}{$filtersettings{'ENABLE_CUSTOM_WHITELIST'}} = "checked='checked'"; | |
1041 | $checked{'ENABLE_CUSTOM_EXPRESSIONS'}{'off'} = ''; | |
1042 | $checked{'ENABLE_CUSTOM_EXPRESSIONS'}{'on'} = ''; | |
1043 | $checked{'ENABLE_CUSTOM_EXPRESSIONS'}{$filtersettings{'ENABLE_CUSTOM_EXPRESSIONS'}} = "checked='checked'"; | |
1044 | $checked{'BLOCK_EXECUTABLES'}{'off'} = ''; | |
1045 | $checked{'BLOCK_EXECUTABLES'}{'on'} = ''; | |
1046 | $checked{'BLOCK_EXECUTABLES'}{$filtersettings{'BLOCK_EXECUTABLES'}} = "checked='checked'"; | |
1047 | $checked{'BLOCK_AUDIO-VIDEO'}{'off'} = ''; | |
1048 | $checked{'BLOCK_AUDIO-VIDEO'}{'on'} = ''; | |
1049 | $checked{'BLOCK_AUDIO-VIDEO'}{$filtersettings{'BLOCK_AUDIO-VIDEO'}} = "checked='checked'"; | |
1050 | $checked{'BLOCK_ARCHIVES'}{'off'} = ''; | |
1051 | $checked{'BLOCK_ARCHIVES'}{'on'} = ''; | |
1052 | $checked{'BLOCK_ARCHIVES'}{$filtersettings{'BLOCK_ARCHIVES'}} = "checked='checked'"; | |
1053 | $checked{'ENABLE_REWRITE'}{'off'} = ''; | |
1054 | $checked{'ENABLE_REWRITE'}{'on'} = ''; | |
1055 | $checked{'ENABLE_REWRITE'}{$filtersettings{'ENABLE_REWRITE'}} = "checked='checked'"; | |
1056 | $checked{'SHOW_CATEGORY'}{'off'} = ''; | |
1057 | $checked{'SHOW_CATEGORY'}{'on'} = ''; | |
1058 | $checked{'SHOW_CATEGORY'}{$filtersettings{'SHOW_CATEGORY'}} = "checked='checked'"; | |
1059 | $checked{'SHOW_URL'}{'off'} = ''; | |
1060 | $checked{'SHOW_URL'}{'on'} = ''; | |
1061 | $checked{'SHOW_URL'}{$filtersettings{'SHOW_URL'}} = "checked='checked'"; | |
1062 | $checked{'SHOW_IP'}{'off'} = ''; | |
1063 | $checked{'SHOW_IP'}{'on'} = ''; | |
1064 | $checked{'SHOW_IP'}{$filtersettings{'SHOW_IP'}} = "checked='checked'"; | |
1065 | $checked{'ENABLE_DNSERROR'}{'off'} = ''; | |
1066 | $checked{'ENABLE_DNSERROR'}{'on'} = ''; | |
1067 | $checked{'ENABLE_DNSERROR'}{$filtersettings{'ENABLE_DNSERROR'}} = "checked='checked'"; | |
1068 | $checked{'ENABLE_JPEG'}{'off'} = ''; | |
1069 | $checked{'ENABLE_JPEG'}{'on'} = ''; | |
1070 | $checked{'ENABLE_JPEG'}{$filtersettings{'ENABLE_JPEG'}} = "checked='checked'"; | |
1071 | $checked{'ENABLE_EXPR_LISTS'}{'off'} = ''; | |
1072 | $checked{'ENABLE_EXPR_LISTS'}{'on'} = ''; | |
1073 | $checked{'ENABLE_EXPR_LISTS'}{$filtersettings{'ENABLE_EXPR_LISTS'}} = "checked='checked'"; | |
1074 | $checked{'BLOCK_IP_ADDR'}{'off'} = ''; | |
1075 | $checked{'BLOCK_IP_ADDR'}{'on'} = ''; | |
1076 | $checked{'BLOCK_IP_ADDR'}{$filtersettings{'BLOCK_IP_ADDR'}} = "checked='checked'"; | |
1077 | $checked{'BLOCK_ALL'}{'off'} = ''; | |
1078 | $checked{'BLOCK_ALL'}{'on'} = ''; | |
1079 | $checked{'BLOCK_ALL'}{$filtersettings{'BLOCK_ALL'}} = "checked='checked'"; | |
1080 | $checked{'ENABLE_EMPTY_ADS'}{'off'} = ''; | |
1081 | $checked{'ENABLE_EMPTY_ADS'}{'on'} = ''; | |
1082 | $checked{'ENABLE_EMPTY_ADS'}{$filtersettings{'ENABLE_EMPTY_ADS'}} = "checked='checked'"; | |
1083 | $checked{'ENABLE_GLOBAL_WHITELIST'}{'off'} = ''; | |
1084 | $checked{'ENABLE_GLOBAL_WHITELIST'}{'on'} = ''; | |
1085 | $checked{'ENABLE_GLOBAL_WHITELIST'}{$filtersettings{'ENABLE_GLOBAL_WHITELIST'}} = "checked='checked'"; | |
1086 | $checked{'ENABLE_SAFESEARCH'}{'off'} = ''; | |
1087 | $checked{'ENABLE_SAFESEARCH'}{'on'} = ''; | |
1088 | $checked{'ENABLE_SAFESEARCH'}{$filtersettings{'ENABLE_SAFESEARCH'}} = "checked='checked'"; | |
1089 | $checked{'ENABLE_LOG'}{'off'} = ''; | |
1090 | $checked{'ENABLE_LOG'}{'on'} = ''; | |
1091 | $checked{'ENABLE_LOG'}{$filtersettings{'ENABLE_LOG'}} = "checked='checked'"; | |
1092 | $checked{'ENABLE_USERNAME_LOG'}{'off'} = ''; | |
1093 | $checked{'ENABLE_USERNAME_LOG'}{'on'} = ''; | |
1094 | $checked{'ENABLE_USERNAME_LOG'}{$filtersettings{'ENABLE_USERNAME_LOG'}} = "checked='checked'"; | |
1095 | $checked{'ENABLE_CATEGORY_LOG'}{'off'} = ''; | |
1096 | $checked{'ENABLE_CATEGORY_LOG'}{'on'} = ''; | |
1097 | $checked{'ENABLE_CATEGORY_LOG'}{$filtersettings{'ENABLE_CATEGORY_LOG'}} = "checked='checked'"; | |
1098 | ||
1099 | foreach $category (@filtergroups) { | |
1100 | $checked{$category}{'off'} = ''; | |
1101 | $checked{$category}{'on'} = ''; | |
1102 | $checked{$category}{$filtersettings{$category}} = "checked='checked'"; | |
1103 | } | |
1104 | ||
1105 | $selected{'DEFINITION'}{$tcsettings{'DEFINITION'}} = "selected='selected'"; | |
1106 | $selected{'FROM_HOUR'}{$tcsettings{'FROM_HOUR'}} = "selected='selected'"; | |
1107 | $selected{'FROM_MINUTE'}{$tcsettings{'FROM_MINUTE'}} = "selected='selected'"; | |
1108 | $selected{'TO_HOUR'}{$tcsettings{'TO_HOUR'}} = "selected='selected'"; | |
1109 | $selected{'TO_MINUTE'}{$tcsettings{'TO_MINUTE'}} = "selected='selected'"; | |
1110 | ||
1111 | @selectedcategories = split(/\|/,$tcsettings{'DST'}); | |
1112 | foreach (@selectedcategories) | |
1113 | { | |
1114 | $selected{'DST'}{$_} = "selected='selected'"; | |
1115 | } | |
1116 | ||
1117 | $selected{'ACCESS'}{$tcsettings{'ACCESS'}} = "selected='selected'"; | |
1118 | ||
1119 | $checked{'ENABLERULE'}{'off'} = ''; | |
1120 | $checked{'ENABLERULE'}{'on'} = ''; | |
1121 | $checked{'ENABLERULE'}{$tcsettings{'ENABLERULE'}} = "checked='checked'"; | |
1122 | $checked{'MON'}{'off'} = ''; | |
1123 | $checked{'MON'}{'on'} = ''; | |
1124 | $checked{'MON'}{$tcsettings{'MON'}} = "checked='checked'"; | |
1125 | $checked{'TUE'}{'off'} = ''; | |
1126 | $checked{'TUE'}{'on'} = ''; | |
1127 | $checked{'TUE'}{$tcsettings{'TUE'}} = "checked='checked'"; | |
1128 | $checked{'WED'}{'off'} = ''; | |
1129 | $checked{'WED'}{'on'} = ''; | |
1130 | $checked{'WED'}{$tcsettings{'WED'}} = "checked='checked'"; | |
1131 | $checked{'THU'}{'off'} = ''; | |
1132 | $checked{'THU'}{'on'} = ''; | |
1133 | $checked{'THU'}{$tcsettings{'THU'}} = "checked='checked'"; | |
1134 | $checked{'FRI'}{'off'} = ''; | |
1135 | $checked{'FRI'}{'on'} = ''; | |
1136 | $checked{'FRI'}{$tcsettings{'FRI'}} = "checked='checked'"; | |
1137 | $checked{'SAT'}{'off'} = ''; | |
1138 | $checked{'SAT'}{'on'} = ''; | |
1139 | $checked{'SAT'}{$tcsettings{'SAT'}} = "checked='checked'"; | |
1140 | $checked{'SUN'}{'off'} = ''; | |
1141 | $checked{'SUN'}{'on'} = ''; | |
1142 | $checked{'SUN'}{$tcsettings{'SUN'}} = "checked='checked'"; | |
1143 | ||
1144 | $selected{'SPORADIC'}{$uqsettings{'SPORADIC'}} = "selected='selected'"; | |
1145 | $selected{'RENEWAL'} {$uqsettings{'RENEWAL'}} = "selected='selected'"; | |
1146 | ||
1147 | $checked{'ENABLEQUOTA'}{'off'} = ''; | |
1148 | $checked{'ENABLEQUOTA'}{'on'} = ''; | |
1149 | $checked{'ENABLEQUOTA'}{$uqsettings{'ENABLEQUOTA'}} = "checked='checked'"; | |
1150 | ||
1151 | $selected{'BE_BLACKLIST'}{$besettings{'BE_BLACKLIST'}} = "selected='selected'"; | |
1152 | ||
1153 | ||
1154 | &Header::showhttpheaders(); | |
1155 | ||
1156 | &Header::openpage($Lang::tr{'urlfilter configuration'}, 1, ''); | |
1157 | ||
1158 | &Header::openbigbox('100%', 'left', '', $errormessage); | |
1159 | ||
1160 | if ($errormessage) { | |
1161 | &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); | |
1162 | print "<font class='base'>$errormessage </font>\n"; | |
1163 | &Header::closebox(); | |
1164 | } elsif (($tcsettings{'CHANGED'} eq 'yes') || ($uqsettings{'CHANGED'} eq 'yes') ) { | |
1165 | &writeconfigfile; | |
1166 | print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n"; | |
1167 | &Header::openbox('100%', 'left', "$Lang::tr{'urlfilter restart notification'}:"); | |
1168 | print "<class name='base'>$Lang::tr{'urlfilter restart message'}\n"; | |
1169 | if ($uqsettings{'MODE'} eq 'USERQUOTA') { print "<p><class name='base'>$Lang::tr{'urlfilter quota restart message'}\n"; } | |
1170 | print "</class>\n"; | |
1171 | print "<p><input type='submit' name='ACTION' value='$Lang::tr{'urlfilter restart'}' />"; | |
1172 | if ($tcsettings{'MODE'} eq 'TIMECONSTRAINT') { print "<input type='hidden' name='MODE' value='TIMECONSTRAINT' />"; } | |
1173 | if ($uqsettings{'MODE'} eq 'USERQUOTA') { print "<input type='hidden' name='MODE' value='USERQUOTA' />"; } | |
1174 | &Header::closebox(); | |
1175 | print "</form>\n"; | |
1176 | } | |
1177 | ||
1178 | if ($restoremessage) { | |
1179 | &Header::openbox('100%', 'left', "$Lang::tr{'urlfilter restore results'}:"); | |
1180 | print "<class name='base'>$restoremessage\n"; | |
1181 | print " </class>\n"; | |
1182 | &Header::closebox(); | |
1183 | } | |
1184 | ||
1185 | if ((!$tcsettings{'TCMODE'}) && (!$uqsettings{'UQMODE'}) && (!$besettings{'BEMODE'})) { | |
1186 | ||
1187 | if (!($filtersettings{'ACTION'} eq $Lang::tr{'urlfilter manage repository'})) { | |
1188 | ||
1189 | #========================================================== | |
1190 | # | |
1191 | # Section: Main Configuration | |
1192 | # | |
1193 | #========================================================== | |
1194 | ||
1195 | print "<form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>\n"; | |
1196 | ||
1197 | &Header::openbox('100%', 'left', "$Lang::tr{'urlfilter filter settings'}:"); | |
1198 | print <<END | |
1199 | <table width='100%'> | |
1200 | <tr> | |
1201 | <td colspan='4'><b>$Lang::tr{'urlfilter block categories'}</b></td> | |
1202 | </tr> | |
1203 | END | |
1204 | ; | |
1205 | ||
1206 | if (@categories == 0) { | |
1207 | print <<END | |
1208 | <tr> | |
1209 | <td><i>$Lang::tr{'urlfilter no categories'}</i></td> | |
1210 | <td> </td> | |
1211 | <td> </td> | |
1212 | <td> </td> | |
1213 | </tr> | |
1214 | ||
1215 | END | |
1216 | ; | |
1217 | } | |
1218 | ||
1219 | for ($n=0; $n<=@categories; $n = $n + $i) { | |
1220 | for ($i=0; $i<=3; $i++) { | |
1221 | if ($i eq 0) { print "<tr>\n"; } | |
1222 | if (($n+$i) < @categories) { | |
1223 | print "<td width='15%'>@categories[$n+$i]:<\/td>\n"; | |
1224 | print "<td width='10%'><input type='checkbox' name=@filtergroups[$n+$i] $checked{@filtergroups[$n+$i]}{'on'} /></td>\n"; | |
1225 | } | |
1226 | if ($i eq 3) { print "<\/tr>\n"; } | |
1227 | } | |
1228 | } | |
1229 | ||
1230 | print <<END | |
1231 | </table> | |
1232 | <hr size='1'> | |
1233 | <table width='100%'> | |
1234 | <tr> | |
1235 | <td><b>$Lang::tr{'urlfilter custom blacklist'}</b></td> | |
1236 | <td> </td> | |
1237 | <td> </td> | |
1238 | <td> </td> | |
1239 | </tr> | |
1240 | <tr> | |
1241 | <td colspan='2'>$Lang::tr{'urlfilter blocked domains'} <img src='/blob.gif' alt='*' /></td> | |
1242 | <td colspan='2'>$Lang::tr{'urlfilter blocked urls'} <img src='/blob.gif' alt='*' /></td> | |
1243 | </tr> | |
1244 | <tr> | |
1245 | <td colspan='2' width='50%'><textarea name='CUSTOM_BLACK_DOMAINS' cols='32' rows='6' wrap='off'> | |
1246 | END | |
1247 | ; | |
1248 | ||
1249 | print $filtersettings{'CUSTOM_BLACK_DOMAINS'}; | |
1250 | ||
1251 | print <<END | |
1252 | </textarea></td> | |
1253 | <td colspan='2' width='50%'><textarea name='CUSTOM_BLACK_URLS' cols='32' rows='6' wrap='off'> | |
1254 | END | |
1255 | ; | |
1256 | ||
1257 | print $filtersettings{'CUSTOM_BLACK_URLS'}; | |
1258 | ||
1259 | print <<END | |
1260 | </textarea></td> | |
1261 | </tr> | |
1262 | </table> | |
1263 | <table width='100%'> | |
1264 | <tr> | |
1265 | <td class='base' width='25%'>$Lang::tr{'urlfilter enable custom blacklist'}:</td> | |
1266 | <td><input type='checkbox' name='ENABLE_CUSTOM_BLACKLIST' $checked{'ENABLE_CUSTOM_BLACKLIST'}{'on'} /></td> | |
1267 | <td> </td> | |
1268 | <td> </td> | |
1269 | </tr> | |
1270 | </table> | |
1271 | <hr size='1'> | |
1272 | <table width='100%'> | |
1273 | <tr> | |
1274 | <td><b>$Lang::tr{'urlfilter custom whitelist'}</b></td> | |
1275 | <td> </td> | |
1276 | <td> </td> | |
1277 | <td> </td> | |
1278 | </tr> | |
1279 | <tr> | |
1280 | <td colspan='2'>$Lang::tr{'urlfilter allowed domains'} <img src='/blob.gif' alt='*' /></td> | |
1281 | <td colspan='2'>$Lang::tr{'urlfilter allowed urls'} <img src='/blob.gif' alt='*' /></td> | |
1282 | </tr> | |
1283 | <tr> | |
1284 | <td colspan='2' width='50%'><textarea name='CUSTOM_WHITE_DOMAINS' cols='32' rows='6' wrap='off'> | |
1285 | END | |
1286 | ; | |
1287 | ||
1288 | print $filtersettings{'CUSTOM_WHITE_DOMAINS'}; | |
1289 | ||
1290 | print <<END | |
1291 | </textarea></td> | |
1292 | <td colspan='2' width='50%'><textarea name='CUSTOM_WHITE_URLS' cols='32' rows='6' wrap='off'> | |
1293 | END | |
1294 | ; | |
1295 | ||
1296 | print $filtersettings{'CUSTOM_WHITE_URLS'}; | |
1297 | ||
1298 | print <<END | |
1299 | </textarea></td> | |
1300 | </tr> | |
1301 | </table> | |
1302 | <table width='100%'> | |
1303 | <tr> | |
1304 | <td class='base' width='25%'>$Lang::tr{'urlfilter enable custom whitelist'}:</td> | |
1305 | <td><input type='checkbox' name='ENABLE_CUSTOM_WHITELIST' $checked{'ENABLE_CUSTOM_WHITELIST'}{'on'} /></td> | |
1306 | <td> </td> | |
1307 | <td> </td> | |
1308 | </tr> | |
1309 | </table> | |
1310 | <hr size='1'> | |
1311 | <table width='100%'> | |
1312 | <tr> | |
1313 | <td colspan='4'><b>$Lang::tr{'urlfilter custom expression list'}</b></td> | |
1314 | </tr> | |
1315 | <tr> | |
1316 | <td colspan='4'>$Lang::tr{'urlfilter blocked expressions'} <img src='/blob.gif' alt='*' /></td> | |
1317 | </tr> | |
1318 | <tr> | |
1319 | <td colspan='4'><textarea name='CUSTOM_EXPRESSIONS' cols='70' rows='3' wrap='off'> | |
1320 | END | |
1321 | ; | |
1322 | ||
1323 | print $filtersettings{'CUSTOM_EXPRESSIONS'}; | |
1324 | ||
1325 | print <<END | |
1326 | </textarea></td> | |
1327 | </tr> | |
1328 | <tr> | |
1329 | <td class='base' width='25%'>$Lang::tr{'urlfilter enable custom expression list'}:</td> | |
1330 | <td><input type='checkbox' name='ENABLE_CUSTOM_EXPRESSIONS' $checked{'ENABLE_CUSTOM_EXPRESSIONS'}{'on'} /></td> | |
1331 | <td> </td> | |
1332 | <td> </td> | |
1333 | </tr> | |
1334 | </table> | |
1335 | <hr size='1'> | |
1336 | <table width='100%'> | |
1337 | <tr> | |
1338 | <td colspan='4'><b>$Lang::tr{'urlfilter file ext block'}</b></td> | |
1339 | </tr> | |
1340 | <tr> | |
1341 | <td width='25%' class='base'>$Lang::tr{'urlfilter block executables'}:</td> | |
1342 | <td width='12%'><input type='checkbox' name='BLOCK_EXECUTABLES' $checked{'BLOCK_EXECUTABLES'}{'on'} /></td> | |
1343 | <td width='25%' class='base'>$Lang::tr{'urlfilter block audio-video'}:</td> | |
1344 | <td><input type='checkbox' name='BLOCK_AUDIO-VIDEO' $checked{'BLOCK_AUDIO-VIDEO'}{'on'} /></td> | |
1345 | </tr> | |
1346 | <tr> | |
1347 | <td class='base'>$Lang::tr{'urlfilter block archives'}:</td> | |
1348 | <td><input type='checkbox' name='BLOCK_ARCHIVES' $checked{'BLOCK_ARCHIVES'}{'on'} /></td> | |
1349 | <td> </td> | |
1350 | <td> </td> | |
1351 | </tr> | |
1352 | </table> | |
1353 | <hr size='1'> | |
1354 | <table width='100%'> | |
1355 | <tr> | |
1356 | <td colspan='4'><b>$Lang::tr{'urlfilter local file redirection'}</b></td> | |
1357 | </tr> | |
1358 | <tr> | |
1359 | <td width='25%' class='base'>$Lang::tr{'urlfilter enable rewrite rules'}:</td> | |
1360 | <td width='12%'><input type='checkbox' name='ENABLE_REWRITE' $checked{'ENABLE_REWRITE'}{'on'} /></td> | |
1361 | <td> </td> | |
1362 | <td> </td> | |
1363 | </tr> | |
1364 | <tr> | |
1365 | <td><input type='submit' name='ACTION' value='$Lang::tr{'urlfilter manage repository'}'></td> | |
1366 | <td> </td> | |
1367 | <td> </td> | |
1368 | <td> </td> | |
1369 | </tr> | |
1370 | </table> | |
1371 | <hr size='1'> | |
1372 | <table width='100%'> | |
1373 | <tr> | |
1374 | <td colspan='2'><b>$Lang::tr{'urlfilter network access control'}</b></td> | |
1375 | <td> </td> | |
1376 | <td> </td> | |
1377 | </tr> | |
1378 | <tr> | |
1465b127 MT |
1379 | <td colspan='2'>$Lang::tr{'urlfilter unfiltered clients'} <img src='/blob.gif' alt='*' /></td> |
1380 | <td colspan='2'>$Lang::tr{'urlfilter banned clients'} <img src='/blob.gif' alt='*' /></td> | |
1381 | </tr> | |
1382 | <tr> | |
1383 | <td colspan='2' width='50%'><textarea name='UNFILTERED_CLIENTS' cols='32' rows='6' wrap='off'> | |
1384 | END | |
1385 | ; | |
1386 | ||
1387 | # transform from pre1.8 client definitions | |
1388 | $filtersettings{'UNFILTERED_CLIENTS'} =~ s/^\s+//g; | |
1389 | $filtersettings{'UNFILTERED_CLIENTS'} =~ s/\s+$//g; | |
1390 | $filtersettings{'UNFILTERED_CLIENTS'} =~ s/\s+-\s+/-/g; | |
1391 | $filtersettings{'UNFILTERED_CLIENTS'} =~ s/\s+/ /g; | |
1392 | ||
1393 | @clients = split(/ /,$filtersettings{'UNFILTERED_CLIENTS'}); | |
1394 | undef $filtersettings{'UNFILTERED_CLIENTS'}; | |
1395 | foreach (@clients) { $filtersettings{'UNFILTERED_CLIENTS'} .= "$_\n"; } | |
1396 | ||
1397 | print $filtersettings{'UNFILTERED_CLIENTS'}; | |
1398 | ||
1399 | print <<END | |
1400 | </textarea></td> | |
1401 | <td colspan='2' width='50%'><textarea name='BANNED_CLIENTS' cols='32' rows='6' wrap='off'> | |
1402 | END | |
1403 | ; | |
1404 | ||
1405 | # transform from pre1.8 client definitions | |
1406 | $filtersettings{'BANNED_CLIENTS'} =~ s/^\s+//g; | |
1407 | $filtersettings{'BANNED_CLIENTS'} =~ s/\s+$//g; | |
1408 | $filtersettings{'BANNED_CLIENTS'} =~ s/\s+-\s+/-/g; | |
1409 | $filtersettings{'BANNED_CLIENTS'} =~ s/\s+/ /g; | |
1410 | ||
1411 | @clients = split(/ /,$filtersettings{'BANNED_CLIENTS'}); | |
1412 | undef $filtersettings{'BANNED_CLIENTS'}; | |
1413 | foreach (@clients) { $filtersettings{'BANNED_CLIENTS'} .= "$_\n"; } | |
1414 | ||
1415 | print $filtersettings{'BANNED_CLIENTS'}; | |
1416 | ||
1417 | print <<END | |
1418 | </textarea></td> | |
10e4f239 MT |
1419 | </tr> |
1420 | </table> | |
1421 | <hr size='1'> | |
1422 | <table width='100%'> | |
1423 | <tr> | |
1424 | <td colspan='4'><b>$Lang::tr{'urlfilter timebased access control'}</b></td> | |
1425 | </tr> | |
1426 | <tr> | |
1427 | <td width='25%'><input type='submit' name='ACTION' value='$Lang::tr{'urlfilter set time constraints'}'></td> | |
1428 | <td width='25%'><input type='submit' name='ACTION' value='$Lang::tr{'urlfilter set user quota'}'></td> | |
1429 | <td> </td> | |
1430 | <td> </td> | |
1431 | </tr> | |
1432 | </table> | |
1433 | <hr size='1'> | |
1434 | <table width='100%'> | |
1435 | <tr> | |
1436 | <td colspan='4'><b>$Lang::tr{'urlfilter block settings'}</b></td> | |
1437 | </tr> | |
1438 | <tr> | |
1439 | <td width='25%' class='base'>$Lang::tr{'urlfilter show category'}:</td> | |
1440 | <td width='12%'><input type='checkbox' name='SHOW_CATEGORY' $checked{'SHOW_CATEGORY'}{'on'} /></td> | |
1441 | <td width='25%' class='base'>$Lang::tr{'urlfilter redirectpage'}: <img src='/blob.gif' alt='*' /></td> | |
1442 | <td><input type='text' name='REDIRECT_PAGE' value='$filtersettings{'REDIRECT_PAGE'}' size='40' /></td> | |
1443 | </tr> | |
1444 | <tr> | |
1445 | <td class='base'>$Lang::tr{'urlfilter show url'}:</td> | |
1446 | <td><input type='checkbox' name='SHOW_URL' $checked{'SHOW_URL'}{'on'} /></td> | |
1447 | <td class='base'>$Lang::tr{'urlfilter msg text 1'}: <img src='/blob.gif' alt='*' /></td> | |
1448 | <td><input type='text' name='MSG_TEXT_1' value='$filtersettings{'MSG_TEXT_1'}' size='40' /></td> | |
1449 | </tr> | |
1450 | <tr> | |
1451 | <td class='base'>$Lang::tr{'urlfilter show ip'}:</td> | |
1452 | <td><input type='checkbox' name='SHOW_IP' $checked{'SHOW_IP'}{'on'} /></td> | |
1453 | <td class='base'>$Lang::tr{'urlfilter msg text 2'}: <img src='/blob.gif' alt='*' /></td> | |
1454 | <td><input type='text' name='MSG_TEXT_2' value='$filtersettings{'MSG_TEXT_2'}' size='40' /></td> | |
1455 | </tr> | |
1456 | <tr> | |
1457 | <td class='base'>$Lang::tr{'urlfilter show dnserror'}:</td> | |
1458 | <td><input type='checkbox' name='ENABLE_DNSERROR' $checked{'ENABLE_DNSERROR'}{'on'} /></td> | |
1459 | <td class='base'>$Lang::tr{'urlfilter msg text 3'}: <img src='/blob.gif' alt='*' /></td> | |
1460 | <td><input type='text' name='MSG_TEXT_3' value='$filtersettings{'MSG_TEXT_3'}' size='40' /></td> | |
1461 | </tr> | |
1462 | <tr> | |
1463 | <td class='base'>$Lang::tr{'urlfilter enable jpeg'}:</td> | |
1464 | <td><input type='checkbox' name='ENABLE_JPEG' $checked{'ENABLE_JPEG'}{'on'} /></td> | |
1465 | <td> </td> | |
1466 | <td> </td> | |
1467 | </tr> | |
1468 | </table> | |
10e4f239 MT |
1469 | <hr size='1'> |
1470 | <table width='100%'> | |
1471 | <tr> | |
1472 | <td colspan='4'><b>$Lang::tr{'urlfilter advanced settings'}</b></td> | |
1473 | </tr> | |
1474 | <tr> | |
1475 | <td width='25%' class='base'>$Lang::tr{'urlfilter enable expression lists'}:</td> | |
1476 | <td width='12%'><input type='checkbox' name='ENABLE_EXPR_LISTS' $checked{'ENABLE_EXPR_LISTS'}{'on'} /></td> | |
1477 | <td width='25%' class='base'>$Lang::tr{'urlfilter enable log'}:</td> | |
1478 | <td><input type='checkbox' name='ENABLE_LOG' $checked{'ENABLE_LOG'}{'on'} /></td> | |
1479 | </tr> | |
1480 | <tr> | |
1481 | <td class='base'>$Lang::tr{'urlfilter safesearch'}:</td> | |
1482 | <td><input type='checkbox' name='ENABLE_SAFESEARCH' $checked{'ENABLE_SAFESEARCH'}{'on'} /></td> | |
1483 | <td class='base'>$Lang::tr{'urlfilter username log'}:</td> | |
1484 | <td><input type='checkbox' name='ENABLE_USERNAME_LOG' $checked{'ENABLE_USERNAME_LOG'}{'on'} /></td> | |
1485 | </tr> | |
1486 | <tr> | |
1487 | <td class='base'>$Lang::tr{'urlfilter empty ads'}:</td> | |
1488 | <td><input type='checkbox' name='ENABLE_EMPTY_ADS' $checked{'ENABLE_EMPTY_ADS'}{'on'} /></td> | |
1489 | <td class='base'>$Lang::tr{'urlfilter category log'}:</td> | |
1490 | <td><input type='checkbox' name='ENABLE_CATEGORY_LOG' $checked{'ENABLE_CATEGORY_LOG'}{'on'} /></td> | |
1491 | </tr> | |
1492 | <tr> | |
1493 | <td class='base'>$Lang::tr{'urlfilter block ip'}:</td> | |
1494 | <td><input type='checkbox' name='BLOCK_IP_ADDR' $checked{'BLOCK_IP_ADDR'}{'on'} /></td> | |
1495 | <td class='base'>$Lang::tr{'urlfilter children'}:</td> | |
1496 | <td><input type='text' name='CHILDREN' value='$filtersettings{'CHILDREN'}' size='5' /></td> | |
1497 | </tr> | |
1498 | <tr> | |
1499 | <td class='base'>$Lang::tr{'urlfilter block all'}:</td> | |
1500 | <td><input type='checkbox' name='BLOCK_ALL' $checked{'BLOCK_ALL'}{'on'} /></td> | |
1501 | <td class='base'>$Lang::tr{'urlfilter whitelist always allowed'}:</td> | |
1502 | <td><input type='checkbox' name='ENABLE_GLOBAL_WHITELIST' $checked{'ENABLE_GLOBAL_WHITELIST'}{'on'} /></td> | |
1503 | </tr> | |
1504 | </table> | |
1505 | <hr size='1'> | |
1506 | <table width='100%'> | |
1507 | <tr> | |
1508 | <td> | |
1509 | <img src='/blob.gif' align='top' alt='*' /> | |
1510 | <font class='base'>$Lang::tr{'this field may be blank'}</font> | |
1511 | </td> | |
8deebac8 | 1512 | <td align='right'> |
1465b127 | 1513 | </td> |
10e4f239 MT |
1514 | </tr> |
1515 | </table> | |
1516 | <table width='100%'> | |
1517 | <tr> | |
1518 | <td> </td> | |
1519 | <td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td> | |
1520 | <td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'urlfilter save and restart'}' /></td> | |
1521 | <td> </td> | |
1522 | </tr> | |
1523 | </table> | |
1524 | END | |
1525 | ; | |
1526 | ||
1527 | &Header::closebox(); | |
1528 | ||
1529 | print "</form>\n"; | |
1530 | ||
1531 | print "<form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>\n"; | |
1532 | ||
1533 | &Header::openbox('100%', 'left', "$Lang::tr{'urlfilter maintenance'}:"); | |
1534 | ||
1535 | print <<END | |
1536 | <table width='100%'> | |
1537 | <tr> | |
1538 | <td class='base'><b>$Lang::tr{'urlfilter blacklist update'}</b></td> | |
1539 | </tr> | |
1540 | <tr> | |
1541 | <td>$Lang::tr{'urlfilter upload information'}<p>$Lang::tr{'urlfilter upload text'}:</td> | |
1542 | </tr> | |
1543 | <tr> | |
1544 | <td><input type='file' name='UPDATEFILE' size='40' /> <input type='submit' name='ACTION' value='$Lang::tr{'urlfilter upload blacklist'}' /></td> | |
1545 | </tr> | |
1546 | </table> | |
1547 | ||
1548 | <hr size='1'> | |
1549 | ||
1550 | <table width='100%'> | |
1551 | <tr> | |
1552 | <td colspan='2' class='base'><b>$Lang::tr{'urlfilter automatic blacklist update'}</b> | |
1553 | END | |
1554 | ; | |
1555 | if (-e "$updflagfile") | |
1556 | { | |
1557 | $blacklistage = int(-M "$updflagfile"); | |
1558 | print " <b>[</b> <small><i>$Lang::tr{'urlfilter blacklist age 1'} <b>$blacklistage</b> $Lang::tr{'urlfilter blacklist age 2'}</i></small> <b>]</b>"; | |
1559 | } | |
1560 | ||
1561 | $updatesettings{'UPDATE_SCHEDULE'} = 'monthly'; | |
1562 | $updatesettings{'CUSTOM_UPDATE_URL'} = ''; | |
1563 | ||
1564 | if (-e "$updconffile") { &General::readhash("$updconffile", \%updatesettings); } | |
1565 | ||
1566 | $checked{'ENABLE_AUTOUPDATE'}{'off'} = ''; | |
1567 | $checked{'ENABLE_AUTOUPDATE'}{'on'} = ''; | |
1568 | $checked{'ENABLE_AUTOUPDATE'}{$updatesettings{'ENABLE_AUTOUPDATE'}} = "checked='checked'"; | |
1569 | ||
1570 | $selected{'UPDATE_SCHEDULE'}{$updatesettings{'UPDATE_SCHEDULE'}} = "selected='selected'"; | |
1571 | ||
1572 | $selected{'UPDATE_SOURCE'}{$updatesettings{'UPDATE_SOURCE'}} = "selected='selected'"; | |
1573 | ||
1574 | print <<END | |
1575 | </td> | |
1576 | </tr> | |
1577 | <tr> | |
1578 | <td width='25%' class='base'>$Lang::tr{'urlfilter enable automatic blacklist update'}:</td> | |
1579 | <td width='75%' class='base'><input type='checkbox' name='ENABLE_AUTOUPDATE' $checked{'ENABLE_AUTOUPDATE'}{'on'} /></td> | |
1580 | </tr> | |
1581 | <tr> | |
1582 | <td class='base'>$Lang::tr{'urlfilter automatic update schedule'}:</td> | |
1583 | <td class='base'> | |
1584 | <select name='UPDATE_SCHEDULE'> | |
1585 | <option value='daily' $selected{'UPDATE_SCHEDULE'}{'daily'}>$Lang::tr{'urlfilter daily'}</option> | |
1586 | <option value='weekly' $selected{'UPDATE_SCHEDULE'}{'weekly'}>$Lang::tr{'urlfilter weekly'}</option> | |
1587 | <option value='monthly' $selected{'UPDATE_SCHEDULE'}{'monthly'}>$Lang::tr{'urlfilter monthly'}</option> | |
1588 | </select> | |
1589 | </td> | |
1590 | </tr> | |
1591 | <tr> | |
1592 | <td class='base'>$Lang::tr{'urlfilter select source'}:</td> | |
1593 | <td class='base' colspan='2'> | |
1594 | <select name='UPDATE_SOURCE'> | |
1595 | END | |
1596 | ; | |
1597 | ||
1598 | foreach (@source_urllist) { | |
1599 | chomp; | |
1600 | $source_name = substr($_,0,rindex($_,",")); | |
1601 | $source_url = substr($_,index($_,",")+1); | |
1602 | print "\t<option value='$source_url' $selected{'UPDATE_SOURCE'}{$source_url}>$source_name</option>\n"; | |
1603 | } | |
1604 | ||
1605 | print <<END | |
1606 | <option value='custom' $selected{'UPDATE_SOURCE'}{'custom'}>$Lang::tr{'urlfilter custom url'}</option> | |
1607 | </select> | |
1608 | </td> | |
1609 | </tr> | |
1610 | <tr> | |
1611 | <td>$Lang::tr{'urlfilter custom url'}:</td> | |
1612 | <td><input type='text' name='CUSTOM_UPDATE_URL' value='$updatesettings{'CUSTOM_UPDATE_URL'}' size='72' /></td> | |
1613 | </tr> | |
1614 | </table> | |
1615 | <table width='100%'> | |
1616 | <tr> | |
1617 | <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> | |
1618 | </tr> | |
1619 | </table> | |
1620 | ||
1621 | <hr size='1'> | |
1622 | ||
1623 | <table width='100%'> | |
1624 | <tr> | |
1625 | <td class='base'><b>$Lang::tr{'urlfilter blacklist editor'}</b></td> | |
1626 | </tr> | |
1627 | <tr> | |
1628 | <td>$Lang::tr{'urlfilter blacklist editor info'}</td> | |
1629 | </tr> | |
1630 | <tr> | |
1631 | <td><input type='submit' name='ACTION' value='$Lang::tr{'urlfilter blacklist editor'}' /></td> | |
1632 | </tr> | |
1633 | </table> | |
1634 | ||
1635 | <hr size='1'> | |
1636 | ||
1637 | <table width='100%'> | |
1638 | <tr> | |
1639 | <td colspan='4' class='base'><b>$Lang::tr{'urlfilter backup settings'}</b></td> | |
1640 | </tr> | |
1641 | <tr> | |
1642 | <td width='25%' class='base'>$Lang::tr{'urlfilter enable full backup'}:</td> | |
1643 | <td width='12%' class='base'><input type='checkbox' name='ENABLE_FULLBACKUP' $checked{'ENABLE_FULLBACKUP'}{'on'} /></td> | |
1644 | <td> </td> | |
1645 | <td> </td> | |
1646 | </tr> | |
1647 | <tr> | |
1648 | <td colspan='4' class='base'><input type='submit' name='ACTION' value='$Lang::tr{'urlfilter backup'}' /></td> | |
1649 | </tr> | |
1650 | </table> | |
1651 | ||
1652 | <hr size='1'> | |
1653 | ||
1654 | <table width='100%'> | |
1655 | <tr> | |
1656 | <td class='base'><b>$Lang::tr{'urlfilter restore settings'}</b></td> | |
1657 | </tr> | |
1658 | <tr> | |
1659 | <td>$Lang::tr{'urlfilter restore text'}:</td> | |
1660 | </tr> | |
1661 | <tr> | |
1662 | <td><input type='file' name='UPDATEFILE' size='40' /> <input type='submit' name='ACTION' value='$Lang::tr{'urlfilter restore'}' /></td> | |
1663 | </tr> | |
1664 | </table> | |
1665 | </form> | |
1666 | END | |
1667 | ; | |
1668 | ||
1669 | &Header::closebox(); | |
1670 | ||
1671 | } else { | |
1672 | ||
1673 | #========================================================== | |
1674 | # | |
1675 | # Section: Manage Repository | |
1676 | # | |
1677 | #========================================================== | |
1678 | ||
1679 | print "<form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>\n"; | |
1680 | ||
1681 | &Header::openbox('100%', 'left', "$Lang::tr{'urlfilter manage local file repository'}:"); | |
1682 | print <<END | |
1683 | <table width='100%'> | |
1684 | <tr> | |
1685 | <td>$Lang::tr{'urlfilter repository information'}<br><br></td> | |
1686 | </tr> | |
1687 | <tr> | |
1688 | <td>$Lang::tr{'urlfilter upload file text'}:</td> | |
1689 | </tr> | |
1690 | <tr> | |
1691 | <td><input type='file' name='UPLOADFILE' size='50' /> <input type='submit' name='ACTION' value='$Lang::tr{'urlfilter upload file'}' /></td> | |
1692 | </tr> | |
1693 | <tr> | |
1694 | <td><br><b>$Lang::tr{'urlfilter upload file information 1'}:</b> $Lang::tr{'urlfilter upload file information 2'}</td> | |
1695 | </tr> | |
1696 | </table> | |
1697 | <hr size='1'> | |
1698 | <table width='100%'> | |
1699 | <tr> | |
1700 | <td><input type='button' name='return2main' value='$Lang::tr{'urlfilter back to main page'}' onClick='self.location.href="$ENV{'SCRIPT_NAME'}"'></td> | |
1701 | </tr> | |
1702 | </table> | |
1703 | </form> | |
1704 | END | |
1705 | ; | |
1706 | ||
1707 | &Header::closebox(); | |
1708 | ||
1709 | &Header::openbox('100%', 'left', "$Lang::tr{'urlfilter current files'}: </b>[$repository]"); | |
1710 | ||
1711 | @repositorylist = <$repository/*>; | |
1712 | ||
1713 | undef @repositoryfiles; | |
1714 | foreach (@repositorylist) | |
1715 | { | |
1716 | if (!-d) { push(@repositoryfiles,substr($_,rindex($_,"/")+1)); } | |
1717 | } | |
1718 | ||
1719 | if (@repositoryfiles) | |
1720 | { | |
1721 | print <<END | |
1722 | <table width='100%'> | |
1723 | <tr> | |
1724 | <td align='center'><b>$Lang::tr{'urlfilter filename'}</b></td> | |
1725 | <td width='15%' align='center'><b>$Lang::tr{'urlfilter filesize'}</b></td> | |
1726 | <td width='10%'></td> | |
1727 | </tr> | |
1728 | END | |
1729 | ; | |
1730 | $id = 0; | |
1731 | foreach $line (@repositoryfiles) | |
1732 | { | |
1733 | $id++; | |
1734 | if ($id % 2) { | |
1735 | print "<tr bgcolor='$Header::table1colour'>\n"; } | |
1736 | else { | |
1737 | print "<tr bgcolor='$Header::table2colour'>\n"; } | |
1738 | $filesize = (-s "$repository/$line"); | |
1739 | 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/; | |
1740 | ||
1741 | print <<END | |
1742 | <td> $line</td> | |
1743 | <td align='right'>$filesize </td> | |
1744 | ||
1745 | <td align='center'> | |
1746 | <form method='post' name='frma$id' action='$ENV{'SCRIPT_NAME'}'> | |
1747 | <input type='image' name='$Lang::tr{'remove'}' src='/images/delete.gif' title='$Lang::tr{'remove'}' alt='$Lang::tr{'remove'}' /> | |
1748 | <input type='hidden' name='ID' value='$line' /> | |
1749 | <input type='hidden' name='ACTION' value='$Lang::tr{'urlfilter remove file'}' /> | |
1750 | </form> | |
1751 | </td> | |
1752 | ||
1753 | </tr> | |
1754 | END | |
1755 | ; | |
1756 | } | |
1757 | ||
1758 | print <<END | |
1759 | </table> | |
1760 | <table> | |
1761 | <tr> | |
1762 | </tr> | |
1763 | </table> | |
1764 | <table> | |
1765 | <tr> | |
1766 | <td class='boldbase'> <b>$Lang::tr{'legend'}:</b></td> | |
1767 | <td> <img src='/images/delete.gif' alt='$Lang::tr{'remove'}' /></td> | |
1768 | <td class='base'>$Lang::tr{'remove'}</td> | |
1769 | </tr> | |
1770 | </table> | |
1771 | END | |
1772 | ; | |
1773 | } else { | |
1774 | ||
1775 | print "<i>$Lang::tr{'urlfilter empty repository'}</i>\n"; | |
1776 | } | |
1777 | ||
1778 | &Header::closebox(); | |
1779 | ||
1780 | } | |
1781 | ||
1782 | } elsif ($tcsettings{'TCMODE'}) { | |
1783 | ||
1784 | #========================================================== | |
1785 | # | |
1786 | # Section: Set Time Constraints | |
1787 | # | |
1788 | #========================================================== | |
1789 | ||
1790 | print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n"; | |
1791 | ||
1792 | $buttontext = $Lang::tr{'urlfilter add rule'}; | |
1793 | if ($tcsettings{'ACTION'} eq $Lang::tr{'edit'}) { | |
1794 | &Header::openbox('100%', 'left', $Lang::tr{'urlfilter edit time constraint rule'}.':'); | |
1795 | $buttontext = $Lang::tr{'urlfilter update rule'}; | |
1796 | } else { | |
1797 | &Header::openbox('100%', 'left', $Lang::tr{'urlfilter add new time constraint rule'}.':'); | |
1798 | } | |
1799 | print <<END | |
1800 | ||
1801 | <table width='100%'> | |
1802 | <tr> | |
1803 | <td width='2%'>$Lang::tr{'urlfilter constraint definition'}</td> | |
1804 | <td width='1%'> </td> | |
1805 | <td width='2%' align='center'>$Lang::tr{'urlfilter monday'}</td> | |
1806 | <td width='2%' align='center'>$Lang::tr{'urlfilter tuesday'}</td> | |
1807 | <td width='2%' align='center'>$Lang::tr{'urlfilter wednesday'}</td> | |
1808 | <td width='2%' align='center'>$Lang::tr{'urlfilter thursday'}</td> | |
1809 | <td width='2%' align='center'>$Lang::tr{'urlfilter friday'}</td> | |
1810 | <td width='2%' align='center'>$Lang::tr{'urlfilter saturday'}</td> | |
1811 | <td width='2%' align='center'>$Lang::tr{'urlfilter sunday'}</td> | |
1812 | <td width='1%'> </td> | |
1813 | <td width='7%' colspan=3>$Lang::tr{'urlfilter from'}</td> | |
1814 | <td width='1%'> </td> | |
1815 | <td width='7%' colspan=3>$Lang::tr{'urlfilter to'}</td> | |
1816 | <td> </td> | |
1817 | </tr> | |
1818 | <tr> | |
1819 | <td class='base'> | |
1820 | <select name='DEFINITION'> | |
1821 | <option value='within' $selected{'DEFINITION'}{'within'}>$Lang::tr{'urlfilter constraint within'}</option> | |
1822 | <option value='outside' $selected{'DEFINITION'}{'outside'}>$Lang::tr{'urlfilter constraint outside'}</option> | |
1823 | </select> | |
1824 | </td> | |
1825 | <td> </td> | |
1826 | <td class='base'><input type='checkbox' name='MON' $checked{'MON'}{'on'} /></td> | |
1827 | <td class='base'><input type='checkbox' name='TUE' $checked{'TUE'}{'on'} /></td> | |
1828 | <td class='base'><input type='checkbox' name='WED' $checked{'WED'}{'on'} /></td> | |
1829 | <td class='base'><input type='checkbox' name='THU' $checked{'THU'}{'on'} /></td> | |
1830 | <td class='base'><input type='checkbox' name='FRI' $checked{'FRI'}{'on'} /></td> | |
1831 | <td class='base'><input type='checkbox' name='SAT' $checked{'SAT'}{'on'} /></td> | |
1832 | <td class='base'><input type='checkbox' name='SUN' $checked{'SUN'}{'on'} /></td> | |
1833 | <td> </td> | |
1834 | <td class='base'> | |
1835 | <select name='FROM_HOUR'> | |
1836 | END | |
1837 | ; | |
1838 | for ($i=0;$i<=24;$i++) { | |
1839 | $_ = sprintf("%02s",$i); | |
1840 | print "<option $selected{'FROM_HOUR'}{$_}>$_</option>\n"; | |
1841 | } | |
1842 | print <<END | |
1843 | </select> | |
1844 | </td> | |
1845 | <td>:</td> | |
1846 | <td class='base'> | |
1847 | <select name='FROM_MINUTE'> | |
1848 | END | |
1849 | ; | |
1850 | for ($i=0;$i<=45;$i+=15) { | |
1851 | $_ = sprintf("%02s",$i); | |
1852 | print "<option $selected{'FROM_MINUTE'}{$_}>$_</option>\n"; | |
1853 | } | |
1854 | print <<END | |
1855 | </select> | |
1856 | <td> - </td> | |
1857 | </td> | |
1858 | <td class='base'> | |
1859 | <select name='TO_HOUR'> | |
1860 | END | |
1861 | ; | |
1862 | for ($i=0;$i<=24;$i++) { | |
1863 | $_ = sprintf("%02s",$i); | |
1864 | print "<option $selected{'TO_HOUR'}{$_}>$_</option>\n"; | |
1865 | } | |
1866 | print <<END | |
1867 | </select> | |
1868 | </td> | |
1869 | <td>:</td> | |
1870 | <td class='base'> | |
1871 | <select name='TO_MINUTE'> | |
1872 | END | |
1873 | ; | |
1874 | for ($i=0;$i<=45;$i+=15) { | |
1875 | $_ = sprintf("%02s",$i); | |
1876 | print "<option $selected{'TO_MINUTE'}{$_}>$_</option>\n"; | |
1877 | } | |
1878 | print <<END | |
1879 | </select> | |
1880 | </td> | |
1881 | <td> </td> | |
1882 | </tr> | |
1883 | </table> | |
1884 | ||
1885 | <br> | |
1886 | ||
1887 | <table width='100%'> | |
1888 | <tr> | |
1889 | <td width='5%'>$Lang::tr{'urlfilter source'}</td> | |
1890 | <td width='1%'> </td> | |
1891 | <td width='5%'>$Lang::tr{'urlfilter dst'} <img src='/blob.gif' alt='*'><img src='/blob.gif' alt='*'></td> | |
1892 | <td width='1%'> </td> | |
1893 | <td width='5%'>$Lang::tr{'urlfilter access'}</td> | |
1894 | <td> </td> | |
1895 | </tr> | |
1896 | <tr> | |
1465b127 MT |
1897 | <td rowspan='2'><textarea name='SRC' cols='28' rows='5' wrap='off'> |
1898 | END | |
1899 | ; | |
1900 | ||
1901 | # transform from pre1.8 client definitions | |
1902 | $tcsettings{'SRC'} =~ s/^\s+//g; | |
1903 | $tcsettings{'SRC'} =~ s/\s+$//g; | |
1904 | $tcsettings{'SRC'} =~ s/\s+-\s+/-/g; | |
1905 | $tcsettings{'SRC'} =~ s/\s+/ /g; | |
1906 | ||
1907 | @clients = split(/ /,$tcsettings{'SRC'}); | |
1908 | undef $tcsettings{'SRC'}; | |
1909 | foreach (@clients) { $tcsettings{'SRC'} .= "$_\n"; } | |
1910 | ||
1911 | print $tcsettings{'SRC'}; | |
1912 | ||
1913 | print <<END | |
1914 | </textarea></td> | |
1915 | ||
10e4f239 | 1916 | <td> </td> |
1465b127 MT |
1917 | <td class='base' rowspan='2' valign='top'> |
1918 | <select name='DST' size='6' multiple> | |
10e4f239 MT |
1919 | <option value='any' $selected{'DST'}{'any'} = "selected='selected'">$Lang::tr{'urlfilter category all'}</option> |
1920 | <option value='in-addr' $selected{'DST'}{'in-addr'} = "selected='selected'">in-addr</option> | |
1921 | END | |
1922 | ; | |
1923 | ||
1924 | &readblockcategories; | |
1925 | foreach (@categories) | |
1926 | { | |
1927 | print "<option value='$_' $selected{'DST'}{$_}>$_</option>\n"; | |
1928 | } | |
1929 | ||
1930 | print <<END | |
1931 | <option value='files' $selected{'DST'}{'files'} = "selected='selected'">files</option> | |
1932 | <option value='custom-blocked' $selected{'DST'}{'custom-blocked'} = "selected='selected'">custom-blocked</option> | |
1933 | <option value='custom-expressions' $selected{'DST'}{'custom-expressions'} = "selected='selected'">custom-expressions</option> | |
1934 | </select> | |
1935 | </td> | |
1936 | <td> </td> | |
1937 | <td class='base' valign='top'> | |
1938 | <select name='ACCESS'> | |
1939 | <option value='block' $selected{'ACCESS'}{'block'}>$Lang::tr{'urlfilter mode block'}</option> | |
1940 | <option value='allow' $selected{'ACCESS'}{'allow'}>$Lang::tr{'urlfilter mode allow'}</option> | |
1941 | </select> | |
1942 | </td> | |
1943 | <td> </td> | |
1944 | </tr> | |
1465b127 MT |
1945 | <tr> |
1946 | <td> </td> | |
1947 | <td> </td> | |
1948 | <td> </td> | |
1949 | <td> </td> | |
1950 | </tr> | |
10e4f239 MT |
1951 | <tr> |
1952 | <td>$Lang::tr{'remark'} <img src='/blob.gif' alt='*'></td> | |
1953 | <td> </td> | |
1954 | <td> </td> | |
1955 | <td> </td> | |
1956 | <td> </td> | |
1465b127 | 1957 | <td> </td> |
10e4f239 MT |
1958 | </tr> |
1959 | <tr> | |
1960 | <td><input type='text' name='COMMENT' value='$tcsettings{'COMMENT'}' size='32' /></td> | |
1961 | <td> </td> | |
1962 | <td> </td> | |
1963 | <td> </td> | |
1964 | <td> </td> | |
1465b127 | 1965 | <td> </td> |
10e4f239 MT |
1966 | </tr> |
1967 | </table> | |
1968 | ||
1969 | <table width='100%'> | |
1970 | <tr> | |
1971 | <td class='base'>$Lang::tr{'urlfilter enabled'}<input type='checkbox' name='ENABLERULE' $checked{'ENABLERULE'}{'on'} /></td> | |
1972 | </tr> | |
1973 | </table> | |
1974 | ||
1975 | <p> | |
1976 | ||
1977 | <table width='50%'> | |
1978 | <tr> | |
1979 | <td><input type='hidden' name='ACTION' value='$Lang::tr{'add'}' /></td> | |
1980 | <td><input type='hidden' name='MODE' value='TIMECONSTRAINT' /></td> | |
1981 | <td><input type='submit' name='SUBMIT' value='$buttontext' /></td> | |
1982 | <td><input type='reset' name='ACTION' value='$Lang::tr{'urlfilter reset'}' /></td> | |
1983 | <td> </td> | |
1984 | <td><input type='button' name='return2main' value='$Lang::tr{'urlfilter back to main page'}' onClick='self.location.href="$ENV{'SCRIPT_NAME'}"'></td> | |
1985 | </tr> | |
1986 | </table> | |
1987 | <p> | |
1988 | <table width='100%'> | |
1989 | <tr> | |
1990 | <td width='1%' align='right'> <img src='/blob.gif' align='top' alt='*' /> </td> | |
1991 | <td><font class='base'>$Lang::tr{'this field may be blank'}</font></td> | |
1992 | </tr> | |
1993 | <tr> | |
1994 | <td width='1%' align='right'><img src='/blob.gif' align='top' alt='*' /><img src='/blob.gif' align='top' alt='*' /> </td> | |
1995 | <td><font class='base'>$Lang::tr{'urlfilter select multi'}</font></td> | |
1996 | </tr> | |
1997 | </table> | |
1998 | END | |
1999 | ; | |
2000 | ||
2001 | if ($tcsettings{'ACTION'} eq $Lang::tr{'edit'}) { | |
2002 | print "<input type='hidden' name='EDITING' value='$tcsettings{'ID'}' />\n"; | |
2003 | } else { | |
2004 | print "<input type='hidden' name='EDITING' value='no' />\n"; | |
2005 | } | |
2006 | ||
2007 | &Header::closebox(); | |
2008 | print "</form>\n"; | |
2009 | ||
2010 | &Header::openbox('100%', 'left', $Lang::tr{'current rules'}); | |
2011 | print <<END | |
2012 | <table width='100%'> | |
2013 | <tr> | |
2014 | <td width='5%' class='boldbase' align='center'><b>$Lang::tr{'urlfilter constraint definition'}</b></td> | |
2015 | <td width='10%' class='boldbase' align='center'><b>$Lang::tr{'urlfilter time space'}</b></td> | |
2016 | <td width='15%' class='boldbase' align='center'><b>$Lang::tr{'urlfilter src'}</b></td> | |
2017 | <td width='5%' class='boldbase' align='center'><b>$Lang::tr{'urlfilter dst'}</b></td> | |
1465b127 | 2018 | <td width='10%' class='boldbase' colspan='5' align='center'> </td> |
10e4f239 MT |
2019 | </tr> |
2020 | END | |
2021 | ; | |
2022 | ||
2023 | if ($tcsettings{'ACTION'} ne '' or $changed ne 'no') | |
2024 | { | |
2025 | open(FILE, $tcfile); | |
2026 | @tclist = <FILE>; | |
2027 | close(FILE); | |
2028 | } | |
2029 | ||
2030 | $id = 0; | |
2031 | foreach $line (@tclist) | |
2032 | { | |
2033 | $id++; | |
2034 | chomp($line); | |
2035 | @temp = split(/\,/,$line); | |
2036 | if($tcsettings{'ACTION'} eq $Lang::tr{'edit'} && $tcsettings{'ID'} eq $id) { | |
2037 | print "<tr bgcolor='$Header::colouryellow'>\n"; } | |
2038 | elsif ($id % 2) { | |
2039 | print "<tr bgcolor='$Header::table1colour'>\n"; } | |
2040 | else { | |
2041 | print "<tr bgcolor='$Header::table2colour'>\n"; } | |
2042 | if ($temp[0] eq 'within') { $temp[0]=$Lang::tr{'urlfilter constraint within'}; } else { $temp[0]=$Lang::tr{'urlfilter constraint outside'}; } | |
2043 | if ($temp[13] eq 'any') { $temp[13]=$Lang::tr{'urlfilter category all'}; } | |
2044 | if ($temp[15] eq 'on') { $gif='on.gif'; $toggle='off'; $gdesc=$Lang::tr{'click to disable'};} | |
2045 | else { $gif='off.gif'; $toggle='on'; $gdesc=$Lang::tr{'click to enable'}; } | |
2046 | if ($temp[14] eq 'block') { $led='led-red.gif'; $ldesc=$Lang::tr{'urlfilter block access'};} | |
2047 | else { $led='led-green.gif'; $ldesc=$Lang::tr{'urlfilter allow access'}; } | |
2048 | ||
2049 | undef $time; | |
2050 | if ($temp[1] eq 'on') { $time.=$Lang::tr{'urlfilter mon'}; } else { $time.='='; } | |
2051 | if ($temp[2] eq 'on') { $time.=$Lang::tr{'urlfilter tue'}; } else { $time.='='; } | |
2052 | if ($temp[3] eq 'on') { $time.=$Lang::tr{'urlfilter wed'}; } else { $time.='='; } | |
2053 | if ($temp[4] eq 'on') { $time.=$Lang::tr{'urlfilter thu'}; } else { $time.='='; } | |
2054 | if ($temp[5] eq 'on') { $time.=$Lang::tr{'urlfilter fri'}; } else { $time.='='; } | |
2055 | if ($temp[6] eq 'on') { $time.=$Lang::tr{'urlfilter sat'}; } else { $time.='='; } | |
2056 | if ($temp[7] eq 'on') { $time.=$Lang::tr{'urlfilter sun'}; } else { $time.='='; } | |
2057 | $time=$time.' '.$temp[8].':'.$temp[9].' to '.$temp[10].':'.$temp[11]; | |
2058 | ||
2059 | print <<END | |
2060 | <td align='center'>$temp[0]</td> | |
2061 | <td align='center' nowrap>$time</td> | |
2062 | <td align='center'>$temp[12]</td> | |
2063 | <td align='center'>$temp[13]</td> | |
2064 | <td align='center'><image src='/images/urlfilter/$led' alt='$ldesc'></td> | |
2065 | ||
2066 | <td align='center'> | |
2067 | <form method='post' name='frma$id' action='$ENV{'SCRIPT_NAME'}'> | |
2068 | <input type='image' name='$Lang::tr{'toggle enable disable'}' src='/images/$gif' title='$gdesc' alt='$gdesc' /> | |
2069 | <input type='hidden' name='MODE' value='TIMECONSTRAINT' /> | |
2070 | <input type='hidden' name='ID' value='$id' /> | |
2071 | <input type='hidden' name='ACTIVE' value='$toggle' /> | |
2072 | <input type='hidden' name='ACTION' value='$Lang::tr{'toggle enable disable'}' /> | |
2073 | </form> | |
2074 | </td> | |
2075 | ||
2076 | <td align='center'> | |
2077 | <form method='post' name='frmb$id' action='$ENV{'SCRIPT_NAME'}'> | |
2078 | <input type='image' name='$Lang::tr{'edit'}' src='/images/edit.gif' title='$Lang::tr{'edit'}' alt='$Lang::tr{'edit'}' /> | |
2079 | <input type='hidden' name='MODE' value='TIMECONSTRAINT' /> | |
2080 | <input type='hidden' name='ID' value='$id' /> | |
2081 | <input type='hidden' name='ACTION' value='$Lang::tr{'edit'}' /> | |
2082 | </form> | |
2083 | </td> | |
2084 | ||
2085 | <td align='center'> | |
2086 | <form method='post' name='frmc$id' action='$ENV{'SCRIPT_NAME'}'> | |
1465b127 MT |
2087 | <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'}' /> |
2088 | <input type='hidden' name='MODE' value='TIMECONSTRAINT' /> | |
2089 | <input type='hidden' name='ID' value='$id' /> | |
2090 | <input type='hidden' name='ACTION' value='$Lang::tr{'urlfilter copy rule'}' /> | |
2091 | </form> | |
2092 | </td> | |
2093 | ||
2094 | <td align='center'> | |
2095 | <form method='post' name='frmd$id' action='$ENV{'SCRIPT_NAME'}'> | |
10e4f239 MT |
2096 | <input type='image' name='$Lang::tr{'remove'}' src='/images/delete.gif' title='$Lang::tr{'remove'}' alt='$Lang::tr{'remove'}' /> |
2097 | <input type='hidden' name='MODE' value='TIMECONSTRAINT' /> | |
2098 | <input type='hidden' name='ID' value='$id' /> | |
2099 | <input type='hidden' name='ACTION' value='$Lang::tr{'remove'}' /> | |
2100 | </form> | |
2101 | </td> | |
2102 | ||
2103 | </tr> | |
2104 | END | |
2105 | ; | |
2106 | if($tcsettings{'ACTION'} eq $Lang::tr{'edit'} && $tcsettings{'ID'} eq $id) { | |
2107 | print "<tr bgcolor='$Header::colouryellow'>\n"; } | |
2108 | elsif ($id % 2) { | |
2109 | print "<tr bgcolor='$Header::table1colour'>\n"; } | |
2110 | else { | |
2111 | print "<tr bgcolor='$Header::table2colour'>\n"; } | |
2112 | print <<END | |
2113 | <td align='center' colspan='4'>$temp[16] | |
2114 | </td> | |
1465b127 | 2115 | <td align='center' colspan='5'> |
10e4f239 MT |
2116 | </td> |
2117 | </tr> | |
2118 | END | |
2119 | ; | |
2120 | } | |
2121 | ||
2122 | print "</table>\n"; | |
2123 | ||
2124 | # If the time constraint file contains entries, print entries and action icons | |
2125 | if (! -z "$tcfile") { | |
2126 | print <<END | |
2127 | ||
2128 | <table> | |
2129 | <tr> | |
2130 | <td class='boldbase'> <b>$Lang::tr{'legend'}:</b></td> | |
2131 | <td> <img src='/images/urlfilter/led-green.gif' alt='$Lang::tr{'urlfilter allow access'}' /></td> | |
2132 | <td class='base'>$Lang::tr{'urlfilter allow'}</td> | |
2133 | <td> <img src='/images/urlfilter/led-red.gif' alt='$Lang::tr{'urlfilter block access'}' /></td> | |
2134 | <td class='base'>$Lang::tr{'urlfilter block'}</td> | |
2135 | <td> <img src='/images/on.gif' alt='$Lang::tr{'click to disable'}' /></td> | |
2136 | <td class='base'>$Lang::tr{'click to disable'}</td> | |
2137 | <td> <img src='/images/off.gif' alt='$Lang::tr{'click to enable'}' /></td> | |
2138 | <td class='base'>$Lang::tr{'click to enable'}</td> | |
2139 | <td> <img src='/images/edit.gif' alt='$Lang::tr{'edit'}' /></td> | |
2140 | <td class='base'>$Lang::tr{'edit'}</td> | |
1465b127 MT |
2141 | <td> <img src='/images/urlfilter/copy.gif' alt='$Lang::tr{'urlfilter copy rule'}' /></td> |
2142 | <td class='base'>$Lang::tr{'urlfilter copy rule'}</td> | |
10e4f239 MT |
2143 | <td> <img src='/images/delete.gif' alt='$Lang::tr{'remove'}' /></td> |
2144 | <td class='base'>$Lang::tr{'remove'}</td> | |
2145 | </tr> | |
2146 | </table> | |
2147 | END | |
2148 | ; | |
2149 | } | |
2150 | ||
2151 | &Header::closebox(); | |
2152 | ||
2153 | } elsif ($uqsettings{'UQMODE'}) { | |
2154 | ||
2155 | #========================================================== | |
2156 | # | |
2157 | # Section: Set User Quota | |
2158 | # | |
2159 | #========================================================== | |
2160 | ||
2161 | print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n"; | |
2162 | ||
2163 | $buttontext = $Lang::tr{'urlfilter add rule'}; | |
2164 | if ($uqsettings{'ACTION'} eq $Lang::tr{'edit'}) { | |
2165 | &Header::openbox('100%', 'left', $Lang::tr{'urlfilter edit user quota rule'}.':'); | |
2166 | $buttontext = $Lang::tr{'urlfilter update rule'}; | |
2167 | } else { | |
2168 | &Header::openbox('100%', 'left', $Lang::tr{'urlfilter add new user quota rule'}.':'); | |
2169 | } | |
2170 | print <<END | |
2171 | ||
2172 | <table width='100%'> | |
2173 | <tr> | |
2174 | <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td> | |
2175 | </tr> | |
2176 | <tr> | |
2177 | <td class='base'>$Lang::tr{'urlfilter user time quota'}:</td> | |
2178 | <td><input type='text' name='TIME_QUOTA' value='$uqsettings{'TIME_QUOTA'}' size='5' /></td> | |
2179 | <td colspan='2' rowspan= '5' valign='top' class='base'> | |
2180 | <table cellpadding='0' cellspacing='0'> | |
2181 | <tr> | |
2182 | <!-- intentionally left empty --> | |
2183 | </tr> | |
2184 | <tr> | |
2185 | <td>$Lang::tr{'urlfilter assigned quota users'}:</td> | |
2186 | </tr> | |
2187 | <tr> | |
2188 | <!-- intentionally left empty --> | |
2189 | </tr> | |
2190 | <tr> | |
2191 | <!-- intentionally left empty --> | |
2192 | </tr> | |
2193 | <tr> | |
2194 | <td><textarea name='QUOTA_USERS' cols='32' rows='6' wrap='off'> | |
2195 | END | |
2196 | ; | |
2197 | ||
2198 | $uqsettings{'QUOTA_USERS'} =~ s/\|/\n/g; | |
2199 | print $uqsettings{'QUOTA_USERS'}; | |
2200 | ||
2201 | print <<END | |
2202 | </textarea></td> | |
2203 | </tr> | |
2204 | </table> | |
2205 | </td> | |
2206 | </tr> | |
2207 | <tr> | |
2208 | <td class='base'>$Lang::tr{'urlfilter activity detection'}:</td> | |
2209 | <td class='base'><select name='SPORADIC'> | |
2210 | <option value='0' $selected{'SPORADIC'}{'0'}>$Lang::tr{'urlfilter disabled'}</option> | |
2211 | <option value='300' $selected{'SPORADIC'}{'300'}>5 $Lang::tr{'urlfilter minutes'}</option> | |
2212 | <option value='900' $selected{'SPORADIC'}{'900'}>15 $Lang::tr{'urlfilter minutes'}</option> | |
2213 | </select></td> | |
2214 | </tr> | |
2215 | <tr> | |
2216 | <td class='base'>$Lang::tr{'urlfilter renewal period'}:</td> | |
2217 | <td class='base'><select name='RENEWAL'> | |
2218 | <option value='hourly' $selected{'RENEWAL'}{'hourly'}>$Lang::tr{'urlfilter hourly'}</option> | |
2219 | <option value='daily' $selected{'RENEWAL'}{'daily'}>$Lang::tr{'urlfilter daily'}</option> | |
2220 | <option value='weekly' $selected{'RENEWAL'}{'weekly'}>$Lang::tr{'urlfilter weekly'}</option> | |
2221 | </select></td> | |
2222 | </tr> | |
2223 | <tr> | |
2224 | <td colspan='2'> </td> | |
2225 | </tr> | |
2226 | <tr> | |
2227 | <td class='base'>$Lang::tr{'urlfilter enabled'}</td> | |
2228 | <td class='base'><input type='checkbox' name='ENABLEQUOTA' $checked{'ENABLEQUOTA'}{'on'} /></td> | |
2229 | </tr> | |
2230 | ||
2231 | </table> | |
2232 | <p> | |
2233 | ||
2234 | <table width='50%'> | |
2235 | <tr> | |
2236 | <td><input type='hidden' name='ACTION' value='$Lang::tr{'add'}' /></td> | |
2237 | <td><input type='hidden' name='MODE' value='USERQUOTA' /></td> | |
2238 | <td><input type='submit' name='SUBMIT' value='$buttontext' /></td> | |
2239 | <td><input type='reset' name='ACTION' value='$Lang::tr{'urlfilter reset'}' /></td> | |
2240 | <td> </td> | |
2241 | <td><input type='button' name='return2main' value='$Lang::tr{'urlfilter back to main page'}' onClick='self.location.href="$ENV{'SCRIPT_NAME'}"'></td> | |
2242 | </tr> | |
2243 | </table> | |
2244 | ||
2245 | <p> | |
2246 | END | |
2247 | ; | |
2248 | ||
2249 | if ($uqsettings{'ACTION'} eq $Lang::tr{'edit'}) { | |
2250 | print "<input type='hidden' name='EDITING' value='$uqsettings{'ID'}' />\n"; | |
2251 | } else { | |
2252 | print "<input type='hidden' name='EDITING' value='no' />\n"; | |
2253 | } | |
2254 | ||
2255 | &Header::closebox(); | |
2256 | print "</form>\n"; | |
2257 | ||
2258 | &Header::openbox('100%', 'left', $Lang::tr{'current rules'}); | |
2259 | print <<END | |
2260 | <table width='100%'> | |
2261 | <tr> | |
2262 | <td width='15%' class='boldbase' align='center'><b><nobr>$Lang::tr{'urlfilter time quota'}</nobr></b></td> | |
2263 | <td width='15%' class='boldbase' align='center'><b><nobr>$Lang::tr{'urlfilter activity detection'}</nobr></b></td> | |
2264 | <td width='10%' class='boldbase' align='center'><b>$Lang::tr{'urlfilter renewal'}</b></td> | |
2265 | <td class='boldbase' align='center'><b>$Lang::tr{'urlfilter assigned users'}</b></td> | |
2266 | <td width='20%' class='boldbase' colspan='4' align='center'> </td> | |
2267 | </tr> | |
2268 | END | |
2269 | ; | |
2270 | ||
2271 | if ($uqsettings{'ACTION'} ne '' or $changed ne 'no') | |
2272 | { | |
2273 | open(FILE, $uqfile); | |
2274 | @uqlist = <FILE>; | |
2275 | close(FILE); | |
2276 | } | |
2277 | ||
2278 | $id = 0; | |
2279 | foreach $line (@uqlist) | |
2280 | { | |
2281 | $id++; | |
2282 | chomp($line); | |
2283 | @temp = split(/\,/,$line); | |
2284 | if($uqsettings{'ACTION'} eq $Lang::tr{'edit'} && $uqsettings{'ID'} eq $id) { | |
2285 | print "<tr bgcolor='$Header::colouryellow'>\n"; } | |
2286 | elsif ($id % 2) { | |
2287 | print "<tr bgcolor='$Header::table1colour'>\n"; } | |
2288 | else { | |
2289 | print "<tr bgcolor='$Header::table2colour'>\n"; } | |
2290 | if ($temp[4] eq 'on') { $gif='on.gif'; $toggle='off'; $gdesc=$Lang::tr{'click to disable'};} | |
2291 | else { $gif='off.gif'; $toggle='on'; $gdesc=$Lang::tr{'click to enable'}; } | |
2292 | ||
2293 | $temp[5] = $temp[1]; | |
2294 | if ($temp[1] eq '0') { $temp[5] = $Lang::tr{'urlfilter disabled'} } else { $temp[5] = ($temp[5]/60).' '.$Lang::tr{'urlfilter minutes'} } | |
2295 | $_ = $temp[3]; s/\|/, /g; $temp[6] = $_; | |
2296 | ||
2297 | print <<END | |
2298 | <td align='center'>$temp[0] $Lang::tr{'urlfilter minutes'}</td> | |
2299 | <td align='center'>$temp[5]</td> | |
2300 | <td align='center'>$Lang::tr{'urlfilter '.$temp[2]}</td> | |
2301 | <td align='center'>$temp[6]</td> | |
2302 | ||
2303 | <td align='center'> | |
2304 | <form method='post' name='frma$id' action='$ENV{'SCRIPT_NAME'}'> | |
2305 | <input type='image' name='$Lang::tr{'toggle enable disable'}' src='/images/$gif' title='$gdesc' alt='$gdesc' /> | |
2306 | <input type='hidden' name='MODE' value='USERQUOTA' /> | |
2307 | <input type='hidden' name='ID' value='$id' /> | |
2308 | <input type='hidden' name='ACTIVE' value='$toggle' /> | |
2309 | <input type='hidden' name='ACTION' value='$Lang::tr{'toggle enable disable'}' /> | |
2310 | </form> | |
2311 | </td> | |
2312 | ||
2313 | <td align='center'> | |
2314 | <form method='post' name='frmb$id' action='$ENV{'SCRIPT_NAME'}'> | |
2315 | <input type='image' name='$Lang::tr{'edit'}' src='/images/edit.gif' title='$Lang::tr{'edit'}' alt='$Lang::tr{'edit'}' /> | |
2316 | <input type='hidden' name='MODE' value='USERQUOTA' /> | |
2317 | <input type='hidden' name='ID' value='$id' /> | |
2318 | <input type='hidden' name='ACTION' value='$Lang::tr{'edit'}' /> | |
2319 | </form> | |
2320 | </td> | |
2321 | ||
2322 | <td align='center'> | |
2323 | <form method='post' name='frmc$id' action='$ENV{'SCRIPT_NAME'}'> | |
2324 | <input type='image' name='$Lang::tr{'remove'}' src='/images/delete.gif' title='$Lang::tr{'remove'}' alt='$Lang::tr{'remove'}' /> | |
2325 | <input type='hidden' name='MODE' value='USERQUOTA' /> | |
2326 | <input type='hidden' name='ID' value='$id' /> | |
2327 | <input type='hidden' name='ACTION' value='$Lang::tr{'remove'}' /> | |
2328 | </form> | |
2329 | </td> | |
2330 | ||
2331 | </tr> | |
2332 | END | |
2333 | ; | |
2334 | } | |
2335 | ||
2336 | print "</table>\n"; | |
2337 | ||
2338 | # If the user quota file contains entries, print entries and action icons | |
2339 | if (! -z "$uqfile") { | |
2340 | print <<END | |
2341 | ||
2342 | <table> | |
2343 | <tr> | |
2344 | <td class='boldbase'> <b>$Lang::tr{'legend'}:</b></td> | |
2345 | <td> <img src='/images/on.gif' alt='$Lang::tr{'click to disable'}' /></td> | |
2346 | <td class='base'>$Lang::tr{'click to disable'}</td> | |
2347 | <td> <img src='/images/off.gif' alt='$Lang::tr{'click to enable'}' /></td> | |
2348 | <td class='base'>$Lang::tr{'click to enable'}</td> | |
2349 | <td> <img src='/images/edit.gif' alt='$Lang::tr{'edit'}' /></td> | |
2350 | <td class='base'>$Lang::tr{'edit'}</td> | |
2351 | <td> <img src='/images/delete.gif' alt='$Lang::tr{'remove'}' /></td> | |
2352 | <td class='base'>$Lang::tr{'remove'}</td> | |
2353 | </tr> | |
2354 | </table> | |
2355 | END | |
2356 | ; | |
2357 | } | |
2358 | ||
2359 | &Header::closebox(); | |
2360 | ||
2361 | } else { | |
2362 | ||
2363 | #========================================================== | |
2364 | # | |
2365 | # Section: Blacklist editor | |
2366 | # | |
2367 | #========================================================== | |
2368 | ||
2369 | print "<form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>\n"; | |
2370 | ||
2371 | &Header::openbox('100%', 'left', $Lang::tr{'urlfilter urlfilter blacklist editor'}.':'); | |
2372 | ||
2373 | print <<END | |
2374 | ||
2375 | <table width='100%'> | |
2376 | <tr> | |
2377 | <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td> | |
2378 | </tr> | |
2379 | <tr> | |
2380 | <td class='base'><b>$Lang::tr{'urlfilter blacklist name'}</b></td> | |
2381 | </tr> | |
2382 | <tr> | |
2383 | <td class='base'>$Lang::tr{'urlfilter blacklist category name'}:</td> | |
2384 | <td><input type='text' name='BE_NAME' value='$besettings{'BE_NAME'}' size='12' /></td> | |
2385 | </tr> | |
2386 | </table> | |
2387 | <hr size='1'> | |
2388 | <table width='100%'> | |
2389 | <tr> | |
2390 | <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='20%'></td> | |
2391 | </tr> | |
2392 | <tr> | |
2393 | <td class='base' colspan='4'><b>$Lang::tr{'urlfilter edit domains urls expressions'}</b></td> | |
2394 | </tr> | |
2395 | <tr> | |
2396 | <td colspan='2'>$Lang::tr{'urlfilter domains'}</td> | |
2397 | <td colspan='2'>$Lang::tr{'urlfilter urls'}</td> | |
2398 | </tr> | |
2399 | <tr> | |
2400 | <td colspan='2'><textarea name='BE_DOMAINS' cols='38' rows='10' wrap='off'> | |
2401 | END | |
2402 | ; | |
2403 | ||
2404 | print $besettings{'BE_DOMAINS'}; | |
2405 | ||
2406 | print <<END | |
2407 | </textarea></td> | |
2408 | <td colspan='2'><textarea name='BE_URLS' cols='38' rows='10' wrap='off'> | |
2409 | END | |
2410 | ; | |
2411 | ||
2412 | print $besettings{'BE_URLS'}; | |
2413 | ||
2414 | print <<END | |
2415 | </textarea></td> | |
2416 | </tr> | |
2417 | <tr> | |
2418 | <td colspan='4'>$Lang::tr{'urlfilter expressions'}</td> | |
2419 | </tr> | |
2420 | <tr> | |
2421 | <td colspan='4'><textarea name='BE_EXPRESSIONS' cols='80' rows='3' wrap='off'> | |
2422 | END | |
2423 | ; | |
2424 | ||
2425 | print $besettings{'BE_EXPRESSIONS'}; | |
2426 | ||
2427 | print <<END | |
2428 | </textarea></td> | |
2429 | </tr> | |
2430 | </table> | |
2431 | <hr size='1'> | |
2432 | <table width='100%'> | |
2433 | <tr> | |
2434 | <td class='base' colspan='4'><b>$Lang::tr{'urlfilter load blacklist'}</b></td> | |
2435 | </tr> | |
2436 | <tr> | |
2437 | <td width='25%' class='base'>$Lang::tr{'urlfilter select blacklist'}:</td> | |
2438 | <td width='20%' class='base'> | |
2439 | <select name='BE_BLACKLIST'> | |
2440 | END | |
2441 | ; | |
2442 | ||
2443 | &readblockcategories; | |
2444 | foreach (@categories) | |
2445 | { | |
2446 | print "<option value='$_' $selected{'BE_BLACKLIST'}{$_}>$_</option>\n"; | |
2447 | } | |
2448 | ||
2449 | print <<END | |
2450 | </select> | |
2451 | </td> | |
2452 | <td> </td> | |
2453 | <td> </td> | |
2454 | <tr> | |
2455 | <td colpsan='4'><input type='submit' name='ACTION' value='$Lang::tr{'urlfilter load blacklist'}' /></td> | |
2456 | </tr> | |
2457 | </tr> | |
2458 | </table> | |
2459 | <hr size='1'> | |
2460 | <table width='100%'> | |
2461 | <tr> | |
2462 | <td class='base' colspan='4'><b>$Lang::tr{'urlfilter import blacklist'}</b></td> | |
2463 | </tr> | |
2464 | <tr> | |
2465 | <td colspan='4'>$Lang::tr{'urlfilter import text'}:</td> | |
2466 | </tr> | |
2467 | <tr> | |
2468 | <td nowrap><input type='file' name='IMPORTFILE' size='40' /> <input type='submit' name='ACTION' value='$Lang::tr{'urlfilter import blacklist'}' /></td> | |
2469 | <td><input type='hidden' name='MODE' value='BLACKLIST_EDITOR' /></td> | |
2470 | </tr> | |
2471 | </table> | |
2472 | <hr size='1'> | |
2473 | <table width='100%'> | |
2474 | <tr> | |
2475 | <td class='base' colspan='4'><b>$Lang::tr{'urlfilter export blacklist'}</b></td> | |
2476 | </tr> | |
2477 | <tr> | |
2478 | <td><input type='submit' name='ACTION' value='$Lang::tr{'urlfilter export blacklist'}' /></td> | |
2479 | </tr> | |
2480 | </table> | |
2481 | <hr size='1'> | |
2482 | <table width='100%'> | |
2483 | <tr> | |
2484 | <td class='base' colspan='4'><b>$Lang::tr{'urlfilter install blacklist'}</b></td> | |
2485 | </tr> | |
2486 | <tr> | |
2487 | <td width='25%' class='base'>$Lang::tr{'urlfilter dont restart urlfilter'}:</td> | |
2488 | <td width='20%' class='base'><input type='checkbox' name='NORESTART' $checked{'NORESTART'}{'on'} /></td> | |
2489 | <td> </td> | |
2490 | <td> </td> | |
2491 | </tr> | |
2492 | <tr> | |
2493 | <td><input type='submit' name='ACTION' value='$Lang::tr{'urlfilter install blacklist'}' /></td> | |
2494 | </tr> | |
2495 | <tr> | |
2496 | <td class='base' colspan='4'><br>$Lang::tr{'urlfilter install information'}</td> | |
2497 | </tr> | |
2498 | </table> | |
2499 | <hr size='1'> | |
2500 | <table width='20%'> | |
2501 | <tr> | |
2502 | <td><input type='reset' name='ACTION' value='$Lang::tr{'urlfilter reset'}' /></td> | |
2503 | <td> </td> | |
2504 | <td><input type='button' name='return2main' value='$Lang::tr{'urlfilter back to main page'}' onClick='self.location.href="$ENV{'SCRIPT_NAME'}"'></td> | |
2505 | </tr> | |
2506 | </table> | |
2507 | ||
2508 | END | |
2509 | ; | |
2510 | ||
2511 | &Header::closebox(); | |
2512 | print "</form>\n"; | |
2513 | ||
2514 | } | |
2515 | ||
2516 | &Header::closebigbox(); | |
2517 | ||
2518 | &Header::closepage(); | |
2519 | ||
2520 | # ------------------------------------------------------------------- | |
2521 | ||
2522 | sub savesettings | |
2523 | { | |
1465b127 MT |
2524 | # transform to pre1.8 client definitions |
2525 | @clients = split(/\n/,$filtersettings{'UNFILTERED_CLIENTS'}); | |
2526 | undef $filtersettings{'UNFILTERED_CLIENTS'}; | |
2527 | foreach(@clients) | |
2528 | { | |
2529 | s/^\s+//g; s/\s+$//g; s/\s+-\s+/-/g; s/\s+/ /g; s/\n//g; | |
2530 | $filtersettings{'UNFILTERED_CLIENTS'} .= "$_ "; | |
2531 | } | |
2532 | $filtersettings{'UNFILTERED_CLIENTS'} =~ s/\s+$//; | |
2533 | ||
2534 | # transform to pre1.8 client definitions | |
2535 | @clients = split(/\n/,$filtersettings{'BANNED_CLIENTS'}); | |
2536 | undef $filtersettings{'BANNED_CLIENTS'}; | |
2537 | foreach(@clients) | |
2538 | { | |
2539 | s/^\s+//g; s/\s+$//g; s/\s+-\s+/-/g; s/\s+/ /g; s/\n//g; | |
2540 | $filtersettings{'BANNED_CLIENTS'} .= "$_ "; | |
2541 | } | |
2542 | $filtersettings{'BANNED_CLIENTS'} =~ s/\s+$//; | |
2543 | ||
10e4f239 MT |
2544 | &writeconfigfile; |
2545 | ||
2546 | delete $filtersettings{'CUSTOM_BLACK_DOMAINS'}; | |
2547 | delete $filtersettings{'CUSTOM_BLACK_URLS'}; | |
2548 | delete $filtersettings{'CUSTOM_WHITE_DOMAINS'}; | |
2549 | delete $filtersettings{'CUSTOM_WHITE_URLS'}; | |
2550 | delete $filtersettings{'CUSTOM_EXPRESSIONS'}; | |
2551 | delete $filtersettings{'BACKGROUND'}; | |
2552 | delete $filtersettings{'UPDATEFILE'}; | |
2553 | ||
2554 | &General::writehash("${General::swroot}/urlfilter/settings", \%filtersettings); | |
2555 | } | |
2556 | ||
2557 | # ------------------------------------------------------------------- | |
2558 | ||
2559 | sub readblockcategories | |
2560 | { | |
2561 | undef(@categories); | |
1465b127 MT |
2562 | |
2563 | &getblockcategory ($dbdir); | |
2564 | ||
2565 | foreach (@categories) { $_ = substr($_,length($dbdir)+1); } | |
10e4f239 MT |
2566 | |
2567 | @filtergroups = @categories; | |
1465b127 | 2568 | |
10e4f239 | 2569 | foreach (@filtergroups) { |
1465b127 | 2570 | s/\//_SLASH_/g; |
10e4f239 MT |
2571 | tr/a-z/A-Z/; |
2572 | $_ = "FILTER_".$_; | |
2573 | } | |
2574 | } | |
2575 | ||
2576 | # ------------------------------------------------------------------- | |
2577 | ||
1465b127 MT |
2578 | sub getblockcategory |
2579 | { | |
2580 | foreach $category (<$_[0]/*>) | |
2581 | { | |
2582 | if (-d $category) | |
2583 | { | |
2584 | if ((-e "$category/domains") || (-e "$category/urls")) | |
2585 | { | |
2586 | unless ($category =~ /\bcustom\b/) { push(@categories,$category); } | |
2587 | } | |
2588 | &getblockcategory ($category); | |
2589 | } | |
2590 | } | |
2591 | } | |
2592 | ||
2593 | # ------------------------------------------------------------------- | |
2594 | ||
10e4f239 MT |
2595 | sub readcustomlists |
2596 | { | |
2597 | if (-e "$dbdir/custom/blocked/domains") { | |
2598 | open(FILE,"$dbdir/custom/blocked/domains"); | |
2599 | delete $filtersettings{'CUSTOM_BLACK_DOMAINS'}; | |
2600 | while (<FILE>) { $filtersettings{'CUSTOM_BLACK_DOMAINS'} .= $_ }; | |
2601 | close(FILE); | |
2602 | } | |
2603 | ||
2604 | if (-e "$dbdir/custom/blocked/urls") { | |
2605 | open(FILE,"$dbdir/custom/blocked/urls"); | |
2606 | delete $filtersettings{'CUSTOM_BLACK_URLS'}; | |
2607 | while (<FILE>) { $filtersettings{'CUSTOM_BLACK_URLS'} .= $_ }; | |
2608 | close(FILE); | |
2609 | } | |
2610 | ||
2611 | if (-e "$dbdir/custom/blocked/expressions") { | |
2612 | open(FILE,"$dbdir/custom/blocked/expressions"); | |
2613 | delete $filtersettings{'CUSTOM_EXPRESSIONS'}; | |
2614 | while (<FILE>) { $filtersettings{'CUSTOM_EXPRESSIONS'} .= $_ }; | |
2615 | close(FILE); | |
2616 | } | |
2617 | ||
2618 | if (-e "$dbdir/custom/allowed/domains") { | |
2619 | open(FILE,"$dbdir/custom/allowed/domains"); | |
2620 | delete $filtersettings{'CUSTOM_WHITE_DOMAINS'}; | |
2621 | while (<FILE>) { $filtersettings{'CUSTOM_WHITE_DOMAINS'} .= $_ }; | |
2622 | close(FILE); | |
2623 | } | |
2624 | if (-e "$dbdir/custom/allowed/urls") { | |
2625 | open(FILE,"$dbdir/custom/allowed/urls"); | |
2626 | delete $filtersettings{'CUSTOM_WHITE_URLS'}; | |
2627 | while (<FILE>) { $filtersettings{'CUSTOM_WHITE_URLS'} .= $_ }; | |
2628 | close(FILE); | |
2629 | } | |
2630 | } | |
2631 | ||
2632 | # ------------------------------------------------------------------- | |
2633 | ||
2634 | sub aggregatedconstraints | |
2635 | { | |
2636 | my $aggregated; | |
2637 | my @old; | |
2638 | my @new; | |
2639 | my @tmp1; | |
2640 | my @tmp2; | |
2641 | my $x; | |
2642 | ||
2643 | if (-e $tcfile) | |
2644 | { | |
2645 | open(TC, $tcfile); | |
2646 | @old = <TC>; | |
2647 | close(TC); | |
2648 | ||
2649 | while (@old > 0) | |
2650 | { | |
2651 | $aggregated = 0; | |
2652 | $x = shift(@old); | |
2653 | chomp($x); | |
2654 | @tmp1 = split(/\,/,$x); | |
2655 | $tmp1[16] = ''; | |
2656 | foreach (@new) | |
2657 | { | |
2658 | @tmp2 = split(/\,/); | |
1465b127 | 2659 | if (($tmp1[15] eq 'on') && ($tmp2[15] eq 'on')) |
10e4f239 MT |
2660 | { |
2661 | if (($tmp1[0] eq $tmp2[0]) && ($tmp1[12] eq $tmp2[12]) && ($tmp1[13] eq $tmp2[13]) && ($tmp1[14] eq $tmp2[14])) | |
2662 | { | |
2663 | $aggregated = 1; | |
2664 | $tmp2[16] .= " weekly "; | |
2665 | if ($tmp1[1] eq 'on') { $tmp2[16] .= "m"; } | |
2666 | if ($tmp1[2] eq 'on') { $tmp2[16] .= "t"; } | |
2667 | if ($tmp1[3] eq 'on') { $tmp2[16] .= "w"; } | |
2668 | if ($tmp1[4] eq 'on') { $tmp2[16] .= "h"; } | |
2669 | if ($tmp1[5] eq 'on') { $tmp2[16] .= "f"; } | |
2670 | if ($tmp1[6] eq 'on') { $tmp2[16] .= "a"; } | |
2671 | if ($tmp1[7] eq 'on') { $tmp2[16] .= "s"; } | |
2672 | $tmp2[16] .= " $tmp1[8]:$tmp1[9]-$tmp1[10]:$tmp1[11]\n"; | |
2673 | $_ = join(",",@tmp2); | |
2674 | } | |
2675 | ||
2676 | } | |
2677 | } | |
2678 | if (!$aggregated) | |
2679 | { | |
2680 | $tmp1[16] .= " weekly "; | |
2681 | if ($tmp1[1] eq 'on') { $tmp1[16] .= "m"; } | |
2682 | if ($tmp1[2] eq 'on') { $tmp1[16] .= "t"; } | |
2683 | if ($tmp1[3] eq 'on') { $tmp1[16] .= "w"; } | |
2684 | if ($tmp1[4] eq 'on') { $tmp1[16] .= "h"; } | |
2685 | if ($tmp1[5] eq 'on') { $tmp1[16] .= "f"; } | |
2686 | if ($tmp1[6] eq 'on') { $tmp1[16] .= "a"; } | |
2687 | if ($tmp1[7] eq 'on') { $tmp1[16] .= "s"; } | |
2688 | $tmp1[16] .= " $tmp1[8]:$tmp1[9]-$tmp1[10]:$tmp1[11]\n"; | |
2689 | $x = join(",",@tmp1); | |
2690 | push(@new,$x); | |
2691 | } | |
2692 | } | |
2693 | } | |
2694 | ||
2695 | return @new; | |
2696 | ||
2697 | } | |
2698 | ||
2699 | # ------------------------------------------------------------------- | |
2700 | ||
1465b127 MT |
2701 | sub setpermissions |
2702 | { | |
2703 | my $bldir = $_[0]; | |
2704 | ||
2705 | foreach $category (<$bldir/*>) | |
2706 | { | |
2707 | if (-d $category){ | |
2708 | system("chmod 755 $category &> /dev/null"); | |
2709 | foreach $blacklist (<$category/*>) | |
2710 | { | |
2711 | if (-f $blacklist) { system("chmod 644 $blacklist &> /dev/null"); } | |
2712 | if (-d $blacklist) { system("chmod 755 $blacklist &> /dev/null"); } | |
2713 | } | |
2714 | system("chmod 666 $category/*.db &> /dev/null"); | |
2715 | &setpermissions ($category); | |
2716 | } | |
2717 | } | |
2718 | } | |
2719 | ||
2720 | # ------------------------------------------------------------------- | |
2721 | ||
10e4f239 MT |
2722 | sub writeconfigfile |
2723 | { | |
2724 | 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\)\$"; | |
1465b127 | 2725 | my $audiovideo = "\\.\(aiff|asf|avi|dif|divx|mov|movie|mp3|mpe?g?|mpv2|ogg|ra?m|snd|qt|wav|wma|wmf|wmv\)\$"; |
10e4f239 MT |
2726 | my $archives = "\\.\(bin|bz2|cab|cdr|dmg|gz|hqx|rar|smi|sit|sea|tar|tgz|zip\)\$"; |
2727 | ||
2728 | my $ident = " anonymous"; | |
2729 | ||
2730 | my $defaultrule=''; | |
2731 | my $tcrule=''; | |
2732 | my $redirect=''; | |
2733 | my $qredirect=''; | |
2734 | ||
2735 | my $idx; | |
2736 | ||
2737 | my @ec=(); | |
2738 | my @tc=(); | |
2739 | my @uq=(); | |
2740 | ||
2741 | if (!(-d "$dbdir/custom")) { mkdir("$dbdir/custom") } | |
2742 | if (!(-d "$dbdir/custom/blocked")) { mkdir("$dbdir/custom/blocked") } | |
2743 | if (!(-d "$dbdir/custom/allowed")) { mkdir("$dbdir/custom/allowed") } | |
2744 | ||
2745 | open(FILE, ">/$dbdir/custom/blocked/domains"); | |
2746 | print FILE $filtersettings{'CUSTOM_BLACK_DOMAINS'}; | |
2747 | close(FILE); | |
2748 | open(FILE, ">/$dbdir/custom/blocked/urls"); | |
2749 | print FILE $filtersettings{'CUSTOM_BLACK_URLS'}; | |
2750 | close(FILE); | |
2751 | open(FILE, ">/$dbdir/custom/blocked/expressions"); | |
2752 | print FILE $filtersettings{'CUSTOM_EXPRESSIONS'}; | |
2753 | close(FILE); | |
2754 | open(FILE, ">/$dbdir/custom/blocked/files"); | |
2755 | if ($filtersettings{'BLOCK_EXECUTABLES'} eq 'on') { print FILE "$executables\n"; } | |
2756 | if ($filtersettings{'BLOCK_AUDIO-VIDEO'} eq 'on') { print FILE "$audiovideo\n"; } | |
2757 | if ($filtersettings{'BLOCK_ARCHIVES'} eq 'on') { print FILE "$archives\n"; } | |
2758 | close(FILE); | |
2759 | open(FILE, ">/$dbdir/custom/allowed/domains"); | |
2760 | print FILE $filtersettings{'CUSTOM_WHITE_DOMAINS'}; | |
2761 | close(FILE); | |
2762 | open(FILE, ">/$dbdir/custom/allowed/urls"); | |
2763 | print FILE $filtersettings{'CUSTOM_WHITE_URLS'}; | |
2764 | close(FILE); | |
2765 | ||
2766 | if ($filtersettings{'ENABLE_USERNAME_LOG'} eq 'on') { $ident = ""; } | |
2767 | ||
2768 | if ($filtersettings{'REDIRECT_PAGE'} eq '') | |
2769 | { | |
2770 | if (($filtersettings{'SHOW_CATEGORY'} eq 'on') || ($filtersettings{'SHOW_URL'} eq 'on') || ($filtersettings{'SHOW_IP'} eq 'on')) { | |
2771 | if ($filtersettings{'SHOW_CATEGORY'} eq 'on') { $redirect .= "&category=%t"; } | |
2772 | if ($filtersettings{'SHOW_URL'} eq 'on') { $redirect .= "&url=%u"; } | |
2773 | if ($filtersettings{'SHOW_IP'} eq 'on') { $redirect .= "&ip=%a"; } | |
2774 | $redirect =~ s/^&/?/; | |
d47ad587 | 2775 | $redirect = "http:\/\/$netsettings{'GREEN_ADDRESS'}:$http_port\/redirect.cgi".$redirect; |
10e4f239 | 2776 | } else { |
1465b127 | 2777 | $redirect="http:\/\/$netsettings{'GREEN_ADDRESS'}:$http_port\/redirect.cgi"; |
10e4f239 MT |
2778 | } |
2779 | } else { $redirect=$filtersettings{'REDIRECT_PAGE'}; } | |
2780 | ||
2781 | if ($filtersettings{'ENABLE_DNSERROR'} eq 'on') { $redirect = "302:http://0.0.0.0"; } | |
2782 | ||
2783 | undef $defaultrule; | |
2784 | ||
2785 | if ($filtersettings{'ENABLE_CUSTOM_WHITELIST'} eq 'on') | |
2786 | { | |
2787 | $defaultrule .= "custom-allowed "; | |
2788 | } | |
2789 | if ($filtersettings{'BLOCK_ALL'} eq 'on') | |
2790 | { | |
2791 | $defaultrule .= "none"; | |
2792 | } | |
2793 | else | |
2794 | { | |
2795 | if ($filtersettings{'BLOCK_IP_ADDR'} eq 'on') | |
2796 | { | |
2797 | $defaultrule .= "!in-addr "; | |
2798 | } | |
2799 | for ($i=0; $i<=@filtergroups; $i++) { | |
2800 | if ($filtersettings{@filtergroups[$i]} eq 'on') | |
2801 | { | |
2802 | $defaultrule .= "!@categories[$i] "; | |
2803 | } | |
2804 | } | |
2805 | if ($filtersettings{'ENABLE_CUSTOM_BLACKLIST'} eq 'on') | |
2806 | { | |
2807 | $defaultrule .= "!custom-blocked "; | |
2808 | } | |
2809 | if ($filtersettings{'ENABLE_CUSTOM_EXPRESSIONS'} eq 'on') | |
2810 | { | |
2811 | $defaultrule .= "!custom-expressions "; | |
2812 | } | |
2813 | if (($filtersettings{'BLOCK_EXECUTABLES'} eq 'on') || | |
2814 | ($filtersettings{'BLOCK_AUDIO-VIDEO'} eq 'on') || | |
2815 | ($filtersettings{'BLOCK_ARCHIVES'} eq 'on')) | |
2816 | { | |
2817 | $defaultrule .= "!files "; | |
2818 | } | |
2819 | $defaultrule .= "any"; | |
2820 | } | |
2821 | ||
1465b127 MT |
2822 | $defaultrule =~ s/\//_/g; |
2823 | ||
10e4f239 MT |
2824 | open(FILE, ">${General::swroot}/urlfilter/squidGuard.conf") or die "Unable to write squidGuard.conf file"; |
2825 | flock(FILE, 2); | |
2826 | ||
2827 | print FILE "logdir /var/log/squidGuard\n"; | |
2828 | print FILE "dbhome $dbdir\n\n"; | |
2829 | ||
2830 | undef @repositoryfiles; | |
2831 | if ($filtersettings{'ENABLE_REWRITE'} eq 'on') | |
2832 | { | |
2833 | @repositorylist = <$repository/*>; | |
2834 | foreach (@repositorylist) | |
2835 | { | |
2836 | if (!-d) { push(@repositoryfiles,substr($_,rindex($_,"/")+1)); } | |
2837 | } | |
2838 | } | |
2839 | ||
2840 | if ((($filtersettings{'ENABLE_REWRITE'} eq 'on') && (@repositoryfiles)) || ($filtersettings{'ENABLE_SAFESEARCH'} eq 'on')) | |
2841 | { | |
1465b127 | 2842 | print FILE "rewrite rew-rule-1 {\n"; |
10e4f239 MT |
2843 | |
2844 | if (($filtersettings{'ENABLE_REWRITE'} eq 'on') && (@repositoryfiles)) | |
2845 | { | |
2846 | print FILE " # rewrite localfiles\n"; | |
2847 | foreach (@repositoryfiles) | |
2848 | { | |
1465b127 | 2849 | print FILE " s@.*/$_\$\@http://$netsettings{'GREEN_ADDRESS'}:$http_port/repository/$_\@i\n"; |
10e4f239 MT |
2850 | } |
2851 | } | |
2852 | ||
2853 | if ($filtersettings{'ENABLE_SAFESEARCH'} eq 'on') | |
2854 | { | |
2855 | print FILE " # rewrite safesearch\n"; | |
2856 | print FILE " s@(.*\\Wgoogle\\.\\w+/(webhp|search|imghp|images|grphp|groups|frghp|froogle)\\?)(.*)(\\bsafe=\\w+)(.*)\@\\1\\3safe=strict\\5\@i\n"; | |
2857 | print FILE " s@(.*\\Wgoogle\\.\\w+/(webhp|search|imghp|images|grphp|groups|frghp|froogle)\\?)(.*)\@\\1safe=strict\\\&\\3\@i\n"; | |
2858 | print FILE " s@(.*\\Wsearch\\.yahoo\\.\\w+/search\\W)(.*)(\\bvm=\\w+)(.*)\@\\1\\2vm=r\\4\@i\n"; | |
2859 | print FILE " s@(.*\\Wsearch\\.yahoo\\.\\w+/search\\W.*)\@\\1\\\&vm=r\@i\n"; | |
2860 | print FILE " s@(.*\\Walltheweb\\.com/customize\\?)(.*)(\\bcopt_offensive=\\w+)(.*)\@\\1\\2copt_offensive=on\\4\@i\n"; | |
2861 | } | |
2862 | ||
2863 | print FILE "}\n\n"; | |
2864 | ||
2865 | if ((!($filtersettings{'UNFILTERED_CLIENTS'} eq '')) && ($filtersettings{'ENABLE_SAFESEARCH'} eq 'on')) { | |
1465b127 | 2866 | print FILE "rewrite rew-rule-2 {\n"; |
10e4f239 MT |
2867 | if (($filtersettings{'ENABLE_REWRITE'} eq 'on') && (@repositoryfiles)) |
2868 | { | |
2869 | print FILE " # rewrite localfiles\n"; | |
2870 | foreach (@repositoryfiles) | |
2871 | { | |
1465b127 | 2872 | print FILE " s@.*/$_\$\@http://$netsettings{'GREEN_ADDRESS'}:$http_port/repository/$_\@i\n"; |
10e4f239 MT |
2873 | } |
2874 | } else { | |
2875 | print FILE " # rewrite nothing\n"; | |
2876 | } | |
2877 | print FILE "}\n\n"; | |
2878 | } | |
2879 | } | |
2880 | ||
1465b127 MT |
2881 | if (!($filtersettings{'UNFILTERED_CLIENTS'} eq '')) { |
2882 | print FILE "src unfiltered {\n"; | |
2883 | print FILE " ip $filtersettings{'UNFILTERED_CLIENTS'}\n"; | |
2884 | print FILE "}\n\n"; | |
2885 | } | |
2886 | if (!($filtersettings{'BANNED_CLIENTS'} eq '')) { | |
2887 | print FILE "src banned {\n"; | |
2888 | print FILE " ip $filtersettings{'BANNED_CLIENTS'}\n"; | |
2889 | if ($filtersettings{'ENABLE_LOG'} eq 'on') | |
2890 | { | |
2891 | if ($filtersettings{'ENABLE_CATEGORY_LOG'} eq 'on') | |
2892 | { | |
2893 | print FILE " logfile ".$ident." banned.log\n"; | |
2894 | } else { | |
2895 | print FILE " logfile ".$ident." urlfilter.log\n"; | |
2896 | } | |
2897 | } | |
2898 | print FILE "}\n\n"; | |
2899 | } | |
2900 | ||
10e4f239 MT |
2901 | if (-e $uqfile) |
2902 | { | |
2903 | open(UQ, $uqfile); | |
2904 | @uqlist = <UQ>; | |
2905 | close(UQ); | |
2906 | ||
2907 | if (@uqlist > 0) | |
2908 | { | |
2909 | $idx=0; | |
2910 | foreach (@uqlist) | |
2911 | { | |
2912 | chomp; | |
2913 | @uq = split(/\,/); | |
2914 | if ($uq[4] eq 'on') | |
2915 | { | |
2916 | $idx++; | |
2917 | $uq[0] = $uq[0] * 60; | |
2918 | if ($uq[1] eq '0') { | |
2919 | if ($uq[2] eq 'hourly') { $uq[1] = 3600 } | |
2920 | if ($uq[2] eq 'daily') { $uq[1] = 86400 } | |
2921 | if ($uq[2] eq 'weekly') { $uq[1] = 604800 } | |
2922 | } | |
2923 | $uq[3] =~ s/\|/ /g; | |
2924 | print FILE "src quota-$idx {\n"; | |
2925 | print FILE " user $uq[3]\n"; | |
2926 | print FILE " userquota $uq[0] $uq[1] $uq[2]\n"; | |
2927 | print FILE "}\n\n"; | |
2928 | } | |
2929 | } | |
2930 | ||
2931 | } | |
2932 | } | |
2933 | ||
2934 | @tclist = &aggregatedconstraints; | |
2935 | ||
2936 | if (@tclist > 0) | |
2937 | { | |
2938 | $idx=0; | |
2939 | foreach (@tclist) | |
2940 | { | |
2941 | chomp; | |
2942 | @tc = split(/\,/); | |
2943 | if ($tc[15] eq 'on') | |
2944 | { | |
2945 | $idx++; | |
2946 | print FILE "src network-$idx {\n"; | |
1465b127 MT |
2947 | @clients = split(/ /,$tc[12]); |
2948 | @temp = split(/-/,$clients[0]); | |
2949 | if ( (&General::validipormask($temp[0])) || (&General::validipandmask($temp[0]))) | |
2950 | { | |
2951 | print FILE " ip $tc[12]\n"; | |
2952 | } else { | |
2953 | print FILE " user"; | |
2954 | @clients = split(/ /,$tc[12]); | |
2955 | foreach $line (@clients) | |
2956 | { | |
2957 | $line =~ s/(^\w+)\\(\w+$)/$1%5c$2/; | |
2958 | print FILE " $line"; | |
2959 | } | |
2960 | print FILE "\n"; | |
2961 | } | |
2962 | if (($filtersettings{'ENABLE_LOG'} eq 'on') && ($tc[14] eq 'block') && ($tc[13] eq 'any')) | |
2963 | { | |
2964 | if ($filtersettings{'ENABLE_CATEGORY_LOG'} eq 'on') | |
2965 | { | |
2966 | print FILE " logfile ".$ident." timeconst.log\n"; | |
2967 | } else { | |
2968 | print FILE " logfile ".$ident." urlfilter.log\n"; | |
2969 | } | |
2970 | } | |
10e4f239 MT |
2971 | print FILE "}\n\n"; |
2972 | } | |
2973 | } | |
2974 | ||
2975 | $idx=0; | |
2976 | foreach (@tclist) | |
2977 | { | |
2978 | chomp; | |
2979 | @tc = split(/\,/); | |
2980 | if ($tc[15] eq 'on') | |
2981 | { | |
2982 | $idx++; | |
2983 | print FILE "time constraint-$idx {\n"; | |
2984 | print FILE "$tc[16]\n"; | |
2985 | print FILE "}\n\n"; | |
2986 | } | |
2987 | } | |
2988 | } | |
2989 | ||
10e4f239 | 2990 | foreach $category (@categories) { |
1465b127 MT |
2991 | $blacklist = $category; |
2992 | $category =~ s/\//_/g; | |
9b7d98ff | 2993 | if ( $filtersettings{"FILTER_".uc($category)} ne "on" ){next;} |
10e4f239 | 2994 | print FILE "dest $category {\n"; |
1465b127 MT |
2995 | if (-e "$dbdir/$blacklist/domains") { |
2996 | print FILE " domainlist $blacklist\/domains\n"; | |
10e4f239 | 2997 | } |
1465b127 MT |
2998 | if (-e "$dbdir/$blacklist/urls") { |
2999 | print FILE " urllist $blacklist\/urls\n"; | |
10e4f239 | 3000 | } |
1465b127 MT |
3001 | if ((-e "$dbdir/$blacklist/expressions") && ($filtersettings{'ENABLE_EXPR_LISTS'} eq 'on')) { |
3002 | print FILE " expressionlist $blacklist\/expressions\n"; | |
10e4f239 | 3003 | } |
1465b127 | 3004 | if ((($category eq 'ads') || ($category eq 'adv')) && ($filtersettings{'ENABLE_EMPTY_ADS'} eq 'on')) |
10e4f239 | 3005 | { |
1465b127 | 3006 | print FILE " redirect http:\/\/$netsettings{'GREEN_ADDRESS'}:$http_port\/images/urlfilter/1x1.gif\n"; |
10e4f239 MT |
3007 | } |
3008 | if ($filtersettings{'ENABLE_LOG'} eq 'on') | |
3009 | { | |
3010 | if ($filtersettings{'ENABLE_CATEGORY_LOG'} eq 'on') | |
3011 | { | |
3012 | print FILE " logfile $ident $category.log\n"; | |
3013 | } else { | |
3014 | print FILE " logfile $ident urlfilter.log\n"; | |
3015 | } | |
3016 | } | |
3017 | print FILE "}\n\n"; | |
1465b127 | 3018 | $category = $blacklist; |
10e4f239 | 3019 | } |
d47ad587 | 3020 | |
10e4f239 MT |
3021 | print FILE "dest files {\n"; |
3022 | print FILE " expressionlist custom\/blocked\/files\n"; | |
3023 | if ($filtersettings{'ENABLE_LOG'} eq 'on') | |
3024 | { | |
3025 | if ($filtersettings{'ENABLE_CATEGORY_LOG'} eq 'on') | |
3026 | { | |
3027 | print FILE " logfile $ident files.log\n"; | |
3028 | } else { | |
3029 | print FILE " logfile $ident urlfilter.log\n"; | |
3030 | } | |
3031 | } | |
3032 | print FILE "}\n\n"; | |
3033 | ||
3034 | print FILE "dest custom-allowed {\n"; | |
3035 | print FILE " domainlist custom\/allowed\/domains\n"; | |
3036 | print FILE " urllist custom\/allowed\/urls\n"; | |
3037 | print FILE "}\n\n"; | |
3038 | ||
3039 | print FILE "dest custom-blocked {\n"; | |
3040 | print FILE " domainlist custom\/blocked\/domains\n"; | |
3041 | print FILE " urllist custom\/blocked\/urls\n"; | |
3042 | if ($filtersettings{'ENABLE_LOG'} eq 'on') | |
3043 | { | |
3044 | if ($filtersettings{'ENABLE_CATEGORY_LOG'} eq 'on') | |
3045 | { | |
3046 | print FILE " logfile $ident custom.log\n"; | |
3047 | } else { | |
3048 | print FILE " logfile $ident urlfilter.log\n"; | |
3049 | } | |
3050 | } | |
3051 | print FILE "}\n\n"; | |
3052 | ||
3053 | print FILE "dest custom-expressions {\n"; | |
3054 | print FILE " expressionlist custom\/blocked\/expressions\n"; | |
3055 | if ($filtersettings{'ENABLE_LOG'} eq 'on') | |
3056 | { | |
3057 | if ($filtersettings{'ENABLE_CATEGORY_LOG'} eq 'on') | |
3058 | { | |
3059 | print FILE " logfile $ident custom.log\n"; | |
3060 | } else { | |
3061 | print FILE " logfile $ident urlfilter.log\n"; | |
3062 | } | |
3063 | } | |
3064 | print FILE "}\n\n"; | |
3065 | ||
3066 | print FILE "acl {\n"; | |
3067 | if (!($filtersettings{'UNFILTERED_CLIENTS'} eq '')) { | |
3068 | print FILE " unfiltered {\n"; | |
3069 | print FILE " pass all\n"; | |
3070 | if ($filtersettings{'ENABLE_SAFESEARCH'} eq 'on') | |
3071 | { | |
1465b127 | 3072 | print FILE " rewrite rew-rule-2\n"; |
10e4f239 MT |
3073 | } |
3074 | print FILE " }\n\n"; | |
3075 | } | |
3076 | if (!($filtersettings{'BANNED_CLIENTS'} eq '')) { | |
3077 | print FILE " banned {\n"; | |
3078 | print FILE " pass "; | |
3079 | if (($filtersettings{'ENABLE_CUSTOM_WHITELIST'} eq 'on') && ($filtersettings{'ENABLE_GLOBAL_WHITELIST'} eq 'on')) | |
3080 | { | |
3081 | print FILE "custom-allowed "; | |
3082 | } | |
3083 | print FILE "none\n"; | |
3084 | print FILE " }\n\n"; | |
3085 | } | |
3086 | ||
3087 | if (-s $uqfile) | |
3088 | { | |
3089 | open(UQ, $uqfile); | |
3090 | @uqlist = <UQ>; | |
3091 | close(UQ); | |
3092 | ||
3093 | $idx=0; | |
3094 | foreach (@uqlist) | |
3095 | { | |
3096 | chomp; | |
3097 | @uq = split(/\,/); | |
3098 | if ($uq[4] eq 'on') | |
3099 | { | |
3100 | $idx++; | |
3101 | $qredirect = $redirect; | |
3102 | $qredirect =~ s/\%t/\%q\%20-\%20\%i/; | |
3103 | print FILE " quota-$idx {\n"; | |
3104 | print FILE " pass "; | |
3105 | if (($filtersettings{'ENABLE_CUSTOM_WHITELIST'} eq 'on') && ($filtersettings{'ENABLE_GLOBAL_WHITELIST'} eq 'on')) | |
3106 | { | |
3107 | print FILE "custom-allowed "; | |
3108 | } | |
3109 | print FILE "none\n"; | |
3110 | unless ($redirect eq $qredirect) { print FILE " redirect $qredirect\n"; } | |
3111 | print FILE " }\n\n"; | |
3112 | } | |
3113 | } | |
3114 | } | |
3115 | ||
3116 | if (@tclist > 0) | |
3117 | { | |
3118 | $idx=0; | |
3119 | foreach (@tclist) | |
3120 | { | |
3121 | chomp; | |
3122 | @tc = split(/\,/); | |
3123 | @ec = split(/\|/,$tc[13]); | |
1465b127 | 3124 | foreach (@ec) { s/\//_/g; } |
10e4f239 MT |
3125 | if ($tc[15] eq 'on') |
3126 | { | |
3127 | $idx++; | |
3128 | print FILE " network-$idx $tc[0] constraint-$idx {\n"; | |
3129 | print FILE " pass "; | |
3130 | ||
3131 | if ($filtersettings{'BLOCK_ALL'} eq 'on') | |
3132 | { | |
3133 | if ($tc[14] eq 'block') | |
3134 | { | |
3135 | if ((@ec == 1) && ($ec[0] eq 'any')) { | |
3136 | if (($filtersettings{'ENABLE_CUSTOM_WHITELIST'} eq 'on') && ($filtersettings{'ENABLE_GLOBAL_WHITELIST'} eq 'on')) | |
3137 | { | |
3138 | print FILE "custom-allowed "; | |
3139 | } | |
3140 | print FILE "none"; | |
3141 | } else { | |
3142 | print FILE $defaultrule; | |
3143 | } | |
3144 | } else { | |
3145 | foreach (@ec) | |
3146 | { | |
3147 | print FILE "$_ "; | |
3148 | } | |
3149 | print FILE $defaultrule unless ((@ec == 1) && ($ec[0] eq 'any')); | |
3150 | } | |
3151 | } else { | |
3152 | if ($tc[14] eq 'block') | |
3153 | { | |
3154 | $tcrule = $defaultrule; | |
3155 | if ($filtersettings{'ENABLE_CUSTOM_WHITELIST'} eq 'on') { | |
3156 | $tcrule =~ s/custom-allowed //; | |
3157 | print FILE "custom-allowed " unless ((@ec == 1) && ($ec[0] eq 'any') && ($filtersettings{'ENABLE_GLOBAL_WHITELIST'} eq 'off')); | |
3158 | } | |
3159 | if ((@ec == 1) && ($ec[0] eq 'any')) { | |
3160 | print FILE "none"; | |
3161 | } else { | |
3162 | foreach (@ec) | |
3163 | { | |
3164 | print FILE "!$_ " unless (index($defaultrule,"!".$_." ") ge 0); | |
3165 | } | |
3166 | } | |
3167 | print FILE $tcrule unless ((@ec == 1) && ($ec[0] eq 'any')); | |
3168 | } else { | |
3169 | $tcrule = $defaultrule; | |
1465b127 | 3170 | if ((@ec == 1) && ($ec[0] eq 'any')) |
10e4f239 | 3171 | { |
1465b127 MT |
3172 | print FILE "any"; |
3173 | } else { | |
3174 | foreach (@ec) | |
3175 | { | |
3176 | $tcrule = "$_ ".$tcrule unless (index($defaultrule,"!".$_." ") ge 0); | |
3177 | $tcrule =~ s/!$_ //; | |
3178 | } | |
3179 | print FILE $tcrule; | |
10e4f239 | 3180 | } |
10e4f239 MT |
3181 | } |
3182 | } | |
3183 | ||
3184 | print FILE "\n"; | |
3185 | ||
3186 | print FILE " }\n\n"; | |
3187 | } | |
3188 | } | |
3189 | } | |
3190 | ||
3191 | print FILE " default {\n"; | |
3192 | print FILE " pass $defaultrule\n"; | |
3193 | if (($filtersettings{'ENABLE_LOG'} eq 'on') && ($filtersettings{'BLOCK_ALL'} eq 'on')) | |
3194 | { | |
3195 | if ($filtersettings{'ENABLE_CATEGORY_LOG'} eq 'on') | |
3196 | { | |
3197 | print FILE " logfile".$ident." default.log\n"; | |
3198 | } else { | |
3199 | print FILE " logfile".$ident." urlfilter.log\n"; | |
3200 | } | |
3201 | } | |
3202 | if ((($filtersettings{'ENABLE_REWRITE'} eq 'on') && (@repositoryfiles)) || ($filtersettings{'ENABLE_SAFESEARCH'} eq 'on')) | |
3203 | { | |
1465b127 | 3204 | print FILE " rewrite rew-rule-1\n"; |
10e4f239 MT |
3205 | } |
3206 | print FILE " redirect $redirect\n"; | |
3207 | print FILE " }\n"; | |
3208 | print FILE "}\n"; | |
3209 | ||
3210 | close FILE; | |
3211 | } | |
3212 | ||
3213 | # ------------------------------------------------------------------- |