0) { $allegato = new Allegati($id_allegato); if (isset($_POST['file'])) { $fileName = trim($_POST['file']); } else { $fileName = $allegato->FILEPATH; } $domanda = new Domanda($allegato->ID_DOMANDA); $LoggedAccount->checkAuthShowDomandaPage($domanda->ID); $documenti_bando = new DocumentiBando($allegato->ID_DOCUMENTO); $pathInfo = $documenti_bando->getPathInfoDocumento(); $folder = $domanda->generateDirForUpload(ROOT_UPLOAD_PRESENTAZIONE, $pathInfo["PATH_DOCUMENTO"]); $filePath = $folder . '/' . $fileName; // echo "filename=".$fileName; // echo "
filePath=".$filePath; // echo "
Content-Length=".filesize($filePath); // exit(); header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . $fileName . '"'); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($filePath)); ob_clean(); flush(); readfile($filePath); exit; } exit; } function downloadIstanza() { global $LoggedAccount; $verificaCsrf = Utils::verifyCsrfToken($_SESSION['Token'], 'csrf_download', $_POST['csrf_download']); if (!$verificaCsrf) { $return['erroreDescrizione'] = "Operazione non consentita - 159"; exit(json_encode($return)); } $response = Utils::initDefaultResponse(); $domanda = Domanda::loadDomandaFromAccount(); if (Utils::isStatoSportelloPreparazione(true) && $domanda->STATO == PREPARATA) { $filePath = File::getFolderFromDomanda($domanda, ROOT_UPLOAD_PRESENTAZIONE); $filePath .= "/domanda_generata/" . $domanda->ALLEGATO_GENERATO; if (file_exists($filePath) && filesize($filePath) > 0) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=' . File::GetValidFilename($domanda->ALLEGATO_GENERATO)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($filePath)); ob_clean(); flush(); readfile($filePath); exit; } else { echo "Si prega di procedere alla generazione del file."; } } else { $response['erroreDescrizione'] = 'Operazione non consentita in questa fase.'; } } function downloadOld() { global $LoggedAccount, $FOLDER_PRECEDENTI; $verificaCsrf = Utils::verifyCsrfToken($_SESSION['Token'], 'csrf_download', $_POST['csrf_download']); if (!$verificaCsrf) { $return['erroreDescrizione'] = "Operazione non consentita - 159"; exit(json_encode($return)); } $response = Utils::initDefaultResponse(); $domandeOld = Domanda::loadDomandeOld(); $anno = intval($_POST['anno']); $datiDomandaOld = array(); foreach ($domandeOld as $domandaOld) { if ($domandaOld['ANNO'] == $anno) { $datiDomandaOld['ID'] = $domandaOld['ID']; $datiDomandaOld['ALLEGATO_GENERATO'] = $domandaOld['ALLEGATO_GENERATO']; $datiDomandaOld['CODICE_FISCALE'] = $domandaOld['CODICE_FISCALE']; } } if ($datiDomandaOld['CODICE_FISCALE'] != $LoggedAccount->CODICE_FISCALE) { Utils::RedirectTo(HTTP_PRIVATE_SECTION . 'dashboard.php'); exit(); } $root_upload = $FOLDER_PRECEDENTI[$anno] . "presentazione/"; $filePath = File::getFolderFromDomandaOld($datiDomandaOld['ID'], $root_upload); $filePath .= "/domanda_generata/" . $datiDomandaOld['ALLEGATO_GENERATO']; // echo $filePath; // exit(); $fileEsiste = 0; if (file_exists($filePath) && filesize($filePath) > 0) { $fileEsiste = 1; } $logs = new Logs(); $logs->ID_OPERATORE = $LoggedAccount->ID; $logs->IP = $_SERVER['REMOTE_ADDR']; $logs->USERNAME = $LoggedAccount->COGNOME . " " . $LoggedAccount->NOME; $logs->MODULE = "DOMANDEOLD"; $logs->ACTION = $fileEsiste; $logs->OPERATION = $filePath; $logs->INFO = ""; $logs->OLDVALUE = ""; $return['saveLogs'] = $logs->Save(); if (file_exists($filePath) && filesize($filePath) > 0) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=' . File::GetValidFilename($datiDomandaOld['ALLEGATO_GENERATO'])); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($filePath)); ob_clean(); flush(); readfile($filePath); exit; } else { Utils::RedirectTo(HTTP_PRIVATE_SECTION . 'dashboard.php'); exit(); } } function printAllegato($allegato, $domanda) { global $LoggedAccount; if (!empty($allegato) && !empty($domanda)) { if ($allegato->FILEPATH != "") { $file = $allegato->FILEPATH; if ($LoggedAccount->checkIstitutoFromLoggedAccount($domanda->CODICE_ISTITUTO)) { // controllo proprietario domanda switch ($allegato->TIPO_DOCUMENTO) { case TIPO_UPLOAD_OBBLIGATORIO: $basePath = File::getFolderFromDomanda($domanda, ROOT_UPLOAD_PRESENTAZIONE); $basePath .= '/obbligatori/'; break; case TIPO_UPLOAD_OPZIONALE: $basePath = File::getFolderFromDomanda($domanda, ROOT_UPLOAD_PRESENTAZIONE); $basePath .= '/opzionali/'; break; case TIPO_UPLOAD_ISTANZA: $basePath = File::getFolderFromDomanda($domanda, ROOT_UPLOAD_PRESENTAZIONE); $basePath .= '/istanza/'; break; case TIPO_UPLOAD_CONTRIBUTO: $basePath = File::getFolderFromDomanda($domanda, ROOT_UPLOAD_EROGAZIONE); $basePath .= '/contributo/'; break; } $filePath = $basePath . $file; if (file_exists($filePath) && filesize($filePath) > 0) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=' . File::GetValidFilename($file)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($filePath)); ob_clean(); flush(); readfile($filePath); exit; } else { $msg = "Non è possibile visualizzare il file richiesto, contattare il supporto tecnico (1316)."; } } else { $msg = "Accesso non autorizzato"; } } else { $msg = "Non è possibile visualizzare il file richiesto, contattare il supporto tecnico (1321)."; } } else { $msg = "Non è possibile visualizzare il file richiesto, contattare il supporto tecnico (1325)."; } echo $msg; }