From 07e3ef46e92c862d052c872f70b5bcfb57363703 Mon Sep 17 00:00:00 2001 From: polo Date: Wed, 18 Nov 2026 22:09:05 +0100 Subject: =?UTF-8?q?possibilit=C3=A9=20d'ins=C3=A9rer=20des=20variables=20d?= =?UTF-8?q?ans=20les=20scripts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- download.php | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'download.php') diff --git a/download.php b/download.php index dfafea6..7c50a5c 100644 --- a/download.php +++ b/download.php @@ -2,11 +2,33 @@ // téléchargements des scripts par les visiteurs $file_names = ['win' => 'rustdesk.bat', 'win_uninstall' => 'rustdesk-uninstall.bat', 'deb' => 'rustdesk.sh', 'arch' => 'rustdesk.sh']; -$scripts = ['win' => 'scripts/rustdesk.bat', 'win_uninstall' => 'scripts/rustdesk-uninstall.bat', 'deb' => 'scripts/rustdesk-deb.sh', 'arch' => 'scripts/rustdesk-arch.sh']; +$scripts = ['win' => 'scripts/rustdesk.bat.php', 'win_uninstall' => 'scripts/rustdesk-uninstall.bat.php', 'deb' => 'scripts/rustdesk-deb.sh.php', 'arch' => 'scripts/rustdesk-arch.sh.php']; + +$os = $_GET['os'] ?? ''; + +// GET incorrect +if(!isset($scripts[$os])){ + http_response_code(400); + die('OS invalide'); +} + +// template introuvable +if(!is_file($scripts[$os])){ + http_response_code(404); + die('Script introuvable'); +} + +// variables à insérer +// ... + +// template +ob_start(); +include $scripts[$os]; +$content = ob_get_clean(); header("Content-Type: application/octet-stream"); -header('Content-Disposition: attachment; filename="' . $file_names[$_GET['os']] . '"'); -header('Content-Length: ' . filesize($scripts[$_GET['os']])); +header('Content-Disposition: attachment; filename="' . $file_names[$os] . '"'); +header('Content-Length: ' . strlen($scripts[$os])); // strlen remplace filesize parce que le fichier laisse sa place à une chaîne php modifiée par l'insersion de variables -readfile($scripts[$_GET['os']]); -exit; +echo($content); // echo remplace readfile pour la même raison +die; -- cgit v1.2.3