forked from brainfoolong/gpio-webinterface
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
29 lines (25 loc) · 748 Bytes
/
index.php
File metadata and controls
29 lines (25 loc) · 748 Bytes
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
<?php
use Nullix\Gpiowebinterface\Core;
use Nullix\Gpiowebinterface\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(View::$rootUrl, "/");
$viewClass = "Nullix\\Gpiowebinterface\\View\\" . $viewClass;
$view = new $viewClass;
$view->load();