-// Checks wether the current user is a member
-function IS_MEMBER () {
- // @TODO Why is this global??? #100
- global $status;
-
- if (!is_array($GLOBALS['last'])) $GLOBALS['last'] = array();
- $ret = false;
-
- // is the cache entry there?
- if (isset($GLOBALS['cache_array']['is_member'])) {
- // Then return it
- return $GLOBALS['cache_array']['is_member'];
- } // END - if
-
- // Fix "deleted" cookies first
- FIX_DELETED_COOKIES(array('userid', 'u_hash'));
-
- // Are cookies set?
- if ((isUserIdSet()) && (isSessionVariableSet('u_hash'))) {
- // Cookies are set with values, but are they valid?
- $result = SQL_QUERY_ESC("SELECT password, status, last_module, last_online FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array(getUserId()), __FUNCTION__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
- // Load data from cookies
- list($password, $status, $mod, $onl) = SQL_FETCHROW($result);
-
- // Validate password by created the difference of it and the secret key
- $valPass = generatePassString($password);
-
- // Transfer last module and online time
- if ((!empty($mod)) && (empty($GLOBALS['last']['module']))) {
- $GLOBALS['last']['module'] = $mod;
- $GLOBALS['last']['online'] = $onl;
- } // END - if
-
- // So did we now have valid data and an unlocked user?
- //* DEBUG: */ echo $valPass."<br />".get_session('u_hash')."<br />";
- if (($status == "CONFIRMED") && ($valPass == get_session('u_hash'))) {
- // Account is confirmed and all cookie data is valid so he is definely logged in! :-)
- $ret = true;
- } else {
- // Maybe got locked etc.
- //* DEBUG: */ echo __LINE__."!!!<br />";
- destroy_user_session();
- }
- } else {
- // Cookie data is invalid!
- //* DEBUG: */ echo __LINE__."***<br />";
- destroy_user_session();
- }
-
- // Free memory
- SQL_FREERESULT($result);
- } else {
- // Cookie data is invalid!
- //* DEBUG: */ echo __LINE__."///<br />";
- destroy_user_session();
- }
-
- // Cache status
- $GLOBALS['cache_array']['is_member'] = $ret;
-
- // Return status
- return $ret;
-}
-