List of commits:
Subject Hash Author Date (UTC)
More bulk updates. a2a2e2545eaad61d0c675ea2afb801f207534515 Catalin(ux) M. BOIE 2011-11-03 22:09:34
Another round of bulk updates. 45bb00a88c420d439b4dd19971808722e4a70895 Catalin(ux) M. BOIE 2011-10-24 22:31:14
Bulk update. Mostly css. 04734cd7cfc4fd4ec55dad70a3490f3065027639 Catalin(ux) M. BOIE 2011-10-03 23:18:26
Added rg_exec function and converted all calls from exec to rg_exec. 097157e5886dace2b9f67ca238a1063a3baff4a0 Catalin(ux) M. BOIE 2011-09-28 03:28:49
Another round of bulk updates cb9dbb75518ab3c214167646197ca7eb0de8e4e6 Catalin(ux) M. BOIE 2011-09-26 19:22:12
Bulk updates cad0c710542dc3fb072268eba40b0abe11217fa9 Catalin(ux) M. BOIE 2011-09-21 20:25:23
Bulk changes. d5274ef5f261086a2af6bd19ac04061bb3d55584 Catalin(ux) M. BOIE 2011-09-15 20:16:46
Store the fist instalation date in 'state' table. e4ba8a9239e72e8de5eed0b3bb1f2a5f2d429105 Catalin(ux) M. BOIE 2011-08-31 16:14:44
Bulk changes. 645d3deb19e399c05a8b14dd88c5151520482b6a Catalin(ux) M. BOIE 2011-08-25 20:39:25
Another bulk update - css related. 3867eb5deadf9827450b40a53efe6c83f518a07b Catalin(ux) M. BOIE 2011-07-26 22:01:13
Bulk update. 9d680f000b7c486be4664e1cb944f424c977c874 Catalin(ux) M. BOIE 2011-07-25 19:06:14
Some ssh and anonymous rights fixes. 9bb20c348a4933056d8f67bd151eb35cf0325835 Catalin(ux) M. BOIE 2011-07-05 22:00:00
Another round of fixes. 45749c46f79f75b29d83ee2d115f987c7765e8c4 Catalin(ux) M. BOIE 2011-07-05 20:01:10
Another round of bulk updates. 6077961d5c443b8a830dc08b3b0ebf37eaf594b3 Catalin(ux) M. BOIE 2011-07-04 22:12:40
Bump version to 0.7. e44064dab5c6f2fa625bb121483a51ec1960cad9 Catalin(ux) M. BOIE 2011-07-03 16:26:47
Lots of changes. 8876190d55995ed98a528edc786e0e9136a0535d Catalin(ux) M. BOIE 2011-07-03 00:03:42
Make %setup quiet as rpmlint told me. b272b9915498fb0a811be2e2687554bbaf887bf1 Catalin(ux) M. BOIE 2011-07-01 03:26:57
Bump version to 0.3 f626f3c66b7b51af2013e16e954e945ba84c12bb Catalin(ux) M. BOIE 2011-07-01 03:25:44
Added logrotate support b827ee7c179d5b72f6ac3ac255edb6de6decb91a Catalin(ux) M. BOIE 2011-07-01 03:25:13
More bulk updates 6dc2b24ebde74bbb64ef2893e2ddb8b7b9456219 Catalin(ux) M. BOIE 2011-07-01 03:16:01
Commit a2a2e2545eaad61d0c675ea2afb801f207534515 - More bulk updates.
Author: Catalin(ux) M. BOIE
Author date (UTC): 2011-11-03 22:09
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2011-11-03 22:09
Parent(s): 45bb00a88c420d439b4dd19971808722e4a70895
Signing key:
Tree: 1583bae11640a00357aee899ad94ddb592e3c0d1
File Lines added Lines deleted
inc/git.inc.php 41 0
inc/keys.inc.php 25 1
inc/prof.inc.php 71 16
inc/repo.inc.php 34 0
inc/sess.inc.php 18 0
inc/sql.inc.php 23 7
inc/user/forgot.form.php 1 1
inc/user/home-page.php 0 17
inc/user/repo-page.php 7 1
inc/util.inc.php 20 0
root/index.php 8 4
root/themes/default/index.php 2 1
root/themes/default/main.css 1 0
root/themes/default/repo/main.html 8 0
scripts/q.php 5 2
tests/Makefile 3 1
File inc/git.inc.php changed (mode: 100644) (index 4c7d1d2..80497b2)
1 1 <?php <?php
2 2 require_once($INC . "/util.inc.php"); require_once($INC . "/util.inc.php");
3 3 require_once($INC . "/log.inc.php"); require_once($INC . "/log.inc.php");
4 require_once($INC . "/prof.inc.php");
4 5
5 6 $rg_git_zero = "0000000000000000000000000000000000000000"; $rg_git_zero = "0000000000000000000000000000000000000000";
6 7
 
