diff options
author | Freya Murphy <freya@freyacat.org> | 2024-05-20 18:56:50 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2024-05-20 18:56:50 -0400 |
commit | 862ff4e52ad52bcf352965c1bafcc48e4ceb643d (patch) | |
tree | 921ea18ed91536e4b804a5728d9b9c10264be963 /src/web/core/router.php | |
parent | v2 done (diff) | |
download | xssbook2-862ff4e52ad52bcf352965c1bafcc48e4ceb643d.tar.gz xssbook2-862ff4e52ad52bcf352965c1bafcc48e4ceb643d.tar.bz2 xssbook2-862ff4e52ad52bcf352965c1bafcc48e4ceb643d.zip |
fix simple php errors
Diffstat (limited to '')
-rw-r--r-- | src/web/core/router.php | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/web/core/router.php b/src/web/core/router.php index 72c7674..557665b 100644 --- a/src/web/core/router.php +++ b/src/web/core/router.php @@ -66,10 +66,14 @@ class Router { * Gets the curret request info * @return array<string,mixed> */ - private function get_req(): array { + private function get_req(): array|bool { $method = $_SERVER['REQUEST_METHOD']; $uri = parse_url($_SERVER['REQUEST_URI']); + if (!$uri) { + return FALSE; + } + $path = $uri['path']; return array_merge( @@ -100,9 +104,11 @@ class Router { die($code . ' (recursed)'); } + $this->main->info = array(); $this->main->info['slug'] = 'index'; $this->main->info['app'] = 'error'; $this->main->info['route'] = 'apps/error'; + $this->main->info['lang'] = $this->get_lang(); $req = $this->main->info; $_GET['code'] = $code; @@ -114,6 +120,12 @@ class Router { * @param bool $recursed */ private function handle_req($req, $recursed = FALSE): void { + + if ($req === FALSE) { + $this->handle_error(500, $recursed); + return; + } + $controller = $this->load->controller($req['route']); if ($controller === NULL) { |