diff --git a/public/admin/addMultimedia.php b/public/admin/addMultimedia.php index 88bb145..7ceaab1 100644 --- a/public/admin/addMultimedia.php +++ b/public/admin/addMultimedia.php @@ -21,7 +21,7 @@ try{ throw new CoreException("Trying to add a media to an invalid model with id '".$notiziaId. "'"); } else{ - $mediaTypeSaved = PostHandler::get("mediaType"); + $mediaTypeSaved = intval(PostHandler::get("mediaType")); if(array_key_exists("action", $_POST) && strcmp(PostHandler::get("action"), "save")==0){ $notizia = GlobalVariables::get("dao")->getFirst("NotiziaModel",array("id"=>$notiziaId)); diff --git a/public/getPDF.php b/public/getPDF.php index e1bf0c1..5ab897a 100644 --- a/public/getPDF.php +++ b/public/getPDF.php @@ -11,14 +11,16 @@ if (array_key_exists("id",$_GET)) { $id = $_GET["id"]; if (!is_null($pdfModel)){ $localFilePath = GlobalVariables::get("config")->paths->media."/".$id.".pdf"; - $exposedFilePath = GlobalVariables::get("config")->paths->xsendfile."/".$id.".pdf"; - if (!SFSManager::fileExists($exposedFilePath)){ - SystemController::shellExec("ln",'-s "'.$localFilePath.'" "'.$exposedFilePath.'"'); + if (SFSManager::fileExists($localFilePath)){ + $exposedFilePath = GlobalVariables::get("config")->paths->xsendfile."/".$id.".pdf"; + if (!SFSManager::fileExists($exposedFilePath)){ + SystemController::shellExec("ln",'-s "'.$localFilePath.'" "'.$exposedFilePath.'"'); + } + header('X-Sendfile: '.$exposedFilePath.''); + + header("Content-type: application/octet-stream"); + header('Content-Disposition: attachment; filename="' . basename($exposedFilePath) . '"'); } - header('X-Sendfile: '.$exposedFilePath.''); - - header("Content-type: application/octet-stream"); - header('Content-Disposition: attachment; filename="' . basename($exposedFilePath) . '"'); } }