<?php
// File: $Id: backend.php,v 1.26.2.1 2002/05/16 12:01:52 eugeniobaldi Exp $ $Name:  $
// ----------------------------------------------------------------------
// POST-NUKE Content Management System
// Copyright (C) 2001 by the Post-Nuke Development Team.
// http://www.postnuke.com/
// ----------------------------------------------------------------------
// Based on:
// PHP-NUKE Web Portal System - http://phpnuke.org/
// Thatware - http://thatware.org/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: Francisco Burzi
// Purpose of file: 
// ----------------------------------------------------------------------

include 'includes/pnAPI.php';
pnInit();
include 'includes/legacy.php';
// eugenio themeover 20020413
// pnThemeLoad();

header("Content-Type: text/xml");

$column = &$pntable['stories_column'];
$sql = "SELECT $column[sid], $column[title] FROM $pntable[stories] ORDER BY $column[sid] DESC";
$result = $dbconn->SelectLimit($sql,10);

/* fifers - no need for a count var.  just use a while loop */
// fifers - should we spit out an error XML doc?
if ($result === false) {
    echo "\n\n<font class=\"pn-normal\">An error occured</font>";
} else {
    echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n";
    echo "<!DOCTYPE rss PUBLIC \"-//Netscape Communications//DTD RSS 0.91//EN\"\n";
    echo " \"http://my.netscape.com/publish/formats/rss-0.91.dtd\">\n\n";
    echo "<rss version=\"0.91\">\n\n";
    echo "<channel>\n";

    $title = pnVarPrepForDisplay(pnConfigGetVar('sitename'));
    $link = pnVarPrepForDisplay(pnGetBaseURL());
    $description = pnVarPrepForDisplay(pnConfigGetVar('backend_title'));

    echo "<title>$title</title>\n";
    echo "<link>$link</link>\n";
    echo "<description>$description</description>\n";
//    echo "<language>$backend_language</language>\n\n";

    while(list($sid, $title) = $result->fields) {
        $title = pnVarPrepHTMLDisplay($title);
        $link = pnVarPrepForDisplay(pnGetBaseURL() . "modules.php?op=modload&name=News&file=article&sid=$sid");

        echo "<item>\n";
        echo "<title>$title</title>\n";
        echo "<link>$link</link>\n";
        echo "</item>\n\n";
        $result->MoveNext();
    }

    echo "</channel>\n";
    echo "</rss>\n";
}
?>