piler/webui/controller/message/download.php

64 lines
1.9 KiB
PHP
Raw Normal View History

2012-02-08 23:14:28 +01:00
<?php
require DIR_SYSTEM . 'helper/mime.php';
2012-02-08 23:14:28 +01:00
class ControllerMessageDownload extends Controller {
public function index(){
$this->id = "content";
$this->template = "message/headers.tpl";
$this->layout = "common/layout-empty";
$request = Registry::get('request');
$db = Registry::get('db');
$this->load->model('search/search');
$this->load->model('search/message');
$this->load->model('audit/audit');
2012-02-08 23:14:28 +01:00
$this->document->title = $this->data['text_message'];
$this->data['id'] = @$this->request->get['id'];
if(!$this->model_audit_audit->can_download()) { die("you cannot download at the moment"); }
2012-02-08 23:14:28 +01:00
if(!verify_piler_id($this->data['id'])) {
2012-09-06 15:27:20 +02:00
AUDIT(ACTION_UNKNOWN, '', '', $this->data['id'], 'unknown id: ' . $this->data['id']);
2012-02-08 23:14:28 +01:00
die("invalid id: " . $this->data['id']);
}
2012-09-06 15:27:20 +02:00
if(!$this->model_search_search->check_your_permission_by_id($this->data['id'])) {
2012-02-08 23:14:28 +01:00
AUDIT(ACTION_UNAUTHORIZED_VIEW_MESSAGE, '', '', $this->data['id'], '');
die("no permission for " . $this->data['id']);
}
AUDIT(ACTION_DOWNLOAD_MESSAGE, '', '', $this->data['id'], '');
2015-10-23 20:40:07 +02:00
$filename = $this->data['piler_id'] = $this->model_search_message->get_piler_id_by_id($this->data['id']);
if(EML_NAME_BASED_ON_SUBJECT == 1) {
$filename = $this->model_search_message->get_subject_id_by_id($this->data['id']);
$filename = $this->model_search_message->fix_subject($filename);
}
2012-09-06 15:27:20 +02:00
2012-02-08 23:14:28 +01:00
header("Cache-Control: public, must-revalidate");
header("Pragma: no-cache");
header("Content-Type: application/octet-stream");
2015-10-23 20:40:07 +02:00
header("Content-Disposition: attachment; filename=" . $filename . ".eml");
2012-02-08 23:14:28 +01:00
header("Content-Transfer-Encoding: binary\n");
2013-01-27 21:43:42 +01:00
$msg = $this->model_search_message->get_raw_message($this->data['piler_id']);
2013-04-09 15:02:10 +02:00
Piler_Mime_Decode::removeJournal($msg);
2013-01-27 21:43:42 +01:00
print $msg;
2012-02-08 23:14:28 +01:00
}
}
?>