... ... function rg_git_install_hooks($dst)
24 25 { {
25 26 global $rg_scripts; global $rg_scripts;
26 27
28 rg_prof_start("git_install_hooks");
29
27 30 rg_log("git_install_hooks: dst=$dst..."); rg_log("git_install_hooks: dst=$dst...");
28 31
29 32 if (file_exists($dst . "/hooks")) { if (file_exists($dst . "/hooks")) {
 
... ... function rg_git_install_hooks($dst)
48 51 return FALSE; return FALSE;
49 52 } }
50 53
54 rg_prof_end("git_install_hooks");
55
51 56 return TRUE; return TRUE;
52 57 } }
53 58
54 59 function rg_git_init($dst) function rg_git_init($dst)
55 60 { {
61 rg_prof_start("git_init");
62
56 63 rg_log("git_init: dst=$dst..."); rg_log("git_init: dst=$dst...");
57 64
58 65 $dir = dirname($dst); $dir = dirname($dst);
 
... ... function rg_git_init($dst)
81 88 if (rg_git_install_hooks($dst) !== TRUE) if (rg_git_install_hooks($dst) !== TRUE)
82 89 return FALSE; return FALSE;
83 90
91 rg_prof_end("git_init");
92
84 93 return TRUE; return TRUE;
85 94 } }
86 95
87 96 function rg_git_clone($src, $dst) function rg_git_clone($src, $dst)
88 97 { {
98 rg_prof_start("git_clone");
99
89 100 rg_log("git_clone: src=$src, dst=$dst..."); rg_log("git_clone: src=$src, dst=$dst...");
90 101
91 102 $dir = dirname($dst); $dir = dirname($dst);
 
... ... function rg_git_clone($src, $dst)
115 126 if (rg_git_install_hooks($dst) !== TRUE) if (rg_git_install_hooks($dst) !== TRUE)
116 127 return FALSE; return FALSE;
117 128
129 rg_prof_end("git_clone");
130
118 131 return TRUE; return TRUE;
119 132 } }
120 133
 
... ... function rg_git_type($obj)
138 151 */ */
139 152 function rg_git_content($obj) function rg_git_content($obj)
140 153 { {
154 rg_prof_start("git_content");
155
141 156 $cmd = "git cat-file -p '" . $obj . "'"; $cmd = "git cat-file -p '" . $obj . "'";
142 157 $a = rg_exec($cmd); $a = rg_exec($cmd);
143 158 if ($a['ok'] != 1) { if ($a['ok'] != 1) {
 
... ... function rg_git_content($obj)
145 160 return FALSE; return FALSE;
146 161 } }
147 162
163 rg_prof_end("git_content");
164
148 165 return $a['data']; return $a['data'];
149 166 } }
150 167
 
... ... function rg_git_reference($refname)
171 188 // TODO: Unit testing // TODO: Unit testing
172 189 function rg_git_rev_ok($rev) function rg_git_rev_ok($rev)
173 190 { {
191 rg_prof_start("git_rev_ok");
192
174 193 $cmd = "git rev-parse --verify --quiet '" . $rev . "'"; $cmd = "git rev-parse --verify --quiet '" . $rev . "'";
175 194 $a = rg_exec($cmd); $a = rg_exec($cmd);
176 195 if ($a['ok'] != 1) { if ($a['ok'] != 1) {
 
... ... function rg_git_rev_ok($rev)
178 197 return FALSE; return FALSE;
179 198 } }
180 199
200 rg_prof_end("git_rev_ok");
201
181 202 return TRUE; return TRUE;
182 203 } }
183 204
 
... ... function rg_git_rev_ok($rev)
187 208 */ */
188 209 function rg_git_whitespace_ok($old, $new) function rg_git_whitespace_ok($old, $new)
189 210 { {
211 rg_prof_start("git_whitespace_ok");
212
190 213 $cmd = "git diff --check " . $old . " " . $new; $cmd = "git diff --check " . $old . " " . $new;
191 214 $a = rg_exec($cmd); $a = rg_exec($cmd);
192 215 if ($a['ok'] != 1) { if ($a['ok'] != 1) {
 
... ... function rg_git_whitespace_ok($old, $new)
194 217 return FALSE; return FALSE;
195 218 } }
196 219
220 rg_prof_end("git_whitespace_ok");
221
197 222 return TRUE; return TRUE;
198 223 } }
199 224
200 225 // TODO: Unit testing // TODO: Unit testing
201 226 function rg_git_merge_base($old, $new) function rg_git_merge_base($old, $new)
202 227 { {
228 rg_prof_start("git_merge_base");
229
203 230 $cmd = "git merge-base " . $old . " " . $new; $cmd = "git merge-base " . $old . " " . $new;
204 231 $a = rg_exec($cmd); $a = rg_exec($cmd);
205 232 if ($a['ok'] != 1) { if ($a['ok'] != 1) {
 
... ... function rg_git_merge_base($old, $new)
207 234 return FALSE; return FALSE;
208 235 } }
209 236
237 rg_prof_end("git_merge_base");
238
210 239 return trim($a['data']); return trim($a['data']);
211 240 } }
212 241
 
... ... function rg_git_merge_base($old, $new)
215 244 */ */
216 245 function rg_git_ls_tree($tree) function rg_git_ls_tree($tree)
217 246 { {
247 rg_prof_start("git_ls_tree");
248
218 249 rg_log("rg_git_ls_tree: tree=$tree"); rg_log("rg_git_ls_tree: tree=$tree");
219 250
220 251 $ret = array(); $ret = array();
 
... ... function rg_git_ls_tree($tree)
247 278 $ret[] = $_y; $ret[] = $_y;
248 279 } }
249 280
281 rg_prof_end("git_ls_tree");
282
250 283 return $ret; return $ret;
251 284 } }
252 285
 
... ... function rg_git_ls_tree($tree)
255 288 */ */
256 289 function rg_git_diff2array($diff) function rg_git_diff2array($diff)
257 290 { {
291 rg_prof_start("git_diff2array");
292
258 293 $ret = array(); $ret = array();
259 294
260 295 $lines = explode("\n", $diff); $lines = explode("\n", $diff);
 
... ... function rg_git_diff2array($diff)
351 386 exit(0); exit(0);
352 387 } }
353 388
389 rg_prof_end("git_diff2array");
390
354 391 return $ret; return $ret;
355 392 } }
356 393
 
