<?
### rss.php - added [v1.21]
// Automatically get $tpath to avoid possible security holes
$tpath = realpath(__FILE__);
$tpath = substr($tpath,0,strrpos($tpath,DIRECTORY_SEPARATOR)+1);
// Check if the file exists on local server and include it
if(file_exists($tpath . "cn_config.php")) {
require_once($tpath . "cn_config.php");
} else {
die("Could not include required configuration file");
}
// Check if a connection to the database was established
if(!isset($link)) {
die("Please make sure the \"\$tpath\" variable is the root path to where 'rss.php' is on your server.");
}
// Page URL to link the news items
if(!isset($page)) { $page = "/index.php"; }
// Set limit for number of items displayed
if(!isset($lim)) { $lim = "5"; }
// Number of characters to cut news titles at
if(!isset($charnum)) { $charnum = "35"; }
// Get news items from database, and order them from newest to oldest
if($c != "") { $t_news .= " WHERE cat = '$c'"; }
$q['info'] = mysql_query("SELECT * FROM $t_news ORDER BY date DESC LIMIT 0, $lim", $link);
### Print XML RSS feed ###
header('Content-type: text/xml');
echo '<?xml version="1.0"?>';
// Edit the XML code below (between the dashed lines) for the output of your rss feed
// ------------------------------------------------------------------
?>
<rss version="2.0">
<channel>
<title><?php echo $set['sitename']; ?> RSS News Feed powered by CzarNews</title>
<description><?php echo $set['sitename']; ?> RSS News Feed powered by CzarNews</description>
<link><?php echo $set['siteurl']; ?></link>
<copyright>All Content copyright <?php echo date('Y'); ?> <?php echo $set['sitename']; ?></copyright>
<?php
while($r = mysql_fetch_array($q['info'], MYSQL_ASSOC)) {
// Edit the XML code below for the output of your rss feed
// Edit the XML code between the dashed lines
// ------------------------------------------------------------------
?>
<item>
<title> <?=htmlentities(strip_tags($r['subject'])); ?></title>
<description> <?=htmlentities(strip_tags($r['content'],'ENT_QUOTES'));?></description>
<link><?php echo $set['siteurl']; ?><? echo $page; ?>?a=<? echo $r['id']; ?></link>
<guid><?php echo $set['siteurl']; ?><? echo $page; ?>?a=<? echo $r['id']; ?></guid>
<pubDate> <?=strftime( "%a, %d %b %Y %T %Z" , $r['date']); ?></pubDate>
</item>
<?
// ------------------------------------------------------------------
}
?>
</channel>
</rss>