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