Fixes for last activity in mailid.php
authorRoland Häder <roland@mxchange.org>
Thu, 5 Nov 2009 14:44:42 +0000 (14:44 +0000)
committerRoland Häder <roland@mxchange.org>
Thu, 5 Nov 2009 14:44:42 +0000 (14:44 +0000)
inc/filters.php
inc/mysql-manager.php
mailid.php

index 4426a95..56d82c0 100644 (file)
@@ -307,12 +307,7 @@ function FILTER_UPDATE_LOGIN_DATA () {
                } // END - if
 
                // 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(
-                               getWhat(),
-                               detectRemoteAddr(),
-                               getMemberId()
-                       ), __FUNCTION__, __LINE__);
+               updateLastActivity(getMemberId());
        }  else {
                // Destroy session, we cannot update!
                destroyMemberSession();
index e8faf0c..c57e681 100644 (file)
@@ -2223,5 +2223,17 @@ function createNewTask ($subject, $notes, $taskType, $userid = 0, $adminId = 0,
                array($adminId, $userid, $taskType, $subject, smartAddSlashes($notes)), __FUNCTION__, __LINE__, true, $strip);
 }
 
+// Updates last module / online time
+// @TODO Fix inconsistency between last_module and getWhat()
+function updateLastActivity($userid) {
+       // Run the update query
+       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(
+                       getWhat(),
+                       detectRemoteAddr(),
+                       bigintval($userid)
+               ), __FUNCTION__, __LINE__);
+}
+
 // [EOF]
 ?>
index 68dfb1c..26a90ba 100644 (file)
@@ -95,7 +95,7 @@ if (($url_userid) > 0 && (($url_mid > 0) || ($url_bid > 0)) && (getTotalFatalErr
                switch ($ltype) {
                        case 'NORMAL':
                                // Is the stats id valid?
-                               $result = SQL_QUERY_ESC("SELECT pool_id, url, subject FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `id`=%s LIMIT 1",
+                               $result = SQL_QUERY_ESC("SELECT `pool_id`, `url`, `subject` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `id`=%s LIMIT 1",
                                        array($url_mid), __FILE__, __LINE__);
                                break;
 
@@ -127,11 +127,14 @@ if (($url_userid) > 0 && (($url_mid > 0) || ($url_bid > 0)) && (getTotalFatalErr
                        if (fetchUserData($url_userid)) {
                                // Status must be CONFIRMED
                                if (getUserData('status') == 'CONFIRMED') {
+                                       // Update last activity
+                                       updateLastActivity($url_userid);
+
                                        // User has confirmed his account so we can procede...
                                        // @TODO Rewrite this to a filter
                                        switch ($ltype) {
                                                case 'NORMAL':
-                                                       $result = SQL_QUERY_ESC("SELECT payment_id FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1",
+                                                       $result = SQL_QUERY_ESC("SELECT `payment_id` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1",
                                                                array(bigintval($pool)), __FILE__, __LINE__);
                                                        if (SQL_NUMROWS($result) == 1) {
                                                                list($pay) = SQL_FETCHROW($result);
@@ -145,7 +148,7 @@ if (($url_userid) > 0 && (($url_mid > 0) || ($url_bid > 0)) && (getTotalFatalErr
                                                        break;
 
                                                case 'BONUS':
-                                                       $result = SQL_QUERY_ESC("SELECT points, time FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
+                                                       $result = SQL_QUERY_ESC("SELECT `points`, `time` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
                                                                array($url_bid), __FILE__, __LINE__);
                                                        if (SQL_NUMROWS($result) == 1) {
                                                                list($points, $time) = SQL_FETCHROW($result);