Remove support for SQL validator

The SOAP service seems to be down for quite some time and it is not
mentioned anywhere on Mimer website.

Signed-off-by: Michal Čihař <michal@cihar.com>
This commit is contained in:
Michal Čihař 2014-04-02 12:09:00 +02:00
parent 2ef07440f6
commit 7233657d4d
15 changed files with 5 additions and 954 deletions

View File

@ -2369,15 +2369,6 @@ SQL query box settings
Whether to display a link to wrap a query in PHP code in any SQL Query
box.
.. config:option:: $cfg['SQLQuery']['Validate']
:type: boolean
:default: false
Whether to display a link to validate a query in any SQL Query box.
.. seealso:: :config:option:`$cfg['SQLValidator']`
.. config:option:: $cfg['SQLQuery']['Refresh']
:type: boolean
@ -2706,42 +2697,6 @@ Default queries
Default queries that will be displayed in query boxes when user didn't
specify any. You can use standard :ref:`faq6_27`.
SQL validator settings
----------------------
.. config:option:: $cfg['SQLValidator']
:type: array
:default: array(...)
.. config:option:: $cfg['SQLValidator']['use']
:type: boolean
:default: false
phpMyAdmin now supports use of the `Mimer SQL Validator
<http://developer.mimer.com/validator/index.htm>`_ service, as originally
published on `Slashdot
<http://developers.slashdot.org/article.pl?sid=02/02/19/1720246>`_. For
help in setting up your system to use the service, see the
:ref:`faqsqlvalidator`.
.. config:option:: $cfg['SQLValidator']['username']
:type: string
:default: ``''``
.. config:option:: $cfg['SQLValidator']['password']
:type: string
:default: ``''``
The SOAP service allows you to log in with ``anonymous`` and any password,
so we use those by default. Instead, if you have an account with them, you
can put your login details here, and it will be used in place of the
anonymous login.
MySQL settings
--------------

View File

@ -1562,21 +1562,8 @@ work with it, nor delete it.
.. _faqsqlvalidator:
6.14 How do I set up the SQL Validator?
---------------------------------------
To use SQL Validator, you need PHP with :term:`XML`, :term:`PCRE` and
:term:`PEAR` support. In addition you need a :term:`SOAP` support, either as a
PHP extension or as a PEAR SOAP module.
To install :term:`PEAR` :term:`SOAP` module, run :command:`pear install
Net_Socket Net_URL HTTP_Request Mail_Mime Net_DIME SOAP` to get the necessary
:term:`PEAR` modules for usage.
If you use the Validator, you should be aware that any :term:`SQL` statement
you submit will be stored anonymously (database/table/column names, strings,
numbers replaced with generic values). The Mimer :term:`SQL` Validator itself,
is © 2001 Upright Database Technology. We utilize it as free SOAP service.
6.14 (withdrawn).
-----------------
.. _faq6_15:

View File

@ -312,13 +312,6 @@ From Wikipedia, the free encyclopedia
.. seealso:: <http://dev.mysql.com/doc/en/storage-engines.html>
SOAP
Simple Object Access Protocol is a protocol specification for exchanging
structured information in the implementation of Web Services in computer
networks.
.. seealso:: <http://en.wikipedia.org/wiki/SOAP>
socket
a form of inter-process communication.

View File

