mirror of
https://github.com/OPSnet/Gazelle.git
synced 2026-09-21 07:12:58 -04:00
Implement router class (!71)
Squashed commit of the following: Author: itismadness <[email protected]> fix bug with router on ajax calls finish up initial router implementation Merge branch 'master' into router Add tests for router Fix boolean on authorized function Finish basic implementation for the router
This commit is contained in:
@@ -413,6 +413,7 @@ define('STAFF_LOCKED', 1);
|
||||
|
||||
$AllowedPages = ['staffpm', 'ajax', 'locked', 'logout', 'login'];
|
||||
|
||||
G::$Router = new \Gazelle\Router(G::$LoggedUser['AuthKey']);
|
||||
if (isset(G::$LoggedUser['LockedAccount']) && !in_array($Document, $AllowedPages)) {
|
||||
require(SERVER_ROOT . '/sections/locked/index.php');
|
||||
}
|
||||
@@ -425,6 +426,20 @@ else {
|
||||
}
|
||||
}
|
||||
|
||||
if (G::$Router->hasRoutes()) {
|
||||
$action = $_REQUEST['action'] ?? '';
|
||||
try {
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
require_once(G::$Router->getRoute($action));
|
||||
}
|
||||
catch (\Gazelle\Exception\RouterException $exception) {
|
||||
error(404);
|
||||
}
|
||||
catch (\Gazelle\Exception\InvalidAccessException $exception) {
|
||||
error(403);
|
||||
}
|
||||
}
|
||||
|
||||
$Debug->set_flag('completed module execution');
|
||||
|
||||
/* Required in the absence of session_start() for providing that pages will change
|
||||
|
||||
Reference in New Issue
Block a user