This commit has been accessed 646 times via Git panel.
commit ee12a88c40f4a146042e341fa1c9a53b1bb774cc
tree 3f3fc027013ec3ecd3ffd334a6f36188db46ac11
parent fad04c570edf82e4bcab26724660cd600bbcf23c
author Engels Antonio <engels@majcms.org> 1354834506 +0800
committer Engels Antonio <engels@majcms.org> 1354834506 +0800
Add Sieve vacation autoresponder
diff --git a/index.php b/index.php
index 9b01025..3793e9b 100644
--- a/index.php
+++ b/index.php
@@ -256,7 +256,68 @@ if (isset($_SESSION['logged_uid'])) {
$usr_name = $usr_data[3];
}
}
+
+ if (isset($mail_home) and !empty($mail_home)) {
+
+ $sivU = explode("@",$_SESSION['logged_uid']);
+ $sivN = $sivU[0];
+ $sivD = $sivU[1];
+ $sivP = "$mail_home/$sivD/{$sivN[0]}/$sivN";
+ if (isset($_POST['usr_auto'])) {
+
+ if (!empty($_POST['usr_auto']) and (strlen($_POST['usr_auto']) <= 1000)) {
+
+ $usr_auto = strip_tags($_POST['usr_auto']);
+ $usr_auto = trim($usr_auto);
+ $usr_auto = ucfirst($usr_auto);
+
+ $sivV = "require \"vacation\";\r\nif not header :contains \"subject\" \"[SPAM]\" {\r\nvacation\r\n:days 1\r\n:addresses [\"{$_SESSION['logged_uid']}\"]\r\n\"$usr_auto\"\r\n;\r\n}";
+
+ $fp = fopen("$sivP/0.sieve","w");
+ fwrite($fp,$sivV);
+ fclose($fp);
+
+ ack("auto-reply enabled");
+ }
+ else {
+ if (file_exists("$sivP/0.sieve")) {
+ unlink("$sivP/0.sieve");
+ }
+
+ ack("auto-reply disabled");
+ }
+
+ $sivR = glob("$sivP/*.sieve");
+
+ if (count($sivR) > 0) {
+
+ $sivW = 'require "include";';
+
+ foreach ($sivR as $sivK => $sivS) {
+
+ $sivW = "$sivW\r\ninclude \"" . str_replace(".sieve","",basename($sivS)) . "\";";
+ }
+
+ if ($sivW != file_get_contents("$sivP/.dovecot.sieve")) {
+
+ $fp = fopen("$sivP/.dovecot.sieve","w");
+ fwrite($fp,$sivW);
+ fclose($fp);
+ }
+ }
+ else {
+ if (file_exists("$sivP/.dovecot.sieve")) {
+ unlink("$sivP/.dovecot.sieve");
+ }
+
+ if (file_exists("$sivP/.dovecot.svbin")) {
+ unlink("$sivP/.dovecot.svbin");
+ }
+ }
+ }
+ }
+
$usr_pw0 = $usr_data[1];
if (isset($_POST['usr_pw1']) and !empty($_POST['usr_pw1']) and isset($_POST['usr_pw2']) and !empty($_POST['usr_pw2']) and isset($_POST['usr_pw3']) and !empty($_POST['usr_pw3']) and (strlen($_POST['usr_pw2']) <= 64) and (strlen($_POST['usr_pw3']) <= 64) and (strlen($_POST['usr_pw2']) >= 8) and (strlen($_POST['usr_pw3']) >= 8)) {
@@ -1268,6 +1329,16 @@ echo "</tr>";
echo "<form method=\"post\">";
echo "<input type=\"hidden\" name=\"set\" value=\"account\">";
echo "<tr bgcolor=\"#ffffff\"><td width=\"400\"><input class=\"input\" type=\"text\" name=\"usr_name\" value=\"$usr_name\" autocomplete=\"off\" maxlength=\"128\" required autofocus></td><td>name</td></tr>";
+
+ $usr_auto = "";
+
+ if (file_exists("$sivP/0.sieve")) {
+ $usrV = file("$sivP/0.sieve");
+ $usr_auto = trim(trim($usrV[5]),'"');
+ }
+
+ echo "<tr bgcolor=\"#ffffff\"><td width=\"400\"><input class=\"input\" type=\"text\" name=\"usr_auto\" value=\"$usr_auto\" autocomplete=\"off\" maxlength=\"1000\"></td><td>auto-reply</td></tr>";
+
echo "<tr bgcolor=\"#ffffff\"><td width=\"400\"><input class=\"input\" type=\"password\" name=\"usr_pw1\" autocomplete=\"off\" maxlength=\"64\"></td><td><nobr>current password</nobr></td></tr>";
echo "</table>";
@@ -1344,10 +1415,6 @@ echo "</tr>";
if (isset($mail_home) and !empty($mail_home)) {
- $sivU = explode("@",$_SESSION['logged_uid']);
- $sivN = $sivU[0];
- $sivD = $sivU[1];
- $sivP = "$mail_home/$sivD/{$sivN[0]}/$sivN";
$sivR = glob("$sivP/*.sieve",GLOB_NOSORT);
if ($del_siv) {
@@ -1476,14 +1543,20 @@ echo "</tr>";
echo "</tr></form>";
echo "</table>";
echo "</div>";
- echo "<div class=\"spacer\"></div>";
$sivR = glob("$sivP/*.sieve");
+ $sivW = 'require "include";';
+
+ if (in_array("$sivP/0.sieve",$sivR)) {
+
+ array_splice($sivR,array_search("$sivP/0.sieve",$sivR),1);
+ $sivW = "$sivW\r\ninclude \"0\";";
+ }
if (count($sivR) > 0) {
- $sivW = 'require "include";';
-
+ echo "<div class=\"spacer\"></div>";
+
echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\">";
foreach ($sivR as $sivK => $sivS) {
@@ -1563,22 +1636,23 @@ echo "</tr>";
}
echo "</table>";
- echo "</div>";
-
- if ($sivW != file_get_contents("$sivP/.dovecot.sieve")) {
+ }
- $fp = fopen("$sivP/.dovecot.sieve","w");
- fwrite($fp,$sivW);
- fclose($fp);
- }
+ if ($sivW != file_get_contents("$sivP/.dovecot.sieve")) {
+
+ $fp = fopen("$sivP/.dovecot.sieve","w");
+ fwrite($fp,$sivW);
+ fclose($fp);
}
- else {
+
+ if (file_get_contents("$sivP/.dovecot.sieve") == 'require "include";') {
+
if (file_exists("$sivP/.dovecot.sieve")) {
- unlink("$sivP/.dovecot.sieve");
+ unlink("$sivP/.dovecot.sieve");
}
if (file_exists("$sivP/.dovecot.svbin")) {
- unlink("$sivP/.dovecot.svbin");
+ unlink("$sivP/.dovecot.svbin");
}
}
}
tree 3f3fc027013ec3ecd3ffd334a6f36188db46ac11
parent fad04c570edf82e4bcab26724660cd600bbcf23c
author Engels Antonio <engels@majcms.org> 1354834506 +0800
committer Engels Antonio <engels@majcms.org> 1354834506 +0800
Add Sieve vacation autoresponder
diff --git a/index.php b/index.php
index 9b01025..3793e9b 100644
--- a/index.php
+++ b/index.php
@@ -256,7 +256,68 @@ if (isset($_SESSION['logged_uid'])) {
$usr_name = $usr_data[3];
}
}
+
+ if (isset($mail_home) and !empty($mail_home)) {
+
+ $sivU = explode("@",$_SESSION['logged_uid']);
+ $sivN = $sivU[0];
+ $sivD = $sivU[1];
+ $sivP = "$mail_home/$sivD/{$sivN[0]}/$sivN";
+ if (isset($_POST['usr_auto'])) {
+
+ if (!empty($_POST['usr_auto']) and (strlen($_POST['usr_auto']) <= 1000)) {
+
+ $usr_auto = strip_tags($_POST['usr_auto']);
+ $usr_auto = trim($usr_auto);
+ $usr_auto = ucfirst($usr_auto);
+
+ $sivV = "require \"vacation\";\r\nif not header :contains \"subject\" \"[SPAM]\" {\r\nvacation\r\n:days 1\r\n:addresses [\"{$_SESSION['logged_uid']}\"]\r\n\"$usr_auto\"\r\n;\r\n}";
+
+ $fp = fopen("$sivP/0.sieve","w");
+ fwrite($fp,$sivV);
+ fclose($fp);
+
+ ack("auto-reply enabled");
+ }
+ else {
+ if (file_exists("$sivP/0.sieve")) {
+ unlink("$sivP/0.sieve");
+ }
+
+ ack("auto-reply disabled");
+ }
+
+ $sivR = glob("$sivP/*.sieve");
+
+ if (count($sivR) > 0) {
+
+ $sivW = 'require "include";';
+
+ foreach ($sivR as $sivK => $sivS) {
+
+ $sivW = "$sivW\r\ninclude \"" . str_replace(".sieve","",basename($sivS)) . "\";";
+ }
+
+ if ($sivW != file_get_contents("$sivP/.dovecot.sieve")) {
+
+ $fp = fopen("$sivP/.dovecot.sieve","w");
+ fwrite($fp,$sivW);
+ fclose($fp);
+ }
+ }
+ else {
+ if (file_exists("$sivP/.dovecot.sieve")) {
+ unlink("$sivP/.dovecot.sieve");
+ }
+
+ if (file_exists("$sivP/.dovecot.svbin")) {
+ unlink("$sivP/.dovecot.svbin");
+ }
+ }
+ }
+ }
+
$usr_pw0 = $usr_data[1];
if (isset($_POST['usr_pw1']) and !empty($_POST['usr_pw1']) and isset($_POST['usr_pw2']) and !empty($_POST['usr_pw2']) and isset($_POST['usr_pw3']) and !empty($_POST['usr_pw3']) and (strlen($_POST['usr_pw2']) <= 64) and (strlen($_POST['usr_pw3']) <= 64) and (strlen($_POST['usr_pw2']) >= 8) and (strlen($_POST['usr_pw3']) >= 8)) {
@@ -1268,6 +1329,16 @@ echo "</tr>";
echo "<form method=\"post\">";
echo "<input type=\"hidden\" name=\"set\" value=\"account\">";
echo "<tr bgcolor=\"#ffffff\"><td width=\"400\"><input class=\"input\" type=\"text\" name=\"usr_name\" value=\"$usr_name\" autocomplete=\"off\" maxlength=\"128\" required autofocus></td><td>name</td></tr>";
+
+ $usr_auto = "";
+
+ if (file_exists("$sivP/0.sieve")) {
+ $usrV = file("$sivP/0.sieve");
+ $usr_auto = trim(trim($usrV[5]),'"');
+ }
+
+ echo "<tr bgcolor=\"#ffffff\"><td width=\"400\"><input class=\"input\" type=\"text\" name=\"usr_auto\" value=\"$usr_auto\" autocomplete=\"off\" maxlength=\"1000\"></td><td>auto-reply</td></tr>";
+
echo "<tr bgcolor=\"#ffffff\"><td width=\"400\"><input class=\"input\" type=\"password\" name=\"usr_pw1\" autocomplete=\"off\" maxlength=\"64\"></td><td><nobr>current password</nobr></td></tr>";
echo "</table>";
@@ -1344,10 +1415,6 @@ echo "</tr>";
if (isset($mail_home) and !empty($mail_home)) {
- $sivU = explode("@",$_SESSION['logged_uid']);
- $sivN = $sivU[0];
- $sivD = $sivU[1];
- $sivP = "$mail_home/$sivD/{$sivN[0]}/$sivN";
$sivR = glob("$sivP/*.sieve",GLOB_NOSORT);
if ($del_siv) {
@@ -1476,14 +1543,20 @@ echo "</tr>";
echo "</tr></form>";
echo "</table>";
echo "</div>";
- echo "<div class=\"spacer\"></div>";
$sivR = glob("$sivP/*.sieve");
+ $sivW = 'require "include";';
+
+ if (in_array("$sivP/0.sieve",$sivR)) {
+
+ array_splice($sivR,array_search("$sivP/0.sieve",$sivR),1);
+ $sivW = "$sivW\r\ninclude \"0\";";
+ }
if (count($sivR) > 0) {
- $sivW = 'require "include";';
-
+ echo "<div class=\"spacer\"></div>";
+
echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\">";
foreach ($sivR as $sivK => $sivS) {
@@ -1563,22 +1636,23 @@ echo "</tr>";
}
echo "</table>";
- echo "</div>";
-
- if ($sivW != file_get_contents("$sivP/.dovecot.sieve")) {
+ }
- $fp = fopen("$sivP/.dovecot.sieve","w");
- fwrite($fp,$sivW);
- fclose($fp);
- }
+ if ($sivW != file_get_contents("$sivP/.dovecot.sieve")) {
+
+ $fp = fopen("$sivP/.dovecot.sieve","w");
+ fwrite($fp,$sivW);
+ fclose($fp);
}
- else {
+
+ if (file_get_contents("$sivP/.dovecot.sieve") == 'require "include";') {
+
if (file_exists("$sivP/.dovecot.sieve")) {
- unlink("$sivP/.dovecot.sieve");
+ unlink("$sivP/.dovecot.sieve");
}
if (file_exists("$sivP/.dovecot.svbin")) {
- unlink("$sivP/.dovecot.svbin");
+ unlink("$sivP/.dovecot.svbin");
}
}
}