<?php

// Einträge aus Datenbank laden und als RSS-Feeds ausgeben

function rss_feed()
  {
	include("../admin/blog/_globalSettings.php");		// User-Settings
	
	include("../scripts/_link2database_blog.php");		// Verbindung zum Server, wähle Datenbank

	include("../scripts/php_blog_tools.php");		// Zusatzfunktionen



	// Anfrage definieren und ausführen

	$query  = "SELECT blog_topics.topic, blog_schema.schema_id, blog_schema.posting_title, blog_schema.posting_description, DATE_FORMAT(blog_schema.schema_date_stamp, '%a, %e %b %Y') AS schema_date_stamp, blog_schema.schema_time_stamp

		   FROM blog_topics INNER JOIN blog_schema ON blog_topics.topic_id = blog_schema.id_topic AND blog_topics.id_owner = blog_schema.id_owner WHERE blog_topics.id_owner = \"$owner_id\" AND blog_topics.topic_close = 0 AND blog_schema.schema_close = 0

		   ORDER BY blog_schema.schema_id DESC LIMIT 50";

	$result = mysql_query($query) or die ("MySQL-Fehler: Anfrage an die Datenbank fehlgeschlagen! \n\n");



	// HTML-String erstellen

	while($row = mysql_fetch_assoc($result))
	  {
		$string[0] .= "    <item> \r\n";

		$string[0] .= "      <title><![CDATA[".$row['posting_title']."]]></title> \r\n";

		$string[0] .= "      <link><![CDATA[http://www.sinnes-lounge.de/blog/".title_maker($row['posting_title'])."_".$row['schema_id'].".html]]></link> \r\n";

		$string[0] .= "      <pubDate>".$row['schema_date_stamp']." ".$row['schema_time_stamp']." GMT</pubDate> \r\n";

		$string[0] .= "      <description><![CDATA[".$row['posting_description']."]]></description> \r\n";

		$string[0] .= "      <comments><![CDATA[http://www.sinnes-lounge.de/blog/kommentare-".$row['schema_id']."-1.html]]></comments> \r\n";

		$string[0] .= "      <category><![CDATA[".$row['topic']."]]></category>
 \r\n";

		$string[0] .= "      <guid><![CDATA[http://www.sinnes-lounge.de/blog/".title_maker($row['posting_title'])."_".$row['schema_id'].".html]]></guid> \r\n";

		$string[0] .= "    </item> \r\n";



		// lastBuildDate

		if (!isset($string[1]))
		  {
			$string[1] = $row['schema_date_stamp']." ".$row['schema_time_stamp']." GMT";
		  }
	  }



	mysql_free_result($result);				// MySQL-Laufzeit-Speicher leeren

								// Verbindung zum Server schließen

	mysql_close($link2mysql) or die ("MySQL-Fehler: Die Verbindung zum MySQL-Server konnte nicht geschlossen werden! \n\n");


	return $string;
  }



$string = rss_feed();						// Funktionsaufruf



header("Content-Type: application/rss+xml");			// Content Type

echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>";	// Header ausgeben

?>

<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <atom:link href="http://www.sinnes-lounge.de/rss/feed-blog.xml" rel="self" type="application/rss+xml" />
    <title>Sinnes-Lounge >> RSS-Newsfeed (Blog)</title>
    <link>http://www.sinnes-lounge.de/blog/index-1.html</link>
    <description>Die diskrete und exklusive Art der Entspannung - Für Ihn, Sie und Paare (RSS-Newsfeed zum Weblog)</description>
    <pubDate>Sat, 24 Oct 2009 08:15:00 GMT</pubDate>
    <lastBuildDate><?php echo $string[1]; ?></lastBuildDate>
    <language>de-de</language>
    <copyright>Inside Dreams GmbH, Gelsenkirchen</copyright>
<?php

echo $string[0];

?>
  </channel>
</rss>
