Translated using Weblate (Polish)
[phpmyadmin.git] / setup / index.php
blob3f6ec03dfa3b8b2901be20a6b9b3cda161ece739
1 <?php
2 /**
3 * Front controller for setup script
4 */
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;
12 use PhpMyAdmin\Core;
13 use PhpMyAdmin\Header;
14 use PhpMyAdmin\Template;
15 use PhpMyAdmin\Url;
17 if (! defined('ROOT_PATH')) {
18 // phpcs:disable PSR1.Files.SideEffects
19 define('ROOT_PATH', dirname(__DIR__) . DIRECTORY_SEPARATOR);
20 // phpcs:enable
23 /** @psalm-suppress InvalidGlobal */
24 global $cfg;
26 // phpcs:disable PSR1.Files.SideEffects
27 define('PHPMYADMIN', true);
28 // phpcs:enable
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!'));
36 $page = 'index';
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,
49 ]);
51 return;
54 if ($page === 'config') {
55 echo (new ConfigController($GLOBALS['ConfigFile'], new Template()))([
56 'formset' => $_GET['formset'] ?? null,
57 'eol' => $_GET['eol'] ?? null,
58 ]);
60 return;
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,
68 ]);
69 header('Location: index.php' . Url::getCommonRaw());
71 return;
74 echo $controller->index([
75 'formset' => $_GET['formset'] ?? null,
76 'mode' => $_GET['mode'] ?? null,
77 'id' => $_GET['id'] ?? null,
78 ]);
80 return;
83 echo (new HomeController($GLOBALS['ConfigFile'], new Template()))([
84 'formset' => $_GET['formset'] ?? null,
85 'version_check' => $_GET['version_check'] ?? null,
86 ]);