X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=plugins%2Ffilters%2Ffilters.php;h=5e150b0ef5f74585010610dff9507d5680bc8bf9;hb=f9d816d49d858c3f5a89ad9409239848a402239b;hp=995adf2e1ff4a43c6909e1cbf3c19f58d1a69e70;hpb=4b5049de2fa934c45599d6e4c74bf2bbee10d34d;p=squirrelmail.git diff --git a/plugins/filters/filters.php b/plugins/filters/filters.php index 995adf2e..5e150b0e 100644 --- a/plugins/filters/filters.php +++ b/plugins/filters/filters.php @@ -3,7 +3,7 @@ /** * Message and Spam Filter Plugin - Filtering Functions * - * @copyright © 1999-2007 The SquirrelMail Project Team + * @copyright © 1999-2009 The SquirrelMail Project Team * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version $Id$ * @package plugins @@ -13,8 +13,7 @@ /** * do not allow to call this file directly */ -if ((isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) || - (isset($HTTP_SERVER_SERVER['SCRIPT_FILENAME']) && $HTTP_SERVER_SERVER['SCRIPT_FILENAME'] == __FILE__) ) { +if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) { header("Location: ../../src/login.php"); die(); } @@ -26,7 +25,7 @@ global $UseSeparateImapConnection, $SpamFilters_CacheTTL; /** - * load required functions. Plugin depends on IMAP functions and they are not + * load required functions. Plugin depends on IMAP functions and they are not * loaded in src/webmail.php */ include_once (SM_PATH . 'functions/imap.php'); @@ -211,8 +210,8 @@ function start_filters($hook_args) { $spamfilters = load_spam_filters(); $AllowSpamFilters = false; - foreach($spamfilters as $filterskey=>$value) { - if ($value['enabled'] == 'yes') { + foreach($spamfilters as $value) { + if ($value['enabled'] == SMPREF_ON) { $AllowSpamFilters = true; break; } @@ -382,7 +381,7 @@ function filter_search_and_delete($imap_stream, $where, $what, $where_to, $user_ $ids = array(); for ($i = 0, $iCnt = count($read); $i < $iCnt; ++$i) { if (preg_match("/^\* SEARCH (.+)$/", $read[$i], $regs)) { - $ids += preg_split("/ /", trim($regs[1])); + $ids += explode(' ', trim($regs[1])); } } if ($response == 'OK' && count($ids)) { @@ -430,7 +429,7 @@ function spam_filters($imap_stream) { $run = false; - foreach ($filters as $Key => $Value) { + foreach ($filters as $Value) { if ($Value['enabled']) { $run = true; break; @@ -451,7 +450,7 @@ function spam_filters($imap_stream) { if (isset($read[0])) { for ($i = 0, $iCnt = count($read); $i < $iCnt; ++$i) { if (preg_match("/^\* SEARCH (.+)$/", $read[$i], $regs)) { - $search_array = preg_split("/ /", trim($regs[1])); + $search_array = explode(' ', trim($regs[1])); break; } } @@ -548,8 +547,12 @@ function filters_spam_check_site($a, $b, $c, $d, &$filters) { foreach ($filters as $key => $value) { if ($filters[$key]['enabled']) { if ($filters[$key]['dns']) { + /** + * RFC allows . on end of hostname to force domain lookup + * to not use search domain from resolv.conf + */ $filter_revip = $d . '.' . $c . '.' . $b . '.' . $a . '.' . - $filters[$key]['dns']; + $filters[$key]['dns'] . '.'; if(!isset($SpamFilters_DNScache[$filter_revip]['L'])) $SpamFilters_DNScache[$filter_revip]['L'] = ''; @@ -563,8 +566,12 @@ function filters_spam_check_site($a, $b, $c, $d, &$filters) { $SpamFilters_DNScache[$filter_revip]['T'] = time() + $SpamFilters_CacheTTL; } - if ($SpamFilters_DNScache[$filter_revip]['L'] == - $filters[$key]['result']) { + + /** + * gethostbyname returns ip if resolved, or returns original + * host query if no resolution + */ + if ($SpamFilters_DNScache[$filter_revip]['L'] != $filter_revip) { return 1; } } @@ -585,7 +592,7 @@ function load_filters() { for ($i = 0; $fltr = getPref($data_dir, $username, 'filter' . $i); $i++) { $ary = explode(',', $fltr); $filters[$i]['where'] = $ary[0]; - $filters[$i]['what'] = $ary[1]; + $filters[$i]['what'] = str_replace('###COMMA###', ',', $ary[1]); $filters[$i]['folder'] = $ary[2]; } return $filters; @@ -717,7 +724,7 @@ function load_spam_filters() { $filters['SPAMhaus']['name'] = 'SPAMhaus Lists'; $filters['SPAMhaus']['link'] = 'http://www.spamhaus.org'; $filters['SPAMhaus']['dns'] = 'sbl.spamhaus.org'; - $filters['SPAMhaus']['result'] = '127.0.0.6'; + $filters['SPAMhaus']['result'] = '127.0.0.2'; $filters['SPAMhaus']['comment'] = _("FREE - SPAMhaus - A list of well-known SPAM sources."); @@ -833,32 +840,8 @@ function load_spam_filters() { $filters['NJABL DUL']['comment'] = _("FREE, for now - Not Just Another Blacklist - Dial-up IPs."); - $filters['Conf DSBL.ORG Relay']['prefname'] = 'filters_spam_dsbl_conf_ss'; - $filters['Conf DSBL.ORG Relay']['name'] = 'DSBL.org Confirmed Relay List'; - $filters['Conf DSBL.ORG Relay']['link'] = 'http://www.dsbl.org/'; - $filters['Conf DSBL.ORG Relay']['dns'] = 'list.dsbl.org'; - $filters['Conf DSBL.ORG Relay']['result'] = '127.0.0.2'; - $filters['Conf DSBL.ORG Relay']['comment'] = - _("FREE - Distributed Sender Boycott List - Confirmed Relays"); - - $filters['Conf DSBL.ORG Multi-Stage']['prefname'] = 'filters_spam_dsbl_conf_ms'; - $filters['Conf DSBL.ORG Multi-Stage']['name'] = 'DSBL.org Confirmed Multi-Stage Relay List'; - $filters['Conf DSBL.ORG Multi-Stage']['link'] = 'http://www.dsbl.org/'; - $filters['Conf DSBL.ORG Multi-Stage']['dns'] = 'multihop.dsbl.org'; - $filters['Conf DSBL.ORG Multi-Stage']['result'] = '127.0.0.2'; - $filters['Conf DSBL.ORG Multi-Stage']['comment'] = - _("FREE - Distributed Sender Boycott List - Confirmed Multi-stage Relays"); - - $filters['UN-Conf DSBL.ORG']['prefname'] = 'filters_spam_dsbl_unc'; - $filters['UN-Conf DSBL.ORG']['name'] = 'DSBL.org UN-Confirmed Relay List'; - $filters['UN-Conf DSBL.ORG']['link'] = 'http://www.dsbl.org/'; - $filters['UN-Conf DSBL.ORG']['dns'] = 'unconfirmed.dsbl.org'; - $filters['UN-Conf DSBL.ORG']['result'] = '127.0.0.2'; - $filters['UN-Conf DSBL.ORG']['comment'] = - _("FREE - Distributed Sender Boycott List - UN-Confirmed Relays"); - foreach ($filters as $Key => $Value) { - $filters[$Key]['enabled'] = getPref($data_dir, $username, $filters[$Key]['prefname']); + $filters[$Key]['enabled'] = (bool)getPref($data_dir, $username, $filters[$Key]['prefname']); } return $filters;