<?php
/*-------------------------------------------------------+
| PHPFusion Content Management System
| Copyright (C) PHPFusion Inc
| https://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: rss_forums.php
| Author: PHPFusion Development Team
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once dirname(__FILE__).'../../../../maincore.php';
if (file_exists(INFUSIONS.'rss_feeds_panel/locale/'.LOCALESET.'rss.php')) {
$locale = fusion_get_locale('', INFUSIONS.'rss_feeds_panel/locale/'.LOCALESET.'rss.php');
} else {
$locale = fusion_get_locale('', INFUSIONS.'rss_feeds_panel/locale/English/rss.php');
}
require_once INFUSIONS.'rss_feeds_panel/RSS.php';
$result = dbquery("SELECT f.forum_id, f.forum_name, f.forum_lastpost, f.forum_postcount,
f.forum_threadcount, f.forum_lastuser, f.forum_access,
t.thread_id, t.thread_lastpost, t.thread_lastpostid, t.thread_subject, t.thread_postcount, t.thread_views, t.thread_lastuser, t.thread_poll,
p.post_message, p.post_id
FROM ".DB_FORUMS." f
LEFT JOIN ".DB_THREADS." t ON f.forum_id = t.forum_id
LEFT JOIN ".DB_POSTS." p ON t.thread_id = p.thread_id
".(multilang_table('FO') ? "WHERE f.forum_language='".LANGUAGE."' AND" : "WHERE")." f.forum_access=0 AND t.thread_hidden='0'
ORDER BY p.post_datestamp DESC LIMIT 0,10
"); // mod Wanabo, added , p.post_id so the link matches the content and is used in line 46. #post_'.$data['post_id']
header('Content-Type: application/rss+xml; charset='.$locale['charset']);
// $rss = new RSS('forums', $settings['sitename'].' - '.$locale['rss_forums'].(multilang_table('FO') ? $locale['rss_in'].LANGUAGE : ''));
$rss = new RSS('forums', $settings['sitename'].' - '.$locale['rss_forums']); // mod Wanabo, shorter title.
if (dbrows($result) != 0) {
while ($data = dbarray($result)) {
$rss->AddItem($data['thread_subject'].' ['.$data['forum_name'].']', $settings['siteurl'].'forum/viewthread.php?forum_id='.$data['forum_id'].'&thread_id='.$data['thread_id'].'&pid='.$data['post_id'].'#post_'.$data['post_id'], nl2br(parseubb(parsesmileys(preg_replace('/\[quote.*\].*\[\/quote\]\s+/si', '', $data['post_message']))))); // mod Wanabo, added , p.post_id so I can get content for #post_'.$data['post_id'] and &pid. With &pid jumping to the correct forum post. Added nl2br, parseubb, parsesmiley and strip quotes for more beautyfull and readable feed contents.
}
} else {
$rss->AddItem($settings['sitename'].' - '.$locale['rss_forums'], $settings['siteurl'], $locale['rss_nodata']);
}
$rss->Write();
<?php
/*-------------------------------------------------------+
| PHPFusion Content Management System
| Copyright (C) PHPFusion Inc
| https://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: RSS.php
| Author: RobiNN
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
// use \PHPFusion\Rewrite\Permalinks;
class RSS {
private $max_items = 50000;
private $items_count = 0;
private $item_count = 0;
private $buffer_size = 1000;
private $writer;
private $title;
private $feed_url;
private $description;
public function __construct($feed_url = '', $title = NULL, $description = NULL) {
$this->writer = new XMLWriter();
$this->feed_url = $feed_url;
$this->title = $title;
$this->description = $description;
//if (fusion_get_settings('site_seo') == 1 && !defined('IN_PERMALINK')) {
// Permalinks::getPermalinkInstance()->handle_url_routing('');
// }
}
private function CreateXML() {
$this->item_count++;
$this->writer->openMemory();
$this->writer->startDocument('1.0', 'UTF-8');
$this->writer->setIndent(TRUE);
$this->writer->startElement('rss');
$this->writer->writeAttribute('version', '2.0');
$this->writer->writeAttribute('xmlns:content', 'http://purl.org/rss/1.0/modules/content/');
$this->writer->writeAttribute('xmlns:atom', 'http://www.w3.org/2005/Atom');
$this->writer->startElement('channel');
$title = !empty($this->title) ? $this->title : fusion_get_settings('sitename');
$this->writer->writeElement('title', $title);
$this->writer->startElement('atom:link');
$this->writer->writeAttribute('href', fusion_get_settings('siteurl').'infusions/rss_feeds_panel/feeds/rss_'.$this->feed_url.'.php');
$this->writer->writeAttribute('rel', 'self');
$this->writer->writeAttribute('type', 'application/rss+xml');
$this->writer->endElement(); // close atom:link
$this->writer->writeElement('link', fusion_get_settings('siteurl'));
$description = !empty($this->description) ? $this->description : fusion_get_settings('description');
$this->writer->writeElement('description', html_entity_decode($description)); // mod Wanabo, (html_entity_decode) fix for error element should not contain HTML
}
private function CloseXML() {
if ($this->writer !== NULL) {
$this->writer->endElement(); // close channel
$this->writer->endElement(); // close rss
$this->writer->endDocument();
$this->Flush();
}
}
public function Write() {
$this->CloseXML();
}
private function Flush() {
echo $this->writer->flush(TRUE);
}
public function AddItem($title, $link, $description) {
if ($this->items_count === 0) {
$this->CreateXML();
} else if ($this->items_count % $this->max_items === 0) {
$this->CloseXML();
$this->CreateXML();
}
if ($this->items_count % $this->buffer_size === 0) {
$this->Flush();
}
$this->writer->startElement('item');
$this->writer->startElement('title');
$this->writer->writeCData(html_entity_decode($title));
$this->writer->endElement(); // close title
$this->writer->writeElement('link', $link);
if (!empty($description)) {
$this->writer->startElement('description');
$this->writer->writeCData(html_entity_decode($description));
$this->writer->endElement(); // close description
}
$this->writer->writeElement('guid', html_entity_decode($link)); // mod Wanabo, added guid for becoming a valid RSS feed
$this->writer->endElement(); // close item
$this->items_count++;
}
}
Category Forum
Suspected Bugs and Errors - 8Labels
None yet
Statistics
1 participant
Notifications
You are not receiving notifications from this thread.
Related Questions