<?
	$databasePath = "resources/db/";
	$db = new SQLite3($databasePath."articles_ES.db");
	$results = $db->query("SELECT * FROM articleStorage ORDER BY articleID DESC LIMIT 20;");

	header('Content-Type: text/xml; charset=UTF-8');
	echo "<?xml version='1.0' encoding='UTF-8'?>\n",
	"<rss version='2.0' xmlns:content='http://purl.org/rss/1.0/modules/content/' xmlns:wfw='http://wellformedweb.org/CommentAPI/' xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:atom='http://www.w3.org/2005/Atom'>\n",
	"\t<channel>\n",
	"\t\t<title>sombra2eternity encounter</title>\n",
	"\t\t<atom:link href='http://sombraencounter.com/rss/articles/' rel='self' type='application/rss+xml' />\n",
	"\t\t<link>http://sombraencounter.com/</link>\n",
	"\t\t<language>es</language>\n",
	"\t\t<description>sombraencounter.com</description>\n",
	"\t\t\t<pubDate>Sun, 03 Jan 2010 10:30:14 +0000</pubDate>\n",
	"\t\t\t<generator>sombra2eternity</generator>\n";

	while($row = $results->fetchArray(SQLITE3_ASSOC)){
		$d = explode("-",$row['articleDate']);
		$articleLink = $baseLink.$d[0]."/".$d[1]."/".$d[2]."/".$row['articleName']."/";

		echo "\t\t<item>\n",
		"\t\t\t<title>".$row['articleTitle']."</title>\n",
		"\t\t\t<link>http://sombraencounter.com/".$articleLink."</link>\n",
		"\t\t\t<comments>http://sombraencounter.com</comments>\n",
		"\t\t\t<pubDate>".date("D, d M Y",strtotime($row['articleDate']))." ".$row['articleTime']." +0000</pubDate>\n",
		"\t\t\t<category><![CDATA[Internet]]></category>\n",
		"\t\t\t<guid isPermaLink='true'>".$articleLink."</guid>\n",
		"\t\t\t<description>".html_entity_decode($row['articleSnippet'],ENT_QUOTES,"UTF-8")."</description>\n",
		"\t\t</item>\n";
	}

	echo "\t</channel>\n",
	"</rss>";
?>
