vats_paster

php_setup

Sep 7th, 2020
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.26 KB | None | 0 0
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4.  * Front controller for setup script
  5.  *
  6.  * @package PhpMyAdmin-Setup
  7.  * @license https://www.gnu.org/licenses/gpl.html GNU GPL 2.0
  8.  */
  9. declare(strict_types=1);
  10.  
  11. use PhpMyAdmin\Controllers\Setup\ConfigController;
  12. use PhpMyAdmin\Controllers\Setup\FormController;
  13. use PhpMyAdmin\Controllers\Setup\HomeController;
  14. use PhpMyAdmin\Controllers\Setup\ServersController;
  15. use PhpMyAdmin\Core;
  16. use PhpMyAdmin\Template;
  17. use PhpMyAdmin\Url;
  18.  
  19. if (! defined('ROOT_PATH')) {
  20.     define('ROOT_PATH', dirname(__DIR__) . DIRECTORY_SEPARATOR);
  21. }
  22.  
  23. global $cfg;
  24.  
  25. require ROOT_PATH . 'setup/lib/common.inc.php';
  26.  
  27. if (@file_exists(CONFIG_FILE) && ! $cfg['DBG']['demo']) {
  28.     Core::fatalError(__('Configuration already exists, setup is disabled!'));
  29. }
  30.  
  31. $page = Core::isValid($_GET['page'], 'scalar') ? (string) $_GET['page'] : null;
  32. $page = preg_replace('/[^a-z]/', '', $page);
  33. if ($page === '') {
  34.     $page = 'index';
  35. }
  36.  
  37. Core::noCacheHeader();
  38.  
  39. if ($page === 'form') {
  40.     $controller = new FormController($GLOBALS['ConfigFile'], new Template());
  41.     echo $controller->index([
  42.         'formset' => $_GET['formset'] ?? null,
  43.     ]);
  44. } elseif ($page === 'config') {
  45.     $controller = new ConfigController($GLOBALS['ConfigFile'], new Template());
  46.     echo $controller->index([
  47.         'formset' => $_GET['formset'] ?? null,
  48.         'eol' => $_GET['eol'] ?? null,
  49.     ]);
  50. } elseif ($page === 'servers') {
  51.     $controller = new ServersController($GLOBALS['ConfigFile'], new Template());
  52.     if (isset($_GET['mode']) && $_GET['mode'] === 'remove' && $_SERVER['REQUEST_METHOD'] == 'POST') {
  53.         $controller->destroy([
  54.             'id' => $_GET['id'] ?? null,
  55.         ]);
  56.         header('Location: index.php' . Url::getCommonRaw());
  57.     } else {
  58.         echo $controller->index([
  59.             'formset' => $_GET['formset'] ?? null,
  60.             'mode' => $_GET['mode'] ?? null,
  61.             'id' => $_GET['id'] ?? null,
  62.         ]);
  63.     }
  64. } else {
  65.     $controller = new HomeController($GLOBALS['ConfigFile'], new Template());
  66.     echo $controller->index([
  67.         'formset' => $_GET['formset'] ?? null,
  68.         'action_done' => $_GET['action_done'] ?? null,
  69.         'version_check' => $_GET['version_check'] ?? null,
  70.     ]);
  71. }
Add Comment
Please, Sign In to add comment