xaizek / rocketgit (License: AGPLv3+) (since 2018-12-09)
Light and fast Git hosting solution suitable to serve both as a hub or as a personal code storage with its tickets, pull requests, API and much more.
Commit b97257f8544be4197bb76c358ee409fd92810b0b

Checkpoint
Author: Catalin(ux) M. BOIE
Author date (UTC): 2012-09-27 12:39
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2012-09-27 12:39
Parent(s): f51442036f0124377ba87d2fd4cb3471f8e6083a
Signing key:
Tree: 8d2f6a613f0f316267bc6ef8a9f8bc39680d73cd
File Lines added Lines deleted
Compare.txt 6 5
TODO 13 4
admin/init.php 4 6
inc/admin/users/add.php 2 3
inc/admin/users/edit.php 4 5
inc/bug.inc.php 564 211
inc/feedback/suggestion.php 2 3
inc/log.inc.php 1 11
inc/struct.inc.php 15 0
inc/user/create.php 2 3
inc/user/info/info.php 2 3
inc/user/pass/pass.php 2 3
inc/user/repo/bug/add/add.php 11 3
inc/user/repo/bug/main.php 57 4
inc/user/repo/bug/search/search.php 64 0
inc/user/repo/bug/show.php 23 17
inc/user/repo/delete/delete.php 2 4
inc/user/repo/edit/edit.php 2 4
inc/util.inc.php 59 11
root/index.php 1 1
root/themes/default/hints/repo/anon_push.html 1 1
root/themes/default/hints/repo/clone_git.html 1 1
root/themes/default/hints/repo/clone_ssh.html 1 1
root/themes/default/hints/repo/merge.html 3 3
root/themes/default/hints/repo/remote_add.html 15 0
root/themes/default/index.html 4 2
root/themes/default/repo/bug/bug_add.html 5 0
root/themes/default/repo/bug/bug_search.html 70 0
root/themes/default/repo/bug/list_labels/footer.html 0 1
root/themes/default/repo/bug/list_note/between.html 2 0
root/themes/default/repo/bug/list_note/footer.html 1 1
root/themes/default/repo/bug/list_note/header.html 1 7
root/themes/default/repo/bug/list_note/line.html 6 6
root/themes/default/repo/bug/main.html 1 0
root/themes/default/repo/bug/not_found.html 3 0
root/themes/default/repo/bug/search/list/footer.html 0 0
root/themes/default/repo/bug/search/list/header.html 2 0
root/themes/default/repo/bug/search/list/line.html 1 0
root/themes/default/repo/bug/search/list/nodata.html 0 0
root/themes/default/repo/bug/search/remove.html 9 0
root/themes/default/repo/bug/show.html 1 0
root/themes/try3/main.css 70 11
samples/config.php 1 1
tests/bug.php 9 1
File Compare.txt changed (mode: 100644) (index 4216a64..d4c2057)
1 Gitlab RocketGit GitHub Gitorious unfuddle.com
1 Gitlab RocketGit GitHub Gitorious unfuddle.com gitolite
2 2
3 License ? GPLv3 Prop. ? ? ?
3 4
4 5 [Features] [Features]
5 Easy instalation No Yes Yes No!
6 SELinux friendly ? Yes ? ?
7 Disto friendly No Yes No No
8 Bug tracker Yes Yes Yes ?
6 Easy instalation No Yes Yes No! ? Yes
7 SELinux friendly ? Yes ? ? ? ?
8 Distro friendly No Yes No No
9 Bug tracker Yes Yes Yes No
9 10 CLI commands (SSH) ? Yes ? ? CLI commands (SSH) ? Yes ? ?
10 11 API ? ? Yes ? API ? ? Yes ?
11 12
File TODO changed (mode: 100644) (index fad2d2b..7356512)
1 1 == BEFORE FIRST RELEASE! == == BEFORE FIRST RELEASE! ==
2 [ ] Add some hints.
3 [ ] Hints for ssh are not indented!
4 [ ] Allow user to specify if is on windows/linux/etc. to be able to give
5 tailored hints.
2 [ ] rg_bug_search should be rg_bug_get/load and rg_bug_search to search using
3 labels/start/end/etc.
4 [ ] bug_update does not update labels!
5 [ ] Integrate remote_add.html.
6 [ ] If you are not logged in, do not show the save option!
7 [ ] ml.php in /root/PHP
8 [ ] Should we expire the reset password token? Why? Somebody can request another
9 one!
10 [ ] All internal error should show a special page?
6 11 [ ] [ ]
7 12
8 13
9 14 == Medium == == Medium ==
15 [ ] Bug rights: add note, anonymous add note, add label.
16 [ ] Allow user to specify if is on windows/linux/etc. to be able to give
17 specific hints. Hm. THe user may have multiple OSs.
18 [ ] The selected menu is not colored different.
10 19 [ ] http://rg.embedromix.ro:8000/user/catab/a13/admin/rights?edit_uid=19 [ ] http://rg.embedromix.ro:8000/user/catab/a13/admin/rights?edit_uid=19
11 20 should give an error! should give an error!
12 21 [ ] Pay attention to: https://github.com/sitaramc/gitolite/wiki: [ ] Pay attention to: https://github.com/sitaramc/gitolite/wiki:
File admin/init.php changed (mode: 100644) (index a43093f..5d7aade)
... ... $_u['disk_quota_mb'] = 0;
38 38 $_u['rights'] = rg_rights_all("user"); $_u['rights'] = rg_rights_all("user");
39 39 $_u['session_time'] = 3600; $_u['session_time'] = 3600;
40 40 $_u['confirm_token'] = ""; $_u['confirm_token'] = "";
41 while (1) {
41 do {
42 42 $username0 = readline("User [" . $_u['username'] . "]: "); $username0 = readline("User [" . $_u['username'] . "]: ");
43 43 if (!empty($username0)) if (!empty($username0))
44 44 $_u['username'] = $username0; $_u['username'] = $username0;
 
... ... while (1) {
46 46 if (!empty($email0)) if (!empty($email0))
47 47 $_u['email'] = $email0; $_u['email'] = $email0;
48 48
49 while (1) {
49 do {
50 50 $_u['pass'] = readline("Password: "); $_u['pass'] = readline("Password: ");
51 51 $_u['pass2'] = readline("Password (confirmation): "); $_u['pass2'] = readline("Password (confirmation): ");
52 52 if (strcmp($_u['pass'], $_u['pass2']) != 0) { if (strcmp($_u['pass'], $_u['pass2']) != 0) {
53 53 echo "Passwords mismatch!\n"; echo "Passwords mismatch!\n";
54 54 continue; continue;
55 55 } }
56 break;
57 }
56 } while(0);
58 57
59 58 $r = rg_user_info($db, $_u['uid'], $_u['username'], "" /* email */); $r = rg_user_info($db, $_u['uid'], $_u['username'], "" /* email */);
60 59 if ($r['ok'] != 1) { if ($r['ok'] != 1) {
 
... ... while (1) {
73 72 echo "Cannot create user (" . rg_user_error() . ")!\n"; echo "Cannot create user (" . rg_user_error() . ")!\n";
74 73 continue; continue;
75 74 } }
76 break;
77 }
75 } while (0);
78 76
79 77
80 78 // Store the timestamp of the first install // Store the timestamp of the first install
File inc/admin/users/add.php changed (mode: 100644) (index 848a9d6..38b35c0)
... ... if ($doit == 1) {
20 20 $rights = @rg_rights_a2s($_REQUEST['rights']); $rights = @rg_rights_a2s($_REQUEST['rights']);
21 21 $session_time = rg_var_uint("session_time"); $session_time = rg_var_uint("session_time");
22 22
23 while (1) {
23 do {
24 24 if (rg_user_ok($xuser) !== TRUE) { if (rg_user_ok($xuser) !== TRUE) {
25 25 $errmsg[] = "invalid user name (" . rg_user_error() . ")"; $errmsg[] = "invalid user name (" . rg_user_error() . ")";
26 26 break; break;
 
... ... if ($doit == 1) {
61 61 // TODO: Send a confirmation e-mail with the password // TODO: Send a confirmation e-mail with the password
62 62
63 63 $_user_add .= "OK!<br />"; $_user_add .= "OK!<br />";
64 break;
65 }
64 } while (0);
66 65 } else { } else {
67 66 $xuser = ""; $xuser = "";
68 67 $realname = ""; $realname = "";
File inc/admin/users/edit.php changed (mode: 100644) (index bf9d8bd..f2b3e99)
... ... if ($doit == 1) {
23 23 $rights = @rg_rights_a2s($_REQUEST['rights']); $rights = @rg_rights_a2s($_REQUEST['rights']);
24 24 $session_time = rg_var_uint("session_time"); $session_time = rg_var_uint("session_time");
25 25
26 while (1) {
26 do {
27 27 $_ui = rg_user_info($db, 0, $xuser, ""); $_ui = rg_user_info($db, 0, $xuser, "");
28 28 if ($_ui['ok'] == 0) { if ($_ui['ok'] == 0) {
29 29 $errmsg[] = "internal error"; $errmsg[] = "internal error";
 
... ... if ($doit == 1) {
53 53
54 54 $_user_edit .= "OK!<br />"; $_user_edit .= "OK!<br />";
55 55 $show_form = 0; $show_form = 0;
56 break;
57 }
56 } while (0);
58 57 } else { } else {
59 58 // TODO: Check if user has the right to edit this info! // TODO: Check if user has the right to edit this info!
60 59
61 60 $_ui = rg_user_info($db, $uid, "", ""); $_ui = rg_user_info($db, $uid, "", "");
62 61 if ($_ui['ok'] == 0) { if ($_ui['ok'] == 0) {
63 $_user_edit .= "internal error!";
62 $_user_edit .= "internal error";
64 63 $show_form = 0; $show_form = 0;
65 64 } else if ($_ui['exists'] == 0) { } else if ($_ui['exists'] == 0) {
66 $_user_edit .= "user does not exist<br />";
65 $_user_edit .= "user does not exist";
67 66 $show_form = 0; $show_form = 0;
68 67 } else { } else {
69 68 $xuser = $_ui['username']; $xuser = $_ui['username'];
File inc/bug.inc.php changed (mode: 100644) (index 8d31d49..8ea95d3)
... ... function rg_bug_error()
20 20 return $rg_bug_error; return $rg_bug_error;
21 21 } }
22 22
23 /* States for a bug */
24 $rg_bug_states = array(
25 "0" => "Any",
26 "1" => "Open",
27 "2" => "Closed"
28 );
29
23 30 /* /*
24 * We want the bug number to be consecutive per project.
31 * Return the state of a bug, as string
32 */
33 function rg_bug_state($v)
34 {
35 global $rg_bug_states;
36
37 if (!isset($rg_bug_states[$v]))
38 return "?";
39
40 return $rg_bug_states[$v];
41 }
42
43 /*
44 * Returns a select for state
45 */
46 function rg_bug_state_select($value)
47 {
48 global $rg_bug_states;
49
50 $ret = "";
51 $ret .= "<select name=\"state\">\n";
52 foreach ($rg_bug_states as $key => $name) {
53 $add = "";
54 if (strcmp($value, $key) == 0)
55 $add = " selected";
56 $ret .= "\t<option value=\"" . $key . "\"" . $add . ">"
57 . $name . "</option>\n";
58 }
59 $ret .= "</select>\n";
60
61 return $ret;
62 }
63
64 /*
65 * We want the bug number to be consecutive per repo.
25 66 * This is why we use a separate table (bugs_max) to track last id. * This is why we use a separate table (bugs_max) to track last id.
26 67 * This function must be inside a transaction. * This function must be inside a transaction.
27 68 */ */
28 69 function rg_bug_next_id($db, $repo_id) function rg_bug_next_id($db, $repo_id)
29 70 { {
30 71 rg_prof_start("bug_next_id"); rg_prof_start("bug_next_id");
72 rg_log("bug_next_id: repo_id=$repo_id");
31 73
32 74 $next_bug_id = FALSE; $next_bug_id = FALSE;
33 75 do { do {
 
... ... function rg_bug_next_id($db, $repo_id)
50 92 if ($rows == 1) if ($rows == 1)
51 93 break; break;
52 94
53 /* This means this is the first bug */
95 /* If we are here, it means that we have no entry in bugs_max. */
96 $res = rg_sql_begin($db);
97 if ($res === FALSE) {
98 rg_bug_set_error("cannot start txn (" . rg_sql_error() . ")");
99 break;
100 }
101
54 102 $sql = "LOCK TABLE bugs_max IN ACCESS EXCLUSIVE MODE"; $sql = "LOCK TABLE bugs_max IN ACCESS EXCLUSIVE MODE";
55 103 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
56 104 if ($res === FALSE) { if ($res === FALSE) {
57 105 rg_bug_set_error("cannot lock max table (" . rg_sql_error() . ")"); rg_bug_set_error("cannot lock max table (" . rg_sql_error() . ")");
58 106 break; break;
59 107 } }
108 rg_sql_free_result($res);
60 109
61 110 /* /*
62 111 * Here, another client may just did the insert and commited * Here, another client may just did the insert and commited
 
... ... function rg_bug_next_id($db, $repo_id)
72 121 $rows = rg_sql_num_rows($res); $rows = rg_sql_num_rows($res);
73 122 rg_sql_free_result($res); rg_sql_free_result($res);
74 123
75 if ($rows == 1) {
76 /*
77 * The other client was faster than us. Just try to update
78 */
79 continue;
124 if ($rows == 0) {
125 // We were faster, just insert.
126 $sql = "INSERT INTO bugs_max (repo_id, last_bug_id)"
127 . " VALUES ($repo_id, 1)";
128 $res = rg_sql_query($db, $sql);
129 if ($res === FALSE) {
130 rg_bug_set_error("cannot insert into max table (" . rg_sql_error() . ")");
131 break;
132 }
133 rg_sql_free_result($res);
134 $next_bug_id = 1;
80 135 } }
81 136
82 // We was faster, just insert.
83 $sql = "INSERT INTO bugs_max (repo_id, last_bug_id)"
84 . " VALUES ($repo_id, 1)";
85 $res = rg_sql_query($db, $sql);
137 // commit (will also unlock)
138 $res = rg_sql_commit($db);
86 139 if ($res === FALSE) { if ($res === FALSE) {
87 rg_bug_set_error("cannot insert into max table (" . rg_sql_error() . ")");
140 rg_bug_set_error("cannot commit (" . rg_sql_error() . ")");
88 141 break; break;
89 142 } }
90 rg_sql_free_result($res);
91 $next_bug_id = 1;
92 } while (0);
143
144 /*
145 * The other client was faster than us. Just repeat
146 * the whole operation.
147 */
148 } while ($next_bug_id === FALSE);
93 149
94 150 rg_log("\tDEBUG: next_bug_id=" . $next_bug_id); rg_log("\tDEBUG: next_bug_id=" . $next_bug_id);
95 151
96 152 rg_prof_end("bug_next_id"); rg_prof_end("bug_next_id");
97
98 153 return $next_bug_id; return $next_bug_id;
99 154 } }
100 155
 
... ... function rg_bug_cosmetic($db, &$row)
124 179 if ($_ui['exists'] == 1) if ($_ui['exists'] == 1)
125 180 $row['assigned_to'] = $_ui['username']; $row['assigned_to'] = $_ui['username'];
126 181 } }
182
183 $row['state'] = rg_bug_state($row['state']);
127 184 } }
128 185
129 186 /* /*
 
... ... function rg_bug_info($db, $repo_id, $bug_id)
135 192 global $rg_bug_info_cache; global $rg_bug_info_cache;
136 193
137 194 rg_prof_start("bug_info"); rg_prof_start("bug_info");
195 rg_log("rg_bug_info: repo_id=$repo_id bug_id=$bug_id");
138 196
139 $key = $repo_id . "-" . $bug_id;
140 if (isset($rg_bug_info_cache[$key]))
141 return $rg_bug_info_cache[$key];
142
143 rg_log("bug_info: repo_id=$repo_id bug_id=$bug_id");
144
145 $ret['ok'] = 0;
146 $ret['exists'] = 0;
147
148 $rg_bug_info_cache[$key] = $ret;
197 $ret = FALSE;
198 do {
199 $key = $repo_id . "-" . $bug_id;
200 if (isset($rg_bug_info_cache[$key])) {
201 $ret = $rg_bug_info_cache[$key];
202 break;
203 }
149 204
150 $sql = "SELECT * FROM bugs"
151 . " WHERE repo_id = " . $repo_id
152 . " AND bug_id = " . $bug_id;
153 $res = rg_sql_query($db, $sql);
154 if ($res === FALSE) {
155 rg_bug_set_error("cannot query (" . rg_sql_error() . ")");
156 return $ret;
157 }
158 $ret['ok'] = 1;
159 $row = rg_sql_fetch_array($res);
160 rg_sql_free_result($res);
161 if (!isset($row['bug_id'])) {
162 rg_log("\tBug not found!");
163 return $ret;
164 }
205 $sql = "SELECT * FROM bugs"
206 . " WHERE repo_id = " . $repo_id
207 . " AND bug_id = " . $bug_id;
208 $res = rg_sql_query($db, $sql);
209 if ($res === FALSE) {
210 rg_bug_set_error("cannot list bugs (" . rg_sql_error() . ")");
211 break;
212 }
213 $ret = array();
214 $rows = rg_sql_num_rows($res);
215 if ($rows == 1)
216 $ret = rg_sql_fetch_array($res);
217 rg_sql_free_result($res);
165 218
166 $row['exists'] = 1;
167 $row['ok'] = 1;
219 $ret['exists'] = $rows;
220 if ($ret['exists'] == 0)
221 break;
168 222
169 rg_bug_cosmetic($db, $row);
223 rg_bug_cosmetic($db, $ret);
170 224
171 $rg_bug_info_cache[$key] = $row;
225 $rg_bug_info_cache[$key] = $ret;
226 } while (0);
172 227
173 228 rg_prof_end("bug_info"); rg_prof_end("bug_info");
174
175 return $row;
229 return $ret;
176 230 } }
177 231
178 232 /* /*
 
... ... function rg_bug_info($db, $repo_id, $bug_id)
181 235 function rg_bug_add($db, $repo_id, $uid, $data) function rg_bug_add($db, $repo_id, $uid, $data)
182 236 { {
183 237 rg_prof_start("bug_add"); rg_prof_start("bug_add");
184
185 238 rg_log("bug_add: repo_id=$repo_id uid=$uid" rg_log("bug_add: repo_id=$repo_id uid=$uid"
186 239 . " data: " . rg_array2string($data)); . " data: " . rg_array2string($data));
187 240
 
... ... function rg_bug_add($db, $repo_id, $uid, $data)
190 243 $e_data = $data; $e_data = $data;
191 244 $e_data['title'] = rg_sql_escape($db, $data['title']); $e_data['title'] = rg_sql_escape($db, $data['title']);
192 245 $e_data['body'] = rg_sql_escape($db, $data['body']); $e_data['body'] = rg_sql_escape($db, $data['body']);
246 $e_data['state'] = sprintf("%u", $data['state']);
193 247 $e_data['labels'] = rg_sql_escape($db, $data['labels']); $e_data['labels'] = rg_sql_escape($db, $data['labels']);
194 248
195 249 $itime = time(); $itime = time();
 
... ... function rg_bug_add($db, $repo_id, $uid, $data)
212 266 break; break;
213 267
214 268 $sql = "INSERT INTO bugs (bug_id, itime, utime, repo_id, uid" $sql = "INSERT INTO bugs (bug_id, itime, utime, repo_id, uid"
215 . ", ip, title, body, assigned_uid, deleted)"
269 . ", ip, title, body, state, assigned_uid, deleted)"
216 270 . " VALUES ($bug_id, $itime, 0, $repo_id, $uid" . " VALUES ($bug_id, $itime, 0, $repo_id, $uid"
217 271 . ", '$ip', '" . $e_data['title'] . "'" . ", '$ip', '" . $e_data['title'] . "'"
218 272 . ", '" . $e_data['body'] . "'" . ", '" . $e_data['body'] . "'"
273 . ", " . $e_data['state']
219 274 . ", " . $e_data['assigned_uid'] . ", " . $e_data['assigned_uid']
220 275 . ", 0)"; . ", 0)";
221 276 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
 
... ... function rg_bug_add($db, $repo_id, $uid, $data)
238 293 rg_sql_rollback($db); rg_sql_rollback($db);
239 294
240 295 rg_prof_end("bug_add"); rg_prof_end("bug_add");
241
242 296 return $ret; return $ret;
243 297 } }
244 298
 
... ... function rg_bug_add($db, $repo_id, $uid, $data)
248 302 function rg_bug_delete($db, $repo_id, $bug_id) function rg_bug_delete($db, $repo_id, $bug_id)
249 303 { {
250 304 rg_prof_start("bug_delete"); rg_prof_start("bug_delete");
251
252 305 rg_log("bug_delete: $repo_id=$repo_id bug_id=$bug_id"); rg_log("bug_delete: $repo_id=$repo_id bug_id=$bug_id");
253 306
254 // TODO: Check rights
307 $ret = FALSE;
308 do {
309 // TODO: Check rights
255 310
256 $now = time();
311 $now = time();
257 312
258 // Only mark it as such, deletion will happen in background
259 $sql = "UPDATE bugs SET deleted = $now"
260 . " WHERE repo_id = $repo_id"
261 . " AND bug_id = $bug_id";
262 $res = rg_sql_query($db, $sql);
263 if ($res === FALSE) {
264 rg_bug_set_error("Cannot delete bug (" . rg_sql_error() . ")");
265 return FALSE;
266 }
267 rg_sql_free_result($res);
313 // Only mark it as such, deletion will happen in background
314 $sql = "UPDATE bugs SET deleted = $now"
315 . " WHERE repo_id = $repo_id"
316 . " AND bug_id = $bug_id";
317 $res = rg_sql_query($db, $sql);
318 if ($res === FALSE) {
319 rg_bug_set_error("Cannot delete bug (" . rg_sql_error() . ")");
320 break;
321 }
322 rg_sql_free_result($res);
323 $ret = TRUE;
324 } while (0);
268 325
269 326 rg_prof_end("bug_delete"); rg_prof_end("bug_delete");
270
271 return TRUE;
327 return $ret;
272 328 } }
273 329
274 330 /* /*
 
... ... function rg_bug_delete($db, $repo_id, $bug_id)
278 334 function rg_bug_update($db, $repo_id, $bug_id, $data) function rg_bug_update($db, $repo_id, $bug_id, $data)
279 335 { {
280 336 rg_prof_start("bug_update"); rg_prof_start("bug_update");
281
282 337 rg_log("bug_update: repo_id=$repo_id bug_id=$bug_id data: " rg_log("bug_update: repo_id=$repo_id bug_id=$bug_id data: "
283 338 . rg_array2string($data)); . rg_array2string($data));
284 339
285 // First, test if it already exists
286 $bi = rg_bug_info($db, $repoid, $bug_id);
287 if ($bi['exists'] != 1)
288 return FALSE;
340 $ret = FALSE;
341 do {
342 // First, test if it already exists
343 $bi = rg_bug_info($db, $repoid, $bug_id);
344 if (($bi === FALSE) || ($bi['exists'] != 1))
345 break;
289 346
290 $e_data = $data;
291 $e_data['title'] = rg_sql_escape($db, $data['title']);
292 $e_data['body'] = rg_sql_escape($db, $data['body']);
347 $e_data = $data;
348 $e_data['title'] = rg_sql_escape($db, $data['title']);
349 $e_data['body'] = rg_sql_escape($db, $data['body']);
350 $e_data['state'] = sprintf("%u", $data['state']);
351 // TODO: make a function to sanitize the input to be called from
352 // both update and insert.
293 353
294 $utime = time();
295
296 $sql = "UPDATE bugs SET utime = $now"
297 . ", title = '" . $e_data['title'] . "'"
298 . ", body = '" . $e_data['body'] . "'"
299 . ", labels = '" . $e_data['labels'] . "'"
300 . ", state = " . $e_data['state']
301 . ", assigned_uid = " . $e_data['assigned_uid']
302 . " WHERE repo_id = $repo_id"
303 . " AND bug_id = $bug_id";
304 $res = rg_sql_query($db, $sql);
305 if ($res === FALSE) {
306 rg_bug_set_error("Cannot update bug (" . rg_sql_error() . ")");
307 return FALSE;
308 }
309 rg_sql_free_result($res);
354 $utime = time();
310 355
311 rg_prof_end("bug_update");
356 $sql = "UPDATE bugs SET utime = $now"
357 . ", title = '" . $e_data['title'] . "'"
358 . ", body = '" . $e_data['body'] . "'"
359 . ", state = " . $e_data['state']
360 . ", assigned_uid = " . $e_data['assigned_uid']
361 . " WHERE repo_id = $repo_id"
362 . " AND bug_id = $bug_id";
363 $res = rg_sql_query($db, $sql);
364 if ($res === FALSE) {
365 rg_bug_set_error("Cannot update bug (" . rg_sql_error() . ")");
366 break;
367 }
368 rg_sql_free_result($res);
369 $ret = TRUE;
370 } while (0);
312 371
313 return TRUE;
372 rg_prof_end("bug_update");
373 return $ret;
314 374 } }
315 375
316 376 /* /*
 
... ... function rg_bug_update($db, $repo_id, $bug_id, $data)
319 379 function rg_bug_list_query($db, $url, $sql) function rg_bug_list_query($db, $url, $sql)
320 380 { {
321 381 rg_prof_start("bug_list_query"); rg_prof_start("bug_list_query");
322
323 382 rg_log("bug_list_query: url=$url, sql=$sql..."); rg_log("bug_list_query: url=$url, sql=$sql...");
324 383
325 $res = rg_sql_query($db, $sql);
326 if ($res === FALSE) {
327 rg_bug_set_error("cannot list by query (" . rg_sql_error() . ")");
328 return FALSE;
329 }
384 $ret = FALSE;
385 do {
386 $res = rg_sql_query($db, $sql);
387 if ($res === FALSE) {
388 rg_bug_set_error("cannot list by query (" . rg_sql_error() . ")");
389 break;
390 }
330 391
331 $d = array();
332 while (($row = rg_sql_fetch_array($res))) {
333 rg_bug_cosmetic($db, $row);
334 $row['url_bug'] = $url . "/bug/" . $row['bug_id'];
335 $d[] = $row;
336 }
337 rg_sql_free_result($res);
392 $d = array();
393 while (($row = rg_sql_fetch_array($res))) {
394 rg_bug_cosmetic($db, $row);
395 $row['url_bug'] = $url . "/bug/" . $row['bug_id'];
396 $d[] = $row;
397 }
398 rg_sql_free_result($res);
399 $ret = TRUE;
400 } while (0);
401
402 if ($ret !== FALSE)
403 $ret = rg_template_table("repo/bug/list", $d, array());
338 404
339 405 rg_prof_end("bug_list_query"); rg_prof_end("bug_list_query");
406 return $ret;
407 }
408
409 /*
410 * Loads all saved searches
411 */
412 function rg_bug_search_load_all($db, $repo_id, $uid, $url)
413 {
414 rg_prof_start("bug_search_load_all");
415 rg_log("bug_search_load_all: repo_id=$repo_id uid=$uid");
416
417 $ret = FALSE;
418 do {
419 $sql = "SELECT name FROM bug_search"
420 . " WHERE (repo_id = $repo_id OR repo_id = 0)"
421 . " AND uid = $uid"
422 . " ORDER BY repo_id, name";
423 $res = rg_sql_query($db, $sql);
424 if ($res === FALSE) {
425 rg_bug_set_error("cannot load searches (" . rg_sql_error() . ")");
426 break;
427 }
428
429 $data = array();
430 // Add predefined
431 $data['All'] = "All";
432 $data['Open'] = "Open";
433 $data['Closed'] = "Closed";
434
435 while (($row = rg_sql_fetch_array($res))) {
436 $name = $row['name'];
437 $data[$name] = $name;
438 }
439
440 $ret = array();
441 foreach ($data as $name => $junk)
442 $ret[] = array("HTML:name" => "<a href=" . $url
443 . "/list/" . $name . ">" . $name . "</a>");
340 444
341 return rg_template_table("repo/bug/list", $d, array());
445 rg_sql_free_result($res);
446 } while (0);
447
448 rg_prof_end("bug_search_load_all");
449 return $ret;
342 450 } }
343 451
344 452 /* /*
345 *
453 * Loads a saved search
346 454 */ */
347 function rg_bug_list($db, $url, $repo_id)
455 function rg_bug_search_load($db, $repo_id, $uid, $name)
348 456 { {
349 rg_log("bug_list: url=$url, repo_id=$repo_id");
457 rg_prof_start("bug_search_load");
458 rg_log("bug_search_load: repo_id=$repo_id uid=$uid name=$name");
459
460 $ret = FALSE;
461 do {
462 $template = array(
463 "name" => $name,
464 "reported_by" => 0,
465 "assigned_to" => 0,
466 "state" => 0,
467 "start" => 0,
468 "end" => 0,
469 "title_string" => "",
470 "body_string" => "",
471 "bugs_per_page" => 25,
472 "global" => 0,
473 "standard" => 1
474 );
475
476 // Pre-defined
477 if (strcmp($name, "All") == 0) {
478 $ret = $template;
479 break;
480 }
481 if (strcmp($name, "Open") == 0) {
482 $template['state'] = 1;
483 $ret = $template;
484 break;
485 }
486 if (strcmp($name, "Closed") == 0) {
487 $template['state'] = 2;
488 $ret = $template;
489 break;
490 }
350 491
351 $sql = "SELECT * FROM bugs"
352 . " WHERE repo_id = $repo_id"
353 . " AND deleted = 0"
354 . " ORDER BY itime";
492 $e_name = rg_sql_escape($db, $name);
355 493
356 return rg_bug_list_query($db, $url, $sql);
494 $sql = "SELECT name, data FROM bug_search"
495 . " WHERE (repo_id = $repo_id OR repo_id = 0)"
496 . " AND uid = $uid"
497 . " AND name = '$e_name'";
498 $res = rg_sql_query($db, $sql);
499 if ($res === FALSE) {
500 rg_bug_set_error("cannot search load (" . rg_sql_error() . ")");
501 break;
502 }
503
504 $rows = rg_sql_num_rows($res);
505 if ($rows > 0) {
506 $row = rg_sql_fetch_array($res);
507 $_data = @unserialize($row['data']);
508 if ($_data === FALSE) {
509 rg_bug_set_error("cannot unserialize search data");
510 break;
511 }
512 $ret = $_data;
513 $ret['name'] = $row['name']; //TODO: escape?!
514 $ret['standard'] = 0;
515 } else {
516 $ret = array();
517 }
518 rg_sql_free_result($res);
519 } while (0);
520
521 rg_prof_end("bug_search_load");
522 return $ret;
357 523 } }
358 524
359 525 /* /*
360 *
526 * Saves the search filtering
527 * TODO: name should not be inside data?
361 528 */ */
362 function rg_bug_search($db, $q)
529 function rg_bug_search_save($db, $repo_id, $uid, $q)
363 530 { {
364 rg_log("bug_search: q=$q...");
531 rg_prof_start("bug_search_save");
532 rg_log("rg_bug_search_save: repo_id=$repo_id uid=$uid"
533 . " q=" . rg_array2string($q));
365 534
366 $e_q = rg_sql_escape($db, $q);
535 $ret = FALSE;
536 do {
537 $name = $q['name'];
538 unset($q['name']);
539
540 // Test if is already present
541 $old = rg_bug_search_load($db, $repo_id, $uid, $name);
542 if ($old === FALSE)
543 break;
367 544
368 $sql = "SELECT * FROM bugs"
369 . " WHERE deleted = 0"
370 . " AND (title ILIKE '%$e_q%' OR body ILIKE '%$e_q%')"
371 . " AND deleted = 0"
372 . " ORDER BY itime"
373 . " LIMIT 10";
545 $s = serialize($q);
546 $e_data = rg_sql_escape($db, $s);
547 $e_name = rg_sql_escape($db, $name);
374 548
375 return rg_bug_list_query($db, "", $sql);
549 // Global?
550 if (isset($q['global']) && ($q['global'] == 0))
551 $e_repo_id = $repo_id;
552 else
553 $e_repo_id = 0;
554
555 if (empty($old)) {
556 $sql = "INSERT INTO bug_search (repo_id, uid, name"
557 . ", data)"
558 . " VALUES ($e_repo_id, $uid, '$e_name'"
559 . ", '$e_data')";
560 } else {
561 $sql = "UPDATE bug_search"
562 . " SET data = '$e_data'"
563 . " WHERE repo_id = $e_repo_id"
564 . " AND uid = $uid"
565 . " AND name = '$e_name'";
566 }
567 $res = rg_sql_query($db, $sql);
568 if ($res === FALSE) {
569 rg_bug_set_error("cannot save search (" . rg_sql_error() . ")");
570 break;
571 }
572 rg_sql_free_result($res);
573 $ret = TRUE;
574 } while (0);
575
576 rg_prof_end("bug_search_save");
577 return $ret;
376 578 } }
377 579
580 /*
581 * Search for bugs
582 */
583 function rg_bug_search($db, $url, $repo_id, $uid, $q)
584 {
585 rg_prof_start("bug_search");
586 rg_log("bug_search: url=$url repo_id=$repo_id uid=$uid"
587 . " q=" . rg_array2string($q));
588
589 $add = array();
590 $limit = 25;
591 $ret = FALSE;
592 do {
593 // reported_by
594 if (!empty($q['reported_by'])) {
595 $_ui = rg_user_info($db, "", $q['reported_by'], "", "");
596 if ($_ui['exists'] != 1) {
597 rg_bug_set_error("cannot lookup user (reported_by)");
598 break;
599 }
600 $add[] = "uid = " . $_ui['uid'];
601 }
602
603 // assigned to
604 if (!empty($q['assigned_to'])) {
605 $_ui = rg_user_info($db, "", $q['assigned_to'], "", "");
606 if ($_ui['exists'] != 1) {
607 rg_bug_set_error("cannot lookup user (assigned_to)");
608 break;
609 }
610 $add[] = "AND assigned_uid = " . $_ui['uid'];
611 }
612
613 // state
614 if (isset($q['state']) && ($q['state'] > 0))
615 $add[] = "AND state = " . $q['state'];
616
617 // start
618 if (!empty($q['start'])) {
619 $ts = rg_date2ts($q['start'], 0, 0, 0);
620 if ($ts === FALSE) {
621 rg_bug_set_error("invalid start date format");
622 break;
623 }
624 $add[] = "AND itime >= $ts";
625 }
626
627 // end
628 if (!empty($q['end'])) {
629 $ts = rg_date2ts_last_second($q['end']);
630 if ($ts === FALSE) {
631 rg_bug_set_error("invalid end date format");
632 break;
633 }
634 $add[] = "AND itime <= $ts";
635 }
636
637 // title_string
638 if (!empty($q['title_string'])) {
639 $_t = rg_sql_escape($db, $q['title_string']);
640 $add[] = "AND title ILIKE '%" . $_t . "%'";
641 }
642
643 // body_string
644 if (!empty($q['body_string'])) {
645 $_t = rg_sql_escape($db, $q['body_string']);
646 $add[] = "AND body ILIKE '%$" . $_t . "%'";
647 }
648
649 // bugs_per_page
650 if (!empty($q['bugs_per_page']))
651 $limit = $q['bugs_per_page'];
652
653 // Only if we have a name and the user is logged in
654 if (!empty($q['name']) && ($uid > 0)) {
655 $r = rg_bug_search_save($db, $repo_id, $uid, $q);
656 if ($r === FALSE)
657 break;
658 }
659
660 $sql = "SELECT * FROM bugs"
661 . " WHERE repo_id = $repo_id"
662 . " AND deleted = 0"
663 . " " . implode(" ", $add)
664 . " ORDER BY itime"
665 . " LIMIT $limit";
666
667 // TODO: order
668 $ret = TRUE;
669 } while (0);
670
671 if ($ret !== FALSE)
672 $ret = rg_bug_list_query($db, $url, $sql);
673
674 rg_prof_end("bug_search");
675 return $ret;
676 }
677
678 /*
679 * Delete a saved search
680 * TODO: Check rights!
681 */
682 function rg_bug_search_remove($db, $repo_id, $uid, $name)
683 {
684 rg_prof_start("bug_search_delete");
685 rg_log("bug_search_remove: repo_id=$repo_id uid=$uid name=$name");
686
687 $ret = FALSE;
688 do {
689 $e_name = rg_sql_escape($db, $name);
690
691 $sql = "DELETE FROM bug_search"
692 . " WHERE repo_id = $repo_id"
693 . " AND uid = $uid"
694 . " AND name = '$e_name'";
695 $res = rg_sql_query($db, $sql);
696 if ($res === FALSE) {
697 rg_bug_set_error("cannot remove search (" . rg_sql_error() . ")");
698 break;
699 }
700 rg_sql_free_result($res);
701 $ret = TRUE;
702 } while (0);
703
704 rg_prof_end("bug_search_delete");
705 return $ret;
706 }
707
708 /*** NOTES ***/
709
378 710 /* /*
379 711 * Add a note for a bug * Add a note for a bug
380 712 */ */
381 713 function rg_bug_note_add($db, $repo_id, $bug_id, $uid, $data) function rg_bug_note_add($db, $repo_id, $bug_id, $uid, $data)
382 714 { {
383 715 rg_prof_start("bug_note_add"); rg_prof_start("bug_note_add");
384
385 716 rg_log("bug_note_add: repo_id=$repo_id bug_id=$bug_id" rg_log("bug_note_add: repo_id=$repo_id bug_id=$bug_id"
386 717 . " data: " . rg_array2string($data)); . " data: " . rg_array2string($data));
387 718
388 // TODO: test if user is allowed to add a note
719 $ret = FALSE;
720 do {
721 // TODO: test if user is allowed to add a note
389 722
390 $e_data = $data;
391 $e_data['note'] = rg_sql_escape($db, $data['note']);
723 $e_data = $data;
724 $e_data['note'] = rg_sql_escape($db, $data['note']);
392 725
393 $itime = time();
394 $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : "?";
395
396 $sql = "INSERT INTO bug_notes (repo_id, bug_id, itime, uid, ip"
397 . ", note)"
398 . " VALUES ($repo_id, $bug_id, $itime, $uid, '$ip'"
399 . ", '" . $e_data['note'] . "')";
400 $res = rg_sql_query($db, $sql);
401 if ($res === FALSE) {
402 rg_bug_set_error("Cannot insert bug note (" . rg_sql_error() . ")");
403 return FALSE;
404 }
405 rg_sql_free_result($res);
726 $itime = time();
727 $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : "?";
406 728
407 rg_prof_end("bug_note_add");
729 $sql = "INSERT INTO bug_notes (repo_id, bug_id, itime, uid, ip"
730 . ", note)"
731 . " VALUES ($repo_id, $bug_id, $itime, $uid, '$ip'"
732 . ", '" . $e_data['note'] . "')";
733 $res = rg_sql_query($db, $sql);
734 if ($res === FALSE) {
735 rg_bug_set_error("Cannot insert bug note (" . rg_sql_error() . ")");
736 break;
737 }
738 rg_sql_free_result($res);
739 $ret = TRUE;
740 } while (0);
408 741
409 return TRUE;
742 rg_prof_end("bug_note_add");
743 return $ret;
410 744 } }
411 745
412 746 /* /*
 
... ... function rg_bug_note_add($db, $repo_id, $bug_id, $uid, $data)
415 749 function rg_bug_note_list($db, $repo_id, $bug_id, $offset) function rg_bug_note_list($db, $repo_id, $bug_id, $offset)
416 750 { {
417 751 rg_prof_start("bug_note_list"); rg_prof_start("bug_note_list");
418
419 752 rg_log("bug_note_list: repo_id=$repo_id bug_id=$bug_id"); rg_log("bug_note_list: repo_id=$repo_id bug_id=$bug_id");
420 753
421 // TODO: test if user is allowed to see a note
422
423 $sql = "SELECT * FROM bug_notes"
424 . " WHERE repo_id = $repo_id"
425 . " AND bug_id = $bug_id"
426 . " ORDER BY itime"
427 . " LIMIT 20 OFFSET $offset";
428 $res = rg_sql_query($db, $sql);
429 if ($res === FALSE) {
430 rg_bug_set_error("Cannot select bug notes (" . rg_sql_error() . ")");
431 return FALSE;
432 }
754 $ret = FALSE;
755 do {
756 // TODO: test if user is allowed to see a note
433 757
434 $data = array();
435 while (($row = rg_sql_fetch_array($res))) {
436 $row['creation'] = gmdate("Y-m-d H:i", $row['itime']);
758 $sql = "SELECT * FROM bug_notes"
759 . " WHERE repo_id = $repo_id"
760 . " AND bug_id = $bug_id"
761 . " ORDER BY itime"
762 . " LIMIT 20 OFFSET $offset";
763 $res = rg_sql_query($db, $sql);
764 if ($res === FALSE) {
765 rg_bug_set_error("Cannot select bug notes (" . rg_sql_error() . ")");
766 break;
767 }
437 768
438 $_ui = rg_user_info($db, $row['uid'], "", "");
439 if ($_ui['exists'] == 1)
440 $row['owner'] = $_ui['username'];
441 else
442 $row['owner'] = "?";
769 $ret = array();
770 while (($row = rg_sql_fetch_array($res))) {
771 $row['creation'] = gmdate("Y-m-d H:i", $row['itime']);
443 772
444 $row['HTML:note'] = nl2br($row['note']);
445 unset($row['note']);
773 $_ui = rg_user_info($db, $row['uid'], "", "");
774 if ($_ui['exists'] == 1)
775 $row['owner'] = $_ui['username'];
776 else
777 $row['owner'] = "?";
446 778
447 $data[] = $row;
448 }
449 rg_sql_free_result($res);
779 $row['HTML:note'] = nl2br($row['note']);
780 unset($row['note']);
450 781
451 rg_prof_end("bug_note_list");
782 $ret[] = $row;
783 }
784 rg_sql_free_result($res);
785 } while (0);
452 786
453 return $data;
787 rg_prof_end("bug_note_list");
788 return $ret;
454 789 } }
455 790
456 /* LABELS */
791 /*** LABELS ***/
457 792
458 793 /* /*
459 794 * Build an array from a string of labels * Build an array from a string of labels
 
... ... function rg_bug_label_string2array($s)
462 797 { {
463 798 $ret = array(); $ret = array();
464 799
465 $s = preg_replace('/\r/', ',', $s);
466 $s = preg_replace('/\n/', ',', $s);
800 $s = preg_replace('/[\r\n\t ]/u', ',', $s);
467 801 rg_log("DEBUG: s=[$s]"); rg_log("DEBUG: s=[$s]");
468 802 $list = explode(",", $s); $list = explode(",", $s);
803 rg_log("DEBUG: list: " . rg_array2string($list));
469 804 if (empty($list)) if (empty($list))
470 805 return array(); return array();
471 806
472 807 foreach ($list as $label) { foreach ($list as $label) {
473 $label = trim($label);
474
475 808 if (empty($label)) if (empty($label))
476 809 continue; continue;
477 810
 
... ... function rg_bug_label_diff($a, $b)
511 844 */ */
512 845 function rg_bug_label_get($db, $repo_id, $bug_id) function rg_bug_label_get($db, $repo_id, $bug_id)
513 846 { {
514 $ret = array();
847 rg_prof_start("bug_label_get");
848 rg_log("bug_label_get: repo_id=$repo_id bug_id=$bug_id");
515 849
516 $sql = "SELECT DISTINCT label FROM bug_labels"
517 . " WHERE repo_id = $repo_id"
518 . " AND bug_id = $bug_id";
519 $res = rg_sql_query($db, $sql);
520 if ($res === FALSE) {
521 rg_bug_set_error("Cannot select labels (" . rg_sql_error() . ")");
522 return FALSE;
523 }
524 while (($row = rg_sql_fetch_array($res)))
525 $ret[] = $row['label'];
526 rg_sql_free_result($res);
850 $ret = FALSE;
851 do {
852 $sql = "SELECT DISTINCT label FROM bug_labels"
853 . " WHERE repo_id = $repo_id"
854 . " AND bug_id = $bug_id"
855 . " ORDER BY label";
856 $res = rg_sql_query($db, $sql);
857 if ($res === FALSE) {
858 rg_bug_set_error("Cannot select labels (" . rg_sql_error() . ")");
859 break;
860 }
861 $ret = array();
862 while (($row = rg_sql_fetch_array($res)))
863 $ret[] = $row['label'];
864 rg_sql_free_result($res);
865 } while(0);
527 866
867 rg_prof_end("bug_label_get");
528 868 return $ret; return $ret;
529 869 } }
530 870
 
... ... function rg_bug_label_get($db, $repo_id, $bug_id)
534 874 function rg_bug_label_insert($db, $repo_id, $bug_id, $labels) function rg_bug_label_insert($db, $repo_id, $bug_id, $labels)
535 875 { {
536 876 rg_prof_start("bug_label_insert"); rg_prof_start("bug_label_insert");
877 rg_log("bug_label_insert: repo_id=$repo_id bug_id=$bug_id labels=$labels");
537 878
538 $labels = rg_bug_label_string2array($labels);
539 rg_log("DEBUG: labels: " . rg_array2string($labels));
540 if (empty($labels))
541 return TRUE;
879 $ret = FALSE;
880 do {
881 $labels = rg_bug_label_string2array($labels);
882 rg_log("DEBUG: labels: " . rg_array2string($labels));
883 if (empty($labels)) {
884 $ret = TRUE;
885 break;
886 }
542 887
543 $existing = rg_bug_label_get($db, $repo_id, $bug_id);
544 rg_log("DEBUG: existing: " . rg_array2string($existing));
545 if ($existing === FALSE)
546 return FALSE;
888 $existing = rg_bug_label_get($db, $repo_id, $bug_id);
889 rg_log("DEBUG: existing: " . rg_array2string($existing));
890 if ($existing === FALSE)
891 break;
547 892
548 $diff = rg_bug_label_diff($labels, $existing);
549 rg_log("DEBUG: diff: " . rg_array2string($diff));
550 if (empty($diff))
551 return TRUE;
893 $diff = rg_bug_label_diff($labels, $existing);
894 rg_log("DEBUG: diff: " . rg_array2string($diff));
895 if (empty($diff)) {
896 $ret = TRUE;
897 break;
898 }
552 899
553 $ret = TRUE;
554 foreach ($diff as $label) {
555 $e_label = rg_sql_escape($db, $label);
900 $list = array();
901 foreach ($diff as $label) {
902 $e_label = rg_sql_escape($db, $label);
903 $list[] = "($repo_id, $bug_id, '$e_label')";
904 }
556 905 $sql = "INSERT INTO bug_labels (repo_id, bug_id, label)" $sql = "INSERT INTO bug_labels (repo_id, bug_id, label)"
557 . " VALUES ($repo_id, $bug_id, '$e_label')";
906 . " VALUES " . implode(",", $list);
558 907 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
559 908 if ($res === FALSE) { if ($res === FALSE) {
560 rg_bug_set_error("Cannot insert label (" . rg_sql_error() . ")");
561 $ret = FALSE;
909 rg_bug_set_error("Cannot insert labels (" . rg_sql_error() . ")");
562 910 break; break;
563 911 } }
564 912 rg_sql_free_result($res); rg_sql_free_result($res);
565 }
913 $ret = TRUE;
914 } while (0);
566 915
567 916 rg_prof_end("bug_label_insert"); rg_prof_end("bug_label_insert");
568
569 917 return $ret; return $ret;
570 918 } }
571 919
 
... ... function rg_bug_label_insert($db, $repo_id, $bug_id, $labels)
574 922 */ */
575 923 function rg_bug_label_html($db, $repo_id, $bug_id) function rg_bug_label_html($db, $repo_id, $bug_id)
576 924 { {
925 rg_prof_start("bug_label_html");
926
577 927 $labels = rg_bug_label_get($db, $repo_id, $bug_id); $labels = rg_bug_label_get($db, $repo_id, $bug_id);
578 928
929 $a = array();
579 930 if (!empty($labels)) { if (!empty($labels)) {
580 $a = array();
581 931 foreach ($labels as $label) foreach ($labels as $label)
582 $a[] = array("label" => $label);
932 $a[] = array("HTML:label" => $label);
583 933 } }
584 934
585 return rg_template_table("repo/bug/list_labels", $a, array());
935 $ret = rg_template_table("repo/bug/list_labels", $a, array());
936
937 rg_prof_end("bug_label_html");
938 return $ret;
586 939 } }
587 940
588 941 ?> ?>
File inc/feedback/suggestion.php changed (mode: 100644) (index d9345b1..1b34a83)
... ... if ($doit == 1) {
10 10 $email = rg_var_str("email"); $email = rg_var_str("email");
11 11 $suggestion = rg_var_str("suggestion"); $suggestion = rg_var_str("suggestion");
12 12
13 while (1) {
13 do {
14 14 if (!rg_token_valid($db, $sid, $token)) { if (!rg_token_valid($db, $sid, $token)) {
15 15 $errmsg[] = "invalid token; try again"; $errmsg[] = "invalid token; try again";
16 16 break; break;
 
... ... if ($doit == 1) {
34 34
35 35 $show_form = 0; $show_form = 0;
36 36 $_suggestion .= "Thank you very much!"; $_suggestion .= "Thank you very much!";
37 break;
38 }
37 } while (0);
39 38 } else { } else {
40 39 $email = ""; $email = "";
41 40 $suggestion = ""; $suggestion = "";
File inc/log.inc.php changed (mode: 100644) (index 0c6640f..08fa1d5)
... ... function rg_log_set_file($file)
18 18 $rg_log_file = $file; $rg_log_file = $file;
19 19 } }
20 20
21 /*
22 * Transforms strange chars to hexa
23 */
24 function rg_log_callback($matches)
25 {
26 $n = pack("a*", $matches[0]);
27 $tmp = unpack("H*", $n);
28 return "[" . $tmp[1] . "]";
29 }
30
31 21 function rg_log($str) function rg_log($str)
32 22 { {
33 23 global $rg_log_file; global $rg_log_file;
 
... ... function rg_log($str)
47 37 $buf0 = gmdate("Y-m-d H:i:s", $t['sec']) . "." . sprintf("%03u", $t['usec'] / 1000); $buf0 = gmdate("Y-m-d H:i:s", $t['sec']) . "." . sprintf("%03u", $t['usec'] / 1000);
48 38 $buf0 .= " " . $rg_log_sid . " "; $buf0 .= " " . $rg_log_sid . " ";
49 39 $buf = ""; $buf = "";
50 $str = preg_replace_callback('/[^\pL\pN\pP\pS \t]/uU', "rg_log_callback", $str);
40 $str = preg_replace_callback('/[^\pL\pN\pP\pS \t]/uU', "rg_callback_hexa", $str);
51 41 $buf .= $buf0 . $str . "\n"; $buf .= $buf0 . $str . "\n";
52 42
53 43 if ($rg_log_fd !== NULL) if ($rg_log_fd !== NULL)
File inc/struct.inc.php changed (mode: 100644) (index d7cf83a..30775b4)
... ... $rg_sql_struct[6]['tables'] = array(
135 135 . ", ip TEXT NOT NULL" . ", ip TEXT NOT NULL"
136 136 . ", title TEXT NOT NULL" . ", title TEXT NOT NULL"
137 137 . ", body TEXT NOT NULL" . ", body TEXT NOT NULL"
138 . ", state SMALLINT NOT NULL"
138 139 . ", assigned_uid INT NOT NULL" . ", assigned_uid INT NOT NULL"
139 140 . ", deleted INT NOT NULL" . ", deleted INT NOT NULL"
140 141 . ")", . ")",
 
... ... $rg_sql_struct[6]['other'] = array(
163 164 . " ON bug_labels (repo_id, bug_id)" . " ON bug_labels (repo_id, bug_id)"
164 165 ); );
165 166
167 $rg_sql_struct[7] = array();
168 $rg_sql_struct[7]['tables'] = array(
169 "bug_search" => "CREATE TABLE bug_search ("
170 . "repo_id INT NOT NULL"
171 . ", uid INT NOT NULL"
172 . ", name TEXT NOT NULL"
173 . ", data TEXT NOT NULL"
174 . ")"
175 );
176 $rg_sql_struct[7]['other'] = array(
177 "bug_search_repo_id_uid" => "CREATE INDEX bug_search_i_repo_id_uid"
178 . " ON bug_search(repo_id, uid)"
179 );
180
166 181 // This must be the last line // This must be the last line
167 182 $rg_sql_schema_ver = count($rg_sql_struct); $rg_sql_schema_ver = count($rg_sql_struct);
168 183
File inc/user/create.php changed (mode: 100644) (index c2f26bf..263c7c1)
... ... if ($doit == 1) {
20 20 $xpass2 = rg_var_str("xpass2"); $xpass2 = rg_var_str("xpass2");
21 21 $session_time = rg_var_uint("session_time"); $session_time = rg_var_uint("session_time");
22 22
23 while (1) {
23 do {
24 24 if (strcmp($xpass, $xpass2) != 0) { if (strcmp($xpass, $xpass2) != 0) {
25 25 $errmsg[] = "password are not the same"; $errmsg[] = "password are not the same";
26 26 break; break;
 
... ... if ($doit == 1) {
61 61
62 62 $show_form = 0; $show_form = 0;
63 63 $_create .= "Check your e-mail and follow the link inside."; $_create .= "Check your e-mail and follow the link inside.";
64 break;
65 }
64 } while (0);
66 65 } else { } else {
67 66 $xuser = ""; $xuser = "";
68 67 $realname = ""; $realname = "";
File inc/user/info/info.php changed (mode: 100644) (index b68994f..d883155)
... ... if ($doit == 1) {
19 19 $rights = $rg_ui['rights']; $rights = $rg_ui['rights'];
20 20 $session_time = rg_var_uint("session_time"); $session_time = rg_var_uint("session_time");
21 21
22 while (1) {
22 do {
23 23 $_u = array(); $_u = array();
24 24 $_u['uid'] = $rg_ui['uid']; $_u['uid'] = $rg_ui['uid'];
25 25 $_u['username'] = $xuser; $_u['username'] = $xuser;
 
... ... if ($doit == 1) {
36 36 } }
37 37
38 38 $_info .= "Information was updated!<br />"; $_info .= "Information was updated!<br />";
39 break;
40 }
39 } while (0);
41 40 } else { } else {
42 41 $xuser = $rg_ui['username']; $xuser = $rg_ui['username'];
43 42 $realname = $rg_ui['realname']; $realname = $rg_ui['realname'];
File inc/user/pass/pass.php changed (mode: 100644) (index 5f18947..7b7c9c1)
... ... if ($doit == 1) {
11 11 $pass1 = rg_var_str("pass1"); $pass1 = rg_var_str("pass1");
12 12 $pass2 = rg_var_str("pass2"); $pass2 = rg_var_str("pass2");
13 13
14 while (1) {
14 do {
15 15 if (!rg_token_valid($db, $sid, $token)) { if (!rg_token_valid($db, $sid, $token)) {
16 16 $errmsg[] = "invalid token; try again"; $errmsg[] = "invalid token; try again";
17 17 break; break;
 
... ... if ($doit == 1) {
34 34
35 35 $_pass .= "Password was changed with success!<br />"; $_pass .= "Password was changed with success!<br />";
36 36 $show_form = 0; $show_form = 0;
37 break;
38 }
37 } while (0);
39 38 } }
40 39
41 40 if ($show_form == 1) { if ($show_form == 1) {
File inc/user/repo/bug/add/add.php changed (mode: 100644) (index 0dc7471..50efdb4)
1 1 <?php <?php
2 rg_log("/inc/repo/bug/add/add");
2 rg_log("/inc/user/repo/bug/add/add");
3 3
4 4 $bug_more = $_more; $bug_more = $_more;
5 5 $_bug_add = ""; $_bug_add = "";
 
... ... if ($doit == 0) {
10 10 // defaults // defaults
11 11 $_x['title'] = ""; $_x['title'] = "";
12 12 $_x['body'] = ""; $_x['body'] = "";
13 $_x['state'] = 1;
13 14 $_x['labels'] = ""; $_x['labels'] = "";
14 15 $_x['assigned_to'] = 0; $_x['assigned_to'] = 0;
15 16 } else { } else {
16 17 $_x['title'] = rg_var_str("title"); $_x['title'] = rg_var_str("title");
17 18 $_x['body'] = rg_var_str("body"); $_x['body'] = rg_var_str("body");
19 $_x['state'] = rg_var_uint("state");
18 20 $_x['labels'] = rg_var_str("labels"); $_x['labels'] = rg_var_str("labels");
19 21 $_x['assigned_uid'] = 0; $_x['assigned_uid'] = 0;
20 22
21 while (1) {
23 do {
22 24 if (!rg_token_valid($db, $sid, rg_var_str("token"))) { if (!rg_token_valid($db, $sid, rg_var_str("token"))) {
23 25 $bug_errmsg[] = "Invalid token. Try again."; $bug_errmsg[] = "Invalid token. Try again.";
24 26 break; break;
 
... ... if ($doit == 0) {
34 36 break; break;
35 37 } }
36 38
39 if (($_x['state'] < 1) || ($_x['state'] > 3)) {
40 $bug_errmsg[] = "State is not valid.";
41 break;
42 }
43
37 44 $bug_id = rg_bug_add($db, $ri['repo_id'], $ui['uid'], $_x); $bug_id = rg_bug_add($db, $ri['repo_id'], $ui['uid'], $_x);
38 45 if ($bug_id === FALSE) { if ($bug_id === FALSE) {
39 46 $bug_errmsg[] = "Cannot add bug (" . rg_bug_error() . ")."; $bug_errmsg[] = "Cannot add bug (" . rg_bug_error() . ").";
 
... ... if ($doit == 0) {
43 50 // redirect to bug home // redirect to bug home
44 51 $url = rg_re_bugpage($rg_ui, $ri, $bug_id); $url = rg_re_bugpage($rg_ui, $ri, $bug_id);
45 52 rg_redirect($url); rg_redirect($url);
46 }
53 } while (0);
47 54 } }
48 55
49 56 $bug_more = array_merge($bug_more, $_x); $bug_more = array_merge($bug_more, $_x);
 
... ... $bug_more['HTML:bug_errmsg'] = rg_template_errmsg($bug_errmsg);
51 58 $bug_more['bug_action'] = "Add bug"; $bug_more['bug_action'] = "Add bug";
52 59 $bug_more['rg_action'] = rg_re_post($cop); $bug_more['rg_action'] = rg_re_post($cop);
53 60 $bug_more['rg_form_token'] = rg_token_get($db, $sid); $bug_more['rg_form_token'] = rg_token_get($db, $sid);
61 $bug_more['HTML:state_select'] = rg_bug_state_select($_x['state']);
54 62 $_bug_add .= rg_template("repo/bug/bug_add.html", $bug_more); $_bug_add .= rg_template("repo/bug/bug_add.html", $bug_more);
55 63 ?> ?>
File inc/user/repo/bug/main.php changed (mode: 100644) (index 4ef8ebf..71fdb4d)
... ... rg_log("/inc/user/repo/bug/main");
3 3
4 4 $_bug_body = ""; $_bug_body = "";
5 5
6 $_op = isset($paras[0]) ? $paras[0] : "";
6 $_more['can_save'] = $rg_ui['uid'] > 0 ? 1 : 0;
7
8 $_op = empty($paras) ? "list" : array_shift($paras);
7 9 switch ($_op) { switch ($_op) {
10 case 'search':
11 include($INC . "/user/repo/bug/search/search.php");
12 $_bug_body .= $_bug_search;
13 break;
14
8 15 case 'add': case 'add':
9 16 include($INC . "/user/repo/bug/add/add.php"); include($INC . "/user/repo/bug/add/add.php");
10 17 $_bug_body .= $_bug_add; $_bug_body .= $_bug_add;
11 18 break; break;
12 19
13 case '': /* list */
14 $r = rg_bug_list($db, $_more['url_repo'], $ri['repo_id']);
20 case 'list': /* list */
21 $_search = empty($paras) ? "All" : array_shift($paras);
22
23 $_url = rg_re_repopage($ui, $ri['name']) . "/bug";
24
25 // Somebody pressed "Remove" button?
26 if (rg_var_uint("remove") == 1) {
27 $token = rg_var_str("token");
28 if (!rg_token_valid($db, $sid, $token)) {
29 $_bug_body .= "Error: invalid token. Try again."; // TODO
30 exit(1); // security_violation!
31 }
32
33 $r = rg_bug_search_remove($db, $ri['repo_id'], $rg_ui['uid'],
34 $_search);
35 if ($r === FALSE)
36 $_bug_body .= "Error: cannot delete search!"; // TODO
37 }
38
39 $r = rg_bug_search_load_all($db, $ri['repo_id'], $rg_ui['uid'], $_url);
40 if ($r === FALSE) {
41 $_bug_body .= "Error: cannot load all searches!"; // TODO
42 } else {
43 $_bug_body .= rg_template_table("repo/bug/search/list",
44 $r, $_more);
45 }
46
47 $filter = rg_bug_search_load($db, $ri['repo_id'], $rg_ui['uid'], $_search);
48 if ($filter === FALSE) {
49 $_bug_body .= "Error: cannot load search!"; // TODO
50 $filter = array();
51 }
52
53 if (isset($filter['name']))
54 $_more['search_name'] = $filter['name'];
55
56 $r = rg_bug_search($db, $_more['url_repo'], $ri['repo_id'],
57 $rg_ui['uid'], $filter);
15 58 if ($r === FALSE) if ($r === FALSE)
16 $_bug_body .= "Error!"; // TODO: do something OK here!
59 $_bug_body .= "Error: Cannot search bugs!"; // TODO: do something OK here!
17 60 else else
18 61 $_bug_body .= $r; $_bug_body .= $r;
62
63 // Show remove for custom search
64 if (isset($filter['standard']) && ($filter['standard'] == 0)) {
65 $_remove_more = $_more;
66 $_remove_more['rg_action'] = $_url . "/list/" . $filter['name'];
67 $_remove_more['rg_form_token'] = rg_token_get($db, $sid);
68 $_remove_more['search_remove_errmsg'] = "";
69 $_bug_body .= rg_template("repo/bug/search/remove.html",
70 $_remove_more);
71 }
19 72 break; break;
20 73
21 74 default: // go directly to a bug default: // go directly to a bug
File inc/user/repo/bug/search/search.php added (mode: 100644) (index 0000000..484e520)
1 <?php
2 rg_log("/inc/user/repo/bug/search/search");
3
4 $_my_more = $_more;
5 $_bug_search = "";
6 $bug_errmsg = array();
7
8 $_x = array();
9 if ($doit == 0) {
10 // defaults
11 $_x['reported_by'] = "";
12 $_x['assigned_to'] = "";
13 $_x['state'] = 0;
14 $_x['order_by'] = "";
15 $_x['include'] = "";
16 $_x['exclude'] = "";
17 $_x['start'] = "";
18 $_x['end'] = "";
19 $_x['title_string'] = "";
20 $_x['body_string'] = "";
21 $_x['bugs_per_page'] = 25;
22 $_x['global'] = 0;
23 $_x['name'] = "";
24 } else {
25 $_x['reported_by'] = rg_var_str("reported_by");
26 $_x['assigned_to'] = rg_var_str("assigned_to");
27 $_x['state'] = rg_var_uint("state");
28 $_x['order_by'] = rg_var_str("order_by");
29 $_x['include'] = rg_var_str("include");
30 $_x['exclude'] = rg_var_str("exclude");
31 $_x['start'] = rg_var_str("start");
32 $_x['end'] = rg_var_str("end");
33 $_x['title_string'] = rg_var_str("title_string");
34 $_x['body_string'] = rg_var_str("body_string");
35 $_x['bugs_per_page'] = rg_var_uint("bugs_per_page");
36 $_x['global'] = rg_var_uint("global");
37 $_x['name'] = rg_var_str("name");
38
39 do {
40 /*
41 if (empty($_x['title'])) {
42 $bug_errmsg[] = "Title too short.";
43 break;
44 }
45 */
46
47 $bugs = rg_bug_search($db, $_more['url_repo'], $ri['repo_id'],
48 $rg_ui['uid'], $_x);
49 if ($bugs === FALSE) {
50 $bug_errmsg[] = "Cannot search bug (" . rg_bug_error() . ").";
51 break;
52 }
53
54 // Show bugs
55 $_bug_search .= $bugs;
56 } while (0);
57 }
58
59 $_my_more = array_merge($_my_more, $_x);
60 $_my_more['HTML:bug_errmsg'] = rg_template_errmsg($bug_errmsg);
61 $_my_more['rg_action'] = rg_re_post($cop);
62 $_my_more['HTML:state_select'] = rg_bug_state_select($_x['state']);
63 $_bug_search .= rg_template("repo/bug/bug_search.html", $_my_more);
64 ?>
File inc/user/repo/bug/show.php changed (mode: 100644) (index 32efe9c..18b1972)
... ... rg_log("/inc/user/repo/bug/show");
3 3
4 4 $_bug_show = ""; $_bug_show = "";
5 5
6 $_my_more = $_more;
7 $_my_more['bug_id'] = $bug_id;
8
6 9 $ibug = rg_bug_info($db, $ri['repo_id'], $bug_id); $ibug = rg_bug_info($db, $ri['repo_id'], $bug_id);
7 if ($ibug['exists'] != 1)
8 die("TODO: Invalid bug (" . rg_bug_error() . ")!"); // TODO: do not use die!
10 if ($ibug === FALSE)
11 rg_fatal("Cannot lookup bug!");
12 if ($ibug['exists'] != 1) {
13 $_bug_body .= rg_template("repo/bug/not_found.html", $_my_more);
14 return;
15 }
9 16
10 $_tmp = array_merge($_more, $ibug);
17 $_my_more = array_merge($_my_more, $ibug);
11 18
12 19 // insert? // insert?
13 20 $doit = rg_var_uint("doit"); $doit = rg_var_uint("doit");
14 21 $note_errmsg = array(); $note_errmsg = array();
15 22 if ($doit == 0) { if ($doit == 0) {
16 23 // default values // default values
17 $_tmp['note'] = "";
24 $_my_more['note'] = "";
18 25 } else { } else {
19 while (1) {
26 do {
20 27 $token = rg_var_str("token"); $token = rg_var_str("token");
21 28 $note = rg_var_str("note"); $note = rg_var_str("note");
22 29
 
... ... if ($doit == 0) {
40 47 } }
41 48
42 49 // prepare form for other note // prepare form for other note
43 $_tmp['note'] = "";
44 break;
45 }
50 $_my_more['note'] = "";
51 } while (0);
46 52 } }
47 53
48 54 // load labels // load labels
49 55 $labels = rg_bug_label_get($db, $ri['repo_id'], $bug_id); $labels = rg_bug_label_get($db, $ri['repo_id'], $bug_id);
50 56 if ($labels === FALSE) if ($labels === FALSE)
51 $_tmp['HTML:labels'] = "Cannot load labels!";
57 $_my_more['HTML:labels'] = "Cannot load labels!";
52 58 else else
53 $_tmp['HTML:labels'] = rg_bug_label_html($db, $ri['repo_id'], $bug_id);
59 $_my_more['HTML:labels'] = rg_bug_label_html($db, $ri['repo_id'], $bug_id);
54 60
55 61 // load notes // load notes
56 62 $notes = rg_bug_note_list($db, $ri['repo_id'], $bug_id, 0); $notes = rg_bug_note_list($db, $ri['repo_id'], $bug_id, 0);
57 63 if ($notes === FALSE) if ($notes === FALSE)
58 $_tmp['HTML:notes'] = "Cannot load notes!";
64 $_my_more['HTML:notes'] = "Cannot load notes!";
59 65 else else
60 $_tmp['HTML:notes'] = rg_template_table("repo/bug/list_note", $notes, array());
66 $_my_more['HTML:notes'] = rg_template_table("repo/bug/list_note", $notes, $_my_more);
61 67
62 68 // add note form // add note form
63 $_tmp['HTML:note_errmsg'] = rg_template_errmsg($note_errmsg);
69 $_my_more['HTML:note_errmsg'] = rg_template_errmsg($note_errmsg);
64 70
65 $_tmp['rg_action'] = rg_re_post($cop);
66 $_tmp['rg_form_token'] = rg_token_get($db, $sid);
67 $_tmp['HTML:note_add'] = rg_template("repo/bug/note_add.html", $_tmp);
71 $_my_more['rg_action'] = rg_re_post($cop);
72 $_my_more['rg_form_token'] = rg_token_get($db, $sid);
73 $_my_more['HTML:note_add'] = rg_template("repo/bug/note_add.html", $_my_more);
68 74
69 $_bug_show .= rg_template("repo/bug/show.html", $_tmp);
75 $_bug_show .= rg_template("repo/bug/show.html", $_my_more);
70 76 ?> ?>
File inc/user/repo/delete/delete.php changed (mode: 100644) (index 151293d..fab6c27)
... ... $_delete = "";
5 5
6 6 $errmsg = array(); $errmsg = array();
7 7
8 while (1) {
8 do {
9 9 $r = rg_repo_delete($db, $ri['repo_id'], $rg_ui); $r = rg_repo_delete($db, $ri['repo_id'], $rg_ui);
10 10 if ($r === FALSE) { if ($r === FALSE) {
11 11 $errmsg[] = rg_repo_error(); $errmsg[] = rg_repo_error();
12 12 break; break;
13 13 } }
14
15 break;
16 }
14 } while (0);
17 15
18 16 $_err = implode("<br />\n", $errmsg); $_err = implode("<br />\n", $errmsg);
19 17 if (!empty($_err)) { if (!empty($_err)) {
File inc/user/repo/edit/edit.php changed (mode: 100644) (index c3bfe96..b554608)
... ... if ($doit == 1) {
20 20 $description = rg_var_str("description"); $description = rg_var_str("description");
21 21 $rights = @rg_rights_a2s($_REQUEST['rights']); $rights = @rg_rights_a2s($_REQUEST['rights']);
22 22
23 while (1) {
23 do {
24 24 // lookup user // lookup user
25 25 $_ui = rg_user_info($db, 0, $rr['user'], ""); $_ui = rg_user_info($db, 0, $rr['user'], "");
26 26 if ($_ui['ok'] != 1) { if ($_ui['ok'] != 1) {
 
... ... if ($doit == 1) {
44 44
45 45 $_edit .= "The repository was updated with success!"; $_edit .= "The repository was updated with success!";
46 46 $_show_form = 0; $_show_form = 0;
47
48 break;
49 }
47 } while (0);
50 48 } else { } else {
51 49 // load variables // load variables
52 50 $repo_id = $ri['repo_id']; $repo_id = $ri['repo_id'];
File inc/util.inc.php changed (mode: 100644) (index a58816b..94791fa)
... ... function rg_image_callback($matches)
367 367 */ */
368 368 function rg_prepare_image($line) function rg_prepare_image($line)
369 369 { {
370 return preg_replace_callback('/@@IMG:(.*)@@/U', "rg_image_callback", $line);
370 return preg_replace_callback('/@@IMG:(.*)@@/uU', "rg_image_callback", $line);
371 371 } }
372 372
373 373 /* /*
374 374 * Replace conditionals * Replace conditionals
375 * @@if(X)_@@A@@_@@B@@ - if X is 0 will return @@B@@, else @@A@@
375 * @@if(X){{@@A@@}}{{@@B@@}} - if X is 0 will return @@B@@, else @@A@@
376 376 */ */
377 377 function rg_prepare_conditionals(&$data, &$what, &$values) function rg_prepare_conditionals(&$data, &$what, &$values)
378 378 { {
379 $what['false'] = "/@@if\(0\){{(.*)}}{{(.*)}}/U";
380 $values['false'] = "\\2";
379 // we need greedy (!U) here to take care of cascading ifs
380 // TODO: probably we need to repeat the replace?
381 $what['false'] = "/@@if\(0\){{(.*)}}{{(.*)}}/su";
382 $values['false'] = '$2';
381 383
382 $what['true'] = "/@@if\(.*\){{(.*)}}{{(.*)}}/U";
383 $values['true'] = "\\1";
384 // For condition, we must be non greedy!
385 $what['true'] = "/@@if\(.*?\){{(.*)}}{{(.*)}}/su";
386 $values['true'] = '$1';
384 387 } }
385 388
386 389 function rg_prepare_replace(&$data, &$what, &$values) function rg_prepare_replace(&$data, &$what, &$values)
 
... ... function rg_redirect($url)
582 585 exit(0); exit(0);
583 586 } }
584 587
588 /*
589 * Transforms strange chars to hexa
590 */
591 function rg_callback_hexa($matches)
592 {
593 $n = pack("a*", $matches[0]);
594 $tmp = unpack("H*", $n);
595 return "[" . $tmp[1] . "]";
596 }
597
585 598 /* /*
586 599 * Transforms an array in a string * Transforms an array in a string
587 600 */ */
 
... ... function rg_array2string($a)
593 606 if (empty($a)) if (empty($a))
594 607 return ""; return "";
595 608
596 $what = array("/\n/", "/\r/");
597 $values = array("\\n", "\\r");
609 $what = array("/[^\pL\pN\pP\pS ]/uU");
598 610
599 611 $ret = ""; $ret = "";
600 612 $add = ""; $add = "";
601 613 foreach ($a as $k => $v) { foreach ($a as $k => $v) {
602 614 if (is_array($v)) if (is_array($v))
603 $s = "[" . rg_array2string($v) . "]";
615 $s = rg_array2string($v);
604 616 else else
605 $s = preg_replace($what, $values, $v);
606 $ret .= $add . "$k=$s";
617 $s = preg_replace_callback($what, "rg_callback_hexa", $v);
618 $ret .= $add . "$k=[$s]";
607 619 $add = " "; $add = " ";
608 620 } }
609 621
 
... ... function rg_shutdown_error()
735 747 rg_error_handler($a['type'], $a['message'], $a['file'], $a['line']); rg_error_handler($a['type'], $a['message'], $a['file'], $a['line']);
736 748 } }
737 749
750 /*
751 * YYYY-MM-DD -> timestamp
752 */
753 function rg_date2ts($s)
754 {
755 rg_log("rg_date2ts s=[$s]");
756
757 if (strlen($s) != 10)
758 return FALSE;
759
760 $f = explode("-", $s);
761
762 if (count($f) != 3)
763 return FALSE;
764
765 return gmmktime(0, 0, 0, $f[1], $f[2], $f[0]);
766 }
767
768 /*
769 * YYYY-MM-DD -> timestamp (last second of the day)
770 */
771 function rg_date2ts_last_second($s)
772 {
773 rg_log("rg_date2ts_last_second s=[$s]");
774
775 if (strlen($s) != 10)
776 return FALSE;
777
778 $f = explode("-", $s);
779
780 if (count($f) != 3)
781 return FALSE;
782
783 return gmmktime(0, 0, 0, $f[1], $f[2] + 1, $f[0]) - 1;
784 }
785
738 786 ?> ?>
File root/index.php changed (mode: 100644) (index 3b1b94a..69e7116)
... ... rg_log("_COOKIE: " . rg_array2string($_COOKIE));
82 82 rg_log("Start! cop=[$cop] op=$op subop=$subop subsubop=$subsubop" rg_log("Start! cop=[$cop] op=$op subop=$subop subsubop=$subsubop"
83 83 . " doit=$doit sid=$sid rr: " . rg_array2string($rr)); . " doit=$doit sid=$sid rr: " . rg_array2string($rr));
84 84 rg_log("paras: " . implode("|", $paras)); rg_log("paras: " . implode("|", $paras));
85 rg_log("DEBUG: locale: " . setlocale(LC_ALL, 0));
86 85
87 86
88 87 // database connection // database connection
 
... ... $more['HTML:rg_theme_url'] = $THEME_URL;
153 152 $more['HTML:rg_body'] = $body; $more['HTML:rg_body'] = $body;
154 153 echo rg_template("index.html", $more); echo rg_template("index.html", $more);
155 154
155 rg_log("DONE!");
156 156 rg_prof_log("rg_log"); rg_prof_log("rg_log");
157 157 ?> ?>
File root/themes/default/hints/repo/anon_push.html changed (mode: 100644) (index 728084b..111ce60)
... ... merge request:<br />
4 4 <code> <code>
5 5 ... clone the repository ...<br /> ... clone the repository ...<br />
6 6 ... make some changes and some commits ...<br /> ... make some changes and some commits ...<br />
7 git push
7 git push<br />
8 8 </code> </code>
File root/themes/default/hints/repo/clone_git.html changed (mode: 100644) (index 64b7498..c8e45d5)
1 1 Clone this repository using git:<br /> Clone this repository using git:<br />
2 2 <code> <code>
3 3 git clone @@git@@ local_dir<br /> git clone @@git@@ local_dir<br />
4 cd local_dir
4 cd local_dir<br />
5 5 </code> </code>
File root/themes/default/hints/repo/clone_ssh.html changed (mode: 100644) (index 5b80b64..fd24385)
1 1 Clone this repository using ssh (do not forget to upload a key):<br /> Clone this repository using ssh (do not forget to upload a key):<br />
2 2 <code> <code>
3 3 git clone @@ssh@@ local_dir<br /> git clone @@ssh@@ local_dir<br />
4 cd local_dir
4 cd local_dir<br />
5 5 </code> </code>
File root/themes/default/hints/repo/merge.html changed (mode: 100644) (index 61535f8..2ecc06b)
1 1 How to merge?<br /> How to merge?<br />
2 2
3 3 <code> <code>
4 git fetch @@url@@ refs/mr/rg_xxxxxxxx
5 git merge ???
4 git fetch @@url@@ refs/mr/rg_xxxxxxxx<br />
5 git merge ???<br />
6 6 </code> </code>
7 7 <br /> <br />
8 8
9 9 How to "see" all merge requests as branches:<br /> How to "see" all merge requests as branches:<br />
10 10 Add, in config file, under the remote you want, a line like this:<br /> Add, in config file, under the remote you want, a line like this:<br />
11 11 <code> <code>
12 fetch = +refs/namespaces/*:refs/remotes/your_remote_name_for_example_origin/mr/*
12 fetch = +refs/namespaces/*:refs/remotes/your_remote_name_for_example_origin/mr/*<br />
13 13 </code> </code>
14 14 After you run a git fetch, you will have all the merge requests localy.<br /> After you run a git fetch, you will have all the merge requests localy.<br />
15 15 You can do ??? You can do ???
File root/themes/default/hints/repo/remote_add.html added (mode: 100644) (index 0000000..46ffbaf)
1 You have the project locally, but not in a Git repository:<br />
2 <code>
3 cd local_dir<br />
4 git init<br />
5 git remote add origin @@ssh@@<br />
6 git push origin master<br />
7 </code>
8 <br />
9
10 If you are switching from another Git hosting provider:<br />
11 <code>
12 cd local_dir<br />
13 git remote change origin @@ssh@@<br />
14 git push origin master<br />
15 </code>
File root/themes/default/index.html changed (mode: 100644) (index a8d2c8d..e393d90)
24 24 </div> </div>
25 25 </div> <!-- header --> </div> <!-- header -->
26 26
27 <div id="main">
27 <div id="main_container">
28 <div id="main">
28 29 @@rg_body@@ @@rg_body@@
29 </div> <!-- main -->
30 </div> <!-- main -->
31 </div> <!-- main_container -->
30 32
31 33 <div id="footer"> <div id="footer">
32 34 <div style="float: left; padding: 5px;"> <div style="float: left; padding: 5px;">
File root/themes/default/repo/bug/bug_add.html changed (mode: 100644) (index c8f6f6a..b99eeaf)
18 18 <br /> <br />
19 19 <br /> <br />
20 20
21 <label for="state" class="form_item_title">State</label><br />
22 @@state_select@@
23 <br />
24 <br />
25
21 26 <label for="labels" class="form_item_title">Labels (comma or Enter separated)</label><br /> <label for="labels" class="form_item_title">Labels (comma or Enter separated)</label><br />
22 27 <textarea name="labels" rows="3" cols="80">@@labels@@</textarea> <textarea name="labels" rows="3" cols="80">@@labels@@</textarea>
23 28 <br /> <br />
File root/themes/default/repo/bug/bug_search.html added (mode: 100644) (index 0000000..0c67033)
1 <div class="formarea">
2
3 <div class="formarea_title">Search bugs</div><br />
4
5 @@bug_errmsg@@
6
7 <form method="post" action="@@rg_action@@">
8 <input type="hidden" name="doit" value="1" />
9
10 <label for="reported_by" class="form_item_title">Reported by</label><br />
11 <input type="text" name="reported_by" value="@@reported_by@@" size="30" />
12 <br />
13 <br />
14
15 <label for="assigned_to" class="form_item_title">Assigned to</label><br />
16 <input type="text" name="assigned_to" value="@@assigned_to@@" size="30" />
17 <br />
18 <br />
19
20 <label for="state" class="form_item_title">State</label><br />
21 @@state_select@@
22 <br />
23 <br />
24
25 <label for="order_by" class="form_item_title">Order by</label><br />
26 <input type="text" name="order_by" value="@@order_by@@" size="40" />
27 <br />
28 <br />
29
30 <label for="start" class="form_item_title">Start date (yyyy-mm-dd)</label><br />
31 <input type="text" name="start" value="@@start@@" size="10" />
32 <br />
33 <br />
34
35 <label for="end" class="form_item_title">End date (yyyy-mm-dd)</label><br />
36 <input type="text" name="end" value="@@end@@" size="10" />
37 <br />
38 <br />
39
40 <label for="title_string" class="form_item_title">Title contains</label><br />
41 <input type="text" name="title_string" value="@@title_string@@" size="40" />
42 <br />
43 <br />
44
45 <label for="body_string" class="form_item_title">Body contains</label><br />
46 <input type="text" name="body_string" value="@@body_string@@" size="40" />
47 <br />
48 <br />
49
50 <label for="bugs_per_page" class="form_item_title">Bugs per page</label><br />
51 <input type="text" name="bugs_per_page" value="@@bugs_per_page@@" size="40" />
52 <br />
53 <br />
54
55 @@if(@@can_save@@){{
56 <label for="global" class="form_item_title">Make this search global?</label><br />
57 <input type="checkbox" name="global" @@if(global){{checked="checked"}}{{}} />
58 <br />
59 <br />
60
61 <label for="body" class="form_item_title">Save search as</label><br />
62 <input type="text" name="name" value="@@name@@" size="40" />
63 <br />
64 <br />
65 }}{{}}
66
67 <input type="submit" name="button" value="Search" />
68
69 </form>
70 </div>
File root/themes/default/repo/bug/list_labels/footer.html changed (mode: 100644) (index 8902b2e..a9b0151)
1 1 </ul> </ul>
2 2 </div> </div>
3 <br />
File root/themes/default/repo/bug/list_note/between.html added (mode: 100644) (index 0000000..cc35a8a)
1 <div style="height: 5px;">
2 </div>
File root/themes/default/repo/bug/list_note/footer.html changed (mode: 100644) (index 000ca4b..04f5b84)
1 </table>
1 </div>
File root/themes/default/repo/bug/list_note/header.html changed (mode: 100644) (index 536924a..3c19d8b)
1 <table>
2 <tr>
3 <th>Creation (UTC)</th>
4 <th>Owner</th>
5 <th>Note</th>
6 </tr>
7
1 <div class="notes">
File root/themes/default/repo/bug/list_note/line.html changed (mode: 100644) (index 9d1825e..ccb8ae8)
1 <tr>
2 <td>@@creation@@</td>
3 <td>@@owner@@</td>
4 <td>@@note@@</td>
5 </tr>
6
1 <div class="note">
2 <b>@@owner@@</b> - @@creation@@
3 <div class="note_body">
4 @@note@@
5 </div>
6 </div>
File root/themes/default/repo/bug/main.html changed (mode: 100644) (index a98cf6b..320e8a7)
2 2 <ul> <ul>
3 3 <li><a href="@@url_repo@@/bug">List</a></li> <li><a href="@@url_repo@@/bug">List</a></li>
4 4 <li><a href="@@url_repo@@/bug/add">Add</a></li> <li><a href="@@url_repo@@/bug/add">Add</a></li>
5 <li><a href="@@url_repo@@/bug/search">Search</a></li>
5 6 </ul> </ul>
6 7 </div> </div>
7 8
File root/themes/default/repo/bug/not_found.html added (mode: 100644) (index 0000000..1d11b35)
1 <div class="warning">
2 Bug <b>@@bug_id@@</b> not found.
3 </div>
File root/themes/default/repo/bug/search/list/footer.html copied from file root/themes/default/repo/urls/footer.html (similarity 100%)
File root/themes/default/repo/bug/search/list/header.html added (mode: 100644) (index 0000000..13457c1)
1 <div class="searches">
2 <ul>
File root/themes/default/repo/bug/search/list/line.html added (mode: 100644) (index 0000000..40decf0)
1 <li>@@name@@</li>
File root/themes/default/repo/bug/search/list/nodata.html copied from file root/themes/default/errmsg/nodata.html (similarity 100%)
File root/themes/default/repo/bug/search/remove.html added (mode: 100644) (index 0000000..b032b77)
1 @@search_remove_errmsg@@
2
3 <form method="post" action="@@rg_action@@">
4 <input type="hidden" name="remove" value="1" />
5 <input type="hidden" name="token" value="@@rg_form_token@@" />
6 <input type="hidden" name="name" value="@@search_name@@" />
7
8 <input type="submit" name="button" value="Remove [@@search_name@@]" />
9 </form>
File root/themes/default/repo/bug/show.html changed (mode: 100644) (index 1691b9e..cc276f2)
11 11 </div> </div>
12 12
13 13 @@labels@@ @@labels@@
14
14 15 @@notes@@ @@notes@@
15 16
16 17 @@note_add@@ @@note_add@@
File root/themes/try3/main.css changed (mode: 100644) (index dfd903b..1d15b50)
... ... body {
7 7 font-family: helvetica, sans-serif; font-family: helvetica, sans-serif;
8 8 font-size: 10pt; font-size: 10pt;
9 9 line-height: 105%; line-height: 105%;
10 background-color: #FFFF99;
10 background-color: #FFFFBB;
11 11 } }
12 12
13 13 table { table {
 
... ... code {
32 32 font-weight: bold; font-weight: bold;
33 33 } }
34 34
35 form input, form textarea {
35 form input, form textarea, form select, form option {
36 36 border: 1px solid #CCCCCC; border: 1px solid #CCCCCC;
37 font-size: 11pt;
38 padding: 5px;
37 font-size: 10pt;
38 padding: 2px;
39 margin: 2px;
39 40 } }
40 41 form input[type="submit"] { font-weight: bold; } form input[type="submit"] { font-weight: bold; }
41 42
 
... ... form input[type="submit"] { font-weight: bold; }
77 78 border-bottom: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;
78 79 } }
79 80
81 #main_container {
82 min-height: 400px;
83 background-color: #EEEEEE;
84 width: 100%;
85 }
86
80 87 #main { #main {
81 88 padding-top: 10px; padding-top: 10px;
82 89 padding-left: 25px; padding-left: 25px;
83 padding-bottom: 10px;
84 90 padding-right: 25px; padding-right: 25px;
85 min-height: 400px;
91 padding-bottom: 10px;
86 92 line-height: 120%; line-height: 120%;
87 background-color: #EEEEEE;
88 width: 100%;
89 93 } }
90 94
91 95 #footer { #footer {
 
... ... form input[type="submit"] { font-weight: bold; }
96 100 } }
97 101
98 102 .formarea { .formarea {
103 margin-top: 10px;
99 104 border: 1px solid #CCCCCC; border: 1px solid #CCCCCC;
100 105 padding: 5px; padding: 5px;
101 106 border-radius: 4px 4px 4px 4px; border-radius: 4px 4px 4px 4px;
 
... ... label {
159 164 .submenu { .submenu {
160 165 border: 1px solid #CCCCCC; border: 1px solid #CCCCCC;
161 166 border-bottom: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;
162 background-color: #FFFF99;
167 background-color: #FFFFBB;
163 168 margin-bottom: 3px; margin-bottom: 3px;
164 169 display: table; display: table;
165 170 } }
 
... ... label {
221 226 background-color: #a0d0ff; background-color: #a0d0ff;
222 227 } }
223 228
229 .searches { padding: 3px 0px; margin: 3px 0px; }
230 .searches ul { list-style-type: none; }
231 .searches ul li {
232 display: inline;
233 padding: 3px 3px;
234 text-decoration: none;
235 color: black;
236 border: 1px solid #cccccc;
237 border-radius: 4px 4px 4px 4px;
238 font-size: 9pt;
239 background-color: #a0d0ff;
240 }
241 .searches ul li a {
242 text-decoration: none;
243 }
244
224 245 .hints { .hints {
225 246 margin-top: 5px; margin-top: 5px;
226 247 background-color: #A0FFA0; background-color: #A0FFA0;
 
... ... label {
237 258
238 259
239 260 .bug { .bug {
240 margin-top: 5px;
261 margin-top: 10px;
241 262 } }
242 263 .bug_body { .bug_body {
243 margin-left: 5px;
264 margin-top: 3px;
244 265 background-color: #A0FFA0; background-color: #A0FFA0;
245 266 padding: 5px; padding: 5px;
246 267 border-radius: 4px 4px 4px 4px; border-radius: 4px 4px 4px 4px;
 
... ... label {
249 270 display: table; display: table;
250 271 } }
251 272
273 .notes {
274 margin-top: 10px;
275 display: table;
276 }
277
278 .note {
279 border: 1px solid #cccccc;
280 padding: 3px;
281 background-color: #DDDDDD;
282 }
283 .note_body {
284 padding: 3px;
285 background-color: #EEEEEE;
286 margin-top: 3px;
287 }
288
289 .warning {
290 margin-top: 10px;
291 background-color: #FFAAAA;
292 padding: 5px;
293 border: 1px solid #CCCCCC;
294 display: table;
295 }
296
297 .button {
298 background: -moz-linear-gradient(center top , #A0FFA0 0px, #A0FFA0 100%) repeat scroll 0 0 padding-box transparent;
299 border: 1px solid #CCCCCC;
300 border-radius: 4px 4px 4px 4px;
301 box-shadow: 0 2px 2px #90FF90 inset;
302 color: #90DD90;
303 display: inline-block;
304 font-weight: bold;
305 text-decoration: none;
306 text-shadow: 0 1px 1px #000000;
307
308 font-size: 24px;
309 padding: 8px;
310 }
File samples/config.php changed (mode: 100644) (index 733af1a..fc06ed2)
5 5 $rg_base = "/home/rocketgit"; $rg_base = "/home/rocketgit";
6 6
7 7 // Database // Database
8 $rg_sql = "host=localhost user=rocketgit dbname=rocketgit";
8 $rg_sql = "host=localhost user=rocketgit dbname=rocketgit application_name=rocketgit";
9 9 $rg_sql_debug = 1; $rg_sql_debug = 1;
10 10
11 11 // Session // Session
File tests/bug.php changed (mode: 100644) (index cb7de83..d92ca6d)
... ... if ($r === FALSE) {
49 49 } }
50 50
51 51 $r = rg_bug_info($db, $repo_id, $bug_id); $r = rg_bug_info($db, $repo_id, $bug_id);
52 if ($r['exists'] != 1) {
52 if ($r === FALSE) {
53 53 rg_log("Cannot lookup a bug (" . rg_bug_error() . ")!"); rg_log("Cannot lookup a bug (" . rg_bug_error() . ")!");
54 54 exit(1); exit(1);
55 55 } }
56 if ($r['exists'] != 1) {
57 rg_log("Seems the bug does not exists!");
58 exit(1);
59 }
56 60
57 61 // test a non existing bug // test a non existing bug
58 62 $r = rg_bug_info($db, $repo_id, 0); $r = rg_bug_info($db, $repo_id, 0);
63 if ($r === FALSE) {
64 rg_log("Cannot lookup a bug (" . rg_bug_error() . ")!");
65 exit(1);
66 }
59 67 if ($r['exists'] != 0) { if ($r['exists'] != 0) {
60 68 rg_log("Wrong bug number (0) returned valid data!"); rg_log("Wrong bug number (0) returned valid data!");
61 69 exit(1); exit(1);
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/rocketgit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master