+ // Should we display adverts in this menu?
+ if ((isExtensionInstalledAndNewer('menu', '0.0.1')) && (getConfig($mode . '_menu_advert_enabled') == 'Y')) {
+ // Add seperator again
+ $GLOBALS['rows'] .= loadTemplate('menu_seperator', true, $mode);
+
+ // Display advert template
+ $GLOBALS['rows'] .= loadTemplate('menu_' . $mode . '_advert_end', true);
+ } // END - if
+
+ // Prepare data
+ $content = array(
+ 'rows' => $GLOBALS['rows'],
+ 'mode' => $mode
+ );
+
+ // Load main template
+ //* DEBUG: */ print(__LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.$content['sub_what'].':'.getWhat()."*<br />");
+ loadTemplate('menu_table', false, $content);
+ } // END - if
+}
+
+// Checks wether the current user is a member
+function isMember () {
+ // By default no member
+ $ret = false;
+
+ // Fix missing 'last_online' array, damn stupid code :(((
+ // @TODO Try to rewrite this to one or more functions
+ if ((!isset($GLOBALS['last_online'])) || (!is_array($GLOBALS['last_online']))) $GLOBALS['last_online'] = array();
+
+ // is the cache entry there?
+ if (isset($GLOBALS['is_member'])) {
+ // Then return it
+ return $GLOBALS['is_member'];
+ } elseif (getMemberId() == '0') {
+ // No member
+ return false;
+ } else {
+ // Transfer userid=>current
+ setCurrentUserid(getMemberId());
+ }
+
+ // Init global user data array
+ initUserData();
+
+ // Fix "deleted" cookies first
+ fixDeletedCookies(array('userid', 'u_hash'));
+
+ // Are cookies set?
+ if ((isMemberIdSet()) && (isSessionVariableSet('u_hash'))) {
+ // Cookies are set with values, but are they valid?
+ if (fetchUserData(getMemberId()) === true) {
+ // Validate password by created the difference of it and the secret key
+ $valPass = generatePassString(getUserData('password'));
+
+ // Transfer last module and online time
+ $GLOBALS['last_online']['module'] = getUserData('last_module');
+ $GLOBALS['last_online']['online'] = getUserData('last_online');
+
+ // So did we now have valid data and an unlocked user?
+ if ((getUserData('status') == 'CONFIRMED') && ($valPass == getSession('u_hash'))) {
+ // Account is confirmed and all cookie data is valid so he is definely logged in! :-)
+ $ret = true;
+ } else {
+ // Maybe got locked etc.
+ logDebugMessage(__FUNCTION__, __LINE__, 'status=' . getUserData('status'));
+ destroyMemberSession();
+ }
+ } else {
+ // Cookie data is invalid!
+ destroyMemberSession();
+ }
+ } else {
+ // Cookie data is invalid!
+ destroyMemberSession();
+ }
+
+ // Cache status
+ $GLOBALS['is_member'] = $ret;
+
+ // Return status
+ return $ret;
+}
+
+// Fetch user data for given user id
+function fetchUserData ($userid, $column='userid') {
+ // If we should look for userid secure&set it here
+ if (substr($column, -2, 2) == 'id') {
+ // Secure userid
+ $userid = bigintval($userid);
+
+ // Set it here
+ setCurrentUserId($userid);
+
+ // Don't look for invalid userids...
+ if ($userid < 1) {
+ // Invalid, so abort here
+ debug_report_bug('User id ' . $userid . ' is invalid.');
+ } elseif (isUserDataValid()) {
+ // Use cache, so it is fine
+ return true;
+ }
+ } elseif (isUserDataValid()) {
+ // Use cache, so it is fine
+ return true;