This page exposes the MySQL API as a set of web-services which is consumed by SQLyog - the most popular GUI to MySQL.
This page allows SQLyog to manage MySQL even if the MySQL port is blocked or remote access to MySQL is not allowed.
*/
/* PHP for PHP/MySQL tunneling */
/* states of comments currently being worked on in the query. */
/* check whether global variables are registered or not */
if (!get_cfg_var("register_globals")) {
extract($_REQUEST);
}
define ( "COMMENT_OFF", 0 );
define ( "COMMENT_HASH", 1 );
define ( "COMMENT_DASH", 2 );
define ( "COMMENT_START", 0 );
/* current element state while parsing XML received as post */
define ( "XML_NOSTATE", 0 );
define ( "XML_HOST", 1 );
define ( "XML_USER", 2 );
define ( "XML_DB", 3 );
define ( "XML_PWD", 4 );
define ( "XML_PORT", 5 );
define ( "XML_QUERY", 6 );
/* uncomment this line to create a debug log */
/*define ( "DEBUG", 1 );*/
/* current character in the query */
$curpos = 0;
/* version constant */
$tunnelversion = '4.1';
/* global variable to keep the state of current XML element */
$xml_state = XML_NOSTATE;
/* global variables to track various informations about the query */
$host = NULL;
$port = NULL;
$db = NULL;
$username = NULL;
$pwd = NULL;
$batch = 0;
$base = 0;
$query = NULL;
/* we stop all error reporting as we check for all sort of errors */
error_reporting ( 0 );
set_time_limit ( 0 );
/* 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 . chr(13) );
fclose ( $fp );
}
}
/* we check if all the external libraries support i.e. expat and mysql in our case is built in or not */
/* if any of the libraries are not found then we show a warning and exit */
if ( AreModulesInstalled () == TRUE ) {
WriteLog ( "Enter AreModulesInstalled" );
ProcessQuery ();
WriteLog ( "Exit AreModulesInstalled" );
}
function convertxmlchars ( $string )
{
WriteLog ( "Enter convertxmlchars" );
WriteLog ( "Input: " . $string );
$result = $string;
$result = eregi_replace('&', '&', $result);
$result = eregi_replace('<', '<', $result);
$result = eregi_replace('>', '>', $result);
$result = eregi_replace('\'', ''', $result);
$result = eregi_replace('\"', '"', $result);
WriteLog ( "Output: " . $result );
WriteLog ( "Exit convertxmlchars" );
return $result;
}
/* we dont allow an user to connect directly to this page from a browser. It can only be accessed using SQLyog */
function ShowAccessError ()
{
global $tunnelversion;
WriteLog ( "Enter showaccesserror" );
$errmsg = '<p><b>Tunnel version: ' . $tunnelversion . '</b>.<p>This PHP page exposes the MySQL API as a set of webservices.<br><br>This page allows SQLyog to manage a MySQL server even if the MySQL port is blocked or remote access to MySQL is not allowed.<br><br>Visit <a href ="http://www.webyog.com">Webyog</a> to get more details about SQLyog.';
$errmsg = '<b>Error:</b> Extension <b>' . $modulenotfound . '</b> was not found compiled and loaded in the PHP interpreter. SQLyog requires this extension to work properly.';
$errmsg .= '<p><b>Tunnel version: ' . $tunnelversion . '</b>.<p>This PHP page exposes the MySQL API as a set of webservices.<br><br>This page allows SQLyog to manage a MySQL server even if the MySQL port is blocked or remote access to MySQL is not allowed.<br><br>Visit <a href ="http://www.webyog.com">Webyog</a> to get more details about SQLyog.';