From c4ceb98e54f072c262519fc2ea31ccf6f8559049 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 4 Mar 2009 06:17:38 +0000 Subject: [PATCH] Even more fixes, loading session was on wrong page (needs db link up) --- inc/databases.php | 2 +- inc/db/lib-mysql3.php | 1 - inc/extensions.php | 3 ++- inc/filters.php | 22 +++++++++++++++++----- inc/modules/admin/what-config_cats.php | 4 ++-- inc/modules/admin/what-config_email.php | 4 ++-- inc/modules/admin/what-config_points.php | 6 +++--- inc/modules/admin/what-email_details.php | 20 +++++++++++++++++--- inc/mysql-connect.php | 8 +++++++- inc/mysql-manager.php | 3 +-- 10 files changed, 52 insertions(+), 21 deletions(-) diff --git a/inc/databases.php b/inc/databases.php index a849015fc6..8f4a1d0961 100644 --- a/inc/databases.php +++ b/inc/databases.php @@ -98,7 +98,7 @@ define('SERVER_URL', "http://www.mxchange.org"); // Current SVN revision //define('CURR_SVN_REVISION', getActualVersion(0)); -define('CURR_SVN_REVISION', "812"); +define('CURR_SVN_REVISION', "813"); define('CURR_SVN_DATE' , getActualVersion(1)); define('CURR_SVN_VERSION' , getActualVersion(2)); diff --git a/inc/db/lib-mysql3.php b/inc/db/lib-mysql3.php index 2e8799d9c6..88a135789b 100644 --- a/inc/db/lib-mysql3.php +++ b/inc/db/lib-mysql3.php @@ -72,7 +72,6 @@ Query string:
// Debug output //* DEBUG: */ print "Query=
".$sql_string."
, affected=".SQL_AFFECTEDROWS().", numrows=".SQL_NUMROWS($result)."
\n"; - if (($GLOBALS['output_mode'] != "1") && ($GLOBALS['output_mode'] != "-1") && (isDebugModeEnabled()) && (isBooleanConstantAndTrue('DEBUG_SQL'))) { // // Debugging stuff... diff --git a/inc/extensions.php b/inc/extensions.php index 68a6ae3326..9a17fa15c7 100644 --- a/inc/extensions.php +++ b/inc/extensions.php @@ -254,7 +254,7 @@ function EXTENSION_REGISTER ($ext_name, $task_id, $dry_run = false, $logout = tr //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ":{$ext_name}/{$EXT_LOAD_MODE}"); if (($ext_name == "sql_patches") && (($EXT_LOAD_MODE == "register") || ($EXT_LOAD_MODE == "remove")) && (!$dry_run) && ($test)) { //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ": LOAD!"); - if ($logout) { + if ($logout === true) { // Then redirect to logout LOAD_URL("modules.php?module=admin&logout=1&".$EXT_LOAD_MODE."=sql_patches"); } else { @@ -387,6 +387,7 @@ function GET_EXT_VERSION ($ext_name) { // Load from database $result = SQL_QUERY_ESC("SELECT ext_version FROM `{!_MYSQL_PREFIX!}_extensions` WHERE ext_name='%s' LIMIT 1", array($ext_name), __FILE__, __LINE__); + //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ": DB - ".SQL_NUMROWS($result).""); // Is the extension there? if (SQL_NUMROWS($result) == 1) { diff --git a/inc/filters.php b/inc/filters.php index f48e19967b..fea4d142fd 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -69,7 +69,7 @@ function INIT_FILTER_SYSTEM () { // Load all active filers $result = SQL_QUERY("SELECT `filter_name`, `filter_function`, `filter_active`".$ADD." FROM `{!_MYSQL_PREFIX!}_filters` -ORDER BY `filter_id` ASC", __FILE__, __LINE__); +ORDER BY `filter_id` ASC", __FUNCTION__, __LINE__); // Are there entries? if (SQL_NUMROWS($result) > 0) { @@ -406,23 +406,35 @@ function FILTER_LOAD_INCLUDES ($data) { // Filter for running SQL commands function FILTER_RUN_SQLS ($data) { + // Debug message + //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, " - Entered!"); + // Is the array there? if ((IS_SQLS_VALID()) && ((!isset($data['dry_run'])) || ($data['dry_run'] == false))) { // Run SQL commands + //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, " - Found ".COUNT_SQLS()." queries to run."); foreach (GET_SQLS() as $sql) { + // Trim spaces away $sql = trim($sql); + + // Is there still a query left? if (!empty($sql)) { // Do we have an "ALTER TABLE" command? if (substr(strtolower($sql), 0, 11) == "alter table") { // Analyse the alteration command - SQL_ALTER_TABLE($sql, __FILE__, __LINE__); + //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "Alterting table: {$sql}"); + SQL_ALTER_TABLE($sql, __FUNCTION__, __LINE__); } else { // Run regular SQL command - $result = SQL_QUERY($sql, __FILE__, __LINE__, false); + //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "Running regular query: {$sql}"); + $result = SQL_QUERY($sql, __FUNCTION__, __LINE__, false); } } // END - if } // END - foreach } // END - if + + // Debug message + //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, " - Left!"); } // Filter for updating/validating login data @@ -438,7 +450,7 @@ function FILTER_UPDATE_LOGIN_DATA () { // Load last module and last online time $result = SQL_QUERY_ESC("SELECT last_module, last_online FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", - array($GLOBALS['userid']), __FILE__, __LINE__); + array($GLOBALS['userid']), __FUNCTION__, __LINE__); // Entry found? if (SQL_NUMROWS($result) == 1) { @@ -462,7 +474,7 @@ function FILTER_UPDATE_LOGIN_DATA () { // Update last module / online time SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET last_module='%s', last_online=UNIX_TIMESTAMP(), REMOTE_ADDR='%s' WHERE userid=%s LIMIT 1", - array($GLOBALS['what'], GET_REMOTE_ADDR(), $GLOBALS['userid']), __FILE__, __LINE__); + array($GLOBALS['what'], GET_REMOTE_ADDR(), $GLOBALS['userid']), __FUNCTION__, __LINE__); } else { // Destroy session, we cannot update! destroy_user_session(); diff --git a/inc/modules/admin/what-config_cats.php b/inc/modules/admin/what-config_cats.php index 5ba6ac5b9a..b8ebcf8b04 100644 --- a/inc/modules/admin/what-config_cats.php +++ b/inc/modules/admin/what-config_cats.php @@ -103,7 +103,7 @@ if (REQUEST_ISSET_POST(('add'))) { // Display message LOAD_TEMPLATE("admin_settings_saved", false, $TEXT); } -} elseif ((REQUEST_ISSET_POST('del')) && ((SELECTION_COUNT(REQUEST_POST('sel')) > 0) || (REQUEST_ISSET_POST(('sel', 0))))) { +} elseif ((REQUEST_ISSET_POST('del')) && (SELECTION_COUNT(REQUEST_POST('sel')) > 0)) { // Delete categories $SW = 2; $OUT = ""; foreach (REQUEST_POST('sel') as $id => $value) { @@ -128,7 +128,7 @@ if (REQUEST_ISSET_POST(('add'))) { // Load main template LOAD_TEMPLATE("admin_del_cats"); -} elseif ((REQUEST_ISSET_POST('edit')) && ((SELECTION_COUNT(REQUEST_POST('sel')) > 0) || (REQUEST_ISSET_POST(('sel', 0))))) { +} elseif ((REQUEST_ISSET_POST('edit')) && (SELECTION_COUNT(REQUEST_POST('sel')) > 0)) { // Edit categories $SW = 2; $OUT = ""; foreach (REQUEST_POST('sel') as $id => $value) diff --git a/inc/modules/admin/what-config_email.php b/inc/modules/admin/what-config_email.php index 6c06e0f951..8b94f53120 100644 --- a/inc/modules/admin/what-config_email.php +++ b/inc/modules/admin/what-config_email.php @@ -93,7 +93,7 @@ if (REQUEST_ISSET_POST(('add_max'))) { // Display message LOAD_TEMPLATE("admin_settings_saved", false, $TEXT); } -} elseif ((REQUEST_ISSET_POST('del')) && ((SELECTION_COUNT(REQUEST_POST('sel')) > 0) || (REQUEST_ISSET_POST(('sel', 0))))) { +} elseif ((REQUEST_ISSET_POST('del')) && (SELECTION_COUNT(REQUEST_POST('sel')) > 0)) { // Delete entries $SW = 2; $OUT = ""; foreach (REQUEST_POST('sel') as $id => $value) @@ -120,7 +120,7 @@ if (REQUEST_ISSET_POST(('add_max'))) { // Load main template LOAD_TEMPLATE("admin_config_email_del"); -} elseif ((REQUEST_ISSET_POST('edit')) && ((SELECTION_COUNT(REQUEST_POST('sel')) > 0) || (REQUEST_ISSET_POST(('sel', 0))))) { +} elseif ((REQUEST_ISSET_POST('edit')) && (SELECTION_COUNT(REQUEST_POST('sel')) > 0)) { // Edit entries $SW = 2; $OUT = ""; foreach (REQUEST_POST('sel') as $id => $value) { diff --git a/inc/modules/admin/what-config_points.php b/inc/modules/admin/what-config_points.php index d94e18fec4..69b400320f 100644 --- a/inc/modules/admin/what-config_points.php +++ b/inc/modules/admin/what-config_points.php @@ -193,8 +193,8 @@ WHERE mails_confirmed < %s", $REF, $REF)); // Load template LOAD_TEMPLATE("admin_config_point_settings"); } elseif (REQUEST_GET('sub') == "ref") { - // 12 3 32 2 3 32 23 4 5 54 3 3 4 4321 - if ((REQUEST_ISSET_POST('del')) && (REQUEST_ISSET_POST('sel')) && ((SELECTION_COUNT(REQUEST_POST('sel')) > 0) || (REQUEST_ISSET_POST('sel', 0)))) { + // 12 3 32 2 3 32 2 3 4 43 21 + if ((REQUEST_ISSET_POST('del')) && (REQUEST_ISSET_POST('sel')) && (SELECTION_COUNT(REQUEST_POST('sel')) > 0)) { // Delete entries $SW = 2; $OUT = ""; foreach (REQUEST_POST('sel') as $id => $value) { @@ -219,7 +219,7 @@ WHERE mails_confirmed < %s", $REF, $REF)); // Load main template LOAD_TEMPLATE("admin_points_del"); - } elseif ((REQUEST_ISSET_POST('edit')) && (REQUEST_ISSET_POST('sel')) && ((SELECTION_COUNT(REQUEST_POST('sel')) > 0) || (REQUEST_ISSET_POST(('sel', 0)))) { + } elseif ((REQUEST_ISSET_POST('edit')) && (REQUEST_ISSET_POST('sel')) && (SELECTION_COUNT(REQUEST_POST('sel')) > 0)) { // Edit entries $SW = 2; $OUT = ""; foreach (REQUEST_POST('sel') as $id => $value) { diff --git a/inc/modules/admin/what-email_details.php b/inc/modules/admin/what-email_details.php index e4e566b19a..26058ec642 100644 --- a/inc/modules/admin/what-email_details.php +++ b/inc/modules/admin/what-email_details.php @@ -94,8 +94,17 @@ ORDER BY timestamp DESC"; $result_normal = SQL_QUERY($sql, __FILE__, __LINE__); // Set offset an current page to default values -if (!REQUEST_ISSET_GET(('page'))) REQUEST_GET('page') = "1"; -if (!REQUEST_ISSET_GET(('offset'))) REQUEST_SET_GET('offset', getConfig('mails_page')); +if (!REQUEST_ISSET_GET('page')) REQUEST_SET_GET('page', "1"); + +if (!REQUEST_ISSET_GET('offset')) { + if (isConfigEntrySet('mails_page')) { + // Set config entry + REQUEST_SET_GET('offset', getConfig('mails_page')); + } else { + // Set default one + REQUEST_SET_GET('offset', 10); + } +} // END - if // Add limitation to SQL string if (!REQUEST_ISSET_GET(('mid'))) { @@ -114,7 +123,12 @@ $result_list = SQL_QUERY($sql, __FILE__, __LINE__); if ((!empty($SQL2)) && ($WHO == _ALL)) $result_bonus = SQL_QUERY($SQL2, __FILE__, __LINE__); // Calculate pages -$PAGES = round(SQL_NUMROWS($result_normal) / getConfig('mails_page') + 0.3); +$PAGES = 0; +if (isConfigEntrySet('mails_page')) { + $PAGES = round(SQL_NUMROWS($result_normal) / getConfig('mails_page') + 0.3); +} // END - if + +// Free result SQL_FREERESULT($result_normal); $MAIL = false; diff --git a/inc/mysql-connect.php b/inc/mysql-connect.php index ee7ec8ebfd..0b60390d92 100644 --- a/inc/mysql-connect.php +++ b/inc/mysql-connect.php @@ -44,7 +44,7 @@ define('DEBUG_SQL', false); require("inc/functions.php"); // Load more function libraries or includes -foreach (array('request-functions', 'session-functions', 'config-functions', 'filters', 'mysql-manager', 'extensions', 'db/lib', 'handler', 'hooks', 'session') as $lib) { +foreach (array('request-functions', 'session-functions', 'config-functions', 'filters', 'mysql-manager', 'extensions', 'db/lib', 'handler', 'hooks') as $lib) { // Load special functions LOAD_INC_ONCE(sprintf("inc/%s.php", $lib)); } // END - foreach @@ -106,6 +106,9 @@ if ((!isInstalling()) && (isInstalled())) { // Load configuration stuff loadConfiguration(); + // Init session + LOAD_INC_ONCE("inc/session.php"); + // Load "databases" aka static arrays LOAD_INC_ONCE("inc/databases.php"); @@ -197,6 +200,9 @@ if ((!isInstalling()) && (isInstalled())) { // Set other missing variables if (!isset($GLOBALS['output_mode'])) $GLOBALS['output_mode'] = "0"; + // Init session + LOAD_INC_ONCE("inc/session.php"); + // Include databases.php LOAD_INC_ONCE("inc/databases.php"); diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index f4f85cbc21..293578e3eb 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -2156,8 +2156,7 @@ function COUNT_SQLS () { function IS_SQLS_VALID () { return ( (IS_SQLS_INITIALIZED()) && - (COUNT_SQLS() > 0) && - (!empty($GLOBALS['sqls'][0])) + (COUNT_SQLS() > 0) ); } -- 2.39.5