[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Debian News RSS Feed



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

i have read the 47th issue of DWN, that there is no official RSS feed provided 
by the debian project. I wrote some code for my website with PHP, to build in 
a RSS feed (that includes my news). It works just fine and was validatet by a 
RSS-Validator. It was also tested with knewsticker. Here is the code i use.
Hope someone can use it:

<?php
$date = date("r");
header('Content-type: application/xml'); 
echo "<?xml version='1.0' encoding='ISO-8859-1' ?>\n";
echo "<!DOCTYPE rss PUBLIC '-//Netscape Communications//DTD RSS 0.91//EN'
'http://my.netscape.com/publish/formats/rss-0.91.dtd'>\n";
echo "<rss version='0.91'>\n";
echo "<channel>\n";
echo "<title>debian</title>\n";
echo "<link>http://www.debian.org</link>\n";
echo "<description>debian WEEKLY NEWS</description>\n";
echo "<language>en-en</language>\n";
echo "<lastBuildDate>$date</lastBuildDate>\n";
echo "<copyright>2004 debian</copyright>\n";
echo "<image>\n";
echo "<title>debian WEEKLY NEWS</title>\n";
echo "<url>http://www.debian.org/favicon.ico</url>\n";
echo "<link>http://www.debian.org</link>\n";
echo "</image>\n";
	
#######################################################################################
	#connect to database
	
#######################################################################################
	$conn_id = mysql_connect ("database","user","passwd");
	$result = mysql ("database","select * from news");
	$num = mysql_numrows ($result);
	if ($num != 0)
	{
	for ($i=0;$i<$num;$i++)
	{
	#########################################
	#database query
	#########################################
		$nrak = $num - $i - 1;
		$id = mysql_result ($result,$nrak,"id");
		$datum = mysql_result ($result,$nrak,"date");
		$header = mysql_result ($result,$nrak,"header");
		$eintrag = mysql_result ($result,$nrak,"entry");

		echo "<item>\n";
		echo "<title>$header</title>\n";
		echo "<link>http://www.debian.org/read_news.php?id=$id</link>\n";
		echo "<description>debian WEEKLY NEWS</description>\n";
		echo "</item>\n";

		    	}
	}
echo "</channel>\n";
echo "</rss>";
?>

- -- 
Greetings


Jens Voskuhl
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBrOh7V3K9CB+D8fgRAhmiAKDU5pFVFQc01TM7syuYvuTGg7rd7gCfZQhI
6YvxK2bccfTuvUYDv0yXV28=
=1S2a
-----END PGP SIGNATURE-----



Reply to: