summaryrefslogtreecommitdiff
path: root/download.php
blob: 7c50a5c908a2e6b69c7d6cb1e1a8b059a9c1665c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
// 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.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[$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

echo($content); // echo remplace readfile pour la même raison
die;