From ef14ba500ff27dd2d1fe6e5debd99f7a5fc4db10 Mon Sep 17 00:00:00 2001 From: winter Sparkles Date: Thu, 6 Aug 2026 23:47:34 +0100 Subject: initial commit --- index.php | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 index.php (limited to 'index.php') diff --git a/index.php b/index.php new file mode 100644 index 0000000..3dee8eb --- /dev/null +++ b/index.php @@ -0,0 +1,50 @@ +Server misconfiguration! couldn't figure out the request path

"; + exit; +} + +$path = explode('?', $path, 2)[0]; + +$config = parse_ini_file(__DIR__ . '/config.ini', true, INI_SCANNER_TYPED); + +App\XMLResponse::addStylesheet('templates/index.xsl'); +App\XMLResponse::addPreamble(function ($doc) use ($config) { + $doc->addAttribute('site-name', $config['site']['name']); + $doc->addAttribute('source', $config['site']['source-location']); +}); + +$router = new App\Router('routes', $config); + +$router->registerStatusHandler(404, function ($path) { + $resp = new App\XMLResponse; + $resp->doc->addAttribute('title', 'Not found'); + $resp->doc->addChild( + 'error', + "The requested page ($path) does not exist." + ); + $resp->send(); +}); + +$router->registerStatusHandler(405, function ($path) { + $method = $_SERVER['REQUEST_METHOD']; + $resp = new App\XMLResponse; + $resp->doc->addAttribute('title', 'Wrong method'); + $resp->doc->addChild( + 'error', + "Your request method ($method) is not valid for this path." + ); + $resp->send(); +}); + +$router->dispatch($path); -- cgit v1.3