summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--feeds/feed.php77
1 files changed, 74 insertions, 3 deletions
diff --git a/feeds/feed.php b/feeds/feed.php
index 11cddbe..65fc372 100644
--- a/feeds/feed.php
+++ b/feeds/feed.php
@@ -18,9 +18,80 @@ array_splice(
0, 2
);
-// TODO
-if ($uri_parts[0] == 'releases')
- throw_http_error(501, "Not Implemented", "Sry, the releases-feed is not yet implemented.");
+if ($uri_parts[0] == 'releases') {
+ if (count($uri_parts) != 1)
+ throw_http_error(501, "Not Implemented", '/feeds/' . implode('/',$uri_parts));
+ $available_isos = apcu_fetch('available_isos', $apcu_success);
+ if ($apcu_success == false || true) {
+ $ch = curl_init("https://mirror.archlinux32.org/archisos/");
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ $listing = curl_exec($ch);
+ curl_close($ch);
+ preg_match_all(
+ ',<a href="(archlinux-([0-9]{4}\.[0-9]{2}\.[0-9]{2})-([^.]+)\.iso)">\1</a>\s+(\S+)\s+\S+\s+([0-9]+)\s*\n,',
+ $listing,
+ $matches,
+ PREG_SET_ORDER
+ );
+ $available_isos = array();
+ foreach ($matches as $match) {
+ $available_isos[] = array(
+ 'file' => $match[1],
+ 'title' => $match[2] . '-' . $match[3],
+ 'build_date' => strtotime(str_replace('.', '-', $match[2])),
+ 'build_type' => $match[3],
+ 'release_date' => $match[4],
+ 'size' => $match[5]
+ );
+ }
+ apcu_store('available_isos', $available_isos, 3600);
+ }
+
+ header('Content-Type: application/rss+xml; charset=utf-8');
+ print "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
+ print "<rss version=\"2.0\">";
+ print "<channel>";
+ print "<title>";
+ print "Arch Linux 32: Releases";
+ print "</title>";
+ print "<link>";
+ print "https://www.archlinux32.org/download/";
+ print "</link>";
+ print "<description>";
+ print "Release ISOs";
+ print "</description>";
+ print "<atom:link href=\"https://www.archlinux32.org/feeds/releases/\" rel=\"self\">";
+ print "</atom:link>";
+ print "<language>";
+ print "en-us";
+ print "</language>";
+ print "<lastBuildDate>";
+ print date('Y-m-d', $available_isos[0]['build_date']);
+ print "</lastBuildDate>";
+ foreach ($available_isos as $available_iso) {
+ print "<item>";
+ print "<title>";
+ print $available_iso['title'];
+ print "</title>";
+ // TODO: link to iso description (do we want that?)
+ print "<description>";
+ print "</description>";
+ print "<pubDate>";
+ print date('Y-m-d', $available_iso['release_date']);
+ print "</pubDate>";
+ // TODO: guid
+ print "<enclosure length=\"";
+ print date('Y-m-d', $available_iso['size']);
+ print "\" type=\"application/x-bittorrent\">";
+ // TODO: url=\"https://www.archlinux32.org/iso/2019.02.01/archlinux-2019.02.01-x86_64.iso.torrent\">";
+ print "</enclosure>";
+ print "</item>";
+ }
+ print "</channel>";
+ print "</rss>";
+
+ die();
+}
if ($uri_parts[0] == 'packages') {