getServerInfo();
if (!defined('MSD_MYSQL_VERSION')) define('MSD_MYSQL_VERSION', $version);
$versions = explode('.', $version);
$new = false;
if ($versions[0] == 4 && $versions[1] >= 1) $new = true;
if ($versions[0] > 4) $new = true;
if (!defined('MSD_NEW_VERSION')) define('MSD_NEW_VERSION', $new);
return $version;
}
function SQLError($sql, $error, $return_output = false)
{
//v(debug_backtrace());
global $lang;
$ret = '
MySQL-ERROR |
' . $lang['L_SQL_ERROR2'] . ' ' . $error . ' |
';
if ($sql > '')
{
$ret .= ' ' . $lang['L_SQL_ERROR1'] . ' ' . Highlight_SQL($sql) . ' |
';
}
$ret .= '
';
if ($return_output) return $ret;
else echo $ret;
}
function Highlight_SQL($sql)
{
global $sql_keywords;
$end = '';
$tickstart = false;
if (function_exists("token_get_all")) $a = @token_get_all("$sql?>");
else return $sql;
foreach ($a as $token)
{
if (!is_array($token))
{
if ($token == '`') $tickstart = !$tickstart;
$end .= $token;
}
else
{
if ($tickstart) $end .= $token[1];
else
{
switch (token_name($token[0]))
{
case "T_STRING":
case "T_AS":
case "T_FOR":
$end .= (in_array(strtoupper($token[1]), $sql_keywords)) ? "" . $token[1] . "" : $token[1];
break;
case "T_IF":
case "T_LOGICAL_AND":
case "T_LOGICAL_OR":
case "T_LOGICAL_XOR":
$end .= (in_array(strtoupper($token[1]), $sql_keywords)) ? "" . $token[1] . "" : $token[1];
break;
case "T_CLOSE_TAG":
case "T_OPEN_TAG":
break;
default:
$end .= $token[1];
}
}
}
}
$end = preg_replace("/`(.*?)`/si", "`$1`", $end);
return $end;
}