Translated using Weblate (Swedish)
[phpmyadmin.git] / setup / config.php
blobca76b6ed109ce7803e2b7f292616d90276f68e4e
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Front controller for config view / download and clear
6 * @package PhpMyAdmin-Setup
7 */
8 use PMA\libraries\config\FormDisplay;
9 use PMA\setup\lib\ConfigGenerator;
11 /**
12 * Core libraries.
14 require './lib/common.inc.php';
16 require './libraries/config/setup.forms.php';
18 $form_display = new FormDisplay($GLOBALS['ConfigFile']);
19 $form_display->registerForm('_config.php', $forms['_config.php']);
20 $form_display->save('_config.php');
21 $config_file_path = $GLOBALS['ConfigFile']->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 $GLOBALS['ConfigFile']->resetConfigData();
32 // drop post data
33 header('HTTP/1.1 303 See Other');
34 header('Location: index.php' . PMA_URL_getCommon());
35 exit;
36 } elseif (PMA_ifSetOr($_POST['submit_download'], '')) {
38 // Output generated config file
40 PMA_downloadHeader('config.inc.php', 'text/plain');
41 echo ConfigGenerator::getConfigFile($GLOBALS['ConfigFile']);
42 exit;
43 } elseif (PMA_ifSetOr($_POST['submit_save'], '')) {
45 // Save generated config file on the server
47 file_put_contents(
48 $config_file_path,
49 ConfigGenerator::getConfigFile($GLOBALS['ConfigFile'])
51 header('HTTP/1.1 303 See Other');
52 header('Location: index.php' . PMA_URL_getCommon() . '&action_done=config_saved');
53 exit;
54 } elseif (PMA_ifSetOr($_POST['submit_load'], '')) {
56 // Load config file from the server
58 $cfg = array();
59 include_once $config_file_path;
60 $GLOBALS['ConfigFile']->setConfigData($cfg);
61 header('HTTP/1.1 303 See Other');
62 header('Location: index.php' . PMA_URL_getCommon());
63 exit;
64 } elseif (PMA_ifSetOr($_POST['submit_delete'], '')) {
66 // Delete config file on the server
68 @unlink($config_file_path);
69 header('HTTP/1.1 303 See Other');
70 header('Location: index.php' . PMA_URL_getCommon());
71 exit;
72 } else {
74 // Show generated config file in a <textarea>
76 header('HTTP/1.1 303 See Other');
77 header('Location: index.php' . PMA_URL_getCommon() . '&page=config');
78 exit;