[MODDB] simple syndication

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
wouterv
Registered User
Posts: 265
Joined: Wed Jan 02, 2008 10:22 am
Location: The Netherlands
Name: Wouter

Re: [BETA] simple syndication

Post by wouterv » Sun Feb 10, 2008 10:20 am

You look in the correct table. Did you click the "Browse" button to look into the table?
Maybe you have changed the setup of your phpBB to not store templats in the database:
ACP>Styles>Templates>Details
There is a Radio button "Store templates in" Filesystem or Database (default is Database).
The copy Template thing is related to the official way you should modify and download Styles, a simple file copy as done with this Mod is not the official way to add files to a Style.
At least you figured out the soluton to your original problem, that counts.

GTT
Registered User
Posts: 36
Joined: Sun Mar 21, 2004 11:08 am
Contact:

Re: [BETA] simple syndication

Post by GTT » Sun Feb 10, 2008 11:58 am

wouterv wrote:You look in the correct table. Did you click the "Browse" button to look into the table?
Yes, i do...
wouterv wrote:Maybe you have changed the setup of your phpBB to not store templats in the database:
ACP>Styles>Templates>Details
There is a Radio button "Store templates in" Filesystem or Database (default is Database).
All my templates are stored in Filesystem but I never changed anything in this configuration... All my phpBB3 boards have the same config with the typicall install...
wouterv wrote:At least you figured out the soluton to your original problem, that counts.
You're right... Thx a lot and sorry for my error... :mrgreen:

dr.3
Registered User
Posts: 39
Joined: Fri Oct 22, 2004 1:05 pm
Contact:

Re: [BETA] simple syndication

Post by dr.3 » Thu Feb 14, 2008 11:30 am

Hi :)

Very nice and simple MOD 8-)

I have only one problem with the v1.1.1f of this MOD in the Microsoft Office Outlook 2007 RSS Feed viewing, the smilies of the posts gives error (wrong image link as X image)

Can anyone helps in solving this problem

wouterv
Registered User
Posts: 265
Joined: Wed Jan 02, 2008 10:22 am
Location: The Netherlands
Name: Wouter

Re: [BETA] simple syndication (smilies)

Post by wouterv » Thu Feb 14, 2008 7:58 pm

[EDIT]
Smilies had been fix earlier but broken again somewhere while adding other fixes...
New code, see below.
Last edited by wouterv on Thu Feb 14, 2008 9:26 pm, edited 2 times in total.

wouterv
Registered User
Posts: 265
Joined: Wed Jan 02, 2008 10:22 am
Location: The Netherlands
Name: Wouter

Re: [BETA] simple syndication 1.1.1g

Post by wouterv » Thu Feb 14, 2008 8:54 pm

Fix for smilies is included again in this 1.1.1g version.
When copy/paste the code, remove the additional spaces that may be added at the start of the file.

syndication.php 1.1.1g:

Code: Select all

<?php
/*
*
* @package phpBB3
* @version $Id: syndication.php,v 1.0 2006/11/27 22:29:16 angelside Exp $
* Modified by CK for holographyforum.org
* @copyright (c) Canver Software
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* Updated by several people: 2008-02-14 - Version 1.1.1g
*
*/

/**
*/
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();

// Begin configuration
$CFG['exclude_forums'] = '';
$CFG['max_topics'] = '20';
// End configuration

// Requests
$fid = request_var('fid', '');
$count = request_var('count', 0);
$chars = request_var('chars', 200);
$type = request_var('type', '');
$topics_only = request_var('t', '');

// If not set, set the output count to max_topics
$count = ($count == 0) ? $CFG['max_topics'] : $count;

// maximum text char limit
if ($chars <0 || $chars > 500)
   $chars = 500; //Maximum

// Generate url
$board_url = generate_board_url();
$index_url = $board_url . '/index.' . $phpEx;
$viewtopic_url = $board_url . '/viewtopic.' . $phpEx;

// ==========================================================================================================================

function codebox($preg)
{
   return $preg[2];
}

// ==========================================================================================================================

