From b66553765b04eb94f84dc96a73b14d369ec9b6f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Thu, 7 Dec 2017 20:40:13 +0100 Subject: [PATCH] repo.php: if no repo parameter is given, list repositories --- repo.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/repo.php b/repo.php index d970f916..f876f794 100644 --- a/repo.php +++ b/repo.php @@ -13,10 +13,30 @@ if (!isset($repositories)) { ); } -if (isset($_REQUEST['repo'])) { - $repo = $_REQUEST['repo']; +if (!isset($_REQUEST['repo'])) { + Header("Content-Type: application/json; charset=utf-8"); + print '{'; + + $c = 0; + foreach ($repositories as $repoId => $repoData) { + print $c++ ? ',' : ''; + $d = array(); + foreach (array('name') as $k) { + if (array_key_exists($k, $repoData)) { + $d[$k] = $repoData[$k]; + } + } + + print json_encode($repoId) . ':'; + print json_encode($d, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_FORCE_OBJECT); + } + + print '}'; + exit(0); } +$repo = $_REQUEST['repo']; + if (!array_key_exists($repo, $repositories)) { Header("HTTP/1.1 404 Repository not found"); exit(0);