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 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/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/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/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/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/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 |
} |
} |