... ... function rg_git_diff2array($diff)
360 397 */ */
361 398 function rg_git_log($max, $from, $to, $also_patch) function rg_git_log($max, $from, $to, $also_patch)
362 399 { {
400 rg_prof_start("git_log");
401
363 402 rg_log("git_log: max=$max"); rg_log("git_log: max=$max");
364 403
365 404 $max_count = ($max == 0) ? "" : " --max-count=$max"; $max_count = ($max == 0) ? "" : " --max-count=$max";
 
... ... function rg_git_log($max, $from, $to, $also_patch)
453 492 $ret[] = $y; $ret[] = $y;
454 493 } }
455 494
495 rg_prof_end("git_log");
496
456 497 return $ret; return $ret;
457 498 } }
458 499
File inc/keys.inc.php changed (mode: 100644) (index 301af61..bfda859)
1 1 <?php <?php
2 2 require_once($INC . "/sql.inc.php"); require_once($INC . "/sql.inc.php");
3 3 require_once($INC . "/state.inc.php"); require_once($INC . "/state.inc.php");
4 require_once($INC . "/prof.inc.php");
4 5
5 6 $rg_keys_error = ""; $rg_keys_error = "";
6 7
 
... ... function rg_keys_fingerprint($key)
61 62 */ */
62 63 function rg_keys_remove($db, $rg_ui, $key_id) function rg_keys_remove($db, $rg_ui, $key_id)
63 64 { {
65 rg_prof_start("keys_remove");
66
64 67 // mark dirty // mark dirty
65 68 if (rg_state_set($db, "authorized_keys", 1) === FALSE) { if (rg_state_set($db, "authorized_keys", 1) === FALSE) {
66 69 rg_keys_set_error("Cannot make state dirty (" . rg_state_error() . ")!"); rg_keys_set_error("Cannot make state dirty (" . rg_state_error() . ")!");
 
... ... function rg_keys_remove($db, $rg_ui, $key_id)
80 83 } }
81 84 rg_sql_free_result($res); rg_sql_free_result($res);
82 85
86 rg_prof_end("keys_remove");
87
83 88 return TRUE; return TRUE;
84 89 } }
85 90
 
... ... function rg_keys_remove($db, $rg_ui, $key_id)
88 93 */ */
89 94 function rg_keys_count($db, $uid) function rg_keys_count($db, $uid)
90 95 { {
96 rg_prof_start("keys_count");
97
91 98 $sql = "SELECT COUNT(*) AS count FROM keys WHERE uid = $uid"; $sql = "SELECT COUNT(*) AS count FROM keys WHERE uid = $uid";
92 99 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
93 100 if ($res === FALSE) { if ($res === FALSE) {
 
... ... function rg_keys_count($db, $uid)
97 104 $row = rg_sql_fetch_array($res); $row = rg_sql_fetch_array($res);
98 105 rg_sql_free_result($res); rg_sql_free_result($res);
99 106
107 rg_prof_end("keys_count");
108
100 109 return $row['count']; return $row['count'];
101 110 } }
102 111
 
... ... function rg_keys_add($db, $rg_ui, $key)
108 117 { {
109 118 global $rg_max_ssh_keys; global $rg_max_ssh_keys;
110 119
120 rg_prof_start("keys_add");
121
111 122 $itime = time(); $itime = time();
112 123 $e_key = rg_sql_escape($db, $key); $e_key = rg_sql_escape($db, $key);
113 124
 
... ... function rg_keys_add($db, $rg_ui, $key)
142 153 } }
143 154 rg_sql_free_result($res); rg_sql_free_result($res);
144 155
145 return rg_sql_last_id($db);
156 $id = rg_sql_last_id($db);
157
158 rg_prof_end("keys_add");
159
160 return $id;
146 161 } }
147 162
148 163 /* /*
 
... ... function rg_keys_regen($db)
154 169 global $rg_scripts; global $rg_scripts;
155 170 global $rg_ssh_paras; global $rg_ssh_paras;
156 171
172 rg_prof_start("keys_regen");
173
157 174 $dirty = rg_state_get($db, "authorized_keys"); $dirty = rg_state_get($db, "authorized_keys");
158 175 if ($dirty == 0) { if ($dirty == 0) {
159 176 // Skip generation because is not dirty // Skip generation because is not dirty
 
... ... function rg_keys_regen($db)
215 232 // mark file as clean // mark file as clean
216 233 rg_state_set($db, "authorized_keys", 0); rg_state_set($db, "authorized_keys", 0);
217 234
235 rg_prof_end("keys_regen");
236
218 237 return TRUE; return TRUE;
219 238 } }
220 239
 
... ... function rg_keys_regen($db)
223 242 */ */
224 243 function rg_keys_list($db, $rg_ui, $url) function rg_keys_list($db, $rg_ui, $url)
225 244 { {
245 rg_prof_start("keys_list");
246
226 247 rg_log("keys_list: rg_uid=" . $rg_ui['uid'] . ", url=$url..."); rg_log("keys_list: rg_uid=" . $rg_ui['uid'] . ", url=$url...");
227 248
228 249 $sql = "SELECT * FROM keys WHERE uid = " . $rg_ui['uid']; $sql = "SELECT * FROM keys WHERE uid = " . $rg_ui['uid'];
 
... ... function rg_keys_list($db, $rg_ui, $url)
254 275 $ret .= "</div>\n"; $ret .= "</div>\n";
255 276 rg_sql_free_result($res); rg_sql_free_result($res);
256 277
278 rg_prof_end("keys_list");
279
257 280 return $ret; return $ret;
258 281 } }
282
259 283 ?> ?>
File inc/prof.inc.php changed (mode: 100644) (index a4e8d77..2aab39c)
2 2 // Profiling functions // Profiling functions
3 3
4 4 $rg_prof_main = array(); $rg_prof_main = array();
5 $rg_prof_start = array();
5 $rg_prof_state = array();
6 $rg_prof_tmp = array();
7
8 /*
9 * This will be called by submodules like git and db
10 */
11 function rg_prof_set($data)
12 {
13 global $rg_prof_state;
14
15 foreach ($data as $k => $v) {
16 if (isset($rg_prof_state[$k]))
17 $rg_prof_state[$k] += $v;
18 else
19 $rg_prof_state[$k] = $v;
20 }
21 }
6 22
7 23 function rg_prof_start($label) function rg_prof_start($label)
8 24 { {
9 25 global $rg_prof_tmp; global $rg_prof_tmp;
10 26 global $rg_prof_state; global $rg_prof_state;
11 27
12 if (isset($rg_prof_tmp[$label]))
13 return;
14
15 28 $rg_prof_tmp[$label] = $rg_prof_state; $rg_prof_tmp[$label] = $rg_prof_state;
16 $rg_prof_tmp[$label]['_ts'] = microtime(TRUE);
29 $rg_prof_tmp[$label]['time_ms'] = sprintf("%u", microtime(TRUE) * 1000);
30 $rg_prof_tmp[$label]['mem'] = memory_get_usage();
31 $rg_prof_tmp[$label]['real_mem'] = memory_get_usage(TRUE);
17 32 } }
18 33
19 34 function rg_prof_end($label) function rg_prof_end($label)
 
