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); } }