@ -1127,14 +1127,6 @@ class PMA_Util
if (! empty($GLOBALS['show_as_php'])) {
$query_base = '$sql = "' . $query_base;
} elseif (! empty($GLOBALS['validatequery'])) {
try {
$query_base = PMA_validateSQL($query_base);
} catch (Exception $e) {
$retval .= PMA_Message::error(
__('Failed to connect to SQL validator!')
)->getDisplay();
}
} elseif (isset($query_base)) {
$query_base = self::formatSql($query_base);
}
@ -1167,11 +1159,6 @@ class PMA_Util
$is_select = preg_match('@^SELECT[[:space:]]+@i', $sql_query);
if (! empty($cfg['SQLQuery']['Explain']) && ! $query_too_big) {
$explain_params = $url_params;
// Detect if we are validating as well
// To preserve the validate uRL data
if (! empty($GLOBALS['validatequery'])) {
$explain_params['validatequery'] = 1;
}
if ($is_select) {
$explain_params['sql_query'] = 'EXPLAIN ' . $sql_query;
$_message = __('Explain SQL');
@ -1253,30 +1240,7 @@ class PMA_Util
$refresh_link = '';
} //refresh
if (! empty($cfg['SQLValidator']['use'])
&& ! empty($cfg['SQLQuery']['Validate'])
) {
$validate_params = $url_params;
if (! empty($GLOBALS['validatequery'])) {
$validate_message = __('Skip Validate SQL');
} else {
$validate_params['validatequery'] = 1;
$validate_message = __('Validate SQL');
}
$validate_link = 'import.php'
. PMA_URL_getCommon($validate_params);
$validate_link = ' ['
. self::linkOrButton($validate_link, $validate_message) . ']';
} else {
$validate_link = '';
} //validator
if (! empty($GLOBALS['validatequery'])) {
$retval .= '<div class="sqlvalidate">';
} else {
$retval .= '<div class="sqlOuter">';
}
$retval .= '<div class="sqlOuter">';
if ($query_too_big) {
$retval .= $shortened_query_base;
} else {
@ -1322,7 +1286,7 @@ class PMA_Util
$inline_edit_link = '';
}
$retval .= $inline_edit_link . $edit_link . $explain_link . $php_link
. $refresh_link . $validate_link;
. $refresh_link;
$retval .= '</div>';
}

View File

