From cf394d1054747ea5334fee6bff6d6a6d20485cb8 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Wed, 20 Feb 2019 10:19:13 +0100 Subject: feeds/feed.php: somewhat functional release feed --- feeds/feed.php | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file 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( + ',\1\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 ""; + print ""; + print ""; + print ""; + print "Arch Linux 32: Releases"; + print ""; + print ""; + print "https://www.archlinux32.org/download/"; + print ""; + print ""; + print "Release ISOs"; + print ""; + print ""; + print ""; + print ""; + print "en-us"; + print ""; + print ""; + print date('Y-m-d', $available_isos[0]['build_date']); + print ""; + foreach ($available_isos as $available_iso) { + print ""; + print ""; + print $available_iso['title']; + print ""; + // TODO: link to iso description (do we want that?) + print ""; + print ""; + print ""; + print date('Y-m-d', $available_iso['release_date']); + print ""; + // TODO: guid + print ""; + // TODO: url=\"https://www.archlinux32.org/iso/2019.02.01/archlinux-2019.02.01-x86_64.iso.torrent\">"; + print ""; + print ""; + } + print ""; + print ""; + + die(); +} if ($uri_parts[0] == 'packages') { -- cgit v1.2.3