trying maildrop
authorPierre Habouzit <madcoder@debian.org>
Wed, 5 Nov 2003 01:44:51 +0000 (01:44 +0000)
committerPierre Habouzit <madcoder@debian.org>
Wed, 5 Nov 2003 01:44:51 +0000 (01:44 +0000)
philter/philter/include/filter.inc.php
philter/philter/include/plugin_autoreply.inc.php
philter/philter/include/plugin_bogofilter.inc.php
philter/philter/include/plugin_custheader.inc.php
philter/philter/include/plugin_forward.inc.php
philter/philter/include/plugin_header.inc.php
philter/philter/include/rule.inc.php

index ab74a41..1258fd0 100644 (file)
@@ -50,7 +50,6 @@ class Filter {
     function to_string() {
         global $mail_pool,$philter;
         $res = "# generated by philter\n"
-            .  "# vim:set syntax=procmail:\n"
             .  "\n";
 
         foreach($this->rules as $id=>$rule)
@@ -60,13 +59,12 @@ class Filter {
                 foreach($rule->matches as $id=>$match)
                     $res .= $philter->config['global_plugins'][$match[0]]->to_string($match);
 
-        $res .= ":0\n"
-             .  "!";
+        $res .= "to \"!";
         foreach($mail_pool->emails as $mail)
             if($mail->is_active())
                 $res .= ' '.$mail->email;
         
-        return $res."\n";
+        return $res."\"\n";
     }
 
     function delete_rule($_rid) {
index 25a9788..95de752 100644 (file)
@@ -32,14 +32,15 @@ EOF;
     function to_string($_data) {
         $uid = get_user_id();
         $text = explode("\n",$_data[1]);
-        $res = "    :0 hc\n"
-            .  "    * !^FROM_DAEMON\n"
-            .  "    * !^X-Philter-Autoreply: $uid\n"
-            .  "    | ( formail -rI'Precedence: junk' -A'X-Philter-Autoreply: $uid; \ \n";
+
+        $res = "    if(! /^X-Philter-Autoreply: $uid$/)\n" # TODO : et ne vient pas da démon
+            .  "    {\n"
+            .  "        to \"| reformail -rt -A'X-Philter-Autoreply: $uid' \\\n"
+            .  "            | ( cat - ; echo '' ; \\\n";
         foreach($text as $line)
-            $res .= "        echo ".escapeshellarg(chop($line))."; \ \n";
-        $res.= "      ) | $"."SENDMAIL -oi -t\n";
-        return $res;
+            $res .= "                echo ".escapeshellarg(chop($line))."; \\\n";
+        $res.= "            ) | $"."SENDMAIL -oi -t\"\n";
+        return $res."    }\n";
     }
 }
 
index a8b6fa8..6abe378 100644 (file)
@@ -18,18 +18,15 @@ class BogoPlugin extends MatchPlugin {
     function to_string($_data) {
         global $philter;
         $bogo = $philter->config['path']['bogofilter'];
-        if($_data[1]==1)
-            return ":0 fw\n"
-                .  "| $bogo -u -e -p\n"
-                .  ":0 e\n"
-                .  "{ EXITCODE=75 HOST }\n"
-                .  "\n";
         
+        if($_data[1]==1)
+            return "xfilter \"$bogo -u -e -p\"\n\n";
+
         if($_data[1]==2)
-            return ":0 HB:\n"
-                .  "* ? $bogo\n"
-                .  "/dev/null\n";
-            
+            return "xfilter \"$bogo -u -e -p\"\n"
+                .  "if (/^X-Bogosity: Yes, tests=bogofilter/)\n"
+                .  "    exit\n\n";
+        
         return "";
     }
 
index 014be81..7f97e30 100644 (file)
@@ -48,10 +48,10 @@ class CustHdrPlugin extends MatchPlugin {
     function to_string($_data) {
         $res = trim($_data[1]).':';
         switch($_data[2]) {
-            case 0: $res = "* ^$res.*{$_data[3]}\n";   break;
-            case 1: $res = "* !$res.*{$_data[3]}\n";   break;
-            case 2: $res = "* $res {$_data[3]}$\n";    break;
-            case 3: $res = "* !$res {$_data[3]}$\n";   break;
+            case 0: $res = "(/^$res.*{$_data[3]}/:h)";   break;
+            case 1: $res = "!(/$res.*{$_data[3]}/:h)";   break;
+            case 2: $res = "(/$res {$_data[3]}$/:h)";    break;
+            case 3: $res = "!(/$res {$_data[3]}$/:h)";   break;
         }
         return $res;
     }
index fc3ac95..9bb4f68 100644 (file)
@@ -36,8 +36,7 @@ EOF;
 
     function to_string($_data) {
         global $mail_pool;
-        return "    :0 c\n"
-            .  "    ! ".$mail_pool->emails[$_data[1]]->email."\n\n";
+        return "    cc ".$mail_pool->emails[$_data[1]]->email."\n";
     }
 }
 
index 5112b9e..2bba0f0 100644 (file)
@@ -61,7 +61,9 @@ EOF;
     
     function to_string($_data) {
         switch($_data[1]) {
-            case 0: $res = '^TO';                 break;
+            case 0:
+                $res = '^(^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope|Apparently(-Resent)?)-To):(.*[^-a-zA-Z0-9_.])?)';
+                break;
             case 1: $res = '^Subject:';           break;
             case 2: $res = '^From:';              break;
             case 3: $res = '^To:';                break;
@@ -72,10 +74,10 @@ EOF;
             case 8: $res = '^X-Mailing-List:';    break;
         }
         switch($_data[2]) {
-            case 0: $res = "* $res.*{$_data[3]}\n";    break;
-            case 1: $res = "* !$res.*{$_data[3]}\n";   break;
-            case 2: $res = "* $res {$_data[3]}$\n";    break;
-            case 3: $res = "* !$res {$_data[3]}$\n";   break;
+            case 0: $res = "(/$res.*{$_data[3]}/:h)";    break;
+            case 1: $res = "!(/$res.*{$_data[3]}/:h)";   break;
+            case 2: $res = "(/$res {$_data[3]}$/:h)";    break;
+            case 3: $res = "!(/$res {$_data[3]}$/:h)";   break;
         }
         return $res;
     }
index e18d470..2800da2 100644 (file)
@@ -88,31 +88,23 @@ class Rule {
 
     function to_string() {
         global $philter;
+        $tmp = array();
+
+        foreach($this->matches as $match)
+            $tmp[] = $philter->config['match_plugins'][$match[0]]->to_string($match);
+        
+        $connector = ($this->all ? ' && ' : ' || ');
+        $res = "if( ".implode($connector, $tmp)." )\n"
+            .  "{\n";
         
-        $bloc = "{\n";
         foreach($this->actions as $action)
-            $bloc .= $philter->config['action_plugins'][$action[0]]->to_string($action);
-        $bloc.= "    :0\n"
-            .  "    /dev/null\n"
-            .  "}\n";
-
-        $res = $this->block  ? ":0\n" : ":0 c\n";
+            $res .= $philter->config['action_plugins'][$action[0]]->to_string($action);
 
-        if($this->all) {
-            foreach($this->matches as $match)
-                $res .= $philter->config['match_plugins'][$match[0]]->to_string($match);
-            $res .= $bloc;
-        } else {
-            $i = 0; $res = '';
-            foreach($this->matches as $match) {
-                $res .= (empty($i) ? ":0\n" : ":0 E\n");
-                $res .= $philter->config['match_plugins'][$match[0]]->to_string($match);
-                $res .= $bloc;
-                $i++;
-            }
-        }
+        if($this->block)
+            $res .= "    to /dev/null\n"
+                 .  "    exit\n";
         
-        return $res."\n";
+        return $res."}\n\n";
     }
 
     function sql_clean($_uid, $_rid) {