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