... ... function rg_prof_end($label)
25 40 if (!isset($rg_prof_tmp[$label])) if (!isset($rg_prof_tmp[$label]))
26 41 return; return;
27 42
43 $start = $rg_prof_tmp[$label];
44
28 45 $c = $rg_prof_state; $c = $rg_prof_state;
29 $c['time'] = microtime(TRUE) - $rg_prof_tmp[$label]['_ts']; unset($c['_ts']);
46 $c['time_ms'] = sprintf("%u", microtime(TRUE) * 1000);
30 47 $c['runs'] = 1; $c['runs'] = 1;
48 $c['mem'] = memory_get_usage();
49 $c['real_mem'] = memory_get_usage(TRUE);
31 50
32 foreach ($rg_prof_tmp[$label] as $key => $val)
51 // we remove what was before start
52 foreach ($start as $key => $val)
33 53 $c[$key] -= $val; $c[$key] -= $val;
34 54
35 55 // add to main label // add to main label
 
... ... function rg_prof_end($label)
40 60 $rg_prof_main[$label][$key] += $val; $rg_prof_main[$label][$key] += $val;
41 61 } }
42 62
43 unset($rg_state_tmp[$label]);
63 unset($rg_prof_tmp[$label]);
44 64 } }
45 65
46 66 function rg_prof_get() function rg_prof_get()
 
... ... function rg_prof_get()
50 70 return $rg_prof_main; return $rg_prof_main;
51 71 } }
52 72
53 function rg_prof_get_total()
73 function rg_prof_log()
54 74 { {
55 75 global $rg_prof_main; global $rg_prof_main;
56 76
57 $t = array();
77 rg_log("prof_log");
58 78
59 $ret = "";
60 79 foreach ($rg_prof_main as $label => $per_label) { foreach ($rg_prof_main as $label => $per_label) {
80 $line = $label . ":";
81
61 82 foreach ($per_label as $k => $v) { foreach ($per_label as $k => $v) {
62 if ($isset($t[$k]))
63 $t[$k] = $v;
83 if ($v > 0)
84 $line .= " $k=$v";
85 }
86 rg_log($line);
87 }
88 }
89
90 function rg_prof_html()
91 {
92 global $rg_prof_main;
93
94 // get all possible variables
95 $vars = array();
96 foreach ($rg_prof_main as $label => $per_label)
97 foreach ($per_label as $k => $v)
98 $vars[$k] = 1;
99
100 $ret = "<table>";
101 $ret .= "<tr>";
102 $ret .= "<td>Label</td>";
103 foreach ($vars as $var => $junk)
104 $ret .= "<td>" . $var . "</td>";
105 $ret .= "</tr>";
106
107 foreach ($rg_prof_main as $label => $per_label) {
108 $ret .= "<tr>";
109
110 $ret .= "<td>" . $label . "</td>";
111
112 foreach ($vars as $k => $junk) {
113 if (!isset($per_label[$k]))
114 $v = 0;
64 115 else else
65 $t[$k] += $v;
116 $v = $per_label[$k];
117 $ret .= "<td>" . $v . "</td>";
66 118 } }
119
120 $ret .= "</tr>";
67 121 } }
68 122
69 return $t;
70 }
123 $ret .= "</table>\n";
71 124
125 return $ret;
126 }
72 127 ?> ?>
File inc/repo.inc.php changed (mode: 100644) (index 10267db..2b98344)
... ... require_once($INC . "/sql.inc.php");
5 5 require_once($INC . "/user.inc.php"); require_once($INC . "/user.inc.php");
6 6 require_once($INC . "/git.inc.php"); require_once($INC . "/git.inc.php");
7 7 require_once($INC . "/rights.inc.php"); require_once($INC . "/rights.inc.php");
8 require_once($INC . "/prof.inc.php");
8 9
9 10 $rg_repo_empty = "4b825dc642cb6eb9a060e54bf8d69288fbee4904"; $rg_repo_empty = "4b825dc642cb6eb9a060e54bf8d69288fbee4904";
10 11
 
... ... function rg_repo_name2base($rr)
98 99 */ */
99 100 function rg_repo_info($db, $rr) function rg_repo_info($db, $rr)
100 101 { {
102 rg_prof_start("repo_info");
103
101 104 rg_log("repo_info: rr:" . implode("|", $rr)); rg_log("repo_info: rr:" . implode("|", $rr));
102 105
103 106 $repo_id = isset($rr['repo_id']) ? $rr['repo_id'] : 0; $repo_id = isset($rr['repo_id']) ? $rr['repo_id'] : 0;
 
... ... function rg_repo_info($db, $rr)
138 141
139 142 $row['exists'] = 1; $row['exists'] = 1;
140 143 $row['ok'] = 1; $row['ok'] = 1;
144
145 rg_prof_end("repo_info");
146
141 147 return $row; return $row;
142 148 } }
143 149
 
