X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=public%2Findex.php;h=e6d0f75a4ce4a9fe449d1cd92c8f81c97b9c7570;hb=80ea76521e2ccbbfac1ac0f33f91af1739ead561;hp=1e6d37f83bcf26f45822e31c68db7065f5d65b45;hpb=6478b415c59070f70ed860f3a592377eef9783b1;p=mdref%2Fmdref diff --git a/public/index.php b/public/index.php index 1e6d37f..e6d0f75 100644 --- a/public/index.php +++ b/public/index.php @@ -1,27 +1,30 @@ add("mdref", ROOT); +define("ROOT", dirname(__DIR__)); +define("REFS", getenv("REFPATH") ?: implode(PATH_SEPARATOR, glob(ROOT."/refs/*"))); -use http\Controller; -use http\Controller\Url; -use http\Controller\Observer\Layout; +ini_set("open_basedir", ROOT.PATH_SEPARATOR.REFS); -use mdref\ExceptionHandler; -use mdref\Action; +if (!ini_get("date.timezone")) { + date_default_timezone_set("UTC"); +} -new ExceptionHandler; +spl_autoload_register(function($c) { + if (!strncmp($c, "mdref\\", 6)) { + return require ROOT . "/" . strtr($c, "\\", "/") . ".php"; + } +}); -$ctl = new Controller; -$ctl->setDependency("baseUrl", new Url) - ->attach(new Action(["refpath" => REFS])) - ->attach(new Layout) - ->notify() - ->getResponse() - ->send(); +$response = new Response; +$ehandler = new ExceptionHandler($response); +$reference = new Reference(explode(PATH_SEPARATOR, REFS)); +$action = new Action($reference, new Request, $response, new BaseUrl); +$action->handle();