[RC2]RSS Feed

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment!
Anti-Spam Guide
Locked
User avatar
joeroberts
Registered User
Posts: 272
Joined: Fri Jun 22, 2007 7:19 pm
Contact:

[RC2]RSS Feed

Post by joeroberts »

I have greated a RSS FEED for phpBB3
demo
this feed as a few nice feature such as

1. Time limmet on how soon it can be updated
2. Theme slyle lay out
3. Easy install
4.works with phpBB 3.0.0 gold and also 3.0.1
Download ModX included


This feed well show the first post of the last 10 topics posted to no need to edit this script to make it work only need to add one line to your style's overall_header.html
all you need is to creat a file called forumrss.php and add this to it

Code: Select all

<?php /**
    *
    * @package phpBB3
    * @version $Id: rssforum.php,v 1.2.3 2008-06-22 13:48 joerobe Exp $
    * @copyright (c) 2005 phpBB Group
    * @license http://opensource.org/licenses/gpl-license.php GNU Public License
    *
    */

    /**
    * @ignore
    */

         define( 'IN_PHPBB', true );
        $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
        $phpEx = substr(strrchr(__FILE__, '.'), 1);
        include_once($phpbb_root_path . 'common.' . $phpEx);
        include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx);
        include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
        $postallowcount='';           
        $user->session_begin();
        $auth->acl( $user->data );
        $user->setup();
        $forum_folder = (strlen($config['script_path']) > 1) ? $config['script_path'] . '/' : '/' ;

        $bbcode = new bbcode();
      //start post count
      $postallowcount='';
        $topic_count = $config['posts_per_page']; // Change in the number of topics you want to show.
        $query = "
            SELECT distinct(p.topic_id) , p.forum_id, p.post_time, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid,
                u.user_id, u.user_email, u.username, u.user_allow_viewemail,
                t.topic_title, f.left_id, f.right_id, t.topic_replies as aantal_posts
            FROM " . POSTS_TABLE . " p JOIN " . USERS_TABLE . " u on p.poster_id = u.user_id JOIN " . TOPICS_TABLE . " t on p.topic_id = t.topic_id JOIN ". FORUMS_TABLE ." f on p.forum_id = f.forum_id
            ORDER BY p.post_time DESC";
        $result = $db->sql_query( $query );
        $rss = '';
        $rss .= "<?xml version=\"1.0\" encoding=\"UTF-8\"?><rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">
        <channel>
        <title>".htmlspecialchars($config['sitename'])."</title>
		<atom:link href=\"".$config['server_protocol'].$config['server_name'].$forum_folder."forumrss.php\" rel=\"self\" type=\"application/rss+xml\" />
        <link>".htmlspecialchars($config['server_protocol'].$config['server_name']).$forum_folder."</link>
        <description>".htmlspecialchars($config['site_desc'])."</description>
        <language>en-us</language>
        <ttl>60</ttl>";//this is to lemmit the time in wich the feed can be updated

              while( $row = $db->sql_fetchrow($result) )
               {
            //gather extra information on each post
                 $sql_view_post ="SELECT * FROM " . POSTS_TABLE . "
                 WHERE post_time = ". $row['post_time'] . "";
                 $res_views_post = $db->sql_query($sql_view_post);
                 $row_views_post = $db->sql_fetchrow($res_views_post);
                 $sql_view ="SELECT * FROM " . TOPICS_TABLE . "
                 WHERE topic_id = ". $row['topic_id'] . "";
                $res_views = $db->sql_query($sql_view);
                $row_views = $db->sql_fetchrow($res_views);
                $sql_tracking ="SELECT * FROM " . TOPICS_TRACK_TABLE . "
                WHERE topic_id = ". $row_views_post['topic_id'] . " AND user_id = " . $user->data['user_id'] . "";
                $tracking_views = $db->sql_query($sql_tracking);
                $tracking_row = $db->sql_fetchrow($tracking_views);
                $sql_session ="SELECT * FROM " . SESSIONS_TABLE . "
                WHERE session_user_id = ". $user->data['user_id'] . "";
                $res_session = $db->sql_query($sql_session);
                $row_session = $db->sql_fetchrow($res_session);
                $forum_id = $row['forum_id'];
                $rowset = $announcement_list = $topic_list = $global_announce_list = array();

               // assume topic is read
               $unread_topic = true;
              // select information for topic from the topics_tracking table
              if (isset($tracking_row['mark_time']) && $tracking_row['mark_time'] >= $row_views_post['post_time'])
              {
                $unread_topic = false;
              }

              // select information for forum containing topic from the forums_tracking table, store in $tracking_row
             if ($row_views_post["poster_id"] == $user->data['user_id'])
             {
               $unread_topic = false;
             }
            if (!$user->data['is_registered'])$unread_topic = false;

               // if the user does not have permissions to list this forum, skip everything until next branch
             if ($auth->acl_get('f_read', $forum_id))
             {
                $postallowcount = $postallowcount+1;
               //when post count reachs board lemmit we stop listing
                if($postallowcount > $config['posts_per_page'])break;
                 // Parse the message and subject
                $message = censor_text($row['post_text']);
                $replies = ($auth->acl_get('m_approve', $forum_id)) ? $row_views['topic_replies_real'] : $row_views['topic_replies'];
                $folder_img = $folder_alt = $topic_type = '';
                topic_status($row_views, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);

                // Second parse bbcode here
                if ($row['bbcode_bitfield'])
                {
                    $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
                }
                $message = bbcode_nl2br($message);
                $message = smiley_text($message);
                $message = str_replace($phpbb_root_path,'./',$message);//fix for smiles
                $message = str_replace('<a href="#" onclick="selectCode(this); return false;">Select all</a>','',$message);//fix for java not allowed in xml
                $message = str_replace(']]',']',$message);//keep xml compliant
                $message = str_replace('&nbsp;',' ',$message);
                $message = str_replace('./',$config['server_protocol'].$config['server_name'].$forum_folder,$message);
                $fids = $row['forum_id'];
                $ids = $row["topic_id"];
                $names = censor_text($row['post_subject']);
                $replies = $row['aantal_posts'];
                $views = $row_views['topic_views'];
                $last_post = $row_views['topic_last_post_id'];
                $last_poster = $row_views['topic_last_poster_name'];
                $last_poster_id = $row_views['topic_last_poster_id'];
                $last_poster_time = $row_views['topic_last_post_time'];
                $url_link = $config['server_protocol'].$config['server_name'].$forum_folder.'viewtopic.php?';
                $topic_read = $user->img($folder_img, $folder_alt);
                $topic_read = str_replace($phpbb_root_path,$config['server_protocol'].$config['server_name'].$forum_folder,$topic_read);//fix for smiles
                $author = ($row['username'] == 'Anonymous')? 'Anonymous@nowhere.com' : $row['user_email'];

                // Send data to output var
                $descrption = '<table cellpadding="1" cellspacing="1" style="border:1px solid #a1a1a1" width="100%" align="center"><div><tr><td><p>'. $topic_read .'<br /><font size="3"><b>Replies:</b></font> '.$replies .'<br />
                <font size="3"><b>Views:</b></font> '.$views .'<br />
                <font size="3"><b>Last Post By:</b></font> <a href="'.$config['server_protocol'].$config['server_name'].$forum_folder.'memberlist.php?mode=viewprofile&u=' . $last_poster_id . '">' . $last_poster .'</a>
                <a href="'.$config['server_protocol'].$config['server_name'].$forum_folder.'viewtopic.php?f='.$row['forum_id'].'&t='.$row["topic_id"].'&p='.$last_post.'#p'.$last_post.'">'.str_replace('./',$config['server_protocol'].$config['server_name'].$forum_folder,$user->img('icon_topic_newest', 'VIEW_LATEST_POST')).'</a><b> ON: '.$user->format_date($last_poster_time).'</b><br />
                <font size="3"><b>Topic By:</b></font> <a href="'.$config['server_protocol'].$config['server_name'].$forum_folder.'memberlist.php?mode=viewprofile&u=' . $row['user_id'] . '">' . $row['username'] .'</a><b> ON: '.$user->format_date($row['post_time']).'</b><br />'. $message .'</p></td></tr></div></table>';
header('Content-type: application/xml; charset=utf-8');
               $rss .= '
               <item>
               <title>'.htmlspecialchars($names).'</title>
               <link>'.$url_link.'f='.$fids.'&t='.$ids.'&p=' .$row_views_post["post_id"].'#p'.$row_views_post["post_id"].'</link>
               <description><![CDATA['. $descrption .'<hr>]]></description>
               <pubDate>' . $user->format_date($last_poster_time,"D, d M Y H:i:s T") . '</pubDate>
			   <guid>'.$url_link.'f='.$fids.'&t='.$ids.'&p=' .$row_views_post["post_id"].'#p'.$row_views_post["post_id"].'</guid>
               </item>';
          }
       }

     $rss .='
     </channel>
     </rss>';
     echo($rss);