... ... function rg_repo_info($db, $rr)
146 152 */ */
147 153 function rg_repo_allow($db, $ri, $rg_ui, $needed_rights) function rg_repo_allow($db, $ri, $rg_ui, $needed_rights)
148 154 { {
155 rg_prof_start("repo_allow");
156
149 157 rg_log("repo_allow: repo_id=" . $ri['repo_id'] rg_log("repo_allow: repo_id=" . $ri['repo_id']
150 158 . " rg_uid=" . $rg_ui['uid'] . " rg_uid=" . $rg_ui['uid']
151 159 . ", needed_rights=$needed_rights..."); . ", needed_rights=$needed_rights...");
 
... ... function rg_repo_allow($db, $ri, $rg_ui, $needed_rights)
180 188
181 189 rg_log("\tAllow access!"); rg_log("\tAllow access!");
182 190
191 rg_prof_end("repo_allow");
192
183 193 return TRUE; return TRUE;
184 194 } }
185 195
 
... ... function rg_repo_allow($db, $ri, $rg_ui, $needed_rights)
191 201 function rg_repo_create($db, $master, $rg_ui, $name, $max_commit_size, function rg_repo_create($db, $master, $rg_ui, $name, $max_commit_size,
192 202 $description, $rights, $max_users) $description, $rights, $max_users)
193 203 { {
204 rg_prof_start("repo_create");
205
194 206 // TODO: reorder parameters - are not logical // TODO: reorder parameters - are not logical
195 207 rg_log("repo_create: rg_uid=" . $rg_ui['uid'] rg_log("repo_create: rg_uid=" . $rg_ui['uid']
196 208 . ", name=[$name], master=$master" . ", name=[$name], master=$master"
 
... ... function rg_repo_create($db, $master, $rg_ui, $name, $max_commit_size,
233 245 // git repo creation will be delayed for serialization reasons // git repo creation will be delayed for serialization reasons
234 246 // and for permission reasons (we are apache here) // and for permission reasons (we are apache here)
235 247
248 rg_prof_end("repo_create");
249
236 250 return TRUE; return TRUE;
237 251 } }
238 252
 
... ... function rg_repo_create($db, $master, $rg_ui, $name, $max_commit_size,
241 255 */ */
242 256 function rg_repo_delete($db, $repo_id, $rg_ui) function rg_repo_delete($db, $repo_id, $rg_ui)
243 257 { {
258 rg_prof_start("repo_delete");
259
244 260 rg_log("repo_delete: rg_uid=" . $rg_ui['uid'] . ", repo_id=$repo_id"); rg_log("repo_delete: rg_uid=" . $rg_ui['uid'] . ", repo_id=$repo_id");
245 261
246 262 // TODO: Check rights // TODO: Check rights
 
... ... function rg_repo_delete($db, $repo_id, $rg_ui)
254 270 } }
255 271 rg_sql_free_result($res); rg_sql_free_result($res);
256 272
273 rg_prof_end("repo_delete");
274
257 275 return TRUE; return TRUE;
258 276 } }
259 277
 
... ... function rg_repo_delete($db, $repo_id, $rg_ui)
263 281 */ */
264 282 function rg_repo_update($db, &$new) function rg_repo_update($db, &$new)
265 283 { {
284 rg_prof_start("repo_update");
285
266 286 rg_log("repo_update: repo_id=" . $new['repo_id'] rg_log("repo_update: repo_id=" . $new['repo_id']
267 287 . ", name=[" . $new['name'] . "]" . ", name=[" . $new['name'] . "]"
268 288 . ", max_commit_size=" . $new['max_commit_size'] . ", max_commit_size=" . $new['max_commit_size']
 
... ... function rg_repo_update($db, &$new)
307 327 } }
308 328 rg_sql_free_result($res); rg_sql_free_result($res);
309 329
330 rg_prof_end("repo_update");
331
310 332 return TRUE; return TRUE;
311 333 } }
312 334
 
... ... function rg_repo_list_query($db, $url, $sql)
317 339 { {
318 340 global $THEME; global $THEME;
319 341
342 rg_prof_start("repo_list_query");
343
320 344 rg_log("repo_list_query: url=$url, sql=$sql..."); rg_log("repo_list_query: url=$url, sql=$sql...");
321 345
322 346 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
 
... ... function rg_repo_list_query($db, $url, $sql)
378 402 } }
379 403 rg_sql_free_result($res); rg_sql_free_result($res);
380 404
405 rg_prof_end("repo_list_query");
406
381 407 return rg_template_table($THEME . "/repo/list", $d, array()); return rg_template_table($THEME . "/repo/list", $d, array());
382 408 } }
383 409
 
... ... function rg_repo_disk_mb($path)
440 466 */ */
441 467 function rg_repo_git_done($db, $repo_id) function rg_repo_git_done($db, $repo_id)
442 468 { {
469 rg_prof_start("repo_git_done");
470
443 471 rg_log("repo_git_done: repo_id=$repo_id..."); rg_log("repo_git_done: repo_id=$repo_id...");
444 472
445 473 $sql = "UPDATE repos SET git_dir_done = 1" $sql = "UPDATE repos SET git_dir_done = 1"
 
... ... function rg_repo_git_done($db, $repo_id)
451 479 } }
452 480 rg_sql_free_result($res); rg_sql_free_result($res);
453 481
482 rg_prof_end("repo_git_done");
483
454 484 return TRUE; return TRUE;
455 485 } }
456 486
 
