PageRenderTime 55ms CodeModel.GetById 2ms app.highlight 45ms RepoModel.GetById 1ms app.codeStats 0ms

/e107_plugins/rss_menu/rss.php

https://github.com/CasperGemini/e107
PHP | 755 lines | 590 code | 85 blank | 80 comment | 69 complexity | 93e3c40a770eb1bb57019f22477b9d24 MD5 | raw file
  1<?php
  2/*
  3* e107 website system
  4*
  5* Copyright (C) 2008-2013 e107 Inc (e107.org)
  6* Released under the terms and conditions of the
  7* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
  8*
  9* RSS Feed management
 10*
 11*/
 12
 13/*
 14Query string: content_type.rss_type.[topic id]
 151: news
 165: comments
 1712: downloads (option: specify category)
 18
 19Plugins should use an e_rss.php file in their plugin folder
 20----------------------------------------------------------------
 21*/
 22
 23require_once('../../class2.php');
 24$e107 = e107::getInstance();
 25if (!$e107->isInstalled('rss_menu'))
 26{
 27	header('Location: '.e_BASE.'index.php');
 28	exit;
 29}
 30
 31$tp = e107::getParser();
 32
 33require_once(e_PLUGIN.'rss_menu/rss_shortcodes.php');
 34require_once(e_HANDLER.'userclass_class.php');
 35
 36/*
 37global $tp;
 38if (!is_object($tp->e_bb))
 39{
 40	require_once(e_HANDLER.'bbcode_handler.php');
 41	$tp->e_bb = new e_bbcode;
 42}
 43*/
 44
 45// Get language file
 46include_lan(e_PLUGIN.'rss_menu/languages/'.e_LANGUAGE.'_admin_rss_menu.php');
 47
 48// Get template
 49if (is_readable(THEME.'rss_template.php'))
 50{
 51	require_once(THEME.'rss_template.php');
 52}
 53else
 54{
 55	require_once(e_PLUGIN.'rss_menu/rss_template.php');
 56}
 57
 58// Query handler
 59if (e_QUERY)
 60{
 61	$tmp = explode('.', e_QUERY);
 62	$content_type = $tp->toDB($tmp[0]);
 63	$rss_type = intval(varset($tmp[1],0));
 64	$topic_id = $tp->toDB($tmp[2],'');
 65}
 66
 67// List available rss feeds
 68if (!$rss_type)
 69{	// Display list of all feeds
 70	require_once(HEADERF);
 71	// require_once(e_PLUGIN.'rss_menu/rss_template.php');		Already loaded
 72
 73	if(!$sql->select('rss', '*', "`rss_class`=0 AND `rss_limit`>0 AND `rss_topicid` NOT REGEXP ('\\\*') ORDER BY `rss_name`"))
 74	{
 75		$ns->tablerender(LAN_ERROR, RSS_LAN_ERROR_4);
 76	}
 77	else
 78	{
 79		$text = $RSS_LIST_HEADER;
 80		while($row = $sql->fetch())
 81		{
 82			$text .= $tp->parseTemplate($RSS_LIST_TABLE, FALSE, $rss_shortcodes);
 83		}
 84		$text .= $RSS_LIST_FOOTER;
 85		$ns->tablerender(RSS_MENU_L2, $text);
 86	}
 87
 88 	require_once(FOOTERF);
 89	exit;
 90}
 91
 92
 93// Returning feeds here
 94// Conversion table for old urls -------
 95$conversion[1] = 'news';
 96$conversion[5] = 'comments';
 97$conversion[10] = 'bugtracker';
 98$conversion[12] = 'download';
 99//-------------------------------------
