revised ms journal handling

This commit is contained in:
SJ
2013-01-27 21:43:42 +01:00
parent e5618dd39b
commit 80cee9f59c
11 changed files with 53 additions and 63 deletions

View File

@ -58,8 +58,11 @@ class ControllerMessageBulkrestore extends Controller {
if(count($rcpt) > 0) {
$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);
$x = $this->model_mail_mail->send_smtp_email(SMARTHOST, SMARTHOST_PORT, SMTP_DOMAIN, SMTP_FROMADDR, $rcpt,
"Received: by piler" . EOL . PILER_HEADER_FIELD . $id . EOL . $this->model_search_message->get_raw_message($piler_id) );
"Received: by piler" . EOL . PILER_HEADER_FIELD . $id . EOL . $msg );
if($x == 1) { $this->data['restored']++; }
}

View File

@ -41,10 +41,9 @@ class ControllerMessageDownload extends Controller {
header("Content-Transfer-Encoding: binary\n");
print $this->model_search_message->get_raw_message($this->data['piler_id']);
exit;
$this->render();
$msg = $this->model_search_message->get_raw_message($this->data['piler_id']);
$this->model_search_message->remove_journal($msg);
print $msg;
}

View File

@ -58,8 +58,11 @@ class ControllerMessageRestore extends Controller {
$this->data['piler_id'] = $this->model_search_message->get_piler_id_by_id($this->data['id']);
$msg = $this->model_search_message->get_raw_message($this->data['piler_id']);
$this->model_search_message->remove_journal($msg);
$x = $this->model_mail_mail->send_smtp_email(SMARTHOST, SMARTHOST_PORT, SMTP_DOMAIN, SMTP_FROMADDR, $rcpt,
"Received: by piler" . EOL . PILER_HEADER_FIELD . $this->data['id'] . EOL . $this->model_search_message->get_raw_message($this->data['piler_id']) );
"Received: by piler" . EOL . PILER_HEADER_FIELD . $this->data['id'] . EOL . $msg );
if($x == 1) { $this->data['data'] = $this->data['text_restored']; }
}

View File

@ -68,6 +68,8 @@ class ModelSearchMessage extends Model {
$msg = $this->get_raw_message($id);
$this->remove_journal($msg);
$pos = strpos($msg, "\n\r\n");
if($pos == false) {
$pos = strpos($msg, "\n\n");
@ -85,6 +87,38 @@ class ModelSearchMessage extends Model {
}
public function remove_journal(&$msg = '') {
$p = $q = '';
$boundary = '';
$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) {
$msg = '';
$q = strstr($p, "Received: from");
if($q) {
$p = '';
$msg = $q;
$q = '';
}
else {
$msg = $p;
$p = '';
}
}
$msg = substr($msg, 0, strlen($msg) - strlen($boundary) - 6);
}
public function extract_message($id = '') {
$header = "";
$body_chunk = "";
@ -102,6 +136,8 @@ class ModelSearchMessage extends Model {
$msg = $this->get_raw_message($id);
$this->remove_journal($msg);
$a = explode("\n", $msg); $msg = "";
while(list($k, $l) = each($a)){