Skip to content

Commit

Permalink
Issue #5079 RSS feed fatal error in PHP 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
CaMer0n committed Nov 16, 2023
1 parent 4f13dbd commit e2527d5
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions e107_plugins/rss_menu/rss.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@
}
}

$text = $tp->parseTemplate($RSS_LIST_HEADER, true);
$text = $tp->parseTemplate($RSS_LIST_HEADER);

while($row = $sql->fetch())
{
$sc->setVars($row);
$text .= $tp->parseTemplate($RSS_LIST_TABLE, false, $sc);
}

$text .= $tp->parseTemplate($RSS_LIST_FOOTER, true);
$text .= $tp->parseTemplate($RSS_LIST_FOOTER);

$ns->tablerender(RSS_MENU_L2, $text);
}
Expand Down Expand Up @@ -175,7 +175,7 @@
{
$rss_title = ($rss->contentType ? $rss->contentType : ucfirst($content_type));

if(E107_DEBUG_LEVEL > 0)
if(defset('E107_DEBUG_LEVEL') > 0)
{
define('e_IFRAME',true);
require_once(HEADERF);
Expand Down Expand Up @@ -211,6 +211,8 @@ class rssCreate
var $rssNamespace;
var $rssCustomChannel;

private $limit;

public function __construct($content_type, $rss_type, $topic_id, $row)
{ // Constructor
$sql_rs = new db;
Expand Down Expand Up @@ -264,6 +266,9 @@ public function __construct($content_type, $rss_type, $topic_id, $row)
$tmp = $sql->db_getList();
$this -> rssItems = array();
$loop=0;

$HTTP = !empty($_SERVER['HTTPS']) ? 'https://' : 'http://';

foreach($tmp as $value)
{
$this -> rssItems[$loop]['title'] = $value['comment_subject'];
Expand All @@ -273,15 +278,15 @@ public function __construct($content_type, $rss_type, $topic_id, $row)
{
case 0 :
case 'news' :
$this -> rssItems[$loop]['link'] = "http://".$_SERVER['HTTP_HOST'].e_HTTP."comment.php?comment.news.".$value['comment_item_id'];
$this -> rssItems[$loop]['link'] = $HTTP.$_SERVER['HTTP_HOST'].e_HTTP."comment.php?comment.news.".$value['comment_item_id'];
break;
case 2 :
case 'download' :
$this -> rssItems[$loop]['link'] = "http://".$_SERVER['HTTP_HOST'].e_HTTP."comment.php?comment.download.".$value['comment_item_id'];
$this -> rssItems[$loop]['link'] = $HTTP.$_SERVER['HTTP_HOST'].e_HTTP."comment.php?comment.download.".$value['comment_item_id'];
break;
case 4:
case 'poll' :
$this -> rssItems[$loop]['link'] = "http://".$_SERVER['HTTP_HOST'].e_HTTP."comment.php?comment.poll.".$value['comment_item_id'];
$this -> rssItems[$loop]['link'] = $HTTP.$_SERVER['HTTP_HOST'].e_HTTP."comment.php?comment.poll.".$value['comment_item_id'];
break;
}

Expand Down Expand Up @@ -421,7 +426,7 @@ function buildRss($rss_title)

$tp = e107::getParser();

header('Content-type: application/xml', TRUE);
header('Content-type: application/xml');

$rss_title = $tp->toRss($tp->toHTML($pref['sitename'],'','defs')." : ".$tp->toHTML($rss_title,'','defs'));
$rss_namespace = ($this->rssNamespace) ? "xmlns:".$this->rssNamespace : '';
Expand All @@ -443,7 +448,7 @@ function buildRss($rss_title)

foreach($this -> rssItems as $value)
{ // Multi-language rss links.
$link = (e_LANQRY) ? str_replace("?","?".e_LANQRY,$value['link']) : $value['link'];
$link = deftrue('e_LANQRY') ? str_replace("?","?".e_LANQRY,$value['link']) : $value['link'];

echo "
<item>
Expand All @@ -470,7 +475,7 @@ function buildRss($rss_title)
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?".">
<!-- generator=\"e107\" -->
<!-- content type=\"".$this->contentType."\" -->
<rss {$rss_namespace} version=\"2.0\"
<rss $rss_namespace version=\"2.0\"
xmlns:content=\"http://purl.org/rss/1.0/modules/content/\"
xmlns:atom=\"http://www.w3.org/2005/Atom\"
xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
Expand All @@ -482,10 +487,10 @@ function buildRss($rss_title)
<link>".$pref['siteurl']."</link>
<description>".$tp->toRss($pref['sitedescription'])."</description>\n";

echo $tp->toHTML($rss_custom_channel,FALSE)."\n"; // must not convert to CDATA.
echo $tp->toHTML($rss_custom_channel)."\n"; // must not convert to CDATA.

echo "
<language>".CORE_LC.(defined("CORE_LC2") ? "-".CORE_LC2 : "")."</language>
<language>".defset('CORE_LC').(defined("CORE_LC2") ? "-".CORE_LC2 : "")."</language>
<copyright>".$tp->toRss(SITEDISCLAIMER)."</copyright>
<managingEditor>".$this->nospam($pref['siteadminemail'])." (".$pref['siteadmin'].")</managingEditor>
<webMaster>".$this->nospam($pref['siteadminemail'])." (".$pref['siteadmin'].")</webMaster>
Expand Down Expand Up @@ -528,8 +533,8 @@ function buildRss($rss_title)

foreach($this -> rssItems as $value)
{ // Multi-language rss links.
$link = (e_LANQRY) ? str_replace("?","?".e_LANQRY,$value['link']) : $value['link'];
$catlink = (e_LANQRY) ? str_replace("?","?".e_LANQRY,$value['category_link']) : $value['category_link'];
$link = deftrue('e_LANQRY') ? str_replace("?","?".e_LANQRY,$value['link']) : $value['link'];
$catlink = deftrue('e_LANQRY') ? str_replace("?","?".e_LANQRY,$value['category_link']) : $value['category_link'];

echo "<item>\n";
echo "<title>".$tp->toRss($value['title'])."</title>\n";
Expand Down Expand Up @@ -626,7 +631,7 @@ function buildRss($rss_title)

foreach($this -> rssItems as $value)
{ // Multi-language rss links.
$link = (e_LANQRY) ? str_replace("?","?".e_LANQRY,$value['link']) : $value['link'];
$link = deftrue('e_LANQRY') ? str_replace("?","?".e_LANQRY,$value['link']) : $value['link'];

echo "
<rdf:li rdf:resource=\"".$link."\" />";
Expand All @@ -641,7 +646,7 @@ function buildRss($rss_title)
unset($link);
foreach($this -> rssItems as $value)
{
$link = (e_LANQRY) ? str_replace("?","?".e_LANQRY,$value['link']) : $value['link']; // Multi-language rss links.
$link = deftrue('e_LANQRY') ? str_replace("?","?".e_LANQRY,$value['link']) : $value['link']; // Multi-language rss links.

echo "
<item rdf:about=\"".$link."\">
Expand All @@ -660,7 +665,7 @@ function buildRss($rss_title)
// Atom
case 4:
echo "<?xml version='1.0' encoding='utf-8'?".">\n
<feed xmlns='http://www.w3.org/2005/Atom'>\n";
<feed xmlns='https://www.w3.org/2005/Atom'>\n";
/*
<feed version='0.3'
xmlns='http://purl.org/atom/ns#'
Expand Down

0 comments on commit e2527d5

Please sign in to comment.