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.
165 righe
7.6 KiB
165 righe
7.6 KiB
<?php |
|
|
|
session_start(); |
|
session_unset(); |
|
session_destroy(); |
|
session_start(); |
|
|
|
$password_esportazione = $_POST["password_esportazione"]; |
|
$_SESSION["bypassCheck"][] = $_SERVER["REQUEST_URI"]; |
|
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php"; |
|
include_once($configPath); |
|
$_POST["password_esportazione"] = $password_esportazione; |
|
|
|
if(! empty($_GET["token"])) { |
|
|
|
$data = null; |
|
|
|
$token = $_GET["token"]; |
|
$token = gzinflate(base64_decode($token)); |
|
if(valid_json($token, $data, false)) { |
|
|
|
if(! empty($data->codice)) { |
|
|
|
$ente = $pdo->go("SELECT codice, denominazione, dominio, esportazione, password_esportazione, giorni_durata_esportazione, data_richiesta_esportazione FROM b_enti WHERE codice = :codice AND esportazione = 'completa'", [":codice" => $data->codice])->fetch(PDO::FETCH_ASSOC); |
|
if(! empty($ente["codice"])) { |
|
|
|
$zipFile = "{$config["mediaFolder"]}/{$ente["codice"]}/esportazione.zip"; |
|
if(! empty($data->hash) && password_verify("{$ente["codice"]}-{$ente["dominio"]}-EXPORT-TUTTOGARE", $data->hash) && file_exists($zipFile)) { |
|
|
|
if(! empty($_POST["password_esportazione"]) && password_verify($_POST["password_esportazione"], $ente["password_esportazione"])) { |
|
|
|
header('Content-Description: File Transfer'); |
|
header('Content-Type: application/octet-stream'); |
|
header('Content-Disposition: attachment; filename="esportazione-tenant-' . $ente["codice"] .'.zip"'); |
|
header('Content-Transfer-Encoding: binary'); |
|
header('Expires: 0'); |
|
header('Cache-Control: must-revalidate'); |
|
header('Pragma: public'); |
|
header('Content-Length: ' . filesize($zipFile)); |
|
|
|
// Pulisci il buffer di output |
|
ob_clean(); |
|
flush(); |
|
|
|
// Apri il file in modalità lettura binaria |
|
$handle = fopen($zipFile, 'rb'); |
|
if ($handle === false) { |
|
die("Could not open file for reading."); |
|
} |
|
|
|
$chunkSize = 10 * 1024 * 1024; // 10MB |
|
|
|
// Leggi e invia il file in chunk |
|
while (!feof($handle)) { |
|
|
|
// Leggi il chunk dal file |
|
$chunk = fread($handle, $chunkSize); |
|
|
|
// Invia il chunk al client |
|
echo $chunk; |
|
|
|
// Pulisci il buffer di output |
|
ob_flush(); |
|
flush(); |
|
} |
|
|
|
// Chiudi il file |
|
fclose($handle); |
|
|
|
exit; |
|
|
|
} |
|
|
|
$print_css = function($required_css) { |
|
foreach ($required_css as $css) { |
|
echo <<<HTML |
|
<link rel="stylesheet" type="text/css" href="{$css}"> |
|
HTML; |
|
} |
|
}; |
|
|
|
$scadenza = date('c', strtotime("+{$ente["giorni_durata_esportazione"]} days", strtotime($ente["data_richiesta_esportazione"]))); |
|
|
|
echo <<<HTML |
|
<!doctype html> |
|
<html lang="it"> |
|
<head> |
|
<meta charset="utf-8"> |
|
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
|
<meta name="viewport" content="width=device-width, initial-scale=1"> |
|
<link rel="apple-touch-icon" sizes="57x57" href="/src/img/favicon.ico/apple-icon-57x57.png"> |
|
<link rel="apple-touch-icon" sizes="60x60" href="/src/img/favicon.ico/apple-icon-60x60.png"> |
|
<link rel="apple-touch-icon" sizes="72x72" href="/src/img/favicon.ico/apple-icon-72x72.png"> |
|
<link rel="apple-touch-icon" sizes="76x76" href="/src/img/favicon.ico/apple-icon-76x76.png"> |
|
<link rel="apple-touch-icon" sizes="114x114" href="/src/img/favicon.ico/apple-icon-114x114.png"> |
|
<link rel="apple-touch-icon" sizes="120x120" href="/src/img/favicon.ico/apple-icon-120x120.png"> |
|
<link rel="apple-touch-icon" sizes="144x144" href="/src/img/favicon.ico/apple-icon-144x144.png"> |
|
<link rel="apple-touch-icon" sizes="152x152" href="/src/img/favicon.ico/apple-icon-152x152.png"> |
|
<link rel="apple-touch-icon" sizes="180x180" href="/src/img/favicon.ico/apple-icon-180x180.png"> |
|
<link rel="icon" type="image/png" sizes="192x192" href="/src/img/favicon.ico/android-icon-192x192.png"> |
|
<link rel="icon" type="image/png" sizes="32x32" href="/src/img/favicon.ico/favicon-32x32.png"> |
|
<link rel="icon" type="image/png" sizes="96x96" href="/src/img/favicon.ico/favicon-96x96.png"> |
|
<link rel="icon" type="image/png" sizes="16x16" href="/src/img/favicon.ico/favicon-16x16.png"> |
|
<link rel="manifest" href="/manifest.json"> |
|
<meta name="msapplication-TileColor" content="#ffffff"> |
|
<meta name="msapplication-TileImage" content="/ms-icon-144x144.png"> |
|
<meta name="theme-color" content="#ffffff"> |
|
<title>TUTTOGAREPA - ESTRAZIONE DATI {$ente['codice']}</title> |
|
<meta name="title" content="TUTTOGAREPA - ESTRAZIONE DATI {$ente['codice']}"/> |
|
<meta http-equiv="Cache-control" content="no-cache"> |
|
<!--[if lt IE 9]> |
|
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> |
|
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> |
|
<![endif]--> |
|
{$print_css($required_css)} |
|
</head> |
|
<body class="bg-light"> |
|
<div class="row h-100"> |
|
<div class="d-block my-auto mx-auto col-5"> |
|
<div class="row"> |
|
<div class="col-12 mb-5 text-center color-amica font-amica"> |
|
<span class="h1 d-block"><span class="icon-tuttogare fa-3x mb-3"></span></span> |
|
<span class="h1 d-block">TUTTOGARE PA</span> |
|
</div> |
|
</div> |
|
<div class="row"> |
|
<div class="col-12"> |
|
<div class="card"> |
|
<div class="card-body"> |
|
<form id="login_form" action="{$_SERVER['REQUEST_URI']}" rel="validate" method="post" target="_self"> |
|
<div class="row my-3"> |
|
<div class="col-12"> |
|
<label for="password_esportazione" class="lead"><i class="fas fa-asterisk mr-2"></i> Password di accesso all'archivio: (*)</label> |
|
<div class="input-group input-group-lg shadow shadow-1 border border-primary rounded"> |
|
<input type="password" class="form-control bg-light" name="password_esportazione" id="password_esportazione" title="password" value="" rel="S;3;0;A"> |
|
<div class="input-group-append"> |
|
<button class="btn btn-primary shadow-none" type="submit"><i class="fas fa-unlock"></i></button> |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
</form> |
|
</div> |
|
<div class="card-footer"> |
|
<small class="text-muted">Questo archivio è disponibile fino al {$scadenza}</small> |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
</body> |
|
</html> |
|
HTML; |
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |