Prepare for 5.0.4
[phpmyadmin.git] / index.php
blob11d40b7ed1334ef1d530a661c8e46b03340fa182
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 PhpMyAdmin\Controllers\HomeController;
11 use PhpMyAdmin\Core;
12 use PhpMyAdmin\DatabaseInterface;
13 use PhpMyAdmin\Response;
14 use PhpMyAdmin\Url;
15 use PhpMyAdmin\Util;
17 if (! defined('ROOT_PATH')) {
18 define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
21 global $server;
23 require_once ROOT_PATH . 'libraries/common.inc.php';
25 /**
26 * pass variables to child pages
28 $drops = [
29 'lang',
30 'server',
31 'collation_connection',
32 'db',
33 'table',
35 foreach ($drops as $each_drop) {
36 if (array_key_exists($each_drop, $_GET)) {
37 unset($_GET[$each_drop]);
40 unset($drops, $each_drop);
42 /**
43 * Black list of all scripts to which front-end must submit data.
44 * Such scripts must not be loaded on home page.
46 $target_blacklist = [
47 'import.php',
48 'export.php',
51 // If we have a valid target, let's load that script instead
52 if (! empty($_REQUEST['target'])
53 && is_string($_REQUEST['target'])
54 && 0 !== strpos($_REQUEST['target'], "index")
55 && ! in_array($_REQUEST['target'], $target_blacklist)
56 && Core::checkPageValidity($_REQUEST['target'], [], true)
57 ) {
58 include ROOT_PATH . $_REQUEST['target'];
59 exit;
62 /** @var Response $response */
63 $response = $containerBuilder->get(Response::class);
65 /** @var DatabaseInterface $dbi */
66 $dbi = $containerBuilder->get(DatabaseInterface::class);
68 /** @var HomeController $controller */
69 $controller = $containerBuilder->get(HomeController::class);
71 if (isset($_REQUEST['ajax_request']) && ! empty($_REQUEST['access_time'])) {
72 exit;
75 if (isset($_POST['set_theme'])) {
76 $controller->setTheme([
77 'set_theme' => $_POST['set_theme'],
78 ]);
80 header('Location: index.php' . Url::getCommonRaw());
81 } elseif (isset($_POST['collation_connection'])) {
82 $controller->setCollationConnection([
83 'collation_connection' => $_POST['collation_connection'],
84 ]);
86 header('Location: index.php' . Url::getCommonRaw());
87 } elseif (! empty($_REQUEST['db'])) {
88 // See FAQ 1.34
89 $page = null;
90 if (! empty($_REQUEST['table'])) {
91 $page = Util::getScriptNameForOption(
92 $GLOBALS['cfg']['DefaultTabTable'],
93 'table'
95 } else {
96 $page = Util::getScriptNameForOption(
97 $GLOBALS['cfg']['DefaultTabDatabase'],
98 'database'
101 include ROOT_PATH . $page;
102 } elseif ($response->isAjax() && ! empty($_REQUEST['recent_table'])) {
103 $response->addJSON($controller->reloadRecentTablesList());
104 } elseif ($GLOBALS['PMA_Config']->isGitRevision()
105 && isset($_REQUEST['git_revision'])
106 && $response->isAjax()
108 $response->addHTML($controller->gitRevision());
109 } else {
110 // Handles some variables that may have been sent by the calling script
111 $GLOBALS['db'] = '';
112 $GLOBALS['table'] = '';
113 $show_query = '1';
115 if ($server > 0) {
116 include ROOT_PATH . 'libraries/server_common.inc.php';
119 $response->addHTML($controller->index());