34 lines
992 B
PHP
34 lines
992 B
PHP
<?php
|
|
include("../db.php");
|
|
|
|
if (!isset($_SESSION['rol']) || $_SESSION['rol'] !== 'admin') {
|
|
header("Location: ../login.php?error=acceso_denegado");
|
|
exit();
|
|
}
|
|
|
|
if (isset($_GET['file'])) {
|
|
$archivo = basename($_GET['file']);
|
|
$ruta_completa = "backups_files/" . $archivo;
|
|
|
|
if (file_exists($ruta_completa)) {
|
|
// MEJORA: Limpia y deshabilita los buffers de salida para evitar corromper el ZIP
|
|
if (ob_get_level()) {
|
|
ob_end_clean();
|
|
}
|
|
|
|
header('Content-Description: File Transfer');
|
|
header('Content-Type: application/octet-stream');
|
|
header('Content-Disposition: attachment; filename="' . $archivo . '"');
|
|
header('Expires: 0');
|
|
header('Cache-Control: must-revalidate');
|
|
header('Pragma: public');
|
|
header('Content-Length: ' . filesize($ruta_completa));
|
|
|
|
flush();
|
|
readfile($ruta_completa);
|
|
exit();
|
|
} else {
|
|
echo "El archivo no existe.";
|
|
}
|
|
}
|
|
?>
|