function parse_message($row, $bbcode_options, $bbcode_uid, $bbcode_bitfield)
{
   global $board_url, $type;

   $row = generate_text_for_display($row, $bbcode_uid, $bbcode_bitfield, $bbcode_options);
   $row = preg_replace_callback("/\<dt\>(.*?)\<\/dt\>\<dd\>\<code\>(.*?)\<\/code\>\<\/dd\>/si", "codebox", $row);
   $row = str_replace('<img src="./', '<img src="' . $board_url . '/', $row);

   if ($type == 'atom')
   {
      $row = str_replace("&nbsp;", " ", $row);
   }
   else
   {
      $row = str_replace("\n", "\n<br />\n", $row);               // Do NOT user nl2br
      $row = htmlspecialchars($row);
   }


   return $row;
}

// ==========================================================================================================================

// Create a date according to correct RFC standard
function format_date($timestamp)
{
   global $type;

   if ($type == 'atom')
      return date('Y-m-d\TH:i:s\Z', $timestamp);            // RFC 3339 for ATOM
   else
      return date('D, d M Y H:i:s O', $timestamp);         // RFC 822 for RSS2
}

// ==========================================================================================================================


$sql_where = '';

// only topic first post
if ($topics_only == 1)
{
   $sql_where = 'AND p.post_id = t.topic_first_post_id';
   $sql_from = 'FROM ' . POSTS_TABLE . ' as p, ' . FORUMS_TABLE . ' as f, ' . USERS_TABLE . ' as u, ' . TOPICS_TABLE . ' as t';
}
else
{
   $sql_from = 'FROM ' . POSTS_TABLE . ' as p, ' . FORUMS_TABLE . ' as f, ' . USERS_TABLE . ' as u';
}

// Exclude forums
if ($CFG['exclude_forums'])
{
   $exclude_forums = explode(',', $CFG['exclude_forums']);
   foreach ($exclude_forums as $i => $id)
   {
      if ($id > 0)
      {
         $sql_where .= ' AND p.forum_id != ' . trim($id);
      }
   }
}

if ($fid != '')
{
   $select_forums = explode(',', $fid);
   $sql_where .= ( sizeof($select_forums)>0 ) ? ' AND f.forum_id IN (' . $fid . ')' : '';
}

// SQL posts table
$sql = 'SELECT p.post_id, p.poster_id, p.post_subject, p.post_text, p.bbcode_uid, p.bbcode_bitfield, p.topic_id, p.forum_id, p.post_time, f.forum_name, f.forum_desc_options, u.username
      ' . $sql_from . '
      WHERE (u.user_id = p.poster_id)
      AND p.post_approved = 1
      AND (f.forum_id = p.forum_id)
      ' . $sql_where . '
      ORDER BY post_time DESC';
$result = $db->sql_query_limit($sql, $count);

while( ($row = $db->sql_fetchrow($result)) )
{

   if (!$auth->acl_get('f_list', $row['forum_id']))
   {
      // if the user does not have permissions to list this forum, skip everything until next branch
      continue;
   }

   if (empty($row['post_subject']))
   {
	  $subj_sql = 'SELECT p.post_subject
	  FROM ' . POSTS_TABLE . ' as p, ' . TOPICS_TABLE . ' as t
	  WHERE (p.topic_id = '.$row['topic_id'] .')
	  AND p.post_id = t.topic_first_post_id';

	  $subj_result = $db->sql_query($subj_sql);
	  $subj_row = $db->sql_fetchrow($subj_result);
	  $row['post_subject'] = $subj_row['post_subject'];
   }

   $template->assign_block_vars('item', array(
      'AUTHOR'      => $row['username'],
      'TIME'         => format_date($row['post_time']),
      'LINK'         => "$board_url/viewtopic.$phpEx" ."?". 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']."&p=".$row['post_id']."#p".$row['post_id'],
      'IDENTIFIER'   => "$board_url/viewtopic.$phpEx" ."?". 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']."&p=".$row['post_id']."#p".$row['post_id'],
      'TITLE'         => $row['post_subject'],
      'TEXT'         => parse_message($row['post_text'], $row['forum_desc_options'], $row['bbcode_uid'], $row['bbcode_bitfield']),
      )
   );
}

