<?
header("Content-Type: text/xml");
mysql_connect("localhost","diasis","thig5See");
mysql_select_db("diasis");
setlocale(LC_TIME, "de_CH");
function formattext($text) {
  $text = preg_replace('/\[mailto="(.*)"\]/i', '$1',$text);
  $text = preg_replace('/\[linkt="(.*)"\]/i', '$1',$text);
	$text = preg_replace('/\[linkint="(.*)"\]/i', '$1',$text);
	$text = preg_replace('/\[linktitle="(.*),(.*)"\]/i', '$2 (https://www.sylon.net/service/$1)',$text);
	$text = preg_replace('/\[linktitleint="(.*),(.*)"\]/i', '$2 (https://www.sylon.net/service/$1)',$text);
	$text = str_replace("</p>","\n\n",$text);
	$text = str_replace("&uuml;","ü",$text);
	$text = str_replace("&ouml;","ö",$text);
	$text = str_replace("&auml;","ä",$text);
	$text = strip_tags($text);
	$text = str_replace("&","&amp;",$text);
	return $text;
}
print "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n"?>
<rss version="2.0"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
	<channel>
		<title>DIAS-iS News: Highlights</title>
		<link>http://www.dias-is.com/welcome.html?diasnews.php</link>
		<description>Die letzten 10 Highlights aus den DIAS-iS News</description>
		<language>de-ch</language>
		<lastBuildDate><?
			$query = mysql_query("SELECT max(`datum`) FROM News");
			print date("r",strtotime(mysql_result($query,0,0)));
		?></lastBuildDate>
		<copyright>Copyright: (C) DATALINE AG</copyright>
		<docs>http://www.dias-is.com</docs>
<?
$query = mysql_query("SELECT `id`, `text`, `datum`, `paket`, `version`, `title` FROM `News` WHERE highlight='Ja' ORDER BY `datum` DESC LIMIT 0,10");
echo mysql_error();
while((list($id,$text,$date,$paket,$version,$title) = mysql_fetch_row($query))) {
	$text = strip_tags($text);
	print "		<item>
			<title>$paket: $title</title>
			<description>".formattext($text)."</description>
			<pubDate>$date</pubDate>
			<link>http://www.dias-is.com/diasnews.php?version=$version&amp;id=$id</link>
		</item>\n";
}
?>
	</channel>
</rss>
