Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 

258 righe
10 KiB

<?php
//exit();
switch ($_POST['action']) {
case 'download':
downloadFile();
break;
case 'download_istanza':
downloadIstanza();
break;
case 'download_sconti':
downloadSconti();
break;
case 'richiesta_integrazione':
richiesta_integrazione();
break;
case 'download_mandati_pdf':
downloadMandatoPdf();
break;
}
function downloadFile(){
global $LoggedAccount;
$id_allegato = intval($_POST['id']);
if($id_allegato>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;
if (file_exists($filePath) && filesize($filePath) > 0) {
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 downloadSconti(){
global $LoggedAccount;
//Utils::print_array($_POST);exit();
$id_sconto = intval($_POST['id']);
if($id_sconto>0){
$sconto = new DomandaSconti($id_sconto);
if(isset($_POST['type'])){
if($_POST['type'] == 'biglietto'){
$fileName = trim($sconto->FILEPATH_BIGLIETTO);
}elseif ($_POST['type'] == 'imbarco'){
$fileName = trim($sconto->FILEPATH_CARTAIMBARCO);
}
}
$istanza = Domanda::loadDomandaFromAccount();
$LoggedAccount->checkAuthShowDomandaPage($istanza->ID);
if($istanza->ID == $sconto->ID_DOMANDA){
$folder = $istanza->generateDirForUpload(ROOT_UPLOAD_PRESENTAZIONE, 'biglietti');
$filePath = $folder .'/'. $fileName;
if (file_exists($filePath) && filesize($filePath) > 0) {
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;
$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 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;
}
function richiesta_integrazione() {
global $LoggedAccount;
// $verificaCsrf = Utils::verifyCsrfToken($_SESSION['Token'], 'csrf_download', $_POST['csrf_download']);
// if (!$verificaCsrf) {
// $return['erroreDescrizione'] = "Operazione non consentita - 159";
// exit(json_encode($return));
// }
// Utils::print_array($_POST);exit();
$id_integrazione = intval($_POST['id']);
if ($id_integrazione > 0) {
$integrazione = new RichiestaIntegrazione($id_integrazione);
$id_sconto = intval($integrazione->ID_DOMANDA_SCONTI);
$sconto = new DomandaSconti($id_sconto);
if (isset($_POST['type'])) {
if ($_POST['type'] == 'richiesta_iniziale') {
$fileName = trim($integrazione->FILEPATH_PDF_PROTOCOLLATO);
} elseif ($_POST['type'] == 'integrazione') {
$fileName = trim($integrazione->FILEPATH_RISPOSTA);
}
}
$istanza = Domanda::loadDomandaFromAccount();
$LoggedAccount->checkAuthShowDomandaPage($istanza->ID);
if ($istanza->ID == $sconto->ID_DOMANDA) {
if ($_POST['type'] == 'richiesta_iniziale') {
$folder = $istanza->generateDirForUpload(ROOT_UPLOAD_PRESENTAZIONE, 'soccorso_istruttorio');
} elseif ($_POST['type'] == 'integrazione') {
$folder = $istanza->generateDirForUpload(ROOT_UPLOAD_PRESENTAZIONE, 'integrazione');
}
$filePath = $folder . '/' . $fileName;
if (file_exists($filePath) && filesize($filePath) > 0) {
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 downloadMandatoPdf() {
$nomeFile = $_POST['nomeFile'];
$basepath = ROOT_UPLOAD_DRS;
if (!is_dir($basepath))
@mkdir($basepath, 0777, true);
$report = $basepath . $nomeFile;
ob_clean();
if (file_exists($report)) {
$url = $report;
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . File::GetValidFilename($nomeFile));
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($url));
ob_clean();
flush();
readfile($url);
exit;
} else {
echo "Il file non esiste!";
}
exit;
}