<?php
// +-------------------------------------------------------+
// | SCRiPTMAFiA 2005 - THE DiRTY HANDS ON YOUR SCRiPTS
// +-------------------------------------------------------+
require_once("../inc/config.php");
require_once("../inc/functions.php");
require_once("../class/db.php");
$sql = &new dbc("SELECT * FROM " . $dbprefix . "_settings");
$global = $sql->fetchrow();
$sql->close();
define("PREFIX", $dbprefix);


if(isset($_REQUEST['pp']) && $_REQUEST['pp']!=""){
	$limit = $_REQUEST['pp'];
	} else {
	$limit = 15;
}

if(!isset($page)){
	$page = 1;
}

$thecateg = ($_REQUEST['rss']=="news") ? "newscat" : "articlecat";

if($_REQUEST['categ']!="all" && $_REQUEST['categ']!=""){
	$catq = "  && ($thecateg='".escs($_REQUEST['categ'])."') ";
}
$area = escs($_REQUEST['area']);

header("Content-Type: text/xml");
header("Cache-Control: no-cache");
header("Pragma: no-cache");

ob_start();
$rss = "<?xml version=\"1.0\" encoding=\"gb2312\" ?>\n";
$rss .= "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns=\"http://my.netscape.com/rdf/simple/0.9/\">\n";

$rss .= " <channel>\n";
$rss .= "  <title>$row->titel</title>\n";
$rss .= "  <link>$row->link</link>\n";
$rss .= "  <description>$row->text</description>\n";
$rss .= " </channel>\n";

if($_REQUEST['rss']=="news"){
	$query = "SELECT uid,hits, image,image_align, newsid, title, text, textmore, time_start FROM ".PREFIX."_news WHERE ((area_id='$area' || allareas='yes') && ((time_end>=".time().") || (time_end='1') || (time_end='0')) && (((ispublic='1')) && (time_start<=".time().")$catq))  ORDER BY ntime DESC limit $limit";
	} else {
	$query = "SELECT id,time_start,title,type FROM ".PREFIX."_articles WHERE ((area='$area' || allareas='yes') && ((time_end>=".time().") || (time_end='1') || (time_end='0')) && (((active='1')) && (time_start<=".time().")$catq))  ORDER BY ctime DESC limit $limit";
}
$sql = new dbc($query);

while ($row = $sql->FetchRow()) {
	$rss .= " <item>\n";
	$rss .= "  <title>" . stripslashes($row->title) . "</title>\n";
	if($_REQUEST['rss']=="news"){
		$rss .= "  <link>http://".$_SERVER['HTTP_HOST'].str_replace("rss/index.php","",$_SERVER['PHP_SELF'])."index.php?p=news&amp;newsid=$row->newsid</link>\n";
	} else {
		$rss .= "  <link>http://".$_SERVER['HTTP_HOST'].str_replace("rss/index.php","",$_SERVER['PHP_SELF'])."index.php?type=$row->type&amp;p=articles&amp;id=$row->id</link>\n";
	}
	$rss .= " </item>\n";
}
$sql->Close();

$rss .= "</rdf:RDF>";

header("Content-Length: " . strlen($rss));
echo $rss;
exit();
?>