Changeset View
Changeset View
Standalone View
Standalone View
core/units/helpers/mailbox_helper.php
Show All 40 Lines | |||||
* @param Array $verify_callback | * @param Array $verify_callback | ||||
* @param Array $process_callback | * @param Array $process_callback | ||||
* @param Array $callback_params | * @param Array $callback_params | ||||
* @param bool $include_attachment_contents | * @param bool $include_attachment_contents | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
function process($connection_info, $verify_callback, $process_callback, $callback_params = Array (), $include_attachment_contents = true) | function process($connection_info, $verify_callback, $process_callback, $callback_params = Array (), $include_attachment_contents = true) | ||||
{ | { | ||||
/** @var POP3Helper $pop3_helper */ | |||||
$pop3_helper = $this->Application->makeClass('POP3Helper', Array ($connection_info)); | $pop3_helper = $this->Application->makeClass('POP3Helper', Array ($connection_info)); | ||||
Lint: CodingStandard.Array.Array.SpaceAfterKeyword: There must be no space between the Array keyword and the opening parenthesis | |||||
PHP keywords must be lowercase; expected "array" but found "Array" Lint: Generic.PHP.LowerCaseKeyword.Found: PHP keywords must be lowercase; expected "array" but found "Array" | |||||
/* @var $pop3_helper POP3Helper */ | |||||
$connection_status = $pop3_helper->initMailbox(); | $connection_status = $pop3_helper->initMailbox(); | ||||
if (is_string($connection_status)) { | if (is_string($connection_status)) { | ||||
return $connection_status; | return $connection_status; | ||||
} | } | ||||
if (defined('DEBUG_MODE') && DEBUG_MODE && $this->Application->isDebugMode()) { | if (defined('DEBUG_MODE') && DEBUG_MODE && $this->Application->isDebugMode()) { | ||||
▲ Show 20 Lines • Show All 174 Lines • ▼ Show 20 Line(s) | |||||
$message_id = array_key_exists('message-id', $this->headers) ? trim($this->headers['message-id']) : ''; | $message_id = array_key_exists('message-id', $this->headers) ? trim($this->headers['message-id']) : ''; | ||||
$good['emailid'] = $message_id ? $message_id : md5($message) . "@in-portal"; | $good['emailid'] = $message_id ? $message_id : md5($message) . "@in-portal"; | ||||
// Stops us looping in stupid conversations with other mail software | // Stops us looping in stupid conversations with other mail software | ||||
if (isset($this->headers['x-loop-detect']) && $this->headers['x-loop-detect'] > 2) { | if (isset($this->headers['x-loop-detect']) && $this->headers['x-loop-detect'] > 2) { | ||||
return false; | return false; | ||||
} | } | ||||
/** @var kEmailSendingHelper $esender */ | |||||
$esender = $this->Application->recallObject('EmailSender'); | $esender = $this->Application->recallObject('EmailSender'); | ||||
/* @var $esender kEmailSendingHelper */ | |||||
// Get the return address | // Get the return address | ||||
$return_path = ''; | $return_path = ''; | ||||
if (array_key_exists('return-path', $this->headers)) { | if (array_key_exists('return-path', $this->headers)) { | ||||
$return_path = $esender->ExtractRecipientEmail($this->headers['return-path']); | $return_path = $esender->ExtractRecipientEmail($this->headers['return-path']); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | |||||
// remove scripts | // remove scripts | ||||
$message_body = preg_replace("/<script[^>]*>[^<]+<\/script[^>]*>/is", '', $message_body); | $message_body = preg_replace("/<script[^>]*>[^<]+<\/script[^>]*>/is", '', $message_body); | ||||
$message_body = preg_replace("/<iframe[^>]*>[^<]*<\/iframe[^>]*>/is", '', $message_body); | $message_body = preg_replace("/<iframe[^>]*>[^<]*<\/iframe[^>]*>/is", '', $message_body); | ||||
if ($message_type == 'html') { | if ($message_type == 'html') { | ||||
$message_body = $esender->ConvertToText($message_body); | $message_body = $esender->ConvertToText($message_body); | ||||
} | } | ||||
/** @var MimeDecodeHelper $mime_decode_helper */ | |||||
$mime_decode_helper = $this->Application->recallObject('MimeDecodeHelper'); | $mime_decode_helper = $this->Application->recallObject('MimeDecodeHelper'); | ||||
/* @var $mime_decode_helper MimeDecodeHelper */ | |||||
// convert to site encoding | // convert to site encoding | ||||
$message_charset = $this->parsedMessage[$message_type][0]['charset']; | $message_charset = $this->parsedMessage[$message_type][0]['charset']; | ||||
if ($message_charset) { | if ($message_charset) { | ||||
$good['message'] = $mime_decode_helper->convertEncoding($message_charset, $message_body); | $good['message'] = $mime_decode_helper->convertEncoding($message_charset, $message_body); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | |||||
* @param string $message | * @param string $message | ||||
* @param bool $include_attachments | * @param bool $include_attachments | ||||
* | * | ||||
*/ | */ | ||||
function decodeMime($message, $include_attachments = true) | function decodeMime($message, $include_attachments = true) | ||||
{ | { | ||||
$message = preg_replace("/\r?\n/", "\r\n", trim($message)); | $message = preg_replace("/\r?\n/", "\r\n", trim($message)); | ||||
/** @var MimeDecodeHelper $mime_decode_helper */ | |||||
$mime_decode_helper = $this->Application->recallObject('MimeDecodeHelper'); | $mime_decode_helper = $this->Application->recallObject('MimeDecodeHelper'); | ||||
/* @var $mime_decode_helper MimeDecodeHelper */ | |||||
// 1. separate headers from bodies | // 1. separate headers from bodies | ||||
$mime_decode_helper->InitHelper($message); | $mime_decode_helper->InitHelper($message); | ||||
$decoded_message = $mime_decode_helper->decode(true, true, true); | $decoded_message = $mime_decode_helper->decode(true, true, true); | ||||
// 2. extract attachments | // 2. extract attachments | ||||
$this->parsedMessage = Array (); // ! reset value | $this->parsedMessage = Array (); // ! reset value | ||||
$this->parseOutput($decoded_message, $this->parsedMessage, $include_attachments); | $this->parseOutput($decoded_message, $this->parsedMessage, $include_attachments); | ||||
▲ Show 20 Lines • Show All 113 Lines • Show Last 20 Lines |
There must be no space between the Array keyword and the opening parenthesis