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.
45 righe
1.2 KiB
45 righe
1.2 KiB
<? |
|
$error = true; |
|
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php"; |
|
include_once($configPath); |
|
|
|
// While ci permette di fare break in caso di errore senza avere nesting infinito |
|
while (isset($_SESSION["utente"]) && $_SESSION["utente"]->permission("archivio_documenti") ) { |
|
// Peschiamo l'OE |
|
$oe = oeManager::getOE($_GET["codice"]); |
|
if (empty($oe)) { |
|
break; |
|
} |
|
// Otteniamo il path assoluto del file |
|
$path = $_GET["file"]; |
|
$realPath = oeManager::getArchiveDocumentPath($oe, $path); |
|
if($realPath === false) { |
|
break; |
|
} |
|
// Prendiamo il contenuto del file |
|
$file = file_get_contents($realPath); |
|
if($file === false) { |
|
break; |
|
} |
|
// Otteniamo il mime type |
|
$finfo = new finfo(FILEINFO_MIME); |
|
$mime = $finfo->buffer($file); |
|
|
|
|
|
header('Content-Description: File Transfer'); |
|
header("Content-Type: {$mime}"); |
|
header("Content-Disposition: attachment; filename={$path}"); |
|
header('Content-Transfer-Encoding: binary'); |
|
header('Expires: 0'); |
|
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
|
header('Pragma: public'); |
|
die($file); |
|
|
|
|
|
break; |
|
} |
|
if ($error) { |
|
header('HTTP/1.0 403 Forbidden'); |
|
die(); |
|
} |
|
?>
|