This blob has been accessed 381 times via Git panel.
- <?php
- require_once("core.php");
- if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset($_SESSION['logged_key']) or ($_SESSION['logged_lvl'] != "subscriber")) {
- exit;
- }
- if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])) {
- $msgno = trim(strip_tags($_POST['msg']));
- if ($_POST['del'] == "1") {
- imap_createmailbox($mbox,"{$host}Trash");
- imap_mail_move($mbox,$msgno,"Trash");
- imap_expunge($mbox);
- }
- if ($_POST['del'] == "0") {
- imap_mail_move($mbox,$msgno,"Inbox");
- imap_expunge($mbox);
- }
- }
- if ($hdr = imap_check($mbox)) {
- $msgCount = $hdr->Nmsgs;
- }
- else {
- echo "failed";
- }
- if (!isset($_POST['show_max']) or empty($_POST['show_max']) or !is_numeric($_POST['show_max'])) {
- $show_max = $msgCount;
- }
- else {
- $show_max = $_POST['show_max'];
- }
- imap_headers($mbox);
- 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);
- rsort($mbox_sort);
- if ($mbox_sort) {
- $msgCount = count($mbox_sort);
- }
- else {
- $msgCount = 0;
- }
- }
- else {
- $mbox_sort = imap_sort($mbox,SORTARRIVAL,1);
- }
- /*
- $mail_images = glob("images/mail*");
- foreach ($mail_images as $mail_image) {
- echo "\n\n<script>\n\tvar img_preload = new Image();\n\timg_preload.src = \"$mail_image\";\n</script>";
- }
- */
- echo "<title>Kartero - $folder ($msgCount) - " . $_SESSION['logged_uid'] . "</title>";
- echo "\n\n<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\" width=\"800\">";
- echo "<tr bgcolor=\"#eeeeee\"><td align=\"center\" width=\"32\">";
- if ($folder == "Trash") {
- echo "un";
- }
- echo "del</td><td align=\"center\" width=\"200\">";
- if ($folder == "Sent") {
- echo "recipient";
- }
- else {
- echo "sender";
- }
- echo "</td><td align=\"center\" width=\"300\">subject</td><td align=\"center\" width=\"64\">";
- if ($folder == "Sent") {
- echo "sent";
- }
- else {
- echo "received";
- }
- echo "</td><td align=\"center\" width=\"64\">size</td><td align=\"center\" width=\"32\">read</td></tr>\n";
- foreach ($mbox_sort as $mbox_num => $mbox_row) {
- if ($mbox_num < $mbox_min) {
- continue;
- }
- if ($mbox_num >= $mbox_max) {
- continue;
- }
- $val = imap_fetch_overview($mbox,$mbox_row);
- $msgno = $val[0]->msgno;
- $seen = $val[0]->seen;
- $recent = $val[0]->recent;
- $answered = $val[0]->answered;
- $size = $val[0]->size;
- if ($folder == "Sent") {
- $from = header_mime2text($val[0]->to);
- }
- else {
- $from = header_mime2text($val[0]->from);
- }
- $from = htmlentities($from,ENT_QUOTES);
- $from = "<b>" . $from;
- $from = str_replace(""","",$from);
- $from = str_replace(">","",$from);
- $from = str_replace(" <","</b><br>",$from);
- $from = ereg_replace("\"","",$from);
- $subj = header_mime2text($val[0]->subject);
- $subj = substr($subj,0,74) . "...";
- }
- $date=$val[0]->date;
- $date = strtotime($date);
- $date = time_elapsed_string($date);
- $size = HumanReadableFilesize($size);
- if ($bgColor == "#ffffff") {
- $bgColor = "#fdfdfd";
- }
- else {
- $bgColor = "#ffffff";
- }
- if ($seen == "0") {
- $status_img = "mail-unread.png";
- }
- if ($seen == "1") {
- $status_img = "mail-read.png";
- }
- if ($recent == "1") {
- $status_img = "mail-new.png";
- }
- if ($answered == "1") {
- $status_img = "mail-replied.png";
- }
- echo "<tr bgcolor=\"$bgColor\">";
- echo "<form method=\"post\"><td>";
- 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\">";
- 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\">";
- }
- else {
- echo "<input type=\"hidden\" name=\"del\" value=\"1\">";
- echo "<input type=\"image\" src=\"images/trashcan_empty.png\">";
- }
- echo "</td></form>";
- echo "<td>$from</td>";
- echo "<td>$subj</td>";
- echo "<td align=\"center\"><nobr>$date ago</nobr></td>";
- echo "<td align=\"right\"><nobr>$size</nobr></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\">";
- 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";
- }
- echo "</table>";
- ?>