@ -1025,11 +1025,6 @@ if (! defined('PMA_MINIMUM_COMMON')) {
*/
include_once './libraries/sqlparser.lib.php';
/**
* SQL Validator interface code
*/
include_once './libraries/sqlvalidator.lib.php';
/**
* the PMA_List_Database class
*/

View File

@ -2718,13 +2718,6 @@ $cfg['SQLQuery']['Explain'] = true;
*/
$cfg['SQLQuery']['ShowAsPHP'] = true;
/**
* Validate a query (see $cfg['SQLValidator'] as well)
*
* @global boolean $cfg['SQLQuery']['Validate']
*/
$cfg['SQLQuery']['Validate'] = false;
/**
* Refresh the results page
*
@ -2824,38 +2817,6 @@ $cfg['DisableMultiTableMaintenance'] = false;
*/
$cfg['SendErrorReports'] = 'ask';
/*******************************************************************************
* If you wish to use the SQL Validator service, you should be aware of the
* following:
* All SQL statements are stored anonymously for statistical purposes.
* Mimer SQL Validator, Copyright 2002 Upright Database Technology.
* All rights reserved.
*
* @global array $cfg['SQLValidator']
*/
$cfg['SQLValidator'] = array();
/**
* Make the SQL Validator available
*
* @global boolean $cfg['SQLValidator']['use']
*/
$cfg['SQLValidator']['use'] = false;
/**
* If you have a custom username, specify it here (defaults to anonymous)
*
* @global string $cfg['SQLValidator']['username']
*/
$cfg['SQLValidator']['username'] = '';
/**
* Password for username
*
* @global string $cfg['SQLValidator']['password']
*/
$cfg['SQLValidator']['password'] = '';
/*******************************************************************************
* Developers ONLY!

View File

@ -809,21 +809,6 @@ class FormDisplay
$opts['comment'] = $comment;
$opts['comment_warning'] = true;
}
if ($system_path == 'SQLQuery/Validate'
&& ! $GLOBALS['cfg']['SQLValidator']['use']
) {
$opts['comment'] = __('SQL Validator is disabled');
$opts['comment_warning'] = true;
}
if ($system_path == 'SQLValidator/use') {
if (!class_exists('SOAPClient')) {
@include_once 'SOAP/Client.php';
if (!class_exists('SOAP_Client')) {
$opts['comment'] = __('SOAP extension not found');
$opts['comment_warning'] = true;
}
}
}
if (!defined('PMA_SETUP')) {
if (($system_path == 'MaxDbList' || $system_path == 'MaxTableList'
|| $system_path == 'QueryHistoryMax')

View File

@ -291,14 +291,6 @@ $strConfigForm_Sql_box_desc = __('Customize links shown in SQL Query boxes.');
$strConfigForm_Sql_desc = __('Customize default options.');
$strConfigForm_Sql_queries = __('SQL queries');
$strConfigForm_Sql_queries_desc = __('SQL queries settings.');
$strConfigForm_Sql_validator = __('SQL Validator');
$strConfigForm_Sql_validator_desc = __(
'If you wish to use the SQL Validator service, you should be aware that '
. '[strong]all SQL statements are stored anonymously for statistical '
. 'purposes[/strong].[br][em][a@http://sqlvalidator.mimer.com/]Mimer SQL '
. 'Validator[/a], Copyright 2002 Upright Database Technology. All rights '
. 'reserved.[/em]'
);
$strConfigForm_Startup = __('Startup');
$strConfigForm_Startup_desc = __('Customize startup page.');
$strConfigForm_DbStructure = __('Database structure');
@ -752,13 +744,6 @@ $strConfigSQLQuery_Edit_name = __('Edit');
$strConfigSQLQuery_Explain_name = __('Explain SQL');
$strConfigSQLQuery_Refresh_name = __('Refresh');
$strConfigSQLQuery_ShowAsPHP_name = __('Create PHP Code');
$strConfigSQLQuery_Validate_desc = __('Requires SQL Validator to be enabled.');
$strConfigSQLQuery_Validate_name = __('Validate SQL');
$strConfigSQLValidator_password_name = __('Password');
$strConfigSQLValidator_use_desc = __('[strong]Warning:[/strong] requires PHP SOAP extension or PEAR SOAP to be installed.');
$strConfigSQLValidator_use_name = __('Enable SQL Validator');
$strConfigSQLValidator_username_desc = __('If you have a custom username, specify it here (defaults to [kbd]anonymous[/kbd]).');
$strConfigSQLValidator_username_name = __('Username');
$strConfigSuhosinDisableWarning_desc = __('A warning is displayed on the main page if Suhosin is detected.');
$strConfigSuhosinDisableWarning_name = __('Suhosin warning');
$strConfigTextareaCols_desc = __('Textarea size (columns) in edit mode, this value will be emphasized for SQL query textareas (*2) and for query window (*1.25).');

View File

@ -164,12 +164,7 @@ $forms['Sql_queries']['Sql_box'] = array('SQLQuery' => array(
'Edit',
'Explain',
'ShowAsPHP',
'Validate',
'Refresh'));
$forms['Sql_queries']['Sql_validator'] = array('SQLValidator' => array(
'use',
'username',
'password'));
$forms['Navi_panel']['Navi_panel'] = array(
'NavigationDisplayLogo',
'NavigationLogoLink',

View File

@ -77,7 +77,6 @@ $forms['Sql_queries']['Sql_box'] = array(
'SQLQuery/Edit',
'SQLQuery/Explain',
'SQLQuery/ShowAsPHP',
'SQLQuery/Validate',
'SQLQuery/Refresh');
$forms['Navi_panel']['Navi_panel'] = array(
'NavigationDisplayLogo',

View File

@ -1490,7 +1490,7 @@ function PMA_executeTheQuery($analyzed_sql_results, $full_sql_query, $is_gotofil
$db, $table, $find_real_end, $sql_query_for_bookmark, $extra_data
) {
// Only if we ask to see the php code
if (isset($GLOBALS['show_as_php']) || ! empty($GLOBALS['validatequery'])) {
if (isset($GLOBALS['show_as_php'])) {
$result = null;
$num_rows = 0;
$unlim_num_rows = 0;
@ -1631,8 +1631,6 @@ function PMA_getMessageForNoRowsReturned($message_to_show, $analyzed_sql_results
} elseif (isset($GLOBALS['show_as_php'])) {
/* User disable showing as PHP, query is only displayed */
$message = PMA_Message::notice(__('Showing SQL query'));
} elseif (! empty($GLOBALS['validatequery'])) {
$message = PMA_Message::notice(__('Validated SQL'));
} else {
$message = PMA_Message::success(
__('MySQL returned an empty result set (i.e. zero rows).')

View File

@ -1,462 +0,0 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* PHP interface to MimerSQL Validator
*
* Copyright 2002, 2003 Robin Johnson <robbat2@users.sourceforge.net>
* http://www.orbis-terrarum.net/?l=people.robbat2
*
* All data is transported over HTTP-SOAP
* And uses either the PEAR SOAP Module or PHP SOAP extension
*
* Install instructions for PEAR SOAP:
* Make sure you have a really recent PHP with PEAR support
* run this: "pear install Mail_Mime Net_DIME SOAP"
*
* @access public
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
/**
* Load SOAP client.
*/
if (class_exists('SOAPClient')) {
$GLOBALS['sqlvalidator_error'] = false;
$GLOBALS['sqlvalidator_soap'] = 'PHP';
} else {
@include_once 'SOAP/Client.php';
if (class_exists('SOAP_Client')) {
$GLOBALS['sqlvalidator_soap'] = 'PEAR';
$GLOBALS['sqlvalidator_error'] = false;
} else {
$GLOBALS['sqlvalidator_soap'] = 'NONE';
$GLOBALS['sqlvalidator_error'] = true;
PMA_warnMissingExtension('soap');
}
}
if (!$GLOBALS['sqlvalidator_error']) {
// Ok, we have SOAP Support, so let's use it!
/**
* @package PhpMyAdmin
*/
class PMA_SQLValidator
{
var $url;
var $service_name;
var $wsdl;
var $output_type;
var $username;
var $password;
var $calling_program;
var $calling_program_version;
var $target_dbms;
var $target_dbms_version;
var $connectionTechnology;
var $connection_technology_version;
var $interactive;
/**
* @var SOAPClient
*/
var $service_link = null;
var $session_data = null;
/**
* Private functions - You don't need to mess with these
*/
/**
* Service opening
*
* @param string $url URL of Mimer SQL Validator WSDL file
*
* @return SOAPClient Object to use
*
* @access private
*/
function _openService($url)
{
if ($GLOBALS['sqlvalidator_soap'] == 'PHP') {
$obj = new SOAPClient($url);
} else {
$obj = new SOAP_Client($url, true);
}
return $obj;
} // end of the "openService()" function
/**
* Service initializer to connect to server
*
* @param SOAPClient $obj Service object
* @param string $username Username
* @param string $password Password
* @param string $calling_program Name of calling program
* @param string $calling_program_version Version of calling program
* @param string $target_dbms Target DBMS
* @param string $target_dbms_version Version of target DBMS
* @param string $con_technology Connection Technology
* @param string $con_technology_version Con. Technology version
* @param integer $interactive boolean 1/0 to specify if
* we are an interactive system
*
* @return object stdClass return object with data
*
* @access private
*/
function _openSession($obj, $username, $password, $calling_program,
$calling_program_version, $target_dbms, $target_dbms_version,
$con_technology, $con_technology_version, $interactive
) {
$use_array = array(
"a_userName" => $username,
"a_password" => $password,
"a_callingProgram" => $calling_program,
"a_callingProgramVersion" => $calling_program_version,
"a_targetDbms" => $target_dbms,
"a_targetDbmsVersion" => $target_dbms_version,
"a_connectionTechnology" => $con_technology,
"a_connectionTechnologyVersion" => $con_technology_version,
"a_interactive" => $interactive,
);
if ($GLOBALS['sqlvalidator_soap'] == 'PHP') {
$ret = $obj->__soapCall("openSession", $use_array);
} else {
$ret = $obj->call("openSession", $use_array);
}
return $ret;
} // end of the "_openSession()" function
/**
* Validator sytem call
*
* @param SOAPClient $obj Service object
* @param object $session Session object
* @param string $sql SQL Query to validate
* @param string $method Data return type
*
* @return object stClass return with data
*
* @access private
*/
function _validateSQL($obj, $session, $sql, $method)
{
$use_array = array(
"a_sessionId" => $session->sessionId,
"a_sessionKey" => $session->sessionKey,
"a_SQL" => $sql,
"a_resultType" => $this->output_type,
);
if ($GLOBALS['sqlvalidator_soap'] == 'PHP') {
$res = $obj->__soapCall("validateSQL", $use_array);
} else {
$res = $obj->call("validateSQL", $use_array);
}
return $res;
} // end of the "validateSQL()" function
/**
* Validator sytem call
*
* @param string $sql SQL Query to validate
*
* @return object stdClass return with data
*
* @access private
*
* @see validateSQL()
*/
function _validate($sql)
{
$ret = $this->_validateSQL(
$this->service_link, $this->session_data, $sql, $this->output_type
);
return $ret;
} // end of the "validate()" function
/**
* Public functions
*/
/**
* Constructor
*
* @access public
*/
function __construct()
{
$this->url
= 'http://sqlvalidator.mimer.com/v1/services';
$this->service_name = 'SQL99Validator';
$this->wsdl = '?wsdl';
$this->output_type = 'html';
$this->username = 'anonymous';
$this->password = '';
$this->calling_program = 'PHP_SQLValidator';
$this->calling_program_version = PMA_VERSION;
$this->target_dbms = 'N/A';
$this->target_dbms_version = 'N/A';
$this->connection_technology = 'PHP';
$this->connection_technology_version = phpversion();
$this->interactive = 1;
$this->service_link = null;
$this->session_data = null;
} // end of the "PMA_SQLValidator()" function
/**
* Sets credentials
*
* @param string $username the username
* @param string $password the password
*
* @return void
* @access public
*/
function setCredentials($username, $password)
{
$this->username = $username;
$this->password = $password;
} // end of the "setCredentials()" function
/**
* Sets the calling program
*
* @param string $calling_program the calling program name
* @param string $calling_program_version the calling program revision
*
* @return void
* @access public
*/
function setCallingProgram($calling_program, $calling_program_version)
{
$this->calling_program = $calling_program;
$this->calling_program_version = $calling_program_version;
} // end of the "setCallingProgram()" function
/**
* Appends the calling program
*
* @param string $calling_program the calling program name
* @param string $calling_program_version the calling program revision
*
* @return void
* @access public
*/
function appendCallingProgram($calling_program, $calling_program_version)
{
$this->calling_program .= ' - ' . $calling_program;
$this->calling_program_version .= ' - ' . $calling_program_version;
} // end of the "appendCallingProgram()" function
/**
* Sets the target DBMS
*
* @param string $target_dbms the target DBMS name
* @param string $target_dbms_version the target DBMS revision
*
* @return void
* @access public
*/
function setTargetDbms($target_dbms, $target_dbms_version)
{
$this->target_dbms = $target_dbms;
$this->target_dbms_version = $target_dbms_version;
} // end of the "setTargetDbms()" function
/**
* Appends the target DBMS
*
* @param string $target_dbms the target DBMS name
* @param string $target_dbms_version the target DBMS revision
*
* @return void
* @access public
*/
function appendTargetDbms($target_dbms, $target_dbms_version)
{
$this->target_dbms .= ' - ' . $target_dbms;
$this->target_dbms_version .= ' - ' . $target_dbms_version;
} // end of the "appendTargetDbms()" function
/**
* Sets the connection technology used
*
* @param string $connection_technology the con. technology name
* @param string $connection_technology_version the con. technology revision
*
* @return void
* @access public
*/
function setConnectionTechnology(
$connection_technology, $connection_technology_version
) {
$this->connection_technology = $connection_technology;
$this->connection_technology_version = $connection_technology_version;
} // end of the "setConnectionTechnology()" function
/**
* Appends the connection technology used
*
* @param string $connection_technology the con. technology name
* @param string $connection_technology_version the con. technology revision
*
* @return void
* @access public
*/
function appendConnectionTechnology(
$connection_technology, $connection_technology_version
) {
$this->connection_technology .= ' - ' . $connection_technology;
$this->connection_technology_version
.= ' - ' . $connection_technology_version;
} // end of the "appendConnectionTechnology()" function
/**
* Sets whether interactive mode should be used or not
*
* @param integer $interactive whether interactive mode should be used or not
*
* @return void
* @access public
*/
function setInteractive($interactive)
{
$this->interactive = $interactive;
} // end of the "setInteractive()" function
/**
* Sets the output type to use
*
* @param string $output_type the output type to use
*
* @return void
* @access public
*/
function setOutputType($output_type)
{
$this->output_type = $output_type;
} // end of the "setOutputType()" function
/**
* Starts service
*
* @return void
* @access public
*/
function startService()
{
$this->service_link = $this->_openService(
$this->url . '/' . $this->service_name . $this->wsdl
);
} // end of the "startService()" function
/**
* Starts session
*
* @return void
* @access public
*/
function startSession()
{
$this->session_data = $this->_openSession(
$this->service_link, $this->username, $this->password,
$this->calling_program, $this->calling_program_version,
$this->target_dbms, $this->target_dbms_version,
$this->connection_technology, $this->connection_technology_version,
true // FIXME: Are we to tell them that we are interactive?
);
if (isset($this->session_data)
&& ($this->session_data != null)
&& ($this->session_data->target != $this->url)
) {
// Reopens the service on the new URL that was provided
$this->url = $this->session_data->target;
$this->startService();
}
} // end of the "startSession()" function
/**
* Do start service and session
*
* @return void
* @access public
*/
function start()
{
$this->startService();
$this->startSession();
} // end of the "start()" function
/**
* Call to determine just if a query is valid or not.
*
* @param string $sql SQL statement to validate
*
* @return string Validator string from Mimer
*
* @see _validate
*/
function isValid($sql)
{
$res = $this->_validate($sql);
return $res->standard;
} // end of the "isValid()" function
/**
* Call for complete validator response
*
* @param string $sql SQL statement to validate
*
* @return string Validator string from Mimer
*
* @see _validate
*/
function validationString($sql)
{
$res = $this->_validate($sql);
return $res->data;
} // end of the "validationString()" function
} // end class PMA_SQLValidator
//add an extra check to ensure that the class was defined without errors
if (!class_exists('PMA_SQLValidator')) {
$GLOBALS['sqlvalidator_error'] = true;
}
} // end else
?>

View File

@ -1,107 +0,0 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* SQL Validator interface for phpMyAdmin
*
* Copyright 2002 Robin Johnson <robbat2@users.sourceforge.net>
* http://www.orbis-terrarum.net/?l=people.robbat2
*
* This function uses the Mimer SQL Validator service
* <http://developer.mimer.com/validator/index.htm> from phpMyAdmin
*
* Copyright for Server side validator systems:
* "All SQL statements are stored anonymously for statistical purposes.
* Mimer SQL Validator, Copyright 2002 Upright Database Technology.
* All rights reserved."
*
* All data is transported over HTTP-SOAP
* And uses the PEAR SOAP Module
*
* Install instructions for PEAR SOAP
* Make sure you have a really recent PHP with PEAR support
* run this: "pear install Mail_Mime Net_DIME SOAP"
*
* Enable the SQL Validator options in the configuration file
* $cfg['SQLQuery']['Validate'] = true;
* $cfg['SQLValidator']['use'] = true;
*
* Also set a username and password if you have a private one
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
/**
* We need the PEAR libraries, so do a minimum version check first
* I'm not sure if PEAR was available before this point
* For now we actually use a configuration flag
*/
if ($cfg['SQLValidator']['use'] == true) {
include_once './libraries/sqlvalidator.class.php';
} // if ($cfg['SQLValidator']['use'] == true)
/**
* This function utilizes the Mimer SQL Validator service
* to validate an SQL query
*
* <http://developer.mimer.com/validator/index.htm>
*
* @param string $sql SQL query to validate
*
* @return string Validator result string
*
* @global array $cfg The PMA configuration array
*/
function PMA_validateSQL($sql)
{
global $cfg;
$str = '';
if ($cfg['SQLValidator']['use']) {
if (isset($GLOBALS['sqlvalidator_error'])
&& $GLOBALS['sqlvalidator_error']
) {
$str = sprintf(
__('The SQL validator could not be initialized. Please check if you have installed the necessary PHP extensions as described in the %sdocumentation%s.'),
'<a href="' . PMA_Util::getDocuLink('faq', 'faqsqlvalidator')
. '" target="documentation">',
'</a>'
);
} else {
// create new class instance
$srv = new PMA_SQLValidator();
// Checks for username settings
// The class defaults to anonymous with an empty password
// automatically
if ($cfg['SQLValidator']['username'] != '') {
$srv->setCredentials(
$cfg['SQLValidator']['username'],
$cfg['SQLValidator']['password']
);
}
// Identify ourselves to the server properly...
$srv->appendCallingProgram('phpMyAdmin', PMA_VERSION);
// ... and specify what database system we are using
$srv->setTargetDbms('MySQL', PMA_MYSQL_STR_VERSION);
// Log on to service
$srv->start();
// Do service validation
$str = $srv->validationString($sql);
}
} // end if
// Gives string back to caller
return $str;
} // end of the "PMA_validateSQL()" function
?>

View File

@ -511,24 +511,6 @@ class PMA_FormDisplay_Test extends PHPUnit_Framework_TestCase
$opts['comment_warning']
);
// SQLValidate
$GLOBALS['cfg']['SQLValidator']['use'] = false;
$method->invokeArgs(
$this->object,
array('SQLQuery/Validate', &$opts)
);
$this->assertEquals(
"SQL Validator is disabled",
$opts['comment']
);
$this->assertTrue(
$opts['comment_warning']
);
if (defined('PMA_SETUP')) {
runkit_constant_remove('PMA_SETUP');
}

View File

@ -1,179 +0,0 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Tests for correctness of SQL validator
*
* @package PhpMyAdmin-test
*/
/*
* Include to test.
*/
define('PMA_MYSQL_STR_VERSION', "5.00.15");
//it will be used before setup on libraries/sqlvalidator.lib.php
global $cfg;
$cfg['SQLValidator']['use'] = false;
require_once 'libraries/php-gettext/gettext.inc';
require_once 'libraries/Message.class.php';
require_once 'libraries/Util.class.php';
require_once 'libraries/Theme.class.php';
require_once 'libraries/sanitizing.lib.php';
require_once 'libraries/sqlvalidator.class.php';
require_once 'libraries/sqlvalidator.lib.php';
/**
* Tests for correctness of SQL validator
*
* @package PhpMyAdmin-test
*/
class PMA_SQLValidator_Test extends PHPUnit_Framework_TestCase
{
/**
* Prepares environment for the test.
*
* @return void
*/
public function setUp()
{
if (function_exists('mb_internal_encoding')) {
mb_internal_encoding('utf-8');
}
$_SESSION['PMA_Theme'] = new PMA_Theme();
$GLOBALS['pmaThemeImage'] = 'theme/';
$GLOBALS['cfg']['SQLValidator']['username'] = "PMA_username";
$GLOBALS['cfg']['SQLValidator']['password'] = "PMA_password";
}
/**
* Tests for PMA_validateSQL failed due to No Configure
*
* @return void
*/
public function testPMA_validateSQL_NoConfigure()
{
$sql = "select * from PMA_test";
//$cfg['SQLValidator']['use'] = false
$this->assertEquals(
'',
PMA_validateSQL($sql)
);
//$cfg['SQLValidator']['use'] = true
$GLOBALS['cfg']['SQLValidator']['use'] = true;
//the sql validatior is not loaded
$GLOBALS['sqlvalidator_error'] = true;
$this->assertContains(
'The SQL validator could not be initialized.',
PMA_validateSQL($sql)
);
}
/**
* Tests for PMA_validateSQL SOAP
*
* @return void
*/
public function testPMA_validateSQL_SOAP()
{
$sql_pass = "select * from PMA_test";
$sql_fail = "select * PMA_test";
//the sql validatior is loaded correctly
//follow need SOAP
$GLOBALS['cfg']['SQLValidator']['use'] = true;
$GLOBALS['sqlvalidator_soap'] = 'PEAR';
$GLOBALS['sqlvalidator_error'] = false;
//validate that the result is the same as SOAP_Client return
//SOAP_Client is mocked with simple logic
$this->assertTrue(
PMA_validateSQL($sql_pass)
);
$this->assertFalse(
PMA_validateSQL($sql_fail)
);
}
}
/**
* Mock the SOAP_Client
*
* @package PhpMyAdmin-test
*/
class SOAP_Client
{
/**
* Mock the SOAP_Client::call method
*
* @param string $name Name
* @param array $arguments Arguments
*
* @return mixed
*/
public function call($name, $arguments)
{
return $this->{$name}($arguments);
}
/**
* Mock the SOAP_Client::openSession method
*
* @param array $args Arguments
*
* @return Session
*/
public function openSession($args)
{
$session = new Session;
$session->target = "http://sqlvalidator.mimer.com/v1/services";
$session->username = $args["a_userName"];
$session->password = $args["a_password"];
$session->calling_program = $args["a_callingProgram"];
$session->sessionId = "sessionId";
$session->sessionKey = "sessionKey";
return $session;
}
/**
* Mock the SOAP_Client::validateSQL method
*
* @param array $args Arguments
*
* @return Session
*/
public function validateSQL($args)
{
$session = new Session;
$sql = $args["a_SQL"];
//simple logic of sql validate
$pos = strstr($sql, "from");
if (!$pos) {
$session->data = false;
} else {
$session->data = true;
}
return $session;
}
}
/**
* Mock return Session class
*
* @package PhpMyAdmin-test
*/
class Session
{
var $target = null;
var $username = null;
var $password = null;
var $calling_program = null;
var $sessionId = null;
var $sessionKey = null;
var $data = null;
}
?>