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:
itismadness
2018-06-12 08:48:15 -04:00
parent b0a12fdd6a
commit 4f8a2c5dad
8 changed files with 254 additions and 125 deletions
+15
View File
@@ -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