This commit has been accessed 657 times via Git panel.
commit 273e04338f5c76bb26d4795bb1293b995075e906
tree b6f779db0ba893c77834f91d75bcf020a6349bf5
parent ee12a88c40f4a146042e341fa1c9a53b1bb774cc
author Engels Antonio <engels@majcms.org> 1354990828 +0800
committer Engels Antonio <engels@majcms.org> 1354990828 +0800
Add auto-reply for 1:1 aliases
diff --git a/core.js b/core.js
index 8cafed1..8e53ff4 100644
--- a/core.js
+++ b/core.js
@@ -1034,3 +1034,17 @@ function same(a) {
document.getElementById("pmc2").innerHTML = "new password"
}
}
+
+function arep() {
+ if (document.getElementById("ar1").value == "") {
+ document.getElementById("ar2").innerHTML = "auto-reply (enter message to activate)";
+ }
+ else {
+ var a = 1000 - document.getElementById("ar1").value.length;
+ if (a == 1) {
+ document.getElementById("ar2").innerHTML = "auto-reply (" + a + " character left)";
+ } else {
+ document.getElementById("ar2").innerHTML = "auto-reply (" + a + " characters left)";
+ }
+ }
+}
diff --git a/index.php b/index.php
index 3793e9b..c39fc07 100644
--- a/index.php
+++ b/index.php
@@ -271,8 +271,26 @@ if (isset($_SESSION['logged_uid'])) {
$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}";
+
+ $usr_addr = "\"{$_SESSION['logged_uid']}\"";
+
+ $usr_query = mysql_query("select id, alias from aliases group by id having count(*) = 1");
+
+ if (mysql_num_rows($usr_query) > 0) {
+
+ while ($usr_aka = mysql_fetch_array($usr_query)) {
+
+ if ($usr_aka[1] == $_SESSION['logged_uid']) {
+ $usr_addr = "$usr_addr,\"{$usr_aka[0]}\"";
+ }
+ }
+ }
+
+ $sivV = "require \"vacation\";\r\nif not header :contains \"subject\" \"[SPAM]\" {\r\nvacation\r\n:days 1\r\n:addresses [$usr_addr]\r\n\"$usr_auto\"\r\n;\r\n}";
+
+ if (!file_exists("$sivP")) {
+ mkdir($sivP,0700,true);
+ }
$fp = fopen("$sivP/0.sieve","w");
fwrite($fp,$sivV);
@@ -285,6 +303,10 @@ if (isset($_SESSION['logged_uid'])) {
unlink("$sivP/0.sieve");
}
+ if (file_exists("$sivP/.dovecot.lda-dupes")) {
+ unlink("$sivP/.dovecot.lda-dupes");
+ }
+
ack("auto-reply disabled");
}
@@ -308,11 +330,11 @@ if (isset($_SESSION['logged_uid'])) {
}
else {
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");
}
}
}
@@ -1337,7 +1359,7 @@ echo "</tr>";
$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=\"text\" name=\"usr_auto\" value=\"$usr_auto\" autocomplete=\"off\" maxlength=\"1000\" id=\"ar1\" onkeyup=\"arep()\"></td><td id=\"ar2\">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>";
tree b6f779db0ba893c77834f91d75bcf020a6349bf5
parent ee12a88c40f4a146042e341fa1c9a53b1bb774cc
author Engels Antonio <engels@majcms.org> 1354990828 +0800
committer Engels Antonio <engels@majcms.org> 1354990828 +0800
Add auto-reply for 1:1 aliases
diff --git a/core.js b/core.js
index 8cafed1..8e53ff4 100644
--- a/core.js
+++ b/core.js
@@ -1034,3 +1034,17 @@ function same(a) {
document.getElementById("pmc2").innerHTML = "new password"
}
}
+
+function arep() {
+ if (document.getElementById("ar1").value == "") {
+ document.getElementById("ar2").innerHTML = "auto-reply (enter message to activate)";
+ }
+ else {
+ var a = 1000 - document.getElementById("ar1").value.length;
+ if (a == 1) {
+ document.getElementById("ar2").innerHTML = "auto-reply (" + a + " character left)";
+ } else {
+ document.getElementById("ar2").innerHTML = "auto-reply (" + a + " characters left)";
+ }
+ }
+}
diff --git a/index.php b/index.php
index 3793e9b..c39fc07 100644
--- a/index.php
+++ b/index.php
@@ -271,8 +271,26 @@ if (isset($_SESSION['logged_uid'])) {
$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}";
+
+ $usr_addr = "\"{$_SESSION['logged_uid']}\"";
+
+ $usr_query = mysql_query("select id, alias from aliases group by id having count(*) = 1");
+
+ if (mysql_num_rows($usr_query) > 0) {
+
+ while ($usr_aka = mysql_fetch_array($usr_query)) {
+
+ if ($usr_aka[1] == $_SESSION['logged_uid']) {
+ $usr_addr = "$usr_addr,\"{$usr_aka[0]}\"";
+ }
+ }
+ }
+
+ $sivV = "require \"vacation\";\r\nif not header :contains \"subject\" \"[SPAM]\" {\r\nvacation\r\n:days 1\r\n:addresses [$usr_addr]\r\n\"$usr_auto\"\r\n;\r\n}";
+
+ if (!file_exists("$sivP")) {
+ mkdir($sivP,0700,true);
+ }
$fp = fopen("$sivP/0.sieve","w");
fwrite($fp,$sivV);
@@ -285,6 +303,10 @@ if (isset($_SESSION['logged_uid'])) {
unlink("$sivP/0.sieve");
}
+ if (file_exists("$sivP/.dovecot.lda-dupes")) {
+ unlink("$sivP/.dovecot.lda-dupes");
+ }
+
ack("auto-reply disabled");
}
@@ -308,11 +330,11 @@ if (isset($_SESSION['logged_uid'])) {
}
else {
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");
}
}
}
@@ -1337,7 +1359,7 @@ echo "</tr>";
$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=\"text\" name=\"usr_auto\" value=\"$usr_auto\" autocomplete=\"off\" maxlength=\"1000\" id=\"ar1\" onkeyup=\"arep()\"></td><td id=\"ar2\">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>";