website view lib/get-feeds.php @ rev 1018
da: fix header, fr, pt: lang.php
author | Paul Issott <paul@slitaz.org> |
---|---|
date | Sat Mar 31 00:14:07 2012 +0100 (2012-03-31) |
parents | 304b3f1894f7 |
children | d21256a7ed5b |
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->guid' 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 // Read Forum Feed
63 function get_feed_forum($feed) {
64 $cache = '/var/cache/slitaz/website';
65 $entries = 4;
66 // have the page displayed even if any xml file
67 if ( ! file_exists("$cache/$feed")) {
68 echo "</p>\n<div>\n";
69 echo "Missing feed: $cache/$feed\n" . "</div>\n";
70 }
71 else {
72 $content = file_get_contents("$cache/$feed");
73 $x = new SimpleXmlElement($content);
74 $count = 0;
75 // We look for last item, channel may not have a PubDate*
76 $up = ($x->channel->item->pubDate);
77 echo "<span>- Updated: " . substr("$up", 5, 17) . "</span>\n";
78 echo "</p>\n<div>\n<ul>\n";
79 foreach($x->channel->item as $entry) {
80 $count = $count + 1;
81 echo " <li><a href='$entry->link' title='$entry->title'>" .
82 $entry->title . "</a></li>\n";
83 if ($count == $entries) {
84 break;
85 }
86 }
87 echo "</ul>\n";
88 }
89 }
91 ?>