2006-12-02 04:36:16 +00:00
< ? php
/*
2011-01-14 18:29:06 +00:00
* e107 website system
*
2013-03-26 12:16:55 +01:00
* Copyright ( C ) 2008 - 2013 e107 Inc ( e107 . org )
2011-01-14 18:29:06 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
* RSS Feed management
*
*/
2006-12-02 04:36:16 +00:00
/*
Query string : content_type . rss_type . [ topic id ]
1 : news
5 : comments
12 : downloads ( option : specify category )
Plugins should use an e_rss . php file in their plugin folder
----------------------------------------------------------------
*/
2009-12-03 22:32:34 +00:00
require_once ( '../../class2.php' );
$e107 = e107 :: getInstance ();
2011-05-13 11:26:35 +00:00
if ( ! $e107 -> isInstalled ( 'rss_menu' ))
2008-12-13 12:34:53 +00:00
{
2009-12-03 22:32:34 +00:00
header ( 'Location: ' . e_BASE . 'index.php' );
2008-12-13 12:34:53 +00:00
exit ;
}
2006-12-02 04:36:16 +00:00
2013-03-26 12:16:55 +01:00
$tp = e107 :: getParser ();
2006-12-02 04:36:16 +00:00
2009-12-03 22:32:34 +00:00
require_once ( e_PLUGIN . 'rss_menu/rss_shortcodes.php' );
require_once ( e_HANDLER . 'userclass_class.php' );
2006-12-02 04:36:16 +00:00
2009-12-03 22:32:34 +00:00
/*
global $tp ;
2011-05-13 11:26:35 +00:00
if ( ! is_object ( $tp -> e_bb ))
2008-12-13 12:34:53 +00:00
{
2006-12-02 04:36:16 +00:00
require_once ( e_HANDLER . 'bbcode_handler.php' );
$tp -> e_bb = new e_bbcode ;
}
2009-12-03 22:32:34 +00:00
*/
2006-12-02 04:36:16 +00:00
2009-09-18 19:05:50 +00:00
// Get language file
2009-12-03 22:32:34 +00:00
include_lan ( e_PLUGIN . 'rss_menu/languages/' . e_LANGUAGE . '_admin_rss_menu.php' );
2006-12-02 04:36:16 +00:00
2009-09-18 19:05:50 +00:00
// Get template
2011-05-13 11:26:35 +00:00
if ( is_readable ( THEME . 'rss_template.php' ))
2008-12-13 12:34:53 +00:00
{
2009-12-03 22:32:34 +00:00
require_once ( THEME . 'rss_template.php' );
2011-05-13 11:26:35 +00:00
}
else
2008-12-13 12:34:53 +00:00
{
2009-12-03 22:32:34 +00:00
require_once ( e_PLUGIN . 'rss_menu/rss_template.php' );
2006-12-02 04:36:16 +00:00
}
2009-09-18 19:05:50 +00:00
// Query handler
2008-10-03 20:15:09 +00:00
if ( e_QUERY )
{
2009-12-03 22:32:34 +00:00
$tmp = explode ( '.' , e_QUERY );
2013-03-26 12:16:55 +01:00
$content_type = $tp -> toDB ( $tmp [ 0 ]);
2008-10-03 20:15:09 +00:00
$rss_type = intval ( varset ( $tmp [ 1 ], 0 ));
2013-03-26 12:16:55 +01:00
$topic_id = $tp -> toDB ( $tmp [ 2 ], '' );
2008-10-03 20:15:09 +00:00
}
2006-12-02 04:36:16 +00:00
2009-09-18 19:05:50 +00:00
// List available rss feeds
2011-05-13 11:26:35 +00:00
if ( ! $rss_type )
2009-12-03 22:32:34 +00:00
{ // Display list of all feeds
2006-12-02 04:36:16 +00:00
require_once ( HEADERF );
2009-12-03 22:32:34 +00:00
// require_once(e_PLUGIN.'rss_menu/rss_template.php'); Already loaded
2006-12-02 04:36:16 +00:00
2013-03-26 12:16:55 +01:00
if ( ! $sql -> select ( 'rss' , '*' , " `rss_class`=0 AND `rss_limit`>0 AND `rss_topicid` NOT REGEXP (' \\ \ *') ORDER BY `rss_name` " ))
2006-12-02 04:36:16 +00:00
{
$ns -> tablerender ( LAN_ERROR , RSS_LAN_ERROR_4 );
}
else
{
$text = $RSS_LIST_HEADER ;
2013-03-26 12:16:55 +01:00
while ( $row = $sql -> fetch ())
2006-12-02 04:36:16 +00:00
{
2013-03-26 12:16:55 +01:00
$text .= $tp -> parseTemplate ( $RSS_LIST_TABLE , FALSE , $rss_shortcodes );
2006-12-02 04:36:16 +00:00
}
$text .= $RSS_LIST_FOOTER ;
$ns -> tablerender ( RSS_MENU_L2 , $text );
}
require_once ( FOOTERF );
exit ;
}
2009-12-03 22:32:34 +00:00
// Returning feeds here
2009-09-18 19:05:50 +00:00
// Conversion table for old urls -------
2009-12-03 22:32:34 +00:00
$conversion [ 1 ] = 'news' ;
$conversion [ 5 ] = 'comments' ;
$conversion [ 10 ] = 'bugtracker' ;
$conversion [ 12 ] = 'download' ;
2006-12-02 04:36:16 +00:00
//-------------------------------------
2011-05-13 11:26:35 +00:00
// Convert certain old urls so we can check the db entries
2009-12-03 22:32:34 +00:00
// Rss.php?1.2 (news, rss-2) --> check = news (check conversion table)
// TODO: legacy stuff still required?
if ( is_numeric ( $content_type ) && isset ( $conversion [ $content_type ]) )
{
$content_type = $conversion [ $content_type ];
2006-12-02 04:36:16 +00:00
}
2009-12-03 22:32:34 +00:00
2006-12-02 04:36:16 +00:00
$check_topic = ( $topic_id ? " AND rss_topicid = ' " . $topic_id . " ' " : " " );
2013-03-26 12:16:55 +01:00
if ( ! $sql -> select ( 'rss' , '*' , " rss_class!=2 AND rss_url=' " . $content_type . " ' " . $check_topic . " AND rss_limit>0 " ))
2009-09-18 19:05:50 +00:00
{ // Check if wildcard present for topic_id
2006-12-02 04:36:16 +00:00
$check_topic = ( $topic_id ? " AND rss_topicid = ' " . str_replace ( $topic_id , " * " , $topic_id ) . " ' " : " " );
2013-03-26 12:16:55 +01:00
if ( ! $sql -> select ( 'rss' , '*' , " rss_class!=2 AND rss_url=' " . $content_type . " ' " . $check_topic . " AND rss_limit>0 " ))
2006-12-02 04:36:16 +00:00
{
require_once ( HEADERF );
2009-12-03 22:32:34 +00:00
$ns -> tablerender ( '' , RSS_LAN_ERROR_1 );
2006-12-02 04:36:16 +00:00
require_once ( FOOTERF );
exit ;
2008-10-03 20:15:09 +00:00
}
else
{
2013-03-26 12:16:55 +01:00
$row = $sql -> fetch ();
2006-12-02 04:36:16 +00:00
}
2008-10-03 20:15:09 +00:00
}
else
{
2013-03-26 12:16:55 +01:00
$row = $sql -> fetch ();
2006-12-02 04:36:16 +00:00
}
2009-12-03 22:32:34 +00:00
2006-12-02 04:36:16 +00:00
// ----------------------------------------------------------------------------
2009-09-18 19:05:50 +00:00
if ( $rss = new rssCreate ( $content_type , $rss_type , $topic_id , $row ))
{
2006-12-02 04:36:16 +00:00
$rss_title = ( $rss -> contentType ? $rss -> contentType : ucfirst ( $content_type ));
2013-06-18 20:21:39 -07:00
$rss -> buildRss ( $rss_title );
2009-09-18 19:05:50 +00:00
}
else
{
2006-12-02 04:36:16 +00:00
require_once ( HEADERF );
$ns -> tablerender ( RSS_LAN_ERROR_0 , RSS_LAN_ERROR_1 );
require_once ( FOOTERF );
exit ;
}
2011-05-13 11:26:35 +00:00
class rssCreate
2009-09-18 19:05:50 +00:00
{
2009-12-03 22:32:34 +00:00
protected $e107 ;
2006-12-02 04:36:16 +00:00
var $contentType ;
var $rssType ;
var $path ;
var $parm ;
var $rssItems ;
var $rssQuery ;
var $topicid ;
var $offset ;
var $rssNamespace ;
var $rssCustomChannel ;
2011-05-13 11:26:35 +00:00
public function __construct ( $content_type , $rss_type , $topic_id , $row )
2009-09-18 19:05:50 +00:00
{ // Constructor
2006-12-02 04:36:16 +00:00
$sql_rs = new db ;
2011-05-13 11:26:35 +00:00
global $rssgen ;
$sql = e107 :: getDb ();
$pref = e107 :: getPref ();
$tp = e107 :: getParser ();
2009-12-03 22:32:34 +00:00
$this -> e107 = e107 :: getInstance ();
2006-12-02 04:36:16 +00:00
$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' ];
2009-12-03 22:32:34 +00:00
if ( ! is_numeric ( $content_type ))
{
$path = e_PLUGIN . $row [ 'rss_path' ] . '/e_rss.php' ;
2006-12-02 04:36:16 +00:00
}
2013-06-18 20:21:39 -07:00
if ( strpos ( $row [ 'rss_path' ], '|' ) !== FALSE ) //FIXME remove this check completely.
2009-12-03 22:32:34 +00:00
{
2006-12-02 04:36:16 +00:00
$tmp = explode ( " | " , $row [ 'rss_path' ]);
$path = e_PLUGIN . $tmp [ 0 ] . " /e_rss.php " ;
2013-06-18 20:21:39 -07:00
$this -> parm = $tmp [ 1 ]; // FIXME @Deprecated - use $parm['url'] instead in data() method within e_rss.php. Parm is used in e_rss.php to define which feed you need to prepare
2006-12-02 04:36:16 +00:00
}
2011-05-13 11:26:35 +00:00
switch ( $content_type )
2009-09-18 19:05:50 +00:00
{
2008-11-02 22:29:33 +00:00
case 'news' :
2006-12-02 04:36:16 +00:00
case 1 :
2009-05-04 09:24:36 +00:00
if ( $topic_id && is_numeric ( $topic_id ))
{
2006-12-02 04:36:16 +00:00
$topic = " AND news_category = " . intval ( $topic_id );
2009-05-04 09:24:36 +00:00
}
else
{
2006-12-02 04:36:16 +00:00
$topic = '' ;
}
2009-09-18 19:05:50 +00:00
2006-12-02 04:36:16 +00:00
$path = '' ;
2012-11-01 02:21:58 +00:00
$render = ( $pref [ 'rss_othernews' ] != 1 ) ? " AND (FIND_IN_SET('0', n.news_render_type) OR FIND_IN_SET(1, n.news_render_type)) " : " " ;
2009-05-04 09:24:36 +00:00
$nobody_regexp = " '(^|,)( " . str_replace ( " , " , " | " , e_UC_NOBODY ) . " )(,| $ )' " ;
2006-12-02 04:36:16 +00:00
$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
2012-11-01 02:21:58 +00:00
WHERE n . news_class IN ( " .USERCLASS_LIST. " ) AND NOT ( n . news_class REGEXP " . $nobody_regexp . " ) AND n . news_start < " .time(). " AND ( n . news_end = 0 || n . news_end > " .time(). " ) { $render } { $topic } ORDER BY n . news_datestamp DESC LIMIT 0 , " . $this -> limit;
2013-03-26 12:16:55 +01:00
$sql -> gen ( $this -> rssQuery );
2006-12-02 04:36:16 +00:00
$tmp = $sql -> db_getList ();
$this -> rssItems = array ();
$loop = 0 ;
2011-05-13 11:26:35 +00:00
foreach ( $tmp as $value )
2009-09-18 19:05:50 +00:00
{
2006-12-02 04:36:16 +00:00
$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' ];
2007-02-07 22:45:10 +00:00
if ( $value [ 'news_summary' ] && $pref [ 'rss_summarydiz' ])
{
$this -> rssItems [ $loop ][ 'description' ] = $value [ 'news_summary' ];
2009-09-18 19:05:50 +00:00
}
else
{
2011-01-16 23:19:50 +00:00
$this -> rssItems [ $loop ][ 'description' ] = ( $value [ 'news_body' ] . " <br /> " . $value [ 'news_extended' ]);
2007-02-07 22:45:10 +00:00
}
2006-12-02 04:36:16 +00:00
$this -> rssItems [ $loop ][ 'author' ] = $value [ 'user_name' ];
2007-02-07 22:45:10 +00:00
$this -> rssItems [ $loop ][ 'author_email' ] = $value [ 'user_email' ];
2011-01-16 23:19:50 +00:00
// $this -> rssItems[$loop]['category'] = "<category domain='".SITEURL."news.php?cat.".$value['news_category']."'>".$value['category_name']."</category>";
$this -> rssItems [ $loop ][ 'category_name' ] = $tp -> toHTML ( $value [ 'category_name' ], TRUE , 'defs' );
$this -> rssItems [ $loop ][ 'category_link' ] = $e107 -> base_path . " news.php?cat. " . $value [ 'news_category' ];
2006-12-02 04:36:16 +00:00
2009-09-18 19:05:50 +00:00
if ( $value [ 'news_allow_comments' ] && $pref [ 'comments_disabled' ] != 1 )
{
2006-12-02 04:36:16 +00:00
$this -> rssItems [ $loop ][ 'comment' ] = " http:// " . $_SERVER [ 'HTTP_HOST' ] . e_HTTP . " comment.php?comment.news. " . $value [ 'news_id' ];
2007-02-07 22:45:10 +00:00
}
2006-12-02 04:36:16 +00:00
$this -> rssItems [ $loop ][ 'pubdate' ] = $value [ 'news_datestamp' ];
2009-09-18 19:05:50 +00:00
if ( $pref [ 'rss_shownewsimage' ] == 1 && strlen ( trim ( $value [ 'news_thumbnail' ])) > 0 ) {
$this -> rssItems [ $loop ][ 'news_thumbnail' ] = $value [ 'news_thumbnail' ];
}
2006-12-02 04:36:16 +00:00
$loop ++ ;
}
break ;
case 2 :
$path = '' ;
$this -> contentType = " articles " ;
break ;
case 3 :
$path = '' ;
$this -> contentType = " reviews " ;
break ;
case 4 :
$path = '' ;
$this -> contentType = " content " ;
break ;
2008-11-02 22:29:33 +00:00
case 'comments' :
2006-12-02 04:36:16 +00:00
case 5 :
$path = '' ;
2008-09-23 20:03:45 +00:00
$this -> rssQuery = " SELECT * FROM `#comments` WHERE `comment_blocked` = 0 ORDER BY `comment_datestamp` DESC LIMIT 0, " . $this -> limit ;
2013-03-26 12:16:55 +01:00
$sql -> gen ( $this -> rssQuery );
2006-12-02 04:36:16 +00:00
$tmp = $sql -> db_getList ();
$this -> rssItems = array ();
$loop = 0 ;
2011-05-13 11:26:35 +00:00
foreach ( $tmp as $value )
2008-10-15 19:13:30 +00:00
{
2006-12-02 04:36:16 +00:00
$this -> rssItems [ $loop ][ 'title' ] = $value [ 'comment_subject' ];
2008-10-15 19:13:30 +00:00
$this -> rssItems [ $loop ][ 'pubdate' ] = $value [ 'comment_datestamp' ];
2006-12-02 04:36:16 +00:00
2011-05-13 11:26:35 +00:00
switch ( $value [ 'comment_type' ])
2008-10-15 19:13:30 +00:00
{
2008-11-02 22:29:33 +00:00
case 0 :
case 'news' :
2006-12-02 04:36:16 +00:00
$this -> rssItems [ $loop ][ 'link' ] = " http:// " . $_SERVER [ 'HTTP_HOST' ] . e_HTTP . " comment.php?comment.news. " . $value [ 'comment_item_id' ];
break ;
2008-11-02 22:29:33 +00:00
case 2 :
case 'download' :
$this -> rssItems [ $loop ][ 'link' ] = " http:// " . $_SERVER [ 'HTTP_HOST' ] . e_HTTP . " comment.php?comment.download. " . $value [ 'comment_item_id' ];
break ;
2006-12-02 04:36:16 +00:00
case 4 :
2008-11-02 22:29:33 +00:00
case 'poll' :
2006-12-02 04:36:16 +00:00
$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 :
2011-05-13 11:26:35 +00:00
if ( ! $this -> topicid )
2009-09-18 19:05:50 +00:00
{
2006-12-02 04:36:16 +00:00
return FALSE ;
}
$path = e_PLUGIN . " forum/e_rss.php " ;
break ;
2009-12-03 22:32:34 +00:00
// case 10 was bugtracker
2006-12-02 04:36:16 +00:00
case 11 :
2011-05-13 11:26:35 +00:00
if ( ! $this -> topicid )
2009-09-18 19:05:50 +00:00
{
2006-12-02 04:36:16 +00:00
return FALSE ;
}
$path = e_PLUGIN . " forum/e_rss.php " ;
break ;
case download :
case 12 :
2009-09-18 19:05:50 +00:00
$path = e_PLUGIN . " download/e_rss.php " ;
2006-12-02 04:36:16 +00:00
break ;
}
2009-09-18 19:05:50 +00:00
if ( isset ( $path ) && $path != '' )
{ // New rss reader from e_rss.php in plugin folder
2011-05-13 11:26:35 +00:00
if ( is_readable ( $path ))
2009-09-18 19:05:50 +00:00
{
2006-12-02 04:36:16 +00:00
require_once ( $path );
2013-06-18 20:21:39 -07:00
$className = basename ( dirname ( $path )) . '_rss' ;
// v2.x standard
if ( $data = e107 :: callMethod ( $className , 'data' , array ( 'url' => $content_type , 'id' => $this -> topicid , 'limit' => $this -> limit )))
{
$eplug_rss_data = array ( 0 => $data );
unset ( $data );
}
2009-09-18 19:05:50 +00:00
foreach ( $eplug_rss_data as $key => $rs )
{
foreach ( $rs as $k => $row )
{
2006-12-02 04:36:16 +00:00
$this -> rssItems [ $k ][ 'author' ] = $row [ 'author' ];
$this -> rssItems [ $k ][ 'author_email' ] = $row [ 'author_email' ];
$this -> rssItems [ $k ][ 'title' ] = $row [ 'title' ];
2009-09-18 19:05:50 +00:00
if ( $row [ 'link' ])
{
2010-10-28 10:54:33 +00:00
if ( stripos ( $row [ 'link' ], 'http' ) !== FALSE )
2009-09-18 19:05:50 +00:00
{
2006-12-02 04:36:16 +00:00
$this -> rssItems [ $k ][ 'link' ] = $row [ 'link' ];
2009-09-18 19:05:50 +00:00
}
else
{
2009-12-03 22:32:34 +00:00
$this -> rssItems [ $k ][ 'link' ] = SITEURLBASE . e_PLUGIN_ABS . $row [ 'link' ];
2006-12-02 04:36:16 +00:00
}
}
$this -> rssItems [ $k ][ 'description' ] = $row [ 'description' ];
2009-09-18 19:05:50 +00:00
if ( $row [ 'enc_url' ])
{
2010-07-02 02:12:49 +00:00
$this -> rssItems [ $k ][ 'enc_url' ] = SITEURLBASE . e_PLUGIN_ABS . $row [ 'enc_url' ] . $row [ 'item_id' ];
2006-12-02 04:36:16 +00:00
}
2009-09-18 19:05:50 +00:00
if ( $row [ 'enc_leng' ])
{
2006-12-02 04:36:16 +00:00
$this -> rssItems [ $k ][ 'enc_leng' ] = $row [ 'enc_leng' ];
}
2009-09-18 19:05:50 +00:00
if ( $eplug_rss [ 'enc_type' ])
{
2006-12-02 04:36:16 +00:00
$this -> rssItems [ $k ][ 'enc_type' ] = $this -> getmime ( $eplug_rss [ 'enc_type' ]);
2009-09-18 19:05:50 +00:00
}
elseif ( $row [ 'enc_type' ])
{
2006-12-02 04:36:16 +00:00
$this -> rssItems [ $k ][ 'enc_type' ] = $row [ 'enc_type' ];
}
$this -> rssItems [ $k ][ 'category_name' ] = $row [ 'category_name' ];
2009-09-18 19:05:50 +00:00
if ( $row [ 'category_link' ])
{
2010-10-28 10:54:33 +00:00
if ( stripos ( $row [ 'category_link' ], 'http' ) !== FALSE )
2009-09-18 19:05:50 +00:00
{
2006-12-02 04:36:16 +00:00
$this -> rssItems [ $k ][ 'category_link' ] = $row [ 'category_link' ];
2009-09-18 19:05:50 +00:00
}
else
{
2009-12-03 22:32:34 +00:00
$this -> rssItems [ $k ][ 'category_link' ] = SITEURLBASE . e_PLUGIN_ABS . $row [ 'category_link' ];
2006-12-02 04:36:16 +00:00
}
}
2009-09-18 19:05:50 +00:00
if ( $row [ 'datestamp' ])
{
2006-12-02 04:36:16 +00:00
$this -> rssItems [ $k ][ 'pubdate' ] = $row [ 'datestamp' ];
}
2011-05-13 11:26:35 +00:00
2010-07-02 02:12:49 +00:00
if ( $row [ 'custom' ]){
$this -> rssItems [ $k ][ 'custom' ] = $row [ 'custom' ];
}
2006-12-02 04:36:16 +00:00
}
}
}
}
}
2011-05-13 11:26:35 +00:00
function buildRss ( $rss_title )
2009-09-18 19:05:50 +00:00
{
2010-10-16 20:23:30 +00:00
global $pref ;
2011-05-13 11:26:35 +00:00
2010-12-14 07:04:57 +00:00
$tp = e107 :: getParser ();
2006-12-02 04:36:16 +00:00
2010-12-14 07:04:57 +00:00
header ( 'Content-type: application/xml' , TRUE );
2011-05-13 11:26:35 +00:00
2010-12-14 07:04:57 +00:00
$rss_title = $tp -> toRss ( $tp -> toHtml ( $pref [ 'sitename' ], '' , 'defs' ) . " : " . $tp -> toHtml ( $rss_title , '' , 'defs' ));
2009-12-03 22:32:34 +00:00
$rss_namespace = ( $this -> rssNamespace ) ? " xmlns: " . $this -> rssNamespace : '' ;
$rss_custom_channel = ( $this -> rssCustomChannel ) ? $this -> rssCustomChannel : '' ;
2006-12-02 04:36:16 +00:00
$time = time ();
2011-05-13 11:26:35 +00:00
switch ( $this -> rssType )
2009-09-18 19:05:50 +00:00
{
case 1 : // RSS 1.0
2009-11-17 13:48:46 +00:00
echo " <?xml version= \" 1.0 \" encoding= \" utf-8 \" ? " . " >
2006-12-02 04:36:16 +00:00
<!-- generator = \ " e107 \" -->
<!-- content type = \ " " . $this -> contentType . " \" -->
< rss version = \ " 0.92 \" >
< channel >
2013-03-26 12:16:55 +01:00
< title > " . $tp->toRss ( $rss_title ). " </ title >
2006-12-02 04:36:16 +00:00
< link > " . $pref['siteurl'] . " </ link >
2013-03-26 12:16:55 +01:00
< description > " . $tp->toRss ( $pref['sitedescription'] ). " </ description >
2006-12-02 04:36:16 +00:00
< lastBuildDate > " . $itemdate = date( " r " , ( $time + $this -> offset)). " </ lastBuildDate >
< docs > http :// backend . userland . com / rss092 </ docs > \n " ;
foreach ( $this -> rssItems as $value )
2009-09-18 19:05:50 +00:00
{ // Multi-language rss links.
2006-12-02 04:36:16 +00:00
$link = ( e_LANQRY ) ? str_replace ( " ? " , " ? " . e_LANQRY , $value [ 'link' ]) : $value [ 'link' ];
echo "
< item >
2013-03-26 12:16:55 +01:00
< title > " . $tp->toRss ( $value['title'] ). " </ title >
< description > " .substr( $tp->toRss ( $value['description'] ),0,150);
2009-09-18 19:05:50 +00:00
if ( $pref [ 'rss_shownewsimage' ] == 1 && strlen ( trim ( $value [ 'news_thumbnail' ])) > 0 )
{
2013-03-26 12:16:55 +01:00
$news_thumbnail = SITEURLBASE . e_IMAGE_ABS . " newspost_images/ " . $tp -> toRss ( $value [ 'news_thumbnail' ]);
2009-09-18 19:05:50 +00:00
echo " <a href=" " . $link . " "><img src=" " . $news_thumbnail . " " height="50" border="0" hspace="10" vspace="10" align="right"></a> " ;
unset ( $news_thumbail );
2011-05-13 11:26:35 +00:00
}
2009-09-18 19:05:50 +00:00
echo " </description>
2006-12-02 04:36:16 +00:00
< author > " . $value['author'] . " & lt ; " . $this->nospam ( $value['author_email'] ). " & gt ; </ author >
< link > " . $link . " </ link >
</ item > " ;
}
echo "
</ channel >
</ rss > " ;
break ;
2009-09-18 19:05:50 +00:00
case 2 : // RSS 2.0
$sitebutton = ( strstr ( SITEBUTTON , " http: " ) ? SITEBUTTON : SITEURL . str_replace ( " ../ " , " " , SITEBUTTON ));
2009-11-17 13:48:46 +00:00
echo " <?xml version= \" 1.0 \" encoding= \" utf-8 \" ? " . " >
2006-12-02 04:36:16 +00:00
<!-- generator = \ " e107 \" -->
<!-- content type = \ " " . $this -> contentType . " \" -->
2011-05-13 11:26:35 +00:00
< rss { $rss_namespace } version = \ " 2.0 \"
xmlns : content = \ " http://purl.org/rss/1.0/modules/content/ \"
2011-01-16 23:19:50 +00:00
xmlns : atom = \ " http://www.w3.org/2005/Atom \"
xmlns : dc = \ " http://purl.org/dc/elements/1.1/ \"
xmlns : sy = \ " http://purl.org/rss/1.0/modules/syndication/ \"
>
2006-12-02 04:36:16 +00:00
< channel >
2013-03-26 12:16:55 +01:00
< title > " . $tp->toRss ( $rss_title ). " </ title >
2006-12-02 04:36:16 +00:00
< link > " . $pref['siteurl'] . " </ link >
2013-03-26 12:16:55 +01:00
< description > " . $tp->toRss ( $pref['sitedescription'] ). " </ description > \n " ;
2006-12-02 04:36:16 +00:00
2013-03-26 12:16:55 +01:00
echo $tp -> toHtml ( $rss_custom_channel , FALSE ) . " \n " ; // must not convert to CDATA.
2006-12-02 04:36:16 +00:00
echo " <language> " . CORE_LC . ( defined ( " CORE_LC2 " ) ? " - " . CORE_LC2 : " " ) . " </language>
2013-03-26 12:16:55 +01:00
< copyright > " . $tp->toRss (SITEDISCLAIMER). " </ copyright >
2009-06-29 06:30:05 +00:00
< managingEditor > " . $this->nospam ( $pref['siteadminemail'] ). " ( " . $pref['siteadmin'] . " ) </ managingEditor >
< webMaster > " . $this->nospam ( $pref['siteadminemail'] ). " ( " . $pref['siteadmin'] . " ) </ webMaster >
2006-12-02 04:36:16 +00:00
< pubDate > " .date( " r " ,( $time + $this -> offset)). " </ pubDate >
< lastBuildDate > " .date( " r " ,( $time + $this -> offset)). " </ lastBuildDate >
< docs > http :// backend . userland . com / rss </ docs >
< generator > e107 ( http :// e107 . org ) </ generator >
2011-01-16 23:19:50 +00:00
< sy : updatePeriod > hourly </ sy : updatePeriod >
< sy : updateFrequency > 1 </ sy : updateFrequency >
< ttl > 60 </ ttl > \n " ;
2011-05-13 11:26:35 +00:00
2011-01-16 23:19:50 +00:00
echo " <atom:link href= \" " . e_SELF . " ? " . $content_type . " .4. " . $this -> topicid . " \" rel= \" self \" type= \" application/rss+xml \" /> \n " ;
2009-06-29 06:30:05 +00:00
2007-05-30 19:25:27 +00:00
if ( trim ( SITEBUTTON ))
{
2009-06-29 06:30:05 +00:00
echo "
< image >
2013-03-26 12:16:55 +01:00
< title > " . $tp->toRss ( $rss_title ). " </ title >
2009-09-18 19:05:50 +00:00
< url > " .(strstr(SITEBUTTON, " http : " )!==FALSE ? SITEBUTTON : SITEURL.str_replace( " ../ " , " " ,SITEBUTTON)). " </ url >
2009-06-29 06:30:05 +00:00
< link > " . $pref['siteurl'] . " </ link >
< width > 88 </ width >
< height > 31 </ height >
2013-03-26 12:16:55 +01:00
< description > " . $tp->toRss ( $pref['sitedescription'] ). " </ description >
2011-01-16 23:19:50 +00:00
</ image > \n " ;
2007-05-30 19:25:27 +00:00
}
2009-06-29 06:30:05 +00:00
// Generally Ignored by 99% of readers.
2009-09-18 19:05:50 +00:00
/*
echo "
2006-12-02 04:36:16 +00:00
< textInput >
< title > Search </ title >
2013-03-26 12:16:55 +01:00
< description > Search " . $tp->toRss ( $pref['sitename'] ). " </ description >
2006-12-02 04:36:16 +00:00
< name > query </ name >
< link > " .SITEURL.(substr(SITEURL, -1) == " / " ? " " : " / " ). " search . php </ link >
</ textInput > " ;
2009-06-29 06:30:05 +00:00
*/
2006-12-02 04:36:16 +00:00
foreach ( $this -> rssItems as $value )
2009-09-18 19:05:50 +00:00
{ // Multi-language rss links.
2006-12-02 04:36:16 +00:00
$link = ( e_LANQRY ) ? str_replace ( " ? " , " ? " . e_LANQRY , $value [ 'link' ]) : $value [ 'link' ];
$catlink = ( e_LANQRY ) ? str_replace ( " ? " , " ? " . e_LANQRY , $value [ 'category_link' ]) : $value [ 'category_link' ];
2013-06-18 20:21:39 -07:00
echo " <item> \n " ;
echo " <title> " . $tp -> toRss ( $value [ 'title' ]) . " </title> \n " ;
2006-12-02 04:36:16 +00:00
2009-09-18 19:05:50 +00:00
if ( $link )
{
2006-12-02 04:36:16 +00:00
echo " <link> " . $link . " </link> \n " ;
}
2013-03-26 12:16:55 +01:00
echo " <description> " . $tp -> toRss ( $value [ 'description' ], TRUE );
2011-01-16 23:19:50 +00:00
if ( $pref [ 'rss_shownewsimage' ] == 1 && strlen ( trim ( $value [ 'news_thumbnail' ])) > 0 ) //FIXME - Fixed path and height?
2009-09-18 19:05:50 +00:00
{
2013-03-26 12:16:55 +01:00
$news_thumbnail = SITEURLBASE . e_IMAGE_ABS . " newspost_images/ " . $tp -> toRss ( $value [ 'news_thumbnail' ]);
2009-09-18 19:05:50 +00:00
echo " <a href=" " . $link . " "><img src=" " . $news_thumbnail . " " height="50" border="0" hspace="10" vspace="10" align="right"></a> " ;
unset ( $news_thumbail );
2011-05-13 11:26:35 +00:00
}
2009-09-18 19:05:50 +00:00
echo " </description> \n " ;
2011-01-16 23:19:50 +00:00
if ( $value [ 'content_encoded' ])
{
2011-05-13 11:26:35 +00:00
echo " <content:encoded> " . $tp -> toRss ( $value [ 'content_encoded' ], TRUE ) . " </content:encoded> \n " ;
2011-01-16 23:19:50 +00:00
}
2011-05-13 11:26:35 +00:00
2009-09-18 19:05:50 +00:00
if ( $value [ 'category_name' ] && $catlink )
{
2013-03-26 12:16:55 +01:00
echo " <category domain=' " . $catlink . " '> " . $tp -> toRss ( $value [ 'category_name' ]) . " </category> \n " ;
2006-12-02 04:36:16 +00:00
}
2009-09-18 19:05:50 +00:00
if ( $value [ 'comment' ])
{
2006-12-02 04:36:16 +00:00
echo " <comments> " . $value [ 'comment' ] . " </comments> \n " ;
}
2009-09-18 19:05:50 +00:00
if ( $value [ 'author' ])
{
2011-05-13 11:26:35 +00:00
echo " <dc:creator> " . $value [ 'author' ] . " </dc:creator> \n " ; // correct tag for author without email.
2006-12-02 04:36:16 +00:00
}
2009-09-18 19:05:50 +00:00
// Enclosure support for podcasting etc.
if ( $value [ 'enc_url' ] && $value [ 'enc_leng' ] && $value [ 'enc_type' ])
{
2006-12-02 04:36:16 +00:00
echo " <enclosure url= \" " . $value [ 'enc_url' ] . " \" length= \" " . $value [ 'enc_leng' ] . " \" type= \" " . $value [ 'enc_type' ] . " \" /> \n " ;
}
echo " <pubDate> " . date ( " r " , ( $value [ 'pubdate' ] + $this -> offset )) . " </pubDate> \n " ;
2009-09-18 19:05:50 +00:00
if ( $link )
{
2006-12-02 04:36:16 +00:00
echo " <guid isPermaLink= \" true \" > " . $link . " </guid> \n " ;
}
2011-05-13 11:26:35 +00:00
2010-07-02 02:12:49 +00:00
if ( isset ( $value [ 'custom' ])) // custom tags. (podcasts etc)
{
foreach ( $value [ 'custom' ] as $cKey => $cVal )
{
2011-05-13 11:26:35 +00:00
echo " < " . $cKey . " > " . $tp -> toRss ( $cVal ) . " </ " . $cKey . " > \n " ;
}
2010-07-02 02:12:49 +00:00
}
2006-12-02 04:36:16 +00:00
2011-01-16 23:19:50 +00:00
echo " </item> \n \n " ;
2006-12-02 04:36:16 +00:00
}
2009-09-18 19:05:50 +00:00
// echo "<atom:link href=\"".e_SELF."?".($this -> contentType).".4.".$this -> topicId ."\" rel=\"self\" type=\"application/rss+xml\" />";
2006-12-02 04:36:16 +00:00
echo "
</ channel >
</ rss > " ;
break ;
2009-09-18 19:05:50 +00:00
case 3 : // RDF
2009-11-17 13:48:46 +00:00
echo " <?xml version= \" 1.0 \" encoding= \" utf-8 \" ? " . " >
2006-12-02 04:36:16 +00:00
<!-- generator = \ " e107 \" -->
<!-- content type = \ " " . $this -> contentType . " \" -->
< rdf : RDF xmlns = \ " http://purl.org/rss/1.0/ \" xmlns:rdf= \" http://www.w3.org/1999/02/22-rdf-syntax-ns# \" xmlns:dc= \" http://purl.org/dc/elements/1.1/ \" xmlns:sy= \" http://purl.org/rss/1.0/modules/syndication/ \" xmlns:admin= \" http://webns.net/mvcb/ \" xmlns:content= \" http://purl.org/rss/1.0/modules/content/ \" >
< channel rdf : about = \ " " . $pref [ 'siteurl' ] . " \" >
2013-03-26 12:16:55 +01:00
< title > " . $tp->toRss ( $rss_title ). " </ title >
2006-12-02 04:36:16 +00:00
< link > " . $pref['siteurl'] . " </ link >
2013-03-26 12:16:55 +01:00
< description > " . $tp->toRss ( $pref['sitedescription'] ). " </ description >
2006-12-02 04:36:16 +00:00
< dc : language > " .CORE_LC.(defined( " CORE_LC2 " ) ? " - " .CORE_LC2 : " " ). " </ dc : language >
< dc : date > " . $this->get_iso_8601_date ( $time + $this -> offset). " </ dc : date >
< dc : creator > " . $this->nospam ( $pref['siteadminemail'] ). " </ dc : creator >
< admin : generatorAgent rdf : resource = \ " http://e107.org \" />
< admin : errorReportsTo rdf : resource = \ " mailto: " . $this -> nospam ( $pref [ 'siteadminemail' ]) . " \" />
< sy : updatePeriod > hourly </ sy : updatePeriod >
< sy : updateFrequency > 1 </ sy : updateFrequency >
< sy : updateBase > 2000 - 01 - 01 T12 : 00 + 00 : 00 </ sy : updateBase >
< items >
< rdf : Seq > " ;
foreach ( $this -> rssItems as $value )
2009-09-18 19:05:50 +00:00
{ // Multi-language rss links.
2006-12-02 04:36:16 +00:00
$link = ( e_LANQRY ) ? str_replace ( " ? " , " ? " . e_LANQRY , $value [ 'link' ]) : $value [ 'link' ];
echo "
< rdf : li rdf : resource = \ " " . $link . " \" /> " ;
}
echo "
</ rdf : Seq >
</ items >
</ channel > " ;
reset ( $this -> rssItems );
unset ( $link );
foreach ( $this -> rssItems as $value )
2011-05-13 11:26:35 +00:00
{
2009-09-18 19:05:50 +00:00
$link = ( e_LANQRY ) ? str_replace ( " ? " , " ? " . e_LANQRY , $value [ 'link' ]) : $value [ 'link' ]; // Multi-language rss links.
2006-12-02 04:36:16 +00:00
echo "
< item rdf : about = \ " " . $link . " \" >
2013-03-26 12:16:55 +01:00
< title > " . $tp->toRss ( $value['title'] ). " </ title >
2006-12-02 04:36:16 +00:00
< link > " . $link . " </ link >
< dc : date > " . $this->get_iso_8601_date ( $time + $this -> offset). " </ dc : date >
< dc : creator > " . $value['author'] . " </ dc : creator >
2013-03-26 12:16:55 +01:00
< dc : subject > " . $tp->toRss ( $value['category_name'] ). " </ dc : subject >
< description > " . $tp->toRss ( $value['description'] );
2009-09-18 19:05:50 +00:00
if ( $pref [ 'rss_shownewsimage' ] == 1 && strlen ( trim ( $value [ 'news_thumbnail' ])) > 0 )
{
2013-03-26 12:16:55 +01:00
$news_thumbnail = SITEURLBASE . e_IMAGE_ABS . " newspost_images/ " . $tp -> toRss ( $value [ 'news_thumbnail' ]);
2009-09-18 19:05:50 +00:00
echo " <a href=" " . $link . " "><img src=" " . $news_thumbnail . " " height="50" border="0" hspace="10" vspace="10" align="right"></a> " ;
unset ( $news_thumbail );
2011-05-13 11:26:35 +00:00
}
2009-09-18 19:05:50 +00:00
echo " </description>
2006-12-02 04:36:16 +00:00
</ item > " ;
}
echo "
</ rdf : RDF > " ;
break ;
2009-09-18 19:05:50 +00:00
// Atom
2006-12-02 04:36:16 +00:00
case 4 :
2009-11-17 13:48:46 +00:00
echo " <?xml version='1.0' encoding='utf-8'? " . " > \n
2006-12-02 04:36:16 +00:00
< feed xmlns = 'http://www.w3.org/2005/Atom' > \n " ;
/*
< feed version = '0.3'
2009-09-18 19:05:50 +00:00
xmlns = 'http://purl.org/atom/ns#'
xmlns : dc = 'http://purl.org/dc/elements/1.1/'
xml : lang = '".CORE_LC.(defined("CORE_LC2") ? "-".CORE_LC2 : "")."' > \n " ;
*/
// Required
2006-12-02 04:36:16 +00:00
echo "
< id > " . $pref['siteurl'] . " </ id > \n
2013-03-26 12:16:55 +01:00
< title type = 'text' > " . $tp->toRss ( $rss_title ). " </ title > \n
2006-12-02 04:36:16 +00:00
< updated > " . $this->get_iso_8601_date ( $time + $this -> offset). " </ updated > \n " ;
2009-09-18 19:05:50 +00:00
// Recommended
2006-12-02 04:36:16 +00:00
echo "
< author > \n
< name > e107 </ name > \n " ;
//<email></email>\n
echo "
< uri > http :// e107 . org /</ uri > \n
</ author > \n
2009-12-03 22:32:34 +00:00
< link rel = 'self' href = '".SITEURLBASE.e_PLUGIN_ABS.' rss_menu / '.e_PAGE.' ? '.e_QUERY."' /> \n " ;
2006-12-02 04:36:16 +00:00
2009-09-18 19:05:50 +00:00
// Optional
2006-12-02 04:36:16 +00:00
include ( e_ADMIN . " ver.php " );
echo "
< category term = 'e107' /> \n
< contributor > \n
< name > e107 </ name > \n
</ contributor > \n
< generator uri = 'http://e107.org/' version = '".$e107info[' e107_version ']."' > e107 </ generator > \n " ;
//<icon>/icon.jpg</icon>\n
echo "
2009-09-18 19:05:50 +00:00
< logo > " .(strstr(SITEBUTTON, " http : " ) ? SITEBUTTON : SITEURL.str_replace( " ../ " , " " , SITEBUTTON)). " </ logo > \n
2006-12-02 04:36:16 +00:00
< rights type = 'html' > " . $pref['siteadmin'] . " - " . $this->nospam ( $pref['siteadminemail'] ). " </ rights > \n " ;
if ( $pref [ 'sitedescription' ]){
echo "
< subtitle type = 'text' > " . $pref['sitedescription'] . " </ subtitle > \n " ;
}
foreach ( $this -> rssItems as $value ) {
echo "
< entry > \n " ;
2009-09-18 19:05:50 +00:00
// Required
2006-12-02 04:36:16 +00:00
echo "
< id > " . $value['link'] . " </ id > \n
2013-03-26 12:16:55 +01:00
< title type = 'text' > " . $tp->toRss ( $value['title'] ). " </ title > \n
2006-12-02 04:36:16 +00:00
< updated > " . $this->get_iso_8601_date ( $value['pubdate'] + $this -> offset). " </ updated > \n " ;
2009-09-18 19:05:50 +00:00
// Recommended
2006-12-02 04:36:16 +00:00
$author = ( $value [ 'author' ]) ? $value [ 'author' ] : " unknown " ;
echo "
< author > \n " ;
echo "
< name > " . $author . " </ name > \n " ;
echo ( $value [ 'author_email' ]) ? " \t \t \t \t \t \t <email> " . $this -> nospam ( $value [ 'author_email' ]) . " </email> \n " : " " ;
echo " </author> \n " ;
//<content>complete story here</content>\n
echo "
< link rel = 'alternate' type = 'text/html' href = '".$value[' link ']."' /> \n
2013-03-26 12:16:55 +01:00
< summary type = 'text' > " . $tp->toRss ( $value['description'] );
2009-09-18 19:05:50 +00:00
if ( $pref [ 'rss_shownewsimage' ] == 1 && strlen ( trim ( $value [ 'news_thumbnail' ])) > 0 )
{
2013-03-26 12:16:55 +01:00
$news_thumbnail = SITEURLBASE . e_IMAGE_ABS . " newspost_images/ " . $tp -> toRss ( $value [ 'news_thumbnail' ]);
2009-09-18 19:05:50 +00:00
echo " <a href=" " . $value [ 'link' ] . " "><img src=" " . $news_thumbnail . " " height="50" border="0" hspace="10" vspace="10" align="right"></a> " ;
unset ( $news_thumbail );
}
echo " </summary> \n " ;
2011-05-13 11:26:35 +00:00
2009-09-18 19:05:50 +00:00
// Optional
2006-12-02 04:36:16 +00:00
if ( $value [ 'category_name' ]){
2013-03-26 12:16:55 +01:00
echo " <category term=' " . $tp -> toRss ( $value [ 'category_name' ]) . " '/> \n " ;
2006-12-02 04:36:16 +00:00
}
//<contributor>
// <name>Jane Doe</name>
//</contributor>
echo " <published> " . $this -> get_iso_8601_date ( $value [ 'pubdate' ] + $this -> offset ) . " </published> \n " ;
//<source>
// <id>http://example.org/</id>
// <title>Fourty-Two</title>
// <updated>2003-12-13T18:30:02Z</updated>
2009-11-17 10:46:35 +00:00
// <rights>© 2005 Example, Inc.</rights>
2006-12-02 04:36:16 +00:00
//</source>
//<rights type='html'>&copy; 2005 John Doe</rights>
echo "
</ entry > \n " ;
}
echo "
</ feed > \n " ;
break ;
}
}
2009-09-18 19:05:50 +00:00
function getmime ( $file )
{
2006-12-02 04:36:16 +00:00
$ext = strtolower ( str_replace ( " . " , " " , strrchr ( basename ( $file ), " . " )));
$mime [ " mp3 " ] = " audio/mpeg " ;
return $mime [ $ext ];
}
2011-05-13 11:26:35 +00:00
function get_iso_8601_date ( $int_date )
2009-09-18 19:05:50 +00:00
{ //$int_date: current date in UNIX timestamp
2006-12-02 04:36:16 +00:00
$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 ;
}
2009-09-18 19:05:50 +00:00
function nospam ( $text )
{
2006-12-02 04:36:16 +00:00
$tmp = explode ( " @ " , $text );
return ( $tmp [ 0 ] != " " ) ? $tmp [ 0 ] . RSS_LAN_2 : RSS_LAN_3 ;
}
2013-03-26 12:16:55 +01:00
} // End class rssCreate