예제 #1
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/Validator.class.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) {
    PMA_fatalError(__('Wrong data'));
}
$values = (array) $values;
$result = PMA_Validator::validate($GLOBALS['ConfigFile'], $vids, $values, true);
if ($result === false) {
    $result = 'Wrong data or no validation for ' . $vids;
}
echo $result !== true ? json_encode($result) : '';
예제 #2
0
 /**
  * Runs validation for all registered forms
  *
  * @return void
  */
 private function _validate()
 {
     if ($this->_isValidated) {
         return;
     }
     $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->_systemPaths);
             $values[$path] = $this->_configFile->getValue($work_path);
             $paths[] = $path;
         }
     }
     // run validation
     $errors = PMA_Validator::validate($this->_configFile, $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->_systemPaths);
             // field error
             if (!$work_path) {
                 // form error, fix path
                 $work_path = $path;
             }
             $this->_errors[$work_path] = $error_list;
         }
     }
     $this->_isValidated = true;
 }