config.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * Front controller for config view / download and clear
  4. */
  5. declare(strict_types=1);
  6. use PhpMyAdmin\Config\Forms\Setup\ConfigForm;
  7. use PhpMyAdmin\Core;
  8. use PhpMyAdmin\Response;
  9. use PhpMyAdmin\Setup\ConfigGenerator;
  10. use PhpMyAdmin\Url;
  11. if (! defined('ROOT_PATH')) {
  12. // phpcs:disable PSR1.Files.SideEffects
  13. define('ROOT_PATH', dirname(__DIR__) . DIRECTORY_SEPARATOR);
  14. // phpcs:enable
  15. }
  16. /**
  17. * Core libraries.
  18. */
  19. require ROOT_PATH . 'setup/lib/common.inc.php';
  20. $form_display = new ConfigForm($GLOBALS['ConfigFile']);
  21. $form_display->save('Config');
  22. $response = Response::getInstance();
  23. $response->disable();
  24. if (isset($_POST['eol'])) {
  25. $_SESSION['eol'] = $_POST['eol'] === 'unix' ? 'unix' : 'win';
  26. }
  27. if (Core::ifSetOr($_POST['submit_clear'], '')) {
  28. // Clear current config and return to main page
  29. $GLOBALS['ConfigFile']->resetConfigData();
  30. // drop post data
  31. $response->generateHeader303('index.php' . Url::getCommonRaw());
  32. exit;
  33. }
  34. if (Core::ifSetOr($_POST['submit_download'], '')) {
  35. // Output generated config file
  36. Core::downloadHeader('config.inc.php', 'text/plain');
  37. $response->disable();
  38. echo ConfigGenerator::getConfigFile($GLOBALS['ConfigFile']);
  39. exit;
  40. }
  41. // Show generated config file in a <textarea>
  42. $response->generateHeader303('index.php' . Url::getCommonRaw(['page' => 'config']));
  43. exit;