Пример #1
0
/**
 * Represents the interface between the linter and  the query editor.
 *
 * @package PhpMyAdmin
 */
/**
 * Loading common files. Used to check for authorization, localization and to
 * load the parsing library.
 */
require_once 'libraries/common.inc.php';
/**
 * Loads the linter.
 */
require_once 'libraries/Linter.class.php';
/**
 * The SQL query to be analyzed.
 *
 * This does not need to be checked again XSS or MySQL injections because it is
 * never executed, just parsed.
 *
 * The client, which will recieve the JSON response will decode the message and
 * and any HTML fragments that are displayed to the user will be encoded anyway.
 *
 * @var string
 */
$sql_query = !empty($_POST['sql_query']) ? $_POST['sql_query'] : '';
// Disabling standard response.
$response = PMA_Response::getInstance();
$response->disable();
echo json_encode(PMA_Linter::lint($sql_query));
Пример #2
0
/**
 * Represents the interface between the linter and  the query editor.
 *
 * @package PhpMyAdmin
 */
define('PHPMYADMIN', true);
// We load the minimum files required to check if the user is logged in.
require_once 'libraries/core.lib.php';
require_once 'libraries/Config.class.php';
$GLOBALS['PMA_Config'] = new PMA_Config(CONFIG_FILE);
require_once 'libraries/session.inc.php';
// If user is not logged in, he should not send any requests, so we exit here to
// avoid external requests.
if (empty($_SESSION['encryption_key'])) {
    // Unauthorized access detected.
    exit;
}
/**
 * Loads the SQL lexer and parser, which are used to detect errors.
 */
require_once 'libraries/sql-parser/autoload.php';
/**
 * Loads the linter.
 */
require_once 'libraries/Linter.class.php';
// The input of this function does not need to be checked again XSS or MySQL
// injections because it is never executed, just parsed.
// The client, which will recieve the JSON response will decode the message and
// and any HTML fragments that are displayed to the user will be encoded anyway.
PMA_Linter::lint($_REQUEST['sql_query']);
Пример #3
0
 /**
  * Test for PMA_Linter::lint
  *
  * @return void
  */
 public function testLongQuery()
 {
     $this->expectOutputString(json_encode(array(array('message' => 'Linting is disabled for this query because it exceeds the maximum length.', 'fromLine' => 0, 'fromColumn' => 0, 'toLine' => 0, 'toColumn' => 0, 'severity' => 'warning'))));
     PMA_Linter::lint(str_repeat(";", 10001));
 }
Пример #4
0
 /**
  * Test for PMA_Linter::lint
  *
  * @dataProvider testLintProvider
  *
  * @param array  $expected The expected result.
  * @param string $query    The query to be analyzed.
  *
  * @return void
  */
 public function testLint($expected, $query)
 {
     $this->assertEquals($expected, PMA_Linter::lint($query));
 }