<?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  RSS Feed for PHP-Nuke phpBB2   */
/************************************************************************/

if (is_file("mainfile.php")) {
include_once("mainfile.php");}
global $prefix, $db, $nukeurl;
header("Content-Type: text/xml");
$sql = "SELECT t.topic_id, t.topic_title FROM ".$prefix."_bbtopics t, ".$prefix."_bbforums f where t.forum_id=f.forum_id and f.auth_view=0  ORDER BY t.topic_last_post_id DESC LIMIT 10";
if ( !($result = $db->sql_query($sql)) )
{ query_die(GENERAL_ERROR, 'Could not obtain _bbtopics', '', __LINE__, __FILE__, $sql);}
    if (!$result) {
	echo "An error occured";
    } else {
        echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n"
	    ."<rss version=\"2.0\" \n"
            ."  xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n"
            ."  xmlns:sy=\"http://purl.org/rss/1.0/modules/syndication/\"\n"
            ."  xmlns:admin=\"http://webns.net/mvcb/\"\n"
            ."  xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n\n"
            ."<channel>\n"
            ."<title>".htmlspecialchars($sitename)." - Forums</title>\n"
            ."<link>$nukeurl</link>\n"
            ."<description>".htmlspecialchars($backend_title)."</description>\n"
	    ."<language>$backend_language</language>\n\n"
            ."<dc:language>".$backend_language."</dc:language>\n"
            ."<dc:creator>".$adminmail."</dc:creator>\n"
            ."<dc:date>".$now."</dc:date>\n\n"
            ."<sy:updatePeriod>hourly</sy:updatePeriod>\n"
            ."<sy:updateFrequency>1</sy:updateFrequency>\n"
            ."<sy:updateBase>".$now."</sy:updateBase>\n\n";
        for ($m=0; $m < $db->sql_numrows($result); $m++) {
	$row = $db->sql_fetchrow($result);
	$topic_id = stripslashes($row['topic_id']);
	$topic_title = stripslashes($row['topic_title']);
            echo "<item>\n"
                ."<title>".htmlspecialchars($topic_title)."</title>\n"
                ."<link>$nukeurl/modules.php?name=Forums&amp;file=viewtopic&amp;t=$topic_id</link>\n"
                ."<guid isPermaLink=\"false\">".$nukeurl."</guid>\n"
                ."<dc:subject>".$topicname."</dc:subject>\n"
                ."<dc:date>".$date."</dc:date>\n"
                ."</item>\n\n";
        }
	echo "</channel>\n"
            ."</rss>";
$db->sql_freeresult($result);
    }

?>