[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!
Suggested Hosts
Artack
Registered User
Posts: 312
Joined: Thu Feb 07, 2008 11:26 pm

Re: [BETA] simple syndication

Post by Artack »

Now everything ok ) Thank You for mod)
One question, what changes have to do, for rename syndication.php to rss.php?
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 »

Did you hardcode the URL in syndication.php to solve your problem?

With the original syndication.php, you may rename it to anything you like with extension .php
The code reads the script file name and adopt it where needed.
If you hardcoded the URL here:

Code: Select all

$feed_link = ("http://yourdomain.xx/syndication.php" . "?" . htmlspecialchars($_SERVER['QUERY_STRING']));
Then replace "syndication.php" with your script file name.
Artack
Registered User
Posts: 312
Joined: Thu Feb 07, 2008 11:26 pm

Re: [BETA] simple syndication

Post by Artack »

wouterv wrote:Did you hardcode the URL in syndication.php to solve your problem?
Yes.
Also I rename to rss.php.
some problems in IE7 with atom format, but I don't care about that.
Did You test add-on for vewonline?
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 »

What is the problem with Atom (or give me the url of your board again, i didn't keep your msg's).

I didn't test the viewonline, honestly I don't see any value for that: most Webfeed users look at the feed without logging into the board, so you won't see any valuable info (besides some additional Guest users).
Artack
Registered User
Posts: 312
Joined: Thu Feb 07, 2008 11:26 pm

Re: [BETA] simple syndication

Post by Artack »

add-on will be useful for admins, can see who read feeds etc
i found where is my mistake, in overall header
thank you
wrongrobot
Registered User
Posts: 13
Joined: Mon Feb 28, 2005 8:13 pm

Re: [BETA] simple syndication

Post by wrongrobot »

So, I'll tell you what... I've been trying, through other means, to get an RSS Feed automation from the forum for so long, it's been a rush just finding a system that is both simple and works effectively. Thanks to everyone working on this!

I have been able to make multiple syndication.php files, renaming each one, to have different configurations, with the associated tweaks to the header file. Great!
I have one that grabs all new posts (like View Latest Posts)
And one that grabs NEW TOPICS only.

The one thing, even after scouring all 22 pages of this topic, that i'm still not seeing:
I can't get the feed to send a user to the latest POST within a topic. It's been asked a number f times already, and this makes me wonder if Im missing something obvious. The

// only topic first post

if ($topics_only == 0)

{

vs.

// only topic first post

if ($topics_only == 1)

{

affects whether or not replies are fed to the feed, but doesn't send the viewer to the reply itself...

What am I missing?
Thanks all
t
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 »

What about this:

Find:

Code: Select all

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';
}
Replace with:

Code: Select all

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';
}
elseif ($topics_only == 2)
{
	$sql_where = 'AND p.post_id = t.topic_last_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';
}
Parameters:
t=1: first post of topics
t=2: last post of topics
otherwise all posts

If this works well for you too, I'll integrate that in a new version.
wouterv
Registered User
Posts: 265
Joined: Wed Jan 02, 2008 10:22 am
Location: The Netherlands
Name: Wouter

Re: [BETA] simple syndication 1.1.2b

Post by wouterv »

Here is the complete 1.1.2b version.

Changes:
-New parameter added: t=2 - last post of topics only.
-Code cleanup and header standardization.

Major change since initial version:
It no longer requires the separate template files, thus no bothering with refresh after updates and no need to update multiple or new styles if any.

Valid parameters:
chars=[number] - number of characters per post, HTML and BBCode tags get stripped: syndication.php?chars=200
count=[number] - number of most recent posts: syndication.php?count=3
fid=[number1,numberX] - forum id, multiple id's separated by a comma: syndication.php?fid=32,50
t=1 - first post of topics only: syndication.php?t=1
t=2 - last post of topics only: syndication.php?t=1
type=atom - Atom format: syndication.php?type=atom
type=rss - RSS format: syndication.php?type=rss

You can also combine parameters: syndication.php?type=atom&count=3
The default without parameters results in: RSS format and all contents of the 20 most recent posts of all forums.

[NOTE 24-09-2008]
If the current user has "No Access" rights for a certain Forum, the contents will not be shown by this Webfeed.
Forums with phpBB Password protection will be shown by this Webfeed; see here:
http://www.phpbb.com/community/viewtopi ... 5#p7160235

syndication.php 1.1.2b:

Code: Select all

<?php
/**
*
* @package phpBB3
* @version $Id: syndication.php,v 1.1.2b 2008/09/20 00:00:00 angelside and many others $
* @copyright (c) 2007 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
*/
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', 0);
$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
}

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

