| 1 | <?php
|
|---|
| 2 | /**
|
|---|
| 3 | *
|
|---|
| 4 | * @package phpBB3
|
|---|
| 5 | * @version $Id$
|
|---|
| 6 | * @copyright (c) 2008 Manchumahara(Sabuj Kundu)
|
|---|
| 7 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|---|
| 8 | *
|
|---|
| 9 | */
|
|---|
| 10 |
|
|---|
| 11 | /**
|
|---|
| 12 | * @ignore
|
|---|
| 13 | */
|
|---|
| 14 |
|
|---|
| 15 | define('IN_PHPBB', true);
|
|---|
| 16 | $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
|
|---|
| 17 | $phpEx = substr(strrchr(__FILE__, '.'), 1);
|
|---|
| 18 | include($phpbb_root_path . 'common.' . $phpEx);
|
|---|
| 19 | include($phpbb_root_path . 'language/en/common.' . $phpEx);
|
|---|
| 20 |
|
|---|
| 21 | // Start session
|
|---|
| 22 | $user->session_begin();
|
|---|
| 23 | $auth->acl($user->data);
|
|---|
| 24 | $user->setup();
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 | function make_xml_compatible($text,$bbcode_uid, $bbcode_bitfield,$bbcode_options)
|
|---|
| 28 | {
|
|---|
| 29 | global $config, $base_url;
|
|---|
| 30 | $text = html_entity_decode(generate_text_for_display($text, $bbcode_uid, $bbcode_bitfield, $bbcode_options));
|
|---|
| 31 | $text = nl2br($text);
|
|---|
| 32 | $text = str_replace('£', '&#163;', $text);
|
|---|
| 33 | $text = str_replace('©', '(c)', $text);
|
|---|
| 34 | $text = htmlspecialchars($text);
|
|---|
| 35 | return $text;
|
|---|
| 36 | }
|
|---|
| 37 | //Get the board url address
|
|---|
| 38 | $board_url = generate_board_url();
|
|---|
| 39 |
|
|---|
| 40 | // Start RSS output
|
|---|
| 41 | header('Content-type: application/rss+xml; charset=UTF-8');
|
|---|
| 42 | $rss_result = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
|---|
| 43 | <rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">
|
|---|
| 44 | <channel>
|
|---|
| 45 | <atom:link href=\"".$board_url."/rss.$phpEx\" rel=\"self\" type=\"application/rss+xml\" />
|
|---|
| 46 | <title>".$config['sitename']."</title>
|
|---|
| 47 | <link>".$board_url."</link>
|
|---|
| 48 | <description>".$config['site_desc']."</description>
|
|---|
| 49 | <language>".$config['default_lang']."</language>
|
|---|
| 50 | <copyright>".$user->lang['RSS_COPYRIGHT']." ".$config['sitename']."</copyright>
|
|---|
| 51 | <managingEditor>".$config['board_email']." (".$config['sitename'].")</managingEditor>
|
|---|
| 52 | <generator>".$config['sitename']."</generator>
|
|---|
| 53 | <ttl>1</ttl>
|
|---|
| 54 | ";
|
|---|
| 55 | //
|
|---|
| 56 | // This SQL query selects the latest topics of all forum
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 | $sql = 'SELECT f.forum_id,f.forum_name, f.forum_desc_options, t.topic_title, t.topic_id,t.topic_last_post_id,t.topic_last_poster_name, p.post_time, p.post_text,
|
|---|
| 60 | p.bbcode_uid, p.bbcode_bitfield, u.username, u.user_id
|
|---|
| 61 | FROM '. FORUMS_TABLE .' f,'.TOPICS_TABLE.' t, '.POSTS_TABLE.' p,'.USERS_TABLE.' u
|
|---|
| 62 | WHERE t.forum_id = f.forum_id
|
|---|
| 63 | AND t.topic_status != 1
|
|---|
| 64 | AND p.post_id = t.topic_last_post_id
|
|---|
| 65 | AND u.user_id = p.poster_id
|
|---|
| 66 | ORDER BY t.topic_last_post_id DESC';
|
|---|
| 67 | if(!$result = $db->sql_query_limit($sql,30))
|
|---|
| 68 | {
|
|---|
| 69 | trigger_error($user->lang['RSS_FAILURE']);
|
|---|
| 70 | }
|
|---|
| 71 | while($row = $db->sql_fetchrow($result))
|
|---|
| 72 | {
|
|---|
| 73 | $forumid=$row['forum_id'];
|
|---|
| 74 | $topicid=$row['topic_id'];
|
|---|
| 75 | if($auth->acl_get('f_read',$forumid)) //getting authentication
|
|---|
| 76 | {
|
|---|
| 77 | $post_link = $board_url."/viewtopic.".$phpEx."?f=".$forumid."&t=".$topicid."#p".$row['topic_last_post_id'];
|
|---|
| 78 | $topic_link = $board_url."/viewtopic.".$phpEx."?f=".$forumid."&t=".$topicid;
|
|---|
| 79 | $description = $user->lang['POST_BY_AUTHOR']." ".$row['topic_last_poster_name']." (".$user->lang['POSTED']." ".$user->format_date($row['post_time']).")<br/>".$row['post_text']."<br /><br /><a href=\"".$topic_link."\">".$user->lang['RSS_READ_TOPIC']."</a><hr />";
|
|---|
| 80 | $rss_result .= "
|
|---|
| 81 | <item>
|
|---|
| 82 | <title>".$row['topic_title']."</title>
|
|---|
| 83 | <link>".$post_link."</link>
|
|---|
| 84 | <description>".make_xml_compatible($description, $row['bbcode_uid'], $row['bbcode_bitfield'], $row['forum_desc_options'])."</description>
|
|---|
| 85 | <pubDate>".$user->format_date($row['post_time'])."</pubDate>
|
|---|
| 86 | <guid isPermaLink=\"true\">".$post_link."</guid>
|
|---|
| 87 | </item>";
|
|---|
| 88 | }
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 | $rss_result .= '</channel></rss>';
|
|---|
| 93 | echo $rss_result;
|
|---|
| 94 | $db->sql_freeresult($result);
|
|---|
| 95 | ?>
|
|---|