Пример #1
0
function ProcessQuery()
{
    global $tunnelversion;
    global $tunnelversionstring;
    global $phpversionerror;
    WriteLog("Enter processquery");
    if (CheckPHPVersion() == FALSE) {
        /*  now the call can be of three types
            1.) Specific to check tunnel version
            2.) Normal where it is expected that the PHP page is 4.3.0
            3.) From browser
            
            We check this by checking the query string which is sent if just a check is done by SQLyog */
        if (isset($_GET['app'])) {
            echo $tunnelversionstring;
            echo $phpversionerror;
        } else {
            ShowAccessError();
        }
        return;
    }
    /* in special case, sqlyog just sends garbage data with query string to check for tunnel version. we need to process that now */
    if (isset($_GET['app'])) {
        echo $tunnelversionstring;
        echo $tunnelversion;
        return;
    }
    /* Starting from 5.1 BETA 4, we dont get the data as URL encoded POST data, we just get it as raw data */
    $xmlrecvd = file_get_contents("php://input");
    /* Check whether the page is called from the browser */
    if (strlen($xmlrecvd) == 0) {
        ShowAccessError();
        return;
    }
    WriteLog($xmlrecvd);
    global $host;
    global $port;
    global $username;
    global $pwd;
    global $db;
    global $batch;
    global $query;
    global $base;
    $ret = GetDetailsFromPostedXML($xmlrecvd);
    if ($ret == FALSE) {
        return;
    }
    /* connect to the mysql server */
    WriteLog("Trying to connect");
    $mysql = mysql_connect("{$host}:{$port}", $username, $pwd);
    if (!$mysql) {
        HandleError(mysql_errno(), mysql_error());
        WriteLog(mysql_error());
        return;
    }
    WriteLog("Connected");
    mysql_select_db(str_replace('`', '', $db), $mysql);
    /* Function will execute setnames in the server as it does in SQLyog client */
    SetName($mysql);
    /* set sql_mode to zero */
    SetNonStrictMode($mysql);
    if ($batch) {
        ExecuteBatchQuery($mysql, $query);
    } else {
        ExecuteSingleQuery($mysql, $query);
    }
    mysql_close($mysql);
    WriteLog("Exit processquery");
}
    return true;
}
/** Detect if the user's PHP/LibXML is affected by the following bug: -

 *  http://bugs.php.net/bug.php?id=45996 

*/
function LibXml2IsBuggy()
{
    global $libxml2_test_query;
    $libxml2_test_query = '';
    $testxml = '<xml><libxml2_test_query>select &apos;a&apos;</libxml2_test_query></xml>';
    GetDetailsFromPostedXML($testxml);
    if (strcasecmp($libxml2_test_query, 'select a') == 0) {
        //This PHP/LibXML is buggy!
        return true;
    }
    //Not buggy!
    return false;
}
/* we can now use SQLyogTunnel.php to log debug informations, which will help us to point out the error */
function WriteLog($loginfo)
{
    if (defined("DEBUG")) {
        $fp = fopen("yogtunnel.log", "a");
        if ($fp == FALSE) {
            return;
        }
        fwrite($fp, $loginfo . "\r\n");
        // MY_CHANGE: Because below it was
        // printing 'Enter' instead of new line
        fclose($fp);
    }
}
function WriteLogTemp($loginfo)
{
    if (defined("DEBUG")) {
        $fp = fopen("sabya.log", "a");
        if ($fp == FALSE) {
            return;
        }
        fwrite($fp, $loginfo . "\r\n");
        // MY_CHANGE: Because below it was
        // printing 'Enter' instead of new line
        fclose($fp);
    }
}
/* Process the  query*/
function ProcessQuery()
{
    WriteLog("Enter processquery");
    if (CheckPHPVersion() == FALSE) {
        /*  now the call can be of three types

            1.) Specific to check tunnel version

            2.) Normal where it is expected that the PHP page is 4.3.0

            3.) From browser

            

            We check this by checking the query string which is sent if just a check is done by SQLyog */
        WriteLog("CheckPHPVersion is FALSE");
        if (isset($_GET['app'])) {
            echo tunnelversionstring;
            echo phpversionerror;
        } else {
            WriteLog("CheckPHPVersion is FALSE and app query string not set");
            ShowAccessError();
        }
        return;
    }
    /* in special case, sqlyog just sends garbage data with query string to check for tunnel version. we need to process that now */
    if (isset($_GET['app'])) {
        WriteLog("app query string not set");
        echo tunnelversionstring;
        echo tunnelversion;
        return;
    }
    /* Starting from 5.1 BETA 4, we dont get the data as URL encoded POST data, we just get it as raw data */
    WriteLog("Trying to get php://input");
    $xmlrecvd = file_get_contents("php://input");
    WriteLog("Got php://input!");
Пример #3
0
function ProcessQuery()
{
    WriteLog("Enter processquery");
    /* Starting from 5.1 BETA 4, we dont get the data as URL encoded POST data, we just get it as raw data */
    $xmlrecvd = file_get_contents("php://input");
    /* Starting from 5.13 BETA, we write the tunnel version in the header itself, so that we can easily check for version mismatch from SQLyog*/
    $versionheader = 'TunnelVersion: 5.13.1';
    header($versionheader);
    /* Check whether the page is called from the browser */
    if (strlen($xmlrecvd) == 0) {
        ShowAccessError();
        return;
    }
    WriteLog($xmlrecvd);
    global $host;
    global $port;
    global $username;
    global $pwd;
    global $db;
    global $batch;
    global $query;
    global $base;
    $ret = GetDetailsFromPostedXML($xmlrecvd);
    if ($ret == FALSE) {
        return;
    }
    /* connect to the mysql server */
    WriteLog("Trying to connect");
    $mysql = mysql_connect("{$host}:{$port}", $username, $pwd);
    if (!$mysql) {
        HandleError(mysql_errno(), mysql_error());
        WriteLog(mysql_error());
        return;
    }
    WriteLog("Connected");
    mysql_select_db(str_replace('`', '', $db), $mysql);
    /* Function will execute setnames in the server as it does in SQLyog client */
    SetName($mysql);
    /* set sql_mode to zero */
    SetNonStrictMode($mysql);
    if ($batch) {
        ExecuteBatchQuery($mysql, $query);
    } else {
        ExecuteSingleQuery($mysql, $query);
    }
    mysql_close($mysql);
    WriteLog("Exit processquery");
}