X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fdb%2Flib-mysql3.php;h=0f18ac383cdfb2ed62b788398bacd2d429ce4946;hp=0109f4e0e45645683dfe646176ea4198516039c0;hb=4917f4ebfbee4a9a3867a7c0763ad1d9218ea921;hpb=963e55ca1ea79e255f235e359cde9f7862191dc5
diff --git a/inc/db/lib-mysql3.php b/inc/db/lib-mysql3.php
index 0109f4e0e4..0f18ac383c 100644
--- a/inc/db/lib-mysql3.php
+++ b/inc/db/lib-mysql3.php
@@ -197,11 +197,11 @@ function SQL_CLOSE(&$link, $F, $L) {
// 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']."
\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
@@ -213,21 +213,29 @@ function SQL_CLOSE(&$link, $F, $L) {
}
// 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 .= ", ''";
}
@@ -240,11 +248,14 @@ function SQL_QUERY_ESC($qstring, $data, $file, $line, $run=true, $strip=true) {
//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)."
"; debug_print_backtrace(); die(""); - } + } // END - if + if ($run) { // Run SQL query (default) return SQL_QUERY($query, $file, $line); @@ -258,13 +269,13 @@ function SQL_INSERTID() { 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)) { @@ -274,6 +285,7 @@ function SQL_ESCAPE($str, $secureString = true) { if (function_exists('mysql_real_escape_string')) { // The new and improved version + //* DEBUG: */ print __FUNCTION__."(".__LINE__."):str={$str}