This blob has been accessed 396 times via Git panel.
- <?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']));
- }
- $host = "{127.0.0.1:143/imap/notls/norsh}";
- $mbox = @imap_open("{$host}$folder", $_SESSION['logged_uid'], $_SESSION['logged_key']) or die("Connection to server failed");
- 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);
- $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>";
- }
- require_once("core.php");
- 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=$val[0]->to;
- }
- else {
- $from=$val[0]->from;
- }
- $subj=$val[0]->subject;
- $date=$val[0]->date;
- $subj = imap_utf8($subj);
- $subj = utf8_decode($subj);
- $from = imap_utf8($from);
- $from = utf8_decode($from);
- $from = htmlentities($from,ENT_QUOTES);
- $from = "<b>" . $from;
- $from = str_replace(""","",$from);
- $from = str_replace(">","",$from);
- $from = str_replace(" <","</b><br>",$from);
- $date = strtotime($date);
- $date = time_elapsed_string($date);
- $size = HumanReadableFilesize($size);
- $from = ereg_replace("\"","",$from);
- if ($bgColor == "#ffffff") {
- $bgColor = "#fdfdfd";
- }
- else {
- $bgColor = "#ffffff";
- }
- $subj = substr($subj,0,74) . "...";
- }
- $subj = htmlentities($subj,ENT_QUOTES);
- 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 ($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\">";
- echo "<input type=\"image\" src=\"images/$status_img\"></td></form>";
- echo "</tr>\n";
- }
- echo "</table>";
- imap_close($mbox);
- ?>