// Compile the feed link
$feed_link = (generate_board_url(TRUE) . $_SERVER['SCRIPT_NAME'] . "?" . htmlspecialchars($_SERVER['QUERY_STRING']));

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

// Common feed header part
$rdf = '';
$rdf .= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";

if ($type == 'atom')
{
	// ATOM feed header part
	$rdf .= "
	<feed xmlns=\"http://www.w3.org/2005/Atom\">
	<title>".strip_tags($config['sitename'])."</title>
	<subtitle>".strip_tags($config['site_desc'])."</subtitle>
	<link href=\"$board_url\" />
	<updated>".format_date($last_build_date)."</updated>
	<id>$board_url</id>
	<link rel=\"self\" href=\"$feed_link\" />";
}
else
{
	// RSS feed header part
	$rdf .= "<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>".strip_tags($config['sitename'])."</title>
			<description>".strip_tags($config['site_desc'])."</description>
			<link>$board_url</link>
			<lastBuildDate>".format_date($last_build_date)."</lastBuildDate>";
}

$sql_where = '';

// Only topic first or last 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';
}
elseif ($topics_only == 2)
{
	$sql_where = 'AND p.post_id = t.topic_last_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'];
	}

	if($chars > 0)
	{
		if ($chars <3)
			$chars = 3;
		strip_tags($row['post_text']);
		strip_bbcode($row['post_text']);
		$row['post_text'] = ( strlen($row['post_text']) > $chars ) ? substr($row['post_text'], 0, ($chars - 3)) . '&#8230;' : $row['post_text'];
	}

	// Define feed items
	$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']);

	if ($type == 'atom')
	{
		// ATOM feed items
		$rdf .= "
		<entry>
			<title>$title</title>
			<link href=\"$link\"/>
			<id>$identifier</id>
			<author>
				<name>$author</name>
			</author>
			<published>$time</published>
			<updated>$time</updated>
			<summary type=\"xhtml\">
				<div xmlns=\"http://www.w3.org/1999/xhtml\">$text</div>
			</summary>
		</entry>";
	}
	else
	{
		// RSS feed items
		$rdf .= "
			<item>
				<dc:creator>$author</dc:creator>
				<pubDate>$time</pubDate>
				<guid>$identifier</guid>
				<link>$link</link>
				<title>$title</title>
				<description>$text</description>
			</item>";
	}

}

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

if ($type == 'atom')
{
	// ATOM feed footer
	$rdf .= "
	</feed>";

	$content_type = 'application/atom+xml';
}
else
{
	// RSS feed footer
	$rdf .= "
		</channel>
	</rss>";

	$content_type = 'application/rss+xml';
}

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

// Output the feed
echo($rdf);
?>
The original file name is "syndication.php". You can name it anything you like (with extension .php) without changes in the code, e.g. to be compatible with previous syndicators.

When copy/paste the code, remove the additional spaces that may be added at the start of the file.

Again: the "syndication_atom.xml" and "syndication_rss2.xml" tempate files are no longer required, just this file in your phpBB root.

Mod History:
2006-12-03 - Version 1.0.0a
first release

2007-01-01 - Version 1.0.1b
re-integrate exclude forums via variable in the header of the file rewrite the sql query hopefully forumspermission will work now add optional parameter to the script count and fid

2007-05-22 - Version 1.0.2b
phpBB3 RC1 test and changes
clean codes

2007-06-08 - Version 1.1.0b
rename mod to "simple syndication" from "simple RSS"
complate rewrite code/function
add rss/atom output
add rss/atom template

2007-06-20 - Version 1.1.1b
fix minor error
add new parameter for show topic only first post

2008-01-15 - Version 1.1.1c
Many fixes by different authors
Validation problems solved, need updated template: syndication_rss2.xml

2008-01-16 - Version 1.1.1d
Corrections to rss or atom type settings

2008-01-17 - Version 1.1.1e
Multiple parameter problem solved

2008-01-17 - Version 1.1.1f
Post without title problem fixed

2008-02-14 - Version 1.1.1g
Smilies fixed again

2008-06-29 - Version 1.1.1h
Suggested fix for showing inline attachments, a bug in this version with sid's is reported 14-07-2008

2008-09-01 - Version 1.1.1i
Truncate posts fixed with chars parameter, build on 1.1.1g

2008-09-13 - Version 1.1.2a
syndication_atom.xml and syndication_rss2.xml template files combined with the main file (templates no longer required)

2008-09-20 - Version 1.1.2b
New parameter added: t=2 - last post of topics only
Code cleanup and header standardization
Last edited by wouterv on Fri Sep 26, 2008 5:30 pm, edited 3 times in total.
Artack
Registered User
Posts: 312
Joined: Thu Feb 07, 2008 11:26 pm

