Translated using Weblate (Interlingua)
[phpmyadmin.git] / setup / config.php
blobdb9e7c905e4cc1f287490c3c02d305298b19d9c3
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 /**
19 * Loads configuration file path
21 * Do this in a function to avoid messing up with global $cfg
23 * @param string $config_file_path
25 * @return array
27 function loadConfig($config_file_path)
29 $cfg = array();
30 if (file_exists($config_file_path)) {
31 include $config_file_path;
33 return $cfg;
36 $form_display = new FormDisplay($GLOBALS['ConfigFile']);
37 $form_display->registerForm('_config.php', $forms['_config.php']);
38 $form_display->save('_config.php');
39 $config_file_path = $GLOBALS['ConfigFile']->getFilePath();
41 if (isset($_POST['eol'])) {
42 $_SESSION['eol'] = ($_POST['eol'] == 'unix') ? 'unix' : 'win';
45 if (PMA_ifSetOr($_POST['submit_clear'], '')) {
47 // Clear current config and return to main page
49 $GLOBALS['ConfigFile']->resetConfigData();
50 // drop post data
51 header('HTTP/1.1 303 See Other');
52 header('Location: index.php' . PMA_URL_getCommon());
53 exit;
54 } elseif (PMA_ifSetOr($_POST['submit_download'], '')) {
56 // Output generated config file
58 PMA_downloadHeader('config.inc.php', 'text/plain');
59 echo ConfigGenerator::getConfigFile($GLOBALS['ConfigFile']);
60 exit;
61 } elseif (PMA_ifSetOr($_POST['submit_save'], '')) {
63 // Save generated config file on the server
65 $result = @file_put_contents(
66 $config_file_path,
67 ConfigGenerator::getConfigFile($GLOBALS['ConfigFile'])
69 if ($result === false) {
70 $state = 'config_not_saved';
71 } else {
72 $state = 'config_saved';
74 header('HTTP/1.1 303 See Other');
75 header('Location: index.php' . PMA_URL_getCommon() . '&action_done=' . $state);
76 exit;
77 } elseif (PMA_ifSetOr($_POST['submit_load'], '')) {
79 // Load config file from the server
81 $GLOBALS['ConfigFile']->setConfigData(
82 loadConfig($config_file_path)
84 header('HTTP/1.1 303 See Other');
85 header('Location: index.php' . PMA_URL_getCommon());
86 exit;
87 } elseif (PMA_ifSetOr($_POST['submit_delete'], '')) {
89 // Delete config file on the server
91 @unlink($config_file_path);
92 header('HTTP/1.1 303 See Other');
93 header('Location: index.php' . PMA_URL_getCommon());
94 exit;
95 } else {
97 // Show generated config file in a <textarea>
99 header('HTTP/1.1 303 See Other');
100 header('Location: index.php' . PMA_URL_getCommon() . '&page=config');
101 exit;