//* DEBUG: */ echo $sql_string."<br />\n";
$result = @mysql_query($sql_string, $link)
or ADD_FATAL($F." (".$L."):".mysql_error()."<br />
-".MYSQL_QUERY_STRING."<br />
+Query string:<br />
".$sql_string);
// Save last successfull query
// Skip double close
return false;
} // END - if
-
- // Add new hits
- $_CONFIG['db_hits'] += $_CONFIG['db_hits_run'];
//* DEBUG: */ echo "DB=".$_CONFIG['db_hits'].",CACHE=".$_CONFIG['cache_hits']."<br />\n";
if ((GET_EXT_VERSION("cache") >= "0.0.7") && (isset($_CONFIG['db_hits'])) && (isset($_CONFIG['cache_hits'])) && (is_object($cacheInstance))) {
+ // Add new hits
+ $_CONFIG['db_hits'] += $_CONFIG['db_hits_run'];
+
// Update counter for db/cache
UPDATE_CONFIG(array("db_hits", "cache_hits"), array(bigintval($_CONFIG['db_hits']), bigintval($_CONFIG['cache_hits'])));
} // END - if
}
// SQL free result
function SQL_FREERESULT($result) {
+ if (!is_resource($result)) {
+ // Abort here
+ return false;
+ } // END - if
+
$res = @mysql_free_result($result);
return $res;
}
// SQL string escaping
function SQL_QUERY_ESC($qstring, $data, $file, $line, $run=true, $strip=true) {
global $link;
+
+ if ($strip) {
+ $strip = "true";
+ } else {
+ $strip = "false";
+ }
+
$query = "";
$eval = "\$query = sprintf(\"".$qstring."\"";
foreach ($data as $var) {
if ((!empty($var)) || ($var === 0)) {
- if ($strip) {
- $eval .= ", SQL_ESCAPE(\"".strip_tags($var)."\")";
- } else {
- $eval .= ", SQL_ESCAPE(\"".$var."\")";
- }
+ $eval .= ", SQL_ESCAPE(\"".$var."\",true,".$strip.")";
} else {
$eval .= ", ''";
}
//fwrite($fp, $file."(".$line."): ".str_replace("\r", "", str_replace("\n", " ", $eval))."\n");
//fclose($fp);
@eval($eval);
+ // Was the eval() command fine?
if (empty($query)) {
+ // Something went wrong?
print "eval=".htmlentities($eval)."<pre>";
debug_print_backtrace();
die("</pre>");
- }
+ } // END - if
+
if ($run) {
// Run SQL query (default)
return SQL_QUERY($query, $file, $line);
return @mysql_insert_id();
}
// Escape a string for the database
-function SQL_ESCAPE($str, $secureString = true) {
+function SQL_ESCAPE($str, $secureString=true,$strip=true) {
global $link;
// Secure string first? (which is the default behaviour!)
if ($secureString) {
// Then do it here
- $str = secureString($str);
+ $str = secureString($str, $strip);
} // END - if
if (!is_resource($link)) {
if (function_exists('mysql_real_escape_string')) {
// The new and improved version
+ //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):str={$str}<br />\n";
return mysql_real_escape_string($str, $link);
} elseif (function_exists('mysql_escape_string')) {
// The obsulete function