xaizek / rocketgit (License: AGPLv3+) (since 2018-12-09)
Light and fast Git hosting solution suitable to serve both as a hub or as a personal code storage with its tickets, pull requests, API and much more.
<root> / inc / keys / keys.php (f78451da42a5a6cbcd51e20dfef78dec6eaac601) (992B) (mode 100644) [raw]
<?php
rg_log("/inc/keys/keys");

$_keys = "";

if ($rg_ui['uid'] == 0) {
	$_keys .= "You do not have access here!";
	return;
}

$key = rg_var_str("key");
$key = preg_replace("|[^/A-Za-z0-9 @/+_\.\=,-]|", "", $key);
$key_id = rg_var_uint("key_id");

// menu
$_url = rg_re_url($op);

$second_menu = array(
	"add_key" => array(
		"text" => "Add key",
		"url" => "&amp;subop=1"
		),
	"list_keys" => array(
		"text" => "List keys",
		"url" => "&amp;subop=2"
		)
);

$_body = "";
$errmsg = array();

switch ($subop) {
case 1: // add
	if ($doit == 1) {
		$_r = rg_keys_add($db, $rg_ui, $key);
		if ($_r === FALSE)
			$_body .= rg_keys_error();
		else
			$_body = "OK!";
	}

	include($INC . "/keys/add.form.php");
	$_body .= $_form;
	break;

case 2: // list
	if (rg_var_uint("delete") == 1) {
		if (rg_keys_remove($db, $rg_ui, $key_id) === FALSE)
			$_body .= "Bad: " . rg_keys_error() . "!<br />\n";
	}

	$_body .= rg_keys_list($db, $rg_ui, $_url . "&amp;subop=2");
	break;

}

$_keys .= $_body;
?>
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/rocketgit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master