1<?php 2/** 3 * Front controller for config view / download and clear 4 */ 5 6declare(strict_types=1); 7 8use PhpMyAdmin\Config\Forms\Setup\ConfigForm; 9use PhpMyAdmin\Core; 10use PhpMyAdmin\Response; 11use PhpMyAdmin\Setup\ConfigGenerator; 12use PhpMyAdmin\Url; 13 14if (! defined('ROOT_PATH')) { 15 // phpcs:disable PSR1.Files.SideEffects 16 define('ROOT_PATH', dirname(__DIR__) . DIRECTORY_SEPARATOR); 17 // phpcs:enable 18} 19 20/** 21 * Core libraries. 22 */ 23require ROOT_PATH . 'setup/lib/common.inc.php'; 24 25$form_display = new ConfigForm($GLOBALS['ConfigFile']); 26$form_display->save('Config'); 27 28$response = Response::getInstance(); 29$response->disable(); 30 31if (isset($_POST['eol'])) { 32 $_SESSION['eol'] = $_POST['eol'] === 'unix' ? 'unix' : 'win'; 33} 34 35if (Core::ifSetOr($_POST['submit_clear'], '')) { 36 // Clear current config and return to main page 37 $GLOBALS['ConfigFile']->resetConfigData(); 38 // drop post data 39 $response->generateHeader303('index.php' . Url::getCommonRaw()); 40 exit; 41} 42 43if (Core::ifSetOr($_POST['submit_download'], '')) { 44 // Output generated config file 45 Core::downloadHeader('config.inc.php', 'text/plain'); 46 $response->disable(); 47 echo ConfigGenerator::getConfigFile($GLOBALS['ConfigFile']); 48 exit; 49} 50 51// Show generated config file in a <textarea> 52$response->generateHeader303('index.php' . Url::getCommonRaw(['page' => 'config'])); 53exit; 54