From 6a3dddfd3ebb4ce41c81c33b0e529c83c7db403c Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Fri, 28 Sep 2018 19:41:58 +0200 Subject: httpdocs/index.php: prepare for other repository types (besides git) --- httpdocs/index.php | 14 ++++++++++---- 1 file 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' ) ) ) -- cgit v1.2.3-70-g09d2