forked from aubymori/hitchhiker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pages.php
30 lines (27 loc) · 778 Bytes
/
pages.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
const PAGES =
[
"/" => "pages/home.php",
"/watch" => "pages/watch.php",
"/channel/**" => "pages/channel.php",
"/c/**" => "pages/channel.php",
"/user/**" => "pages/channel.php",
"/feed/**" => "pages/feed.php",
"/results" => "pages/results.php",
"/playlist" => "pages/playlist.php"
];
const PAGES_FALLBACK_PAGE = "pages/unknown.php";
function getPage($path)
{
$strPath = "/" . implode("/", $path["path"]); // Pure evil
foreach (PAGES as $glob => $pointer)
{
// Todo: fnmatch does not work on some configurations,
// notably old PHP versions on Windows.
if (fnmatch($glob, $strPath))
{
return @include PAGES[$glob];
}
}
return include PAGES_FALLBACK_PAGE;
}