MyBB Community Forums

Full Version: RSS Feed Parser?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Does anyone know a php code or a mod that can parse the rss feed URL you get from the Forum's RSS Syndication? I want to have the latest forum posts from one of my forum's sections to appear on the main page of my website.
Hey,

Find a third party RSS reader script for your site and then goto [your forum url]/misc.php?action=syndication

Select the forums you want post to show in the feed and click generate syndication url which then you can use with the RSS reader script.
Is there a built in function to strip the tags from posts instead of going to RSS feed route?

Edit: added img tag stripping

function StripMyBBTags($Post)
{
	// ** Strip HR
	$Post = str_replace('[hr]', '', $Post);
	
	// ** Strip Quotes
	$QuoteIndex = strpos($Post, '[quote=');
	while($QuoteIndex!==false)
	{
		$QuoteLength = (strpos($Post, '[/quote]', $QuoteIndex) - $QuoteIndex) + 8;
		$Post = substr_replace($Post, '', $QuoteIndex, $QuoteLength);
		
		$QuoteIndex = strpos($Post, '[quote=');
	}
	$Post = str_replace('[/quote]', '', $Post);

	// ** Strip Images
	$ImageIndex = strpos($Post, '[img]');
	while($ImageIndex!==false)
	{
		$ImageLength = (strpos($Post, '[/img]', $ImageIndex) - $ImageIndex) + 6;
		$Post = substr_replace($Post, '', $ImageIndex, $ImageLength);
		
		$ImageIndex = strpos($Post, '[img]');
	}
	$Post = str_replace('[/img]', '', $Post);

	// ** Strip URL
	$URLIndex = strpos($Post, '[url=');
	if($URLIndex!==false)
	{
		$URLCloseIndex = strpos($Post, ']', $URLIndex);
		$Post = substr_replace($Post, '', $URLIndex, ($URLCloseIndex - $URLIndex) + 1);
		$Post = str_replace('[/url]', '', $Post);
	}
	
	// ** Strip Size
	$SizeIndex = strpos($Post, '[size=');
	if($SizeIndex!==false)
	{
		$SizeCloseIndex = strpos($Post, ']', $SizeIndex);
		$Post = substr_replace($Post, '', $SizeIndex, ($SizeCloseIndex - $SizeIndex) + 1);
		$Post = str_replace('[/size]', '', $Post);
	}

	// ** Strip Font
	$FontIndex = strpos($Post, '[font=');
	if($FontIndex!==false)
	{
		$FontCloseIndex = strpos($Post, ']', $FontIndex);
		$Post = substr_replace($Post, '', $FontIndex, ($FontCloseIndex - $FontIndex) + 1);
		$Post = str_replace('[/font]', '', $Post);
	}

	// ** Strip common formatting
	$Post = str_replace('[b]', '', $Post);
	$Post = str_replace('[/b]', '', $Post);
	$Post = str_replace('[u]', '', $Post);
	$Post = str_replace('[/u]', '', $Post);
	$Post = str_replace('[i]', '', $Post);
	$Post = str_replace('[/i]', '', $Post);
	
	return $Post;
}
My carudden nice addition and I hope to take advantage of them
Gary Experience
Pleasure, hopefully we can all add to it, so that we can get a definitive function. The code is a bit hacky. I'm sure some guru will come with a preg_replace one-liner Wink
carudden, what exactly does your code do and where do I put it at?

Quote:Find a third party RSS reader script for your site and then goto [your forum url]/misc.php?action=syndication

I've no idea where an ideal third party RSS reader script is. I've seen a few but they all aren't up to par. They've got links at the end of the parsing that say "Subscribe to this" and their parse style is plain.
Eh..I've found out how to use Simplepie...gonna switch my site's CMS since my current one is no longer compatible with Simplepie.
(2009-04-29, 03:49 PM)windrider07 Wrote: [ -> ]carudden, what exactly does your code do and where do I put it at?

I have a sql query against the myBB database directly:
Quote:SELECT
pos.tid,
pos.pid,
pos.subject,
pos.message,
pos.uid,
pos.username
FROM mybb_posts pos
ORDER BY pos.dateline DESC
LIMIT 0,4

The I simply execute the function sending in the message:
$Message = StripMyBBTags(mysql_result($result, $i, "message"));

ps. I've updated the function to strip images.