Even more fixes, loading session was on wrong page (needs db link up)
authorRoland Häder <roland@mxchange.org>
Wed, 4 Mar 2009 06:17:38 +0000 (06:17 +0000)
committerRoland Häder <roland@mxchange.org>
Wed, 4 Mar 2009 06:17:38 +0000 (06:17 +0000)
inc/databases.php
inc/db/lib-mysql3.php
inc/extensions.php
inc/filters.php
inc/modules/admin/what-config_cats.php
inc/modules/admin/what-config_email.php
inc/modules/admin/what-config_points.php
inc/modules/admin/what-email_details.php
inc/mysql-connect.php
inc/mysql-manager.php

index a849015fc640c4eac79ab77b3e8c5b011b8ef4f0..8f4a1d09619119a70c8ae21719ededdc289a8978 100644 (file)
@@ -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));
 
index 2e8799d9c60dde95b38409806475de94bb47108e..88a135789b280c4e573327eebd2eb26aa71c5428 100644 (file)
@@ -72,7 +72,6 @@ Query string:<br />
 
        // Debug output
        //* DEBUG: */ print "Query=<pre>".$sql_string."</pre>, affected=<strong>".SQL_AFFECTEDROWS()."</strong>, numrows=<strong>".SQL_NUMROWS($result)."</strong><br />\n";
-
        if (($GLOBALS['output_mode'] != "1") && ($GLOBALS['output_mode'] != "-1") && (isDebugModeEnabled()) && (isBooleanConstantAndTrue('DEBUG_SQL'))) {
                //
                // Debugging stuff...
index 68a6ae3326f7ff5e489b841f4661d12e3465098e..9a17fa15c7725804676dc7d0ae447aa3aaadddea 100644 (file)
@@ -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&amp;logout=1&amp;".$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) {
index f48e19967b735678f8e08346cbe1dd5f8d1a810d..fea4d142fd393beb224031759ad8b34a2e00ab65 100644 (file)
@@ -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();
index 5ba6ac5b9af639d0b7d6fc387ef096fab3036e5c..b8ebcf8b04bb5483580e8993139443db767ad2b4 100644 (file)
@@ -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)
index 6c06e0f951183042a090b2c5fa7f8b5179c2d570..8b94f531202370ec89873612baab54e2bcb673c5 100644 (file)
@@ -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) {
index d94e18fec4da62f6170b57656160ab29be657de8..69b400320f750f1e8f46b6bc9c5f39193b4bba08 100644 (file)
@@ -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) {
index e4e566b19a92d49780389f56c80276a4ea91a628..26058ec642fcd46d7c1e9b5b9ddf41b8ea1dcbb7 100644 (file)
@@ -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;
index ee7ec8ebfd02599335e797ac30fe1244ecad912f..0b60390d9227f7b19fce04dbb1ac7f3a1d4184b2 100644 (file)
@@ -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");
 
index f4f85cbc21b50ff8302ae2ea94d265d153e952fa..293578e3eb2fc636ef6d6d1d239c961f5f0c8bf0 100644 (file)
@@ -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)
        );
 }