Translated using Weblate (Portuguese)
[phpmyadmin.git] / index.php
blob3b0cdba3d8d7112dddf476d91900459769b1b12c
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Main loader script
6 * @package PhpMyAdmin
7 */
8 declare(strict_types=1);
10 use FastRoute\Dispatcher;
11 use FastRoute\RouteCollector;
12 use PhpMyAdmin\Core;
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';
26 });
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';
30 });
31 $routes->addRoute(['GET', 'POST'], '/tracking', function () {
32 require_once ROOT_PATH . 'libraries/entry_points/database/tracking.php';
33 });
34 });
35 $routes->addGroup('/server', function (RouteCollector $routes) {
36 $routes->addRoute('GET', '/collations', function () {
37 require_once ROOT_PATH . 'libraries/entry_points/server/collations.php';
38 });
39 $routes->addRoute(['GET', 'POST'], '/databases', function () {
40 require_once ROOT_PATH . 'libraries/entry_points/server/databases.php';
41 });
42 $routes->addRoute('GET', '/engines', function () {
43 require_once ROOT_PATH . 'libraries/entry_points/server/engines.php';
44 });
45 $routes->addRoute('GET', '/plugins', function () {
46 require_once ROOT_PATH . 'libraries/entry_points/server/plugins.php';
47 });
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';
51 });
52 });
53 $routes->addRoute(['GET', 'POST'], '/variables', function () {
54 require_once ROOT_PATH . 'libraries/entry_points/server/variables.php';
55 });
56 });
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';
60 });
61 });
62 });
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]);
70 exit;
74 /**
75 * pass variables to child pages
77 $drops = [
78 'lang',
79 'server',
80 'collation_connection',
81 'db',
82 'table',
84 foreach ($drops as $each_drop) {
85 if (array_key_exists($each_drop, $_GET)) {
86 unset($_GET[$each_drop]);
89 unset($drops, $each_drop);
91 /**
92 * Black list of all scripts to which front-end must submit data.
93 * Such scripts must not be loaded on home page.
95 $target_blacklist = [
96 'import.php',
97 'export.php',
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'];
108 exit;
111 require_once ROOT_PATH . 'libraries/entry_points/home.php';