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.
Commit 31ccba6e43e02c34fa2139fe352c3799feecd249

Invites now accepts a file as the body of the e-mail and php_errormsg fixes.
Author: Catalin(ux) M. BOIE
Author date (UTC): 2015-05-09 04:17
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2015-05-09 04:17
Parent(s): 00828bd5eaf5ad08ff7736a6c5627c21179a8e20
Signing key:
Tree: 9b143a0751004fca30a0b4d277291b70fec1e049
File Lines added Lines deleted
AUTHORS 1 0
TODO 3 13
inc/admin.inc.php 34 4
inc/fixes.inc.php 3 0
inc/git.inc.php 5 0
inc/keys.inc.php 1 0
inc/mr.inc.php 4 0
inc/repo.inc.php 2 0
inc/sql.inc.php 1 0
inc/user.inc.php 5 0
inc/util.inc.php 14 4
root/themes/default/admin/invites/invites.html 19 4
root/themes/default/admin/invites/sent.html 1 1
root/themes/default/download-vm.html 62 2
root/themes/default/features.html 1 1
scripts/cron.php 1 0
tests/util.php 14 0
File AUTHORS changed (mode: 100644) (index df01c63..e14603f)
... ... Ioan Albescu
8 8 Nicolae Tipeiu Nicolae Tipeiu
9 9 Bogdan Vatra Bogdan Vatra
10 10 James Dean James Dean
11 Seby Marinescu (VMware ESX help)
File TODO changed (mode: 100644) (index 537c0a4..32c9903)
1 1 == Where I stopped last time == == Where I stopped last time ==
2 [ ] VirtualBox instalation
3 - Go to https://www.virtualbox.org/wiki/Downloads, download a proper
4 executable and install it.
5 - Download ovf/vmdk
6 - Start VirtualBox
7 "New"
8 Set the name "rocketgit1-fedora21-i386", Type: "Linux", Version: "Fedora (32bit)
9 256MiB RAM
10 "Use an existing virtual hard drive file, select vmdk
11 "Create"
12 "Settings -> Network -> Adapter 1: Attached to: Host-only Adapter -> OK
13 "Start"
14 login, find out the ip address, go to browser and access it
15 2 [ ] [ ]
16 3
17 4 == BEFORE NEXT RELEASE == == BEFORE NEXT RELEASE ==
5 [ ] Saving fields in forms when session exired to be reused next time.
6 [ ] Compression off for ssh because objects are already compressed?
7 [ ] Add a random token in header to prevent watermarking (this is the name?).
18 8 [ ] User home page link is missing from top bar! [ ] User home page link is missing from top bar!
19 9 [ ] Add "Spread the word!" on website. [ ] Add "Spread the word!" on website.
20 10 [ ] Give up on submenu1/2 and integrate them when needed? [ ] Give up on submenu1/2 and integrate them when needed?
File inc/admin.inc.php changed (mode: 100644) (index 1127ab1..7cdd4f1)
... ... function rg_admin_invite($db, $event)
44 44 */ */
45 45 function rg_admin_invite_one($db, $event) function rg_admin_invite_one($db, $event)
46 46 { {
47 global $rg_admin_email;
47 global $rg_admin_email, $rg_admin_name;
48
49 $admin_name = "=?UTF-8?B?"
50 . base64_encode($rg_admin_name) . "?=";
48 51
49 52 $rg = array(); $rg = array();
50 53 $subject = preg_replace('/{NAME}/', $event['name'], $event['subject']); $subject = preg_replace('/{NAME}/', $event['name'], $event['subject']);
51 54 $subject = "=?UTF-8?B?" . base64_encode(trim($subject)) . "?="; $subject = "=?UTF-8?B?" . base64_encode(trim($subject)) . "?=";
52 55 $header = rg_template("mail/common.head.txt", $rg); $header = rg_template("mail/common.head.txt", $rg);
56 $header = trim($header);
57 $header .= "\nFrom: $admin_name <" . $rg_admin_email . ">";
58 rg_log_ml("DEBUG: header=$header");
53 59 $body = preg_replace('/{NAME}/', $event['name'], $event['body']); $body = preg_replace('/{NAME}/', $event['name'], $event['body']);
54 60
55 61 $r = mail($event['email'], $subject, $body, $header, $r = mail($event['email'], $subject, $body, $header,
 
... ... function rg_admin_invites_high_level($db, $rg)
81 87 if (rg_var_int("doit") == 0) if (rg_var_int("doit") == 0)
82 88 break; break;
83 89
84 $inv['list'] = rg_var_str("inv::list");
85 $inv['subject'] = rg_var_str("inv::subject");
86 $inv['body'] = rg_var_str("inv::body");
90 $inv['list'] = rg_var_str('inv::list');
91 $inv['subject'] = rg_var_str('inv::subject');
92 $inv['body'] = rg_var_str('inv::body');
93
94 while (isset($_FILES['inv::file'])) {
95 if (empty($_FILES['inv::file']['tmp_name']))
96 break;
97
98 rg_log_ml("DEBUG: we have a file uploaded: " . print_r($_FILES, TRUE));
99 if ($_FILES['inv::file']['error'] !== UPLOAD_ERR_OK) {
100 $errmsg[] = "error in upload (1); try again";
101 break;
102 }
103
104 if (!is_uploaded_file($_FILES['inv::file']['tmp_name'])) {
105 $errmsg[] = "error in upload (2); try again";
106 break;
107 }
108
109 $inv['body'] = @file_get_contents($_FILES['inv::file']['tmp_name']);
110 if ($inv['body'] === FALSE) {
111 $errmsg[] = "error in upload (3); try again";
112 break;
113 }
114
115 break;
116 }
87 117
88 118 if (!rg_valid_referer()) { if (!rg_valid_referer()) {
89 119 $errmsg[] = "invalid referer; try again"; $errmsg[] = "invalid referer; try again";
File inc/fixes.inc.php changed (mode: 100644) (index 2e002de..e3fa9d2)
... ... function rg_fixes_keys_regen($db)
95 95 */ */
96 96 function rg_fixes_repo_index_by_id_one($uid, $repo_id, $repo_name) function rg_fixes_repo_index_by_id_one($uid, $repo_id, $repo_name)
97 97 { {
98 global $php_errormsg;
99
98 100 rg_log_enter("fixes_repo_index_by_id_one:" rg_log_enter("fixes_repo_index_by_id_one:"
99 101 . " uid=$uid repo_id=$repo_id repo_name=$repo_name"); . " uid=$uid repo_id=$repo_id repo_name=$repo_name");
100 102
 
... ... function rg_fixes_repo_index_by_id($db)
190 192 */ */
191 193 function rg_fixes_user_index_by_id_one($uid, $username) function rg_fixes_user_index_by_id_one($uid, $username)
192 194 { {
195 global $php_errormsg;
193 196 global $rg_repos; global $rg_repos;
194 197
195 198 rg_log_enter("fixes_user_index_by_id_one: uid=$uid username=$username"); rg_log_enter("fixes_user_index_by_id_one: uid=$uid username=$username");
File inc/git.inc.php changed (mode: 100644) (index 8062559..cc54913)
... ... function rg_git_info($msg)
50 50 */ */
51 51 function rg_git_install_hooks($dst) function rg_git_install_hooks($dst)
52 52 { {
53 global $php_errormsg;
53 54 global $rg_scripts; global $rg_scripts;
54 55
55 56 rg_prof_start("git_install_hooks"); rg_prof_start("git_install_hooks");
 
... ... function rg_git_install_hooks($dst)
101 102 */ */
102 103 function rg_git_init($dst) function rg_git_init($dst)
103 104 { {
105 global $php_errormsg;
106
104 107 rg_prof_start("git_init"); rg_prof_start("git_init");
105 108 rg_log_enter("git_init: dst=$dst"); rg_log_enter("git_init: dst=$dst");
106 109
 
... ... function rg_git_init($dst)
146 149
147 150 function rg_git_clone($src, $dst) function rg_git_clone($src, $dst)
148 151 { {
152 global $php_errormsg;
153
149 154 rg_prof_start("git_clone"); rg_prof_start("git_clone");
150 155 rg_log_enter("git_clone: src=$src, dst=$dst"); rg_log_enter("git_clone: src=$src, dst=$dst");
151 156
File inc/keys.inc.php changed (mode: 100644) (index 0de0804..13d3dfe)
... ... function rg_keys_update_use($db, $key_id, $ip)
371 371 */ */
372 372 function rg_keys_regen($db) function rg_keys_regen($db)
373 373 { {
374 global $php_errormsg;
374 375 global $rg_keys_file; global $rg_keys_file;
375 376 global $rg_scripts; global $rg_scripts;
376 377 global $rg_ssh_paras; global $rg_ssh_paras;
File inc/mr.inc.php changed (mode: 100644) (index 55c15ea..3734143)
... ... function rg_mr_error()
31 31 */ */
32 32 function rg_mr_queue_add($repo_id, $namespace, $old_rev, $new_rev, $refname, $ip) function rg_mr_queue_add($repo_id, $namespace, $old_rev, $new_rev, $refname, $ip)
33 33 { {
34 global $php_errormsg;
34 35 global $rg_mr_queue; global $rg_mr_queue;
35 36
36 37 rg_log("rg_mr_create: repo_id=$repo_id namespace=$namespace" rg_log("rg_mr_create: repo_id=$repo_id namespace=$namespace"
 
... ... function rg_mr_create($db, $repo_id, $namespace, $old_rev, $new_rev, $refname,
98 99 */ */
99 100 function rg_mr_queue_load_file($file) function rg_mr_queue_load_file($file)
100 101 { {
102 global $php_errormsg;
103
101 104 $ret = array(); $ret = array();
102 105 $ret['ok'] = 0; $ret['ok'] = 0;
103 106
 
... ... function rg_mr_queue_load_file($file)
122 125 */ */
123 126 function rg_mr_queue_process($db) function rg_mr_queue_process($db)
124 127 { {
128 global $php_errormsg;
125 129 global $rg_mr_queue; global $rg_mr_queue;
126 130
127 131 rg_prof_start("mr_queue_process"); rg_prof_start("mr_queue_process");
File inc/repo.inc.php changed (mode: 100644) (index c9a7f76..45a9d33)
... ... function rg_repo_event_del($db, $event)
301 301 */ */
302 302 function rg_repo_event_symlink_by_name($db, $e) function rg_repo_event_symlink_by_name($db, $e)
303 303 { {
304 global $php_errormsg;
305
304 306 rg_prof_start("repo_event_symlink_by_name"); rg_prof_start("repo_event_symlink_by_name");
305 307
306 308 $id_path = rg_repo_path_by_id($e['ui::uid'], $e['ri::repo_id']); $id_path = rg_repo_path_by_id($e['ui::uid'], $e['ri::repo_id']);
File inc/sql.inc.php changed (mode: 100644) (index d2baec9..a472e99)
... ... function rg_sql_app($name)
42 42 */ */
43 43 function rg_sql_open_nodelay($h) function rg_sql_open_nodelay($h)
44 44 { {
45 global $php_errormsg;
45 46 global $rg_sql_debug; global $rg_sql_debug;
46 47 global $rg_sql_conn; global $rg_sql_conn;
47 48
File inc/user.inc.php changed (mode: 100644) (index 8feceba..84aff7d)
... ... function rg_user_event_rename($db, $event)
101 101 */ */
102 102 function rg_user_link_by_name($db, $event) function rg_user_link_by_name($db, $event)
103 103 { {
104 global $php_errormsg;
105
104 106 rg_log("user_link_by_name: event=" . rg_array2string($event)); rg_log("user_link_by_name: event=" . rg_array2string($event));
105 107
106 108 $by_id = rg_user_path_by_id($event['ui::uid']); $by_id = rg_user_path_by_id($event['ui::uid']);
 
... ... function rg_user_insert_rename($db, $uid, $old_name)
326 328 */ */
327 329 function rg_user_rename($db, $ui, $new_name) function rg_user_rename($db, $ui, $new_name)
328 330 { {
331 global $php_errormsg;
332
329 333 rg_prof_start("user_rename"); rg_prof_start("user_rename");
330 334 rg_log_enter("user_rename: from=[" . $ui['username'] . "]" rg_log_enter("user_rename: from=[" . $ui['username'] . "]"
331 335 . " to=[" . $new_name . "]..."); . " to=[" . $new_name . "]...");
 
... ... function rg_user_forgot_pass_mail_prepare($db, $email)
1176 1180 */ */
1177 1181 function rg_user_forgot_pass_mail($db, $email) function rg_user_forgot_pass_mail($db, $email)
1178 1182 { {
1183 global $php_errormsg;
1179 1184 global $rg_admin_name, $rg_admin_email; global $rg_admin_name, $rg_admin_email;
1180 1185
1181 1186 rg_log("user_forgot_pass_mail: email=$email"); rg_log("user_forgot_pass_mail: email=$email");
File inc/util.inc.php changed (mode: 100644) (index 6c379a6..2ca3c11)
... ... function rg_id($len)
92 92 $_lock = array(); $_lock = array();
93 93 function rg_lock($file) function rg_lock($file)
94 94 { {
95 global $php_errormsg;
96
95 97 global $_lock; global $_lock;
96 98 global $rg_lock_dir; global $rg_lock_dir;
97 99
 
... ... function rg_chars_allow($name, $allowed_regexp, &$invalid)
335 337 */ */
336 338 function rg_rmdir($dir) function rg_rmdir($dir)
337 339 { {
340 global $php_errormsg;
341
338 342 if (!is_dir($dir)) { if (!is_dir($dir)) {
339 343 rg_util_set_error("WARN: asked to remove a non-existing dir ($dir)"); rg_util_set_error("WARN: asked to remove a non-existing dir ($dir)");
340 344 return TRUE; return TRUE;
 
... ... function rg_prepare_replace(&$data, &$what, &$values)
470 474 rg_prepare_replace_helper($data, "", $what, $values); rg_prepare_replace_helper($data, "", $what, $values);
471 475 } }
472 476
473 $what['DUMP'] = "/@@DUMP@@/uU";
474 $values['DUMP'] = rg_xss_safe(print_r($data, TRUE));
475
476 477 // we replace @@unknown@@ with empty // we replace @@unknown@@ with empty
477 478 //$what['FINAL'] = "/@@.*@@/U"; //$what['FINAL'] = "/@@.*@@/U";
478 479 //$values['FINAL'] = ""; //$values['FINAL'] = "";
 
... ... function rg_prepare_replace(&$data, &$what, &$values)
488 489 function rg_replace_lookup(&$data, $var) function rg_replace_lookup(&$data, $var)
489 490 { {
490 491 rg_prepare_replace($data, $what, $values); rg_prepare_replace($data, $what, $values);
492 if (empty($what))
493 return $var;
494
491 495 return preg_replace($what, $values, $var); return preg_replace($what, $values, $var);
492 496 } }
493 497
 
... ... function rg_replace_conditionals($block, &$data)
633 637 */ */
634 638 function rg_file_get_contents($f) function rg_file_get_contents($f)
635 639 { {
640 global $php_errormsg;
641
636 642 if (!file_exists($f)) if (!file_exists($f))
637 643 return ""; return "";
638 644
639 $c = file_get_contents($f);
645 $c = @file_get_contents($f);
640 646 if ($c === FALSE) { if ($c === FALSE) {
641 647 rg_internal_error("Could not load file [$f] ($php_errormsg)."); rg_internal_error("Could not load file [$f] ($php_errormsg).");
642 648 return ""; return "";
 
... ... function rg_array2string($a)
1007 1013 */ */
1008 1014 function rg_dir_load_pattern($dir, $pattern) function rg_dir_load_pattern($dir, $pattern)
1009 1015 { {
1016 global $php_errormsg;
1017
1010 1018 $ret = FALSE; $ret = FALSE;
1011 1019 if (!file_exists($dir)) { if (!file_exists($dir)) {
1012 1020 rg_util_set_error("$dir does not exists"); rg_util_set_error("$dir does not exists");
 
... ... function rg_dir_load_deep($dir)
1070 1078 */ */
1071 1079 function rg_copy_tree($src, $dst, $mask) function rg_copy_tree($src, $dst, $mask)
1072 1080 { {
1081 global $php_errormsg;
1082
1073 1083 rg_log("rg_copy_tree($src, $dst, $mask)"); rg_log("rg_copy_tree($src, $dst, $mask)");
1074 1084
1075 1085 if (!is_dir($dst)) { if (!is_dir($dst)) {
File root/themes/default/admin/invites/invites.html changed (mode: 100644) (index 64ead77..2cc6bbd)
4 4
5 5 @@errmsg@@ @@errmsg@@
6 6
7 <form method="post" action="/op/admin/invites">
7 <form method="post" action="/op/admin/invites" enctype="multipart/form-data">
8 8 <input type="hidden" name="doit" value="1" /> <input type="hidden" name="doit" value="1" />
9 9 <input type="hidden" name="token" value="@@rg_form_token@@" /> <input type="hidden" name="token" value="@@rg_form_token@@" />
10 10
11 <label for="inv::list" class="form_item_title">People list (email|name pairs)</label><br />
11 <label for="inv::list" class="form_item_title">
12 People list (email|name pairs)
13 </label><br />
12 14 <textarea name="inv::list" rows="20" cols="100">@@inv::list@@</textarea> <textarea name="inv::list" rows="20" cols="100">@@inv::list@@</textarea>
13 15 <br /> <br />
14 16 <br /> <br />
15 17
16 <label for="inv::subject" class="form_item_title">Subject</label><br />
18 <label for="inv::subject" class="form_item_title">
19 Subject ({NAME} will be replaced with the name defined above)
20 </label><br />
17 21 <input type="text" name="inv::subject" size="100" value="@@inv::subject@@" /> <input type="text" name="inv::subject" size="100" value="@@inv::subject@@" />
18 22 <br /> <br />
19 23 <br /> <br />
20 24
21 <label for="inv::body" class="form_item_title">Body of e-mail ({NAME} will be replaced with the name defined above)</label><br />
25 <label for="inv::file" class="form_item_title">
26 File containing the body of the mail e-mail
27 ({NAME} will be replaced with the name defined above)
28 </label><br />
29 <input type="file" name="inv::file" size="80" />
30 <br />
31 <br />
32
33 <label for="inv::body" class="form_item_title">
34 If you did not upload any file, insert here the body of e-mail
35 ({NAME} will be replaced with the name defined above)
36 </label><br />
22 37 <textarea name="inv::body" rows="20" cols="100">@@inv::body@@</textarea> <textarea name="inv::body" rows="20" cols="100">@@inv::body@@</textarea>
23 38 <br /> <br />
24 39 <br /> <br />
File root/themes/default/admin/invites/sent.html changed (mode: 100644) (index 05cb590..78faea8)
1 1 <div class="ok"> <div class="ok">
2 Invites sent.
2 The invites were queued for sending.
3 3 </div> </div>
File root/themes/default/download-vm.html changed (mode: 100644) (index e8c67c3..998369f)
1 1 <div class="islands"> <div class="islands">
2 2 <div class="main_title">Download - virtual machines</div> <div class="main_title">Download - virtual machines</div>
3 3
4 <div class="island_row">
5 <div class="island_cell">
6 <div class="island">
7 <div class="island_title">RocketGit as a virtual machine</div>
8
9 On this page you will find instructions on how to deploy
10 RocketGit using a virtualization solution:<br />
11 - <a href="#qemu">qemu/KVM/libvirt</a><br />
12 - <a href="#vmware_esxi">VMware ESXi</a><br />
13 - <a href="#vmware_player">VMware Player</a><br />
14 - <a href="#virtualbox">VirtualBox</a>
15 </div>
16 </div>
17 </div>
18
4 19 <a id="qemu"></a> <a id="qemu"></a>
5 20 <div class="island_row"> <div class="island_row">
6 21 <div class="island_cell"> <div class="island_cell">
 
103 118 </div> </div>
104 119 </div> </div>
105 120
106 <a id="vmware"></a>
121 <a id="vmware_esxi"></a>
122 <div class="island_row">
123 <div class="island_cell">
124 <div class="island">
125 <div class="island_title">VMware ESXi based virtualization</div>
126
127 Steps to follow:<br />
128
129 - download VMX config file (2 KiB) from
130 <a href="http://downloads.rocketgit.com/vm/rocketgit1-fedora-21-i386.vmx">http://downloads.rocketgit.com/vm/rocketgit1-fedora-21-i386-esx.vmx</a><br />
131 <br />
132
133 - download VMDK image (164 MiB) from
134 <a href="http://downloads.rocketgit.com/vm/rocketgit1-fedora-21-i386.vmdk.zip">http://downloads.rocketgit.com/vm/rocketgit1-fedora-21-i386.vmdk.zip</a>
135 in the same folder as previous file<br />
136 <br />
137
138 - decompress the image and move both files to a ESX datastore<br />
139 <br />
140
141 - in VMware Client, browse the datastore, right click on .vmx file,
142 and choose "Add to inventory"<br />
143 <br />
144
145 - now, you may want to change some virtual machine parameters;
146 pay attention to the network definition<br />
147 <br />
148
149 - start the virtual machine<br />
150 <br />
151
152 - attach to the console to find out the ip address (ip ad li)<br />
153 <br />
154
155 - point your browser to the ip address found, using http or
156 https and create an admin account<br />
157 <br />
158
159 Now, please follow the <a href="#common">common section<a/> below to
160 finish the installation.<br />
161
162 </div>
163 </div>
164 </div>
165
166 <a id="vmware_player"></a>
107 167 <div class="island_row"> <div class="island_row">
108 168 <div class="island_cell"> <div class="island_cell">
109 169 <div class="island"> <div class="island">
 
157 217 </div> </div>
158 218 </div> </div>
159 219
160 <a id="vbox"></a>
220 <a id="virtualbox"></a>
161 221 <div class="island_row"> <div class="island_row">
162 222 <div class="island_cell"> <div class="island_cell">
163 223 <div class="island"> <div class="island">
File root/themes/default/features.html changed (mode: 100644) (index a222306..223beaa)
34 34 <div class="island_row"> <div class="island_row">
35 35 <div class="island_cell"> <div class="island_cell">
36 36 <div class="island"> <div class="island">
37 <div class="island_title">Ready to go</div>
37 <div class="island_title">Ready to use</div>
38 38 You can just open your web browser and start using You can just open your web browser and start using
39 39 RocketGit, but even if you choose to install RocketGit on your RocketGit, but even if you choose to install RocketGit on your
40 40 machine you can have it up and running in under 2 minutes. You machine you can have it up and running in under 2 minutes. You
File scripts/cron.php changed (mode: 100644) (index c4ba0d2..64cca7e)
2 2 // This is called by cron // This is called by cron
3 3 error_reporting(E_ALL); error_reporting(E_ALL);
4 4 ini_set("track_errors", "On"); ini_set("track_errors", "On");
5 set_time_limit(0);
5 6
6 7 $now = time(); $now = time();
7 8
File tests/util.php changed (mode: 100644) (index d7933c8..d4e63bd)
... ... $rg_no_db = TRUE;
14 14 require_once("common.php"); require_once("common.php");
15 15
16 16
17 // Test rg_prepare_replace_helper
18 $a = array('a' => 'A', 'arr' => array('bb' => 'BB', 'HTML:cc' => 'ș'));
19 $what = array();
20 $value = array();
21 $r = rg_prepare_replace($a, $what, $values);
22 $r2 = preg_replace($what, $values, '@@a@@-@@arr::bb@@-@@arr::cc@@-@@alien@@');
23 $e = 'A-BB-ș-@@alien@@';
24 if (strcmp($r2, $e) != 0) {
25 rg_log("prepare_replace_helper is not working as expeceted!");
26 rg_log_ml("e: $e");
27 rg_log_ml("r2: $r2");
28 exit(1);
29 }
30
17 31 // Test template functions // Test template functions
18 32 function inc($v) { return $v + 1; } function inc($v) { return $v + 1; }
19 33 function dec($v) { return $v - 1; } function dec($v) { return $v - 1; }
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