Modify website to support new sub-folders architecture

This commit is contained in:
Benjamin_Loison committed 2023-02-13 05:45:08 +01:00
1 parent a51e3b1a9a
commit dfdfbe3272
2 files changed
+10 -2

No files matched your search

+9 -1
View File
@@ -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');