$template->assign_var('FEED_LINK', generate_board_url(TRUE) . $_SERVER['SCRIPT_NAME'] . "?" . htmlspecialchars($_SERVER['QUERY_STRING']));

if ($type == 'atom')
{
   $content_type = 'application/atom+xml';
   $tpl = 'atom';
}
else
{
   $content_type = 'application/rss+xml';
   $tpl = 'rss2';
}

$template->set_filenames(array(
   'body' => 'syndication_' . $tpl . '.xml')
);

// get time, use current time
$last_build_date = mktime();

$template->assign_vars(array(
   'HEADER'      => '<?xml version="1.0" encoding="UTF-8"?>' . "\n", // workaround for remove_php_tags() removing this line from the template
   'TITLE'         => strip_tags($config['sitename']),
   'DESCRIPTION'   => strip_tags($config['site_desc']),
   'LINK'         => $board_url,
   'LAST_BUILD'   => format_date($last_build_date)
   )
);

// gzip compression
if ($config['gzip_compress'])
{
   if (@extension_loaded('zlib') && !headers_sent())
   {
      ob_start('ob_gzhandler');
   }
}

// Start output
header ('Content-Type: ' . $content_type . '; charset=UTF-8');

//header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
//header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
//header("Cache-Control: no-store, no-cache, must-revalidate");   // HTTP/1.1
//header("Cache-Control: post-check=0, pre-check=0", false);      // HTTP/1.1
//header("Pragma: no-cache");                              // HTTP/1.0

$template->display('body');
exit;
?>
The modified "syndication_rss2.xml" template for proper validation:

Code: Select all

{HEADER}
<rss version="2.0"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<atom:link href="{FEED_LINK}" rel="self" type="application/rss+xml" />
		<title>{TITLE}</title>
		<description>{DESCRIPTION}</description>
		<link>{LINK}</link>
		<lastBuildDate>{LAST_BUILD}</lastBuildDate>
		<!-- BEGIN item -->
		<item>
			<dc:creator>{item.AUTHOR}</dc:creator>
			<pubDate>{item.TIME}</pubDate>
			<guid>{item.IDENTIFIER}</guid>
			<link>{item.LINK}</link>
			<title>{item.TITLE}</title>
			<description>{item.TEXT}</description>
		</item>
		<!-- END item -->
	</channel>
</rss>
To refresh the Template if you replaced the original one:
1) In the ACP: General>Purge cache
2) Open in MySQL the "phpbb_styles_template_data" table, browse to and remove the "syndication_rss2.xml" lines (one line for each style you applied this Mod to).

dr.3
Registered User
Posts: 39
Joined: Fri Oct 22, 2004 1:05 pm
Contact:

Re: [BETA] simple syndication

Post by dr.3 » Thu Feb 14, 2008 11:58 pm

Thank you dear wouterv 8-)

Perfect work :)

gkazanci
Registered User
Posts: 43
Joined: Sun Oct 07, 2007 1:04 pm

Re: [BETA] simple syndication

Post by gkazanci » Mon Feb 18, 2008 8:37 am

hi;
Is there any possibility to see the username of the poster in RSS feeds ?

wouterv
Registered User
Posts: 265
Joined: Wed Jan 02, 2008 10:22 am
Location: The Netherlands
Name: Wouter

Re: [BETA] simple syndication

Post by wouterv » Mon Feb 18, 2008 9:10 am

The feed generated with this mod does include the name of the poster.
When you open the feed with IE7, the name of the poster is shown in the second line (date, time | name).
For other Feed readers you may need to enable view of a specific column.

wouterv
Registered User
Posts: 265
Joined: Wed Jan 02, 2008 10:22 am
Location: The Netherlands
Name: Wouter

Re: [BETA] simple syndication

Post by wouterv » Mon Feb 18, 2008 9:10 am

