1 |
diff -Nur smeserver-dansguardian-panel-2.11-old/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/dungogdansguardian.pm smeserver-dansguardian-panel-2.11/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/dungogdansguardian.pm |
2 |
--- smeserver-dansguardian-panel-2.11-old/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/dungogdansguardian.pm 2009-03-13 22:23:20.000000000 -0400 |
3 |
+++ smeserver-dansguardian-panel-2.11/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/dungogdansguardian.pm 1969-12-31 19:00:00.000000000 -0500 |
4 |
@@ -1,1236 +0,0 @@ |
5 |
-#---------------------------------------------------------------------- |
6 |
-# dungogdansguardian.pm |
7 |
-# support@dungog.net |
8 |
-#---------------------------------------------------------------------- |
9 |
- |
10 |
-package esmith::FormMagick::Panel::dungogdansguardian; |
11 |
- |
12 |
-use strict; |
13 |
-use warnings; |
14 |
- |
15 |
-use esmith::FormMagick; |
16 |
-use esmith::ConfigDB; |
17 |
-use esmith::AccountsDB; |
18 |
-use esmith::cgi; |
19 |
- |
20 |
-use Exporter; |
21 |
-use Carp qw(verbose); |
22 |
- |
23 |
-use HTML::Tabulate; |
24 |
- |
25 |
-our @ISA = qw(esmith::FormMagick Exporter); |
26 |
- |
27 |
-our @EXPORT = qw(); |
28 |
- |
29 |
-our $db = esmith::ConfigDB->open(); |
30 |
-our $adb = esmith::AccountsDB->open(); |
31 |
-our $ddb = esmith::ConfigDB->open('dungog') or die "Could not open dungog DB\n"; |
32 |
-our $bdb = esmith::ConfigDB->open('blacklist') or die "Could not open blacklist DB\n"; |
33 |
-our $pdb = esmith::ConfigDB->open('phraselist') or die "Could not open phraselist DB\n"; |
34 |
- |
35 |
- |
36 |
-sub new { |
37 |
- shift; |
38 |
- my $self = esmith::FormMagick->new(); |
39 |
- $self->{calling_package} = (caller)[0]; |
40 |
- bless $self; |
41 |
- return $self; |
42 |
-} |
43 |
- |
44 |
-sub get_loglevel |
45 |
-{ |
46 |
- return $ddb->get_prop('dansguardian', 'loglevel'); |
47 |
-} |
48 |
-sub get_logfileformat |
49 |
-{ |
50 |
- return $ddb->get_prop('dansguardian', 'logfileformat'); |
51 |
-} |
52 |
-sub get_proxyaccess |
53 |
-{ |
54 |
- return $db->get_prop('squid', 'RequireAuth'); |
55 |
-} |
56 |
-sub get_portblocking |
57 |
-{ |
58 |
- return $db->get_prop('dansguardian', 'portblocking'); |
59 |
-} |
60 |
-sub get_port |
61 |
-{ |
62 |
- return $ddb->get_prop('dansguardian', 'port'); |
63 |
-} |
64 |
-sub get_status |
65 |
-{ |
66 |
- return $db->get_prop('dansguardian', 'status'); |
67 |
-} |
68 |
-sub get_bypassproxyto |
69 |
-{ |
70 |
- return $db->get_prop('squid', 'BypassProxyTo'); |
71 |
-} |
72 |
-sub get_bypassproxyfrom |
73 |
-{ |
74 |
- return $db->get_prop('squid', 'BypassProxyFrom'); |
75 |
-} |
76 |
-sub get_TCPBlocks |
77 |
-{ |
78 |
- return $db->get_prop('masq', 'TCPBlocks'); |
79 |
-} |
80 |
-sub get_UDPBlocks |
81 |
-{ |
82 |
- return $db->get_prop('masq', 'UDPBlocks'); |
83 |
-} |
84 |
-sub get_mode |
85 |
-{ |
86 |
- my $self = shift; |
87 |
- my $q = $self->{cgi}; |
88 |
- my $g = $q->param('g') ||''; |
89 |
- return $ddb->get_prop("dansguardian$g", 'mode'); |
90 |
-} |
91 |
-sub get_bypass |
92 |
-{ |
93 |
- my $self = shift; |
94 |
- my $q = $self->{cgi}; |
95 |
- my $g = $q->param('g') ||''; |
96 |
- return $ddb->get_prop("dansguardian$g", 'bypass'); |
97 |
-} |
98 |
-sub get_reportinglevel |
99 |
-{ |
100 |
- my $self = shift; |
101 |
- my $q = $self->{cgi}; |
102 |
- my $g = $q->param('g') ||''; |
103 |
- return $ddb->get_prop("dansguardian$g", 'reportinglevel'); |
104 |
-} |
105 |
-sub get_deniedpage |
106 |
-{ |
107 |
- my $self = shift; |
108 |
- my $q = $self->{cgi}; |
109 |
- my $g = $q->param('g') ||''; |
110 |
- return $ddb->get_prop("dansguardian$g", 'deniedpage'); |
111 |
-} |
112 |
-sub get_deniedurl |
113 |
-{ |
114 |
- my $self = shift; |
115 |
- my $q = $self->{cgi}; |
116 |
- my $g = $q->param('g') ||''; |
117 |
- return $ddb->get_prop("dansguardian$g", 'deniedurl'); |
118 |
-} |
119 |
-sub get_scan |
120 |
-{ |
121 |
- my $self = shift; |
122 |
- my $q = $self->{cgi}; |
123 |
- my $g = $q->param('g') ||''; |
124 |
- return $ddb->get_prop("dansguardian$g", 'scan'); |
125 |
-} |
126 |
-sub get_weight |
127 |
-{ |
128 |
- my $self = shift; |
129 |
- my $q = $self->{cgi}; |
130 |
- my $g = $q->param('g') ||''; |
131 |
- return $ddb->get_prop("dansguardian$g", 'weight'); |
132 |
-} |
133 |
-sub get_pics |
134 |
-{ |
135 |
- my $self = shift; |
136 |
- my $q = $self->{cgi}; |
137 |
- my $g = $q->param('g' ||''); |
138 |
- return $ddb->get_prop("dansguardian$g", 'pics'); |
139 |
-} |
140 |
-sub get_regexpurl |
141 |
-{ |
142 |
- my $self = shift; |
143 |
- my $q = $self->{cgi}; |
144 |
- my $g = $q->param('g') ||''; |
145 |
- return $ddb->get_prop("dansguardian$g", 'regexpurl'); |
146 |
-} |
147 |
-sub get_regexpsearch |
148 |
-{ |
149 |
- my $self = shift; |
150 |
- my $q = $self->{cgi}; |
151 |
- my $g = $q->param('g') ||''; |
152 |
- return $ddb->get_prop("dansguardian$g", 'regexpsearch'); |
153 |
-} |
154 |
-sub get_regexpurlads |
155 |
-{ |
156 |
- my $self = shift; |
157 |
- my $q = $self->{cgi}; |
158 |
- my $g = $q->param('g') ||''; |
159 |
- return $ddb->get_prop("dansguardian$g", 'regexpurlads'); |
160 |
-} |
161 |
-sub get_regexpurlproxy |
162 |
-{ |
163 |
- my $self = shift; |
164 |
- my $q = $self->{cgi}; |
165 |
- my $g = $q->param('g') ||''; |
166 |
- return $ddb->get_prop("dansguardian$g", 'regexpurlproxy'); |
167 |
-} |
168 |
-sub get_blanketban |
169 |
-{ |
170 |
- my $self = shift; |
171 |
- my $q = $self->{cgi}; |
172 |
- my $g = $q->param('g') ||''; |
173 |
- return $ddb->get_prop("dansguardian$g", 'blanketban'); |
174 |
-} |
175 |
-sub get_ipban |
176 |
-{ |
177 |
- my $self = shift; |
178 |
- my $q = $self->{cgi}; |
179 |
- my $g = $q->param('g') ||''; |
180 |
- return $ddb->get_prop("dansguardian$g", 'ipban'); |
181 |
-} |
182 |
-sub get_https |
183 |
-{ |
184 |
- my $self = shift; |
185 |
- my $q = $self->{cgi}; |
186 |
- my $g = $q->param('g') ||''; |
187 |
- return $ddb->get_prop("dansguardian$g", 'https'); |
188 |
-} |
189 |
-sub get_file |
190 |
-{ |
191 |
- my $self = shift; |
192 |
- my $q = $self->{cgi}; |
193 |
- my $g = $q->param('g') ||''; |
194 |
- return $ddb->get_prop("dansguardian$g", 'file'); |
195 |
-} |
196 |
-sub get_criterion |
197 |
-{ |
198 |
- my $self = shift; |
199 |
- my $q = $self->{cgi}; |
200 |
- my $key = $q->param('key') ||''; |
201 |
- return $ddb->get_prop($key, 'criterion') || ''; |
202 |
-} |
203 |
- |
204 |
-sub get_status_summary |
205 |
-{ |
206 |
- my $self = shift; |
207 |
- my $q = $self->{cgi}; |
208 |
- |
209 |
- my $status = $db->get_prop('dansguardian', "status"); |
210 |
- my $Auth = $db->get_prop('squid', "RequireAuth"); |
211 |
- my $port = $ddb->get_prop('dansguardian', "port"); |
212 |
- my $block = $db->get_prop('dansguardian', "portblocking"); |
213 |
- |
214 |
- my $STATUS = $self->localise('STATUS'); |
215 |
- my $PORT = $self->localise('PORT'); |
216 |
- my $PROXYACCESS = $self->localise('PROXYACCESS'); |
217 |
- my $BLOCKING = $self->localise('PORTBLOCKING'); |
218 |
- |
219 |
- my $status2; |
220 |
- if ($status eq 'enabled') |
221 |
- { $status2 = $self->localise('ENABLED'); } else { $status2 = $self->localise('DISABLED'); } |
222 |
- |
223 |
- my $block2; |
224 |
- if ($block eq 'yes') |
225 |
- { $block2 = $self->localise('ENABLED'); } else { $block2 = $self->localise('DISABLED'); } |
226 |
- |
227 |
- return "$STATUS : <b>$status2</b>, $PORT : <b>$port</b>, $PROXYACCESS : <b>$Auth</b>, $BLOCKING : <b>$block2</b>"; |
228 |
-} |
229 |
- |
230 |
-sub get_custom_denied |
231 |
-{ |
232 |
- my $self = shift; |
233 |
- my $q = $self->{cgi}; |
234 |
- my $g = $q->param('g') ||''; |
235 |
- my $Ldefault = $self->localise('Ldefault'); |
236 |
- |
237 |
- my $defaults = $ddb->get_prop("dansguardian", "deniedurl") || 'dansguardian.pl'; |
238 |
- |
239 |
- my $deniedurl = $ddb->get_prop("dansguardian$g", "deniedurl") || 'nul'; |
240 |
- if (($deniedurl eq 'nul') && (-e "/home/e-smith/files/ibays/Primary/cgi-bin/dansguardian$g.pl")) |
241 |
- { $deniedurl = "dansguardian$g.pl"; } |
242 |
- |
243 |
- my $language = $ddb->get_prop('dansguardian', "language") || 'ukenglish'; |
244 |
- my $customhtml = 'nul'; |
245 |
- if (-e "/etc/dansguardian/languages/$language/template$g.html") |
246 |
- { $customhtml = "$language/template$g.html"; } |
247 |
- |
248 |
- return "$Ldefault = $defaults, html = $customhtml, cgi = $deniedurl"; |
249 |
-} |
250 |
- |
251 |
-sub print_global_table |
252 |
-{ |
253 |
- my $self = shift; |
254 |
- my $q = $self->{cgi}; |
255 |
- |
256 |
- my $description = $self->localise('DESCRIPTION'); |
257 |
- my $Lf2 = $self->localise('Lf2'); |
258 |
- my $Lf3 = $self->localise('Lf3'); |
259 |
- my $Lf4 = $self->localise('Lf4'); |
260 |
- my $Lf5 = $self->localise('Lf5'); |
261 |
- |
262 |
- my @groups = $adb->get_all_by_prop(type => "group"); |
263 |
- my @gnames = ''; |
264 |
- foreach my $g (@groups) |
265 |
- { |
266 |
- my $groupname = $g->key(); |
267 |
- push (@gnames, $groupname) |
268 |
- } |
269 |
- |
270 |
- print $q->start_table({-CLASS => "sme-border"}),"\n"; |
271 |
- print $q->Tr ( |
272 |
- esmith::cgi::genSmallCell($q, $description,"header"), |
273 |
- esmith::cgi::genSmallCell($q, '',"header")),"\n"; |
274 |
- |
275 |
- |
276 |
- print $q->Tr (esmith::cgi::genSmallCell ($q, $Lf2), |
277 |
- esmith::cgi::genSmallCell ($q, |
278 |
- $q->popup_menu (-name => "f2", |
279 |
- -values => [ sort @gnames ], |
280 |
- -default => $ddb->get_prop('dansguardian', "f2") || ''))); |
281 |
- |
282 |
- print $q->Tr (esmith::cgi::genSmallCell ($q, $Lf3), |
283 |
- esmith::cgi::genSmallCell ($q, |
284 |
- $q->popup_menu (-name => "f3", |
285 |
- -values => [ sort @gnames ], |
286 |
- -default => $ddb->get_prop('dansguardian', "f3") || ''))); |
287 |
- |
288 |
- print $q->Tr (esmith::cgi::genSmallCell ($q, $Lf4), |
289 |
- esmith::cgi::genSmallCell ($q, |
290 |
- $q->popup_menu (-name => "f4", |
291 |
- -values => [ sort @gnames ], |
292 |
- -default => $ddb->get_prop('dansguardian', "f4") || ''))); |
293 |
- |
294 |
- print $q->Tr (esmith::cgi::genSmallCell ($q, $Lf5), |
295 |
- esmith::cgi::genSmallCell ($q, |
296 |
- $q->popup_menu (-name => "f5", |
297 |
- -values => [ sort @gnames ], |
298 |
- -default => $ddb->get_prop('dansguardian', "f5") || ''))); |
299 |
- |
300 |
- print $q->end_table; |
301 |
- |
302 |
- return ""; |
303 |
-} |
304 |
- |
305 |
-sub print_summary |
306 |
-{ |
307 |
- my $self = shift; |
308 |
- my $q = $self->{cgi}; |
309 |
- |
310 |
- my $description = $self->localise('DESCRIPTION'); |
311 |
- my $LAllow = $self->localise('LAllow'); |
312 |
- my $LClient_IP = $self->localise('LClient_IP'); |
313 |
- my $LDeny = $self->localise('LDeny'); |
314 |
- my $modify = $self->localise('MODIFY'); |
315 |
- my $Lcommon = $self->localise('Lcommon'); |
316 |
- my $Ldefault = $self->localise('Ldefault'); |
317 |
- my $Lf0 = $self->localise('Lf0'); |
318 |
- my $Lf1 = $self->localise('Lf1'); |
319 |
- my $Lf2 = $self->localise('Lf2'); |
320 |
- my $Lf3 = $self->localise('Lf3'); |
321 |
- my $Lf4 = $self->localise('Lf4'); |
322 |
- my $Lf5 = $self->localise('Lf5'); |
323 |
- my $GROUP = $self->localise('GROUP'); |
324 |
- my $Lmode = $self->localise('Lmode'); |
325 |
- my $LURLban = $self->localise('LURLban'); |
326 |
- my $Lscan = $self->localise('Lscan'); |
327 |
- my $Lbypass = $self->localise('Lbypass'); |
328 |
- my $Llists = $self->localise('Llists'); |
329 |
- my $Lsettings = $self->localise('Lsettings'); |
330 |
- |
331 |
- my @groups = $adb->get_all_by_prop(type => "group"); |
332 |
- my @gnames = ''; |
333 |
- foreach my $g (@groups) |
334 |
- { |
335 |
- my $groupname = $g->key(); |
336 |
- push (@gnames, $groupname) |
337 |
- } |
338 |
- |
339 |
- print $q->start_table({-CLASS => "sme-border"}),"\n"; |
340 |
- print $q->Tr ( |
341 |
- esmith::cgi::genSmallCell($q, $description,"header"), |
342 |
- esmith::cgi::genSmallCell($q, $GROUP,"header"), |
343 |
- esmith::cgi::genSmallCell($q, $Lmode,"header"), |
344 |
- esmith::cgi::genSmallCell($q, $LURLban,"header"), |
345 |
- esmith::cgi::genSmallCell($q, $Lscan,"header"), |
346 |
- esmith::cgi::genSmallCell($q, $Lbypass,"header"), |
347 |
- esmith::cgi::genSmallCell($q, $Lsettings,"header"), |
348 |
- esmith::cgi::genSmallCell($q, $Llists,"header")),"\n"; |
349 |
- |
350 |
- print $q->Tr (esmith::cgi::genSmallCell ($q, $Lf0), |
351 |
- esmith::cgi::genSmallCell ($q, ''), |
352 |
- esmith::cgi::genSmallCell ($q, ''), |
353 |
- esmith::cgi::genSmallCell ($q, ''), |
354 |
- esmith::cgi::genSmallCell ($q, ''), |
355 |
- esmith::cgi::genSmallCell ($q, ''), |
356 |
- esmith::cgi::genSmallCell ($q, ''), |
357 |
- esmith::cgi::genSmallCell ($q, |
358 |
- $q->a ({href => $q->url (-absolute => 1) |
359 |
- . "?page=0&page_stack=&g=f0&gname=$Lcommon&wherenext=GroupLists"}, $modify))); |
360 |
- |
361 |
- print $q->Tr (esmith::cgi::genSmallCell ($q, $Lf1), |
362 |
- esmith::cgi::genSmallCell ($q, ''), |
363 |
- esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf1', "mode") || ''), |
364 |
- esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf1', "blanketban") . " / " . |
365 |
- $ddb->get_prop('dansguardianf1', "https") . " / " . |
366 |
- $ddb->get_prop('dansguardianf1', "ipban") . " / " . |
367 |
- $ddb->get_prop('dansguardianf1', "file") . " - " . |
368 |
- $ddb->get_prop('dansguardianf1', "regexpurl") . " / " . |
369 |
- $ddb->get_prop('dansguardianf1', "regexpurlads") . " / " . |
370 |
- $ddb->get_prop('dansguardianf1', "regexpurlproxy")), |
371 |
- esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf1', "scan") || ''), |
372 |
- esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf1', "bypass") || ''), |
373 |
- esmith::cgi::genSmallCell ($q, |
374 |
- $q->a ({href => $q->url (-absolute => 1) |
375 |
- . "?page=0&page_stack=&g=f1&gname=$Ldefault&wherenext=GroupSettings"}, $modify)), |
376 |
- esmith::cgi::genSmallCell ($q, |
377 |
- $q->a ({href => $q->url (-absolute => 1) |
378 |
- . "?page=0&page_stack=&g=f1&gname=$Ldefault&wherenext=GroupLists"}, $modify))); |
379 |
- |
380 |
- my $gname = $ddb->get_prop('dansguardian', "f2"); |
381 |
- if ($gname) { |
382 |
- print $q->Tr (esmith::cgi::genSmallCell ($q, $Lf2), |
383 |
- esmith::cgi::genSmallCell ($q, $gname ), |
384 |
- esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf2', "mode") || ''), |
385 |
- esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf2', "blanketban") . " / " . |
386 |
- $ddb->get_prop('dansguardianf2', "https") . " / " . |
387 |
- $ddb->get_prop('dansguardianf2', "ipban") . " / " . |
388 |
- $ddb->get_prop('dansguardianf2', "file") . " - " . |
389 |
- $ddb->get_prop('dansguardianf2', "regexpurl") . " / " . |
390 |
- $ddb->get_prop('dansguardianf2', "regexpurlads") . " / " . |
391 |
- $ddb->get_prop('dansguardianf2', "regexpurlproxy")), |
392 |
- esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf2', "scan") || ''), |
393 |
- esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf2', "bypass") || ''), |
394 |
- esmith::cgi::genSmallCell ($q, |
395 |
- $q->a ({href => $q->url (-absolute => 1) |
396 |
- . "?page=0&page_stack=&g=f2&gname=$gname&wherenext=GroupSettings"}, $modify)), |
397 |
- esmith::cgi::genSmallCell ($q, |
398 |
- $q->a ({href => $q->url (-absolute => 1) |
399 |
- . "?page=0&page_stack=&g=f2&gname=$gname&wherenext=GroupLists"}, $modify))); |
400 |
- } |
401 |
- |
402 |
- $gname = $ddb->get_prop('dansguardian', "f3"); |
403 |
- if ($gname) { |
404 |
- print $q->Tr (esmith::cgi::genSmallCell ($q, $Lf3), |
405 |
- esmith::cgi::genSmallCell ($q, $gname ), |
406 |
- esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf3', "mode") || ''), |
407 |
- esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf3', "blanketban") . " / " . |
408 |
- $ddb->get_prop('dansguardianf3', "https") . " / " . |
409 |
- $ddb->get_prop('dansguardianf3', "ipban") . " / " . |
410 |
- $ddb->get_prop('dansguardianf3', "file") . " - " . |
411 |
- $ddb->get_prop('dansguardianf3', "regexpurl") . " / " . |
412 |
- $ddb->get_prop('dansguardianf3', "regexpurlads") . " / " . |
413 |
- $ddb->get_prop('dansguardianf3', "regexpurlproxy")), |
414 |
- esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf3', "scan") || ''), |
415 |
- esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf3', "bypass") || ''), |
416 |
- esmith::cgi::genSmallCell ($q, |
417 |
- $q->a ({href => $q->url (-absolute => 1) |
418 |
- . "?page=0&page_stack=&g=f3&gname=$gname&wherenext=GroupSettings"}, $modify)), |
419 |
- esmith::cgi::genSmallCell ($q, |
420 |
- $q->a ({href => $q->url (-absolute => 1) |
421 |
- . "?page=0&page_stack=&g=f3&gname=$gname&wherenext=GroupLists"}, $modify))); |
422 |
- } |
423 |
- |
424 |
- $gname = $ddb->get_prop('dansguardian', "f4"); |
425 |
- if ($gname) { |
426 |
- print $q->Tr (esmith::cgi::genSmallCell ($q, $Lf4), |
427 |
- esmith::cgi::genSmallCell ($q, $gname ), |
428 |
- esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf4', "mode") || ''), |
429 |
- esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf4', "blanketban") . " / " . |
430 |
- $ddb->get_prop('dansguardianf4', "https") . " / " . |
431 |
- $ddb->get_prop('dansguardianf4', "ipban") . " / " . |
432 |
- $ddb->get_prop('dansguardianf4', "file") . " - " . |
433 |
- $ddb->get_prop('dansguardianf4', "regexpurl") . " / " . |
434 |
- $ddb->get_prop('dansguardianf4', "regexpurlads") . " / " . |
435 |
- $ddb->get_prop('dansguardianf4', "regexpurlproxy")), |
436 |
- esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf4', "scan") || ''), |
437 |
- esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf4', "bypass") || ''), |
438 |
- esmith::cgi::genSmallCell ($q, |
439 |
- $q->a ({href => $q->url (-absolute => 1) |
440 |
- . "?page=0&page_stack=&g=f4&gname=$gname&wherenext=GroupSettings"}, $modify)), |
441 |
- esmith::cgi::genSmallCell ($q, |
442 |
- $q->a ({href => $q->url (-absolute => 1) |
443 |
- . "?page=0&page_stack=&g=f4&gname=$gname&wherenext=GroupLists"}, $modify))); |
444 |
- } |
445 |
- |
446 |
- $gname = $ddb->get_prop('dansguardian', "f5"); |
447 |
- if ($gname) { |
448 |
- print $q->Tr (esmith::cgi::genSmallCell ($q, $Lf5), |
449 |
- esmith::cgi::genSmallCell ($q, $gname ), |
450 |
- esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf5', "mode") || ''), |
451 |
- esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf5', "blanketban") . " / " . |
452 |
- $ddb->get_prop('dansguardianf5', "https") . " / " . |
453 |
- $ddb->get_prop('dansguardianf5', "ipban") . " / " . |
454 |
- $ddb->get_prop('dansguardianf5', "file") . " - " . |
455 |
- $ddb->get_prop('dansguardianf5', "regexpurl") . " / " . |
456 |
- $ddb->get_prop('dansguardianf5', "regexpurlads") . " / " . |
457 |
- $ddb->get_prop('dansguardianf5', "regexpurlproxy")), |
458 |
- esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf5', "scan") || ''), |
459 |
- esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf5', "bypass") || ''), |
460 |
- esmith::cgi::genSmallCell ($q, |
461 |
- $q->a ({href => $q->url (-absolute => 1) |
462 |
- . "?page=0&page_stack=&g=f5&gname=$gname&wherenext=GroupSettings"}, $modify)), |
463 |
- esmith::cgi::genSmallCell ($q, |
464 |
- $q->a ({href => $q->url (-absolute => 1) |
465 |
- . "?page=0&page_stack=&g=f5&gname=$gname&wherenext=GroupLists"}, $modify))); |
466 |
- } |
467 |
- |
468 |
- print $q->end_table; |
469 |
- |
470 |
- return ""; |
471 |
-} |
472 |
- |
473 |
-sub save_reload |
474 |
-{ |
475 |
- my $self = shift; |
476 |
- my $q = $self->{cgi}; |
477 |
- |
478 |
- foreach ('loglevel','logfileformat','f2','f3','f4','f5','deniedurl') |
479 |
- { $ddb->set_prop('dansguardian', "$_", $q->param("$_")); } |
480 |
- |
481 |
- unless ( system ("/sbin/e-smith/signal-event", "dansguardian-reload") == 0 ) |
482 |
- { return $self->error('ERROR'); } |
483 |
- |
484 |
- return $self->success("SUCCESS"); |
485 |
-} |
486 |
- |
487 |
-sub save_group_settings |
488 |
-{ |
489 |
- my $self = shift; |
490 |
- my $q = $self->{cgi}; |
491 |
- my $g = $q->param ('g') ||''; |
492 |
- |
493 |
- foreach ('mode','bypass','reportinglevel','scan','weight','pics','deniedpage','deniedurl', |
494 |
- 'regexpurl','regexpsearch','regexpurlads','regexpurlproxy','blanketban','https','ipban','file') |
495 |
- { $ddb->set_prop("dansguardian$g", "$_", $q->param("$_")); } |
496 |
- |
497 |
- unless ( system ("/sbin/e-smith/signal-event", "dansguardian-reload") == 0 ) |
498 |
- { return $self->error('ERROR'); } |
499 |
- |
500 |
- return $self->success("SUCCESS"); |
501 |
-} |
502 |
- |
503 |
-sub save_proxy |
504 |
-{ |
505 |
- my $self = shift; |
506 |
- my $q = $self->{cgi} ||''; |
507 |
- |
508 |
- my $status = $q->param ('status') || ''; |
509 |
- my $proxyaccess = $q->param ('proxyaccess') || ''; |
510 |
- my $portblocking = $q->param ('portblocking') || ''; |
511 |
- my $port = $q->param ('port') || ''; |
512 |
- |
513 |
- $db->set_prop('squid', "RequireAuth", $proxyaccess); |
514 |
- $ddb->set_prop('dansguardian', "port", $port); |
515 |
- |
516 |
- my $bypassproxyfrom = $q->param ('bypassproxyfrom') || ''; |
517 |
- my $bypassproxyto = $q->param ('bypassproxyto') || ''; |
518 |
- my $TCPBlocks = $q->param ('TCPBlocks') || ''; |
519 |
- my $UDPBlocks = $q->param ('UDPBlocks') || ''; |
520 |
- |
521 |
- $db->set_prop('squid', "BypassProxyFrom", $bypassproxyfrom); |
522 |
- $db->set_prop('squid', "BypassProxyTo", $bypassproxyto); |
523 |
- $db->set_prop('masq', "UDPBlocks", $UDPBlocks); |
524 |
- $db->set_prop('masq', "TCPBlocks", $TCPBlocks); |
525 |
- |
526 |
- if ($status eq 'disabled') |
527 |
- { |
528 |
- $db->set_prop('squid', "TransparentPort", '3128'); |
529 |
- $db->set_prop('dansguardian', "status", 'disabled'); |
530 |
- $db->set_prop('dansguardian', "portblocking", 'no'); |
531 |
- |
532 |
- unless ( system ("/sbin/e-smith/signal-event", "dansguardian-save") == 0 ) |
533 |
- { return $self->error('ERROR'); } |
534 |
- |
535 |
- return $self->success("SUCCESS_STOP"); |
536 |
- } |
537 |
- else |
538 |
- { |
539 |
- $db->set_prop('squid', "TransparentPort", $port); |
540 |
- $db->set_prop('dansguardian', "status", 'enabled'); |
541 |
- $db->set_prop('dansguardian', "portblocking", $portblocking); |
542 |
- } |
543 |
- |
544 |
- unless ( system ("/sbin/e-smith/signal-event", "dansguardian-save") == 0 ) |
545 |
- { return $self->error('ERROR'); } |
546 |
- |
547 |
- return $self->success("SUCCESS_PROMPT"); |
548 |
-} |
549 |
- |
550 |
-sub portentry |
551 |
-{ |
552 |
- my ($fm, $port) = @_; |
553 |
- if (not $port) |
554 |
- { |
555 |
- return "FM_NONBLANK"; |
556 |
- } |
557 |
- elsif ($port =~ /^(\d{4})$/) |
558 |
- { |
559 |
- return "OK"; |
560 |
- } |
561 |
- else |
562 |
- { |
563 |
- return "ERROR_PORT"; |
564 |
- } |
565 |
-} |
566 |
- |
567 |
-sub print_list_table |
568 |
-{ |
569 |
- my $self = shift; |
570 |
- my $q = $self->{cgi}; |
571 |
- my $g = $q->param('g') || ''; |
572 |
- my $gname = $q->param('gname') || ''; |
573 |
- |
574 |
- my $description = $self->localise('DESCRIPTION'); |
575 |
- my $Lasite = $self->localise('Lasite'); |
576 |
- my $Laurl = $self->localise('Laurl'); |
577 |
- my $Lphrases = $self->localise('Lphrases'); |
578 |
- my $Lregexp = $self->localise('Lregexp'); |
579 |
- my $Lfileext = $self->localise('Lfileext'); |
580 |
- my $Lmimetype = $self->localise('Lmimetype'); |
581 |
- my $ALLlists = $self->localise('LALLlists'); |
582 |
- my $ENABLED = $self->localise('ENABLED'); |
583 |
- |
584 |
- my $Lgrey = $self->localise('Lgrey'); |
585 |
- my $Lweighted = $self->localise('Lweighted'); |
586 |
- my $Lmodifyurl = $self->localise('Lmodifyurl'); |
587 |
- my $LAllow = $self->localise('LAllow'); |
588 |
- my $LDeny = $self->localise('LDeny'); |
589 |
- my $LAVexcept = $self->localise('LAVexcept'); |
590 |
- my $Lexception = $self->localise('Lexception'); |
591 |
- my $Lblacklist = $self->localise('Lblacklist'); |
592 |
- my $Lphraselist = $self->localise('Lphraselist'); |
593 |
- my $Lrepcon = $self->localise('Lrepcon'); |
594 |
- my $Lallowurl = $self->localise('Lallowurl'); |
595 |
- my $Lallowsite = $self->localise('Lallowsite'); |
596 |
- my $LClientIP = $self->localise('LClientIP'); |
597 |
- my $Lcommon = $self->localise('Lcommon'); |
598 |
- my $Commonlists = $self->localise('LCommonlists'); |
599 |
- |
600 |
- print $q->start_table({-CLASS => "sme-border"}),"\n"; |
601 |
- print $q->Tr ( |
602 |
- esmith::cgi::genSmallCell($q, $description,"header"), |
603 |
- esmith::cgi::genSmallCell($q, $q->a ({href => $q->url (-absolute => 1) |
604 |
- . "?page=0&page_stack=&g=$g&gname=$gname&wherenext=ShowAllLists"}, $ALLlists),"header"), |
605 |
- esmith::cgi::genSmallCell($q, '',"header"), |
606 |
- esmith::cgi::genSmallCell($q, '',"header"), |
607 |
- esmith::cgi::genSmallCell($q, '',"header"), |
608 |
- esmith::cgi::genSmallCell($q, $q->a ({href => $q->url (-absolute => 1) |
609 |
- . "?page=0&page_stack=&g=$g&gname=$gname&wherenext=ShowCommonLists"}, $Commonlists),"header")); |
610 |
- |
611 |
- print $q->Tr (esmith::cgi::genSmallCell ($q, $Lasite), |
612 |
- esmith::cgi::genSmallCell ($q, |
613 |
- $q->a ({href => $q->url (-absolute => 1) |
614 |
- . "?page=0&page_stack=&g=$g&list=greysitelist$g&wherenext=ViewList"}, $Lgrey)), |
615 |
- esmith::cgi::genSmallCell ($q, |
616 |
- $q->a ({href => $q->url (-absolute => 1) |
617 |
- . "?page=0&page_stack=&g=$g&list=exceptionsitelist$g&wherenext=ViewList"}, $LAllow)), |
618 |
- esmith::cgi::genSmallCell ($q, |
619 |
- $q->a ({href => $q->url (-absolute => 1) |
620 |
- . "?page=0&page_stack=&g=$g&list=bannedsitelist$g&wherenext=ViewList"}, $LDeny)), |
621 |
- esmith::cgi::genSmallCell ($q,''), |
622 |
- esmith::cgi::genSmallCell ($q, |
623 |
- $q->a ({href => $q->url (-absolute => 1) |
624 |
- . "?page=0&page_stack=&g=f0&list=exceptionvirussitelist&wherenext=ViewList"}, $LAVexcept))); |
625 |
- |
626 |
- print $q->Tr (esmith::cgi::genSmallCell ($q, $Laurl), |
627 |
- esmith::cgi::genSmallCell ($q, |
628 |
- $q->a ({href => $q->url (-absolute => 1) |
629 |
- . "?page=0&page_stack=&g=$g&list=greyurllist$g&wherenext=ViewList"}, $Lgrey)), |
630 |
- esmith::cgi::genSmallCell ($q, |
631 |
- $q->a ({href => $q->url (-absolute => 1) |
632 |
- . "?page=0&page_stack=&g=$g&list=exceptionurllist$g&wherenext=ViewList"}, $LAllow)), |
633 |
- esmith::cgi::genSmallCell ($q, |
634 |
- $q->a ({href => $q->url (-absolute => 1) |
635 |
- . "?page=0&page_stack=&g=$g&list=bannedurllist$g&wherenext=ViewList"}, $LDeny)), |
636 |
- esmith::cgi::genSmallCell ($q,''), |
637 |
- esmith::cgi::genSmallCell ($q, |
638 |
- $q->a ({href => $q->url (-absolute => 1) |
639 |
- . "?page=0&page_stack=&g=f0&list=exceptionvirusurllist&wherenext=ViewList"}, $LAVexcept))); |
640 |
- |
641 |
- print $q->Tr (esmith::cgi::genSmallCell ($q, $Lphrases), |
642 |
- esmith::cgi::genSmallCell ($q, |
643 |
- $q->a ({href => $q->url (-absolute => 1) |
644 |
- . "?page=0&page_stack=&g=$g&list=weightedphraselist$g&wherenext=ViewList"}, $Lweighted)), |
645 |
- esmith::cgi::genSmallCell ($q, |
646 |
- $q->a ({href => $q->url (-absolute => 1) |
647 |
- . "?page=0&page_stack=&g=$g&list=exceptionphraselist$g&wherenext=ViewList"}, $LAllow)), |
648 |
- esmith::cgi::genSmallCell ($q, |
649 |
- $q->a ({href => $q->url (-absolute => 1) |
650 |
- . "?page=0&page_stack=&g=$g&list=bannedphraselist$g&wherenext=ViewList"}, $LDeny)), |
651 |
- esmith::cgi::genSmallCell ($q, ''), |
652 |
- esmith::cgi::genSmallCell ($q,'')); |
653 |
- |
654 |
- print $q->Tr (esmith::cgi::genSmallCell ($q, $Lregexp), |
655 |
- esmith::cgi::genSmallCell ($q, |
656 |
- $q->a ({href => $q->url (-absolute => 1) |
657 |
- . "?page=0&page_stack=&g=$g&list=urlregexplist$g&wherenext=ViewList"}, $Lmodifyurl)), |
658 |
- esmith::cgi::genSmallCell ($q, |
659 |
- $q->a ({href => $q->url (-absolute => 1) |
660 |
- . "?page=0&page_stack=&g=$g&list=exceptionregexpurllist$g&wherenext=ViewList"}, $LAllow)), |
661 |
- esmith::cgi::genSmallCell ($q, |
662 |
- $q->a ({href => $q->url (-absolute => 1) |
663 |
- . "?page=0&page_stack=&g=$g&list=bannedregexpurllist$g&wherenext=ViewList"}, $LDeny)), |
664 |
- esmith::cgi::genSmallCell ($q, |
665 |
- $q->a ({href => $q->url (-absolute => 1) |
666 |
- . "?page=0&page_stack=&g=$g&list=contentregexplist$g&wherenext=ViewList"}, $Lrepcon)), |
667 |
- esmith::cgi::genSmallCell ($q, '')); |
668 |
- |
669 |
- |
670 |
- print $q->Tr (esmith::cgi::genSmallCell ($q, $Lfileext), |
671 |
- esmith::cgi::genSmallCell ($q, ''), |
672 |
- esmith::cgi::genSmallCell ($q, |
673 |
- $q->a ({href => $q->url (-absolute => 1) |
674 |
- . "?page=0&page_stack=&g=$g&list=exceptionextensionlist$g&wherenext=ViewList"}, $Lexception)), |
675 |
- esmith::cgi::genSmallCell ($q, |
676 |
- $q->a ({href => $q->url (-absolute => 1) |
677 |
- . "?page=0&page_stack=&g=$g&list=bannedextensionlist$g&wherenext=ViewList"}, $LDeny)), |
678 |
- esmith::cgi::genSmallCell ($q, |
679 |
- $q->a ({href => $q->url (-absolute => 1) |
680 |
- . "?page=0&page_stack=&g=$g&list=exceptionfileurllist$g&wherenext=ViewList"}, $Lallowurl)), |
681 |
- esmith::cgi::genSmallCell ($q, |
682 |
- $q->a ({href => $q->url (-absolute => 1) |
683 |
- . "?page=0&page_stack=&g=f0&list=exceptionvirusextensionlist&wherenext=ViewList"}, $LAVexcept))); |
684 |
- |
685 |
- print $q->Tr (esmith::cgi::genSmallCell ($q, $Lmimetype), |
686 |
- esmith::cgi::genSmallCell ($q, ''), |
687 |
- esmith::cgi::genSmallCell ($q, |
688 |
- $q->a ({href => $q->url (-absolute => 1) |
689 |
- . "?page=0&page_stack=&g=$g&list=exceptionmimetypelist$g&wherenext=ViewList"}, $Lexception)), |
690 |
- esmith::cgi::genSmallCell ($q, |
691 |
- $q->a ({href => $q->url (-absolute => 1) |
692 |
- . "?page=0&page_stack=&g=$g&list=bannedmimetypelist$g&wherenext=ViewList"}, $LDeny)), |
693 |
- esmith::cgi::genSmallCell ($q, |
694 |
- $q->a ({href => $q->url (-absolute => 1) |
695 |
- . "?page=0&page_stack=&g=$g&list=exceptionfilesitelist$g&wherenext=ViewList"}, $Lallowsite)), |
696 |
- esmith::cgi::genSmallCell ($q, |
697 |
- $q->a ({href => $q->url (-absolute => 1) |
698 |
- . "?page=0&page_stack=&g=f0&list=exceptionvirusmimetypelist&wherenext=ViewList"}, $LAVexcept))); |
699 |
- |
700 |
- #Client IP |
701 |
- if ($g eq 'f0') |
702 |
- { |
703 |
- print $q->Tr (esmith::cgi::genSmallCell ($q, $LClientIP), |
704 |
- esmith::cgi::genSmallCell ($q, ''), |
705 |
- esmith::cgi::genSmallCell ($q, |
706 |
- $q->a ({href => $q->url (-absolute => 1) |
707 |
- . "?page=0&page_stack=&g=$g&list=exceptioniplist&wherenext=ViewList"}, $Lexception)), |
708 |
- esmith::cgi::genSmallCell ($q, |
709 |
- $q->a ({href => $q->url (-absolute => 1) |
710 |
- . "?page=0&page_stack=&g=$g&list=bannediplist&wherenext=ViewList"}, $LDeny)), |
711 |
- esmith::cgi::genSmallCell ($q, ''), |
712 |
- esmith::cgi::genSmallCell ($q, '')); |
713 |
- } |
714 |
- |
715 |
- #prepared lists |
716 |
- unless ($g eq 'f0') |
717 |
- { |
718 |
- print $q->Tr (esmith::cgi::genSmallCell ($q, $ENABLED), |
719 |
- esmith::cgi::genSmallCell ($q, ''), |
720 |
- esmith::cgi::genSmallCell ($q, |
721 |
- $q->a ({href => $q->url (-absolute => 1) |
722 |
- . "?page=0&page_stack=&g=$g&gname=$gname&wherenext=ViewPhraseList"}, $Lphraselist)), |
723 |
- esmith::cgi::genSmallCell ($q, |
724 |
- $q->a ({href => $q->url (-absolute => 1) |
725 |
- . "?page=0&page_stack=&g=$g&gname=$gname&wherenext=ViewBlackList"}, $Lblacklist)), |
726 |
- esmith::cgi::genSmallCell ($q, ''), |
727 |
- esmith::cgi::genSmallCell ($q, '')); |
728 |
- } |
729 |
- |
730 |
- print $q->end_table; |
731 |
- return ""; |
732 |
-} |
733 |
- |
734 |
-sub print_list_description |
735 |
-{ |
736 |
- my $self = shift; |
737 |
- my $q = $self->{cgi}; |
738 |
- my $g = $q->param ('g') ||''; |
739 |
- my $desc = $self->localise('MODIFY_LIST_SETTINGS'); |
740 |
- |
741 |
- if ($g eq 'f0') |
742 |
- { |
743 |
- $desc = $self->localise('MODIFY_GLOBAL_LIST_SETTINGS'); |
744 |
- } |
745 |
- |
746 |
- return "$desc"; |
747 |
-} |
748 |
- |
749 |
-sub print_record_table |
750 |
-{ |
751 |
- my $self = shift; |
752 |
- my $q = $self->{cgi}; |
753 |
- my $g = $q->param ('g') ||''; |
754 |
- my $list = $q->param('list') ||''; |
755 |
- |
756 |
- my $record = $self->localise('RECORD'); |
757 |
- my $modify = $self->localise('MODIFY'); |
758 |
- my $remove = $self->localise('REMOVE'); |
759 |
- my $new = $self->localise('NEW'); |
760 |
- |
761 |
- |
762 |
- print $q->start_table({-CLASS => "sme-border"}),"\n"; |
763 |
- print $q->Tr ( |
764 |
- esmith::cgi::genSmallCell($q, $record,"header"), |
765 |
- esmith::cgi::genSmallCell($q, '',"header"), |
766 |
- esmith::cgi::genSmallCell($q, '',"header")),"\n"; |
767 |
- |
768 |
- print $q->Tr (esmith::cgi::genSmallCell ($q, ''), |
769 |
- esmith::cgi::genSmallCell ($q, ''), |
770 |
- esmith::cgi::genSmallCell ($q, |
771 |
- $q->a ({href => $q->url (-absolute => 1) |
772 |
- . "?page=0&page_stack=&g=$g&list=$list&key=new&wherenext=Edit"}, $new))); |
773 |
- |
774 |
- foreach my $hash ($ddb->get_all_by_prop(type => $list)) |
775 |
- { |
776 |
- my $key = $hash->key; |
777 |
- my $criterion = $hash->prop("criterion") || ''; |
778 |
- |
779 |
- #allows for three sets of bracketed words |
780 |
- #$record =~ s/</<\;/g; ?? |
781 |
- #$record =~ s/>/>\;/g; |
782 |
- $criterion =~ s/</<\;/; |
783 |
- $criterion =~ s/>/>\;/; |
784 |
- $criterion =~ s/</<\;/; |
785 |
- $criterion =~ s/>/>\;/; |
786 |
- $criterion =~ s/</<\;/; |
787 |
- $criterion =~ s/>/>\;/; |
788 |
- |
789 |
- print $q->Tr (esmith::cgi::genSmallCell ($q, $criterion), |
790 |
- esmith::cgi::genSmallCell ($q, |
791 |
- $q->a ({href => $q->url (-absolute => 1) |
792 |
- . "?page=0&page_stack=&g=$g&list=$list&key=$key&wherenext=Edit"}, $modify)), |
793 |
- esmith::cgi::genSmallCell ($q, |
794 |
- $q->a ({href => $q->url (-absolute => 1) |
795 |
- . "?page=0&page_stack=&g=$g&criterion=$criterion&key=$key&wherenext=Delete"}, $remove))); |
796 |
- } |
797 |
- |
798 |
- print $q->end_table; |
799 |
- |
800 |
- return ""; |
801 |
-} |
802 |
- |
803 |
-sub print_all_lists |
804 |
-{ |
805 |
- my $self = shift; |
806 |
- my $q = $self->{cgi}; |
807 |
- my $g = $q->param ('g') ||''; |
808 |
- my $all = (); |
809 |
- |
810 |
- if ($g =~ /^(f\d{1})$/) |
811 |
- { |
812 |
- $g = $1; |
813 |
- } |
814 |
- |
815 |
- print $q->start_table({-CLASS => "sme-border"}),"\n"; |
816 |
- |
817 |
- $all .= "<code>\n"; |
818 |
- |
819 |
- my @files = ('bannedextensionlist','bannedsitelist','exceptionfilesitelist','exceptionregexpurllist', |
820 |
- 'greysitelist','weightedphraselist','bannedmimetypelist','bannedurllist','exceptionfileurllist', |
821 |
- 'exceptionsitelist','greyurllist','bannedphraselist','contentregexplist','exceptionmimetypelist','exceptionurllist','pics', |
822 |
- 'bannedregexpurllist','exceptionextensionlist','exceptionphraselist','greyregexpurllist','urlregexplist'); |
823 |
- |
824 |
- foreach (@files) |
825 |
- { |
826 |
- |
827 |
- if ( -e "/etc/dansguardian/lists/$g/$_" ) |
828 |
- { |
829 |
- open (INF,"/etc/dansguardian/lists/$g/$_") |
830 |
- or die ("can't open /etc/dansguardian/lists/$g/$_ to read. "); |
831 |
- |
832 |
- $all .= "<br>\n"; |
833 |
- $all .= "<b> /etc/dansguardian/lists/$g/$_ </b><br>\n"; |
834 |
- |
835 |
- while (<INF>) |
836 |
- { |
837 |
- # allow for 4 sets |
838 |
- $_ =~ s/</<\;/; |
839 |
- $_ =~ s/>/>\;/; |
840 |
- $_ =~ s/</<\;/; |
841 |
- $_ =~ s/>/>\;/; |
842 |
- $_ =~ s/</<\;/; |
843 |
- $_ =~ s/>/>\;/; |
844 |
- $_ =~ s/</<\;/; |
845 |
- $_ =~ s/>/>\;/; |
846 |
- |
847 |
- $all .= "$_<br>\n"; |
848 |
- } |
849 |
- close INF; |
850 |
- } |
851 |
- } |
852 |
- |
853 |
- $all .= "<\code>\n"; |
854 |
- |
855 |
- print $q->end_table; |
856 |
- |
857 |
- return "$all"; |
858 |
-} |
859 |
- |
860 |
-sub print_common_lists |
861 |
-{ |
862 |
- my $self = shift; |
863 |
- my $q = $self->{cgi}; |
864 |
- my $g = $q->param ('g') ||''; |
865 |
- my $all = (); |
866 |
- |
867 |
- if ($g =~ /^(f\d{1})$/) |
868 |
- { |
869 |
- $g = $1; |
870 |
- } |
871 |
- |
872 |
- print $q->start_table({-CLASS => "sme-border"}),"\n"; |
873 |
- |
874 |
- $all .= "<code>\n"; |
875 |
- |
876 |
- my @files = ('exceptioniplist','bannediplist','contentscanners/exceptionvirusextensionlist', |
877 |
- 'contentscanners/exceptionvirusmimetypelist','contentscanners/exceptionvirussitelist','contentscanners/exceptionvirusurllist'); |
878 |
- |
879 |
- foreach (@files) |
880 |
- { |
881 |
- |
882 |
- if ( -e "/etc/dansguardian/lists/$_" ) |
883 |
- { |
884 |
- open (INF,"/etc/dansguardian/lists/$_") |
885 |
- or die ("can't open /etc/dansguardian/lists/$_ to read. "); |
886 |
- |
887 |
- $all .= "<br>\n"; |
888 |
- $all .= "<b> /etc/dansguardian/lists/$_ </b><br>\n"; |
889 |
- |
890 |
- while (<INF>) |
891 |
- { |
892 |
- # allow for 4 sets |
893 |
- $_ =~ s/</<\;/; |
894 |
- $_ =~ s/>/>\;/; |
895 |
- $_ =~ s/</<\;/; |
896 |
- $_ =~ s/>/>\;/; |
897 |
- $_ =~ s/</<\;/; |
898 |
- $_ =~ s/>/>\;/; |
899 |
- $_ =~ s/</<\;/; |
900 |
- $_ =~ s/>/>\;/; |
901 |
- |
902 |
- $all .= "$_<br>\n"; |
903 |
- } |
904 |
- close INF; |
905 |
- } |
906 |
- } |
907 |
- |
908 |
- $all .= "<\code>\n"; |
909 |
- |
910 |
- print $q->end_table; |
911 |
- |
912 |
- return "$all"; |
913 |
-} |
914 |
- |
915 |
-sub print_phraselist_head |
916 |
-{ |
917 |
- my $self = shift; |
918 |
- my $q = $self->{cgi} ||''; |
919 |
- my $all = (); |
920 |
- |
921 |
- print $q->start_table({-CLASS => "sme-border"}),"\n"; |
922 |
- |
923 |
- $all .= "<code>\n"; |
924 |
- |
925 |
- system ("/usr/bin/head /etc/dansguardian/lists/phraselists/*/* > /tmp/lists") == 0 |
926 |
- or die ("Error occurred reading phraselists\n"); |
927 |
- |
928 |
- if ( -e "/tmp/lists" ) |
929 |
- { |
930 |
- open (INF,"/tmp/lists") |
931 |
- or die ("can't open /tmp/lists read. "); |
932 |
- |
933 |
- $all .= "<br><b> head /etc/dansguardian/lists/phraselists/* </b><br>\n"; |
934 |
- |
935 |
- while (<INF>) |
936 |
- { |
937 |
- # allow for 4 sets |
938 |
- $_ =~ s/</<\;/; |
939 |
- $_ =~ s/>/>\;/; |
940 |
- $_ =~ s/</<\;/; |
941 |
- $_ =~ s/>/>\;/; |
942 |
- $_ =~ s/</<\;/; |
943 |
- $_ =~ s/>/>\;/; |
944 |
- $_ =~ s/</<\;/; |
945 |
- $_ =~ s/>/>\;/; |
946 |
- |
947 |
- $all .= "$_<br>\n"; |
948 |
- } |
949 |
- close INF; |
950 |
- } |
951 |
- |
952 |
- $all .= "<\code>\n"; |
953 |
- print $q->end_table; |
954 |
- return "$all"; |
955 |
-} |
956 |
-sub print_blacklist_head |
957 |
-{ |
958 |
- my $self = shift; |
959 |
- my $q = $self->{cgi}; |
960 |
- my $all = (); |
961 |
- |
962 |
- print $q->start_table({-CLASS => "sme-border"}),"\n"; |
963 |
- |
964 |
- $all .= "<code>\n"; |
965 |
- |
966 |
- system ("/usr/bin/head /etc/dansguardian/blacklists/*/* > /tmp/lists") == 0 |
967 |
- or die ("Error occurred reading phraselists\n"); |
968 |
- |
969 |
- if ( -e "/tmp/lists" ) |
970 |
- { |
971 |
- open (INF,"/tmp/lists") |
972 |
- or die ("can't open /tmp/lists read. "); |
973 |
- |
974 |
- $all .= "<br><b> head /etc/dansguardian/blacklists/* </b><br>\n"; |
975 |
- |
976 |
- while (<INF>) |
977 |
- { |
978 |
- # allow for 4 sets |
979 |
- $_ =~ s/</<\;/; |
980 |
- $_ =~ s/>/>\;/; |
981 |
- $_ =~ s/</<\;/; |
982 |
- $_ =~ s/>/>\;/; |
983 |
- $_ =~ s/</<\;/; |
984 |
- $_ =~ s/>/>\;/; |
985 |
- $_ =~ s/</<\;/; |
986 |
- $_ =~ s/>/>\;/; |
987 |
- |
988 |
- $all .= "$_<br>\n"; |
989 |
- } |
990 |
- close INF; |
991 |
- } |
992 |
- |
993 |
- $all .= "<\code>\n"; |
994 |
- print $q->end_table; |
995 |
- return "$all"; |
996 |
-} |
997 |
- |
998 |
-sub save_record |
999 |
-{ |
1000 |
- my $self = shift; |
1001 |
- my $q = $self->{cgi}; |
1002 |
- my $g = $q->param ('g') ||''; |
1003 |
- my $key = $q->param ('key') ||''; |
1004 |
- my $list = $q->param ('list') ||''; |
1005 |
- my $criterion = $q->param ('criterion'); |
1006 |
- |
1007 |
- if ($key eq 'new') |
1008 |
- { |
1009 |
- my $random = int(rand(999999)); |
1010 |
- $key = $list.$random; |
1011 |
- $ddb->new_record($key, { type => "$list" }); |
1012 |
- } |
1013 |
- $ddb->set_prop($key, 'criterion', $criterion); |
1014 |
- |
1015 |
- return $self->success("SUCCESS_STORED"); |
1016 |
-} |
1017 |
-sub delete_record |
1018 |
-{ |
1019 |
- my $self = shift; |
1020 |
- my $q = $self->{cgi} ||''; |
1021 |
- my $key = $q->param('key') ||''; |
1022 |
- |
1023 |
- my $rec = $ddb->get($key); |
1024 |
- $rec->delete; |
1025 |
- |
1026 |
- return $self->success("SUCCESS_STORED"); |
1027 |
-} |
1028 |
- |
1029 |
-sub print_phraselist_table |
1030 |
-{ |
1031 |
- my $self = shift; |
1032 |
- my $q = $self->{cgi}; |
1033 |
- my $g = $q->param ('g') ||''; |
1034 |
- |
1035 |
- my $Llist = $self->localise('LIST'); |
1036 |
- |
1037 |
- my @lists = $pdb->get_all_by_prop(type => "list"); |
1038 |
- my @gnames = ''; |
1039 |
- foreach my $g (@lists) |
1040 |
- { |
1041 |
- my $groupname = $g->key(); |
1042 |
- push (@gnames, $groupname) |
1043 |
- } |
1044 |
- |
1045 |
- my @installed = ('badwords','googlesearches'); |
1046 |
- foreach (@gnames) |
1047 |
- { |
1048 |
- push (@installed, $_) |
1049 |
- if (-e "/etc/dansguardian/lists/phraselists/$_/weighted"); |
1050 |
- } |
1051 |
- |
1052 |
- #hide table if you have no rules |
1053 |
- my $installed = @installed || 'no lists'; |
1054 |
- if ($installed eq 'no lists') |
1055 |
- { |
1056 |
- return "$self->localise('ERROR');" |
1057 |
- } |
1058 |
- else |
1059 |
- { |
1060 |
- |
1061 |
- print $q->start_table({-CLASS => "sme-border"}),"\n"; |
1062 |
- |
1063 |
- print $q->Tr ( esmith::cgi::genSmallCell($q, $Llist,"header"), |
1064 |
- esmith::cgi::genSmallCell($q, '',"header")),"\n"; |
1065 |
- |
1066 |
- #checkboxes |
1067 |
- my ($a, $aa) = ''; |
1068 |
- foreach (sort @installed) |
1069 |
- { |
1070 |
- $a = $_; |
1071 |
- $aa = $pdb->get_prop($_, $g) || ''; |
1072 |
- if ($aa eq 'on') { $aa = "checked"; } |
1073 |
- |
1074 |
- print $q->Tr (esmith::cgi::genSmallCell ($q, $_), |
1075 |
- esmith::cgi::genSmallCell ($q, ("<input type=\"checkbox\" name=\"$a\" $aa>"))); |
1076 |
- } |
1077 |
- } |
1078 |
- |
1079 |
- print $q->end_table; |
1080 |
- |
1081 |
- return ""; |
1082 |
-} |
1083 |
-sub save_phrase |
1084 |
-{ |
1085 |
- my $self = shift; |
1086 |
- my $q = $self->{cgi}; |
1087 |
- my $g = $q->param ('g') ||''; |
1088 |
- |
1089 |
- my @lists = $pdb->get_all_by_prop(type => "list"); |
1090 |
- my @gnames = ''; |
1091 |
- foreach my $g (@lists) |
1092 |
- { |
1093 |
- my $groupname = $g->key(); |
1094 |
- push (@gnames, $groupname) |
1095 |
- } |
1096 |
- |
1097 |
- my @installed = (); |
1098 |
- foreach (@gnames) |
1099 |
- { |
1100 |
- push (@installed, $_) |
1101 |
- if (-e "/etc/dansguardian/lists/phraselists/$_/weighted"); |
1102 |
- } |
1103 |
- |
1104 |
- #skip if you have nothing |
1105 |
- my $installed = @installed || 'no lists'; |
1106 |
- unless ($installed eq 'no lists') |
1107 |
- { |
1108 |
- #from checkboxes |
1109 |
- my ($a, $aa) = ''; |
1110 |
- foreach (@installed) |
1111 |
- { |
1112 |
- my $a = $_; |
1113 |
- my $aa = $q->param ($a) || ''; |
1114 |
- $pdb->set_prop($_, $g, $aa); |
1115 |
- } |
1116 |
- } |
1117 |
- |
1118 |
- return $self->success("SUCCESS_STORED"); |
1119 |
-} |
1120 |
- |
1121 |
- |
1122 |
-sub print_blacklist_table |
1123 |
-{ |
1124 |
- my $self = shift; |
1125 |
- my $q = $self->{cgi}; |
1126 |
- my $g = $q->param ('g') ||''; |
1127 |
- |
1128 |
- my $Llist = $self->localise('LIST'); |
1129 |
- my $LWhite = $self->localise('LWhite'); |
1130 |
- my $LGrey = $self->localise('Lgrey'); |
1131 |
- my $LBlack = $self->localise('LBlack'); |
1132 |
- |
1133 |
- my @lists = $bdb->get_all_by_prop(type => "list"); |
1134 |
- my @gnames = ''; |
1135 |
- foreach my $g (@lists) |
1136 |
- { |
1137 |
- my $groupname = $g->key(); |
1138 |
- push (@gnames, $groupname) |
1139 |
- } |
1140 |
- |
1141 |
- my @installed = (); |
1142 |
- foreach (@gnames) |
1143 |
- { |
1144 |
- push (@installed, $_) |
1145 |
- if (-e "/etc/dansguardian/blacklists/$_/domains"); |
1146 |
- } |
1147 |
- |
1148 |
- #hide table if you have no rules |
1149 |
- my $installed = @installed || 'no lists'; |
1150 |
- if ($installed eq 'no lists') |
1151 |
- { |
1152 |
- return "$self->localise('NO_BLACK');" |
1153 |
- } |
1154 |
- else |
1155 |
- { |
1156 |
- print $q->start_table({-CLASS => "sme-border"}),"\n"; |
1157 |
- print $q->Tr ( |
1158 |
- esmith::cgi::genSmallCell($q, $Llist,"header"), |
1159 |
- esmith::cgi::genSmallCell($q, $LWhite,"header"), |
1160 |
- esmith::cgi::genSmallCell($q, $LGrey,"header"), |
1161 |
- esmith::cgi::genSmallCell($q, $LBlack,"header")),"\n"; |
1162 |
- |
1163 |
- #checkboxes |
1164 |
- my ($a, $b, $c, $aa, $bb, $cc) = ''; |
1165 |
- foreach (sort @installed) |
1166 |
- { |
1167 |
- $a = $_.'white'; |
1168 |
- $aa = $bdb->get_prop($_, "white$g") || ''; |
1169 |
- if ($aa eq 'on') { $aa = "checked"; } |
1170 |
- |
1171 |
- my $b = $_.'grey'; |
1172 |
- $bb = $bdb->get_prop($_, "grey$g") || ''; |
1173 |
- if ($bb eq 'on') { $bb = "checked"; } |
1174 |
- |
1175 |
- my $c = $_.'black'; |
1176 |
- $cc= $bdb->get_prop($_, "black$g") || ''; |
1177 |
- if ($cc eq 'on') { $cc = "checked"; } |
1178 |
- |
1179 |
- #todo |
1180 |
- my $listname = $self->localise($_); |
1181 |
- |
1182 |
- print $q->Tr |
1183 |
- (esmith::cgi::genSmallCell ($q, $listname), |
1184 |
- esmith::cgi::genSmallCell ($q, ("<input type=\"checkbox\" name=\"$a\" $aa>")), |
1185 |
- esmith::cgi::genSmallCell ($q, ("<input type=\"checkbox\" name=\"$b\" $bb>")), |
1186 |
- esmith::cgi::genSmallCell ($q, ("<input type=\"checkbox\" name=\"$c\" $cc>"))); |
1187 |
- } |
1188 |
- } |
1189 |
- |
1190 |
- print $q->end_table; |
1191 |
- |
1192 |
- return ""; |
1193 |
-} |
1194 |
-sub save_black |
1195 |
-{ |
1196 |
- my $self = shift; |
1197 |
- my $q = $self->{cgi}; |
1198 |
- my $g = $q->param ('g') ||''; |
1199 |
- |
1200 |
- my @lists = $bdb->get_all_by_prop(type => "list"); |
1201 |
- my @gnames = ''; |
1202 |
- foreach my $g (@lists) |
1203 |
- { |
1204 |
- my $groupname = $g->key(); |
1205 |
- push (@gnames, $groupname) |
1206 |
- } |
1207 |
- |
1208 |
- my @installed = (); |
1209 |
- foreach (@gnames) |
1210 |
- { |
1211 |
- push (@installed, $_) |
1212 |
- if (-e "/etc/dansguardian/blacklists/$_/domains"); |
1213 |
- } |
1214 |
- |
1215 |
- #skip if you have nothing |
1216 |
- my $installed = @installed || 'no lists'; |
1217 |
- unless ($installed eq 'no lists') |
1218 |
- { |
1219 |
- #from checkboxes |
1220 |
- my ($a, $b, $c, $aa, $bb, $cc,) = ''; |
1221 |
- foreach (@installed) |
1222 |
- { |
1223 |
- my $a = $_.'white'; |
1224 |
- my $aa = $q->param ("$a") || ''; |
1225 |
- $bdb->set_prop($_, "white$g", $aa); |
1226 |
- |
1227 |
- my $b = $_.'grey'; |
1228 |
- my $bb = $q->param ("$b") || ''; |
1229 |
- $bdb->set_prop($_, "grey$g", $bb); |
1230 |
- |
1231 |
- my $c = $_.'black'; |
1232 |
- my $cc = $q->param ("$c") || ''; |
1233 |
- $bdb->set_prop($_, "black$g", $cc); |
1234 |
- } |
1235 |
- } |
1236 |
- |
1237 |
- return $self->success("SUCCESS_STORED"); |
1238 |
-} |
1239 |
- |
1240 |
-1; |
1241 |
diff -Nur smeserver-dansguardian-panel-2.11-old/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/dungogdansguardian.pm smeserver-dansguardian-panel-2.11/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/dungogdansguardian.pm |
1242 |
--- smeserver-dansguardian-panel-2.11-old/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/dungogdansguardian.pm 1969-12-31 19:00:00.000000000 -0500 |
1243 |
+++ smeserver-dansguardian-panel-2.11/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/dungogdansguardian.pm 2009-03-13 22:23:20.000000000 -0400 |
1244 |
@@ -0,0 +1,1236 @@ |
1245 |
+#---------------------------------------------------------------------- |
1246 |
+# dungogdansguardian.pm |
1247 |
+# support@dungog.net |
1248 |
+#---------------------------------------------------------------------- |
1249 |
+ |
1250 |
+package esmith::FormMagick::Panel::dungogdansguardian; |
1251 |
+ |
1252 |
+use strict; |
1253 |
+use warnings; |
1254 |
+ |
1255 |
+use esmith::FormMagick; |
1256 |
+use esmith::ConfigDB; |
1257 |
+use esmith::AccountsDB; |
1258 |
+use esmith::cgi; |
1259 |
+ |
1260 |
+use Exporter; |
1261 |
+use Carp qw(verbose); |
1262 |
+ |
1263 |
+use HTML::Tabulate; |
1264 |
+ |
1265 |
+our @ISA = qw(esmith::FormMagick Exporter); |
1266 |
+ |
1267 |
+our @EXPORT = qw(); |
1268 |
+ |
1269 |
+our $db = esmith::ConfigDB->open(); |
1270 |
+our $adb = esmith::AccountsDB->open(); |
1271 |
+our $ddb = esmith::ConfigDB->open('dungog') or die "Could not open dungog DB\n"; |
1272 |
+our $bdb = esmith::ConfigDB->open('blacklist') or die "Could not open blacklist DB\n"; |
1273 |
+our $pdb = esmith::ConfigDB->open('phraselist') or die "Could not open phraselist DB\n"; |
1274 |
+ |
1275 |
+ |
1276 |
+sub new { |
1277 |
+ shift; |
1278 |
+ my $self = esmith::FormMagick->new(); |
1279 |
+ $self->{calling_package} = (caller)[0]; |
1280 |
+ bless $self; |
1281 |
+ return $self; |
1282 |
+} |
1283 |
+ |
1284 |
+sub get_loglevel |
1285 |
+{ |
1286 |
+ return $ddb->get_prop('dansguardian', 'loglevel'); |
1287 |
+} |
1288 |
+sub get_logfileformat |
1289 |
+{ |
1290 |
+ return $ddb->get_prop('dansguardian', 'logfileformat'); |
1291 |
+} |
1292 |
+sub get_proxyaccess |
1293 |
+{ |
1294 |
+ return $db->get_prop('squid', 'RequireAuth'); |
1295 |
+} |
1296 |
+sub get_portblocking |
1297 |
+{ |
1298 |
+ return $db->get_prop('dansguardian', 'portblocking'); |
1299 |
+} |
1300 |
+sub get_port |
1301 |
+{ |
1302 |
+ return $ddb->get_prop('dansguardian', 'port'); |
1303 |
+} |
1304 |
+sub get_status |
1305 |
+{ |
1306 |
+ return $db->get_prop('dansguardian', 'status'); |
1307 |
+} |
1308 |
+sub get_bypassproxyto |
1309 |
+{ |
1310 |
+ return $db->get_prop('squid', 'BypassProxyTo'); |
1311 |
+} |
1312 |
+sub get_bypassproxyfrom |
1313 |
+{ |
1314 |
+ return $db->get_prop('squid', 'BypassProxyFrom'); |
1315 |
+} |
1316 |
+sub get_TCPBlocks |
1317 |
+{ |
1318 |
+ return $db->get_prop('masq', 'TCPBlocks'); |
1319 |
+} |
1320 |
+sub get_UDPBlocks |
1321 |
+{ |
1322 |
+ return $db->get_prop('masq', 'UDPBlocks'); |
1323 |
+} |
1324 |
+sub get_mode |
1325 |
+{ |
1326 |
+ my $self = shift; |
1327 |
+ my $q = $self->{cgi}; |
1328 |
+ my $g = $q->param('g') ||''; |
1329 |
+ return $ddb->get_prop("dansguardian$g", 'mode'); |
1330 |
+} |
1331 |
+sub get_bypass |
1332 |
+{ |
1333 |
+ my $self = shift; |
1334 |
+ my $q = $self->{cgi}; |
1335 |
+ my $g = $q->param('g') ||''; |
1336 |
+ return $ddb->get_prop("dansguardian$g", 'bypass'); |
1337 |
+} |
1338 |
+sub get_reportinglevel |
1339 |
+{ |
1340 |
+ my $self = shift; |
1341 |
+ my $q = $self->{cgi}; |
1342 |
+ my $g = $q->param('g') ||''; |
1343 |
+ return $ddb->get_prop("dansguardian$g", 'reportinglevel'); |
1344 |
+} |
1345 |
+sub get_deniedpage |
1346 |
+{ |
1347 |
+ my $self = shift; |
1348 |
+ my $q = $self->{cgi}; |
1349 |
+ my $g = $q->param('g') ||''; |
1350 |
+ return $ddb->get_prop("dansguardian$g", 'deniedpage'); |
1351 |
+} |
1352 |
+sub get_deniedurl |
1353 |
+{ |
1354 |
+ my $self = shift; |
1355 |
+ my $q = $self->{cgi}; |
1356 |
+ my $g = $q->param('g') ||''; |
1357 |
+ return $ddb->get_prop("dansguardian$g", 'deniedurl'); |
1358 |
+} |
1359 |
+sub get_scan |
1360 |
+{ |
1361 |
+ my $self = shift; |
1362 |
+ my $q = $self->{cgi}; |
1363 |
+ my $g = $q->param('g') ||''; |
1364 |
+ return $ddb->get_prop("dansguardian$g", 'scan'); |
1365 |
+} |
1366 |
+sub get_weight |
1367 |
+{ |
1368 |
+ my $self = shift; |
1369 |
+ my $q = $self->{cgi}; |
1370 |
+ my $g = $q->param('g') ||''; |
1371 |
+ return $ddb->get_prop("dansguardian$g", 'weight'); |
1372 |
+} |
1373 |
+sub get_pics |
1374 |
+{ |
1375 |
+ my $self = shift; |
1376 |
+ my $q = $self->{cgi}; |
1377 |
+ my $g = $q->param('g' ||''); |
1378 |
+ return $ddb->get_prop("dansguardian$g", 'pics'); |
1379 |
+} |
1380 |
+sub get_regexpurl |
1381 |
+{ |
1382 |
+ my $self = shift; |
1383 |
+ my $q = $self->{cgi}; |
1384 |
+ my $g = $q->param('g') ||''; |
1385 |
+ return $ddb->get_prop("dansguardian$g", 'regexpurl'); |
1386 |
+} |
1387 |
+sub get_regexpsearch |
1388 |
+{ |
1389 |
+ my $self = shift; |
1390 |
+ my $q = $self->{cgi}; |
1391 |
+ my $g = $q->param('g') ||''; |
1392 |
+ return $ddb->get_prop("dansguardian$g", 'regexpsearch'); |
1393 |
+} |
1394 |
+sub get_regexpurlads |
1395 |
+{ |
1396 |
+ my $self = shift; |
1397 |
+ my $q = $self->{cgi}; |
1398 |
+ my $g = $q->param('g') ||''; |
1399 |
+ return $ddb->get_prop("dansguardian$g", 'regexpurlads'); |
1400 |
+} |
1401 |
+sub get_regexpurlproxy |
1402 |
+{ |
1403 |
+ my $self = shift; |
1404 |
+ my $q = $self->{cgi}; |
1405 |
+ my $g = $q->param('g') ||''; |
1406 |
+ return $ddb->get_prop("dansguardian$g", 'regexpurlproxy'); |
1407 |
+} |
1408 |
+sub get_blanketban |
1409 |
+{ |
1410 |
+ my $self = shift; |
1411 |
+ my $q = $self->{cgi}; |
1412 |
+ my $g = $q->param('g') ||''; |
1413 |
+ return $ddb->get_prop("dansguardian$g", 'blanketban'); |
1414 |
+} |
1415 |
+sub get_ipban |
1416 |
+{ |
1417 |
+ my $self = shift; |
1418 |
+ my $q = $self->{cgi}; |
1419 |
+ my $g = $q->param('g') ||''; |
1420 |
+ return $ddb->get_prop("dansguardian$g", 'ipban'); |
1421 |
+} |
1422 |
+sub get_https |
1423 |
+{ |
1424 |
+ my $self = shift; |
1425 |
+ my $q = $self->{cgi}; |
1426 |
+ my $g = $q->param('g') ||''; |
1427 |
+ return $ddb->get_prop("dansguardian$g", 'https'); |
1428 |
+} |
1429 |
+sub get_file |
1430 |
+{ |
1431 |
+ my $self = shift; |
1432 |
+ my $q = $self->{cgi}; |
1433 |
+ my $g = $q->param('g') ||''; |
1434 |
+ return $ddb->get_prop("dansguardian$g", 'file'); |
1435 |
+} |
1436 |
+sub get_criterion |
1437 |
+{ |
1438 |
+ my $self = shift; |
1439 |
+ my $q = $self->{cgi}; |
1440 |
+ my $key = $q->param('key') ||''; |
1441 |
+ return $ddb->get_prop($key, 'criterion') || ''; |
1442 |
+} |
1443 |
+ |
1444 |
+sub get_status_summary |
1445 |
+{ |
1446 |
+ my $self = shift; |
1447 |
+ my $q = $self->{cgi}; |
1448 |
+ |
1449 |
+ my $status = $db->get_prop('dansguardian', "status"); |
1450 |
+ my $Auth = $db->get_prop('squid', "RequireAuth"); |
1451 |
+ my $port = $ddb->get_prop('dansguardian', "port"); |
1452 |
+ my $block = $db->get_prop('dansguardian', "portblocking"); |
1453 |
+ |
1454 |
+ my $STATUS = $self->localise('STATUS'); |
1455 |
+ my $PORT = $self->localise('PORT'); |
1456 |
+ my $PROXYACCESS = $self->localise('PROXYACCESS'); |
1457 |
+ my $BLOCKING = $self->localise('PORTBLOCKING'); |
1458 |
+ |
1459 |
+ my $status2; |
1460 |
+ if ($status eq 'enabled') |
1461 |
+ { $status2 = $self->localise('ENABLED'); } else { $status2 = $self->localise('DISABLED'); } |
1462 |
+ |
1463 |
+ my $block2; |
1464 |
+ if ($block eq 'yes') |
1465 |
+ { $block2 = $self->localise('ENABLED'); } else { $block2 = $self->localise('DISABLED'); } |
1466 |
+ |
1467 |
+ return "$STATUS : <b>$status2</b>, $PORT : <b>$port</b>, $PROXYACCESS : <b>$Auth</b>, $BLOCKING : <b>$block2</b>"; |
1468 |
+} |
1469 |
+ |
1470 |
+sub get_custom_denied |
1471 |
+{ |
1472 |
+ my $self = shift; |
1473 |
+ my $q = $self->{cgi}; |
1474 |
+ my $g = $q->param('g') ||''; |
1475 |
+ my $Ldefault = $self->localise('Ldefault'); |
1476 |
+ |
1477 |
+ my $defaults = $ddb->get_prop("dansguardian", "deniedurl") || 'dansguardian.pl'; |
1478 |
+ |
1479 |
+ my $deniedurl = $ddb->get_prop("dansguardian$g", "deniedurl") || 'nul'; |
1480 |
+ if (($deniedurl eq 'nul') && (-e "/home/e-smith/files/ibays/Primary/cgi-bin/dansguardian$g.pl")) |
1481 |
+ { $deniedurl = "dansguardian$g.pl"; } |
1482 |
+ |
1483 |
+ my $language = $ddb->get_prop('dansguardian', "language") || 'ukenglish'; |
1484 |
+ my $customhtml = 'nul'; |
1485 |
+ if (-e "/etc/dansguardian/languages/$language/template$g.html") |
1486 |
+ { $customhtml = "$language/template$g.html"; } |
1487 |
+ |
1488 |
+ return "$Ldefault = $defaults, html = $customhtml, cgi = $deniedurl"; |
1489 |
+} |
1490 |
+ |
1491 |
+sub print_global_table |
1492 |
+{ |
1493 |
+ my $self = shift; |
1494 |
+ my $q = $self->{cgi}; |
1495 |
+ |
1496 |
+ my $description = $self->localise('DESCRIPTION'); |
1497 |
+ my $Lf2 = $self->localise('Lf2'); |
1498 |
+ my $Lf3 = $self->localise('Lf3'); |
1499 |
+ my $Lf4 = $self->localise('Lf4'); |
1500 |
+ my $Lf5 = $self->localise('Lf5'); |
1501 |
+ |
1502 |
+ my @groups = $adb->get_all_by_prop(type => "group"); |
1503 |
+ my @gnames = ''; |
1504 |
+ foreach my $g (@groups) |
1505 |
+ { |
1506 |
+ my $groupname = $g->key(); |
1507 |
+ push (@gnames, $groupname) |
1508 |
+ } |
1509 |
+ |
1510 |
+ print $q->start_table({-CLASS => "sme-border"}),"\n"; |
1511 |
+ print $q->Tr ( |
1512 |
+ esmith::cgi::genSmallCell($q, $description,"header"), |
1513 |
+ esmith::cgi::genSmallCell($q, '',"header")),"\n"; |
1514 |
+ |
1515 |
+ |
1516 |
+ print $q->Tr (esmith::cgi::genSmallCell ($q, $Lf2), |
1517 |
+ esmith::cgi::genSmallCell ($q, |
1518 |
+ $q->popup_menu (-name => "f2", |
1519 |
+ -values => [ sort @gnames ], |
1520 |
+ -default => $ddb->get_prop('dansguardian', "f2") || ''))); |
1521 |
+ |
1522 |
+ print $q->Tr (esmith::cgi::genSmallCell ($q, $Lf3), |
1523 |
+ esmith::cgi::genSmallCell ($q, |
1524 |
+ $q->popup_menu (-name => "f3", |
1525 |
+ -values => [ sort @gnames ], |
1526 |
+ -default => $ddb->get_prop('dansguardian', "f3") || ''))); |
1527 |
+ |
1528 |
+ print $q->Tr (esmith::cgi::genSmallCell ($q, $Lf4), |
1529 |
+ esmith::cgi::genSmallCell ($q, |
1530 |
+ $q->popup_menu (-name => "f4", |
1531 |
+ -values => [ sort @gnames ], |
1532 |
+ -default => $ddb->get_prop('dansguardian', "f4") || ''))); |
1533 |
+ |
1534 |
+ print $q->Tr (esmith::cgi::genSmallCell ($q, $Lf5), |
1535 |
+ esmith::cgi::genSmallCell ($q, |
1536 |
+ $q->popup_menu (-name => "f5", |
1537 |
+ -values => [ sort @gnames ], |
1538 |
+ -default => $ddb->get_prop('dansguardian', "f5") || ''))); |
1539 |
+ |
1540 |
+ print $q->end_table; |
1541 |
+ |
1542 |
+ return ""; |
1543 |
+} |
1544 |
+ |
1545 |
+sub print_summary |
1546 |
+{ |
1547 |
+ my $self = shift; |
1548 |
+ my $q = $self->{cgi}; |
1549 |
+ |
1550 |
+ my $description = $self->localise('DESCRIPTION'); |
1551 |
+ my $LAllow = $self->localise('LAllow'); |
1552 |
+ my $LClient_IP = $self->localise('LClient_IP'); |
1553 |
+ my $LDeny = $self->localise('LDeny'); |
1554 |
+ my $modify = $self->localise('MODIFY'); |
1555 |
+ my $Lcommon = $self->localise('Lcommon'); |
1556 |
+ my $Ldefault = $self->localise('Ldefault'); |
1557 |
+ my $Lf0 = $self->localise('Lf0'); |
1558 |
+ my $Lf1 = $self->localise('Lf1'); |
1559 |
+ my $Lf2 = $self->localise('Lf2'); |
1560 |
+ my $Lf3 = $self->localise('Lf3'); |
1561 |
+ my $Lf4 = $self->localise('Lf4'); |
1562 |
+ my $Lf5 = $self->localise('Lf5'); |
1563 |
+ my $GROUP = $self->localise('GROUP'); |
1564 |
+ my $Lmode = $self->localise('Lmode'); |
1565 |
+ my $LURLban = $self->localise('LURLban'); |
1566 |
+ my $Lscan = $self->localise('Lscan'); |
1567 |
+ my $Lbypass = $self->localise('Lbypass'); |
1568 |
+ my $Llists = $self->localise('Llists'); |
1569 |
+ my $Lsettings = $self->localise('Lsettings'); |
1570 |
+ |
1571 |
+ my @groups = $adb->get_all_by_prop(type => "group"); |
1572 |
+ my @gnames = ''; |
1573 |
+ foreach my $g (@groups) |
1574 |
+ { |
1575 |
+ my $groupname = $g->key(); |
1576 |
+ push (@gnames, $groupname) |
1577 |
+ } |
1578 |
+ |
1579 |
+ print $q->start_table({-CLASS => "sme-border"}),"\n"; |
1580 |
+ print $q->Tr ( |
1581 |
+ esmith::cgi::genSmallCell($q, $description,"header"), |
1582 |
+ esmith::cgi::genSmallCell($q, $GROUP,"header"), |
1583 |
+ esmith::cgi::genSmallCell($q, $Lmode,"header"), |
1584 |
+ esmith::cgi::genSmallCell($q, $LURLban,"header"), |
1585 |
+ esmith::cgi::genSmallCell($q, $Lscan,"header"), |
1586 |
+ esmith::cgi::genSmallCell($q, $Lbypass,"header"), |
1587 |
+ esmith::cgi::genSmallCell($q, $Lsettings,"header"), |
1588 |
+ esmith::cgi::genSmallCell($q, $Llists,"header")),"\n"; |
1589 |
+ |
1590 |
+ print $q->Tr (esmith::cgi::genSmallCell ($q, $Lf0), |
1591 |
+ esmith::cgi::genSmallCell ($q, ''), |
1592 |
+ esmith::cgi::genSmallCell ($q, ''), |
1593 |
+ esmith::cgi::genSmallCell ($q, ''), |
1594 |
+ esmith::cgi::genSmallCell ($q, ''), |
1595 |
+ esmith::cgi::genSmallCell ($q, ''), |
1596 |
+ esmith::cgi::genSmallCell ($q, ''), |
1597 |
+ esmith::cgi::genSmallCell ($q, |
1598 |
+ $q->a ({href => $q->url (-absolute => 1) |
1599 |
+ . "?page=0&page_stack=&g=f0&gname=$Lcommon&wherenext=GroupLists"}, $modify))); |
1600 |
+ |
1601 |
+ print $q->Tr (esmith::cgi::genSmallCell ($q, $Lf1), |
1602 |
+ esmith::cgi::genSmallCell ($q, ''), |
1603 |
+ esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf1', "mode") || ''), |
1604 |
+ esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf1', "blanketban") . " / " . |
1605 |
+ $ddb->get_prop('dansguardianf1', "https") . " / " . |
1606 |
+ $ddb->get_prop('dansguardianf1', "ipban") . " / " . |
1607 |
+ $ddb->get_prop('dansguardianf1', "file") . " - " . |
1608 |
+ $ddb->get_prop('dansguardianf1', "regexpurl") . " / " . |
1609 |
+ $ddb->get_prop('dansguardianf1', "regexpurlads") . " / " . |
1610 |
+ $ddb->get_prop('dansguardianf1', "regexpurlproxy")), |
1611 |
+ esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf1', "scan") || ''), |
1612 |
+ esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf1', "bypass") || ''), |
1613 |
+ esmith::cgi::genSmallCell ($q, |
1614 |
+ $q->a ({href => $q->url (-absolute => 1) |
1615 |
+ . "?page=0&page_stack=&g=f1&gname=$Ldefault&wherenext=GroupSettings"}, $modify)), |
1616 |
+ esmith::cgi::genSmallCell ($q, |
1617 |
+ $q->a ({href => $q->url (-absolute => 1) |
1618 |
+ . "?page=0&page_stack=&g=f1&gname=$Ldefault&wherenext=GroupLists"}, $modify))); |
1619 |
+ |
1620 |
+ my $gname = $ddb->get_prop('dansguardian', "f2"); |
1621 |
+ if ($gname) { |
1622 |
+ print $q->Tr (esmith::cgi::genSmallCell ($q, $Lf2), |
1623 |
+ esmith::cgi::genSmallCell ($q, $gname ), |
1624 |
+ esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf2', "mode") || ''), |
1625 |
+ esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf2', "blanketban") . " / " . |
1626 |
+ $ddb->get_prop('dansguardianf2', "https") . " / " . |
1627 |
+ $ddb->get_prop('dansguardianf2', "ipban") . " / " . |
1628 |
+ $ddb->get_prop('dansguardianf2', "file") . " - " . |
1629 |
+ $ddb->get_prop('dansguardianf2', "regexpurl") . " / " . |
1630 |
+ $ddb->get_prop('dansguardianf2', "regexpurlads") . " / " . |
1631 |
+ $ddb->get_prop('dansguardianf2', "regexpurlproxy")), |
1632 |
+ esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf2', "scan") || ''), |
1633 |
+ esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf2', "bypass") || ''), |
1634 |
+ esmith::cgi::genSmallCell ($q, |
1635 |
+ $q->a ({href => $q->url (-absolute => 1) |
1636 |
+ . "?page=0&page_stack=&g=f2&gname=$gname&wherenext=GroupSettings"}, $modify)), |
1637 |
+ esmith::cgi::genSmallCell ($q, |
1638 |
+ $q->a ({href => $q->url (-absolute => 1) |
1639 |
+ . "?page=0&page_stack=&g=f2&gname=$gname&wherenext=GroupLists"}, $modify))); |
1640 |
+ } |
1641 |
+ |
1642 |
+ $gname = $ddb->get_prop('dansguardian', "f3"); |
1643 |
+ if ($gname) { |
1644 |
+ print $q->Tr (esmith::cgi::genSmallCell ($q, $Lf3), |
1645 |
+ esmith::cgi::genSmallCell ($q, $gname ), |
1646 |
+ esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf3', "mode") || ''), |
1647 |
+ esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf3', "blanketban") . " / " . |
1648 |
+ $ddb->get_prop('dansguardianf3', "https") . " / " . |
1649 |
+ $ddb->get_prop('dansguardianf3', "ipban") . " / " . |
1650 |
+ $ddb->get_prop('dansguardianf3', "file") . " - " . |
1651 |
+ $ddb->get_prop('dansguardianf3', "regexpurl") . " / " . |
1652 |
+ $ddb->get_prop('dansguardianf3', "regexpurlads") . " / " . |
1653 |
+ $ddb->get_prop('dansguardianf3', "regexpurlproxy")), |
1654 |
+ esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf3', "scan") || ''), |
1655 |
+ esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf3', "bypass") || ''), |
1656 |
+ esmith::cgi::genSmallCell ($q, |
1657 |
+ $q->a ({href => $q->url (-absolute => 1) |
1658 |
+ . "?page=0&page_stack=&g=f3&gname=$gname&wherenext=GroupSettings"}, $modify)), |
1659 |
+ esmith::cgi::genSmallCell ($q, |
1660 |
+ $q->a ({href => $q->url (-absolute => 1) |
1661 |
+ . "?page=0&page_stack=&g=f3&gname=$gname&wherenext=GroupLists"}, $modify))); |
1662 |
+ } |
1663 |
+ |
1664 |
+ $gname = $ddb->get_prop('dansguardian', "f4"); |
1665 |
+ if ($gname) { |
1666 |
+ print $q->Tr (esmith::cgi::genSmallCell ($q, $Lf4), |
1667 |
+ esmith::cgi::genSmallCell ($q, $gname ), |
1668 |
+ esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf4', "mode") || ''), |
1669 |
+ esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf4', "blanketban") . " / " . |
1670 |
+ $ddb->get_prop('dansguardianf4', "https") . " / " . |
1671 |
+ $ddb->get_prop('dansguardianf4', "ipban") . " / " . |
1672 |
+ $ddb->get_prop('dansguardianf4', "file") . " - " . |
1673 |
+ $ddb->get_prop('dansguardianf4', "regexpurl") . " / " . |
1674 |
+ $ddb->get_prop('dansguardianf4', "regexpurlads") . " / " . |
1675 |
+ $ddb->get_prop('dansguardianf4', "regexpurlproxy")), |
1676 |
+ esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf4', "scan") || ''), |
1677 |
+ esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf4', "bypass") || ''), |
1678 |
+ esmith::cgi::genSmallCell ($q, |
1679 |
+ $q->a ({href => $q->url (-absolute => 1) |
1680 |
+ . "?page=0&page_stack=&g=f4&gname=$gname&wherenext=GroupSettings"}, $modify)), |
1681 |
+ esmith::cgi::genSmallCell ($q, |
1682 |
+ $q->a ({href => $q->url (-absolute => 1) |
1683 |
+ . "?page=0&page_stack=&g=f4&gname=$gname&wherenext=GroupLists"}, $modify))); |
1684 |
+ } |
1685 |
+ |
1686 |
+ $gname = $ddb->get_prop('dansguardian', "f5"); |
1687 |
+ if ($gname) { |
1688 |
+ print $q->Tr (esmith::cgi::genSmallCell ($q, $Lf5), |
1689 |
+ esmith::cgi::genSmallCell ($q, $gname ), |
1690 |
+ esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf5', "mode") || ''), |
1691 |
+ esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf5', "blanketban") . " / " . |
1692 |
+ $ddb->get_prop('dansguardianf5', "https") . " / " . |
1693 |
+ $ddb->get_prop('dansguardianf5', "ipban") . " / " . |
1694 |
+ $ddb->get_prop('dansguardianf5', "file") . " - " . |
1695 |
+ $ddb->get_prop('dansguardianf5', "regexpurl") . " / " . |
1696 |
+ $ddb->get_prop('dansguardianf5', "regexpurlads") . " / " . |
1697 |
+ $ddb->get_prop('dansguardianf5', "regexpurlproxy")), |
1698 |
+ esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf5', "scan") || ''), |
1699 |
+ esmith::cgi::genSmallCell ($q, $ddb->get_prop('dansguardianf5', "bypass") || ''), |
1700 |
+ esmith::cgi::genSmallCell ($q, |
1701 |
+ $q->a ({href => $q->url (-absolute => 1) |
1702 |
+ . "?page=0&page_stack=&g=f5&gname=$gname&wherenext=GroupSettings"}, $modify)), |
1703 |
+ esmith::cgi::genSmallCell ($q, |
1704 |
+ $q->a ({href => $q->url (-absolute => 1) |
1705 |
+ . "?page=0&page_stack=&g=f5&gname=$gname&wherenext=GroupLists"}, $modify))); |
1706 |
+ } |
1707 |
+ |
1708 |
+ print $q->end_table; |
1709 |
+ |
1710 |
+ return ""; |
1711 |
+} |
1712 |
+ |
1713 |
+sub save_reload |
1714 |
+{ |
1715 |
+ my $self = shift; |
1716 |
+ my $q = $self->{cgi}; |
1717 |
+ |
1718 |
+ foreach ('loglevel','logfileformat','f2','f3','f4','f5','deniedurl') |
1719 |
+ { $ddb->set_prop('dansguardian', "$_", $q->param("$_")); } |
1720 |
+ |
1721 |
+ unless ( system ("/sbin/e-smith/signal-event", "dansguardian-reload") == 0 ) |
1722 |
+ { return $self->error('ERROR'); } |
1723 |
+ |
1724 |
+ return $self->success("SUCCESS"); |
1725 |
+} |
1726 |
+ |
1727 |
+sub save_group_settings |
1728 |
+{ |
1729 |
+ my $self = shift; |
1730 |
+ my $q = $self->{cgi}; |
1731 |
+ my $g = $q->param ('g') ||''; |
1732 |
+ |
1733 |
+ foreach ('mode','bypass','reportinglevel','scan','weight','pics','deniedpage','deniedurl', |
1734 |
+ 'regexpurl','regexpsearch','regexpurlads','regexpurlproxy','blanketban','https','ipban','file') |
1735 |
+ { $ddb->set_prop("dansguardian$g", "$_", $q->param("$_")); } |
1736 |
+ |
1737 |
+ unless ( system ("/sbin/e-smith/signal-event", "dansguardian-reload") == 0 ) |
1738 |
+ { return $self->error('ERROR'); } |
1739 |
+ |
1740 |
+ return $self->success("SUCCESS"); |
1741 |
+} |
1742 |
+ |
1743 |
+sub save_proxy |
1744 |
+{ |
1745 |
+ my $self = shift; |
1746 |
+ my $q = $self->{cgi} ||''; |
1747 |
+ |
1748 |
+ my $status = $q->param ('status') || ''; |
1749 |
+ my $proxyaccess = $q->param ('proxyaccess') || ''; |
1750 |
+ my $portblocking = $q->param ('portblocking') || ''; |
1751 |
+ my $port = $q->param ('port') || ''; |
1752 |
+ |
1753 |
+ $db->set_prop('squid', "RequireAuth", $proxyaccess); |
1754 |
+ $ddb->set_prop('dansguardian', "port", $port); |
1755 |
+ |
1756 |
+ my $bypassproxyfrom = $q->param ('bypassproxyfrom') || ''; |
1757 |
+ my $bypassproxyto = $q->param ('bypassproxyto') || ''; |
1758 |
+ my $TCPBlocks = $q->param ('TCPBlocks') || ''; |
1759 |
+ my $UDPBlocks = $q->param ('UDPBlocks') || ''; |
1760 |
+ |
1761 |
+ $db->set_prop('squid', "BypassProxyFrom", $bypassproxyfrom); |
1762 |
+ $db->set_prop('squid', "BypassProxyTo", $bypassproxyto); |
1763 |
+ $db->set_prop('masq', "UDPBlocks", $UDPBlocks); |
1764 |
+ $db->set_prop('masq', "TCPBlocks", $TCPBlocks); |
1765 |
+ |
1766 |
+ if ($status eq 'disabled') |
1767 |
+ { |
1768 |
+ $db->set_prop('squid', "TransparentPort", '3128'); |
1769 |
+ $db->set_prop('dansguardian', "status", 'disabled'); |
1770 |
+ $db->set_prop('dansguardian', "portblocking", 'no'); |
1771 |
+ |
1772 |
+ unless ( system ("/sbin/e-smith/signal-event", "dansguardian-save") == 0 ) |
1773 |
+ { return $self->error('ERROR'); } |
1774 |
+ |
1775 |
+ return $self->success("SUCCESS_STOP"); |
1776 |
+ } |
1777 |
+ else |
1778 |
+ { |
1779 |
+ $db->set_prop('squid', "TransparentPort", $port); |
1780 |
+ $db->set_prop('dansguardian', "status", 'enabled'); |
1781 |
+ $db->set_prop('dansguardian', "portblocking", $portblocking); |
1782 |
+ } |
1783 |
+ |
1784 |
+ unless ( system ("/sbin/e-smith/signal-event", "dansguardian-save") == 0 ) |
1785 |
+ { return $self->error('ERROR'); } |
1786 |
+ |
1787 |
+ return $self->success("SUCCESS_PROMPT"); |
1788 |
+} |
1789 |
+ |
1790 |
+sub portentry |
1791 |
+{ |
1792 |
+ my ($fm, $port) = @_; |
1793 |
+ if (not $port) |
1794 |
+ { |
1795 |
+ return "FM_NONBLANK"; |
1796 |
+ } |
1797 |
+ elsif ($port =~ /^(\d{4})$/) |
1798 |
+ { |
1799 |
+ return "OK"; |
1800 |
+ } |
1801 |
+ else |
1802 |
+ { |
1803 |
+ return "ERROR_PORT"; |
1804 |
+ } |
1805 |
+} |
1806 |
+ |
1807 |
+sub print_list_table |
1808 |
+{ |
1809 |
+ my $self = shift; |
1810 |
+ my $q = $self->{cgi}; |
1811 |
+ my $g = $q->param('g') || ''; |
1812 |
+ my $gname = $q->param('gname') || ''; |
1813 |
+ |
1814 |
+ my $description = $self->localise('DESCRIPTION'); |
1815 |
+ my $Lasite = $self->localise('Lasite'); |
1816 |
+ my $Laurl = $self->localise('Laurl'); |
1817 |
+ my $Lphrases = $self->localise('Lphrases'); |
1818 |
+ my $Lregexp = $self->localise('Lregexp'); |
1819 |
+ my $Lfileext = $self->localise('Lfileext'); |
1820 |
+ my $Lmimetype = $self->localise('Lmimetype'); |
1821 |
+ my $ALLlists = $self->localise('LALLlists'); |
1822 |
+ my $ENABLED = $self->localise('ENABLED'); |
1823 |
+ |
1824 |
+ my $Lgrey = $self->localise('Lgrey'); |
1825 |
+ my $Lweighted = $self->localise('Lweighted'); |
1826 |
+ my $Lmodifyurl = $self->localise('Lmodifyurl'); |
1827 |
+ my $LAllow = $self->localise('LAllow'); |
1828 |
+ my $LDeny = $self->localise('LDeny'); |
1829 |
+ my $LAVexcept = $self->localise('LAVexcept'); |
1830 |
+ my $Lexception = $self->localise('Lexception'); |
1831 |
+ my $Lblacklist = $self->localise('Lblacklist'); |
1832 |
+ my $Lphraselist = $self->localise('Lphraselist'); |
1833 |
+ my $Lrepcon = $self->localise('Lrepcon'); |
1834 |
+ my $Lallowurl = $self->localise('Lallowurl'); |
1835 |
+ my $Lallowsite = $self->localise('Lallowsite'); |
1836 |
+ my $LClientIP = $self->localise('LClientIP'); |
1837 |
+ my $Lcommon = $self->localise('Lcommon'); |
1838 |
+ my $Commonlists = $self->localise('LCommonlists'); |
1839 |
+ |
1840 |
+ print $q->start_table({-CLASS => "sme-border"}),"\n"; |
1841 |
+ print $q->Tr ( |
1842 |
+ esmith::cgi::genSmallCell($q, $description,"header"), |
1843 |
+ esmith::cgi::genSmallCell($q, $q->a ({href => $q->url (-absolute => 1) |
1844 |
+ . "?page=0&page_stack=&g=$g&gname=$gname&wherenext=ShowAllLists"}, $ALLlists),"header"), |
1845 |
+ esmith::cgi::genSmallCell($q, '',"header"), |
1846 |
+ esmith::cgi::genSmallCell($q, '',"header"), |
1847 |
+ esmith::cgi::genSmallCell($q, '',"header"), |
1848 |
+ esmith::cgi::genSmallCell($q, $q->a ({href => $q->url (-absolute => 1) |
1849 |
+ . "?page=0&page_stack=&g=$g&gname=$gname&wherenext=ShowCommonLists"}, $Commonlists),"header")); |
1850 |
+ |
1851 |
+ print $q->Tr (esmith::cgi::genSmallCell ($q, $Lasite), |
1852 |
+ esmith::cgi::genSmallCell ($q, |
1853 |
+ $q->a ({href => $q->url (-absolute => 1) |
1854 |
+ . "?page=0&page_stack=&g=$g&list=greysitelist$g&wherenext=ViewList"}, $Lgrey)), |
1855 |
+ esmith::cgi::genSmallCell ($q, |
1856 |
+ $q->a ({href => $q->url (-absolute => 1) |
1857 |
+ . "?page=0&page_stack=&g=$g&list=exceptionsitelist$g&wherenext=ViewList"}, $LAllow)), |
1858 |
+ esmith::cgi::genSmallCell ($q, |
1859 |
+ $q->a ({href => $q->url (-absolute => 1) |
1860 |
+ . "?page=0&page_stack=&g=$g&list=bannedsitelist$g&wherenext=ViewList"}, $LDeny)), |
1861 |
+ esmith::cgi::genSmallCell ($q,''), |
1862 |
+ esmith::cgi::genSmallCell ($q, |
1863 |
+ $q->a ({href => $q->url (-absolute => 1) |
1864 |
+ . "?page=0&page_stack=&g=f0&list=exceptionvirussitelist&wherenext=ViewList"}, $LAVexcept))); |
1865 |
+ |
1866 |
+ print $q->Tr (esmith::cgi::genSmallCell ($q, $Laurl), |
1867 |
+ esmith::cgi::genSmallCell ($q, |
1868 |
+ $q->a ({href => $q->url (-absolute => 1) |
1869 |
+ . "?page=0&page_stack=&g=$g&list=greyurllist$g&wherenext=ViewList"}, $Lgrey)), |
1870 |
+ esmith::cgi::genSmallCell ($q, |
1871 |
+ $q->a ({href => $q->url (-absolute => 1) |
1872 |
+ . "?page=0&page_stack=&g=$g&list=exceptionurllist$g&wherenext=ViewList"}, $LAllow)), |
1873 |
+ esmith::cgi::genSmallCell ($q, |
1874 |
+ $q->a ({href => $q->url (-absolute => 1) |
1875 |
+ . "?page=0&page_stack=&g=$g&list=bannedurllist$g&wherenext=ViewList"}, $LDeny)), |
1876 |
+ esmith::cgi::genSmallCell ($q,''), |
1877 |
+ esmith::cgi::genSmallCell ($q, |
1878 |
+ $q->a ({href => $q->url (-absolute => 1) |
1879 |
+ . "?page=0&page_stack=&g=f0&list=exceptionvirusurllist&wherenext=ViewList"}, $LAVexcept))); |
1880 |
+ |
1881 |
+ print $q->Tr (esmith::cgi::genSmallCell ($q, $Lphrases), |
1882 |
+ esmith::cgi::genSmallCell ($q, |
1883 |
+ $q->a ({href => $q->url (-absolute => 1) |
1884 |
+ . "?page=0&page_stack=&g=$g&list=weightedphraselist$g&wherenext=ViewList"}, $Lweighted)), |
1885 |
+ esmith::cgi::genSmallCell ($q, |
1886 |
+ $q->a ({href => $q->url (-absolute => 1) |
1887 |
+ . "?page=0&page_stack=&g=$g&list=exceptionphraselist$g&wherenext=ViewList"}, $LAllow)), |
1888 |
+ esmith::cgi::genSmallCell ($q, |
1889 |
+ $q->a ({href => $q->url (-absolute => 1) |
1890 |
+ . "?page=0&page_stack=&g=$g&list=bannedphraselist$g&wherenext=ViewList"}, $LDeny)), |
1891 |
+ esmith::cgi::genSmallCell ($q, ''), |
1892 |
+ esmith::cgi::genSmallCell ($q,'')); |
1893 |
+ |
1894 |
+ print $q->Tr (esmith::cgi::genSmallCell ($q, $Lregexp), |
1895 |
+ esmith::cgi::genSmallCell ($q, |
1896 |
+ $q->a ({href => $q->url (-absolute => 1) |
1897 |
+ . "?page=0&page_stack=&g=$g&list=urlregexplist$g&wherenext=ViewList"}, $Lmodifyurl)), |
1898 |
+ esmith::cgi::genSmallCell ($q, |
1899 |
+ $q->a ({href => $q->url (-absolute => 1) |
1900 |
+ . "?page=0&page_stack=&g=$g&list=exceptionregexpurllist$g&wherenext=ViewList"}, $LAllow)), |
1901 |
+ esmith::cgi::genSmallCell ($q, |
1902 |
+ $q->a ({href => $q->url (-absolute => 1) |
1903 |
+ . "?page=0&page_stack=&g=$g&list=bannedregexpurllist$g&wherenext=ViewList"}, $LDeny)), |
1904 |
+ esmith::cgi::genSmallCell ($q, |
1905 |
+ $q->a ({href => $q->url (-absolute => 1) |
1906 |
+ . "?page=0&page_stack=&g=$g&list=contentregexplist$g&wherenext=ViewList"}, $Lrepcon)), |
1907 |
+ esmith::cgi::genSmallCell ($q, '')); |
1908 |
+ |
1909 |
+ |
1910 |
+ print $q->Tr (esmith::cgi::genSmallCell ($q, $Lfileext), |
1911 |
+ esmith::cgi::genSmallCell ($q, ''), |
1912 |
+ esmith::cgi::genSmallCell ($q, |
1913 |
+ $q->a ({href => $q->url (-absolute => 1) |
1914 |
+ . "?page=0&page_stack=&g=$g&list=exceptionextensionlist$g&wherenext=ViewList"}, $Lexception)), |
1915 |
+ esmith::cgi::genSmallCell ($q, |
1916 |
+ $q->a ({href => $q->url (-absolute => 1) |
1917 |
+ . "?page=0&page_stack=&g=$g&list=bannedextensionlist$g&wherenext=ViewList"}, $LDeny)), |
1918 |
+ esmith::cgi::genSmallCell ($q, |
1919 |
+ $q->a ({href => $q->url (-absolute => 1) |
1920 |
+ . "?page=0&page_stack=&g=$g&list=exceptionfileurllist$g&wherenext=ViewList"}, $Lallowurl)), |
1921 |
+ esmith::cgi::genSmallCell ($q, |
1922 |
+ $q->a ({href => $q->url (-absolute => 1) |
1923 |
+ . "?page=0&page_stack=&g=f0&list=exceptionvirusextensionlist&wherenext=ViewList"}, $LAVexcept))); |
1924 |
+ |
1925 |
+ print $q->Tr (esmith::cgi::genSmallCell ($q, $Lmimetype), |
1926 |
+ esmith::cgi::genSmallCell ($q, ''), |
1927 |
+ esmith::cgi::genSmallCell ($q, |
1928 |
+ $q->a ({href => $q->url (-absolute => 1) |
1929 |
+ . "?page=0&page_stack=&g=$g&list=exceptionmimetypelist$g&wherenext=ViewList"}, $Lexception)), |
1930 |
+ esmith::cgi::genSmallCell ($q, |
1931 |
+ $q->a ({href => $q->url (-absolute => 1) |
1932 |
+ . "?page=0&page_stack=&g=$g&list=bannedmimetypelist$g&wherenext=ViewList"}, $LDeny)), |
1933 |
+ esmith::cgi::genSmallCell ($q, |
1934 |
+ $q->a ({href => $q->url (-absolute => 1) |
1935 |
+ . "?page=0&page_stack=&g=$g&list=exceptionfilesitelist$g&wherenext=ViewList"}, $Lallowsite)), |
1936 |
+ esmith::cgi::genSmallCell ($q, |
1937 |
+ $q->a ({href => $q->url (-absolute => 1) |
1938 |
+ . "?page=0&page_stack=&g=f0&list=exceptionvirusmimetypelist&wherenext=ViewList"}, $LAVexcept))); |
1939 |
+ |
1940 |
+ #Client IP |
1941 |
+ if ($g eq 'f0') |
1942 |
+ { |
1943 |
+ print $q->Tr (esmith::cgi::genSmallCell ($q, $LClientIP), |
1944 |
+ esmith::cgi::genSmallCell ($q, ''), |
1945 |
+ esmith::cgi::genSmallCell ($q, |
1946 |
+ $q->a ({href => $q->url (-absolute => 1) |
1947 |
+ . "?page=0&page_stack=&g=$g&list=exceptioniplist&wherenext=ViewList"}, $Lexception)), |
1948 |
+ esmith::cgi::genSmallCell ($q, |
1949 |
+ $q->a ({href => $q->url (-absolute => 1) |
1950 |
+ . "?page=0&page_stack=&g=$g&list=bannediplist&wherenext=ViewList"}, $LDeny)), |
1951 |
+ esmith::cgi::genSmallCell ($q, ''), |
1952 |
+ esmith::cgi::genSmallCell ($q, '')); |
1953 |
+ } |
1954 |
+ |
1955 |
+ #prepared lists |
1956 |
+ unless ($g eq 'f0') |
1957 |
+ { |
1958 |
+ print $q->Tr (esmith::cgi::genSmallCell ($q, $ENABLED), |
1959 |
+ esmith::cgi::genSmallCell ($q, ''), |
1960 |
+ esmith::cgi::genSmallCell ($q, |
1961 |
+ $q->a ({href => $q->url (-absolute => 1) |
1962 |
+ . "?page=0&page_stack=&g=$g&gname=$gname&wherenext=ViewPhraseList"}, $Lphraselist)), |
1963 |
+ esmith::cgi::genSmallCell ($q, |
1964 |
+ $q->a ({href => $q->url (-absolute => 1) |
1965 |
+ . "?page=0&page_stack=&g=$g&gname=$gname&wherenext=ViewBlackList"}, $Lblacklist)), |
1966 |
+ esmith::cgi::genSmallCell ($q, ''), |
1967 |
+ esmith::cgi::genSmallCell ($q, '')); |
1968 |
+ } |
1969 |
+ |
1970 |
+ print $q->end_table; |
1971 |
+ return ""; |
1972 |
+} |
1973 |
+ |
1974 |
+sub print_list_description |
1975 |
+{ |
1976 |
+ my $self = shift; |
1977 |
+ my $q = $self->{cgi}; |
1978 |
+ my $g = $q->param ('g') ||''; |
1979 |
+ my $desc = $self->localise('MODIFY_LIST_SETTINGS'); |
1980 |
+ |
1981 |
+ if ($g eq 'f0') |
1982 |
+ { |
1983 |
+ $desc = $self->localise('MODIFY_GLOBAL_LIST_SETTINGS'); |
1984 |
+ } |
1985 |
+ |
1986 |
+ return "$desc"; |
1987 |
+} |
1988 |
+ |
1989 |
+sub print_record_table |
1990 |
+{ |
1991 |
+ my $self = shift; |
1992 |
+ my $q = $self->{cgi}; |
1993 |
+ my $g = $q->param ('g') ||''; |
1994 |
+ my $list = $q->param('list') ||''; |
1995 |
+ |
1996 |
+ my $record = $self->localise('RECORD'); |
1997 |
+ my $modify = $self->localise('MODIFY'); |
1998 |
+ my $remove = $self->localise('REMOVE'); |
1999 |
+ my $new = $self->localise('NEW'); |
2000 |
+ |
2001 |
+ |
2002 |
+ print $q->start_table({-CLASS => "sme-border"}),"\n"; |
2003 |
+ print $q->Tr ( |
2004 |
+ esmith::cgi::genSmallCell($q, $record,"header"), |
2005 |
+ esmith::cgi::genSmallCell($q, '',"header"), |
2006 |
+ esmith::cgi::genSmallCell($q, '',"header")),"\n"; |
2007 |
+ |
2008 |
+ print $q->Tr (esmith::cgi::genSmallCell ($q, ''), |
2009 |
+ esmith::cgi::genSmallCell ($q, ''), |
2010 |
+ esmith::cgi::genSmallCell ($q, |
2011 |
+ $q->a ({href => $q->url (-absolute => 1) |
2012 |
+ . "?page=0&page_stack=&g=$g&list=$list&key=new&wherenext=Edit"}, $new))); |
2013 |
+ |
2014 |
+ foreach my $hash ($ddb->get_all_by_prop(type => $list)) |
2015 |
+ { |
2016 |
+ my $key = $hash->key; |
2017 |
+ my $criterion = $hash->prop("criterion") || ''; |
2018 |
+ |
2019 |
+ #allows for three sets of bracketed words |
2020 |
+ #$record =~ s/</<\;/g; ?? |
2021 |
+ #$record =~ s/>/>\;/g; |
2022 |
+ $criterion =~ s/</<\;/; |
2023 |
+ $criterion =~ s/>/>\;/; |
2024 |
+ $criterion =~ s/</<\;/; |
2025 |
+ $criterion =~ s/>/>\;/; |
2026 |
+ $criterion =~ s/</<\;/; |
2027 |
+ $criterion =~ s/>/>\;/; |
2028 |
+ |
2029 |
+ print $q->Tr (esmith::cgi::genSmallCell ($q, $criterion), |
2030 |
+ esmith::cgi::genSmallCell ($q, |
2031 |
+ $q->a ({href => $q->url (-absolute => 1) |
2032 |
+ . "?page=0&page_stack=&g=$g&list=$list&key=$key&wherenext=Edit"}, $modify)), |
2033 |
+ esmith::cgi::genSmallCell ($q, |
2034 |
+ $q->a ({href => $q->url (-absolute => 1) |
2035 |
+ . "?page=0&page_stack=&g=$g&criterion=$criterion&key=$key&wherenext=Delete"}, $remove))); |
2036 |
+ } |
2037 |
+ |
2038 |
+ print $q->end_table; |
2039 |
+ |
2040 |
+ return ""; |
2041 |
+} |
2042 |
+ |
2043 |
+sub print_all_lists |
2044 |
+{ |
2045 |
+ my $self = shift; |
2046 |
+ my $q = $self->{cgi}; |
2047 |
+ my $g = $q->param ('g') ||''; |
2048 |
+ my $all = (); |
2049 |
+ |
2050 |
+ if ($g =~ /^(f\d{1})$/) |
2051 |
+ { |
2052 |
+ $g = $1; |
2053 |
+ } |
2054 |
+ |
2055 |
+ print $q->start_table({-CLASS => "sme-border"}),"\n"; |
2056 |
+ |
2057 |
+ $all .= "<code>\n"; |
2058 |
+ |
2059 |
+ my @files = ('bannedextensionlist','bannedsitelist','exceptionfilesitelist','exceptionregexpurllist', |
2060 |
+ 'greysitelist','weightedphraselist','bannedmimetypelist','bannedurllist','exceptionfileurllist', |
2061 |
+ 'exceptionsitelist','greyurllist','bannedphraselist','contentregexplist','exceptionmimetypelist','exceptionurllist','pics', |
2062 |
+ 'bannedregexpurllist','exceptionextensionlist','exceptionphraselist','greyregexpurllist','urlregexplist'); |
2063 |
+ |
2064 |
+ foreach (@files) |
2065 |
+ { |
2066 |
+ |
2067 |
+ if ( -e "/etc/dansguardian/lists/$g/$_" ) |
2068 |
+ { |
2069 |
+ open (INF,"/etc/dansguardian/lists/$g/$_") |
2070 |
+ or die ("can't open /etc/dansguardian/lists/$g/$_ to read. "); |
2071 |
+ |
2072 |
+ $all .= "<br>\n"; |
2073 |
+ $all .= "<b> /etc/dansguardian/lists/$g/$_ </b><br>\n"; |
2074 |
+ |
2075 |
+ while (<INF>) |
2076 |
+ { |
2077 |
+ # allow for 4 sets |
2078 |
+ $_ =~ s/</<\;/; |
2079 |
+ $_ =~ s/>/>\;/; |
2080 |
+ $_ =~ s/</<\;/; |
2081 |
+ $_ =~ s/>/>\;/; |
2082 |
+ $_ =~ s/</<\;/; |
2083 |
+ $_ =~ s/>/>\;/; |
2084 |
+ $_ =~ s/</<\;/; |
2085 |
+ $_ =~ s/>/>\;/; |
2086 |
+ |
2087 |
+ $all .= "$_<br>\n"; |
2088 |
+ } |
2089 |
+ close INF; |
2090 |
+ } |
2091 |
+ } |
2092 |
+ |
2093 |
+ $all .= "<\code>\n"; |
2094 |
+ |
2095 |
+ print $q->end_table; |
2096 |
+ |
2097 |
+ return "$all"; |
2098 |
+} |
2099 |
+ |
2100 |
+sub print_common_lists |
2101 |
+{ |
2102 |
+ my $self = shift; |
2103 |
+ my $q = $self->{cgi}; |
2104 |
+ my $g = $q->param ('g') ||''; |
2105 |
+ my $all = (); |
2106 |
+ |
2107 |
+ if ($g =~ /^(f\d{1})$/) |
2108 |
+ { |
2109 |
+ $g = $1; |
2110 |
+ } |
2111 |
+ |
2112 |
+ print $q->start_table({-CLASS => "sme-border"}),"\n"; |
2113 |
+ |
2114 |
+ $all .= "<code>\n"; |
2115 |
+ |
2116 |
+ my @files = ('exceptioniplist','bannediplist','contentscanners/exceptionvirusextensionlist', |
2117 |
+ 'contentscanners/exceptionvirusmimetypelist','contentscanners/exceptionvirussitelist','contentscanners/exceptionvirusurllist'); |
2118 |
+ |
2119 |
+ foreach (@files) |
2120 |
+ { |
2121 |
+ |
2122 |
+ if ( -e "/etc/dansguardian/lists/$_" ) |
2123 |
+ { |
2124 |
+ open (INF,"/etc/dansguardian/lists/$_") |
2125 |
+ or die ("can't open /etc/dansguardian/lists/$_ to read. "); |
2126 |
+ |
2127 |
+ $all .= "<br>\n"; |
2128 |
+ $all .= "<b> /etc/dansguardian/lists/$_ </b><br>\n"; |
2129 |
+ |
2130 |
+ while (<INF>) |
2131 |
+ { |
2132 |
+ # allow for 4 sets |
2133 |
+ $_ =~ s/</<\;/; |
2134 |
+ $_ =~ s/>/>\;/; |
2135 |
+ $_ =~ s/</<\;/; |
2136 |
+ $_ =~ s/>/>\;/; |
2137 |
+ $_ =~ s/</<\;/; |
2138 |
+ $_ =~ s/>/>\;/; |
2139 |
+ $_ =~ s/</<\;/; |
2140 |
+ $_ =~ s/>/>\;/; |
2141 |
+ |
2142 |
+ $all .= "$_<br>\n"; |
2143 |
+ } |
2144 |
+ close INF; |
2145 |
+ } |
2146 |
+ } |
2147 |
+ |
2148 |
+ $all .= "<\code>\n"; |
2149 |
+ |
2150 |
+ print $q->end_table; |
2151 |
+ |
2152 |
+ return "$all"; |
2153 |
+} |
2154 |
+ |
2155 |
+sub print_phraselist_head |
2156 |
+{ |
2157 |
+ my $self = shift; |
2158 |
+ my $q = $self->{cgi} ||''; |
2159 |
+ my $all = (); |
2160 |
+ |
2161 |
+ print $q->start_table({-CLASS => "sme-border"}),"\n"; |
2162 |
+ |
2163 |
+ $all .= "<code>\n"; |
2164 |
+ |
2165 |
+ system ("/usr/bin/head /etc/dansguardian/lists/phraselists/*/* > /tmp/lists") == 0 |
2166 |
+ or die ("Error occurred reading phraselists\n"); |
2167 |
+ |
2168 |
+ if ( -e "/tmp/lists" ) |
2169 |
+ { |
2170 |
+ open (INF,"/tmp/lists") |
2171 |
+ or die ("can't open /tmp/lists read. "); |
2172 |
+ |
2173 |
+ $all .= "<br><b> head /etc/dansguardian/lists/phraselists/* </b><br>\n"; |
2174 |
+ |
2175 |
+ while (<INF>) |
2176 |
+ { |
2177 |
+ # allow for 4 sets |
2178 |
+ $_ =~ s/</<\;/; |
2179 |
+ $_ =~ s/>/>\;/; |
2180 |
+ $_ =~ s/</<\;/; |
2181 |
+ $_ =~ s/>/>\;/; |
2182 |
+ $_ =~ s/</<\;/; |
2183 |
+ $_ =~ s/>/>\;/; |
2184 |
+ $_ =~ s/</<\;/; |
2185 |
+ $_ =~ s/>/>\;/; |
2186 |
+ |
2187 |
+ $all .= "$_<br>\n"; |
2188 |
+ } |
2189 |
+ close INF; |
2190 |
+ } |
2191 |
+ |
2192 |
+ $all .= "<\code>\n"; |
2193 |
+ print $q->end_table; |
2194 |
+ return "$all"; |
2195 |
+} |
2196 |
+sub print_blacklist_head |
2197 |
+{ |
2198 |
+ my $self = shift; |
2199 |
+ my $q = $self->{cgi}; |
2200 |
+ my $all = (); |
2201 |
+ |
2202 |
+ print $q->start_table({-CLASS => "sme-border"}),"\n"; |
2203 |
+ |
2204 |
+ $all .= "<code>\n"; |
2205 |
+ |
2206 |
+ system ("/usr/bin/head /etc/dansguardian/blacklists/*/* > /tmp/lists") == 0 |
2207 |
+ or die ("Error occurred reading phraselists\n"); |
2208 |
+ |
2209 |
+ if ( -e "/tmp/lists" ) |
2210 |
+ { |
2211 |
+ open (INF,"/tmp/lists") |
2212 |
+ or die ("can't open /tmp/lists read. "); |
2213 |
+ |
2214 |
+ $all .= "<br><b> head /etc/dansguardian/blacklists/* </b><br>\n"; |
2215 |
+ |
2216 |
+ while (<INF>) |
2217 |
+ { |
2218 |
+ # allow for 4 sets |
2219 |
+ $_ =~ s/</<\;/; |
2220 |
+ $_ =~ s/>/>\;/; |
2221 |
+ $_ =~ s/</<\;/; |
2222 |
+ $_ =~ s/>/>\;/; |
2223 |
+ $_ =~ s/</<\;/; |
2224 |
+ $_ =~ s/>/>\;/; |
2225 |
+ $_ =~ s/</<\;/; |
2226 |
+ $_ =~ s/>/>\;/; |
2227 |
+ |
2228 |
+ $all .= "$_<br>\n"; |
2229 |
+ } |
2230 |
+ close INF; |
2231 |
+ } |
2232 |
+ |
2233 |
+ $all .= "<\code>\n"; |
2234 |
+ print $q->end_table; |
2235 |
+ return "$all"; |
2236 |
+} |
2237 |
+ |
2238 |
+sub save_record |
2239 |
+{ |
2240 |
+ my $self = shift; |
2241 |
+ my $q = $self->{cgi}; |
2242 |
+ my $g = $q->param ('g') ||''; |
2243 |
+ my $key = $q->param ('key') ||''; |
2244 |
+ my $list = $q->param ('list') ||''; |
2245 |
+ my $criterion = $q->param ('criterion'); |
2246 |
+ |
2247 |
+ if ($key eq 'new') |
2248 |
+ { |
2249 |
+ my $random = int(rand(999999)); |
2250 |
+ $key = $list.$random; |
2251 |
+ $ddb->new_record($key, { type => "$list" }); |
2252 |
+ } |
2253 |
+ $ddb->set_prop($key, 'criterion', $criterion); |
2254 |
+ |
2255 |
+ return $self->success("SUCCESS_STORED"); |
2256 |
+} |
2257 |
+sub delete_record |
2258 |
+{ |
2259 |
+ my $self = shift; |
2260 |
+ my $q = $self->{cgi} ||''; |
2261 |
+ my $key = $q->param('key') ||''; |
2262 |
+ |
2263 |
+ my $rec = $ddb->get($key); |
2264 |
+ $rec->delete; |
2265 |
+ |
2266 |
+ return $self->success("SUCCESS_STORED"); |
2267 |
+} |
2268 |
+ |
2269 |
+sub print_phraselist_table |
2270 |
+{ |
2271 |
+ my $self = shift; |
2272 |
+ my $q = $self->{cgi}; |
2273 |
+ my $g = $q->param ('g') ||''; |
2274 |
+ |
2275 |
+ my $Llist = $self->localise('LIST'); |
2276 |
+ |
2277 |
+ my @lists = $pdb->get_all_by_prop(type => "list"); |
2278 |
+ my @gnames = ''; |
2279 |
+ foreach my $g (@lists) |
2280 |
+ { |
2281 |
+ my $groupname = $g->key(); |
2282 |
+ push (@gnames, $groupname) |
2283 |
+ } |
2284 |
+ |
2285 |
+ my @installed = ('badwords','googlesearches'); |
2286 |
+ foreach (@gnames) |
2287 |
+ { |
2288 |
+ push (@installed, $_) |
2289 |
+ if (-e "/etc/dansguardian/lists/phraselists/$_/weighted"); |
2290 |
+ } |
2291 |
+ |
2292 |
+ #hide table if you have no rules |
2293 |
+ my $installed = @installed || 'no lists'; |
2294 |
+ if ($installed eq 'no lists') |
2295 |
+ { |
2296 |
+ return "$self->localise('ERROR');" |
2297 |
+ } |
2298 |
+ else |
2299 |
+ { |
2300 |
+ |
2301 |
+ print $q->start_table({-CLASS => "sme-border"}),"\n"; |
2302 |
+ |
2303 |
+ print $q->Tr ( esmith::cgi::genSmallCell($q, $Llist,"header"), |
2304 |
+ esmith::cgi::genSmallCell($q, '',"header")),"\n"; |
2305 |
+ |
2306 |
+ #checkboxes |
2307 |
+ my ($a, $aa) = ''; |
2308 |
+ foreach (sort @installed) |
2309 |
+ { |
2310 |
+ $a = $_; |
2311 |
+ $aa = $pdb->get_prop($_, $g) || ''; |
2312 |
+ if ($aa eq 'on') { $aa = "checked"; } |
2313 |
+ |
2314 |
+ print $q->Tr (esmith::cgi::genSmallCell ($q, $_), |
2315 |
+ esmith::cgi::genSmallCell ($q, ("<input type=\"checkbox\" name=\"$a\" $aa>"))); |
2316 |
+ } |
2317 |
+ } |
2318 |
+ |
2319 |
+ print $q->end_table; |
2320 |
+ |
2321 |
+ return ""; |
2322 |
+} |
2323 |
+sub save_phrase |
2324 |
+{ |
2325 |
+ my $self = shift; |
2326 |
+ my $q = $self->{cgi}; |
2327 |
+ my $g = $q->param ('g') ||''; |
2328 |
+ |
2329 |
+ my @lists = $pdb->get_all_by_prop(type => "list"); |
2330 |
+ my @gnames = ''; |
2331 |
+ foreach my $g (@lists) |
2332 |
+ { |
2333 |
+ my $groupname = $g->key(); |
2334 |
+ push (@gnames, $groupname) |
2335 |
+ } |
2336 |
+ |
2337 |
+ my @installed = (); |
2338 |
+ foreach (@gnames) |
2339 |
+ { |
2340 |
+ push (@installed, $_) |
2341 |
+ if (-e "/etc/dansguardian/lists/phraselists/$_/weighted"); |
2342 |
+ } |
2343 |
+ |
2344 |
+ #skip if you have nothing |
2345 |
+ my $installed = @installed || 'no lists'; |
2346 |
+ unless ($installed eq 'no lists') |
2347 |
+ { |
2348 |
+ #from checkboxes |
2349 |
+ my ($a, $aa) = ''; |
2350 |
+ foreach (@installed) |
2351 |
+ { |
2352 |
+ my $a = $_; |
2353 |
+ my $aa = $q->param ($a) || ''; |
2354 |
+ $pdb->set_prop($_, $g, $aa); |
2355 |
+ } |
2356 |
+ } |
2357 |
+ |
2358 |
+ return $self->success("SUCCESS_STORED"); |
2359 |
+} |
2360 |
+ |
2361 |
+ |
2362 |
+sub print_blacklist_table |
2363 |
+{ |
2364 |
+ my $self = shift; |
2365 |
+ my $q = $self->{cgi}; |
2366 |
+ my $g = $q->param ('g') ||''; |
2367 |
+ |
2368 |
+ my $Llist = $self->localise('LIST'); |
2369 |
+ my $LWhite = $self->localise('LWhite'); |
2370 |
+ my $LGrey = $self->localise('Lgrey'); |
2371 |
+ my $LBlack = $self->localise('LBlack'); |
2372 |
+ |
2373 |
+ my @lists = $bdb->get_all_by_prop(type => "list"); |
2374 |
+ my @gnames = ''; |
2375 |
+ foreach my $g (@lists) |
2376 |
+ { |
2377 |
+ my $groupname = $g->key(); |
2378 |
+ push (@gnames, $groupname) |
2379 |
+ } |
2380 |
+ |
2381 |
+ my @installed = (); |
2382 |
+ foreach (@gnames) |
2383 |
+ { |
2384 |
+ push (@installed, $_) |
2385 |
+ if (-e "/etc/dansguardian/blacklists/$_/domains"); |
2386 |
+ } |
2387 |
+ |
2388 |
+ #hide table if you have no rules |
2389 |
+ my $installed = @installed || 'no lists'; |
2390 |
+ if ($installed eq 'no lists') |
2391 |
+ { |
2392 |
+ return "$self->localise('NO_BLACK');" |
2393 |
+ } |
2394 |
+ else |
2395 |
+ { |
2396 |
+ print $q->start_table({-CLASS => "sme-border"}),"\n"; |
2397 |
+ print $q->Tr ( |
2398 |
+ esmith::cgi::genSmallCell($q, $Llist,"header"), |
2399 |
+ esmith::cgi::genSmallCell($q, $LWhite,"header"), |
2400 |
+ esmith::cgi::genSmallCell($q, $LGrey,"header"), |
2401 |
+ esmith::cgi::genSmallCell($q, $LBlack,"header")),"\n"; |
2402 |
+ |
2403 |
+ #checkboxes |
2404 |
+ my ($a, $b, $c, $aa, $bb, $cc) = ''; |
2405 |
+ foreach (sort @installed) |
2406 |
+ { |
2407 |
+ $a = $_.'white'; |
2408 |
+ $aa = $bdb->get_prop($_, "white$g") || ''; |
2409 |
+ if ($aa eq 'on') { $aa = "checked"; } |
2410 |
+ |
2411 |
+ my $b = $_.'grey'; |
2412 |
+ $bb = $bdb->get_prop($_, "grey$g") || ''; |
2413 |
+ if ($bb eq 'on') { $bb = "checked"; } |
2414 |
+ |
2415 |
+ my $c = $_.'black'; |
2416 |
+ $cc= $bdb->get_prop($_, "black$g") || ''; |
2417 |
+ if ($cc eq 'on') { $cc = "checked"; } |
2418 |
+ |
2419 |
+ #todo |
2420 |
+ my $listname = $self->localise($_); |
2421 |
+ |
2422 |
+ print $q->Tr |
2423 |
+ (esmith::cgi::genSmallCell ($q, $listname), |
2424 |
+ esmith::cgi::genSmallCell ($q, ("<input type=\"checkbox\" name=\"$a\" $aa>")), |
2425 |
+ esmith::cgi::genSmallCell ($q, ("<input type=\"checkbox\" name=\"$b\" $bb>")), |
2426 |
+ esmith::cgi::genSmallCell ($q, ("<input type=\"checkbox\" name=\"$c\" $cc>"))); |
2427 |
+ } |
2428 |
+ } |
2429 |
+ |
2430 |
+ print $q->end_table; |
2431 |
+ |
2432 |
+ return ""; |
2433 |
+} |
2434 |
+sub save_black |
2435 |
+{ |
2436 |
+ my $self = shift; |
2437 |
+ my $q = $self->{cgi}; |
2438 |
+ my $g = $q->param ('g') ||''; |
2439 |
+ |
2440 |
+ my @lists = $bdb->get_all_by_prop(type => "list"); |
2441 |
+ my @gnames = ''; |
2442 |
+ foreach my $g (@lists) |
2443 |
+ { |
2444 |
+ my $groupname = $g->key(); |
2445 |
+ push (@gnames, $groupname) |
2446 |
+ } |
2447 |
+ |
2448 |
+ my @installed = (); |
2449 |
+ foreach (@gnames) |
2450 |
+ { |
2451 |
+ push (@installed, $_) |
2452 |
+ if (-e "/etc/dansguardian/blacklists/$_/domains"); |
2453 |
+ } |
2454 |
+ |
2455 |
+ #skip if you have nothing |
2456 |
+ my $installed = @installed || 'no lists'; |
2457 |
+ unless ($installed eq 'no lists') |
2458 |
+ { |
2459 |
+ #from checkboxes |
2460 |
+ my ($a, $b, $c, $aa, $bb, $cc,) = ''; |
2461 |
+ foreach (@installed) |
2462 |
+ { |
2463 |
+ my $a = $_.'white'; |
2464 |
+ my $aa = $q->param ("$a") || ''; |
2465 |
+ $bdb->set_prop($_, "white$g", $aa); |
2466 |
+ |
2467 |
+ my $b = $_.'grey'; |
2468 |
+ my $bb = $q->param ("$b") || ''; |
2469 |
+ $bdb->set_prop($_, "grey$g", $bb); |
2470 |
+ |
2471 |
+ my $c = $_.'black'; |
2472 |
+ my $cc = $q->param ("$c") || ''; |
2473 |
+ $bdb->set_prop($_, "black$g", $cc); |
2474 |
+ } |
2475 |
+ } |
2476 |
+ |
2477 |
+ return $self->success("SUCCESS_STORED"); |
2478 |
+} |
2479 |
+ |
2480 |
+1; |