config.php 1.4 KB

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