summaryrefslogtreecommitdiff
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php128
1 files changed, 80 insertions, 48 deletions
diff --git a/index.php b/index.php
index 862cbba..319f414 100644
--- a/index.php
+++ b/index.php
@@ -67,70 +67,102 @@ print_header("", "home");
<a href="https://news.archlinux32.org/" title="Browse the news archives">Latest News</a>
<span class="arrow"></span>
</h3>
+ <a href="https://archlinux.org/feeds/news/" title="Arch News RSS Feed" class="rss-icon"><img width="16" height="16" src="/static/rss.c5ebdc5318d6.png" alt="RSS Feed" /></a>
<a href="https://news.archlinux32.org/rss.php" title="Arch 32 News RSS Feed" class="rss-icon"><img width="16" height="16" src="/static/rss.c5ebdc5318d6.png" alt="RSS Feed" /></a>
<?php
$ch = curl_init("https://news.archlinux32.org/rss.php");
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
-$news = curl_exec($ch);
+$news32 = curl_exec($ch);
curl_close($ch);
+$news32 = simplexml_load_string($news32);
-$news = simplexml_load_string($news);
+$ch = curl_init("https://www.archlinux.org/feeds/news/");
+curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+$news64 = curl_exec($ch);
+curl_close($ch);
+$news64 = simplexml_load_string($news64);
-if ($news === false) {
+$news = array();
+if ($news32 === false) {
print " <h4>\n";
- print " sorry, news are currently unavailable\n";
+ print " sorry, arch 32 news are currently unavailable\n";
print " </h4>\n";
-
} else {
-
- $news_count = -5;
- foreach($news -> entry as $entry) {
- $news_count ++;
- if ($news_count == 0) {
- print " <h3>\n";
- print " <a href=\"https://news.archlinux32.org/\" title=\"Browse the news archives\">Older News</a>\n";
- print " <span class=\"arrow\"></span>\n";
- print " </h3>\n";
- print " <dl class=\"newslist\">\n";
- }
- if ($news_count < 0) {
- print " <h4>\n";
- print " <a href=\"";
- print $entry -> {'link'} -> attributes() -> {'href'};
- print "\" title=\"View full article: ";
- print $entry -> title;
- print "\">";
- print $entry -> title;
- print "</a>\n";
- print " </h4>\n";
- print " <p class=\"timestamp\">\n";
- print " " . explode('T', $entry -> published)[0] . "\n";
- print " </p>\n";
- print " <div class=\"article-content\">\n";
- print $entry -> content;
- print " </div>\n";
- } else {
- print " <dt>";
- print explode('T', $entry -> published)[0];
- print "</dt>\n";
- print " <dd>\n";
- print " <a href=\"";
- print $entry -> {'link'} -> attributes() -> {'href'};
- print "\" title=\"View full article: ";
- print $entry -> title;
- print "\">";
- print $entry -> title;
- print "</a>\n";
- print " </dd>\n";
- }
+ foreach($news32 -> {'entry'} as $entry) {
+ $news[] = array (
+ 'content' => $entry -> {'content'},
+ 'date' => explode('T', $entry -> {'published'})[0],
+ 'link' => $entry -> {'link'} -> attributes() -> {'href'},
+ 'title' => $entry -> {'title'}
+ );
}
- if ($news_count >= 0) {
- print " </dl>\n";
+}
+if ($news64 === false) {
+ print " <h4>\n";
+ print " sorry, upstream arch news are currently unavailable\n";
+ print " </h4>\n";
+} else {
+ foreach($news64 -> {'channel'} -> {'item'} as $entry) {
+ $news[] = array (
+ 'content' => $entry -> {'description'},
+ 'date' => date('Y-m-d', strtotime($entry -> {'pubDate'})),
+ 'link' => $entry -> {'link'},
+ 'title' => $entry -> {'title'}
+ );
}
+}
+
+function cmp_news_date($a, $b) {
+ return strtotime($b['date']) - strtotime($a['date']);
+}
+usort($news, 'cmp_news_date');
+$news_count = -5;
+foreach($news as $entry) {
+ $news_count ++;
+ if ($news_count == 0) {
+ print " <h3>\n";
+ print " <a href=\"https://news.archlinux32.org/\" title=\"Browse the news archives\">Older News</a>\n";
+ print " <span class=\"arrow\"></span>\n";
+ print " </h3>\n";
+ print " <dl class=\"newslist\">\n";
+ }
+ if ($news_count < 0) {
+ print " <h4>\n";
+ print " <a href=\"";
+ print $entry['link'];
+ print "\" title=\"View full article: ";
+ print $entry['title'];
+ print "\">";
+ print $entry['title'];
+ print "</a>\n";
+ print " </h4>\n";
+ print " <p class=\"timestamp\">\n";
+ print " " . $entry['date'] . "\n";
+ print " </p>\n";
+ print " <div class=\"article-content\">\n";
+ print $entry['content'];
+ print " </div>\n";
+ } else {
+ print " <dt>";
+ print $entry['date'];
+ print "</dt>\n";
+ print " <dd>\n";
+ print " <a href=\"";
+ print $entry['link'];
+ print "\" title=\"View full article: ";
+ print $entry['title'];
+ print "\">";
+ print $entry['title'];
+ print "</a>\n";
+ print " </dd>\n";
+ }
+}
+if ($news_count >= 0) {
+ print " </dl>\n";
}
?>