[edit] double post, removed

User avatar
Lisbon
Registered User
Posts: 825
Joined: Wed Jan 30, 2008 12:28 pm
Location: Zermatt

Re: [BETA] simple syndication

Post by Lisbon » Tue Feb 19, 2008 9:03 pm

This Mod work in Subsilver2?

jimwillsher
Registered User
Posts: 51
Joined: Thu Mar 18, 2004 9:54 am

Re: [BETA] simple syndication

Post by jimwillsher » Tue Feb 19, 2008 9:18 pm

Try it?

bmeador
Registered User
Posts: 25
Joined: Thu Jul 01, 2004 9:52 pm

Re: [BETA] simple syndication

Post by bmeador » Wed Feb 20, 2008 4:33 am

Any chance you guys could provide a hack to duplicate the RSS feed naming scheme in this mod:

http://www.phpbb.com/community/viewtopi ... yndication

I've been using the above with phpbb2 for some time now and can't really upgrade to phpbb3 until I have a RSS syndication solution that duplicates the feed naming scheme all of my customers are currently using. It looks like that MOD isn't being ported to v3. I assume there are a lot of other folks in the same boat as me?

Thanks!

jimwillsher
Registered User
Posts: 51
Joined: Thu Mar 18, 2004 9:54 am

Re: [BETA] simple syndication

Post by jimwillsher » Wed Feb 20, 2008 6:56 am

You expect us to read 230 posts to find the naming convention? A link to the specific post would be appreciated. Or better - describe it here!!!


Jim

bmeador
Registered User
Posts: 25
Joined: Thu Jul 01, 2004 9:52 pm

Re: [BETA] simple syndication

Post by bmeador » Wed Feb 20, 2008 7:13 am

Actually, I'm kind of glad you asked because I realized I linked to the wrong MOD. I actually use this one:

http://www.phpbb.com/community/viewtopi ... &sk=t&sd=a

It appears that the format he uses is here in the MOD notes:

## For URL's the following arguments may be optionally passed (as applicable):
##
## f=x - forum id. Use data only from this forum to output RSS.
## t=1 - only new topics (first messages in topic). Default - 0.
## c=x - feed items count. If omitted, the value of DEFAULT_ITEMS constant (defined in mod's code) will be used. Admin can limit the maximal possible value of x by setting MAX_ITEMS constant at the beginning of mod's code.
## topic=x - view topic 'x' only
## nolimit - turn off "If-Modified-Since" record limit (by default)
## styled - use XSLT style for RSS feed
## atom - generate atom 0.3 feed instead of rss 2.0
## login - turn WWW-Authenticate on. May not work on some hosts.
## uid=x - set user id for WWW-Authenticate. Use it instead of "login" for Opera or Mozilla for cyrillic nicknames. You could than use any text for login but correct password in dialog box.
## Examples of Usage and Syntax:
## rss.php
## Last 25 or less messages from public forums
## rss.php?login&atom
## Last 25 records from allowed forums in Atom 0.3 format
## rss.php?login&f=1&c=10
## Last 10 records from private forum number 1

Does that help?

wouterv
Registered User
Posts: 265
Joined: Wed Jan 02, 2008 10:22 am
Location: The Netherlands
Name: Wouter

Re: [BETA] simple syndication

Post by wouterv » Wed Feb 20, 2008 9:03 pm

The parameters for this mod are:
rss - RSS format
atom - Atom format
count - number of most recent posts
fid - forum id
t - first post of topics only
The default without parameters results in: RSS format and 10 most recent posts of all forums.

It is quite easy to change the matching parameters according to your list.
Even easier is prior to upgrade from phpBB 2.0 to 3.0, to post one announcement regarding the upgrade and successive changes in the webfeed. This last old announcement will be read by your users, up to them to change the URL in their feedreaders.

[Edit]
This mod generates Atom 1.0 and RSS 2.0, that may cause incompatibility issues anyway with older feedreaders.
Last edited by wouterv on Wed Feb 20, 2008 9:19 pm, edited 1 time in total.

Locked

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