... ... function rg_repo_git_done($db, $repo_id)
459 489 */ */
460 490 function rg_repo_rights_get($db, $ri, $uid, $flags) function rg_repo_rights_get($db, $ri, $uid, $flags)
461 491 { {
492 rg_prof_start("repo_rights_get");
493
462 494 rg_log("rg_repo_rights_get: repo_id=" . $ri['repo_id'] . ", uid=$uid" rg_log("rg_repo_rights_get: repo_id=" . $ri['repo_id'] . ", uid=$uid"
463 495 . " flags=$flags..."); . " flags=$flags...");
464 496
 
... ... function rg_repo_rights_get($db, $ri, $uid, $flags)
495 527 . $r['rights'] . ")=" . $ret['rights']); . $r['rights'] . ")=" . $ret['rights']);
496 528 $ret['ok'] = 1; $ret['ok'] = 1;
497 529
530 rg_prof_end("repo_rights_get");
531
498 532 return $ret; return $ret;
499 533 } }
500 534
File inc/sess.inc.php changed (mode: 100644) (index 5646012..4a0164d)
2 2 require_once($INC . "/log.inc.php"); require_once($INC . "/log.inc.php");
3 3 require_once($INC . "/sql.inc.php"); require_once($INC . "/sql.inc.php");
4 4 require_once($INC . "/token.inc.php"); require_once($INC . "/token.inc.php");
5 require_once($INC . "/prof.inc.php");
5 6
6 7 /* /*
7 8 * Add a session * Add a session
8 9 */ */
9 10 function rg_sess_add($db, $uid, $sid, $session_time) function rg_sess_add($db, $uid, $sid, $session_time)
10 11 { {
12 rg_prof_start("sess_add");
13
11 14 rg_log("sess_add: uid=$uid, sid=$sid, session_time=$session_time."); rg_log("sess_add: uid=$uid, sid=$sid, session_time=$session_time.");
12 15
13 16 $ip = @$_SERVER['REMOTE_ADDR']; $ip = @$_SERVER['REMOTE_ADDR'];
 
... ... function rg_sess_add($db, $uid, $sid, $session_time)
23 26 } }
24 27 rg_sql_free_result($res); rg_sql_free_result($res);
25 28
29 rg_prof_end("sess_add");
30
26 31 return TRUE; return TRUE;
27 32 } }
28 33
 
... ... function rg_sess_add($db, $uid, $sid, $session_time)
31 36 */ */
32 37 function rg_sess_valid($db, $sid) function rg_sess_valid($db, $sid)
33 38 { {
39 rg_prof_start("sess_valid");
40
34 41 rg_log("sess_valid: sid=$sid..."); rg_log("sess_valid: sid=$sid...");
35 42
36 43 $uid = FALSE; $uid = FALSE;
 
... ... function rg_sess_valid($db, $sid)
57 64 rg_log("\tSession not found!"); rg_log("\tSession not found!");
58 65 } }
59 66
67 rg_prof_end("sess_valid");
68
60 69 return $uid; return $uid;
61 70 } }
62 71
 
... ... function rg_sess_valid($db, $sid)
65 74 */ */
66 75 function rg_sess_update($db, $sid) function rg_sess_update($db, $sid)
67 76 { {
77 rg_prof_start("sess_update");
78
68 79 rg_log("sess_update: sid=$sid..."); rg_log("sess_update: sid=$sid...");
69 80
70 81 $e_sid = rg_sql_escape($db, $sid); $e_sid = rg_sql_escape($db, $sid);
 
... ... function rg_sess_update($db, $sid)
78 89 } }
79 90 rg_sql_free_result($res); rg_sql_free_result($res);
80 91
92 rg_prof_end("sess_update");
93
81 94 return TRUE; return TRUE;
82 95 } }
83 96
 
... ... function rg_sess_update($db, $sid)
86 99 */ */
87 100 function rg_sess_destroy($db, $sid, &$rg_ui) function rg_sess_destroy($db, $sid, &$rg_ui)
88 101 { {
102 rg_prof_start("sess_destroy");
103
89 104 rg_log("sess_destroy: sid=$sid..."); rg_log("sess_destroy: sid=$sid...");
90 105
91 106 $e_sid = rg_sql_escape($db, $sid); $e_sid = rg_sql_escape($db, $sid);
 
... ... function rg_sess_destroy($db, $sid, &$rg_ui)
105 120 $rg_ui['uid'] = 0; $rg_ui['uid'] = 0;
106 121 $rg_ui['is_admin'] = 0; $rg_ui['is_admin'] = 0;
107 122
123 rg_prof_end("sess_destroy");
124
108 125 return TRUE; return TRUE;
109 126 } }
127
110 128 ?> ?>
File inc/sql.inc.php changed (mode: 100644) (index 4e855f0..0236cd2)
1 1 <?php <?php
2 2 require_once($INC . "/log.inc.php"); require_once($INC . "/log.inc.php");
3 require_once($INC . "/prof.inc.php");
3 4
4 5 $rg_sql_error = ""; $rg_sql_error = "";
5 6
 
... ... function rg_sql_open($str)
34 35 if ($rg_sql_debug > 0) if ($rg_sql_debug > 0)
35 36 rg_log("DB: opening [$str]..."); rg_log("DB: opening [$str]...");
36 37
38 rg_prof_set(array("db_conn" => 1));
39
40 $_s = microtime(TRUE);
37 41 $db = @pg_pconnect($str); $db = @pg_pconnect($str);
42 $diff = sprintf("%u", (microtime(TRUE) - $_s) * 1000);
43 rg_prof_set(array("db_conn_time_ms" => $diff));
38 44 if ($db === FALSE) { if ($db === FALSE) {
39 45 rg_sql_set_error("cannot connect to database (" . $php_errormsg . ")"); rg_sql_set_error("cannot connect to database (" . $php_errormsg . ")");
46 rg_prof_set(array("db_conn_errors" => 1));
40 47 return FALSE; return FALSE;
41 48 } }
42 49
 
