This commit has been accessed 721 times via Git panel.
commit 46b815abbcd832adc6ecd07c4507df8846be6953
tree 7f580e52129c56467a902dfc86d503c82844acd9
parent 2e27c12f5c88e76d3a7f98d3674c3892351662d0
author Engels Antonio <engels@kartero.org> 1381776189 +0800
committer Engels Antonio <engels@kartero.org> 1381776189 +0800
Add inbox check and drafts support
diff --git a/check.php b/check.php
new file mode 100644
index 0000000..fa3b255
--- /dev/null
+++ b/check.php
@@ -0,0 +1,32 @@
+<?php
+
+session_start();
+
+if (!isset($_SESSION['logged_uid'])) {
+ echo 0;
+ exit;
+}
+
+ob_start();
+
+require_once("conf.php");
+
+ob_end_clean();
+
+$subdir = explode('@', $_SESSION['logged_uid']);
+
+$usrdir = "$mail_root/$subdir[1]/{$subdir[0][0]}/$subdir[0]/new";
+
+if (!file_exists($usrdir)) {
+ echo 0;
+ exit;
+}
+
+if (count(glob("$usrdir/*", GLOB_NOSORT)) > 0) {
+ echo 1;
+}
+else {
+ echo 0;
+}
+
+?>
diff --git a/core.php b/core.php
index 92fa1bc..5bf836c 100644
--- a/core.php
+++ b/core.php
@@ -542,4 +542,95 @@ function kartero_local_storage($element,$storage,$destroy=0) {
}
}
+function pass1_process($mbox, $msgno, $path) {
+
+ $emailMessage = new EmailMessage($mbox, imap_msgno($mbox,$msgno));
+ $emailMessage->fetch();
+
+ if (count($emailMessage->attachments > 0)) {
+
+ if (!file_exists($path)) {
+ mkdir($path,0700,1);
+ }
+
+ foreach ($emailMessage->attachments as $key => $attachment) {
+
+ $fileContent = $attachment[data];
+
+ if (($fileContent != "") and (($attachment[inline] == 1) or ($attachment[filename] == ""))) {
+ $fileName = $key;
+ }
+ else {
+ $fileName = $attachment[filename];
+ }
+
+ $fileName = str_replace(" ", "_", $fileName);
+ $fileName = preg_replace("/[^a-zA-Z0-9.\-_@]/u", "", $fileName);
+
+ if (!file_exists("$path/$fileName") and (mb_strlen($fileContent,"8bit") > 0)) {
+ file_put_contents("$path/$fileName",$fileContent);
+ }
+ }
+ }
+}
+
+function pass2_extract($mbox, $msgno, $p, $partno, $path) {
+ $data = ($partno) ? imap_fetchbody($mbox, $msgno, $partno, FT_UID) : imap_body($mbox, $msgno, FT_UID);
+ if ($p->encoding == 4)
+ $data = quoted_printable_decode($data);
+ else if ($p->encoding == 3)
+ $data = base64_decode($data);
+ $params = array();
+ if ($p->parameters)
+ foreach ($p->parameters as $x)
+ $params[strtolower($x->attribute)] = $x->value;
+ if ($p->dparameters)
+ foreach ($p->dparameters as $x)
+ $params[strtolower($x->attribute)] = $x->value;
+ if ($params['filename'] || $params['name']) {
+ $partid = htmlentities($p->id, ENT_QUOTES, "UTF-8");
+ $filename = ($params['filename']) ? $params['filename'] : $params['name'];
+ $attachments[$filename] = $data;
+ $image[$key] = $filename;
+ }
+ if (count($attachments) > 0) {
+ if (!file_exists($path)) {
+ mkdir($path, 0700, 1);
+ }
+ foreach ($attachments as $key => $val) {
+ $files = glob("$path/*", GLOB_NOSORT);
+ if (count($files) > 0) {
+ $dup = "0";
+ foreach ($files as $file) {
+ if (file_get_contents($file) == $val) {
+ $dup++;
+ }
+ }
+ if (($dup == 0) and (mb_strlen($val,"8bit") > 0)) {
+ file_put_contents("$path/$key", $val);
+ }
+ }
+ else {
+ if (mb_strlen($val,"8bit") > 0) {
+ file_put_contents("$path/$key", $val);
+ }
+ }
+ unset($files);
+ }
+ }
+}
+
+function pass2_process($mbox, $msgno, $path) {
+ $attachments = array();
+ $s = imap_fetchstructure($mbox, $msgno, FT_UID);
+ if (!$s->parts) {
+ pass2_extract($mbox, $msgno, $s, 0, $path);
+ }
+ else {
+ foreach ($s->parts as $partno0 => $p) {
+ pass2_extract($mbox, $msgno, $p, $partno0 + 1, $path);
+ }
+ }
+}
+
?>
diff --git a/css.php b/css.php
index bc9eac2..d4d3826 100644
--- a/css.php
+++ b/css.php
@@ -8,6 +8,8 @@ body {
background: #ffffff;
font-size: 0.75em;
font-family: arial,helvetica,sans-serif;
+ margin-right: 20px;
+ margin-left: 20px;
}
a,a:link,a:visited,a:hover,a:active {
@@ -157,3 +159,12 @@ a,a:link,a:visited,a:hover,a:active {
-webkit-animation-timing-function: ease;
-moz-animation-timing-function: ease;
}
+
+.inboxE:hover, .inboxE:focus,.inboxE:active {
+ background-color: #ffffdd;
+ background-image: -webkit-linear-gradient(bottom, #ffffdd 50%, #ffffcc 100%);
+ background-image: -moz-linear-gradient(bottom, #ffffdd 50%, #ffffcc 100%);
+ background-image: -ms-linear-gradient(bottom, #ffffdd 50%, #ffffcc 100%);
+ background-image: -o-linear-gradient(bottom, #ffffdd 50%, #ffffcc 100%);
+ background-image: linear-gradient(bottom, #ffffdd 50%, #ffffcc 100%);
+}
diff --git a/filedrop.php b/filedrop.php
index 337a331..921a353 100644
--- a/filedrop.php
+++ b/filedrop.php
@@ -57,8 +57,11 @@ if (file_exists("attach/i/$fileUsr/$filedrop_box")) {
$css = str_replace("</style>","",$css);
echo "<style>\r\n$css</style>\r\n\r\n";
- }
+ // compensate for body { margin-right: 20px; margin-left: 20px; } in css.php
+ echo "<style>body { margin-right: 5px; margin-left: 5px; }</style>";
+ }
+
echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\">";
foreach ($fileAttachments as $fileAttachment) {
diff --git a/folders.php b/folders.php
index 25f32c3..192c023 100644
--- a/folders.php
+++ b/folders.php
@@ -85,16 +85,16 @@ if (!isset($_POST['get']) and !isset($_POST['rep'])) {
}
}
-if ($folder == "Trash") {
+if (($folder == "Trash") or ($folder == "Spam")) {
- $trash_status = imap_status($mbox, "{$imap_host}Trash", SA_MESSAGES+SA_UNSEEN);
+ $trash_status = imap_status($mbox, "{$imap_host}$folder", SA_MESSAGES+SA_UNSEEN);
if ($trash_status->messages > 0) {
echo "<form method=\"post\">";
echo "<input type=\"hidden\" name=\"emt\" value=\"1\">";
- echo "<input type=\"hidden\" name=\"box\" value=\"Trash\">";
- echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/trashcan_purge.png\" onclick=\"if (confirm('Delete ALL messages in Trash permanently?')) {return true;} else {return false;}\"></td><td><nobr>Empty Trash</nobr></td></tr>";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/trashcan_purge.png\" onclick=\"if (confirm('Delete ALL messages in $folder permanently?')) {return true;} else {return false;}\"></td><td><nobr>Empty $folder</nobr></td></tr>";
echo "</form>";
}
}
diff --git a/inbox.php b/inbox.php
index 5e2d87e..88bb9b3 100644
--- a/inbox.php
+++ b/inbox.php
@@ -69,13 +69,13 @@ echo "<title>Kartero - $folder ($msgCount) - " . $_SESSION['logged_uid'] . "</ti
echo "\n\n<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\" width=\"100%\">";
-echo "<tr bgcolor=\"#eeeeee\"><td align=\"center\" width=\"32\">";
+echo "<tr bgcolor=\"#eeeeee\"><td align=\"center\" width=\"32\"><nobr>";
if ($folder == "Trash") {
echo "un";
}
-echo "del</td><td align=\"center\" width=\"200\">";
+echo "del</nobr></td><td align=\"center\" style=\"min-width: 200px; width: auto;\">";
if ($folder == "Sent") {
echo "recipient";
@@ -84,7 +84,7 @@ else {
echo "sender";
}
-echo "</td><td align=\"center\" width=\"300\">subject</td><td align=\"center\" width=\"100\">";
+echo "</td><td align=\"center\" style=\"min-width: 300px; width: auto;\">subject</td><td align=\"center\" width=\"100\">";
if ($folder == "Sent") {
echo "sent";
@@ -206,9 +206,9 @@ foreach ($mbox_sort as $mbox_num => $mbox_row) {
$subj = "<b style=\"color: red; text-shadow: 0.1em 0.1em #dedede;\">!</b> $subj";
}
- echo "<tr bgcolor=\"$bgColor\">";
+ echo "<tr class=\"inboxE\" bgcolor=\"$bgColor\">";
- echo "<form method=\"post\"><td>";
+ echo "<form method=\"post\"><td align=\"center\">";
echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
diff --git a/index.php b/index.php
index cef0d9c..7b254cf 100644
--- a/index.php
+++ b/index.php
@@ -213,7 +213,7 @@ if (isset($_SESSION['logged_uid'])) {
echo "<nobr>You are currently logged in to your {$_SESSION['logged_uid']} {$_SESSION['logged_lvl']} account. Click <a href=\"?do=logout\">here</a> to logout.</nobr><br><br>";
- echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
+ echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">";
echo "<tr><td colspan=\"3\" valign=\"top\">";
if ($_SESSION['logged_lvl'] == "subscriber") {
@@ -1075,7 +1075,7 @@ if (isset($_SESSION['logged_uid'])) {
}
}
- echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
+ echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">";
if (isset($_POST['reply_from']) and isset($_POST['reply_to']) and isset($_POST['reply_subj']) and isset($_POST['reply_body']) and !empty($_POST['reply_from']) and !empty($_POST['reply_to']) and !empty($_POST['reply_subj']) and !empty($_POST['reply_body'])) {
@@ -1191,6 +1191,10 @@ if (isset($_SESSION['logged_uid'])) {
imap_createmailbox($mbox,"{$imap_host}Sent");
imap_append($mbox,"{$imap_host}Sent","To: $reply_to\nSubject: $reply_subj\nDate: $reply_date\n$reply_headers\n\n$reply_body\n");
mail($reply_to, $reply_subj, $reply_body, $reply_headers, "-f {$reply_fenv[0]}");
+
+ if ($folder == "Drafts") {
+ imap_delete($mbox, $_POST['msg'], FT_UID);
+ }
}
kartero_local_storage("reply_body",$_SESSION['logged_uid'],1);
@@ -1541,33 +1545,35 @@ echo "</tr>";
echo "<div id=\"filters\" style=\"display: none;\">";
}
- 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 "<option value=\"body\">If message body 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($imap_host,"",$sieveF);
+ if (count($sivR) < 255) {
+ 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 "<option value=\"body\">If message body 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($imap_host,"",$sieveF);
+
+ echo "<option value=\"$sieveF\">then move to $sieveF</option>";
+ }
- echo "<option value=\"$sieveF\">then move to $sieveF</option>";
+ echo "</select></td>";
+ echo "<td><input class=\"button\" type=\"submit\" value=\"add filter\"></td>";
+ echo "</tr></form>";
+ echo "</table>";
+ echo "</div>";
}
- echo "</select></td>";
- echo "<td><input class=\"button\" type=\"submit\" value=\"add filter\"></td>";
- echo "</tr></form>";
- echo "</table>";
- echo "</div>";
-
$sivR = glob("$sivP/*.sieve");
$sivW = 'require "include";';
@@ -1685,13 +1691,14 @@ echo "</tr>";
// imap_ping() should be doing this, but it's not working:
$mbox = @imap_open("{$imap_host}$folder", $_SESSION['logged_uid'], $_SESSION['logged_key'], CL_EXPUNGE) or die(imap_last_error());
- include("inbox.php");
-/*
if ((count($_POST) == 0) or ((count($_POST) == 3) and array_key_exists('x',$_POST) and array_key_exists('y',$_POST) and ($_POST['box'] == "INBOX"))) {
- echo "<script src=\"jquery-1.9.1.min.js\" async></script>";
- echo "<script>setInterval(\"$('#main').load('inbox.php');\", 60000);</script>";
+
+ echo '<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>';
+ echo '<script>window.jQuery||document.write(\'<script src="jquery-2.0.3.min.js"><\/script>\')</script>';
+ echo '<script>idleTime=0;$(document).ready(function(){var idleInterval=setInterval(timerIncrement,1000);$(this).mousemove(function(e){idleTime=0});$(this).keypress(function(e){idleTime=0})});function timerIncrement(){idleTime=idleTime+1;if(idleTime>59){$.ajax({url:"check.php",cache:false}).done(function(delta){if(delta==1){location.replace(document.URL)}});idleTime=0}}</script>';
}
-*/
+
+ include("inbox.php");
}
echo "</div></td>";
diff --git a/pass2.php b/pass2.php
deleted file mode 100644
index 753629a..0000000
--- a/pass2.php
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php
-
-function pass2_extract($mbox, $msgno, $p, $partno, $path) {
- $data = ($partno) ? imap_fetchbody($mbox, $msgno, $partno, FT_UID) : imap_body($mbox, $msgno, FT_UID);
- if ($p->encoding == 4)
- $data = quoted_printable_decode($data);
- else if ($p->encoding == 3)
- $data = base64_decode($data);
- $params = array();
- if ($p->parameters)
- foreach ($p->parameters as $x)
- $params[strtolower($x->attribute)] = $x->value;
- if ($p->dparameters)
- foreach ($p->dparameters as $x)
- $params[strtolower($x->attribute)] = $x->value;
- if ($params['filename'] || $params['name']) {
- $partid = htmlentities($p->id, ENT_QUOTES, "UTF-8");
- $filename = ($params['filename']) ? $params['filename'] : $params['name'];
- $attachments[$filename] = $data;
- $image[$key] = $filename;
- }
- if (count($attachments) > 0) {
- if (!file_exists($path)) {
- mkdir($path, 0700, 1);
- }
- foreach ($attachments as $key => $val) {
- $files = glob("$path/*", GLOB_NOSORT);
- if (count($files) > 0) {
- $dup = "0";
- foreach ($files as $file) {
- if (file_get_contents($file) == $val) {
- $dup++;
- }
- }
- if (($dup == 0) and (mb_strlen($val,"8bit") > 0)) {
- file_put_contents("$path/$key", $val);
- }
- }
- else {
- if (mb_strlen($val,"8bit") > 0) {
- file_put_contents("$path/$key", $val);
- }
- }
- unset($files);
- }
- }
-}
-
-function pass2_process($mbox, $msgno, $path) {
- $attachments = array();
- $s = imap_fetchstructure($mbox, $msgno, FT_UID);
- if (!$s->parts) {
- pass2_extract($mbox, $msgno, $s, 0, $path);
- }
- else {
- foreach ($s->parts as $partno0 => $p) {
- pass2_extract($mbox, $msgno, $p, $partno0 + 1, $path);
- }
- }
-}
-
-pass2_process($mbox, $msgno, $filePath);
-
-?>
\ No newline at end of file
diff --git a/post.php b/post.php
index 89edc41..3056597 100644
--- a/post.php
+++ b/post.php
@@ -63,9 +63,11 @@ if (isset($_POST['new']) and !empty($_POST['new']) and is_numeric($_POST['new'])
echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_rr\"></td><td valign=\"middle\">read receipt</td>";
echo "<td width=\"10\"></td>";
echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_dr\"></td><td valign=\"middle\">delivery receipt</td>";
+ echo "<td width=\"10\"></td>";
+ echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_dm\" id=\"reply_dm\" onclick=\"if (this.checked) { document.getElementById('reply_go').innerHTML='save'; } else { document.getElementById('reply_go').innerHTML='send'; }\"></td><td valign=\"middle\">draft</td>";
echo "</tr></table>";
- echo "</td><td align=\"right\"><div class=\"label\"><input type=\"image\" src=\"images/mail-reply.png\" onclick=\"if (confirm('Send message?')) {return true;} else {return false;}\"></div><div class=\"label\">send</div></td></tr>";
+ echo "</td><td align=\"right\"><div class=\"label\"><input type=\"image\" src=\"images/mail-reply.png\" onclick=\"if (document.getElementById('reply_dm').checked) { if (confirm('Save message?')) {return true;} else {return false;}} else { if (confirm('Send message?')) {return true;} else {return false;}}\"></div><div class=\"label\" id=\"reply_go\">send</div></td></tr>";
echo "</table>";
diff --git a/read.php b/read.php
index b80da8a..0835b98 100644
--- a/read.php
+++ b/read.php
@@ -223,57 +223,60 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<td width=\"5\"></td>";
- echo "<form method=\"post\"><td class=\"label\">";
- echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
- echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
- echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
- echo "<input type=\"hidden\" name=\"rep\" value=\"4\">";
-
- if (isset($_POST['imap_search_query']) and !empty($_POST['imap_search_query']) and isset($_POST['imap_search_where']) and !empty($_POST['imap_search_where'])) {
- echo "<input type=\"hidden\" name=\"imap_search_query\" value=\"{$_POST['imap_search_query']}\">";
- echo "<input type=\"hidden\" name=\"imap_search_where\" value=\"{$_POST['imap_search_where']}\">";
- }
-
- echo "<input type=\"image\" src=\"images/mail-redirect.png\">";
- echo "</td></form>";
-
- echo "<td width=\"5\"></td>";
-
- echo "<form method=\"post\"><td class=\"label\">";
- echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
- echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
- echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
- echo "<input type=\"hidden\" name=\"rep\" value=\"2\">";
-
- if (isset($_POST['imap_search_query']) and !empty($_POST['imap_search_query']) and isset($_POST['imap_search_where']) and !empty($_POST['imap_search_where'])) {
- echo "<input type=\"hidden\" name=\"imap_search_query\" value=\"{$_POST['imap_search_query']}\">";
- echo "<input type=\"hidden\" name=\"imap_search_where\" value=\"{$_POST['imap_search_where']}\">";
- }
-
- echo "<input type=\"image\" src=\"images/mail-forward.png\">";
- echo "</td></form>";
-
- echo "<td width=\"5\"></td>";
-
- if (strpos($header->toaddress,",")) {
-
+ if ($folder != "Drafts") {
+
+ echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
+ echo "<input type=\"hidden\" name=\"rep\" value=\"4\">";
+
+ if (isset($_POST['imap_search_query']) and !empty($_POST['imap_search_query']) and isset($_POST['imap_search_where']) and !empty($_POST['imap_search_where'])) {
+ echo "<input type=\"hidden\" name=\"imap_search_query\" value=\"{$_POST['imap_search_query']}\">";
+ echo "<input type=\"hidden\" name=\"imap_search_where\" value=\"{$_POST['imap_search_where']}\">";
+ }
+
+ echo "<input type=\"image\" src=\"images/mail-redirect.png\">";
+ echo "</td></form>";
+
+ echo "<td width=\"5\"></td>";
+
echo "<form method=\"post\"><td class=\"label\">";
echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
- echo "<input type=\"hidden\" name=\"rep\" value=\"3\">";
-
+ echo "<input type=\"hidden\" name=\"rep\" value=\"2\">";
+
if (isset($_POST['imap_search_query']) and !empty($_POST['imap_search_query']) and isset($_POST['imap_search_where']) and !empty($_POST['imap_search_where'])) {
echo "<input type=\"hidden\" name=\"imap_search_query\" value=\"{$_POST['imap_search_query']}\">";
echo "<input type=\"hidden\" name=\"imap_search_where\" value=\"{$_POST['imap_search_where']}\">";
}
-
- echo "<input type=\"image\" src=\"images/mail-reply-all.png\">";
+
+ echo "<input type=\"image\" src=\"images/mail-forward.png\">";
echo "</td></form>";
-
+
echo "<td width=\"5\"></td>";
- }
+ if (strpos($header->toaddress,",")) {
+
+ echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
+ echo "<input type=\"hidden\" name=\"rep\" value=\"3\">";
+
+ if (isset($_POST['imap_search_query']) and !empty($_POST['imap_search_query']) and isset($_POST['imap_search_where']) and !empty($_POST['imap_search_where'])) {
+ echo "<input type=\"hidden\" name=\"imap_search_query\" value=\"{$_POST['imap_search_query']}\">";
+ echo "<input type=\"hidden\" name=\"imap_search_where\" value=\"{$_POST['imap_search_where']}\">";
+ }
+
+ echo "<input type=\"image\" src=\"images/mail-reply-all.png\">";
+ echo "</td></form>";
+
+ echo "<td width=\"5\"></td>";
+ }
+ }
+
echo "<form method=\"post\"><td class=\"label\">";
echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
@@ -336,20 +339,27 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<td class=\"label\">unread</td>";
echo "<td width=\"5\"></td>";
- echo "<td class=\"label\">redirect</td>";
- echo "<td width=\"5\"></td>";
-
- echo "<td class=\"label\">forward</td>";
- echo "<td width=\"5\"></td>";
-
- if (strpos($header->toaddress,",")) {
- echo "<td class=\"label\"><nobr>reply all</nobr></td>";
+ if ($folder != "Drafts") {
+ echo "<td class=\"label\">redirect</td>";
+ echo "<td width=\"5\"></td>";
+
+ echo "<td class=\"label\">forward</td>";
echo "<td width=\"5\"></td>";
}
-
- echo "<td class=\"label\">reply</td>";
- echo "<td width=\"5\"></td>";
-
+
+ if ($folder == "Drafts") {
+ echo "<td class=\"label\">edit</td>";
+ echo "<td width=\"5\"></td>";
+ }
+ else {
+ if (strpos($header->toaddress,",")) {
+ echo "<td class=\"label\"><nobr>reply all</nobr></td>";
+ echo "<td width=\"5\"></td>";
+ }
+ echo "<td class=\"label\">reply</td>";
+ echo "<td width=\"5\"></td>";
+ }
+
if ($msgno_next != "") {
echo "<td class=\"label\"><nobr>prev msg</nobr></td>";
echo "<td width=\"5\"></td>";
@@ -367,7 +377,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$usr_mbox = kartero_sort_folders($imap_host,imap_list($mbox,$imap_host,"*"));
- if ((count($usr_mbox) > 0) and ($folder != "Sent") and ($folder != "Trash")) {
+ if ((count($usr_mbox) > 0) and ($folder != "Drafts") and ($folder != "Sent") and ($folder != "Trash")) {
echo "<div class=\"message\">";
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
@@ -392,6 +402,10 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
continue;
}
+ if ($move_box == "Drafts") {
+ continue;
+ }
+
if ($move_box == "Sent") {
continue;
}
@@ -415,36 +429,8 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$filePath = "attach/o/$fileUsr/$fileDir";
- $emailMessage = new EmailMessage($mbox, imap_msgno($mbox,$msgno));
- $emailMessage->fetch();
-
- if (count($emailMessage->attachments > 0)) {
-
- if (!file_exists($filePath)) {
- mkdir($filePath,0700,1);
- }
-
- foreach ($emailMessage->attachments as $key => $attachment) {
-
- $fileContent = $attachment[data];
-
- if (($fileContent != "") and (($attachment[inline] == 1) or ($attachment[filename] == ""))) {
- $fileName = $key;
- }
- else {
- $fileName = $attachment[filename];
- }
-
- $fileName = str_replace(" ", "_", $fileName);
- $fileName = preg_replace("/[^a-zA-Z0-9.\-_@]/u", "", $fileName);
-
- if (!file_exists("$filePath/$fileName") and (mb_strlen($fileContent,"8bit") > 0)) {
- file_put_contents("$filePath/$fileName",$fileContent);
- }
- }
- }
-
- include("pass2.php");
+ pass1_process($mbox, $msgno, $filePath);
+ pass2_process($mbox, $msgno, $filePath);
$bodyTEXT = get_part($mbox, $msgno, "TEXT/PLAIN");
$bodyHTML = get_part($mbox, $msgno, "TEXT/HTML");
@@ -571,7 +557,7 @@ if (isset($header_rr) and (strlen($header_rr) > 0)) {
$header_ov = imap_fetch_overview($mbox,$msgno,FT_UID);
- if ((strlen($rcpt_mail) > 0) and ($folder != "Sent") and ($folder != "Trash") and ($folder != "Spam") and ($folder != "Junk") and ($header_ov[0]->answered == "0")) {
+ if ((strlen($rcpt_mail) > 0) and ($folder != "Drafts") and ($folder != "Sent") and ($folder != "Trash") and ($folder != "Spam") and ($folder != "Junk") and ($header_ov[0]->answered == "0")) {
$header_message_id = imap_utf8($header->message_id);
@@ -589,5 +575,5 @@ if (isset($header_rr) and (strlen($header_rr) > 0)) {
echo "<script>if (confirm('The message sender has requested a response to indicate that you have read this message.\\nWould you like to send a receipt?')) { document.getElementById('receipt').submit(); }</script>";
}
}
-
-?>
\ No newline at end of file
+
+?>
diff --git a/send.php b/send.php
index 474ea5f..4f45b66 100644
--- a/send.php
+++ b/send.php
@@ -19,9 +19,10 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$header_ccaddress = imap_utf8($header->ccaddress);
$reply_quote = trim(get_part($mbox, $msgno, "TEXT/PLAIN"));
+ $reply_quote = mb_convert_encoding($reply_quote,"UTF-8");
if ($_POST['rep'] != 2) {
- $reply_quote = wordwrap($reply_quote,75,"\r\n");
+ $reply_quote = wordwrap($reply_quote,75,"\n");
}
$reply_quote_lines = explode("\n",$reply_quote);
@@ -33,21 +34,26 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$reply_quote_rows = count($reply_quote_lines) + 1;
}
- $reply_from = "$usr_name <{$_SESSION['logged_uid']}>";
-
- $reply_to = imap_utf8($header->reply_toaddress);
-
- if ($reply_to != "") {
+ if ($folder != "Drafts") {
+ $reply_from = "$usr_name <{$_SESSION['logged_uid']}>";
+
$reply_to = imap_utf8($header->reply_toaddress);
+
+ if ($reply_to != "") {
+ $reply_to = imap_utf8($header->reply_toaddress);
+ }
+ else {
+ $reply_to = imap_utf8($header->fromaddress);
+ }
+
+ if (($_POST['rep'] == 3) and strpos(imap_utf8($header->toaddress),",")) {
+ $reply_to = $reply_to . ", " . imap_utf8($header->toaddress);
+ }
}
else {
- $reply_to = imap_utf8($header->fromaddress);
- }
-
- if (($_POST['rep'] == 3) and strpos(imap_utf8($header->toaddress),",")) {
-
- $reply_to = $reply_to . ", " . imap_utf8($header->toaddress);
- }
+ $reply_from = imap_utf8($header->fromaddress);
+ $reply_to = imap_utf8($header->toaddress);
+ }
if (($_POST['rep'] == 2) or ($_POST['rep'] == 4)) {
@@ -62,23 +68,22 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$reply_subject = str_replace("FWD: ","Fwd: ",$reply_subject);
$reply_subject = str_replace("RE: ","Re: ",$reply_subject);
- if (($_POST['rep'] == 2) or ($_POST['rep'] == 4)) {
-
- $redirect_from = htmlentities($reply_to,ENT_QUOTES,"UTF-8");
-
- $reply_to = "";
-
- if ($_POST['rep'] == 2) {
- $reply_subject = "Fwd: " . $reply_subject;
+ if ($folder != "Drafts") {
+ if (($_POST['rep'] == 2) or ($_POST['rep'] == 4)) {
+
+ $redirect_from = htmlentities($reply_to,ENT_QUOTES,"UTF-8");
+
+ $reply_to = "";
+
+ if ($_POST['rep'] == 2) {
+ $reply_subject = "Fwd: " . $reply_subject;
+ }
+ }
+ else {
+ $reply_subject = "Re: " . $reply_subject;
}
-
-
- }
- else {
- $reply_subject = "Re: " . $reply_subject;
-
}
-
+
if (substr_count($reply_subject, "Fwd: ") > 1) {
while (substr_count($reply_subject, "Fwd: ") > 1) {
@@ -107,7 +112,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$header_fetch = imap_fetchheader($mbox,$msgno,FT_UID);
- $header_raw_lines = explode("\r\n",$header_fetch);
+ $header_raw_lines = explode("\n",$header_fetch);
foreach ($header_raw_lines as $header_raw_line) {
@@ -189,8 +194,15 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<tr><td><b>To:</b></td><td colspan=\"2\"><input required class=\"input\" type=\"text\" name=\"reply_to\" value=\"$reply_to\" required></td></tr>";
echo "<tr><td><b>Cc:</b></td><td colspan=\"2\"><input class=\"input\" type=\"text\" name=\"reply_cc\" value=\"$reply_cc\"></td></tr>";
- echo "<tr><td><b>Bcc:</b></td><td colspan=\"2\"><input class=\"input\" type=\"text\" name=\"reply_bcc\"></td></tr>";
+ if ($folder != "Drafts") {
+ echo "<tr><td><b>Bcc:</b></td><td colspan=\"2\"><input class=\"input\" type=\"text\" name=\"reply_bcc\"></td></tr>";
+ }
+ else {
+ $reply_bcc = imap_utf8($header->bccaddress);
+ echo "<tr><td><b>Bcc:</b></td><td colspan=\"2\"><input class=\"input\" type=\"text\" name=\"reply_bcc\" value=\"$reply_bcc\"></td></tr>";
+ }
+
echo "<tr><td><b>Subject:</b></td><td colspan=\"2\"><input required class=\"input\" type=\"text\" name=\"reply_subj\" value=\"$reply_subject\" required";
if ($_POST['rep'] == 4) {
@@ -210,23 +222,24 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
if (($_POST['rep'] == 2) or ($_POST['rep'] == 4)) {
if ($_POST['rep'] == 2) {
- echo "---------------------------------------- Begin Forwarded Message ----------------------------------------\r\n";
- echo "From: $header_fromaddress\r\n";
- echo "To: $header_toaddress\r\n";
+ echo "---------------------------------------- Begin Forwarded Message ----------------------------------------\n";
+ echo "From: $header_fromaddress\n";
+ echo "To: $header_toaddress\n";
if (strlen($header_ccaddress) != 0) {
- echo "Cc: $header_ccaddress\r\n";
+ echo "Cc: $header_ccaddress\n";
}
- echo "Date: $header_date\r\n";
- echo "Subject: $header_subject\r\n\r\n";
+ echo "Date: $header_date\n";
+ echo "Subject: $header_subject\n\n";
}
echo $reply_quote;
}
else {
+ if ($folder != "Drafts") {
$reply_personal = imap_utf8($header->fromaddress);
- echo "On $header_date, $reply_personal wrote:\r\n";
+ echo "On $header_date, $reply_personal wrote:";
foreach ($reply_quote_lines as $reply_quote_line) {
@@ -234,7 +247,11 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$reply_quote_line = preg_replace("/(^> >)/",">>",$reply_quote_line);
$reply_quote_line = preg_replace("/(^>> >)/",">>>",$reply_quote_line);
- echo $reply_quote_line;
+ echo "\n$reply_quote_line";
+ }
+ }
+ else {
+ echo $reply_quote;
}
}
@@ -253,17 +270,86 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<tr><td></td><td>";
if ($_POST['rep'] != 4) {
+
+ if ($folder == "Drafts") {
+
+ $header_fetch = imap_utf8(imap_fetchheader($mbox,$msgno,FT_UID|FT_PREFETCHTEXT));
+
+ $header_raw_lines = explode("\n",$header_fetch);
- echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>";
- echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_hi\"></td><td valign=\"middle\">high priority</td>";
- echo "<td width=\"10\"></td>";
- echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_rr\"></td><td valign=\"middle\">read receipt</td>";
- echo "<td width=\"10\"></td>";
- echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_dr\"></td><td valign=\"middle\">delivery receipt</td>";
- echo "</tr></table>";
+ foreach ($header_raw_lines as $header_raw_line) {
+
+ if (strstr($header_raw_line,"X-Priority: 1")) {
+ $header_priority = $header_raw_line;
+ }
+
+ if (strstr($header_raw_line,"Importance: High")) {
+ $header_priority = $header_raw_line;
+ }
+
+ if (strstr($header_raw_line,"X-Confirm-Reading-To:")) {
+ $header_rr = $header_raw_line;
+ }
+
+ if (strstr($header_raw_line,"Disposition-Notification-To:")) {
+ $header_rr = $header_raw_line;
+ }
+
+ if (strstr($header_raw_line,"Return-Receipt-To:")) {
+ $header_dr = $header_raw_line;
+ }
+ }
+
+ echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>";
+
+ if ($header_priority != "") {
+ echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_hi\" checked></td><td valign=\"middle\">high priority</td>";
+ }
+ else {
+ echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_hi\"></td><td valign=\"middle\">high priority</td>";
+ }
+
+ echo "<td width=\"10\"></td>";
+
+ if ($header_rr != "") {
+ echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_rr\" checked></td><td valign=\"middle\">read receipt</td>";
+ }
+ else {
+ echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_rr\"></td><td valign=\"middle\">read receipt</td>";
+ }
+
+ echo "<td width=\"10\"></td>";
+
+ if ($header_dr != "") {
+ echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_dr\" checked></td><td valign=\"middle\">delivery receipt</td>";
+ }
+ else {
+ echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_dr\"></td><td valign=\"middle\">delivery receipt</td>";
+ }
+
+ echo "<td width=\"10\"></td>";
+ echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_dm\" id=\"reply_dm\" onclick=\"if (this.checked) { document.getElementById('reply_go').innerHTML='save'; } else { document.getElementById('reply_go').innerHTML='send'; }\"></td><td valign=\"middle\">draft</td>";
+ echo "</tr></table>";
+ }
+ else {
+ echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>";
+ echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_hi\"></td><td valign=\"middle\">high priority</td>";
+ echo "<td width=\"10\"></td>";
+ echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_rr\"></td><td valign=\"middle\">read receipt</td>";
+ echo "<td width=\"10\"></td>";
+ echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_dr\"></td><td valign=\"middle\">delivery receipt</td>";
+ echo "<td width=\"10\"></td>";
+ echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_dm\" id=\"reply_dm\" onclick=\"if (this.checked) { document.getElementById('reply_go').innerHTML='save'; } else { document.getElementById('reply_go').innerHTML='send'; }\"></td><td valign=\"middle\">draft</td>";
+ echo "</tr></table>";
+ }
}
- echo "</td><td align=\"right\"><div class=\"label\"><input type=\"image\" src=\"images/mail-reply.png\" onclick=\"if (confirm('Send message?')) {return true;} else {return false;}\"></div><div class=\"label\">send</div></td></tr>";
+ if ($_POST['rep'] != 4) {
+ echo "</td><td align=\"right\"><div class=\"label\"><input type=\"image\" src=\"images/mail-reply.png\" onclick=\"if (document.getElementById('reply_dm').checked) { if (confirm('Save message?')) {return true;} else {return false;}} else { if (confirm('Send message?')) {return true;} else {return false;}}\"></div><div class=\"label\" id=\"reply_go\">send</div></td></tr>";
+ }
+ else {
+ echo "</td><td align=\"right\"><div class=\"label\"><input type=\"image\" src=\"images/mail-reply.png\" onclick=\"if (confirm('Send message?')) {return true;} else {return false;}\"></div><div class=\"label\" id=\"reply_go\">send</div></td></tr>";
+ }
echo "</table>";
@@ -275,6 +361,11 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
if ($_POST['rep'] != 4) {
+ if ($folder == "Drafts") {
+ pass1_process($mbox, $msgno, "attach/i/$fileUsr/$filedrop_box");
+ pass2_process($mbox, $msgno, "attach/i/$fileUsr/$filedrop_box");
+ }
+
?>
<div class="message">
tree 7f580e52129c56467a902dfc86d503c82844acd9
parent 2e27c12f5c88e76d3a7f98d3674c3892351662d0
author Engels Antonio <engels@kartero.org> 1381776189 +0800
committer Engels Antonio <engels@kartero.org> 1381776189 +0800
Add inbox check and drafts support
diff --git a/check.php b/check.php
new file mode 100644
index 0000000..fa3b255
--- /dev/null
+++ b/check.php
@@ -0,0 +1,32 @@
+<?php
+
+session_start();
+
+if (!isset($_SESSION['logged_uid'])) {
+ echo 0;
+ exit;
+}
+
+ob_start();
+
+require_once("conf.php");
+
+ob_end_clean();
+
+$subdir = explode('@', $_SESSION['logged_uid']);
+
+$usrdir = "$mail_root/$subdir[1]/{$subdir[0][0]}/$subdir[0]/new";
+
+if (!file_exists($usrdir)) {
+ echo 0;
+ exit;
+}
+
+if (count(glob("$usrdir/*", GLOB_NOSORT)) > 0) {
+ echo 1;
+}
+else {
+ echo 0;
+}
+
+?>
diff --git a/core.php b/core.php
index 92fa1bc..5bf836c 100644
--- a/core.php
+++ b/core.php
@@ -542,4 +542,95 @@ function kartero_local_storage($element,$storage,$destroy=0) {
}
}
+function pass1_process($mbox, $msgno, $path) {
+
+ $emailMessage = new EmailMessage($mbox, imap_msgno($mbox,$msgno));
+ $emailMessage->fetch();
+
+ if (count($emailMessage->attachments > 0)) {
+
+ if (!file_exists($path)) {
+ mkdir($path,0700,1);
+ }
+
+ foreach ($emailMessage->attachments as $key => $attachment) {
+
+ $fileContent = $attachment[data];
+
+ if (($fileContent != "") and (($attachment[inline] == 1) or ($attachment[filename] == ""))) {
+ $fileName = $key;
+ }
+ else {
+ $fileName = $attachment[filename];
+ }
+
+ $fileName = str_replace(" ", "_", $fileName);
+ $fileName = preg_replace("/[^a-zA-Z0-9.\-_@]/u", "", $fileName);
+
+ if (!file_exists("$path/$fileName") and (mb_strlen($fileContent,"8bit") > 0)) {
+ file_put_contents("$path/$fileName",$fileContent);
+ }
+ }
+ }
+}
+
+function pass2_extract($mbox, $msgno, $p, $partno, $path) {
+ $data = ($partno) ? imap_fetchbody($mbox, $msgno, $partno, FT_UID) : imap_body($mbox, $msgno, FT_UID);
+ if ($p->encoding == 4)
+ $data = quoted_printable_decode($data);
+ else if ($p->encoding == 3)
+ $data = base64_decode($data);
+ $params = array();
+ if ($p->parameters)
+ foreach ($p->parameters as $x)
+ $params[strtolower($x->attribute)] = $x->value;
+ if ($p->dparameters)
+ foreach ($p->dparameters as $x)
+ $params[strtolower($x->attribute)] = $x->value;
+ if ($params['filename'] || $params['name']) {
+ $partid = htmlentities($p->id, ENT_QUOTES, "UTF-8");
+ $filename = ($params['filename']) ? $params['filename'] : $params['name'];
+ $attachments[$filename] = $data;
+ $image[$key] = $filename;
+ }
+ if (count($attachments) > 0) {
+ if (!file_exists($path)) {
+ mkdir($path, 0700, 1);
+ }
+ foreach ($attachments as $key => $val) {
+ $files = glob("$path/*", GLOB_NOSORT);
+ if (count($files) > 0) {
+ $dup = "0";
+ foreach ($files as $file) {
+ if (file_get_contents($file) == $val) {
+ $dup++;
+ }
+ }
+ if (($dup == 0) and (mb_strlen($val,"8bit") > 0)) {
+ file_put_contents("$path/$key", $val);
+ }
+ }
+ else {
+ if (mb_strlen($val,"8bit") > 0) {
+ file_put_contents("$path/$key", $val);
+ }
+ }
+ unset($files);
+ }
+ }
+}
+
+function pass2_process($mbox, $msgno, $path) {
+ $attachments = array();
+ $s = imap_fetchstructure($mbox, $msgno, FT_UID);
+ if (!$s->parts) {
+ pass2_extract($mbox, $msgno, $s, 0, $path);
+ }
+ else {
+ foreach ($s->parts as $partno0 => $p) {
+ pass2_extract($mbox, $msgno, $p, $partno0 + 1, $path);
+ }
+ }
+}
+
?>
diff --git a/css.php b/css.php
index bc9eac2..d4d3826 100644
--- a/css.php
+++ b/css.php
@@ -8,6 +8,8 @@ body {
background: #ffffff;
font-size: 0.75em;
font-family: arial,helvetica,sans-serif;
+ margin-right: 20px;
+ margin-left: 20px;
}
a,a:link,a:visited,a:hover,a:active {
@@ -157,3 +159,12 @@ a,a:link,a:visited,a:hover,a:active {
-webkit-animation-timing-function: ease;
-moz-animation-timing-function: ease;
}
+
+.inboxE:hover, .inboxE:focus,.inboxE:active {
+ background-color: #ffffdd;
+ background-image: -webkit-linear-gradient(bottom, #ffffdd 50%, #ffffcc 100%);
+ background-image: -moz-linear-gradient(bottom, #ffffdd 50%, #ffffcc 100%);
+ background-image: -ms-linear-gradient(bottom, #ffffdd 50%, #ffffcc 100%);
+ background-image: -o-linear-gradient(bottom, #ffffdd 50%, #ffffcc 100%);
+ background-image: linear-gradient(bottom, #ffffdd 50%, #ffffcc 100%);
+}
diff --git a/filedrop.php b/filedrop.php
index 337a331..921a353 100644
--- a/filedrop.php
+++ b/filedrop.php
@@ -57,8 +57,11 @@ if (file_exists("attach/i/$fileUsr/$filedrop_box")) {
$css = str_replace("</style>","",$css);
echo "<style>\r\n$css</style>\r\n\r\n";
- }
+ // compensate for body { margin-right: 20px; margin-left: 20px; } in css.php
+ echo "<style>body { margin-right: 5px; margin-left: 5px; }</style>";
+ }
+
echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\">";
foreach ($fileAttachments as $fileAttachment) {
diff --git a/folders.php b/folders.php
index 25f32c3..192c023 100644
--- a/folders.php
+++ b/folders.php
@@ -85,16 +85,16 @@ if (!isset($_POST['get']) and !isset($_POST['rep'])) {
}
}
-if ($folder == "Trash") {
+if (($folder == "Trash") or ($folder == "Spam")) {
- $trash_status = imap_status($mbox, "{$imap_host}Trash", SA_MESSAGES+SA_UNSEEN);
+ $trash_status = imap_status($mbox, "{$imap_host}$folder", SA_MESSAGES+SA_UNSEEN);
if ($trash_status->messages > 0) {
echo "<form method=\"post\">";
echo "<input type=\"hidden\" name=\"emt\" value=\"1\">";
- echo "<input type=\"hidden\" name=\"box\" value=\"Trash\">";
- echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/trashcan_purge.png\" onclick=\"if (confirm('Delete ALL messages in Trash permanently?')) {return true;} else {return false;}\"></td><td><nobr>Empty Trash</nobr></td></tr>";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/trashcan_purge.png\" onclick=\"if (confirm('Delete ALL messages in $folder permanently?')) {return true;} else {return false;}\"></td><td><nobr>Empty $folder</nobr></td></tr>";
echo "</form>";
}
}
diff --git a/inbox.php b/inbox.php
index 5e2d87e..88bb9b3 100644
--- a/inbox.php
+++ b/inbox.php
@@ -69,13 +69,13 @@ echo "<title>Kartero - $folder ($msgCount) - " . $_SESSION['logged_uid'] . "</ti
echo "\n\n<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\" width=\"100%\">";
-echo "<tr bgcolor=\"#eeeeee\"><td align=\"center\" width=\"32\">";
+echo "<tr bgcolor=\"#eeeeee\"><td align=\"center\" width=\"32\"><nobr>";
if ($folder == "Trash") {
echo "un";
}
-echo "del</td><td align=\"center\" width=\"200\">";
+echo "del</nobr></td><td align=\"center\" style=\"min-width: 200px; width: auto;\">";
if ($folder == "Sent") {
echo "recipient";
@@ -84,7 +84,7 @@ else {
echo "sender";
}
-echo "</td><td align=\"center\" width=\"300\">subject</td><td align=\"center\" width=\"100\">";
+echo "</td><td align=\"center\" style=\"min-width: 300px; width: auto;\">subject</td><td align=\"center\" width=\"100\">";
if ($folder == "Sent") {
echo "sent";
@@ -206,9 +206,9 @@ foreach ($mbox_sort as $mbox_num => $mbox_row) {
$subj = "<b style=\"color: red; text-shadow: 0.1em 0.1em #dedede;\">!</b> $subj";
}
- echo "<tr bgcolor=\"$bgColor\">";
+ echo "<tr class=\"inboxE\" bgcolor=\"$bgColor\">";
- echo "<form method=\"post\"><td>";
+ echo "<form method=\"post\"><td align=\"center\">";
echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
diff --git a/index.php b/index.php
index cef0d9c..7b254cf 100644
--- a/index.php
+++ b/index.php
@@ -213,7 +213,7 @@ if (isset($_SESSION['logged_uid'])) {
echo "<nobr>You are currently logged in to your {$_SESSION['logged_uid']} {$_SESSION['logged_lvl']} account. Click <a href=\"?do=logout\">here</a> to logout.</nobr><br><br>";
- echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
+ echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">";
echo "<tr><td colspan=\"3\" valign=\"top\">";
if ($_SESSION['logged_lvl'] == "subscriber") {
@@ -1075,7 +1075,7 @@ if (isset($_SESSION['logged_uid'])) {
}
}
- echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
+ echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">";
if (isset($_POST['reply_from']) and isset($_POST['reply_to']) and isset($_POST['reply_subj']) and isset($_POST['reply_body']) and !empty($_POST['reply_from']) and !empty($_POST['reply_to']) and !empty($_POST['reply_subj']) and !empty($_POST['reply_body'])) {
@@ -1191,6 +1191,10 @@ if (isset($_SESSION['logged_uid'])) {
imap_createmailbox($mbox,"{$imap_host}Sent");
imap_append($mbox,"{$imap_host}Sent","To: $reply_to\nSubject: $reply_subj\nDate: $reply_date\n$reply_headers\n\n$reply_body\n");
mail($reply_to, $reply_subj, $reply_body, $reply_headers, "-f {$reply_fenv[0]}");
+
+ if ($folder == "Drafts") {
+ imap_delete($mbox, $_POST['msg'], FT_UID);
+ }
}
kartero_local_storage("reply_body",$_SESSION['logged_uid'],1);
@@ -1541,33 +1545,35 @@ echo "</tr>";
echo "<div id=\"filters\" style=\"display: none;\">";
}
- 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 "<option value=\"body\">If message body 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($imap_host,"",$sieveF);
+ if (count($sivR) < 255) {
+ 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 "<option value=\"body\">If message body 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($imap_host,"",$sieveF);
+
+ echo "<option value=\"$sieveF\">then move to $sieveF</option>";
+ }
- echo "<option value=\"$sieveF\">then move to $sieveF</option>";
+ echo "</select></td>";
+ echo "<td><input class=\"button\" type=\"submit\" value=\"add filter\"></td>";
+ echo "</tr></form>";
+ echo "</table>";
+ echo "</div>";
}
- echo "</select></td>";
- echo "<td><input class=\"button\" type=\"submit\" value=\"add filter\"></td>";
- echo "</tr></form>";
- echo "</table>";
- echo "</div>";
-
$sivR = glob("$sivP/*.sieve");
$sivW = 'require "include";';
@@ -1685,13 +1691,14 @@ echo "</tr>";
// imap_ping() should be doing this, but it's not working:
$mbox = @imap_open("{$imap_host}$folder", $_SESSION['logged_uid'], $_SESSION['logged_key'], CL_EXPUNGE) or die(imap_last_error());
- include("inbox.php");
-/*
if ((count($_POST) == 0) or ((count($_POST) == 3) and array_key_exists('x',$_POST) and array_key_exists('y',$_POST) and ($_POST['box'] == "INBOX"))) {
- echo "<script src=\"jquery-1.9.1.min.js\" async></script>";
- echo "<script>setInterval(\"$('#main').load('inbox.php');\", 60000);</script>";
+
+ echo '<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>';
+ echo '<script>window.jQuery||document.write(\'<script src="jquery-2.0.3.min.js"><\/script>\')</script>';
+ echo '<script>idleTime=0;$(document).ready(function(){var idleInterval=setInterval(timerIncrement,1000);$(this).mousemove(function(e){idleTime=0});$(this).keypress(function(e){idleTime=0})});function timerIncrement(){idleTime=idleTime+1;if(idleTime>59){$.ajax({url:"check.php",cache:false}).done(function(delta){if(delta==1){location.replace(document.URL)}});idleTime=0}}</script>';
}
-*/
+
+ include("inbox.php");
}
echo "</div></td>";
diff --git a/pass2.php b/pass2.php
deleted file mode 100644
index 753629a..0000000
--- a/pass2.php
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php
-
-function pass2_extract($mbox, $msgno, $p, $partno, $path) {
- $data = ($partno) ? imap_fetchbody($mbox, $msgno, $partno, FT_UID) : imap_body($mbox, $msgno, FT_UID);
- if ($p->encoding == 4)
- $data = quoted_printable_decode($data);
- else if ($p->encoding == 3)
- $data = base64_decode($data);
- $params = array();
- if ($p->parameters)
- foreach ($p->parameters as $x)
- $params[strtolower($x->attribute)] = $x->value;
- if ($p->dparameters)
- foreach ($p->dparameters as $x)
- $params[strtolower($x->attribute)] = $x->value;
- if ($params['filename'] || $params['name']) {
- $partid = htmlentities($p->id, ENT_QUOTES, "UTF-8");
- $filename = ($params['filename']) ? $params['filename'] : $params['name'];
- $attachments[$filename] = $data;
- $image[$key] = $filename;
- }
- if (count($attachments) > 0) {
- if (!file_exists($path)) {
- mkdir($path, 0700, 1);
- }
- foreach ($attachments as $key => $val) {
- $files = glob("$path/*", GLOB_NOSORT);
- if (count($files) > 0) {
- $dup = "0";
- foreach ($files as $file) {
- if (file_get_contents($file) == $val) {
- $dup++;
- }
- }
- if (($dup == 0) and (mb_strlen($val,"8bit") > 0)) {
- file_put_contents("$path/$key", $val);
- }
- }
- else {
- if (mb_strlen($val,"8bit") > 0) {
- file_put_contents("$path/$key", $val);
- }
- }
- unset($files);
- }
- }
-}
-
-function pass2_process($mbox, $msgno, $path) {
- $attachments = array();
- $s = imap_fetchstructure($mbox, $msgno, FT_UID);
- if (!$s->parts) {
- pass2_extract($mbox, $msgno, $s, 0, $path);
- }
- else {
- foreach ($s->parts as $partno0 => $p) {
- pass2_extract($mbox, $msgno, $p, $partno0 + 1, $path);
- }
- }
-}
-
-pass2_process($mbox, $msgno, $filePath);
-
-?>
\ No newline at end of file
diff --git a/post.php b/post.php
index 89edc41..3056597 100644
--- a/post.php
+++ b/post.php
@@ -63,9 +63,11 @@ if (isset($_POST['new']) and !empty($_POST['new']) and is_numeric($_POST['new'])
echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_rr\"></td><td valign=\"middle\">read receipt</td>";
echo "<td width=\"10\"></td>";
echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_dr\"></td><td valign=\"middle\">delivery receipt</td>";
+ echo "<td width=\"10\"></td>";
+ echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_dm\" id=\"reply_dm\" onclick=\"if (this.checked) { document.getElementById('reply_go').innerHTML='save'; } else { document.getElementById('reply_go').innerHTML='send'; }\"></td><td valign=\"middle\">draft</td>";
echo "</tr></table>";
- echo "</td><td align=\"right\"><div class=\"label\"><input type=\"image\" src=\"images/mail-reply.png\" onclick=\"if (confirm('Send message?')) {return true;} else {return false;}\"></div><div class=\"label\">send</div></td></tr>";
+ echo "</td><td align=\"right\"><div class=\"label\"><input type=\"image\" src=\"images/mail-reply.png\" onclick=\"if (document.getElementById('reply_dm').checked) { if (confirm('Save message?')) {return true;} else {return false;}} else { if (confirm('Send message?')) {return true;} else {return false;}}\"></div><div class=\"label\" id=\"reply_go\">send</div></td></tr>";
echo "</table>";
diff --git a/read.php b/read.php
index b80da8a..0835b98 100644
--- a/read.php
+++ b/read.php
@@ -223,57 +223,60 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<td width=\"5\"></td>";
- echo "<form method=\"post\"><td class=\"label\">";
- echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
- echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
- echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
- echo "<input type=\"hidden\" name=\"rep\" value=\"4\">";
-
- if (isset($_POST['imap_search_query']) and !empty($_POST['imap_search_query']) and isset($_POST['imap_search_where']) and !empty($_POST['imap_search_where'])) {
- echo "<input type=\"hidden\" name=\"imap_search_query\" value=\"{$_POST['imap_search_query']}\">";
- echo "<input type=\"hidden\" name=\"imap_search_where\" value=\"{$_POST['imap_search_where']}\">";
- }
-
- echo "<input type=\"image\" src=\"images/mail-redirect.png\">";
- echo "</td></form>";
-
- echo "<td width=\"5\"></td>";
-
- echo "<form method=\"post\"><td class=\"label\">";
- echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
- echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
- echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
- echo "<input type=\"hidden\" name=\"rep\" value=\"2\">";
-
- if (isset($_POST['imap_search_query']) and !empty($_POST['imap_search_query']) and isset($_POST['imap_search_where']) and !empty($_POST['imap_search_where'])) {
- echo "<input type=\"hidden\" name=\"imap_search_query\" value=\"{$_POST['imap_search_query']}\">";
- echo "<input type=\"hidden\" name=\"imap_search_where\" value=\"{$_POST['imap_search_where']}\">";
- }
-
- echo "<input type=\"image\" src=\"images/mail-forward.png\">";
- echo "</td></form>";
-
- echo "<td width=\"5\"></td>";
-
- if (strpos($header->toaddress,",")) {
-
+ if ($folder != "Drafts") {
+
+ echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
+ echo "<input type=\"hidden\" name=\"rep\" value=\"4\">";
+
+ if (isset($_POST['imap_search_query']) and !empty($_POST['imap_search_query']) and isset($_POST['imap_search_where']) and !empty($_POST['imap_search_where'])) {
+ echo "<input type=\"hidden\" name=\"imap_search_query\" value=\"{$_POST['imap_search_query']}\">";
+ echo "<input type=\"hidden\" name=\"imap_search_where\" value=\"{$_POST['imap_search_where']}\">";
+ }
+
+ echo "<input type=\"image\" src=\"images/mail-redirect.png\">";
+ echo "</td></form>";
+
+ echo "<td width=\"5\"></td>";
+
echo "<form method=\"post\"><td class=\"label\">";
echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
- echo "<input type=\"hidden\" name=\"rep\" value=\"3\">";
-
+ echo "<input type=\"hidden\" name=\"rep\" value=\"2\">";
+
if (isset($_POST['imap_search_query']) and !empty($_POST['imap_search_query']) and isset($_POST['imap_search_where']) and !empty($_POST['imap_search_where'])) {
echo "<input type=\"hidden\" name=\"imap_search_query\" value=\"{$_POST['imap_search_query']}\">";
echo "<input type=\"hidden\" name=\"imap_search_where\" value=\"{$_POST['imap_search_where']}\">";
}
-
- echo "<input type=\"image\" src=\"images/mail-reply-all.png\">";
+
+ echo "<input type=\"image\" src=\"images/mail-forward.png\">";
echo "</td></form>";
-
+
echo "<td width=\"5\"></td>";
- }
+ if (strpos($header->toaddress,",")) {
+
+ echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
+ echo "<input type=\"hidden\" name=\"rep\" value=\"3\">";
+
+ if (isset($_POST['imap_search_query']) and !empty($_POST['imap_search_query']) and isset($_POST['imap_search_where']) and !empty($_POST['imap_search_where'])) {
+ echo "<input type=\"hidden\" name=\"imap_search_query\" value=\"{$_POST['imap_search_query']}\">";
+ echo "<input type=\"hidden\" name=\"imap_search_where\" value=\"{$_POST['imap_search_where']}\">";
+ }
+
+ echo "<input type=\"image\" src=\"images/mail-reply-all.png\">";
+ echo "</td></form>";
+
+ echo "<td width=\"5\"></td>";
+ }
+ }
+
echo "<form method=\"post\"><td class=\"label\">";
echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
@@ -336,20 +339,27 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<td class=\"label\">unread</td>";
echo "<td width=\"5\"></td>";
- echo "<td class=\"label\">redirect</td>";
- echo "<td width=\"5\"></td>";
-
- echo "<td class=\"label\">forward</td>";
- echo "<td width=\"5\"></td>";
-
- if (strpos($header->toaddress,",")) {
- echo "<td class=\"label\"><nobr>reply all</nobr></td>";
+ if ($folder != "Drafts") {
+ echo "<td class=\"label\">redirect</td>";
+ echo "<td width=\"5\"></td>";
+
+ echo "<td class=\"label\">forward</td>";
echo "<td width=\"5\"></td>";
}
-
- echo "<td class=\"label\">reply</td>";
- echo "<td width=\"5\"></td>";
-
+
+ if ($folder == "Drafts") {
+ echo "<td class=\"label\">edit</td>";
+ echo "<td width=\"5\"></td>";
+ }
+ else {
+ if (strpos($header->toaddress,",")) {
+ echo "<td class=\"label\"><nobr>reply all</nobr></td>";
+ echo "<td width=\"5\"></td>";
+ }
+ echo "<td class=\"label\">reply</td>";
+ echo "<td width=\"5\"></td>";
+ }
+
if ($msgno_next != "") {
echo "<td class=\"label\"><nobr>prev msg</nobr></td>";
echo "<td width=\"5\"></td>";
@@ -367,7 +377,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$usr_mbox = kartero_sort_folders($imap_host,imap_list($mbox,$imap_host,"*"));
- if ((count($usr_mbox) > 0) and ($folder != "Sent") and ($folder != "Trash")) {
+ if ((count($usr_mbox) > 0) and ($folder != "Drafts") and ($folder != "Sent") and ($folder != "Trash")) {
echo "<div class=\"message\">";
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
@@ -392,6 +402,10 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
continue;
}
+ if ($move_box == "Drafts") {
+ continue;
+ }
+
if ($move_box == "Sent") {
continue;
}
@@ -415,36 +429,8 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$filePath = "attach/o/$fileUsr/$fileDir";
- $emailMessage = new EmailMessage($mbox, imap_msgno($mbox,$msgno));
- $emailMessage->fetch();
-
- if (count($emailMessage->attachments > 0)) {
-
- if (!file_exists($filePath)) {
- mkdir($filePath,0700,1);
- }
-
- foreach ($emailMessage->attachments as $key => $attachment) {
-
- $fileContent = $attachment[data];
-
- if (($fileContent != "") and (($attachment[inline] == 1) or ($attachment[filename] == ""))) {
- $fileName = $key;
- }
- else {
- $fileName = $attachment[filename];
- }
-
- $fileName = str_replace(" ", "_", $fileName);
- $fileName = preg_replace("/[^a-zA-Z0-9.\-_@]/u", "", $fileName);
-
- if (!file_exists("$filePath/$fileName") and (mb_strlen($fileContent,"8bit") > 0)) {
- file_put_contents("$filePath/$fileName",$fileContent);
- }
- }
- }
-
- include("pass2.php");
+ pass1_process($mbox, $msgno, $filePath);
+ pass2_process($mbox, $msgno, $filePath);
$bodyTEXT = get_part($mbox, $msgno, "TEXT/PLAIN");
$bodyHTML = get_part($mbox, $msgno, "TEXT/HTML");
@@ -571,7 +557,7 @@ if (isset($header_rr) and (strlen($header_rr) > 0)) {
$header_ov = imap_fetch_overview($mbox,$msgno,FT_UID);
- if ((strlen($rcpt_mail) > 0) and ($folder != "Sent") and ($folder != "Trash") and ($folder != "Spam") and ($folder != "Junk") and ($header_ov[0]->answered == "0")) {
+ if ((strlen($rcpt_mail) > 0) and ($folder != "Drafts") and ($folder != "Sent") and ($folder != "Trash") and ($folder != "Spam") and ($folder != "Junk") and ($header_ov[0]->answered == "0")) {
$header_message_id = imap_utf8($header->message_id);
@@ -589,5 +575,5 @@ if (isset($header_rr) and (strlen($header_rr) > 0)) {
echo "<script>if (confirm('The message sender has requested a response to indicate that you have read this message.\\nWould you like to send a receipt?')) { document.getElementById('receipt').submit(); }</script>";
}
}
-
-?>
\ No newline at end of file
+
+?>
diff --git a/send.php b/send.php
index 474ea5f..4f45b66 100644
--- a/send.php
+++ b/send.php
@@ -19,9 +19,10 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$header_ccaddress = imap_utf8($header->ccaddress);
$reply_quote = trim(get_part($mbox, $msgno, "TEXT/PLAIN"));
+ $reply_quote = mb_convert_encoding($reply_quote,"UTF-8");
if ($_POST['rep'] != 2) {
- $reply_quote = wordwrap($reply_quote,75,"\r\n");
+ $reply_quote = wordwrap($reply_quote,75,"\n");
}
$reply_quote_lines = explode("\n",$reply_quote);
@@ -33,21 +34,26 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$reply_quote_rows = count($reply_quote_lines) + 1;
}
- $reply_from = "$usr_name <{$_SESSION['logged_uid']}>";
-
- $reply_to = imap_utf8($header->reply_toaddress);
-
- if ($reply_to != "") {
+ if ($folder != "Drafts") {
+ $reply_from = "$usr_name <{$_SESSION['logged_uid']}>";
+
$reply_to = imap_utf8($header->reply_toaddress);
+
+ if ($reply_to != "") {
+ $reply_to = imap_utf8($header->reply_toaddress);
+ }
+ else {
+ $reply_to = imap_utf8($header->fromaddress);
+ }
+
+ if (($_POST['rep'] == 3) and strpos(imap_utf8($header->toaddress),",")) {
+ $reply_to = $reply_to . ", " . imap_utf8($header->toaddress);
+ }
}
else {
- $reply_to = imap_utf8($header->fromaddress);
- }
-
- if (($_POST['rep'] == 3) and strpos(imap_utf8($header->toaddress),",")) {
-
- $reply_to = $reply_to . ", " . imap_utf8($header->toaddress);
- }
+ $reply_from = imap_utf8($header->fromaddress);
+ $reply_to = imap_utf8($header->toaddress);
+ }
if (($_POST['rep'] == 2) or ($_POST['rep'] == 4)) {
@@ -62,23 +68,22 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$reply_subject = str_replace("FWD: ","Fwd: ",$reply_subject);
$reply_subject = str_replace("RE: ","Re: ",$reply_subject);
- if (($_POST['rep'] == 2) or ($_POST['rep'] == 4)) {
-
- $redirect_from = htmlentities($reply_to,ENT_QUOTES,"UTF-8");
-
- $reply_to = "";
-
- if ($_POST['rep'] == 2) {
- $reply_subject = "Fwd: " . $reply_subject;
+ if ($folder != "Drafts") {
+ if (($_POST['rep'] == 2) or ($_POST['rep'] == 4)) {
+
+ $redirect_from = htmlentities($reply_to,ENT_QUOTES,"UTF-8");
+
+ $reply_to = "";
+
+ if ($_POST['rep'] == 2) {
+ $reply_subject = "Fwd: " . $reply_subject;
+ }
+ }
+ else {
+ $reply_subject = "Re: " . $reply_subject;
}
-
-
- }
- else {
- $reply_subject = "Re: " . $reply_subject;
-
}
-
+
if (substr_count($reply_subject, "Fwd: ") > 1) {
while (substr_count($reply_subject, "Fwd: ") > 1) {
@@ -107,7 +112,7 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$header_fetch = imap_fetchheader($mbox,$msgno,FT_UID);
- $header_raw_lines = explode("\r\n",$header_fetch);
+ $header_raw_lines = explode("\n",$header_fetch);
foreach ($header_raw_lines as $header_raw_line) {
@@ -189,8 +194,15 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<tr><td><b>To:</b></td><td colspan=\"2\"><input required class=\"input\" type=\"text\" name=\"reply_to\" value=\"$reply_to\" required></td></tr>";
echo "<tr><td><b>Cc:</b></td><td colspan=\"2\"><input class=\"input\" type=\"text\" name=\"reply_cc\" value=\"$reply_cc\"></td></tr>";
- echo "<tr><td><b>Bcc:</b></td><td colspan=\"2\"><input class=\"input\" type=\"text\" name=\"reply_bcc\"></td></tr>";
+ if ($folder != "Drafts") {
+ echo "<tr><td><b>Bcc:</b></td><td colspan=\"2\"><input class=\"input\" type=\"text\" name=\"reply_bcc\"></td></tr>";
+ }
+ else {
+ $reply_bcc = imap_utf8($header->bccaddress);
+ echo "<tr><td><b>Bcc:</b></td><td colspan=\"2\"><input class=\"input\" type=\"text\" name=\"reply_bcc\" value=\"$reply_bcc\"></td></tr>";
+ }
+
echo "<tr><td><b>Subject:</b></td><td colspan=\"2\"><input required class=\"input\" type=\"text\" name=\"reply_subj\" value=\"$reply_subject\" required";
if ($_POST['rep'] == 4) {
@@ -210,23 +222,24 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
if (($_POST['rep'] == 2) or ($_POST['rep'] == 4)) {
if ($_POST['rep'] == 2) {
- echo "---------------------------------------- Begin Forwarded Message ----------------------------------------\r\n";
- echo "From: $header_fromaddress\r\n";
- echo "To: $header_toaddress\r\n";
+ echo "---------------------------------------- Begin Forwarded Message ----------------------------------------\n";
+ echo "From: $header_fromaddress\n";
+ echo "To: $header_toaddress\n";
if (strlen($header_ccaddress) != 0) {
- echo "Cc: $header_ccaddress\r\n";
+ echo "Cc: $header_ccaddress\n";
}
- echo "Date: $header_date\r\n";
- echo "Subject: $header_subject\r\n\r\n";
+ echo "Date: $header_date\n";
+ echo "Subject: $header_subject\n\n";
}
echo $reply_quote;
}
else {
+ if ($folder != "Drafts") {
$reply_personal = imap_utf8($header->fromaddress);
- echo "On $header_date, $reply_personal wrote:\r\n";
+ echo "On $header_date, $reply_personal wrote:";
foreach ($reply_quote_lines as $reply_quote_line) {
@@ -234,7 +247,11 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$reply_quote_line = preg_replace("/(^> >)/",">>",$reply_quote_line);
$reply_quote_line = preg_replace("/(^>> >)/",">>>",$reply_quote_line);
- echo $reply_quote_line;
+ echo "\n$reply_quote_line";
+ }
+ }
+ else {
+ echo $reply_quote;
}
}
@@ -253,17 +270,86 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<tr><td></td><td>";
if ($_POST['rep'] != 4) {
+
+ if ($folder == "Drafts") {
+
+ $header_fetch = imap_utf8(imap_fetchheader($mbox,$msgno,FT_UID|FT_PREFETCHTEXT));
+
+ $header_raw_lines = explode("\n",$header_fetch);
- echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>";
- echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_hi\"></td><td valign=\"middle\">high priority</td>";
- echo "<td width=\"10\"></td>";
- echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_rr\"></td><td valign=\"middle\">read receipt</td>";
- echo "<td width=\"10\"></td>";
- echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_dr\"></td><td valign=\"middle\">delivery receipt</td>";
- echo "</tr></table>";
+ foreach ($header_raw_lines as $header_raw_line) {
+
+ if (strstr($header_raw_line,"X-Priority: 1")) {
+ $header_priority = $header_raw_line;
+ }
+
+ if (strstr($header_raw_line,"Importance: High")) {
+ $header_priority = $header_raw_line;
+ }
+
+ if (strstr($header_raw_line,"X-Confirm-Reading-To:")) {
+ $header_rr = $header_raw_line;
+ }
+
+ if (strstr($header_raw_line,"Disposition-Notification-To:")) {
+ $header_rr = $header_raw_line;
+ }
+
+ if (strstr($header_raw_line,"Return-Receipt-To:")) {
+ $header_dr = $header_raw_line;
+ }
+ }
+
+ echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>";
+
+ if ($header_priority != "") {
+ echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_hi\" checked></td><td valign=\"middle\">high priority</td>";
+ }
+ else {
+ echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_hi\"></td><td valign=\"middle\">high priority</td>";
+ }
+
+ echo "<td width=\"10\"></td>";
+
+ if ($header_rr != "") {
+ echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_rr\" checked></td><td valign=\"middle\">read receipt</td>";
+ }
+ else {
+ echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_rr\"></td><td valign=\"middle\">read receipt</td>";
+ }
+
+ echo "<td width=\"10\"></td>";
+
+ if ($header_dr != "") {
+ echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_dr\" checked></td><td valign=\"middle\">delivery receipt</td>";
+ }
+ else {
+ echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_dr\"></td><td valign=\"middle\">delivery receipt</td>";
+ }
+
+ echo "<td width=\"10\"></td>";
+ echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_dm\" id=\"reply_dm\" onclick=\"if (this.checked) { document.getElementById('reply_go').innerHTML='save'; } else { document.getElementById('reply_go').innerHTML='send'; }\"></td><td valign=\"middle\">draft</td>";
+ echo "</tr></table>";
+ }
+ else {
+ echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>";
+ echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_hi\"></td><td valign=\"middle\">high priority</td>";
+ echo "<td width=\"10\"></td>";
+ echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_rr\"></td><td valign=\"middle\">read receipt</td>";
+ echo "<td width=\"10\"></td>";
+ echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_dr\"></td><td valign=\"middle\">delivery receipt</td>";
+ echo "<td width=\"10\"></td>";
+ echo "<td valign=\"middle\"><input type=\"checkbox\" name=\"reply_dm\" id=\"reply_dm\" onclick=\"if (this.checked) { document.getElementById('reply_go').innerHTML='save'; } else { document.getElementById('reply_go').innerHTML='send'; }\"></td><td valign=\"middle\">draft</td>";
+ echo "</tr></table>";
+ }
}
- echo "</td><td align=\"right\"><div class=\"label\"><input type=\"image\" src=\"images/mail-reply.png\" onclick=\"if (confirm('Send message?')) {return true;} else {return false;}\"></div><div class=\"label\">send</div></td></tr>";
+ if ($_POST['rep'] != 4) {
+ echo "</td><td align=\"right\"><div class=\"label\"><input type=\"image\" src=\"images/mail-reply.png\" onclick=\"if (document.getElementById('reply_dm').checked) { if (confirm('Save message?')) {return true;} else {return false;}} else { if (confirm('Send message?')) {return true;} else {return false;}}\"></div><div class=\"label\" id=\"reply_go\">send</div></td></tr>";
+ }
+ else {
+ echo "</td><td align=\"right\"><div class=\"label\"><input type=\"image\" src=\"images/mail-reply.png\" onclick=\"if (confirm('Send message?')) {return true;} else {return false;}\"></div><div class=\"label\" id=\"reply_go\">send</div></td></tr>";
+ }
echo "</table>";
@@ -275,6 +361,11 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
if ($_POST['rep'] != 4) {
+ if ($folder == "Drafts") {
+ pass1_process($mbox, $msgno, "attach/i/$fileUsr/$filedrop_box");
+ pass2_process($mbox, $msgno, "attach/i/$fileUsr/$filedrop_box");
+ }
+
?>
<div class="message">