<?php
function date_convert($date){
  $date_year=substr($date,0,4);
  $date_month=substr($date,5,2);
  $date_day=substr($date,8,2);

  $date=date("D, d M Y", mktime(0,0,0,$date_month,$date_day,$date_year));
  return $date;
};

header("Content-Type: text/xml");

$db=mysql_connect (localhost, "lzr_lzr", "84698469") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db("lzr_comments");

//RSS Related stuff
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n<rss version=\"2.0\">\n\n";
echo "<channel>\n<title>LZR (Leeran Z. Raphaely)</title>\n<link>http://lzr.cc</link>\n";
echo "<description>The personal page of Leeran Z. Raphaely aka me. Contains my music, games, programs, and stuff.</description>\n";

$result=mysql_query("SELECT * FROM news ORDER BY creationdate DESC, id DESC", $db);
$totnum=mysql_numrows($result);
if($totnum>20) $totnum=20;
for($i=0; $i<$totnum; $i++)
{
	echo "<item>\n\t<title>".strip_tags(mysql_result($result, $i, "title"))."</title>\n";
	echo "\t<link>http://lzr.cc/home.php?id=".mysql_result($result, $i, "id")."</link>\n";
	echo "\t<description>".strip_tags(mysql_result($result, $i, "text"))."</description>\n";
	echo "\t<pubDate>".date_convert(mysql_result($result, $i, "creationdate"))." 12:00:00 GMT</pubDate>\n";
	echo "\t<guid>http://lzr.cc/home.php?id=".mysql_result($result, $i, "id")."</guid>\n</item>\n\n";
}
echo "</channel>\n\n</rss>";

mysql_close();
?>
