function sp_load_current_user()
{
    global $current_user, $spThisUser, $spGuestCookie;
    if (empty($current_user)) {
        $current_user = wp_get_current_user();
    }
    $spThisUser = sp_get_user($current_user->ID, true);
    # check for a cookie if a guest
    $spGuestCookie = new stdClass();
    $spGuestCookie->guest_name = '';
    $spGuestCookie->guest_email = '';
    $spGuestCookie->display_name = '';
    if ($spThisUser->guest && empty($spThisUser->offmember)) {
        # so no record of them being a current member
        $sfguests = sp_get_option('sfguests');
        if ($sfguests['storecookie']) {
            if (isset($_COOKIE['guestname_' . COOKIEHASH])) {
                $spGuestCookie->guest_name = sp_filter_name_display($_COOKIE['guestname_' . COOKIEHASH]);
            }
            if (isset($_COOKIE['guestemail_' . COOKIEHASH])) {
                $spGuestCookie->guest_email = sp_filter_email_display($_COOKIE['guestemail_' . COOKIEHASH]);
            }
            $spGuestCookie->display_name = $spGuestCookie->guest_name;
        }
    }
}
function sp_do_sp_UserGroupsTag($userid, $args = '', $noMembershipLabel = '', $adminLabel = '')
{
    #check if forum displayed
    if (sp_abort_display_forum()) {
        return;
    }
    global $spPaths;
    $defs = array('tagClass' => 'spUserGroupsTag', 'stacked' => 1, 'showTitle' => 1, 'showBadge' => 1, 'echo' => 1);
    $a = wp_parse_args($args, $defs);
    extract($a, EXTR_SKIP);
    $tagClass = esc_attr($tagClass);
    $stacked = (int) $stacked;
    $showTitle = (int) $showTitle;
    $showBadge = (int) $showBadge;
    $echo = (int) $echo;
    $thisUser = sp_get_user($userid);
    $show = false;
    $tout = "<span class='{$tagClass}'>";
    if (!empty($thisUser->memberships)) {
        $first = true;
        $split = $stacked ? '<br />' : ', ';
        foreach ($thisUser->memberships as $membership) {
            if (!$first) {
                $tout .= $split;
            }
            if ($showTitle) {
                $show = true;
                $tout .= $membership['usergroup_name'];
            }
            if ($showBadge && !empty($membership['usergroup_badge'])) {
                $show = true;
                if ($showTitle) {
                    $tout .= '<br />';
                }
                $tout .= "<img src='" . SF_STORE_URL . '/' . $spPaths['ranks'] . '/' . $membership['usergroup_badge'] . "' alt='' />";
            }
            $first = false;
        }
    } else {
        if ($thisUser->admin) {
            if ($showTitle) {
                $show = true;
                $tout .= sp_filter_title_display($adminLabel);
            }
        } else {
            $show = true;
            $tout .= sp_filter_title_display($noMembershipLabel);
        }
    }
    $tout .= "</span>\n";
    $out = $show ? $tout : '';
    if ($echo) {
        echo $out;
    } else {
        return $out;
    }
}
function sp_do_sp_ShowSpecialRanksTag($userid, $args = '')
{
    #check if forum displayed
    if (sp_abort_display_forum()) {
        return;
    }
    if (empty($userid)) {
        return;
    }
    $defs = array('tagClass' => 'spSpecialRankTag', 'titleClass' => 'spSpecialRankTag', 'badgeClass' => 'spSpecialRankTag', 'showTitle' => 1, 'showBadge' => 1, 'echo' => 1);
    $a = wp_parse_args($args, $defs);
    extract($a, EXTR_SKIP);
    $echo = (int) $echo;
    $thisUser = sp_get_user($userid);
    include_once SF_PLUGIN_DIR . '/forum/content/sp-common-view-functions.php';
    $data = sp_UserSpecialRank($a, $thisUser->special_rank);
    if ($echo) {
        echo $data;
    } else {
        return $data;
    }
}
    function sp_topicview_query($topicid = 0, $cPage = 1, $forumid = 0)
    {
        global $spGlobals, $spThisUser, $spVars;
        # do we have a valid topic id
        if ($topicid == 0) {
            $this->topicViewStatus = 'no data';
            return;
        } else {
            $WHERE = SFTOPICS . '.topic_id=' . $topicid;
        }
        # default to no access
        $this->topicViewStatus = 'no access';
        # some setup vars
        $startlimit = 0;
        $lastpage = 0;
        # how many posts per page?
        $ppaged = $spGlobals['display']['posts']['perpage'];
        if (!$ppaged) {
            $ppaged = 10;
        }
        # setup where we are in the post list (paging)
        if ($cPage != 1) {
            $startlimit = ($cPage - 1) * $ppaged;
        }
        $LIMIT = $startlimit . ', ' . $ppaged;
        # Set up order by
        $setSort = false;
        $reverse = false;
        $setSort = $spGlobals['display']['posts']['sortdesc'];
        if (isset($spGlobals['sort_order']['topic'])) {
            $reverse = array_search($topicid, (array) $spGlobals['sort_order']['topic']) !== false ? true : false;
        }
        if (isset($spThisUser->postDESC) && $spThisUser->postDESC) {
            $reverse = !$reverse;
        }
        if ($setSort xor $reverse) {
            $ORDER = 'post_pinned DESC, ' . SFPOSTS . ".post_id DESC";
        } else {
            $ORDER = 'post_pinned DESC, ' . SFPOSTS . ".post_id ASC";
        }
        # add newpost/sfwaiting support for admins
        $waitCheck = ', NULL AS new_post';
        if ($spThisUser->admin || $spThisUser->moderator) {
            $waitCheck = ', ' . SFWAITING . '.post_count AS new_post';
        }
        # Discover if this topic is in users new post list
        $maybeNewPost = false;
        if ($spThisUser->member && sp_is_in_users_newposts($topicid)) {
            $maybeNewPost = true;
        }
        # retrieve topic and post records
        $spdb = new spdbComplex();
        $spdb->table = SFTOPICS;
        $spdb->found_rows = true;
        $spdb->fields = 'group_id, ' . SFTOPICS . '.topic_id, ' . SFTOPICS . '.forum_id, topic_name, topic_slug, topic_status, topic_pinned, topic_icon, topic_opened, ' . SFTOPICS . '.post_count, forum_name, forum_slug, forum_status,
							  forum_disabled, forum_rss_private, ' . SFPOSTS . '.post_id, ' . spdb_zone_datetime('post_date') . ', ' . SFPOSTS . '.user_id, ' . SFTOPICS . '.user_id AS topic_starter,
							  guest_name, guest_email, post_status, post_pinned, post_index, post_edit, poster_ip, source, post_content' . $waitCheck;
        $spdb->join = array(SFPOSTS . ' ON ' . SFTOPICS . '.topic_id=' . SFPOSTS . '.topic_id', SFFORUMS . ' ON ' . SFTOPICS . '.forum_id=' . SFFORUMS . '.forum_id');
        if ($spThisUser->admin || $spThisUser->moderator) {
            $spdb->left_join = array(SFWAITING . ' ON ' . SFPOSTS . '.post_id=' . SFWAITING . '.post_id');
        }
        $spdb->where = $WHERE;
        $spdb->orderby = $ORDER;
        $spdb->limits = $LIMIT;
        $spdb = apply_filters('sph_topicview_query', $spdb, $this);
        if (!empty($spThisUser->inspect['q_spTopicView'])) {
            $spdb->inspect = 'spTopicView';
            $spdb->show = true;
        }
        $records = $spdb->select();
        $t = array();
        if ($records) {
            $tidx = $topicid;
            $pidx = 0;
            $r = current($records);
            if (sp_get_auth('view_forum', $r->forum_id)) {
                $this->topicViewStatus = 'data';
                # construct the parent topic object
                $t[$tidx] = new stdClass();
                $t[$tidx]->topic_id = $r->topic_id;
                $t[$tidx]->forum_id = $r->forum_id;
                $t[$tidx]->group_id = $r->group_id;
                $t[$tidx]->forum_name = sp_filter_title_display($r->forum_name);
                $t[$tidx]->topic_name = sp_filter_title_display($r->topic_name);
                $t[$tidx]->topic_slug = $r->topic_slug;
                $t[$tidx]->topic_opened = $r->topic_opened;
                $t[$tidx]->forum_status = $r->forum_status;
                $t[$tidx]->topic_pinned = $r->topic_pinned;
                $t[$tidx]->forum_disabled = $r->forum_disabled;
                $t[$tidx]->forum_slug = $r->forum_slug;
                $t[$tidx]->forum_rss_private = $r->forum_rss_private;
                $t[$tidx]->topic_permalink = sp_build_url($r->forum_slug, $r->topic_slug, 1, 0);
                $t[$tidx]->topic_status = $r->topic_status;
                $t[$tidx]->topic_icon = sanitize_file_name($r->topic_icon);
                $t[$tidx]->rss = '';
                $t[$tidx]->editmode = 0;
                $t[$tidx]->tools_flag = 1;
                $t[$tidx]->display_page = $this->topicPage;
                $t[$tidx]->posts_per_page = $ppaged;
                $t[$tidx]->unread = 0;
                # user calc_rows and nor post_count as - for example - some posts may be hiodden by choice.
                $t[$tidx]->post_count = spdb_select('var', 'SELECT FOUND_ROWS()');
                # Can the user create new topics or should we lock the forum?
                $t[$tidx]->start_topics = sp_get_auth('start_topics', $r->forum_id);
                $t[$tidx]->reply_topics = sp_get_auth('reply_topics', $r->forum_id);
                $t[$tidx]->reply_own_topics = sp_get_auth('reply_own_topics', $r->forum_id);
                # grab topic start info
                $t[$tidx]->topic_starter = $r->topic_starter;
                $totalPages = $r->post_count / $ppaged;
                if (!is_int($totalPages)) {
                    $totalPages = intval($totalPages) + 1;
                }
                $t[$tidx]->total_pages = $totalPages;
                if ($setSort xor $reverse) {
                    if ($cPage == 1) {
                        $lastpage = true;
                    }
                } else {
                    if ($cPage == $totalPages) {
                        $lastpage = true;
                    }
                }
                $t[$tidx]->last_page = $lastpage;
                $t[$tidx] = apply_filters('sph_topicview_topic_record', $t[$tidx], $r);
                reset($records);
                unset($r);
                # now loop through the post records
                $newPostFlag = false;
                $firstPostPage = 1;
                $pinned = 0;
                # define post id and post user id arrays for plugins to use in combined filter
                $p = array();
                $u = array();
                foreach ($records as $r) {
                    $pidx = $r->post_id;
                    $p[] = $pidx;
                    # prepare for user object
                    $cUser = $spThisUser->ID == $r->user_id;
                    $cSmall = !$cUser;
                    $t[$tidx]->posts[$pidx] = new stdClass();
                    $t[$tidx]->posts[$pidx]->post_id = $r->post_id;
                    $t[$tidx]->posts[$pidx]->post_date = $r->post_date;
                    $t[$tidx]->posts[$pidx]->user_id = $r->user_id;
                    $t[$tidx]->posts[$pidx]->guest_name = sp_filter_name_display($r->guest_name);
                    $t[$tidx]->posts[$pidx]->guest_email = sp_filter_email_display($r->guest_email);
                    $t[$tidx]->posts[$pidx]->post_status = $r->post_status;
                    $t[$tidx]->posts[$pidx]->post_pinned = $r->post_pinned;
                    $t[$tidx]->posts[$pidx]->post_index = $r->post_index;
                    $t[$tidx]->posts[$pidx]->poster_ip = $r->poster_ip;
                    $t[$tidx]->posts[$pidx]->source = $r->source;
                    $t[$tidx]->posts[$pidx]->post_permalink = sp_build_url($r->forum_slug, $r->topic_slug, $cPage, $r->post_id);
                    $t[$tidx]->posts[$pidx]->edits = '';
                    $t[$tidx]->posts[$pidx]->last_post = 0;
                    $t[$tidx]->posts[$pidx]->last_post_on_page = 0;
                    $t[$tidx]->posts[$pidx]->first_post_on_page = $firstPostPage;
                    $t[$tidx]->posts[$pidx]->editmode = 0;
                    $t[$tidx]->posts[$pidx]->post_content = sp_filter_content_display($r->post_content);
                    $t[$tidx]->posts[$pidx]->first_pinned = 0;
                    $t[$tidx]->posts[$pidx]->last_pinned = 0;
                    $t[$tidx]->posts[$pidx]->postUser = new stdClass();
                    $t[$tidx]->posts[$pidx]->postUser = clone sp_get_user($r->user_id, $cUser, $cSmall);
                    # populate the user guest name and email in case the poster is a guest
                    if ($r->user_id == 0) {
                        $t[$tidx]->posts[$pidx]->postUser->guest_name = $t[$tidx]->posts[$pidx]->guest_name;
                        $t[$tidx]->posts[$pidx]->postUser->guest_email = $t[$tidx]->posts[$pidx]->guest_email;
                        $t[$tidx]->posts[$pidx]->postUser->display_name = $t[$tidx]->posts[$pidx]->guest_name;
                        $t[$tidx]->posts[$pidx]->postUser->ip = $t[$tidx]->posts[$pidx]->poster_ip;
                    }
                    # pinned status
                    if ($firstPostPage == 1 && $r->post_pinned) {
                        $t[$tidx]->posts[$pidx]->first_pinned = true;
                        $pinned = $pidx;
                    }
                    if ($firstPostPage == 0 && $pinned > 0 && $r->post_pinned == false) {
                        $t[$tidx]->posts[$pinned]->last_pinned = true;
                    } elseif ($r->post_pinned) {
                        $pinned = $pidx;
                    }
                    $firstPostPage = 0;
                    # Is this a new post for the current user?
                    if ($spThisUser->guest) {
                        $newPostFlag = false;
                    } else {
                        if ($maybeNewPost && strtotime($r->post_date) > strtotime($spThisUser->lastvisit)) {
                            $newPostFlag = true;
                        }
                        if (isset($r->new_post)) {
                            $newPostFlag = true;
                        }
                    }
                    $t[$tidx]->posts[$pidx]->new_post = $newPostFlag;
                    # do we need to hide an admin post?
                    if (!sp_get_auth('view_admin_posts', $r->forum_id) && sp_is_forum_admin($r->user_id)) {
                        $adminview = sp_get_sfmeta('adminview', 'message');
                        if ($adminview) {
                            $t[$tidx]->posts[$pidx]->post_content = '<div class="spMessage">';
                            $t[$tidx]->posts[$pidx]->post_content .= sp_filter_text_display($adminview[0]['meta_value']);
                            $t[$tidx]->posts[$pidx]->post_content .= '</div>';
                        } else {
                            $t[$tidx]->posts[$pidx]->post_content = '';
                        }
                    }
                    # do we need to hide an others posts?
                    if (sp_get_auth('view_own_admin_posts', $r->forum_id) && !sp_is_forum_admin($r->user_id) && !sp_is_forum_mod($r->user_id) && $spThisUser->ID != $r->user_id) {
                        $userview = sp_get_sfmeta('userview', 'message');
                        if ($userview) {
                            $t[$tidx]->posts[$pidx]->post_content = '<div class="spMessage">';
                            $t[$tidx]->posts[$pidx]->post_content .= sp_filter_text_display($userview[0]['meta_value']);
                            $t[$tidx]->posts[$pidx]->post_content .= '</div>';
                        } else {
                            $t[$tidx]->posts[$pidx]->post_content = '';
                        }
                    }
                    # Is this post to be edited?
                    if ($spVars['displaymode'] == 'edit' && $spVars['postedit'] == $r->post_id) {
                        $t[$tidx]->editmode = 1;
                        $t[$tidx]->editpost_id = $r->post_id;
                        $t[$tidx]->editpost_content = sp_filter_content_edit($r->post_content);
                        $t[$tidx]->posts[$pidx]->editmode = 1;
                    }
                    # Add edit history
                    if (!empty($r->post_edit) && is_serialized($r->post_edit)) {
                        $edits = unserialize($r->post_edit);
                        $eidx = 0;
                        foreach ($edits as $e) {
                            $t[$tidx]->posts[$pidx]->edits[$eidx] = new stdClass();
                            $t[$tidx]->posts[$pidx]->edits[$eidx]->by = $e['by'];
                            $t[$tidx]->posts[$pidx]->edits[$eidx]->at = $e['at'];
                            $eidx++;
                        }
                    }
                    if (!in_array($r->user_id, $u)) {
                        $u[] = $r->user_id;
                    }
                    $t[$tidx]->posts[$pidx] = apply_filters('sph_topicview_post_records', $t[$tidx]->posts[$pidx], $r);
                }
                # index of post IDs with position in listing
                $t[$tidx]->post_keys = $p;
                $t[$tidx]->posts[$pidx]->last_post = $lastpage;
                $t[$tidx]->posts[$pidx]->last_post_on_page = 1;
                # save last post on page id
                $t[$tidx]->last_post_id = $r->post_id;
                # allow plugins to add more data to combined topic/post data structure
                $t[$tidx] = apply_filters('sph_topicview_combined_data', $t[$tidx], $p, $u);
                unset($records);
            } else {
                # check for view forum lists but not topic lists
                if (sp_can_view($r->forum_id, 'forum-title')) {
                    $this->topicViewStatus = 'sneak peek';
                }
            }
        }
        return $t;
    }
