e_bb)) {
require_once(e_HANDLER.'bbcode_handler.php');
$tp->e_bb = new e_bbcode;
}
//get language file
if (is_readable(e_PLUGIN."rss_menu/languages/".e_LANGUAGE.".php")) {
include_once(e_PLUGIN."rss_menu/languages/".e_LANGUAGE.".php");
} else {
include_once(e_PLUGIN."rss_menu/languages/English.php");
}
//get template
if (is_readable(THEME."rss_template.php")) {
require_once(THEME."rss_template.php");
} else {
require_once(e_PLUGIN."rss_menu/rss_template.php");
}
//query handler
list($content_type, $rss_type, $topic_id) = explode(".", e_QUERY);
//list available rss feeds
if (intval($rss_type) == false) {
require_once(HEADERF);
require_once(e_PLUGIN."rss_menu/rss_template.php");
if(!$sql->db_Select("rss", "*", "rss_class='0' AND rss_limit>0 AND rss_topicid NOT REGEXP ('\\\*') ORDER BY rss_name"))
{
$ns->tablerender(LAN_ERROR, RSS_LAN_ERROR_4);
}
else
{
$text = $RSS_LIST_HEADER;
while($row=$sql->db_Fetch())
{
$text .= $tp -> parseTemplate($RSS_LIST_TABLE, FALSE, $rss_shortcodes);
}
$text .= $RSS_LIST_FOOTER;
$ns->tablerender(RSS_MENU_L2, $text);
}
require_once(FOOTERF);
exit;
}
//conversion table for old urls -------
$conversion[1] = "news";
$conversion[5] = "comments";
$conversion[10] = "bugtracker";
$conversion[12] = "download";
//-------------------------------------
//convert certain old urls so we can check the db entries ---------------------
if($topic_id){
//rss.php?1.2.14 (news, rss-2, cat=14)
if(is_numeric($content_type) && isset($conversion[$content_type]) ){
$content_type = $conversion[$content_type];
}
}else{
//rss.php?1.2 (news, rss-2) --> check = news (check conversion table)
if(is_numeric($content_type) && isset($conversion[$content_type]) ){
$content_type = $conversion[$content_type];
}
}
$check_topic = ($topic_id ? " AND rss_topicid = '".$topic_id."' " : "");
if(!$sql -> db_Select("rss", "*", "rss_class!='2' AND rss_url='".$content_type."' ".$check_topic." AND rss_limit>0 "))
{
//check if wildcard present for topic_id
$check_topic = ($topic_id ? " AND rss_topicid = '".str_replace($topic_id, "*", $topic_id)."' " : "");
if(!$sql -> db_Select("rss", "*", "rss_class!='2' AND rss_url='".$content_type."' ".$check_topic." AND rss_limit>0 "))
{
require_once(HEADERF);
$ns->tablerender("", RSS_LAN_ERROR_1);
require_once(FOOTERF);
exit;
}else{
$row = $sql->db_Fetch();
}
}else{
$row = $sql->db_Fetch();
}
//debugging
//echo $check." - ".$content_type." - ".$rss_type." - ".$topic_id."
";
//exit;
// ----------------------------------------------------------------------------
if($rss = new rssCreate($content_type, $rss_type, $topic_id, $row)){
$rss_title = ($rss->contentType ? $rss->contentType : ucfirst($content_type));
$rss->buildRss ($rss_title);
}else{
require_once(HEADERF);
$ns->tablerender(RSS_LAN_ERROR_0, RSS_LAN_ERROR_1);
require_once(FOOTERF);
exit;
}
class rssCreate {
var $contentType;
var $rssType;
var $path;
var $parm;
var $rssItems;
var $rssQuery;
var $topicid;
var $offset;
var $rssNamespace;
var $rssCustomChannel;
function rssCreate($content_type, $rss_type, $topic_id, $row) {
// constructor
$sql_rs = new db;
global $tp, $sql, $e107, $PLUGINS_DIRECTORY, $pref, $rssgen;
$this -> path = e_PLUGIN."rss_menu/";
$this -> rssType = $rss_type;
$this -> topicid = $topic_id;
$this -> offset = $pref['time_offset'] * 3600;
$this -> limit = $row['rss_limit'];
$this -> contentType = $row['rss_name'];
if(!is_numeric($content_type)){
$path = e_PLUGIN.$row['rss_path']."/e_rss.php";
}
if(strpos($row['rss_path'],'|')!==FALSE){
$tmp = explode("|", $row['rss_path']);
$path = e_PLUGIN.$tmp[0]."/e_rss.php";
$this -> parm = $tmp[1]; //parm is used in e_rss.php to define which feed you need to prepare
}
switch ($content_type) {
case news:
case 1:
if($topic_id && is_numeric($topic_id)){
$topic = " AND news_category = ".intval($topic_id);
}else{
$topic = '';
}
$path='';
$render = ($pref['rss_othernews'] != 1) ? "AND n.news_render_type < 2" : "";
$this -> rssQuery = "
SELECT n.*, u.user_id, u.user_name, u.user_email, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n
LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
WHERE n.news_class IN (".USERCLASS_LIST.") AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") {$render} {$topic} ORDER BY news_datestamp DESC LIMIT 0,".$this -> limit;
$sql->db_Select_gen($this -> rssQuery);
$tmp = $sql->db_getList();
$this -> rssItems = array();
$loop=0;
foreach($tmp as $value) {
$this -> rssItems[$loop]['title'] = $value['news_title'];
$this -> rssItems[$loop]['link'] = "http://".$_SERVER['HTTP_HOST'].e_HTTP."news.php?item.".$value['news_id'].".".$value['news_category'];
if($value['news_summary']){
$this -> rssItems[$loop]['description'] = $value['news_summary'];
}else{
$this -> rssItems[$loop]['description'] = $value['news_body'];
}
$this -> rssItems[$loop]['author'] = $value['user_name'];
$this -> rssItems[$loop]['author_email'] = $value['user_email'];
$this -> rssItems[$loop]['category'] = "".$value['category_name']."";
if($value['news_allow_comments'] && $pref['comments_disabled'] != 1){
$this -> rssItems[$loop]['comment'] = "http://".$_SERVER['HTTP_HOST'].e_HTTP."comment.php?comment.news.".$value['news_id'];
}
$this -> rssItems[$loop]['pubdate'] = $value['news_datestamp'];
$loop++;
}
break;
case 2:
$path='';
$this -> contentType = "articles";
break;
case 3:
$path='';
$this -> contentType = "reviews";
break;
case 4:
$path='';
$this -> contentType = "content";
break;
case comments:
case 5:
$path='';
$this -> rssQuery = "SELECT * FROM #comments ORDER BY comment_datestamp DESC LIMIT 0,".$this -> limit;
$sql->db_Select_gen($this -> rssQuery);
$tmp = $sql->db_getList();
$this -> rssItems = array();
$loop=0;
foreach($tmp as $value) {
$this -> rssItems[$loop]['title'] = $value['comment_subject'];
switch ($value['comment_type']) {
case 0:
$this -> rssItems[$loop]['link'] = "http://".$_SERVER['HTTP_HOST'].e_HTTP."comment.php?comment.news.".$value['comment_item_id'];
break;
case 4:
$this -> rssItems[$loop]['link'] = "http://".$_SERVER['HTTP_HOST'].e_HTTP."comment.php?comment.poll.".$value['comment_item_id'];
break;
}
$this -> rssItems[$loop]['description'] = $value['comment_comment'];
$this -> rssItems[$loop]['author'] = substr($value['comment_author'], (strpos($value['comment_author'], ".")+1));
$loop++;
}
break;
case 6:
case 7:
$path = e_PLUGIN."forum/e_rss.php";
break;
case 8:
if(!$this -> topicid) {
return FALSE;
}
$path = e_PLUGIN."forum/e_rss.php";
break;
/*
case 10:
$this -> limit = '9';
$path='';
$this -> contentType = "bugtracker reports";
$sql->db_Select("bugtrack2_bugs", "*", "bugtrack2_bugs_status=0 ORDER BY bugtrack2_bugs_datestamp LIMIT 0,".$this -> limit);
$tmp = $sql->db_getList();
$this -> rssItems = array();
$loop=0;
foreach($tmp as $value) {
$nick = preg_replace("/[0-9]+\./", "", $value['bugtrack2_bugs_poster']);
$this -> rssItems[$loop]['author'] = $nick;
$this -> rssItems[$loop]['title'] = $value['bugtrack2_bugs_summary'];
$this -> rssItems[$loop]['link'] = $e107->base_path.$PLUGINS_DIRECTORY."bugtracker2/bugtracker2.php?0.bug.".$value['bugtrack2_bugs_id'];
$this -> rssItems[$loop]['description'] = $value['bugtrack2_bugs_description'];
$loop++;
}
break;
*/
case 11:
if(!$this -> topicid) {
return FALSE;
}
$path = e_PLUGIN."forum/e_rss.php";
break;
case download:
case 12:
if($topic_id && is_numeric($topic_id)){
$topic = "d.download_category='".intval($topic_id)."' AND ";
}else{
$topic = "";
}
$path='';
$class_list = "0,251,252,253";
$query = "SELECT d.*, dc.* FROM #download AS d LEFT JOIN #download_category AS dc ON d.download_category = dc.download_category_id WHERE {$topic} d.download_active > 0 AND d.download_class IN (".$class_list.") ORDER BY d.download_datestamp DESC LIMIT 0,".$this -> limit;
$sql -> db_Select_gen($query);
// $sql->db_Select("download", "*", "{$topic} download_active > 0 AND download_class IN (".$class_list.") ORDER BY download_datestamp DESC LIMIT 0,".$this -> limit);
$tmp = $sql->db_getList();
$this -> rssItems = array();
$loop=0;
foreach($tmp as $value) {
if($value['download_author']){
$nick = preg_replace("/[0-9]+\./", "", $value['download_author']);
$this -> rssItems[$loop]['author'] = $nick;
}
$this -> rssItems[$loop]['author_email'] = $value['download_author_email'];
$this -> rssItems[$loop]['title'] = $value['download_name'];
$this -> rssItems[$loop]['link'] = $e107->base_path."download.php?view.".$value['download_id'];
$this -> rssItems[$loop]['description'] = ($rss_type == 3 ? $value['download_description'] : $value['download_description']);
$this -> rssItems[$loop]['category_name'] = $value['download_category_name'];
$this -> rssItems[$loop]['category_link'] = $e107->base_path."download.php?list.".$value['download_category_id'];
$this -> rssItems[$loop]['enc_url'] = $e107->base_path."request.php?".$value['download_id'];
$this -> rssItems[$loop]['enc_leng'] = $value['download_filesize'];
$this -> rssItems[$loop]['enc_type'] = $this->getmime($value['download_url']);
$this -> rssItems[$loop]['pubdate'] = $value['download_datestamp'];
$loop++;
}
break;
}
if(isset($path) && $path!=''){
//new rss reader from e_rss.php in plugin folder
if (is_readable($path)) {
require_once($path);
foreach($eplug_rss_data as $key=>$rs){
foreach($rs as $k=>$row){
$this -> rssItems[$k]['author'] = $row['author'];
$this -> rssItems[$k]['author_email'] = $row['author_email'];
$this -> rssItems[$k]['title'] = $row['title'];
if($row['link']){
if(eregi("http",$row['link'])){
$this -> rssItems[$k]['link'] = $row['link'];
}else{
$this -> rssItems[$k]['link'] = $e107->base_path.$PLUGINS_DIRECTORY.$row['link'];
}
}
$this -> rssItems[$k]['description'] = $row['description'];
if($row['enc_url']){
$this -> rssItems[$k]['enc_url'] = $e107->base_path.$PLUGINS_DIRECTORY.$enc_url.$row['item_id'];
}
if($row['enc_leng']){
$this -> rssItems[$k]['enc_leng'] = $row['enc_leng'];
}
if($eplug_rss['enc_type']){
$this -> rssItems[$k]['enc_type'] = $this->getmime($eplug_rss['enc_type']);
}elseif($row['enc_type']){
$this -> rssItems[$k]['enc_type'] = $row['enc_type'];
}
$this -> rssItems[$k]['category_name'] = $row['category_name'];
if($row['category_link']){
if(eregi("http",$row['category_link'])){
$this -> rssItems[$k]['category_link'] = $row['category_link'];
}else{
$this -> rssItems[$k]['category_link'] = $e107->base_path.$PLUGINS_DIRECTORY.$row['category_link'];
}
}
if($row['datestamp']){
$this -> rssItems[$k]['pubdate'] = $row['datestamp'];
}
}
}
}
}
}
function buildRss($rss_title) {
global $sql, $pref, $tp, $e107, $PLUGINS_DIRECTORY;
header('Content-type: application/xml', TRUE);
$rss_title = $tp->toRss($pref['sitename']." : ".$rss_title);
$rss_namespace = ($this->rssNamespace) ? "xmlns:".$this->rssNamespace : "";
$rss_custom_channel = ($this->rssCustomChannel) ? $this->rssCustomChannel : "";
$time = time();
switch ($this -> rssType) {
case 1: // Rss 1.0
echo "
".$tp->toRss($rss_title)."
".$pref['siteurl']."
".$tp->toRss($pref['sitedescription'])."
".$itemdate = date("r", ($time + $this -> offset))."
http://backend.userland.com/rss092\n";
foreach($this -> rssItems as $value)
{
// Multi-language rss links.
$link = (e_LANQRY) ? str_replace("?","?".e_LANQRY,$value['link']) : $value['link'];
echo "
-
".$tp->toRss($value['title'])."
".$tp->toRss(substr($value['description'],0,150))."
".$value['author']."<".$this->nospam($value['author_email']).">
".$link."
";
}
echo "
";
break;
case 2: // rss 2.0
$sitebutton = (strstr(SITEBUTTON, "http:") ? SITEBUTTON : SITEURL.str_replace("../", "", e_IMAGE).SITEBUTTON);
echo "
".$tp->toRss($rss_title)."
".$pref['siteurl']."
".$tp->toRss($pref['sitedescription'])."\n";
echo $tp->toRss($rss_custom_channel,TRUE)."\n";
echo "".CORE_LC.(defined("CORE_LC2") ? "-".CORE_LC2 : "")."
".preg_replace("#\
|\n|\r#si", "", SITEDISCLAIMER)."
".$pref['siteadmin']." - ".$this->nospam($pref['siteadminemail'])."
".$this->nospam($pref['siteadminemail'])."
".date("r",($time + $this -> offset))."
".date("r",($time + $this -> offset))."
http://backend.userland.com/rss
e107 (http://e107.org)
60
".$tp->toRss($rss_title)."
".(strstr(SITEBUTTON, "http:") ? SITEBUTTON : SITEURL.str_replace("../", "", e_IMAGE).SITEBUTTON)."
".$pref['siteurl']."
88
31
".$tp->toRss($pref['sitedescription'])."
Search
Search ".$tp->toRss($pref['sitename'])."
query
".SITEURL.(substr(SITEURL, -1) == "/" ? "" : "/")."search.php
";
foreach($this -> rssItems as $value)
{
// Multi-language rss links.
$link = (e_LANQRY) ? str_replace("?","?".e_LANQRY,$value['link']) : $value['link'];
$catlink = (e_LANQRY) ? str_replace("?","?".e_LANQRY,$value['category_link']) : $value['category_link'];
echo "
-
".$tp->toRss($value['title'])."\n";
if($link){
echo "".$link."\n";
}
echo "".$tp->toRss($value['description'],TRUE)."\n";
if($value['category_name'] && $catlink){
echo "".$tp -> toRss($value['category_name'])."\n";
}
if($value['comment']){
//echo "".$tp->toRss($value['comment'])."\n";
echo "".$value['comment']."\n";
}
if($value['author']){
echo "".$value['author']."<".$this->nospam($value['author_email']).">\n";
}
// enclosure support for podcasting etc.
if($value['enc_url'] && $value['enc_leng'] && $value['enc_type']){
echo "\n";
}
echo "".date("r", ($value['pubdate'] + $this -> offset))."\n";
if($link){
echo "".$link."\n";
}
echo "
";
}
echo "
";
break;
case 3: // rdf
echo "
".$tp->toRss($rss_title)."
".$pref['siteurl']."
".$tp->toRss($pref['sitedescription'])."
".CORE_LC.(defined("CORE_LC2") ? "-".CORE_LC2 : "")."
".$this->get_iso_8601_date($time + $this -> offset). "
".$this->nospam($pref['siteadminemail'])."
nospam($pref['siteadminemail'])."\" />
hourly
1
2000-01-01T12:00+00:00
";
foreach($this -> rssItems as $value)
{
// Multi-language rss links.
$link = (e_LANQRY) ? str_replace("?","?".e_LANQRY,$value['link']) : $value['link'];
echo "
";
}
echo "
";
reset($this -> rssItems);
unset($link);
foreach($this -> rssItems as $value)
{
// Multi-language rss links.
$link = (e_LANQRY) ? str_replace("?","?".e_LANQRY,$value['link']) : $value['link'];
echo "
-
".$tp->toRss($value['title'])."
".$link."
".$this->get_iso_8601_date($time + $this -> offset)."
".$value['author']."
".$tp->toRss($value['category_name'])."
".$tp->toRss($value['description'])."
";
}
echo "
";
break;
//new feed for atom - still in development, and not yet tested
case 4:
echo "\n
\n";
/*
\n";
*/
//required
echo "
".$pref['siteurl']."\n
".$tp->toRss($rss_title)."\n
".$this->get_iso_8601_date($time + $this -> offset)."\n";
//recommended
echo "
\n
e107\n";
//\n
echo "
http://e107.org/\n
\n
\n";
//optional
include(e_ADMIN."ver.php");
echo "
\n
\n
e107\n
\n
e107\n";
///icon.jpg\n
echo "
".(strstr(SITEBUTTON, "http:") ? SITEBUTTON : SITEURL.str_replace("../", "", e_IMAGE).SITEBUTTON)."\n
".$pref['siteadmin']." - ".$this->nospam($pref['siteadminemail'])."\n";
if($pref['sitedescription']){
echo "
".$pref['sitedescription']."\n";
}
foreach($this -> rssItems as $value) {
echo "
\n";
//required
echo "
".$value['link']."\n
".$tp->toRss($value['title'])."\n
".$this->get_iso_8601_date($value['pubdate'] + $this -> offset)."\n";
//recommended
$author = ($value['author']) ? $value['author'] : "unknown";
echo "
\n";
echo "
".$author."\n";
echo ($value['author_email']) ? "\t\t\t\t\t\t".$this->nospam($value['author_email'])."\n" : "";
echo "\n";
//complete story here\n
echo "
\n
".$tp->toRss($value['description'])."\n";
//optional
if($value['category_name']){
echo "\n";
}
//
// Jane Doe
//
echo "".$this->get_iso_8601_date($value['pubdate'] + $this -> offset)."\n";
//
//© 2005 John Doe
echo "
\n";
}
echo "
\n";
break;
}
}
function getmime($file){
$ext = strtolower(str_replace(".","",strrchr(basename($file), ".")));
$mime["mp3"] = "audio/mpeg";
return $mime[$ext];
}
function get_iso_8601_date($int_date) {
//$int_date: current date in UNIX timestamp
$date_mod = date('Y-m-d\TH:i:s', $int_date);
$pre_timezone = date('O', $int_date);
$time_zone = substr($pre_timezone, 0, 3).":".substr($pre_timezone, 3, 2);
$date_mod .= $time_zone;
return $date_mod;
}
function nospam($text){
$tmp = explode("@",$text);
return ($tmp[0] != "") ? $tmp[0].RSS_LAN_2 : RSS_LAN_3;
}
}
?>