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

Add de/doc/index.php, lib/html/header.de.html, update lib/html/nav.de.html (thanks HGT)
author Paul Issott <paul@slitaz.org>
date Sun Mar 19 17:52:44 2017 +0000 (2017-03-19)
parents 8585804d4b9a
children 7d0c505926c6
line source
1 <?php
3 function updated() {
4 $addr = explode('/', $_SERVER['REQUEST_URI']);
5 $lang = $addr[1];
6 $native = array(
7 "cn"=>"- 更新于: ",
8 "da"=>"- Opdateret den: ",
9 "de"=>"- Aktualisiert am: ",
10 "en"=>"- Updated: ",
11 "es"=>"- Actualizado el: ",
12 "fr"=>"- Mis à jour le: ",
13 "id"=>"- Diperbarui pada: ",
14 "it"=>"- Aggiornato il: ",
15 "pt"=>"- Atualizado em: ",
16 "ru"=>"— Обновлено: "
17 );
18 if (!isset($native[$lang]))
19 $lang = "en";
20 return $native[$lang];
21 }
23 // Read RSS Feed
24 function get_feed($feed) {
25 $cache = '/var/cache/slitaz/website';
26 $entries = 4;
27 // no follow all links, but hg commits
28 if ($feed == "wok.xml")
29 $nofollow = "";
30 else
31 $nofollow = " rel='nofollow'";
32 // have the page displayed even if any xml file
33 if ( ! file_exists("$cache/$feed")) {
34 echo "</p>\n<div>\n";
35 echo "Missing feed: $cache/$feed\n";
36 }
37 else {
38 $content = file_get_contents("$cache/$feed");
39 $x = new SimpleXmlElement($content);
40 $count = 0;
41 // We look for last item, channel may not have a PubDate*
42 $up = ($x->channel->item->pubDate);
43 echo "<span>" . updated() . substr("$up", 5, 17) . "</span>\n";
44 echo "</p>\n<div>\n<ul>\n";
45 foreach($x->channel->item as $entry) {
46 $count = $count + 1;
47 echo " <li><a href='$entry->guid'" . $nofollow . ">" .
48 $entry->title . "</a></li>\n";
49 if ($count == $entries) {
50 break;
51 }
52 }
53 echo "</ul>\n";
54 }
55 }
57 // Read Blog RSS Feed
58 function get_feed_blog($feed) {
59 $cache = '/var/cache/slitaz/website';
60 $entries = 4;
61 // have the page displayed even if any xml file
62 if ( ! file_exists("$cache/$feed")) {
63 echo "<div>\n";
64 echo "Missing feed: $cache/$feed\n";
65 echo "</div>\n";
66 }
67 else {
68 $content = file_get_contents("$cache/$feed");
69 $x = new SimpleXmlElement($content);
70 $count = 0;
71 // We look for last item, channel may not have a PubDate*
72 $up = ($x->channel->item->pubDate);
74 echo "<ul>\n";
75 foreach($x->channel->item as $entry) {
76 $count = $count + 1;
77 echo " <li><a href='$entry->link'><strong>" .
78 $entry->title . "</strong></a>\n";
79 echo "<span>- " . substr("$entry->pubDate", 5, 17) . "</span>\n";
80 echo "<p>$entry->description</p>\n</li>";
81 if ($count == $entries) {
82 break;
83 }
84 }
85 echo "</ul>\n";
86 }
87 }
89 // Read Forum Feed
90 function get_feed_forum($feed) {
91 $cache = '/var/cache/slitaz/website';
92 $entries = 4;
93 // have the page displayed even if any xml file
94 if ( ! file_exists("$cache/$feed")) {
95 echo "</p>\n<div>\n";
96 echo "Missing feed: $cache/$feed\n";
97 }
98 else {
99 $content = file_get_contents("$cache/$feed");
100 $x = new SimpleXmlElement($content);
101 $count = 0;
102 // We look for last item, channel may not have a PubDate*
103 $up = ($x->channel->item->pubDate);
104 echo "<span>" . updated() . substr("$up", 5, 17) . "</span>\n";
105 echo "</p>\n<div>\n<ul>\n";
106 foreach($x->channel->item as $entry) {
107 $count = $count + 1;
108 echo " <li><a href='$entry->link' rel='nofollow'>" .
109 $entry->title . "</a></li>\n";
110 if ($count == $entries) {
111 break;
112 }
113 }
114 echo "</ul>\n";
115 }
116 }
118 ?>