This commit has been accessed 578 times via Git panel.
commit c39368623626f18c42782db97e896b40d262cea3
tree 1442b69eea184b1f91e8342fdc9f24ab8a496015
parent f418b478a19f9b2b881ab11f3189f7d281e9d377
author Engels Antonio <engels@majcms.org> 1335336917 +0800
committer Engels Antonio <engels@majcms.org> 1335336917 +0800
Segregate settings
diff --git a/index.php b/index.php
index c5f3496..86ac454 100644
--- a/index.php
+++ b/index.php
@@ -864,7 +864,6 @@ if (isset($_SESSION['logged_uid'])) {
if (isset($_POST['del_box']) and !empty($_POST['del_box'])) {
$del_box = imap_utf7_encode(ucwords(trim(preg_replace("/[^a-z0-9 ]/i","",strip_tags($_POST['del_box'])))));
- $del_siv = $del_box;
if (($del_box != "INBOX") and ($del_box != "Sent") and ($del_box != "Trash")) {
imap_deletemailbox($mbox,"{$host}$del_box");
@@ -1007,275 +1006,316 @@ if (isset($_SESSION['logged_uid'])) {
elseif (isset($_POST['set']) and !empty($_POST['set'])) {
echo "<title>Kartero - Settings</title>";
- echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" width=\"800\">";
- echo "<form method=\"post\">";
- echo "<input type=\"hidden\" name=\"set\" value=\"1\">";
- 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>";
- echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"password\" name=\"usr_pw1\" autocomplete=\"off\" maxlength=\"64\"></td><td>current password</td></tr>";
- echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"password\" name=\"usr_pw2\" autocomplete=\"off\" maxlength=\"64\"></td><td>new password";
+ echo "<div class=\"message\">";
+ echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
- if (isset($_POST['usr_pw1']) and !empty($_POST['usr_pw1']) and isset($_POST['usr_pw2']) and (strlen($_POST['usr_pw2']) < 8)) {
- echo " <font color=\"red\">too short</font>";
- }
+ echo "<tr>";
+ echo "<form method=\"post\"><td class=\"label\"><input type=\"hidden\" name=\"set\" value=\"account\"><input type=\"image\" src=\"images/mail-settings.png\"></td></form>";
+ echo "<form method=\"post\"><td class=\"label\"><input type=\"hidden\" name=\"set\" value=\"folders\"><input type=\"image\" src=\"images/mail-settings.png\"></td></form>";
+ echo "<form method=\"post\"><td class=\"label\"><input type=\"hidden\" name=\"set\" value=\"filters\"><input type=\"image\" src=\"images/mail-settings.png\"></td></form>";
+ echo "</tr>";
- echo "</td></tr>";
+ echo "<tr><td class=\"label\">account</td><td class=\"label\">folders</td><td class=\"label\">filters</td></tr>";
- echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"password\" name=\"usr_pw3\" autocomplete=\"off\" maxlength=\"64\"></td><td>new password";
+ echo "</table>";
+ echo "</div>";
- if (isset($_POST['usr_pw1']) and !empty($_POST['usr_pw1']) and isset($_POST['usr_pw3']) and (strlen($_POST['usr_pw3']) < 8)) {
- echo " <font color=\"red\">too short</font>";
- }
+ if ($_POST['set'] == "account") {
- echo "</td></tr>";
+ echo "<div class=\"spacer\"></div>";
+ echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" width=\"800\">";
+ 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>";
+ echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"password\" name=\"usr_pw1\" autocomplete=\"off\" maxlength=\"64\"></td><td>current password</td></tr>";
- echo "<tr bgcolor=\"#ffffff\"><td><input class=\"button\" type=\"submit\" value=\"update\"></td><td></td></tr>";
- echo "</form></table>";
+ echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"password\" name=\"usr_pw2\" autocomplete=\"off\" maxlength=\"64\"></td><td>new password";
- echo "<br><table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" width=\"800\">";
- echo "<form method=\"post\">";
- echo "<input type=\"hidden\" name=\"set\" value=\"1\">";
- echo "<tr bgcolor=\"#ffffff\"><td width=\"200\"><input class=\"input\" type=\"text\" name=\"new_box\" autocomplete=\"off\" maxlength=\"200\" required autofocus></td>";
- echo "<td width=\"197\"><input class=\"button\" type=\"submit\" value=\"create folder\"></td><td></td></tr>";
- echo "</form>";
+ if (isset($_POST['usr_pw1']) and !empty($_POST['usr_pw1']) and isset($_POST['usr_pw2']) and (strlen($_POST['usr_pw2']) < 8)) {
+ echo " <font color=\"red\">too short</font>";
+ }
- $usr_box = imap_list($mbox,$host,"*");
- $usr_box = array_diff($usr_box,array("{$host}INBOX","{$host}Sent","{$host}Trash"));
+ echo "</td></tr>";
- if (count($usr_box) > 0) {
+ echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"password\" name=\"usr_pw3\" autocomplete=\"off\" maxlength=\"64\"></td><td>new password";
- sort($usr_box);
+ if (isset($_POST['usr_pw1']) and !empty($_POST['usr_pw1']) and isset($_POST['usr_pw3']) and (strlen($_POST['usr_pw3']) < 8)) {
+ echo " <font color=\"red\">too short</font>";
+ }
- echo "<form method=\"post\">";
- echo "<input type=\"hidden\" name=\"set\" value=\"1\">";
- echo "<tr bgcolor=\"#ffffff\"><td width=\"200\"><select class=\"input\" name=\"del_box\">";
+ echo "</td></tr>";
- foreach ($usr_box as $del_box) {
-
- $del_box = imap_utf7_decode(str_replace($host,"",$del_box));
-
- echo "<option value=\"$del_box\">$del_box</option>";
- }
-
- echo "</select></td><td width=\"197\"><input class=\"button\" type=\"submit\" value=\"delete folder\" onclick=\"if (confirm('Delete folder and all messages in it?')) {return true;} else {return false;}\"></td><td></td></tr>";
- echo "</form>";
+ echo "<tr bgcolor=\"#ffffff\"><td><input class=\"button\" type=\"submit\" value=\"update\"></td><td></td></tr>";
+ echo "</form></table>";
}
- echo "</table>";
- if (isset($mail_home) and !empty($mail_home)) {
+ if (($_POST['set'] == "folders") or ($_POST['set'] == "filters") or ($_POST['set'] == "sivD") or ($_POST['set'] == "sivM")) {
- $sivU = explode("@",$_SESSION['logged_uid']);
- $sivN = $sivU[0];
- $sivD = $sivU[1];
- $sivP = "$mail_home/$sivD/{$sivN[0]}/$sivN";
- $sivR = glob("$sivP/*.sieve",GLOB_NOSORT);
+ $usr_box = imap_list($mbox,$host,"*");
+ $usr_box = array_diff($usr_box,array("{$host}INBOX","{$host}Sent","{$host}Trash"));
- if ($del_siv) {
-
- foreach ($sivR as $sivI) {
-
- if (stripos(file_get_contents($sivI),"fileinto \"$del_siv\";")) {
- unlink($sivI);
+ 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_box) {
+
+ foreach ($sivR as $sivI) {
+
+ if (stripos(file_get_contents($sivI),"fileinto \"$del_box\";")) {
+ unlink($sivI);
+ }
}
}
}
+ }
- if (isset($_POST['sieveT']) and !empty($_POST['sieveT']) and isset($_POST['sieveV']) and !empty($_POST['sieveV']) and isset($_POST['sieveF']) and !empty($_POST['sieveF'])) {
+ if ($_POST['set'] == "folders") {
- $sieveT = strtolower(trim(strip_tags($_POST['sieveT'])));
- $sieveV = trim($_POST['sieveV']);
- $sieveF = imap_utf7_encode(trim(strip_tags($_POST['sieveF'])));
+ echo "<div class=\"spacer\"></div>";
+ echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" width=\"800\">";
+ echo "<form method=\"post\">";
+ echo "<input type=\"hidden\" name=\"set\" value=\"folders\">";
+ echo "<tr bgcolor=\"#ffffff\"><td width=\"200\"><input class=\"input\" type=\"text\" name=\"new_box\" autocomplete=\"off\" maxlength=\"200\" required autofocus></td>";
+ echo "<td width=\"197\"><input class=\"button\" type=\"submit\" value=\"create folder\"></td><td></td></tr>";
+ echo "</form>";
- if ($sieveT == "subject") {
- $sieveV = strip_tags($sieveV);
- }
- if ($sieveV != "") {
- $sieveW = "require \"fileinto\"; if header :contains \"$sieveT\" \"$sieveV\" { fileinto \"$sieveF\"; }";
- }
+ if (count($usr_box) > 0) {
- if ($sieveW != ""){
-
- if (count($sivR) > 0) {
+ sort($usr_box);
+
+ echo "<form method=\"post\">";
+ echo "<input type=\"hidden\" name=\"set\" value=\"folders\">";
+ echo "<tr bgcolor=\"#ffffff\"><td width=\"200\"><select class=\"input\" name=\"del_box\">";
+
+ foreach ($usr_box as $del_box) {
+
+ $del_box = imap_utf7_decode(str_replace($host,"",$del_box));
- foreach ($sivR as $sieveR) {
-
- if (strtolower(trim(file_get_contents($sieveR))) != strtolower($sieveW)) {
- continue;
- }
-
- unlink($sieveR);
- }
- }
-
- $sieveP = "$sivP/" . date("YmdHis") . ".sieve";
+ echo "<option value=\"$del_box\">$del_box</option>";
+ }
+
+ echo "</select></td><td width=\"197\"><input class=\"button\" type=\"submit\" value=\"delete folder\" onclick=\"if (confirm('Delete folder and all messages in it?')) {return true;} else {return false;}\"></td><td></td></tr>";
+ echo "</form>";
+ }
+ echo "</table>";
+ }
- if (!file_exists($sivP)) {
- mkdir($sivP,0700,true);
- }
+ if (($_POST['set'] == "filters") or ($_POST['set'] == "sivD") or ($_POST['set'] == "sivM")) {
- $fp = fopen($sieveP,"w");
- fwrite($fp,$sieveW);
- fclose($fp);
+ if (isset($mail_home) and !empty($mail_home)) {
+
+ if (isset($_POST['sieveT']) and !empty($_POST['sieveT']) and isset($_POST['sieveV']) and !empty($_POST['sieveV']) and isset($_POST['sieveF']) and !empty($_POST['sieveF'])) {
- $sieveC = "$sieveT \"$sieveV\"";
+ $sieveT = strtolower(trim(strip_tags($_POST['sieveT'])));
+ $sieveV = trim($_POST['sieveV']);
+ $sieveF = imap_utf7_encode(trim(strip_tags($_POST['sieveF'])));
- $sieveO = (imap_search($mbox,$sieveC,SE_UID));
+ if ($sieveT == "subject") {
+ $sieveV = strip_tags($sieveV);
+ }
- foreach ($sieveO as $sivO) {
- imap_mail_move($mbox,$sivO,$sieveF,CP_UID);
- imap_expunge($mbox);
- }
- }
- }
+ if ($sieveV != "") {
+ $sieveW = "require \"fileinto\"; if header :contains \"$sieveT\" \"$sieveV\" { fileinto \"$sieveF\"; }";
+ }
- if (isset($_POST['sieve']) and !empty($_POST['sieve'])) {
+ if ($sieveW != ""){
+
+ if (count($sivR) > 0) {
+
+ foreach ($sivR as $sieveR) {
- $sieve = strtolower(trim(strip_tags($_POST['sieve'])));
+ if (strtolower(trim(file_get_contents($sieveR))) != strtolower($sieveW)) {
+ continue;
+ }
+
+ unlink($sieveR);
+ }
+ }
- if (isset($_POST['sivM']) and !empty($_POST['sivM'])) {
+ $sieveP = "$sivP/" . date("YmdHis") . ".sieve";
- $sivM = trim(strip_tags($_POST['sivM']));
+ if (!file_exists($sivP)) {
+ mkdir($sivP,0700,true);
+ }
- if (file_exists("$sivP/$sivM") and ($_POST['set'] == "sivM")) {
+ $fp = fopen($sieveP,"w");
+ fwrite($fp,$sieveW);
+ fclose($fp);
- $sivMs = file_get_contents("$sivP/$sieve");
- $sivMt = file_get_contents("$sivP/$sivM");
+ $sieveC = "$sieveT \"$sieveV\"";
- $fp = fopen("$sivP/$sieve","w");
- fwrite($fp,$sivMt);
- fclose($fp);
+ $sieveO = (imap_search($mbox,$sieveC,SE_UID));
- $fp = fopen("$sivP/$sivM","w");
- fwrite($fp,$sivMs);
- fclose($fp);
+ foreach ($sieveO as $sivO) {
+ imap_mail_move($mbox,$sivO,$sieveF,CP_UID);
+ imap_expunge($mbox);
+ }
}
}
- if (file_exists("$sivP/$sieve") and ($_POST['set'] == "sivD")) {
- unlink("$sivP/$sieve");
- }
- }
+ if (isset($_POST['sieve']) and !empty($_POST['sieve'])) {
- echo "<br><table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" width=\"100%\">";
- echo "<form method=\"post\"><input type=\"hidden\" name=\"set\" value=\"sivA\"><tr>";
- echo "<td width=\"200\"><select class=\"input\" name=\"sieveT\">";
- echo "<option value=\"subject\">If message subject contains</option>";
- echo "<option value=\"from\">If message from contains</option>";
- echo "<option value=\"to\">If message to contains</option>";
- echo "<option value=\"cc\">If message cc contains</option>";
- echo "</td>";
- echo "<td><input class=\"input\" type=\"text\" name=\"sieveV\" autocomplete=\"off\" required></td>";
- echo "<td><select class=\"input\" name=\"sieveF\"><option value=\"Trash\" selected>then move to Trash</option>";
+ $sieve = strtolower(trim(strip_tags($_POST['sieve'])));
- foreach ($usr_box as $sieveF) {
+ if (isset($_POST['sivM']) and !empty($_POST['sivM'])) {
- $sieveF = str_replace($host,"",$sieveF);
+ $sivM = trim(strip_tags($_POST['sivM']));
- echo "<option value=\"$sieveF\">then move to $sieveF</option>";
- }
+ if (file_exists("$sivP/$sivM") and ($_POST['set'] == "sivM")) {
- echo "</select></td>";
- echo "<td><input class=\"button\" type=\"submit\" value=\"add filter\"></td>";
- echo "</tr></form>";
- echo "</table>";
+ $sivMs = file_get_contents("$sivP/$sieve");
+ $sivMt = file_get_contents("$sivP/$sivM");
- $sivR = glob("$sivP/*.sieve");
+ $fp = fopen("$sivP/$sieve","w");
+ fwrite($fp,$sivMt);
+ fclose($fp);
- if (count($sivR) > 0) {
+ $fp = fopen("$sivP/$sivM","w");
+ fwrite($fp,$sivMs);
+ fclose($fp);
+ }
+ }
+
+ if (file_exists("$sivP/$sieve") and ($_POST['set'] == "sivD")) {
+ unlink("$sivP/$sieve");
+ }
+ }
- $sivW = 'require "include";';
+ echo "<div class=\"spacer\"></div>";
+ echo "<div class=\"message\" style=\"padding: 0;\">";
+ echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" width=\"100%\">";
+ echo "<form method=\"post\"><input type=\"hidden\" name=\"set\" value=\"filters\"><tr>";
+ echo "<td width=\"200\"><select class=\"input\" name=\"sieveT\">";
+ echo "<option value=\"subject\">If message subject contains</option>";
+ echo "<option value=\"from\">If message from contains</option>";
+ echo "<option value=\"to\">If message to contains</option>";
+ echo "<option value=\"cc\">If message cc contains</option>";
+ echo "</td>";
+ echo "<td><input class=\"input\" type=\"text\" name=\"sieveV\" autocomplete=\"off\" required></td>";
+ echo "<td><select class=\"input\" name=\"sieveF\"><option value=\"Trash\" selected>then move to Trash</option>";
+
+ foreach ($usr_box as $sieveF) {
+
+ $sieveF = str_replace($host,"",$sieveF);
+
+ echo "<option value=\"$sieveF\">then move to $sieveF</option>";
+ }
- echo "<br><table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\">";
+ echo "</select></td>";
+ echo "<td><input class=\"button\" type=\"submit\" value=\"add filter\"></td>";
+ echo "</tr></form>";
+ echo "</table>";
+ echo "</div>";
+ echo "<div class=\"spacer\"></div>";
- foreach ($sivR as $sivK => $sivS) {
+ $sivR = glob("$sivP/*.sieve");
- if ($bgColor == "#ffffff") {
- $bgColor = "#fdfdfd";
- }
- else {
- $bgColor = "#ffffff";
- }
+ if (count($sivR) > 0) {
- if ($sivK > 0) {
+ $sivW = 'require "include";';
+
+ echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\">";
- $sivKp = $sivK - 1;
+ foreach ($sivR as $sivK => $sivS) {
- if (array_key_exists($sivKp,$sivR)) {
- $sivKp = basename($sivR[$sivKp]);
- }
- else {
- unset($sivKp);
- }
- }
+ if ($bgColor == "#ffffff") {
+ $bgColor = "#fdfdfd";
+ }
+ else {
+ $bgColor = "#ffffff";
+ }
- if ($sivK < count($sivR)) {
+ if ($sivK > 0) {
- $sivKn = $sivK + 1;
+ $sivKp = $sivK - 1;
- if (array_key_exists($sivKn,$sivR)) {
- $sivKn = basename($sivR[$sivKn]);
- }
- else {
- unset($sivKn);
+ if (array_key_exists($sivKp,$sivR)) {
+ $sivKp = basename($sivR[$sivKp]);
+ }
+ else {
+ unset($sivKp);
+ }
}
- }
- $sivC = (explode('"',file_get_contents($sivS)));
- $sivF = basename($sivS);
+ if ($sivK < count($sivR)) {
- $sivW = $sivW . "\r\ninclude \"" . str_replace(".sieve","",$sivF) . '";';
+ $sivKn = $sivK + 1;
- echo "<form method=\"post\">";
- echo "<input type=\"hidden\" name=\"set\" value=\"sivD\">";
- echo "<input type=\"hidden\" name=\"sieve\" value=\"$sivF\">";
- echo "<tr bgcolor=\"$bgColor\">";
- echo "<td valign=\"bottom\" width=\"24\"><input type=\"image\" src=\"images/sieve-del.png\"></td>";
- echo "</form>";
+ if (array_key_exists($sivKn,$sivR)) {
+ $sivKn = basename($sivR[$sivKn]);
+ }
+ else {
+ unset($sivKn);
+ }
+ }
- if ($sivKp) {
+ $sivC = (explode('"',file_get_contents($sivS)));
+ $sivF = basename($sivS);
+
+ $sivW = $sivW . "\r\ninclude \"" . str_replace(".sieve","",$sivF) . '";';
+
echo "<form method=\"post\">";
- echo "<input type=\"hidden\" name=\"set\" value=\"sivM\">";
+ echo "<input type=\"hidden\" name=\"set\" value=\"sivD\">";
echo "<input type=\"hidden\" name=\"sieve\" value=\"$sivF\">";
- echo "<input type=\"hidden\" name=\"sivM\" value=\"$sivKp\">";
- echo "<td valign=\"bottom\" width=\"24\"><input type=\"image\" src=\"images/sieve-up.png\"></td>";
+ echo "<tr bgcolor=\"$bgColor\">";
+ echo "<td valign=\"bottom\" width=\"24\"><input type=\"image\" src=\"images/sieve-del.png\"></td>";
echo "</form>";
- }
- else {
- echo "<td></td>";
- }
- if ($sivKn) {
- echo "<form method=\"post\">";
- echo "<input type=\"hidden\" name=\"set\" value=\"sivM\">";
- echo "<input type=\"hidden\" name=\"sieve\" value=\"$sivF\">";
- echo "<input type=\"hidden\" name=\"sivM\" value=\"$sivKn\">";
- echo "<td valign=\"bottom\" width=\"24\"><input type=\"image\" src=\"images/sieve-down.png\"></td>";
- echo "</form>";
- }
- else {
- echo "<td></td>";
+ if ($sivKp) {
+ echo "<form method=\"post\">";
+ echo "<input type=\"hidden\" name=\"set\" value=\"sivM\">";
+ echo "<input type=\"hidden\" name=\"sieve\" value=\"$sivF\">";
+ echo "<input type=\"hidden\" name=\"sivM\" value=\"$sivKp\">";
+ echo "<td valign=\"bottom\" width=\"24\"><input type=\"image\" src=\"images/sieve-up.png\"></td>";
+ echo "</form>";
+ }
+ else {
+ if (count($sivR) > 1) {
+ echo "<td></td>";
+ }
+ }
+
+ if ($sivKn) {
+ echo "<form method=\"post\">";
+ echo "<input type=\"hidden\" name=\"set\" value=\"sivM\">";
+ echo "<input type=\"hidden\" name=\"sieve\" value=\"$sivF\">";
+ echo "<input type=\"hidden\" name=\"sivM\" value=\"$sivKn\">";
+ echo "<td valign=\"bottom\" width=\"24\"><input type=\"image\" src=\"images/sieve-down.png\"></td>";
+ echo "</form>";
+ }
+ else {
+ if (count($sivR) > 1) {
+ echo "<td></td>";
+ }
+ }
+ echo "<td>If message {$sivC[3]} contains {$sivC[5]} then move to {$sivC[7]}</td>";
+ echo "</tr>";
}
- echo "<td>If message {$sivC[3]} contains {$sivC[5]} then move to {$sivC[7]}</td>";
- echo "</tr>";
- }
- echo "</table>";
-
- if ($sivW != file_get_contents("$sivP/.dovecot.sieve")) {
+ echo "</table>";
- $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_exists("$sivP/.dovecot.sieve")) {
+ else {
+ if (file_exists("$sivP/.dovecot.sieve")) {
unlink("$sivP/.dovecot.sieve");
- }
+ }
- if (file_exists("$sivP/.dovecot.svbin")) {
+ if (file_exists("$sivP/.dovecot.svbin")) {
unlink("$sivP/.dovecot.svbin");
+ }
}
}
}
tree 1442b69eea184b1f91e8342fdc9f24ab8a496015
parent f418b478a19f9b2b881ab11f3189f7d281e9d377
author Engels Antonio <engels@majcms.org> 1335336917 +0800
committer Engels Antonio <engels@majcms.org> 1335336917 +0800
Segregate settings
diff --git a/index.php b/index.php
index c5f3496..86ac454 100644
--- a/index.php
+++ b/index.php
@@ -864,7 +864,6 @@ if (isset($_SESSION['logged_uid'])) {
if (isset($_POST['del_box']) and !empty($_POST['del_box'])) {
$del_box = imap_utf7_encode(ucwords(trim(preg_replace("/[^a-z0-9 ]/i","",strip_tags($_POST['del_box'])))));
- $del_siv = $del_box;
if (($del_box != "INBOX") and ($del_box != "Sent") and ($del_box != "Trash")) {
imap_deletemailbox($mbox,"{$host}$del_box");
@@ -1007,275 +1006,316 @@ if (isset($_SESSION['logged_uid'])) {
elseif (isset($_POST['set']) and !empty($_POST['set'])) {
echo "<title>Kartero - Settings</title>";
- echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" width=\"800\">";
- echo "<form method=\"post\">";
- echo "<input type=\"hidden\" name=\"set\" value=\"1\">";
- 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>";
- echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"password\" name=\"usr_pw1\" autocomplete=\"off\" maxlength=\"64\"></td><td>current password</td></tr>";
- echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"password\" name=\"usr_pw2\" autocomplete=\"off\" maxlength=\"64\"></td><td>new password";
+ echo "<div class=\"message\">";
+ echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
- if (isset($_POST['usr_pw1']) and !empty($_POST['usr_pw1']) and isset($_POST['usr_pw2']) and (strlen($_POST['usr_pw2']) < 8)) {
- echo " <font color=\"red\">too short</font>";
- }
+ echo "<tr>";
+ echo "<form method=\"post\"><td class=\"label\"><input type=\"hidden\" name=\"set\" value=\"account\"><input type=\"image\" src=\"images/mail-settings.png\"></td></form>";
+ echo "<form method=\"post\"><td class=\"label\"><input type=\"hidden\" name=\"set\" value=\"folders\"><input type=\"image\" src=\"images/mail-settings.png\"></td></form>";
+ echo "<form method=\"post\"><td class=\"label\"><input type=\"hidden\" name=\"set\" value=\"filters\"><input type=\"image\" src=\"images/mail-settings.png\"></td></form>";
+ echo "</tr>";
- echo "</td></tr>";
+ echo "<tr><td class=\"label\">account</td><td class=\"label\">folders</td><td class=\"label\">filters</td></tr>";
- echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"password\" name=\"usr_pw3\" autocomplete=\"off\" maxlength=\"64\"></td><td>new password";
+ echo "</table>";
+ echo "</div>";
- if (isset($_POST['usr_pw1']) and !empty($_POST['usr_pw1']) and isset($_POST['usr_pw3']) and (strlen($_POST['usr_pw3']) < 8)) {
- echo " <font color=\"red\">too short</font>";
- }
+ if ($_POST['set'] == "account") {
- echo "</td></tr>";
+ echo "<div class=\"spacer\"></div>";
+ echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" width=\"800\">";
+ 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>";
+ echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"password\" name=\"usr_pw1\" autocomplete=\"off\" maxlength=\"64\"></td><td>current password</td></tr>";
- echo "<tr bgcolor=\"#ffffff\"><td><input class=\"button\" type=\"submit\" value=\"update\"></td><td></td></tr>";
- echo "</form></table>";
+ echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"password\" name=\"usr_pw2\" autocomplete=\"off\" maxlength=\"64\"></td><td>new password";
- echo "<br><table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" width=\"800\">";
- echo "<form method=\"post\">";
- echo "<input type=\"hidden\" name=\"set\" value=\"1\">";
- echo "<tr bgcolor=\"#ffffff\"><td width=\"200\"><input class=\"input\" type=\"text\" name=\"new_box\" autocomplete=\"off\" maxlength=\"200\" required autofocus></td>";
- echo "<td width=\"197\"><input class=\"button\" type=\"submit\" value=\"create folder\"></td><td></td></tr>";
- echo "</form>";
+ if (isset($_POST['usr_pw1']) and !empty($_POST['usr_pw1']) and isset($_POST['usr_pw2']) and (strlen($_POST['usr_pw2']) < 8)) {
+ echo " <font color=\"red\">too short</font>";
+ }
- $usr_box = imap_list($mbox,$host,"*");
- $usr_box = array_diff($usr_box,array("{$host}INBOX","{$host}Sent","{$host}Trash"));
+ echo "</td></tr>";
- if (count($usr_box) > 0) {
+ echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"password\" name=\"usr_pw3\" autocomplete=\"off\" maxlength=\"64\"></td><td>new password";
- sort($usr_box);
+ if (isset($_POST['usr_pw1']) and !empty($_POST['usr_pw1']) and isset($_POST['usr_pw3']) and (strlen($_POST['usr_pw3']) < 8)) {
+ echo " <font color=\"red\">too short</font>";
+ }
- echo "<form method=\"post\">";
- echo "<input type=\"hidden\" name=\"set\" value=\"1\">";
- echo "<tr bgcolor=\"#ffffff\"><td width=\"200\"><select class=\"input\" name=\"del_box\">";
+ echo "</td></tr>";
- foreach ($usr_box as $del_box) {
-
- $del_box = imap_utf7_decode(str_replace($host,"",$del_box));
-
- echo "<option value=\"$del_box\">$del_box</option>";
- }
-
- echo "</select></td><td width=\"197\"><input class=\"button\" type=\"submit\" value=\"delete folder\" onclick=\"if (confirm('Delete folder and all messages in it?')) {return true;} else {return false;}\"></td><td></td></tr>";
- echo "</form>";
+ echo "<tr bgcolor=\"#ffffff\"><td><input class=\"button\" type=\"submit\" value=\"update\"></td><td></td></tr>";
+ echo "</form></table>";
}
- echo "</table>";
- if (isset($mail_home) and !empty($mail_home)) {
+ if (($_POST['set'] == "folders") or ($_POST['set'] == "filters") or ($_POST['set'] == "sivD") or ($_POST['set'] == "sivM")) {
- $sivU = explode("@",$_SESSION['logged_uid']);
- $sivN = $sivU[0];
- $sivD = $sivU[1];
- $sivP = "$mail_home/$sivD/{$sivN[0]}/$sivN";
- $sivR = glob("$sivP/*.sieve",GLOB_NOSORT);
+ $usr_box = imap_list($mbox,$host,"*");
+ $usr_box = array_diff($usr_box,array("{$host}INBOX","{$host}Sent","{$host}Trash"));
- if ($del_siv) {
-
- foreach ($sivR as $sivI) {
-
- if (stripos(file_get_contents($sivI),"fileinto \"$del_siv\";")) {
- unlink($sivI);
+ 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_box) {
+
+ foreach ($sivR as $sivI) {
+
+ if (stripos(file_get_contents($sivI),"fileinto \"$del_box\";")) {
+ unlink($sivI);
+ }
}
}
}
+ }
- if (isset($_POST['sieveT']) and !empty($_POST['sieveT']) and isset($_POST['sieveV']) and !empty($_POST['sieveV']) and isset($_POST['sieveF']) and !empty($_POST['sieveF'])) {
+ if ($_POST['set'] == "folders") {
- $sieveT = strtolower(trim(strip_tags($_POST['sieveT'])));
- $sieveV = trim($_POST['sieveV']);
- $sieveF = imap_utf7_encode(trim(strip_tags($_POST['sieveF'])));
+ echo "<div class=\"spacer\"></div>";
+ echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" width=\"800\">";
+ echo "<form method=\"post\">";
+ echo "<input type=\"hidden\" name=\"set\" value=\"folders\">";
+ echo "<tr bgcolor=\"#ffffff\"><td width=\"200\"><input class=\"input\" type=\"text\" name=\"new_box\" autocomplete=\"off\" maxlength=\"200\" required autofocus></td>";
+ echo "<td width=\"197\"><input class=\"button\" type=\"submit\" value=\"create folder\"></td><td></td></tr>";
+ echo "</form>";
- if ($sieveT == "subject") {
- $sieveV = strip_tags($sieveV);
- }
- if ($sieveV != "") {
- $sieveW = "require \"fileinto\"; if header :contains \"$sieveT\" \"$sieveV\" { fileinto \"$sieveF\"; }";
- }
+ if (count($usr_box) > 0) {
- if ($sieveW != ""){
-
- if (count($sivR) > 0) {
+ sort($usr_box);
+
+ echo "<form method=\"post\">";
+ echo "<input type=\"hidden\" name=\"set\" value=\"folders\">";
+ echo "<tr bgcolor=\"#ffffff\"><td width=\"200\"><select class=\"input\" name=\"del_box\">";
+
+ foreach ($usr_box as $del_box) {
+
+ $del_box = imap_utf7_decode(str_replace($host,"",$del_box));
- foreach ($sivR as $sieveR) {
-
- if (strtolower(trim(file_get_contents($sieveR))) != strtolower($sieveW)) {
- continue;
- }
-
- unlink($sieveR);
- }
- }
-
- $sieveP = "$sivP/" . date("YmdHis") . ".sieve";
+ echo "<option value=\"$del_box\">$del_box</option>";
+ }
+
+ echo "</select></td><td width=\"197\"><input class=\"button\" type=\"submit\" value=\"delete folder\" onclick=\"if (confirm('Delete folder and all messages in it?')) {return true;} else {return false;}\"></td><td></td></tr>";
+ echo "</form>";
+ }
+ echo "</table>";
+ }
- if (!file_exists($sivP)) {
- mkdir($sivP,0700,true);
- }
+ if (($_POST['set'] == "filters") or ($_POST['set'] == "sivD") or ($_POST['set'] == "sivM")) {
- $fp = fopen($sieveP,"w");
- fwrite($fp,$sieveW);
- fclose($fp);
+ if (isset($mail_home) and !empty($mail_home)) {
+
+ if (isset($_POST['sieveT']) and !empty($_POST['sieveT']) and isset($_POST['sieveV']) and !empty($_POST['sieveV']) and isset($_POST['sieveF']) and !empty($_POST['sieveF'])) {
- $sieveC = "$sieveT \"$sieveV\"";
+ $sieveT = strtolower(trim(strip_tags($_POST['sieveT'])));
+ $sieveV = trim($_POST['sieveV']);
+ $sieveF = imap_utf7_encode(trim(strip_tags($_POST['sieveF'])));
- $sieveO = (imap_search($mbox,$sieveC,SE_UID));
+ if ($sieveT == "subject") {
+ $sieveV = strip_tags($sieveV);
+ }
- foreach ($sieveO as $sivO) {
- imap_mail_move($mbox,$sivO,$sieveF,CP_UID);
- imap_expunge($mbox);
- }
- }
- }
+ if ($sieveV != "") {
+ $sieveW = "require \"fileinto\"; if header :contains \"$sieveT\" \"$sieveV\" { fileinto \"$sieveF\"; }";
+ }
- if (isset($_POST['sieve']) and !empty($_POST['sieve'])) {
+ if ($sieveW != ""){
+
+ if (count($sivR) > 0) {
+
+ foreach ($sivR as $sieveR) {
- $sieve = strtolower(trim(strip_tags($_POST['sieve'])));
+ if (strtolower(trim(file_get_contents($sieveR))) != strtolower($sieveW)) {
+ continue;
+ }
+
+ unlink($sieveR);
+ }
+ }
- if (isset($_POST['sivM']) and !empty($_POST['sivM'])) {
+ $sieveP = "$sivP/" . date("YmdHis") . ".sieve";
- $sivM = trim(strip_tags($_POST['sivM']));
+ if (!file_exists($sivP)) {
+ mkdir($sivP,0700,true);
+ }
- if (file_exists("$sivP/$sivM") and ($_POST['set'] == "sivM")) {
+ $fp = fopen($sieveP,"w");
+ fwrite($fp,$sieveW);
+ fclose($fp);
- $sivMs = file_get_contents("$sivP/$sieve");
- $sivMt = file_get_contents("$sivP/$sivM");
+ $sieveC = "$sieveT \"$sieveV\"";
- $fp = fopen("$sivP/$sieve","w");
- fwrite($fp,$sivMt);
- fclose($fp);
+ $sieveO = (imap_search($mbox,$sieveC,SE_UID));
- $fp = fopen("$sivP/$sivM","w");
- fwrite($fp,$sivMs);
- fclose($fp);
+ foreach ($sieveO as $sivO) {
+ imap_mail_move($mbox,$sivO,$sieveF,CP_UID);
+ imap_expunge($mbox);
+ }
}
}
- if (file_exists("$sivP/$sieve") and ($_POST['set'] == "sivD")) {
- unlink("$sivP/$sieve");
- }
- }
+ if (isset($_POST['sieve']) and !empty($_POST['sieve'])) {
- echo "<br><table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" width=\"100%\">";
- echo "<form method=\"post\"><input type=\"hidden\" name=\"set\" value=\"sivA\"><tr>";
- echo "<td width=\"200\"><select class=\"input\" name=\"sieveT\">";
- echo "<option value=\"subject\">If message subject contains</option>";
- echo "<option value=\"from\">If message from contains</option>";
- echo "<option value=\"to\">If message to contains</option>";
- echo "<option value=\"cc\">If message cc contains</option>";
- echo "</td>";
- echo "<td><input class=\"input\" type=\"text\" name=\"sieveV\" autocomplete=\"off\" required></td>";
- echo "<td><select class=\"input\" name=\"sieveF\"><option value=\"Trash\" selected>then move to Trash</option>";
+ $sieve = strtolower(trim(strip_tags($_POST['sieve'])));
- foreach ($usr_box as $sieveF) {
+ if (isset($_POST['sivM']) and !empty($_POST['sivM'])) {
- $sieveF = str_replace($host,"",$sieveF);
+ $sivM = trim(strip_tags($_POST['sivM']));
- echo "<option value=\"$sieveF\">then move to $sieveF</option>";
- }
+ if (file_exists("$sivP/$sivM") and ($_POST['set'] == "sivM")) {
- echo "</select></td>";
- echo "<td><input class=\"button\" type=\"submit\" value=\"add filter\"></td>";
- echo "</tr></form>";
- echo "</table>";
+ $sivMs = file_get_contents("$sivP/$sieve");
+ $sivMt = file_get_contents("$sivP/$sivM");
- $sivR = glob("$sivP/*.sieve");
+ $fp = fopen("$sivP/$sieve","w");
+ fwrite($fp,$sivMt);
+ fclose($fp);
- if (count($sivR) > 0) {
+ $fp = fopen("$sivP/$sivM","w");
+ fwrite($fp,$sivMs);
+ fclose($fp);
+ }
+ }
+
+ if (file_exists("$sivP/$sieve") and ($_POST['set'] == "sivD")) {
+ unlink("$sivP/$sieve");
+ }
+ }
- $sivW = 'require "include";';
+ echo "<div class=\"spacer\"></div>";
+ echo "<div class=\"message\" style=\"padding: 0;\">";
+ echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" width=\"100%\">";
+ echo "<form method=\"post\"><input type=\"hidden\" name=\"set\" value=\"filters\"><tr>";
+ echo "<td width=\"200\"><select class=\"input\" name=\"sieveT\">";
+ echo "<option value=\"subject\">If message subject contains</option>";
+ echo "<option value=\"from\">If message from contains</option>";
+ echo "<option value=\"to\">If message to contains</option>";
+ echo "<option value=\"cc\">If message cc contains</option>";
+ echo "</td>";
+ echo "<td><input class=\"input\" type=\"text\" name=\"sieveV\" autocomplete=\"off\" required></td>";
+ echo "<td><select class=\"input\" name=\"sieveF\"><option value=\"Trash\" selected>then move to Trash</option>";
+
+ foreach ($usr_box as $sieveF) {
+
+ $sieveF = str_replace($host,"",$sieveF);
+
+ echo "<option value=\"$sieveF\">then move to $sieveF</option>";
+ }
- echo "<br><table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\">";
+ echo "</select></td>";
+ echo "<td><input class=\"button\" type=\"submit\" value=\"add filter\"></td>";
+ echo "</tr></form>";
+ echo "</table>";
+ echo "</div>";
+ echo "<div class=\"spacer\"></div>";
- foreach ($sivR as $sivK => $sivS) {
+ $sivR = glob("$sivP/*.sieve");
- if ($bgColor == "#ffffff") {
- $bgColor = "#fdfdfd";
- }
- else {
- $bgColor = "#ffffff";
- }
+ if (count($sivR) > 0) {
- if ($sivK > 0) {
+ $sivW = 'require "include";';
+
+ echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\">";
- $sivKp = $sivK - 1;
+ foreach ($sivR as $sivK => $sivS) {
- if (array_key_exists($sivKp,$sivR)) {
- $sivKp = basename($sivR[$sivKp]);
- }
- else {
- unset($sivKp);
- }
- }
+ if ($bgColor == "#ffffff") {
+ $bgColor = "#fdfdfd";
+ }
+ else {
+ $bgColor = "#ffffff";
+ }
- if ($sivK < count($sivR)) {
+ if ($sivK > 0) {
- $sivKn = $sivK + 1;
+ $sivKp = $sivK - 1;
- if (array_key_exists($sivKn,$sivR)) {
- $sivKn = basename($sivR[$sivKn]);
- }
- else {
- unset($sivKn);
+ if (array_key_exists($sivKp,$sivR)) {
+ $sivKp = basename($sivR[$sivKp]);
+ }
+ else {
+ unset($sivKp);
+ }
}
- }
- $sivC = (explode('"',file_get_contents($sivS)));
- $sivF = basename($sivS);
+ if ($sivK < count($sivR)) {
- $sivW = $sivW . "\r\ninclude \"" . str_replace(".sieve","",$sivF) . '";';
+ $sivKn = $sivK + 1;
- echo "<form method=\"post\">";
- echo "<input type=\"hidden\" name=\"set\" value=\"sivD\">";
- echo "<input type=\"hidden\" name=\"sieve\" value=\"$sivF\">";
- echo "<tr bgcolor=\"$bgColor\">";
- echo "<td valign=\"bottom\" width=\"24\"><input type=\"image\" src=\"images/sieve-del.png\"></td>";
- echo "</form>";
+ if (array_key_exists($sivKn,$sivR)) {
+ $sivKn = basename($sivR[$sivKn]);
+ }
+ else {
+ unset($sivKn);
+ }
+ }
- if ($sivKp) {
+ $sivC = (explode('"',file_get_contents($sivS)));
+ $sivF = basename($sivS);
+
+ $sivW = $sivW . "\r\ninclude \"" . str_replace(".sieve","",$sivF) . '";';
+
echo "<form method=\"post\">";
- echo "<input type=\"hidden\" name=\"set\" value=\"sivM\">";
+ echo "<input type=\"hidden\" name=\"set\" value=\"sivD\">";
echo "<input type=\"hidden\" name=\"sieve\" value=\"$sivF\">";
- echo "<input type=\"hidden\" name=\"sivM\" value=\"$sivKp\">";
- echo "<td valign=\"bottom\" width=\"24\"><input type=\"image\" src=\"images/sieve-up.png\"></td>";
+ echo "<tr bgcolor=\"$bgColor\">";
+ echo "<td valign=\"bottom\" width=\"24\"><input type=\"image\" src=\"images/sieve-del.png\"></td>";
echo "</form>";
- }
- else {
- echo "<td></td>";
- }
- if ($sivKn) {
- echo "<form method=\"post\">";
- echo "<input type=\"hidden\" name=\"set\" value=\"sivM\">";
- echo "<input type=\"hidden\" name=\"sieve\" value=\"$sivF\">";
- echo "<input type=\"hidden\" name=\"sivM\" value=\"$sivKn\">";
- echo "<td valign=\"bottom\" width=\"24\"><input type=\"image\" src=\"images/sieve-down.png\"></td>";
- echo "</form>";
- }
- else {
- echo "<td></td>";
+ if ($sivKp) {
+ echo "<form method=\"post\">";
+ echo "<input type=\"hidden\" name=\"set\" value=\"sivM\">";
+ echo "<input type=\"hidden\" name=\"sieve\" value=\"$sivF\">";
+ echo "<input type=\"hidden\" name=\"sivM\" value=\"$sivKp\">";
+ echo "<td valign=\"bottom\" width=\"24\"><input type=\"image\" src=\"images/sieve-up.png\"></td>";
+ echo "</form>";
+ }
+ else {
+ if (count($sivR) > 1) {
+ echo "<td></td>";
+ }
+ }
+
+ if ($sivKn) {
+ echo "<form method=\"post\">";
+ echo "<input type=\"hidden\" name=\"set\" value=\"sivM\">";
+ echo "<input type=\"hidden\" name=\"sieve\" value=\"$sivF\">";
+ echo "<input type=\"hidden\" name=\"sivM\" value=\"$sivKn\">";
+ echo "<td valign=\"bottom\" width=\"24\"><input type=\"image\" src=\"images/sieve-down.png\"></td>";
+ echo "</form>";
+ }
+ else {
+ if (count($sivR) > 1) {
+ echo "<td></td>";
+ }
+ }
+ echo "<td>If message {$sivC[3]} contains {$sivC[5]} then move to {$sivC[7]}</td>";
+ echo "</tr>";
}
- echo "<td>If message {$sivC[3]} contains {$sivC[5]} then move to {$sivC[7]}</td>";
- echo "</tr>";
- }
- echo "</table>";
-
- if ($sivW != file_get_contents("$sivP/.dovecot.sieve")) {
+ echo "</table>";
- $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_exists("$sivP/.dovecot.sieve")) {
+ else {
+ if (file_exists("$sivP/.dovecot.sieve")) {
unlink("$sivP/.dovecot.sieve");
- }
+ }
- if (file_exists("$sivP/.dovecot.svbin")) {
+ if (file_exists("$sivP/.dovecot.svbin")) {
unlink("$sivP/.dovecot.svbin");
+ }
}
}
}