/** * topic rss feed, 10 latest posts in the topic * @param $forum_id forum id */ function getRssTopic($topic_id) { global $gConf; $topic_id = (int) $topic_id; $gConf['topics_per_page'] = 10; $gConf['date_format'] = '%a, %e %b %Y %k:%i:%s GMT'; $fdb = new DbForum(); $t = $fdb->getTopic($topic_id); if (!$t) { exit; } $a = $fdb->getPosts($topic_id, 0); reset($a); $items = ''; $lastBuildDate = ''; while (list(, $r) = each($a)) { $lp = $fdb->getTopicPost($r['topic_id'], 'last'); $td = strip_tags(substr($r['post_text'], 0, 256)); if (strlen($td) == 256) { $td .= '[...]'; } $tt = substr($td, 0, 32); $lastBuildDate = $lp['when']; $items .= <<<EOF \t\t\t<item> \t\t\t\t<title>{$tt}</title> \t\t\t\t<link>{$gConf['url']['base']}index.php?action=goto&topic_id={$r['topic_id']}</link> \t\t\t\t<description>{$td}</description> \t\t\t\t<pubDate>{$lp['when']}</pubDate> \t\t\t\t<guid>{$gConf['url']['base']}index.php?action=goto&topic_id={$r['topic_id']}</guid> \t\t\t</item> EOF; } return <<<EOF <rss version="2.0"> \t<channel> \t\t<title>{$t['topic_title']}</title> \t\t<link>{$gConf['url']['base']}index.php?action=goto&topic_id={$topic_id}</link> \t\t<description>{$t['topic_title']}</description> \t\t<lastBuildDate>{$lastBuildDate}</lastBuildDate>\t \t\t{$items} \t</channel> </rss> EOF; }
/** * topic rss feed, 10 latest posts in the topic * @param $forum_id forum id */ function getRssTopic($topic_uri) { global $gConf; $gConf['topics_per_page'] = 10; $gConf['date_format'] = '%a, %e %b %Y %k:%i:%s GMT'; $fdb = new DbForum(); $t = $fdb->getTopicByUri($topic_uri); $topic_id = (int) $t['topic_id']; if (!$t) { exit; } $a = $fdb->getPosts($topic_id, 0); reset($a); $items = ''; $lastBuildDate = ''; while (list(, $r) = each($a)) { $lp = $fdb->getTopicPost($r['topic_id'], 'last'); $td = strip_tags(substr($r['post_text'], 0, 256)); if (strlen($td) == 256) { $td .= '[...]'; } $tt = substr($td, 0, 32); $lastBuildDate = $lp['when']; $items .= "\n\t\t\t<item>\n\t\t\t\t<title>{$tt}</title>\n\t\t\t\t<link>" . $gConf['url']['base'] . sprintf($gConf['rewrite']['topic'], $t['topic_uri']) . "</link>\n\t\t\t\t<description>{$td}</description>\n\t\t\t\t<pubDate>{$lp['when']}</pubDate>\n\t\t\t\t<guid>" . $gConf['url']['base'] . sprintf($gConf['rewrite']['topic'], $t['topic_uri']) . "#{$r['post_id']}</guid>\n\t\t\t</item>"; } return "\n<rss version=\"2.0\">\n\t<channel>\n\t\t<title>{$t['topic_title']}</title>\n\t\t<link>" . $gConf['url']['base'] . sprintf($gConf['rewrite']['topic'], $t['topic_uri']) . "</link>\n\t\t<description>{$t['topic_title']}</description>\n\t\t<lastBuildDate>{$lastBuildDate}</lastBuildDate>\t\n\t\t{$items}\n\t</channel>\n</rss>"; }