<?php
header("Content-type: application/xml"); 
print "<?xml version=\"1.0\" ?>".chr(13);
print "<rss version=\"2.0\" xmlns:CC=\"http://backend.userland.com/creativeCommonsRssModule\" xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">".chr(13);
print "<channel>".chr(13);
print "<title>Today in History</title>".chr(13);
print "<link>http://www.tnl.net/when/today</link>".chr(13);
print "<description>Interesting events which happened today</description>".chr(13);
print "<language>en</language>".chr(13);
print "<CC:license>http://creativecommons.org/licenses/by-nc-sa/1.0/</CC:license>".chr(13);
print "<image>".chr(13);
print "<title>TNL.net</title>".chr(13);
print "<url>http://www.tnl.net/assets/images/logos/tnl.net-logo.gif</url>".chr(13);
print "<link>http://www.tnl.net/when/today</link>".chr(13);
print "<width>125</width>".chr(13);
print "<height>44</height>".chr(13);
print "<description>Today in History</description>".chr(13);
print "</image>".chr(13);

print "<item>".chr(13);
$Host = "localhost";
$User = "root";
$Password = "24661tnl";
$DB = "tnl";

$when_month = date("m");
$when_day = date("d");
$thismonth = mktime(1,1,1,$when_month,$when_day,1);
$writtenmonth = date("F jS",$thismonth);

$WhenLink = mysql_connect ($Host,$User,$Password);
$events = 'SELECT * FROM `when` WHERE 1 AND `month` ='.$when_month.' AND `day` ='.$when_day.' AND `type` = \'event\' ORDER BY `year` ASC '; 
$birthdays = 'SELECT * FROM `when` WHERE 1 AND `month` ='.$when_month.' AND `day` ='.$when_day.' AND `type` = \'birthday\' ORDER BY `year` ASC '; 

$event_query = mysql_db_query ($DB, $events, $WhenLink);
$birthday_query = mysql_db_query ($DB, $birthdays, $WhenLink);

print "<title>Historical Events that happened on ".$writtenmonth."</title>".chr(13);
print "<link>http://www.tnl.net/when/".$when_month."/".$when_day."</link>".chr(13);
print "<description><![CDATA[";

while ($eventcontent = mysql_fetch_array ($event_query))
	{
	print "<strong>".$eventcontent[year]."</strong>";
	print $eventcontent[description];
	print "<br />";
}
print chr(13)."<!-- begin(Yahoo ad) --><a href=\"http://ypn-rss.overture.com/rss/33003/".$when_month.$when_day."1/click/\"><img src=\"http://ypn-rss.overture.com/rss/33003/".$when_month.$when_day."1/img/?url=http://www.tnl.net/when/".$when_month."/".$when_day."&amp;pid=1516816020\" alt=\"Ads by Yahoo!\" border=\"0\"/></a><!-- end(Yahoo ad) -->".chr(13);
print "]]></description>".chr(13);
print "<pubDate>".date(r)."</pubDate>".chr(13);
print "<guid>http://www.tnl.net/when/".$when_month."/".$when_day."#events</guid>".chr(13);
print "<author>today@nospam.tnl.net (Tristan Louis)</author>".chr(13);
print "<category>History</category>".chr(13);
print "<CC:license>http://creativecommons.org/licenses/by-nc-sa/1.0/</CC:license>".chr(13);
print "</item>".chr(13);
print "<item>".chr(13);
print "<title>".$writtenmonth." Birthdays</title>".chr(13);
print "<link>http://www.tnl.net/when/".$when_month."/".$when_day."</link>".chr(13);
print "<description><![CDATA[";

while ($birthdaycontent = mysql_fetch_array ($birthday_query))
	{
	print "<strong>".$birthdaycontent[year]."</strong>";
	print $birthdaycontent[description];
	print "<br />";
	}
// print chr(13)."<!-- begin(Yahoo ad) --><a href=\"http://ypn-rss.overture.com/rss/33003/".$when_month.$when_day."2/click/\"><img src=\"http://ypn-rss.overture.com/rss/33003/".$when_month.$when_day."2/img/?url=http://www.tnl.net/when/".$when_month."/".$when_day."&amp;pid=1516816020\" alt=\"Ads by Yahoo!\" border=\"0\"/></a><!-- end(Yahoo ad) -->".chr(13);

mysql_close ($WhenLink);

print "]]></description>".chr(13);
print "<pubDate>".date(r)."</pubDate>".chr(13);
print "<guid>http://www.tnl.net/when/".$when_month."/".$when_day."</guid>".chr(13);
print "<author>today@nospam.tnl.net (Tristan Louis)</author>".chr(13);
print "<category>History</category>".chr(13);
print "<CC:license>http://creativecommons.org/licenses/by-nc-sa/1.0/</CC:license>".chr(13);
print "</item>".chr(13);

print "</channel>".chr(13);
print "</rss>".chr(13);

?>

