From 89e4554cb0bbf4b515f1e9f4ec6d48d0a95706c5 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Sun, 26 Sep 2010 09:36:55 -0400
Subject: [PATCH] Merged revisions 1917-2036 from trunk.
---
server/plugins-available/maildrop_plugin.inc.php | 44 +++++++++++++++++++++++++-------------------
1 files changed, 25 insertions(+), 19 deletions(-)
diff --git a/server/plugins-available/maildrop_plugin.inc.php b/server/plugins-available/maildrop_plugin.inc.php
index 6296653..3b1360f 100644
--- a/server/plugins-available/maildrop_plugin.inc.php
+++ b/server/plugins-available/maildrop_plugin.inc.php
@@ -82,8 +82,8 @@
if(!is_dir($this->mailfilter_config_dir)) {
$app->log("Mailfilter config directory '".$this->mailfilter_config_dir."' does not exist. Creating it now.",LOGLEVEL_WARN);
mkdir($this->mailfilter_config_dir);
- exec("chown vmail ".$this->mailfilter_config_dir);
- exec("chmod 770 ".$this->mailfilter_config_dir);
+ chown($this->mailfilter_config_dir, 'vmail');
+ chmod($this->mailfilter_config_dir, 0770);
}
if(isset($data["new"]["email"])) {
@@ -95,13 +95,13 @@
// make sure that the config directories exist
if(!is_dir($this->mailfilter_config_dir.'/'.$email_parts[1])) {
mkdir($this->mailfilter_config_dir.'/'.$email_parts[1]);
- exec("chown vmail ".$this->mailfilter_config_dir.'/'.$email_parts[1]);
- exec("chmod 770 ".$this->mailfilter_config_dir.'/'.$email_parts[1]);
+ chown($this->mailfilter_config_dir.'/'.$email_parts[1], 'vmail');
+ chmod($this->mailfilter_config_dir.'/'.$email_parts[1], 0770);
}
if(!is_dir($this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0])) {
mkdir($this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0]);
- exec("chown vmail ".$this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0]);
- exec("chmod 770 ".$this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0]);
+ chown($this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0], 'vmail');
+ chmod($this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0], 0770);
}
// Check if something has been changed regarding the autoresponders
@@ -151,27 +151,30 @@
$config_file_path = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.autoresponder';
file_put_contents($config_file_path,$tpl);
$app->log("Writing Autoresponder mailfilter file: $config_file_path",LOGLEVEL_DEBUG);
- exec("chmod 770 $config_file_path");
- exec("chown vmail $config_file_path");
+ chmod($config_file_path, 0770);
+ chown($config_file_path, 'vmail');
unset($tpl);
unset($config_file_path);
// Write the autoresponder message file
$config_file_path = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.vacation.msg';
file_put_contents($config_file_path,$data["new"]["autoresponder_text"]);
- exec("chmod 770 $config_file_path");
- exec("chown vmail $config_file_path");
+ chmod($config_file_path, 0770);
+ chown($config_file_path, 'vmail');
$app->log("Writing Autoresponder message file: $config_file_path",LOGLEVEL_DEBUG);
}
}
- // Write the custom mailfilter script, if mailfilter recipe has changed
- if($data["old"]["custom_mailfilter"] != $data["new"]["custom_mailfilter"]
- or $data["old"]["move_junk"] != $data["new"]["move_junk"]
- or $data["old"]["cc"] != $data["new"]["cc"]) {
+ // Write the custom mailfilter script, if mailfilter recipe has changed
+ if($data["old"]["custom_mailfilter"] != $data["new"]["custom_mailfilter"]
+ or $data["old"]["move_junk"] != $data["new"]["move_junk"]
+ or $data["old"]["cc"] != $data["new"]["cc"]) {
$app->log("Mailfilter config has been changed",LOGLEVEL_DEBUG);
- if(trim($data["new"]["custom_mailfilter"]) != '' or $data["new"]["move_junk"] != 'n') {
+ if(trim($data["new"]["custom_mailfilter"]) != ''
+ or $data["new"]["move_junk"] != 'n'
+ or $data["new"]["cc"] != '') {
+
// Delete the old filter recipe
$email_parts = explode("@",$data["old"]["email"]);
$file = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.mailfilter';
@@ -189,6 +192,7 @@
if($data["new"]["cc"] != '') {
$mailfilter_content .= "cc \"!".$data["new"]["cc"]."\"\n";
+ $app->log("Added CC address ".$data["new"]["cc"].' to mailfilter file.',LOGLEVEL_DEBUG);
}
if($data["new"]["move_junk"] == 'y') {
@@ -196,10 +200,13 @@
}
$mailfilter_content .= $data["new"]["custom_mailfilter"];
+ // Replace windows linebreaks in mailfilter file
+ $mailfilter_content = str_replace("\r\n","\n",$mailfilter_content);
+
file_put_contents($config_file_path,$mailfilter_content);
$app->log("Writing new custom Mailfiter".$config_file_path,LOGLEVEL_DEBUG);
- exec("chmod 770 $config_file_path");
- exec("chown vmail $config_file_path");
+ chmod($config_file_path, 0770);
+ chown($config_file_path, 'vmail');
unset($config_file_path);
} else {
// Delete the mailfilter recipe
@@ -208,7 +215,6 @@
if(is_file($file)) unlink($file) or $app->log("Unable to delete file: $file",LOGLEVEL_WARN);
$app->log("Deleting custom Mailfiter".$file,LOGLEVEL_DEBUG);
}
- //}
}
}
@@ -244,4 +250,4 @@
} // end class
-?>
\ No newline at end of file
+?>
--
Gitblit v1.9.1