Location: PHPKode > projects > HB-NS > hb-ns/rss.php
<?php
//
// this file is an exmple of how to include an rss feed which will list the last six newsitems
// with an extract of the text and a link to read more
// if you want to show more or less than six extracts change the 6 in line 12 to another number
//
ob_start("ob_gzhandler");
header('Content-Type: application/rss+xml');
include_once("configuration.php");
include_once("functions.php");
if ($rss_limit == "")
{
	$rss_limit = 6;
}

echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
echo "<!-- feedurl: http://$SERVER_NAME$PHP_SELF -->\n";
?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<title><?php echo $sitename; ?></title>
		<link><?php echo $base_url; ?></link>
		<description><?php echo $description; ?></description>
		<dc:language><?php echo $language; ?></dc:language>
		<dc:creator><?php echo $adminname; ?></dc:creator>
		<dc:rights><?php echo $copy; ?></dc:rights>
<?php
$query = "SELECT id, title, topic, text FROM $table WHERE (expires >= '$now' OR expires = '00000000') AND push <= $now";
if (!empty ($topic))
{
	$query .= " AND topic='$topic'";
}
$query .= " ORDER BY id DESC LIMIT 0,$rss_limit";
$result = mysql_query($query);
while($query_data = mysql_fetch_array($result))
{
	$article = $query_data["id"];
	$title = htmlentities($query_data["title"]);
	$topic = htmlentities($query_data["topic"]);
	$topic_name = urlencode($topic);
	$text = convertBBCode($query_data["text"]);
	
	if ($allow_comments == "yes")
	{
		$query2 = "SELECT count(id) as counter FROM $comment_table WHERE id=$article AND approved='1'";
		$result2 = mysql_query($query2);
		while($query_data2 = mysql_fetch_array($result2))
		{
			$number = $query_data2["counter"];
			$show_comment_counter = " ($number comments)";
		}
	}

	echo "\t\t<item>\n";
	echo "\t\t\t<title>$title</title>\n";
	echo "\t\t\t<link>$news_base?article=$article</link>\n";
	if ($allow_comments == "yes") echo "\t\t\t<comments>$news_base?action=comment&amp;article=$article#comments</comments>\n";
	echo "\t\t\t<description><![CDATA[$text";
	if (!empty ($topic)) echo "<br><br>Topic: <a href=\"$news_base?action=topic&amp;topic=$topic_name\">$topic</a>";
	echo "$show_comment_counter";
	echo "]]></description>\n";
	echo "\t\t</item>\n";
}
?>
	</channel>
</rss>
<?php
ob_end_flush();
?>
Return current item: HB-NS