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