"Fossies" - the Fresh Open Source Software Archive

Member "phpMyAdmin-5.1.0-all-languages/setup/validate.php" (24 Feb 2021, 972 Bytes) of package /linux/www/phpMyAdmin-5.1.0-all-languages.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "validate.php": 5.0.4-english_vs_5.1.0-english.

    1 <?php
    2 /**
    3  * Validation callback.
    4  */
    5 
    6 declare(strict_types=1);
    7 
    8 use PhpMyAdmin\Config\Validator;
    9 use PhpMyAdmin\Core;
   10 
   11 if (! defined('ROOT_PATH')) {
   12     // phpcs:disable PSR1.Files.SideEffects
   13     define('ROOT_PATH', dirname(__DIR__) . DIRECTORY_SEPARATOR);
   14     // phpcs:enable
   15 }
   16 
   17 /**
   18  * Core libraries.
   19  */
   20 require ROOT_PATH . 'setup/lib/common.inc.php';
   21 
   22 $validators = [];
   23 
   24 Core::headerJSON();
   25 
   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'));
   32 }
   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)
   39     );
   40 }
   41 echo $result !== true ? json_encode($result) : '';