// Checks wether the current user is a member
function IS_MEMBER () {
- // @TODO Why is this global??? #100
- global $status;
+ // By default no member
+ $ret = false;
// Fix missing 'last' array, damn stupid code :(((
// @TODO Try to rewrite this to one or more functions
if ((!isset($GLOBALS['last'])) || (!is_array($GLOBALS['last']))) $GLOBALS['last'] = array();
- $ret = false;
-
// is the cache entry there?
- if (isset($GLOBALS['cache_array']['is_member'])) {
+ if (isset($GLOBALS['is_member'])) {
// Then return it
- return $GLOBALS['cache_array']['is_member'];
+ return $GLOBALS['is_member'];
} // END - if
+ // Init global 'status'
+ $GLOBALS['status'] = false;
+
// Fix "deleted" cookies first
fixDeletedCookies(array('userid', 'u_hash'));
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__);
+ array(getUserId()), __FUNCTION__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Load data from cookies
- list($password, $status, $mod, $onl) = SQL_FETCHROW($result);
+ list($password, $GLOBALS['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']))) {
+ // @TODO Try to rewrite this to one or more functions
$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 />".getSession('u_hash')."<br />";
- if (($status == 'CONFIRMED') && ($valPass == getSession('u_hash'))) {
+ if (($GLOBALS['status'] == 'CONFIRMED') && ($valPass == getSession('u_hash'))) {
// Account is confirmed and all cookie data is valid so he is definely logged in! :-)
$ret = true;
} else {
}
// Cache status
- $GLOBALS['cache_array']['is_member'] = $ret;
+ $GLOBALS['is_member'] = $ret;
// Return status
return $ret;
// Try to look the entry up
$result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_user_links` WHERE %s='%s' AND `userid`=%s AND link_type='%s' LIMIT 1",
- array($rowName, $stats_id, bigintval($uid), $type), __FUNCTION__, __LINE__);
+ array($rowName, $stats_id, bigintval($uid), $type), __FUNCTION__, __LINE__);
// Was it *not* found?
if (SQL_NUMROWS($result) == 0) {
// So we add one!
SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_links` (%s, userid, link_type) VALUES ('%s','%s','%s')",
- array($rowName, $stats_id, bigintval($uid), $type), __FUNCTION__, __LINE__);
+ array($rowName, $stats_id, bigintval($uid), $type), __FUNCTION__, __LINE__);
$ret = 'done';
} else {
// Already found