<?php
/************************************************************************/
/* Maximus CMS: Web Portal System                                       */
/* ==============================                                       */
/*                                                                      */
/* Copyright (c) 2002 - 2006                                            */
/* http://www.php-maximus.fr                                            */
/* dev@php-maximus.org                                                  */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
/* Based on PHP-NUKE: Web Portal System                                 */
/************************************************************************/
if (is_file("mainfile.php")) {
include_once("mainfile.php");}
global $prefix, $db, $nukeurl;
header("Content-Type: text/xml");
$cat = $db->XMFnum($cat);
if ($cat != "") {
	$sql = "SELECT catid FROM ".TABLE_STORIES_CAT." WHERE title LIKE '%$cat%' LIMIT 1";
if ( !($resultat = $db->sql_query($sql)) )
{ query_die(GENERAL_ERROR, 'Could not obtain _stories_cat', '', __LINE__, __FILE__, $sql);}
	$catid = $db->sql_fetchrow($resultat);
	if ($catid == "") {
		$sql = "SELECT sid, title, hometext FROM ".TABLE_STORIES." ORDER BY sid DESC LIMIT 10";
	if ( !($result = $db->sql_query($sql)) )
{ query_die(GENERAL_ERROR, 'Could not obtain _stories', '', __LINE__, __FILE__, $sql);}
	} else {
		$catid = $db->XMFnum($catid);
		$sql = "SELECT sid, title, hometext FROM ".TABLE_STORIES." WHERE catid='$catid' ORDER BY sid DESC LIMIT 10";
	if ( !($result = $db->sql_query($sql)) )
{ query_die(GENERAL_ERROR, 'Could not obtain _stories', '', __LINE__, __FILE__, $sql);}
	}
} else {
	$sql = "SELECT sid, title, hometext FROM ".TABLE_STORIES." ORDER BY sid DESC LIMIT 10";
	if ( !($result = $db->sql_query($sql)) )
{ query_die(GENERAL_ERROR, 'Could not obtain _stories', '', __LINE__, __FILE__, $sql);}
}

echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n"
    ."<!DOCTYPE rss PUBLIC \"-//Netscape Communications//DTD RSS 0.91//EN\"\n"
    ." \"http://my.netscape.com/publish/formats/rss-0.91.dtd\">\n\n"
    ."<rss version=\"0.91\">\n\n"
    ."<channel>\n"
    ."<title>".htmlspecialchars($sitename)."</title>\n"
    ."<link>$nukeurl</link>\n"
    ."<description>".htmlspecialchars($backend_title)."</description>\n"
    ."<language>$backend_language</language>\n\n";

while ($row = $db->sql_fetchrow($result)) {
	$rsid = $db->XMFnum($row['sid']);
	$rtitle = stripslashes($row['title']);
	$rtext = stripslashes($row['hometext']);
	echo "<item>\n"
	    ."<title>".htmlspecialchars($rtitle)."</title>\n"
	    ."<link>$nukeurl/modules.php?name=News&amp;file=article&amp;sid=$rsid</link>\n"
	    ."<description>".htmlspecialchars($rtext)."</description>\n"
	    ."</item>\n\n";
}
echo "</channel>\n"
    ."</rss>";
$db->sql_freeresult($result);

?>