Upload via GUI (34 Dateien)
This commit is contained in:
@@ -4,7 +4,38 @@ require_once __DIR__ . '/inc/lib.php';
|
||||
site_require_access();
|
||||
|
||||
$platform = (string) ($_GET['platform'] ?? '');
|
||||
$release = site_app_release($platform);
|
||||
$wanted = (string) ($_GET['version'] ?? '');
|
||||
$json = static function (array $data): void {
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
header('Cache-Control: no-store');
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
exit;
|
||||
};
|
||||
/** Angaben zu einer Version; für das System-Update (server) mit Signatur des Herausgebers. */
|
||||
$describe = static function (string $platform, array $r): array {
|
||||
$d = [
|
||||
'platform' => $platform,
|
||||
'version' => $r['version'],
|
||||
'sha256' => $r['sha256'],
|
||||
'size' => (int) $r['size'],
|
||||
'notes' => $r['notes'],
|
||||
'created_at' => $r['created_at'],
|
||||
];
|
||||
if ($platform === 'server') $d['signature'] = site_sign_update((string) $r['version'], (string) $r['sha256']);
|
||||
return $d;
|
||||
};
|
||||
|
||||
// Liste aller Versionen (System-Update: „Bestimmte Version installieren“)
|
||||
if (($_GET['list'] ?? '') === '1' && isset(site_app_platforms()[$platform])) {
|
||||
$json(['platform' => $platform, 'releases' => array_map(fn($r) => $describe($platform, $r), array_slice(site_app_versions($platform), 0, 20))]);
|
||||
}
|
||||
|
||||
$release = null;
|
||||
if ($wanted !== '' && isset(site_app_platforms()[$platform]) && preg_match('/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/', ltrim($wanted, 'vV'))) {
|
||||
foreach (site_app_versions($platform) as $r) if ($r['version'] === ltrim($wanted, 'vV')) { $release = $r; break; }
|
||||
} elseif ($wanted === '') {
|
||||
$release = site_app_release($platform);
|
||||
}
|
||||
if (!$release) {
|
||||
http_response_code(404);
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
@@ -15,19 +46,7 @@ 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;
|
||||
}
|
||||
if (($_GET['download'] ?? '') !== '1') $json($describe($platform, $release));
|
||||
|
||||
$kind = site_app_platforms()[$platform];
|
||||
$filename = $kind['file'];
|
||||
|
||||
Reference in New Issue
Block a user