function rawQuery($query) { global $queries, $querytext, $loguser, $dblink, $debugMode, $logSqlErrors, $dbpref, $loguserid, $mysqlCellClass; // if($debugMode) // $queryStart = usectime(); $res = @$dblink->query($query); if (!$res) { $theError = $dblink->error; if ($logSqlErrors) { $thequery = sqlEscape($query); $ip = sqlEscape($_SERVER["REMOTE_ADDR"]); $time = time(); if (!$loguserid) { $loguserid = 0; } $get = sqlEscape(var_export($_GET, true)); $post = sqlEscape(var_export($_POST, true)); $cookie = sqlEscape(var_export($_COOKIE, true)); $theError = sqlEscape($theError); $logQuery = "INSERT INTO {$dbpref}queryerrors (`user`,`ip`,`time`,`query`,`get`,`post`,`cookie`, `error`) VALUES ({$loguserid}, '{$ip}', {$time}, '{$thequery}', '{$get}', '{$post}', '{$cookie}', '{$theError}')"; $res = @$dblink->query($logQuery); } if ($debugMode) { $bt = ""; if (function_exists("backTrace")) { $bt = backTrace(); } die(nl2br($bt) . "<br /><br />" . htmlspecialchars($theError) . "<br /><br />Query was: <code>" . htmlspecialchars($query) . "</code>"); /* <br />This could have been caused by a database layout change in a recent git revision. Try running the installer again to fix it. <form action=\"install/doinstall.php\" method=\"POST\"><br /> <input type=\"hidden\" name=\"action\" value=\"Install\" /> <input type=\"hidden\" name=\"existingSettings\" value=\"true\" /> <input type=\"submit\" value=\"Click here to re-run the installation script\" /></form>");*/ } trigger_error("MySQL Error.", E_USER_ERROR); die("MySQL Error."); } $queries++; if ($debugMode) { $mysqlCellClass = ($mysqlCellClass + 1) % 2; $querytext .= "<tr class=\"cell{$mysqlCellClass}\"><td><pre style=\"white-space:pre-wrap;\">" . htmlspecialchars(preg_replace('/^\\s*/m', "", $query)) . "</pre></td><td>"; if (function_exists("backTrace")) { $querytext .= backTrace(); } } return $res; }
/** * @internal * * @return void */ function logBackTrace($backTrace = null) { $backTrace = backTrace($backTrace); error_log("Mango Stack trace:"); foreach ($backTrace as $backString) { error_log($backString); } }