index : archweb32 | |
Archlinux32 website | gitolite user |
summaryrefslogtreecommitdiff |
author | Erich Eckner <git@eckner.net> | 2019-02-08 11:20:36 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2019-02-08 11:20:36 +0100 |
commit | b4fcb4c27b058dd417ef1a225915ef305493bf7f (patch) | |
tree | f51afa95295334c9bc434bb4a30ce2083a8535f8 /feeds | |
parent | 1f75ab18a6d7d3bb24aaa863185afb30b31ee61a (diff) |
-rw-r--r-- | feeds/feed.php | 125 |
diff --git a/feeds/feed.php b/feeds/feed.php index 040c36d..177071b 100644 --- a/feeds/feed.php +++ b/feeds/feed.php @@ -1,3 +1,126 @@ <?php -echo "sry, this is not yet implemented: " . $_SERVER['REQUEST_URI']; +require_once "../init.php"; + +require_once BASE . "/lib/mysql.php"; + +$uri_parts = explode('/', $_SERVER['REQUEST_URI']); + +if ($uri_parts[0] != '' || $uri_parts[1] != 'feeds') + throw_http_error(422, 'Unprocessable Entity'); + +$last = array_pop($uri_parts); +if ($last != '') + array_push($uri_parts, $last); + +array_splice( + $uri_parts, + 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] == 'packages') { + + array_splice( + $uri_parts, + 0, 1 + ); + +// TODO: implement "added" and "removed" - but how? +// $actions = array('' => '', 'added' => 'added', 'removed' => 'removed'); + $actions = array('' => ''); + $archs = array('all' => 'all'); + $result = mysql_run_query( + "SELECT DISTINCT `architectures`.`name` FROM `architectures`" . + mysql_join_architectures_repositories() . + " WHERE `repositories`.`is_on_master_mirror`" . + " ORDER BY `name`" + ); + while ($row = $result -> fetch_assoc()) + $archs[$row['name']] = $row['name']; + $repos = array('' => ''); + $result = mysql_run_query( + "SELECT DISTINCT `repositories`.`name` FROM `repositories` WHERE `repositories`.`is_on_master_mirror` ORDER BY `name`" + ); + while ($row = $result -> fetch_assoc()) + $repos[$row['name']] = $row['name']; + + if (count($uri_parts) > 0 && array_key_exists($uri_parts[0], $actions)) { + $action = $uri_parts[0]; + array_splice( + $uri_parts, + 0, 1 + ); + } + else + $action = ''; + + if (count($uri_parts) > 0) { + if (!array_key_exists($uri_parts[0], $archs)) + throw_http_error(501, "Not Implemented", implode('/',$uri_parts)); + $arch = $uri_parts[0]; + array_splice( + $uri_parts, + 0, 1 + ); + } + else + $arch = ''; + + if (count($uri_parts) > 0) { + if (!array_key_exists($uri_parts[0], $repos)) + throw_http_error(501, "Not Implemented", implode('/',$uri_parts)); + $repo = $uri_parts[0]; + array_splice( + $uri_parts, + 0, 1 + ); + } + else + $repo = ''; + + if (count($uri_parts) != 0) + throw_http_error(501, "Not Implemented", implode('/',$uri_parts)); + +# $result = mysql_run_query( +# TODO +# ); + + print "<rss version=\"2.0\">"; + print "<channel>"; + print "<title>"; + print "Arch Linux 32: "; + switch ($action) { + case '': + print "Recent package updates"; + break; + case 'added': + print "Recent added packages"; + break; + case 'removes': + print "Recent removed packages"; + break; + } + if ($arch != '') + print " (" . $arch; + if ($repo != '') + print " [" . $repo . "]"; + if ($arch != '') + print ")"; + print "</title>"; + print "<link>"; + print "https://archlinux32.org" . $_SERVER['REQUEST_URI']; + print "</link>"; + print "<description>"; + print "</description>"; +# TODO + print "</channel>"; + + die(); + +} + +throw_http_error(501, "Not Implemented"); |