RSS Feed from Forums Broken
Recent › Forums › Main Forum › Suggestion Box › RSS Feed from Forums Broken
- This topic has 27 replies, 4 voices, and was last updated 10/17/2012 at 8:17 am by Ryan Stasel.
-
AuthorPosts
-
10/16/2012 at 8:12 am #6259
okay, it isn’t perfectly validating (there’s currently no guid’s), but here ya go:
[code]<?php
header('Content-Type: text/xml; charset=UTF-8');
function get_url_contents($url) {
//echo $url;
$crl = curl_init();
$timeout = 5;
curl_setopt ($crl, CURLOPT_URL, $url);
curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt ($crl, CURLOPT_HEADER, 0);
curl_setopt ($crl, CURLOPT_USERAGENT, "Mozilla/4.0");
$ret = curl_exec($crl);
curl_close($crl);
return $ret;
}$url = 'http://www.wickededgeusa.com/index.php?option=com_kunena&func=rss&Itemid=63';
$feed = get_url_contents($url);
//$feed_array = explode("r", $feed);
$feed_array = preg_split('/n|r/', $feed, -1, PREG_SPLIT_NO_EMPTY);
foreach($feed_array as $line) {
if(preg_match("”,$line)) {
$fixed = preg_replace(“/&/”, “&”, $line);
$root_link_parts = preg_split(‘/>|</', $fixed, -1);
$root_link = $root_link_parts[2];
//$fixed = $fixed . "n" . '’ . $root_link . ”;
} elseif(preg_match(“//”,$line) == 1) {
$fixed = preg_replace(“/&/”, “”, $line);
} elseif(preg_match(“//”,$line) == 1) {
$fixed = ”;
} elseif(preg_match(‘//’, $line)) {
$fixed = $line . “n” . ”;
} else {
$fixed = $line;
}
echo $fixed . “n”;
}?>[/code]
10/16/2012 at 8:42 am #6260Got GUID’s working.
Now the only error is the image “link”. But that’s really nothing, other than just being nit picky.
10/16/2012 at 9:01 am #6261Thanks Staze for bringing this up and all your help in getting it resolved!
Got GUID’s working.
Now the only error is the image “link”. But that’s really nothing, other than just being nit picky.
-Clay
10/16/2012 at 9:03 am #6262no prob. It’d been bugging me for a bit, but I figured I’d finally report it. =P
Until now I hadn’t done the legwork to actually figure out what was going on, just that the links didn’t work.
10/16/2012 at 11:21 am #6266Obviously the issue should be fixed via patching Kunena, but my code should fix a general idea of the issue. The biggest one, is not HTML encoding the url’s under . Once that’s addressed, I’m guessing the RSS will validate, albeit messily.
If I have time tomorrow I’ll look at the code for 1.6 and see if I can figure out where it’s going wrong.
And Clay, this is the least I can do given the product. =)
10/17/2012 at 3:30 am #6279Okay, found the fix.
After installing Joomla 1.5.21, and Kunena 1.6, I found the configuration option that’s the issue.
In the Joomla administration area, under Components, Kunena Forum, Configuration. In there is an RSS tab. Change the RSS Specification to RSS 2.0, and save. That should fix the issue. I’m guessing right now it’s set to RSS 0.91, or RSS 1.0, both of which are pretty old at this point, and setting them that way is not really needed anymore.
Give that a shot, and let me know, and I’ll give it a test. Weird that RSS previous to 2.0 allowed non-encoded URLs….
Thanks!
10/17/2012 at 3:34 am #6280Though now that I look at the RSS feed raw, it says it’s RSS 2.0, but obviously isn’t valid.
Any chance you could tell which which specific version numbers of Kunena and Joomla are being run? I only see the major versions (Joomla 1.5, and Kunena 1.6).
Or maybe just the version of joomla/libraries/joomla/document/feed/renderer/rss.php (version should be at the top).
I’m a bit confused, as it seems like link’s in general aren’t being url encoded… which makes me think something is wonky.
Thanks!
10/17/2012 at 3:49 am #6281Here are the Joomla! specs:
PHP Built on: Windows NT WEBB38 6.1 build 7601
Database Version: 5.0.54-log
Database Collation: utf8_general_ci
PHP Version: 5.2.17
Web Server: Microsoft-IIS/7.5
Web Server to PHP interface: cgi-fcgi
Joomla! Version: Joomla! 1.5.20 Stable [ senu takaa ] 18-July-2010 18:00 GMT
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.92 Safari/537.4and the Kunena specs:
Installed version: Kunena 1.6.3
-Clay
10/17/2012 at 4:00 am #6282excellent. I’ve recreated the issue with those versions. Now I get to find the fix. =)
10/17/2012 at 5:43 am #6284okay, got it fixed. Attached is a patch, and here’s the manual way to do it.
In joomla/libraries/joomla/document/feed/renderer, there’s rss.php. Open that up, and change line 123 from:
[code]$feed.= ” “.str_replace(‘ ‘,’%20’,$data->items[$i]->link).”n”;[/code]
to
[code]$feed.= ” “.htmlspecialchars($data->items[$i]->link, ENT_COMPAT, ‘UTF-8’).”n”;[/code]
then just comment out the next line, 124, with two forward slashes infront of it, so it looks like:
[code]//$feed.= “”.str_replace(‘ ‘,’%20’,$data->items[$i]->link).”n”;[/code]
That’s all there is to it. Save and you’re done.
So, the question is, why it’s like this. Honestly, I don’t know. The commented out part is likely because one person added some code and forgot to remove the old. All it does is fix the “duplicate GUID” validation issue. The first part of the code is to encode the url to be html safe, so replace & with &, spaces with %20, etc. Previously all they were doing was replacing spaces with %20. The other validation errors are annoying, but they’re mainly cosmetic.
Obviously create a backup of rss.php before making changes, but having tested these with the same Joomla and Kunena versions, I’m fairly confident they’ll work. Please let me know!
Attachments:10/17/2012 at 7:04 am #6288Hi Staze. Made your changes please check on your end. Thanks!
10/17/2012 at 7:12 am #6289Fascinating. Still doesn’t work with Google Reader. But the w3c validator comes back “clean”.
Only thing I can imagine is that it’s the validator error saying “Your feed appears to be encoded as “utf-8”, but your server is reporting “US-ASCII”
I’m not positive here, but that’s all I can figure.
See here: http://forums.iis.net/p/1155439/1894464.aspx#1894464
Seems like we should just make .php encoding UTF-8. That’s all I can figure at this point. =/
10/17/2012 at 8:17 am #6295Okay, well, either something else got tweaked, or Google was caching bad data, or maybe the webserver was caching the previous php or output. Anyway, it’s working now. =D The URL’s are proper, and link to the appropriate articles. W3validator still shows the ASCII/UTF error, but I honestly don’t think that’s a huge issue unless you got non-english symbols in the URL (which I’m guessing won’t happen anyway).
Thanks for your help on this. Now I can actually use the reader feed. =)
Let me know if you need any additional info, testing, etc. =)
-
AuthorPosts
- You must be logged in to reply to this topic.