mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-08 00:31:58 +01:00
parent
1412a77fee
commit
a5f005769f
@ -84,8 +84,7 @@ 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);
|
||||
Piler_Mime_Decode::splitMessage($msg, $headers, $journal, $body);
|
||||
$msg = $headers . $body;
|
||||
$this->model_search_message->remove_journal($msg);
|
||||
|
||||
if(RESTORE_OVER_IMAP == 1 && Registry::get('auditor_user') == 0) {
|
||||
if($imap_ok) {
|
||||
|
@ -51,9 +51,7 @@ class ControllerMessageDownload extends Controller {
|
||||
|
||||
$msg = $this->model_search_message->get_raw_message($this->data['piler_id']);
|
||||
|
||||
Piler_Mime_Decode::splitMessage($msg, $headers, $journal, $body);
|
||||
$msg = $headers . $body;
|
||||
|
||||
$this->model_search_message->remove_journal($msg);
|
||||
print $msg;
|
||||
}
|
||||
|
||||
|
@ -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,3 +47,5 @@ class ControllerMessageJournal extends Controller {
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -72,8 +72,7 @@ class ControllerMessageRestore extends Controller {
|
||||
|
||||
$msg = $this->model_search_message->get_raw_message($this->data['piler_id']);
|
||||
|
||||
Piler_Mime_Decode::splitMessage($msg, $headers, $journal, $body);
|
||||
$msg = $headers . $body;
|
||||
$this->model_search_message->remove_journal($msg);
|
||||
|
||||
if(RESTORE_OVER_IMAP == 1) {
|
||||
if($this->model_mail_mail->connect_imap()) {
|
||||
|
@ -26,8 +26,7 @@ class ModelMessageRestore extends Model {
|
||||
|
||||
$rawemail = $this->model_search_message->get_raw_message($piler_id);
|
||||
|
||||
Piler_Mime_Decode::splitMessage($rawemail, $headers, $journal, $body);
|
||||
$rawemail = $headers . $body;
|
||||
$this->model_search_message->remove_journal($rawemail);
|
||||
|
||||
$zip->addFromString($filename . ".eml", $rawemail);
|
||||
|
||||
|
@ -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::splitMessage($msg, $headers, $journal, $body);
|
||||
if($journal) { $has_journal = 1; }
|
||||
Piler_Mime_Decode::splitMessageRaw($msg, $headers, $body);
|
||||
|
||||
$has_journal = $this->remove_journal($headers);
|
||||
|
||||
$headers = Piler_Mime_Decode::escape_lt_gt_symbols($headers);
|
||||
|
||||
@ -123,8 +123,6 @@ 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);
|
||||
|
||||
@ -165,21 +163,58 @@ 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);
|
||||
|
||||
Piler_Mime_Decode::splitMessage($msg, $headers, $journal, $body);
|
||||
$has_journal = $this->remove_journal($msg);
|
||||
|
||||
if($journal) { $has_journal = 1; }
|
||||
|
||||
$headers = Piler_Mime_Decode::splitHeaders($headers);
|
||||
Piler_Mime_Decode::splitMessage($msg, $headers, $body);
|
||||
|
||||
for($i=0; $i<count(Piler_Mime_Decode::HEADER_FIELDS); $i++) {
|
||||
if(isset($headers[Piler_Mime_Decode::HEADER_FIELDS[$i]]) && is_array($headers[Piler_Mime_Decode::HEADER_FIELDS[$i]])) {
|
||||
@ -218,7 +253,7 @@ class ModelSearchMessage extends Model {
|
||||
$this->message['text/html'] = $purifier->purify($body);
|
||||
}
|
||||
else {
|
||||
$this->message['text/plain'] = str_replace("\n", "<br />\n", $body);
|
||||
$this->message['text/plain'] = $body;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ class Piler_Mime_Decode {
|
||||
|
||||
public static function parseMessage($message, &$result) {
|
||||
|
||||
self::splitMessage($message, $headers, $journal, $body);
|
||||
self::splitMessage($message, $headers, $body);
|
||||
|
||||
$boundary = self::getBoundary($headers);
|
||||
|
||||
@ -31,7 +31,7 @@ class Piler_Mime_Decode {
|
||||
|
||||
for($i=0; $i<count($parts); $i++) {
|
||||
|
||||
self::splitMessage($parts[$i], $headers, $journal, $body);
|
||||
self::splitMessage($parts[$i], $headers, $body);
|
||||
|
||||
$boundary = self::getBoundary($headers);
|
||||
if($boundary) {
|
||||
@ -86,29 +86,9 @@ class Piler_Mime_Decode {
|
||||
}
|
||||
|
||||
|
||||
public static function splitMessage($message, &$headers, &$journal, &$body, $EOL = "\n") {
|
||||
$journal = '';
|
||||
|
||||
public static function splitMessage($message, &$headers, &$body, $EOL = "\n") {
|
||||
self::splitMessageRaw($message, $headers, $body);
|
||||
$headers = self::splitHeaders($headers);
|
||||
|
||||
if(isset($headers['x-ms-journal-report']) && isset($headers['content-type']['boundary'])) {
|
||||
$boundary = $headers['content-type']['boundary'];
|
||||
$headers = self::splitMime($body, $boundary);
|
||||
|
||||
self::splitMessageRaw($headers[0], $s, $journal);
|
||||
|
||||
$i = strpos($headers[1], "\n");
|
||||
$msg = substr($headers[1], $i);
|
||||
|
||||
$i = 0;
|
||||
while(ctype_space($msg[$i])) { $i++; }
|
||||
if($i > 0) { $msg = substr($msg, $i); }
|
||||
|
||||
self::splitMessageRaw($msg, $headers, $body);
|
||||
}
|
||||
|
||||
$headers .= $EOL . $EOL;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user