fixes "orphaned" sub folders when renaming parent folder
[squirrelmail.git] / plugins / filters / filters.php
1 <?php
2
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 */
27
28 function filters_sqimap_read_data ($imap_stream, $pre, $handle_errors, &$response, &$message) {
29 global $color, $squirrelmail_language, $imap_general_debug;
30
31 $data = array();
32 $size = 0;
33
34 do {
35 $read = fgets($imap_stream, 9096);
36 if (ereg("^$pre (OK|BAD|NO)(.*)$", $read, $regs)) {
37 break; // found end of reply
38 }
39
40 // Continue if needed for this single line
41 while (strpos($read, "\n") === false) {
42 $read .= fgets($imap_stream, 9096);
43 }
44
45 $data[] = $read;
46
47 if (ereg("^\\* [0-9]+ FETCH.*\\{([0-9]+)\\}", $read, $regs)) {
48 $size = $regs[1];
49 if ($imap_general_debug) {
50 echo "<small><tt><font color=\"#CC0000\">Size is $size</font></tt></small><br>\n";
51 }
52
53 $total_size = 0;
54 do {
55 $read = fgets($imap_stream, 9096);
56 if ($imap_general_debug) {
57 echo "<small><tt><font color=\"#CC0000\">$read</font></tt></small><br>\n";
58 flush();
59 }
60 $data[] = $read;
61 $total_size += strlen($read);
62 } while ($total_size < $size);
63
64 $size = 0;
65 }
66 // For debugging purposes
67 if ($imap_general_debug) {
68 echo "<small><tt><font color=\"#CC0000\">$read</font></tt></small><br>\n";
69 flush();
70 }
71 } while (true);
72
73 $response = $regs[1];
74 $message = trim($regs[2]);
75
76 if ($imap_general_debug) {
77 echo '--<br>';
78 }
79
80 if (!$handle_errors) {
81 return $data;
82 }
83
84 if ($response == 'NO') {
85 // ignore this error from m$ exchange, it is not fatal (aka bug)
86 if (strstr($message, 'command resulted in') === false) {
87 set_up_language($squirrelmail_language);
88 echo "<br><b><font color=$color[2]>\n" .
89 _("ERROR : Could not complete request.") .
90 "</b><br>\n" .
91 _("Reason Given: ") .
92 $message . "</font><br>\n";
93 exit;
94 }
95 } else if ($response == 'BAD') {
96 set_up_language($squirrelmail_language);
97 echo "<br><b><font color=$color[2]>\n" .
98 _("ERROR : Bad or malformed request.") .
99 "</b><br>\n" .
100 _("Server responded: ") .
101 $message . "</font><br>\n";
102 exit;
103 }
104
105 return $data;
106 }
107
108
109 function start_filters() {
110 global $mailbox, $username, $key, $imapServerAddress, $imapPort, $imap,
111 $imap_general, $filters, $imap_stream, $imapConnection,
112 $UseSeparateImapConnection, $AllowSpamFilters;
113
114 if ($mailbox == 'INBOX') {
115 // Detect if we have already connected to IMAP or not.
116 // Also check if we are forced to use a separate IMAP connection
117 if ((!isset($imap_stream) && !isset($imapConnection)) ||
118 $UseSeparateImapConnection) {
119 $stream = sqimap_login($username, $key, $imapServerAddress,
120 $imapPort, 10);
121 $previously_connected = false;
122 } elseif (isset($imapConnection)) {
123 $stream = $imapConnection;
124 $previously_connected = true;
125 } else {
126 $previously_connected = true;
127 $stream = $imap_stream;
128 }
129
130 if (sqimap_get_num_messages($stream, 'INBOX') > 0) {
131 // Filter spam from inbox before we sort them into folders
132 if ($AllowSpamFilters) {
133 spam_filters($stream);
134 }
135
136 // Sort into folders
137 user_filters($stream);
138 }
139
140 if (!$previously_connected) {
141 sqimap_logout($stream);
142 }
143 }
144 }
145
146
147 function user_filters($imap_stream) {
148 $filters = load_filters();
149 if (! $filters) return;
150
151 sqimap_mailbox_select($imap_stream, 'INBOX');
152
153 // For every rule
154 for ($i=0; $i < count($filters); $i++) {
155 // If it is the "combo" rule
156 if ($filters[$i]['where'] == 'To or Cc') {
157 /*
158 * If it's "TO OR CC", we have to do two searches, one for TO
159 * and the other for CC.
160 */
161 filter_search_and_delete($imap_stream, 'TO',
162 $filters[$i]['what'], $filters[$i]['folder']);
163 filter_search_and_delete($imap_stream, 'CC',
164 $filters[$i]['what'], $filters[$i]['folder']);
165 } else {
166 /*
167 * If it's a normal TO, CC, SUBJECT, or FROM, then handle it
168 * normally.
169 */
170 filter_search_and_delete($imap_stream, $filters[$i]['where'],
171 $filters[$i]['what'], $filters[$i]['folder']);
172 }
173 }
174 // Clean out the mailbox whether or not auto_expunge is on
175 // That way it looks like it was redirected properly
176 sqimap_mailbox_expunge($imap_stream, 'INBOX');
177 }
178
179 function filter_search_and_delete($imap, $where, $what, $where_to) {
180 // Don't mess with the " characters on this fputs line!
181 fputs ($imap, 'a001 SEARCH ALL ' . $where . ' "' . addslashes($what) .
182 "\"\r\n");
183 $read = filters_sqimap_read_data ($imap, 'a001', true, $response, $message);
184
185 // This may have problems with EIMS due to it being goofy
186
187 for ($r=0; $r < count($read) &&
188 substr($read[$r], 0, 8) != '* SEARCH'; $r++) {}
189 if ($response == 'OK') {
190 $ids = explode(' ', $read[$r]);
191 if (sqimap_mailbox_exists($imap, $where_to)) {
192 for ($j=2; $j < count($ids); $j++) {
193 $id = trim($ids[$j]);
194 sqimap_messages_copy ($imap, $id, $id, $where_to);
195 sqimap_messages_flag ($imap, $id, $id, 'Deleted');
196 }
197 }
198 }
199 }
200
201 // These are the spam filters
202 function spam_filters($imap_stream) {
203 global $data_dir, $username;
204 global $SpamFilters_YourHop;
205 global $SpamFilters_DNScache;
206
207 $filters_spam_scan = getPref($data_dir, $username, 'filters_spam_scan');
208 $filters_spam_folder = getPref($data_dir, $username, 'filters_spam_folder');
209 $filters = load_spam_filters();
210
211 $run = 0;
212
213 foreach ($filters as $Key=> $Value) {
214 if ($Value['enabled']) {
215 $run ++;
216 }
217 }
218
219 // short-circuit
220 if ($run == 0) {
221 return;
222 }
223
224 sqimap_mailbox_select($imap_stream, 'INBOX');
225
226 // Ask for a big list of all "Received" headers in the inbox with
227 // flags for each message. Kinda big.
228 fputs($imap_stream, 'A3999 FETCH 1:* (FLAGS BODY.PEEK[HEADER.FIELDS ' .
229 "(RECEIVED)])\r\n");
230
231 $read = filters_sqimap_read_data ($imap_stream, 'A3999', true,
232 $response, $message);
233
234 if ($response != 'OK') {
235 return;
236 }
237
238 $i = 0;
239 while ($i < count($read)) {
240 // EIMS will give funky results
241 $Chunks = explode(' ', $read[$i]);
242 if ($Chunks[0] != '*') {
243 $i ++;
244 continue;
245 }
246 $MsgNum = $Chunks[1];
247
248 $IPs = array();
249 $i ++;
250 $IsSpam = 0;
251 $Scan = 1;
252
253 // Check for normal IMAP servers
254 if ($filters_spam_scan == 'new') {
255 if (is_int(strpos($Chunks[4], '\Seen'))) {
256 $Scan = 0;
257 }
258 }
259
260 // Look through all of the Received headers for IP addresses
261 // Stop when I get ")" on a line
262 // Stop if I get "*" on a line (don't advance)
263 // and above all, stop if $i is bigger than the total # of lines
264 while (($i < count($read)) &&
265 ($read[$i][0] != ')' && $read[$i][0] != '*' &&
266 $read[$i][0] != "\n") && (! $IsSpam)) {
267 // Check to see if this line is the right "Received from" line
268 // to check
269 if (is_int(strpos($read[$i], $SpamFilters_YourHop))) {
270
271 // short-circuit and skip work if we don't scan this one
272 if ($Scan) {
273 $read[$i] = ereg_replace('[^0-9\.]', ' ', $read[$i]);
274 $elements = explode(' ', $read[$i]);
275 foreach ($elements as $value) {
276 if ($value != '' &&
277 ereg('[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}',
278 $value, $regs)) {
279 $Chunks = explode('.', $value);
280 if (filters_spam_check_site($Chunks[0],
281 $Chunks[1], $Chunks[2], $Chunks[3],
282 $filters)) {
283 $IsSpam ++;
284 break; // no sense in checking more IPs
285 }
286 // If we've checked one IP and YourHop is
287 // just a space
288 if ($SpamFilters_YourHop == ' ') {
289 break; // don't check any more
290 }
291 }
292 }
293 }
294 }
295 $i ++;
296 }
297
298 // Lookie! It's spam! Yum!
299 if ($IsSpam) {
300 if (sqimap_mailbox_exists($imap_stream, $filters_spam_folder)) {
301 sqimap_messages_copy ($imap_stream, $MsgNum, $MsgNum,
302 $filters_spam_folder);
303 sqimap_messages_flag ($imap_stream, $MsgNum, $MsgNum,
304 'Deleted');
305 }
306 } else {
307 }
308 }
309
310 sqimap_mailbox_expunge($imap_stream, 'INBOX');
311
312 session_register('SpamFilters_DNScache');
313 }
314
315
316 // Does the loop through each enabled filter for the specified IP address.
317 // IP format: $a.$b.$c.$d
318 function filters_spam_check_site($a, $b, $c, $d, &$filters) {
319 global $SpamFilters_DNScache;
320 foreach ($filters as $key => $value) {
321 if ($filters[$key]['enabled']) {
322 if ($filters[$key]['dns']) {
323 $filter_revip = $d . '.' . $c . '.' . $b . '.' . $a . '.' .
324 $filters[$key]['dns'];
325 if (strlen($SpamFilters_DNScache[$filter_revip]) == 0) {
326 $SpamFilters_DNScache[$filter_revip] =
327 gethostbyname($filter_revip);
328 }
329 if ($SpamFilters_DNScache[$filter_revip] ==
330 $filters[$key]['result']) {
331 return 1;
332 }
333 }
334 }
335 }
336 return 0;
337 }
338
339 function load_filters() {
340 global $data_dir, $username;
341 $filters = array();
342 for ($i=0; $fltr = getPref($data_dir, $username, 'filter' . $i); $i++) {
343 $ary = explode(',', $fltr);
344 $filters[$i]['where'] = $ary[0];
345 $filters[$i]['what'] = $ary[1];
346 $filters[$i]['folder'] = $ary[2];
347 }
348 return $filters;
349 }
350
351 function load_spam_filters() {
352 global $data_dir, $username;
353
354 $filters['MAPS RBL']['prefname'] = 'filters_spam_maps_rbl';
355 $filters['MAPS RBL']['name'] = 'MAPS Realtime Blackhole List';
356 $filters['MAPS RBL']['link'] = 'http://www.mail-abuse.org/rbl/';
357 $filters['MAPS RBL']['dns'] = 'blackholes.mail-abuse.org';
358 $filters['MAPS RBL']['result'] = '127.0.0.2';
359 $filters['MAPS RBL']['comment'] =
360 _("COMMERCIAL - This list contains servers that are verified spam senders. It is a pretty reliable list to scan spam from.");
361
362 $filters['MAPS RSS']['prefname'] = 'filters_spam_maps_rss';
363 $filters['MAPS RSS']['name'] = 'MAPS Relay Spam Stopper';
364 $filters['MAPS RSS']['link'] = 'http://www.mail-abuse.org/rss/';
365 $filters['MAPS RSS']['dns'] = 'relays.mail-abuse.org';
366 $filters['MAPS RSS']['result'] = '127.0.0.2';
367 $filters['MAPS RSS']['comment'] =
368 _("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.");
369
370 $filters['MAPS DUL']['prefname'] = 'filters_spam_maps_dul';
371 $filters['MAPS DUL']['name'] = 'MAPS Dial-Up List';
372 $filters['MAPS DUL']['link'] = 'http://www.mail-abuse.org/dul/';
373 $filters['MAPS DUL']['dns'] = 'dialups.mail-abuse.org';
374 $filters['MAPS DUL']['result'] = '127.0.0.3';
375 $filters['MAPS DUL']['comment'] =
376 _("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.");
377
378 $filters['MAPS RBLplus-RBL']['prefname'] = 'filters_spam_maps_rblplus_rbl';
379 $filters['MAPS RBLplus-RBL']['name'] = 'MAPS RBL+ RBL List';
380 $filters['MAPS RBLplus-RBL']['link'] = 'http://www.mail-abuse.org/';
381 $filters['MAPS RBLplus-RBL']['dns'] = 'rbl-plus.mail-abuse.org';
382 $filters['MAPS RBLplus-RBL']['result'] = '127.0.0.2';
383 $filters['MAPS RBLplus-RBL']['comment'] =
384 _("COMMERCIAL - RBL+ Blackhole entries.");
385
386 $filters['MAPS RBLplus-RSS']['prefname'] = 'filters_spam_maps_rblplus_rss';
387 $filters['MAPS RBLplus-RSS']['name'] = 'MAPS RBL+ List RSS entries';
388 $filters['MAPS RBLplus-RSS']['link'] = 'http://www.mail-abuse.org/';
389 $filters['MAPS RBLplus-RSS']['dns'] = 'rbl-plus.mail-abuse.org';
390 $filters['MAPS RBLplus-RSS']['result'] = '127.0.0.2';
391 $filters['MAPS RBLplus-RSS']['comment'] =
392 _("COMMERCIAL - RBL+ OpenRelay entries.");
393
394 $filters['MAPS RBLplus-DUL']['prefname'] = 'filters_spam_maps_rblplus_dul';
395 $filters['MAPS RBLplus-DUL']['name'] = 'MAPS RBL+ List DUL entries';
396 $filters['MAPS RBLplus-DUL']['link'] = 'http://www.mail-abuse.org/';
397 $filters['MAPS RBLplus-DUL']['dns'] = 'rbl-plus.mail-abuse.org';
398 $filters['MAPS RBLplus-DUL']['result'] = '127.0.0.3';
399 $filters['MAPS RBLplus-DUL']['comment'] =
400 _("COMMERCIAL - RBL+ Dial-up entries.");
401
402 $filters['Osirusoft Relays']['prefname'] = 'filters_spam_maps_osirusoft_relay';
403 $filters['Osirusoft Relays']['name'] = 'Osirusoft Relay List';
404 $filters['Osirusoft Relays']['link'] = 'http://relays.osirusoft.com/';
405 $filters['Osirusoft Relays']['dns'] = 'relays.osirusoft.com';
406 $filters['Osirusoft Relays']['result'] = '127.0.0.2';
407 $filters['Osirusoft Relays']['comment'] =
408 _("FREE - Osirusoft Relays - Osirusofts list of verified open relays. Seems to include servers used by abuse@uunet.net auto-replies too.");
409
410 $filters['Osirusoft DUL']['prefname'] = 'filters_spam_maps_osirusoft_dul';
411 $filters['Osirusoft DUL']['name'] = 'Osirusoft Dialup List';
412 $filters['Osirusoft DUL']['link'] = 'http://relays.osirusoft.com/';
413 $filters['Osirusoft DUL']['dns'] = 'relays.osirusoft.com';
414 $filters['Osirusoft DUL']['result'] = '127.0.0.3';
415 $filters['Osirusoft DUL']['comment'] =
416 _("FREE - Osirusoft Dialups - Osirusofts Dialup Spam Source list.");
417
418 $filters['Osirusoft Spam Source']['prefname'] = 'filters_spam_maps_osirusoft_rc';
419 $filters['Osirusoft Spam Source']['name'] = 'Osirusoft Confirmed Spam Source List';
420 $filters['Osirusoft Spam Source']['link'] = 'http://relays.osirusoft.com/';
421 $filters['Osirusoft Spam Source']['dns'] = 'relays.osirusoft.com';
422 $filters['Osirusoft Spam Source']['result'] = '127.0.0.4';
423 $filters['Osirusoft Spam Source']['comment'] =
424 _("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.");
425
426 $filters['Osirusoft Smart Host']['prefname'] = 'filters_spam_maps_osirusoft_sh';
427 $filters['Osirusoft Smart Host']['name'] = 'Osirusoft Smart Host List';
428 $filters['Osirusoft Smart Host']['link'] = 'http://relays.osirusoft.com/';
429 $filters['Osirusoft Smart Host']['dns'] = 'relays.osirusoft.com';
430 $filters['Osirusoft Smart Host']['result'] = '127.0.0.5';
431 $filters['Osirusoft Smart Host']['comment'] =
432 _("FREE - Osirusoft Smart Hosts - List of hosts that are secure but relay for other mail servers that are not secure.");
433
434 $filters['Osirusoft SPAMware']['prefname'] = 'filters_spam_maps_osirusoft_ss';
435 $filters['Osirusoft SPAMware']['name'] = 'Osirusoft Spamware Developers List';
436 $filters['Osirusoft SPAMware']['link'] = 'http://relays.osirusoft.com/';
437 $filters['Osirusoft SPAMware']['dns'] = 'relays.osirusoft.com';
438 $filters['Osirusoft SPAMware']['result'] = '127.0.0.6';
439 $filters['Osirusoft SPAMware']['comment'] =
440 _("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.");
441
442 $filters['Osirusoft Unc. OptIn']['prefname'] = 'filters_spam_maps_osirusoft_sl';
443 $filters['Osirusoft Unc. OptIn']['name'] = 'Osirusoft Unconfirmed OptIn Server List';
444 $filters['Osirusoft Unc. OptIn']['link'] = 'http://relays.osirusoft.com/';
445 $filters['Osirusoft Unc. OptIn']['dns'] = 'relays.osirusoft.com';
446 $filters['Osirusoft Unc. OptIn']['result'] = '127.0.0.7';
447 $filters['Osirusoft Unc. OptIn']['comment'] =
448 _("FREE - Osirusoft Unconfirmed OptIn Servers - List of listservers that opt users in without confirmation.");
449
450 $filters['Osirusoft Insecure Formmail']['prefname'] = 'filters_spam_maps_osirusoft_fm';
451 $filters['Osirusoft Insecure Formmail']['name'] = 'Osirusoft Insecure formmail.cvi Script List';
452 $filters['Osirusoft Insecure Formmail']['link'] = 'http://relays.osirusoft.com/';
453 $filters['Osirusoft Insecure Formmail']['dns'] = 'relays.osirusoft.com';
454 $filters['Osirusoft Insecure Formmail']['result'] = '127.0.0.8';
455 $filters['Osirusoft Insecure Formmail']['comment'] =
456 _("FREE - Osirusoft Insecure formmail.cgi scripts - List of insecure formmail.cgi scripts. (planned).");
457
458 $filters['Osirusoft Open Proxy']['prefname'] = 'filters_spam_maps_osirusoft_op';
459 $filters['Osirusoft Open Proxy']['name'] = 'Osirusoft Open Proxy Server List';
460 $filters['Osirusoft Open Proxy']['link'] = 'http://relays.osirusoft.com/';
461 $filters['Osirusoft Open Proxy']['dns'] = 'relays.osirusoft.com';
462 $filters['Osirusoft Open Proxy']['result'] = '127.0.0.9';
463 $filters['Osirusoft Open Proxy']['comment'] =
464 _("FREE - Osirusoft Open Proxy Servers - List of Open Proxy Servers.");
465
466 $filters['ORDB']['prefname'] = 'filters_spam_ordb';
467 $filters['ORDB']['name'] = 'Open Relay Database List';
468 $filters['ORDB']['link'] = 'http://www.ordb.org/';
469 $filters['ORDB']['dns'] = 'relays.ordb.org';
470 $filters['ORDB']['result'] = '127.0.0.2';
471 $filters['ORDB']['comment'] =
472 _("FREE - ORDB was born when ORBS went off the air. It seems to have fewer false positives than ORBS did though.");
473
474 $filters['ORBZ Inputs']['prefname'] = 'filters_spam_orbz';
475 $filters['ORBZ Inputs']['name'] = 'ORBZ Inputs List';
476 $filters['ORBZ Inputs']['link'] = 'http://www.orbz.org/';
477 $filters['ORBZ Inputs']['dns'] = 'inputs.orbz.org';
478 $filters['ORBZ Inputs']['result'] = '127.0.0.2';
479 $filters['ORBZ Inputs']['comment'] =
480 _("FREE - Another ORBS replacement (just the INPUTS database used here).");
481
482 $filters['ORBZ Outputs']['prefname'] = 'filters_spam_orbz_outputs';
483 $filters['ORBZ Outputs']['name'] = 'ORBZ Outputs List';
484 $filters['ORBZ Outputs']['link'] = 'http://www.orbz.org/';
485 $filters['ORBZ Outputs']['dns'] = 'outputs.orbz.org';
486 $filters['ORBZ Outputs']['result'] = '127.0.0.2';
487 $filters['ORBZ Outputs']['comment'] =
488 _("FREE - Another ORBS replacement (just the OUTPUTS database used here).");
489
490 $filters['FiveTen Direct']['prefname'] = 'filters_spam_fiveten_src';
491 $filters['FiveTen Direct']['name'] = 'Five-Ten-sg.com Direct SPAM Sources';
492 $filters['FiveTen Direct']['link'] = 'http://www.five-ten-sg.com/blackhole.php';
493 $filters['FiveTen Direct']['dns'] = 'blackholes.five-ten-sg.com';
494 $filters['FiveTen Direct']['result'] = '127.0.0.2';
495 $filters['FiveTen Direct']['comment'] =
496 _("FREE - Five-Ten-sg.com - Direct SPAM sources.");
497
498 $filters['FiveTen DUL']['prefname'] = 'filters_spam_fiveten_dul';
499 $filters['FiveTen DUL']['name'] = 'Five-Ten-sg.com DUL Lists';
500 $filters['FiveTen DUL']['link'] = 'http://www.five-ten-sg.com/blackhole.php';
501 $filters['FiveTen DUL']['dns'] = 'blackholes.five-ten-sg.com';
502 $filters['FiveTen DUL']['result'] = '127.0.0.3';
503 $filters['FiveTen DUL']['comment'] =
504 _("FREE - Five-Ten-sg.com - Dial-up lists - includes some DSL IPs.");
505
506 $filters['FiveTen Unc. OptIn']['prefname'] = 'filters_spam_fiveten_oi';
507 $filters['FiveTen Unc. OptIn']['name'] = 'Five-Ten-sg.com Unconfirmed OptIn Lists';
508 $filters['FiveTen Unc. OptIn']['link'] = 'http://www.five-ten-sg.com/blackhole.php';
509 $filters['FiveTen Unc. OptIn']['dns'] = 'blackholes.five-ten-sg.com';
510 $filters['FiveTen Unc. OptIn']['result'] = '127.0.0.4';
511 $filters['FiveTen Unc. OptIn']['comment'] =
512 _("FREE - Five-Ten-sg.com - Bulk mailers that do not use confirmed opt-in.");
513
514 $filters['FiveTen Others']['prefname'] = 'filters_spam_fiveten_oth';
515 $filters['FiveTen Others']['name'] = 'Five-Ten-sg.com Other Misc. Servers';
516 $filters['FiveTen Others']['link'] = 'http://www.five-ten-sg.com/blackhole.php';
517 $filters['FiveTen Others']['dns'] = 'blackholes.five-ten-sg.com';
518 $filters['FiveTen Others']['result'] = '127.0.0.5';
519 $filters['FiveTen Others']['comment'] =
520 _("FREE - Five-Ten-sg.com - Other misc. servers.");
521
522 $filters['FiveTen Single Stage']['prefname'] = 'filters_spam_fiveten_ss';
523 $filters['FiveTen Single Stage']['name'] = 'Five-Ten-sg.com Single Stage Servers';
524 $filters['FiveTen Single Stage']['link'] = 'http://www.five-ten-sg.com/blackhole.php';
525 $filters['FiveTen Single Stage']['dns'] = 'blackholes.five-ten-sg.com';
526 $filters['FiveTen Single Stage']['result'] = '127.0.0.6';
527 $filters['FiveTen Single Stage']['comment'] =
528 _("FREE - Five-Ten-sg.com - Single Stage servers.");
529
530 $filters['FiveTen SPAM Support']['prefname'] = 'filters_spam_fiveten_supp';
531 $filters['FiveTen SPAM Support']['name'] = 'Five-Ten-sg.com SPAM Support Servers';
532 $filters['FiveTen SPAM Support']['link'] = 'http://www.five-ten-sg.com/blackhole.php';
533 $filters['FiveTen SPAM Support']['dns'] = 'blackholes.five-ten-sg.com';
534 $filters['FiveTen SPAM Support']['result'] = '127.0.0.7';
535 $filters['FiveTen SPAM Support']['comment'] =
536 _("FREE - Five-Ten-sg.com - SPAM Support servers.");
537
538 $filters['FiveTen Web forms']['prefname'] = 'filters_spam_fiveten_wf';
539 $filters['FiveTen Web forms']['name'] = 'Five-Ten-sg.com Web Form IPs';
540 $filters['FiveTen Web forms']['link'] = 'http://www.five-ten-sg.com/blackhole.php';
541 $filters['FiveTen Web forms']['dns'] = 'blackholes.five-ten-sg.com';
542 $filters['FiveTen Web forms']['result'] = '127.0.0.8';
543 $filters['FiveTen Web forms']['comment'] =
544 _("FREE - Five-Ten-sg.com - Web Form IPs.");
545
546 $filters['Dorkslayers']['prefname'] = 'filters_spam_dorks';
547 $filters['Dorkslayers']['name'] = 'Dorkslayers Lists';
548 $filters['Dorkslayers']['link'] = 'http://www.dorkslayers.com';
549 $filters['Dorkslayers']['dns'] = 'orbs.dorkslayers.com';
550 $filters['Dorkslayers']['result'] = '127.0.0.2';
551 $filters['Dorkslayers']['comment'] =
552 _("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.");
553
554 $filters['SPAMhaus']['prefname'] = 'filters_spam_spamhaus';
555 $filters['SPAMhaus']['name'] = 'SPAMhaus Lists';
556 $filters['SPAMhaus']['link'] = 'http://www.spamhaus.org';
557 $filters['SPAMhaus']['dns'] = 'sbl.spamhaus.org';
558 $filters['SPAMhaus']['result'] = '127.0.0.6';
559 $filters['SPAMhaus']['comment'] =
560 _("FREE - SPAMhaus - A list of well-known SPAM sources.");
561
562 $filters['SPAMcop']['prefname'] = 'filters_spam_spamcop';
563 $filters['SPAMcop']['name'] = 'SPAM Cop Lists';
564 $filters['SPAMcop']['link'] = 'http://spamcop.net/bl.shtml';
565 $filters['SPAMcop']['dns'] = 'bl.spamcop.net';
566 $filters['SPAMcop']['result'] = '127.0.0.2';
567 $filters['SPAMcop']['comment'] =
568 _("FREE, for now - SPAMCOP - An interesting solution that lists servers that have a very high spam to legit email ratio (85% or more).");
569
570 $filters['dev.null.dk']['prefname'] = 'filters_spam_devnull';
571 $filters['dev.null.dk']['name'] = 'dev.null.dk Lists';
572 $filters['dev.null.dk']['link'] = 'http://dev.null.dk/';
573 $filters['dev.null.dk']['dns'] = 'dev.null.dk';
574 $filters['dev.null.dk']['result'] = '127.0.0.2';
575 $filters['dev.null.dk']['comment'] =
576 _("FREE - dev.null.dk - I don't have any detailed info on this list.");
577
578 $filters['visi.com']['prefname'] = 'filters_spam_visi';
579 $filters['visi.com']['name'] = 'visi.com Relay Stop List';
580 $filters['visi.com']['link'] = 'http://relays.visi.com';
581 $filters['visi.com']['dns'] = 'relays.visi.com';
582 $filters['visi.com']['result'] = '127.0.0.2';
583 $filters['visi.com']['comment'] =
584 _("FREE - visi.com - Relay Stop List. Very conservative OpenRelay List.");
585
586 $filters['2mbit.com Open Relays']['prefname'] = 'filters_spam_2mb_or';
587 $filters['2mbit.com Open Relays']['name'] = '2mbit.com Open Relays List';
588 $filters['2mbit.com Open Relays']['link'] = 'http://www.2mbit.com/sbl.php';
589 $filters['2mbit.com Open Relays']['dns'] = 'blackholes.2mbit.com';
590 $filters['2mbit.com Open Relays']['result'] = '127.0.0.2';
591 $filters['2mbit.com Open Relays']['comment'] =
592 _("FREE - 2mbit.com Open Relays - Another list of Open Relays.");
593
594 $filters['2mbit.com SPAM Source']['prefname'] = 'filters_spam_2mb_ss';
595 $filters['2mbit.com SPAM Source']['name'] = '2mbit.com SPAM Source List';
596 $filters['2mbit.com SPAM Source']['link'] = 'http://www.2mbit.com/sbl.php';
597 $filters['2mbit.com SPAM Source']['dns'] = 'blackholes.2mbit.com';
598 $filters['2mbit.com SPAM Source']['result'] = '127.0.0.4';
599 $filters['2mbit.com SPAM Source']['comment'] =
600 _("FREE - 2mbit.com SPAM Source - List of Direct SPAM Sources.");
601
602 $filters['2mbit.com SPAM ISPs']['prefname'] = 'filters_spam_2mb_isp';
603 $filters['2mbit.com SPAM ISPs']['name'] = '2mbit.com SPAM-friendly ISP List';
604 $filters['2mbit.com SPAM ISPs']['link'] = 'http://www.2mbit.com/sbl.php';
605 $filters['2mbit.com SPAM ISPs']['dns'] = 'blackholes.2mbit.com';
606 $filters['2mbit.com SPAM ISPs']['result'] = '127.0.0.10';
607 $filters['2mbit.com SPAM ISPs']['comment'] =
608 _("FREE - 2mbit.com SPAM ISPs - List of SPAM-friendly ISPs.");
609
610 $filters['Leadmon DUL']['prefname'] = 'filters_spam_lm_dul';
611 $filters['Leadmon DUL']['name'] = 'Leadmon.net DUL List';
612 $filters['Leadmon DUL']['link'] = 'http://www.leadmon.net/spamguard/';
613 $filters['Leadmon DUL']['dns'] = 'spamguard.leadmon.net';
614 $filters['Leadmon DUL']['result'] = '127.0.0.2';
615 $filters['Leadmon DUL']['comment'] =
616 _("FREE - Leadmon DUL - Another list of Dial-up or otherwise dynamically assigned IPs.");
617
618 $filters['Leadmon SPAM Source']['prefname'] = 'filters_spam_lm_ss';
619 $filters['Leadmon SPAM Source']['name'] = 'Leadmon.net SPAM Source List';
620 $filters['Leadmon SPAM Source']['link'] = 'http://www.leadmon.net/spamguard/';
621 $filters['Leadmon SPAM Source']['dns'] = 'spamguard.leadmon.net';
622 $filters['Leadmon SPAM Source']['result'] = '127.0.0.3';
623 $filters['Leadmon SPAM Source']['comment'] =
624 _("FREE - Leadmon SPAM Source - List of IPs Leadmon.net has received SPAM directly from.");
625
626 $filters['Leadmon Bulk Mailers']['prefname'] = 'filters_spam_lm_bm';
627 $filters['Leadmon Bulk Mailers']['name'] = 'Leadmon.net Bulk Mailers List';
628 $filters['Leadmon Bulk Mailers']['link'] = 'http://www.leadmon.net/spamguard/';
629 $filters['Leadmon Bulk Mailers']['dns'] = 'spamguard.leadmon.net';
630 $filters['Leadmon Bulk Mailers']['result'] = '127.0.0.4';
631 $filters['Leadmon Bulk Mailers']['comment'] =
632 _("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.");
633
634 $filters['Leadmon Open Relays']['prefname'] = 'filters_spam_lm_or';
635 $filters['Leadmon Open Relays']['name'] = 'Leadmon.net Open Relays List';
636 $filters['Leadmon Open Relays']['link'] = 'http://www.leadmon.net/spamguard/';
637 $filters['Leadmon Open Relays']['dns'] = 'spamguard.leadmon.net';
638 $filters['Leadmon Open Relays']['result'] = '127.0.0.5';
639 $filters['Leadmon Open Relays']['comment'] =
640 _("FREE - Leadmon Open Relays - Single Stage Open Relays that are not listed on other active RBLs.");
641
642 $filters['Leadmon Multi-stage']['prefname'] = 'filters_spam_lm_ms';
643 $filters['Leadmon Multi-stage']['name'] = 'Leadmon.net Multi-Stage Relay List';
644 $filters['Leadmon Multi-stage']['link'] = 'http://www.leadmon.net/spamguard/';
645 $filters['Leadmon Multi-stage']['dns'] = 'spamguard.leadmon.net';
646 $filters['Leadmon Multi-stage']['result'] = '127.0.0.6';
647 $filters['Leadmon Multi-stage']['comment'] =
648 _("FREE - Leadmon Multi-stage - Multi-Stage Open Relays that are not listed on other active RBLs and that have sent SPAM to Leadmon.net.");
649
650 $filters['Leadmon SpamBlock']['prefname'] = 'filters_spam_lm_sb';
651 $filters['Leadmon SpamBlock']['name'] = 'Leadmon.net SpamBlock Sites List';
652 $filters['Leadmon SpamBlock']['link'] = 'http://www.leadmon.net/spamguard/';
653 $filters['Leadmon SpamBlock']['dns'] = 'spamguard.leadmon.net';
654 $filters['Leadmon SpamBlock']['result'] = '127.0.0.7';
655 $filters['Leadmon SpamBlock']['comment'] =
656 _("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.");
657
658 $filters['NJABL Open Relays']['prefname'] = 'filters_spam_njabl_or';
659 $filters['NJABL Open Relays']['name'] = 'NJABL Open Relay/Direct Spam Source List';
660 $filters['NJABL Open Relays']['link'] = 'http://www.njabl.org/';
661 $filters['NJABL Open Relays']['dns'] = 'dnsbl.njabl.org';
662 $filters['NJABL Open Relays']['result'] = '127.0.0.2';
663 $filters['NJABL Open Relays']['comment'] =
664 _("FREE, for now - Not Just Another Blacklist - Both Open Relays and Direct SPAM Sources.");
665
666 $filters['NJABL DUL']['prefname'] = 'filters_spam_njabl_dul';
667 $filters['NJABL DUL']['name'] = 'NJABL Dial-ups List';
668 $filters['NJABL DUL']['link'] = 'http://www.njabl.org/';
669 $filters['NJABL DUL']['dns'] = 'dnsbl.njabl.org';
670 $filters['NJABL DUL']['result'] = '127.0.0.3';
671 $filters['NJABL DUL']['comment'] =
672 _("FREE, for now - Not Just Another Blacklist - Dial-up IPs.");
673
674 foreach ($filters as $Key => $Value) {
675 $filters[$Key]['enabled'] = getPref($data_dir, $username,
676 $filters[$Key]['prefname']);
677 }
678
679 return $filters;
680 }
681
682 function remove_filter ($id) {
683 global $data_dir, $username;
684
685 while ($nextFilter = getPref($data_dir, $username, 'filter' .
686 ($id + 1))) {
687 setPref($data_dir, $username, 'filter' . $id, $nextFilter);
688 $id ++;
689 }
690
691 removePref($data_dir, $username, 'filter' . $id);
692 }
693
694 function filter_swap($id1, $id2) {
695 global $data_dir, $username;
696
697 $FirstFilter = getPref($data_dir, $username, 'filter' . $id1);
698 $SecondFilter = getPref($data_dir, $username, 'filter' . $id2);
699
700 if ($FirstFilter && $SecondFilter) {
701 setPref($data_dir, $username, 'filter' . $id2, $FirstFilter);
702 setPref($data_dir, $username, 'filter' . $id1, $SecondFilter);
703 }
704 }
705 ?>