more modules
authorPierre Habouzit <madcoder@debian.org>
Wed, 29 Oct 2003 13:25:28 +0000 (13:25 +0000)
committerPierre Habouzit <madcoder@debian.org>
Wed, 29 Oct 2003 13:25:28 +0000 (13:25 +0000)
philter/philter/include/filter.inc.php
philter/philter/include/philter.inc.php
philter/philter/include/plugin_autoreply.inc.php
philter/philter/include/plugin_bogofilter.inc.php
philter/philter/include/rule.inc.php
philter/philter/install.d/config.inc.php

index 34c9297..ab74a41 100644 (file)
@@ -51,9 +51,6 @@ class Filter {
         global $mail_pool,$philter;
         $res = "# generated by philter\n"
             .  "# vim:set syntax=procmail:\n"
-            .  "\n"
-            .  ":0 f\n"
-            .  "|formail -I'X-Philter-Or'\n"
             .  "\n";
 
         foreach($this->rules as $id=>$rule)
index 463f772..4a71714 100644 (file)
@@ -28,7 +28,7 @@ class Philter {
     function Philter() {
         $this->config = array(
             'db'      => array('host', 'name', 'user', 'pwd', 'link'),
-            'path'    => array('procmail', 'spool'),
+            'path'    => array('spool'),
             'match_plugins' => array(),
             'action_plugins' => array(),
             'global_plugins' => array(),
@@ -93,6 +93,9 @@ class Philter {
         fwrite($f, $procmail, strlen($procmail));
         fclose($f);
         rename($file.".tmp", $file);
+        echo "<pre>\n";
+        echo $procmail;
+        echo "</pre>\n";
         return true;
     }
 
index e068ce1..25a9788 100644 (file)
@@ -33,10 +33,11 @@ EOF;
         $uid = get_user_id();
         $text = explode("\n",$_data[1]);
         $res = "    :0 hc\n"
-            .  "    *X-Philter-Autoreply: $uid"
-            .  "    | ( formail -rA'X-Philter-Autoreply: $uid; \ \n";
+            .  "    * !^FROM_DAEMON\n"
+            .  "    * !^X-Philter-Autoreply: $uid\n"
+            .  "    | ( formail -rI'Precedence: junk' -A'X-Philter-Autoreply: $uid; \ \n";
         foreach($text as $line)
-            $res .= "        echo ".escapeshellarg($line)."; \ \n";
+            $res .= "        echo ".escapeshellarg(chop($line))."; \ \n";
         $res.= "      ) | $"."SENDMAIL -oi -t\n";
         return $res;
     }
index e50488d..a8b6fa8 100644 (file)
@@ -16,8 +16,21 @@ class BogoPlugin extends MatchPlugin {
     function is_global() { return true; }
 
     function to_string($_data) {
-        $res = "\n";
-        return $res;
+        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]==2)
+            return ":0 HB:\n"
+                .  "* ? $bogo\n"
+                .  "/dev/null\n";
+            
+        return "";
     }
 
     function to_form($_data) {
index 218e59c..e18d470 100644 (file)
@@ -89,34 +89,30 @@ class Rule {
     function to_string() {
         global $philter;
         
+        $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";
 
         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 f\n" : ":0 fE\n");
+                $res .= (empty($i) ? ":0\n" : ":0 E\n");
                 $res .= $philter->config['match_plugins'][$match[0]]->to_string($match);
-                $res .= "| formail -I'X-Philter-Or: yes'\n";
+                $res .= $bloc;
                 $i++;
             }
-
-            $res.= ":0 f\n"
-                .  "* ^X-Philter-Or: yes\n"
-                .  "| formail -I'X-Philter-Or'\n"
-                .  ($this->block ? ":0 A\n" : ":0 Ac\n");
         }
         
-        $res.= "{\n";
-        foreach($this->actions as $action)
-            $res .= $philter->config['action_plugins'][$action[0]]->to_string($action);
-        $res.= "    :0\n"
-            .  "    /dev/null\n"
-            .  "}\n\n";
-
-        return $res;
+        return $res."\n";
     }
 
     function sql_clean($_uid, $_rid) {
index 4ffc08a..81d08b0 100644 (file)
@@ -7,7 +7,6 @@
 * Copyright: See COPYING files that comes with this distribution
 ********************************************************************************/
 
-
 $philter = new Philter();
 
 /********** LOCALE **********/
@@ -25,8 +24,8 @@ $philter->pconnect();
 
 /********** PATHS **********/
     
-$philter->config['path']['procmail'] = "/usr/bin/procmail";
-$philter->config['path']['spool']    = "/var/spool/philter";
+$philter->config['path']['bogofilter'] = "/usr/bin/bogfilter -d /var/mail/.bogofilter";
+$philter->config['path']['spool']      = "/var/spool/philter";
 
 /********** PLUGINS **********/