Re: [BETA] simple syndication

Post by Artack »

Not working after update
All types of feeds have
This feed does not validate.
line 1, column 4: XML parsing error: <unknown>:1:4: xml declaration not at start of external entity
here is my file

Code: Select all

    <?php
    /**
    *
    * @package phpBB3
    * @version $Id: syndication.php,v 1.1.2b 2008/09/20 00:00:00 angelside and many others $
    * @copyright (c) 2007 phpBB Group
    * @license http://opensource.org/licenses/gpl-license.php GNU Public License
    *
    */

    /**
    */
    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'] = '17,28,33,40';
    $cfg['max_topics'] = '20';
    // End configuration

    // Requests
    $fid = request_var('fid', '');
    $count = request_var('count', 0);
    $chars = request_var('chars', 0);
    $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
    }

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

    // Compile the feed link
    $feed_link = ("http://www.mydomain.xx/syndication.php" . "?" . htmlspecialchars($_SERVER['QUERY_STRING']));

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

    // Common feed header part
    $rdf = '';
    $rdf .= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";

    if ($type == 'atom')
    {
       // ATOM feed header part
       $rdf .= "
       <feed xmlns=\"http://www.w3.org/2005/Atom\">
       <title>".strip_tags($config['sitename'])."</title>
       <subtitle>".strip_tags($config['site_desc'])."</subtitle>
       <link href=\"$board_url\" />
       <updated>".format_date($last_build_date)."</updated>
       <id>$board_url</id>
       <link rel=\"self\" href=\"$feed_link\" />";
    }
    else
    {
       // RSS feed header part
       $rdf .= "<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>".strip_tags($config['sitename'])."</title>
             <description>".strip_tags($config['site_desc'])."</description>
             <link>$board_url</link>
             <lastBuildDate>".format_date($last_build_date)."</lastBuildDate>";
    }

    $sql_where = '';

    // Only topic first or last 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';
    }
    elseif ($topics_only == 2)
    {
       $sql_where = 'AND p.post_id = t.topic_last_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'];
       }

       if($chars > 0)
       {
          if ($chars <3)
             $chars = 3;
          strip_tags($row['post_text']);
          strip_bbcode($row['post_text']);
          $row['post_text'] = ( strlen($row['post_text']) > $chars ) ? substr($row['post_text'], 0, ($chars - 3)) . '&#8230;' : $row['post_text'];
       }

       // Define feed items
       $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']);

       if ($type == 'atom')
       {
          // ATOM feed items
          $rdf .= "
          <entry>
             <title>$title</title>
             <link href=\"$link\"/>
             <id>$identifier</id>
             <author>
                <name>$author</name>
             </author>
             <published>$time</published>
             <updated>$time</updated>
             <summary type=\"xhtml\">
                <div xmlns=\"http://www.w3.org/1999/xhtml\">$text</div>
             </summary>
          </entry>";
       }
       else
       {
          // RSS feed items
          $rdf .= "
             <item>
                <dc:creator>$author</dc:creator>
                <pubDate>$time</pubDate>
                <guid>$identifier</guid>
                <link>$link</link>
                <title>$title</title>
                <description>$text</description>
             </item>";
       }

    }

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

    if ($type == 'atom')
    {
       // ATOM feed footer
       $rdf .= "
       </feed>";

       $content_type = 'application/atom+xml';
    }
    else
    {
       // RSS feed footer
       $rdf .= "
          </channel>
       </rss>";

       $content_type = 'application/rss+xml';
    }

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

    // Output the feed
    echo($rdf);
    ?>
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 »

Due to the copy/paste action, your file seems to start with spaces (there seems to be spaces in front of every line). Remove the spaces, the file MUST start with: <?php....
Artack
Registered User
Posts: 312
Joined: Thu Feb 07, 2008 11:26 pm

Re: [BETA] simple syndication

Post by Artack »

This bug from copying with firefox.
Now I copy usig IE, and everything working.
When You planned release version?
Regards
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 »

To prevent showing password protected forums in the Webfeed, modify the 1.1.2b version as follows:

[EDIT]
29-09-2008: little update in the $sql variable

Find:

Code: Select all

$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
Replace with:

Code: Select all

$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, f.forum_password
Find:

Code: Select all

	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;
	}
Replace with:

Code: Select all

	if ((!$auth->acl_get('f_list', $row['forum_id'])) || ($row['forum_password']))
	{
		// If the user has no access or the forum is passworded, skip everything until next branch
		continue;
	}