... ... function rg_sql_query($db, $sql)
58 65 { {
59 66 global $rg_sql_debug; global $rg_sql_debug;
60 67
61 if ($rg_sql_debug > 0) {
68 $_s = microtime(TRUE);
69
70 if ($rg_sql_debug > 0)
62 71 rg_log("\tDB: running [$sql]..."); rg_log("\tDB: running [$sql]...");
63 $_s = microtime(TRUE);
64 }
65 72
66 73 $res = @pg_query($db, $sql); $res = @pg_query($db, $sql);
67 74 if ($res === FALSE) { if ($res === FALSE) {
68 75 rg_sql_set_error("$sql: " . @pg_last_error($db)); rg_sql_set_error("$sql: " . @pg_last_error($db));
76 rg_prof_set(array("query_errors" => 1));
69 77 return FALSE; return FALSE;
70 78 } }
71 79
72 if ($rg_sql_debug > 0) {
73 $diff = sprintf("%u", (microtime(TRUE) - $_s) * 1000);
74 $rows = rg_sql_num_rows($res);
80 $diff = sprintf("%u", (microtime(TRUE) - $_s) * 1000);
81 $rows = rg_sql_num_rows($res);
82 if ($rows == 0)
75 83 $arows = rg_sql_affected_rows($res); $arows = rg_sql_affected_rows($res);
84 else
85 $arows = 0;
86
87 if ($rg_sql_debug > 0)
76 88 rg_log("\tDB: Took " . $diff . "ms, $rows row(s), $arows affected"); rg_log("\tDB: Took " . $diff . "ms, $rows row(s), $arows affected");
77 }
89
90 rg_prof_set(array("queries" => 1,
91 "rows" => $rows,
92 "affected rows" => $arows,
93 "query_time_ms" => $diff));
78 94
79 95 return $res; return $res;
80 96 } }
File inc/user/forgot.form.php changed (mode: 100644) (index 6b6b4f5..f9bae34)
... ... $_forgot_form .= '
18 18 <br /> <br />
19 19
20 20 <label for="pass2"> <label for="pass2">
21 <span class="form_item_title">New password (retype)</span><br />
21 <span class="form_item_title">New password (re-type)</span><br />
22 22 <input type="password" name="pass2" value="" /> <input type="password" name="pass2" value="" />
23 23 </label> </label>
24 24 <br /> <br />
File inc/user/home-page.php changed (mode: 100644) (index 9255b7c..e485bef)
... ... if ($ui === FALSE) {
9 9 return; return;
10 10 } }
11 11
12 // menu
13 if ($ui['uid'] == $rg_ui['uid']) {
14 $second_menu = array(
15 "edit_info" => array(
16 "text" => "Edit info",
17 "op" => "edit_info"
18 ),
19 "change_pass" => array(
20 "text" => "Change password",
21 "op" => "change_pass"
22 ),
23 "keys" => array(
24 "text" => "SSH keys",
25 "op" => "keys"
26 )
27 );
28 }
29 12
30 13 // list of repositories // list of repositories
31 14 $_home .= rg_repo_list($db, "", $ui); $_home .= rg_repo_list($db, "", $ui);
File inc/user/repo-page.php changed (mode: 100644) (index fbc178d..08f9218)
... ... if ($ri === FALSE) {
22 22 $_more = array( $_more = array(
23 23 "owner" => $user, "owner" => $user,
24 24 "url" => rg_re_repopage($rr), "url" => rg_re_repopage($rr),
25 "ssh" => rg_re_repo_ssh($rr),
26 "git" => rg_re_repo_git($rr)
25 27 ); );
26 $_home .= rg_template($THEME . "/repo/main.html", $ri, $_more);
28 $ri2 = $ri;
29 $ri2['default_rights'] = implode(", ", rg_rights_text("repo", $ri['default_rights']));
30 $ri2['max_commit_size'] = $ri['max_commit_size'] == 0 ? "unlimited" : rg_1024($ri['max_commit_size']);
31 $ri2['max_users'] = $ri['max_users'] == 0 ? "unlimited" : rg_1000($ri['max_users']);
32 $_home .= rg_template($THEME . "/repo/main.html", $ri2, $_more);
27 33
28 34 $repo_dir = rg_repo_name2base($rr) . $repo . ".git"; $repo_dir = rg_repo_name2base($rr) . $repo . ".git";
29 35 putenv("GIT_DIR=$repo_dir"); putenv("GIT_DIR=$repo_dir");
File inc/util.inc.php changed (mode: 100644) (index 469a8cd..cbc80be)
... ... function rg_re_repopage($rr)
123 123 return $_SERVER['PHP_SELF'] . "?vv=$s"; return $_SERVER['PHP_SELF'] . "?vv=$s";
124 124 } }
125 125
126 function rg_re_repo_ssh($rr)
127 {
128 if (strcmp($rr['type'], "user") == 0)
129 $prefix = "/user";
130 else
131 $prefix = "";
132
133 return "ssh://rocketgit@" . $_SERVER['SERVER_NAME'] . $prefix . "/" . $rr['user'] . "/" . $rr['repo'];
134 }
135
136 function rg_re_repo_git($rr)
137 {
138 if (strcmp($rr['type'], "user") == 0)
139 $prefix = "/user";
140 else
141 $prefix = "";
142
143 return "git://" . $_SERVER['SERVER_NAME'] . $prefix . "/" . $rr['user'] . "/" . $rr['repo'];
144 }
145
126 146 function rg_var_str($name) function rg_var_str($name)
127 147 { {
128 148 $ret = ""; $ret = "";
File root/index.php changed (mode: 100644) (index e8d6d7f..8cf84a1)
2 2 error_reporting(E_ALL); error_reporting(E_ALL);
3 3 ini_set("track_errors", "On"); ini_set("track_errors", "On");
4 4
5 $_s = microtime(TRUE);
6
7 5 $INC = dirname(__FILE__) . "/../inc"; $INC = dirname(__FILE__) . "/../inc";
8 6 $ROOT = dirname(__FILE__); $ROOT = dirname(__FILE__);
9 7
 
... ... include_once($INC . "/user.inc.php");
19 17 include_once($INC . "/repo.inc.php"); include_once($INC . "/repo.inc.php");
20 18 include_once($INC . "/keys.inc.php"); include_once($INC . "/keys.inc.php");
21 19 include_once($INC . "/token.inc.php"); include_once($INC . "/token.inc.php");
20 include_once($INC . "/prof.inc.php");
21
22 rg_prof_start("MAIN");
22 23
23 24 rg_log_set_file("/var/log/rocketgit-web/main.log"); rg_log_set_file("/var/log/rocketgit-web/main.log");
24 25
 
... ... rg_log("After login_by_sid, rg_ui=" . print_r($rg_ui, TRUE));
102 103 $body = ""; $body = "";
103 104 // Chain dispatching // Chain dispatching
104 105 do { do {
106 rg_log("Dispatching to [$op]");
107
105 108 $redispatch = 0; $redispatch = 0;
106 109
107 110 // Re-init second line menu // Re-init second line menu
 
... ... if ($rg_ui['uid'] > 0)
145 148 else else
146 149 $rg_username = "Not logged in"; $rg_username = "Not logged in";
147 150
148 $_diff = sprintf("%u", (microtime(TRUE) - $_s) * 1000);
151 rg_prof_end("MAIN");
152
149 153 include($THEME . "/index.php"); include($THEME . "/index.php");
150 154
151 rg_log("Done in $_diff ms.");
155 rg_prof_log();
152 156 ?> ?>
File root/themes/default/index.php changed (mode: 100644) (index dea7404..aa76e2a)
32 32 </div> </div>
33 33
34 34 <div id="profiling"> <div id="profiling">
35 <small>Profiling: <?php echo $_diff; ?>ms.</small>
35 Profiling:<br />
36 <?php echo rg_prof_html(); ?>
36 37 </div> </div>
37 38
38 39 </div> <!-- container --> </div> <!-- container -->
File root/themes/default/main.css changed (mode: 100644) (index 88c2437..570e501)
... ... th, td {
103 103 background-color: #eeeeee; background-color: #eeeeee;
104 104 padding: 5px 5px; padding: 5px 5px;
105 105 border-bottom: 1px solid #000000; border-bottom: 1px solid #000000;
106 font-size: 9pt;
106 107 } }
107 108
108 109 .error { .error {
File root/themes/default/repo/main.html changed (mode: 100644) (index 86622d7..75d56c4)
1 1 <span class="repo_title"><a href="@@url@@">@@owner@@/@@name@@</a></span><br /> <span class="repo_title"><a href="@@url@@">@@owner@@/@@name@@</a></span><br />
2 2 <span class="repo_desc">@@description@@</span><br /> <span class="repo_desc">@@description@@</span><br />
3 3 <br /> <br />
4 Git: <a href="@@git@@">@@git@@</a><br />
5 SSH: <a href="@@ssh@@">@@ssh@@</a><br />
6 <br />
7
8 Max commit size: @@max_commit_size@@<br />
9 Maximum number of users: @@max_users@@<br />
10 Rights: @@default_rights@@<br />
11 <br />
4 12
5 13 <a href="@@url@@/log">Log</a> <a href="@@url@@/log">Log</a>
6 14 <a href="@@url@@/tree">Tree</a> <a href="@@url@@/tree">Tree</a>
File scripts/q.php changed (mode: 100644) (index f8a43d7..da01acd)
... ... $INC = dirname(__FILE__) . "/../inc";
13 13 require_once($INC . "/log.inc.php"); require_once($INC . "/log.inc.php");
14 14 require_once($INC . "/sql.inc.php"); require_once($INC . "/sql.inc.php");
15 15 require_once($INC . "/repo.inc.php"); require_once($INC . "/repo.inc.php");
16 require_once($INC . "/prof.inc.php");
17
18 rg_prof_start("MAIN");
16 19
17 20 rg_log_set_file("/var/log/rocketgit/q.log"); rg_log_set_file("/var/log/rocketgit/q.log");
18 21
 
... ... while (TRUE) {
111 114 sleep(10); sleep(10);
112 115 } }
113 116
114 $_diff = sprintf("%u", microtime(TRUE) - $_s);
115 rg_log("Done in " . $_diff . "s!");
117 rg_prof_end("MAIN");
118 rg_prof_log();
116 119 ?> ?>
File tests/Makefile changed (mode: 100644) (index ce989f6..2943db5)
1 tests := util db keys repo rights state user git hook_update hook_pre-receive
1 tests := util db keys repo rights state user git hook_update hook_pre-receive prof
2 2 .PHONY: $(tests) .PHONY: $(tests)
3 3
4 4 all: $(tests) all: $(tests)
 
... ... hook_update:
33 33 hook_pre-receive: hook_pre-receive:
34 34 ./hook_pre-receive.sh ./hook_pre-receive.sh
35 35
36 prof:
37 php prof.php
36 38
37 39 .PHONY: clean .PHONY: clean
38 40 clean: clean:
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