3 * Front controller for config view / download and clear
5 * @package phpMyAdmin-setup
6 * @license http://www.gnu.org/licenses/gpl.html GNU GPL 2.0
13 require './lib/common.inc.php';
14 require_once './setup/lib/Form.class.php';
15 require_once './setup/lib/FormDisplay.class.php';
17 $form_display = new FormDisplay();
18 $form_display->registerForm('_config.php');
19 $form_display->save('_config.php');
20 $config_file_path = ConfigFile
::getInstance()->getFilePath();
22 if (isset($_POST['eol'])) {
23 $_SESSION['eol'] = ($_POST['eol'] == 'unix') ?
'unix' : 'win';
26 if (PMA_ifSetOr($_POST['submit_clear'], '')) {
28 // Clear current config and return to main page
30 $_SESSION['ConfigFile'] = array();
32 header('HTTP/1.1 303 See Other');
33 header('Location: index.php');
35 } elseif (PMA_ifSetOr($_POST['submit_download'], '')) {
37 // Output generated config file
39 header('Content-Type: text/plain');
40 header('Content-Disposition: attachment; filename="config.inc.php"');
41 echo ConfigFile
::getInstance()->getConfigFile();
43 } elseif (PMA_ifSetOr($_POST['submit_save'], '')) {
45 // Save generated config file on the server
47 file_put_contents($config_file_path, ConfigFile
::getInstance()->getConfigFile());
48 header('HTTP/1.1 303 See Other');
49 header('Location: index.php');
51 } elseif (PMA_ifSetOr($_POST['submit_load'], '')) {
53 // Load config file from the server
56 require_once $config_file_path;
57 $_SESSION['ConfigFile'] = $cfg;
58 header('HTTP/1.1 303 See Other');
59 header('Location: index.php');
61 } elseif (PMA_ifSetOr($_POST['submit_delete'], '')) {
63 // Delete config file on the server
65 @unlink
($config_file_path);
66 header('HTTP/1.1 303 See Other');
67 header('Location: index.php');
71 // Show generated config file in a <textarea>
73 header('HTTP/1.1 303 See Other');
74 header('Location: index.php?page=config');