function sp_SetupUserProfileData($userid = 0)
{
    global $spProfileUser, $spVars, $spThisUser;
    if (empty($userid)) {
        if (!empty($spVars['member'])) {
            $userid = (int) $spVars['member'];
        } else {
            $userid = $spThisUser->ID;
        }
    }
    $spProfileUser = sp_get_user($userid);
    $spProfileUser = apply_filters('sph_profile_user_data', $spProfileUser);
}
function sp_OnlineStatus($args = '', $user, $userProfile = '')
{
    global $spThisUser;
    $defs = array('tagClass' => 'spOnlineStatus', 'onlineIcon' => 'sp_UserOnline.png', 'offlineIcon' => 'sp_UserOffline.png', 'echo' => 1, 'get' => 0);
    $a = wp_parse_args($args, $defs);
    $a = apply_filters('sph_OnlineStatus_args', $a);
    extract($a, EXTR_SKIP);
    # sanitize before use
    $tagClass = esc_attr($tagClass);
    $onlineIcon = sanitize_file_name($onlineIcon);
    $offlineIcon = sanitize_file_name($offlineIcon);
    $user = (int) $user;
    $echo = (int) $echo;
    $get = (int) $get;
    # output display name
    $out = '';
    if (empty($userProfile)) {
        $userProfile = sp_get_user($user);
    }
    $spMemberOpts = sp_get_option('sfmemberopts');
    if (($spThisUser->admin || (!$spMemberOpts['sfhidestatus'] || !$userProfile->hidestatus)) && sp_is_online($user)) {
        $icon = sp_find_icon(SPTHEMEICONSURL, sanitize_file_name($onlineIcon));
        if ($get) {
            return true;
        }
    } else {
        $icon = sp_find_icon(SPTHEMEICONSURL, sanitize_file_name($offlineIcon));
        if ($get) {
            return false;
        }
    }
    $out .= "<img class='{$tagClass}' src='{$icon}' />";
    $out = apply_filters('sph_OnlineStatus', $out, $user, $a);
    if ($echo) {
        echo $out;
    } else {
        return $out;
    }
}
예제 #7
0
    die('Access denied - you cannot directly call this file');
}
global $spVars, $spThisUser, $spPostList, $spThisPostList;
# check installed version is correct
if (sp_get_system_status() != 'ok') {
    $out .= '<img style="style="vertical-align:bottom;border:none;"" src="' . sp_paint_file_icon(SPTHEMEICONSURL, 'sp_Information.png') . '" alt="" />' . "\n";
    $out .= '&nbsp;&nbsp;' . sp_text('The forum is temporarily unavailable while being upgraded to a new version');
    echo $out;
}
# are we doing feed keys? If so reset user to that f the passed feedkey - else leave as guest
$rssopt = sp_get_option('sfrss');
if (isset($rssopt['sfrssfeedkey']) && $rssopt['sfrssfeedkey']) {
    # get the user requesting feed
    $feedkey = $spVars['feedkey'];
    $userid = spdb_table(SFMEMBERS, "feedkey='{$feedkey}'", 'user_id');
    $spThisUser = sp_get_user($userid, true);
}
# = Support Functions ===========================
function sp_rss_filter($text)
{
    echo convert_chars(ent2ncr($text));
}
function sp_rss_excerpt($text)
{
    $rssopt = sp_get_option('sfrss');
    $max = $rssopt['sfrsswords'];
    if ($max == 0) {
        return $text;
    }
    $bits = explode(" ", $text);
    $text = '';
function sp_do_sp_FeaturedPostsTag($args = '')
{
    #check if forum displayed
    if (sp_abort_display_forum()) {
        return;
    }
    $defs = array('tagId' => 'spFeaturedPostsTag', 'tagClass' => 'spListTag', 'listId' => 'spListItemTag%ID%', 'listClass' => 'spListItemTag', 'linkClass' => 'spLinkTag', 'textClass' => 'spTextTag', 'avatarClass' => 'spAvatarTag', 'listTags' => 1, 'postIds' => '', 'limit' => 5, 'itemOrder' => 'FTUD', 'linkScope' => 'forum', 'beforeForum' => __('Forum: ', 'sp-featured'), 'afterForum' => '<br />', 'beforeTopic' => __('Topic: ', 'sp-featured'), 'afterTopic' => '<br />', 'beforeUser' => __('By: ', 'sp-featured'), 'afterUser' => '', 'beforeDate' => '&nbsp;-', 'afterDate' => '<br />', 'avatarSize' => 25, 'niceDate' => 1, 'postTip' => 1, 'beforePost' => __('Post: ', 'sp-featured'), 'afterPost' => '<br />', 'echo' => 1);
    $a = wp_parse_args($args, $defs);
    $a = apply_filters('sph_FeaturedPostsTag_args', $a);
    extract($a, EXTR_SKIP);
    # sanitize before use
    $tagId = esc_attr($tagId);
    $tagClass = esc_attr($tagClass);
    $listClass = esc_attr($listClass);
    $listId = esc_attr($listId);
    $linkClass = esc_attr($linkClass);
    $textClass = esc_attr($textClass);
    $avatarClass = esc_attr($avatarClass);
    $listTags = (int) $listTags;
    $postIds = esc_attr($postIds);
    $limit = (int) $limit;
    $itemOrder = esc_attr($itemOrder);
    $linkScope = esc_attr($linkScope);
    $beforeForum = sp_filter_title_display($beforeForum);
    $afterForum = sp_filter_title_display($afterForum);
    $beforeTopic = sp_filter_title_display($beforeTopic);
    $afterTopic = sp_filter_title_display($afterTopic);
    $beforeUser = sp_filter_title_display($beforeUser);
    $afterUser = sp_filter_title_display($afterUser);
    $beforeDate = sp_filter_title_display($beforeDate);
    $afterDate = sp_filter_title_display($afterDate);
    $avatarSize = (int) $avatarSize;
    $niceDate = (int) $niceDate;
    $postTip = (int) $postTip;
    $beforePost = sp_filter_title_display($beforePost);
    $afterPst = sp_filter_title_display($afterPost);
    $echo = (int) $echo;
    sp_forum_api_support();
    global $spPostList, $spThisPostList;
    # do we have post ids specified?
    if (empty($postIds)) {
        $posts = sp_get_sfmeta('featured', 'posts');
        $postIds = implode(',', $posts[0]['meta_value']);
    }
    $where = SFPOSTS . '.post_id IN (' . $postIds . ')';
    $spPostList = new spPostList($where, SFPOSTS . '.post_id DESC', $limit);
    if (empty($spPostList)) {
        return;
    }
    if (!empty($beforeForum)) {
        $beforeForum = trim($beforeForum) . ' ';
    }
    if (!empty($beforeTopic)) {
        $beforeTopic = trim($beforeTopic) . ' ';
    }
    if (!empty($beforeUser)) {
        $beforeUser = trim($beforeUser) . ' ';
    }
    if (!empty($beforeDate)) {
        $beforeDate = trim($beforeDate) . ' ';
    }
    if (!empty($afterForum)) {
        $afterForum = ' ' . trim($afterForum);
    }
    if (!empty($afterTopic)) {
        $afterTopic = ' ' . trim($afterTopic);
    }
    if (!empty($afterUser)) {
        $afterUser = '******' . trim($afterUser);
    }
    if (!empty($afterDate)) {
        $afterDate = ' ' . trim($afterDate);
    }
    $fLink = $tLink = $aLink = false;
    if ($linkScope == 'forum') {
        $fLink = $tLink = true;
    }
    if ($linkScope == 'all') {
        $aLink = true;
    }
    # Start building dislay
    if ($listTags ? $out = "<ul id='{$tagId}' class='{$tagClass}'>" : ($out = "<div id='{$tagId}' class='{$tagClass}'>")) {
    }
    # start the loop
    if (sp_has_postlist()) {
        while (sp_loop_postlist()) {
            sp_the_postlist();
            $thisId = str_ireplace('%ID%', $spThisPostList->topic_id, $listId);
            if ($listTags ? $out .= "<li id='{$thisId}' class='{$listClass}'>" : ($out .= "<div id='{$thisId}' class='{$listClass}'>")) {
            }
            $title = $postTip ? "title='{$spThisPostList->post_tip}'" : '';
            if ($aLink) {
                $out .= "<a class='{$linkClass}' {$title} href='{$spThisPostList->post_permalink}'>";
            }
            for ($x = 0; $x < strlen($itemOrder); $x++) {
                switch (substr($itemOrder, $x, 1)) {
                    case 'F':
                        # Forum
                        $out .= $beforeForum;
                        if ($fLink) {
                            $out .= "<a class='{$linkClass}' href='{$spThisPostList->forum_permalink}'>";
                        }
                        $out .= $spThisPostList->forum_name;
                        if ($fLink) {
                            $out .= '</a>';
                        }
                        $out .= $afterForum;
                        break;
                    case 'T':
                        # Topic
                        $out .= $beforeTopic;
                        if ($tLink) {
                            $out .= "<a class='{$linkClass}' {$title} href='{$spThisPostList->post_permalink}'>";
                        }
                        $out .= $spThisPostList->topic_name;
                        if ($tLink) {
                            $out .= '</a>';
                        }
                        $out .= $afterTopic;
                        break;
                    case 'P':
                        # Post
                        $out .= $beforePost;
                        $out .= $spThisPostList->post_content;
                        $out .= $afterPost;
                        break;
                    case 'E':
                        # Excerpt
                        $out .= $beforePost;
                        $out .= $spThisPostList->post_tip;
                        $out .= $afterPost;
                        break;
                    case 'A':
                        # Avatar
                        $thisUser = sp_get_user($spThisPostList->user_id);
                        $spx = $avatarSize + 10 . 'px';
                        $out .= sp_UserAvatar("tagClass={$avatarClass}&size={$avatarSize}&link=none&context=user&echo=0", $thisUser);
                        break;
                    case 'U':
                        # user
                        $out .= "<span class='{$textClass}'>{$spThisPostList->display_name}{$afterUser}</span>";
                        break;
                    case 'D':
                        # date
                        if ($niceDate) {
                            $out .= "<span class='{$textClass}'>" . $beforeDate . sp_nicedate($spThisPostList->post_date) . "{$afterDate}</span>\n";
                        } else {
                            $out .= "<span class='{$textClass}'>" . $beforeDate . sp_date('d', $spThisPostList->post_date) . "{$afterDate}</span>\n";
                        }
                        break;
                    default:
                        # Invalid code
                        $out .= '<br />' . __('Invalid Tag Code Found', 'sp-featured') . '<br />';
                        break;
                }
            }
            if ($aLink) {
                $out .= '</a>';
            }
            if ($listTags ? $out .= '</li>' : ($out .= '</div>')) {
            }
        }
    }
    if ($listTags ? $out .= '</ul>' : ($out .= '</div>')) {
    }
    $out = apply_filters('sph_FeaturedPostsTag', $out);
    if ($echo) {
        echo $out;
    } else {
        return $out;
    }
}