2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Front controller for config view / download and clear
6 * @package phpMyAdmin-setup
12 require './lib/common.inc.php';
13 require_once './libraries/config/Form.class.php';
14 require_once './libraries/config/FormDisplay.class.php';
15 require_once './setup/lib/ConfigGenerator.class.php';
17 require './libraries/config/setup.forms.php';
19 $form_display = new FormDisplay();
20 $form_display->registerForm('_config.php', $forms['_config.php']);
21 $form_display->save('_config.php');
22 $config_file_path = ConfigFile
::getInstance()->getFilePath();
24 if (isset($_POST['eol'])) {
25 $_SESSION['eol'] = ($_POST['eol'] == 'unix') ?
'unix' : 'win';
28 if (PMA_ifSetOr($_POST['submit_clear'], '')) {
30 // Clear current config and return to main page
32 ConfigFile
::getInstance()->resetConfigData();
34 header('HTTP/1.1 303 See Other');
35 header('Location: index.php');
37 } elseif (PMA_ifSetOr($_POST['submit_download'], '')) {
39 // Output generated config file
41 PMA_download_header('config.inc.php', 'text/plain');
42 echo ConfigGenerator
::getConfigFile();
44 } elseif (PMA_ifSetOr($_POST['submit_save'], '')) {
46 // Save generated config file on the server
48 file_put_contents($config_file_path, ConfigGenerator
::getConfigFile());
49 header('HTTP/1.1 303 See Other');
50 header('Location: index.php?action_done=config_saved');
52 } elseif (PMA_ifSetOr($_POST['submit_load'], '')) {
54 // Load config file from the server
57 include_once $config_file_path;
58 ConfigFile
::getInstance()->setConfigData($cfg);
59 header('HTTP/1.1 303 See Other');
60 header('Location: index.php');
62 } elseif (PMA_ifSetOr($_POST['submit_delete'], '')) {
64 // Delete config file on the server
66 @unlink
($config_file_path);
67 header('HTTP/1.1 303 See Other');
68 header('Location: index.php');
72 // Show generated config file in a <textarea>
74 header('HTTP/1.1 303 See Other');
75 header('Location: index.php?page=config');