Code:<?php
/************************************************************************/
/* RSS Feed for PHP-Nuke phpBB2 Forums */
/* =================================== */
/* This file is created by Truden (www.truden.com) */
/* by combyning rdf_nuke.php from Chris with backend_818.php from Truden*/
/* See http://www.karakas-online.de/forum/viewtopic.php?t=899 */
/* for more details. */
/* */
/* Enjoy! */
/* */
/* Truden */
/* */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
include("mainfile.php");
global $prefix, $db, $nukeurl, $sitename;
header ('Expires: ' . gmdate('d M Y H:i:s', time()) . ' GMT');
header ('Last-Modified: ' . gmdate('d M Y H:i:s') . ' GMT');
header ('Content-Type: text/xml; charset=UTF-8');
// Taken from rdf_nuke.php, created by Chris (http://www.karakas-online.de/forum/viewtopic.php?t=899):
$module_name = "Forums";
$nuke_root_path = "modules.php?name=" . $module_name;
$nuke_file_path = $nuke_root_path . "&file=";
define('IN_PHPBB', true);
$phpbb_root_path = './modules/' . $module_name . '/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
// include('includes/bbcode.'.$phpEx);
// If not set, set the output count to 10
$count = ( !isset($HTTP_GET_VARS['count']) ) ? 10 : intval($HTTP_GET_VARS['count']);
$count = ( $count == 0 ) ? 10 : $count;
// Characters
$chars = ( isset($HTTP_GET_VARS['chars']) ) ? intval($HTTP_GET_VARS['chars']) : 200;
if($chars<0 || $chars>500) $chars=500; //Maximum
$type = ( isset($HTTP_GET_VARS['type']) ) ? $HTTP_GET_VARS['type'] : 'latest';
$news = ( $type == 'news' );
// Create main board url (some code borrowed from functions_post.php)
// viewtopic and index adapted by Chris
$viewtopic = $nuke_file_path . 'viewtopic';
// We don't need these three, but I include them anyway,
// just in case you need them...
$server_name = trim($board_config['server_name']);
$server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://';
$server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/';
$viewtopic_url = $nukeurl . '/' . $viewtopic;
$fid = ( isset($HTTP_GET_VARS['fid']) ) ? $HTTP_GET_VARS['fid'] : array();
if(!is_array($fid)) $fid = array($fid);
$fid_new = array();
for($i=0; $i<sizeof($fid); $i++)
{
if(intval($fid[$i]) > 0)
{
if(!in_array($fid[$i], $fid_new))
{
$fid_new[] = $fid[$i];
}
}
}
$fid = $fid_new;
$sql_where = ( sizeof($fid)>0 ) ? " AND topic_status='0' AND f.forum_id IN (" . implode($fid, ", ") . ")" : " ";
$sql_orderby = $news ? 't.topic_time DESC' : 'p.post_time DESC';
$sql_post_id_field = $news ? 't.topic_first_post_id' : 't.topic_last_post_id';
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?><?xml-stylesheet title=\"XSL_formatting\" type=\"text/xsl\" href=\"backend_f.xsl\" ?>\n";
echo "<rss version=\"2.0\" \n";
echo " xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n";
echo " xmlns:sy=\"http://purl.org/rss/1.0/modules/syndication/\"\n";
echo " xmlns:admin=\"http://webns.net/mvcb/\"\n";
echo " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n\n";
echo "<channel>\n";
echo "<language>he-il</language>\n";
echo "<title>".htmlspecialchars($sitename)."</title>\n";
echo "<link>".htmlspecialchars($nukeurl)."</link>\n";
echo "<description>".$slogan."</description>\n";
echo "<dc:creator>headmin@preflight.us</dc:creator>\n";
echo "<sy:updatePeriod>hourly</sy:updatePeriod>\n";
echo "<sy:updateFrequency>1</sy:updateFrequency>\n";
// Added by Chris:
define('TOPICS_TABLE', $prefix.'_bbtopics');
define('POSTS_TABLE', $prefix.'_bbposts');
define('POSTS_TEXT_TABLE', $prefix.'_bbposts_text');
define('FORUMS_TABLE', $prefix.'_bbforums');
define('AUTH_ALL', 0);
define('POST_TOPIC_URL', 't');
define('POST_POST_URL', 'p');
$sql = "SELECT t.topic_id, t.topic_status, t.topic_title, p.post_id, p.post_time, pt.post_text, pt.bbcode_uid, f.forum_name, f.forum_status, f.auth_read FROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p, " . POSTS_TEXT_TABLE . " AS pt, " . FORUMS_TABLE . " AS f WHERE f.forum_id = t.forum_id AND f.auth_read = '0' AND p.topic_id = t.topic_id AND p.post_id = $sql_post_id_field AND pt.post_id = p.post_id AND t.topic_status='0' AND f.forum_status='0' $sql_where ORDER BY $sql_orderby LIMIT $count";
$topics_query = $db->sql_query($sql);
if ( !$topics_query )
{
$topics_query = "";
}
else
{
$topics = $db->sql_fetchrowset($topics_query);
}
if ( count($topics) == 0 )
{
$topics = "";
}
else
{
// $topics contains all interesting data
for ($i = 0; $i < count($topics); $i++)
{
if(isset($HTTP_GET_VARS['titlepattern']))
{
$title = $HTTP_GET_VARS['titlepattern'];
$title = str_replace('__DATE__', gmdate("d.m.Y H:i", $topics[$i]['post_time']), $title);
$title = str_replace('__TITLE__', $topics[$i]['topic_title'], $title);
$title = str_replace('__FORUM__', $topics[$i]['forum_name'], $title);
}
else
{
$title = $topics[$i]['topic_title'];
}
$url = ($news) ? $viewtopic_url . "&" . POST_TOPIC_URL . "=" . $topics[$i]['topic_id'] : $viewtopic_url . "&" . POST_POST_URL . "=" . $topics[$i]['post_id'] . "#" . $topics[$i]['post_id'];
$message = $topics[$i]['post_text'];
$bbcode_uid = $topics[$i]['bbcode_uid'];
$message = preg_replace("/\[.*?:$bbcode_uid:?.*?\]/si", '', $message);
$message = preg_replace('/\[url=([^\]]*)\]([^[]*)\[\/url\]/si', '<a href="\1">\2</a>', $message);
$message = preg_replace('/\[url\]|\[\/url\]/si', '', $message);
$message = str_replace("\n", "\n<br />\n", $message);
// $message = smilies_pass($message);
// $message = preg_replace("/$smilies_path/", $smilies_url, $message);
if($chars > 0) {
$message = ( strlen($message) > $chars ) ? substr($message, 0, ($chars - 4)) . ' ...' : $message;
}
echo "<item>\n";
echo "<title>".$title."</title>\n";
echo "<link>".$url."</link>\n";
echo "<description><![CDATA[$message]]></description>\n";
echo "<dc:subject>".$title."</dc:subject>\n";
echo "<pubDate>" . gmdate('d M Y H:i:s', $topics[$i]['post_time']) . " GMT</pubDate>\n";
echo "<guid>".$url."</guid>\n";
echo "</item>\n\n";
}
}
echo "</channel>\n";
echo "</rss>\n";
?>
|