Loic's code updates
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
/** SQL Validator interface for phpMyAdmin
|
|
||||||
|
/**
|
||||||
|
* SQL Validator interface for phpMyAdmin
|
||||||
*
|
*
|
||||||
* Copyright 2002 Robin Johnson <robbat2@users.sourceforge.net>
|
* Copyright 2002 Robin Johnson <robbat2@users.sourceforge.net>
|
||||||
* http://www.orbis-terrarum.net/?l=people.robbat2
|
* http://www.orbis-terrarum.net/?l=people.robbat2
|
||||||
@@ -28,16 +30,18 @@
|
|||||||
* Also set a username and password if you have a private one
|
* Also set a username and password if you have a private one
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
if (!defined('PMA_SQL_VALIDATOR_INCLUDED')) {
|
if (!defined('PMA_SQL_VALIDATOR_INCLUDED')) {
|
||||||
define('PMA_SQL_VALIDATOR_INCLUDED', 1);
|
define('PMA_SQL_VALIDATOR_INCLUDED', 1);
|
||||||
|
|
||||||
// We need the PEAR libraries, so do a minimum version check first
|
// We need the PEAR libraries, so do a minimum version check first
|
||||||
// I'm not sure if PEAR was available before this point
|
// I'm not sure if PEAR was available before this point
|
||||||
// For now we actually use a configuration flag
|
// For now we actually use a configuration flag
|
||||||
if ($cfg['SQLValidator']['use'] == TRUE) {
|
if ($cfg['SQLValidator']['use'] == TRUE && !defined(PMA_SQL_VALIDATOR_CLASS_INCLUDED)) {
|
||||||
include_once('sqlvalidator.class.php3');
|
include('./sqlvalidator.class.php3');
|
||||||
} // if ($cfg['SQLValidator']['use'] == TRUE)
|
} // if ($cfg['SQLValidator']['use'] == TRUE)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function utilizes the Mimer SQL Validator service
|
* This function utilizes the Mimer SQL Validator service
|
||||||
* to validate an SQL query
|
* to validate an SQL query
|
||||||
@@ -47,55 +51,48 @@ if (!defined('PMA_SQL_VALIDATOR_INCLUDED')) {
|
|||||||
* @param string SQL query to validate
|
* @param string SQL query to validate
|
||||||
*
|
*
|
||||||
* @return string Validator result string
|
* @return string Validator result string
|
||||||
|
*
|
||||||
|
* @global array The PMA configuration array
|
||||||
*/
|
*/
|
||||||
function validateSQL($sql)
|
function PMA_validateSQL($sql)
|
||||||
{
|
{
|
||||||
global $cfg;
|
global $cfg;
|
||||||
|
|
||||||
$str = '';
|
$str = '';
|
||||||
|
|
||||||
if ($cfg['SQLValidator']['use'] == TRUE) {
|
if ($cfg['SQLValidator']['use'] == TRUE) {
|
||||||
// create new class instance
|
// create new class instance
|
||||||
$srv = new SQLValidator();
|
$srv = new PMA_SQLValidator();
|
||||||
|
|
||||||
// check for username settings
|
// Checks for username settings
|
||||||
// The class defaults to anonymous with an empty password
|
// The class defaults to anonymous with an empty password
|
||||||
// automatically
|
// automatically
|
||||||
if ($cfg['SQLValidator']['username'] != '') {
|
if ($cfg['SQLValidator']['username'] != '') {
|
||||||
$srv->setCredentials($cfg['SQLValidator']['username'], $cfg['SQLValidator']['password']);
|
$srv->setCredentials($cfg['SQLValidator']['username'], $cfg['SQLValidator']['password']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Identify ourselves to the server properly
|
// Identify ourselves to the server properly...
|
||||||
$srv->appendCallingProgram('phpMyAdmin', PMA_VERSION);
|
$srv->appendCallingProgram('phpMyAdmin', PMA_VERSION);
|
||||||
|
|
||||||
// And specify what database system we are using
|
// ... and specify what database system we are using
|
||||||
$srv->setTargetDbms('MySQL', PMA_MYSQL_STR_VERSION);
|
$srv->setTargetDbms('MySQL', PMA_MYSQL_STR_VERSION);
|
||||||
|
|
||||||
// Log on to service
|
// Log on to service
|
||||||
$srv->start();
|
$srv->start();
|
||||||
|
|
||||||
// Do service validation
|
// Do service validation
|
||||||
$str = $srv->ValidationString($sql);
|
$str = $srv->validationString($sql);
|
||||||
|
|
||||||
// Strip out the copyright if requested
|
|
||||||
if($cfg['SQLValidator']['DisplayCopyright'] != TRUE) {
|
|
||||||
$match = "reserved.<br/>\n<br/>";
|
|
||||||
$pos = strpos($str,$match);
|
|
||||||
$pos += strlen($match);
|
|
||||||
$str = substr($str,$pos);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
else {
|
||||||
|
// The service is not available so note that properly
|
||||||
// The service is not available
|
|
||||||
// So note that properly
|
|
||||||
$str = $GLOBALS['strValidatorDisabled'];
|
$str = $GLOBALS['strValidatorDisabled'];
|
||||||
|
} // end if... else...
|
||||||
|
|
||||||
}
|
// Gives string back to caller
|
||||||
|
|
||||||
// Give string back to caller
|
|
||||||
return $str;
|
return $str;
|
||||||
|
} // end of the "PMA_validateSQL()" function
|
||||||
} // function validateSQL($sql)
|
|
||||||
|
|
||||||
|
|
||||||
} // $__PMA_SQL_VALIDATOR__
|
} // $__PMA_SQL_VALIDATOR__
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user