Example #1
0
/**
 * This function utilizes the Mimer SQL Validator service
 * to validate an SQL query
 *
 * <http://developer.mimer.com/validator/index.htm>
 *
 * @param   string   SQL query to validate
 *
 * @return  string   Validator result string
 *
 * @global  array    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($GLOBALS['strValidatorError'], '<a href="./Documentation.html#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;
}
/**
 * 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 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;
}