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_topic_link($forumid, $topicid, $linktext = '', $listtags = true)
{
    global $current_user;
    sf_initialise_globals($forumid);
    if (empty($forumid)) {
        return '';
    }
    if (empty($topicid)) {
        return '';
    }
    $out = '';
    if (sf_topic_exists($topicid)) {
        if (sf_can_view_forum($forum_id)) {
            $forumslug = sf_get_forum_slug($forumid);
            $topicrec = sf_get_topic_record($topicid);
            $topicslug = $topicrec->topic_slug;
            if (empty($linktext)) {
                $linktext = stripslashes($topicrec->topic_name);
            }
            if ($listtags) {
                $out .= "<li>\n";
            }
            $out .= '<a href="' . sf_build_url($forumslug, $topicslug, 1, 0) . '">' . $linktext . '</a>' . "\n";
            if ($listtags) {
                $out .= "</li>\n";
            }
        }
    } else {
        $out = printf(__('Topic %s Not Found', 'sforum'), $topicid) . "\n";
    }
    echo $out;
    return;
}