00001 <?php
00002
00003
00004
00033 @include_once('SOAP/Client.php');
00034
00035 if (!function_exists('class_exists') || !class_exists('SOAP_Client')) {
00036 $GLOBALS['sqlvalidator_error'] = TRUE;
00037 } else {
00038
00039
00040 class PMA_SQLValidator {
00041
00042 var $url;
00043 var $service_name;
00044 var $wsdl;
00045 var $output_type;
00046
00047 var $username;
00048 var $password;
00049 var $calling_program;
00050 var $calling_program_version;
00051 var $target_dbms;
00052 var $target_dbms_version;
00053 var $connectionTechnology;
00054 var $connection_technology_version;
00055 var $interactive;
00056
00057 var $service_link = NULL;
00058 var $session_data = NULL;
00059
00060
00074 function _openService($url)
00075 {
00076 $obj = new SOAP_Client($url, TRUE);
00077 return $obj;
00078 }
00079
00080
00099 function _openSession($obj, $username, $password,
00100 $calling_program, $calling_program_version,
00101 $target_dbms, $target_dbms_version,
00102 $connection_technology, $connection_technology_version,
00103 $interactive)
00104 {
00105 $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" => $connection_technology, "a_connectionTechnologyVersion" => $connection_technology_version, "a_interactive" => $interactive);
00106 $ret = $obj->call("openSession",$use_array);
00107
00108
00109
00110
00111
00112
00113
00114
00115 return $ret;
00116 }
00117
00118
00131 function _validateSQL($obj, $session, $sql, $method)
00132 {
00133 $use_array = array("a_sessionId" => $session->sessionId, "a_sessionKey" => $session->sessionKey, "a_SQL" => $sql, "a_resultType" => $this->output_type);
00134 $res = $obj->call("validateSQL",$use_array);
00135
00136
00137
00138 return $res;
00139 }
00140
00141
00153 function _validate($sql)
00154 {
00155 $ret = $this->_validateSQL($this->service_link, $this->session_data,
00156 $sql, $this->output_type);
00157 return $ret;
00158 }
00159
00160
00170 function PMA_SQLValidator()
00171 {
00172 $this->url = 'http:
00173 $this->service_name = 'SQL99Validator';
00174 $this->wsdl = '?wsdl';
00175
00176 $this->output_type = 'html';
00177
00178 $this->username = 'anonymous';
00179 $this->password = '';
00180 $this->calling_program = 'PHP_SQLValidator';
00181 $this->calling_program_version = '$Revision: 2.2 $';
00182 $this->target_dbms = 'N/A';
00183 $this->target_dbms_version = 'N/A';
00184 $this->connection_technology = 'PHP';
00185 $this->connection_technology_version = phpversion();
00186 $this->interactive = 1;
00187
00188 $this->service_link = NULL;
00189 $this->session_data = NULL;
00190 }
00191
00192
00201 function setCredentials($username, $password)
00202 {
00203 $this->username = $username;
00204 $this->password = $password;
00205 }
00206
00207
00216 function setCallingProgram($calling_program, $calling_program_version)
00217 {
00218 $this->calling_program = $calling_program;
00219 $this->calling_program_version = $calling_program_version;
00220 }
00221
00222
00231 function appendCallingProgram($calling_program, $calling_program_version)
00232 {
00233 $this->calling_program .= ' - ' . $calling_program;
00234 $this->calling_program_version .= ' - ' . $calling_program_version;
00235 }
00236
00237
00246 function setTargetDbms($target_dbms, $target_dbms_version)
00247 {
00248 $this->target_dbms = $target_dbms;
00249 $this->target_dbms_version = $target_dbms_version;
00250 }
00251
00252
00261 function appendTargetDbms($target_dbms, $target_dbms_version)
00262 {
00263 $this->target_dbms .= ' - ' . $target_dbms;
00264 $this->target_dbms_version .= ' - ' . $target_dbms_version;
00265 }
00266
00267
00276 function setConnectionTechnology($connection_technology, $connection_technology_version)
00277 {
00278 $this->connection_technology = $connection_technology;
00279 $this->connection_technology_version = $connection_technology_version;
00280 }
00281
00282
00291 function appendConnectionTechnology($connection_technology, $connection_technology_version)
00292 {
00293 $this->connection_technology .= ' - ' . $connection_technology;
00294 $this->connection_technology_version .= ' - ' . $connection_technology_version;
00295 }
00296
00297
00305 function setInteractive($interactive)
00306 {
00307 $this->interactive = $interactive;
00308 }
00309
00310
00318 function setOutputType($output_type)
00319 {
00320 $this->output_type = $output_type;
00321 }
00322
00323
00329 function startService()
00330 {
00331
00332 $this->service_link = $this->_openService($this->url . '/' . $this->service_name . $this->wsdl);
00333
00334 }
00335
00336
00342 function startSession()
00343 {
00344 $this->session_data = $this->_openSession($this->service_link, $this->username, $this->password,
00345 $this->calling_program, $this->calling_program_version,
00346 $this->target_dbms, $this->target_dbms_version,
00347 $this->connection_technology, $this->connection_technology_version,
00348 $this->interactive);
00349
00350 if (isset($this->session_data) && ($this->session_data != NULL)
00351 && ($this->session_data->target != $this->url)) {
00352
00353 $url = $this->session_data->target;
00354 $this->startService();
00355 }
00356 }
00357
00358
00364 function start()
00365 {
00366 $this->startService();
00367 $this->startSession();
00368 }
00369
00370
00380 function isValid($sql)
00381 {
00382 $res = $this->_validate($sql);
00383 return $res->standard;
00384 }
00385
00386
00396 function validationString($sql)
00397 {
00398 $res = $this->_validate($sql);
00399 return $res->data;
00400
00401 }
00402 }
00403
00404
00405 if (!class_exists('PMA_SQLValidator')) {
00406 $GLOBALS['sqlvalidator_error'] = TRUE;
00407 }
00408
00409 }
00410
00411 ?>