This blob has been accessed 292 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']));
- $header = imap_rfc822_parse_headers(imap_fetchbody($mbox,$msgno,0,FT_UID));
- $header_subject = header_mime2text($header->subject);
- $header_fromaddress = header_mime2text($header->fromaddress);
- $header_fromaddress = htmlentities($header_fromaddress,ENT_QUOTES);
- $header_toaddress = header_mime2text($header->toaddress);
- $header_toaddress = htmlentities($header_toaddress,ENT_QUOTES);
- $header_date = header_mime2text($header->date);
- $header_date = preg_replace("/\([^\)]+\)/","",$header_date);
- $header_date = trim($header_date);
- $header_date_age = time_elapsed_string(strtotime($header_date));
- $header_ccaddress = header_mime2text($header->ccaddress);
- $header_ccaddress = htmlentities($header_ccaddress,ENT_QUOTES);
- $header_bccaddress = header_mime2text($header->bccaddress);
- $header_bccaddress = htmlentities($header_bccaddress,ENT_QUOTES);
- $header_fetch = imap_fetchheader($mbox,$msgno,FT_UID|FT_PREFETCHTEXT);
- $header_raw_lines = explode("\r\n",$header_fetch);
- foreach ($header_raw_lines as $header_raw_line) {
- $header_mailer = $header_raw_line;
- }
- $header_user_agent = $header_raw_line;
- }
- $header_priority = $header_raw_line;
- }
- $header_priority = $header_raw_line;
- }
- $header_rr = $header_raw_line;
- }
- $header_rr = $header_raw_line;
- }
- $header_dr = $header_raw_line;
- }
- }
- 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_row = array_search($msgno, $mbox_sort);
- $mbox_row_prev = $mbox_row - 1;
- $mbox_row_next = $mbox_row + 1;
- $msgno_next = $mbox_sort[$mbox_row_prev];
- $msgno_prev = $mbox_sort[$mbox_row_next];
- echo "<title>Kartero - $folder - $header_subject</title>";
- echo "<table border=\"0\" cellspacing=\"0\" callpadding=\"0\" width=\"100%\"><tr><td valign=\"top\">";
- echo "<div class=\"message\">";
- $fileFrom = extract_emails_from($header_fromaddress);
- $fileFrom = $fileFrom[0];
- $fileFrom = sha1($fileFrom);
- $filePic = "";
- if (file_exists("images/contacts/$fileUsr/{$fileFrom}.gif") and !file_exists("images/contacts/$fileUsr/{$fileFrom}.jpg") and !file_exists("images/contacts/$fileUsr/{$fileFrom}.png")) {
- $filePic = "images/contacts/$fileUsr/{$fileFrom}.gif";
- }
- if (!file_exists("images/contacts/$fileUsr/{$fileFrom}.gif") and file_exists("images/contacts/$fileUsr/{$fileFrom}.jpg") and !file_exists("images/contacts/$fileUsr/{$fileFrom}.png")) {
- $filePic = "images/contacts/$fileUsr/{$fileFrom}.jpg";
- }
- if (!file_exists("images/contacts/$fileUsr/{$fileFrom}.gif") and !file_exists("images/contacts/$fileUsr/{$fileFrom}.jpg") and file_exists("images/contacts/$fileUsr/{$fileFrom}.png")) {
- $filePic = "images/contacts/$fileUsr/{$fileFrom}.png";
- }
- if ($filePic != "") {
- $filePicSize = getimagesize($filePic);
- if (($filePicSize[0] > 0) and ($filePicSize[1] > 0)) {
- //echo "<style> .apic { padding: 3px; background: #fff; -moz-box-shadow: 1px 1px 3px #222; -khtml-box-shadow: 1px 1px 3px #222; -webkit-box-shadow: 1px 1px 3px #222; box-shadow: 1px 1px 3px #222; } </style>";
- echo "<img class=\"apic\" src=\"$filePic\" border=\"0\" width=\"{$filePicSize[0]}\" height=\"{$filePicSize[1]}\" align=\"right\">";
- }
- }
- if ($header_priority != "") {
- echo "<b style=\"color: red; text-shadow: 0.1em 0.1em #dedede;\">!</b> ";
- }
- echo "<b>Subject: $header_subject</b>";
- echo "<br><br>From: $header_fromaddress";
- echo "<br>To: $header_toaddress";
- if ($header_ccaddress != "") {
- echo "<br>Cc: $header_ccaddress";
- }
- if ($header_bccaddress != "") {
- echo "<br>Bcc: $header_bccaddress";
- }
- echo "<br>Date: $header_date ($header_date_age ago)";
- }
- else {
- echo "<br>Date: <font color=\"red\">Missing! Sender is non-standards compliant or message is probably spam.</font>";
- }
- if ($header_mailer != "") {
- echo "<br>$header_mailer";
- }
- if (($header_user_agent != "") and ($header_mailer == "")) {
- echo "<br>$header_user_agent";
- }
- echo "<a style=\"float: right;\" id=\"headerM\" onclick=\"document.getElementById('header1').className ='message';document.getElementById('header2').className='spacer';document.getElementById('headerL').style.display='inline';document.getElementById('headerM').style.display='none'\">...</a>";
- echo "<a class=\"hide\" style=\"float: right;\" id=\"headerL\" onclick=\"document.getElementById('header1').className ='hide';document.getElementById('header2').className='hide';document.getElementById('headerL').style.display='none';document.getElementById('headerM').style.display='inline'\">...</a>";
- echo "</div>";
- echo "<div class=\"spacer\"></div>";
- echo "<div id=\"header1\" class=\"hide\">";
- echo nl2br(htmlentities(preg_replace('/^\n+|^[\t\s]*\n+/m','',$header_fetch),ENT_QUOTES));
- echo "</div>";
- echo "<div id=\"header2\" class=\"hide\"></div>";
- $fileDir = sha1(microtime(true));
- echo "<div class=\"message\" style=\"padding: 2px;\">";
- echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"><tr>";
- 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\">";
- 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></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=\"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>";
- 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,",")) {
- 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\">";
- 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>";
- echo "<td width=\"5\"></td>";
- if ($msgno_next != "") {
- echo "<form method=\"post\"><td class=\"label\">";
- 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>";
- echo "<td width=\"5\"></td>";
- }
- if ($msgno_prev != "") {
- echo "<form method=\"post\"><td class=\"label\">";
- 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>";
- }
- echo "</tr><tr>";
- if ($folder == "Trash") {
- echo "<td class=\"label\">undelete</td>";
- }
- else {
- echo "<td class=\"label\">delete</td>";
- }
- echo "<td></td>";
- 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>";
- 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>";
- }
- if ($msgno_prev != "") {
- echo "<td class=\"label\"><nobr>next msg</nobr></td>";
- }
- echo "</tr></table>";
- echo "</div>";
- echo "<div class=\"spacer\"></div>";
- $usr_mbox = kartero_sort_folders($imap_host,imap_list($mbox,$imap_host,"*"));
- if ((count($usr_mbox) > 0) and ($folder != "Sent") and ($folder != "Trash")) {
- echo "<div class=\"message\">";
- echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
- echo "<form method=\"post\">";
- echo "<input type=\"hidden\" name=\"move_msg\" value=\"$msgno\">";
- echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
- 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><select name=\"move_box\" onchange=\"this.form.submit();\">";
- echo "<option value=\"\" selected>$folder</option>";
- foreach ($usr_mbox as $move_box) {
- $move_box = str_replace($imap_host,"",$move_box);
- if ($folder == $move_box) {
- continue;
- }
- if ($move_box == "Sent") {
- continue;
- }
- if ($move_box == "Trash") {
- continue;
- }
- echo "<option value=\"$move_box\">$move_box</option>";
- }
- echo "</select></td>";
- echo "<noscript><td><input type=\"submit\" value=\"move\"></td></noscript>";
- echo "</tr></form></table>";
- echo "</div>";
- echo "<div class=\"spacer\"></div>";
- }
- echo "<div class=\"message\">";
- $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);
- }
- }
- }
- $bodyTEXT = get_part($mbox, $msgno, "TEXT/PLAIN");
- $bodyHTML = get_part($mbox, $msgno, "TEXT/HTML");
- if ($bodyHTML != "") {
- $msgBody = $bodyHTML;
- if (stristr($msgBody,'src="cid:')) {
- $msgBody = str_ireplace('src="cid:',"src=\"$filePath/",$msgBody);
- }
- if (stristr($msgBody,'src=cid:')) {
- $msgBody = str_ireplace('src=cid:',"src=$filePath/",$msgBody);
- }
- }
- else {
- $msgBody = trim($bodyTEXT);
- $msgBody = nl2br($msgBody);
- $msgBody = preg_replace("/([^\w\/])(www\.[a-z0-9\-]+\.[a-z0-9\-]+)/i","$1http://$2",$msgBody);
- $msgBody = preg_replace("/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i","<a target=\"_blank\" href=\"$1\">$1</a>",$msgBody);
- $msgBody = preg_replace("/([\w-?&;#~=\.\/]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?))/i","<a href=\"mailto:$1\">$1</a>",$msgBody);
- }
- $msgBody = mb_convert_encoding($msgBody,"UTF-8","auto");
- $msgBody = mb_convert_encoding($msgBody,"UTF-8","UTF-8");
- $get_fromaddress = extract_emails_from($header->fromaddress);
- $get_fromaddress = explode("@",$get_fromaddress[0]);
- if (strtoupper($get_fromaddress[0]) == "MAILER-DAEMON") {
- echo nl2br(htmlentities(imap_body($mbox,$msgno,FT_UID)));
- }
- else {
- echo $msgBody;
- }
- echo "</div>";
- if (file_exists("$filePath")) {
- $fileAttachments = glob("$filePath/*");
- if (count($fileAttachments) > 0) {
- sort($fileAttachments);
- reset($fileAttachments);
- echo "<div class=\"spacer\"></div>";
- echo "<div class=\"message\" style=\"position: relative;\">";
- echo "<div style=\"position: absolute; top: -15; right: -15;\"><img src=\"images/attach.png\" border=\"0\" width=\"48\" height=\"48\"></div>";
- echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\">";
- foreach ($fileAttachments as $fileAttachment) {
- $fileName = str_replace("$filePath/","",$fileAttachment);
- $fileSize = filesize($fileAttachment);
- $fileSize = HumanReadableFilesize($fileSize);
- $fileScan = "";
- $scanFile = exec("clamdscan -i --no-summary $fileAttachment",$scanResult,$scanErr);
- if ($scanErr == "1") {
- $fileScan = explode(" ", $scanFile);
- $fileScan = " <font color=\"red\">{$fileScan[1]}</font>";
- }
- if (is_image($fileAttachment)) {
- $img_size = getimagesize($fileAttachment);
- $imgSize = "";
- if (($img_size[0] > 0) and ($img_size[1] > 0)) {
- $imgSize = ", {$img_size[0]}x{$img_size[1]} pixels";
- if ($img_size[bits] > 0) {
- $imgSize = "$imgSize, {$img_size[bits]}-bit image";
- }
- }
- echo "\r\n<tr><td><a href=\"$fileAttachment\" target=\"_blank\"><img src=\"images/file.png\" border=\"0\" width=\"36\" height=\"36\"></a></td><td><a href=\"$fileAttachment\" target=\"_blank\">$fileName</a><br>$fileSize{$imgSize}{$fileScan}</td></tr>\r\n";
- }
- else {
- echo "\r\n<tr><td><a href=\"$fileAttachment\"><img src=\"images/file.png\" border=\"0\" width=\"36\" height=\"36\"></a></td><td><a href=\"$fileAttachment\">$fileName</a><br>$fileSize{$fileScan}</td></tr>\r\n";
- }
- }
- echo "</table>";
- echo "</div>";
- $_SESSION['clean_up_o'] = $fileDir;
- }
- else {
- rmdirr($filePath);
- }
- }
- echo "</td></tr></table>";
- }
- $rcpt_mail = extract_emails_from($header_rr);
- $rcpt_mail = $rcpt_mail[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")) {
- $header_message_id = header_mime2text($header->message_id);
- echo "<form id=\"receipt\" method=\"post\" action=\"rcpt.php\" target=\"rcpt\" style=\"display: none;\">";
- echo "<input type=\"hidden\" name=\"rcpt_mail\" value=\"$rcpt_mail\">";
- echo "<input type=\"hidden\" name=\"rcpt_subj\" value=\"$header_subject\">";
- echo "<input type=\"hidden\" name=\"rcpt_date\" value=\"$header_date\">";
- echo "<input type=\"hidden\" name=\"rcpt_omid\" value=\"$header_message_id\">";
- echo "<input type=\"hidden\" name=\"rcpt_omno\" value=\"$msgno\">";
- echo "<iframe id=\"rcpt\" name=\"rcpt\" src=\"rcpt.php\" frameborder=\"0\" scrolling=\"0\" width=\"0\" height=\"0\" style=\"display: none;\"></iframe>";
- echo "</form>";
- 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>";
- }
- }
- ?>