2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * SQL Validator interface for phpMyAdmin
6 * Copyright 2002 Robin Johnson <robbat2@users.sourceforge.net>
7 * http://www.orbis-terrarum.net/?l=people.robbat2
9 * This function uses the Mimer SQL Validator service
10 * <http://developer.mimer.com/validator/index.htm> from phpMyAdmin
12 * Copyright for Server side validator systems:
13 * "All SQL statements are stored anonymously for statistical purposes.
14 * Mimer SQL Validator, Copyright 2002 Upright Database Technology.
15 * All rights reserved."
17 * All data is transported over HTTP-SOAP
18 * And uses the PEAR SOAP Module
20 * Install instructions for PEAR SOAP
21 * Make sure you have a really recent PHP with PEAR support
22 * run this: "pear install Mail_Mime Net_DIME SOAP"
24 * Enable the SQL Validator options in the configuration file
25 * $cfg['SQLQuery']['Validate'] = TRUE;
26 * $cfg['SQLValidator']['use'] = FALSE;
28 * Also set a username and password if you have a private one
33 if (! defined('PHPMYADMIN')) {
38 * We need the PEAR libraries, so do a minimum version check first
39 * I'm not sure if PEAR was available before this point
40 * For now we actually use a configuration flag
42 if ($cfg['SQLValidator']['use'] == TRUE) {
43 require_once './libraries/sqlvalidator.class.php';
44 } // if ($cfg['SQLValidator']['use'] == TRUE)
48 * This function utilizes the Mimer SQL Validator service
49 * to validate an SQL query
51 * <http://developer.mimer.com/validator/index.htm>
53 * @param string SQL query to validate
55 * @return string Validator result string
57 * @global array The PMA configuration array
59 function PMA_validateSQL($sql)
65 if ($cfg['SQLValidator']['use']) {
66 if (isset($GLOBALS['sqlvalidator_error'])
67 && $GLOBALS['sqlvalidator_error']) {
68 $str = sprintf($GLOBALS['strValidatorError'], '<a href="./Documentation.html#faqsqlvalidator" target="documentation">', '</a>');
70 // create new class instance
71 $srv = new PMA_SQLValidator();
73 // Checks for username settings
74 // The class defaults to anonymous with an empty password
76 if ($cfg['SQLValidator']['username'] != '') {
77 $srv->setCredentials($cfg['SQLValidator']['username'], $cfg['SQLValidator']['password']);
80 // Identify ourselves to the server properly...
81 $srv->appendCallingProgram('phpMyAdmin', PMA_VERSION
);
83 // ... and specify what database system we are using
84 $srv->setTargetDbms('MySQL', PMA_MYSQL_STR_VERSION
);
89 // Do service validation
90 $str = $srv->validationString($sql);
95 // Gives string back to caller
97 } // end of the "PMA_validateSQL()" function