<?php
error_reporting(E_ALL);
//phpinfo();
$_s = microtime(TRUE);
$INC = dirname(__FILE__) . "/../inc";
$ROOT = dirname(__FILE__);
$THEME = $ROOT . "/themes/default";
require_once("/etc/rg/config.php");
require_once($INC . "/log.inc.php");
include_once($INC . "/db.inc.php");
include_once($INC . "/user.inc.php");
include_once($INC . "/repo.inc.php");
include_once($INC . "/keys.inc.php");
include_once($INC . "/token.inc.php");
rg_log_set_file("/tmp/rg_web.log");
$rg_sql_debug = $rg_db_debug;
// TODO: make subop and subsubop as strings
$op = rg_var_str("op");
$subop = rg_var_uint("subop");
$subsubop = rg_var_uint("subsubop");
$doit = rg_var_uint("doit");
$sid = rg_var_re("sid", "/[^A-Za-z0-9]/");
$token = rg_var_re("token", "/[^A-Za-z0-9]/");
rg_log("IP: " . @$_SERVER['REMOTE_ADDR']);
rg_log("_REQUEST: " . trim(print_r($_REQUEST, TRUE)));
rg_log("_COOKIE: " . trim(print_r($_COOKIE, TRUE)));
rg_log("Start! op=$op/$subop/$subsubop, doit=$doit, sid=$sid...");
$head = "";
$head .= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\""
. " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
$head .= "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
$head .= "<head>\n";
$head .= " <title>RocketGit</title>\n";
$head .= " <meta content=\"text/html; charset=UTF-8\" http-equiv=\"content-type\" />\n";
$css = preg_replace("/\n/", " ", @file_get_contents($THEME . "/main.css"));
$head .= " <style type=\"text/css\">" . $css . "</style>\n";
$head .= "</head>\n";
$head .= "<body>\n";
// database connection
$db = rg_sql_open($rg_db);
if ($db === FALSE)
die("Cannot open database!");
rg_user_login_by_sid($db, $sid, $rg_ui);
rg_log("After login_by_sid, rg_ui=" . print_r($rg_ui, TRUE));
$body = "";
// Chain dispatching
do {
include($INC . "/dispatch/dispatch.php");
} while (strcmp($op, "") != 0);
$tail = "</body>\n";
$tail .= "</html>\n";
// menu
$amenu = array(
"login" => array("text" => "Login"),
"personal" => array("text" => "Personal"),
"repo" => array("text" => "My repositories"),
"keys" => array("text" => "SSH keys"),
"admin" => array("text" => "Admin", "needs_admin" => 1),
"logout" => array("text" => "Logout")
);
$menu = "";
$add = "";
foreach ($amenu as $_op => $_info) {
if (isset($_info['needs_admin']) && ($rg_ui['is_admin'] == 0))
continue;
$_text = $_info['text'];
if (strcmp($_op, $op) == 0) {
$menu .= $add . "[$_text]\n";
} else {
$menu .= $add . "[<a href=\""
. rg_re_url($_op) . "\">$_text</a>]\n";
}
$add = " ";
}
if (isset($rg_ui['user']))
$menu .= " [" . $rg_ui['user'] . "]\n";
$menu .= "<br />\n";
echo $head . $menu . $body . $tail;
$_diff = sprintf("%u", (microtime(TRUE) - $_s) * 1000);
rg_log("Done in $_diff ms.");
?>
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