3 * Front controller for config view / download and clear
5 * @package phpMyAdmin-setup
6 * @author Piotr Przybylski <piotrprz@gmail.com>
7 * @license http://www.gnu.org/licenses/gpl.html GNU GPL 2.0
14 require './lib/common.inc.php';
15 require_once './setup/lib/Form.class.php';
16 require_once './setup/lib/FormDisplay.class.php';
18 $form_display = new FormDisplay();
19 $form_display->registerForm('_config.php');
20 $form_display->save('_config.php');
21 $config_file_path = ConfigFile
::getInstance()->getFilePath();
23 if (isset($_POST['eol'])) {
24 $_SESSION['eol'] = ($_POST['eol'] == 'unix') ?
'unix' : 'win';
27 if (PMA_ifSetOr($_POST['submit_clear'], '')) {
29 // Clear current config and return to main page
31 $_SESSION['ConfigFile'] = array();
33 header('HTTP/1.1 303 See Other');
34 header('Location: index.php');
36 } elseif (PMA_ifSetOr($_POST['submit_download'], '')) {
38 // Output generated config file
40 header('Content-Type: text/plain');
41 header('Content-Disposition: attachment; filename="config.inc.php"');
42 echo ConfigFile
::getInstance()->getConfigFile();
44 } elseif (PMA_ifSetOr($_POST['submit_save'], '')) {
46 // Save generated config file on the server
48 file_put_contents($config_file_path, ConfigFile
::getInstance()->getConfigFile());
49 header('HTTP/1.1 303 See Other');
50 header('Location: index.php');
52 } elseif (PMA_ifSetOr($_POST['submit_load'], '')) {
54 // Load config file from the server
57 require_once $config_file_path;
58 $_SESSION['ConfigFile'] = $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');