* @copyright 2004-2007 Alexandros Vellis * @package plugins * @subpackage avelsieve */ /** * Rule type: #10; Description: generic SPAM-rule, with SPAM-score, * whitelist and RBLs defined in the configuration file. * * The rule that will be produced (in $out) will be something like: * *
 *    if allof( anyof(header :contains "X-Spam-Rule" "Open.Relay.Database" ,
 *                header :contains "X-Spam-Rule" "Spamhaus.Block.List" 
 *            ),
 *         header :value "gt" :comparator "i;ascii-numeric" "80" ) {
 *       
 *       fileinto "INBOX.Junk";
 *       discard;
 *   }
 * 
* * Or, if a Whitelist is specified: * *
 *   if allof( anyof(header :contains "X-Spam-Rule" "Open.Relay.Database" ,
 *               header :contains "X-Spam-Rule" "Spamhaus.Block.List" 
 *           ),
 *         header :value "gt" :comparator "i;ascii-numeric" "80" ,
 *         not anyof(header :contains "From" "Important Person",
 *               header :contains "From" "Foo Person"
 *         )
 *       ) {
 *       
 *       fileinto "INBOX.Junk";
 *       discard;
 *   }
 * 
*/ function avelsieve_buildrule_10($rule) { global $avelsieve_rules_settings; $spamrule_score_default = $avelsieve_rules_settings[10]['spamrule_score_default']; $spamrule_score_header = $avelsieve_rules_settings[10]['spamrule_score_header']; $spamrule_tests = $avelsieve_rules_settings[10]['spamrule_tests']; $spamrule_tests_header = $avelsieve_rules_settings[10]['spamrule_tests_header']; $spamrule_action_default = $avelsieve_rules_settings[10]['spamrule_action_default']; $out = ''; $text = ''; $terse = ''; $spamrule_advanced = false; if(isset($rule['advanced'])) { $spamrule_advanced = true; } if(isset($rule['score'])) { $sc = $rule['score']; } else { $sc = $spamrule_score_default; } if(isset($rule['tests'])) { $te = $rule['tests']; } else { $te = array_keys($spamrule_tests); } if(isset($rule['action'])) { $ac = $rule['action']; } else { $ac = $spamrule_action_default; } $out .= 'if allof( '; $text .= _("All messages considered as SPAM (unsolicited commercial messages)"); $terse .= _("SPAM"); if(sizeof($te) > 1) { $out .= ' anyof( '; for($i=0; $i 0) { /* Insert here header-match like rules, ORed of course. */ $text .= ' (' . _("unless") . ' '; $terse .= '
' . _("Whitelist:") . '' . sprintf( _("Score > %s") , $sc); } $text .= ', ' . _("will be") . ' '; $terse .= ''; if($ac == 'junk') { $out .= 'fileinto "INBOX.Junk";'; $text .= _("stored in the Junk Folder."); $terse .= _("Junk"); } elseif($ac == 'trash') { $text .= _("stored in the Trash Folder."); global $data_dir, $username; $trash_folder = getPref($data_dir, $username, 'trash_folder'); /* Fallback in case it does not exist. Thanks to Eduardo * Mayoral. If not even Trash does not exist, it will end up in * INBOX... */ if($trash_folder == '' || $trash_folder == 'none') { $trash_folder = "Trash"; } $out .= 'fileinto "'.$trash_folder.'";'; $terse .= _("Trash"); } elseif($ac == 'discard') { $out .= 'discard;'; $text .= _("discarded."); $terse .= _("Discard"); } return(array($out,$text,$terse)); }