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.
121 righe
3.8 KiB
121 righe
3.8 KiB
<?php |
|
|
|
$configPath = substr(__DIR__, 0, strpos(__DIR__, "/public_html")) . "/config.php"; |
|
include_once($configPath); |
|
|
|
if(! empty($_GET["codice"]) && $_SESSION["utente"]->permission("fvoe")) { |
|
|
|
$fvoe = FVOE::init($_GET["codice"], FVOEInizializationType::CODICE_FVOE); |
|
if(! empty($fvoe->info["codice"]) && $fvoe->info["stato"] >= 20 && $fvoe->isAccessible()) { |
|
|
|
if(isset($_GET["all"]) && isset($_GET["type"])) { |
|
|
|
$directory = generateStrongPassword(10, false, 'l'); |
|
$path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $directory; |
|
|
|
foreach ($fvoe->tipologia_documenti as $tipologia) { |
|
|
|
$documents = $fvoe->fetchDocumentsByType($tipologia["codice"]); |
|
|
|
if($_GET["type"] == "current") { |
|
$documents->getCurrentDocuments(); |
|
} |
|
|
|
if($_GET["type"] == "archive") { |
|
$documents->getOldDocuments(); |
|
} |
|
|
|
if($documents->count() > 0) { |
|
|
|
foreach($documents->all() as $document) { |
|
|
|
$file = $fvoe->getDocument($document->id_documento); |
|
if(! empty($file) && $file->status == 200 && ! empty($file->contenutoDocumento->contenuto)) { |
|
|
|
if(! is_dir($path)) { mkdir($path, 0775, true); } |
|
$filename = strtolower($file->contenutoDocumento->nomefile); |
|
$content = base64_decode($file->contenutoDocumento->contenuto); |
|
file_put_contents($path . DIRECTORY_SEPARATOR . $filename, $content); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
$command = sprintf('cd %s && zip -rj %s %s', escapeshellarg(dirname($path)), escapeshellarg("{$directory}.zip"), escapeshellarg($path)); |
|
exec($command, $output, $result); |
|
if($result === 0) { |
|
|
|
$command = sprintf('rm -rf %s', escapeshellarg($path)); |
|
exec($command, $output, $result); |
|
|
|
$path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . "{$directory}.zip"; |
|
$length = filesize($path); |
|
|
|
header("Content-Description: File Transfer"); |
|
header('Content-Type: application/zip'); |
|
header("Content-Disposition: attachment; filename={$directory}.zip"); |
|
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: $length"); |
|
|
|
readfile($path); |
|
unlink($path); |
|
exit; |
|
|
|
} |
|
|
|
} else if(isset($_GET['tipologia'])) { |
|
|
|
$document = $fvoe->fetchDocumentsByType($_GET['tipologia']); |
|
if($document->count() > 0) { |
|
|
|
$documents = array_column(json_decode(json_encode($document->all()), true), null, "id_documento"); |
|
if(! empty($documents[$_GET["id_documento"]])) { |
|
|
|
$document = $fvoe->getDocument($_GET["id_documento"]); |
|
if($document->status == 200) { |
|
|
|
$content = $document->contenutoDocumento->contenuto; |
|
$content = base64_decode($content); |
|
|
|
$finfo = finfo_open(FILEINFO_MIME_TYPE); |
|
$mimetype = finfo_buffer($finfo, $content); |
|
$filename = strtolower($document->contenutoDocumento->nomefile); |
|
$length = strlen($content); |
|
// $length = $document->contenutoDocumento->dimensione; |
|
|
|
header("Content-Description: File Transfer"); |
|
header("Content-Type: $mimetype"); |
|
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: $length"); |
|
|
|
echo $content; |
|
exit(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
} |
|
|
|
} |
|
|
|
HTTPStatus(403); |
|
?> |
|
<h1>Forbidden</h1> |
|
<a href="/index.php"><?= __("Ritorna") ?></a>
|