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 954ee41b76dcfe6920ebd36bd81453bc26276890

Checkpoint
Author: Catalin(ux) M. BOIE
Author date (UTC): 2014-11-14 22:37
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2014-11-14 22:37
Parent(s): 91a81af5a65c575fa1d61ac9cc5eb759b746a9ed
Signing key:
Tree: 48c77fbac8bc9c0019fa0712800a7af00e547184
File Lines added Lines deleted
TODO 41 22
admin/init.php 7 4
configure 1 1
inc/admin/admin.php 0 1
inc/admin/plans/plans.php 1 1
inc/bug.inc.php 18 14
inc/cache.inc.php 22 7
inc/events.inc.php 24 11
inc/feedback/suggestion.php 7 7
inc/git.inc.php 92 60
inc/keys.inc.php 29 18
inc/login/login.php 6 8
inc/plan.inc.php 2 2
inc/prof.inc.php 19 5
inc/repo.inc.php 121 78
inc/rights.inc.php 11 9
inc/sess.inc.php 20 12
inc/sql.inc.php 3 3
inc/struct.inc.php 5 4
inc/user.inc.php 10 19
inc/user/forgot_send.php 3 4
inc/user/keys/keys.php 18 18
inc/user/pass/pass.php 3 2
inc/user/repo-page.php 38 40
inc/user/repo/bug/main.php 22 21
inc/user/repo/bug/search/search.php 8 9
inc/user/repo/bug/show/add_note.php 7 7
inc/user/repo/bug/show/show.php 33 39
inc/util.inc.php 28 14
inc/watch.inc.php 21 13
root/index.php 0 1
root/themes/default/hints/repo/edit_repo_refs_rights.html 2 2
root/themes/default/hints/repo/edit_rights.html 1 2
root/themes/default/repo/bug/search/remove.html 1 1
root/themes/default/repo/bug/search/search.html 1 1
root/themes/default/repo/bug/show.html 1 1
root/themes/default/repo/list/line.html 1 1
root/themes/default/repo/main.html 1 1
root/themes/default/user/repo/rights/form_repo.html 1 1
root/themes/default/user/repo/rights/form_repo_path.html 1 1
root/themes/default/user/repo/rights/form_repo_refs.html 1 1
root/themes/default/user/repo/rights/list_repo/line.html 1 1
root/themes/default/user/repo/rights/list_repo_path/line.html 1 1
root/themes/default/user/repo/rights/list_repo_refs/line.html 1 1
samples/rg.conf 7 0
scripts/cache.php 8 6
scripts/cron.php 6 4
scripts/events.php 1 1
scripts/q.php 1 1
selinux/rocketgit.te 5 5
tests/prof.php 18 0
File TODO changed (mode: 100644) (index 143d8f7..88e58b2)
1 1 == Where I stopped last time == == Where I stopped last time ==
2 [ ] In loguri, la username, paar unele cu '?'. O fi de la cache + bug-ul in user.inc?
2 [ ] Investigate "event_signal_daemon: event_id=[] timeout=ms"
3 NULL=no_wait, 0=forever
4 rg_event_signal_daemon - timeout 0 OK
5 rg_socket - timeout 0 OK
6 socket_recv_wait - timeout 0
7 $rg_cache_timeout is pretty safe (0 or >0, NULL does not make sense)
8
9 change NULL=forever, 0=no_wait
10 rg_event_signal_daemon - timeout 0 OK
11 rg_socket - timeout 0 OK
12 socket_recv_wait - timeout 0
13 $rg_cache_timeout is pretty safe (0 or >0, NULL does not make sense)
14
15
16 [ ] cache: on timeout, should we close the connection?
17 Probably not, but we should flush the input after a timeout.
18 [ ] Description passed in e-mail, may have security implications?
19 [ ] Seems that repo description is not updated under repo name. A caching
20 problem?
21 [ ] Replace rg_var_str with rg_var_str_core. It is ok to not have escaped in
22 db, but be careful with "HTML:" construct! Audit all HTML: and then
23 switch. Do not forget that is a problem how it works now:
24 for example, description that contains '<' will not work correctly.
25 The problem is with HTML: vars that include unescaped vars.
26 Is it possible?
27 Seems is working for repo description. Do it everywhere?
28 [ ] In loguri, la username, apar unele cu '?'. O fi de la cache
29 + bug-ul in user.inc?
3 30 [ ] We should invalidate rights cache when repo goes from public -> private [ ] We should invalidate rights cache when repo goes from public -> private
4 31 and viceversa. and viceversa.
5 [ ] For autogenerated rights, disable also edit button.
6 [ ] adding rights is not working
7 32 [ ] We should not call cosmetic in rights hl because we anyway load again the [ ] We should not call cosmetic in rights hl because we anyway load again the
8 33 list. list.
9 [ ] Use can_be_deleted when showing delete checkboxes for rights. Done. Test.
10 34 [ ] Add unit test for inject functions. [ ] Add unit test for inject functions.
11 35 [ ] When changing rights, invalidate/update cache. [ ] When changing rights, invalidate/update cache.
12 36 [ ] Retest repo rename. Better, add an unit test. [ ] Retest repo rename. Better, add an unit test.
13 [ ] who_text or other name?
14 37 [ ] We have big races for cache. But, the same with the database. [ ] We have big races for cache. But, the same with the database.
15 [ ] Maybe we should model memory cache after network cache, so we can
16 invalidate whole trees of stuff. Right now, we cannot because we build
17 a string with '|' delimiter. It is already done, we should get rid of
18 custom caches in all files!
19 [ ] See, for regular expressions we need to output them in browser as
20 html escaped. The rest of the variables must be stored escaped in db.
21 Strange.
22 38 [ ] We must test in HL functions if we have rights, not in rg_user_remove & co. [ ] We must test in HL functions if we have rights, not in rg_user_remove & co.
23 39 [ ] The caller of rg_user_make_admin must check rights for administering repo. [ ] The caller of rg_user_make_admin must check rights for administering repo.
24 40 [ ] What right is "Access repo"?! I think is for web. Not clear. Check. [ ] What right is "Access repo"?! I think is for web. Not clear. Check.
25 41 Seems is used on repo-page.php to give access or not to the repo. Seems is used on repo-page.php to give access or not to the repo.
26 42 But I should only check if is public. But I should only check if is public.
27 [ ] We must return error if a user tries to drop 'fetch' for a public repo.
28 But if the user switch it to be private repo? It's the user problem.
29 [ ] Special case: rights are empty and repo is public. Should I test
30 default rights only? Same with private repos.
31 [ ] Remove rg_menu stuff (replaced with templates).
43 No, because the same test is used also for pivate repos.
44 [ ] If a project is private and the admin gives "Access repo" to a user,
45 that user sees the repo as public. Unit test.
32 46 [ ] Run hook_update.sh test. It not passes anymore. [ ] Run hook_update.sh test. It not passes anymore.
33 47 [ ] I have to define what means a 'public' repo: fetch + see bugtracker? [ ] I have to define what means a 'public' repo: fetch + see bugtracker?
34 48 [ ] In the process to remove 'ri.rights_text' and replace by 'public'. [ ] In the process to remove 'ri.rights_text' and replace by 'public'.
35 [ ] How to prevent a user to cut his access from an IP? Maybe admin should not
36 filter by IP.
37 [ ] If a project is private and the admin gives "Access repo" to a user,
38 that user sees the repo as public.
49 [ ] serialize returns a binary string! Not ok to store it like this in db!
39 50
40 51 == BEFORE NEXT RELEASE == == BEFORE NEXT RELEASE ==
52 [ ] keywords for search. Really needed?
53 [ ] check: seems the browser uses 0x0d instead of 0x0a in textareas. unify?
54 [ ] performance: update session only after the page was sent to the client!
55 [ ] ionut: http://blogs.atlassian.com/2014/10/git-summit-2014-video-roundup/?atl_medium=ACE
56 [ ] Get rid of custom caches in all files!
57 [ ] Remove rg_menu stuff (replaced with templates).
58 [ ] Repo owner can e-mail to users that watch?
59 [ ] Enforce commit messages formats based on a regex.
60 [ ] Add redirect to HTTPS and enable HSTS
41 61 [ ] If a user has all rights, show "All" instead of full list. [ ] If a user has all rights, show "All" instead of full list.
42 62 Do this in rg_rights_text? Do this in rg_rights_text?
43 63 [ ] Should a user see her/his rights? [ ] Should a user see her/his rights?
44 64 [ ] Add rights 'allow non-ascii file names'. [ ] Add rights 'allow non-ascii file names'.
45 [ ] Add 'desc' to rights.
46 65 [ ] We should not show delete checkboxes/buttons if a user is not allowed [ ] We should not show delete checkboxes/buttons if a user is not allowed
47 66 to delete items. to delete items.
48 67 [ ] In cache, what if a var has \n in it? [ ] In cache, what if a var has \n in it?
File admin/init.php changed (mode: 100644) (index 343a3cf..291efde)
... ... $_u['is_admin'] = 1;
45 45 $_u['rights'] = rg_rights_all("user"); $_u['rights'] = rg_rights_all("user");
46 46 $_u['session_time'] = 3600; $_u['session_time'] = 3600;
47 47 $_u['confirm_token'] = ""; $_u['confirm_token'] = "";
48 do {
48 while (1) {
49 49 $username0 = readline("User [" . $_u['username'] . "]: "); $username0 = readline("User [" . $_u['username'] . "]: ");
50 50 if (!empty($username0)) if (!empty($username0))
51 51 $_u['username'] = $username0; $_u['username'] = $username0;
 
... ... do {
53 53 if (!empty($email0)) if (!empty($email0))
54 54 $_u['email'] = $email0; $_u['email'] = $email0;
55 55
56 do {
56 while(1) {
57 57 $_u['pass'] = readline("Password: "); $_u['pass'] = readline("Password: ");
58 58 $_u['pass2'] = readline("Password (confirmation): "); $_u['pass2'] = readline("Password (confirmation): ");
59 59 if (strcmp($_u['pass'], $_u['pass2']) != 0) { if (strcmp($_u['pass'], $_u['pass2']) != 0) {
60 60 echo "Passwords mismatch!\n"; echo "Passwords mismatch!\n";
61 61 continue; continue;
62 62 } }
63 } while(0);
63 break;
64 }
64 65
65 66 $r = rg_user_info($db, $_u['uid'], $_u['username'], "" /* email */); $r = rg_user_info($db, $_u['uid'], $_u['username'], "" /* email */);
66 67 if ($r['ok'] != 1) { if ($r['ok'] != 1) {
 
... ... do {
79 80 echo "Cannot create user (" . rg_user_error() . ")!\n"; echo "Cannot create user (" . rg_user_error() . ")!\n";
80 81 continue; continue;
81 82 } }
82 } while (0);
83
84 break;
85 }
83 86
84 87
85 88 // Store the timestamp of the first install // Store the timestamp of the first install
File configure changed (mode: 100755) (index d33bb6c..92c4bc4)
1 1 #!/bin/bash #!/bin/bash
2 2
3 ./duilder
3 ./duilder "${@}"
File inc/admin/admin.php changed (mode: 100644) (index 706e05f..5e31f9d)
1 1 <?php <?php
2 2 rg_log("FILE: /inc/admin/admin"); rg_log("FILE: /inc/admin/admin");
3 3
4 $admin_more = $rg;
5 4 $_admin = ""; $_admin = "";
6 5
7 6 if ($rg['login_ui']['is_admin'] != 1) { if ($rg['login_ui']['is_admin'] != 1) {
File inc/admin/plans/plans.php changed (mode: 100644) (index cee1baa..e35fd30)
... ... case 'list': // list
10 10 break; break;
11 11
12 12 case 'edit': // edit case 'edit': // edit
13 $admin_more['id'] = empty($paras) ? 0 : array_shift($paras);
13 $rg['id'] = empty($paras) ? 0 : array_shift($paras);
14 14 // no break here // no break here
15 15 case 'add': // add case 'add': // add
16 16 $_admin_plans .= rg_plan_edit_high_level($db, $rg); $_admin_plans .= rg_plan_edit_high_level($db, $rg);
File inc/bug.inc.php changed (mode: 100644) (index 3eb0f63..c00813a)
... ... function rg_bug_event_add_all($db, $event)
115 115 */ */
116 116 function rg_bug_event_note_add_one($db, $event) function rg_bug_event_note_add_one($db, $event)
117 117 { {
118 rg_log("DEBUG: bug_event_note_add_one event=" . rg_array2string($event));
118 rg_log_enter("DEBUG: bug_event_note_add_one event=" . rg_array2string($event));
119 119
120 120 $ret = FALSE; $ret = FALSE;
121
122 do {
121 while (1) {
123 122 // lookup user email // lookup user email
124 123 $ui = rg_user_info($db, $event['uid'], "", ""); $ui = rg_user_info($db, $event['uid'], "", "");
125 124 if ($ui['exists'] != 1) { if ($ui['exists'] != 1) {
 
... ... function rg_bug_event_note_add_one($db, $event)
131 130 $event['ui.email'] = $ui['email']; $event['ui.email'] = $ui['email'];
132 131 $r = rg_mail("mail/user/repo/bug/new_note", $event); $r = rg_mail("mail/user/repo/bug/new_note", $event);
133 132 if ($r === FALSE) if ($r === FALSE)
134 return FALSE;
135 } while (0);
133 break;
134
135 $ret = array();
136 break;
137 }
136 138
137 return array();
139 rg_log_exit();
140 return $ret;
138 141 } }
139 142
140 143 /* /*
 
... ... function rg_bug_cosmetic($db, &$row)
295 298 } }
296 299
297 300 $row['deleted_text'] = ""; $row['deleted_text'] = "";
298 $row['deleted_who_text'] = "";
301 $row['deleted_who_name'] = "";
299 302 if (isset($row['deleted_who']) && ($row['deleted_who'] > 0)) { if (isset($row['deleted_who']) && ($row['deleted_who'] > 0)) {
300 303 $_ui = rg_user_info($db, $row['deleted_who'], "", ""); $_ui = rg_user_info($db, $row['deleted_who'], "", "");
301 304 if ($_ui['exists'] == 1) if ($_ui['exists'] == 1)
302 $row['deleted_who_text'] = $_ui['username'];
305 $row['deleted_who_name'] = $_ui['username'];
303 306
304 307 $row['deleted_text'] = gmdate("Y-m-d H:i", $row['deleted']); $row['deleted_text'] = gmdate("Y-m-d H:i", $row['deleted']);
305 308 } }
 
... ... function rg_bug_info($db, $repo_id, $bug_id)
320 323 $ret['exists'] = 0; $ret['exists'] = 0;
321 324 while (1) { while (1) {
322 325 $key = $repo_id . "::bugs::" . $bug_id; $key = $repo_id . "::bugs::" . $bug_id;
323 $ret = rg_cache_get($key);
324 if ($ret !== FALSE)
326 $c = rg_cache_get($key);
327 if ($c !== FALSE) {
328 $ret = $c;
325 329 break; break;
330 }
326 331
327 332 $params = array("repo_id" => $repo_id, $params = array("repo_id" => $repo_id,
328 333 "bug_id" => $bug_id); "bug_id" => $bug_id);
 
... ... function rg_bug_info($db, $repo_id, $bug_id)
338 343 $rows = rg_sql_num_rows($res); $rows = rg_sql_num_rows($res);
339 344 if ($rows == 1) if ($rows == 1)
340 345 $ret = rg_sql_fetch_array($res); $ret = rg_sql_fetch_array($res);
341 $ret['ok'] = 1;
342 346 rg_sql_free_result($res); rg_sql_free_result($res);
343 347
348 $ret['ok'] = 1;
344 349 $ret['exists'] = $rows; $ret['exists'] = $rows;
345 350 if ($ret['exists'] == 1) if ($ret['exists'] == 1)
346 351 rg_bug_cosmetic($db, $ret); rg_bug_cosmetic($db, $ret);
 
... ... function rg_bug_search_remove($db, $repo_id, $uid, $name)
909 914 "uid" => $uid, "uid" => $uid,
910 915 "name" => $name); "name" => $name);
911 916 $sql = "DELETE FROM bug_search" $sql = "DELETE FROM bug_search"
912 . " WHERE repo_id = @@repo_id@@"
917 . " WHERE (repo_id = 0 OR repo_id = @@repo_id@@)"
913 918 . " AND uid = @@uid@@" . " AND uid = @@uid@@"
914 919 . " AND name = @@name@@"; . " AND name = @@name@@";
915 920 $res = rg_sql_query_params($db, $sql, $params); $res = rg_sql_query_params($db, $sql, $params);
 
... ... function rg_bug_label_html($db, $labels)
1221 1226 /* /*
1222 1227 * High level function for adding/creating a bug * High level function for adding/creating a bug
1223 1228 */ */
1224 function rg_bug_edit_high_level($db, $rg)
1229 function rg_bug_edit_high_level($db, &$rg)
1225 1230 { {
1226 1231 rg_log_enter("rg_bug_edit_high_level"); rg_log_enter("rg_bug_edit_high_level");
1227 1232
 
... ... function rg_bug_edit_high_level($db, $rg)
1287 1292 return $ret; return $ret;
1288 1293 } }
1289 1294
1290
1291 1295 ?> ?>
File inc/cache.inc.php changed (mode: 100644) (index 0567530..e3007db)
... ... function rg_cache_get($ns_var)
298 298
299 299 $c = rg_socket($rg_cache_socket, $c = rg_socket($rg_cache_socket,
300 300 "GET " . $ns_var . "\n", $rg_cache_timeout); "GET " . $ns_var . "\n", $rg_cache_timeout);
301 if ($c === FALSE)
301 if ($c === FALSE) {
302 // Give up for the rest of the session
303 $rg_cache_enable = FALSE;
302 304 break; break;
305 }
303 306
304 307 $t = explode(" ", $c, 2); $t = explode(" ", $c, 2);
305 308 if (strcmp($t[0], "OK") != 0) if (strcmp($t[0], "OK") != 0)
 
... ... function rg_cache_get($ns_var)
308 311 if (!isset($t[1])) if (!isset($t[1]))
309 312 break; break;
310 313
311 $ret = @unserialize(trim($t[1]));
312 if ($ret === FALSE)
314 $x = trim(stripcslashes($t[1]));
315 $ret = @unserialize($x);
316 if ($ret === FALSE) {
317 file_put_contents("/tmp/rg_debug", $x);
313 318 break; break;
319 }
314 320
315 321 rg_cache_core_set($ns_var, $ret); rg_cache_core_set($ns_var, $ret);
316 322
 
... ... function rg_cache_get($ns_var)
322 328 return $ret; return $ret;
323 329 } }
324 330
331 /*
332 * Prepares a string to be send to the wire
333 */
334 function rg_cache_prepare($s)
335 {
336 $x = serialize($s);
337 return addcslashes($x, "\n\r\\");
338 }
339
325 340 /* /*
326 341 * Sets a variable in the cache daemon * Sets a variable in the cache daemon
327 342 */ */
 
... ... function rg_cache_set($ns_var, $value)
341 356 if ($rg_cache_enable === FALSE) if ($rg_cache_enable === FALSE)
342 357 break; break;
343 358
344 $c = rg_socket($rg_cache_socket,
345 "SET " . $ns_var . "=" . serialize($value) . "\n", $rg_cache_timeout);
359 $c = rg_socket($rg_cache_socket, "SET " . $ns_var . "="
360 . rg_cache_prepare($value) . "\n", $rg_cache_timeout);
346 361 if ($c === FALSE) if ($c === FALSE)
347 362 break; break;
348 363
 
... ... function rg_cache_merge($ns_var, $list)
454 469 if ($rg_cache_enable === FALSE) if ($rg_cache_enable === FALSE)
455 470 break; break;
456 471
457 $c = rg_socket($rg_cache_socket,
458 "MERGE " . $ns_var . "=" . serialize($list) . "\n", $rg_cache_timeout);
472 $c = rg_socket($rg_cache_socket, "MERGE " . $ns_var . "="
473 . rg_cache_prepare($list) . "\n", $rg_cache_timeout);
459 474 if ($c === FALSE) if ($c === FALSE)
460 475 break; break;
461 476
File inc/events.inc.php changed (mode: 100644) (index 9f4ea26..3c797cb)
... ... function rg_event_register_functions($functions)
48 48
49 49 /* /*
50 50 * Signals the daemon that there is some work to do * Signals the daemon that there is some work to do
51 * @timeout == NULL, do not wait, 0 = wait forever, else, wait @timeout miliseconds.
51 * @timeout == NULL=forever, 0=no_wait, else, wait @timeout ms
52 52 */ */
53 53 function rg_event_signal_daemon($ev_id, $timeout) function rg_event_signal_daemon($ev_id, $timeout)
54 54 { {
 
... ... function rg_event_signal_daemon($ev_id, $timeout)
57 57 if (empty($rg_event_socket)) if (empty($rg_event_socket))
58 58 return TRUE; return TRUE;
59 59
60 if ($timeout === NULL)
61 $s_timeout = "forever";
62 else if ($timeout === 0)
63 $s_timeout = "no_wait";
64 else
65 $s_timeout = $timeout . "ms";
66
60 67 rg_prof_start("event_signal_daemon"); rg_prof_start("event_signal_daemon");
61 rg_log("event_signal_daemon: event_id=[$ev_id] timeout=" . $timeout . "ms");
68 rg_log("event_signal_daemon: event_id=[$ev_id] timeout=$s_timeout");
62 69
63 70 if (empty($ev_id)) if (empty($ev_id))
64 71 $buf = "W"; $buf = "W";
 
... ... function rg_event_signal_daemon($ev_id, $timeout)
75 82 function rg_event_add($db, $event) function rg_event_add($db, $event)
76 83 { {
77 84 rg_prof_start("event_add"); rg_prof_start("event_add");
78 rg_log("event_add: event=" . rg_array2string($event));
85 rg_log_enter("event_add: event=" . rg_array2string($event));
79 86
80 87 $ret = FALSE; $ret = FALSE;
81 do {
88 while (1) {
82 89 $now = time(); $now = time();
83 90 $prio = $event['prio']; unset($event['prio']); $prio = $event['prio']; unset($event['prio']);
84 91 $params = array("now" => $now, $params = array("now" => $now,
 
... ... function rg_event_add($db, $event)
96 103 rg_event_signal_daemon("", NULL); rg_event_signal_daemon("", NULL);
97 104
98 105 $ret = TRUE; $ret = TRUE;
99 } while (0);
106 break;
107 }
100 108
109 rg_log_exit();
101 110 rg_prof_end("event_add"); rg_prof_end("event_add");
102 111 return $ret; return $ret;
103 112 } }
 
... ... function rg_event_process($db, $event)
110 119 global $rg_event_split_functions; global $rg_event_split_functions;
111 120
112 121 rg_prof_start("event_process"); rg_prof_start("event_process");
113 rg_log("event_process: event=" . rg_array2string($event));
122 rg_log_enter("event_process: event=" . rg_array2string($event));
114 123
115 124 $ret = FALSE; $ret = FALSE;
116 do {
125 while (1) {
117 126 $category = $event['category']; $category = $event['category'];
118 127 unset($event['category']); unset($event['category']);
119 128
 
... ... function rg_event_process($db, $event)
148 157 break; break;
149 158
150 159 $ret = TRUE; $ret = TRUE;
151 } while (0);
160 break;
161 }
152 162
163 rg_log_exit();
153 164 rg_prof_end("event_process"); rg_prof_end("event_process");
154 165 return $ret; return $ret;
155 166 } }
 
... ... function rg_event_notify(&$notify_list, $ev_id, $misc)
210 221 function rg_event_process_queue($db, &$notify_list) function rg_event_process_queue($db, &$notify_list)
211 222 { {
212 223 rg_prof_start("event_process_queue"); rg_prof_start("event_process_queue");
213 rg_log("event_process_queue: notify_list: "
224 rg_log_enter("event_process_queue: notify_list: "
214 225 . rg_array2string($notify_list)); . rg_array2string($notify_list));
215 226
216 227 $ret = FALSE; $ret = FALSE;
217 228 $do_rollback = 0; $do_rollback = 0;
218 do {
229 while (1) {
219 230 $r = rg_sql_begin($db); $r = rg_sql_begin($db);
220 231 if ($r !== TRUE) { if ($r !== TRUE) {
221 232 rg_event_set_error("Cannot begin transaction" rg_event_set_error("Cannot begin transaction"
 
... ... function rg_event_process_queue($db, &$notify_list)
272 283
273 284 $ret = $no_of_events; $ret = $no_of_events;
274 285 $do_rollback = 0; $do_rollback = 0;
275 } while (0);
286 break;
287 }
276 288
277 289 if ($do_rollback == 1) if ($do_rollback == 1)
278 290 rg_sql_rollback($db); rg_sql_rollback($db);
279 291
292 rg_log_exit();
280 293 rg_prof_end("event_process_queue"); rg_prof_end("event_process_queue");
281 294 return $ret; return $ret;
282 295 } }
File inc/feedback/suggestion.php changed (mode: 100644) (index 585d3a7..ae653d1)
1 1 <?php <?php
2 2 rg_log("FILE: /feedback/suggestion"); rg_log("FILE: /feedback/suggestion");
3 3
4 $suggestion_more = $rg;
5 4 $_suggestion = ""; $_suggestion = "";
6 5
7 6 $errmsg = array(); $errmsg = array();
8 7 $show_form = 1; $show_form = 1;
9 8
10 do {
9 while (1) {
11 10 if ($rg['doit'] != 1) { if ($rg['doit'] != 1) {
12 11 // defaults // defaults
13 12 $suggestion = ""; $suggestion = "";
 
... ... do {
35 34
36 35 $show_form = 0; $show_form = 0;
37 36 $_suggestion .= rg_template("suggestion_sent.html", $rg); $_suggestion .= rg_template("suggestion_sent.html", $rg);
38 } while (0);
37 break;
38 }
39 39
40 40 if ($show_form == 1) { if ($show_form == 1) {
41 $suggestion_more['suggestion'] = $suggestion;
42 $suggestion_more['HTML:errmsg'] = rg_template_errmsg($errmsg);
43 $suggestion_more['rg_form_token'] = rg_token_get($db, $rg['sid']);
44 $_suggestion .= rg_template("suggestion.html", $suggestion_more);
41 $rg['suggestion'] = $suggestion;
42 $rg['HTML:errmsg'] = rg_template_errmsg($errmsg);
43 $rg['rg_form_token'] = rg_token_get($db, $rg['sid']);
44 $_suggestion .= rg_template("suggestion.html", $rg);
45 45 } }
46 46
47 47 ?> ?>
File inc/git.inc.php changed (mode: 100644) (index bc25461..d060bf7)
... ... function rg_git_install_hooks($dst)
53 53 global $rg_scripts; global $rg_scripts;
54 54
55 55 rg_prof_start("git_install_hooks"); rg_prof_start("git_install_hooks");
56 rg_log("git_install_hooks: dst=$dst");
56 rg_log_enter("git_install_hooks: dst=$dst");
57 57
58 58 $ret = FALSE; $ret = FALSE;
59 do {
59 while (1) {
60 60 if (file_exists($dst . "/hooks")) { if (file_exists($dst . "/hooks")) {
61 61 if (is_link($dst . "/hooks")) { if (is_link($dst . "/hooks")) {
62 62 $_dir = readlink($dst . "/hooks"); $_dir = readlink($dst . "/hooks");
 
... ... function rg_git_install_hooks($dst)
88 88 } }
89 89
90 90 $ret = TRUE; $ret = TRUE;
91 } while (0);
91 break;
92 }
92 93
94 rg_log_exit();
93 95 rg_prof_end("git_install_hooks"); rg_prof_end("git_install_hooks");
94 96 return $ret; return $ret;
95 97 } }
 
... ... function rg_git_install_hooks($dst)
100 102 function rg_git_init($dst) function rg_git_init($dst)
101 103 { {
102 104 rg_prof_start("git_init"); rg_prof_start("git_init");
103 rg_log("git_init: dst=$dst");
105 rg_log_enter("git_init: dst=$dst");
104 106
105 107 $ret = FALSE; $ret = FALSE;
106 do {
108 while (1) {
107 109 $dir = dirname($dst); $dir = dirname($dst);
108 110 if (!file_exists($dir)) { if (!file_exists($dir)) {
109 111 $r = @mkdir($dir, 0755, TRUE); $r = @mkdir($dir, 0755, TRUE);
 
... ... function rg_git_init($dst)
134 136 break; break;
135 137
136 138 $ret = TRUE; $ret = TRUE;
137 } while (0);
139 break;
140 }
138 141
142 rg_log_exit();
139 143 rg_prof_end("git_init"); rg_prof_end("git_init");
140 144 return $ret; return $ret;
141 145 } }
 
... ... function rg_git_init($dst)
143 147 function rg_git_clone($src, $dst) function rg_git_clone($src, $dst)
144 148 { {
145 149 rg_prof_start("git_clone"); rg_prof_start("git_clone");
146 rg_log("git_clone: src=$src, dst=$dst");
150 rg_log_enter("git_clone: src=$src, dst=$dst");
147 151
148 152 $ret = FALSE; $ret = FALSE;
149 do {
153 while (1) {
150 154 $dir = dirname($dst); $dir = dirname($dst);
151 155 if (!file_exists($dir)) { if (!file_exists($dir)) {
152 156 $r = @mkdir($dir, 0755, TRUE); $r = @mkdir($dir, 0755, TRUE);
 
... ... function rg_git_clone($src, $dst)
175 179 break; break;
176 180
177 181 $ret = TRUE; $ret = TRUE;
178 } while (0);
182 break;
183 }
179 184
185 rg_log_exit();
180 186 rg_prof_end("git_clone"); rg_prof_end("git_clone");
181 187 return $ret; return $ret;
182 188 } }
 
... ... function rg_git_type($obj)
189 195 global $rg_git_zero; global $rg_git_zero;
190 196
191 197 rg_prof_start("git_type"); rg_prof_start("git_type");
192 rg_log("git_type: obj=$obj");
198 rg_log_enter("git_type: obj=$obj");
193 199
194 200 $ret = FALSE; $ret = FALSE;
195 do {
201 while (1) {
196 202 if (strcmp($obj, $rg_git_zero) == 0) { if (strcmp($obj, $rg_git_zero) == 0) {
197 203 $ret = "zero"; $ret = "zero";
198 204 break; break;
 
... ... function rg_git_type($obj)
206 212 } }
207 213
208 214 $ret = trim($a['data']); $ret = trim($a['data']);
209 } while (0);
215 break;
216 }
210 217
218 rg_log_exit();
211 219 rg_prof_end("git_type"); rg_prof_end("git_type");
212 220 return $ret; return $ret;
213 221 } }
 
... ... function rg_git_type($obj)
218 226 function rg_git_content($obj) function rg_git_content($obj)
219 227 { {
220 228 rg_prof_start("git_content"); rg_prof_start("git_content");
221 rg_log("git_content: obj=$obj");
229 rg_log_enter("git_content: obj=$obj");
222 230
223 231 $ret = FALSE; $ret = FALSE;
224 do {
232 while (1) {
225 233 $cmd = "git cat-file -p '" . $obj . "'"; $cmd = "git cat-file -p '" . $obj . "'";
226 234 $a = rg_exec($cmd); $a = rg_exec($cmd);
227 235 if ($a['ok'] != 1) { if ($a['ok'] != 1) {
 
... ... function rg_git_content($obj)
230 238 } }
231 239
232 240 $ret = $a['data']; $ret = $a['data'];
233 } while (0);
241 break;
242 }
234 243
244 rg_log_exit();
235 245 rg_prof_end("git_content"); rg_prof_end("git_content");
236 246 return $ret; return $ret;
237 247 } }
 
... ... function rg_git_reference($refname)
264 274 function rg_git_rev_ok($rev) function rg_git_rev_ok($rev)
265 275 { {
266 276 rg_prof_start("git_rev_ok"); rg_prof_start("git_rev_ok");
267 rg_log("git_rev_ok: rev=$rev");
277 rg_log_enter("git_rev_ok: rev=$rev");
268 278
269 279 $ret = FALSE; $ret = FALSE;
270 do {
280 while (1) {
271 281 $cmd = "git rev-parse --verify '" . $rev . "'"; $cmd = "git rev-parse --verify '" . $rev . "'";
272 282 $a = rg_exec($cmd); $a = rg_exec($cmd);
273 283 if ($a['ok'] != 1) { if ($a['ok'] != 1) {
 
... ... function rg_git_rev_ok($rev)
276 286 } }
277 287
278 288 $ret = TRUE; $ret = TRUE;
279 } while (0);
289 break;
290 }
280 291
292 rg_log_exit();
281 293 rg_prof_end("git_rev_ok"); rg_prof_end("git_rev_ok");
282 294 return $ret; return $ret;
283 295 } }
 
... ... function rg_git_whitespace_ok($old, $new)
292 304 global $rg_git_empty; global $rg_git_empty;
293 305
294 306 rg_prof_start("git_whitespace_ok"); rg_prof_start("git_whitespace_ok");
295 rg_log("git_whitespace_ok: old=$old new=$new");
307 rg_log_enter("git_whitespace_ok: old=$old new=$new");
296 308
297 309 $ret = FALSE; $ret = FALSE;
298 do {
310 while (1) {
299 311 if (strcmp($old, $rg_git_zero) == 0) if (strcmp($old, $rg_git_zero) == 0)
300 312 $old = $rg_git_empty; $old = $rg_git_empty;
301 313
 
... ... function rg_git_whitespace_ok($old, $new)
310 322 } else { } else {
311 323 $ret = TRUE; $ret = TRUE;
312 324 } }
313 } while (0);
325 break;
326 }
314 327
328 rg_log_exit();
315 329 rg_prof_end("git_whitespace_ok"); rg_prof_end("git_whitespace_ok");
316 330 return $ret; return $ret;
317 331 } }
 
... ... function rg_git_whitespace_ok($old, $new)
320 334 function rg_git_merge_base($old, $new) function rg_git_merge_base($old, $new)
321 335 { {
322 336 rg_prof_start("git_merge_base"); rg_prof_start("git_merge_base");
323 rg_log("git_merge_base: old=$old new=$new");
337 rg_log_enter("git_merge_base: old=$old new=$new");
324 338
325 339 $ret = FALSE; $ret = FALSE;
326 do {
340 while (1) {
327 341 $cmd = "git merge-base " . $old . " " . $new; $cmd = "git merge-base " . $old . " " . $new;
328 342 $a = rg_exec($cmd); $a = rg_exec($cmd);
329 343 if ($a['ok'] != 1) { if ($a['ok'] != 1) {
 
... ... function rg_git_merge_base($old, $new)
332 346 } }
333 347
334 348 $ret = trim($a['data']); $ret = trim($a['data']);
335 } while (0);
349 break;
350 }
336 351
352 rg_log_exit();
337 353 rg_prof_end("git_merge_base"); rg_prof_end("git_merge_base");
338 354 return $ret; return $ret;
339 355 } }
 
... ... function rg_git_merge_base($old, $new)
346 362 function rg_git_update_ref($ref, $old, $new, $reason) function rg_git_update_ref($ref, $old, $new, $reason)
347 363 { {
348 364 rg_prof_start("git_update_ref"); rg_prof_start("git_update_ref");
349 rg_log("git_update_ref: ref=$ref old=$old new=$new reason=$reason");
365 rg_log_enter("git_update_ref: ref=$ref old=$old new=$new reason=$reason");
350 366
351 367 $ret = FALSE; $ret = FALSE;
352 do {
368 while (1) {
353 369 $cmd = "git update-ref"; $cmd = "git update-ref";
354 370 if (!empty($reason)) if (!empty($reason))
355 371 $cmd .= " -m " . escapeshellarg($reason); $cmd .= " -m " . escapeshellarg($reason);
 
... ... function rg_git_update_ref($ref, $old, $new, $reason)
369 385 } }
370 386
371 387 $ret = TRUE; $ret = TRUE;
372 } while (0);
388 break;
389 }
373 390
391 rg_log_exit();
374 392 rg_prof_end("git_update_ref"); rg_prof_end("git_update_ref");
375 393 return $ret; return $ret;
376 394 } }
 
... ... function rg_git_update_ref($ref, $old, $new, $reason)
381 399 function rg_git_ls_tree($tree, $path) function rg_git_ls_tree($tree, $path)
382 400 { {
383 401 rg_prof_start("git_ls_tree"); rg_prof_start("git_ls_tree");
384 rg_log("rg_git_ls_tree: tree=$tree path=$path");
402 rg_log_enter("rg_git_ls_tree: tree=$tree path=$path");
385 403
386 404 $ret = FALSE; $ret = FALSE;
387 do {
405 while (1) {
388 406 $op = " "; $op = " ";
389 407 if (empty($tree)) { if (empty($tree)) {
390 408 $op = " --full-tree"; $op = " --full-tree";
 
... ... function rg_git_ls_tree($tree, $path)
421 439 $_y['size'] = $_t[3]; $_y['size'] = $_t[3];
422 440 $ret[] = $_y; $ret[] = $_y;
423 441 } }
424 } while (0);
442 break;
443 }
425 444
426 445 // We are forced to use print_r instead of array2string because // We are forced to use print_r instead of array2string because
427 446 // it may be a multilevel array. // it may be a multilevel array.
428 447 rg_log_ml("DEBUG: ls-tree: " . print_r($ret, TRUE)); rg_log_ml("DEBUG: ls-tree: " . print_r($ret, TRUE));
429 448
449 rg_log_exit();
430 450 rg_prof_end("git_ls_tree"); rg_prof_end("git_ls_tree");
431 451 return $ret; return $ret;
432 452 } }
 
... ... function rg_git_diff2array($diff)
549 569 function rg_git_log($path, $max, $from, $to, $also_patch) function rg_git_log($path, $max, $from, $to, $also_patch)
550 570 { {
551 571 rg_prof_start("git_log"); rg_prof_start("git_log");
552 rg_log("git_log: path=$path from=$from to=$to max=$max");
572 rg_log_enter("git_log: path=$path from=$from to=$to max=$max");
553 573
554 574 $ret = FALSE; $ret = FALSE;
555 do {
575 while (1) {
556 576 if (!file_exists($path . "/refs/heads/master")) { if (!file_exists($path . "/refs/heads/master")) {
557 577 rg_log("\tRepo is empty."); rg_log("\tRepo is empty.");
558 return "";
578 $ret = "";
579 break;
559 580 } }
560 581
561 582 $max_count = ($max == 0) ? "" : " --max-count=$max"; $max_count = ($max == 0) ? "" : " --max-count=$max";
 
... ... function rg_git_log($path, $max, $from, $to, $also_patch)
659 680
660 681 $ret[] = $y; $ret[] = $y;
661 682 } }
662 } while (0);
683 break;
684 }
663 685
686 rg_log_exit();
664 687 rg_prof_end("git_log"); rg_prof_end("git_log");
665 688 return $ret; return $ret;
666 689 } }
 
... ... function rg_git_stats($log)
741 764 */ */
742 765 function rg_git_files($old, $new) function rg_git_files($old, $new)
743 766 { {
744 rg_log("rg_git_files old=$old new=$new");
745 767 rg_prof_start("git_files"); rg_prof_start("git_files");
768 rg_log_enter("rg_git_files old=$old new=$new");
746 769
747 770 // TODO: Here we can deny non ascii file names. Move to update_branch? // TODO: Here we can deny non ascii file names. Move to update_branch?
748 771 // git diff --cached --name-only --diff-filter=A -z $against | LC_ALL=C tr -d '[ -~]\0') // git diff --cached --name-only --diff-filter=A -z $against | LC_ALL=C tr -d '[ -~]\0')
 
... ... function rg_git_files($old, $new)
765 788 break; break;
766 789 } }
767 790
791 rg_log_exit();
768 792 rg_prof_end("git_files"); rg_prof_end("git_files");
769 793 return $ret; return $ret;
770 794 } }
 
... ... function rg_git_files($old, $new)
777 801 */ */
778 802 function rg_git_diff($a, $template_file) function rg_git_diff($a, $template_file)
779 803 { {
780 //rg_log("DEBUG: git_diff: a: " . rg_array2string($a));
781 804 rg_prof_start("git_diff"); rg_prof_start("git_diff");
805 //rg_log_enter("DEBUG: git_diff: a: " . rg_array2string($a));
782 806
783 807 $ret = "<div class=\"diff\">\n"; $ret = "<div class=\"diff\">\n";
784 808
 
... ... function rg_git_update_tag($db, $a)
894 918 global $rg_git_zero; global $rg_git_zero;
895 919
896 920 rg_prof_start("git_update_tag"); rg_prof_start("git_update_tag");
897 rg_log("git_update_tag: " . rg_array2string($a));
921 rg_log_enter("git_update_tag: " . rg_array2string($a));
898 922
899 923 $ip = $a['ip']; $ip = $a['ip'];
900 924 $uid = $a['login_uid']; $uid = $a['login_uid'];
 
... ... function rg_git_update_tag($db, $a)
945 969 // We can clean now the namespace - TODO // We can clean now the namespace - TODO
946 970 } }
947 971
972 rg_log_exit();
948 973 rg_prof_end("git_update_tag"); rg_prof_end("git_update_tag");
949 974 } }
950 975
 
... ... function rg_git_refs($repo_path)
1095 1120 */ */
1096 1121 function rg_git_branches_and_tags($repo_dir, $base_url, $current_ref) function rg_git_branches_and_tags($repo_dir, $base_url, $current_ref)
1097 1122 { {
1098 rg_log("git_branches_and_tags: repo_dir=$repo_dir base_url=$base_url"
1123 rg_log_enter("git_branches_and_tags: repo_dir=$repo_dir base_url=$base_url"
1099 1124 . " current_ref=$current_ref"); . " current_ref=$current_ref");
1100 1125
1101 1126 $ret = array(); $ret = array();
 
... ... function rg_git_branches_and_tags($repo_dir, $base_url, $current_ref)
1139 1164
1140 1165 rg_log("rg_git_branches_and_tags: ret:" . rg_array2string($ret)); rg_log("rg_git_branches_and_tags: ret:" . rg_array2string($ret));
1141 1166
1167 rg_log_exit();
1142 1168 return $ret; return $ret;
1143 1169 } }
1144 1170
 
... ... function rg_git_parse_ref(&$paras)
1185 1211 function rg_git_diff_tree($tree1, $tree2) function rg_git_diff_tree($tree1, $tree2)
1186 1212 { {
1187 1213 rg_prof_start("git_diff_tree"); rg_prof_start("git_diff_tree");
1188 rg_log("rg_git_diff_tree: tree1=$tree1 tree2=$tree2");
1214 rg_log_enter("rg_git_diff_tree: tree1=$tree1 tree2=$tree2");
1189 1215
1190 $ret = array();
1216 $ret = FALSE;
1217 while (1) {
1218 $cmd = "git diff-tree -r " . escapeshellarg($tree1)
1219 . " " . escapeshellarg($tree2);
1220 $a = rg_exec($cmd);
1221 if ($a['ok'] != 1) {
1222 rg_git_set_error("error on diff-tree (" . $a['errmsg'] . ")");
1223 break;
1224 }
1191 1225
1192 $cmd = "git diff-tree -r " . escapeshellarg($tree1)
1193 . " " . escapeshellarg($tree2);
1194 $a = rg_exec($cmd);
1195 if ($a['ok'] != 1) {
1196 rg_git_set_error("error on diff-tree (" . $a['errmsg'] . ")");
1197 return FALSE;
1198 }
1226 $output = explode("\n", trim($a['data']));
1227 $ret = array();
1228 foreach ($output as $line) {
1229 $_y = array();
1230 $_t = explode(" ", $line, 5);
1231 $_y['mode1'] = $_t[0];
1232 $_y['mode2'] = $_t[1];
1233 $_y['ref1'] = $_t[2];
1234 $_y['ref2'] = $_t[3];
1235
1236 $_op_file = explode("\t", $_t[4], 2);
1237 $_y['op'] = $_op_file[0];
1238 $_y['file'] = $_op_file[1]; // TODO: here, the filename is not UTF-8!
1239 $ret[] = $_y;
1240 }
1199 1241
1200 $output = explode("\n", trim($a['data']));
1201 foreach ($output as $line) {
1202 $_y = array();
1203 $_t = explode(" ", $line, 5);
1204 $_y['mode1'] = $_t[0];
1205 $_y['mode2'] = $_t[1];
1206 $_y['ref1'] = $_t[2];
1207 $_y['ref2'] = $_t[3];
1208
1209 $_op_file = explode("\t", $_t[4], 2);
1210 $_y['op'] = $_op_file[0];
1211 $_y['file'] = $_op_file[1]; // TODO: here, the filename is not UTF-8!
1212 $ret[] = $_y;
1242 break;
1213 1243 } }
1214 1244
1215 1245 rg_log("DEBUG: diff-tree: " . rg_array2string($ret)); rg_log("DEBUG: diff-tree: " . rg_array2string($ret));
1216 1246
1247 rg_log_exit();
1217 1248 rg_prof_end("git_diff_tree"); rg_prof_end("git_diff_tree");
1218 1249 return $ret; return $ret;
1219 1250 } }
1251
1220 1252 ?> ?>
File inc/keys.inc.php changed (mode: 100644) (index 479af50..406bda4)
... ... function rg_keys_info($key)
119 119
120 120 $ret = array(); $ret = array();
121 121 $ret['ok'] = 0; $ret['ok'] = 0;
122 do {
122 while(1) {
123 123 if (strpos($key, "PRIVATE KEY") !== FALSE) { if (strpos($key, "PRIVATE KEY") !== FALSE) {
124 124 rg_keys_set_error("private instead of pulic key"); rg_keys_set_error("private instead of pulic key");
125 125 break; break;
 
... ... function rg_keys_info($key)
148 148 $ret['fingerprint'] = implode(":", $a); $ret['fingerprint'] = implode(":", $a);
149 149
150 150 $ret['ok'] = 1; $ret['ok'] = 1;
151 } while (0);
151 break;
152 }
152 153
153 154 rg_prof_end("keys_info"); rg_prof_end("keys_info");
154 155 return $ret; return $ret;
 
... ... function rg_keys_info($key)
160 161 function rg_keys_remove($db, $ui, $list) function rg_keys_remove($db, $ui, $list)
161 162 { {
162 163 rg_prof_start("keys_remove"); rg_prof_start("keys_remove");
163 rg_log("keys_remove: list=" . rg_array2string($list));
164 rg_log_enter("keys_remove: list=" . rg_array2string($list));
164 165
165 166 $ret = FALSE; $ret = FALSE;
166 do {
167 while (1) {
167 168 $my_list = array(); $my_list = array();
168 169 foreach ($list as $key_id => $junk) foreach ($list as $key_id => $junk)
169 170 $my_list[] = sprintf("%u", $key_id); $my_list[] = sprintf("%u", $key_id);
 
... ... function rg_keys_remove($db, $ui, $list)
193 194 } }
194 195
195 196 $ret = TRUE; $ret = TRUE;
196 } while (0);
197 break;
198 }
197 199
200 rg_log_exit();
198 201 rg_prof_end("keys_remove"); rg_prof_end("keys_remove");
199 202 return $ret; return $ret;
200 203 } }
 
... ... function rg_keys_count($db, $uid)
207 210 rg_prof_start("keys_count"); rg_prof_start("keys_count");
208 211
209 212 $ret = FALSE; $ret = FALSE;
210 do {
213 while (1) {
211 214 $params = array("uid" => $uid); $params = array("uid" => $uid);
212 215 $sql = "SELECT COUNT(*) AS count FROM keys" $sql = "SELECT COUNT(*) AS count FROM keys"
213 216 . " WHERE uid = @@uid@@"; . " WHERE uid = @@uid@@";
 
... ... function rg_keys_count($db, $uid)
220 223 rg_sql_free_result($res); rg_sql_free_result($res);
221 224
222 225 $ret = $row['count']; $ret = $row['count'];
223 } while (0);
226 break;
227 }
224 228
225 229 rg_prof_end("keys_count"); rg_prof_end("keys_count");
226 230 return $ret; return $ret;
 
... ... function rg_keys_add($db, $ui, $key)
235 239 global $rg_max_ssh_keys; global $rg_max_ssh_keys;
236 240
237 241 rg_prof_start("keys_add"); rg_prof_start("keys_add");
238 rg_log("keys_add: $key=$key");
242 rg_log_enter("keys_add: $key=$key");
239 243
240 244 $ret = FALSE; $ret = FALSE;
241 245 $do_rollback = 0; $do_rollback = 0;
242 do {
246 while (1) {
243 247 $itime = time(); $itime = time();
244 248
245 249 $ki = rg_keys_info($key); $ki = rg_keys_info($key);
 
... ... function rg_keys_add($db, $ui, $key)
304 308 $do_rollback = 0; $do_rollback = 0;
305 309
306 310 $ret = $key_id; $ret = $key_id;
307 } while (0);
311 break;
312 }
308 313
309 314 if ($do_rollback == 1) if ($do_rollback == 1)
310 315 rg_sql_rollback($db); rg_sql_rollback($db);
311 316
317 rg_log_exit();
312 318 rg_prof_end("keys_add"); rg_prof_end("keys_add");
313 319 return $ret; return $ret;
314 320 } }
 
... ... function rg_keys_add($db, $ui, $key)
319 325 function rg_keys_update_use($db, $key_id, $ip) function rg_keys_update_use($db, $key_id, $ip)
320 326 { {
321 327 rg_prof_start("keys_update_use"); rg_prof_start("keys_update_use");
322 rg_log("keys_update_use: key_id=$key_id, ip=$ip");
328 rg_log_enter("keys_update_use: key_id=$key_id, ip=$ip");
323 329
324 330 $ret = FALSE; $ret = FALSE;
325 do {
331 while (1) {
326 332 $now = time(); $now = time();
327 333
328 334 $params = array("now" => $now, $params = array("now" => $now,
 
... ... function rg_keys_update_use($db, $key_id, $ip)
350 356 } }
351 357 rg_sql_free_result($res); rg_sql_free_result($res);
352 358 $ret = TRUE; $ret = TRUE;
353 } while (0);
359 break;
360 }
354 361
362 rg_log_exit();
355 363 rg_prof_end("keys_update_use"); rg_prof_end("keys_update_use");
356 364 return $ret; return $ret;
357 365 } }
 
... ... function rg_keys_regen($db)
369 377
370 378 $now = time(); $now = time();
371 379 $ret = FALSE; $ret = FALSE;
372 do {
380 while (1) {
373 381 // create .ssh folder if does not exists // create .ssh folder if does not exists
374 382 $dir = dirname($rg_keys_file); $dir = dirname($rg_keys_file);
375 383 if (!file_exists($dir)) { if (!file_exists($dir)) {
 
... ... function rg_keys_regen($db)
430 438 rg_cache_set("key::last_regen_time", $now); rg_cache_set("key::last_regen_time", $now);
431 439
432 440 $ret = TRUE; $ret = TRUE;
433 } while (0);
441 break;
442 }
434 443
435 444 rg_prof_end("keys_regen"); rg_prof_end("keys_regen");
436 445 return $ret; return $ret;
 
... ... function rg_keys_regen($db)
442 451 function rg_keys_list($db, $ui) function rg_keys_list($db, $ui)
443 452 { {
444 453 rg_prof_start("keys_list"); rg_prof_start("keys_list");
445 rg_log("keys_list: uid=" . $ui['uid']);
454 rg_log_enter("keys_list: uid=" . $ui['uid']);
446 455
447 456 $ret = FALSE; $ret = FALSE;
448 do {
457 while (1) {
449 458 $params = array("uid" => $ui['uid']); $params = array("uid" => $ui['uid']);
450 459 $sql = "SELECT * FROM keys WHERE uid = @@uid@@" $sql = "SELECT * FROM keys WHERE uid = @@uid@@"
451 460 . " ORDER BY itime DESC"; . " ORDER BY itime DESC";
 
... ... function rg_keys_list($db, $ui)
490 499 $ret[] = $t; $ret[] = $t;
491 500 } }
492 501 rg_sql_free_result($res); rg_sql_free_result($res);
493 } while (0);
502 break;
503 }
494 504
505 rg_log_exit();
495 506 rg_prof_end("keys_list"); rg_prof_end("keys_list");
496 507 return $ret; return $ret;
497 508 } }
File inc/login/login.php changed (mode: 100644) (index e608671..c1c195b)
1 1 <?php <?php
2 2 rg_log("FILE: /inc/login/login"); rg_log("FILE: /inc/login/login");
3 3
4 $login_more = $rg;
5
6 4 $user = rg_var_str("user"); $user = rg_var_str("user");
7 5 $pass = rg_var_str("pass"); $pass = rg_var_str("pass");
8 6 $lock_ip = rg_var_uint("lock_ip"); $lock_ip = rg_var_uint("lock_ip");
 
... ... if ($rg['doit'] == 1) {
23 21 } }
24 22 } }
25 23
26 $login_more['user'] = $user;
27 $login_more['pass'] = $pass;
28 $login_more['HTML:errmsg'] = rg_template_errmsg($errmsg);
29 $login_more['forgot_send'] = rg_re_url("/op/forgot_send");
30 $login_more['create_account'] = rg_re_url("/op/create_account");
31 $_login .= rg_template("user/login.html", $login_more);
24 $rg['user'] = $user;
25 $rg['pass'] = $pass;
26 $rg['HTML:errmsg'] = rg_template_errmsg($errmsg);
27 $rg['forgot_send'] = rg_re_url("/op/forgot_send");
28 $rg['create_account'] = rg_re_url("/op/create_account");
29 $_login .= rg_template("user/login.html", $rg);
32 30 ?> ?>
File inc/plan.inc.php changed (mode: 100644) (index 5ee27fc..572df97)
... ... function rg_plan_select($db, $plan_id)
233 233 /* /*
234 234 * High-level function for rg_plan_list * High-level function for rg_plan_list
235 235 */ */
236 function rg_plan_list_high_level($db, $rg)
236 function rg_plan_list_high_level($db, &$rg)
237 237 { {
238 238 $ret = ""; $ret = "";
239 239
 
... ... function rg_plan_list_high_level($db, $rg)
275 275 /* /*
276 276 * High-level function for rg_plan_edit. * High-level function for rg_plan_edit.
277 277 */ */
278 function rg_plan_edit_high_level($db, $rg)
278 function rg_plan_edit_high_level($db, &$rg)
279 279 { {
280 280 rg_log("plan_edit_high_level rg:" . rg_array2string($rg)); rg_log("plan_edit_high_level rg:" . rg_array2string($rg));
281 281
File inc/prof.inc.php changed (mode: 100644) (index 50383b4..b1eb16a)
... ... function rg_prof_start($label)
25 25 global $rg_prof_tmp; global $rg_prof_tmp;
26 26 global $rg_prof_state; global $rg_prof_state;
27 27
28 $rg_prof_tmp[$label] = $rg_prof_state;
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);
28 if (isset($rg_prof_tmp[$label])) {
29 // Nested func call
30 $rg_prof_tmp[$label]['level']++;
31 $rg_prof_tmp[$label]['runs']++;
32 } else {
33 $rg_prof_tmp[$label] = $rg_prof_state;
34 $rg_prof_tmp[$label]['time_ms'] = sprintf("%u", microtime(TRUE) * 1000);
35 $rg_prof_tmp[$label]['mem'] = memory_get_usage();
36 $rg_prof_tmp[$label]['real_mem'] = memory_get_usage(TRUE);
37 $rg_prof_tmp[$label]['level'] = 1;
38 $rg_prof_tmp[$label]['runs'] = 1;
39 }
32 40 } }
33 41
34 42 function rg_prof_end($label) function rg_prof_end($label)
 
... ... function rg_prof_end($label)
42 50 return; return;
43 51 } }
44 52
53 // We are in a recursive call, do not record info in this case
54 $rg_prof_tmp[$label]['level']--;
55 if ($rg_prof_tmp[$label]['level'] > 0)
56 return;
57
45 58 $start = $rg_prof_tmp[$label]; $start = $rg_prof_tmp[$label];
46 59
47 60 $c = $rg_prof_state; $c = $rg_prof_state;
48 61 $c['time_ms'] = sprintf("%u", microtime(TRUE) * 1000); $c['time_ms'] = sprintf("%u", microtime(TRUE) * 1000);
49 $c['runs'] = 1;
62 $c['runs'] = $start['runs']; $start['runs'] = 0;
50 63 $c['mem'] = memory_get_usage(); $c['mem'] = memory_get_usage();
51 64 $c['real_mem'] = memory_get_usage(TRUE); $c['real_mem'] = memory_get_usage(TRUE);
65 $c['level'] = 0; // just to not complain that is not defined
52 66
53 67 // we substract what was before start // we substract what was before start
54 68 foreach ($start as $key => $val) foreach ($start as $key => $val)
File inc/repo.inc.php changed (mode: 100644) (index a0faacb..6b9e1a5)
... ... function rg_repo_rights_inject($db, $obj_id, $type, $owner, $uid)
75 75 $a['right_id'] = 0; $a['right_id'] = 0;
76 76 $a['ip'] = ""; $a['ip'] = "";
77 77 $a['can_be_deleted'] = 0; $a['can_be_deleted'] = 0;
78 $a['desc'] = "Autogenerated";
78 $a['description'] = "Autogenerated";
79 79
80 80 if ($ui['is_admin'] == 1) { if ($ui['is_admin'] == 1) {
81 81 $a['rights'] = rg_rights_all($type); $a['rights'] = rg_rights_all($type);
 
... ... function rg_repo_event_symlink_by_name($db, $e)
267 267 $new_path = rg_repo_path_by_name($e['ui.uid'], $e['ri.name']); $new_path = rg_repo_path_by_name($e['ui.uid'], $e['ri.name']);
268 268
269 269 $ret = FALSE; $ret = FALSE;
270 do {
270 while (1) {
271 271 // Check if we already did the rename // Check if we already did the rename
272 272 if (file_exists($new_path)) { if (file_exists($new_path)) {
273 273 if (!is_link($new_path)) { if (!is_link($new_path)) {
 
... ... function rg_repo_event_symlink_by_name($db, $e)
314 314 } }
315 315
316 316 $ret = array(); $ret = array();
317 } while (0);
317 break;
318 }
318 319
319 320 rg_prof_end("repo_event_symlink_by_name"); rg_prof_end("repo_event_symlink_by_name");
320 321 return $ret; return $ret;
 
... ... function rg_repo_event_symlink_by_name($db, $e)
326 327 function rg_repo_event_storage_create($db, $e) function rg_repo_event_storage_create($db, $e)
327 328 { {
328 329 rg_prof_start("repo_event_storage_create"); rg_prof_start("repo_event_storage_create");
329 rg_log("repo_event_storage_create: e=" . rg_array2string($e));
330 rg_log_enter("repo_event_storage_create: e=" . rg_array2string($e));
330 331
331 332 $ret = FALSE; $ret = FALSE;
332 do {
333 while (1) {
333 334 $by_id_path = rg_repo_path_by_id($e['ui.uid'], $e['ri.repo_id']); $by_id_path = rg_repo_path_by_id($e['ui.uid'], $e['ri.repo_id']);
334 335 if (!is_dir($by_id_path)) { if (!is_dir($by_id_path)) {
335 336 if (mkdir($by_id_path, 0755, TRUE) === FALSE) { if (mkdir($by_id_path, 0755, TRUE) === FALSE) {
 
... ... function rg_repo_event_storage_create($db, $e)
370 371 break; break;
371 372
372 373 $ret = array(); $ret = array();
373 } while (0);
374
375 return $ret;
374 break;
375 }
376 376
377 rg_log_exit();
377 378 rg_prof_end("repo_event_storage_create"); rg_prof_end("repo_event_storage_create");
378 return array();
379 return $ret;
379 380 } }
380 381
381 382 /* /*
 
... ... function rg_repo_event_notify_user($db, $event)
419 420 function rg_repo_history_insert($db, $event) function rg_repo_history_insert($db, $event)
420 421 { {
421 422 rg_prof_start("repo_history_insert"); rg_prof_start("repo_history_insert");
422 rg_log("repo_history_insert: event=" . rg_array2string($event));
423 rg_log_enter("repo_history_insert: event=" . rg_array2string($event));
423 424
424 425 $ret = FALSE; $ret = FALSE;
425 do {
426 while (1) {
426 427 $now = time(); $now = time();
427 428 $params = array("now" => $now, $params = array("now" => $now,
428 429 "repo_id" => $event['ri.repo_id'], "repo_id" => $event['ri.repo_id'],
 
... ... function rg_repo_history_insert($db, $event)
437 438
438 439 rg_sql_free_result($res); rg_sql_free_result($res);
439 440 $ret = array(); $ret = array();
440 } while (0);
441 break;
442 }
441 443
444 rg_log_exit();
442 445 rg_prof_end("repo_history_insert"); rg_prof_end("repo_history_insert");
443 446 return $ret; return $ret;
444 447 } }
 
... ... function rg_repo_path_by_name($uid, $repo_name)
564 567 return rg_user_path_by_id($uid) . "/repos/by_name/" . $repo_name . ".git"; return rg_user_path_by_id($uid) . "/repos/by_name/" . $repo_name . ".git";
565 568 } }
566 569
567 $rg_repo_info_cache = array();
568 function rg_repo_invalidate_cache($uid, $repo_id)
570 /*
571 * Improve repo info
572 */
573 function rg_repo_cosmetic(&$row)
569 574 { {
570 global $rg_repo_info_cache;
571
572 $key = $uid . " " . $repo_id;
573 if (isset($rg_repo_info_cache[$key]))
574 unset($rg_repo_info_cache[$key]);
575
576 //rg_log_ml("DEBUG: rg_repo_info_cache: " . print_r($rg_repo_info_cache, TRUE));
575 $_a = htmlspecialchars($row['description'], ENT_QUOTES);
576 $row['HTML:description_nice'] = nl2br($_a);
577 577 } }
578 578
579 579 /* /*
 
... ... function rg_repo_invalidate_cache($uid, $repo_id)
582 582 */ */
583 583 function rg_repo_info($db, $repo_id, $uid, $repo_name) function rg_repo_info($db, $repo_id, $uid, $repo_name)
584 584 { {
585 global $rg_repo_info_cache;
586
587 585 rg_prof_start("repo_info"); rg_prof_start("repo_info");
588 rg_log("repo_info: repo_id=$repo_id uid=$uid repo_name=$repo_name.");
586 rg_log_enter("repo_info: repo_id=$repo_id uid=$uid repo_name=$repo_name.");
589 587
590 588 $ret['ok'] = 0; $ret['ok'] = 0;
591 589 $ret['exists'] = 0; $ret['exists'] = 0;
592 do {
593 if ($repo_id > 0) {
594 $key = $repo_id;
595 if (isset($rg_repo_info_cache[$key])) {
596 $ret = $rg_repo_info_cache[$key];
597 $ret['from_cache'] = 1;
598 break;
599 }
600 }
601
590 while(1) {
602 591 $params = array("uid" => $uid, $params = array("uid" => $uid,
603 592 "repo_id" => $repo_id, "repo_id" => $repo_id,
604 593 "repo_name" => $repo_name); "repo_name" => $repo_name);
605 594
606 595 if ($repo_id > 0) { if ($repo_id > 0) {
596 $c = rg_cache_get("repo_by_id::$repo_id");
597 if ($c !== FALSE) {
598 $ret = $c;
599 break;
600 }
601
607 602 $sql = "SELECT * FROM repos WHERE repo_id = @@repo_id@@"; $sql = "SELECT * FROM repos WHERE repo_id = @@repo_id@@";
608 603 } else if (!empty($repo_name)) { } else if (!empty($repo_name)) {
604 $x_repo_id = rg_cache_get("repo_by_name::$uid::$repo_name");
605 if ($x_repo_id !== FALSE) {
606 $ret = rg_repo_info($db, $x_repo_id, $uid, "");
607 break;
608 }
609
609 610 $sql = "SELECT * FROM repos WHERE uid = @@uid@@" $sql = "SELECT * FROM repos WHERE uid = @@uid@@"
610 611 . " AND name = @@repo_name@@"; . " AND name = @@repo_name@@";
611 612 } else { } else {
 
... ... function rg_repo_info($db, $repo_id, $uid, $repo_name)
622 623 if ($rows > 0) if ($rows > 0)
623 624 $ret = rg_sql_fetch_array($res); $ret = rg_sql_fetch_array($res);
624 625 rg_sql_free_result($res); rg_sql_free_result($res);
625 $ret['ok'] = 1;
626 626
627 627 if (($rows == 0) && ($repo_id == 0)) { if (($rows == 0) && ($repo_id == 0)) {
628 628 // Repo not found, maybe it was renamed // Repo not found, maybe it was renamed
 
... ... function rg_repo_info($db, $repo_id, $uid, $repo_name)
636 636 break; break;
637 637 } }
638 638
639 // small fixes
639 $ret['ok'] = 1;
640 640 if ($rows > 0) { if ($rows > 0) {
641 rg_repo_cosmetic($ret);
641 642 $ret['exists'] = 1; $ret['exists'] = 1;
642 $ret['HTML:description'] = nl2br($ret['description']);
643 643 } }
644 } while (0);
645 644
646 if (($repo_id > 0) && !isset($ret['from_cache']))
647 $rg_repo_info_cache[$key] = $ret;
645 rg_cache_set("repo_by_id::$repo_id", $ret);
646
647 if ($ret['exists'] == 1)
648 rg_cache_set("repo_by_name::$uid::" . $ret['name'],
649 $ret['repo_id']);
650
651 break;
652 }
648 653
654 rg_log_exit();
649 655 rg_prof_end("repo_info"); rg_prof_end("repo_info");
650 656 return $ret; return $ret;
651 657 } }
 
... ... function rg_repo_info($db, $repo_id, $uid, $repo_name)
656 662 function rg_repo_delete($db, $repo_id, $ui) function rg_repo_delete($db, $repo_id, $ui)
657 663 { {
658 664 rg_prof_start("repo_delete"); rg_prof_start("repo_delete");
659 rg_log("repo_delete: uid=" . $ui['uid'] . ", repo_id=$repo_id");
665 rg_log_enter("repo_delete: uid=" . $ui['uid'] . ", repo_id=$repo_id");
660 666
661 667 $ret = FALSE; $ret = FALSE;
662 do {
663 // TODO: Check rights
668 while (1) {
664 669 // TODO: Transaction? // TODO: Transaction?
665 670
666 671 $ri = rg_repo_info($db, $repo_id, 0, ""); $ri = rg_repo_info($db, $repo_id, 0, "");
 
... ... function rg_repo_delete($db, $repo_id, $ui)
673 678
674 679 // Only mark it as such, deletion will happen in background // Only mark it as such, deletion will happen in background
675 680 $params = array("repo_id" => $repo_id); $params = array("repo_id" => $repo_id);
676 $sql = "UPDATE repos SET deleted = 1 WHERE repo_id = @@repo_id@@";
681 $sql = "UPDATE repos SET deleted = 1"
682 . " WHERE repo_id = @@repo_id@@";
677 683 $res = rg_sql_query_params($db, $sql, $params); $res = rg_sql_query_params($db, $sql, $params);
678 684 if ($res === FALSE) { if ($res === FALSE) {
679 685 rg_repo_set_error("Cannot delete (" . rg_sql_error() . ")"); rg_repo_set_error("Cannot delete (" . rg_sql_error() . ")");
 
... ... function rg_repo_delete($db, $repo_id, $ui)
693 699 break; break;
694 700 } }
695 701
702 rg_cache_unset("repo_by_id::$repo_id");
703 rg_cache_unset("repo_by_name::" . $ui['uid'] . "::" . $ri['name']);
704
696 705 $ret = TRUE; $ret = TRUE;
697 } while (0);
706 break;
707 }
698 708
709 rg_log_exit();
699 710 rg_prof_end("repo_delete"); rg_prof_end("repo_delete");
700 711 return $ret; return $ret;
701 712 } }
702 713
703 714 /* /*
704 * Lookup in db the old names, so we can redirect the user to the new name
715 * Lookup in db the old name, so we can redirect the user to the new name
705 716 */ */
706 717 function rg_repo_lookup_by_old_name($db, $uid, $old_name) function rg_repo_lookup_by_old_name($db, $uid, $old_name)
707 718 { {
708 719 rg_prof_start("repo_lookup_by_old_name"); rg_prof_start("repo_lookup_by_old_name");
709 rg_log("repo_lookup_by_old_name: uid=$uid old_name=$old_name");
720 rg_log_enter("repo_lookup_by_old_name: uid=$uid old_name=$old_name");
710 721
711 722 $ret = FALSE; $ret = FALSE;
712 do {
723 while (1) {
724 $c = rg_cache_get("repo_by_name::$uid::$old_name");
725 if ($c !== FALSE) {
726 $ret = $c;
727 break;
728 }
729
713 730 $params = array("uid" => $uid, "old_name" => $old_name); $params = array("uid" => $uid, "old_name" => $old_name);
714 731 $sql = "SELECT repo_id FROM repos_renames" $sql = "SELECT repo_id FROM repos_renames"
715 732 . " WHERE uid = @@uid@@" . " WHERE uid = @@uid@@"
 
... ... function rg_repo_lookup_by_old_name($db, $uid, $old_name)
728 745 $ret = 0; $ret = 0;
729 746 else else
730 747 $ret = $row['repo_id']; $ret = $row['repo_id'];
731 } while (0);
732 748
749 rg_cache_set("repo_by_name::$uid::$old_name", $ret);
750 break;
751 }
752
753 rg_log_exit();
733 754 rg_prof_end("repo_lookup_by_old_name"); rg_prof_end("repo_lookup_by_old_name");
734 755 return $ret; return $ret;
735 756 } }
 
... ... function rg_repo_lookup_by_old_name($db, $uid, $old_name)
740 761 function rg_repo_insert_rename($db, $uid, $repo_id, $old_name) function rg_repo_insert_rename($db, $uid, $repo_id, $old_name)
741 762 { {
742 763 rg_prof_start("repo_insert_rename"); rg_prof_start("repo_insert_rename");
743 rg_log("repo_insert_rename: uid=$uid repo_id=$repo_id old_name=$old_name");
764 rg_log_enter("repo_insert_rename: uid=$uid repo_id=$repo_id old_name=$old_name");
744 765
745 766 $ret = FALSE; $ret = FALSE;
746 do {
767 while (1) {
747 768 // Check if already exists in the database // Check if already exists in the database
748 769 $r = rg_repo_lookup_by_old_name($db, $uid, $old_name); $r = rg_repo_lookup_by_old_name($db, $uid, $old_name);
749 770 if ($r === FALSE) if ($r === FALSE)
 
... ... function rg_repo_insert_rename($db, $uid, $repo_id, $old_name)
772 793 break; break;
773 794 } }
774 795
796 rg_cache_set("repo_by_name::$uid::$old_name", $repo_id);
797
775 798 $ret = TRUE; $ret = TRUE;
776 } while (0);
799 break;
800 }
777 801
802 rg_log_exit();
778 803 rg_prof_end("repo_insert_rename"); rg_prof_end("repo_insert_rename");
779 804 return $ret; return $ret;
780 805 } }
 
... ... function rg_repo_insert_rename($db, $uid, $repo_id, $old_name)
783 808 * Creates/updates a repository * Creates/updates a repository
784 809 * @login_ui - info of the user doing the update. * @login_ui - info of the user doing the update.
785 810 * TODO: Warning, it may not be the owner. * TODO: Warning, it may not be the owner.
786 * TODO: check rights - also for create?
787 811 * TODO: where do we validate if the user has enough public/private slots? * TODO: where do we validate if the user has enough public/private slots?
788 812 */ */
789 813 function rg_repo_edit($db, $login_ui, &$new) function rg_repo_edit($db, $login_ui, &$new)
 
... ... function rg_repo_edit($db, $login_ui, &$new)
839 863 $new['description'] = trim($new['description']); $new['description'] = trim($new['description']);
840 864 $new['itime'] = time(); $new['itime'] = time();
841 865 $new['uid'] = $login_ui['uid']; $new['uid'] = $login_ui['uid'];
866 rg_repo_cosmetic($new);
842 867
843 868 if ($new['repo_id'] == 0) { if ($new['repo_id'] == 0) {
844 869 $sql = "INSERT INTO repos (uid, master, name" $sql = "INSERT INTO repos (uid, master, name"
 
... ... function rg_repo_edit($db, $login_ui, &$new)
904 929 break; break;
905 930 } }
906 931
932 $new['ok'] = 1;
933 rg_cache_set("repo_by_id::" . $new['repo_id'], $new);
934 rg_cache_set("repo_by_name::" . $login_ui['uid'] . "::"
935 . $new['name'], $new['repo_id']);
936
907 937 $ret = TRUE; $ret = TRUE;
908 938 break; break;
909 939 } }
 
... ... function rg_repo_list_query($db, $url, $sql, $params)
943 973 $_line['owner'] = $_ui['username']; $_line['owner'] = $_ui['username'];
944 974 $_line['url_repo'] = rg_re_repopage($_ui, $row['name']); $_line['url_repo'] = rg_re_repopage($_ui, $row['name']);
945 975 $_line['url_user'] = rg_re_userpage($_ui); $_line['url_user'] = rg_re_userpage($_ui);
946 $_line['HTML:description'] = nl2br($row['description']);
976 rg_repo_cosmetic($_line);
947 977
948 978 $master_repo = "-"; $master_repo = "-";
949 979 if ($row['master'] > 0) { if ($row['master'] > 0) {
 
... ... function rg_repo_size($path, $all)
1029 1059 //rg_log("repo_disk_mb: path=$path"); //rg_log("repo_disk_mb: path=$path");
1030 1060
1031 1061 $ret = FALSE; $ret = FALSE;
1032 do {
1062 while (1) {
1033 1063 $dir = @opendir($path); $dir = @opendir($path);
1034 1064 if ($dir === FALSE) { if ($dir === FALSE) {
1035 1065 rg_repo_set_error("Cannot open $path!"); rg_repo_set_error("Cannot open $path!");
 
... ... function rg_repo_size($path, $all)
1074 1104
1075 1105 if ($error === FALSE) if ($error === FALSE)
1076 1106 $ret = $total; $ret = $total;
1077 } while (0);
1107 break;
1108 }
1078 1109
1079 1110 return $ret; return $ret;
1080 1111 } }
 
... ... function rg_repo_size($path, $all)
1085 1116 function rg_repo_git_done($db, $repo_id) function rg_repo_git_done($db, $repo_id)
1086 1117 { {
1087 1118 rg_prof_start("repo_git_done"); rg_prof_start("repo_git_done");
1088 rg_log("repo_git_done: repo_id=$repo_id...");
1119 rg_log_enter("repo_git_done: repo_id=$repo_id...");
1089 1120
1090 1121 $ret = FALSE; $ret = FALSE;
1091 do {
1122 while (1) {
1092 1123 $params = array("repo_id" => $repo_id); $params = array("repo_id" => $repo_id);
1093 1124 $sql = "UPDATE repos SET git_dir_done = 1" $sql = "UPDATE repos SET git_dir_done = 1"
1094 1125 . " WHERE repo_id = @@repo_id@@"; . " WHERE repo_id = @@repo_id@@";
 
... ... function rg_repo_git_done($db, $repo_id)
1100 1131 rg_sql_free_result($res); rg_sql_free_result($res);
1101 1132
1102 1133 $ret = TRUE; $ret = TRUE;
1103 } while (0);
1134 break;
1135 }
1104 1136
1137 rg_log_exit();
1105 1138 rg_prof_end("repo_git_done"); rg_prof_end("repo_git_done");
1106 1139 return $ret; return $ret;
1107 1140 } }
 
... ... function rg_repo_stats_push2file($a)
1136 1169 /* /*
1137 1170 * High level function to delete rights ids * High level function to delete rights ids
1138 1171 */ */
1139 function rg_repo_admin_delete_rights($db, $rg, $obj_id, &$errmsg)
1172 function rg_repo_admin_delete_rights($db, &$rg, $obj_id, &$errmsg)
1140 1173 { {
1141 1174 $errmsg = array(); $errmsg = array();
1142 1175
 
... ... function rg_repo_admin_delete_rights($db, $rg, $obj_id, &$errmsg)
1157 1190 /* /*
1158 1191 * High level function for Repo -> Admin -> Rights -> Repo/Refs rights menu. * High level function for Repo -> Admin -> Rights -> Repo/Refs rights menu.
1159 1192 */ */
1160 function rg_repo_admin_rights($db, $rg, $type)
1193 function rg_repo_admin_rights($db, &$rg, $type)
1161 1194 { {
1162 1195 rg_log("rg_repo_admin_rights type=$type"); rg_log("rg_repo_admin_rights type=$type");
1163 1196
 
... ... function rg_repo_admin_rights($db, $rg, $type)
1174 1207 $a['edit_id'] = rg_var_uint("edit_id"); $a['edit_id'] = rg_var_uint("edit_id");
1175 1208 $a['username'] = rg_var_str("username"); $a['username'] = rg_var_str("username");
1176 1209 $a['rights'] = rg_rights_a2s(rg_var_str("rights")); $a['rights'] = rg_rights_a2s(rg_var_str("rights"));
1177 $a['misc'] = rg_var_str("misc");
1210 $a['misc'] = rg_var_str_core("misc");
1178 1211 $a['ip'] = rg_var_str("ip"); $a['ip'] = rg_var_str("ip");
1179 1212 $a['prio'] = rg_var_uint("prio"); $a['prio'] = rg_var_uint("prio");
1180 $a['desc'] = rg_var_str("desc");
1213 $a['description'] = rg_var_str("description");
1181 1214 //rg_log_ml("CHECK: a(POST)=" . print_r($a, TRUE)); //rg_log_ml("CHECK: a(POST)=" . print_r($a, TRUE));
1182 1215
1183 1216 $errmsg = array(); $errmsg = array();
 
... ... function rg_repo_admin_rights($db, $rg, $type)
1254 1287 $a['who'] = $rg['login_ui']['uid']; $a['who'] = $rg['login_ui']['uid'];
1255 1288 $r = rg_rights_set($db, $type, $a); $r = rg_rights_set($db, $type, $a);
1256 1289 if ($r !== TRUE) { if ($r !== TRUE) {
1257 $errmsg[] = rg_repo_error();
1290 $errmsg[] = rg_rights_error();
1258 1291 break; break;
1259 1292 } }
1260 1293
 
... ... function rg_repo_admin_rights($db, $rg, $type)
1268 1301 $rg['right_id'] = 0; $rg['right_id'] = 0;
1269 1302 $rg['username'] = ""; $rg['username'] = "";
1270 1303 $rg['rights'] = rg_rights_default($type); $rg['rights'] = rg_rights_default($type);
1271 $rg['desc'] = "";
1304 $rg['description'] = "";
1272 1305 $rg['misc'] = ""; $rg['misc'] = "";
1273 1306 $rg['ip'] = ""; $rg['ip'] = "";
1274 1307 $rg['prio'] = 100; $rg['prio'] = 100;
 
... ... function rg_repo_admin_delete($db, $rg)
1319 1352
1320 1353 $show_form = 1; $show_form = 1;
1321 1354
1322 do {
1355 while (1) {
1323 1356 if ($rg['doit'] != 1) if ($rg['doit'] != 1)
1324 1357 break; break;
1325 1358
 
... ... function rg_repo_admin_delete($db, $rg)
1343 1376
1344 1377 $ret .= rg_template("user/repo/delete/done.html", $rg); $ret .= rg_template("user/repo/delete/done.html", $rg);
1345 1378 $show_form = 0; $show_form = 0;
1346 } while (0);
1379
1380 // TODO: shouldn't we invalidate the cache?
1381 break;
1382 }
1347 1383
1348 1384 if ($show_form == 1) { if ($show_form == 1) {
1349 1385 $rg['HTML:errmsg'] = rg_template_errmsg($errmsg); $rg['HTML:errmsg'] = rg_template_errmsg($errmsg);
 
... ... function rg_repo_admin_delete($db, $rg)
1357 1393 /* /*
1358 1394 * High level function creating/editing a repo * High level function creating/editing a repo
1359 1395 */ */
1360 function rg_repo_edit_high_level($db, $rg)
1396 function rg_repo_edit_high_level($db, &$rg)
1361 1397 { {
1362 rg_log("rg_repo_edit_high_level");
1363
1364 if (rg_rights_allow($db, $rg['ri']['repo_id'], "repo", $rg['ri']['uid'],
1365 $rg['login_ui']['uid'], "E", $rg['ip'], "") !== TRUE)
1366 return rg_template("user/repo/deny_edit.html", $rg);
1398 rg_log_enter("rg_repo_edit_high_level");
1367 1399
1368 1400 $ret = ""; $ret = "";
1369 1401
1370 1402 $errmsg = array(); $errmsg = array();
1371 1403 $load_form = TRUE; $load_form = TRUE;
1372 do {
1404 while (1) {
1405 if (rg_rights_allow($db, $rg['ri']['repo_id'], "repo", $rg['ri']['uid'],
1406 $rg['login_ui']['uid'], "E", $rg['ip'], "") !== TRUE) {
1407 $ret .= rg_template("user/repo/deny_edit.html", $rg);
1408 $load_form = FALSE;
1409 break;
1410 }
1411
1373 1412 if ($rg['doit'] != 1) { if ($rg['doit'] != 1) {
1374 1413 if (!isset($rg['ri'])) { if (!isset($rg['ri'])) {
1375 1414 // Defaults // Defaults
 
... ... function rg_repo_edit_high_level($db, $rg)
1393 1432 $rg['ri']['repo_id'] = rg_var_uint("repo_id"); $rg['ri']['repo_id'] = rg_var_uint("repo_id");
1394 1433 $rg['ri']['name'] = rg_var_str("name"); // TODO: filter name! $rg['ri']['name'] = rg_var_str("name"); // TODO: filter name!
1395 1434 $rg['ri']['max_commit_size'] = rg_var_uint("max_commit_size"); $rg['ri']['max_commit_size'] = rg_var_uint("max_commit_size");
1396 $rg['ri']['description'] = rg_var_str("description");
1435 $rg['ri']['description'] = rg_var_str_core("description");
1397 1436 $rg['ri']['public'] = rg_var_bool("public"); $rg['ri']['public'] = rg_var_bool("public");
1398 1437 $rg['ri']['master'] = rg_var_uint("master"); $rg['ri']['master'] = rg_var_uint("master");
1438 rg_repo_cosmetic($rg['ri']);
1439 rg_log_ml("CHECK: after repo edit: rg[ri]=" . print_r($rg['ri'], TRUE));
1399 1440
1400 1441 $r = rg_repo_edit($db, $rg['login_ui'], $rg['ri']); $r = rg_repo_edit($db, $rg['login_ui'], $rg['ri']);
1401 1442 if ($r === FALSE) { if ($r === FALSE) {
 
... ... function rg_repo_edit_high_level($db, $rg)
1412 1453 } }
1413 1454
1414 1455 $load_form = FALSE; $load_form = FALSE;
1415 } while (0);
1456 break;
1457 }
1416 1458
1417 1459 if ($load_form) { if ($load_form) {
1418 1460 if ($rg['ri']['master'] > 0) { if ($rg['ri']['master'] > 0) {
1419 1461 $rg['ri']['master_name'] = $rg['ri']['master']; $rg['ri']['master_name'] = $rg['ri']['master'];
1420 $_mi = repo_info($db, $rg['ri']['master'], "");
1462 $_mi = rg_repo_info($db, $rg['ri']['master'], "");
1421 1463 if ($_mi['exists'] == 1) if ($_mi['exists'] == 1)
1422 1464 $rg['ri']['master_name'] = $_mi['name']; $rg['ri']['master_name'] = $_mi['name'];
1423 1465 } else { } else {
 
... ... function rg_repo_edit_high_level($db, $rg)
1432 1474 $ret .= rg_template("repo/add_edit.html", $rg); $ret .= rg_template("repo/add_edit.html", $rg);
1433 1475 } }
1434 1476
1477 rg_log_exit();
1435 1478 return $ret; return $ret;
1436 1479 } }
1437 1480
1438 1481 /* /*
1439 1482 * High level function for 'Repo -> Admin' menu * High level function for 'Repo -> Admin' menu
1440 1483 */ */
1441 function rg_repo_admin($db, $rg, $paras)
1484 function rg_repo_admin($db, &$rg, $paras)
1442 1485 { {
1443 1486 rg_log("rg_repo_admin paras=" . rg_array2string($paras)); rg_log("rg_repo_admin paras=" . rg_array2string($paras));
1444 1487
File inc/rights.inc.php changed (mode: 100644) (index 02ce797..9f267f3)
... ... function rg_rights_cosmetic($db, &$row)
215 215 else else
216 216 $row['nice.ip'] = $row['ip']; $row['nice.ip'] = $row['ip'];
217 217
218 if (!isset($row['desc']))
219 $row['desc'] = "";
218 if (!isset($row['description']))
219 $row['description'] = "";
220 220 } }
221 221
222 222 /* /*
 
... ... function rg_rights_get($db, $obj_id, $type, $owner, $uid, $right_id)
295 295 $a['ip'] = ""; $a['ip'] = "";
296 296 $a['can_be_deleted'] = 0; $a['can_be_deleted'] = 0;
297 297 $a['rights'] = rg_rights_all($type); $a['rights'] = rg_rights_all($type);
298 $a['desc'] = "Autogenerated";
298 $a['description'] = "Autogenerated";
299 299 rg_rights_cosmetic($db, $a); rg_rights_cosmetic($db, $a);
300 300
301 301 rg_log_ml("rights_get: inject right for owner: " . print_r($a, TRUE)); rg_log_ml("rights_get: inject right for owner: " . print_r($a, TRUE));
 
... ... function rg_rights_set($db, $type, $a)
357 357 rg_prof_start("rights_set"); rg_prof_start("rights_set");
358 358 rg_log_enter("rg_rights_set: type=$type a=" . rg_array2string($a)); rg_log_enter("rg_rights_set: type=$type a=" . rg_array2string($a));
359 359
360 $ret = FALSE;
360 361 while (1) { while (1) {
361 362 if ($a['prio'] < 10) { if ($a['prio'] < 10) {
362 363 rg_rights_set_error("prio must be at least 10"); rg_rights_set_error("prio must be at least 10");
 
... ... function rg_rights_set($db, $type, $a)
365 366
366 367 $r = rg_rights_validate_ip($a['ip']); $r = rg_rights_validate_ip($a['ip']);
367 368 if ($r !== TRUE) if ($r !== TRUE)
368 break;
369 break;
369 370
370 371 $a['type'] = $type; $a['type'] = $type;
371 372 $a['now'] = time(); $a['now'] = time();
 
... ... function rg_rights_set($db, $type, $a)
380 381 . ", prio = @@prio@@" . ", prio = @@prio@@"
381 382 . ", itime = @@now@@" . ", itime = @@now@@"
382 383 . ", who = @@who@@" . ", who = @@who@@"
383 . ", desc = @@desc@@"
384 . ", description = @@description@@"
384 385 . " WHERE right_id = @@right_id@@"; . " WHERE right_id = @@right_id@@";
385 386 else else
386 387 $sql = "INSERT INTO rights (type, uid, obj_id, rights" $sql = "INSERT INTO rights (type, uid, obj_id, rights"
387 . ", misc, ip, prio, itime, who, desc)"
388 . ", misc, ip, prio, itime, who, description)"
388 389 . " VALUES (@@type@@, @@uid@@, @@obj_id@@, @@rights@@" . " VALUES (@@type@@, @@uid@@, @@obj_id@@, @@rights@@"
389 390 . ", @@misc@@, @@ip@@, @@prio@@, @@now@@, @@who@@" . ", @@misc@@, @@ip@@, @@prio@@, @@now@@, @@who@@"
390 . ", @@desc@@)";
391 . ", @@description@@)";
391 392 $res = rg_sql_query_params($db, $sql, $a); $res = rg_sql_query_params($db, $sql, $a);
392 393 if ($res === FALSE) { if ($res === FALSE) {
393 rg_rights_set_error("cannot alter rights (" . rg_sql_error() . ")!");
394 rg_rights_set_error("cannot alter rights");
394 395 break; break;
395 396 } }
396 397 rg_sql_free_result($res); rg_sql_free_result($res);
 
... ... function rg_rights_set($db, $type, $a)
399 400 $key = "rights_by_obj_id::" . $a['obj_id'] . "::" . $a['type']; $key = "rights_by_obj_id::" . $a['obj_id'] . "::" . $a['type'];
400 401 rg_cache_unset($key); rg_cache_unset($key);
401 402
403 $ret = TRUE;
402 404 break; break;
403 405 } }
404 406
405 407 rg_log_exit(); rg_log_exit();
406 408 rg_prof_end("rights_set"); rg_prof_end("rights_set");
407 return TRUE;
409 return $ret;
408 410 } }
409 411
410 412 /* /*
File inc/sess.inc.php changed (mode: 100644) (index aa33aef..4bb845d)
... ... require_once($INC . "/prof.inc.php");
10 10 function rg_sess_add($db, $uid, $sid, $session_time, $lock_ip) function rg_sess_add($db, $uid, $sid, $session_time, $lock_ip)
11 11 { {
12 12 rg_prof_start("sess_add"); rg_prof_start("sess_add");
13 rg_log("sess_add: uid=$uid, sid=$sid, session_time=$session_time"
13 rg_log_enter("sess_add: uid=$uid, sid=$sid, session_time=$session_time"
14 14 . " lock_ip=$lock_ip"); . " lock_ip=$lock_ip");
15 15
16 16 if ($lock_ip == 1) if ($lock_ip == 1)
 
... ... function rg_sess_add($db, $uid, $sid, $session_time, $lock_ip)
20 20 $now = time(); $now = time();
21 21
22 22 $ret = FALSE; $ret = FALSE;
23 do {
23 while (1) {
24 24 $params = array("sid" => $sid, $params = array("sid" => $sid,
25 25 "uid" => $uid, "uid" => $uid,
26 26 "expire" => $now + $session_time, "expire" => $now + $session_time,
 
... ... function rg_sess_add($db, $uid, $sid, $session_time, $lock_ip)
40 40 rg_cache_set("sess::" . $sid, $params); rg_cache_set("sess::" . $sid, $params);
41 41
42 42 $ret = TRUE; $ret = TRUE;
43 } while (0);
43 break;
44 }
44 45
46 rg_log_exit();
45 47 rg_prof_end("sess_add"); rg_prof_end("sess_add");
46 48 return $ret; return $ret;
47 49 } }
 
... ... function rg_sess_add($db, $uid, $sid, $session_time, $lock_ip)
53 55 function rg_sess_valid($db, $sid) function rg_sess_valid($db, $sid)
54 56 { {
55 57 rg_prof_start("sess_valid"); rg_prof_start("sess_valid");
56 rg_log("sess_valid: sid=$sid...");
58 rg_log_enter("sess_valid: sid=$sid...");
57 59
58 60 $ret = FALSE; $ret = FALSE;
59 do {
61 while (1) {
60 62 $r = rg_cache_get("sess::" . $sid); $r = rg_cache_get("sess::" . $sid);
61 63 if ($r === FALSE) { if ($r === FALSE) {
62 64 $params = array("sid" => $sid); $params = array("sid" => $sid);
 
... ... function rg_sess_valid($db, $sid)
97 99 rg_log("\tSession valid, uid=$uid, expire=+" rg_log("\tSession valid, uid=$uid, expire=+"
98 100 . ($r['expire'] - $now) . "s"); . ($r['expire'] - $now) . "s");
99 101 $ret = $r; $ret = $r;
100 } while (0);
102 break;
103 }
101 104
105 rg_log_exit();
102 106 rg_prof_end("sess_valid"); rg_prof_end("sess_valid");
103 107 return $ret; return $ret;
104 108 } }
 
... ... function rg_sess_valid($db, $sid)
111 115 function rg_sess_update($db, $sess) function rg_sess_update($db, $sess)
112 116 { {
113 117 rg_prof_start("sess_update"); rg_prof_start("sess_update");
114 rg_log("sess_update: sess=" . rg_array2string($sess));
118 rg_log_enter("sess_update: sess=" . rg_array2string($sess));
115 119
116 120 $now = time(); $now = time();
117 121
118 122 $ret = FALSE; $ret = FALSE;
119 do {
123 while (1) {
120 124 if ($sess['last_db_write'] + 60 > $now) { if ($sess['last_db_write'] + 60 > $now) {
121 125 $_diff = $now - $sess['last_db_write']; $_diff = $now - $sess['last_db_write'];
122 126 rg_log("DEBUG: last_db_write is fresh enough (" . $_diff . "s)."); rg_log("DEBUG: last_db_write is fresh enough (" . $_diff . "s).");
 
... ... function rg_sess_update($db, $sess)
139 143 rg_cache_set("sess::" . $sess['sid'], $sess); rg_cache_set("sess::" . $sess['sid'], $sess);
140 144
141 145 $ret = TRUE; $ret = TRUE;
142 } while (0);
146 break;
147 }
143 148
149 rg_log_exit();
144 150 rg_prof_end("sess_update"); rg_prof_end("sess_update");
145 151 return $ret; return $ret;
146 152 } }
 
... ... function rg_sess_update($db, $sess)
151 157 function rg_sess_destroy($db, $sid, &$ui) function rg_sess_destroy($db, $sid, &$ui)
152 158 { {
153 159 rg_prof_start("sess_destroy"); rg_prof_start("sess_destroy");
154 rg_log("sess_destroy: sid=$sid...");
160 rg_log_enter("sess_destroy: sid=$sid...");
155 161
156 162 $ret = FALSE; $ret = FALSE;
157 do {
163 while (1) {
158 164 $params = array("sid" => $sid); $params = array("sid" => $sid);
159 165 $sql = "DELETE FROM sess WHERE sid = @@sid@@"; $sql = "DELETE FROM sess WHERE sid = @@sid@@";
160 166 $res = rg_sql_query_params($db, $sql, $params); $res = rg_sql_query_params($db, $sql, $params);
 
... ... function rg_sess_destroy($db, $sid, &$ui)
174 180 rg_cache_unset("sess::" . $sid); rg_cache_unset("sess::" . $sid);
175 181
176 182 $ret = TRUE; $ret = TRUE;
177 } while (0);
183 break;
184 }
178 185
186 rg_log_exit();
179 187 rg_prof_end("sess_destroy"); rg_prof_end("sess_destroy");
180 188 return $ret; return $ret;
181 189 } }
File inc/sql.inc.php changed (mode: 100644) (index 37b10b6..4a80b29)
... ... function rg_sql_open_nodelay($h)
35 35 rg_prof_start("sql_open_nodelay"); rg_prof_start("sql_open_nodelay");
36 36
37 37 $ret = FALSE; $ret = FALSE;
38 do {
38 while (1) {
39 39 if (!isset($rg_sql_conn[$h])) { if (!isset($rg_sql_conn[$h])) {
40 40 rg_internal_error("Handler $h not present!"); rg_internal_error("Handler $h not present!");
41 41 break; break;
 
... ... function rg_sql_open_nodelay($h)
50 50 if ($rg_sql_debug > 0) if ($rg_sql_debug > 0)
51 51 rg_log("DB: opening [$str]..."); rg_log("DB: opening [$str]...");
52 52
53 // TODO: I do not remember what this is doing. Bad!
54 53 rg_prof_set(array("db_conn" => 1)); rg_prof_set(array("db_conn" => 1));
55 54
56 55 $_s = microtime(TRUE); $_s = microtime(TRUE);
 
... ... function rg_sql_open_nodelay($h)
78 77 rg_log("Connect OK to database."); rg_log("Connect OK to database.");
79 78 $rg_sql_conn[$h]['db'] = $db; $rg_sql_conn[$h]['db'] = $db;
80 79 $ret = $db; $ret = $db;
81 } while (0);
80 break;
81 }
82 82
83 83 rg_prof_end("sql_open_nodelay"); rg_prof_end("sql_open_nodelay");
84 84 return $ret; return $ret;
File inc/struct.inc.php changed (mode: 100644) (index 0e84a9c..e6ebaec)
... ... $rg_sql_struct[28]['other'] = array(
385 385 "ALTER TABLE repos ADD last_bug_id INTEGER NOT NULL DEFAULT 0" "ALTER TABLE repos ADD last_bug_id INTEGER NOT NULL DEFAULT 0"
386 386 ); );
387 387
388 /* add this in next update
389 388 $rg_sql_struct[29] = array(); $rg_sql_struct[29] = array();
390 389 $rg_sql_struct[29]['tables'] = array(); $rg_sql_struct[29]['tables'] = array();
391 390 $rg_sql_struct[29]['other'] = array( $rg_sql_struct[29]['other'] = array(
392 "add rights.desc" =>
393 "ALTER TABLE rights ADD desc TEXT NOT NULL DEFAULT ''"
391 "add rights.description" =>
392 "ALTER TABLE rights ADD description TEXT NOT NULL DEFAULT ''",
393 "index users table" =>
394 "CREATE UNIQUE INDEX users_username ON users(username)"
394 395 ); );
395 */
396
396 397
397 398 // This must be the last line // This must be the last line
398 399 $rg_sql_schema_ver = count($rg_sql_struct); $rg_sql_schema_ver = count($rg_sql_struct);
File inc/user.inc.php changed (mode: 100644) (index 6a1e5d7..1e05acb)
... ... function rg_user_edit($db, $d)
495 495 rg_sql_free_result($res); rg_sql_free_result($res);
496 496
497 497 // invalidate cache (because we may not have the password) // invalidate cache (because we may not have the password)
498 // TODO: but, we can do a merge!
498 499 if ($d['uid'] > 0) if ($d['uid'] > 0)
499 500 rg_cache_unset("user::" . $d['uid']); rg_cache_unset("user::" . $d['uid']);
500 501
 
... ... function rg_user_edit($db, $d)
514 515 } }
515 516 } }
516 517
518 // TODO: should we cache here the user_by_uid and user_by_name
519
517 520 $ret = $row['uid']; $ret = $row['uid'];
518 521 break; break;
519 522 } }
 
... ... function rg_user_info($db, $uid, $user, $email)
572 575 $ret['uid'] = 0; $ret['uid'] = 0;
573 576 $ret['is_admin'] = 0; $ret['is_admin'] = 0;
574 577 $ret['rights'] = ""; $ret['rights'] = "";
575
576 $set_cache = FALSE;
577 $set_cache_user = FALSE;
578 $set_cache_email = FALSE;
579 578 while (1) { while (1) {
580 579 $params = array("uid" => $uid, $params = array("uid" => $uid,
581 580 "user" => $user, "user" => $user,
 
... ... function rg_user_info($db, $uid, $user, $email)
589 588 } }
590 589
591 590 $sql = "SELECT * FROM users WHERE uid = @@uid@@"; $sql = "SELECT * FROM users WHERE uid = @@uid@@";
592 $set_cache = TRUE;
593 591 } else if (!empty($user)) { } else if (!empty($user)) {
594 592 if (rg_user_ok($user) !== TRUE) if (rg_user_ok($user) !== TRUE)
595 593 break; break;
 
... ... function rg_user_info($db, $uid, $user, $email)
601 599 } }
602 600
603 601 $sql = "SELECT * FROM users WHERE username = @@user@@"; $sql = "SELECT * FROM users WHERE username = @@user@@";
604 $set_cache_user = TRUE;
605 602 } else if (!empty($email)) { } else if (!empty($email)) {
606 603 $c = rg_cache_get("email_to_uid::" . $email); $c = rg_cache_get("email_to_uid::" . $email);
607 604 if ($c != FALSE) { if ($c != FALSE) {
 
... ... function rg_user_info($db, $uid, $user, $email)
610 607 } }
611 608
612 609 $sql = "SELECT * FROM users WHERE email = @@email@@"; $sql = "SELECT * FROM users WHERE email = @@email@@";
613 $set_cache_email = TRUE;
614 610 } else { } else {
615 611 rg_user_set_error("invalid user"); rg_user_set_error("invalid user");
616 612 break; break;
 
... ... function rg_user_info($db, $uid, $user, $email)
635 631
636 632 $ret = array_merge($ret, $row); $ret = array_merge($ret, $row);
637 633 $ret['exists'] = 1; $ret['exists'] = 1;
638 break;
639 }
640 634
641 if (($ret['ok'] == 1) && $set_cache)
642 635 rg_cache_set("user::" . $uid, $ret); rg_cache_set("user::" . $uid, $ret);
636 rg_cache_set("username_to_uid::" . $ret['username'], $ret['uid']);
637 rg_cache_set("email_to_uid::" . $ret['email'], $ret['uid']);
643 638
644 if ($ret['exists'] == 1) {
645 if ($set_cache_user)
646 rg_cache_set("username_to_uid::" . $ret['username'], $ret['uid']);
647
648 if ($set_cache_email)
649 rg_cache_set("email_to_uid::" . $ret['email'], $ret['uid']);
639 break;
650 640 } }
651 641
652 642 rg_log_exit(); rg_log_exit();
 
... ... function rg_user_over_limit($db, $ui, &$max)
1359 1349 /* /*
1360 1350 * High-level function for editing a user * High-level function for editing a user
1361 1351 */ */
1362 function rg_user_edit_high_level($db, $rg)
1352 function rg_user_edit_high_level($db, &$rg)
1363 1353 { {
1364 1354 rg_log("user_edit_high_level"); rg_log("user_edit_high_level");
1365 1355
 
... ... function rg_user_edit_high_level($db, $rg)
1405 1395
1406 1396 $errmsg = array(); $errmsg = array();
1407 1397 $load_form = TRUE; $load_form = TRUE;
1408 do {
1398 while (1) {
1409 1399 if ($rg['doit'] != 1) if ($rg['doit'] != 1)
1410 1400 break; break;
1411 1401
 
... ... function rg_user_edit_high_level($db, $rg)
1466 1456 else else
1467 1457 $ret = rg_template("user/edit_ok.html", $rg); $ret = rg_template("user/edit_ok.html", $rg);
1468 1458 $load_form = FALSE; $load_form = FALSE;
1469 } while (0);
1459 break;
1460 }
1470 1461
1471 1462 if ($load_form) { if ($load_form) {
1472 1463 $rg = array_merge($rg, $ui); $rg = array_merge($rg, $ui);
File inc/user/forgot_send.php changed (mode: 100644) (index edf6db4..2526202)
1 1 <?php <?php
2 2 rg_log("FILE: /inc/user/forgot_send"); rg_log("FILE: /inc/user/forgot_send");
3 3
4 $forgot_send_more = $rg;
5 4 $email = rg_var_str("email"); $email = rg_var_str("email");
6 5
7 6 $_forgot = ""; $_forgot = "";
 
... ... if ($rg['doit'] == 1) {
25 24 } }
26 25
27 26 if ($_show_form == 1) { if ($_show_form == 1) {
28 $forgot_send_more['email'] = $email;
29 $forgot_send_more['HTML:errmsg'] = rg_template_errmsg($errmsg);
30 $_forgot .= rg_template("user/forgot_send.html", $forgot_send_more);
27 $rg['email'] = $email;
28 $rg['HTML:errmsg'] = rg_template_errmsg($errmsg);
29 $_forgot .= rg_template("user/forgot_send.html", $rg);
31 30 } }
32 31
33 32 ?> ?>
File inc/user/keys/keys.php changed (mode: 100644) (index b99d68e..d52d03a)
... ... rg_log("FILE: /inc/user/keys/keys");
3 3
4 4 $add_errmsg = array(); $add_errmsg = array();
5 5 $del_errmsg = array(); $del_errmsg = array();
6 $_my_more = $rg;
7 6
8 7 $_keys = ""; $_keys = "";
9 8
 
... ... $key_delete_ids = rg_var_str("key_delete_ids");
15 14 // menu // menu
16 15 $_url = rg_re_url($sparas); $_url = rg_re_url($sparas);
17 16
18 $_my_more['HTML:status'] = "";
17 $rg['HTML:status'] = "";
19 18
20 19 if (rg_var_uint("add") == 1) { if (rg_var_uint("add") == 1) {
21 do {
20 while (1) {
22 21 if (!rg_token_valid($db, $rg['sid'], $rg['token'])) { if (!rg_token_valid($db, $rg['sid'], $rg['token'])) {
23 22 $add_errmsg[] = "Invalid token. Try again."; $add_errmsg[] = "Invalid token. Try again.";
24 23 break; break;
 
... ... if (rg_var_uint("add") == 1) {
27 26 $_r = rg_keys_add($db, $rg['login_ui'], $key); $_r = rg_keys_add($db, $rg['login_ui'], $key);
28 27 if ($_r === FALSE) if ($_r === FALSE)
29 28 $add_errmsg[] = rg_keys_error(); $add_errmsg[] = rg_keys_error();
30 } while (0);
29 break;
30 }
31 31 } else if (rg_var_uint("delete") == 1) { } else if (rg_var_uint("delete") == 1) {
32 do {
32 while (1) {
33 33 if (!rg_token_valid($db, $rg['sid'], $rg['token'])) { if (!rg_token_valid($db, $rg['sid'], $rg['token'])) {
34 34 $del_errmsg[] = "Invalid token. Try again."; $del_errmsg[] = "Invalid token. Try again.";
35 35 break; break;
 
... ... if (rg_var_uint("add") == 1) {
45 45 break; break;
46 46 } }
47 47
48 $_my_more['HTML:status'] =
49 rg_template("user/keys/remove_ok.html", $_my_more);
50 } while (0);
48 $rg['HTML:status'] = rg_template("user/keys/remove_ok.html", $rg);
49 break;
50 }
51 51 } }
52 52
53 $_my_more['HTML:add_errmsg'] = rg_template_errmsg($add_errmsg);
54 $_my_more['HTML:del_errmsg'] = rg_template_errmsg($del_errmsg);
53 $rg['HTML:add_errmsg'] = rg_template_errmsg($add_errmsg);
54 $rg['HTML:del_errmsg'] = rg_template_errmsg($del_errmsg);
55 55
56 $_my_more['HTML:add_form'] = rg_template("user/keys/add.html", $_my_more);
56 $rg['HTML:add_form'] = rg_template("user/keys/add.html", $rg);
57 57
58 58 $keys_list = rg_keys_list($db, $rg['login_ui']); $keys_list = rg_keys_list($db, $rg['login_ui']);
59 59 if ($keys_list === FALSE) if ($keys_list === FALSE)
60 $_my_more['HTML:keys'] = rg_warning("Could not load keys. Try later."); // TODO
60 $rg['HTML:keys'] = rg_warning("Could not load keys. Try later."); // TODO
61 61 else else
62 $_my_more['HTML:keys'] = rg_template_table("user/keys/list", $keys_list, $_my_more);
62 $rg['HTML:keys'] = rg_template_table("user/keys/list", $keys_list, $rg);
63 63
64 64 $hints = array(); $hints = array();
65 65 if ($rg_ssh_port != 0) if ($rg_ssh_port != 0)
66 $hints[]['HTML:hint'] = rg_template("hints/ssh/key.html", $_my_more);
67 $_my_more['HTML:hints'] = rg_template_table("hints/list", $hints, $_my_more);
66 $hints[]['HTML:hint'] = rg_template("hints/ssh/key.html", $rg);
67 $rg['HTML:hints'] = rg_template_table("hints/list", $hints, $rg);
68 68
69 $_my_more['rg_form_token'] = rg_token_get($db, $rg['sid']);
70 $_my_more['key'] = $key;
69 $rg['rg_form_token'] = rg_token_get($db, $rg['sid']);
70 $rg['key'] = $key;
71 71
72 $_keys = rg_template("user/keys/main.html", $_my_more);
72 $_keys = rg_template("user/keys/main.html", $rg);
73 73 ?> ?>
File inc/user/pass/pass.php changed (mode: 100644) (index 231c7fa..ca6f37d)
... ... $pass1 = rg_var_str("pass1");
10 10 $pass2 = rg_var_str("pass2"); $pass2 = rg_var_str("pass2");
11 11
12 12 $show_form = 1; $show_form = 1;
13 do {
13 while (1) {
14 14 if ($rg['doit'] != 1) if ($rg['doit'] != 1)
15 15 break; break;
16 16
 
... ... do {
36 36
37 37 $_pass .= rg_template("user/pass_changed.html", $rg); $_pass .= rg_template("user/pass_changed.html", $rg);
38 38 $show_form = 0; $show_form = 0;
39 } while (0);
39 break;
40 }
40 41
41 42 if ($show_form == 1) { if ($show_form == 1) {
42 43 $rg['HTML:errmsg'] = rg_template_errmsg($errmsg); $rg['HTML:errmsg'] = rg_template_errmsg($errmsg);
File inc/user/repo-page.php changed (mode: 100644) (index f21ee40..da95869)
... ... $rg['url_repo'] = rg_re_repopage($rg['page_ui'], $repo);
58 58 $rg['ssh'] = rg_re_repo_ssh($organization, $user, $repo); $rg['ssh'] = rg_re_repo_ssh($organization, $user, $repo);
59 59 $rg['git'] = rg_re_repo_git($organization, $user, $repo); $rg['git'] = rg_re_repo_git($organization, $user, $repo);
60 60 $rg['can_admin'] = $can_admin; $rg['can_admin'] = $can_admin;
61 $repo_more = $rg;
62 $repo_more['hints'] = "";
61 $rg['hints'] = "";
63 62
64 63 $repo_path = rg_repo_path_by_id($rg['ri']['uid'], $rg['ri']['repo_id']); $repo_path = rg_repo_path_by_id($rg['ri']['uid'], $rg['ri']['repo_id']);
65 64 rg_log("repo_path=$repo_path"); rg_log("repo_path=$repo_path");
66 65 putenv("GIT_DIR=$repo_path"); // TODO: this will be removed after all functios will got a path para putenv("GIT_DIR=$repo_path"); // TODO: this will be removed after all functios will got a path para
67 66
68 $repo_more['repo_body'] = "";
69 $repo_more['repo_right'] = "";
70 $repo_more['branches_and_tags'] = "";
71 $repo_more['repo_submenu'] = "";
67 $rg['repo_body'] = "";
68 $rg['repo_right'] = "";
69 $rg['branches_and_tags'] = "";
70 $rg['repo_submenu'] = "";
72 71 $_repo_body = ""; $_repo_body = "";
73 72 $_repo_right = ""; $_repo_right = "";
74 73
75 74 // build urls list // build urls list
76 75 $urls = array(); $urls = array();
77 76 if ($rg_ssh_port != 0) if ($rg_ssh_port != 0)
78 $urls[]['HTML:url'] = '<a href="' . $repo_more['ssh'] . '">' . $repo_more['ssh'] . '</a>';
77 $urls[]['HTML:url'] = '<a href="' . $rg['ssh'] . '">' . $rg['ssh'] . '</a>';
79 78 if ($rg_git_port != 0) if ($rg_git_port != 0)
80 $urls[]['HTML:url'] = '<a href="' . $repo_more['git'] . '">' . $repo_more['git'] . '</a>';
81 $repo_more['HTML:urls'] = rg_template_table("repo/urls", $urls, $repo_more);
79 $urls[]['HTML:url'] = '<a href="' . $rg['git'] . '">' . $rg['git'] . '</a>';
80 $rg['HTML:urls'] = rg_template_table("repo/urls", $urls, $rg);
82 81
83 82 // default tab // default tab
84 83 $_subop = empty($paras) ? "history" : array_shift($paras); $_subop = empty($paras) ? "history" : array_shift($paras);
 
... ... if (strcmp($_subop, "history") == 0) {
88 87 if ($hist === FALSE) if ($hist === FALSE)
89 88 $_repo_body .= rg_warning("Cannot load history. Try again later."); $_repo_body .= rg_warning("Cannot load history. Try again later.");
90 89 else else
91 $_repo_body .= rg_template_table("repo/history", $hist, $repo_more);
90 $_repo_body .= rg_template_table("repo/history", $hist, $rg);
92 91 } else if (strcmp($_subop, "admin") == 0) { } else if (strcmp($_subop, "admin") == 0) {
93 92 $_repo_body .= rg_repo_admin($db, $rg, $paras); $_repo_body .= rg_repo_admin($db, $rg, $paras);
94 93 } else if (strcmp($_subop, "source") == 0) { } else if (strcmp($_subop, "source") == 0) {
 
... ... if (strcmp($_subop, "history") == 0) {
96 95
97 96 $type_ref = rg_git_parse_ref($paras); $type_ref = rg_git_parse_ref($paras);
98 97 $ref = $type_ref['ref_path']; $ref = $type_ref['ref_path'];
99 $repo_more = array_merge($repo_more, $type_ref);
98 $rg = array_merge($rg, $type_ref);
100 99
101 $bt = rg_git_branches_and_tags($repo_path, $repo_more['url_repo'],
100 $bt = rg_git_branches_and_tags($repo_path, $rg['url_repo'],
102 101 $type_ref['ref_url']); $type_ref['ref_url']);
103 //rg_log("DEBUG: repo_more: " . rg_array2string($repo_more));
104 $repo_more = array_merge($repo_more, $bt);
102 $rg = array_merge($rg, $bt);
105 103
106 104 $hints = array(); $hints = array();
107 105 if ($rg_ssh_port != 0) if ($rg_ssh_port != 0)
108 $hints[]['HTML:hint'] = rg_template("hints/repo/clone_ssh.html", $repo_more);
106 $hints[]['HTML:hint'] = rg_template("hints/repo/clone_ssh.html", $rg);
109 107 if ($rg_git_port != 0) if ($rg_git_port != 0)
110 $hints[]['HTML:hint'] = rg_template("hints/repo/clone_git.html", $repo_more);
108 $hints[]['HTML:hint'] = rg_template("hints/repo/clone_git.html", $rg);
111 109 if (rg_rights_allow($db, $rg['ri']['repo_id'], "repo_refs", if (rg_rights_allow($db, $rg['ri']['repo_id'], "repo_refs",
112 110 $rg['ri']['uid'], $rg['login_ui']['uid'], "H", $rg['ip'], FALSE)) /* H = anon push */ $rg['ri']['uid'], $rg['login_ui']['uid'], "H", $rg['ip'], FALSE)) /* H = anon push */
113 $hints[]['HTML:hint'] = rg_template("hints/repo/anon_push.html", $repo_more);
114 $repo_more['HTML:hints'] = rg_template_table("hints/list", $hints, $repo_more);
111 $hints[]['HTML:hint'] = rg_template("hints/repo/anon_push.html", $rg);
112 $rg['HTML:hints'] = rg_template_table("hints/list", $hints, $rg);
115 113
116 $_repo_body .= rg_template("repo/source.html", $repo_more);
114 $_repo_body .= rg_template("repo/source.html", $rg);
117 115
118 116 rg_log("DEBUG: _subsubop=[$_subsubop]"); rg_log("DEBUG: _subsubop=[$_subsubop]");
119 117 if (strcmp($_subsubop, "tree") == 0) { if (strcmp($_subsubop, "tree") == 0) {
 
... ... if (strcmp($_subop, "history") == 0) {
122 120 if (strcmp($type, "blob") == 0) { if (strcmp($type, "blob") == 0) {
123 121 // find hash of blob // find hash of blob
124 122 $_path = implode("/", $paras); $_path = implode("/", $paras);
125 $repo_more['path'] = "/" . $_path;
123 $rg['path'] = "/" . $_path;
126 124 $_tree = rg_git_ls_tree($ref, $_path); $_tree = rg_git_ls_tree($ref, $_path);
127 125 if ($_tree === FALSE) { if ($_tree === FALSE) {
128 126 $_repo_body .= "Invalid path!"; $_repo_body .= "Invalid path!";
 
... ... if (strcmp($_subop, "history") == 0) {
135 133 "HTML:content" => rg_template_list($c) "HTML:content" => rg_template_list($c)
136 134 ); );
137 135 $blob = array_merge($blob, $_content); $blob = array_merge($blob, $_content);
138 $blob = array_merge($blob, $repo_more);
136 $blob = array_merge($blob, $rg);
139 137 $_repo_body .= rg_template("repo/blob.html", $blob); $_repo_body .= rg_template("repo/blob.html", $blob);
140 138 } }
141 139 } else if (strcmp($type, "tree") == 0) { } else if (strcmp($type, "tree") == 0) {
142 140 // find treeish of dir // find treeish of dir
143 141 $_path = implode("/", $paras); $_path = implode("/", $paras);
144 $repo_more['path'] = "/" . $_path;
142 $rg['path'] = "/" . $_path;
145 143 $_tree = rg_git_ls_tree($ref, $_path); $_tree = rg_git_ls_tree($ref, $_path);
146 144 if ($_tree === FALSE) { if ($_tree === FALSE) {
147 145 $_repo_body .= "Invalid path!"; $_repo_body .= "Invalid path!";
 
... ... if (strcmp($_subop, "history") == 0) {
149 147 $_hash = $_tree[0]['ref']; $_hash = $_tree[0]['ref'];
150 148 $_tree = rg_git_ls_tree($_hash, ""); $_tree = rg_git_ls_tree($_hash, "");
151 149 $_repo_body .= rg_template_table("repo/tree", $_repo_body .= rg_template_table("repo/tree",
152 $_tree, $repo_more);
150 $_tree, $rg);
153 151 } }
154 152 } else { // default is to show root tree } else { // default is to show root tree
155 $repo_more['path'] = "";
153 $rg['path'] = "";
156 154 $_tree = rg_git_ls_tree($ref, ""); $_tree = rg_git_ls_tree($ref, "");
157 155 $_repo_body .= rg_template_table("repo/tree", $_tree, $_repo_body .= rg_template_table("repo/tree", $_tree,
158 $repo_more);
156 $rg);
159 157 } }
160 158 } else { } else {
161 159 // show the log // show the log
 
... ... if (strcmp($_subop, "history") == 0) {
166 164 // TODO: rg_internal_error? // TODO: rg_internal_error?
167 165 } else if (empty($log)) { } else if (empty($log)) {
168 166 $_repo_body .= rg_template("repo/not_init.html", $_repo_body .= rg_template("repo/not_init.html",
169 $repo_more);
167 $rg);
170 168 } else { } else {
171 169 //rg_log("DEBUG: log: " . print_r($log, TRUE)); //rg_log("DEBUG: log: " . print_r($log, TRUE));
172 170 $_repo_body .= rg_git_log_template($log, $_repo_body .= rg_git_log_template($log,
173 "repo/log", $repo_more);
171 "repo/log", $rg);
174 172 } }
175 173
176 174 $type = array_shift($paras); $type = array_shift($paras);
 
... ... if (strcmp($_subop, "history") == 0) {
216 214 } }
217 215 } }
218 216 } }
219 $_repo_right = rg_template("repo/source_r.html", $repo_more);
217 $_repo_right = rg_template("repo/source_r.html", $rg);
220 218 } else if (strcmp($_subop, "bug") == 0) { } else if (strcmp($_subop, "bug") == 0) {
221 219 include($INC . "/user/repo/bug/main.php"); include($INC . "/user/repo/bug/main.php");
222 220 $_repo_body .= $bug_body; $_repo_body .= $bug_body;
223 221 } else if (strcmp($_subop, "stats") == 0) { } else if (strcmp($_subop, "stats") == 0) {
224 $_repo_body .= rg_template("repo/stats.html", $repo_more);
222 $_repo_body .= rg_template("repo/stats.html", $rg);
225 223 } else if (strcmp($_subop, "mr") == 0) { } else if (strcmp($_subop, "mr") == 0) {
226 224 if (empty($paras)) { if (empty($paras)) {
227 $_repo_body .= rg_template("repo/mrs.html", $repo_more);
225 $_repo_body .= rg_template("repo/mrs.html", $rg);
228 226
229 227 $r = rg_mr_load($db, $rg['ri']['repo_id'], 20); $r = rg_mr_load($db, $rg['ri']['repo_id'], 20);
230 228 if ($r === FALSE) { if ($r === FALSE) {
231 229 $_repo_body .= "Error getting merge request list (" $_repo_body .= "Error getting merge request list ("
232 230 . rg_mr_error() . ")."; . rg_mr_error() . ").";
233 231 } else { } else {
234 $_repo_body .= rg_template_table("repo/mr/list", $r,
235 $repo_more);
232 $_repo_body .= rg_template_table("repo/mr/list", $r, $rg);
236 233 } }
237 234 } else { } else {
238 235 $mr = preg_replace('/[^0-9a-zA-Z_]/', '', array_shift($paras)); $mr = preg_replace('/[^0-9a-zA-Z_]/', '', array_shift($paras));
239 do {
236 while (1) {
240 237 $mri = rg_mr_load_one($db, $rg['ri']['repo_id'], $mr); $mri = rg_mr_load_one($db, $rg['ri']['repo_id'], $mr);
241 238 if ($mri === FALSE) { if ($mri === FALSE) {
242 239 $_repo_body .= "Error getting merge request (" . rg_mr_error() . ")."; $_repo_body .= "Error getting merge request (" . rg_mr_error() . ").";
 
... ... if (strcmp($_subop, "history") == 0) {
251 248 } }
252 249
253 250 $mri['HTML:diff'] = rg_git_log_template($_log, $mri['HTML:diff'] = rg_git_log_template($_log,
254 "repo/log", $repo_more);
255 $_repo_body .= rg_template("repo/mr/page.html", $mri,
256 $repo_more);
257 } while (0);
251 "repo/log", $rg);
252 $_repo_body .= rg_template("repo/mr/page.html", $mri, $rg);
253
254 break;
255 }
258 256 } }
259 257 } }
260 258
261 $repo_more['HTML:repo_body'] = $_repo_body;
262 $repo_more['HTML:repo_right'] = $_repo_right;
263 $_repo_page = rg_template("repo/main.html", $repo_more);
259 $rg['HTML:repo_body'] = $_repo_body;
260 $rg['HTML:repo_right'] = $_repo_right;
261 $_repo_page = rg_template("repo/main.html", $rg);
264 262 ?> ?>
File inc/user/repo/bug/main.php changed (mode: 100644) (index 17e3998..d8dafbb)
1 1 <?php <?php
2 2 rg_log("FILE: /inc/user/repo/bug/main"); rg_log("FILE: /inc/user/repo/bug/main");
3 3
4 $repo_bug_more = $repo_more;
5 4 $_bug_body = ""; $_bug_body = "";
6 5
7 $repo_bug_more['can_save'] = $rg['login_ui']['uid'] > 0 ? 1 : 0;
6 $rg['can_save'] = $rg['login_ui']['uid'] > 0 ? 1 : 0;
8 7
9 8 $_op = empty($paras) ? "list" : array_shift($paras); $_op = empty($paras) ? "list" : array_shift($paras);
10 9 switch ($_op) { switch ($_op) {
 
... ... case 'search':
14 13 break; break;
15 14
16 15 case 'add': case 'add':
17 $_bug_body .= rg_bug_edit_high_level($db, $repo_more);
16 $_bug_body .= rg_bug_edit_high_level($db, $rg);
18 17 break; break;
19 18
20 19 case 'list': case 'list':
20 // TODO: security: do I validate 'sparas' everywhere?!
21 21 $_search = empty($paras) ? "All" : array_shift($paras); $_search = empty($paras) ? "All" : array_shift($paras);
22 22
23 23 // Somebody pressed "Remove" (search) button? // Somebody pressed "Remove" (search) button?
 
... ... case 'list':
27 27 exit(1); // security_violation?! exit(1); // security_violation?!
28 28 } }
29 29
30 $_search_name = rg_var_str("name");
30 31 $r = rg_bug_search_remove($db, $rg['ri']['repo_id'], $r = rg_bug_search_remove($db, $rg['ri']['repo_id'],
31 $rg['login_ui']['uid'], $_search);
32 $rg['login_ui']['uid'], $_search_name);
32 33 if ($r === FALSE) if ($r === FALSE)
33 34 $_bug_body .= rg_warning("Error: cannot delete search!"); // TODO $_bug_body .= rg_warning("Error: cannot delete search!"); // TODO
34 35 } }
 
... ... case 'list':
38 39 $_bug_body .= rg_warning("Error: cannot load all searches!"); // TODO $_bug_body .= rg_warning("Error: cannot load all searches!"); // TODO
39 40 } else { } else {
40 41 $_bug_body .= rg_template_table("repo/bug/search/list", $_bug_body .= rg_template_table("repo/bug/search/list",
41 $r, $repo_bug_more);
42 $r, $rg);
42 43 } }
43 44
44 45 $filter = rg_bug_search_load($db, $rg['ri']['repo_id'], $filter = rg_bug_search_load($db, $rg['ri']['repo_id'],
 
... ... case 'list':
49 50 } }
50 51
51 52 if (isset($filter['name'])) if (isset($filter['name']))
52 $repo_bug_more['search_name'] = $filter['name'];
53 $rg['search_name'] = $filter['name'];
53 54
54 55 $r = rg_bug_search($db, $rg['ri']['repo_id'], $rg['login_ui']['uid'], $filter); $r = rg_bug_search($db, $rg['ri']['repo_id'], $rg['login_ui']['uid'], $filter);
55 if ($r === FALSE)
56 $_bug_body .= rg_warning("Error: Cannot search bugs!"); // TODO: do something OK here!
57 else
58 $_bug_body .= rg_template_table("repo/bug/list", $r, $repo_bug_more);
56 if ($r === FALSE) {
57 // TODO: do something OK here!
58 $_bug_body .= rg_warning("Error: Cannot search bugs!");
59 } else {
60 $_bug_body .= rg_template_table("repo/bug/list", $r, $rg);
61 }
59 62
60 63 // Show remove for custom search // Show remove for custom search
61 64 // TODO: don't we check for uid also? Security problems? // TODO: don't we check for uid also? Security problems?
62 65 if (isset($filter['standard']) && ($filter['standard'] == 0)) { if (isset($filter['standard']) && ($filter['standard'] == 0)) {
63 $_remove_more = $repo_bug_more;
64 $_remove_more['rg_form_token'] = rg_token_get($db, $rg['sid']);
65 $_remove_more['search_remove_errmsg'] = "";
66 $_bug_body .= rg_template("repo/bug/search/remove.html",
67 $_remove_more);
66 $rg['rg_form_token'] = rg_token_get($db, $rg['sid']);
67 $rg['search_remove_errmsg'] = "";
68 $_bug_body .= rg_template("repo/bug/search/remove.html", $rg);
68 69 } }
69 70 break; break;
70 71
71 72 default: // show - go directly to a bug default: // show - go directly to a bug
72 73 $bug_id = intval($_op); $bug_id = intval($_op);
73 $repo_bug_more['bug'] = array();
74 $repo_bug_more['bug']['bug_id'] = $bug_id;
74 $rg['bug'] = array();
75 $rg['bug']['bug_id'] = $bug_id;
75 76 if ($bug_id > 0) { if ($bug_id > 0) {
76 $repo_bug_more['bug']['url'] = $rg['url_repo'] . "/bug/"
77 . $repo_bug_more['bug']['bug_id'];
77 $rg['bug']['url'] = $rg['url_repo'] . "/bug/"
78 . $rg['bug']['bug_id'];
78 79 include($INC . "/user/repo/bug/show/show.php"); include($INC . "/user/repo/bug/show/show.php");
79 80 $_bug_body .= $_bug_show; $_bug_body .= $_bug_show;
80 81 } }
81 82 break; break;
82 83 } }
83 84
84 $repo_bug_more['HTML:bug_body'] = $_bug_body;
85 $bug_body = rg_template("repo/bug/main.html", $repo_bug_more);
85 $rg['HTML:bug_body'] = $_bug_body;
86 $bug_body = rg_template("repo/bug/main.html", $rg);
86 87 ?> ?>
File inc/user/repo/bug/search/search.php changed (mode: 100644) (index 234a83c..5acce9e)
1 1 <?php <?php
2 2 rg_log("FILE: /inc/user/repo/bug/search/search"); rg_log("FILE: /inc/user/repo/bug/search/search");
3 3
4 $bug_search_more = $repo_bug_more;
5 4 $_bug_search = ""; $_bug_search = "";
6 5 $errmsg = array(); $errmsg = array();
7 6
 
... ... if ($rg['doit'] == 0) {
39 38 $_x['name'] = rg_var_str("name"); $_x['name'] = rg_var_str("name");
40 39 $_x['standard'] = 0; $_x['standard'] = 0;
41 40
42 do {
41 while (1) {
43 42 $bugs = rg_bug_search($db, $rg['ri']['repo_id'], $bugs = rg_bug_search($db, $rg['ri']['repo_id'],
44 43 $rg['login_ui']['uid'], $_x); $rg['login_ui']['uid'], $_x);
45 44 if ($bugs === FALSE) { if ($bugs === FALSE) {
 
... ... if ($rg['doit'] == 0) {
48 47 } }
49 48
50 49 // Show bugs // Show bugs
51 $_bug_search .= rg_template_table("repo/bug/list", $bugs,
52 $bug_search_more);
53 } while (0);
50 $_bug_search .= rg_template_table("repo/bug/list", $bugs, $rg);
51 break;
52 }
54 53 } }
55 54
56 $bug_search_more = array_merge($bug_search_more, $_x);
57 $bug_search_more['HTML:errmsg'] = rg_template_errmsg($errmsg);
55 $rg = array_merge($rg, $_x);
56 $rg['HTML:errmsg'] = rg_template_errmsg($errmsg);
58 57 $_exclude = array(); $_exclude = array();
59 $bug_search_more['HTML:state_select'] = rg_bug_state_select($_x['state'], $_exclude);
60 $_bug_search .= rg_template("repo/bug/search/search.html", $bug_search_more);
58 $rg['HTML:state_select'] = rg_bug_state_select($_x['state'], $_exclude);
59 $_bug_search .= rg_template("repo/bug/search/search.html", $rg);
61 60 ?> ?>
File inc/user/repo/bug/show/add_note.php changed (mode: 100644) (index 1271f8b..0cd16a0)
... ... rg_log("FILE: /inc/user/repo/bug/show/add_note");
3 3
4 4 $note_add_doit = rg_var_uint("note_add_doit"); $note_add_doit = rg_var_uint("note_add_doit");
5 5
6 $add_note_more = $repo_bug_show_more;
7 6 $note = ""; $note = "";
8 7
9 8 $note_errmsg = array(); $note_errmsg = array();
10 9
11 do {
10 while (1) {
12 11 if ($note_add_doit != 1) if ($note_add_doit != 1)
13 12 break; break;
14 13
 
... ... do {
36 35
37 36 // allow another note to be added // allow another note to be added
38 37 $note = ""; $note = "";
39 } while (0);
38 break;
39 }
40 40
41 41 // add note form // add note form
42 $add_note_more['HTML:note_errmsg'] = rg_template_errmsg($note_errmsg);
43 $add_note_more['rg_form_token'] = rg_token_get($db, $rg['sid']);
44 $add_note_more['note'] = $note;
45 $repo_bug_show_more['HTML:note_add'] = rg_template("repo/bug/note_add.html", $add_note_more);
42 $rg['HTML:note_errmsg'] = rg_template_errmsg($note_errmsg);
43 $rg['rg_form_token'] = rg_token_get($db, $rg['sid']);
44 $rg['note'] = $note;
45 $rg['HTML:note_add'] = rg_template("repo/bug/note_add.html", $rg);
46 46 ?> ?>
File inc/user/repo/bug/show/show.php changed (mode: 100644) (index f8baf29..47d3e5e)
... ... rg_log("FILE: /inc/user/repo/bug/show/show");
3 3
4 4 // TODO: security checks // TODO: security checks
5 5
6 $repo_bug_show_more = $repo_bug_more;
7 6 $_bug_show = ""; $_bug_show = "";
8 7
9 $repo_bug_show_more['HTML:bug_edit'] = "";
8 $rg['HTML:bug_edit'] = "";
10 9
11 $ibug = rg_bug_info($db, $rg['ri']['repo_id'],
12 $repo_bug_show_more['bug']['bug_id']);
10 $ibug = rg_bug_info($db, $rg['ri']['repo_id'], $rg['bug']['bug_id']);
13 11 if ($ibug === FALSE) if ($ibug === FALSE)
14 12 rg_fatal("Cannot lookup bug!"); rg_fatal("Cannot lookup bug!");
15 13
16 $repo_bug_show_more['bug'] = array_merge($repo_bug_show_more['bug'], $ibug);
14 $rg['bug'] = array_merge($rg['bug'], $ibug);
17 15
18 16 if ($ibug['exists'] != 1) { if ($ibug['exists'] != 1) {
19 $_bug_body .= rg_template("repo/bug/not_found.html", $repo_bug_show_more);
17 $_bug_body .= rg_template("repo/bug/not_found.html", $rg);
20 18 return; return;
21 19 } }
22 20
 
... ... if ($ibug['exists'] != 1) {
24 22 if ($ibug['deleted'] > 0) { if ($ibug['deleted'] > 0) {
25 23 if (rg_rights_allow($db, $rg['ri']['repo_id'], "repo", $rg['ri']['uid'], if (rg_rights_allow($db, $rg['ri']['repo_id'], "repo", $rg['ri']['uid'],
26 24 $rg['login_ui']['uid'], "d", $rg['ip'], "") !== TRUE) { $rg['login_ui']['uid'], "d", $rg['ip'], "") !== TRUE) {
27 $_bug_body .= rg_template("repo/bug/deleted.html", $repo_bug_show_more);
25 $_bug_body .= rg_template("repo/bug/deleted.html", $rg);
28 26 return; return;
29 27 } }
30 28 } }
31 29
32 30 // load labels // load labels
33 $labels = rg_bug_label_get($db, $rg['ri']['repo_id'], $repo_bug_show_more['bug']['bug_id']);
31 $labels = rg_bug_label_get($db, $rg['ri']['repo_id'], $rg['bug']['bug_id']);
34 32 if ($labels === FALSE) if ($labels === FALSE)
35 $repo_bug_show_more['HTML:labels_html'] = "Cannot load labels!";
33 $rg['HTML:labels_html'] = "Cannot load labels!";
36 34 else else
37 $repo_bug_show_more['HTML:labels_html'] = rg_bug_label_html($db, $labels);
38 $repo_bug_show_more['bug']['labels'] = implode(" ", $labels);
35 $rg['HTML:labels_html'] = rg_bug_label_html($db, $labels);
36 $rg['bug']['labels'] = implode(" ", $labels);
39 37
40 38 // edit // edit
41 $repo_bug_show_more['HTML:edit_form'] = rg_template("repo/bug/b_edit.html",
42 $repo_bug_show_more);
43 if (rg_var_uint("edit") == 1) {
44 $repo_bug_show_more['HTML:bug_edit'] =
45 rg_bug_edit_high_level($db, $repo_bug_show_more);
46 }
39 $rg['HTML:edit_form'] = rg_template("repo/bug/b_edit.html", $rg);
40 if (rg_var_uint("edit") == 1)
41 $rg['HTML:bug_edit'] = rg_bug_edit_high_level($db, $rg);
47 42
48 43 // close/re-open // close/re-open
49 44 $close_reopen_error = ""; $close_reopen_error = "";
50 do {
45 while (1) {
51 46 if (rg_var_uint("close_reopen") != 1) if (rg_var_uint("close_reopen") != 1)
52 47 break; break;
53 48
 
... ... do {
80 75 } }
81 76
82 77 // TODO: do something with the error code // TODO: do something with the error code
83 } while (0);
78 break;
79 }
84 80 if ($ibug['state'] == 1) if ($ibug['state'] == 1)
85 81 $t = "repo/bug/b_close.html"; $t = "repo/bug/b_close.html";
86 82 else else
87 83 $t = "repo/bug/b_reopen.html"; $t = "repo/bug/b_reopen.html";
88 $repo_bug_show_more['HTML:close_form'] = rg_template($t, $repo_bug_show_more);
89 $repo_bug_show_more['HTML:button_error'] = rg_warning($close_reopen_error,
90 $repo_bug_show_more);
84 $rg['HTML:close_form'] = rg_template($t, $rg);
85 $rg['HTML:button_error'] = rg_warning($close_reopen_error, $rg);
91 86
92 87 // 'add_note' must be unconditionally included because we must insert the form // 'add_note' must be unconditionally included because we must insert the form
93 88 include($INC . "/user/repo/bug/show/add_note.php"); include($INC . "/user/repo/bug/show/add_note.php");
94 89
95 90 // load notes // load notes
96 91 $notes = rg_bug_note_list($db, $rg['ri']['repo_id'], $notes = rg_bug_note_list($db, $rg['ri']['repo_id'],
97 $repo_bug_show_more['bug']['bug_id'], 0);
92 $rg['bug']['bug_id'], 0);
98 93 if ($notes === FALSE) if ($notes === FALSE)
99 $repo_bug_show_more['HTML:notes'] = "Cannot load notes!";
94 $rg['HTML:notes'] = "Cannot load notes!";
100 95 else else
101 $repo_bug_show_more['HTML:notes'] = rg_template_table("repo/bug/list_note", $notes, $repo_bug_show_more);
96 $rg['HTML:notes'] = rg_template_table("repo/bug/list_note", $notes, $rg);
102 97
103 98 // watch // watch
104 99 $watch_body = ""; $watch_body = "";
105 100 $watch = rg_watch_load($db, "bug", $rg['login_ui']['uid'], $rg['ri']['repo_id'], $watch = rg_watch_load($db, "bug", $rg['login_ui']['uid'], $rg['ri']['repo_id'],
106 $repo_bug_show_more['bug']['bug_id']);
101 $rg['bug']['bug_id']);
107 102 if ($watch === FALSE) { if ($watch === FALSE) {
108 103 $watch_body .= rg_warning("Internal error."); $watch_body .= rg_warning("Internal error.");
109 104 } else { } else {
 
... ... if ($watch === FALSE) {
112 107 if (rg_var_uint("watch") == 1) { if (rg_var_uint("watch") == 1) {
113 108 // user pressed watch button // user pressed watch button
114 109 $r = rg_watch_add($db, "bug", $rg['login_ui']['uid'], $r = rg_watch_add($db, "bug", $rg['login_ui']['uid'],
115 $rg['ri']['repo_id'], $repo_bug_show_more['bug']['bug_id']);
110 $rg['ri']['repo_id'], $rg['bug']['bug_id']);
116 111 if ($r === FALSE) if ($r === FALSE)
117 112 rg_internal_error("TODO: find something here"); rg_internal_error("TODO: find something here");
118 113 $watch = 1; $watch = 1;
 
... ... if ($watch === FALSE) {
122 117 if (rg_var_uint("unwatch") == 1) { if (rg_var_uint("unwatch") == 1) {
123 118 // user pressed unwatch button // user pressed unwatch button
124 119 $r = rg_watch_del($db, "bug", $rg['login_ui']['uid'], $r = rg_watch_del($db, "bug", $rg['login_ui']['uid'],
125 $rg['ri']['repo_id'], $repo_bug_show_more['bug']['bug_id']);
120 $rg['ri']['repo_id'], $rg['bug']['bug_id']);
126 121 if ($r === FALSE) if ($r === FALSE)
127 122 rg_internal_error("TODO: find something here"); rg_internal_error("TODO: find something here");
128 123 $watch = 0; $watch = 0;
 
... ... if ($watch === FALSE) {
133 128 $t = "repo/bug/b_watch.html"; $t = "repo/bug/b_watch.html";
134 129 else else
135 130 $t = "repo/bug/b_unwatch.html"; $t = "repo/bug/b_unwatch.html";
136 $r = rg_template($t, $repo_bug_show_more);
131 $r = rg_template($t, $rg);
137 132 if ($r !== FALSE) if ($r !== FALSE)
138 133 $watch_body .= $r; $watch_body .= $r;
139 134 } }
140 $repo_bug_show_more['HTML:watch_form'] = $watch_body;
135 $rg['HTML:watch_form'] = $watch_body;
141 136
142 137 // delete // delete
143 138 $delete_error = ""; $delete_error = "";
144 do {
139 while (1) {
145 140 $del_undel = rg_var_uint("del_undel"); $del_undel = rg_var_uint("del_undel");
146 141 if ($del_undel == 0) if ($del_undel == 0)
147 142 break; break;
 
... ... do {
163 158 $delete_error = rg_bug_error(); $delete_error = rg_bug_error();
164 159 break; break;
165 160 } }
166 } while (0);
167 $repo_bug_show_more['HTML:button_error'] = rg_warning($delete_error,
168 $repo_bug_show_more);
161 break;
162 }
163 $rg['HTML:button_error'] = rg_warning($delete_error, $rg);
169 164
170 165
171 166 // We must look it up again because it can be edited above; no prob, is in cache // We must look it up again because it can be edited above; no prob, is in cache
172 $ibug = rg_bug_info($db, $rg['ri']['repo_id'],
173 $repo_bug_show_more['bug']['bug_id']);
167 $ibug = rg_bug_info($db, $rg['ri']['repo_id'], $rg['bug']['bug_id']);
174 168 if ($ibug === FALSE) if ($ibug === FALSE)
175 169 rg_fatal("Cannot lookup bug!"); rg_fatal("Cannot lookup bug!");
176 $repo_bug_show_more = rg_array_merge($repo_bug_show_more, "bug", $ibug);
170 $rg = rg_array_merge($rg, "bug", $ibug);
177 171
178 $repo_bug_show_more['rg_form_token'] = rg_token_get($db, $rg['sid']);
179 $_bug_show .= rg_template("repo/bug/show.html", $repo_bug_show_more);
172 $rg['rg_form_token'] = rg_token_get($db, $rg['sid']);
173 $_bug_show .= rg_template("repo/bug/show.html", $rg);
180 174 ?> ?>
File inc/util.inc.php changed (mode: 100644) (index e6270a7..9931874)
... ... function rg_re_repo_git($organization, $user, $repo)
244 244 . $prefix . "/" . $user . "/" . $repo; . $prefix . "/" . $user . "/" . $repo;
245 245 } }
246 246
247 function rg_var_str($name)
247 function rg_var_str_core($name)
248 248 { {
249 249 $ret = ""; $ret = "";
250 250
 
... ... function rg_var_str($name)
257 257 else if (isset($_GET[$name])) else if (isset($_GET[$name]))
258 258 $ret = $_GET[$name]; $ret = $_GET[$name];
259 259
260 return $ret;
261 }
262
263 function rg_var_str($name)
264 {
265 $ret = rg_var_str_core($name);
266
260 267 if (is_string($ret)) if (is_string($ret))
261 268 return htmlspecialchars($ret, ENT_QUOTES); return htmlspecialchars($ret, ENT_QUOTES);
262 269
 
... ... function rg_prepare_func($s, &$what, &$values)
401 408
402 409 $seen = array(); $seen = array();
403 410
404 $r = preg_match_all('/@@func:(.*):(.*)@@/uU', $s, $matches, PREG_SET_ORDER);
411 $r = preg_match_all('/@@func:(.*):(.*)@@/uU', $s, $matches, PREG_SET_ORDER);
405 412 foreach ($matches as $i) { foreach ($matches as $i) {
406 413 $k = '/' . $i[0] . '/'; $k = '/' . $i[0] . '/';
407 414 $func = $i[1]; $func = $i[1];
 
... ... function rg_replace_conditionals($block, &$data)
602 609 rg_prof_start("replace_conditionals"); rg_prof_start("replace_conditionals");
603 610 $ret = array(); $ret = array();
604 611
605 do {
612 while (1) {
606 613 $stack = array(); $stack = array();
607 614 $stack[] = TRUE; $stack[] = TRUE;
608 615 $ret = rg_replace_conditionals_block($block, $data, $stack); $ret = rg_replace_conditionals_block($block, $data, $stack);
 
... ... function rg_replace_conditionals($block, &$data)
614 621 $ret = FALSE; $ret = FALSE;
615 622 break; break;
616 623 } }
617 } while (0);
624
625 break;
626 }
618 627
619 628 rg_prof_end("replace_conditionals"); rg_prof_end("replace_conditionals");
620 629 return $ret; return $ret;
 
... ... function rg_ok($msg)
805 814 function rg_exec($cmd) function rg_exec($cmd)
806 815 { {
807 816 rg_prof_start("exec"); rg_prof_start("exec");
808 rg_log("Executing [$cmd]...");
817 rg_log_enter("Executing [$cmd]...");
809 818
810 819 $ret = array(); $ret = array();
811 820 $ret['ok'] = 0; $ret['ok'] = 0;
812 821 $ret['errmsg'] = ""; $ret['errmsg'] = "";
813 822 $ret['code'] = 65000; // fake code $ret['code'] = 65000; // fake code
814 do {
823 while (1) {
815 824 $desc = array( $desc = array(
816 825 0 => array("pipe", "r"), 0 => array("pipe", "r"),
817 826 1 => array("pipe", "w"), 1 => array("pipe", "w"),
 
... ... function rg_exec($cmd)
884 893 $ret['code'] = 0; $ret['code'] = 0;
885 894 $ret['ok'] = 1; $ret['ok'] = 1;
886 895 } }
887 } while (0);
888 896
897 break;
898 }
899
900 rg_log_exit();
889 901 rg_prof_end("exec"); rg_prof_end("exec");
890 902 return $ret; return $ret;
891 903 } }
 
... ... $rg_socket_cache = array();
1200 1212
1201 1213 /* /*
1202 1214 * Receives buffers and test if @wait string is present. * Receives buffers and test if @wait string is present.
1203 * @timeout - in miliseconds
1215 * @timeout - in miliseconds, NULL=forever, 0=no_wait
1204 1216 */ */
1205 1217 function rg_socket_recv_wait($socket, $wait, $timeout) function rg_socket_recv_wait($socket, $wait, $timeout)
1206 1218 { {
 
... ... function rg_socket_recv_wait($socket, $wait, $timeout)
1215 1227 } }
1216 1228
1217 1229 $ret_buf = ""; $ret_buf = "";
1218 do {
1230 while (1) {
1219 1231 $reads = array($socket); $writes = array(); $ex = array(); $reads = array($socket); $writes = array(); $ex = array();
1220 1232 $r = socket_select($reads, $writes, $ex, $tv_sec, $tv_usec); $r = socket_select($reads, $writes, $ex, $tv_sec, $tv_usec);
1221 1233 if ($r === FALSE) { if ($r === FALSE) {
 
... ... function rg_socket_recv_wait($socket, $wait, $timeout)
1246 1258 $ret = $ret_buf; $ret = $ret_buf;
1247 1259 break; break;
1248 1260 } }
1249 } while (0);
1261
1262 break;
1263 }
1250 1264
1251 1265 return $ret; return $ret;
1252 1266 } }
 
... ... function rg_socket_send($socket, $buf)
1280 1294
1281 1295 /* /*
1282 1296 * Connects to a socket, send @buf and returns the answer. * Connects to a socket, send @buf and returns the answer.
1283 * If timeout is 0, we do not wait for an answer. If is NULL, we wait forever.
1284 * Else, wait the number of miliseconds.
1297 * @timeout: NULL=forever, 0=no_wait
1298 is 0, we do not wait for an answer. If is NULL, we wait forever.
1285 1299 */ */
1286 1300 function rg_socket($path, $buf, $timeout) function rg_socket($path, $buf, $timeout)
1287 1301 { {
 
... ... function rg_socket($path, $buf, $timeout)
1306 1320 $r = socket_connect($socket, $path); $r = socket_connect($socket, $path);
1307 1321 if ($r === FALSE) { if ($r === FALSE) {
1308 1322 $tries--; $tries--;
1309 usleep(200000);
1323 usleep(50 * 1000);
1310 1324 continue; continue;
1311 1325 } }
1312 1326
 
... ... function rg_socket($path, $buf, $timeout)
1324 1338 if ($r !== TRUE) if ($r !== TRUE)
1325 1339 break; break;
1326 1340
1327 if ($timeout == 0) {
1341 if ($timeout === 0) {
1328 1342 rg_log("We do not have to wait. Exit."); rg_log("We do not have to wait. Exit.");
1329 1343 $ret = ""; $ret = "";
1330 1344 break; break;
File inc/watch.inc.php changed (mode: 100644) (index 02c78ad..93c52d8)
... ... function rg_watch_load($db, $type, $uid, $obj_id1, $obj_id2)
33 33 return $rg_watch_load_cache[$key]; return $rg_watch_load_cache[$key];
34 34
35 35 rg_prof_start("watch_load"); rg_prof_start("watch_load");
36 rg_log("watch_load: type=$type uid=$uid obj_id=$obj_id1/$obj_id2");
36 rg_log_enter("watch_load: type=$type uid=$uid obj_id=$obj_id1/$obj_id2");
37 37
38 38 $ret = FALSE; $ret = FALSE;
39 do {
39 while (1) {
40 40 $params = array("uid" => $uid, $params = array("uid" => $uid,
41 41 "obj_id1" => $obj_id1, "obj_id1" => $obj_id1,
42 42 "obj_id2" => $obj_id2); "obj_id2" => $obj_id2);
 
... ... function rg_watch_load($db, $type, $uid, $obj_id1, $obj_id2)
62 62
63 63 $ret = $rows > 0 ? 1 : 0; $ret = $rows > 0 ? 1 : 0;
64 64 $rg_watch_load_cache[$key] = $ret; $rg_watch_load_cache[$key] = $ret;
65 } while (0);
65 break;
66 }
66 67
68 rg_log_exit();
67 69 rg_prof_end("watch_load"); rg_prof_end("watch_load");
68 70 return $ret; return $ret;
69 71 } }
 
... ... function rg_watch_add($db, $type, $uid, $obj_id1, $obj_id2)
82 84 return $rg_watch_add_state[$key]; return $rg_watch_add_state[$key];
83 85
84 86 rg_prof_start("watch_add"); rg_prof_start("watch_add");
85 rg_log("watch_add type=$type, uid=$uid obj_id=$obj_id1/$obj_id2");
87 rg_log_enter("watch_add type=$type, uid=$uid obj_id=$obj_id1/$obj_id2");
86 88
87 89 $ret = FALSE; $ret = FALSE;
88 do {
90 while (1) {
89 91 $r = rg_watch_load($db, $type, $uid, $obj_id1, $obj_id2); $r = rg_watch_load($db, $type, $uid, $obj_id1, $obj_id2);
90 92 if ($r === FALSE) if ($r === FALSE)
91 93 break; break;
 
... ... function rg_watch_add($db, $type, $uid, $obj_id1, $obj_id2)
114 116 rg_sql_free_result($res); rg_sql_free_result($res);
115 117
116 118 $ret = TRUE; $ret = TRUE;
117 } while (0);
119 break;
120 }
118 121
119 122 $rg_watch_add_state[$key] = $ret; $rg_watch_add_state[$key] = $ret;
120 123
124 rg_log_exit();
121 125 rg_prof_end("watch_add"); rg_prof_end("watch_add");
122 126 return $ret; return $ret;
123 127 } }
 
... ... function rg_watch_add($db, $type, $uid, $obj_id1, $obj_id2)
128 132 function rg_watch_del($db, $type, $login_uid, $obj_id1, $obj_id2) function rg_watch_del($db, $type, $login_uid, $obj_id1, $obj_id2)
129 133 { {
130 134 rg_prof_start("watch_del"); rg_prof_start("watch_del");
131 rg_log("watch_del type=$type, login_uid=$login_uid obj_id=$obj_id1/$obj_id2");
135 rg_log_enter("watch_del type=$type, login_uid=$login_uid obj_id=$obj_id1/$obj_id2");
132 136
133 137 $ret = FALSE; $ret = FALSE;
134 do {
138 while (1) {
135 139 if (strcmp($type, "bug") == 0) { if (strcmp($type, "bug") == 0) {
136 140 $sql = "DELETE FROM watch_bug" $sql = "DELETE FROM watch_bug"
137 141 . " WHERE uid = $login_uid" . " WHERE uid = $login_uid"
 
... ... function rg_watch_del($db, $type, $login_uid, $obj_id1, $obj_id2)
151 155 rg_sql_free_result($res); rg_sql_free_result($res);
152 156
153 157 $ret = TRUE; $ret = TRUE;
154 } while (0);
158 break;
159 }
155 160
161 rg_log_exit();
156 162 rg_prof_end("watch_del"); rg_prof_end("watch_del");
157 163 return $ret; return $ret;
158 164 } }
 
... ... function rg_watch_del($db, $type, $login_uid, $obj_id1, $obj_id2)
163 169 function rg_watch_load_by_obj_id($db, $type, $obj_id1, $obj_id2) function rg_watch_load_by_obj_id($db, $type, $obj_id1, $obj_id2)
164 170 { {
165 171 rg_prof_start("watch_load_by_obj_id"); rg_prof_start("watch_load_by_obj_id");
166 rg_log("watch_load_by_obj_id: type=$type obj_id=$obj_id1/$obj_id2");
172 rg_log_enter("watch_load_by_obj_id: type=$type obj_id=$obj_id1/$obj_id2");
167 173
168 174 $ret = FALSE; $ret = FALSE;
169 do {
175 while (1) {
170 176 $params = array("obj_id1" => $obj_id1, $params = array("obj_id1" => $obj_id1,
171 177 "obj_id2" => $obj_id2); "obj_id2" => $obj_id2);
172 178
 
... ... function rg_watch_load_by_obj_id($db, $type, $obj_id1, $obj_id2)
189 195 while (($row = rg_sql_fetch_array($res))) { while (($row = rg_sql_fetch_array($res))) {
190 196 $ret[] = $row['uid']; $ret[] = $row['uid'];
191 197 } }
192
193 198 rg_sql_free_result($res); rg_sql_free_result($res);
194 } while (0);
195 199
200 break;
201 }
202
203 rg_log_exit();
196 204 rg_prof_end("watch_load_by_obj_id"); rg_prof_end("watch_load_by_obj_id");
197 205 return $ret; return $ret;
198 206 } }
File root/index.php changed (mode: 100644) (index 43dae64..6ae4eb2)
... ... $rg['rg_account_allow_creation'] = $rg_account_allow_creation;
35 35
36 36 // Init variables // Init variables
37 37 $THEME_URL = "/themes/" . $rg_theme; $THEME_URL = "/themes/" . $rg_theme;
38 $sparas = "";
39 38 $rg['login_ui'] = array(); $rg['login_ui'] = array();
40 39 $rg['target_ui'] = array("ok" => 1, "exists" => 0, "uid" => 0); $rg['target_ui'] = array("ok" => 1, "exists" => 0, "uid" => 0);
41 40 $rg['ri'] = array("repo_id" => 0, "uid" => 0); $rg['ri'] = array("repo_id" => 0, "uid" => 0);
File root/themes/default/hints/repo/edit_repo_refs_rights.html changed (mode: 100644) (index 3591855..e673740)
... ... spaces/tabs etc. will be allowed.
4 4
5 5 Example rights for references:<br /> Example rights for references:<br />
6 6 <pre> <pre>
7 refs/heads/x * Fetch + Push = Allow user to fetch/push in private namespace 'x'<br />
8 {USER} * Fetch + Push + Create branch+Delete branch = Logged in user 'USER' has rights to refs/heads/USER<br />
7 refs/heads/x Fetch + Push = Allow user to fetch/push in private namespace 'x'
8 refs/heads/{USER} Fetch + Push + Create branch + Delete branch = The push user 'USER' has rights to refs/heads/USER
9 9 </pre> </pre>
File root/themes/default/hints/repo/edit_rights.html changed (mode: 100644) (index 8e2b7d9..2ac1fa0)
... ... You can use both IPv4 and IPv6. Some examples: 4.4.4.4, 1.2.3.0/24,
7 7 2001:6:3456::/64. 2001:6:3456::/64.
8 8 <br /><br /> <br /><br />
9 9
10 Priority is used to order the rights in the proper order.
11 They are evaluated top to bottom.
10 Priority is used to order the rights. They are evaluated top to bottom.
File root/themes/default/repo/bug/search/remove.html changed (mode: 100644) (index e88e3a3..3a8ff3f)
1 1 @@search_remove_errmsg@@ @@search_remove_errmsg@@
2 2
3 <form method="post" action="@@url@@">
3 <form method="post" action="@@url_repo@@/bug/list">
4 4 <input type="hidden" name="remove" value="1" /> <input type="hidden" name="remove" value="1" />
5 5 <input type="hidden" name="token" value="@@rg_form_token@@" /> <input type="hidden" name="token" value="@@rg_form_token@@" />
6 6 <input type="hidden" name="name" value="@@search_name@@" /> <input type="hidden" name="name" value="@@search_name@@" />
File root/themes/default/repo/bug/search/search.html changed (mode: 100644) (index 1bd917b..71942f6)
4 4
5 5 @@errmsg@@ @@errmsg@@
6 6
7 <form method="post" action="@@url@@">
7 <form method="post" action="@@url_repo@@/bug/search">
8 8 <input type="hidden" name="doit" value="1" /> <input type="hidden" name="doit" value="1" />
9 9
10 10 <label for="reported_by" class="form_item_title">Reported by</label><br /> <label for="reported_by" class="form_item_title">Reported by</label><br />
File root/themes/default/repo/bug/show.html changed (mode: 100644) (index e23f4c8..ecf8fd8)
30 30 Reporter: <b>@@bug.owner@@</b><br /> Reporter: <b>@@bug.owner@@</b><br />
31 31 Assigned to: <b>@@if("@@bug.assigned_to@@" == ""){{-}}{{@@bug.assigned_to@@}}</b><br /> Assigned to: <b>@@if("@@bug.assigned_to@@" == ""){{-}}{{@@bug.assigned_to@@}}</b><br />
32 32 @@if(@@bug.deleted@@ != 0){{ @@if(@@bug.deleted@@ != 0){{
33 <font color="red">Deleted by: @@bug.deleted_who_text@@ (@@bug.deleted_text@@ UTC)</font><br />
33 <font color="red">Deleted by: @@bug.deleted_who_name@@ (@@bug.deleted_text@@ UTC)</font><br />
34 34 }}{{}} }}{{}}
35 35 </div> </div>
36 36
File root/themes/default/repo/list/line.html changed (mode: 100644) (index 2f4a523..b1d50e3)
1 1 <tr> <tr>
2 2 <td><a href="@@url_user@@">@@owner@@</a>/<a href="@@url_repo@@">@@name@@</a></td> <td><a href="@@url_user@@">@@owner@@</a>/<a href="@@url_repo@@">@@name@@</a></td>
3 <td><small>@@description@@</small></td>
3 <td><small>@@description_nice@@</small></td>
4 4 <td>@@clone_of@@</td> <td>@@clone_of@@</td>
5 5 <td>@@creation@@</td> <td>@@creation@@</td>
6 6 <td>@@if(@@public@@ == 1){{Public}}{{Private}}</td> <td>@@if(@@public@@ == 1){{Public}}{{Private}}</td>
File root/themes/default/repo/main.html changed (mode: 100644) (index d590770..ce0dc59)
5 5 <a href="@@url_user@@">@@page_ui.username@@</a> / <a href="@@url_repo@@">@@ri.name@@</a> <a href="@@url_user@@">@@page_ui.username@@</a> / <a href="@@url_repo@@">@@ri.name@@</a>
6 6 </div> </div>
7 7 <div class="repo_desc"> <div class="repo_desc">
8 @@ri.description@@
8 @@ri.description_nice@@
9 9 </div> </div>
10 10
11 11 @@urls@@ @@urls@@
File root/themes/default/user/repo/rights/form_repo.html changed (mode: 100644) (index c0878a4..8655cd5)
19 19 <br /> <br />
20 20
21 21 <label class="form_item_title" for="desc">Description</label><br /> <label class="form_item_title" for="desc">Description</label><br />
22 <textarea name="desc" rows="3" cols="50">@@desc@@</textarea>
22 <textarea name="description" rows="3" cols="50">@@description@@</textarea>
23 23 <br /> <br />
24 24 <br /> <br />
25 25
File root/themes/default/user/repo/rights/form_repo_path.html changed (mode: 100644) (index 7580b47..55f9a6e)
24 24 <br /> <br />
25 25
26 26 <label class="form_item_title" for="desc">Description</label><br /> <label class="form_item_title" for="desc">Description</label><br />
27 <textarea name="desc" rows="3" cols="50">@@desc@@</textarea>
27 <textarea name="description" rows="3" cols="50">@@description@@</textarea>
28 28 <br /> <br />
29 29 <br /> <br />
30 30
File root/themes/default/user/repo/rights/form_repo_refs.html changed (mode: 100644) (index 19bb83b..5771ef5)
24 24 <br /> <br />
25 25
26 26 <label class="form_item_title" for="desc">Description</label><br /> <label class="form_item_title" for="desc">Description</label><br />
27 <textarea name="desc" rows="3" cols="50">@@desc@@</textarea>
27 <textarea name="description" rows="3" cols="50">@@description@@</textarea>
28 28 <br /> <br />
29 29 <br /> <br />
30 30
File root/themes/default/user/repo/rights/list_repo/line.html changed (mode: 100644) (index 2ac646e..a227605)
6 6 <td>@@username@@</td> <td>@@username@@</td>
7 7 <td>@@nice.ip@@</td> <td>@@nice.ip@@</td>
8 8 <td>@@rights_text@@</td> <td>@@rights_text@@</td>
9 <td>@@desc@@</td>
9 <td>@@description@@</td>
10 10 <td>@@if(@@can_be_deleted@@ == 1){{<a href="@@url_repo@@/admin/repo_rights?edit_id=@@right_id@@">Edit</a>}}{{N/A}}</td> <td>@@if(@@can_be_deleted@@ == 1){{<a href="@@url_repo@@/admin/repo_rights?edit_id=@@right_id@@">Edit</a>}}{{N/A}}</td>
11 11 </tr> </tr>
File root/themes/default/user/repo/rights/list_repo_path/line.html changed (mode: 100644) (index df4a5b5..6637dde)
7 7 <td>@@nice.ip@@</td> <td>@@nice.ip@@</td>
8 8 <td>@@misc@@</td> <td>@@misc@@</td>
9 9 <td>@@rights_text@@</td> <td>@@rights_text@@</td>
10 <td>@@desc@@</td>
10 <td>@@description@@</td>
11 11 <td>@@if(@@can_be_deleted@@ == 1){{<a href="@@url_repo@@/admin/path_rights?edit_id=@@right_id@@">Edit</a>}}{{N/A}}</td> <td>@@if(@@can_be_deleted@@ == 1){{<a href="@@url_repo@@/admin/path_rights?edit_id=@@right_id@@">Edit</a>}}{{N/A}}</td>
12 12 </tr> </tr>
File root/themes/default/user/repo/rights/list_repo_refs/line.html changed (mode: 100644) (index e10cb9d..75c334d)
7 7 <td>@@nice.ip@@</td> <td>@@nice.ip@@</td>
8 8 <td>@@misc@@</td> <td>@@misc@@</td>
9 9 <td>@@rights_text@@</td> <td>@@rights_text@@</td>
10 <td>@@desc@@</td>
10 <td>@@description@@</td>
11 11 <td>@@if(@@can_be_deleted@@ == 1){{<a href="@@url_repo@@/admin/refs_rights?edit_id=@@right_id@@">Edit</a>}}{{N/A}}</td> <td>@@if(@@can_be_deleted@@ == 1){{<a href="@@url_repo@@/admin/refs_rights?edit_id=@@right_id@@">Edit</a>}}{{N/A}}</td>
12 12 </tr> </tr>
File samples/rg.conf changed (mode: 100644) (index 4bc4045..f0f4010)
30 30 RewriteRule (.*) /index.php?rwe=1&vv=$1 [L,QSA] RewriteRule (.*) /index.php?rwe=1&vv=$1 [L,QSA]
31 31
32 32
33 # Security
34 <IfModule mod_headers.c>
35 Header always append X-Frame-Options DENY
36 # Add this for SSL
37 #Header set Strict-Transport-Security "max-age=31536000"
38 </IfModule>
39
33 40 # Compress # Compress
34 41 AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript
35 42 DeflateBufferSize 81920 DeflateBufferSize 81920
File scripts/cache.php changed (mode: 100644) (index 137935e..3d7e63b)
... ... function rg_handle_command($k, &$conn_table, $cmd)
49 49
50 50 $a = explode(" ", $cmd, 2); $a = explode(" ", $cmd, 2);
51 51 $buf = "ER Invalid command\n"; $buf = "ER Invalid command\n";
52 do {
52 while (1) {
53 53 if (!isset($a[0])) if (!isset($a[0]))
54 54 break; break;
55 55
 
... ... function rg_handle_command($k, &$conn_table, $cmd)
68 68 break; break;
69 69 $ns_var = trim($ns_var_value[0]); $ns_var = trim($ns_var_value[0]);
70 70 $value = trim($ns_var_value[1]); $value = trim($ns_var_value[1]);
71 $value = unserialize($value);
71 $value = unserialize(stripcslashes($value));
72 72 if ($value !== FALSE) { if ($value !== FALSE) {
73 73 rg_cache_core_set("normal::" . $ns_var, $value); rg_cache_core_set("normal::" . $ns_var, $value);
74 74 $buf = "OK\n"; $buf = "OK\n";
 
... ... function rg_handle_command($k, &$conn_table, $cmd)
84 84 break; break;
85 85 $ns_var = trim($ns_var_value[0]); $ns_var = trim($ns_var_value[0]);
86 86 $value = trim($ns_var_value[1]); $value = trim($ns_var_value[1]);
87 $value = unserialize($value);
87 $value = unserialize(stripcslashes($value));
88 88 if ($value !== FALSE) { if ($value !== FALSE) {
89 89 rg_cache_core_merge("normal::" . $ns_var, $value); rg_cache_core_merge("normal::" . $ns_var, $value);
90 90 $buf = "OK\n"; $buf = "OK\n";
 
... ... function rg_handle_command($k, &$conn_table, $cmd)
105 105 if ($ret === FALSE) if ($ret === FALSE)
106 106 $buf = "NOT_FOUND\n"; $buf = "NOT_FOUND\n";
107 107 else else
108 $buf = "OK " . serialize($ret) . "\n";
108 $buf = "OK " . rg_cache_prepare($ret) . "\n";
109 109 break; break;
110 110 } }
111 111
 
... ... function rg_handle_command($k, &$conn_table, $cmd)
123 123 if ($ret === FALSE) if ($ret === FALSE)
124 124 $buf = "NOT_FOUND\n"; $buf = "NOT_FOUND\n";
125 125 else else
126 $buf = "OK " . $ret . "\n";
126 $buf = "OK " . rg_cache_prepare($ret) . "\n";
127 127 break; break;
128 128 } }
129 129
 
... ... function rg_handle_command($k, &$conn_table, $cmd)
155 155 $buf = "OK " . $ret . "\n"; $buf = "OK " . $ret . "\n";
156 156 break; break;
157 157 } }
158 } while (0);
158
159 break;
160 }
159 161
160 162 $s['send'] .= $buf; $s['send'] .= $buf;
161 163 $conn_table['w'][$k] = $s['socket']; $conn_table['w'][$k] = $s['socket'];
File scripts/cron.php changed (mode: 100644) (index c927072..8fc6848)
... ... if ($r !== TRUE)
41 41 exit(1); exit(1);
42 42
43 43 if ((gmdate("H") == 0) && (gmdate("i") == 3)) { if ((gmdate("H") == 0) && (gmdate("i") == 3)) {
44 do {
44 while (1) {
45 45 rg_log("Compute repository sizes if dirty..."); rg_log("Compute repository sizes if dirty...");
46 46 // delete 'dirty' files // delete 'dirty' files
47 47 $sql = "SELECT uid, repo_id, master FROM repos"; $sql = "SELECT uid, repo_id, master FROM repos";
 
... ... if ((gmdate("H") == 0) && (gmdate("i") == 3)) {
74 74 } }
75 75 } }
76 76 rg_sql_free_result($res); rg_sql_free_result($res);
77 } while (0);
77 break;
78 }
78 79
79 do {
80 while (1) {
80 81 rg_log("Compute repository sizes per user..."); rg_log("Compute repository sizes per user...");
81 82 $sql = "SELECT SUM(disk_used_mb) AS disk_used_mb, uid" $sql = "SELECT SUM(disk_used_mb) AS disk_used_mb, uid"
82 83 . " FROM repos" . " FROM repos"
 
... ... if ((gmdate("H") == 0) && (gmdate("i") == 3)) {
95 96 rg_sql_free_result($res2); rg_sql_free_result($res2);
96 97 } }
97 98 rg_sql_free_result($res); rg_sql_free_result($res);
98 } while (0);
99 break;
100 }
99 101 } }
100 102
101 103 if (gmdate("H") == 3) { if (gmdate("H") == 3) {
File scripts/events.php changed (mode: 100644) (index bcd0706..7cb03ac)
... ... do {
106 106 // check machine load - if too big we will delay // check machine load - if too big we will delay
107 107 $load = rg_load(); $load = rg_load();
108 108 if ($load > 10) { if ($load > 10) {
109 rg_log("\tLoad too big! Skip queue processing.");
109 rg_log("\tLoad too big! Skip queue processing.");
110 110 break; break;
111 111 } }
112 112
File scripts/q.php changed (mode: 100644) (index dfcdbd8..3f875d7)
... ... while (TRUE) {
61 61 // check machine load - if too big we will delay // check machine load - if too big we will delay
62 62 $load = rg_load(); $load = rg_load();
63 63 if ($load > 10) { if ($load > 10) {
64 rg_log("\tLoad too big!");
64 rg_log("\tLoad too big!");
65 65 sleep(10); sleep(10);
66 66 continue; continue;
67 67 } }
File selinux/rocketgit.te changed (mode: 100644) (index 0079a3a..11821b7)
... ... policy_module(rocketgit,1.0.73)
6 6 # #
7 7
8 8 gen_require(` gen_require(`
9 # really needed httpd_log_t?
10 type httpd_t;
11 type httpd_log_t;
12 type system_mail_t;
13 type unconfined_t;
9 # really needed httpd_log_t?
10 type httpd_t;
11 type httpd_log_t;
12 type system_mail_t;
13 type unconfined_t;
14 14 ') ')
15 15
16 16 type rocketgit_t; type rocketgit_t;
File tests/prof.php changed (mode: 100644) (index 7faae86..dc658a6)
... ... if (!isset($t['label1'])) {
24 24 exit(1); exit(1);
25 25 } }
26 26
27 rg_prof_start("label2");
28 sleep(1);
29 rg_prof_start("label2");
30 sleep(1);
31 rg_prof_end("label2");
32 rg_prof_end("label2");
33 $t = rg_prof_get();
34 if (($t['label2']['time_ms'] < 1800) || ($t['label2']['time_ms'] > 2200)) {
35 print_r($t);
36 echo "Nested profiling is not working (time_ms)\n";
37 exit(1);
38 }
39 if ($t['label2']['runs'] != 2) {
40 print_r($t);
41 echo "Nested profiling is not working (runs)\n";
42 exit(1);
43 }
44
27 45 echo "prof: OK!\n"; echo "prof: OK!\n";
28 46 ?> ?>
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