<?php
/*
- * Message and Spam Filter Plugin
- * By Luke Ehresman <luke@squirrelmail.org>
- * Tyler Akins
- * Brent Bice
- * (c) 2000 (GNU GPL - see ../../COPYING)
+ * Message and Spam Filter Plugin
+ * Copyright (c) 1999-2001 The Squirrelmail Development Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
*
* This plugin filters your inbox into different folders based upon given
* criteria. It is most useful for people who are subscibed to mailing lists
*
* Also view plugins/README.plugins for more information.
*
+ * $Id$
+ *
*/
function start_filters() {
if ($Value['enabled'])
$run ++;
}
-
+
// short-circuit
if ($run == 0) {
return;
}
-
+
sqimap_mailbox_select($imap_stream, 'INBOX');
-
- // Ask for a big list of all "Received" headers in the inbox with
+
+ // Ask for a big list of all "Received" headers in the inbox with
// flags for each message. Kinda big.
fputs($imap_stream, 'A3999 FETCH 1:* (FLAGS BODY.PEEK[HEADER.FIELDS ' .
"(RECEIVED)])\r\n");
-
+
$read = sqimap_read_data ($imap_stream, 'A3999', true, $response, $message);
-
+
if ($response != 'OK')
return;
$i ++;
$IsSpam = 0;
$Scan = 1;
-
- // Check for normal IMAP servers
+
+ // Check for normal IMAP servers
if ($filters_spam_scan == 'new') {
if (is_int(strpos($Chunks[4], '\Seen'))) {
$Scan = 0;
}
}
-
- // Look through all of the Received headers for IP addresses
- // Stop when I get ")" on a line
- // Stop if I get "*" on a line (don't advance)
+
+ // Look through all of the Received headers for IP addresses
+ // Stop when I get ")" on a line
+ // Stop if I get "*" on a line (don't advance)
// and above all, stop if $i is bigger than the total # of lines
while (($i < count($read)) &&
($read[$i][0] != ')' && $read[$i][0] != '*' &&
- $read[$i][0] != "\n") && (! $IsSpam))
- {
+ $read[$i][0] != "\n") && (! $IsSpam))
+ {
// Check to see if this line is the right "Received from" line
// to check
if (is_int(strpos($read[$i], $SpamFilters_YourHop))) {
- // short-circuit and skip work if we don't scan this one
+ // short-circuit and skip work if we don't scan this one
if ($Scan) {
$read[$i] = ereg_replace('[^0-9\.]', ' ', $read[$i]);
$elements = explode(' ', $read[$i]);
foreach ($elements as $value) {
- if ($value != '' &&
+ if ($value != '' &&
ereg('[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}',
- $value, $regs)) {
- $Chunks = explode('.', $value);
- if ("$SpamFilters_DNScache[$value]" == "") {
+ $value, $regs)) {
+ $Chunks = explode('.', $value);
+ if ("$SpamFilters_DNScache[$value]" == "") {
$SpamFilters_DNScache[$value] =
filters_spam_check_site($Chunks[0], $Chunks[1],
- $Chunks[2], $Chunks[3], $filters);
- }
- if ($SpamFilters_DNScache[$value]) {
- $IsSpam ++;
+ $Chunks[2], $Chunks[3], $filters);
+ }
+ if ($SpamFilters_DNScache[$value]) {
+ $IsSpam ++;
break; // no sense in checking more IPs
- }
+ }
}
- }
+ }
}
}
$i ++;
}
-
- // Lookie! It's spam! Yum!
+
+ // Lookie! It's spam! Yum!
if ($IsSpam) {
if (sqimap_mailbox_exists ($imap_stream, $filters_spam_folder)) {
- sqimap_messages_copy ($imap_stream, $MsgNum, $MsgNum,
- $filters_spam_folder);
- sqimap_messages_flag ($imap_stream, $MsgNum, $MsgNum,
- 'Deleted');
+ sqimap_messages_copy ($imap_stream, $MsgNum, $MsgNum,
+ $filters_spam_folder);
+ sqimap_messages_flag ($imap_stream, $MsgNum, $MsgNum,
+ 'Deleted');
}
}
}
-
+
sqimap_mailbox_expunge($imap_stream, 'INBOX');
}
$filters['MAPS DUL']['link'] = 'http://www.mail-abuse.org/dul/';
$filters['MAPS DUL']['dns'] = 'dialups.mail-abuse.org';
$filters['MAPS DUL']['comment'] =
-_("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.");
+_("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.");
$filters['MAPS RBLplus']['prefname'] = 'filters_spam_maps_rblplus';
$filters['MAPS RBLplus']['name'] = 'MAPS RBL+ List';
$filters['Osirusoft']['link'] = 'http://relays.osirusoft.com/';
$filters['Osirusoft']['dns'] = 'relays.osirusoft.com';
$filters['Osirusoft']['comment'] =
-_("FREE - Osirusoft - Very thorough, but also rejects replies from many ISP\'s abuse@domain.name email messages for some reason.");
+_("FREE - Osirusoft - Very thorough, but also rejects replies from many ISP's abuse@domain.name email messages for some reason.");
$filters['ORDB']['prefname'] = 'filters_spam_ordb';
$filters['ORDB']['name'] = 'Open Relay Database List';
$filters['Five-Ten']['link'] = 'http://www.five-ten-sg.com/blackhole.php';
$filters['Five-Ten']['dns'] = 'blackholes.five-ten-sg.com';
$filters['Five-Ten']['comment'] =
-_("FREE - Five-Ten-sg.com has SPAM source, OpenRelay, and and Dialup IPs.");
+_("FREE - Five-Ten-sg.com has SPAM source, OpenRelay, and Dialup IPs.");
$filters['Dorkslayers']['prefname'] = 'filters_spam_dorks';
$filters['Dorkslayers']['name'] = 'Dorkslayers Lists';
$filters['ORBL']['link'] = 'http://www.orbl.org';
$filters['ORBL']['dns'] = 'or.orbl.org';
$filters['ORBL']['comment'] =
-_("'FREE - ORBL is another ORBS spinoff formed after ORBS shut down. May be SLOOOOOOW!");
+_("FREE - ORBL is another ORBS spinoff formed after ORBS shut down. May be SLOOOOOOW!");
$filters['ORBZ-UK']['prefname'] = 'filters_spam_orbzuk';
$filters['ORBZ-UK']['name'] = 'ORBZ-UK Lists';