website view lib/get-feeds.php @ rev 908

Remove freenode.ver (we are now an official group on Freenode)
author Christophe Lincoln <pankso@slitaz.org>
date Thu Mar 08 02:47:12 2012 +0100 (2012-03-08)
parents 06cbe83c458a
children 304b3f1894f7
line source
1 <?php
3 // Read RSS Feed
4 function get_feed($feed) {
5 $cache = '/var/cache/slitaz/website';
6 $entries = 4;
7 // have the page displayed even if any xml file
8 if ( ! file_exists("$cache/$feed")) {
9 echo "</p>\n<div>\n";
10 echo "Missing feed: $cache/$feed\n" . "</div>\n";
11 }
12 else {
13 $content = file_get_contents("$cache/$feed");
14 $x = new SimpleXmlElement($content);
15 $count = 0;
16 // We look for last item, channel may not have a PubDate*
17 $up = ($x->channel->item->pubDate);
18 echo "<span>- Updated: " . substr("$up", 5, 17) . "</span>\n";
19 echo "</p>\n<div>\n<ul>\n";
20 foreach($x->channel->item as $entry) {
21 $count = $count + 1;
22 echo " <li><a href='$entry->link' title='$entry->title'>" .
23 $entry->title . "</a></li>\n";
24 if ($count == $entries) {
25 break;
26 }
27 }
28 echo "</ul>\n";
29 }
30 }
32 // Read Blog RSS Feed
33 function get_feed_blog($feed) {
34 $cache = '/var/cache/slitaz/website';
35 $entries = 4;
36 // have the page displayed even if any xml file
37 if ( ! file_exists("$cache/$feed")) {
38 echo "Missing feed: $cache/$feed\n" . "</div>\n";
39 }
40 else {
41 $content = file_get_contents("$cache/$feed");
42 $x = new SimpleXmlElement($content);
43 $count = 0;
44 // We look for last item, channel may not have a PubDate*
45 $up = ($x->channel->item->pubDate);
47 echo "<ul>\n";
48 foreach($x->channel->item as $entry) {
49 $count = $count + 1;
50 echo " <li><strong><a href='$entry->link' title='$entry->title'>" .
51 $entry->title . "</strong></a>\n";
52 echo "<span>- " . substr("$entry->pubDate", 5, 17) . "</span>\n";
53 echo "<p>$entry->description</p>\n</li>";
54 if ($count == $entries) {
55 break;
56 }
57 }
58 echo "</ul>\n";
59 }
60 }
62 ?>