* @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