index.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Main loader script
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. declare(strict_types=1);
  9. use PhpMyAdmin\Controllers\HomeController;
  10. use PhpMyAdmin\Core;
  11. use PhpMyAdmin\DatabaseInterface;
  12. use PhpMyAdmin\Response;
  13. use PhpMyAdmin\Url;
  14. use PhpMyAdmin\Util;
  15. if (! defined('ROOT_PATH')) {
  16. define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
  17. }
  18. global $server;
  19. require_once ROOT_PATH . 'libraries/common.inc.php';
  20. /**
  21. * pass variables to child pages
  22. */
  23. $drops = [
  24. 'lang',
  25. 'server',
  26. 'collation_connection',
  27. 'db',
  28. 'table',
  29. ];
  30. foreach ($drops as $each_drop) {
  31. if (array_key_exists($each_drop, $_GET)) {
  32. unset($_GET[$each_drop]);
  33. }
  34. }
  35. unset($drops, $each_drop);
  36. /**
  37. * Black list of all scripts to which front-end must submit data.
  38. * Such scripts must not be loaded on home page.
  39. */
  40. $target_blacklist = [
  41. 'import.php',
  42. 'export.php',
  43. ];
  44. // If we have a valid target, let's load that script instead
  45. if (! empty($_REQUEST['target'])
  46. && is_string($_REQUEST['target'])
  47. && 0 !== strpos($_REQUEST['target'], "index")
  48. && ! in_array($_REQUEST['target'], $target_blacklist)
  49. && Core::checkPageValidity($_REQUEST['target'], [], true)
  50. ) {
  51. include ROOT_PATH . $_REQUEST['target'];
  52. exit;
  53. }
  54. /** @var Response $response */
  55. $response = $containerBuilder->get(Response::class);
  56. /** @var DatabaseInterface $dbi */
  57. $dbi = $containerBuilder->get(DatabaseInterface::class);
  58. /** @var HomeController $controller */
  59. $controller = $containerBuilder->get(HomeController::class);
  60. if (isset($_REQUEST['ajax_request']) && ! empty($_REQUEST['access_time'])) {
  61. exit;
  62. }
  63. if (isset($_POST['set_theme'])) {
  64. $controller->setTheme([
  65. 'set_theme' => $_POST['set_theme'],
  66. ]);
  67. header('Location: index.php' . Url::getCommonRaw());
  68. } elseif (isset($_POST['collation_connection'])) {
  69. $controller->setCollationConnection([
  70. 'collation_connection' => $_POST['collation_connection'],
  71. ]);
  72. header('Location: index.php' . Url::getCommonRaw());
  73. } elseif (! empty($_REQUEST['db'])) {
  74. // See FAQ 1.34
  75. $page = null;
  76. if (! empty($_REQUEST['table'])) {
  77. $page = Util::getScriptNameForOption(
  78. $GLOBALS['cfg']['DefaultTabTable'],
  79. 'table'
  80. );
  81. } else {
  82. $page = Util::getScriptNameForOption(
  83. $GLOBALS['cfg']['DefaultTabDatabase'],
  84. 'database'
  85. );
  86. }
  87. include ROOT_PATH . $page;
  88. } elseif ($response->isAjax() && ! empty($_REQUEST['recent_table'])) {
  89. $response->addJSON($controller->reloadRecentTablesList());
  90. } elseif ($GLOBALS['PMA_Config']->isGitRevision()
  91. && isset($_REQUEST['git_revision'])
  92. && $response->isAjax()
  93. ) {
  94. $response->addHTML($controller->gitRevision());
  95. } else {
  96. // Handles some variables that may have been sent by the calling script
  97. $GLOBALS['db'] = '';
  98. $GLOBALS['table'] = '';
  99. $show_query = '1';
  100. if ($server > 0) {
  101. include ROOT_PATH . 'libraries/server_common.inc.php';
  102. }
  103. $response->addHTML($controller->index());
  104. }