function loop_recursive(&$breadcrumbs, &$dba, $temp)
{
    global $_QUERYPARAMS;
    if (is_array($temp) && !empty($temp)) {
        switch ($temp['row_type']) {
            case TOPIC:
                $temp['location'] = K4Url::getTopicUrl($temp['post_id']);
                break;
            case REPLY:
                $temp['location'] = K4Url::getPostUrl($temp['post_id']);
                break;
            case FAQANSWER:
                $temp['location'] = K4Url::getGenUrl('faq', $temp['category_id'] . '#faq' . $temp['answer_id']);
                break;
        }
        $breadcrumbs[] = $temp;
        if ($temp['row_type'] & REPLY) {
            if ($temp['post_id'] != $temp['parent_id']) {
                loop_recursive($breadcrumbs, $dba, $dba->getRow("SELECT * FROM " . K4POSTS . " WHERE row_level = " . intval($temp['row_level'] - 1) . " AND post_id = " . intval($temp['parent_id']) . " LIMIT 1"));
            } else {
                loop_recursive($breadcrumbs, $dba, $dba->getRow("SELECT * FROM " . K4POSTS . " WHERE post_id = " . intval($temp['post_id']) . " LIMIT 1"));
            }
        }
    }
}
 function current()
 {
     $temp = parent::current();
     $temp['posticon'] = @$temp['posticon'] != '' ? file_exists(BB_BASE_DIR . '/tmp/upload/posticons/' . @$temp['posticon']) ? @$temp['posticon'] : 'clear.gif' : 'clear.gif';
     $temp['post_id'] = 't' . $temp['post_id'];
     if ($temp['poster_id'] > 0) {
         $temp['post_display_user_ddmenu'] = 1;
         if (!isset($this->users[$temp['poster_id']])) {
             $user = $this->dba->getRow("SELECT " . $this->qp['user'] . $this->qp['userinfo'] . " FROM " . K4USERS . " u LEFT JOIN " . K4USERINFO . " ui ON u.id=ui.user_id WHERE u.id=" . intval($temp['poster_id']));
             if (is_array($user) && !empty($user)) {
                 $group = get_user_max_group($user, $this->groups);
                 $user['group_color'] = !isset($group['color']) || $group['color'] == '' ? '000000' : $group['color'];
                 $user['group_nicename'] = isset($group['nicename']) ? $group['nicename'] : '';
                 $user['group_avatar'] = isset($group['avatar']) ? $group['avatar'] : '';
                 $user['online'] = time() - ini_get('session.gc_maxlifetime') > $user['seen'] ? 'offline' : 'online';
                 $this->users[$user['id']] = $user;
             }
         } else {
             $user = $this->users[$temp['poster_id']];
         }
         if (is_array($user) && !empty($user)) {
             if ($user['flag_level'] > 0 && $_SESSION['user']->get('perms') >= MODERATOR) {
                 $temp['post_user_background'] = 'background-color: #FFFF00;';
             }
             foreach ($user as $key => $val) {
                 $temp['post_user_' . $key] = $val;
             }
             $temp['profilefields'] =& new FAArrayIterator(get_profile_fields($this->fields, $temp));
             $temp['post_user_title'] = $user['user_title'];
             $temp['post_user_user_title'] = get_user_title($user['user_title'], $user['num_posts']);
         }
         if (!isset($temp['post_user_online'])) {
             $temp['post_user_online'] = 'offline';
         }
         /* This array holds all of the userinfo for users that post to this topic */
         $this->users[$user['id']] = $user;
     } else {
         $temp['post_user_id'] = 0;
         $temp['post_user_name'] = $temp['poster_name'];
     }
     /* Deal with acronyms */
     replace_acronyms($temp['body_text']);
     /* word censors */
     replace_censors($temp['body_text']);
     replace_censors($temp['name']);
     /* Do any polls if they exist */
     do_post_polls($temp, $this->dba);
     /* do we have any attachments? */
     if (isset($temp['attachments']) && $temp['attachments'] > 0) {
         $temp['attachment_files'] = new K4AttachmentsIterator($this->dba, $this->user, $temp['post_id'], 0);
     }
     // url's
     $temp['U_TOPICURL'] = K4Url::getTopicUrl($temp['post_id']);
     $temp['U_POSTURL'] = K4Url::getPostUrl($temp['post_id']);
     $temp['U_MEMBERURL'] = K4Url::getMemberUrl($temp['poster_id']);
     if ($this->sr && $temp['num_replies'] > 0) {
         $this->result = $this->dba->executeQuery("SELECT * FROM " . K4POSTS . " WHERE parent_id = " . intval($temp['post_id']) . " AND row_type=" . REPLY . " " . ($this->post_id ? "AND post_id = " . $this->post_id : "") . " AND created >= " . 3600 * 24 * intval($temp['daysprune']) . " ORDER BY " . $temp['sortedby'] . " " . $temp['sortorder'] . " LIMIT " . intval($temp['start']) . "," . intval($temp['postsperpage']));
         $temp['replies'] = new RepliesIterator($this->user, $this->dba, $this->result, $this->qp, $this->users, $this->groups, $this->fields);
     }
     return $temp;
 }
 function current()
 {
     $temp = parent::current();
     /* Cache this forum in the session */
     cache_forum($temp);
     /**
      * Do the icon
      */
     switch ($temp['row_type']) {
         case FORUM:
             $temp['forum_icon'] = 'forum_off';
             forum_icon($temp, $temp['forum_icon']);
             break;
         case GALLERY:
             $temp['forum_icon'] = 'forum_gallery';
             break;
         case METAFORUM:
             $temp['forum_icon'] = 'forum_meta';
             break;
         case ARCHIVEFORUM:
             $temp['forum_icon'] = 'forum_archive';
             break;
     }
     /* Set a nice representation of what level we're on */
     $temp['level'] = @str_repeat('   ', $this->level);
     /* Should we query down to the next level of forums? */
     if ($temp['row_type'] & CATEGORY) {
         $temp['forums'] =& new K4ForumsIterator($this->dba, "SELECT * FROM " . K4FORUMS . " WHERE parent_id = " . $temp['forum_id'] . " ORDER BY row_order ASC", TRUE, $this->level + 1);
     }
     if ($this->do_recurse) {
         if ($temp['subforums'] > 0 && $this->settings['showsubforums'] == 1) {
             $it = new K4ForumsIterator($this->dba, "SELECT * FROM " . K4FORUMS . " WHERE parent_id = " . intval($temp['forum_id']) . " ORDER BY row_order ASC", FALSE, $this->level + 1);
             if ($it->hasNext()) {
                 // add the iterator
                 $temp['subforums_list'] = $it;
             } else {
                 // if this forum doesn't actually have subforums, fix it
                 $this->dba->executeUpdate("UPDATE " . K4FORUMS . " SET subforums=0 WHERE forum_id = " . intval($temp['forum_id']));
             }
         }
     }
     /**
      * Get the moderators
      */
     $temp['moderators'] = array();
     $temp['are_moderators'] = 0;
     if ($temp['moderating_groups'] != '') {
         $groups = explode('|', $temp['moderating_groups']);
         if (is_array($groups)) {
             foreach ($groups as $g) {
                 if (isset($this->usergroups[$g])) {
                     $temp['U_USERGROUPURL'] = K4Url::getUserGroupUrl($g);
                     $temp['moderators'][] = $this->usergroups[$g];
                 }
             }
             $temp['are_moderators'] = 1;
         }
     }
     if ($temp['moderating_users'] != '') {
         $users = force_unserialize($temp['moderating_users']);
         if (is_array($users) && !empty($users)) {
             foreach ($users as $user_id => $username) {
                 $temp['U_GMEMBERURL'] = K4Url::getMemberUrl($user_id);
                 $temp['moderators'][] = array('user_id' => $user_id, 'name' => $username);
             }
             $temp['are_moderators'] = 1;
         }
     }
     $temp['moderators'] =& new FAArrayIterator($temp['moderators']);
     /* Replace topic/post names with censors */
     replace_censors($temp['topic_name']);
     replace_censors($temp['post_name']);
     $temp['topics'] = number_format($temp['topics']);
     $temp['replies'] = number_format($temp['replies']);
     $temp['posts'] = number_format($temp['posts']);
     //		/* Set cookies for all of the topics */
     //		bb_settopic_cache_item('forums', serialize($this->forums), time() + 3600 * 25 * 5);
     $temp['safe_description'] = strip_tags($temp['description']);
     $temp['forum'] = $temp['row_type'] == CATEGORY ? 0 : 1;
     // custom url's
     $temp['U_FORUMURL'] = K4Url::getForumUrl($temp['forum_id']);
     $temp['U_TOPICURL'] = K4Url::getTopicUrl($temp['post_id']);
     $temp['U_POSTURL'] = K4Url::getPostUrl($temp['post_id']);
     $temp['U_FINDPOSTURL'] = K4Url::getPostUrl($temp['post_id']);
     $temp['U_MEMBERURL'] = K4Url::getMemberUrl($temp['post_uid']);
     $temp['U_REDIRECTURL'] = K4Url::getRedirectUrl($temp['forum_id']);
     /* Return the formatted forum info */
     return $temp;
 }
 function current()
 {
     $temp = parent::current();
     $temp['posticon'] = isset($temp['posticon']) && @$temp['posticon'] != '' ? file_exists(BB_BASE_DIR . '/tmp/upload/posticons/' . @$temp['posticon']) ? @$temp['posticon'] : 'clear.gif' : 'clear.gif';
     if ($temp['poster_id'] > 0) {
         if (!isset($this->users[$temp['poster_id']])) {
             $temp['post_display_user_ddmenu'] = 1;
             // display a ddmenu
             $user = $this->dba->getRow("SELECT " . $this->qp['user'] . $this->qp['userinfo'] . " FROM " . K4USERS . " u LEFT JOIN " . K4USERINFO . " ui ON u.id=ui.user_id WHERE u.id=" . intval($temp['poster_id']));
             if (is_array($user) && !empty($user)) {
                 $group = get_user_max_group($user, $this->groups);
                 $user['group_color'] = !isset($group['color']) || $group['color'] == '' ? '000000' : $group['color'];
                 $user['group_nicename'] = $group['nicename'];
                 $user['group_avatar'] = $group['avatar'];
                 $user['online'] = time() - ini_get('session.gc_maxlifetime') > $user['seen'] ? 'offline' : 'online';
                 $this->users[$user['id']] = $user;
             }
         } else {
             $temp['post_display_user_ddmenu'] = $this->result->hasPrev() ? 0 : 1;
             // use a different ddmenu
             $user = $this->users[$temp['poster_id']];
         }
         if (is_array($user) && !empty($user)) {
             if ($user['flag_level'] > 0 && $_SESSION['user']->get('perms') >= MODERATOR) {
                 $temp['post_user_background'] = 'background-color: #FFFF00;';
             }
             foreach ($user as $key => $val) {
                 $temp['post_user_' . $key] = $val;
             }
             $temp['profilefields'] = new FAArrayIterator(get_profile_fields($this->fields, $temp));
             $temp['post_user_title'] = $user['user_title'];
             $temp['post_user_user_title'] = get_user_title($user['user_title'], $user['num_posts']);
         }
         if (!isset($temp['post_user_online'])) {
             $temp['post_user_online'] = 'offline';
         }
     } else {
         $temp['post_user_id'] = 0;
         $temp['post_user_name'] = $temp['poster_name'];
     }
     /* do we have any attachments? */
     if (isset($temp['attachments']) && $temp['attachments'] > 0) {
         $temp['attachment_files'] = new K4AttachmentsIterator($this->dba, $this->user, $temp['post_id']);
     }
     /* Deal with acronyms */
     replace_acronyms($temp['body_text']);
     /* word censors!! */
     replace_censors($temp['body_text']);
     replace_censors($temp['name']);
     /* Do any polls if they exist */
     do_post_polls($temp, $this->dba);
     // url's
     $temp['U_TOPICURL'] = K4Url::getTopicUrl($temp['post_id']);
     $temp['U_POSTURL'] = K4Url::getPostUrl($temp['post_id']);
     $temp['U_MEMBERURL'] = K4Url::getMemberUrl($temp['poster_id']);
     return $temp;
 }