3 * Front controller for setup script
6 declare(strict_types
=1);
8 use PhpMyAdmin\Controllers\Setup\ConfigController
;
9 use PhpMyAdmin\Controllers\Setup\FormController
;
10 use PhpMyAdmin\Controllers\Setup\HomeController
;
11 use PhpMyAdmin\Controllers\Setup\ServersController
;
13 use PhpMyAdmin\Header
;
14 use PhpMyAdmin\Template
;
17 if (! defined('ROOT_PATH')) {
18 // phpcs:disable PSR1.Files.SideEffects
19 define('ROOT_PATH', dirname(__DIR__
) . DIRECTORY_SEPARATOR
);
23 /** @psalm-suppress InvalidGlobal */
26 // phpcs:disable PSR1.Files.SideEffects
27 define('PHPMYADMIN', true);
30 require ROOT_PATH
. 'setup/lib/common.inc.php';
32 if (@file_exists
(CONFIG_FILE
) && ! $cfg['DBG']['demo']) {
33 Core
::fatalError(__('Configuration already exists, setup is disabled!'));
37 if (isset($_GET['page']) && in_array($_GET['page'], ['form', 'config', 'servers'], true)) {
38 $page = $_GET['page'];
41 Core
::noCacheHeader();
43 // Sent security-related headers
44 (new Header())->sendHttpHeaders();
46 if ($page === 'form') {
47 echo (new FormController($GLOBALS['ConfigFile'], new Template()))([
48 'formset' => $_GET['formset'] ??
null,
54 if ($page === 'config') {
55 echo (new ConfigController($GLOBALS['ConfigFile'], new Template()))([
56 'formset' => $_GET['formset'] ??
null,
57 'eol' => $_GET['eol'] ??
null,
63 if ($page === 'servers') {
64 $controller = new ServersController($GLOBALS['ConfigFile'], new Template());
65 if (isset($_GET['mode']) && $_GET['mode'] === 'remove' && ($_SERVER['REQUEST_METHOD'] ??
'GET') === 'POST') {
66 $controller->destroy([
67 'id' => $_GET['id'] ??
null,
69 header('Location: index.php' . Url
::getCommonRaw());
74 echo $controller->index([
75 'formset' => $_GET['formset'] ??
null,
76 'mode' => $_GET['mode'] ??
null,
77 'id' => $_GET['id'] ??
null,
83 echo (new HomeController($GLOBALS['ConfigFile'], new Template()))([
84 'formset' => $_GET['formset'] ??
null,
85 'version_check' => $_GET['version_check'] ??
null,