From ef72635b6b9d64809bb7ef1d696b9f8edddcb6f9 Mon Sep 17 00:00:00 2001 From: Jage9 Date: Sun, 22 Feb 2026 02:38:06 -0500 Subject: [PATCH] Make media proxy syntax compatible with older PHP runtimes --- deploy/php/media_proxy.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/deploy/php/media_proxy.php b/deploy/php/media_proxy.php index a5536a8..fef9e8b 100644 --- a/deploy/php/media_proxy.php +++ b/deploy/php/media_proxy.php @@ -1,5 +1,4 @@ strtolower(trim($v)), - explode(',', (string) $allowlistEnv) - ))); + $allowlist = array(); + $rawAllowlist = explode(',', (string) $allowlistEnv); + foreach ($rawAllowlist as $entry) { + $normalized = strtolower(trim((string) $entry)); + if ($normalized !== '') { + $allowlist[] = $normalized; + } + } $allowed = false; foreach ($allowlist as $suffix) { if ($suffix === '') { @@ -161,7 +164,7 @@ curl_setopt_array($ch, [ 'Accept: */*', 'Connection: keep-alive', ], - CURLOPT_HEADERFUNCTION => static function ($curl, $headerLine) use (&$upstreamHeaders, &$statusCode, &$sentContentType): int { + CURLOPT_HEADERFUNCTION => function ($curl, $headerLine) use (&$upstreamHeaders, &$statusCode, &$sentContentType) { $trimmed = trim($headerLine); $length = strlen($headerLine); if ($trimmed === '') { @@ -199,7 +202,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'HEAD') { /** * Emit downstream headers exactly once (before body bytes). */ -$emitHeaders = static function () use (&$headersSent, &$statusCode, &$upstreamHeaders, &$sentContentType, $ch): void { +$emitHeaders = function () use (&$headersSent, &$statusCode, &$upstreamHeaders, &$sentContentType, $ch) { if ($headersSent) { return; } @@ -235,7 +238,7 @@ $emitHeaders = static function () use (&$headersSent, &$statusCode, &$upstreamHe }; // Stream output incrementally. -curl_setopt($ch, CURLOPT_WRITEFUNCTION, static function ($curl, $chunk) use ($emitHeaders): int { +curl_setopt($ch, CURLOPT_WRITEFUNCTION, function ($curl, $chunk) use ($emitHeaders) { $emitHeaders(); $len = strlen($chunk); if ($len > 0) {