From 5db6cebdf78f4620268b64384cd24d81f15ac403 Mon Sep 17 00:00:00 2001 From: Robin Johnson Date: Tue, 6 Aug 2002 17:09:02 +0000 Subject: [PATCH] Loic's code updates --- libraries/sqlvalidator.php3 | 71 ++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 37 deletions(-) diff --git a/libraries/sqlvalidator.php3 b/libraries/sqlvalidator.php3 index 535a25b5e..9856ffef6 100644 --- a/libraries/sqlvalidator.php3 +++ b/libraries/sqlvalidator.php3 @@ -1,17 +1,19 @@ * http://www.orbis-terrarum.net/?l=people.robbat2 - * - * This function uses the Mimer SQL Validator service + * + * This function uses the Mimer SQL Validator service * 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. + * Mimer SQL Validator, Copyright 2002 Upright Database Technology. * All rights reserved." * * All data is transported over HTTP-SOAP @@ -27,76 +29,71 @@ * * Also set a username and password if you have a private one */ - + + if (!defined('PMA_SQL_VALIDATOR_INCLUDED')) { define('PMA_SQL_VALIDATOR_INCLUDED', 1); // 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('sqlvalidator.class.php3'); + if ($cfg['SQLValidator']['use'] == TRUE && !defined(PMA_SQL_VALIDATOR_CLASS_INCLUDED)) { + include('./sqlvalidator.class.php3'); } // if ($cfg['SQLValidator']['use'] == TRUE) + /** * This function utilizes the Mimer SQL Validator service * to validate an SQL query * * * - * @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; + $str = ''; + if ($cfg['SQLValidator']['use'] == TRUE) { // 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 // automatically - if($cfg['SQLValidator']['username'] != '') { + if ($cfg['SQLValidator']['username'] != '') { $srv->setCredentials($cfg['SQLValidator']['username'], $cfg['SQLValidator']['password']); } - // Identify ourselves to the server properly - $srv->appendCallingProgram('phpMyAdmin',PMA_VERSION); + // 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); + // ... 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); - - // Strip out the copyright if requested - if($cfg['SQLValidator']['DisplayCopyright'] != TRUE) { - $match = "reserved.
\n
"; - $pos = strpos($str,$match); - $pos += strlen($match); - $str = substr($str,$pos); + $str = $srv->validationString($sql); + } - - } else { - - // The service is not available - // So note that properly - $str = $GLOBALS['strValidatorDisabled']; - } + else { + // The service is not available so note that properly + $str = $GLOBALS['strValidatorDisabled']; + } // end if... else... - // Give string back to caller + // Gives string back to caller return $str; + } // end of the "PMA_validateSQL()" function - } // function validateSQL($sql) - - -} //$__PMA_SQL_VALIDATOR__ +} // $__PMA_SQL_VALIDATOR__ ?>