lint.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Represents the interface between the linter and the query editor.
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. use PhpMyAdmin\Core;
  9. use PhpMyAdmin\Linter;
  10. use PhpMyAdmin\Response;
  11. $_GET['ajax_request'] = 'true';
  12. /**
  13. * Loading common files. Used to check for authorization, localization and to
  14. * load the parsing library.
  15. */
  16. require_once 'libraries/common.inc.php';
  17. /**
  18. * The SQL query to be analyzed.
  19. *
  20. * This does not need to be checked again XSS or MySQL injections because it is
  21. * never executed, just parsed.
  22. *
  23. * The client, which will recieve the JSON response will decode the message and
  24. * and any HTML fragments that are displayed to the user will be encoded anyway.
  25. *
  26. * @var string
  27. */
  28. $sql_query = !empty($_POST['sql_query']) ? $_POST['sql_query'] : '';
  29. // Disabling standard response.
  30. Response::getInstance()->disable();
  31. Core::headerJSON();
  32. if (! empty($_POST['options'])) {
  33. $options = $_POST['options'];
  34. if (! empty($options['routine_editor'])) {
  35. $sql_query = 'CREATE PROCEDURE `a`() ' . $sql_query;
  36. } elseif (! empty($options['trigger_editor'])) {
  37. $sql_query = 'CREATE TRIGGER `a` AFTER INSERT ON `b` FOR EACH ROW '
  38. . $sql_query;
  39. } elseif (! empty($options['event_editor'])) {
  40. $sql_query = 'CREATE EVENT `a` ON SCHEDULE EVERY MINUTE DO ' . $sql_query;
  41. }
  42. }
  43. echo json_encode(Linter::lint($sql_query));