function sf_blog_linked_tag($postid, $show_img = true)
{
    sf_initialise_globals();
    include_once SF_PLUGIN_DIR . '/linking/sf-links-forum.php';
    $checkrow = sf_blog_links_postmeta('read', $postid, '');
    if ($checkrow) {
        $keys = explode('@', $checkrow->meta_value);
        $sfpostlinking = array();
        $sfpostlinking = get_option('sfpostlinking');
        $text = stripslashes($sfpostlinking['sflinkblogtext']);
        $icon = '<img src="' . SFRESOURCES . 'bloglink.png" alt="" />';
        if ($show_img) {
            $text = str_replace('%ICON%', $icon, $text);
        } else {
            $text = str_replace('%ICON%', '', $text);
        }
        $postcount = sf_get_posts_count_in_topic($keys[1]);
        $counttext = ' - (' . $postcount . ') ' . __("Posts", "sforum");
        echo '<span class="sfforumlink"><a href="' . sf_build_url(sf_get_forum_slug($keys[0]), sf_get_topic_slug($keys[1]), 1, 0) . '">' . $text . '</a>' . $counttext . '</span>';
    }
}
function sf_recent_posts_alt_tag($limit = 5, $forum = false, $user = true, $postdate = false, $listtags = true, $posttime = false)
{
    global $wpdb, $current_user, $sfvars;
    sf_initialise_globals($sfvars['forumid']);
    $out = '';
    $where = " WHERE post_status = 0";
    # limit to viewable forums based on permissions
    if (!$current_user->forumadmin) {
        $allforums = sf_get_forum_memberships($current_user->ID);
        if ($allforums) {
            $forum_ids = '';
            foreach ($allforums as $thisforum) {
                if (sf_can_view_forum($thisforum->forum_id)) {
                    $forum_ids[] = $thisforum->forum_id;
                }
            }
        } else {
            return '';
        }
        # create where clause based on forums that current user can view
        if ($forum_ids != '') {
            $where .= " AND forum_id IN (" . implode(",", $forum_ids) . ") ";
        }
    }
    $sfposts = $wpdb->get_results("SELECT DISTINCT forum_id, topic_id FROM " . SFPOSTS . $where . " ORDER BY post_id DESC LIMIT " . $limit);
    if ($sfposts) {
        foreach ($sfposts as $sfpost) {
            $thisforum = sf_get_forum_record($sfpost->forum_id);
            $p = false;
            $postdetails = sf_get_last_post_in_topic($sfpost->topic_id);
            # Start contruction
            if ($listtags) {
                $out .= "<li class='sftagli'>\n";
            }
            $out .= '<a href="' . sf_build_url($thisforum->forum_slug, sf_get_topic_slug($sfpost->topic_id), 1, $postdetails->post_id, $postdetails->post_index) . '">';
            $out .= sf_get_topic_name(sf_get_topic_slug($sfpost->topic_id));
            if ($forum) {
                $out .= ' ' . __("posted in", "sforum") . ' ' . stripslashes($thisforum->forum_name);
                $p = true;
            }
            if ($user) {
                $out .= ' ' . __("by ", "sforum") . ' ';
                $poster = sf_build_name_display($postdetails->user_id, stripslashes($postdetails->display_name));
                if (empty($poster)) {
                    $poster = apply_filters('sf_show_post_name', stripslashes($postdetails->guest_name));
                }
                $out .= $poster;
                $p = true;
            }
            if ($postdate) {
                $out .= ' ' . __("on", "sforum") . ' ' . mysql2date(SFDATES, $postdetails->post_date);
                if ($posttime) {
                    $out .= ' ' . __("at", "sforum") . ' ' . mysql2date(SFTIMES, $postdetails->post_date) . "\n";
                }
                $p = true;
            }
            $out .= '</a>';
            if ($listtags) {
                $out .= "</li>\n";
            }
        }
    } else {
        if ($listtags) {
            $out .= "<li class='sftagli'>\n";
        }
        $out .= __("No Topics to Display", "sforum") . "\n";
        if ($listtags) {
            $out .= "</li>\n";
        }
    }
    echo $out;
    return;
}