41 lines
1.6 KiB
PHP
41 lines
1.6 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
require_once __DIR__ . '/inc/lib.php';
|
|
site_require_access();
|
|
|
|
$platform = (string) ($_GET['platform'] ?? '');
|
|
$release = site_app_release($platform);
|
|
if (!$release) {
|
|
http_response_code(404);
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
exit(json_encode(['error' => 'Kein App-Release vorhanden.']));
|
|
}
|
|
$path = site_storage() . '/apps/' . $platform . '/' . basename((string) $release['file']);
|
|
if (!is_file($path)) {
|
|
http_response_code(404);
|
|
exit;
|
|
}
|
|
if (($_GET['download'] ?? '') !== '1') {
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
header('Cache-Control: no-store');
|
|
echo json_encode([
|
|
'platform' => $platform,
|
|
'version' => $release['version'],
|
|
'sha256' => $release['sha256'],
|
|
'size' => (int) $release['size'],
|
|
'notes' => $release['notes'],
|
|
'created_at' => $release['created_at'],
|
|
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
|
exit;
|
|
}
|
|
|
|
$filename = ['android' => 'DeskHub.apk', 'windows' => 'DeskHub-Setup.exe', 'minecraft' => 'DeskHub-Minecraft.jar'][$platform];
|
|
while (ob_get_level() > 0) @ob_end_clean();
|
|
header('Content-Type: ' . ['android' => 'application/vnd.android.package-archive', 'windows' => 'application/vnd.microsoft.portable-executable', 'minecraft' => 'application/java-archive'][$platform]);
|
|
header('Content-Disposition: attachment; filename="' . $filename . '"');
|
|
header('Content-Length: ' . filesize($path));
|
|
header('X-Content-Type-Options: nosniff');
|
|
header('X-DeskHub-SHA256: ' . $release['sha256']);
|
|
header('X-DeskHub-Version: ' . $release['version']);
|
|
readfile($path);
|