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