- Edited
Hey guys
Not sure where to tag this but the RSS feed for the forum seems to be broken.
Hey guys
Not sure where to tag this but the RSS feed for the forum seems to be broken.
Seems an issue with this PHP (rss.php):
<?php
header('Content-Type: application/xml');
echo '<?xml version="1.0" encoding="US-ASCII" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
';
$url = 'http://'.$_SERVER['HTTP_HOST'].str_replace('/rss.php','',$_SERVER['PHP_SELF']);
$requesturl = $url.'/api/discussions';
$request = file_get_contents($requesturl);
$request = json_decode($request);
$title = 'KaOS Forum';
$description = 'This is the place to get support for using KaOS and have online discussions with fellow users.';
echo '
<title>'.$title.'</title>
<link>'.$url.'</link>
<description>'.$description.'</description>
<atom:link href="http://'.str_replace(':80','',$_SERVER['HTTP_HOST']).$_SERVER['PHP_SELF'].'" rel="self" type="application/rss+xml" />
';
foreach ($request->data as $k) {
$m = file_get_contents($requesturl.'/'.$k->id);
$m = json_decode($m);
$date=new DateTime($m->data->attributes->startTime);
echo '
<item>
<title>'.$m->data->attributes->title.'</title>
<link>'.$url.'/d/'.$m->data->id.'</link>
<guid>'.$url.'/d/'.$m->data->id.'</guid>
<pubDate>'.$date->format('D, d M Y H:i:s O').'</pubDate>
<description>'.substr(preg_replace('/[^\x20-\x7E]/','', strip_tags($m->included[0]->attributes->contentHtml)), 0, 140).'...</description>
</item>
';
}
Echo '</channel>
</rss>
';
?>
Not clear yet what/where the error is.
Thanks for reporting though.
In Firefox, the error is that "&" is not being escaped
<title>Qt 5.12.1, Readline 8.0.0, Frameworks 5.55.0 & KDE Apps 18.12.2</title>
I suggest change the title and description lines to these
<title>'.htmlentities($m->data->attributes->title, ENT_XML1 | ENT_QUOTES,'ISO-8859-1', true).'</title>
<description>'.htmlentities(substr(preg_replace('/[^\x20-\x7E]/','', strip_tags($m->included[0]->attributes->contentHtml)), 0, 140), ENT_XML1 | ENT_QUOTES,'ISO-8859-1', true).'...</description>
Just found it too
Renamed that topic, no more ampersand, now all is good. But I will adjust the code with your suggestions.