config.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. /**
  9. * Core libraries.
  10. */
  11. require './lib/common.inc.php';
  12. require_once './libraries/config/Form.class.php';
  13. require_once './libraries/config/FormDisplay.class.php';
  14. require_once './setup/lib/ConfigGenerator.class.php';
  15. require './libraries/config/setup.forms.php';
  16. $form_display = new FormDisplay($GLOBALS['ConfigFile']);
  17. $form_display->registerForm('_config.php', $forms['_config.php']);
  18. $form_display->save('_config.php');
  19. $config_file_path = $GLOBALS['ConfigFile']->getFilePath();
  20. if (isset($_POST['eol'])) {
  21. $_SESSION['eol'] = ($_POST['eol'] == 'unix') ? 'unix' : 'win';
  22. }
  23. if (PMA_ifSetOr($_POST['submit_clear'], '')) {
  24. //
  25. // Clear current config and return to main page
  26. //
  27. $GLOBALS['ConfigFile']->resetConfigData();
  28. // drop post data
  29. header('HTTP/1.1 303 See Other');
  30. header('Location: index.php');
  31. exit;
  32. } elseif (PMA_ifSetOr($_POST['submit_download'], '')) {
  33. //
  34. // Output generated config file
  35. //
  36. PMA_downloadHeader('config.inc.php', 'text/plain');
  37. echo ConfigGenerator::getConfigFile($GLOBALS['ConfigFile']);
  38. exit;
  39. } elseif (PMA_ifSetOr($_POST['submit_save'], '')) {
  40. //
  41. // Save generated config file on the server
  42. //
  43. file_put_contents(
  44. $config_file_path,
  45. ConfigGenerator::getConfigFile($GLOBALS['ConfigFile'])
  46. );
  47. header('HTTP/1.1 303 See Other');
  48. header('Location: index.php?action_done=config_saved');
  49. exit;
  50. } elseif (PMA_ifSetOr($_POST['submit_load'], '')) {
  51. //
  52. // Load config file from the server
  53. //
  54. $cfg = array();
  55. include_once $config_file_path;
  56. $GLOBALS['ConfigFile']->setConfigData($cfg);
  57. header('HTTP/1.1 303 See Other');
  58. header('Location: index.php');
  59. exit;
  60. } elseif (PMA_ifSetOr($_POST['submit_delete'], '')) {
  61. //
  62. // Delete config file on the server
  63. //
  64. @unlink($config_file_path);
  65. header('HTTP/1.1 303 See Other');
  66. header('Location: index.php');
  67. exit;
  68. } else {
  69. //
  70. // Show generated config file in a <textarea>
  71. //
  72. header('HTTP/1.1 303 See Other');
  73. header('Location: index.php?page=config');
  74. exit;
  75. }
  76. ?>