Fix typo
This commit is contained in:
@@ -24,234 +24,235 @@ if (!defined('PMA_SQL_VALIDATOR_CLASS_INCLUDED')) {
|
|||||||
define('PMA_SQL_VALIDATOR_CLASS_INCLUDED', 1);
|
define('PMA_SQL_VALIDATOR_CLASS_INCLUDED', 1);
|
||||||
|
|
||||||
@include("SOAP/Client.php");
|
@include("SOAP/Client.php");
|
||||||
if(!class_exists('SOAP_Client') {
|
if(!class_exists('SOAP_Client')) {
|
||||||
$GLOBALS['sqlvalidator_error'] = TRUE;
|
$GLOBALS['sqlvalidator_error'] = TRUE;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Ok, so we have SOAP Support, so let's use it!
|
// Ok, so we have SOAP Support, so let's use it!
|
||||||
|
|
||||||
class SQLValidator {
|
class SQLValidator {
|
||||||
|
|
||||||
var $url;
|
var $url;
|
||||||
var $serviceName;
|
var $serviceName;
|
||||||
var $wsdl;
|
var $wsdl;
|
||||||
var $outputType;
|
var $outputType;
|
||||||
|
|
||||||
var $username;
|
var $username;
|
||||||
var $password;
|
var $password;
|
||||||
var $callingProgram;
|
var $callingProgram;
|
||||||
var $callingProgramVersion;
|
var $callingProgramVersion;
|
||||||
var $targetDbms;
|
var $targetDbms;
|
||||||
var $targetDbmsVersion;
|
var $targetDbmsVersion;
|
||||||
var $connectionTechnology;
|
var $connectionTechnology;
|
||||||
var $connectionTechnologyVersion;
|
var $connectionTechnologyVersion;
|
||||||
var $interactive;
|
var $interactive;
|
||||||
|
|
||||||
var $serviceLink = NULL;
|
var $serviceLink = NULL;
|
||||||
var $sessionData = NULL;
|
var $sessionData = NULL;
|
||||||
|
|
||||||
function dataInit()
|
function dataInit()
|
||||||
{
|
{
|
||||||
$this->url = "http://sqlvalidator.mimer.com/v1/services";
|
$this->url = "http://sqlvalidator.mimer.com/v1/services";
|
||||||
$this->serviceName = 'SQL99Validator';
|
$this->serviceName = 'SQL99Validator';
|
||||||
$this->wsdl = '?wsdl';
|
$this->wsdl = '?wsdl';
|
||||||
|
|
||||||
$this->outputType = 'html';
|
|
||||||
|
|
||||||
$this->username = 'anonymous';
|
$this->outputType = 'html';
|
||||||
$this->password = '';
|
|
||||||
$this->callingProgram = 'PHP_SQLValidator';
|
|
||||||
$this->callingProgramVersion = '$Revision$';
|
|
||||||
$this->targetDbms = 'N/A';
|
|
||||||
$this->targetDbmsVersion = 'N/A';
|
|
||||||
$this->connectionTechnology = 'PHP';
|
|
||||||
$this->connectionTechnologyVersion = phpversion();
|
|
||||||
$this->interactive = 1;
|
|
||||||
|
|
||||||
$this->serviceLink = NULL;
|
$this->username = 'anonymous';
|
||||||
$this->sessionData = NULL;
|
$this->password = '';
|
||||||
}
|
$this->callingProgram = 'PHP_SQLValidator';
|
||||||
|
$this->callingProgramVersion = '$Revision$';
|
||||||
|
$this->targetDbms = 'N/A';
|
||||||
|
$this->targetDbmsVersion = 'N/A';
|
||||||
|
$this->connectionTechnology = 'PHP';
|
||||||
|
$this->connectionTechnologyVersion = phpversion();
|
||||||
|
$this->interactive = 1;
|
||||||
|
|
||||||
function SQLValidator()
|
$this->serviceLink = NULL;
|
||||||
{
|
$this->sessionData = NULL;
|
||||||
$this->dataInit();
|
|
||||||
}
|
|
||||||
|
|
||||||
function setCredentials($username,$password)
|
|
||||||
{
|
|
||||||
$this->username = $username;
|
|
||||||
$this->password = $password;
|
|
||||||
}
|
|
||||||
|
|
||||||
function setCallingProgram($callingProgram,$callingProgramVersion)
|
|
||||||
{
|
|
||||||
$this->callingProgram = $callingProgram;
|
|
||||||
$this->callingProgramVersion = $callingProgramVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
function appendCallingProgram($callingProgram,$callingProgramVersion)
|
|
||||||
{
|
|
||||||
$this->callingProgram .= ' - ' . $callingProgram;
|
|
||||||
$this->callingProgramVersion .= ' - ' . $callingProgramVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
function setTargetDbms($targetDbms,$targetDbmsVersion)
|
|
||||||
{
|
|
||||||
$this->targetDbms = $targetDbms;
|
|
||||||
$this->targetDbmsVersion = $targetDbmsVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
function appendTargetDbms($targetDbms,$targetDbmsVersion)
|
|
||||||
{
|
|
||||||
$this->targetDbms .= ' - ' . $targetDbms;
|
|
||||||
$this->targetDbmsVersion .= ' - ' . $targetDbmsVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
function setConnectionTechnology($connectionTechnology,$connectionTechnologyVersion)
|
|
||||||
{
|
|
||||||
$this->connectionTechnology = $connectionTechnology;
|
|
||||||
$this->connectionTechnologyVersion = $connectionTechnologyVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
function appendConnectionTechnology($connectionTechnology,$connectionTechnologyVersion)
|
|
||||||
{
|
|
||||||
$this->connectionTechnology .= ' - ' . $connectionTechnology;
|
|
||||||
$this->connectionTechnologyVersion .= ' - ' . $connectionTechnologyVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
function setInteractive($interactive)
|
|
||||||
{
|
|
||||||
$this->interactive = $interactive;
|
|
||||||
}
|
|
||||||
|
|
||||||
function setOutputType($outputtype)
|
|
||||||
{
|
|
||||||
$this->OutputType = $outputtype;
|
|
||||||
}
|
|
||||||
|
|
||||||
function start()
|
|
||||||
{
|
|
||||||
$this->startService();
|
|
||||||
$this->startSession();
|
|
||||||
}
|
|
||||||
|
|
||||||
function startService()
|
|
||||||
{
|
|
||||||
$this->serviceLink = $this->_openService($this->url.'/'.$this->serviceName.$this->wsdl);
|
|
||||||
}
|
|
||||||
|
|
||||||
function startSession()
|
|
||||||
{
|
|
||||||
$this->sessionData = $this->_openSession($this->serviceLink, $this->username, $this->password, $this->callingProgram, $this->callingProgramVersion, $this->targetDbms, $this->targetDbmsVersion, $this->connectionTechnology, $this->connectionTechnologyVersion, $this->interactive);
|
|
||||||
|
|
||||||
if( isset($this->sessionData) &&
|
|
||||||
($this->sessionData != NULL) &&
|
|
||||||
($this->sessionData->target != $this->url))
|
|
||||||
{
|
|
||||||
// Reopen the service on the new URL that was provided
|
|
||||||
$url = $this->sessionData->target;
|
|
||||||
$this->startService();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
function SQLValidator()
|
||||||
* Call to determine just if a query is valid or not.
|
{
|
||||||
*
|
$this->dataInit();
|
||||||
* @param string SQL statement to validate
|
}
|
||||||
*
|
|
||||||
* @return string Validator string from Mimer
|
|
||||||
*
|
|
||||||
* @see _validate
|
|
||||||
*/
|
|
||||||
function isValid($sql)
|
|
||||||
{
|
|
||||||
$res = $this->_validate($sql);
|
|
||||||
return $res->standard;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Call for complete validator response
|
|
||||||
*
|
|
||||||
* @param string SQL statement to validate
|
|
||||||
*
|
|
||||||
* @return string Validator string from Mimer
|
|
||||||
*
|
|
||||||
* @see _validate
|
|
||||||
*/
|
|
||||||
function ValidationString($sql)
|
|
||||||
{
|
|
||||||
$res = $this->_validate($sql);
|
|
||||||
return $res->data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Private functions beyond here
|
function setCredentials($username,$password)
|
||||||
* You don't need to mess with these
|
{
|
||||||
*/
|
$this->username = $username;
|
||||||
|
$this->password = $password;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
function setCallingProgram($callingProgram,$callingProgramVersion)
|
||||||
* Service opening
|
{
|
||||||
*
|
$this->callingProgram = $callingProgram;
|
||||||
* @param string URL of Mimer SQL Validator WSDL file
|
$this->callingProgramVersion = $callingProgramVersion;
|
||||||
*
|
}
|
||||||
* @return object Object to use
|
|
||||||
*/
|
|
||||||
function _openService($url)
|
|
||||||
{
|
|
||||||
$obj = new SOAP_Client($url,TRUE);
|
|
||||||
return $obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
function appendCallingProgram($callingProgram,$callingProgramVersion)
|
||||||
* Service initializer to connect to server
|
{
|
||||||
*
|
$this->callingProgram .= ' - ' . $callingProgram;
|
||||||
* @param object Service object
|
$this->callingProgramVersion .= ' - ' . $callingProgramVersion;
|
||||||
* @param string Username
|
}
|
||||||
* @param string Password
|
|
||||||
* @param string Name of calling program
|
|
||||||
* @param string Version of calling program
|
|
||||||
* @param string Target DBMS
|
|
||||||
* @param string Version of target DBMS
|
|
||||||
* @param string Connection Technology
|
|
||||||
* @param string version of Connection Technology
|
|
||||||
* @param number boolean of 1/0 to specify if we are an interactive system
|
|
||||||
*
|
|
||||||
* @return object stdClass return object with data
|
|
||||||
*/
|
|
||||||
function _openSession($obj, $username, $password, $callingProgram, $callingProgramVersion, $targetDbms, $targetDbmsVersion, $connectionTechnology, $connectionTechnologyVersion, $interactive)
|
|
||||||
{
|
|
||||||
|
|
||||||
$ret = $obj->openSession($username, $password, $callingProgram, $callingProgramVersion, $targetDbms, $targetDbmsVersion, $connectionTechnology, $connectionTechnologyVersion, $interactive);
|
function setTargetDbms($targetDbms,$targetDbmsVersion)
|
||||||
|
{
|
||||||
|
$this->targetDbms = $targetDbms;
|
||||||
|
$this->targetDbmsVersion = $targetDbmsVersion;
|
||||||
|
}
|
||||||
|
|
||||||
return $ret;
|
function appendTargetDbms($targetDbms,$targetDbmsVersion)
|
||||||
}
|
{
|
||||||
|
$this->targetDbms .= ' - ' . $targetDbms;
|
||||||
|
$this->targetDbmsVersion .= ' - ' . $targetDbmsVersion;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
function setConnectionTechnology($connectionTechnology,$connectionTechnologyVersion)
|
||||||
* Validator sytem call
|
{
|
||||||
*
|
$this->connectionTechnology = $connectionTechnology;
|
||||||
* @param object Service object
|
$this->connectionTechnologyVersion = $connectionTechnologyVersion;
|
||||||
* @param object Session object
|
}
|
||||||
* @param string SQL Query to validate
|
|
||||||
* @param string Data return type
|
|
||||||
*
|
|
||||||
* @return object stClass return with data
|
|
||||||
*/
|
|
||||||
function _validateSQL($obj,$session,$sql,$method)
|
|
||||||
{
|
|
||||||
$res = $obj->validateSQL($session->sessionId, $session->sessionKey, $sql, $this->outputType);
|
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
function appendConnectionTechnology($connectionTechnology,$connectionTechnologyVersion)
|
||||||
* Validator sytem call
|
{
|
||||||
*
|
$this->connectionTechnology .= ' - ' . $connectionTechnology;
|
||||||
* @param string SQL Query to validate
|
$this->connectionTechnologyVersion .= ' - ' . $connectionTechnologyVersion;
|
||||||
*
|
}
|
||||||
* @return object stClass return with data
|
|
||||||
*/
|
function setInteractive($interactive)
|
||||||
function _validate($sql)
|
{
|
||||||
{
|
$this->interactive = $interactive;
|
||||||
$ret = $this->_validateSQL($this->serviceLink, $this->sessionData, $sql, $this->outputType);
|
}
|
||||||
return $ret;
|
|
||||||
|
function setOutputType($outputtype)
|
||||||
|
{
|
||||||
|
$this->OutputType = $outputtype;
|
||||||
|
}
|
||||||
|
|
||||||
|
function start()
|
||||||
|
{
|
||||||
|
$this->startService();
|
||||||
|
$this->startSession();
|
||||||
|
}
|
||||||
|
|
||||||
|
function startService()
|
||||||
|
{
|
||||||
|
$this->serviceLink = $this->_openService($this->url.'/'.$this->serviceName.$this->wsdl);
|
||||||
|
}
|
||||||
|
|
||||||
|
function startSession()
|
||||||
|
{
|
||||||
|
$this->sessionData = $this->_openSession($this->serviceLink, $this->username, $this->password, $this->callingProgram, $this->callingProgramVersion, $this->targetDbms, $this->targetDbmsVersion, $this->connectionTechnology, $this->connectionTechnologyVersion, $this->interactive);
|
||||||
|
|
||||||
|
if( isset($this->sessionData) &&
|
||||||
|
($this->sessionData != NULL) &&
|
||||||
|
($this->sessionData->target != $this->url))
|
||||||
|
{
|
||||||
|
// Reopen the service on the new URL that was provided
|
||||||
|
$url = $this->sessionData->target;
|
||||||
|
$this->startService();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call to determine just if a query is valid or not.
|
||||||
|
*
|
||||||
|
* @param string SQL statement to validate
|
||||||
|
*
|
||||||
|
* @return string Validator string from Mimer
|
||||||
|
*
|
||||||
|
* @see _validate
|
||||||
|
*/
|
||||||
|
function isValid($sql)
|
||||||
|
{
|
||||||
|
$res = $this->_validate($sql);
|
||||||
|
return $res->standard;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call for complete validator response
|
||||||
|
*
|
||||||
|
* @param string SQL statement to validate
|
||||||
|
*
|
||||||
|
* @return string Validator string from Mimer
|
||||||
|
*
|
||||||
|
* @see _validate
|
||||||
|
*/
|
||||||
|
function ValidationString($sql)
|
||||||
|
{
|
||||||
|
$res = $this->_validate($sql);
|
||||||
|
return $res->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Private functions beyond here
|
||||||
|
* You don't need to mess with these
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Service opening
|
||||||
|
*
|
||||||
|
* @param string URL of Mimer SQL Validator WSDL file
|
||||||
|
*
|
||||||
|
* @return object Object to use
|
||||||
|
*/
|
||||||
|
function _openService($url)
|
||||||
|
{
|
||||||
|
$obj = new SOAP_Client($url,TRUE);
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Service initializer to connect to server
|
||||||
|
*
|
||||||
|
* @param object Service object
|
||||||
|
* @param string Username
|
||||||
|
* @param string Password
|
||||||
|
* @param string Name of calling program
|
||||||
|
* @param string Version of calling program
|
||||||
|
* @param string Target DBMS
|
||||||
|
* @param string Version of target DBMS
|
||||||
|
* @param string Connection Technology
|
||||||
|
* @param string version of Connection Technology
|
||||||
|
* @param number boolean of 1/0 to specify if we are an interactive system
|
||||||
|
*
|
||||||
|
* @return object stdClass return object with data
|
||||||
|
*/
|
||||||
|
function _openSession($obj, $username, $password, $callingProgram, $callingProgramVersion, $targetDbms, $targetDbmsVersion, $connectionTechnology, $connectionTechnologyVersion, $interactive)
|
||||||
|
{
|
||||||
|
|
||||||
|
$ret = $obj->openSession($username, $password, $callingProgram, $callingProgramVersion, $targetDbms, $targetDbmsVersion, $connectionTechnology, $connectionTechnologyVersion, $interactive);
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validator sytem call
|
||||||
|
*
|
||||||
|
* @param object Service object
|
||||||
|
* @param object Session object
|
||||||
|
* @param string SQL Query to validate
|
||||||
|
* @param string Data return type
|
||||||
|
*
|
||||||
|
* @return object stClass return with data
|
||||||
|
*/
|
||||||
|
function _validateSQL($obj,$session,$sql,$method)
|
||||||
|
{
|
||||||
|
$res = $obj->validateSQL($session->sessionId, $session->sessionKey, $sql, $this->outputType);
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validator sytem call
|
||||||
|
*
|
||||||
|
* @param string SQL Query to validate
|
||||||
|
*
|
||||||
|
* @return object stClass return with data
|
||||||
|
*/
|
||||||
|
function _validate($sql)
|
||||||
|
{
|
||||||
|
$ret = $this->_validateSQL($this->serviceLink, $this->sessionData, $sql, $this->outputType);
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user