From b422b6ded608807c7d3bb8b965b3797ca513610b Mon Sep 17 00:00:00 2001 From: winter Sparkles Date: Sat, 8 Aug 2026 23:01:51 +0100 Subject: implement a large chunk of the auth system itself :D --- webroot/index.php | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 webroot/index.php (limited to 'webroot/index.php') diff --git a/webroot/index.php b/webroot/index.php new file mode 100644 index 0000000..729cdf2 --- /dev/null +++ b/webroot/index.php @@ -0,0 +1,63 @@ +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); + +require_once __DIR__ . '/../localisation.php'; + +Psso\XMLResponse::addStylesheet('../templates/index.xsl'); +Psso\XMLResponse::addPreamble(function ($doc) use ($config) { + $doc->addAttribute('site-name', $config['site']['name']); + $doc->addAttribute('source', $config['site']['source-location']); +}); + +$router = new Psso\Router('../routes', $config); + +$router->registerStatusHandler(404, function ($path) { + $resp = new Psso\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 Psso\XMLResponse; + $resp->doc->addAttribute('title', 'Wrong method'); + $resp->doc->addChild( + 'error', + "Your request method ($method) is not valid for this path." + ); + $resp->send(); +}); + +$router->setExceptionHandler(function (Throwable $e) { + $resp = new Psso\XMLResponse; + $resp->doc->addAttribute('title', 'Uncaught exception'); + $resp->doc->addChild( + 'error', + $e::class . ': ' . $e->getMessage() + ); + $resp->send(); + error_log($e); +}); + +$router->dispatch($path); -- cgit v1.3