X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=inc%2Fdb%2Flib-mysql3.php;h=513137e8b437c9ec6c92964b5147eb6fbabf386b;hb=df4543d96d8b13dd770c34f7c84fdfa1786a4595;hp=c463f8de30061e4f730a9fd20d85a687c57cc927;hpb=8a2ab6a6beb399e024ec5a56b487b03c4f65551c;p=mailer.git
diff --git a/inc/db/lib-mysql3.php b/inc/db/lib-mysql3.php
index c463f8de30..513137e8b4 100644
--- a/inc/db/lib-mysql3.php
+++ b/inc/db/lib-mysql3.php
@@ -41,7 +41,10 @@ if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
// SQL queries
function SQL_QUERY($sql_string, $F, $L)
{
- global $link, $CSS, $CONFIG, $OK;
+ global $link, $CSS, $_CONFIG, $OK;
+
+ // Remove \t, \n and \r from queries they may confuse some MySQL version I have heard
+ $sql_string = str_replace("\t", " ", str_replace("\n", " ", str_replace("\r", " ", $sql_string)));
// Run SQL command
$result = @mysql_query($sql_string, $link)
@@ -49,10 +52,14 @@ function SQL_QUERY($sql_string, $F, $L)
".MYSQL_QUERY_STRING."
".$sql_string);
- // Debug output
- //* DEBUG: */ print "Query=".$sql_string.", affected=".SQL_AFFECTEDROWS().", numrows=".SQL_NUMROWS($result)."
\n";
+ // Count this query
+ if (!isset($_CONFIG['sql_count'])) $_CONFIG['sql_count'] = 0;
+ $_CONFIG['sql_count']++;
+
+ // Debug output
+ //* DEBUG: */ print "Query=
".$sql_string."
, affected=".SQL_AFFECTEDROWS().", numrows=".SQL_NUMROWS($result)."
\n";
- if (($CSS != "1") && ($CSS != "-1") && (DEBUG_MODE) && (DEBUG_SQL))
+ if (($CSS != "1") && ($CSS != "-1") && (isBooleanConstantAndTrue('DEBUG_MODE')) && (DEBUG_SQL))
{
//
// Debugging stuff...
@@ -63,20 +70,20 @@ function SQL_QUERY($sql_string, $F, $L)
fwrite($fp, "Module=".$GLOBALS['module']."\n");
$OK = true;
}
- fwrite($fp, $F."(LINE=".$L."|NUM=".SQL_NUMROWS($result)."|AFFECTED=".SQL_AFFECTEDROWS()."): ".str_replace('\r', '', str_replace('\n', " ", $sql_string))."\n");
+ fwrite($fp, $F."(LINE=".$L."|NUM=".SQL_NUMROWS($result)."|AFFECTED=".SQL_AFFECTEDROWS()."): ".str_replace('\r', "", str_replace('\n', " ", $sql_string))."\n");
fclose($fp);
}
// Count DB hits
- if (!isset($CONFIG['db_hits']))
+ if (!isset($_CONFIG['db_hits']))
{
// Count in dummy variable
- $CONFIG['db_hits'] = 0;
+ $_CONFIG['db_hits'] = 0;
}
else
{
// Count to config array
- $CONFIG['db_hits']++;
+ $_CONFIG['db_hits']++;
}
return $result;
}
@@ -133,7 +140,7 @@ function SQL_FETCHARRAY($res=false, $nr=0, $remove_numerical=true)
// Shall we remove numerical data here automatically?
if ($remove_numerical)
{
- // So let's remove all numerical elements to save memory!
+ // So let's remove all numerical elements to save memory!
$max = count($row);
for ($idx = 0; $idx < ($max / 2); $idx++)
{
@@ -167,27 +174,30 @@ function SQL_CONNECT($host, $login, $password, $F, $L)
// SQL select database
function SQL_SELECT_DB($DB, $link, $F, $L)
{
- $DB = @mysql_select_db($DB, $link) or ADD_FATAL($F." (".$L."):".mysql_error());
- return $DB;
+ $select = false;
+ if (is_resource($link)) {
+ $select = @mysql_select_db($DB, $link) or ADD_FATAL($F." (".$L."):".mysql_error());
+ }
+ return $select;
}
// SQL close link
function SQL_CLOSE($link, $F, $L)
{
- global $CONFIG, $CACHE, $CFG_CACHE;
- if ((GET_EXT_VERSION("cache") >= "0.0.7") && (isset($CONFIG['db_hits'])) && (isset($CONFIG['cache_hits'])) && (is_object($CACHE)))
+ global $_CONFIG, $cacheInstance, $cacheArray;
+ if ((GET_EXT_VERSION("cache") >= "0.0.7") && (isset($_CONFIG['db_hits'])) && (isset($_CONFIG['cache_hits'])) && (is_object($cacheInstance)))
{
// Update counter for db/cache
- $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_config SET db_hits=%d, cache_hits=%d WHERE config='0' LIMIT 1",
- array(bigintval($CONFIG['db_hits']), bigintval($CONFIG['cache_hits'])), __FILE__, __LINE__);
+ $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_config SET db_hits=%d, cache_hits=%d WHERE config=0 LIMIT 1",
+ array(bigintval($_CONFIG['db_hits']), bigintval($_CONFIG['cache_hits'])), __FILE__, __LINE__);
// Update cache here
if (GET_EXT_VERSION("cache") >= "0.1.2")
{
- if ($CACHE->cache_file("config", true))
+ if ($cacheInstance->cache_file("config", true))
{
// Replace data
- $CACHE->cache_replace("cache_hits", $CONFIG['cache_hits'], "0", $CFG_CACHE);
- $CACHE->cache_replace("db_hits" , $CONFIG['db_hits'] , "0", $CFG_CACHE);
+ $cacheInstance->cache_replace("cache_hits", $_CONFIG['cache_hits'], "0", $cacheArray);
+ $cacheInstance->cache_replace("db_hits" , $_CONFIG['db_hits'] , "0", $cacheArray);
}
}
}
@@ -227,7 +237,7 @@ function SQL_QUERY_ESC($qstring, $data, $file, $line, $run=true, $strip=true)
// Debugging
//
//$fp = fopen(PATH."escape_debug.log", 'a') or mxchange_die("Cannot write debug.log!");
- //fwrite($fp, $file."(".$line."): ".str_replace('\r', '', str_replace('\n', " ", $eval))."\n");
+ //fwrite($fp, $file."(".$line."): ".str_replace('\r', "", str_replace('\n', " ", $eval))."\n");
//fclose($fp);
eval($eval);
if ($run)