Files
thetool/application/EmailLog/EmailLogController.php
2025-08-22 17:49:54 +02:00

48 lines
1.3 KiB
PHP

<?php
class EmailLogController extends mfBaseController {
protected function init() {
$this->needlogin = true;
$me = new User();
$me->loadMe();
$this->me = $me;
$this->layout()->set("me", $me);
}
protected function downloadContentAction() {
$hash = $this->request->hash;
$aid = $this->request->aid;
$att = EmailLogAttachment::getOne($aid);
if(!$att) {
header("{$_SERVER['SERVER_PROTOCOL']} 404 Not Found");
echo "File not found";
}
//var_dump($att);exit;
$content = EmailLogAttachmentContent::getFirst(["sha256" => $hash]);
if(!$content) {
header("{$_SERVER['SERVER_PROTOCOL']} 404 Not Found");
echo "File not found";
}
if($att->content_id != $content->id) {
header("{$_SERVER['SERVER_PROTOCOL']} 404 Not Found");
echo "File not found";
}
set_time_limit(36000);
if($content->mimetype) {
header("Content-Type: $content->mimetype");
} else {
header("Content-Type: application/octet-stream");
}
header('Content-disposition: attachment; filename="' . $att->filename . '"');
header("Content-Length: $content->filesize");
echo $content->content;
exit;
}
}