100
101// Convert certain old urls so we can check the db entries
102// Rss.php?1.2 (news, rss-2) --> check = news (check conversion table)
103// TODO: legacy stuff still required?
104if(is_numeric($content_type) && isset($conversion[$content_type]) )
105{
106	$content_type = $conversion[$content_type];
107}
108
109
110$check_topic = ($topic_id ? " AND rss_topicid = '".$topic_id."' " : "");
111
112if(!$sql->select('rss', '*', "rss_class!=2 AND rss_url='".$content_type."' ".$check_topic." AND rss_limit>0 "))
113{	// Check if wildcard present for topic_id
114	$check_topic = ($topic_id ? " AND rss_topicid = '".str_replace($topic_id, "*", $topic_id)."' " : "");
115	if(!$sql->select('rss', '*', "rss_class!=2 AND rss_url='".$content_type."' ".$check_topic." AND rss_limit>0 "))
116	{
117		require_once(HEADERF);
118		$ns->tablerender('', RSS_LAN_ERROR_1);
119		require_once(FOOTERF);
120		exit;
121	}
122	else
123	{
124		$row = $sql->fetch();
125	}
126}
127else
128{
129	$row = $sql->fetch();
130}
131
132
133// ----------------------------------------------------------------------------
134
135if($rss = new rssCreate($content_type, $rss_type, $topic_id, $row))
136{
137	$rss_title = ($rss->contentType ? $rss->contentType : ucfirst($content_type));
138	$rss->buildRss($rss_title);
139}
140else
141{
142	require_once(HEADERF);
143	$ns->tablerender(RSS_LAN_ERROR_0, RSS_LAN_ERROR_1);
144	require_once(FOOTERF);
145	exit;
146}
147
148class rssCreate
149{
150	protected $e107;
151
152	var $contentType;
153	var $rssType;
154	var $path;
155	var $parm;
156	var $rssItems;
157	var $rssQuery;
158	var $topicid;
159	var $offset;
160	var $rssNamespace;
161	var $rssCustomChannel;
162
163	public function __construct($content_type, $rss_type, $topic_id, $row)
164	{	// Constructor
165		$sql_rs = new db;
166		global $rssgen;
167		$sql = e107::getDb();
168		$pref = e107::getPref();
169		$tp = e107::getParser();
170
171		$this->e107 = e107::getInstance();
172
173		$this -> path = e_PLUGIN."rss_menu/";
174		$this -> rssType = $rss_type;
175		$this -> topicid = $topic_id;
176		$this -> offset = $pref['time_offset'] * 3600;
177		$this -> limit = $row['rss_limit'];
178		$this -> contentType = $row['rss_name'];
179
180		if(!is_numeric($content_type))
181		{
182			$path = e_PLUGIN.$row['rss_path'].'/e_rss.php';
183		}
184		if(strpos($row['rss_path'],'|')!==FALSE) //FIXME remove this check completely. 
185		{
186			$tmp = explode("|", $row['rss_path']);
187			$path = e_PLUGIN.$tmp[0]."/e_rss.php";
188			$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
189		}
190
191		switch ($content_type)
192		{
193			case 'news' :
194			case 1:
195				if($topic_id && is_numeric($topic_id))
196				{
197					$topic = " AND news_category = ".intval($topic_id);
198				}
199				else
200				{
201					$topic = '';
202				}
203
204				$path='';
205				$render = ($pref['rss_othernews'] != 1) ? "AND (FIND_IN_SET('0', n.news_render_type) OR FIND_IN_SET(1, n.news_render_type))" : "";
206				$nobody_regexp = "'(^|,)(".str_replace(",", "|", e_UC_NOBODY).")(,|$)'";
207
208				$this -> rssQuery = "
209				SELECT n.*, u.user_id, u.user_name, u.user_email, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n
210				LEFT JOIN #user AS u ON n.news_author = u.user_id
211				LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
212				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;
213				$sql->gen($this->rssQuery);
214				$tmp = $sql->db_getList();
215				$this -> rssItems = array();
216				$loop=0;
217				foreach($tmp as $value)
218				{
219					$this -> rssItems[$loop]['title'] = $value['news_title'];
220					$this -> rssItems[$loop]['link'] = "http://".$_SERVER['HTTP_HOST'].e_HTTP."news.php?item.".$value['news_id'].".".$value['news_category'];
221					if($value['news_summary'] && $pref['rss_summarydiz'])
222					{
223						$this -> rssItems[$loop]['description'] = $value['news_summary'];
224					}
225					else
226					{
227						$this -> rssItems[$loop]['description'] = ($value['news_body']."<br />".$value['news_extended']);
228					}
229					$this -> rssItems[$loop]['author'] = $value['user_name'];
230					$this -> rssItems[$loop]['author_email'] = $value['user_email'];
231				//	$this -> rssItems[$loop]['category'] = "<category domain='".SITEURL."news.php?cat.".$value['news_category']."'>".$value['category_name']."</category>";
232					$this -> rssItems[$loop]['category_name'] = $tp->toHTML($value['category_name'],TRUE,'defs');
233                    $this -> rssItems[$loop]['category_link'] = $e107->base_path."news.php?cat.".$value['news_category'];
234
235					if($value['news_allow_comments'] && $pref['comments_disabled'] != 1)
236					{
237						$this -> rssItems[$loop]['comment'] = "http://".$_SERVER['HTTP_HOST'].e_HTTP."comment.php?comment.news.".$value['news_id'];
238					}
239					$this -> rssItems[$loop]['pubdate'] = $value['news_datestamp'];
240					if($pref['rss_shownewsimage'] == 1 && strlen(trim($value['news_thumbnail'])) > 0) {
241						$this -> rssItems[$loop]['news_thumbnail'] = $value['news_thumbnail'];
242					}
243
244					$loop++;
245				}
246				break;
247			case 2:
248				$path='';
249				$this -> contentType = "articles";
250				break;
251			case 3:
252				$path='';
253				$this -> contentType = "reviews";
254				break;
255			case 4:
256				$path='';
257				$this -> contentType = "content";
258				break;
259			case 'comments' :
260			case 5:
261				$path='';
262				$this -> rssQuery = "SELECT * FROM `#comments` WHERE `comment_blocked` = 0 ORDER BY `comment_datestamp` DESC LIMIT 0,".$this -> limit;
263				$sql->gen($this -> rssQuery);
264				$tmp = $sql->db_getList();
265				$this -> rssItems = array();
266				$loop=0;
267				foreach($tmp as $value)
268				{
269					$this -> rssItems[$loop]['title'] = $value['comment_subject'];
270					$this -> rssItems[$loop]['pubdate'] = $value['comment_datestamp'];
271
272					switch ($value['comment_type'])
273					{
274						case 0 :
275						case 'news' :
276							$this -> rssItems[$loop]['link'] = "http://".$_SERVER['HTTP_HOST'].e_HTTP."comment.php?comment.news.".$value['comment_item_id'];
277							break;
278						case 2 :
279						case 'download' :
280							$this -> rssItems[$loop]['link'] = "http://".$_SERVER['HTTP_HOST'].e_HTTP."comment.php?comment.download.".$value['comment_item_id'];
281							break;
282						case 4:
283						case 'poll' :
284							$this -> rssItems[$loop]['link'] = "http://".$_SERVER['HTTP_HOST'].e_HTTP."comment.php?comment.poll.".$value['comment_item_id'];
285							break;
286					}
287
288					$this -> rssItems[$loop]['description'] = $value['comment_comment'];
289					$this -> rssItems[$loop]['author'] = substr($value['comment_author'], (strpos($value['comment_author'], ".")+1));
290					$loop++;
291				}
292				break;
293
294			case 6:
295			case 7:
296				$path = e_PLUGIN."forum/e_rss.php";
297				break;
298
299			case 8:
300				if(!$this -> topicid)
301				{
302					return FALSE;
303				}
304				$path = e_PLUGIN."forum/e_rss.php";
305				break;
306
307			// case 10 was bugtracker
308			case 11:
309				if(!$this -> topicid)
310				{
311					return FALSE;
312				}
313				$path = e_PLUGIN."forum/e_rss.php";
314				break;
315
316			case download:
317			case 12:
318				$path = e_PLUGIN."download/e_rss.php";
319				break;
320		}
321
322		if(isset($path) && $path!='')
323		{	// New rss reader from e_rss.php in plugin folder
324			if (is_readable($path))
325			{
326				require_once($path);
327				
328				$className = basename(dirname($path)).'_rss';
329				
330				// v2.x standard 
331				if($data = e107::callMethod($className,'data', array('url' => $content_type, 'id' => $this->topicid, 'limit' => $this->limit)))
332				{			
333					$eplug_rss_data = array(0 => $data);
334					unset($data);			
335				}
336								
337				foreach($eplug_rss_data as $key=>$rs)
338				{
339					foreach($rs as $k=>$row)
340					{
341						$this -> rssItems[$k]['author'] = $row['author'];
342						$this -> rssItems[$k]['author_email'] = $row['author_email'];
343						$this -> rssItems[$k]['title'] = $row['title'];
344						if($row['link'])
345						{
346							if(stripos($row['link'], 'http') !== FALSE)
347							{
348								$this -> rssItems[$k]['link'] = $row['link'];
349							}
350							else
351							{
352								$this -> rssItems[$k]['link'] = SITEURLBASE.e_PLUGIN_ABS.$row['link'];
353							}
354						}
355						$this -> rssItems[$k]['description'] = $row['description'];
356						if($row['enc_url'])
357						{
358							$this -> rssItems[$k]['enc_url'] = SITEURLBASE.e_PLUGIN_ABS.$row['enc_url'].$row['item_id'];
359						}
360						if($row['enc_leng'])
361						{
362							$this -> rssItems[$k]['enc_leng'] = $row['enc_leng'];
363						}
364
365						if($eplug_rss['enc_type'])
366						{
367							$this -> rssItems[$k]['enc_type'] = $this->getmime($eplug_rss['enc_type']);
368						}
369						elseif($row['enc_type'])
370						{
371							$this -> rssItems[$k]['enc_type'] = $row['enc_type'];
372						}
373
374						$this -> rssItems[$k]['category_name'] = $row['category_name'];
375						if($row['category_link'])
376						{
377							if(stripos($row['category_link'], 'http') !== FALSE)
378							{
379								$this -> rssItems[$k]['category_link'] = $row['category_link'];
380							}
381							else
382							{
383								$this -> rssItems[$k]['category_link'] = SITEURLBASE.e_PLUGIN_ABS.$row['category_link'];
384							}
385						}
386						if($row['datestamp'])
387						{
388							$this -> rssItems[$k]['pubdate'] = $row['datestamp'];
389						}
390
391						if($row['custom']){
392							$this -> rssItems[$k]['custom'] = $row['custom'];
393						}
394					}
395				}
396			}
397		}
398	}
399
400	function buildRss($rss_title)
401	{
402		global $pref;
403
404		$tp = e107::getParser();
405
406		header('Content-type: application/xml', TRUE);
407
408		$rss_title = $tp->toRss($tp->toHtml($pref['sitename'],'','defs')." : ".$tp->toHtml($rss_title,'','defs'));
409        $rss_namespace = ($this->rssNamespace) ? "xmlns:".$this->rssNamespace : '';
410        $rss_custom_channel = ($this->rssCustomChannel) ? $this->rssCustomChannel : '';
411		$time = time();
412		switch ($this -> rssType)
413		{
414			case 1:		// RSS 1.0
415				echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?".">
416						<!-- generator=\"e107\" -->
417						<!-- content type=\"".$this -> contentType."\" -->
418						<rss version=\"0.92\">
419						<channel>
420						<title>".$tp->toRss($rss_title)."</title>
421						<link>".$pref['siteurl']."</link>
422						<description>".$tp->toRss($pref['sitedescription'])."</description>
423						<lastBuildDate>".$itemdate = date("r", ($time + $this -> offset))."</lastBuildDate>
424						<docs>http://backend.userland.com/rss092</docs>\n";
425
426					foreach($this -> rssItems as $value)
427					{	// Multi-language rss links.
428						$link 		= (e_LANQRY) ? str_replace("?","?".e_LANQRY,$value['link']) : $value['link'];
429
430						echo "
431							<item>
432							<title>".$tp->toRss($value['title'])."</title>
433							<description>".substr($tp->toRss($value['description']),0,150);
434						if($pref['rss_shownewsimage'] == 1 && strlen(trim($value['news_thumbnail'])) > 0)
435						{
436							$news_thumbnail = SITEURLBASE.e_IMAGE_ABS."newspost_images/".$tp->toRss($value['news_thumbnail']);
437							echo "&lt;a href=&quot;".$link."&quot;&gt;&lt;img src=&quot;".$news_thumbnail."&quot; height=&quot;50&quot; border=&quot;0&quot; hspace=&quot;10&quot; vspace=&quot;10&quot; align=&quot;right&quot;&gt;&lt;/a&gt;";
438							unset($news_thumbail);
439						}
440						echo "</description>
441							<author>".$value['author']."&lt;".$this->nospam($value['author_email'])."&gt;</author>
442							<link>".$link."</link>
443							</item>";
444					}
445					echo "
446						</channel>
447						</rss>";
448			break;
449
450			case 2:	// RSS 2.0
451				$sitebutton = (strstr(SITEBUTTON, "http:") ? SITEBUTTON : SITEURL.str_replace("../", "", SITEBUTTON));
452				echo "<?xml version=\"1.0\" encoding=\"utf-8\"?".">
453				<!-- generator=\"e107\" -->
454				<!-- content type=\"".$this -> contentType."\" -->
455				<rss {$rss_namespace} version=\"2.0\"
456					xmlns:content=\"http://purl.org/rss/1.0/modules/content/\"
457					xmlns:atom=\"http://www.w3.org/2005/Atom\"
458					xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
459					xmlns:sy=\"http://purl.org/rss/1.0/modules/syndication/\"
460				>
461				<channel>
462				<title>".$tp->toRss($rss_title)."</title>
463				<link>".$pref['siteurl']."</link>
464				<description>".$tp->toRss($pref['sitedescription'])."</description>\n";
465
466				echo $tp->toHtml($rss_custom_channel,FALSE)."\n"; // must not convert to CDATA.
467
468				echo "<language>".CORE_LC.(defined("CORE_LC2") ? "-".CORE_LC2 : "")."</language>
469				<copyright>".$tp->toRss(SITEDISCLAIMER)."</copyright>
470				<managingEditor>".$this->nospam($pref['siteadminemail'])." (".$pref['siteadmin'].")</managingEditor>
471				<webMaster>".$this->nospam($pref['siteadminemail'])." (".$pref['siteadmin'].")</webMaster>
472				<pubDate>".date("r",($time + $this -> offset))."</pubDate>
473				<lastBuildDate>".date("r",($time + $this -> offset))."</lastBuildDate>
474				<docs>http://backend.userland.com/rss</docs>
475				<generator>e107 (http://e107.org)</generator>
476				<sy:updatePeriod>hourly</sy:updatePeriod>
477				<sy:updateFrequency>1</sy:updateFrequency>
478				<ttl>60</ttl>\n";
479
480				echo "<atom:link href=\"".e_SELF."?".$content_type.".4.".$this->topicid."\" rel=\"self\" type=\"application/rss+xml\" />\n";
481
482				if (trim(SITEBUTTON))
483				{
484					echo "
485					<image>
486					<title>".$tp->toRss($rss_title)."</title>
487					<url>".(strstr(SITEBUTTON, "http:")!==FALSE ? SITEBUTTON : SITEURL.str_replace("../", "",SITEBUTTON))."</url>
488					<link>".$pref['siteurl']."</link>
489					<width>88</width>
490					<height>31</height>
491					<description>".$tp->toRss($pref['sitedescription'])."</description>
492					</image>\n";
493				}
494
495				// Generally Ignored by 99% of readers.
496				/*
497				echo "
498				<textInput>
499				<title>Search</title>
500				<description>Search ".$tp->toRss($pref['sitename'])."</description>
501				<name>query</name>
502				<link>".SITEURL.(substr(SITEURL, -1) == "/" ? "" : "/")."search.php</link>
503				</textInput>";
504				*/
505
506				foreach($this -> rssItems as $value)
507				{   // Multi-language rss links.
508					$link 		= (e_LANQRY) ? str_replace("?","?".e_LANQRY,$value['link']) : $value['link'];
509                    $catlink	= (e_LANQRY) ? str_replace("?","?".e_LANQRY,$value['category_link']) : $value['category_link'];
510
511					echo "<item>\n";
512					echo "<title>".$tp->toRss($value['title'])."</title>\n";
513
514					if($link)
515					{
516						echo "<link>".$link."</link>\n";
517					}
518
519					echo "<description>".$tp->toRss($value['description'],TRUE);
520					if($pref['rss_shownewsimage'] == 1 && strlen(trim($value['news_thumbnail'])) > 0) //FIXME - Fixed path and height?
521					{
522						$news_thumbnail = SITEURLBASE.e_IMAGE_ABS."newspost_images/".$tp->toRss($value['news_thumbnail']);
523						echo "&lt;a href=&quot;".$link."&quot;&gt;&lt;img src=&quot;".$news_thumbnail."&quot; height=&quot;50&quot; border=&quot;0&quot; hspace=&quot;10&quot; vspace=&quot;10&quot; align=&quot;right&quot;&gt;&lt;/a&gt;";
524						unset($news_thumbail);
525					}
526					echo "</description>\n";
527
528					if($value['content_encoded'])
529					{
530						echo "<content:encoded>".$tp->toRss($value['content_encoded'],TRUE)."</content:encoded>\n";
531					}
532
533					if($value['category_name'] && $catlink)
534					{
535						echo "<category domain='".$catlink."'>".$tp->toRss($value['category_name'])."</category>\n";
536					}
537
538					if($value['comment'])
539					{
540						echo "<comments>".$value['comment']."</comments>\n";
541					}
542
543					if($value['author'])
544					{
545						echo "<dc:creator>".$value['author']."</dc:creator>\n"; // correct tag for author without email.
546					}
547
548					// Enclosure support for podcasting etc.
549					if($value['enc_url'] && $value['enc_leng'] && $value['enc_type'])
550					{
551						echo "<enclosure url=\"".$value['enc_url']."\" length=\"".$value['enc_leng']."\" type=\"".$value['enc_type']."\"   />\n";
552					}
553
554					echo "<pubDate>".date("r", ($value['pubdate'] + $this -> offset))."</pubDate>\n";
555
556					if($link)
557					{
558						echo "<guid isPermaLink=\"true\">".$link."</guid>\n";
559					}
560
561					if(isset($value['custom'])) // custom tags. (podcasts etc)
562					{
563						foreach($value['custom'] as $cKey => $cVal)
564						{
565							echo "<".$cKey.">".$tp->toRss($cVal)."</".$cKey.">\n";
566						}
567					}
568
569					echo "</item>\n\n";
570				}
571				// echo "<atom:link href=\"".e_SELF."?".($this -> contentType).".4.".$this -> topicId ."\" rel=\"self\" type=\"application/rss+xml\" />";
572				echo "
573				</channel>
574				</rss>";
575			break;
576
577			case 3: 	// RDF
578				echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?".">
579				<!-- generator=\"e107\" -->
580				<!-- content type=\"".$this -> contentType."\" -->
581				<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/\">
582				<channel rdf:about=\"".$pref['siteurl']."\">
583				<title>".$tp->toRss($rss_title)."</title>
584				<link>".$pref['siteurl']."</link>
585				<description>".$tp->toRss($pref['sitedescription'])."</description>
586				<dc:language>".CORE_LC.(defined("CORE_LC2") ? "-".CORE_LC2 : "")."</dc:language>
587				<dc:date>".$this->get_iso_8601_date($time + $this -> offset). "</dc:date>
588				<dc:creator>".$this->nospam($pref['siteadminemail'])."</dc:creator>
589				<admin:generatorAgent rdf:resource=\"http://e107.org\" />
590				<admin:errorReportsTo rdf:resource=\"mailto:".$this->nospam($pref['siteadminemail'])."\" />
591				<sy:updatePeriod>hourly</sy:updatePeriod>
592				<sy:updateFrequency>1</sy:updateFrequency>
593				<sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
594				<items>
595				<rdf:Seq>";
596
597				foreach($this -> rssItems as $value)
598				{   // Multi-language rss links.
599					$link = (e_LANQRY) ? str_replace("?","?".e_LANQRY,$value['link']) : $value['link'];
600
601					echo "
602						<rdf:li rdf:resource=\"".$link."\" />";
603				}
604
605				echo "
606				</rdf:Seq>
607				</items>
608				</channel>";
609
610				reset($this -> rssItems);
611				unset($link);
612				foreach($this -> rssItems as $value)
613				{
614					$link = (e_LANQRY) ? str_replace("?","?".e_LANQRY,$value['link']) : $value['link']; // Multi-language rss links.
615
616					echo "
617						<item rdf:about=\"".$link."\">
618						<title>".$tp->toRss($value['title'])."</title>
619						<link>".$link."</link>
620						<dc:date>".$this->get_iso_8601_date($time + $this -> offset)."</dc:date>
621						<dc:creator>".$value['author']."</dc:creator>
622						<dc:subject>".$tp->toRss($value['category_name'])."</dc:subject>
623						<description>".$tp->toRss($value['description']);
624					if($pref['rss_shownewsimage'] == 1 && strlen(trim($value['news_thumbnail'])) > 0)
625					{
626						$news_thumbnail = SITEURLBASE.e_IMAGE_ABS."newspost_images/".$tp->toRss($value['news_thumbnail']);
627						echo "&lt;a href=&quot;".$link."&quot;&gt;&lt;img src=&quot;".$news_thumbnail."&quot; height=&quot;50&quot; border=&quot;0&quot; hspace=&quot;10&quot; vspace=&quot;10&quot; align=&quot;right&quot;&gt;&lt;/a&gt;";
628						unset($news_thumbail);
629					}
630					echo "</description>
631						</item>";
632				}
633				echo "
634				</rdf:RDF>";
635			break;
636
637			// Atom
638			case 4:
639				echo "<?xml version='1.0' encoding='utf-8'?".">\n
640				<feed xmlns='http://www.w3.org/2005/Atom'>\n";
641				/*
642				<feed version='0.3'
643				xmlns='http://purl.org/atom/ns#'
644				xmlns:dc='http://purl.org/dc/elements/1.1/'
645				xml:lang='".CORE_LC.(defined("CORE_LC2") ? "-".CORE_LC2 : "")."'>\n";
646				*/
647					// Required
648					echo "
649					<id>".$pref['siteurl']."</id>\n
650					<title type='text'>".$tp->toRss($rss_title)."</title>\n
651					<updated>".$this->get_iso_8601_date($time + $this -> offset)."</updated>\n";
652
653					// Recommended
654					echo "
655					<author>\n
656						<name>e107</name>\n";
657						//<email></email>\n
658						echo "
659						<uri>http://e107.org/</uri>\n
660					</author>\n
661					<link rel='self' href='".SITEURLBASE.e_PLUGIN_ABS.'rss_menu/'.e_PAGE.'?'.e_QUERY."' />\n";
662
663					// Optional
664					include(e_ADMIN."ver.php");
665					echo "
666					<category term='e107'/>\n
667					<contributor>\n
668						<name>e107</name>\n
669					</contributor>\n
670					<generator uri='http://e107.org/' version='".$e107info['e107_version']."'>e107</generator>\n";
671					//<icon>/icon.jpg</icon>\n
672					echo "
673					<logo>".(strstr(SITEBUTTON, "http:") ? SITEBUTTON : SITEURL.str_replace("../", "", SITEBUTTON))."</logo>\n
674					<rights type='html'>".$pref['siteadmin']." - ".$this->nospam($pref['siteadminemail'])."</rights>\n";
675					if($pref['sitedescription']){
676					echo "
677					<subtitle type='text'>".$pref['sitedescription']."</subtitle>\n";
678                    }
679					foreach($this -> rssItems as $value) {
680					echo "
681					<entry>\n";
682
683						// Required
684						echo "
685						<id>".$value['link']."</id>\n
686						<title type='text'>".$tp->toRss($value['title'])."</title>\n
687						<updated>".$this->get_iso_8601_date($value['pubdate'] + $this -> offset)."</updated>\n";
688
689						// Recommended
690                        $author = ($value['author']) ? $value['author'] : "unknown";
691
692						echo "
693						<author>\n";
694						echo "
695						<name>".$author."</name>\n";
696						echo ($value['author_email']) ? "\t\t\t\t\t\t<email>".$this->nospam($value['author_email'])."</email>\n" : "";
697						echo "</author>\n";
698						//<content>complete story here</content>\n
699						echo "
700						<link rel='alternate' type='text/html' href='".$value['link']."' />\n
701						<summary type='text'>".$tp->toRss($value['description']);
702						if($pref['rss_shownewsimage'] == 1 && strlen(trim($value['news_thumbnail'])) > 0)
703						{
704							$news_thumbnail = SITEURLBASE.e_IMAGE_ABS."newspost_images/".$tp->toRss($value['news_thumbnail']);
705							echo "&lt;a href=&quot;".$value['link']."&quot;&gt;&lt;img src=&quot;".$news_thumbnail."&quot; height=&quot;50&quot; border=&quot;0&quot; hspace=&quot;10&quot; vspace=&quot;10&quot; align=&quot;right&quot;&gt;&lt;/a&gt;";
706							unset($news_thumbail);
707						}
708						echo "</summary>\n";
709
710						// Optional
711						if($value['category_name']){
712							echo "<category term='".$tp->toRss($value['category_name'])."'/>\n";
713						}
714						//<contributor>
715						//	<name>Jane Doe</name>
716						//</contributor>
717						echo "<published>".$this->get_iso_8601_date($value['pubdate'] + $this -> offset)."</published>\n";
718						//<source>
719						//	<id>http://example.org/</id>
720						//	<title>Fourty-Two</title>
721						//	<updated>2003-12-13T18:30:02Z</updated>
722						//	<rights>Š 2005 Example, Inc.</rights>
723						//</source>
724						//<rights type='html'>&amp;copy; 2005 John Doe</rights>
725						echo "
726					</entry>\n";
727					}
728				echo "
729				</feed>\n";
730			break;
731		}
732	}
733
734	function getmime($file)
735	{
736		$ext = strtolower(str_replace(".","",strrchr(basename($file), ".")));
737		$mime["mp3"] = "audio/mpeg";
738		return $mime[$ext];
739	}
740
741	function get_iso_8601_date($int_date)
742	{	//$int_date: current date in UNIX timestamp
743		$date_mod = date('Y-m-d\TH:i:s', $int_date);
744		$pre_timezone = date('O', $int_date);
745		$time_zone = substr($pre_timezone, 0, 3).":".substr($pre_timezone, 3, 2);
746		$date_mod .= $time_zone;
747		return $date_mod;
748	}
749
750	function nospam($text)
751	{
752		$tmp = explode("@",$text);
753		return ($tmp[0] != "") ? $tmp[0].RSS_LAN_2 : RSS_LAN_3;
754	}
755} // End class rssCreate