Files
fdn2/public/getPDF.php
T

29 lines
896 B
PHP

<?php
/*
Author: Riccardo Di Dato
Creation Date: 04/mar/2016
*/
require_once(dirname(__FILE__). "/load.php");
if (array_key_exists("id",$_GET)) {
$pdfModel = GlobalVariables::get("dao")->getFirst("MediaModel",array("id"=>$_GET['id']));
$id = $_GET["id"];
if (!is_null($pdfModel)){
$localFilePath = GlobalVariables::get("config")->paths->media."/".$id.".".$pdfModel->extension;
if (SFSManager::fileExists($localFilePath)){
$exposedFilePath = GlobalVariables::get("config")->paths->xsendfile."/".$id.".".$pdfModel->extension;
if (!SFSManager::fileExists($exposedFilePath)){
SystemController::shellExec("ln",'-nFs "'.$localFilePath.'" "'.$exposedFilePath.'"');
}
header('X-Sendfile: '.$exposedFilePath.'');
header("Content-type: application/octet-stream");
header('Content-Disposition: attachment; filename="' . basename($exposedFilePath) . '"');
}
}
}
?>