X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fsql-functions.php;h=ede7d72f89b2b1631a0e26b184ce5d5620187332;hb=378729b7c01f1cf81a83de69deaa0510b3302af4;hp=9e82b02dafca1baa693075ec9754f159801c5fcc;hpb=e64f2bb51b24f86921ecb27f4afd7cb0a6e71ca3;p=mailer.git diff --git a/inc/sql-functions.php b/inc/sql-functions.php index 9e82b02daf..ede7d72f89 100644 --- a/inc/sql-functions.php +++ b/inc/sql-functions.php @@ -10,11 +10,6 @@ * -------------------------------------------------------------------- * * Kurzbeschreibung : SQL-Funktionen fuer Queries * * -------------------------------------------------------------------- * - * $Revision:: $ * - * $Date:: $ * - * $Tag:: 0.2.1-FINAL $ * - * $Author:: $ * - * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * * Copyright (c) 2009 - 2013 by Mailer Developer Team * * For more information visit: http://mxchange.org * @@ -304,7 +299,9 @@ function sqlQueryEscaped ($sqlString, $data, $file, $line, $run = TRUE, $strip = // Escape all data foreach ($data as $key => $value) { + //* DEBUG: */ logDebugMessage(basename($file) . '/' . __FUNCTION__, $line . '/' . __LINE__, 'key=' . $key . ',value=' . $value . ',run=' . intval($run) . ',strip=' . intval($strip) . ',secure=' . intval($secure)); $dataSecured[$key] = sqlEscapeString($value, $secure, $strip); + //* DEBUG: */ logDebugMessage(basename($file) . '/' . __FUNCTION__, $line . '/' . __LINE__, 'dataSecured[key]=' . $dataSecured[$key]); } // END - foreach // Generate query @@ -546,20 +543,23 @@ function sqlPrepareQueryString ($sqlString, $enableCodes = TRUE) { // Is it already cached? if (!isset($GLOBALS['sql_strings']['' . $sqlString . ''])) { // Preserve escaping and compile URI codes+config+expression code - $sqlString2 = FILTER_COMPILE_EXPRESSION_CODE(FILTER_COMPILE_CONFIG($sqlString)); + $sqlString2 = str_replace(chr(92), '{BACKLASH}', $sqlString); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sqlString2=' . $sqlString2); + $sqlString2 = FILTER_COMPILE_EXPRESSION_CODE(FILTER_COMPILE_CONFIG($sqlString2)); // Debug message //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sqlString2=' . $sqlString2); - // Do final compilation and revert {ESCAPE} + // Do final compilation and revert {BACKSLASH} $GLOBALS['sql_strings']['' . $sqlString . ''] = doFinalCompilation($sqlString2, FALSE, $enableCodes); + $GLOBALS['sql_strings']['' . $sqlString . ''] = str_replace('{BACKLASH}', chr(92), $GLOBALS['sql_strings']['' . $sqlString . '']); } else { // Log message //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sqlString=' . $sqlString . ' - CACHE!'); } // Debug message - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sqlString=' . $sqlString . ',enableCodes=' . intval($enableCodes) . ',sql_strings=' . $GLOBALS['sql_strings']['' . $sqlString . ''] . ' - EXIT!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sqlString=' . $sqlString . ',enableCodes=' . intval($enableCodes) . ',returned sql_string=' . $GLOBALS['sql_strings']['' . $sqlString . ''] . ' - EXIT!'); // Return it return $GLOBALS['sql_strings']['' . $sqlString . '']; @@ -585,7 +585,7 @@ function ifSqlTableExists ($tableName) { array($tableName), __FUNCTION__, __LINE__); // Is a link there? - if (!is_resource($result)) { + if (!isValidSqlLink($result)) { // Is installation phase? if (isInstaller()) { // Then silently abort here @@ -630,7 +630,7 @@ function ifSqlTableColumnExists ($tableName, $columnName, $forceFound = FALSE) { ), __FUNCTION__, __LINE__); // Is a link there? - if (!is_resource($result)) { + if (!isValidSqlLink($result)) { // Is installation phase? if (isInstaller()) { // Then silently abort here @@ -672,7 +672,7 @@ function ifSqlTableIndexExist ($tableName, $keyName, $forceFound = FALSE) { $result = sqlQueryEscaped("SHOW INDEX FROM `%s`", array($tableName), __FUNCTION__, __LINE__); // Is a link there? - if (!is_resource($result)) { + if (!isValidSqlLink($result)) { // Is installation phase? if (isInstaller()) { // Then silently abort here @@ -777,5 +777,41 @@ WHERE ); } +// Log SQL errors to debug.log in installation phase or call reportBug() +function logSqlError ($file, $line, $message) { + // Remember plain error in last_sql_error + setSqlError($file, $line, $message); + + // Is login set? + if (!empty($GLOBALS['mysql']['login'])) { + // Secure login name in message + $message = str_replace($GLOBALS['mysql']['login'], '***', $message); + } // END - if + + // Is database password set? + if (!empty($GLOBALS['mysql']['password'])) { + // Secure password in message + $message = str_replace($GLOBALS['mysql']['password'], '***', $message); + } // END - if + + // Is database name set? + if (!empty($GLOBALS['mysql']['dbase'])) { + // Secure database name in message + $message = str_replace($GLOBALS['mysql']['dbase'], '***', $message); + } // END - if + + // Is there installation phase? + if (isInstaller()) { + /* + * In installation phase, we don't want SQL errors abort e.g. connection + * tests, so just log it away. + */ + logDebugMessage($file, $line, $message); + } else { + // Regular mode, then call reportBug() + reportBug($file, $line, $message); + } +} + // [EOF] ?>