more modules
[old-projects.git] / philter / philter / include / rule.inc.php
index 5f1736d..e18d470 100644 (file)
@@ -89,15 +89,30 @@ class Rule {
     function to_string() {
         global $philter;
         
-        $res = ($this->block ? ":0\n" : ":0 c\n");
-        foreach($this->matches as $match)
-            $res .= $philter->config['match_plugins'][$match[0]]->to_string($match);
-        $res.= "{\n";
+        $bloc = "{\n";
         foreach($this->actions as $action)
-            $res .= $philter->config['actioh_plugins'][$action[0]]->to_string($action);
-        $res.= "}\n\n";
+            $bloc .= $philter->config['action_plugins'][$action[0]]->to_string($action);
+        $bloc.= "    :0\n"
+            .  "    /dev/null\n"
+            .  "}\n";
 
-        return $res;
+        $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\n" : ":0 E\n");
+                $res .= $philter->config['match_plugins'][$match[0]]->to_string($match);
+                $res .= $bloc;
+                $i++;
+            }
+        }
+        
+        return $res."\n";
     }
 
     function sql_clean($_uid, $_rid) {