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
2023-04-30 21:50:11 +02:00

51 lines
1.3 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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("","'", $title);
//$title = str_replace("…","...", $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("","'", $title);
//$title = str_replace("…","...", $title);
echo "\t\t<a href='".$link."' target='_blank'>".utf8_decode($title)."</a><br />\n";
}
}
}
else
echo "Fichier source introuvable ou corrompu ($source)<br />";
?>