+ } // END - if
+
+ // Debug message
+ //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, " - Left!");
+}
+
+// Filter for updating/validating login data
+function FILTER_UPDATE_LOGIN_DATA () {
+ // Add missing array
+ if ((!isset($GLOBALS['last'])) || (!is_array($GLOBALS['last']))) $GLOBALS['last'] = array();
+
+ // Recheck if logged in
+ if (!IS_MEMBER()) return false;
+
+ // Secure user ID
+ setUserId(get_session('userid'));
+
+ // 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(getUserId()), __FUNCTION__, __LINE__);
+
+ // Entry found?
+ if (SQL_NUMROWS($result) == 1) {
+ // Load last module and online time
+ list($mod, $onl) = SQL_FETCHROW($result);
+
+ // Maybe first login time?
+ if (empty($mod)) $mod = "login";
+
+ // This will be displayed on welcome page! :-)
+ if (empty($GLOBALS['last']['module'])) {
+ $GLOBALS['last']['module'] = $mod; $GLOBALS['last']['online'] = $onl;
+ } // END - if
+
+ // "what" not set?
+ if (empty($GLOBALS['what'])) {
+ // Fix it to default
+ $GLOBALS['what'] = "welcome";
+ if (getConfig('index_home') != "") $GLOBALS['what'] = getConfig('index_home');
+ } // 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($GLOBALS['what'], GET_REMOTE_ADDR(), getUserId()), __FUNCTION__, __LINE__);
+ } else {
+ // Destroy session, we cannot update!
+ destroy_user_session();