panel admin: asistente, backups y ayuda
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?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.";
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user