<?php
// $Id: newsRSS.php,v 1.1 2004/07/11 10:28:45 Farsus Exp $
// -------------------------------------------------------------------------//
//			                 RUNCMS                                         //
//                                                                          //
//	 reliable - Unique - Nocost &  Simplicity & ease off use                //
//                       < http://www.runcms.org >                          //
// -------------------------------------------------------------------------//
// Original Author: i-Tech (Half-Dead)
// Author Website : http://www.i-Technology.NET
// License Type   : LGPL: See /manual/LICENSES/LGPL.txt
// ------------------------------------------------------------------------- //

//---------------------------------------------------------------------------------------//
/**
* Builds the news RSS feed
*
*/
function build_rss() {
global $db, $xoopsConfig;

if ( @file_exists(XOOPS_ROOT_PATH . '/modules/news/cache/config.php') ) {
	include_once(XOOPS_ROOT_PATH . '/modules/news/cache/config.php');
}

if ( @file_exists(XOOPS_ROOT_PATH . '/modules/news/language/'.$xoopsConfig['language'].'/admin.php') ) {
	include_once(XOOPS_ROOT_PATH . '/modules/news/language/'.$xoopsConfig['language'].'/admin.php');
	} else {
		include_once(XOOPS_ROOT_PATH . '/modules/news/language/english/admin.php');
	}

if ($newsConfig['rss_enable'] == 1) {
	$SQL = 'SELECT title, storyid, hometext FROM '.$db->prefix('stories').' WHERE published>0 AND published<'.(time()+10).' ORDER BY published DESC';
	$query = $db->query($SQL, $newsConfig['rss_maxitems']);
	if ($query) {
		include_once(XOOPS_ROOT_PATH . '/class/xml-rss.php');
		$rss = new xml_rss(XOOPS_ROOT_PATH . '/modules/news/cache/news.xml');
		$rss->channel_title .= " :: "._MI_NEWS_NAME;
		$rss->image_title   .= " :: "._MI_NEWS_NAME;
		$rss->max_items            = $newsConfig['rss_maxitems'];
		$rss->max_item_description = $newsConfig['rss_maxdescription'];
		while ( list($title, $link, $description) = $db->fetch_row($query) ) {
			$link = XOOPS_URL . '/modules/news/article.php?storyid=' . $link;
			$rss->build($title, $link, $description);
		}
		$rss->save();
	}
}

}

?>
