<?php
/*========================================================*\
||########################################################||
||# #||
||# WB News v1.0.0 #||
||# ---------------------------------------------------- #||
||# Copyright (c) 2004-2008 #||
||# Created: 18th September 2005 #||
||# Filename: news.rss.php #||
||# #||
||########################################################||
/*========================================================*/
/**
* @author $Author: pmcilwaine $
* @version $Id: news.rss.php,v 1.2.2.2 2008/03/07 21:45:34 pmcilwaine Exp $
*/
$installpath = substr(__FILE__, 0, (($pos = strpos(__FILE__, basename(__FILE__))) != -1 ? $pos : 0));
include $installpath . "global.php"; //get the global file
if ( $config['rss_on'] == 1 && $config['systemstatus'] == 0)
{
// RSS Header
$display = '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n";
// XSL Header
if (file_exists($config['installdir'] . "/templates/" . $config["themepath"] . "/rss/feed.xsl"))
{
$stylesheet = 'http://' . $_SERVER['HTTP_HOST'] . "/" . str_replace($_SERVER['DOCUMENT_ROOT'], "", $config['installdir']);
$stylesheet .= '/templates/' . $theme['THEME_DIRECTORY'] . "/rss/feed.xsl";
$display .= '<?xml-stylesheet type="text/xsl" href="' . $stylesheet . '"?>' . "\r\n";
}
$display .= '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">' . "\r\n";
$display .= '<channel>' . "\r\n";
$display .= '<atom:link href="http://' . $_SERVER["HTTP_HOST"] . $_SERVER["PHP_SELF"] . '" rel="self" type="application/rss+xml" />' . "\r\n";
$display .= '<title>' . (empty($config['sitename']) ? "WB News RSS Generated" : $config['sitename']) . '</title>' . "\r\n";
$display .= '<link>' . (empty($config['siteaddress']) ? "http://" . $_SERVER['HTTP_HOST'] . "/" : $config['siteaddress']) . '</link>' . "\r\n";
$display .= '<description>WB News Generated RSS File</description>' . "\r\n";
$display .= '<generator>WB News v1.0.0 - http://www.webmobo.com/</generator>' . "\r\n";
$display .= '<language>en-us</language>' . "\r\n";
$cond = array();
$cond[] = "\"publish\"='1'";
if ( isset($_GET["catid"]) )
{
$cond[] = "\"catid\"='" . intval($_GET["catid"]) . "'";
}
$cond = join( " AND ", $cond );
$newslist = $DB->ListBy( TBL_NEWS, $cond, array("*"), "\"timeposted\" DESC" );
foreach ( $newslist as $news )
{
$replace = array( "\r", "\r\n" );
$news['news'] = /*bbcode(nl2br(htmldecode(*/$news['news']/*)))*/;
$news['news'] = str_replace($replace, "", $news['news']);
$display .= "<item>\r\n";
$display .= '<title>' . $news['title'] . '</title>' . "\r\n";
$link = str_replace( "{newsid}", $news["id"], $config['newsdisplay'] );
$parse_link = parse_url( $link );
if ( !array_key_exists( "scheme", $parse_link ) )
{
$link = "http://" . $link;
}
if ( !array_key_exists( "host", $parse_link ) )
{
$link = substr( $link, 0, 7 ) . $_SERVER["HTTP_HOST"] . "/" . substr( $link, 7 );
}
$display .= '<link>' . $link . '</link>' . "\r\n";
$display .= '<description><![CDATA[' . $news['news'] . ']]></description>' . "\r\n";
$display .= '<guid isPermaLink="true">' . $link . '</guid>' . "\r\n";
$display .= '<pubDate>' . date( "D, d M Y h:i:s T", $news['timeposted'] ) . '</pubDate>' . "\r\n";
$display .= '</item>' . "\r\n";
}
// footer
$display .= '</channel>'."\r\n";
$display .= '</rss>';
header('Content-type: application/xml');
echo $display;
}
?>