<?php
if (!isset($_GET['file'])) {
    die("Nincs fájl megadva.");
}

$file = realpath($_GET['file']);

// Megakadályozza, hogy a webrooton kívülre mutasson
$baseDir = realpath('.');

if ($file === false || strpos($file, $baseDir) !== 0) {
    die("Érvénytelen fájl.");
}

if (!is_file($file)) {
    die("A fájl nem található.");
}

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . basename($file) . '"');
header('Content-Length: ' . filesize($file));
readfile($file);
exit;
?>