/admin/init.php (c8c889bb81eb7d60223aa5db88dd9f78cfe2034d) (1967 bytes) (mode 100644) (type blob)
<?php
// This is executed at the first instalation.
// Or, if you want to create another admin user.
error_reporting(E_ALL);
ini_set("track_errors", "On");
require_once("/etc/rocketgit/config.php");
$INC = dirname(__FILE__) . "/../inc";
require_once($INC . "/util.inc.php");
require_once($INC . "/log.inc.php");
require_once($INC . "/sql.inc.php");
require_once($INC . "/struct.inc.php");
require_once($INC . "/state.inc.php");
rg_log_set_file("init.log");
$db = rg_sql_open($rg_sql);
if ($db === FALSE) {
echo "Internal error (" . rg_sql_error() . ")!\n";
exit(1);
}
$r = rg_sql_struct_update_if_needed($db, 0);
if ($r !== TRUE) {
echo "Cannot init structure. Check the logs!\n";
exit(1);
}
// creating admin user
$uid = 0;
$username = "admin";
$email = $rg_admin_email;
$is_admin = 1;
$disk_quota_mb = 0;
$rights = rg_rights_all("user");
$session_time = 3600;
$confirm_token = "";
while (1) {
$username0 = readline("User [$username]: ");
if (!empty($username0))
$username = $username0;
$email0 = readline("E-mail [$email]: ");
if (!empty($email0))
$email = $email0;
while (1) {
$pass = readline("Password: ");
$pass2 = readline("Password (confirmation): ");
if (strcmp($pass, $pass2) != 0) {
echo "Passwords mismatch!\n";
continue;
}
break;
}
$r = rg_user_info($db, $uid, $username, "" /* email */);
if ($r['ok'] != 1) {
echo "Error looking up user $username (" . rg_user_error() . ")!\n";
exit(1);
}
if ($r['exists'] == 1) {
echo "User $username already exists. Try another one!\n";
continue;
}
$r = rg_user_edit($db, $uid, $username, $email, $pass, $is_admin,
$disk_quota_mb, $rights, $session_time, $confirm_token);
if ($r !== TRUE) {
echo "Cannot create user (" . rg_user_error() . ")!\n";
continue;
}
break;
}
// Store the timestamp of the first install
$first_install = rg_state_get($db, "first_install");
if ($first_install == 0)
rg_state_set($db, "first_install", time());
echo "Done!\n";
?>
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
26 |
85c946cb687f42a070d70d4c9ce8b528b1cc1559 |
.exclude |
100644 |
blob |
87 |
bf1d9081b000eeaff7698f3e4dfae542742e473f |
.gitignore |
100644 |
blob |
35147 |
94a9ed024d3859793618152ea559a168bbcbb5e2 |
LICENSE |
100644 |
blob |
1188 |
30b2a355d57f534d1cc68cd325856e05f5e0dc51 |
Makefile.in |
100644 |
blob |
1990 |
ebe4e09a5e2c9f0fc756c60201a9e91383b0f58e |
README |
100644 |
blob |
11349 |
94c277449633ed17b469596f5e9d12e3542abead |
TODO |
040000 |
tree |
- |
a21c67d61a01e934223da1bb0bd5e1953c025f78 |
admin |
040000 |
tree |
- |
76a16691bc48bbe42bdc63a6d1244d2d49e4da2d |
artwork |
100755 |
blob |
23 |
d33bb6c4ecdce1390ce1db3c79ea3b93e22ea755 |
configure |
100755 |
blob |
13311 |
a6e2825b35f915e6d64c2a981fa3b6266b2bf587 |
duilder |
100644 |
blob |
268 |
3923b9deec801f5f28dc99655e9589aec171c24d |
duilder.conf |
040000 |
tree |
- |
5b0fa0789b479882ae207c2793b484bdc3256790 |
hooks |
040000 |
tree |
- |
691c441ce1291afc91a0d9b292845226847783ee |
inc |
100644 |
blob |
1786 |
de959fd88880e4a3633df5bff53350f41c1cab22 |
rocketgit.spec.in |
040000 |
tree |
- |
7a4fae61c69688ddd13a9d144d5d9b63c38c8a83 |
root |
040000 |
tree |
- |
de3787c6c0e011e858cff1fca4527a3a7c287c1c |
samples |
040000 |
tree |
- |
7694937b7375fe70a32ac96aa2c751f955e37a6a |
scripts |
040000 |
tree |
- |
283d4926c8688721e1e992c001eefde5804269ab |
tests |
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://rocketgit.com/user/catalinux/rocketgit
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/rocketgit
Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/rocketgit
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main