<?php
header('Content-Type: text/html; charset=utf-8'); // Set header to UTF8
session_start();
include_once('../../database/config.php');

include_once('includes/php/functions.php');
echo "<" . "?xml version=\"1.0\" ?" . ">\n"; ?> 
<rss version="2.0">
	<channel>
		<title>Nieuws Recruitment.nl</title>
		<copyright>Copyright (c) 2012 - 2013, Recruitment.nl</copyright>
		<link>http://www.recruitment.nl/nieuws-rss.xml</link>
		<language>nl</language>
		<description>Nieuwsberichten omtrent de recruitmentmarkt</description>
		<pubDate><?php echo date( "D, d M Y H:i:s O" );?></pubDate>
<?php
$sql="SELECT * FROM `news` WHERE (pubdate BETWEEN '0000-00-00 00:00' AND NOW()) AND (unpubdate > DATE_SUB(CURDATE(),INTERVAL 1 DAY) OR unpubdate IS NULL) ORDER BY pubdate DESC LIMIT 20";
$result	=	db_query($sql, '','fetchall');


foreach($result AS $item){
	$omschrijving =  preg_replace('/[^(\x20-\x7F)]*/','', strip_tags(substr($item['content'],0,500 ) ) ) . "";

	echo"	<item>\n";
	echo"		<title><![CDATA[" . htmlspecialchars($item['title']) . "]]></title>\n";
	echo"		<link><![CDATA[http://www.recruitment.nl/nieuws/" . htmlspecialchars($item['urlpart']) . "/]]></link>\n";
	echo"		<description><![CDATA[" . htmlspecialchars($omschrijving) . "]]></description>\n";
	echo"		<pubDate>".date("r", strtotime($item["created"]))."</pubDate>\n";
	echo"		<category>recruitment</category>\n";
	echo"	</item>\n";
}
?>	
	</channel>
</rss>