function sp_UsersAlsoViewing($args = '', $messageLabel = '')
{
    global $spThisUser, $spVars;
    $defs = array('tagClass' => 'spAlsoViewingContainer', 'userHolder' => 'spBrowsingUserHolder', 'browsingClass' => 'spBrowsingTopic', 'messageClass' => 'spBrowsingMessage', 'avatarClass' => 'spAvatar', 'avatarSize' => 30, 'includeAdmins' => 1, 'includeMods' => 1, 'includeMembers' => 0, 'displayToAll' => 0, 'echo' => 1, 'get' => 0);
    $a = wp_parse_args($args, $defs);
    $a = apply_filters('sph_UsersAlsoViewing_args', $a);
    extract($a, EXTR_SKIP);
    # sanitize before use
    $tagClass = esc_attr($tagClass);
    $browsingClass = esc_attr($browsingClass);
    $messageClass = esc_attr($messageClass);
    $avatarClass = esc_attr($avatarClass);
    $avatarSize = (int) $avatarSize;
    $includeAdmins = (int) $includeAdmins;
    $includeMods = (int) $includeMods;
    $includeMembers = (int) $includeMembers;
    $displayToAll = (int) $displayToAll;
    $echo = (int) $echo;
    $get = (int) $get;
    # get online user data
    $members = sp_get_members_online();
    if ($get) {
        return $members;
    }
    $out = '';
    $tout = '';
    # get member info to check against members browsing topic
    if ($members) {
        foreach ($members as $user) {
            if ($spThisUser->ID != $user->trackuserid) {
                if (!empty($spVars['pageview'])) {
                    if ($spVars['pageview'] == 'topic' && $user->topic_id == $spVars['topicid']) {
                        # check to see if admin, mod, or user
                        if ($displayToAll || $spThisUser->admin && $includeAdmins && sp_is_forum_admin($user->trackuserid) || $displayToAll || $spThisUser->admin && $includeMods && sp_is_forum_mod($user->trackuserid) || $displayToAll || $spThisUser->admin && $includeMembers && !sp_is_forum_mod($user->trackuserid != 0)) {
                            $tout .= "<div class='{$userHolder}'>";
                            $tout .= sp_UserAvatar("tagClass={$avatarClass}&size={$avatarSize}&link=none&context=user&echo=0", $user->trackuserid);
                            $tout .= "<span class='{$browsingClass}'>";
                            $tout .= sp_build_name_display($user->trackuserid, $user->display_name);
                            $tout .= "</span>";
                            $tout .= "<br><span> {$messageLabel}</span>";
                            $tout .= "</div>";
                        }
                    }
                }
            }
        }
    }
    if (!empty($tout)) {
        $out = "<div class='{$tagClass}'>";
        $out .= $tout;
        $out .= "</div>";
    }
    # finish it up
    if ($echo) {
        echo $out;
    } else {
        return $out;
    }
}
function sp_OnlineStats($args = '', $mostLabel = '', $currentLabel = '', $browsingLabel = '', $guestLabel = '')
{
    $defs = array('pMostClass' => 'spMostOnline', 'pCurrentClass' => 'spCurrentOnline', 'pBrowsingClass' => 'spCurrentBrowsing', 'link_names' => 1, 'usersOnly' => 0, 'echo' => 1, 'get' => 0);
    $a = wp_parse_args($args, $defs);
    $a = apply_filters('sph_OnlineStats_args', $a);
    extract($a, EXTR_SKIP);
    # sanitize before use
    $pMostClass = esc_attr($pMostClass);
    $pCurrentClass = esc_attr($pCurrentClass);
    $pBrowsingClass = esc_attr($pBrowsingClass);
    $link_names = (int) $link_names;
    $usersOnly = (int) $usersOnly;
    $echo = (int) $echo;
    $get = (int) $get;
    if (!empty($mostLabel)) {
        $mostLabel = sp_filter_title_display($mostLabel);
    }
    if (!empty($currentLabel)) {
        $currentLabel = sp_filter_title_display($currentLabel);
    }
    if (!empty($browsingLabel)) {
        $browsingLabel = sp_filter_title_display($browsingLabel);
    }
    if (!empty($guestLabel)) {
        $guestLabel = sp_filter_title_display($guestLabel);
    }
    # grab most online stat and update if new most
    $max = sp_get_option('spMostOnline');
    $online = spdb_count(SFTRACK);
    if ($online > $max) {
        $max = $online;
        sp_update_option('spMostOnline', $max);
    }
    $members = sp_get_members_online();
    if ($get) {
        $getData = new stdClass();
        $getData->max = $max;
        $getData->members = $members;
        return $getData;
    }
    # render the max online stats
    $out = "<p class='{$pMostClass}'><span>{$mostLabel}</span>{$max}</p>";
    # render the current online stats
    $browse = '';
    $out .= "<p class='{$pCurrentClass}'><span>{$currentLabel}</span>";
    # members online
    if ($members) {
        global $spThisUser, $spVars;
        $firstOnline = true;
        $firstBrowsing = true;
        $spMemberOpts = sp_get_option('sfmemberopts');
        foreach ($members as $user) {
            $userOpts = unserialize($user->user_options);
            if (!isset($userOpts['hidestatus'])) {
                $userOpts['hidestatus'] = false;
            }
            if ($spThisUser->admin || !$spMemberOpts['sfhidestatus'] || !$userOpts['hidestatus']) {
                if (!$firstOnline) {
                    $out .= ', ';
                }
                $out .= "<span class='spOnlineUser " . $user->display . "'>";
                $out .= sp_build_name_display($user->trackuserid, sp_filter_name_display($user->display_name), $link_names);
                $out .= '</span>';
                $firstOnline = false;
                # Set up the members browsing curent item list while here
                # Check that pageview is  set as this might be called from outside of the forum
                if (!empty($spVars['pageview'])) {
                    if ($spVars['pageview'] == 'forum' && $user->forum_id == $spVars['forumid'] || $spVars['pageview'] == 'topic' && $user->topic_id == $spVars['topicid']) {
                        if (!$firstBrowsing) {
                            $browse .= ', ';
                        }
                        $browse .= "<span class='spOnlineUser " . $user->display . "'>";
                        $browse .= sp_build_name_display($user->trackuserid, sp_filter_name_display($user->display_name), $link_names);
                        $browse .= '</span>';
                        $firstBrowsing = false;
                    }
                }
            }
        }
    }
    # guests online
    if (!$usersOnly && $online && $online > count($members)) {
        $guests = $online - count($members);
        $out .= "<br />{$guests} <span class='spOnlineUser spType-Guest'>{$guestLabel}</span>";
    }
    $out .= '</p>';
    # Members and guests browsing
    $out .= "<p class='{$pBrowsingClass}'>";
    $guestBrowsing = sp_guests_browsing();
    if ($browse || $guestBrowsing) {
        $out .= "<span>{$browsingLabel}</span>";
    }
    if ($browse) {
        $out .= $browse;
    }
    if (!$usersOnly && $guestBrowsing != 0) {
        $out .= "<br />{$guestBrowsing} <span class='spOnlineUser spType-Guest'>{$guestLabel}</span>";
    }
    $out .= "</p>\n";
    # finish it up
    $out = apply_filters('sph_OnlineStats', $out, $a);
    if ($echo) {
        echo $out;
    } else {
        return $out;
    }
}