849bdf42 |
1 | <?php |
4eee5968 |
2 | |
15e6162e |
3 | /** |
4 | * Message and Spam Filter Plugin |
5 | * |
6 | * Copyright (c) 1999-2002 The SquirrelMail Project Team |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * This plugin filters your inbox into different folders based upon given |
10 | * criteria. It is most useful for people who are subscibed to mailing lists |
11 | * to help organize their messages. The argument stands that filtering is |
12 | * not the place of the client, which is why this has been made a plugin for |
13 | * SquirrelMail. You may be better off using products such as Sieve or |
14 | * Procmail to do your filtering so it happens even when SquirrelMail isn't |
15 | * running. |
16 | * |
17 | * If you need help with this, or see improvements that can be made, please |
18 | * email me directly at the address above. I definately welcome suggestions |
19 | * and comments. This plugin, as is the case with all SquirrelMail plugins, |
20 | * is not directly supported by the developers. Please come to me off the |
21 | * mailing list if you have trouble with it. |
22 | * |
23 | * Also view plugins/README.plugins for more information. |
24 | * |
25 | * $Id$ |
26 | */ |
4eee5968 |
27 | |
a2a566eb |
28 | function filters_SaveCache () { |
29 | global $data_dir, $SpamFilters_DNScache; |
30 | |
31 | if (file_exists($data_dir . "/dnscache")) { |
32 | $fp = fopen($data_dir . "/dnscache", "r"); |
33 | } else { |
34 | $fp = false; |
35 | } |
36 | if ($fp) { |
37 | flock($fp,LOCK_EX); |
38 | } else { |
39 | $fp = fopen($data_dir . "/dnscache", "w+"); |
40 | fclose($fp); |
41 | $fp = fopen($data_dir . "/dnscache", "r"); |
42 | flock($fp,LOCK_EX); |
43 | } |
44 | $fp1=fopen($data_dir . "/dnscache", "w+"); |
45 | |
46 | foreach ($SpamFilters_DNScache as $Key=> $Value) { |
47 | $tstr = $Key . ',' . $Value['L'] . ',' . $Value['T'] . "\n"; |
48 | fputs ($fp1, $tstr); |
49 | } |
50 | fclose($fp1); |
51 | flock($fp,LOCK_UN); |
52 | fclose($fp); |
53 | } |
54 | |
55 | |
56 | function filters_LoadCache () { |
57 | global $data_dir, $SpamFilters_DNScache; |
58 | |
59 | if (file_exists($data_dir . "/dnscache")) { |
6ade76e0 |
60 | $SpamFilters_DNScache = array(); |
a2a566eb |
61 | if ($fp = fopen ($data_dir . "/dnscache", "r")) { |
62 | flock($fp,LOCK_SH); |
63 | while ($data=fgetcsv($fp,1024)) { |
64 | if ($data[2] > time()) { |
65 | $SpamFilters_DNScache[$data[0]]['L'] = $data[1]; |
66 | $SpamFilters_DNScache[$data[0]]['T'] = $data[2]; |
67 | } |
68 | } |
69 | |
70 | flock($fp,LOCK_UN); |
71 | } |
72 | } |
73 | } |
74 | |
75 | function filters_bulkquery($filters_spam_scan, $filters, $read) { |
76 | global $SpamFilters_YourHop, $attachment_dir, $username, |
6ade76e0 |
77 | $SpamFilters_DNScache, $SpamFilters_BulkQuery, |
78 | $SpamFilters_CacheTTL; |
a2a566eb |
79 | |
80 | $IPs = array(); |
81 | $i = 0; |
82 | while ($i < count($read)) { |
83 | // EIMS will give funky results |
84 | $Chunks = explode(' ', $read[$i]); |
85 | if ($Chunks[0] != '*') { |
86 | $i ++; |
87 | continue; |
88 | } |
89 | $MsgNum = $Chunks[1]; |
90 | |
91 | $i ++; |
a2a566eb |
92 | |
93 | // Look through all of the Received headers for IP addresses |
94 | // Stop when I get ")" on a line |
95 | // Stop if I get "*" on a line (don't advance) |
96 | // and above all, stop if $i is bigger than the total # of lines |
97 | while (($i < count($read)) && |
98 | ($read[$i][0] != ')' && $read[$i][0] != '*' && |
99 | $read[$i][0] != "\n")) { |
100 | // Check to see if this line is the right "Received from" line |
101 | // to check |
102 | if (is_int(strpos($read[$i], $SpamFilters_YourHop))) { |
c8a2c24d |
103 | $read[$i] = ereg_replace('[^0-9\.]', ' ', $read[$i]); |
104 | $elements = explode(' ', $read[$i]); |
105 | foreach ($elements as $value) { |
106 | if ($value != '' && |
107 | ereg('[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}', |
108 | $value, $regs)) { |
109 | $Chunks = explode('.', $value); |
110 | $IP = $Chunks[3] . '.' . $Chunks[2] . '.' . |
111 | $Chunks[1] . '.' . $Chunks[0]; |
112 | foreach ($filters as $key => $value) { |
113 | if ($filters[$key]['enabled'] && |
114 | $filters[$key]['dns']) { |
115 | if (strlen($SpamFilters_DNScache[$IP.'.'.$filters[$key]['dns']]) == 0) { |
116 | $IPs[$IP] = true; |
117 | break; |
a2a566eb |
118 | } |
119 | } |
c8a2c24d |
120 | } |
121 | // If we've checked one IP and YourHop is |
122 | // just a space |
123 | if ($SpamFilters_YourHop == ' ') { |
124 | break; // don't check any more |
a2a566eb |
125 | } |
126 | } |
127 | } |
128 | } |
129 | $i ++; |
130 | } |
131 | } |
132 | |
133 | if (count($IPs) > 0) { |
134 | $rbls = array(); |
135 | foreach ($filters as $key => $value) { |
136 | if ($filters[$key]['enabled']) { |
137 | if ($filters[$key]['dns']) { |
138 | $rbls[$filters[$key]['dns']] = true; |
139 | } |
140 | } |
141 | } |
142 | |
143 | $bqfil = $attachment_dir . $username . "-bq.in"; |
144 | $fp = fopen($bqfil, "w"); |
6ade76e0 |
145 | fputs ($fp, $SpamFilters_CacheTTL . "\n"); |
a2a566eb |
146 | foreach ($rbls as $key => $value) { |
147 | fputs ($fp, "." . $key . "\n"); |
148 | } |
149 | fputs ($fp, "----------\n"); |
150 | foreach ($IPs as $key => $value) { |
151 | fputs ($fp, $key . "\n"); |
152 | } |
153 | fclose ($fp); |
154 | $bqout = array(); |
155 | exec ($SpamFilters_BulkQuery . " < " . $bqfil, $bqout); |
156 | foreach ($bqout as $value) { |
157 | $Chunks = explode(',', $value); |
158 | $SpamFilters_DNScache[$Chunks[0]]['L'] = $Chunks[1]; |
159 | $SpamFilters_DNScache[$Chunks[0]]['T'] = $Chunks[2] + time(); |
160 | } |
161 | unlink($bqfil); |
162 | } |
163 | } |
164 | |
165 | |
10a26cea |
166 | function filters_sqimap_read_data ($imap_stream, $pre, $handle_errors, &$response, &$message) { |
167 | global $color, $squirrelmail_language, $imap_general_debug; |
4eee5968 |
168 | |
10a26cea |
169 | $data = array(); |
170 | $size = 0; |
4eee5968 |
171 | |
10a26cea |
172 | do { |
173 | $read = fgets($imap_stream, 9096); |
174 | if (ereg("^$pre (OK|BAD|NO)(.*)$", $read, $regs)) { |
175 | break; // found end of reply |
176 | } |
4eee5968 |
177 | |
10a26cea |
178 | // Continue if needed for this single line |
179 | while (strpos($read, "\n") === false) { |
180 | $read .= fgets($imap_stream, 9096); |
181 | } |
4eee5968 |
182 | |
10a26cea |
183 | $data[] = $read; |
4eee5968 |
184 | |
10a26cea |
185 | if (ereg("^\\* [0-9]+ FETCH.*\\{([0-9]+)\\}", $read, $regs)) { |
186 | $size = $regs[1]; |
4eee5968 |
187 | if ($imap_general_debug) { |
10a26cea |
188 | echo "<small><tt><font color=\"#CC0000\">Size is $size</font></tt></small><br>\n"; |
4eee5968 |
189 | } |
4eee5968 |
190 | |
10a26cea |
191 | $total_size = 0; |
192 | do { |
193 | $read = fgets($imap_stream, 9096); |
194 | if ($imap_general_debug) { |
195 | echo "<small><tt><font color=\"#CC0000\">$read</font></tt></small><br>\n"; |
196 | flush(); |
197 | } |
198 | $data[] = $read; |
199 | $total_size += strlen($read); |
200 | } while ($total_size < $size); |
4eee5968 |
201 | |
10a26cea |
202 | $size = 0; |
203 | } |
204 | // For debugging purposes |
ae840cbb |
205 | if ($imap_general_debug) { |
10a26cea |
206 | echo "<small><tt><font color=\"#CC0000\">$read</font></tt></small><br>\n"; |
207 | flush(); |
ae840cbb |
208 | } |
10a26cea |
209 | } while (true); |
4eee5968 |
210 | |
10a26cea |
211 | $response = $regs[1]; |
212 | $message = trim($regs[2]); |
4eee5968 |
213 | |
10a26cea |
214 | if ($imap_general_debug) { |
215 | echo '--<br>'; |
216 | } |
217 | |
218 | if (!$handle_errors) { |
219 | return $data; |
220 | } |
221 | |
222 | if ($response == 'NO') { |
223 | // ignore this error from m$ exchange, it is not fatal (aka bug) |
224 | if (strstr($message, 'command resulted in') === false) { |
4eee5968 |
225 | set_up_language($squirrelmail_language); |
10a26cea |
226 | echo "<br><b><font color=$color[2]>\n" . |
227 | _("ERROR : Could not complete request.") . |
228 | "</b><br>\n" . |
229 | _("Reason Given: ") . |
230 | $message . "</font><br>\n"; |
4eee5968 |
231 | exit; |
232 | } |
10a26cea |
233 | } else if ($response == 'BAD') { |
234 | set_up_language($squirrelmail_language); |
235 | echo "<br><b><font color=$color[2]>\n" . |
236 | _("ERROR : Bad or malformed request.") . |
237 | "</b><br>\n" . |
238 | _("Server responded: ") . |
239 | $message . "</font><br>\n"; |
240 | exit; |
4eee5968 |
241 | } |
242 | |
10a26cea |
243 | return $data; |
244 | } |
245 | |
246 | |
247 | function start_filters() { |
248 | global $mailbox, $username, $key, $imapServerAddress, $imapPort, $imap, |
249 | $imap_general, $filters, $imap_stream, $imapConnection, |
250 | $UseSeparateImapConnection, $AllowSpamFilters; |
251 | |
9feb4369 |
252 | # We really want to do this for ALL mailbox. |
d9a8ac55 |
253 | # if ($mailbox == 'INBOX') { |
10a26cea |
254 | // Detect if we have already connected to IMAP or not. |
255 | // Also check if we are forced to use a separate IMAP connection |
256 | if ((!isset($imap_stream) && !isset($imapConnection)) || |
257 | $UseSeparateImapConnection) { |
258 | $stream = sqimap_login($username, $key, $imapServerAddress, |
259 | $imapPort, 10); |
260 | $previously_connected = false; |
261 | } elseif (isset($imapConnection)) { |
262 | $stream = $imapConnection; |
263 | $previously_connected = true; |
264 | } else { |
265 | $previously_connected = true; |
266 | $stream = $imap_stream; |
267 | } |
4eee5968 |
268 | |
10a26cea |
269 | if (sqimap_get_num_messages($stream, 'INBOX') > 0) { |
270 | // Filter spam from inbox before we sort them into folders |
271 | if ($AllowSpamFilters) { |
272 | spam_filters($stream); |
4eee5968 |
273 | } |
274 | |
10a26cea |
275 | // Sort into folders |
276 | user_filters($stream); |
277 | } |
4eee5968 |
278 | |
10a26cea |
279 | if (!$previously_connected) { |
280 | sqimap_logout($stream); |
4eee5968 |
281 | } |
d9a8ac55 |
282 | # } |
10a26cea |
283 | } |
284 | |
285 | |
286 | function user_filters($imap_stream) { |
c8a2c24d |
287 | global $data_dir, $username; |
10a26cea |
288 | $filters = load_filters(); |
289 | if (! $filters) return; |
c8a2c24d |
290 | $filters_user_scan = getPref($data_dir, $username, 'filters_user_scan'); |
10a26cea |
291 | |
292 | sqimap_mailbox_select($imap_stream, 'INBOX'); |
293 | |
9feb4369 |
294 | /* For every rule */ |
10a26cea |
295 | for ($i=0; $i < count($filters); $i++) { |
296 | // If it is the "combo" rule |
297 | if ($filters[$i]['where'] == 'To or Cc') { |
9feb4369 |
298 | |
299 | /* If it's "TO OR CC", we have to do two */ |
300 | /* searches one for TO and the other for CC. */ |
301 | filter_search_and_delete($imap_stream, |
302 | 'TO', |
303 | $filters[$i]['what'], |
304 | $filters[$i]['folder'], |
305 | $filters_user_scan); |
306 | filter_search_and_delete($imap_stream, |
307 | 'CC', |
308 | $filters[$i]['what'], |
309 | $filters[$i]['folder'], |
310 | $filters_user_scan); |
10a26cea |
311 | } else { |
9feb4369 |
312 | |
313 | /* If it's a normal TO, CC, SUBJECT, */ |
314 | /* or FROM, then handle it normally. */ |
315 | filter_search_and_delete($imap_stream, |
316 | $filters[$i]['where'], |
317 | $filters[$i]['what'], |
318 | $filters[$i]['folder'], |
319 | $filters_user_scan); |
4eee5968 |
320 | } |
4eee5968 |
321 | } |
9feb4369 |
322 | |
323 | /* Clean out the mailbox whether or not auto_expunge is */ |
324 | /* on That way it looks like it was redirected properly */ |
10a26cea |
325 | sqimap_mailbox_expunge($imap_stream, 'INBOX'); |
326 | } |
327 | |
c8a2c24d |
328 | function filter_search_and_delete($imap, $where, $what, $where_to, $user_scan) { |
9feb4369 |
329 | global $languages, $squirrelmail_language, $allow_charset_search, |
330 | $uid_support; |
c8a2c24d |
331 | if ($user_scan == 'new') { |
332 | $category = 'UNSEEN'; |
333 | } else { |
334 | $category = 'ALL'; |
335 | } |
336 | |
9feb4369 |
337 | if ($allow_charset_search |
338 | && isset($languages[$squirrelmail_language]['CHARSET']) |
339 | && $languages[$squirrelmail_language]['CHARSET']) { |
340 | $search_str = 'SEARCH CHARSET "' |
f9ca4be0 |
341 | . strtoupper($languages[$squirrelmail_language]['CHARSET']) |
9feb4369 |
342 | . '" ' . $category . ' '; |
f9ca4be0 |
343 | } else { |
9feb4369 |
344 | $search_str = 'SEARCH CHARSET "US-ASCII" ' . $category . ' '; |
f9ca4be0 |
345 | } |
9da6bdde |
346 | if ($where == "Header") { |
347 | $what = explode(':', $what); |
348 | $where = trim($where . ' ' . $what[0]); |
349 | $what = addslashes(trim($what[1])); |
350 | } |
f9ca4be0 |
351 | $search_str .= $where . ' {' . strlen($what) . "}\r\n" . $what . "\r\n"; |
9feb4369 |
352 | $readin = sqimap_run_command($imap, $search_str, false, $result, $message, $uid_support); |
10a26cea |
353 | |
9feb4369 |
354 | for ($r=0; $r < count($readin) && substr($readin[$r], 0, 8) != '* SEARCH'; ++$r) {} |
355 | if ($result == 'OK') { |
356 | $ids = explode(' ', $readin[$r]); |
10a26cea |
357 | if (sqimap_mailbox_exists($imap, $where_to)) { |
358 | for ($j=2; $j < count($ids); $j++) { |
359 | $id = trim($ids[$j]); |
360 | sqimap_messages_copy ($imap, $id, $id, $where_to); |
9feb4369 |
361 | sqimap_messages_flag ($imap, $id, $id, 'Deleted', true); |
4eee5968 |
362 | } |
363 | } |
364 | } |
10a26cea |
365 | } |
4eee5968 |
366 | |
10a26cea |
367 | // These are the spam filters |
368 | function spam_filters($imap_stream) { |
369 | global $data_dir, $username; |
370 | global $SpamFilters_YourHop; |
371 | global $SpamFilters_DNScache; |
a2a566eb |
372 | global $SpamFilters_SharedCache; |
373 | global $SpamFilters_BulkQuery; |
4eee5968 |
374 | |
10a26cea |
375 | $filters_spam_scan = getPref($data_dir, $username, 'filters_spam_scan'); |
376 | $filters_spam_folder = getPref($data_dir, $username, 'filters_spam_folder'); |
377 | $filters = load_spam_filters(); |
4eee5968 |
378 | |
a2a566eb |
379 | if ($SpamFilters_SharedCache) { |
380 | filters_LoadCache(); |
381 | } |
382 | |
10a26cea |
383 | $run = 0; |
4eee5968 |
384 | |
10a26cea |
385 | foreach ($filters as $Key=> $Value) { |
386 | if ($Value['enabled']) { |
387 | $run ++; |
4eee5968 |
388 | } |
10a26cea |
389 | } |
4eee5968 |
390 | |
10a26cea |
391 | // short-circuit |
392 | if ($run == 0) { |
393 | return; |
394 | } |
4eee5968 |
395 | |
10a26cea |
396 | sqimap_mailbox_select($imap_stream, 'INBOX'); |
4eee5968 |
397 | |
10a26cea |
398 | // Ask for a big list of all "Received" headers in the inbox with |
399 | // flags for each message. Kinda big. |
c8a2c24d |
400 | //fputs($imap_stream, 'A3999 FETCH 1:* (FLAGS BODY.PEEK[HEADER.FIELDS ' . |
401 | // "(RECEIVED)])\r\n"); |
402 | $sid = sqimap_session_id(); |
403 | if ($filters_spam_scan != 'new') { |
404 | fputs($imap_stream, $sid.' FETCH 1:* (FLAGS BODY.PEEK[HEADER.FIELDS ' . |
405 | "(RECEIVED)])\r\n"); |
406 | } else { |
407 | fputs ($imap_stream, $sid.' SEARCH UNSEEN' . "\r\n"); |
408 | $read = filters_sqimap_read_data ($imap_stream, $sid, true, |
409 | $response, $message); |
410 | $sid = sqimap_session_id(); |
411 | if ($response != 'OK' || trim($read[0]) == '* SEARCH') { |
412 | fputs($imap_stream, |
413 | $sid.' FETCH 1:* (FLAGS BODY.PEEK[HEADER.FIELDS ' . |
414 | "(RECEIVED)])\r\n"); |
415 | } else { |
416 | $read[0] = trim($read[0]); |
417 | $i = 0; |
418 | $imap_query = $sid.' FETCH '; |
419 | $Chunks = explode(' ', $read[0]); |
420 | for ($i=2; $i < (count($Chunks)-1) ; $i++) { |
421 | $imap_query .= $Chunks[$i].','; |
422 | } |
423 | $imap_query .= $Chunks[count($Chunks)-1]; |
424 | $imap_query .= ' (FLAGS BODY.PEEK[HEADER.FIELDS '; |
425 | $imap_query .= "(RECEIVED)])\r\n"; |
426 | fputs($imap_stream, $imap_query); |
427 | } |
428 | } |
429 | |
430 | $read = filters_sqimap_read_data ($imap_stream, $sid, true, |
10a26cea |
431 | $response, $message); |
10a26cea |
432 | if ($response != 'OK') { |
433 | return; |
434 | } |
4eee5968 |
435 | |
a2a566eb |
436 | if (strlen($SpamFilters_BulkQuery) > 0) { |
437 | filters_bulkquery($filters_spam_scan, $filters, $read); |
438 | } |
439 | |
10a26cea |
440 | $i = 0; |
441 | while ($i < count($read)) { |
442 | // EIMS will give funky results |
443 | $Chunks = explode(' ', $read[$i]); |
444 | if ($Chunks[0] != '*') { |
4eee5968 |
445 | $i ++; |
10a26cea |
446 | continue; |
447 | } |
448 | $MsgNum = $Chunks[1]; |
4eee5968 |
449 | |
10a26cea |
450 | $IPs = array(); |
451 | $i ++; |
452 | $IsSpam = 0; |
4eee5968 |
453 | |
10a26cea |
454 | // Look through all of the Received headers for IP addresses |
455 | // Stop when I get ")" on a line |
456 | // Stop if I get "*" on a line (don't advance) |
457 | // and above all, stop if $i is bigger than the total # of lines |
458 | while (($i < count($read)) && |
459 | ($read[$i][0] != ')' && $read[$i][0] != '*' && |
460 | $read[$i][0] != "\n") && (! $IsSpam)) { |
461 | // Check to see if this line is the right "Received from" line |
462 | // to check |
463 | if (is_int(strpos($read[$i], $SpamFilters_YourHop))) { |
464 | |
465 | // short-circuit and skip work if we don't scan this one |
c8a2c24d |
466 | $read[$i] = ereg_replace('[^0-9\.]', ' ', $read[$i]); |
467 | $elements = explode(' ', $read[$i]); |
468 | foreach ($elements as $value) { |
469 | if ($value != '' && |
470 | ereg('[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}', |
471 | $value, $regs)) { |
472 | $Chunks = explode('.', $value); |
473 | if (filters_spam_check_site($Chunks[0], |
474 | $Chunks[1], $Chunks[2], $Chunks[3], |
475 | $filters)) { |
476 | $IsSpam ++; |
477 | break; // no sense in checking more IPs |
478 | } |
479 | // If we've checked one IP and YourHop is |
480 | // just a space |
481 | if ($SpamFilters_YourHop == ' ') { |
482 | break; // don't check any more |
a9aa7ab7 |
483 | } |
a9aa7ab7 |
484 | } |
4eee5968 |
485 | } |
4eee5968 |
486 | } |
10a26cea |
487 | $i ++; |
488 | } |
4eee5968 |
489 | |
10a26cea |
490 | // Lookie! It's spam! Yum! |
491 | if ($IsSpam) { |
492 | if (sqimap_mailbox_exists($imap_stream, $filters_spam_folder)) { |
493 | sqimap_messages_copy ($imap_stream, $MsgNum, $MsgNum, |
494 | $filters_spam_folder); |
495 | sqimap_messages_flag ($imap_stream, $MsgNum, $MsgNum, |
496 | 'Deleted'); |
4eee5968 |
497 | } |
10a26cea |
498 | } else { |
4eee5968 |
499 | } |
10a26cea |
500 | } |
4eee5968 |
501 | |
10a26cea |
502 | sqimap_mailbox_expunge($imap_stream, 'INBOX'); |
4eee5968 |
503 | |
a2a566eb |
504 | if ($SpamFilters_SharedCache) { |
505 | filters_SaveCache(); |
506 | } else { |
507 | session_register('SpamFilters_DNScache'); |
508 | } |
10a26cea |
509 | } |
4eee5968 |
510 | |
511 | |
10a26cea |
512 | // Does the loop through each enabled filter for the specified IP address. |
513 | // IP format: $a.$b.$c.$d |
514 | function filters_spam_check_site($a, $b, $c, $d, &$filters) { |
a2a566eb |
515 | global $SpamFilters_DNScache, $SpamFilters_CacheTTL; |
10a26cea |
516 | foreach ($filters as $key => $value) { |
517 | if ($filters[$key]['enabled']) { |
518 | if ($filters[$key]['dns']) { |
519 | $filter_revip = $d . '.' . $c . '.' . $b . '.' . $a . '.' . |
520 | $filters[$key]['dns']; |
a7cd90dd |
521 | if (strlen($SpamFilters_DNScache[$filter_revip]['L']) == 0) { |
522 | $SpamFilters_DNScache[$filter_revip]['L'] = |
523 | gethostbyname($filter_revip); |
524 | $SpamFilters_DNScache[$filter_revip]['T'] = |
525 | time() + $SpamFilters_CacheTTL; |
526 | } |
527 | if ($SpamFilters_DNScache[$filter_revip]['L'] == |
528 | $filters[$key]['result']) { |
529 | return 1; |
4eee5968 |
530 | } |
531 | } |
532 | } |
4eee5968 |
533 | } |
10a26cea |
534 | return 0; |
535 | } |
536 | |
537 | function load_filters() { |
538 | global $data_dir, $username; |
c8a2c24d |
539 | |
10a26cea |
540 | $filters = array(); |
541 | for ($i=0; $fltr = getPref($data_dir, $username, 'filter' . $i); $i++) { |
542 | $ary = explode(',', $fltr); |
543 | $filters[$i]['where'] = $ary[0]; |
544 | $filters[$i]['what'] = $ary[1]; |
545 | $filters[$i]['folder'] = $ary[2]; |
4eee5968 |
546 | } |
10a26cea |
547 | return $filters; |
548 | } |
549 | |
550 | function load_spam_filters() { |
51199e7a |
551 | global $data_dir, $username, $SpamFilters_ShowCommercial; |
552 | |
553 | if ($SpamFilters_ShowCommercial) { |
554 | $filters['MAPS RBL']['prefname'] = 'filters_spam_maps_rbl'; |
555 | $filters['MAPS RBL']['name'] = 'MAPS Realtime Blackhole List'; |
556 | $filters['MAPS RBL']['link'] = 'http://www.mail-abuse.org/rbl/'; |
557 | $filters['MAPS RBL']['dns'] = 'blackholes.mail-abuse.org'; |
558 | $filters['MAPS RBL']['result'] = '127.0.0.2'; |
559 | $filters['MAPS RBL']['comment'] = |
560 | _("COMMERCIAL - This list contains servers that are verified spam senders. It is a pretty reliable list to scan spam from."); |
561 | |
562 | $filters['MAPS RSS']['prefname'] = 'filters_spam_maps_rss'; |
563 | $filters['MAPS RSS']['name'] = 'MAPS Relay Spam Stopper'; |
564 | $filters['MAPS RSS']['link'] = 'http://www.mail-abuse.org/rss/'; |
565 | $filters['MAPS RSS']['dns'] = 'relays.mail-abuse.org'; |
566 | $filters['MAPS RSS']['result'] = '127.0.0.2'; |
567 | $filters['MAPS RSS']['comment'] = |
568 | _("COMMERCIAL - Servers that are configured (or misconfigured) to allow spam to be relayed through their system will be banned with this. Another good one to use."); |
569 | |
570 | $filters['MAPS DUL']['prefname'] = 'filters_spam_maps_dul'; |
571 | $filters['MAPS DUL']['name'] = 'MAPS Dial-Up List'; |
572 | $filters['MAPS DUL']['link'] = 'http://www.mail-abuse.org/dul/'; |
573 | $filters['MAPS DUL']['dns'] = 'dialups.mail-abuse.org'; |
574 | $filters['MAPS DUL']['result'] = '127.0.0.3'; |
575 | $filters['MAPS DUL']['comment'] = |
576 | _("COMMERCIAL - Dial-up users are often filtered out since they should use their ISP's mail servers to send mail. Spammers typically get a dial-up account and send spam directly from there."); |
577 | |
578 | $filters['MAPS RBLplus-RBL']['prefname'] = 'filters_spam_maps_rblplus_rbl'; |
579 | $filters['MAPS RBLplus-RBL']['name'] = 'MAPS RBL+ RBL List'; |
580 | $filters['MAPS RBLplus-RBL']['link'] = 'http://www.mail-abuse.org/'; |
581 | $filters['MAPS RBLplus-RBL']['dns'] = 'rbl-plus.mail-abuse.org'; |
582 | $filters['MAPS RBLplus-RBL']['result'] = '127.0.0.2'; |
583 | $filters['MAPS RBLplus-RBL']['comment'] = |
584 | _("COMMERCIAL - RBL+ Blackhole entries."); |
585 | |
586 | $filters['MAPS RBLplus-RSS']['prefname'] = 'filters_spam_maps_rblplus_rss'; |
587 | $filters['MAPS RBLplus-RSS']['name'] = 'MAPS RBL+ List RSS entries'; |
588 | $filters['MAPS RBLplus-RSS']['link'] = 'http://www.mail-abuse.org/'; |
589 | $filters['MAPS RBLplus-RSS']['dns'] = 'rbl-plus.mail-abuse.org'; |
590 | $filters['MAPS RBLplus-RSS']['result'] = '127.0.0.2'; |
591 | $filters['MAPS RBLplus-RSS']['comment'] = |
592 | _("COMMERCIAL - RBL+ OpenRelay entries."); |
593 | |
594 | $filters['MAPS RBLplus-DUL']['prefname'] = 'filters_spam_maps_rblplus_dul'; |
595 | $filters['MAPS RBLplus-DUL']['name'] = 'MAPS RBL+ List DUL entries'; |
596 | $filters['MAPS RBLplus-DUL']['link'] = 'http://www.mail-abuse.org/'; |
597 | $filters['MAPS RBLplus-DUL']['dns'] = 'rbl-plus.mail-abuse.org'; |
598 | $filters['MAPS RBLplus-DUL']['result'] = '127.0.0.3'; |
599 | $filters['MAPS RBLplus-DUL']['comment'] = |
600 | _("COMMERCIAL - RBL+ Dial-up entries."); |
601 | } |
10a26cea |
602 | |
603 | $filters['Osirusoft Relays']['prefname'] = 'filters_spam_maps_osirusoft_relay'; |
604 | $filters['Osirusoft Relays']['name'] = 'Osirusoft Relay List'; |
605 | $filters['Osirusoft Relays']['link'] = 'http://relays.osirusoft.com/'; |
606 | $filters['Osirusoft Relays']['dns'] = 'relays.osirusoft.com'; |
607 | $filters['Osirusoft Relays']['result'] = '127.0.0.2'; |
608 | $filters['Osirusoft Relays']['comment'] = |
609 | _("FREE - Osirusoft Relays - Osirusofts list of verified open relays. Seems to include servers used by abuse@uunet.net auto-replies too."); |
610 | |
611 | $filters['Osirusoft DUL']['prefname'] = 'filters_spam_maps_osirusoft_dul'; |
612 | $filters['Osirusoft DUL']['name'] = 'Osirusoft Dialup List'; |
613 | $filters['Osirusoft DUL']['link'] = 'http://relays.osirusoft.com/'; |
614 | $filters['Osirusoft DUL']['dns'] = 'relays.osirusoft.com'; |
615 | $filters['Osirusoft DUL']['result'] = '127.0.0.3'; |
616 | $filters['Osirusoft DUL']['comment'] = |
617 | _("FREE - Osirusoft Dialups - Osirusofts Dialup Spam Source list."); |
618 | |
619 | $filters['Osirusoft Spam Source']['prefname'] = 'filters_spam_maps_osirusoft_rc'; |
620 | $filters['Osirusoft Spam Source']['name'] = 'Osirusoft Confirmed Spam Source List'; |
621 | $filters['Osirusoft Spam Source']['link'] = 'http://relays.osirusoft.com/'; |
622 | $filters['Osirusoft Spam Source']['dns'] = 'relays.osirusoft.com'; |
623 | $filters['Osirusoft Spam Source']['result'] = '127.0.0.4'; |
624 | $filters['Osirusoft Spam Source']['comment'] = |
625 | _("FREE - Osirusoft Confirmed Spam Source - Sites that continually spam and have been manually added after multiple nominations. Use with caution. Seems to catch abuse auto-replies from some ISPs."); |
626 | |
627 | $filters['Osirusoft Smart Host']['prefname'] = 'filters_spam_maps_osirusoft_sh'; |
628 | $filters['Osirusoft Smart Host']['name'] = 'Osirusoft Smart Host List'; |
629 | $filters['Osirusoft Smart Host']['link'] = 'http://relays.osirusoft.com/'; |
630 | $filters['Osirusoft Smart Host']['dns'] = 'relays.osirusoft.com'; |
631 | $filters['Osirusoft Smart Host']['result'] = '127.0.0.5'; |
632 | $filters['Osirusoft Smart Host']['comment'] = |
633 | _("FREE - Osirusoft Smart Hosts - List of hosts that are secure but relay for other mail servers that are not secure."); |
634 | |
635 | $filters['Osirusoft SPAMware']['prefname'] = 'filters_spam_maps_osirusoft_ss'; |
636 | $filters['Osirusoft SPAMware']['name'] = 'Osirusoft Spamware Developers List'; |
637 | $filters['Osirusoft SPAMware']['link'] = 'http://relays.osirusoft.com/'; |
638 | $filters['Osirusoft SPAMware']['dns'] = 'relays.osirusoft.com'; |
639 | $filters['Osirusoft SPAMware']['result'] = '127.0.0.6'; |
640 | $filters['Osirusoft SPAMware']['comment'] = |
641 | _("FREE - Osirusoft Spamware Developers - It is believed that these are IP ranges of companies that are known to produce spam software. Seems to catch abuse auto-replies from some ISPs."); |
642 | |
643 | $filters['Osirusoft Unc. OptIn']['prefname'] = 'filters_spam_maps_osirusoft_sl'; |
644 | $filters['Osirusoft Unc. OptIn']['name'] = 'Osirusoft Unconfirmed OptIn Server List'; |
645 | $filters['Osirusoft Unc. OptIn']['link'] = 'http://relays.osirusoft.com/'; |
646 | $filters['Osirusoft Unc. OptIn']['dns'] = 'relays.osirusoft.com'; |
647 | $filters['Osirusoft Unc. OptIn']['result'] = '127.0.0.7'; |
648 | $filters['Osirusoft Unc. OptIn']['comment'] = |
649 | _("FREE - Osirusoft Unconfirmed OptIn Servers - List of listservers that opt users in without confirmation."); |
650 | |
651 | $filters['Osirusoft Insecure Formmail']['prefname'] = 'filters_spam_maps_osirusoft_fm'; |
652 | $filters['Osirusoft Insecure Formmail']['name'] = 'Osirusoft Insecure formmail.cvi Script List'; |
653 | $filters['Osirusoft Insecure Formmail']['link'] = 'http://relays.osirusoft.com/'; |
654 | $filters['Osirusoft Insecure Formmail']['dns'] = 'relays.osirusoft.com'; |
655 | $filters['Osirusoft Insecure Formmail']['result'] = '127.0.0.8'; |
656 | $filters['Osirusoft Insecure Formmail']['comment'] = |
657 | _("FREE - Osirusoft Insecure formmail.cgi scripts - List of insecure formmail.cgi scripts. (planned)."); |
658 | |
659 | $filters['Osirusoft Open Proxy']['prefname'] = 'filters_spam_maps_osirusoft_op'; |
660 | $filters['Osirusoft Open Proxy']['name'] = 'Osirusoft Open Proxy Server List'; |
661 | $filters['Osirusoft Open Proxy']['link'] = 'http://relays.osirusoft.com/'; |
662 | $filters['Osirusoft Open Proxy']['dns'] = 'relays.osirusoft.com'; |
663 | $filters['Osirusoft Open Proxy']['result'] = '127.0.0.9'; |
664 | $filters['Osirusoft Open Proxy']['comment'] = |
665 | _("FREE - Osirusoft Open Proxy Servers - List of Open Proxy Servers."); |
666 | |
667 | $filters['ORDB']['prefname'] = 'filters_spam_ordb'; |
668 | $filters['ORDB']['name'] = 'Open Relay Database List'; |
669 | $filters['ORDB']['link'] = 'http://www.ordb.org/'; |
670 | $filters['ORDB']['dns'] = 'relays.ordb.org'; |
671 | $filters['ORDB']['result'] = '127.0.0.2'; |
672 | $filters['ORDB']['comment'] = |
673 | _("FREE - ORDB was born when ORBS went off the air. It seems to have fewer false positives than ORBS did though."); |
674 | |
10a26cea |
675 | $filters['FiveTen Direct']['prefname'] = 'filters_spam_fiveten_src'; |
676 | $filters['FiveTen Direct']['name'] = 'Five-Ten-sg.com Direct SPAM Sources'; |
677 | $filters['FiveTen Direct']['link'] = 'http://www.five-ten-sg.com/blackhole.php'; |
678 | $filters['FiveTen Direct']['dns'] = 'blackholes.five-ten-sg.com'; |
679 | $filters['FiveTen Direct']['result'] = '127.0.0.2'; |
680 | $filters['FiveTen Direct']['comment'] = |
681 | _("FREE - Five-Ten-sg.com - Direct SPAM sources."); |
682 | |
683 | $filters['FiveTen DUL']['prefname'] = 'filters_spam_fiveten_dul'; |
684 | $filters['FiveTen DUL']['name'] = 'Five-Ten-sg.com DUL Lists'; |
685 | $filters['FiveTen DUL']['link'] = 'http://www.five-ten-sg.com/blackhole.php'; |
686 | $filters['FiveTen DUL']['dns'] = 'blackholes.five-ten-sg.com'; |
687 | $filters['FiveTen DUL']['result'] = '127.0.0.3'; |
688 | $filters['FiveTen DUL']['comment'] = |
689 | _("FREE - Five-Ten-sg.com - Dial-up lists - includes some DSL IPs."); |
690 | |
691 | $filters['FiveTen Unc. OptIn']['prefname'] = 'filters_spam_fiveten_oi'; |
692 | $filters['FiveTen Unc. OptIn']['name'] = 'Five-Ten-sg.com Unconfirmed OptIn Lists'; |
693 | $filters['FiveTen Unc. OptIn']['link'] = 'http://www.five-ten-sg.com/blackhole.php'; |
694 | $filters['FiveTen Unc. OptIn']['dns'] = 'blackholes.five-ten-sg.com'; |
695 | $filters['FiveTen Unc. OptIn']['result'] = '127.0.0.4'; |
696 | $filters['FiveTen Unc. OptIn']['comment'] = |
697 | _("FREE - Five-Ten-sg.com - Bulk mailers that do not use confirmed opt-in."); |
698 | |
699 | $filters['FiveTen Others']['prefname'] = 'filters_spam_fiveten_oth'; |
700 | $filters['FiveTen Others']['name'] = 'Five-Ten-sg.com Other Misc. Servers'; |
701 | $filters['FiveTen Others']['link'] = 'http://www.five-ten-sg.com/blackhole.php'; |
702 | $filters['FiveTen Others']['dns'] = 'blackholes.five-ten-sg.com'; |
703 | $filters['FiveTen Others']['result'] = '127.0.0.5'; |
704 | $filters['FiveTen Others']['comment'] = |
705 | _("FREE - Five-Ten-sg.com - Other misc. servers."); |
706 | |
707 | $filters['FiveTen Single Stage']['prefname'] = 'filters_spam_fiveten_ss'; |
708 | $filters['FiveTen Single Stage']['name'] = 'Five-Ten-sg.com Single Stage Servers'; |
709 | $filters['FiveTen Single Stage']['link'] = 'http://www.five-ten-sg.com/blackhole.php'; |
710 | $filters['FiveTen Single Stage']['dns'] = 'blackholes.five-ten-sg.com'; |
711 | $filters['FiveTen Single Stage']['result'] = '127.0.0.6'; |
712 | $filters['FiveTen Single Stage']['comment'] = |
713 | _("FREE - Five-Ten-sg.com - Single Stage servers."); |
714 | |
715 | $filters['FiveTen SPAM Support']['prefname'] = 'filters_spam_fiveten_supp'; |
716 | $filters['FiveTen SPAM Support']['name'] = 'Five-Ten-sg.com SPAM Support Servers'; |
717 | $filters['FiveTen SPAM Support']['link'] = 'http://www.five-ten-sg.com/blackhole.php'; |
718 | $filters['FiveTen SPAM Support']['dns'] = 'blackholes.five-ten-sg.com'; |
719 | $filters['FiveTen SPAM Support']['result'] = '127.0.0.7'; |
720 | $filters['FiveTen SPAM Support']['comment'] = |
721 | _("FREE - Five-Ten-sg.com - SPAM Support servers."); |
722 | |
723 | $filters['FiveTen Web forms']['prefname'] = 'filters_spam_fiveten_wf'; |
724 | $filters['FiveTen Web forms']['name'] = 'Five-Ten-sg.com Web Form IPs'; |
725 | $filters['FiveTen Web forms']['link'] = 'http://www.five-ten-sg.com/blackhole.php'; |
726 | $filters['FiveTen Web forms']['dns'] = 'blackholes.five-ten-sg.com'; |
727 | $filters['FiveTen Web forms']['result'] = '127.0.0.8'; |
728 | $filters['FiveTen Web forms']['comment'] = |
729 | _("FREE - Five-Ten-sg.com - Web Form IPs."); |
730 | |
731 | $filters['Dorkslayers']['prefname'] = 'filters_spam_dorks'; |
732 | $filters['Dorkslayers']['name'] = 'Dorkslayers Lists'; |
733 | $filters['Dorkslayers']['link'] = 'http://www.dorkslayers.com'; |
734 | $filters['Dorkslayers']['dns'] = 'orbs.dorkslayers.com'; |
735 | $filters['Dorkslayers']['result'] = '127.0.0.2'; |
736 | $filters['Dorkslayers']['comment'] = |
737 | _("FREE - Dorkslayers appears to include only really bad open relays outside the US to avoid being sued. Interestingly enough, their website recommends you NOT use their service."); |
738 | |
739 | $filters['SPAMhaus']['prefname'] = 'filters_spam_spamhaus'; |
740 | $filters['SPAMhaus']['name'] = 'SPAMhaus Lists'; |
741 | $filters['SPAMhaus']['link'] = 'http://www.spamhaus.org'; |
742 | $filters['SPAMhaus']['dns'] = 'sbl.spamhaus.org'; |
743 | $filters['SPAMhaus']['result'] = '127.0.0.6'; |
744 | $filters['SPAMhaus']['comment'] = |
745 | _("FREE - SPAMhaus - A list of well-known SPAM sources."); |
746 | |
747 | $filters['SPAMcop']['prefname'] = 'filters_spam_spamcop'; |
748 | $filters['SPAMcop']['name'] = 'SPAM Cop Lists'; |
749 | $filters['SPAMcop']['link'] = 'http://spamcop.net/bl.shtml'; |
750 | $filters['SPAMcop']['dns'] = 'bl.spamcop.net'; |
751 | $filters['SPAMcop']['result'] = '127.0.0.2'; |
752 | $filters['SPAMcop']['comment'] = |
753 | _("FREE, for now - SPAMCOP - An interesting solution that lists servers that have a very high spam to legit email ratio (85% or more)."); |
754 | |
46a184ff |
755 | $filters['dev.null.dk']['prefname'] = 'filters_spam_devnull'; |
756 | $filters['dev.null.dk']['name'] = 'dev.null.dk Lists'; |
757 | $filters['dev.null.dk']['link'] = 'http://dev.null.dk/'; |
758 | $filters['dev.null.dk']['dns'] = 'dev.null.dk'; |
759 | $filters['dev.null.dk']['result'] = '127.0.0.2'; |
760 | $filters['dev.null.dk']['comment'] = |
761 | _("FREE - dev.null.dk - I don't have any detailed info on this list."); |
762 | |
763 | $filters['visi.com']['prefname'] = 'filters_spam_visi'; |
764 | $filters['visi.com']['name'] = 'visi.com Relay Stop List'; |
765 | $filters['visi.com']['link'] = 'http://relays.visi.com'; |
766 | $filters['visi.com']['dns'] = 'relays.visi.com'; |
767 | $filters['visi.com']['result'] = '127.0.0.2'; |
768 | $filters['visi.com']['comment'] = |
769 | _("FREE - visi.com - Relay Stop List. Very conservative OpenRelay List."); |
770 | |
771 | $filters['2mbit.com Open Relays']['prefname'] = 'filters_spam_2mb_or'; |
772 | $filters['2mbit.com Open Relays']['name'] = '2mbit.com Open Relays List'; |
773 | $filters['2mbit.com Open Relays']['link'] = 'http://www.2mbit.com/sbl.php'; |
774 | $filters['2mbit.com Open Relays']['dns'] = 'blackholes.2mbit.com'; |
775 | $filters['2mbit.com Open Relays']['result'] = '127.0.0.2'; |
776 | $filters['2mbit.com Open Relays']['comment'] = |
777 | _("FREE - 2mbit.com Open Relays - Another list of Open Relays."); |
778 | |
779 | $filters['2mbit.com SPAM Source']['prefname'] = 'filters_spam_2mb_ss'; |
780 | $filters['2mbit.com SPAM Source']['name'] = '2mbit.com SPAM Source List'; |
781 | $filters['2mbit.com SPAM Source']['link'] = 'http://www.2mbit.com/sbl.php'; |
782 | $filters['2mbit.com SPAM Source']['dns'] = 'blackholes.2mbit.com'; |
783 | $filters['2mbit.com SPAM Source']['result'] = '127.0.0.4'; |
784 | $filters['2mbit.com SPAM Source']['comment'] = |
785 | _("FREE - 2mbit.com SPAM Source - List of Direct SPAM Sources."); |
786 | |
787 | $filters['2mbit.com SPAM ISPs']['prefname'] = 'filters_spam_2mb_isp'; |
788 | $filters['2mbit.com SPAM ISPs']['name'] = '2mbit.com SPAM-friendly ISP List'; |
789 | $filters['2mbit.com SPAM ISPs']['link'] = 'http://www.2mbit.com/sbl.php'; |
790 | $filters['2mbit.com SPAM ISPs']['dns'] = 'blackholes.2mbit.com'; |
791 | $filters['2mbit.com SPAM ISPs']['result'] = '127.0.0.10'; |
792 | $filters['2mbit.com SPAM ISPs']['comment'] = |
793 | _("FREE - 2mbit.com SPAM ISPs - List of SPAM-friendly ISPs."); |
794 | |
795 | $filters['Leadmon DUL']['prefname'] = 'filters_spam_lm_dul'; |
796 | $filters['Leadmon DUL']['name'] = 'Leadmon.net DUL List'; |
797 | $filters['Leadmon DUL']['link'] = 'http://www.leadmon.net/spamguard/'; |
798 | $filters['Leadmon DUL']['dns'] = 'spamguard.leadmon.net'; |
799 | $filters['Leadmon DUL']['result'] = '127.0.0.2'; |
800 | $filters['Leadmon DUL']['comment'] = |
801 | _("FREE - Leadmon DUL - Another list of Dial-up or otherwise dynamically assigned IPs."); |
802 | |
803 | $filters['Leadmon SPAM Source']['prefname'] = 'filters_spam_lm_ss'; |
804 | $filters['Leadmon SPAM Source']['name'] = 'Leadmon.net SPAM Source List'; |
805 | $filters['Leadmon SPAM Source']['link'] = 'http://www.leadmon.net/spamguard/'; |
806 | $filters['Leadmon SPAM Source']['dns'] = 'spamguard.leadmon.net'; |
807 | $filters['Leadmon SPAM Source']['result'] = '127.0.0.3'; |
808 | $filters['Leadmon SPAM Source']['comment'] = |
809 | _("FREE - Leadmon SPAM Source - List of IPs Leadmon.net has received SPAM directly from."); |
810 | |
811 | $filters['Leadmon Bulk Mailers']['prefname'] = 'filters_spam_lm_bm'; |
812 | $filters['Leadmon Bulk Mailers']['name'] = 'Leadmon.net Bulk Mailers List'; |
813 | $filters['Leadmon Bulk Mailers']['link'] = 'http://www.leadmon.net/spamguard/'; |
814 | $filters['Leadmon Bulk Mailers']['dns'] = 'spamguard.leadmon.net'; |
815 | $filters['Leadmon Bulk Mailers']['result'] = '127.0.0.4'; |
816 | $filters['Leadmon Bulk Mailers']['comment'] = |
817 | _("FREE - Leadmon Bulk Mailers - Bulk mailers that do not require confirmed opt-in or that have allowed known spammers to become clients and abuse their services."); |
818 | |
819 | $filters['Leadmon Open Relays']['prefname'] = 'filters_spam_lm_or'; |
820 | $filters['Leadmon Open Relays']['name'] = 'Leadmon.net Open Relays List'; |
821 | $filters['Leadmon Open Relays']['link'] = 'http://www.leadmon.net/spamguard/'; |
822 | $filters['Leadmon Open Relays']['dns'] = 'spamguard.leadmon.net'; |
823 | $filters['Leadmon Open Relays']['result'] = '127.0.0.5'; |
824 | $filters['Leadmon Open Relays']['comment'] = |
825 | _("FREE - Leadmon Open Relays - Single Stage Open Relays that are not listed on other active RBLs."); |
826 | |
827 | $filters['Leadmon Multi-stage']['prefname'] = 'filters_spam_lm_ms'; |
828 | $filters['Leadmon Multi-stage']['name'] = 'Leadmon.net Multi-Stage Relay List'; |
829 | $filters['Leadmon Multi-stage']['link'] = 'http://www.leadmon.net/spamguard/'; |
830 | $filters['Leadmon Multi-stage']['dns'] = 'spamguard.leadmon.net'; |
831 | $filters['Leadmon Multi-stage']['result'] = '127.0.0.6'; |
832 | $filters['Leadmon Multi-stage']['comment'] = |
833 | _("FREE - Leadmon Multi-stage - Multi-Stage Open Relays that are not listed on other active RBLs and that have sent SPAM to Leadmon.net."); |
834 | |
835 | $filters['Leadmon SpamBlock']['prefname'] = 'filters_spam_lm_sb'; |
836 | $filters['Leadmon SpamBlock']['name'] = 'Leadmon.net SpamBlock Sites List'; |
837 | $filters['Leadmon SpamBlock']['link'] = 'http://www.leadmon.net/spamguard/'; |
838 | $filters['Leadmon SpamBlock']['dns'] = 'spamguard.leadmon.net'; |
839 | $filters['Leadmon SpamBlock']['result'] = '127.0.0.7'; |
840 | $filters['Leadmon SpamBlock']['comment'] = |
841 | _("FREE - Leadmon SpamBlock - Sites on this listing have sent Leadmon.net direct SPAM from IPs in netblocks where the entire block has no DNS mappings. It's a list of BLOCKS of IPs being used by people who have SPAMmed Leadmon.net."); |
842 | |
843 | $filters['NJABL Open Relays']['prefname'] = 'filters_spam_njabl_or'; |
844 | $filters['NJABL Open Relays']['name'] = 'NJABL Open Relay/Direct Spam Source List'; |
845 | $filters['NJABL Open Relays']['link'] = 'http://www.njabl.org/'; |
846 | $filters['NJABL Open Relays']['dns'] = 'dnsbl.njabl.org'; |
847 | $filters['NJABL Open Relays']['result'] = '127.0.0.2'; |
848 | $filters['NJABL Open Relays']['comment'] = |
849 | _("FREE, for now - Not Just Another Blacklist - Both Open Relays and Direct SPAM Sources."); |
850 | |
851 | $filters['NJABL DUL']['prefname'] = 'filters_spam_njabl_dul'; |
852 | $filters['NJABL DUL']['name'] = 'NJABL Dial-ups List'; |
853 | $filters['NJABL DUL']['link'] = 'http://www.njabl.org/'; |
854 | $filters['NJABL DUL']['dns'] = 'dnsbl.njabl.org'; |
855 | $filters['NJABL DUL']['result'] = '127.0.0.3'; |
856 | $filters['NJABL DUL']['comment'] = |
857 | _("FREE, for now - Not Just Another Blacklist - Dial-up IPs."); |
858 | |
18b078e9 |
859 | $filters['Conf DSBL.ORG Relay']['prefname'] = 'filters_spam_dsbl_conf_ss'; |
860 | $filters['Conf DSBL.ORG Relay']['name'] = 'DSBL.org Confirmed Relay List'; |
861 | $filters['Conf DSBL.ORG Relay']['link'] = 'http://www.dsbl.org/'; |
862 | $filters['Conf DSBL.ORG Relay']['dns'] = 'list.dsbl.org'; |
863 | $filters['Conf DSBL.ORG Relay']['result'] = '127.0.0.2'; |
864 | $filters['Conf DSBL.ORG Relay']['comment'] = |
865 | _("FREE - Distributed Sender Boycott List - Confirmed Relays"); |
866 | |
867 | $filters['Conf DSBL.ORG Multi-Stage']['prefname'] = 'filters_spam_dsbl_conf_ms'; |
868 | $filters['Conf DSBL.ORG Multi-Stage']['name'] = 'DSBL.org Confirmed Multi-Stage Relay List'; |
869 | $filters['Conf DSBL.ORG Multi-Stage']['link'] = 'http://www.dsbl.org/'; |
870 | $filters['Conf DSBL.ORG Multi-Stage']['dns'] = 'multihop.dsbl.org'; |
871 | $filters['Conf DSBL.ORG Multi-Stage']['result'] = '127.0.0.2'; |
872 | $filters['Conf DSBL.ORG Multi-Stage']['comment'] = |
873 | _("FREE - Distributed Sender Boycott List - Confirmed Multi-stage Relays"); |
874 | |
875 | $filters['UN-Conf DSBL.ORG']['prefname'] = 'filters_spam_dsbl_unc'; |
876 | $filters['UN-Conf DSBL.ORG']['name'] = 'DSBL.org UN-Confirmed Relay List'; |
877 | $filters['UN-Conf DSBL.ORG']['link'] = 'http://www.dsbl.org/'; |
878 | $filters['UN-Conf DSBL.ORG']['dns'] = 'unconfirmed.dsbl.org'; |
879 | $filters['UN-Conf DSBL.ORG']['result'] = '127.0.0.2'; |
880 | $filters['UN-Conf DSBL.ORG']['comment'] = |
881 | _("FREE - Distributed Sender Boycott List - UN-Confirmed Relays"); |
882 | |
10a26cea |
883 | foreach ($filters as $Key => $Value) { |
884 | $filters[$Key]['enabled'] = getPref($data_dir, $username, |
885 | $filters[$Key]['prefname']); |
4eee5968 |
886 | } |
887 | |
10a26cea |
888 | return $filters; |
889 | } |
4eee5968 |
890 | |
10a26cea |
891 | function remove_filter ($id) { |
892 | global $data_dir, $username; |
4eee5968 |
893 | |
10a26cea |
894 | while ($nextFilter = getPref($data_dir, $username, 'filter' . |
895 | ($id + 1))) { |
896 | setPref($data_dir, $username, 'filter' . $id, $nextFilter); |
897 | $id ++; |
4eee5968 |
898 | } |
899 | |
10a26cea |
900 | removePref($data_dir, $username, 'filter' . $id); |
901 | } |
4eee5968 |
902 | |
10a26cea |
903 | function filter_swap($id1, $id2) { |
904 | global $data_dir, $username; |
4eee5968 |
905 | |
10a26cea |
906 | $FirstFilter = getPref($data_dir, $username, 'filter' . $id1); |
907 | $SecondFilter = getPref($data_dir, $username, 'filter' . $id2); |
908 | |
909 | if ($FirstFilter && $SecondFilter) { |
910 | setPref($data_dir, $username, 'filter' . $id2, $FirstFilter); |
911 | setPref($data_dir, $username, 'filter' . $id1, $SecondFilter); |
4eee5968 |
912 | } |
10a26cea |
913 | } |
4eec80a7 |
914 | |
915 | /* This update the filter rules when |
916 | renaming or deleting folders */ |
f5ab1fb9 |
917 | function update_for_folder ($args) { |
918 | $old_folder = $args[0]; |
a2a566eb |
919 | $new_folder = $args[2]; |
920 | $action = $args[1]; |
4eec80a7 |
921 | global $plugins, $data_dir, $username; |
922 | $filters = array(); |
923 | $filters = load_filters(); |
924 | $filter_count = count($filters); |
925 | $p = 0; |
926 | for ($i=0;$i<$filter_count;$i++) { |
927 | if (!empty($filters)) { |
928 | if ($old_folder == $filters[$i]['folder']) { |
929 | if ($action == 'rename') { |
930 | $filters[$i]['folder'] = $new_folder; |
931 | setPref($data_dir, $username, 'filter'.$i, |
932 | $filters[$i]['where'].','.$filters[$i]['what'].','.$new_folder); |
933 | } |
934 | elseif ($action == 'delete') { |
935 | remove_filter($p); |
936 | $p = $p-1; |
937 | } |
938 | } |
939 | $p++; |
940 | } |
941 | } |
942 | } |
849bdf42 |
943 | ?> |