forked from brainfoolong/omxwebgui-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
30 lines (26 loc) · 785 Bytes
/
index.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
use Nullix\Omxwebgui\Core;
use Nullix\Omxwebgui\View;
include __DIR__ . "/src/Core.php";
Core::init();
$viewClass = "Index";
$url = $_SERVER["REQUEST_URI"];
View::$rootUrl = $url;
// check if we are directly on index.php
preg_match("~(.*?)\/index.php($|\?)~", $url, $match);
if ($match) {
View::$rootUrl = $match[1];
}
// just check if the given view exists
preg_match("~(.*?)\/index.php\/([a-z]+)~", $url, $match);
if ($match
&& file_exists(__DIR__ . "/src/View/" . ucfirst($match[2]) . ".php")
) {
$viewClass = ucfirst($match[2]);
View::$rootUrl = $match[1];
}
View::$rootUrl = rtrim("http://" . $_SERVER["HTTP_HOST"] . "/"
. trim(View::$rootUrl, "/ "), "/");
$viewClass = "Nullix\\Omxwebgui\\View\\" . $viewClass;
$view = new $viewClass;
$view->load();