<?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");

$year = date("Y", time());
$gmtdiff = date("O", time());
$gmtstr = substr($gmtdiff, 0, 3) . ":" . substr($gmtdiff, 3, 9);

$now = date("Y-m-d\TH:i:s", time());
$now = $now . $gmtstr;
$modified = date("Y-m-d\TH:i:s", strtotime($startdate));
$modified = $modified . $gmtstr;

echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"
    ."<feed version=\"0.3\" xmlns=\"http://purl.org/atom/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xml:lang=\"fr\">\n"
    ."  <title>".htmlspecialchars($sitename)."</title>\n"
    ."  <link rel=\"alternate\" type=\"text/html\" href=\"".htmlspecialchars($nukeurl)."\" />\n"
    ."  <modified>".$modified."</modified>\n"
    ."  <tagline>".$slogan."</tagline>\n"
    ."  <id>tag:$domain,$year:/blog//1</id>\n"
    ."  <copyright>Copyright (c), $year ".$domain."</copyright>\n\n";

$sql = "SELECT s.sid,t.topicname,s.informant,s.title,s.time,s.hometext FROM ".TABLE_STORIES." s, ".TABLE_TOPICS." t where s.topic = t.topicid ORDER BY sid DESC LIMIT 10";
if ( !($result = $db->sql_query($sql)) )
{ query_die(GENERAL_ERROR, 'Could not obtain _stories or _topics', '', __LINE__, __FILE__, $sql);}

while ($row = $db->sql_fetchrow($result)) {
    $rsid = $db->XMFnum($row['sid']);
    $topicname = stripslashes($row['topicname']);
    $informant = stripslashes($row['informant']);
    $title = stripslashes($row['title']);
    $time = stripslashes($row['time']);
    $hometext = stripslashes($row['hometext']);
    if ($informant == "") {
        $informant = $anonymous;
    }

    // 2004-08-02T12:15:23-06:00
    $date = date("Y-m-d\TH:i:s", strtotime($time));
    $date = $date . $gmtstr;

    echo "<entry>\n"
        ."    <title>".$title."</title>\n"
        ."    <link rel=\"alternate\" type=\"text/html\" href=\"$nukeurl/phpnuke-nukescripts-article-$rsid.html\" />\n"
        ."    <modified>".$date."</modified>\n"
        ."    <issued>".$date."</issued>\n"
        ."    <id>tag:$domain,$year:/blog//$rsid</id>\n"
        ."    <created>".$date."</created>\n\n"
        ."    <summary type=\"text/html\">".$title."</summary>\n"
        ."    <author>\n"
        ."      <name>".$informant."</name>\n"
        ."      <url>".$nukeurl."</url>\n"
        ."      <email>".$adminmail."</email>\n"
        ."    </author>\n"
        ."    <dc:subject>".$topicname."</dc:subject>\n\n"
        ."    <content type=\"text/html\" mode=\"escaped\" xml:lang=\"fr\" xml:base=\"".$nukeurl."\">\n"
        ."      <![CDATA[".htmlspecialchars($hometext)."]]>\n"
        ."    </content>\n"
        ."  </entry>\n\n";
}

echo "</feed>\n";

?>