Fix #16786 - JS error when clicking on phpMyAdmin logo link defined to an external...
[phpmyadmin.git] / setup / validate.php
blob7833d952d182d714ab4aae9b678955bc87236010
1 <?php
2 /**
3 * Validation callback.
4 */
6 declare(strict_types=1);
8 use PhpMyAdmin\Config\Validator;
9 use PhpMyAdmin\Core;
11 if (! defined('ROOT_PATH')) {
12 // phpcs:disable PSR1.Files.SideEffects
13 define('ROOT_PATH', dirname(__DIR__) . DIRECTORY_SEPARATOR);
14 // phpcs:enable
17 /**
18 * Core libraries.
20 require ROOT_PATH . 'setup/lib/common.inc.php';
22 $validators = [];
24 Core::headerJSON();
26 $ids = Core::isValid($_POST['id'], 'scalar') ? $_POST['id'] : null;
27 $vids = explode(',', $ids);
28 $vals = Core::isValid($_POST['values'], 'scalar') ? $_POST['values'] : null;
29 $values = json_decode($vals);
30 if (! ($values instanceof stdClass)) {
31 Core::fatalError(__('Wrong data'));
33 $values = (array) $values;
34 $result = Validator::validate($GLOBALS['ConfigFile'], $vids, $values, true);
35 if ($result === false) {
36 $result = sprintf(
37 __('Wrong data or no validation for %s'),
38 implode(',', $vids)
41 echo $result !== true ? json_encode($result) : '';