glob only dirs
[mdref/mdref] / public / index.php
1 <?php
2
3 use mdref\Action;
4 use mdref\BaseUrl;
5 use mdref\Reference;
6 use mdref\ExceptionHandler;
7
8 use http\Env\Request;
9 use http\Env\Response;
10
11 define("ROOT", dirname(__DIR__));
12 define("REFS", getenv("REFPATH") ?: implode(PATH_SEPARATOR, glob(ROOT."/refs/*", GLOB_ONLYDIR)));
13
14 ini_set("open_basedir", ROOT.PATH_SEPARATOR.REFS);
15
16 if (!ini_get("date.timezone")) {
17 date_default_timezone_set("UTC");
18 }
19
20 spl_autoload_register(function($c) {
21 if (!strncmp($c, "mdref\\", 6)) {
22 return require ROOT . "/" . strtr($c, "\\", "/") . ".php";
23 }
24 });
25
26 $response = new Response;
27 $ehandler = new ExceptionHandler($response);
28 $reference = new Reference(explode(PATH_SEPARATOR, REFS));
29 $action = new Action($reference, new Request, $response, new BaseUrl);
30 $action->handle();