This commit has been accessed 543 times via Git panel.
commit b8112b2c9a8285a66ce9277bfa30db223149b96a
tree 0bc16f511aa563acec1c6cd358b1023dbcbf7be6
parent ca95a2490c38ae1b18f66486432be48f639d05c4
author Engels Antonio <engels@majcms.org> 1301074233 +0800
committer Engels Antonio <engels@majcms.org> 1301074233 +0800
Add search based on From, To, Cc, Subject and text/body
diff --git a/folders.php b/folders.php
index 09c36ac..799ac24 100644
--- a/folders.php
+++ b/folders.php
@@ -11,6 +11,7 @@ $conn = '{127.0.0.1:143/imap/notls/norsh}';
$mbox = imap_open($conn, $_SESSION['logged_uid'], $_SESSION['logged_key'], OP_HALFOPEN) or die("can't connect: " . imap_last_error());
echo "<div class=\"folders\"><table border=\"0\" cellspacing=\"1\" callpadding=\"2\">";
+
echo "<form method=\"post\">";
echo "<input type=\"hidden\" name=\"new\" value=\"1\">";
echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-new.png\"></td><td>Compose</td></tr>";
@@ -24,6 +25,12 @@ if (!isset($_POST['get']) and !isset($_POST['rep'])) {
echo "<form method=\"post\">";
echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_prev\">";
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+
+ 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 "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-next.png\"></td><td>Prev $mbox_ppg Msgs</td></tr>";
echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-next.png\"></td><td>Prev</td></tr>";
echo "</form>";
@@ -40,6 +47,12 @@ if (!isset($_POST['get']) and !isset($_POST['rep'])) {
echo "<form method=\"post\">";
echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_next\">";
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+
+ 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 "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-prev.png\"></td><td>Next $mbox_ppg Msgs</td></tr>";
echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-prev.png\"></td><td>Next</td></tr>";
echo "</form>";
@@ -64,6 +77,18 @@ echo "</table></div>";
echo "<div style=\"height: 4px;\"></div>";
+echo "<div class=\"folders\"><table border=\"0\" cellspacing=\"0\" callpadding=\"0\">";
+
+echo "<form method=\"post\">";
+echo "<input type=\"hidden\" name=\"dig\" value=\"1\">";
+echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-search.png\"></td><td>Search</td></tr>";
+echo "</form>";
+
+echo "</table></div>";
+
+echo "<div style=\"height: 4px;\"></div>";
+
$folders = imap_list($mbox, $conn, "*");
if (is_array($folders)) {
diff --git a/images/mail-search.png b/images/mail-search.png
new file mode 100644
index 0000000..166ce5e
Binary files /dev/null and b/images/mail-search.png differ
diff --git a/inbox.php b/inbox.php
index c4b19ed..78b77ac 100644
--- a/inbox.php
+++ b/inbox.php
@@ -50,7 +50,25 @@ else {
imap_headers($mbox);
-$mbox_sort = imap_sort($mbox,"SORTARRIVAL",1);
+
+if (isset($_POST['imap_search_query']) and !empty($_POST['imap_search_query']) and isset($_POST['imap_search_where']) and !empty($_POST['imap_search_where'])) {
+
+ $imap_search_query = $_POST['imap_search_query'];
+ $imap_search_where = $_POST['imap_search_where'];
+ $imap_search_criteria = $imap_search_where . ' "'. $imap_search_query . '"';
+ $mbox_sort = imap_search($mbox,$imap_search_criteria);
+
+ if ($mbox_sort) {
+ $msgCount = count($mbox_sort);
+ }
+ else {
+ $msgCount = 0;
+ }
+}
+else {
+ $mbox_sort = imap_sort($mbox,"SORTARRIVAL",1);
+}
+
/*
$mail_images = glob("images/mail*");
@@ -165,6 +183,13 @@ foreach ($mbox_sort as $mbox_num => $mbox_row) {
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
+
+ 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']}\">";
+ }
+
+
if ($folder == "Trash") {
echo "<input type=\"hidden\" name=\"del\" value=\"0\">";
echo "<input type=\"image\" src=\"images/trashcan_full.png\">";
@@ -188,6 +213,14 @@ foreach ($mbox_sort as $mbox_num => $mbox_row) {
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
echo "<input type=\"hidden\" name=\"get\" value=\"1\">";
+
+
+ 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/$status_img\"></td></form>";
echo "</tr>\n";
diff --git a/index.php b/index.php
index 07a08ef..51e4695 100644
--- a/index.php
+++ b/index.php
@@ -880,6 +880,9 @@ if (isset($_SESSION['logged_uid'])) {
elseif (isset($_POST['new']) and !empty($_POST['new'])) {
include("post.php");
}
+ elseif (isset($_POST['dig']) and !empty($_POST['dig'])) {
+ include("search.php");
+ }
else {
include("inbox.php");
diff --git a/post.php b/post.php
index 81072d5..eb1bba3 100644
--- a/post.php
+++ b/post.php
@@ -55,7 +55,7 @@ if (isset($_POST['new']) and !empty($_POST['new']) and is_numeric($_POST['new'])
echo "<input type=\"hidden\" name=\"filedrop_box\" value=\"$filedrop_box\">";
- echo "<tr><td></td><td align=\"right\"><div class=\"label\"><input type=\"image\" src=\"images/mail-reply.png\"></div><div class=\"label\">send</div></td></tr>";
+ echo "<tr><td></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 "</table>";
diff --git a/read.php b/read.php
index 4668c1f..3920ac5 100644
--- a/read.php
+++ b/read.php
@@ -57,7 +57,23 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
}
}
- $mbox_sort = imap_sort($mbox,"SORTARRIVAL",1);
+ if (isset($_POST['imap_search_query']) and !empty($_POST['imap_search_query']) and isset($_POST['imap_search_where']) and !empty($_POST['imap_search_where'])) {
+
+ $imap_search_query = $_POST['imap_search_query'];
+ $imap_search_where = $_POST['imap_search_where'];
+ $imap_search_criteria = $imap_search_where . ' "'. $imap_search_query . '"';
+ $mbox_sort = imap_search($mbox,$imap_search_criteria);
+
+ if ($mbox_sort) {
+ $msgCount = count($mbox_sort);
+ }
+ else {
+ $msgCount = 0;
+ }
+ }
+ else {
+ $mbox_sort = imap_sort($mbox,"SORTARRIVAL",1);
+ }
$mbox_row = array_search($msgno, $mbox_sort);
@@ -106,6 +122,11 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
+ 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']}\">";
+ }
+
if ($folder == "Trash") {
echo "<input type=\"hidden\" name=\"del\" value=\"0\">";
echo "<input type=\"image\" src=\"images/trashcan_full.png\">";
@@ -124,6 +145,12 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
echo "<input type=\"hidden\" name=\"not\" value=\"1\">";
+
+ 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-unread.png\">";
echo "</td></form>";
@@ -134,6 +161,12 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
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>";
@@ -146,6 +179,12 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
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>";
@@ -157,6 +196,12 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
echo "<input type=\"hidden\" name=\"rep\" value=\"1\">";
+
+ 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.png\">";
echo "</td></form>";
@@ -167,6 +212,12 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno_next\">";
echo "<input type=\"hidden\" name=\"get\" value=\"1\">";
+
+ 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-next.png\">";
echo "</td></form>";
@@ -178,6 +229,12 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno_prev\">";
echo "<input type=\"hidden\" name=\"get\" value=\"1\">";
+
+ 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-prev.png\">";
echo "</td></form>";
}
@@ -250,12 +307,22 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$struct = imap_fetchstructure($mbox, $msgno);
+//print_r($struct->parts);
+
+/*
+foreach ($struct->parts as $structP) {
+ $structP2 = $structP->parts;
+ echo "<br>";
+ print_r($structP2);
+ echo "<br><br>";
+}
+*/
$contentParts = count($struct->parts);
for ($n = 0; $n <= $contentParts; $n++) {
$contentPart = imap_bodystruct($mbox,$msgno,$n);
-
+
if (($contentPart->disposition == "attachment") or ($contentPart->disposition == "inline")) {
if ($contentPart->bytes > 0) {
diff --git a/search.php b/search.php
new file mode 100644
index 0000000..43b264f
--- /dev/null
+++ b/search.php
@@ -0,0 +1,79 @@
+<?php
+
+session_start();
+
+if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset($_SESSION['logged_key']) or ($_SESSION['logged_lvl'] != "subscriber")) {
+ exit;
+}
+
+if (!isset($_POST['box']) or empty($_POST['box'])) {
+ $folder = "INBOX";
+}
+else {
+ $folder = trim(strip_tags($_POST['box']));
+}
+
+$conn = '{127.0.0.1:143/imap/notls/norsh}';
+
+$mbox = imap_open($conn, $_SESSION['logged_uid'], $_SESSION['logged_key'], OP_HALFOPEN) or die("can't connect: " . imap_last_error());
+
+$search_folders = imap_list($mbox,$conn,"*");
+
+if (is_array($search_folders)) {
+
+ reset($search_folders);
+ sort($search_folders);
+
+ echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"><tr>";
+
+ echo "<form method=\"post\">";
+ echo "<td><select class=\"input\" name=\"box\">";
+
+ foreach ($search_folders as $search_folder) {
+
+ $search_folder = str_replace($conn,"",$search_folder);
+
+ if ($folder == $search_folder) {
+ echo "<option selected>$search_folder</option>";
+ }
+ else {
+ echo "<option>$search_folder</option>";
+ }
+ }
+
+ echo "</select></td>";
+
+ echo "<td width=\"2\"></td>";
+
+ echo "<td><select class=\"input\" name=\"imap_search_where\">";
+ echo "<option value=\"FROM\">From:</option>";
+
+ if (strtolower($folder) == strtolower("Sent")) {
+ echo "<option value=\"TO\" selected>To:</option>";
+ }
+ else {
+ echo "<option value=\"TO\">To:</option>";
+ }
+
+ echo "<option value=\"CC\">Cc:</option>";
+ echo "<option value=\"SUBJECT\">Subject</option>";
+ echo "<option value=\"TEXT\">Text</option>";
+ echo "<option value=\"BODY\">Body</option>";
+ echo "</select></td>";
+
+ echo "<td width=\"2\"></td>";
+
+ echo "<td><input type=\"text\" class=\"input\" name=\"imap_search_query\"></td>";
+
+ echo "<td width=\"2\"></td>";
+
+ echo "<td width=\"40\"><input type=\"submit\" value=\"search\"></td>";
+ echo "</form>";
+
+ echo "</tr></table>";
+
+}
+
+imap_close($mbox);
+
+?>
diff --git a/send.php b/send.php
index 8bc6d87..5934b1a 100644
--- a/send.php
+++ b/send.php
@@ -31,7 +31,11 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$header_toaddress = $header->toaddress;
$header_ccaddress = $header->ccaddress;
- $reply_quote = wordwrap(trim(get_part($mbox, $msgno, "TEXT/PLAIN")),75,"\r\n");
+ $reply_quote = trim(get_part($mbox, $msgno, "TEXT/PLAIN"));
+
+ if ($_POST['rep'] != 2) {
+ $reply_quote = wordwrap($reply_quote,75,"\r\n");
+ }
$reply_quote_lines = explode("\n",$reply_quote);
@@ -204,7 +208,12 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
echo "<input type=\"hidden\" name=\"filedrop_box\" value=\"$filedrop_box\">";
- echo "<tr><td></td><td align=\"right\"><div class=\"label\"><input type=\"image\" src=\"images/mail-reply.png\"></div><div class=\"label\">send</div></td></tr>";
+ 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 "<tr><td></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 "</table>";
tree 0bc16f511aa563acec1c6cd358b1023dbcbf7be6
parent ca95a2490c38ae1b18f66486432be48f639d05c4
author Engels Antonio <engels@majcms.org> 1301074233 +0800
committer Engels Antonio <engels@majcms.org> 1301074233 +0800
Add search based on From, To, Cc, Subject and text/body
diff --git a/folders.php b/folders.php
index 09c36ac..799ac24 100644
--- a/folders.php
+++ b/folders.php
@@ -11,6 +11,7 @@ $conn = '{127.0.0.1:143/imap/notls/norsh}';
$mbox = imap_open($conn, $_SESSION['logged_uid'], $_SESSION['logged_key'], OP_HALFOPEN) or die("can't connect: " . imap_last_error());
echo "<div class=\"folders\"><table border=\"0\" cellspacing=\"1\" callpadding=\"2\">";
+
echo "<form method=\"post\">";
echo "<input type=\"hidden\" name=\"new\" value=\"1\">";
echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-new.png\"></td><td>Compose</td></tr>";
@@ -24,6 +25,12 @@ if (!isset($_POST['get']) and !isset($_POST['rep'])) {
echo "<form method=\"post\">";
echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_prev\">";
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+
+ 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 "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-next.png\"></td><td>Prev $mbox_ppg Msgs</td></tr>";
echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-next.png\"></td><td>Prev</td></tr>";
echo "</form>";
@@ -40,6 +47,12 @@ if (!isset($_POST['get']) and !isset($_POST['rep'])) {
echo "<form method=\"post\">";
echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_next\">";
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+
+ 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 "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-prev.png\"></td><td>Next $mbox_ppg Msgs</td></tr>";
echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-prev.png\"></td><td>Next</td></tr>";
echo "</form>";
@@ -64,6 +77,18 @@ echo "</table></div>";
echo "<div style=\"height: 4px;\"></div>";
+echo "<div class=\"folders\"><table border=\"0\" cellspacing=\"0\" callpadding=\"0\">";
+
+echo "<form method=\"post\">";
+echo "<input type=\"hidden\" name=\"dig\" value=\"1\">";
+echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-search.png\"></td><td>Search</td></tr>";
+echo "</form>";
+
+echo "</table></div>";
+
+echo "<div style=\"height: 4px;\"></div>";
+
$folders = imap_list($mbox, $conn, "*");
if (is_array($folders)) {
diff --git a/images/mail-search.png b/images/mail-search.png
new file mode 100644
index 0000000..166ce5e
Binary files /dev/null and b/images/mail-search.png differ
diff --git a/inbox.php b/inbox.php
index c4b19ed..78b77ac 100644
--- a/inbox.php
+++ b/inbox.php
@@ -50,7 +50,25 @@ else {
imap_headers($mbox);
-$mbox_sort = imap_sort($mbox,"SORTARRIVAL",1);
+
+if (isset($_POST['imap_search_query']) and !empty($_POST['imap_search_query']) and isset($_POST['imap_search_where']) and !empty($_POST['imap_search_where'])) {
+
+ $imap_search_query = $_POST['imap_search_query'];
+ $imap_search_where = $_POST['imap_search_where'];
+ $imap_search_criteria = $imap_search_where . ' "'. $imap_search_query . '"';
+ $mbox_sort = imap_search($mbox,$imap_search_criteria);
+
+ if ($mbox_sort) {
+ $msgCount = count($mbox_sort);
+ }
+ else {
+ $msgCount = 0;
+ }
+}
+else {
+ $mbox_sort = imap_sort($mbox,"SORTARRIVAL",1);
+}
+
/*
$mail_images = glob("images/mail*");
@@ -165,6 +183,13 @@ foreach ($mbox_sort as $mbox_num => $mbox_row) {
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
+
+ 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']}\">";
+ }
+
+
if ($folder == "Trash") {
echo "<input type=\"hidden\" name=\"del\" value=\"0\">";
echo "<input type=\"image\" src=\"images/trashcan_full.png\">";
@@ -188,6 +213,14 @@ foreach ($mbox_sort as $mbox_num => $mbox_row) {
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
echo "<input type=\"hidden\" name=\"get\" value=\"1\">";
+
+
+ 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/$status_img\"></td></form>";
echo "</tr>\n";
diff --git a/index.php b/index.php
index 07a08ef..51e4695 100644
--- a/index.php
+++ b/index.php
@@ -880,6 +880,9 @@ if (isset($_SESSION['logged_uid'])) {
elseif (isset($_POST['new']) and !empty($_POST['new'])) {
include("post.php");
}
+ elseif (isset($_POST['dig']) and !empty($_POST['dig'])) {
+ include("search.php");
+ }
else {
include("inbox.php");
diff --git a/post.php b/post.php
index 81072d5..eb1bba3 100644
--- a/post.php
+++ b/post.php
@@ -55,7 +55,7 @@ if (isset($_POST['new']) and !empty($_POST['new']) and is_numeric($_POST['new'])
echo "<input type=\"hidden\" name=\"filedrop_box\" value=\"$filedrop_box\">";
- echo "<tr><td></td><td align=\"right\"><div class=\"label\"><input type=\"image\" src=\"images/mail-reply.png\"></div><div class=\"label\">send</div></td></tr>";
+ echo "<tr><td></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 "</table>";
diff --git a/read.php b/read.php
index 4668c1f..3920ac5 100644
--- a/read.php
+++ b/read.php
@@ -57,7 +57,23 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
}
}
- $mbox_sort = imap_sort($mbox,"SORTARRIVAL",1);
+ if (isset($_POST['imap_search_query']) and !empty($_POST['imap_search_query']) and isset($_POST['imap_search_where']) and !empty($_POST['imap_search_where'])) {
+
+ $imap_search_query = $_POST['imap_search_query'];
+ $imap_search_where = $_POST['imap_search_where'];
+ $imap_search_criteria = $imap_search_where . ' "'. $imap_search_query . '"';
+ $mbox_sort = imap_search($mbox,$imap_search_criteria);
+
+ if ($mbox_sort) {
+ $msgCount = count($mbox_sort);
+ }
+ else {
+ $msgCount = 0;
+ }
+ }
+ else {
+ $mbox_sort = imap_sort($mbox,"SORTARRIVAL",1);
+ }
$mbox_row = array_search($msgno, $mbox_sort);
@@ -106,6 +122,11 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
+ 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']}\">";
+ }
+
if ($folder == "Trash") {
echo "<input type=\"hidden\" name=\"del\" value=\"0\">";
echo "<input type=\"image\" src=\"images/trashcan_full.png\">";
@@ -124,6 +145,12 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
echo "<input type=\"hidden\" name=\"not\" value=\"1\">";
+
+ 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-unread.png\">";
echo "</td></form>";
@@ -134,6 +161,12 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
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>";
@@ -146,6 +179,12 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
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>";
@@ -157,6 +196,12 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
echo "<input type=\"hidden\" name=\"rep\" value=\"1\">";
+
+ 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.png\">";
echo "</td></form>";
@@ -167,6 +212,12 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno_next\">";
echo "<input type=\"hidden\" name=\"get\" value=\"1\">";
+
+ 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-next.png\">";
echo "</td></form>";
@@ -178,6 +229,12 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno_prev\">";
echo "<input type=\"hidden\" name=\"get\" value=\"1\">";
+
+ 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-prev.png\">";
echo "</td></form>";
}
@@ -250,12 +307,22 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$struct = imap_fetchstructure($mbox, $msgno);
+//print_r($struct->parts);
+
+/*
+foreach ($struct->parts as $structP) {
+ $structP2 = $structP->parts;
+ echo "<br>";
+ print_r($structP2);
+ echo "<br><br>";
+}
+*/
$contentParts = count($struct->parts);
for ($n = 0; $n <= $contentParts; $n++) {
$contentPart = imap_bodystruct($mbox,$msgno,$n);
-
+
if (($contentPart->disposition == "attachment") or ($contentPart->disposition == "inline")) {
if ($contentPart->bytes > 0) {
diff --git a/search.php b/search.php
new file mode 100644
index 0000000..43b264f
--- /dev/null
+++ b/search.php
@@ -0,0 +1,79 @@
+<?php
+
+session_start();
+
+if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset($_SESSION['logged_key']) or ($_SESSION['logged_lvl'] != "subscriber")) {
+ exit;
+}
+
+if (!isset($_POST['box']) or empty($_POST['box'])) {
+ $folder = "INBOX";
+}
+else {
+ $folder = trim(strip_tags($_POST['box']));
+}
+
+$conn = '{127.0.0.1:143/imap/notls/norsh}';
+
+$mbox = imap_open($conn, $_SESSION['logged_uid'], $_SESSION['logged_key'], OP_HALFOPEN) or die("can't connect: " . imap_last_error());
+
+$search_folders = imap_list($mbox,$conn,"*");
+
+if (is_array($search_folders)) {
+
+ reset($search_folders);
+ sort($search_folders);
+
+ echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"><tr>";
+
+ echo "<form method=\"post\">";
+ echo "<td><select class=\"input\" name=\"box\">";
+
+ foreach ($search_folders as $search_folder) {
+
+ $search_folder = str_replace($conn,"",$search_folder);
+
+ if ($folder == $search_folder) {
+ echo "<option selected>$search_folder</option>";
+ }
+ else {
+ echo "<option>$search_folder</option>";
+ }
+ }
+
+ echo "</select></td>";
+
+ echo "<td width=\"2\"></td>";
+
+ echo "<td><select class=\"input\" name=\"imap_search_where\">";
+ echo "<option value=\"FROM\">From:</option>";
+
+ if (strtolower($folder) == strtolower("Sent")) {
+ echo "<option value=\"TO\" selected>To:</option>";
+ }
+ else {
+ echo "<option value=\"TO\">To:</option>";
+ }
+
+ echo "<option value=\"CC\">Cc:</option>";
+ echo "<option value=\"SUBJECT\">Subject</option>";
+ echo "<option value=\"TEXT\">Text</option>";
+ echo "<option value=\"BODY\">Body</option>";
+ echo "</select></td>";
+
+ echo "<td width=\"2\"></td>";
+
+ echo "<td><input type=\"text\" class=\"input\" name=\"imap_search_query\"></td>";
+
+ echo "<td width=\"2\"></td>";
+
+ echo "<td width=\"40\"><input type=\"submit\" value=\"search\"></td>";
+ echo "</form>";
+
+ echo "</tr></table>";
+
+}
+
+imap_close($mbox);
+
+?>
diff --git a/send.php b/send.php
index 8bc6d87..5934b1a 100644
--- a/send.php
+++ b/send.php
@@ -31,7 +31,11 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
$header_toaddress = $header->toaddress;
$header_ccaddress = $header->ccaddress;
- $reply_quote = wordwrap(trim(get_part($mbox, $msgno, "TEXT/PLAIN")),75,"\r\n");
+ $reply_quote = trim(get_part($mbox, $msgno, "TEXT/PLAIN"));
+
+ if ($_POST['rep'] != 2) {
+ $reply_quote = wordwrap($reply_quote,75,"\r\n");
+ }
$reply_quote_lines = explode("\n",$reply_quote);
@@ -204,7 +208,12 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
echo "<input type=\"hidden\" name=\"filedrop_box\" value=\"$filedrop_box\">";
- echo "<tr><td></td><td align=\"right\"><div class=\"label\"><input type=\"image\" src=\"images/mail-reply.png\"></div><div class=\"label\">send</div></td></tr>";
+ 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 "<tr><td></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 "</table>";