Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // phpbb_news includes
- require('./config.inc.php');
- require('./include/bbparser.php');
- require('./include/functions.php');
- // This allows us to include phpBB3 files without them causing a script exit
- define('IN_PHPBB',true);
- // Set phpbb_root_path and phpEx to allow phpbb included files to include files of their own
- $phpbb_root_path = PHPBB3_DIR_ABSOLUTE;
- $phpEx = substr(strrchr(__FILE__, '.'), 1);
- require(PHPBB3_DIR_ABSOLUTE . '/config.' . $phpEx);
- require(PHPBB3_DIR_ABSOLUTE . '/includes/constants.' . $phpEx);
- require(PHPBB3_DIR_ABSOLUTE . '/includes/db/' . $dbms . '.' . $phpEx);
- // Initialize and connect to the database using phpbb's built in DB classes
- $db = new $sql_db();
- $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false);
- // Quickly find smilies location from phpbb3 config table under 'smilies_path'
- $sql = 'SELECT config_value FROM `' . CONFIG_TABLE . '` WHERE config_name = "smilies_path"';
- $result = $db->sql_query($sql);
- $smilies_path = $db->sql_fetchfield('config_value');
- if($smilies_path == '') {
- $smilies_path = '/';
- }
- /*
- * First we need to get all valid children of our target forum or category - we do this by
- * finding all forums with a left_id and right_id within the left_id and right_id of the
- * target forum, and then selecting all topics from those forums.
- */
- $sql = '
- SELECT t.*,fn.*,p.*, u.*, (SELECT COUNT(*) FROM `' . POSTS_TABLE . '` cc WHERE cc.topic_id = t.topic_id AND cc.post_id != t.topic_first_post_id) as comment_count FROM `' . TOPICS_TABLE . '` t
- INNER JOIN (`' . FORUMS_TABLE . '` fn) ON (fn.forum_id = t.forum_id)
- INNER JOIN (`' . POSTS_TABLE . '` p) ON (p.post_id = t.topic_first_post_id)
- INNER JOIN (`' . USERS_TABLE . '` u) ON (u.user_id = t.topic_poster)
- WHERE t.forum_id IN
- (
- SELECT fm.forum_id FROM `' . FORUMS_TABLE . '` f
- INNER JOIN (`' . FORUMS_TABLE . '` fm) ON
- (
- fm.left_id > f.left_id AND fm.right_id < f.right_id
- )
- WHERE f.forum_id = ' . PHPBB3_NEWS_FORUM_ID . '
- ) OR t.forum_id = ' . PHPBB3_NEWS_FORUM_ID . '
- ORDER BY t.topic_time DESC';
- //Grab latest 10 news articles (edit this later)
- $result = $db->sql_query_limit($sql,PHPBB3_NEWS_LATEST_NUMBER);
- //Loop over results, parse BBCode and sanitize output
- while($news_item = $db->sql_fetchrow($result)) {
- $bbp = new BBParser($news_item['post_text'],$news_item['bbcode_uid']);
- $news_item['post_text'] = $bbp->parse();
- $news_item['post_text'] = nl2br(str_replace('{SMILIES_PATH}',PHPBB3_DIR_RELATIVE . $smilies_path,html_entity_decode($news_item['post_text'])));
- $news_item['post_time'] = date('r',$news_item['post_time']);
- $news_item['post_length'] = strlen($news_item['post_text']);
- $b_xml = '
- <item id="${topic_id}">
- <name>${topic_title}</name>
- <category id="${forum_id}">
- <name>${forum_name}</name>
- <description>${forum_desc}</description>
- </category>
- <author id="${topic_poster}">
- <name>${topic_first_poster_name}</name>
- <colour>${user_colour}</colour>
- </author>
- <content bbcode_uid="${bbcode_uid}" length="${post_length}">${post_text}</content>
- <comments count="${comment_count}" />
- </item>';
- $i_xml .= stringExpand($b_xml,$news_item);
- }
- header('Content-type: text/xml');
- echo '
- <page title="Latest News">
- <news>
- ' . $i_xml . '
- </news>
- </page>';
- $db->sql_freeresult($result);
- ?>
Add Comment
Please, Sign In to add comment