/**
  * Runs validation for all registered forms
  *
  * @uses ConfigFile::getInstance()
  * @uses ConfigFile::getValue()
  * @uses PMA_config_validate()
  */
 private function _validate()
 {
     if ($this->is_validated) {
         return;
     }
     $cf = ConfigFile::getInstance();
     $paths = array();
     $values = array();
     foreach ($this->forms as $form) {
         /* @var $form Form */
         $paths[] = $form->name;
         // collect values and paths
         foreach ($form->fields as $path) {
             $work_path = array_search($path, $this->system_paths);
             $values[$path] = $cf->getValue($work_path);
             $paths[] = $path;
         }
     }
     // run validation
     $errors = PMA_config_validate($paths, $values, false);
     // change error keys from canonical paths to work paths
     if (is_array($errors) && count($errors) > 0) {
         $this->errors = array();
         foreach ($errors as $path => $error_list) {
             $work_path = array_search($path, $this->system_paths);
             // field error
             if (!$work_path) {
                 // form error, fix path
                 $work_path = $path;
             }
             $this->errors[$work_path] = $error_list;
         }
     }
     $this->is_validated = true;
 }
示例#2
0
<?php

/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * Validation callback.
 *
 * @package PhpMyAdmin-setup
 */
/**
 * Core libraries.
 */
require './lib/common.inc.php';
$validators = array();
require './libraries/config/validate.lib.php';
header('Content-type: application/json');
$vids = explode(',', filter_input(INPUT_POST, 'id'));
$values = json_decode(filter_input(INPUT_POST, 'values'));
if (!$values instanceof stdClass) {
    die(__('Wrong data'));
}
$values = (array) $values;
$result = PMA_config_validate($vids, $values, true);
if ($result === false) {
    $result = 'Wrong data or no validation for ' . $vids;
}
echo $result !== true ? json_encode($result) : '';