commit 34b834deb2ed23c5e0a7675c322453500094085f
parent eac0a85714d99b2418a08955128bea94ff39c432
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date: Wed, 1 May 2024 15:48:24 +0200
Option to create git-repositories via GET request
Diffstat:
2 files changed, 101 insertions(+), 0 deletions(-)
diff --git a/create_repo/.htaccess b/create_repo/.htaccess
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# SPDX-FileCopyrightText: 2021-2024 JayVii <jayvii[AT]posteo[DOT]de>
+
+# Protected / Private repositories
+AuthType Basic
+AuthName "Private Repositories! You need a password to access them."
+AuthUserFile /etc/apache2/.htpassword
+Require valid-user
diff --git a/create_repo/index.php b/create_repo/index.php
@@ -0,0 +1,93 @@
+<!-- SPDX-License-Identifier: AGPL-3.0-or-later
+ SPDX-FileCopyrightText: 2021-2024 JayVii <jayvii[AT]posteo[DOT]de> -->
+
+<?php
+
+// Fetch Repository Type (may only be "pub" or "priv")
+$repo_type = preg_replace(
+ '/[^a-z]/',
+ '',
+ basename($_GET["type"])
+);
+if ($repo_type != "pub") {
+ $repo_type = "priv";
+}
+
+// Fetch Repository Name
+$repo_name = preg_replace(
+ '/[^a-zA-Z0-9\s\.\,\!\?\:\_\-]/',
+ '',
+ basename($_GET["name"])
+);
+
+// Fetch Repository Description
+$repo_desc = preg_replace(
+ '/[^a-zA-Z0-9\s\.\,\!\?\:\_\-]/',
+ '',
+ $_GET["description"]
+);
+
+// Fetch Repository Owner
+$repo_owner = preg_replace(
+ '/[^a-zA-Z0-9\s\.\,\!\?\:\_\-]/',
+ '',
+ basename($_GET["owner"])
+);
+
+?>
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<meta name="viewport" content="width=device-width, initial-scale=1" />
+<title>Create Repositories</title>
+<link rel="icon" type="image/png" href="../favicon.png" />
+<link rel="stylesheet" type="text/css" href="../style.css" />
+</head>
+<body>
+<table>
+<tr><td><img src="../logo.png" alt="" width="32" height="32" /></td>
+<td><span class="desc">Creating a new Repository</span></td></tr><tr><td></td><td>
+</td></tr>
+</table>
+<hr/>
+<div id="content">
+
+<?php
+
+ # check whether type and name are given (description and owner may be empty)
+ if (is_null($repo_type) || is_null($repo_name)) {
+ $content = "<p id=\"status\"></p>";
+ } else {
+ passthru(
+ $_SERVER['DOCUMENT_ROOT'] . "/bin/git_create_repo.sh " .
+ "\"" . $repo_type . "\" " .
+ "\"" . $repo_name . "\" " .
+ "\"" . $repo_desc . "\" " .
+ "\"" . $repo_owner . "\"",
+ $response
+ );
+ $content = "<p id=\"status\">" . $response . "</p>";
+ }
+
+ echo $content;
+?>
+
+ <form method="GET">
+ <label for="name">Repository Name</label><br>
+ <input type="text" id="name" name="name" maxlength="30" placeholder="my_new_project"><br>
+ <label for="description">Repository Description</label><br>
+ <input type="text" id="description" name="description" maxlength="100" placeholder="This is it about"><br>
+ <label for="owner" >Repository Owner</label><br>
+ <input type="text" id="owner" name="owner"maxlength="30"><br>
+ <span>Repository Type</span><br>
+ <input type="radio" id="priv" name="type"><br>
+ <label for="priv">Private</label><br>
+ <input type="radio" id="pub" name="type"><br>
+ <label for="pub">Public</label><br>
+ <input type="submit" value="Submit">
+ </form>
+</div>
+</body>
+</html>