2 /* vim: set expandtab sw=4 ts=4 sts=4: */
8 declare(strict_types
=1);
10 use FastRoute\Dispatcher
;
11 use FastRoute\RouteCollector
;
14 use function FastRoute\simpleDispatcher
;
16 if (! defined('ROOT_PATH')) {
17 define('ROOT_PATH', __DIR__
. DIRECTORY_SEPARATOR
);
20 require_once ROOT_PATH
. 'libraries/common.inc.php';
22 if (isset($_GET['route']) ||
isset($_POST['route'])) {
23 $dispatcher = simpleDispatcher(function (RouteCollector
$routes) {
24 $routes->addRoute(['GET', 'POST'], '[/]', function () {
25 require_once ROOT_PATH
. 'libraries/entry_points/home.php';
27 $routes->addGroup('/database', function (RouteCollector
$routes) {
28 $routes->addRoute(['GET', 'POST'], '/structure', function () {
29 require_once ROOT_PATH
. 'libraries/entry_points/database/structure.php';
31 $routes->addRoute(['GET', 'POST'], '/tracking', function () {
32 require_once ROOT_PATH
. 'libraries/entry_points/database/tracking.php';
35 $routes->addGroup('/server', function (RouteCollector
$routes) {
36 $routes->addRoute('GET', '/collations', function () {
37 require_once ROOT_PATH
. 'libraries/entry_points/server/collations.php';
39 $routes->addRoute(['GET', 'POST'], '/databases', function () {
40 require_once ROOT_PATH
. 'libraries/entry_points/server/databases.php';
42 $routes->addRoute('GET', '/engines', function () {
43 require_once ROOT_PATH
. 'libraries/entry_points/server/engines.php';
45 $routes->addRoute('GET', '/plugins', function () {
46 require_once ROOT_PATH
. 'libraries/entry_points/server/plugins.php';
48 $routes->addGroup('/status', function (RouteCollector
$routes) {
49 $routes->addRoute('GET', '/queries', function () {
50 require_once ROOT_PATH
. 'libraries/entry_points/server/status/queries.php';
53 $routes->addRoute(['GET', 'POST'], '/variables', function () {
54 require_once ROOT_PATH
. 'libraries/entry_points/server/variables.php';
57 $routes->addGroup('/table', function (RouteCollector
$routes) {
58 $routes->addRoute(['GET', 'POST'], '/tracking', function () {
59 require_once ROOT_PATH
. 'libraries/entry_points/table/tracking.php';
63 $routeInfo = $dispatcher->dispatch(
64 $_SERVER['REQUEST_METHOD'],
65 rawurldecode($_GET['route'] ??
$_POST['route'])
67 if ($routeInfo[0] === Dispatcher
::FOUND
) {
68 $handler = $routeInfo[1];
69 $handler($routeInfo[2]);
75 * pass variables to child pages
80 'collation_connection',
84 foreach ($drops as $each_drop) {
85 if (array_key_exists($each_drop, $_GET)) {
86 unset($_GET[$each_drop]);
89 unset($drops, $each_drop);
92 * Black list of all scripts to which front-end must submit data.
93 * Such scripts must not be loaded on home page.
100 // If we have a valid target, let's load that script instead
101 if (! empty($_REQUEST['target'])
102 && is_string($_REQUEST['target'])
103 && 0 !== strpos($_REQUEST['target'], "index")
104 && ! in_array($_REQUEST['target'], $target_blacklist)
105 && Core
::checkPageValidity($_REQUEST['target'], [], true)
107 include ROOT_PATH
. $_REQUEST['target'];
111 require_once ROOT_PATH
. 'libraries/entry_points/home.php';