website view libs/get-feeds.php @ rev 845

Use links to http://doc.slitaz.org/ for handbook
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat May 14 13:21:28 2011 +0200 (2011-05-14)
parents 111573c244f6
children
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 ?>