n/oldblog
Archived
1
0
Fork 0
This repository has been archived on 2024-02-13. You can view files and clone it, but cannot push or open issues or pull requests.
oldblog/modules/rssparser.php

52 lines
1.3 KiB
PHP
Raw Normal View History

2023-04-30 21:28:42 +02:00
<?php
extract($themeset, EXTR_OVERWRITE);
$rootdir="/home/www/website/backends/xml/";
global $nbnews;
global $titre;
if (file_exists($rootdir.$source) && filesize($rootdir.$source) != 0)
{
//$rss = simplexml_load_string(utf8_encode(implode(" ",file($rootdir.$source))));
$rss = simplexml_load_file($rootdir.$source);
if (!($rss))
echo "failed to decode XML for $source";
if (!isset($nbnews))
{
//$nbnews = $index_title;
$nbnews = 10;
}
$ga = 0;
if ($rss->channel->item->link)
{
while($ga<=$nbnews-1)
{
$link = str_replace("&","&amp;", $rss->channel->item[$ga]->link);
$title = $rss->channel->item[$ga++]->title;
//$title = str_replace("& ","&amp;", $title);
//$title = str_replace("<22>","'", $title);
//$title = str_replace("<22>","...", $title);
echo "\t\t<a href='".$link."' target='_blank'>".utf8_decode($title)."</a><br />\n";
}
}
else
{
while($ga<=$nbnews-1)
{
$link = str_replace("&","&amp;", $rss->item[$ga]->link);
$title = $rss->item[$ga++]->title;
//$title = str_replace("& ","&amp;", $title);
//$title = str_replace("<22>","'", $title);
//$title = str_replace("<22>","...", $title);
echo "\t\t<a href='".$link."' target='_blank'>".utf8_decode($title)."</a><br />\n";
}
}
}
else
echo "Fichier source introuvable ou corrompu ($source)<br />";
?>