Not this turned on...
[mailer.git] / inc / db / lib-mysql3.php
index 13d333d1b2e16f99c1cb5206e88ff7a0470ba18b..c7cc26c7fae8ee02da7c98dd0d3e0e6d7f889995 100644 (file)
@@ -18,6 +18,7 @@
  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -71,8 +72,12 @@ function SQL_QUERY ($sqlString, $F, $L) {
        // Remove \t, \n and \r from queries they may confuse some MySQL version I have heard
        $sqlString = str_replace("\t", ' ', str_replace("\n", ' ', str_replace("\r", ' ', $sqlString)));
 
-       // Compile config out
-       $sqlString = FILTER_COMPILE_CONFIG($sqlString, true);
+       // Replace {PER}
+       $sqlString = str_replace('{PER}', '%', $sqlString);
+
+       // Compile config entries out
+       $eval = "\$sqlString = \"".FILTER_COMPILE_CONFIG(escapeQuotes($sqlString))."\";";
+       eval($eval);
 
        // Starting time
        $querytimeBefore = microtime(true);
@@ -101,7 +106,7 @@ Query string:<br />
        incrementConfigEntry('sql_count');
 
        // Debug output
-       if ((getOutputMode() != 1) && (isDebugModeEnabled()) && (isConfigEntrySet('DEBUG_SQL')) && (getConfig('DEBUG_SQL') == 'Y')) {
+       if ((getOutputMode() != 1) && (isDebugModeEnabled()) && (isSqlDebuggingEnabled())) {
                //
                // Debugging stuff...
                //
@@ -196,7 +201,7 @@ function SQL_FETCHARRAY ($res, $nr=0, $remove_numerical=true) {
                // Return row
                return $row;
        } else {
-               // Return a false here...
+               // Return a false, else some loops would go endless...
                return false;
        }
 }
@@ -220,7 +225,7 @@ function SQL_CONNECT ($host, $login, $password, $F, $L) {
        SQL_SET_LINK($connect);
 
        // Destroy cache
-       unset($GLOBALS['sql_link_res']);
+       unset($GLOBALS['is_sql_link_up']);
 }
 
 // SQL select database
@@ -247,7 +252,7 @@ function SQL_CLOSE ($F, $L) {
        SQL_SET_LINK(null);
 
        // Destroy cache
-       unset($GLOBALS['sql_link_res']);
+       unset($GLOBALS['is_sql_link_up']);
 
        // Return the result
        return $close;
@@ -281,7 +286,7 @@ function SQL_QUERY_ESC ($qstring, $data, $F, $L, $run=true, $strip=true, $secure
        // Debugging
        //
        //* DEBUG: */ $fp = fopen(getConfig('CACHE_PATH') . 'escape_debug.log', 'a') or app_die(__FILE__, __LINE__, "Cannot write debug.log!");
-       //* DEBUG: */ fwrite($fp, $F.'('.$L."): ".str_replace("\r", '', str_replace("\n", " ", $eval))."\n");
+       //* DEBUG: */ fwrite($fp, $F.'('.$L."): ".str_replace("\r", '', str_replace("\n", ' ', $eval))."\n");
        //* DEBUG: */ fclose($fp);
 
        if ($run === true) {
@@ -525,15 +530,15 @@ function SQL_IS_LINK_UP () {
        $linkUp = false;
 
        // Do we have cached this?
-       if (isset($GLOBALS['sql_link_res'])) {
+       if (isset($GLOBALS['is_sql_link_up'])) {
                // Then use this
-               $linkUp = $GLOBALS['sql_link_res'];
+               $linkUp = $GLOBALS['is_sql_link_up'];
        } else {
                // Get it
                $linkUp = is_resource(SQL_GET_LINK());
 
                // And cache it
-               $GLOBALS['sql_link_res'] = $linkUp;
+               $GLOBALS['is_sql_link_up'] = $linkUp;
        }
 
        // Return the result