Upload via GUI (338 Dateien)

This commit is contained in:
2026-10-25 17:47:11 +00:00
parent 35809532cf
commit 3aed0cc517
4 changed files with 244 additions and 16 deletions
+18
View File
@@ -0,0 +1,18 @@
<?php
declare(strict_types=1);
/**
* Kleiner, öffentlicher Erreichbarkeitstest für die DeskHub-API.
* Gibt keine internen Details oder Zugangsdaten zurück.
*/
require_once __DIR__ . '/../../../includes/bootstrap.php';
header('Content-Type: application/json; charset=utf-8');
header('Cache-Control: no-store');
try {
get_db()->query('SELECT 1');
echo json_encode(['status' => 'ok'], JSON_UNESCAPED_UNICODE);
} catch (Throwable $e) {
http_response_code(503);
echo json_encode(['status' => 'unavailable'], JSON_UNESCAPED_UNICODE);
}
@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
require_once __DIR__ . '/common.php';
/**
* Update-Prüfung der Apps: GET ?platform=android|windows liefert die aktuell veröffentlichte Version,
* mit &download=1 die Installationsdatei. Die Quelle ist die Plugin-Webseite (Zugangsschlüssel bleibt auf dem Server).
*/
api_require_method('GET');
api_require_staff();
$platform = (string) ($_GET['platform'] ?? '');
if (!in_array($platform, ['android', 'windows'], true)) api_error(400, 'bad_platform', 'Unbekannte Plattform.');
$info = app_publisher_info($platform);
if (!$info) api_json(['available' => false, 'platform' => $platform]);
if (($_GET['download'] ?? '') !== '1') {
api_json([
'available' => true,
'platform' => $platform,
'version' => (string) $info['version'],
'sha256' => (string) $info['sha256'],
'size' => (int) $info['size'],
'notes' => (string) ($info['notes'] ?? ''),
'publishedAt' => (string) ($info['modified_at'] ?? ''),
]);
}
@set_time_limit(0);
while (ob_get_level() > 0) { @ob_end_clean(); }
header('Content-Type: ' . $info['mime']);
header('Content-Disposition: attachment; filename="' . $info['filename'] . '"');
if ((int) $info['size'] > 0) header('Content-Length: ' . (int) $info['size']);
header('X-Content-Type-Options: nosniff');
header('X-DeskHub-SHA256: ' . $info['sha256']);
header('Cache-Control: private, no-store');
$url = app_publisher_endpoint($platform, true);
$headers = function_exists('catalog_access_headers') ? catalog_access_headers($url) : [];
if (function_exists('curl_init')) {
$ch = curl_init($url);
curl_setopt_array($ch, [CURLOPT_FOLLOWLOCATION => false, CURLOPT_CONNECTTIMEOUT => 8, CURLOPT_TIMEOUT => 0, CURLOPT_HTTPHEADER => $headers, CURLOPT_RETURNTRANSFER => false, CURLOPT_WRITEFUNCTION => static function ($curl, $chunk) { echo $chunk; return strlen($chunk); }]);
curl_exec($ch);
curl_close($ch);
} else {
$remote = @fopen($url, 'rb', false, stream_context_create(['http' => ['timeout' => 0, 'header' => implode("\r\n", $headers)]]));
if ($remote) { fpassthru($remote); fclose($remote); }
}