validate.php 845 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Validation callback.
  5. *
  6. * @package PhpMyAdmin-Setup
  7. */
  8. use PhpMyAdmin\Config\Validator;
  9. use PhpMyAdmin\Core;
  10. /**
  11. * Core libraries.
  12. */
  13. require './lib/common.inc.php';
  14. $validators = array();
  15. Core::headerJSON();
  16. $ids = Core::isValid($_POST['id'], 'scalar') ? $_POST['id'] : null;
  17. $vids = explode(',', $ids);
  18. $vals = Core::isValid($_POST['values'], 'scalar') ? $_POST['values'] : null;
  19. $values = json_decode($vals);
  20. if (!($values instanceof stdClass)) {
  21. Core::fatalError(__('Wrong data'));
  22. }
  23. $values = (array)$values;
  24. $result = Validator::validate($GLOBALS['ConfigFile'], $vids, $values, true);
  25. if ($result === false) {
  26. $result = sprintf(
  27. __('Wrong data or no validation for %s'),
  28. implode(',', $vids)
  29. );
  30. }
  31. echo $result !== true ? json_encode($result) : '';