This blob has been accessed 462 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,"{$imap_host}Trash");
- imap_mail_move($mbox,$msgno,"Trash",CP_UID);
- imap_expunge($mbox);
- }
- if ($_POST['del'] == "0") {
- imap_mail_move($mbox,$msgno,"Inbox",CP_UID);
- 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'];
- }
- 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,SE_UID);
- rsort($mbox_sort);
- if ($mbox_sort) {
- $msgCount = count($mbox_sort);
- }
- else {
- $msgCount = 0;
- }
- }
- else {
- //$mbox_sort = imap_sort($mbox,SORTARRIVAL,1,SE_UID|SE_NOPREFETCH);
- $mbox_sort = imap_sort($mbox,SORTDATE,1,SE_UID|SE_NOPREFETCH);
- }
- /*
- $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=\"100%\">";
- //echo "<tr bgcolor=\"#eeeeee\"><td align=\"center\" width=\"32\"><nobr>";
- echo "<tr bgcolor=\"#eeeeee\"><td style=\"text-align: center; width: 32px; width: 2rem;\"><nobr>";
- if ($folder == "Trash") {
- echo "un";
- }
- //echo "del</nobr></td><td align=\"center\" style=\"min-width: 12.5rem; width: auto;\">";
- echo "del</nobr></td><td style=\"text-align: center; width: 256px; width: 16rem;\">";
- if ($folder == "Sent") {
- echo "recipient";
- }
- else {
- echo "sender";
- }
- //echo "</td><td align=\"center\" style=\"min-width: 18.75rem; width: auto;\">subject</td><td align=\"center\" width=\"100\">";
- echo "</td><td align=\"center\">subject</td><td style=\"text-align: center; width: 100px; width: 6.25rem;\">";
- 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";
- echo "</td><td style=\"text-align: center; width: 64px; width: 4rem;\">size</td><td style=\"text-align: center; width: 32px; width: 2rem;\">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,FT_UID);
- $msgno = $val[0]->uid;
- $seen = $val[0]->seen;
- $recent = $val[0]->recent;
- $answered = $val[0]->answered;
- $size = $val[0]->size;
- if ($folder == "Sent") {
- $from = imap_utf8($val[0]->to);
- }
- else {
- $from = imap_utf8($val[0]->from);
- }
- $from = htmlentities($from,ENT_QUOTES,"UTF-8");
- $from = "<b>" . $from;
- $from = str_replace(""","",$from);
- $from = str_replace(">","",$from);
- $from = str_replace(" <","</b><br>",$from);
- $from = ereg_replace("\"","",$from);
- $subj = imap_utf8($val[0]->subject);
- //if (strlen($subj) > 75) {
- // $subj = substr($subj,0,74) . "...";
- //}
- $subj = trim(substr($subj,0,79)) . " ...";
- }
- $date = $val[0]->date;
- $date = preg_replace("/\([^\)]+\)/","",$date);
- $date = trim($date);
- $date = strtotime($date);
- $dalt = $date;
- $date = time_elapsed_string($date) . " ago";
- if (strpos($date,"week") or strpos($date,"month") or strpos($date,"year")) {
- $dalt = date("M j, Y",$dalt);
- }
- if (strpos($date,"day")) {
- $dalt = date("D, H:i",$dalt);
- }
- if (strpos($date,"second") or strpos($date,"minute") or strpos($date,"hour")) {
- $dalt = date("H:i",$dalt);
- }
- }
- else {
- $dalt = "";
- }
- $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";
- }
- $header_fetch = imap_utf8(imap_fetchheader($mbox,$mbox_row,FT_UID|FT_PREFETCHTEXT));
- $header_raw_lines = explode("\r\n",$header_fetch);
- $header_priority = "";
- foreach ($header_raw_lines as $header_raw_line) {
- $header_priority = $header_raw_line;
- }
- $header_priority = $header_raw_line;
- }
- }
- if ($header_priority != "") {
- $subj = "<b style=\"color: red; text-shadow: 1px 1px #dedede; text-shadow: 0.1rem 0.1rem #dedede;\">!</b> $subj";
- }
- echo "<tr class=\"inboxE\" bgcolor=\"$bgColor\">";
- 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\">";
- 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>";
- $subj = "(No Subject)";
- }
- echo "<td><nobr>$subj</nobr></td>";
- if ($dalt == "") {
- echo "<td align=\"center\"><nobr>(No Date)</nobr></td>";
- }
- else {
- echo "<td align=\"center\" onmouseover=\"document.getElementById('$msgno').innerHTML='$dalt';\" onmouseout=\"document.getElementById('$msgno').innerHTML='$date';\"><nobr id=\"$msgno\">$date</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>";
- ?>