After further testing, this will be included in a next version.
Last edited by wouterv on Mon Sep 29, 2008 4:06 pm, edited 1 time in total.
sysdev
Registered User
Posts: 6
Joined: Wed Sep 17, 2008 8:36 pm

Re: [BETA] simple syndication

Post by sysdev »

Hey there. Is there a way to get this mod to dish out the RSS and ATOM feeds automatically for the specific thread that you're currently on? For example, consider the following scenarios:

1. When you're in a topic and you want to get the feed for that specific thread, that you can click on the feed button on your browser and get the last x made posts within that specific topic?

2. If you're in a forum and you want to get the feed for that forum, that you can click the feed button on your browser, and get the last x posts that were posted within that forum, including all topics (e.g., the last 10 posts made within that forum if x were 10)?

3. If you're in a group and want to get the feed for that group of forums, that you can click the feed button on your browser, and get the last x posts that were posted within that group, including all forums and topics within each forum, within that group (e.g., the last 10 posts made within that group if x were 10)?

4. The current default behavior of the mod, where for all groups, for all forums, and for all topics, you get the last x posts made to the board at large - but only when you are located at the board index (or a portal homepage if you were using something like Stargate Portal, phpBB3 Portal, or whatever others).

I would assume that some modifications would need to be made in the following code ...

Code: Select all

<link rel="alternate" type="application/rss+xml" title="{SITENAME}" href="syndication.php?type=rss" />
<link rel="alternate" type="application/atom+xml" title="{SITENAME}" href="syndication.php?type=atom" />
... to create dynamic RSS and ATOM links that contain the ids of the forum, the posts, and whatever else that you are currently located at. Is this correct, and if so, what would I need to do to enable this capability?

Also, (second question,) could a hyperlink be created with (or without) RSS and ATOM icons to be placed somewhere on the page (perhaps the overall_header and/or overall_footer), that will allow the user to navigate directly to the feed corresponding to the page that they're currently on - using the same above scenarios for group, forum, and topic? In other words, a hyperlink that takes you to the same feed that the feed button on your browser would take you to if clicked?

Any help with these two questions would be greatly appreciated. This is an excellent mod that adds a lot of potential to any phpbb3-powered board. Thank you for the hard work and time that you all have put into this.
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 »

I don't think that the actual Forum ID etc. can dynamically be used as parameter (fid=...) for the syndicator.
A possibility may be to add a link in the "Forum Rules" box, in the ACP Forum Edit screen with "fid" according to that forum, like this:

Code: Select all

[url=http://Your_phpBB_url/syndication.php?fid=...][img]http://Your_phpBB_url/feed-icon-14x14.png[/img] RSS[/url]
Of course you need to grab the feed-icon from http://www.feedicons.com/ and locate it on your server.
And I think there is a discussion somewhere in the generic Mod discussion on how to edit the look of the "pink" Forum Rules box.
sysdev
Registered User
Posts: 6
Joined: Wed Sep 17, 2008 8:36 pm

Re: [BETA] simple syndication

Post by sysdev »

wouterv wrote:I don't think that the actual Forum ID etc. can dynamically be used as parameter (fid=...) for the syndicator.
I would think that it is possible, according to the notes in the install.xml file:

Code: Select all

Author Notes

count is a parameter how many topics the script should display fid is forumid 
it says that forums you would display.

example: rss.php?count=3&fid=2,4
it say the script display the 3 last topics consider forum 2 and 4


Put this file in your phpBB3 directory.

You can call this script without parameters, what will result in an 
RSS_FEED with the x latest posts from all your forums.
x is specified in $CFG['max_topics']

You can specify the number of posts via the url parameter count:
http://www.domain.com/phpBB3/syndication.php?count=50

If you want show only first post on topic, use this parameter:
http://www.domain.com/phpBB3/syndication.php?t=1

This will result in an RSS_FEED with the latest 50 posts from all your forums.

You can also specify to look only at a specified forum using the fid parameter:
http://www.domain.com/phpBB3/syndication.php?fid=9

This will result in an RSS_FEED with the latest x posts from your forum with the id 9.

You can also mix the paramters:
http://www.domain.com/phpBB2/syndication.php?fi ... ,6&count=3

will show you the latest 3 posts from forum 5 and 6.


atom or rss type:
http://www.domain.com/phpBB3/syndication.php?type=atom
http://www.domain.com/phpBB3/syndication.php?type=rss

If not use type, default is rss.

THIS SCRIPT WILL ONLY SHOW POSTS FROM PUBLIC FORUMS
So theoretically, you should be able to use those parameters to dynamically-generate the LINK url. I just don't know how to do it in PHP. If you asked me to do it in ASP or JavaScript though I probably could - I just know *squat* about how to code it PHP. :?
Locked

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