PHPNuke Feeds for RSS 2.0 and Atom 0.3
September 27th, 2004
Last week as I found that Firefox supported RSS feeds as Live Bookmarks. I watch over the a website which uses PHPNuke. I found that the only feed it provided was an older version of the RSS format which Firefox did not support. Granted PHPNuke was a much older version so I upgraded it hoping there would be a better feed, but I found nothing. I then looked for a module which provided new feed formats, but found none, so I had to make my own...
I took the RSS 0.91 version provided in backend.php and created an RSS 2.0 and Atom 0.3 feed. It was easy enough to create my own database query to get the additional information for these more data heavy feeds so it was an easy task.
To verify I had the feed properly formatted in the end I used the Feed Validator website. After I had the initial structure looking correct the validator pointed out a couple of problems. First I needed to correct the date format. And second, there were characters in the custom feed which were not in the ASCII character set.
The date format was easy enough to fix, but in PHP4 I had to do a bit of work. The explanation of the problem shows the dates must use the W3C date format, also known as the ISO 8601 date format. The hard part was getting the timezone right. It appears that in PHP5 the format character 'c' will provide the ISO 8601 according to the documentation. A few lines of code is all that is needed to make this date format.
Next I had the illegal characters in the content of the site news. The actual character encoding specified in the feed is iso-8859-1. Just like is done in backend.php I use the htmlspecialchars function to clean up the string for use in the feed, but it did not clean up these special characters. My short term fix was to simply edit the news stories with the invalid characters and make the feed validator happy. Now it works, but a longer term solution should catch those invalid characters. I do not normally write code with PHP, so there could a useful function to fix the character encoding that I do not know about. I am open to suggestions.
Now that I have the code working I made the content available on the PHPNuke site, but when I reload the main screen in Firefox it does not provide the icon in the lower right to let me create a live bookmark of the feeds. As I expected, I needed to add some meta data to the meta.php document. On line 34 of that document I added the following lines:
echo "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"$nukeurl/rss2.php\" />\n"; echo "<link rel=\"alternate\" type=\"application/atom+xml\" title=\"Atom\" href=\"$nukeurl/atom.php\" />\n";
And here are the new php documents for the feeds. I would like to get feedback on any improvements. And if you have a PHPNuke website you think I would like, please send me a link. I would like to get your feeds into my live bookmark list.

October 18th, 2004 at 5:49 am
RSS 2.0 works correctly, good job!
October 19th, 2004 at 1:22 pm
Dude you are awesome. Must now update site...
October 25th, 2004 at 3:13 am
Thanks for this solution. You're awesome.
I found it by Search_Engine. Have you announced it on phpnuke.org also?
EO
October 25th, 2004 at 3:17 am
ooh, E-Mailadresses are posted searchable for spambots.
Please delete my E-mailadress in the comment before this.
cpteos
November 4th, 2004 at 11:27 am
Cool. This is one of those enhancements along with Trackback that I've been wanting to see in PHPNuke, but haven't had the time to do it myself. I'm using it now as well and will let you know if I run into anything. Thanks!
November 21st, 2004 at 1:34 pm
I am still using php nuke version 5.0 (I've done some of my own patching to make it more secure). Anyway, all I had to do was change two lines that handled the sql to get both of your scripts to work:
$result = mysql_query("SELECT s.sid,t.topicname,s.informant,s.title,s.time,s.hometext FROM ".$prefix."_stories s, ".$prefix."_topics t where s.topic = t.topicid ORDER BY sid DESC LIMIT 10");
while ($row = mysql_fetch_assoc($result)) {
April 15th, 2005 at 11:43 am
Thanks very much for sharing this...
May 15th, 2005 at 5:41 am
Merci ...
pour votre travail
mon site phpnuke
fonctionne parfaitement avec le Rss de Safari sous Tiger !!!
May 25th, 2005 at 8:46 am
Hi , I'm new to working with rss and maybe you can help me. I made this file http://www.libertyunites.us/backendtributes.php that works ok but I can not get the images to show up, I tweeked a mod to offer Prayers for the victims of terror and this war. I wanted people to be able to pull the persons picture from my server as well as a link to read/post a prayer/tribute. If you have any ideas please let me know. Stop on over to LU and take a look. I hope you can help.
Blessings
John
http://www.libertyunites.us
June 20th, 2005 at 1:05 pm
Thanks for the script. To fix the character encoding that you do not know about:
http://hulan.cz/blog/item/php-script-to-convert-x-html-entities-to-decimal-unicode-representation/category/apache-php
you'll find the function entity_to_decimal_value($string) that converts the entity to its unicode decimal value
July 9th, 2005 at 9:51 pm
Excellent. It was a missing point for phpnuke.
Thank you
July 21st, 2005 at 12:09 pm
Thanks Brennan. Worked beautifully. I had to change some code because my site is based on Nuke but a lot has been changed, but it worked just fine.
I also had a big problem getting a sucessfull validation from feedvalidator.org due to 2 blank lines on the top.
After 1 hour(!) I found it was 2 spaces after the ?> on the language.php file! uff
August 6th, 2005 at 10:52 pm
You are the man! I had been wanting to update my rss feeds for a while but could never find the time. You've saved me a good deal of effort.
musicNerve.com
August 23rd, 2005 at 4:48 pm
Thank you SO much! It fixed my PHPnuke 7.1 and finally, it also works with Google Toolbar. Thanx again dude!
April 9th, 2006 at 6:39 pm
Thanks. I'm trying to build PHPNuke support into my Feed Button Maker.
If you wanna help test, email me.
July 27th, 2006 at 7:46 am
Is there a way of add the whole article into the feed, and hopefully the author and the comments also?. I wan't to use Wordpress for my site instead and at the moment I think RSS is the best way to import it. So far your script works perfect, I'm only missing the main part of the article, author and all the comments