File TODO changed (mode: 100644) (index c735d80..f1ed3fb) |
1 |
1 |
== BEFORE FIRST RELEASE! == |
== BEFORE FIRST RELEASE! == |
|
2 |
|
[ ] array2string but transform \n into \\n (same for \r). Only rg_log may use \n. |
|
3 |
|
[ ] Fix PostgreSQL auth because httpd is in private tmp so we need TCP! |
|
4 |
|
[ ] Cannot lock the schema upgrade because both web and cron try to own the lock! |
|
5 |
|
Let only cron/q/remote to do it, in web just wait (or give error) |
|
6 |
|
(or auto retry). |
2 |
7 |
[ ] Make available the merge requests. |
[ ] Make available the merge requests. |
3 |
8 |
[ ] Add possibility to reject merge requests, to apply, to delete etc. |
[ ] Add possibility to reject merge requests, to apply, to delete etc. |
4 |
9 |
[ ] JUNK1/JUNK2: http://rg.embedromix.ro:8000/user/catab/rocketgit/commit/afd1df2..f919c9b |
[ ] JUNK1/JUNK2: http://rg.embedromix.ro:8000/user/catab/rocketgit/commit/afd1df2..f919c9b |
|
8 |
13 |
[ ] "log" does not list last entries! More exactly, seems the owner does not update repo! |
[ ] "log" does not list last entries! More exactly, seems the owner does not update repo! |
9 |
14 |
[ ] @@branch@@ is not defined for merge requests. Should it? Probably yes, to filter them. |
[ ] @@branch@@ is not defined for merge requests. Should it? Probably yes, to filter them. |
10 |
15 |
[ ] Create a repo and click on it; seems we get error (gabi)! |
[ ] Create a repo and click on it; seems we get error (gabi)! |
11 |
|
[ ] Enforce Signoff-by lines per project (a new permission) |
|
12 |
|
= reject commits without signoff! |
|
13 |
|
Maybe, do it generic, allow a text field to enumerate what should be in a commit! |
|
14 |
|
Also, present a list with checkboxex: at least Signoff-by, Reported-by, Acked-by! |
|
15 |
|
[ ] |
|
16 |
16 |
[ ] Check if we have a way to disable merge requests per project. |
[ ] Check if we have a way to disable merge requests per project. |
17 |
17 |
[ ] Add real name to user info. |
[ ] Add real name to user info. |
18 |
18 |
[ ] Add permission to add bug tracker to a project. |
[ ] Add permission to add bug tracker to a project. |
|
19 |
|
[ ] Remove all @@DUMP@@s from templates. |
|
20 |
|
[ ] Seems we are double html escape the body of a bug. |
|
21 |
|
[ ] We are escaping when we insert in database _and_ when we output on screen! |
|
22 |
|
What should we do? |
|
23 |
|
[ ] Bug number is not race free allocated! |
|
24 |
|
[ ] |
|
25 |
|
|
19 |
26 |
|
|
20 |
27 |
== Medium == |
== Medium == |
|
28 |
|
[ ] If we do ssh without any command, be nice and show how to clone, |
|
29 |
|
show projects, rights etc. CHeck ssh.inc.php. |
|
30 |
|
[ ] Enforce Signoff-by lines per project (a new permission) |
|
31 |
|
= reject commits without signoff! |
|
32 |
|
Maybe, do it generic, allow a text field to enumerate what should be in a commit! |
|
33 |
|
Also, present a list with checkboxex: at least Signoff-by, Reported-by, Acked-by! |
21 |
34 |
[ ] Linus on why GitHub sucks: https://github.com/torvalds/linux/pull/17#issuecomment-5654674 |
[ ] Linus on why GitHub sucks: https://github.com/torvalds/linux/pull/17#issuecomment-5654674 |
22 |
35 |
[ ] Warn if commit messages are too long (no wrap). |
[ ] Warn if commit messages are too long (no wrap). |
23 |
36 |
[ ] Allow possibility to send an e-mail to mainteiner from web with a pull request |
[ ] Allow possibility to send an e-mail to mainteiner from web with a pull request |
24 |
37 |
[ ] Check https://github.com/torvalds/linux/pull/17#issuecomment-5654674 |
[ ] Check https://github.com/torvalds/linux/pull/17#issuecomment-5654674 |
25 |
38 |
[ ] Merge requests e-mail: explanation of why to pull, diffstat! Maybe also the patch if is small. |
[ ] Merge requests e-mail: explanation of why to pull, diffstat! Maybe also the patch if is small. |
26 |
39 |
[ ] Check git-request-pull |
[ ] Check git-request-pull |
|
40 |
|
[ ] Show the size of a repository. Also when you ssh from terminal. |
|
41 |
|
See git-count-objects and http://stackoverflow.com/questions/8185276/find-size-of-git-repo. |
|
42 |
|
[ ] Logo for project. |
|
43 |
|
[ ] Default branch per project[/user]. |
|
44 |
|
[ ] Main language of the project. |
|
45 |
|
[ ] Web site for a project. |
|
46 |
|
[ ] |
27 |
47 |
|
|
28 |
48 |
== Normal priority == |
== Normal priority == |
|
49 |
|
[ ] Add hint about "ssh rocketgit@server" to quickly find status etc. |
|
50 |
|
[ ] rg_redirect does not record profiling information! |
|
51 |
|
[ ] git bundle |
29 |
52 |
[ ] How to sign merge requests?! |
[ ] How to sign merge requests?! |
30 |
53 |
[ ] Signal, with red, if a key was uploaded in the last X days. |
[ ] Signal, with red, if a key was uploaded in the last X days. |
31 |
54 |
[ ] Store in a cookie the last uid used, and if > 0, lookup e-mail and prefill |
[ ] Store in a cookie the last uid used, and if > 0, lookup e-mail and prefill |
File inc/bug.inc.php changed (mode: 100644) (index 1fb7fe9..1eb5d7b) |
... |
... |
function rg_bug_error() |
20 |
20 |
return $rg_bug_error; |
return $rg_bug_error; |
21 |
21 |
} |
} |
22 |
22 |
|
|
|
23 |
|
/* |
|
24 |
|
* This is valled from rg_repo_add |
|
25 |
|
*/ |
|
26 |
|
function rg_bug_add_max($db, $repo_id) |
|
27 |
|
{ |
|
28 |
|
rg_prof_start("bug_add_max"); |
|
29 |
|
|
|
30 |
|
$sql = "INSERT INTO bugs_max (repo_id, last_bug_id)" |
|
31 |
|
. " VALUES ($repo_id, 0)"; |
|
32 |
|
$res = rg_sql_query($db, $sql); |
|
33 |
|
if ($res === FALSE) { |
|
34 |
|
rg_bug_set_error("cannot init bug max (" . rg_sql_error() . ")"); |
|
35 |
|
return FALSE; |
|
36 |
|
} |
|
37 |
|
rg_sql_free_result($res); |
|
38 |
|
|
|
39 |
|
rg_prof_end("bug_add_max"); |
|
40 |
|
|
|
41 |
|
return TRUE; |
|
42 |
|
} |
|
43 |
|
|
23 |
44 |
/* |
/* |
24 |
45 |
* We want the bug number to be consecutive per project. |
* We want the bug number to be consecutive per project. |
25 |
|
* TODO: Big race here, two people can insert the get the same id! |
|
|
46 |
|
* This is why we use a separate table (bugs_max) to track last id. |
|
47 |
|
* This function must be inside a transaction. |
26 |
48 |
*/ |
*/ |
27 |
49 |
function rg_bug_next_id($db, $repo_id) |
function rg_bug_next_id($db, $repo_id) |
28 |
50 |
{ |
{ |
29 |
51 |
rg_prof_start("bug_next_id"); |
rg_prof_start("bug_next_id"); |
30 |
52 |
|
|
31 |
|
$sql = "SELECT MAX(bug_id) + 1 AS max FROM bugs" |
|
32 |
|
. " WHERE repo_id = $repo_id"; |
|
|
53 |
|
$sql = "UPDATE bugs_max SET last_bug_id = last_bug_id + 1" |
|
54 |
|
. " WHERE repo_id = $repo_id" |
|
55 |
|
. " RETURNING last_bug_id AS next_bug_id"; |
33 |
56 |
$res = rg_sql_query($db, $sql); |
$res = rg_sql_query($db, $sql); |
34 |
57 |
if ($res === FALSE) { |
if ($res === FALSE) { |
35 |
|
rg_bug_set_error("cannot get max (" . rg_sql_error() . ")"); |
|
36 |
|
return $ret; |
|
|
58 |
|
rg_bug_set_error("cannot get/update max (" . rg_sql_error() . ")"); |
|
59 |
|
return FALSE; |
37 |
60 |
} |
} |
38 |
61 |
$row = rg_sql_fetch_array($res); |
$row = rg_sql_fetch_array($res); |
39 |
|
rg_log("DEBUG: max=" . $row['max']); |
|
|
62 |
|
$next_bug_id = $row['next_bug_id']; |
|
63 |
|
rg_log("\tDEBUG: next_bug_id=" . $next_bug_id); |
40 |
64 |
rg_sql_free_result($res); |
rg_sql_free_result($res); |
41 |
65 |
|
|
42 |
66 |
rg_prof_end("bug_next_id"); |
rg_prof_end("bug_next_id"); |
43 |
67 |
|
|
44 |
|
return empty($row['max']) ? 1 : $row['max']; |
|
|
68 |
|
return $next_bug_id; |
|
69 |
|
} |
|
70 |
|
|
|
71 |
|
/* |
|
72 |
|
* Helper function to populate some fields for a bug |
|
73 |
|
*/ |
|
74 |
|
function rg_bug_cosmetic($db, &$row) |
|
75 |
|
{ |
|
76 |
|
$_ui = rg_user_info($db, $row['uid'], "", ""); |
|
77 |
|
if ($_ui['exists'] != 1) |
|
78 |
|
$row['owner'] = "?"; |
|
79 |
|
else |
|
80 |
|
$row['owner'] = $_ui['username']; |
|
81 |
|
|
|
82 |
|
$row['HTML:body'] = nl2br($row['body']); |
|
83 |
|
unset($row['body']); |
|
84 |
|
$row['creation'] = gmdate("Y-m-d H:i", $row['itime']); |
|
85 |
|
|
|
86 |
|
if ($row['utime'] > 0) |
|
87 |
|
$row['updated'] = gmdate("Y-m-d H:i", $row['utime']); |
|
88 |
|
else |
|
89 |
|
$row['updated'] = "-"; |
|
90 |
|
|
|
91 |
|
$row['assigned_to'] = "-"; |
|
92 |
|
if ($row['assigned_uid'] > 0) { |
|
93 |
|
$_ui = rg_user_info($db, $row['assigned_uid'], "", ""); |
|
94 |
|
if ($_ui['exists'] == 1) |
|
95 |
|
$row['assigned_to'] = $_ui['username']; |
|
96 |
|
} |
45 |
97 |
} |
} |
46 |
98 |
|
|
47 |
99 |
/* |
/* |
|
... |
... |
function rg_bug_info($db, $repo_id, $bug_id) |
84 |
136 |
$row['exists'] = 1; |
$row['exists'] = 1; |
85 |
137 |
$row['ok'] = 1; |
$row['ok'] = 1; |
86 |
138 |
|
|
|
139 |
|
rg_bug_cosmetic($db, $row); |
|
140 |
|
|
87 |
141 |
$rg_bug_info_cache[$key] = $row; |
$rg_bug_info_cache[$key] = $row; |
88 |
142 |
|
|
89 |
143 |
rg_prof_end("bug_info"); |
rg_prof_end("bug_info"); |
|
... |
... |
function rg_bug_add($db, $repo_id, $uid, $data) |
111 |
165 |
$itime = time(); |
$itime = time(); |
112 |
166 |
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ""; |
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ""; |
113 |
167 |
|
|
114 |
|
$bug_id = rg_bug_next_id($db, $repo_id); |
|
115 |
|
if ($bug_id == 0) |
|
116 |
|
return FALSE; |
|
|
168 |
|
$ret = FALSE; |
|
169 |
|
$rollback = 0; |
|
170 |
|
do { |
|
171 |
|
if (rg_sql_begin($db) !== TRUE) |
|
172 |
|
break; |
|
173 |
|
|
|
174 |
|
$rollback = 1; |
|
175 |
|
|
|
176 |
|
$bug_id = rg_bug_next_id($db, $repo_id); |
|
177 |
|
if ($bug_id === FALSE) |
|
178 |
|
break; |
|
179 |
|
|
|
180 |
|
$err = rg_bug_label_insert($db, $repo_id, $bug_id, $data['labels']); |
|
181 |
|
if ($err !== TRUE) |
|
182 |
|
break; |
|
183 |
|
|
|
184 |
|
$sql = "INSERT INTO bugs force_fail_to_test_consecutive_bug_id (bug_id, itime, utime, repo_id, uid, ip" |
|
185 |
|
. ", title, body, assigned_uid, deleted)" |
|
186 |
|
. " VALUES ($bug_id, $itime, 0, $repo_id, $uid, '$ip'" |
|
187 |
|
. ", '" . $e_data['title'] . "'" |
|
188 |
|
. ", '" . $e_data['body'] . "'" |
|
189 |
|
. ", " . $e_data['assigned_uid'] |
|
190 |
|
. ", 0)"; |
|
191 |
|
$res = rg_sql_query($db, $sql); |
|
192 |
|
if ($res === FALSE) { |
|
193 |
|
rg_bug_set_error("Cannot insert bug (" . rg_sql_error() . ")"); |
|
194 |
|
break; |
|
195 |
|
} |
|
196 |
|
rg_sql_free_result($res); |
117 |
197 |
|
|
118 |
|
$sql = "INSERT INTO bugs (bug_id, itime, utime, repo_id, uid, ip" |
|
119 |
|
. ", title, body, labels, state, assigned_uid, deleted)" |
|
120 |
|
. " VALUES ($bug_id, $itime, 0, $repo_id, $uid, '$ip'" |
|
121 |
|
. ", '" . $e_data['title'] . "'" |
|
122 |
|
. ", '" . $e_data['body'] . "'" |
|
123 |
|
. ", '" . $e_data['labels'] . "'" |
|
124 |
|
. ", " . $e_data['state'] |
|
125 |
|
. ", " . $e_data['assigned_uid'] |
|
126 |
|
. ", 0)"; |
|
127 |
|
$res = rg_sql_query($db, $sql); |
|
128 |
|
if ($res === FALSE) { |
|
129 |
|
rg_bug_set_error("Cannot insert bug (" . rg_sql_error() . ")"); |
|
130 |
|
return FALSE; |
|
131 |
|
} |
|
132 |
|
rg_sql_free_result($res); |
|
|
198 |
|
if (rg_sql_commit($db) === FALSE) { |
|
199 |
|
rg_bug_set_error("Cannot commit (" . rg_sql_error() . ")"); |
|
200 |
|
break; |
|
201 |
|
} |
|
202 |
|
|
|
203 |
|
$ret = $bug_id; |
|
204 |
|
$rollback = 0; |
|
205 |
|
} while (0); |
|
206 |
|
|
|
207 |
|
if ($rollback == 1) |
|
208 |
|
rg_sql_rollback($db); |
133 |
209 |
|
|
134 |
210 |
rg_prof_end("bug_add"); |
rg_prof_end("bug_add"); |
135 |
211 |
|
|
136 |
|
return $bug_id; |
|
|
212 |
|
return $ret; |
137 |
213 |
} |
} |
138 |
214 |
|
|
139 |
215 |
/* |
/* |
|
... |
... |
function rg_bug_update($db, $repo_id, $bug_id, $data) |
184 |
260 |
$e_data = $data; |
$e_data = $data; |
185 |
261 |
$e_data['title'] = rg_sql_escape($db, $data['title']); |
$e_data['title'] = rg_sql_escape($db, $data['title']); |
186 |
262 |
$e_data['body'] = rg_sql_escape($db, $data['body']); |
$e_data['body'] = rg_sql_escape($db, $data['body']); |
187 |
|
$e_data['labels'] = rg_sql_escape($db, $data['labels']); |
|
188 |
263 |
|
|
189 |
264 |
$utime = time(); |
$utime = time(); |
190 |
265 |
|
|
|
... |
... |
function rg_bug_list_query($db, $url, $sql) |
225 |
300 |
|
|
226 |
301 |
$d = array(); |
$d = array(); |
227 |
302 |
while (($row = rg_sql_fetch_array($res))) { |
while (($row = rg_sql_fetch_array($res))) { |
228 |
|
$_line = array(); |
|
229 |
|
|
|
230 |
|
foreach ($row as $k => $v) |
|
231 |
|
$_line[$k] = $v; |
|
232 |
|
|
|
233 |
|
$_ui = rg_user_info($db, $row['uid'], "", ""); |
|
234 |
|
if ($_ui['exists'] != 1) |
|
235 |
|
$_line['owner'] = "?"; |
|
236 |
|
else |
|
237 |
|
$_line['owner'] = $_ui['username']; |
|
238 |
|
|
|
239 |
|
$_line['body'] = nl2br(htmlspecialchars($row['body'])); |
|
240 |
|
$_line['creation'] = gmdate("Y-m-d", $row['itime']); |
|
241 |
|
$_line['updated'] = gmdate("Y-m-d", $row['utime']); |
|
242 |
|
|
|
243 |
|
if ($row['assigned_uid'] == 0) { |
|
244 |
|
$_line['assigned_to'] = "-"; |
|
245 |
|
} else { |
|
246 |
|
$_ui = rg_user_info($db, $row['assigned_uid'], "", ""); |
|
247 |
|
if ($_ui['exists'] != 1) { |
|
248 |
|
$_line['assigned_to'] = "?"; |
|
249 |
|
} else { |
|
250 |
|
$_line['assigned_to'] = $_ui['username']; |
|
251 |
|
} |
|
252 |
|
} |
|
253 |
|
|
|
254 |
|
$d[] = $_line; |
|
|
303 |
|
rg_bug_cosmetic($db, $row); |
|
304 |
|
$row['url_bug'] = $url . "/bug/" . $row['bug_id']; |
|
305 |
|
$d[] = $row; |
255 |
306 |
} |
} |
256 |
307 |
rg_sql_free_result($res); |
rg_sql_free_result($res); |
257 |
308 |
|
|
258 |
309 |
rg_prof_end("bug_list_query"); |
rg_prof_end("bug_list_query"); |
259 |
310 |
|
|
260 |
|
return rg_template_table("bug/list", $d, array()); |
|
|
311 |
|
return rg_template_table("repo/bug/list", $d, array()); |
261 |
312 |
} |
} |
262 |
313 |
|
|
263 |
314 |
/* |
/* |
|
... |
... |
function rg_bug_list($db, $url, $repo_id) |
269 |
320 |
|
|
270 |
321 |
$sql = "SELECT * FROM bugs" |
$sql = "SELECT * FROM bugs" |
271 |
322 |
. " WHERE repo_id = $repo_id" |
. " WHERE repo_id = $repo_id" |
|
323 |
|
. " AND deleted = 0" |
272 |
324 |
. " ORDER BY itime"; |
. " ORDER BY itime"; |
273 |
325 |
|
|
274 |
326 |
return rg_bug_list_query($db, $url, $sql); |
return rg_bug_list_query($db, $url, $sql); |
|
... |
... |
function rg_bug_search($db, $q) |
286 |
338 |
$sql = "SELECT * FROM bugs" |
$sql = "SELECT * FROM bugs" |
287 |
339 |
. " WHERE deleted = 0" |
. " WHERE deleted = 0" |
288 |
340 |
. " AND (title ILIKE '%$e_q%' OR body ILIKE '%$e_q%')" |
. " AND (title ILIKE '%$e_q%' OR body ILIKE '%$e_q%')" |
|
341 |
|
. " AND deleted = 0" |
289 |
342 |
. " ORDER BY itime" |
. " ORDER BY itime" |
290 |
343 |
. " LIMIT 10"; |
. " LIMIT 10"; |
291 |
344 |
|
|
|
... |
... |
function rg_bug_note_add($db, $repo_id, $bug_id, $uid, $data) |
326 |
379 |
return TRUE; |
return TRUE; |
327 |
380 |
} |
} |
328 |
381 |
|
|
|
382 |
|
/* |
|
383 |
|
* List notes for a bug |
|
384 |
|
*/ |
|
385 |
|
function rg_bug_note_list($db, $repo_id, $bug_id, $offset) |
|
386 |
|
{ |
|
387 |
|
rg_prof_start("bug_note_list"); |
|
388 |
|
|
|
389 |
|
rg_log("bug_note_list: repo_id=$repo_id bug_id=$bug_id"); |
|
390 |
|
|
|
391 |
|
// TODO: test if user is allowed to see a note |
|
392 |
|
|
|
393 |
|
$sql = "SELECT * FROM bug_notes" |
|
394 |
|
. " WHERE repo_id = $repo_id" |
|
395 |
|
. " AND bug_id = $bug_id" |
|
396 |
|
. " ORDER BY itime" |
|
397 |
|
. " LIMIT 20 OFFSET $offset"; |
|
398 |
|
$res = rg_sql_query($db, $sql); |
|
399 |
|
if ($res === FALSE) { |
|
400 |
|
rg_bug_set_error("Cannot select bug notes (" . rg_sql_error() . ")"); |
|
401 |
|
return FALSE; |
|
402 |
|
} |
|
403 |
|
|
|
404 |
|
$data = array(); |
|
405 |
|
while (($row = rg_sql_fetch_array($res))) { |
|
406 |
|
$row['creation'] = gmdate("Y-m-d H:i", $row['itime']); |
|
407 |
|
|
|
408 |
|
$_ui = rg_user_info($db, $row['uid'], "", ""); |
|
409 |
|
if ($_ui['exists'] == 1) |
|
410 |
|
$row['owner'] = $_ui['username']; |
|
411 |
|
else |
|
412 |
|
$row['owner'] = "?"; |
|
413 |
|
|
|
414 |
|
$row['HTML:note'] = nl2br($row['note']); |
|
415 |
|
unset($row['note']); |
|
416 |
|
|
|
417 |
|
$data[] = $row; |
|
418 |
|
} |
|
419 |
|
rg_sql_free_result($res); |
|
420 |
|
|
|
421 |
|
rg_prof_end("bug_note_list"); |
|
422 |
|
|
|
423 |
|
return $data; |
|
424 |
|
} |
|
425 |
|
|
|
426 |
|
/* LABELS */ |
|
427 |
|
|
|
428 |
|
/* |
|
429 |
|
* Build an array from a string of labels |
|
430 |
|
*/ |
|
431 |
|
function rg_bug_label_string2array($s) |
|
432 |
|
{ |
|
433 |
|
$ret = array(); |
|
434 |
|
|
|
435 |
|
$s = preg_replace('/\w/', ',', $s); |
|
436 |
|
$list = explode(",", $s); |
|
437 |
|
if (empty($list)) |
|
438 |
|
return array(); |
|
439 |
|
|
|
440 |
|
foreach ($list as $label) |
|
441 |
|
$ret[] = trim($label); |
|
442 |
|
|
|
443 |
|
return $ret; |
|
444 |
|
} |
|
445 |
|
|
|
446 |
|
/* |
|
447 |
|
* Builds a string of labels, from an array |
|
448 |
|
*/ |
|
449 |
|
function rg_bug_label_array2string($a) |
|
450 |
|
{ |
|
451 |
|
return implode(",", $a); |
|
452 |
|
} |
|
453 |
|
|
|
454 |
|
/* |
|
455 |
|
* Returns labels that are in the first set but not in the second |
|
456 |
|
*/ |
|
457 |
|
function rg_bug_label_diff($a, $b) |
|
458 |
|
{ |
|
459 |
|
$ret = array(); |
|
460 |
|
|
|
461 |
|
if (empty($a)) |
|
462 |
|
return array(); |
|
463 |
|
|
|
464 |
|
foreach ($a as $label) |
|
465 |
|
if (!isset($b[$label])) |
|
466 |
|
$ret[] = $label; |
|
467 |
|
|
|
468 |
|
return $ret; |
|
469 |
|
} |
|
470 |
|
|
|
471 |
|
/* |
|
472 |
|
* Get all labels for a project |
|
473 |
|
*/ |
|
474 |
|
function rg_bug_label_get($db, $repo_id, $bug_id) |
|
475 |
|
{ |
|
476 |
|
$ret = array(); |
|
477 |
|
|
|
478 |
|
$sql = "SELECT DISTINCT label FROM bug_labels" |
|
479 |
|
. " WHERE repo_id = $repo_id" |
|
480 |
|
. " AND bug_id = $bug_id"; |
|
481 |
|
$res = rg_sql_query($db, $sql); |
|
482 |
|
if ($res === FALSE) { |
|
483 |
|
rg_bug_set_error("Cannot select labels (" . rg_sql_error() . ")"); |
|
484 |
|
return FALSE; |
|
485 |
|
} |
|
486 |
|
while (($row = rg_sql_fetch_array($res))) |
|
487 |
|
$ret[] = $row['label']; |
|
488 |
|
rg_sql_free_result($res); |
|
489 |
|
|
|
490 |
|
return $ret; |
|
491 |
|
} |
|
492 |
|
|
|
493 |
|
/* |
|
494 |
|
* Inserts labels |
|
495 |
|
*/ |
|
496 |
|
function rg_bug_label_insert($db, $repo_id, $bug_id, $labels) |
|
497 |
|
{ |
|
498 |
|
rg_prof_start("bug_label_insert"); |
|
499 |
|
|
|
500 |
|
$labels = rg_bug_label_string2array($labels); |
|
501 |
|
if (empty($labels)) |
|
502 |
|
return TRUE; |
|
503 |
|
|
|
504 |
|
$existing = rg_bug_label_get($db, $repo_id, $bug_id); |
|
505 |
|
if ($existing === FALSE) |
|
506 |
|
return FALSE; |
|
507 |
|
|
|
508 |
|
$diff = rg_bug_label_diff($labels, $existing); |
|
509 |
|
if (empty($diff)) |
|
510 |
|
return TRUE; |
|
511 |
|
|
|
512 |
|
$ret = TRUE; |
|
513 |
|
foreach ($diff as $label) { |
|
514 |
|
$e_label = rg_sql_escape($db, $label); |
|
515 |
|
$sql = "INSERT INTO bug_labels (repo_id, bug_id, label)" |
|
516 |
|
. " VALUES ($repo_id, $bug_id, '$e_label')"; |
|
517 |
|
$res = rg_sql_query($db, $sql); |
|
518 |
|
if ($res === FALSE) { |
|
519 |
|
rg_bug_set_error("Cannot insert label (" . rg_sql_error() . ")"); |
|
520 |
|
$ret = FALSE; |
|
521 |
|
break; |
|
522 |
|
} |
|
523 |
|
rg_sql_free_result($res); |
|
524 |
|
} |
|
525 |
|
|
|
526 |
|
rg_prof_end("bug_label_insert"); |
|
527 |
|
|
|
528 |
|
return $ret; |
|
529 |
|
} |
|
530 |
|
|
329 |
531 |
?> |
?> |
File inc/git.inc.php changed (mode: 100644) (index 02bcad4..bc4d1b2) |
... |
... |
function rg_git_whitespace_ok($old, $new) |
267 |
267 |
. " " . escapeshellarg($old) |
. " " . escapeshellarg($old) |
268 |
268 |
. " " . escapeshellarg($new); |
. " " . escapeshellarg($new); |
269 |
269 |
$a = rg_exec($cmd); |
$a = rg_exec($cmd); |
270 |
|
rg_log("\ta:" . print_r($a, TRUE)); |
|
|
270 |
|
rg_log("\ta:" . rg_array2string($a)); |
271 |
271 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
272 |
272 |
rg_git_set_error("error on diff (" . $a['errmsg'] . ")"); |
rg_git_set_error("error on diff (" . $a['errmsg'] . ")"); |
273 |
273 |
$ret = $a['data']; |
$ret = $a['data']; |
|
... |
... |
function rg_git_ls_tree($tree, $path) |
387 |
387 |
|
|
388 |
388 |
rg_prof_end("git_ls_tree"); |
rg_prof_end("git_ls_tree"); |
389 |
389 |
|
|
|
390 |
|
// We are forced to use print_r instead of array2string because |
|
391 |
|
// it may be a multilevel array. |
390 |
392 |
rg_log("DEBUG: ls-tree: " . print_r($ret, TRUE)); |
rg_log("DEBUG: ls-tree: " . print_r($ret, TRUE)); |
391 |
393 |
|
|
392 |
394 |
return $ret; |
return $ret; |
|
... |
... |
function rg_git_stats($log) |
683 |
685 |
* Nice diff per file |
* Nice diff per file |
684 |
686 |
* Outputs the result of replacing variables in a template with real variables |
* Outputs the result of replacing variables in a template with real variables |
685 |
687 |
* @a - output of rg_git_diff2array[index] |
* @a - output of rg_git_diff2array[index] |
686 |
|
* TODO: Switch to r66_template_table? |
|
|
688 |
|
* TODO: Switch to rg_template_table? |
687 |
689 |
*/ |
*/ |
688 |
690 |
function rg_git_diff($a, $template_file) |
function rg_git_diff($a, $template_file) |
689 |
691 |
{ |
{ |
690 |
|
rg_log("git_diff: a: " . print_r($a, TRUE)); |
|
|
692 |
|
rg_log("git_diff: a: " . rg_array2string($a)); |
691 |
693 |
|
|
692 |
694 |
$ret = "<div class=\"diff\">\n"; |
$ret = "<div class=\"diff\">\n"; |
693 |
695 |
|
|
|
... |
... |
function rg_git_diff($a, $template_file) |
696 |
698 |
// for each file changed |
// for each file changed |
697 |
699 |
foreach ($a as $fileindex => $finfo) { |
foreach ($a as $fileindex => $finfo) { |
698 |
700 |
if (!isset($finfo['file'])) |
if (!isset($finfo['file'])) |
699 |
|
rg_log("BAD finfo:" . print_r($finfo, TRUE)); |
|
|
701 |
|
rg_log("BAD finfo:" . rg_array2string($finfo)); |
700 |
702 |
|
|
701 |
703 |
$ret .= "<br />\n"; |
$ret .= "<br />\n"; |
702 |
704 |
|
|
|
... |
... |
function rg_git_branches_and_tags($repo_dir, $base_url, $current_ref) |
1005 |
1007 |
$ret['HTML:branches_and_tags'] .= implode("\n", $_l); |
$ret['HTML:branches_and_tags'] .= implode("\n", $_l); |
1006 |
1008 |
$ret['HTML:branches_and_tags'] .= "</div>\n"; |
$ret['HTML:branches_and_tags'] .= "</div>\n"; |
1007 |
1009 |
|
|
1008 |
|
rg_log("rg_git_branches_and_tags: ret:" . print_r($ret, TRUE)); |
|
|
1010 |
|
rg_log("rg_git_branches_and_tags: ret:" . rg_array2string($ret)); |
1009 |
1011 |
|
|
1010 |
1012 |
return $ret; |
return $ret; |
1011 |
1013 |
} |
} |
|
... |
... |
function rg_git_diff_tree($tree1, $tree2) |
1084 |
1086 |
|
|
1085 |
1087 |
rg_prof_end("git_diff_tree"); |
rg_prof_end("git_diff_tree"); |
1086 |
1088 |
|
|
1087 |
|
rg_log("DEBUG: diff-tree: " . print_r($ret, TRUE)); |
|
|
1089 |
|
rg_log("DEBUG: diff-tree: " . rg_array2string($ret)); |
1088 |
1090 |
|
|
1089 |
1091 |
return $ret; |
return $ret; |
1090 |
1092 |
} |
} |
File inc/repo.inc.php changed (mode: 100644) (index 80bcd9e..f3f2fa0) |
... |
... |
require_once($INC . "/user.inc.php"); |
6 |
6 |
require_once($INC . "/git.inc.php"); |
require_once($INC . "/git.inc.php"); |
7 |
7 |
require_once($INC . "/rights.inc.php"); |
require_once($INC . "/rights.inc.php"); |
8 |
8 |
require_once($INC . "/prof.inc.php"); |
require_once($INC . "/prof.inc.php"); |
|
9 |
|
require_once($INC . "/bug.inc.php"); |
9 |
10 |
|
|
10 |
11 |
$rg_repo_error = ""; |
$rg_repo_error = ""; |
11 |
12 |
|
|
|
... |
... |
function rg_repo_create($db, $master, $rg_ui, $name, $max_commit_size, |
241 |
242 |
|
|
242 |
243 |
$itime = time(); |
$itime = time(); |
243 |
244 |
|
|
244 |
|
$sql = "INSERT INTO repos (uid, master, name, itime" |
|
245 |
|
. ", max_commit_size, description, git_dir_done, default_rights" |
|
246 |
|
. ", max_users)" |
|
247 |
|
. " VALUES (" . $rg_ui['uid'] . ", $master, '$e_name', $itime" |
|
248 |
|
. ", $max_commit_size, '$e_description', 0, '$rights', $max_users)"; |
|
249 |
|
$res = rg_sql_query($db, $sql); |
|
250 |
|
if ($res === FALSE) { |
|
251 |
|
rg_repo_set_error("Cannot insert (" . rg_sql_error() . ")"); |
|
252 |
|
return FALSE; |
|
253 |
|
} |
|
254 |
|
rg_sql_free_result($res); |
|
|
245 |
|
$ret = FALSE; |
|
246 |
|
$rollback = 0; |
|
247 |
|
do { |
|
248 |
|
if (rg_sql_begin($db) === FALSE) { |
|
249 |
|
rg_repo_set_error("cannot begin transaction to add a repo" |
|
250 |
|
. " (" . rg_sql_error() . ")"); |
|
251 |
|
break; |
|
252 |
|
} |
|
253 |
|
|
|
254 |
|
$rollback = 1; |
|
255 |
|
|
|
256 |
|
$sql = "INSERT INTO repos (uid, master, name, itime" |
|
257 |
|
. ", max_commit_size, description, git_dir_done, default_rights" |
|
258 |
|
. ", max_users)" |
|
259 |
|
. " VALUES (" . $rg_ui['uid'] . ", $master, '$e_name', $itime" |
|
260 |
|
. ", $max_commit_size, '$e_description', 0, '$rights', $max_users)" |
|
261 |
|
. " RETURNING repo_id"; |
|
262 |
|
$res = rg_sql_query($db, $sql); |
|
263 |
|
if ($res === FALSE) { |
|
264 |
|
rg_repo_set_error("Cannot insert (" . rg_sql_error() . ")"); |
|
265 |
|
break; |
|
266 |
|
} |
|
267 |
|
$row = rg_sql_fetch_array($res); |
|
268 |
|
$repo_id = $row['repo_id']; |
|
269 |
|
rg_sql_free_result($res); |
|
270 |
|
|
|
271 |
|
if (rg_bug_add_max($db, $repo_id)) { |
|
272 |
|
rg_repo_set_error(rg_bug_error()); |
|
273 |
|
break; |
|
274 |
|
} |
|
275 |
|
|
|
276 |
|
if (rg_sql_commit($db) === FALSE) { |
|
277 |
|
rg_repo_set_error("Cannot commit (" . rg_sql_error() . ")"); |
|
278 |
|
break; |
|
279 |
|
} |
|
280 |
|
|
|
281 |
|
$rollback = 0; |
|
282 |
|
$ret = TRUE; |
|
283 |
|
} while (0); |
|
284 |
|
|
|
285 |
|
if ($rollback == 1) |
|
286 |
|
rg_sql_rollback($db); |
255 |
287 |
|
|
256 |
288 |
// git repo creation will be delayed for serialization reasons |
// git repo creation will be delayed for serialization reasons |
257 |
|
// and for permission reasons (we are apache here) |
|
|
289 |
|
// and for permission reasons (we are 'apache' user here) |
258 |
290 |
|
|
259 |
291 |
rg_prof_end("repo_create"); |
rg_prof_end("repo_create"); |
260 |
292 |
|
|
261 |
|
return TRUE; |
|
|
293 |
|
return $ret; |
262 |
294 |
} |
} |
263 |
295 |
|
|
264 |
296 |
/* |
/* |
|
... |
... |
function rg_repo_list_query($db, $url, $sql) |
377 |
409 |
$_line['owner'] = $_ui['username']; |
$_line['owner'] = $_ui['username']; |
378 |
410 |
$_line['url_repo'] = rg_re_repopage($_ui, $row['name']); |
$_line['url_repo'] = rg_re_repopage($_ui, $row['name']); |
379 |
411 |
$_line['url_user'] = rg_re_userpage($_ui); |
$_line['url_user'] = rg_re_userpage($_ui); |
380 |
|
$_line['HTML:description'] = nl2br(htmlspecialchars($row['description'])); |
|
|
412 |
|
$_line['HTML:description'] = nl2br($row['description']); |
381 |
413 |
|
|
382 |
414 |
$master_repo = "-"; |
$master_repo = "-"; |
383 |
415 |
if ($row['master'] > 0) { |
if ($row['master'] > 0) { |
File inc/struct.inc.php changed (mode: 100644) (index 886ac19..7d64820) |
... |
... |
$rg_sql_struct[5]['tables'] = array( |
121 |
121 |
|
|
122 |
122 |
$rg_sql_struct[6] = array(); |
$rg_sql_struct[6] = array(); |
123 |
123 |
$rg_sql_struct[6]['tables'] = array( |
$rg_sql_struct[6]['tables'] = array( |
|
124 |
|
"bugs_max" => "CREATE TABLE bugs_max (" |
|
125 |
|
. "repo_id INT NOT NULL PRIMARY KEY" |
|
126 |
|
. ", last_bug_id INT NOT NULL" |
|
127 |
|
. ")", |
124 |
128 |
"bugs" => "CREATE TABLE bugs (" |
"bugs" => "CREATE TABLE bugs (" |
125 |
129 |
. "repo_id INT NOT NULL" |
. "repo_id INT NOT NULL" |
126 |
130 |
. ", bug_id INT NOT NULL" |
. ", bug_id INT NOT NULL" |
|
... |
... |
$rg_sql_struct[6]['tables'] = array( |
130 |
134 |
. ", ip TEXT NOT NULL" |
. ", ip TEXT NOT NULL" |
131 |
135 |
. ", title TEXT NOT NULL" |
. ", title TEXT NOT NULL" |
132 |
136 |
. ", body TEXT NOT NULL" |
. ", body TEXT NOT NULL" |
133 |
|
. ", labels TEXT NOT NULL" |
|
134 |
|
. ", state INT NOT NULL" |
|
135 |
137 |
. ", assigned_uid INT NOT NULL" |
. ", assigned_uid INT NOT NULL" |
136 |
138 |
. ", deleted INT NOT NULL" |
. ", deleted INT NOT NULL" |
137 |
139 |
. ")", |
. ")", |
|
... |
... |
$rg_sql_struct[6]['tables'] = array( |
142 |
144 |
. ", itime INT NOT NULL" |
. ", itime INT NOT NULL" |
143 |
145 |
. ", uid INT NOT NULL" |
. ", uid INT NOT NULL" |
144 |
146 |
. ", ip TEXT NOT NULL" |
. ", ip TEXT NOT NULL" |
|
147 |
|
. ")", |
|
148 |
|
"bug_labels" => "CREATE TABLE bug_labels (" |
|
149 |
|
. "repo_id INT NOT NULL" |
|
150 |
|
. ", bug_id INT NOT NULL" |
|
151 |
|
. ", label TEXT NOT NULL" |
145 |
152 |
. ")" |
. ")" |
146 |
153 |
); |
); |
147 |
154 |
$rg_sql_struct[6]['other'] = array( |
$rg_sql_struct[6]['other'] = array( |
|
... |
... |
$rg_sql_struct[6]['other'] = array( |
149 |
156 |
. " ON bugs (repo_id, bug_id)", |
. " ON bugs (repo_id, bug_id)", |
150 |
157 |
"bugs_index_itime" => "CREATE INDEX bugs_i_itime" |
"bugs_index_itime" => "CREATE INDEX bugs_i_itime" |
151 |
158 |
. " ON bugs (itime)", |
. " ON bugs (itime)", |
152 |
|
"bug_notes_index_repo_id_bug_id" => "CREATE UNIQUE INDEX bug_notes_i_repo_id_bug_id" |
|
153 |
|
. " ON bug_notes (repo_id, bug_id)" |
|
|
159 |
|
"bug_notes_index_repo_id_bug_id" => "CREATE INDEX bug_notes_i_repo_id_bug_id" |
|
160 |
|
. " ON bug_notes (repo_id, bug_id)", |
|
161 |
|
"bug_labels_index_repo_id_bug_id" => "CREATE INDEX bug_labels_i_repo_id_bug_id" |
|
162 |
|
. " ON bug_labels (repo_id, bug_id)" |
154 |
163 |
); |
); |
155 |
164 |
|
|
156 |
165 |
// This must be the last line |
// This must be the last line |
|
... |
... |
function rg_sql_struct_update_if_needed($db, $flags) |
235 |
244 |
if (rg_lock("schema_upgrade.lock") === FALSE) |
if (rg_lock("schema_upgrade.lock") === FALSE) |
236 |
245 |
return FALSE; |
return FALSE; |
237 |
246 |
|
|
238 |
|
if (rg_sql_begin($db) !== TRUE) |
|
239 |
|
return FALSE; |
|
|
247 |
|
$ret = FALSE; |
|
248 |
|
$rollback = 0; |
|
249 |
|
do { |
|
250 |
|
if (rg_sql_begin($db) !== TRUE) |
|
251 |
|
break; |
240 |
252 |
|
|
241 |
|
$r = rg_sql_struct_run($db, $flags, $old); |
|
242 |
|
if ($r !== TRUE) { |
|
243 |
|
rg_log("Cannot update schema (" . rg_sql_error() . ")"); |
|
244 |
|
return FALSE; |
|
245 |
|
} |
|
|
253 |
|
$rollback = 1; |
246 |
254 |
|
|
247 |
|
$r = rg_state_set($db, "schema_version", $rg_sql_schema_ver); |
|
248 |
|
if ($r !== TRUE) { |
|
249 |
|
rg_log("Cannot update schema ver (" . rg_state_error() . ")"); |
|
250 |
|
return FALSE; |
|
251 |
|
} |
|
|
255 |
|
$r = rg_sql_struct_run($db, $flags, $old); |
|
256 |
|
if ($r !== TRUE) { |
|
257 |
|
rg_log("Cannot update schema (" . rg_sql_error() . ")"); |
|
258 |
|
break; |
|
259 |
|
} |
252 |
260 |
|
|
253 |
|
if (rg_sql_commit($db) !== TRUE) |
|
254 |
|
return FALSE; |
|
|
261 |
|
$r = rg_state_set($db, "schema_version", $rg_sql_schema_ver); |
|
262 |
|
if ($r !== TRUE) { |
|
263 |
|
rg_log("Cannot update schema ver (" . rg_state_error() . ")"); |
|
264 |
|
break; |
|
265 |
|
} |
|
266 |
|
|
|
267 |
|
if (rg_sql_commit($db) !== TRUE) |
|
268 |
|
break; |
|
269 |
|
|
|
270 |
|
$rollback = 0; |
|
271 |
|
$ret = TRUE; |
|
272 |
|
} while (0); |
|
273 |
|
|
|
274 |
|
if ($rollback == 1) |
|
275 |
|
rg_sql_rollback($db); |
255 |
276 |
|
|
256 |
277 |
rg_unlock("schema_upgrade.lock"); |
rg_unlock("schema_upgrade.lock"); |
257 |
278 |
|
|
258 |
|
return TRUE; |
|
|
279 |
|
return $ret; |
259 |
280 |
} |
} |
260 |
281 |
?> |
?> |
File inc/user/repo-page.php changed (mode: 100644) (index 3899721..c5d647d) |
... |
... |
if (empty($subop)) |
50 |
50 |
|
|
51 |
51 |
$_more['repo_body'] = ""; |
$_more['repo_body'] = ""; |
52 |
52 |
$_more['repo_right'] = ""; |
$_more['repo_right'] = ""; |
|
53 |
|
$_more['branches_and_tags'] = ""; |
53 |
54 |
$_repo_body = ""; |
$_repo_body = ""; |
54 |
55 |
$_repo_right = ""; |
$_repo_right = ""; |
55 |
56 |
|
|
|
... |
... |
if (strcmp($subop, "admin") == 0) { |
68 |
69 |
|
|
69 |
70 |
$bt = rg_git_branches_and_tags($repo_dir, $_more['url_repo'], |
$bt = rg_git_branches_and_tags($repo_dir, $_more['url_repo'], |
70 |
71 |
$type_ref['ref_url']); |
$type_ref['ref_url']); |
71 |
|
rg_log("DEBUG: _more: " . print_r($_more, TRUE)); |
|
|
72 |
|
rg_log("DEBUG: _more: " . rg_array2string($_more)); |
72 |
73 |
$_more = array_merge($_more, $bt); |
$_more = array_merge($_more, $bt); |
73 |
74 |
|
|
74 |
75 |
$_repo_body .= rg_template("repo/source.html", $_more); |
$_repo_body .= rg_template("repo/source.html", $_more); |
|
... |
... |
if (strcmp($subop, "admin") == 0) { |
89 |
90 |
$_hash = $_tree[0]['ref']; |
$_hash = $_tree[0]['ref']; |
90 |
91 |
$c = rg_git_content($_hash); |
$c = rg_git_content($_hash); |
91 |
92 |
$_content = array( |
$_content = array( |
92 |
|
"obj" => $obj, |
|
|
93 |
|
"hash" => $_hash, |
93 |
94 |
"HTML:content" => rg_template_list($c) |
"HTML:content" => rg_template_list($c) |
94 |
95 |
); |
); |
95 |
96 |
$blob = array_merge($blob, $_content); |
$blob = array_merge($blob, $_content); |
|
... |
... |
if (strcmp($subop, "admin") == 0) { |
142 |
143 |
} |
} |
143 |
144 |
|
|
144 |
145 |
$log = rg_git_log(1, $first, $second, TRUE); |
$log = rg_git_log(1, $first, $second, TRUE); |
145 |
|
rg_log("log: " . print_r($log, TRUE)); |
|
|
146 |
|
rg_log("log: " . rg_array2string($log)); |
146 |
147 |
|
|
147 |
148 |
// stats |
// stats |
148 |
149 |
$_repo_body .= rg_git_files_stats($log[0]['files'], "repo/fstat"); |
$_repo_body .= rg_git_files_stats($log[0]['files'], "repo/fstat"); |
|
... |
... |
if (strcmp($subop, "admin") == 0) { |
153 |
154 |
} |
} |
154 |
155 |
} |
} |
155 |
156 |
$_repo_right = rg_template("repo/source_r.html", $_more); |
$_repo_right = rg_template("repo/source_r.html", $_more); |
156 |
|
} else if (strcmp($subop, "issues") == 0) { |
|
157 |
|
$_repo_body .= rg_template("repo/issues.html", $_more); |
|
|
157 |
|
} else if (strcmp($subop, "bug") == 0) { |
|
158 |
|
include($INC . "/user/repo/bug/main.php"); |
|
159 |
|
$_repo_body .= rg_template("repo/bug/main.html", $_more); |
158 |
160 |
} else if (strcmp($subop, "stats") == 0) { |
} else if (strcmp($subop, "stats") == 0) { |
159 |
161 |
$_repo_body .= rg_template("repo/stats.html", $_more); |
$_repo_body .= rg_template("repo/stats.html", $_more); |
160 |
162 |
} else if (strcmp($subop, "mrs") == 0) { |
} else if (strcmp($subop, "mrs") == 0) { |
File inc/util.inc.php changed (mode: 100644) (index e0c87ea..3a1e284) |
... |
... |
function rg_re_repopage($ui, $repo) |
166 |
166 |
return $_SERVER['PHP_SELF'] . "?vv=$s"; |
return $_SERVER['PHP_SELF'] . "?vv=$s"; |
167 |
167 |
} |
} |
168 |
168 |
|
|
|
169 |
|
function rg_re_bugpage($ui, $ri, $bug_id) |
|
170 |
|
{ |
|
171 |
|
if (!isset($ui['organization'])) { |
|
172 |
|
rg_internal_error("rg_re_repopage called with wrong ui!"); |
|
173 |
|
exit(1); |
|
174 |
|
} |
|
175 |
|
|
|
176 |
|
$s = rg_re_userpage($ui) . "/" . $ri['name'] . "/bug/" . $bug_id; |
|
177 |
|
|
|
178 |
|
if (isset($_REQUEST['rwe'])) |
|
179 |
|
return $s; |
|
180 |
|
|
|
181 |
|
return $_SERVER['PHP_SELF'] . "?vv=$s"; |
|
182 |
|
} |
|
183 |
|
|
169 |
184 |
function rg_re_repo_ssh($rr) |
function rg_re_repo_ssh($rr) |
170 |
185 |
{ |
{ |
171 |
186 |
global $rg_ssh_port; |
global $rg_ssh_port; |
|
... |
... |
function rg_prepare_conditionals(&$data, &$what, &$values) |
343 |
358 |
function rg_prepare_replace(&$data, &$what, &$values) |
function rg_prepare_replace(&$data, &$what, &$values) |
344 |
359 |
{ |
{ |
345 |
360 |
if (!empty($data)) { |
if (!empty($data)) { |
|
361 |
|
if (!is_array($data)) |
|
362 |
|
rg_internal_error("invalid type passed"); |
346 |
363 |
foreach ($data as $k => $v) { |
foreach ($data as $k => $v) { |
347 |
364 |
if (strncmp($k, "HTML:", 5) == 0) { |
if (strncmp($k, "HTML:", 5) == 0) { |
348 |
365 |
$k = substr($k, 5); |
$k = substr($k, 5); |
|
... |
... |
function rg_prepare_replace(&$data, &$what, &$values) |
355 |
372 |
} |
} |
356 |
373 |
|
|
357 |
374 |
$what['DUMP'] = "/@@DUMP@@/U"; |
$what['DUMP'] = "/@@DUMP@@/U"; |
358 |
|
$values['DUMP'] = print_r($data, TRUE); |
|
|
375 |
|
$values['DUMP'] = htmlspecialchars(print_r($data, TRUE)); |
359 |
376 |
|
|
360 |
377 |
// we replace @@unknown@@ with empty |
// we replace @@unknown@@ with empty |
361 |
378 |
//$what['FINAL'] = "/@@.*@@/U"; |
//$what['FINAL'] = "/@@.*@@/U"; |
|
... |
... |
function rg_template_list($c) |
459 |
476 |
return $ret; |
return $ret; |
460 |
477 |
} |
} |
461 |
478 |
|
|
|
479 |
|
/* |
|
480 |
|
* Show errors using a template |
|
481 |
|
*/ |
|
482 |
|
function rg_template_errmsg($a) |
|
483 |
|
{ |
|
484 |
|
$b = array(); |
|
485 |
|
foreach ($a as $junk => $err) |
|
486 |
|
$b[] = array("error" => $err); |
|
487 |
|
return rg_template_table("errmsg", $b, array()); |
|
488 |
|
} |
|
489 |
|
|
462 |
490 |
/* |
/* |
463 |
491 |
* Execute $cmd and returns the output as a string, binary safe |
* Execute $cmd and returns the output as a string, binary safe |
464 |
492 |
*/ |
*/ |
|
... |
... |
function rg_array2string($a) |
515 |
543 |
if (empty($a)) |
if (empty($a)) |
516 |
544 |
return ""; |
return ""; |
517 |
545 |
|
|
|
546 |
|
$what = array("/\n/", "/\r/"); |
|
547 |
|
$values = array("\\n", "\\r"); |
|
548 |
|
|
518 |
549 |
$ret = ""; |
$ret = ""; |
519 |
550 |
$add = ""; |
$add = ""; |
520 |
551 |
foreach ($a as $k => $v) { |
foreach ($a as $k => $v) { |
521 |
|
$ret .= $add . "$k=$v"; |
|
|
552 |
|
if (is_array($v)) |
|
553 |
|
$s = "[" . rg_array2string($v) . "]"; |
|
554 |
|
else |
|
555 |
|
$s = preg_replace($what, $values, $v); |
|
556 |
|
$ret .= $add . "$k=$s"; |
522 |
557 |
$add = " "; |
$add = " "; |
523 |
558 |
} |
} |
524 |
559 |
|
|
File scripts/remote.php changed (mode: 100644) (index ae8c667..9c96336) |
... |
... |
require_once($INC . "/sql.inc.php"); |
12 |
12 |
require_once($INC . "/struct.inc.php"); |
require_once($INC . "/struct.inc.php"); |
13 |
13 |
require_once($INC . "/repo.inc.php"); |
require_once($INC . "/repo.inc.php"); |
14 |
14 |
require_once($INC . "/prof.inc.php"); |
require_once($INC . "/prof.inc.php"); |
|
15 |
|
require_once($INC . "/ssh.inc.php"); |
15 |
16 |
|
|
16 |
17 |
rg_prof_start("remote.php"); |
rg_prof_start("remote.php"); |
17 |
18 |
|
|
|
... |
... |
function fatal($str) |
37 |
38 |
} |
} |
38 |
39 |
|
|
39 |
40 |
rg_log("Start..."); |
rg_log("Start..."); |
40 |
|
rg_log("_SERVER: " . print_r($_SERVER, TRUE)); |
|
|
41 |
|
rg_log("_SERVER: " . rg_array2string($_SERVER)); |
41 |
42 |
|
|
42 |
43 |
umask(0022); |
umask(0022); |
43 |
44 |
|
|
|
45 |
|
$db = rg_sql_open($rg_sql); |
|
46 |
|
if ($db === FALSE) |
|
47 |
|
fatal("Internal error (db)!"); |
|
48 |
|
|
|
49 |
|
$r = rg_sql_struct_update_if_needed($db, 0); |
|
50 |
|
if ($r !== TRUE) |
|
51 |
|
fatal("We are in a short maintenance. Try again later."); |
|
52 |
|
|
44 |
53 |
if (isset($_SERVER['SSH_CONNECTION'])) { |
if (isset($_SERVER['SSH_CONNECTION'])) { |
45 |
54 |
rg_log("SSH connection: " . $_SERVER['SSH_CONNECTION']); |
rg_log("SSH connection: " . $_SERVER['SSH_CONNECTION']); |
46 |
55 |
$access_type = 1; |
$access_type = 1; |
|
... |
... |
if (isset($_SERVER['SSH_CONNECTION'])) { |
54 |
63 |
fatal("uid not provided!"); |
fatal("uid not provided!"); |
55 |
64 |
rg_log("\tuid is $uid."); |
rg_log("\tuid is $uid."); |
56 |
65 |
|
|
57 |
|
$cmd_repo = trim(@$_SERVER['SSH_ORIGINAL_COMMAND']); |
|
58 |
|
if (empty($cmd_repo)) |
|
59 |
|
fatal("No SSH_ORIGINAL_COMMAND provided!"); |
|
|
66 |
|
if (!isset($_SERVER['SSH_ORIGINAL_COMMAND'])) |
|
67 |
|
$cmd_repo = ""; |
|
68 |
|
else |
|
69 |
|
$cmd_repo = trim($_SERVER['SSH_ORIGINAL_COMMAND']); |
|
70 |
|
rg_ssh_dispatch($db, $uid, $cmd_repo); |
60 |
71 |
|
|
61 |
72 |
$ssh_client = getenv("SSH_CLIENT"); |
$ssh_client = getenv("SSH_CLIENT"); |
62 |
73 |
$_t = explode(" ", $ssh_client); |
$_t = explode(" ", $ssh_client); |
|
... |
... |
$_t = preg_replace('/\.git$/' , '', $_t); |
113 |
124 |
$_t = explode("/", $_t); |
$_t = explode("/", $_t); |
114 |
125 |
if (strcmp($_t[0], "user") == 0) { |
if (strcmp($_t[0], "user") == 0) { |
115 |
126 |
$prefix = "/user"; |
$prefix = "/user"; |
116 |
|
$user = $_t[1]; |
|
117 |
|
$repo = $_t[2]; |
|
|
127 |
|
$user = isset($_t[1]) ? $_t[1] : ""; |
|
128 |
|
$repo = isset($_t[2]) ? $_t[2] : ""; |
118 |
129 |
} else { |
} else { |
119 |
130 |
$prefix = ""; |
$prefix = ""; |
120 |
|
$user = $_t[0]; |
|
121 |
|
$repo = $_t[1]; |
|
|
131 |
|
$user = isset($_t[0]) ? $_t[0] : ""; |
|
132 |
|
$repo = isset($_t[1]) ? $_t[1] : ""; |
122 |
133 |
} |
} |
123 |
134 |
|
|
124 |
135 |
rg_log("host=[$host] cmd=[$cmd] prefix=[$prefix] user=[$user] repo=[$repo]."); |
rg_log("host=[$host] cmd=[$cmd] prefix=[$prefix] user=[$user] repo=[$repo]."); |
|
... |
... |
if (rg_user_ok($user) !== TRUE) |
130 |
141 |
if (rg_repo_ok($repo) !== TRUE) |
if (rg_repo_ok($repo) !== TRUE) |
131 |
142 |
fatal("Repo [$repo] is invalid (" . rg_repo_error() . ")"); |
fatal("Repo [$repo] is invalid (" . rg_repo_error() . ")"); |
132 |
143 |
|
|
133 |
|
$db = rg_sql_open($rg_sql); |
|
134 |
|
if ($db === FALSE) |
|
135 |
|
fatal("Internal error (db)!"); |
|
136 |
|
|
|
137 |
|
$r = rg_sql_struct_update_if_needed($db, 0); |
|
138 |
|
if ($r !== TRUE) |
|
139 |
|
fatal("We are in a short maintenance. Try again later."); |
|
140 |
|
|
|
141 |
144 |
// Loading info about the repository |
// Loading info about the repository |
142 |
145 |
$rr = array("prefix" => $prefix, "user" => $user, "repo" => $repo); |
$rr = array("prefix" => $prefix, "user" => $user, "repo" => $repo); |
143 |
146 |
$ri = rg_repo_info($db, $rr); |
$ri = rg_repo_info($db, $rr); |