diff --git a/webui/controller/message/bulkrestore.php b/webui/controller/message/bulkrestore.php index 3adb8c8c..20f02845 100644 --- a/webui/controller/message/bulkrestore.php +++ b/webui/controller/message/bulkrestore.php @@ -84,7 +84,8 @@ class ControllerMessageBulkrestore extends Controller { $piler_id = $this->model_search_message->get_piler_id_by_id($id); $msg = $this->model_search_message->get_raw_message($piler_id); - $this->model_search_message->remove_journal($msg); + Piler_Mime_Decode::splitMessage($msg, $headers, $journal, $body); + $msg = $headers . $body; if(RESTORE_OVER_IMAP == 1 && Registry::get('auditor_user') == 0) { if($imap_ok) { diff --git a/webui/controller/message/download.php b/webui/controller/message/download.php index c823a5f8..6deed05e 100644 --- a/webui/controller/message/download.php +++ b/webui/controller/message/download.php @@ -51,7 +51,9 @@ class ControllerMessageDownload extends Controller { $msg = $this->model_search_message->get_raw_message($this->data['piler_id']); - $this->model_search_message->remove_journal($msg); + Piler_Mime_Decode::splitMessage($msg, $headers, $journal, $body); + $msg = $headers . $body; + print $msg; } diff --git a/webui/controller/message/journal.php b/webui/controller/message/journal.php index b9e1b9a3..d6e2744c 100644 --- a/webui/controller/message/journal.php +++ b/webui/controller/message/journal.php @@ -14,7 +14,7 @@ class ControllerMessageJournal extends Controller { $this->load->model('search/search'); $this->load->model('search/message'); - + $this->load->model('audit/audit'); $this->load->model('user/user'); $this->document->title = $this->data['text_message']; @@ -47,5 +47,3 @@ class ControllerMessageJournal extends Controller { } - -?> diff --git a/webui/controller/message/restore.php b/webui/controller/message/restore.php index 4bcdc977..09a99bd0 100644 --- a/webui/controller/message/restore.php +++ b/webui/controller/message/restore.php @@ -72,7 +72,8 @@ class ControllerMessageRestore extends Controller { $msg = $this->model_search_message->get_raw_message($this->data['piler_id']); - $this->model_search_message->remove_journal($msg); + Piler_Mime_Decode::splitMessage($msg, $headers, $journal, $body); + $msg = $headers . $body; if(RESTORE_OVER_IMAP == 1) { if($this->model_mail_mail->connect_imap()) { diff --git a/webui/model/message/restore.php b/webui/model/message/restore.php index 63315d9f..0e9de47d 100644 --- a/webui/model/message/restore.php +++ b/webui/model/message/restore.php @@ -26,7 +26,8 @@ class ModelMessageRestore extends Model { $rawemail = $this->model_search_message->get_raw_message($piler_id); - $this->model_search_message->remove_journal($rawemail); + Piler_Mime_Decode::splitMessage($rawemail, $headers, $journal, $body); + $rawemail = $headers . $body; $zip->addFromString($filename . ".eml", $rawemail); diff --git a/webui/model/search/message.php b/webui/model/search/message.php index 0cc526bc..f42474f2 100644 --- a/webui/model/search/message.php +++ b/webui/model/search/message.php @@ -105,12 +105,12 @@ class ModelSearchMessage extends Model { public function get_message_headers($id = '') { $headers = ''; + $has_journal = 0; $msg = $this->get_raw_message($id); - Piler_Mime_Decode::splitMessageRaw($msg, $headers, $body); - - $has_journal = $this->remove_journal($headers); + Piler_Mime_Decode::splitMessage($msg, $headers, $journal, $body); + if($journal) { $has_journal = 1; } $headers = Piler_Mime_Decode::escape_lt_gt_symbols($headers); @@ -123,6 +123,8 @@ class ModelSearchMessage extends Model { $boundary = ''; $msg = $this->get_raw_message($id); + Piler_Mime_Decode::splitMessage($msg, $headers, $journal, $body); + return $journal; $hdr = substr($msg, 0, 8192); @@ -163,58 +165,21 @@ class ModelSearchMessage extends Model { } - public function remove_journal(&$msg = '') { - $p = $q = ''; - $boundary = ''; - $has_journal = 0; - - $hdr = substr($msg, 0, 4096); - - $s = preg_split("/\n/", $hdr); - while(list($k, $v) = each($s)) { - if(preg_match("/boundary\s{0,}=\s{0,}\"{0,}([\w\_\-\@\.]+)\"{0,}/i", $v, $m)) { - if(isset($m[1])) { $boundary = $m[1]; break; } - } - } - - $p = strstr($msg, "\nX-MS-Journal-Report:"); - - if($p) { - $has_journal = 1; - - $msg = ''; - $q = strstr($p, "Received: from"); - if($q) { - $p = ''; - $msg = $q; - $q = ''; - } - else { - $msg = $p; - $p = ''; - } - - if($boundary) { - $msg = substr($msg, 0, strlen($msg) - strlen($boundary) - 6); - } - } - - return $has_journal; - } - - public function extract_message($id = '', $terms = '') { $from = "From: "; $to = "To: "; $cc = "Cc: "; $subject = "Subject: "; $date = "Date: "; + $has_journal = 0; $msg = $this->get_raw_message($id); - $has_journal = $this->remove_journal($msg); + Piler_Mime_Decode::splitMessage($msg, $headers, $journal, $body); - Piler_Mime_Decode::splitMessage($msg, $headers, $body); + if($journal) { $has_journal = 1; } + + $headers = Piler_Mime_Decode::splitHeaders($headers); for($i=0; $imessage['text/html'] = $purifier->purify($body); } else { - $this->message['text/plain'] = $body; + $this->message['text/plain'] = str_replace("\n", "
\n", $body); } } diff --git a/webui/system/helper/mime.php b/webui/system/helper/mime.php index 65eb750c..d33d6f7c 100644 --- a/webui/system/helper/mime.php +++ b/webui/system/helper/mime.php @@ -7,7 +7,7 @@ class Piler_Mime_Decode { public static function parseMessage($message, &$result) { - self::splitMessage($message, $headers, $body); + self::splitMessage($message, $headers, $journal, $body); $boundary = self::getBoundary($headers); @@ -31,7 +31,7 @@ class Piler_Mime_Decode { for($i=0; $i 0) { $msg = substr($msg, $i); } + + self::splitMessageRaw($msg, $headers, $body); + } + + $headers .= $EOL . $EOL; }