Location: PHPKode > projects > XennoBB > xennobb/syndicate.php
<?php
/*

  Copyright (C) 2005-2011 UserDot
  Visit XennoBB at www.userdot.net/projects/xennobb
  Originally based on PunBB www.punbb.org

  XennoBB is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published
  by the Free Software Foundation; either version 2 of the License,
  or (at your option) any later version.

  XennoBB is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  MA 02110-1301 USA

 */
include dirname(__FILE__) . '/include/config.php';
require FORUM_ROOT . 'include/init.php';
require_once FORUM_ROOT . 'include/functions/Parser.php';
$type = isset($_GET['type']) ? BB_Input::Htmlspecialchars($_GET['type']) : 'rss20';
$result = $db->query('SELECT g_read_board FROM ' . $db->prefix . 'usergroups WHERE g_id=3') or BB_Functions::Error($lang['error_36'], __FILE__, __LINE__, $db->error());
if ($db->result($result) == '0')
{
    exit('No permission');
}
if (!empty($_GET["cid"]))
{
    $where = "        AND c.id = '" . $db->escape($_GET['cid']) . "'";
    $title = 'cid';
}
else if (!empty($_GET["fid"]))
{
    $where = "        AND f.id = '" . $db->escape($_GET['fid']) . "'";
    $title = 'fid';
}
else if (!empty($_GET["tid"]))
{
    $where = "        AND t.id = '" . $db->escape($_GET['tid']) . "'";
    $title = 'tid';
}
else
{
    $where = '';
    $title = '';
}
if ($type == 'atom03')
{

    function xBB_Put_Header($cur, $title)
    {
        switch ($title)
        {
            case "cid":
                $title = ' : ' . $cur['cat_name'];
                break;
            case "fid":
                $title = ' : ' . $cur['cat_name'] . ' : ' . $cur['forum_name'];
                break;
            case "tid":
                $title = ' : ' . $cur['cat_name'] . ' : ' . $cur['forum_name'] . ' : ' . $cur['subject'];
                break;
            default:
                $title = '';
                break;
        }
        global $lang;
        date_default_timezone_set('UTC');
        echo '<' . '?xml version="1.0" encoding="' . $lang['lang_encoding'] . '"?' . '>' . "\n";
        echo "<feed version=\"0.3\" xmlns=\"http://purl.org/atom/ns#\">\n";
        echo "<title>" . BB_Input::Entity_To_Decimal_Value(BB_Input::Htmlspecialchars(bb_board_title . $title)) . "</title>\n";
        echo "<tagline>" . BB_Input::Entity_To_Decimal_Value(BB_Input::Htmlspecialchars(bb_board_title)) . "</tagline>\n";
        echo "<link rel=\"alternate\" type=\"text/html\" href=\"" . bb_forum_url . "\"/>\n";
        echo "<id>" . bb_forum_url . "</id>\n";
        echo "<modified>" . strval(date("c")) . "</modified>\n";
        echo "<author>\n";
        echo "\t<name>XennoBB</name>\n";
        echo "</author>\n";
    }

    function xBB_Put_Post($cur)
    {
        echo "<entry>\n";
        echo "<title>" . BB_Input::Entity_To_Decimal_Value(BB_Input::Htmlspecialchars($cur['subject'] . ' in ' . $cur['cat_name'] . ' : ' . $cur['forum_name'])) . "</title>\n";
        $link = bb_forum_url . 'topic.php?pid=' . strval($cur['id']) . '#' . strval($cur['id']);
        echo "<link rel=\"alternate\" type=\"text/html\" href=\"" . BB_Input::Entity_To_Decimal_Value(BB_Input::Htmlspecialchars($link)) . "\"/>\n";
        echo "<created>" . strval(date("c", $cur['postposted'])) . "</created>\n";
        echo "<issued>" . strval(date("c", $cur['postposted'])) . "</issued>\n";
        echo "<modified>" . strval(date("c", $cur['postposted'])) . "</modified>\n";
        echo "<id>" . BB_Input::Entity_To_Decimal_Value(BB_Input::Htmlspecialchars($link)) . "</id>\n";
        $data = "Topic: " . BB_Parser::Parse_Message($cur['subject'], 0) . "\n\nMessage: " . BB_Parser::Parse_Message($cur['message'], 0);
        echo "<summary>" . BB_Input::Encode_XML($data) . "</summary>\n";
        echo "</entry>\n";
    }

    function xBB_Put_Footer()
    {
        echo "</feed>\n";
    }

    ob_start();
    $result = $db->query("SELECT p.id AS id, p.message AS message, p.posted AS postposted, t.subject AS subject, f.forum_name, c.cat_name FROM " . $db->prefix . "posts p LEFT JOIN " . $db->prefix . "topics t ON p.topic_id=t.id INNER JOIN " . $db->prefix . "forums AS f ON f.id=t.forum_id LEFT JOIN " . $db->prefix . "categories AS c ON f.cat_id = c.id LEFT JOIN " . $db->prefix . "permissions AS fp ON (fp.forum_id=f.id AND fp.gid=3) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) $where ORDER BY postposted DESC LIMIT 0, 15") or BB_Functions::Error($lang['error_101'], __FILE__, __LINE__, $db->error());
    ;
    $i = 0;
    while ($cur = $db->fetch_assoc($result))
    {
        if ($i == 0)
        {
            xBB_Put_Header($cur, $title);
            $i++;
        }
        xBB_Put_Post($cur);
    }
    xBB_Put_Footer();
    $feed = ob_get_contents();
    ob_end_clean();
    $eTag = '"' . md5($feed) . '"';
    header('Etag: ' . $eTag);
    if ($eTag == $_SERVER['HTTP_IF_NONE_MATCH'])
    {
        header("HTTP/1.0 304 Not Modified");
        header('Content-Length: 0');
    }
    else
    {
        header("Content-type: text/xml");
        echo $feed;
    }
}
else if ($type == 'atom10')
{

    function xBB_Put_Header($cur, $title)
    {
        switch ($title)
        {
            case "cid":
                $title = ' : ' . $cur['cat_name'];
                break;
            case "fid":
                $title = ' : ' . $cur['cat_name'] . ' : ' . $cur['forum_name'];
                break;
            case "tid":
                $title = ' : ' . $cur['cat_name'] . ' : ' . $cur['forum_name'] . ' : ' . $cur['subject'];
                break;
            default:
                $title = '';
                break;
        }
        global $lang;
        echo '<' . '?xml version="1.0" encoding="' . $lang['lang_encoding'] . '"?' . '>' . "\n";
        echo "<feed xmlns=\"http://www.w3.org/2005/Atom\">\n";
        echo "<title>" . BB_Input::Entity_To_Decimal_Value(BB_Input::Htmlspecialchars(bb_board_title . $title)) . "</title>\n";
        echo "<subtitle>" . BB_Input::Entity_To_Decimal_Value(BB_Input::Htmlspecialchars(bb_board_title)) . "</subtitle>\n";
        echo "<link rel=\"self\" href=\"" . bb_website_url . "/syndicate.php?type=atom10\"/>\n";
        echo "<id>" . bb_forum_url . "</id>\n";
        echo "<updated>" . strval(date("c")) . "</updated>\n";
        echo "<author>\n";
        echo "\t<name>XennoBB</name>\n";
        echo "\t<uri>http://www.xennobb.com</uri>\n";
        echo "</author>\n";
        echo "<rights>" . BB_Input::Entity_To_Decimal_Value(BB_Input::Htmlspecialchars(bb_board_title . $title)) . "</rights>\n";
    }

    function xBB_Put_Post($cur)
    {
        echo "<entry>\n";
        echo "<title>" . BB_Input::Entity_To_Decimal_Value(BB_Input::Htmlspecialchars($cur['subject'] . ' in ' . $cur['cat_name'] . ' : ' . $cur['forum_name'])) . "</title>\n";
        $link = bb_forum_url . 'topic.php?pid=' . strval($cur['id']) . '#' . strval($cur['id']);
        echo "<link rel=\"alternate\" type=\"text/html\" href=\"" . BB_Input::Entity_To_Decimal_Value(BB_Input::Htmlspecialchars($link)) . "\"/>\n";
        echo "<updated>" . strval(date("c", $cur['postposted'])) . "</updated>\n";
        echo "<id>" . BB_Input::Entity_To_Decimal_Value(BB_Input::Htmlspecialchars($link)) . "</id>\n";
        $data = "Topic: " . BB_Parser::Parse_Message($cur['subject'], 0) . "\n\nMessage: " . BB_Parser::Parse_Message($cur['message'], 0);
        echo "<summary>" . BB_Input::Encode_XML($data) . "</summary>\n";
        echo "</entry>\n";
    }

    function xBB_Put_Footer()
    {
        echo "</feed>\n";
    }

    ob_start();
    $result = $db->query("SELECT p.id AS id, p.message AS message, p.posted AS postposted, t.subject AS subject, f.forum_name, c.cat_name FROM " . $db->prefix . "posts p LEFT JOIN " . $db->prefix . "topics t ON p.topic_id=t.id INNER JOIN " . $db->prefix . "forums AS f ON f.id=t.forum_id LEFT JOIN " . $db->prefix . "categories AS c ON f.cat_id = c.id LEFT JOIN " . $db->prefix . "permissions AS fp ON (fp.forum_id=f.id AND fp.gid=3) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) $where ORDER BY postposted DESC LIMIT 0,15") or BB_Functions::Error($lang['error_101'], __FILE__, __LINE__, $db->error());
    ;
    $i = 0;
    while ($cur = $db->fetch_assoc($result))
    {
        if ($i == 0)
        {
            xBB_Put_Header($cur, $title);
            $i++;
        }
        xBB_Put_Post($cur);
    }
    xBB_Put_Footer();
    $feed = ob_get_contents();
    ob_end_clean();
    $eTag = '"' . md5($feed) . '"';
    header('Etag: ' . $eTag);
    if ($eTag == $_SERVER['HTTP_IF_NONE_MATCH'])
    {
        header("HTTP/1.0 304 Not Modified");
        header('Content-Length: 0');
    }
    else
    {
        header("Content-type: text/xml");
        echo $feed;
    }
}
else if ($type == 'rss10')
{

    function xBB_Put_Header($cur, $title)
    {
        switch ($title)
        {
            case "cid":
                $title = ' : ' . $cur['cat_name'];
                break;
            case "fid":
                $title = ' : ' . $cur['cat_name'] . ' : ' . $cur['forum_name'];
                break;
            case "tid":
                $title = ' : ' . $cur['cat_name'] . ' : ' . $cur['forum_name'] . ' : ' . $cur['subject'];
                break;
            default:
                $title = '';
                break;
        }
        global $lang;
        echo '<' . '?xml version="1.0" encoding="' . $lang['lang_encoding'] . '"?' . '>' . "\n";
        echo '<rdf:RDF' . "\n";
        echo "\t" . 'xmlns="http://purl.org/rss/1.0/"' . "\n";
        echo "\t" . 'xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"' . "\n";
        echo "\t" . 'xmlns:slash="http://purl.org/rss/1.0/modules/slash/"' . "\n";
        echo "\t" . 'xmlns:dc="http://purl.org/dc/elements/1.1/">' . "\n";
        echo '<channel rdf:about="' . bb_forum_url . '">' . "\n";
        echo "\t" . '<title>' . BB_Input::Entity_To_Decimal_Value(BB_Input::Htmlspecialchars(bb_board_title . $title)) . '</title>' . "\n";
        echo "\t" . '<description>' . BB_Input::Entity_To_Decimal_Value(BB_Input::Htmlspecialchars(bb_board_title)) . '</description>' . "\n";
        echo "\t" . '<link>' . bb_forum_url . '</link>' . "\n";
        echo "\t" . '<image rdf:resource="' . bb_forum_url . '/img/general/button-rss.png" />' . "\n";
        echo "\t" . '<dc:date>' . strval(date('l dS \of F Y h:i:s A')) . '</dc:date>' . "\n";
        echo '</channel>' . "\n";
    }

    function xBB_Put_Post($cur)
    {
        $link = bb_forum_url . 'topic.php?pid=' . strval($cur['id']) . '#' . strval($cur['id']);
        echo "<item rdf:about=\"" . BB_Input::Entity_To_Decimal_Value(BB_Input::Htmlspecialchars($link)) . "\">" . "\n";
        echo "\t" . "<dc:format>text/html</dc:format>" . "\n";
        echo "\t" . "<dc:date>" . strval(date("r", $cur['postposted'])) . "</dc:date>" . "\n";
        echo "\t" . "<dc:source>" . bb_forum_url . "</dc:source>" . "\n";
        echo "\t" . "<title>" . BB_Input::Entity_To_Decimal_Value(BB_Input::Htmlspecialchars($cur['subject'] . ' in ' . $cur['cat_name'] . ' : ' . $cur['forum_name'])) . "</title>" . "\n";
        echo "\t" . "<link>" . BB_Input::Entity_To_Decimal_Value(BB_Input::Htmlspecialchars($link)) . "</link>" . "\n";
        $data = "Topic: " . BB_Parser::Parse_Message($cur['subject'], 0) . "\n\nMessage: " . BB_Parser::Parse_Message($cur['message'], 0);
        echo "\t" . "<description>" . BB_Input::Encode_XML($data) . "</description>" . "\n";
        echo "</item>\n";
    }

    function xBB_Put_Footer()
    {
        echo "</rdf:RDF>\n";
    }

    ob_start();
    $result = $db->query("SELECT p.id AS id, p.message AS message, p.posted AS postposted, t.subject AS subject, f.forum_name, c.cat_name FROM " . $db->prefix . "posts p LEFT JOIN " . $db->prefix . "topics t ON p.topic_id=t.id INNER JOIN " . $db->prefix . "forums AS f ON f.id=t.forum_id LEFT JOIN " . $db->prefix . "categories AS c ON f.cat_id = c.id LEFT JOIN " . $db->prefix . "permissions AS fp ON (fp.forum_id=f.id AND fp.gid=3) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) $where ORDER BY postposted DESC LIMIT 0,15") or BB_Functions::Error($lang['error_101'], __FILE__, __LINE__, $db->error());
    ;
    $i = 0;
    while ($cur = $db->fetch_assoc($result))
    {
        if ($i == 0)
        {
            xBB_Put_Header($cur, $title);
            $i++;
        }
        xBB_Put_Post($cur);
    }
    xBB_Put_Footer();
    $feed = ob_get_contents();
    ob_end_clean();
    $eTag = '"' . md5($feed) . '"';
    header('Etag: ' . $eTag);
    if ($eTag == $_SERVER['HTTP_IF_NONE_MATCH'])
    {
        header("HTTP/1.0 304 Not Modified");
        header('Content-Length: 0');
    }
    else
    {
        header("Content-type: text/xml");
        echo $feed;
    }
}
else if ($type == 'rss20')
{

    function xBB_Put_Header($cur, $title)
    {
        switch ($title)
        {
            case "cid":
                $title = ' : ' . $cur['cat_name'];
                break;
            case "fid":
                $title = ' : ' . $cur['cat_name'] . ' : ' . $cur['forum_name'];
                break;
            case "tid":
                $title = ' : ' . $cur['cat_name'] . ' : ' . $cur['forum_name'] . ' : ' . $cur['subject'];
                break;
            default:
                $title = '';
                break;
        }
        global $lang;
        echo '<' . '?xml version="1.0" encoding="' . $lang['lang_encoding'] . '"?' . '>' . "\n";
        echo "<rss version=\"2.0\">\n";
        echo "<channel>\n";
        echo "<title>" . BB_Input::Entity_To_Decimal_Value(BB_Input::Htmlspecialchars(bb_board_title . $title)) . "</title>\n";
        echo "<link>" . bb_forum_url . "</link>\n";
        echo "<description>" . BB_Input::Entity_To_Decimal_Value(BB_Input::Htmlspecialchars(bb_board_title)) . "</description>\n";
        echo "<language>en</language>\n";
        echo "<docs>http://backend.userland.com/rss</docs>\n";
    }

    function xBB_Put_Post($cur)
    {
        echo "<item>\n";
        echo "<title>" . BB_Input::Entity_To_Decimal_Value(BB_Input::Htmlspecialchars($cur['subject'] . ' in ' . $cur['cat_name'] . ' : ' . $cur['forum_name'])) . "</title>\n";
        $link = bb_forum_url . 'topic.php?pid=' . strval($cur['id']) . '#' . strval($cur['id']);
        echo "<link>" . BB_Input::Entity_To_Decimal_Value(BB_Input::Htmlspecialchars($link)) . "</link>\n";
        echo '<guid isPermaLink="false">' . strval($cur['id']) . '@' . bb_forum_url . '</guid>' . "\n";
        $data = "Topic: " . BB_Parser::Parse_Message($cur['subject'], 0) . "\n\nMessage: " . BB_Parser::Parse_Message($cur['message'], 0);
        echo "<description>" . BB_Input::Encode_XML($data) . "</description>\n";
        echo "<pubDate>" . strval(date("r", $cur['postposted'])) . "</pubDate>\n";
        echo "</item>\n";
    }

    function xBB_Put_Footer()
    {
        echo "</channel>\n";
        echo "</rss>\n";
    }

    ob_start();
    $result = $db->query("SELECT p.id AS id, p.message AS message, p.posted AS postposted, t.subject AS subject, f.forum_name, c.cat_name FROM " . $db->prefix . "posts p LEFT JOIN " . $db->prefix . "topics t ON p.topic_id=t.id INNER JOIN " . $db->prefix . "forums AS f ON f.id=t.forum_id LEFT JOIN " . $db->prefix . "categories AS c ON f.cat_id = c.id LEFT JOIN " . $db->prefix . "permissions AS fp ON (fp.forum_id=f.id AND fp.gid=3) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) $where ORDER BY postposted DESC LIMIT 0,15") or BB_Functions::Error($lang['error_101'], __FILE__, __LINE__, $db->error());
    ;
    $i = 0;
    while ($cur = $db->fetch_assoc($result))
    {
        if ($i == 0)
        {
            xBB_Put_Header($cur, $title);
            $i++;
        }
        xBB_Put_Post($cur);
    }
    xBB_Put_Footer();
    $feed = ob_get_contents();
    ob_end_clean();
    $eTag = '"' . md5($feed) . '"';
    header('Etag: ' . $eTag);
    if ($eTag == $_SERVER['HTTP_IF_NONE_MATCH'])
    {
        header("HTTP/1.0 304 Not Modified");
        header('Content-Length: 0');
    }
    else
    {
        header("Content-type: text/xml");
        echo $feed;
    }
}
else if ($type == 'opml')
{

    function xBB_Put_Header()
    {
        global $lang;
        echo '<' . '?xml version="1.0" encoding="ISO-8859-1"?' . '>' . "\n";
        echo "<opml version=\"1.0\">\n";
        echo "<head>\n";
        echo "<title>" . BB_Input::Entity_To_Decimal_Value(BB_Input::Htmlspecialchars(bb_board_title)) . "</title>\n";
        echo "<ownerName>" . BB_Input::Entity_To_Decimal_Value(BB_Input::Htmlspecialchars(bb_board_title)) . "</ownerName>\n";
        echo "<ownerEmail>" . BB_Input::Entity_To_Decimal_Value(BB_Input::Htmlspecialchars(bb_admin_email)) . "</ownerEmail>\n";
        echo "<dateCreated>" . BB_Input::Entity_To_Decimal_Value(BB_Input::Htmlspecialchars(date("D, d M Y H:i:s T"))) . "</dateCreated>\n";
        echo "<dateModified>" . BB_Input::Entity_To_Decimal_Value(BB_Input::Htmlspecialchars(date("D, d M Y H:i:s T"))) . "</dateModified>\n";
        echo "</head>\n";
    }

    function xBB_Put_Category($cur)
    {
        global $lang, $db;
        echo '<outline text="' . BB_Input::Entity_To_Decimal_Value(BB_Input::Htmlspecialchars($cur[1])) . '" type="rss" xmlUrl="' . bb_website_url . '/syndicate.php?type=rss20&amp;cid=' . $cur[0] . '" >' . "\n";
        $result2 = $db->query("SELECT id, forum_name, disp_position FROM " . $db->prefix . "forums WHERE cat_id=" . $cur[0] . " ORDER BY disp_position ASC") or BB_Functions::Error($lang['error_54'], __FILE__, __LINE__, $db->error());
        ;
        while ($res = $db->fetch_row($result2))
            xBB_Put_Forum($res);
        echo "</outline>\n";
    }

    function xBB_Put_Forum($res)
    {
        global $lang;
        echo '<outline text="' . BB_Input::Entity_To_Decimal_Value(BB_Input::Htmlspecialchars($res[1])) . '" type="rss" xmlUrl="' . bb_website_url . '/syndicate.php?type=rss20&amp;fid=' . $res[0] . '" />' . "\n";
    }

    ob_start();
    xBB_Put_Header();
    $result = $db->query("SELECT id, cat_name, disp_position FROM " . $db->prefix . "categories ORDER BY disp_position ASC") or BB_Functions::Error($lang['error_122'], __FILE__, __LINE__, $db->error());
    ;
    echo "<body>\n";
    while ($cur = $db->fetch_row($result))
    {
        xBB_Put_Category($cur);
    }
    echo "</body>\n";
    echo "</opml>\n";
    $feed = ob_get_contents();
    ob_end_clean();
    $eTag = '"' . md5($feed) . '"';
    header('Etag: ' . $eTag);
    if ($eTag == $_SERVER['HTTP_IF_NONE_MATCH'])
    {
        header("HTTP/1.0 304 Not Modified");
        header('Content-Length: 0');
    }
    else
    {
        header('Content-type: application/xml; charset=ISO-8859-1');
        header("Cache-Control: no-store, no-cache, must-revalidate");
        header("Cache-Control: post-check=0, pre-check=0", false);
        echo $feed;
    }
}
else if ($type == 'google_sitemap')
{
    $result = $db->query('SELECT t.id as topic_id, subject, last_post, sticky FROM ' . $db->prefix . 'topics AS t LEFT JOIN ' . $db->prefix . 'permissions AS fp ON (fp.forum_id=t.forum_id AND fp.gid=3) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL ORDER BY last_post DESC') or BB_Functions::Error($lang['error_37'], __FILE__, __LINE__, $db->error());
    $result2 = $db->query('SELECT f.id as forum_id, forum_name, last_post FROM ' . $db->prefix . 'forums AS f LEFT JOIN ' . $db->prefix . 'permissions AS fp ON (fp.forum_id=f.id AND fp.gid=3) WHERE fp.read_forum IS NULL OR fp.read_forum=1 ORDER BY f.id DESC') or BB_Functions::Error($lang['error_54'], __FILE__, __LINE__, $db->error());
    $output = '<' . '?xml version="1.0" encoding="UTF-8"?' . '>' . "\n";
    $output .= '<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">' . "\n";
    $output .= "<url>\n";
    $output .= "\t<loc>" . bb_forum_url . "/" . "</loc>\n";
    $output .= "\t<lastmod>" . gmdate('Y-m-d\TH:i:s+00:00', time()) . "</lastmod>\n";
    $output .= "\t<priority>1.0</priority>\n";
    $output .= "</url>\n\n";
    while ($cur_forum = $db->fetch_assoc($result2))
    {
        $lastmodified = gmdate('Y-m-d\TH:i:s+00:00', $cur_forum['last_post']);
        $viewforum = BB_Input::Rewrite_URL("f", $cur_forum['forum_id'], $cur_forum['forum_name']);
        $priority = '1.0';
        $output .= "<url>\n";
        $output .= "\t<loc>" . bb_forum_url . "$viewforum</loc>\n";
        $output .= "\t<lastmod>$lastmodified</lastmod>\n";
        $output .= "\t<priority>$priority</priority>\n";
        $output .= "</url>\n\n";
    }
    while ($cur_topic = $db->fetch_assoc($result))
    {
        $lastmodified = gmdate('Y-m-d\TH:i:s+00:00', $cur_topic['last_post']);
        $viewtopic = BB_Input::Rewrite_URL("t", $cur_topic['topic_id'], $cur_topic['subject']);
        $priority = ($cur_topic['sticky'] == '1') ? '1.0' : '0.5';
        $output .= "<url>\n";
        $output .= "\t<loc>" . bb_forum_url . "$viewtopic" . "</loc>\n";
        $output .= "\t<lastmod>$lastmodified</lastmod>\n";
        $output .= "\t<priority>$priority</priority>\n";
        $output .= "</url>\n\n";
    }
    $output .= "</urlset>\n";
    header('Content-type: application/xml');
    echo $output;
}
Return current item: XennoBB