Copyright (C) 2008-2015 All Rights Reserved. Contributor(s): Mark J Crane */ include "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; if (permission_exists('email_view')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //get email $email_uuid = check_str($_REQUEST["id"]); $msg_found = false; if ($email_uuid != '') { $sql = "select * from v_emails "; $sql .= "where email_uuid = '".$email_uuid."' "; $sql .= "and domain_uuid = '".$domain_uuid."' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result_count = count($result); unset ($prep_statement, $sql); if ($result_count > 0) { foreach($result as $row) { $sent = $row['sent_date']; $type = $row['type']; $status = $row['status']; $email = $row['email']; $msg_found = true; break; } } } if (!$msg_found) { $_SESSION["message"] = $text['message-invalid_email']; header("Location: emails.php"); exit; } //includes require('resources/pop3/mime_parser.php'); require('resources/pop3/rfc822_addresses.php'); //parse the email message $mime = new mime_parser_class; $mime->decode_bodies = 1; $parameters = array('Data' => $email); $success = $mime->Decode($parameters, $decoded); if ($success) { //get the headers $headers = json_decode($decoded[0]["Headers"]["x-headers:"], true); $subject = $decoded[0]["Headers"]["subject:"]; $from = $decoded[0]["Headers"]["from:"]; $reply_to = $decoded[0]["Headers"]["reply-to:"]; $to = $decoded[0]["Headers"]["to:"]; $subject = $decoded[0]["Headers"]["subject:"]; if (substr_count($subject, '=?utf-8?B?') > 0) { $subject = str_replace('=?utf-8?B?', '', $subject); $subject = str_replace('?=', '', $subject); $subject = base64_decode($subject); } //get the body $body = ''; $content_type = $decoded[0]['Headers']['content-type:']; if (substr($content_type, 0, 15) == "multipart/mixed" || substr($content_type, 0, 21) == "multipart/alternative") { foreach($decoded[0]["Parts"] as $row) { $body_content_type = $row["Headers"]["content-type:"]; if (substr($body_content_type, 0, 9) == "text/html") { $body = $row["Body"]; } if (substr($body_content_type, 0, 10) == "text/plain") { $body_plain = $row["Body"]; $body = $body_plain; } } } else { $content_type_array = explode(";", $content_type); $body = $decoded[0]["Body"]; } //get the attachments (if any) foreach ($decoded[0]['Parts'] as &$parts_array) { $content_type = $parts_array["Parts"][0]["Headers"]["content-type:"]; //audio/wav; name="msg_b64f97e0-8570-11e4-8400-35da04cdaa74.wav" $content_transfer_encoding = $parts_array["Parts"][0]["Headers"]["content-transfer-encoding:"]; //base64 $content_disposition = $parts_array["Parts"][0]["Headers"]["content-disposition"]; //attachment; filename="msg_b64f97e0-8570-11e4-8400-35da04cdaa74.wav" $file_name = $parts_array["FileName"]; $file_size = $parts_array["BodyLength"]; } } else { $_SESSION["message"] = $text['message-decoding_error'].(($mime->error != '') ? ': '.htmlspecialchars($mime->error) : null); header("Location: emails.php"); exit; } //show the header $document['title'] = $text['title-view_email']; require_once "resources/header.php"; //show content echo "\n"; echo " "; echo " "; echo " "; echo " "; echo "
"; echo " ".$text['header-view_email']."\n"; echo " "; echo " "; if (permission_exists('email_download')) { echo " "; } if (permission_exists('email_resend')) { echo " "; } echo "
"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
".$text['label-sent']."".$sent."
".$text['label-type']."".$text['label-type_'.$type]."
".$text['label-status']."".$text['label-status_'.$status]."
".$text['label-from']."".$from."
".$text['label-to']."".$to."
".$text['label-subject']."".$subject."
".$text['label-message'].""; echo " \n"; echo " \n"; echo " \n"; echo "
".$text['label-attachment']."".$file_name." (".round($file_size/1024,2)." KB)
\n"; echo "

"; //include the footer require_once "resources/footer.php"; ?>