summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-09-28 19:41:58 +0200
committerErich Eckner <git@eckner.net>2018-09-28 19:41:58 +0200
commit6a3dddfd3ebb4ce41c81c33b0e529c83c7db403c (patch)
tree3ef7d3a1d26807178da429251286be6a0e737257
parentc23c7ee7e673de726b49a1018fcccce7f35a43f0 (diff)
downloadarchive-server-6a3dddfd3ebb4ce41c81c33b0e529c83c7db403c.tar.xz
httpdocs/index.php: prepare for other repository types (besides git)
-rw-r--r--httpdocs/index.php14
1 files changed, 10 insertions, 4 deletions
diff --git a/httpdocs/index.php b/httpdocs/index.php
index 7879034..478db2d 100644
--- a/httpdocs/index.php
+++ b/httpdocs/index.php
@@ -7,7 +7,13 @@ if (isset($_GET['r'])) {
if (base64_decode($_GET['r'],true)===false)
die('Invalid base64');
- if (!is_dir($work_dir . 'repositories/' . $_GET['r'])) {
+ if (!isset($_GET['t']))
+ die('Repository type not given');
+
+ if ($_GET['t']!='git')
+ die('Repository type not implemented');
+
+ if (!is_dir($work_dir . 'repositories/' . $_GET['t'] . '/' . $_GET['r'])) {
$wish_list = fopen($work_dir . 'wish-list','a');
if ($wish_list === false)
die('Cannot open wish-list');
@@ -60,7 +66,7 @@ if (isset($_GET['r'])) {
);
if (trim(shell_exec(
- 'GNUPGHOME="' . $work_dir . 'gnupg" git -C "' . $work_dir . 'repositories/' . $_GET['r'] . '" verify-tag --raw "' . $commit_identifier . '" 2>&1 | ' .
+ 'GNUPGHOME="' . $work_dir . 'gnupg" git -C "' . $work_dir . 'repositories/' . $_GET['t'] . '/' . $_GET['r'] . '" verify-tag --raw "' . $commit_identifier . '" 2>&1 | ' .
'grep -c "\[GNUPG:\] VALIDSIG ' . $key_regex . ' "'
)) == '0')
die('Commit ' . $commit_identifier . ' is not signed by ' . $_GET['valid_keys']);
@@ -76,7 +82,7 @@ if (isset($_GET['r'])) {
$prefix = '';
}
$handle = popen(
- 'git -C "../work/repositories/' . $_GET['r'] . '" archive' . $prefix . ' "' . $commit_identifier . '" | ' .
+ 'git -C "../work/repositories/' . $_GET['t'] . '/' . $_GET['r'] . '" archive' . $prefix . ' "' . $commit_identifier . '" | ' .
'gzip -nc',
'r'
);
@@ -104,7 +110,7 @@ print
explode(
"\n",
shell_exec(
- 'ls "' . $work_dir . 'repositories"'
+ 'find "' . $work_dir . 'repositories" -mindepth 2 -maxdepth 2 -printf "%f\n" | sort'
)
)
)