From dfdfbe32720384f796aa784c0c86e55832a589f6 Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Mon, 13 Feb 2023 05:45:08 +0100 Subject: [PATCH] Modify website to support new sub-folders architecture --- website/channels.php | 10 +++++++++- website/index.php | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/website/channels.php b/website/channels.php index e8bdbe1..a226434 100644 --- a/website/channels.php +++ b/website/channels.php @@ -15,11 +15,19 @@ } } + function str_replace_first($needle, $replace, $haystack) { + $pos = strpos($haystack, $needle); + if ($pos !== false) { + $haystack = substr_replace($haystack, $replace, $pos, strlen($needle)); + } + return $haystack; + } + $uri = $_SERVER['REQUEST_URI']; $uri = str_replace('/channels/', '', $uri); $prefix = '/mnt/HDD0/YouTube_captions_search_engine/channels/'; if (str_contains($uri, '/')) { - $uri = str_replace('/', '#', $uri); + $uri = str_replace_first('/', '#', $uri); $uri = $prefix . $uri; if (str_ends_with($uri, '.json')) { header('Content-Type: application/json; charset=UTF-8'); diff --git a/website/index.php b/website/index.php index 742b474..9b14d7b 100644 --- a/website/index.php +++ b/website/index.php @@ -39,7 +39,7 @@ See