?>
add it to your forum root dir.
now open your style overall_header.php(if your style is data base driven the go to your admin style theme overall_header.html)
and right below <html> add

Code: Select all

<link rel="alternate" type="application/rss+xml" title="Forum" href="forumrss.php">

clear your cache and your done

edits
  1. fix for google rss reader
  2. fixed for updating new topic post
  3. fix (Post()) at end of tittle
    2008-05-26 13:48
  4. fix post read
  5. roported errors in phpBB
  6. set post limit by configs post limit not topic limit
  7. clean up code add more explanations
    2008-06-22 12:28
  8. fix utf-8 compliant
  9. image fix for smiles
Last edited by joeroberts on Sun Jun 22, 2008 10:18 pm, edited 26 times in total.
User avatar
bonelifer
Community Team Member
Community Team Member
Posts: 3511
Joined: Wed Oct 27, 2004 11:35 pm
Name: William
Contact:

Re: [beta]RSS Feed

Post by bonelifer »

This shouldn't show HIDDEN FORUMS. Right now while I'm logged out it shows posts from my Administrators forum which is hidden.
Knowledge Base | phpBB Board Rules | Search Customisation Database
Image
Please don't contact me via PM or email for phpBB support .
User avatar
fiorefrank
Registered User
Posts: 226
Joined: Fri Jun 08, 2007 10:43 am
Location: Italy
Contact:

Re: [beta]RSS Feed

Post by fiorefrank »

bonelifer wrote:This shouldn't show HIDDEN FORUMS. Right now while I'm logged out it shows posts from my Administrators forum which is hidden.
ow no!
This is not good!
User avatar
joeroberts
Registered User
Posts: 272
Joined: Fri Jun 22, 2007 7:19 pm
Contact:

Re: [beta]RSS Feed

Post by joeroberts »

bonelifer wrote:This shouldn't show HIDDEN FORUMS. Right now while I'm logged out it shows posts from my Administrators forum which is hidden.
it should not no
User avatar
joeroberts
Registered User
Posts: 272
Joined: Fri Jun 22, 2007 7:19 pm
Contact:

Re: [beta]RSS Feed

Post by joeroberts »

fix for auth()
Last edited by joeroberts on Sun Apr 06, 2008 5:29 am, edited 1 time in total.
User avatar
joeroberts
Registered User
Posts: 272
Joined: Fri Jun 22, 2007 7:19 pm
Contact:

Re: [beta]RSS Feed

Post by joeroberts »

update to feed
  1. fix for New Post No New Post
  2. fix for post icons matching catigory(stick, lock,and announcement)
  3. fix lay out to display properly
  4. fix code box
Last edited by joeroberts on Sun Apr 06, 2008 5:30 am, edited 1 time in total.
User avatar
joeroberts
Registered User
Posts: 272
Joined: Fri Jun 22, 2007 7:19 pm
Contact:

Re: [beta]RSS Feed

Post by joeroberts »

cleaned up for valid-rss
Last edited by joeroberts on Thu Apr 10, 2008 2:34 pm, edited 2 times in total.
User avatar
stickerboy
Former Team Member
Posts: 7349
Joined: Mon Mar 29, 2004 2:27 pm
Location: Airdrie, UK (127.0.0.1)
Name: Kenny Cameron
Contact:

Re: [beta]RSS Feed

Post by stickerboy »

Not sure if it's a bug or not, and if it is, how important it is to fix.
But if you check my feed here
See the 3rd post down (MODs on this Forum).

My MOD prefixes aren't showing correctly i.e. [RC" instead of [RC]
It's not anything major to me, but I don't know if this goes any deeper?
Using the code from your last post btw :)
Other than that, I like the layout, very nice work.
I'm a web-designing code-decrypting tech-support musician
|| Twitter || Flickr || phpBB Snippets ||
Formerly known as cherokee red
User avatar
joeroberts
Registered User
Posts: 272
Joined: Fri Jun 22, 2007 7:19 pm
Contact:

Re: [beta]RSS Feed

Post by joeroberts »

sorry thought there was a error with one of the tittle's from my site so I removed the ] from messages and turnned out to be something else and forgot to put them back
here is the fixed
Last edited by joeroberts on Sun Apr 06, 2008 5:32 am, edited 1 time in total.
User avatar
stickerboy
Former Team Member
Posts: 7349
Joined: Mon Mar 29, 2004 2:27 pm
Location: Airdrie, UK (127.0.0.1)
Name: Kenny Cameron
Contact:

Re: [beta]RSS Feed

Post by stickerboy »

Perfect, that seems to work nicely :)
I'm a web-designing code-decrypting tech-support musician
|| Twitter || Flickr || phpBB Snippets ||
Formerly known as cherokee red
gmartin
Registered User
Posts: 1
Joined: Fri Apr 04, 2008 1:22 pm

Re: [beta]RSS Feed

Post by gmartin »

There is a reference to an rsssheet.css theme ... which is not installed, and is not mentioned here in the post.
Which other requeriments are there to get it to work?
User avatar
joeroberts
Registered User
Posts: 272
Joined: Fri Jun 22, 2007 7:19 pm
Contact:

Re: [beta]RSS Feed

Post by joeroberts »

the .css sheet is not needed at this time and well be overlooked
and nothing else is need to make this work but what was said on post one
User avatar
bonelifer
Community Team Member
Community Team Member
Posts: 3511
Joined: Wed Oct 27, 2004 11:35 pm
Name: William
Contact:

Re: [beta]RSS Feed

Post by bonelifer »

It's customary to update the code in the first post so people don't have to guess which one's correct.
Knowledge Base | phpBB Board Rules | Search Customisation Database
Image
Please don't contact me via PM or email for phpBB support .
User avatar
joeroberts
Registered User
Posts: 272
Joined: Fri Jun 22, 2007 7:19 pm
Contact:

Re: [beta]RSS Feed

Post by joeroberts »

bonelifer wrote:It's customary to update the code in the first post so people don't have to guess which one's correct.
last one as staed
sorry thought there was a error with one of the tittle's from my site so I removed the ] from messages and turnned out to be something else and forgot to put them back
here is the fixed
chainprayer
Registered User
Posts: 162
Joined: Sat Sep 08, 2007 5:25 pm
Contact:

Re: [beta]RSS Feed

Post by chainprayer »

Love the MOD! Exactly what I was looking for!

Any specific place to put the code in the overall_header that works best?

Thanks!
Locked

Return to “[3.0.x] MODs in Development”