<?php
error_reporting(E_ALL | E_STRICT);
ini_set("track_errors", "On");
$INC = "../inc";
require_once($INC . "/keys.inc.php");
require_once($INC . "/db/struct.inc.php");
rg_log_set_file("keys.log");
$rg_sql_debug = 1;
$db = rg_sql_open("dbname=trg");
if ($db === FALSE) {
echo "Cannot create a database (" . rg_sql_error() . ")!\n";
exit(1);
}
// needed for state table
$ignore_errors = FALSE;
$drop_tables = TRUE;
$old_schema_ver = 0;
$r = rg_sql_struct_run($db, $ignore_errors, $drop_tables, $old_schema_ver);
if ($r === FALSE) {
echo "Cannot create structure!\n";
exit(1);
}
// insert a key 1
$rg_ui = array("uid" => 1, "is_admin" => 0);
$key = "aaa 'bbb' first_key";
$key_id1 = rg_keys_add($db, $rg_ui, $key);
if ($key_id1 === FALSE) {
echo "Cannot add key 1 (" . rg_keys_error() . ")!\n";
exit(1);
}
// insert a key 2
$rg_ui = array("uid" => 2, "is_admin" => 0);
$key = "aaa 'bbb' second_key";
$key_id2 = rg_keys_add($db, $rg_ui, $key);
if ($key_id2 === FALSE) {
echo "Cannot add key 2 (" . rg_keys_error() . ")!\n";
exit(1);
}
// test key file generation
$rg_scripts = "/a";
$rg_keys_file = "afile.txt";
$rg_ssh_paras = "ssh1,ssh2,ssh3";
$r = rg_keys_regen($db);
if ($r === FALSE) {
echo "Cannot regenerate keys (" . rg_keys_error() . ")!\n";
exit(1);
}
$c = @file_get_contents("afile.txt");
if ($c === FALSE) {
echo "Cannot regenerate file: " . rg_keys_error() . "!\n";
exit(1);
}
$e = "command=\"/usr/bin/php " . $rg_scripts . "/scripts/remote.php 1\"," . $rg_ssh_paras . " aaa 'bbb' first_key\n"
. "command=\"/usr/bin/php " . $rg_scripts . "/scripts/remote.php 2\"," . $rg_ssh_paras . " aaa 'bbb' second_key\n";
if (strcmp($c, $e) != 0) {
echo "Generated file does not seems OK\n";
exit(1);
}
@unlink("afile.txt");
// delete a key
$rg_ui = array("uid" => 1, "is_admin" => 0);
$r = rg_keys_remove($db, $rg_ui, $key_id1);
if ($r === FALSE) {
echo "Cannot remove key (" . rg_keys_error() . ")!\n";
exit(1);
}
rg_sql_close($db);
echo "keys: OK\n";
?>
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