home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / phpMyAdmin / libraries / sqlvalidator.lib.php < prev    next >
Encoding:
PHP Script  |  2008-06-23  |  3.0 KB  |  99 lines

  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4.  * SQL Validator interface for phpMyAdmin
  5.  *
  6.  * Copyright 2002 Robin Johnson <robbat2@users.sourceforge.net>
  7.  * http://www.orbis-terrarum.net/?l=people.robbat2
  8.  *
  9.  * This function uses the Mimer SQL Validator service
  10.  * <http://developer.mimer.com/validator/index.htm> from phpMyAdmin
  11.  *
  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."
  16.  *
  17.  * All data is transported over HTTP-SOAP
  18.  * And uses the PEAR SOAP Module
  19.  *
  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"
  23.  *
  24.  * Enable the SQL Validator options in the configuration file
  25.  * $cfg['SQLQuery']['Validate'] = TRUE;
  26.  * $cfg['SQLValidator']['use']  = FALSE;
  27.  *
  28.  * Also set a username and password if you have a private one
  29.  *
  30.  * @version $Id: sqlvalidator.lib.php 11326 2008-06-17 21:32:48Z lem9 $
  31.  */
  32. if (! defined('PHPMYADMIN')) {
  33.     exit;
  34. }
  35.  
  36. /**
  37.  * We need the PEAR libraries, so do a minimum version check first
  38.  * I'm not sure if PEAR was available before this point
  39.  * For now we actually use a configuration flag
  40.  */
  41. if ($cfg['SQLValidator']['use'] == TRUE)  {
  42.     require_once './libraries/sqlvalidator.class.php';
  43. } // if ($cfg['SQLValidator']['use'] == TRUE)
  44.  
  45.  
  46. /**
  47.  * This function utilizes the Mimer SQL Validator service
  48.  * to validate an SQL query
  49.  *
  50.  * <http://developer.mimer.com/validator/index.htm>
  51.  *
  52.  * @param   string   SQL query to validate
  53.  *
  54.  * @return  string   Validator result string
  55.  *
  56.  * @global  array    The PMA configuration array
  57.  */
  58. function PMA_validateSQL($sql)
  59. {
  60.     global $cfg;
  61.  
  62.     $str = '';
  63.  
  64.     if ($cfg['SQLValidator']['use']) {
  65.         if (isset($GLOBALS['sqlvalidator_error'])
  66.             && $GLOBALS['sqlvalidator_error']) {
  67.             $str = sprintf($GLOBALS['strValidatorError'], '<a href="./Documentation.html#faqsqlvalidator" target="documentation">', '</a>');
  68.         } else {
  69.             // create new class instance
  70.             $srv = new PMA_SQLValidator();
  71.  
  72.             // Checks for username settings
  73.             // The class defaults to anonymous with an empty password
  74.             // automatically
  75.             if ($cfg['SQLValidator']['username'] != '') {
  76.                 $srv->setCredentials($cfg['SQLValidator']['username'], $cfg['SQLValidator']['password']);
  77.             }
  78.  
  79.             // Identify ourselves to the server properly...
  80.             $srv->appendCallingProgram('phpMyAdmin', PMA_VERSION);
  81.  
  82.             // ... and specify what database system we are using
  83.             $srv->setTargetDbms('MySQL', PMA_MYSQL_STR_VERSION);
  84.  
  85.             // Log on to service
  86.             $srv->start();
  87.  
  88.             // Do service validation
  89.             $str = $srv->validationString($sql);
  90.         }
  91.  
  92.     } // end if
  93.  
  94.     // Gives string back to caller
  95.     return $str;
  96. } // end of the "PMA_validateSQL()" function
  97.  
  98. ?>
  99.