List of commits:
Subject Hash Author Date (UTC)
Bulk updates cad0c710542dc3fb072268eba40b0abe11217fa9 Catalin(ux) M. BOIE 2011-09-21 20:25:23
Bulk changes. d5274ef5f261086a2af6bd19ac04061bb3d55584 Catalin(ux) M. BOIE 2011-09-15 20:16:46
Store the fist instalation date in 'state' table. e4ba8a9239e72e8de5eed0b3bb1f2a5f2d429105 Catalin(ux) M. BOIE 2011-08-31 16:14:44
Bulk changes. 645d3deb19e399c05a8b14dd88c5151520482b6a Catalin(ux) M. BOIE 2011-08-25 20:39:25
Another bulk update - css related. 3867eb5deadf9827450b40a53efe6c83f518a07b Catalin(ux) M. BOIE 2011-07-26 22:01:13
Bulk update. 9d680f000b7c486be4664e1cb944f424c977c874 Catalin(ux) M. BOIE 2011-07-25 19:06:14
Some ssh and anonymous rights fixes. 9bb20c348a4933056d8f67bd151eb35cf0325835 Catalin(ux) M. BOIE 2011-07-05 22:00:00
Another round of fixes. 45749c46f79f75b29d83ee2d115f987c7765e8c4 Catalin(ux) M. BOIE 2011-07-05 20:01:10
Another round of bulk updates. 6077961d5c443b8a830dc08b3b0ebf37eaf594b3 Catalin(ux) M. BOIE 2011-07-04 22:12:40
Bump version to 0.7. e44064dab5c6f2fa625bb121483a51ec1960cad9 Catalin(ux) M. BOIE 2011-07-03 16:26:47
Lots of changes. 8876190d55995ed98a528edc786e0e9136a0535d Catalin(ux) M. BOIE 2011-07-03 00:03:42
Make %setup quiet as rpmlint told me. b272b9915498fb0a811be2e2687554bbaf887bf1 Catalin(ux) M. BOIE 2011-07-01 03:26:57
Bump version to 0.3 f626f3c66b7b51af2013e16e954e945ba84c12bb Catalin(ux) M. BOIE 2011-07-01 03:25:44
Added logrotate support b827ee7c179d5b72f6ac3ac255edb6de6decb91a Catalin(ux) M. BOIE 2011-07-01 03:25:13
More bulk updates 6dc2b24ebde74bbb64ef2893e2ddb8b7b9456219 Catalin(ux) M. BOIE 2011-07-01 03:16:01
Bulk changes e3771b115feb49698383730893ced1bac5670cac Catalin(ux) M. BOIE 2011-06-29 21:50:03
Ignore Changelog-last file. 32260f93743a577cbaf7cefd335517e4a42edcf0 Catalin(ux) M. BOIE 2011-06-27 21:20:53
Ignore *.out files. 265ba83a2df891cdcc7b35801a46cfc2583983ee Catalin(ux) M. BOIE 2011-06-27 21:20:23
Added shadow-utils as dependency fot user/groupadd. f5816c0bd992881439706041986a3a178eaf69bd Catalin(ux) M. BOIE 2011-06-27 21:08:32
More rpm fixes. 701daf680d15dc69a2a8709f6de5167b55ce02c2 Catalin(ux) M. BOIE 2011-06-27 21:01:24
Commit cad0c710542dc3fb072268eba40b0abe11217fa9 - Bulk updates
Author: Catalin(ux) M. BOIE
Author date (UTC): 2011-09-21 20:25
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2011-09-21 20:25
Parent(s): d5274ef5f261086a2af6bd19ac04061bb3d55584
Signing key:
Tree: 9df609e92fa3c4059be47deded81a8f6c581aebf
File Lines added Lines deleted
TODO 11 0
admin/update.php 7 3
inc/admin/users/user.form.php 1 1
inc/db/struct.inc.php 17 9
inc/dispatch/dispatch.php 13 12
inc/feedback/suggestion.form.php 2 2
inc/feedback/suggestion.php 1 1
inc/git.inc.php 373 0
inc/keys.inc.php 35 1
inc/login/login.form.php 1 1
inc/repo.inc.php 64 64
inc/repo/repo.form.php 1 1
inc/repo/repo.php 6 6
inc/repo/repo_page.php 8 8
inc/repo/rights.form.php 1 1
inc/repo/search.form.php 1 1
inc/user.inc.php 16 0
inc/user/create.php 1 1
inc/user/forgot.form.php 1 1
inc/user/forgot_send.form.php 1 1
inc/user/home-page.php 4 6
inc/user/keys/add.form.php 5 5
inc/user/keys/keys.php 16 42
inc/user/pass.form.php 0 42
inc/user/repo-page.php 35 10
inc/util.inc.php 80 10
root/index.php 46 9
root/themes/default/main.css 34 8
root/themes/default/repo/blob.html 6 0
root/themes/default/repo/list/header.html 8 5
root/themes/default/repo/list/line.html 2 2
root/themes/default/repo/log/footer.html 0 0
root/themes/default/repo/log/header.html 10 0
root/themes/default/repo/log/line.html 9 0
root/themes/default/repo/main.html 9 0
root/themes/default/repo/tree/header.html 1 2
root/themes/default/repo/tree/line.html 1 1
samples/config.php 7 5
samples/rg.conf 5 7
scripts/cron.php 8 3
scripts/q.php 54 27
scripts/remote.php 19 8
tests/Makefile 1 1
tests/git.php 1 1
tests/hook_pre-receive.sh 1 1
tests/hook_update.sh 1 1
tests/keys.php 21 0
tests/repo.php 10 7
tests/rights.php 1 1
tests/state.php 1 1
tests/user.php 13 2
tests/util.php 1 1
File TODO changed (mode: 100644) (index 2711216..8d4583b)
79 79 [ ] Smart HTTP transport [ ] Smart HTTP transport
80 80 [ ] Move forget pass token into users table. [ ] Move forget pass token into users table.
81 81 [ ] Audit all error messages to not propage usefull info to an attacker. [ ] Audit all error messages to not propage usefull info to an attacker.
82 Split in two error messages: one for logs and one for user.
82 83 [ ] git-daemon connection - cannot get IP info? setenv? [ ] git-daemon connection - cannot get IP info? setenv?
83 84 [ ] Do not show submenus if user is not logged in on repopage (ialbeascu) [ ] Do not show submenus if user is not logged in on repopage (ialbeascu)
84 85 - duplicate menus?! maybe add an admin link in repopage that goes - duplicate menus?! maybe add an admin link in repopage that goes
 
86 87 [ ] Undo SELinux stuff when uninstalling applications. [ ] Undo SELinux stuff when uninstalling applications.
87 88 [ ] Nice graphic (unrelated to git): http://tctechcrunch2011.files.wordpress.com/2011/07/hadoop2.png?w=640 [ ] Nice graphic (unrelated to git): http://tctechcrunch2011.files.wordpress.com/2011/07/hadoop2.png?w=640
88 89 [ ] git-notes may be used to attach messages to commits. Nice. [ ] git-notes may be used to attach messages to commits. Nice.
90 [ ] Store also the size of the patch aong history/commit info.
91 [ ] Check SELinux MLS
92 [ ] Store users and repositories to /var/lib/rocketgit so we can set a proper
93 SELinux context on that folder.
94 [ ] Test if 'first_install' state is working correctly.
95 [ ] Deal with empty repositories (rg_git_ls_tree etc.).
96 [ ] Show age of an user/org/repo. Example: 1 year, 3 months, 4 days.
97 [ ] The rewrite engine should pass a single op for user and for org, but with para org=0 or 1.
98 This is to have the same page for both types of users.
89 99 [ ] [ ]
90 100
91 101 == Versus == == Versus ==
92 102 * http://www.wikivs.com/wiki/GitHub_vs_Gitorious * http://www.wikivs.com/wiki/GitHub_vs_Gitorious
103 * http://unfuddle.com/about/tour/plans
93 104 * *
94 105
95 106
File admin/update.php changed (mode: 100644) (index acb1a81..05db22d)
... ... require_once($INC . "/db/struct.inc.php");
14 14
15 15 rg_log_set_file("/var/log/rocketgit/update.log"); rg_log_set_file("/var/log/rocketgit/update.log");
16 16
17 echo "RocketGit: upgrading...\n";
18
17 19 $db = rg_sql_open($rg_sql); $db = rg_sql_open($rg_sql);
18 20 if ($db === FALSE) { if ($db === FALSE) {
19 21 echo "Internal error (" . rg_sql_error() . ")!\n"; echo "Internal error (" . rg_sql_error() . ")!\n";
 
... ... if ($db === FALSE) {
24 26 $old_schema_ver = rg_state_get($db, "schema_version"); $old_schema_ver = rg_state_get($db, "schema_version");
25 27 if (empty($old_schema_ver)) if (empty($old_schema_ver))
26 28 $old_schema_ver = 1; $old_schema_ver = 1;
29 echo "RocketGit: old_schema_ver=$old_schema_ver.\n";
27 30
28 31 if (rg_sql_begin($db) !== TRUE) { if (rg_sql_begin($db) !== TRUE) {
29 32 echo "RocketGit: Cannot start transaction (" . rg_sql_error() . ")!\n"; echo "RocketGit: Cannot start transaction (" . rg_sql_error() . ")!\n";
 
... ... $ignore_errors = FALSE;
34 37 $drop_tables = FALSE; $drop_tables = FALSE;
35 38 $r = rg_sql_struct_run($db, $ignore_errors, $drop_tables, $old_schema_ver); $r = rg_sql_struct_run($db, $ignore_errors, $drop_tables, $old_schema_ver);
36 39 if ($r !== TRUE) { if ($r !== TRUE) {
37 echo "rocketgir: Cannot update schema (" . rg_sql_error() . ")!\n";
40 echo "RocketGit: Cannot update schema (" . rg_sql_error() . ")!\n";
38 41 exit(1); exit(1);
39 42 } }
40 43
41 if (rg_state_set("schema_version", $rg_sql_schema_version) !== TRUE) {
42 echo "rocketgir: Cannot set schema_version"
44 if (rg_state_set($db, "schema_version", $rg_sql_schema_ver) !== TRUE) {
45 echo "RocketGit: Cannot set schema_version"
43 46 . " (" . rg_state_error() . ")!\n"; . " (" . rg_state_error() . ")!\n";
44 47 exit(1); exit(1);
45 48 } }
 
... ... if (rg_sql_commit($db) !== TRUE) {
49 52 exit(1); exit(1);
50 53 } }
51 54
55 echo "RocketGit: OK! New schema version is $rg_sql_schema_ver.\n";
52 56 ?> ?>
File inc/admin/users/user.form.php changed (mode: 100644) (index 243ea91..30e55cd)
... ... if (count($errmsg) > 0)
10 10 $_form .= '<span class="error">' . implode("<br />\n", $errmsg) . '</span><br /><br />' . "\n"; $_form .= '<span class="error">' . implode("<br />\n", $errmsg) . '</span><br /><br />' . "\n";
11 11
12 12 $_form .= ' $_form .= '
13 <form method="post" action="' . $_SERVER['PHP_SELF'] . '">
13 <form method="post" action="' . rg_re_post($op) . '">
14 14 <input type="hidden" name="op" value="' . $op . '" /> <input type="hidden" name="op" value="' . $op . '" />
15 15 <input type="hidden" name="subop" value="' . $subop . '" /> <input type="hidden" name="subop" value="' . $subop . '" />
16 16 <input type="hidden" name="subsubop" value="' . $subsubop . '" /> <input type="hidden" name="subsubop" value="' . $subsubop . '" />
File inc/db/struct.inc.php changed (mode: 100644) (index f359fb8..8bd1c99)
1 1 <?php <?php
2 $rg_sql_schema_ver = 1;
3
4 2 $rg_sql_struct = array(); $rg_sql_struct = array();
5 $rg_sql_struct[0] = array();
6 $rg_sql_struct[0]['tables'] = array(
3 $rg_sql_struct[1] = array();
4 $rg_sql_struct[1]['tables'] = array(
7 5 "repos" => "CREATE TABLE repos" "repos" => "CREATE TABLE repos"
8 6 . " (repo_id SERIAL PRIMARY KEY" . " (repo_id SERIAL PRIMARY KEY"
9 7 . ", name TEXT UNIQUE NOT NULL" . ", name TEXT UNIQUE NOT NULL"
 
... ... $rg_sql_struct[0]['tables'] = array(
65 63 . ", sid TEXT NOT NULL" . ", sid TEXT NOT NULL"
66 64 . ", expire INTEGER NOT NULL)" . ", expire INTEGER NOT NULL)"
67 65 ); );
68 $rg_sql_struct[0]['other'] = array();
66 $rg_sql_struct[1]['other'] = array();
69 67
70 $rg_sql_struct[1] = array();
71 $rg_sql_struct[1]['tables'] = array(
68 $rg_sql_struct[2] = array();
69 $rg_sql_struct[2]['tables'] = array(
72 70 "suggestions" => "CREATE TABLE suggestions" "suggestions" => "CREATE TABLE suggestions"
73 71 . " (suggestion_id SERIAL PRIMARY KEY" . " (suggestion_id SERIAL PRIMARY KEY"
74 72 . ", uid INTEGER NOT NULL" . ", uid INTEGER NOT NULL"
75 73 . ", email TEXT NOT NULL" . ", email TEXT NOT NULL"
76 74 . ", suggestion TEXT NOT NULL)" . ", suggestion TEXT NOT NULL)"
77 75 ); );
78 $rg_sql_struct[1]['other'] = array();
76 $rg_sql_struct[2]['other'] = array();
77
78 $rg_sql_struct[3] = array();
79 $rg_sql_struct[3]['tables'] = array();
80 $rg_sql_struct[3]['other'] = array(
81 "add organization field to user" => "ALTER TABLE users"
82 . " ADD organization SMALLINT NOT NULL DEFAULT 0"
83 );
84 $rg_sql_schema_ver = count($rg_sql_struct);
85
86
79 87
80 88 /* /*
81 89 * Generate structure * Generate structure
 
... ... function rg_sql_struct_run($db, $ignore_errors, $drop_tables, $old_schema_ver)
90 98 . " drop_tables=" . ($drop_tables ? "Yes" : "No") . " drop_tables=" . ($drop_tables ? "Yes" : "No")
91 99 . " old_schema_ver=$old_schema_ver..."); . " old_schema_ver=$old_schema_ver...");
92 100
93 for ($i = $old_schema_ver; $i <= $rg_sql_schema_ver; $i++) {
101 for ($i = $old_schema_ver + 1; $i <= $rg_sql_schema_ver; $i++) {
94 102 foreach ($rg_sql_struct[$i] as $type => $sqls) { foreach ($rg_sql_struct[$i] as $type => $sqls) {
95 103 if (count($sqls) == 0) if (count($sqls) == 0)
96 104 continue; continue;
File inc/dispatch/dispatch.php changed (mode: 100644) (index da9dcbd..58f126a)
... ... case 'logout':
17 17 $redispatch = 1; $redispatch = 1;
18 18 $op = "bye"; $op = "bye";
19 19 } else { } else {
20 $body .= "Not OK!";
20 $body .= "Cannot log you out. Please clean all cookies"
21 . " and restart browser!";
21 22 } }
22 23 break; break;
23 24
 
... ... case 'admin':
36 37 $body .= $_admin; $body .= $_admin;
37 38 break; break;
38 39
39 case 'keys':
40 include($INC . "/keys/keys.php");
41 $body .= $_keys;
42 break;
43
44 40 case 'forgot_link': // forgot pass link case 'forgot_link': // forgot pass link
45 41 include($INC . "/user/forgot.php"); include($INC . "/user/forgot.php");
46 42 $body .= $_forgot; $body .= $_forgot;
 
... ... case 'bye':
56 52 $body .= $_bye; $body .= $_bye;
57 53 break; break;
58 54
59 case 'personal':
60 include($INC . "/personal/personal.php");
61 $body .= $_personal;
62 break;
63
64 55 case 'create_account': case 'create_account':
65 56 include($INC . "/user/create.php"); include($INC . "/user/create.php");
66 57 $body .= $_create; $body .= $_create;
 
... ... case 'suggestion':
76 67 $body .= $_suggestion; $body .= $_suggestion;
77 68 break; break;
78 69
70 case 'repo-page':
71 include($INC . "/user/repo-page.php");
72 $body .= $_home;
73 break;
74
75 case 'home-page':
76 include($INC . "/user/home-page.php");
77 $body .= $_home;
78 break;
79
79 80 default: default:
80 rg_log("Invalid operation!");
81 rg_log("Invalid operation [$op]!");
81 82 } }
82 83
83 84 ?> ?>
File inc/feedback/suggestion.form.php changed (mode: 100644) (index 58cbabc..9b9cc30)
1 1 <?php <?php
2 $_form = '<div class="formarea">';
2 $_form = '<div class="formarea">' . "\n";
3 3
4 4 if (count($errmsg) > 0) if (count($errmsg) > 0)
5 5 $_form .= '<span class="error">' . implode("<br />\n", $errmsg) . '</span><br /><br />' . "\n"; $_form .= '<span class="error">' . implode("<br />\n", $errmsg) . '</span><br /><br />' . "\n";
 
... ... $_form .= '
11 11 <input type="hidden" name="token" value="' . rg_token_get($db, $sid) . '" /> <input type="hidden" name="token" value="' . rg_token_get($db, $sid) . '" />
12 12
13 13 <label for="email"> <label for="email">
14 <span class="form_item_title">E-mail</span><br />
14 <span class="form_item_title">Your e-mail</span><br />
15 15 <input type="text" name="email" value="' . $email . '" /> <input type="text" name="email" value="' . $email . '" />
16 16 </label> </label>
17 17 <br /> <br />
File inc/feedback/suggestion.php changed (mode: 100644) (index f00e80f..8630f32)
1 1 <?php <?php
2 2 rg_log("/feedback/suggestion"); rg_log("/feedback/suggestion");
3 3
4 $_suggestion = "<br />\n";
4 $_suggestion = "";
5 5
6 6 $errmsg = array(); $errmsg = array();
7 7 $show_form = 1; $show_form = 1;
File inc/git.inc.php changed (mode: 100644) (index 17ea73b..8873a3e)
... ... function rg_git_type($obj)
136 136 return trim($a); return trim($a);
137 137 } }
138 138
139 /*
140 * Outputs the content of an object
141 */
142 function rg_git_content($obj)
143 {
144 $cmd = "git cat-file -p '" . $obj . "'";
145 rg_log("\texec $cmd...");
146 $a = exec($cmd, $output, $err);
147 if ($err != 0) {
148 rg_git_set_error("error $err (" . implode("|", $output) . " ($a)");
149 return FALSE;
150 }
151
152 return trim($a);
153 }
154
139 155 /* /*
140 156 * Corrects a revision * Corrects a revision
141 157 */ */
 
... ... function rg_git_merge_base($old, $new)
199 215 return trim($a); return trim($a);
200 216 } }
201 217
218 /*
219 * Returns a tree (git ls-tree)
220 */
221 function rg_git_ls_tree($tree)
222 {
223 rg_log("rg_git_ls_tree: tree=$tree");
224
225 $ret = array();
226
227 $op = " ";
228 if (empty($tree)) {
229 $op = " --full-tree";
230 $tree = " HEAD";
231 }
232
233 $cmd = "git ls-tree --long" . $op . $tree;
234 rg_log("\texec $cmd...");
235 $a = @exec($cmd, $output, $err);
236 if ($err != 0) {
237 rg_git_set_error("error $err out=[" . implode("|", $output) . "] a=[$a]");
238 return FALSE;
239 }
240
241 foreach ($output as $line) {
242 $_y = array();
243 $_t = explode("\t", $line);
244 $_y['file'] = trim($_t[1]);
245 $_i = preg_replace("/([0-9]*) ([a-z]*) ([a-z0-9]*) ( *)([0-9]*)/",
246 '${1} ${2} ${3} ${5}', $_t[0]);
247 $_t = explode(" ", $_i);
248 $_y['mode'] = $_t[0];
249 $_y['type'] = $_t[1];
250 $_y['ref'] = $_t[2];
251 $_y['size'] = $_t[3];
252 $ret[] = $_y;
253 }
254
255 return $ret;
256 }
257
258 /*
259 * Show last @max commits, no merges, sort by topo
260 * @also_patch = TRUE if caller needs also the patch
261 */
262 function rg_git_log($max, $also_patch)
263 {
264 rg_log("git_log: max=$max");
265
266 $max_count = ($max == 0) ? "" : " --max-count=$max";
267 $patches = $also_patch ? " --patch" : "";
268
269 $cmd = "git log"
270 . " --no-merges"
271 . " -z"
272 . $max_count
273 . $patches
274 . " --pretty=\"format:"
275 . "%x00-=ROCKETGIT=-%x00"
276 . "sha1_short:%h%x00\"\""
277 . "sha1_long:%H%x00\"\""
278 . "tree:%t%x00\"\""
279 . "parents_short:%p%x00\"\""
280 . "parents_long:%P%x00\"\""
281 . "author name:%aN%x00\"\""
282 . "author email:%aE%x00\"\""
283 . "author date:%at%x00\"\""
284 . "committer name:%cN%x00\"\""
285 . "committer email:%ce%x00\"\""
286 . "committer date:%ct%x00\"\""
287 . "encoding:%e%x00\"\""
288 . "subject:%s%x00\"\""
289 . "body:%b%x00\"\""
290 . "notes:%N%x00\"\""
291 . "%x00ROCKETGIT_END_OF_VARS%x00\""
292 . " --numstat";
293 rg_log("\texec $cmd...");
294 $a = @exec($cmd, $output, $err);
295 if ($err != 0) {
296 rg_git_set_error("error $err out=[" . implode("|", $output) . "] a=[$a]");
297 return FALSE;
298 }
299
300 $a = implode("", $output);
301
302 $blocks = explode("\0-=ROCKETGIT=-\0", $a);
303 // ignore first entry because of separator
304 unset($blocks[0]);
305
306 $ret = array();
307 foreach ($blocks as $junk => $block) {
308 $y = array("vars" => array(), "files" => array(), "patches" => array());
309
310 // split block in two: vars and stats + patches
311 $parts = explode("\0ROCKETGIT_END_OF_VARS\0", $block, 2);
312
313 // vars
314 $x = explode ("\0", $parts[0]);
315 $count = count($x);
316 for ($i = 0; $i < $count - 1; $i++) {
317 $_t = explode(":", $x[$i], 2);
318 if (isset($_t[1]))
319 $y['vars'][$_t[0]] = trim($_t[1]);
320 else
321 echo "Var " . $_t[0] . " has no value!\n";
322 }
323
324 // stats & patches
325 $stats_and_patches = trim($parts[1]);
326 $_sp = explode("\0\0", $stats_and_patches, 2);
327 $stats = $_sp[0];
328 if (isset($_sp[1]))
329 $y['patches'] = rg_git_diff2array(trim($_sp[1]));
330
331 // stats
332 $_t = explode("\0", $stats);
333 $y['vars']['files_changed'] = count($_t);
334 $total_add = 0;
335 $total_del = 0;
336 foreach ($_t as $junk => $fi) {
337 $__t = explode("\t", $fi);
338 $y['files'][$__t[2]] = array(
339 "add" => $__t[0],
340 "del" => $__t[1]);
341 $total_add += intval($__t[0]);
342 $total_del += intval($__t[1]);
343 }
344 $y['vars']['lines_add'] = $total_add;
345 $y['vars']['lines_del'] = $total_del;
346
347 // final additions
348 $y['vars']['author date UTC'] = gmdate("Y-m-d H:i:s", $y['vars']['author date']);
349 $y['vars']['committer date UTC'] = gmdate("Y-m-d H:i:s", $y['vars']['committer date']);
350
351 $ret[] = $y;
352 }
353
354 return $ret;
355 }
356
357 /*
358 * Transforms a diff into an array (ready for rg_git_diff_template)
359 */
360 function rg_git_diff2array($diff)
361 {
362 $ret = array();
363
364 $lines = explode("\n", $diff);
365 $file = 0;
366 foreach ($lines as $line) {
367 if (strncmp($line, "diff ", 5) == 0) {
368 $file++;
369 $ret[$file] = array();
370 $ret[$file]['flags'] = "";
371 $ret[$file]['chunks'] = array();
372 $file_name_sel = "dst";
373 $file_name_tmp = array();
374 continue;
375 }
376
377 if (strncmp($line, "new file ", 9) == 0) {
378 $ret[$file]['flags'] .= "N";
379 continue;
380 }
381
382 if (strncmp($line, "deleted file ", 13) == 0) {
383 $ret[$file]['flags'] .= "D";
384 $file_name_sel = "src";
385 continue;
386 }
387
388 if (strncmp($line, "index ", 6) == 0) {
389 $ret[$file]['index'] = substr($line, 6);
390 continue;
391 }
392
393 if (strncmp($line, "--- ", 4) == 0) {
394 if (strncmp($line, "--- a/", 2) == 0)
395 $file_name_tmp['src'] = substr($line, 6);
396 else
397 $file_name_tmp['src'] = substr($line, 4);
398 continue;
399 }
400
401 if (strncmp($line, "+++ ", 4) == 0) {
402 if (strncmp($line, "+++ b/", 2) == 0)
403 $file_name_tmp['dst'] = substr($line, 6);
404 else
405 $file_name_tmp['dst'] = substr($line, 4);
406 continue;
407 }
408
409 if (strncmp($line, "@@ ", 3) == 0) {
410 $_t = explode(" ", $line, 5);
411 $chunk = $_t[1] . " " . $_t[2];
412 $ret[$file]['chunks'][$chunk] = array();
413 $ret[$file]['chunks'][$chunk]['section'] = @trim($_t[4]);
414 $lineno = substr($line, 3);
415 $lineno = 0; // TODO: fixit!
416 continue;
417 }
418
419 if (!isset($file_name_tmp[$file_name_sel])) {
420 echo "bad!";
421 echo $diff;
422 exit(0);
423 }
424
425 if (!isset($ret[$file]['file']))
426 $ret[$file]['file'] = $file_name_tmp[$file_name_sel];
427
428 if ((strncmp($line, " ", 1) == 0)
429 || (strncmp($line, "+", 1) == 0)
430 || (strncmp($line, "-", 1) == 0)) {
431 $ret[$file]['chunks'][$chunk]['lines'][$lineno++] = $line;
432 continue;
433 }
434
435 echo "I do not know how to parse [" . trim($line) . "]!\n";
436 exit(0);
437 }
438
439 return $ret;
440 }
441
442 /*
443 * Outputs the result of replacing variables in a template with real variables
444 */
445 function rg_git_log_template($log, $template_dir, $more)
446 {
447 $t = array();
448
449 foreach ($log as $index => $info) {
450 $v = array();
451 foreach ($info['vars'] as $var => $value)
452 $v[$var] = $value;
453 $t[] = $v;
454 }
455
456 return rg_template_table($template_dir, $t, $more);
457 }
458
459 /*
460 * Build statistics
461 * TODO: Use caching
462 * TODO: count merges
463 */
464 function rg_git_stats($log)
465 {
466 $ret = array(
467 "authors" => array(),
468 "commits" => 0,
469 "lines_add" => 0,
470 "lines_del" => 0
471 );
472
473 foreach ($log as $index => $ci) {
474 $v = $ci['vars'];
475
476 if (!isset($ret['project_start_date'])) {
477 $ret['project_start_date'] = $v['author date'];
478 $ret['project_start_author'] = $v['author name'];
479 }
480 $ret['project_last_date'] = $v['author date'];
481 $ret['project_last_author'] = $v['author name'];
482
483 // global stats
484 $ret['lines_add'] += intval($v['lines_add']);
485 $ret['lines_del'] += intval($v['lines_del']);
486 $ret['commits']++;
487
488 // stats per author
489 $a = $v['author name'];
490 if (!isset($ret['authors'][$a])) {
491 $ret['authors'][$a] = array(
492 'first_commit' => 0,
493 'last_commit' => 0,
494 'commits' => 0,
495 'lines_add' => 0,
496 'lines_del' => 0);
497 }
498 $ret['authors'][$a]['commits']++;
499 $ret['authors'][$a]['lines_add'] += intval($v['lines_add']);
500 $ret['authors'][$a]['lines_del'] += intval($v['lines_del']);
501 if ($ret['authors'][$a]['first_commit'] == 0)
502 $ret['authors'][$a]['first_commit'] = $v['author date'];
503 $ret['authors'][$a]['last_commit'] = $v['author date'];
504 }
505
506 return $ret;
507 }
508
509 /*
510 * Nice diff per file
511 * Outputs the result of replacing variables in a template with real variables
512 * @a - output of rg_git_diff2array[index]
513 */
514 function rg_git_diff_template($a, $template_file)
515 {
516 $ret = "";
517
518 $template = @file_get_contents($template_file);
519 if ($template === FALSE)
520 return "Error: cannot load template ($template_file)!";
521
522 foreach ($a as $fileindex => $finfo) {
523 $f = $finfo['file'];
524 $ret .= "<b>";
525 if (strstr($finfo['flags'], "N"))
526 $ret .= "file [$f] added </br/>\n";
527 else if (strstr($finfo['flags'], "D"))
528 $ret .= "file [$f] deleted:<br />";
529 else
530 $ret .= "file [$f] changed:<br />\n";
531 $ret .= "</b>";
532
533 foreach ($finfo['chunks'] as $chunk => $ci) {
534 $ret .= "chunk [$chunk], section [" . $ci['section'] . "]:<br />\n";
535 $ret .= "<table border=1>\n";
536 foreach ($ci['lines'] as $line_no => $line) {
537 $v = $template;
538
539 $left_color = "#eeeeee";
540 $right_color = "#eeeeee";
541
542 $c = substr($line, 0, 1);
543 $line = substr($line, 1);
544 if (strcmp($c, " ") == 0) {
545 $left = $line;
546 $right = $line;
547 } else if (strcmp($c, "+") == 0) {
548 $left = "";
549 $right = $line;
550 $right_color = "#00ff00";
551 } else if (strcmp($c, "-") == 0) {
552 $left = $line;
553 $left_color = "#ff0000";
554 $right = "";
555 } else {
556 echo "Something wrong with [$line]!\n";
557 exit(0);
558 }
559
560 $v = preg_replace("/@@line@@/", $line_no, $v);
561 $v = preg_replace("/@@left@@/", htmlspecialchars($left), $v);
562 $v = preg_replace("/@@right@@/", htmlspecialchars($right), $v);
563
564 $v = preg_replace("/@@left_color@@/", $left_color, $v);
565 $v = preg_replace("/@@right_color@@/", $right_color, $v);
566 $ret .= $v;
567 }
568 $ret .= "</table>\n";
569 }
570 }
571
572 return $ret;
573 }
574
202 575 ?> ?>
File inc/keys.inc.php changed (mode: 100644) (index bbe6c5a..301af61)
... ... function rg_keys_remove($db, $rg_ui, $key_id)
83 83 return TRUE; return TRUE;
84 84 } }
85 85
86 /*
87 * Count the number of keys per user
88 */
89 function rg_keys_count($db, $uid)
90 {
91 $sql = "SELECT COUNT(*) AS count FROM keys WHERE uid = $uid";
92 $res = rg_sql_query($db, $sql);
93 if ($res === FALSE) {
94 rg_keys_set_error("cannot query (" . rg_sql_error() . ")");
95 return FALSE;
96 }
97 $row = rg_sql_fetch_array($res);
98 rg_sql_free_result($res);
99
100 return $row['count'];
101 }
102
86 103 /* /*
87 104 * Add a key * Add a key
88 105 * Returns the key_id of the key. * Returns the key_id of the key.
89 106 */ */
90 107 function rg_keys_add($db, $rg_ui, $key) function rg_keys_add($db, $rg_ui, $key)
91 108 { {
109 global $rg_max_ssh_keys;
110
92 111 $itime = time(); $itime = time();
93 112 $e_key = rg_sql_escape($db, $key); $e_key = rg_sql_escape($db, $key);
94 113
95 114 if (rg_keys_valid($key) === FALSE) if (rg_keys_valid($key) === FALSE)
96 115 return FALSE; return FALSE;
97 116
117 // check if we are over the maximum
118 // the config after update may not have this defined.
119 if ($rg_max_ssh_keys == 0)
120 $rg_max_ssh_keys = 10;
121 $no_of_keys = rg_keys_count($db, $rg_ui['uid']);
122 if ($no_of_keys === FALSE)
123 return FALSE;
124
125 if ($no_of_keys >= $rg_max_ssh_keys) {
126 rg_keys_set_error("too many keys; please delete some");
127 return FALSE;
128 }
129
98 130 // set dirty // set dirty
99 131 if (rg_state_set($db, "authorized_keys", 1) === FALSE) { if (rg_state_set($db, "authorized_keys", 1) === FALSE) {
100 132 rg_keys_set_error("cannot make state dirty: " . rg_state_error()); rg_keys_set_error("cannot make state dirty: " . rg_state_error());
 
... ... function rg_keys_list($db, $rg_ui, $url)
200 232 return FALSE; return FALSE;
201 233 } }
202 234
203 $ret = "<table>\n";
235 $ret = "<div class=\"rg_keys_list\">\n";
236 $ret .= "<table width=\"100%\">\n";
204 237 $ret .= "<tr>\n"; $ret .= "<tr>\n";
205 238 $ret .= " <th>Date (UTC)</th>\n"; $ret .= " <th>Date (UTC)</th>\n";
206 239 $ret .= " <th>Fingerprint</th>\n"; $ret .= " <th>Fingerprint</th>\n";
 
... ... function rg_keys_list($db, $rg_ui, $url)
218 251 $ret .= "</tr>\n"; $ret .= "</tr>\n";
219 252 } }
220 253 $ret .= "</table>\n"; $ret .= "</table>\n";
254 $ret .= "</div>\n";
221 255 rg_sql_free_result($res); rg_sql_free_result($res);
222 256
223 257 return $ret; return $ret;
File inc/login/login.form.php changed (mode: 100644) (index 6113e29..33be868)
... ... if (count($errmsg) > 0)
5 5 $_form .= '<span class="error">' . implode("<br />\n", $errmsg) . '</span><br /><br />' . "\n"; $_form .= '<span class="error">' . implode("<br />\n", $errmsg) . '</span><br /><br />' . "\n";
6 6
7 7 $_form .= ' $_form .= '
8 <form method="post" action="' . $_SERVER['PHP_SELF'] . '">
8 <form method="post" action="' . rg_re_post($op) . '">
9 9 <input type="hidden" name="op" value="' . $op . '" /> <input type="hidden" name="op" value="' . $op . '" />
10 10 <input type="hidden" name="subop" value="1" /> <input type="hidden" name="subop" value="1" />
11 11 <input type="hidden" name="doit" value="1" /> <input type="hidden" name="doit" value="1" />
File inc/repo.inc.php changed (mode: 100644) (index 2e4f20f..d783a35)
... ... function rg_repo_error()
51 51 function rg_repo_ok($repo) function rg_repo_ok($repo)
52 52 { {
53 53 global $rg_repo_allow; global $rg_repo_allow;
54 global $rg_repo_min_len;
54 55 global $rg_repo_max_len; global $rg_repo_max_len;
55 56
56 57 if (empty($repo)) { if (empty($repo)) {
 
... ... function rg_repo_ok($repo)
68 69 return FALSE; return FALSE;
69 70 } }
70 71
72 if (strlen($repo) < $rg_repo_min_len) {
73 rg_repo_set_error("Repository name is too short"
74 . " (minimum $rg_repo_min_len).");
75 return FALSE;
76 }
77
71 78 if (strlen($repo) > $rg_repo_max_len) { if (strlen($repo) > $rg_repo_max_len) {
72 rg_repo_set_error("Repository name is too long");
79 rg_repo_set_error("Repository name is too long"
80 . " (maximum $rg_repo_max_len).");
73 81 return FALSE; return FALSE;
74 82 } }
75 83
 
... ... function rg_repo_ok($repo)
79 87 /* /*
80 88 * Returns the path to a repository based on name * Returns the path to a repository based on name
81 89 */ */
82 function rg_repo_name2base($repo)
90 function rg_repo_name2base($rr)
83 91 { {
84 global $rg_base_repo;
85
86 $len = strlen($repo);
87 $v = $repo;
88 if ($len == 1)
89 $v .= "_";
90
91 return $rg_base_repo . "/"
92 . $v[0] . "/" . $v[1] . "/";
92 return rg_user_name2path($rr) . "/repos/";
93 93 } }
94 94
95 95 /* /*
96 96 * Return info about a repo * Return info about a repo
97 * @param rr contains data about user and repo
97 98 */ */
98 function rg_repo_info($db, $repo_id, $repo)
99 function rg_repo_info($db, $rr)
99 100 { {
100 rg_log("repo_info: repo_id/repo=[$repo_id/$repo]...");
101 rg_log("repo_info: rr:" . implode("|", $rr));
102
103 $repo_id = isset($rr['repo_id']) ? $rr['repo_id'] : 0;
104 $user = isset($rr['user']) ? $rr['user'] : "";
105 $repo = isset($rr['repo']) ? $rr['repo'] : "";
101 106
102 107 $ret['ok'] = 0; $ret['ok'] = 0;
103 108 $ret['exists'] = 0; $ret['exists'] = 0;
104 109
105 110 if ($repo_id > 0) { if ($repo_id > 0) {
106 $add = " AND repo_id = $repo_id";
107 } else if (!empty($repo)) {
111 $add = " repo_id = $repo_id";
112 } else if (!empty($user) && !empty($repo)) {
113 $ui = rg_user_info($db, 0, $user, "");
114 if ($ui['ok'] != 1) {
115 $ret['errmsg'] = "Invalid repo path (user)";
116 return $ret;
117 }
108 118 $e_repo = rg_sql_escape($db, $repo); $e_repo = rg_sql_escape($db, $repo);
109 $add = " AND name = '$e_repo'";
119 $add = " uid = " . $ui['uid'] . " AND name = '$e_repo'";
110 120 } else { } else {
111 $ret['errmsg'] = "No repo_id or name specified!";
121 $ret['errmsg'] = "No repo_id or user/name specified!";
112 122 return $ret; return $ret;
113 123 } }
114 124
115 $sql = "SELECT * FROM repos WHERE 1 = 1" . $add;
125 $sql = "SELECT * FROM repos WHERE " . $add;
116 126 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
117 127 if ($res === FALSE) { if ($res === FALSE) {
118 128 $ret['errmsg'] = "Cannot query (" . rg_sql_error() . ")"; $ret['errmsg'] = "Cannot query (" . rg_sql_error() . ")";
 
... ... function rg_repo_update($db, &$new)
305 315 */ */
306 316 function rg_repo_list_query($db, $url, $sql) function rg_repo_list_query($db, $url, $sql)
307 317 { {
308 global $rg_ui;
318 global $THEME;
309 319
310 320 rg_log("repo_list_query: url=$url, sql=$sql..."); rg_log("repo_list_query: url=$url, sql=$sql...");
311 321
312 322 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
313 if ($res === FALSE)
323 if ($res === FALSE) {
324 rg_repo_set_error("cannot list by query (" . rg_sql_error() . ")");
314 325 return FALSE; return FALSE;
326 }
315 327
316 $admin_mode = 0;
317 if ($rg_ui['is_admin'] == 1)
318 $admin_mode = 1;
319
320 $ret = "<table>\n";
321 $ret .= "<tr>\n";
322 $ret .= " <th>Name</th>\n";
323 if ($admin_mode == 1)
324 $ret .= " <th>Owner</th>\n";
325 $ret .= " <th>Description</th>\n";
326 $ret .= " <th>Clone of</th>\n";
327 $ret .= " <th>Creation date (UTC)</th>\n";
328 $ret .= " <th>Default rights</th>\n";
329 $ret .= " <th>Disk used/max</th>\n";
330 $ret .= " <th>Max commit size</th>\n";
331 $ret .= " <th>Max users</th>\n";
332 $ret .= "</tr>\n";
333
328 $d = array();
334 329 while (($row = rg_sql_fetch_array($res))) { while (($row = rg_sql_fetch_array($res))) {
335 $ret .= "<tr>\n";
336 $_link = rg_re_repopage($row['repo_id'], $row['name']);
337 $ret .= " <td><a href=\"$_link\">" . $row['name'] . "</a></td>\n";
338 if ($admin_mode == 1) {
339 $_ui = rg_user_info($db, $row['uid'], "", "");
340 if ($_ui['exists'] != 1)
341 $v = "?" . $row['uid'] . "?";
342 else
343 $v = $_ui['username'];
344 $ret .= " <td>$v</td>\n";
330 $_line = array();
331
332 foreach ($row as $k => $v)
333 $_line[$k] = htmlspecialchars($v);
334
335 $_ui = rg_user_info($db, $row['uid'], "", "");
336 if ($_ui['exists'] != 1) {
337 $v = "?" . $row['uid'] . "?";
338 $organization = 0;
339 } else {
340 $v = $_ui['username'];
341 $organization = $_ui['organization'];
345 342 } }
346 $ret .= " <td><small>" . nl2br($row['description']) . "</small></td>\n";
343 $_line['owner'] = htmlspecialchars($v);
344
345 $_line['link'] = rg_re_repopage($organization, $_line['owner'],
346 $row['name']);
347
348 $_line['description'] = nl2br(htmlspecialchars($row['description']));
349
350 $master_repo = "-";
347 351 if ($row['master'] > 0) { if ($row['master'] > 0) {
348 352 $master_repo = "?"; $master_repo = "?";
349 353 $_mi = rg_repo_info($db, $row['master'], ""); $_mi = rg_repo_info($db, $row['master'], "");
350 354 if ($_mi['exists'] = 1) if ($_mi['exists'] = 1)
351 355 $master_repo = $_mi['name']; $master_repo = $_mi['name'];
352 356 } }
353 $ret .= " <td>" . ($row['master'] == 0 ? "-" : $master_repo) . "</td>\n";
354 $ret .= " <td>" . gmdate("Y-m-d H:i:s", $row['itime']) . "</td>\n";
357 $_line['clone_of'] = htmlspecialchars($master_repo);
358 $_line['creation'] = gmdate("Y-m-d H:i:s", $row['itime']);
355 359
356 360 // rights // rights
357 $_r = implode(", ", rg_rights_text("repo", $row['default_rights']));
358 $ret .= " <td>" . $_r . "</td>\n";
361 $_line['rights'] = implode(", ", rg_rights_text("repo", $row['default_rights']));
359 362
360 $_max = "ulimited";
363 $_max = "unlimited";
361 364 if ($row['disk_quota_mb'] > 0) if ($row['disk_quota_mb'] > 0)
362 365 $_max = rg_1024($row['disk_quota_mb'] * 1024 * 1024); $_max = rg_1024($row['disk_quota_mb'] * 1024 * 1024);
363 $ret .= " <td>" . $row['disk_used_mb'] . "/" . $_max . "</td>\n";
366 $_line['disk_used'] = $row['disk_used_mb'] . "/" . $_max;
364 367
365 $_v = "ulimited";
368 $_line['max_commit_size'] = "unlimited";
366 369 if ($row['max_commit_size'] > 0) if ($row['max_commit_size'] > 0)
367 $_v = rg_1024($row['max_commit_size']);
368 $ret .= " <td>" . $_v . "</td>\n";
370 $_line['max_commit_size'] = rg_1024($row['max_commit_size']);
369 371
370 $_v = "ulimited";
372 $_line['max_users'] = "unlimited";
371 373 if ($row['max_users'] > 0) if ($row['max_users'] > 0)
372 $_v = $row['max_users'];
373 $ret .= " <td>" . $_v . "</td>\n";
374 $_line['max_users'] = $row['max_users'];
374 375
375 $ret .= "</tr>\n";
376 $d[] = $_line;
376 377 } }
377 $ret .= "</table>\n";
378 378 rg_sql_free_result($res); rg_sql_free_result($res);
379 379
380 return $ret;
380 return rg_template_table($THEME . "/repo/list", $d, array());
381 381 } }
382 382
383 383 /* /*
File inc/repo/repo.form.php changed (mode: 100644) (index c76ed92..cb59087)
... ... if (count($errmsg) > 0)
5 5 $_form .= '<span class="error">' . implode("<br />\n", $errmsg) . '</span><br /><br />' . "\n"; $_form .= '<span class="error">' . implode("<br />\n", $errmsg) . '</span><br /><br />' . "\n";
6 6
7 7 $_form .= ' $_form .= '
8 <form method="post" action="' . $_SERVER['PHP_SELF'] . '">
8 <form method="post" action="' . rg_re_post($op) . '">
9 9 <input type="hidden" name="op" value="' . $op . '" /> <input type="hidden" name="op" value="' . $op . '" />
10 10 <input type="hidden" name="subop" value="' . $subop . '" /> <input type="hidden" name="subop" value="' . $subop . '" />
11 11 <input type="hidden" name="repo_id" value="' . $repo_id . '" /> <input type="hidden" name="repo_id" value="' . $repo_id . '" />
File inc/repo/repo.php changed (mode: 100644) (index 24671e0..fd8e8ca)
... ... $_url = rg_re_url($op);
25 25 $second_menu = array( $second_menu = array(
26 26 "create_repo" => array( "create_repo" => array(
27 27 "text" => "Create", "text" => "Create",
28 "url" => "&amp;subop=1"
28 "url" => "&amp;subop=create"
29 29 ), ),
30 30 "list_repos" => array( "list_repos" => array(
31 31 "text" => "List", "text" => "List",
32 "url" => "&amp;subop=2"
32 "url" => "&amp;subop=list"
33 33 ), ),
34 34 "search_repo" => array( "search_repo" => array(
35 35 "text" => "Search", "text" => "Search",
36 "url" => "&amp;subop=3"
36 "url" => "&amp;subop=search"
37 37 ) )
38 38 ); );
39 39
 
... ... $_body = "";
42 42 $errmsg = array(); $errmsg = array();
43 43
44 44 switch ($subop) { switch ($subop) {
45 case 1: // create
45 case 'create':
46 46 if ($doit == 1) { if ($doit == 1) {
47 47 $_r = rg_repo_create($db, $master_repo_id, $rg_ui, $name, $_r = rg_repo_create($db, $master_repo_id, $rg_ui, $name,
48 48 $max_commit_size, $description, $rights, $max_users); $max_commit_size, $description, $rights, $max_users);
 
... ... case 1: // create
61 61 } }
62 62 break; break;
63 63
64 case 2: // list
64 case 'list':
65 65 $_body .= rg_repo_list($db, "", $rg_ui); $_body .= rg_repo_list($db, "", $rg_ui);
66 66 break; break;
67 67
68 case 3: // search
68 case 'search':
69 69 if ($doit == 1) { if ($doit == 1) {
70 70 $_body .= rg_repo_search($db, $q, $masters); $_body .= rg_repo_search($db, $q, $masters);
71 71 } else { } else {
File inc/repo/repo_page.php changed (mode: 100644) (index 253a3fa..83df9ba)
... ... $max_users = rg_var_uint("max_users");
10 10 $user = rg_var_str("user"); $user = rg_var_str("user");
11 11 $master_repo_id = 0; $master_repo_id = 0;
12 12
13 // menu
13 // menu - TODO: second_level menu?
14 14 $_url = rg_re_repopage($repo_id, $name); $_url = rg_re_repopage($repo_id, $name);
15 15 $_menu = ""; $_menu = "";
16 $_menu .= "[<a href=\"$_url&amp;subop=1\">Edit</a>]";
17 $_menu .= "&nbsp;[<a href=\"$_url&amp;subop=2\">Rights</a>]";
18 $_menu .= "&nbsp;[<a href=\"$_url&amp;subop=3\">Delete</a>]";
16 $_menu .= "[<a href=\"$_url&amp;subop=edit\">Edit</a>]";
17 $_menu .= "&nbsp;[<a href=\"$_url&amp;subop=rights\">Rights</a>]";
18 $_menu .= "&nbsp;[<a href=\"$_url&amp;subop=delete\">Delete</a>]";
19 19 $_menu .= "<br />\n"; $_menu .= "<br />\n";
20 20 $_menu .= "<br />\n"; $_menu .= "<br />\n";
21 21
 
... ... $show_repo_info = 1;
40 40 $errmsg = array(); $errmsg = array();
41 41
42 42 switch ($subop) { switch ($subop) {
43 case 1: // edit
43 case 'edit':
44 44 if ($doit == 1) { if ($doit == 1) {
45 45 while (1) { while (1) {
46 46 if (rg_repo_allow($db, $ri, $rg_ui, "A") === FALSE) { if (rg_repo_allow($db, $ri, $rg_ui, "A") === FALSE) {
 
... ... case 1: // edit
76 76 } }
77 77 break; break;
78 78
79 case 2: // rights
79 case 'rights':
80 80 $remove_uid = rg_var_uint("remove_uid"); $remove_uid = rg_var_uint("remove_uid");
81 81 rg_log("\tDEBUG remove_uid=$remove_uid"); rg_log("\tDEBUG remove_uid=$remove_uid");
82 82
 
... ... case 2: // rights
117 117 } }
118 118
119 119 // list rights // list rights
120 $_url = rg_re_repopage($ri['repo_id'], $ri['name']);
120 $_url = rg_re_repopage($ri['organization'], $ri['repo_id'], $ri['name']);
121 121 $_body .= rg_repo_rights_list($db, $ri, $_url); $_body .= rg_repo_rights_list($db, $ri, $_url);
122 122
123 123 $_body .= "<br />\n"; $_body .= "<br />\n";
 
... ... case 2: // rights
126 126 $_body .= $_form; $_body .= $_form;
127 127 break; break;
128 128
129 case 3: // delete
129 case 'delete':
130 130 while (1) { while (1) {
131 131 if (rg_repo_allow($db, $ri, $rg_ui, "A") === FALSE) { if (rg_repo_allow($db, $ri, $rg_ui, "A") === FALSE) {
132 132 $errmsg[] = "Not allowed!"; $errmsg[] = "Not allowed!";
File inc/repo/rights.form.php changed (mode: 100644) (index ebc8efd..b7c9867)
... ... $_form = '<div class="formarea">';
4 4 if (count($errmsg) > 0) if (count($errmsg) > 0)
5 5 $_form .= '<span class="error">' . implode("<br />\n", $errmsg) . '</span><br /><br />' . "\n"; $_form .= '<span class="error">' . implode("<br />\n", $errmsg) . '</span><br /><br />' . "\n";
6 6
7 <form method="post" action="' . $_SERVER['PHP_SELF'] . '">
7 <form method="post" action="' . rg_re_post($op) . '">
8 8 <input type="hidden" name="op" value="' . $op . '" /> <input type="hidden" name="op" value="' . $op . '" />
9 9 <input type="hidden" name="subop" value="' . $subop . '" /> <input type="hidden" name="subop" value="' . $subop . '" />
10 10 <input type="hidden" name="repo_id" value="' . $repo_id . '" /> <input type="hidden" name="repo_id" value="' . $repo_id . '" />
File inc/repo/search.form.php changed (mode: 100644) (index f69148a..a64d2a5)
... ... if (count($errmsg) > 0)
5 5 $_form .= '<span class="error">' . implode("<br />\n", $errmsg) . '</span><br /><br />' . "\n"; $_form .= '<span class="error">' . implode("<br />\n", $errmsg) . '</span><br /><br />' . "\n";
6 6
7 7 $_form .= ' $_form .= '
8 <form method="post" action="' . $_SERVER['PHP_SELF'] . '">
8 <form method="post" action="' . rg_re_post($op) . '">
9 9 <input type="hidden" name="op" value="' . $op . '" /> <input type="hidden" name="op" value="' . $op . '" />
10 10 <input type="hidden" name="subop" value="' . $subop . '" /> <input type="hidden" name="subop" value="' . $subop . '" />
11 11 <input type="hidden" name="doit" value="1" /> <input type="hidden" name="doit" value="1" />
File inc/user.inc.php changed (mode: 100644) (index 914d27a..acbb613)
... ... function rg_user_error()
26 26 return $_rg_user_error; return $_rg_user_error;
27 27 } }
28 28
29 /*
30 * Returns the path to user home based on name
31 */
32 function rg_user_name2path($rr)
33 {
34 global $rg_base;
35
36 $len = strlen($rr['user']);
37 $v = $rr['user'];
38 if ($len == 1)
39 $v .= "_";
40
41 return $rg_base . "/" . $rr['type'] . "s/"
42 . $v[0] . "/" . $v[1] . "/" . $rr['user'];
43 }
44
29 45 /* /*
30 46 * Computes password hash * Computes password hash
31 47 */ */
File inc/user/create.php changed (mode: 100644) (index 55c5de9..fa281d1)
1 1 <?php <?php
2 rg_log("/create/create.php");
2 rg_log("/inc/user/create");
3 3
4 4 $_create = "<br />\n"; $_create = "<br />\n";
5 5
File inc/user/forgot.form.php changed (mode: 100644) (index c4dbc0c..de70637)
... ... if (count($errmsg) > 0)
5 5 $_forgot_form .= '<span class="error">' . implode("<br />\n", $errmsg) . '</span><br /><br />' . "\n"; $_forgot_form .= '<span class="error">' . implode("<br />\n", $errmsg) . '</span><br /><br />' . "\n";
6 6
7 7 $_forgot_form .= ' $_forgot_form .= '
8 <form method="post" action="' . $_SERVER['PHP_SELF'] . '">
8 <form method="post" action="' . rg_re_post($op) . '">
9 9 <input type="hidden" name="op" value="' . $op . '" /> <input type="hidden" name="op" value="' . $op . '" />
10 10 <input type="hidden" name="forgot_token" value="' . $forgot_token . '" /> <input type="hidden" name="forgot_token" value="' . $forgot_token . '" />
11 11 <input type="hidden" name="doit" value="1" /> <input type="hidden" name="doit" value="1" />
File inc/user/forgot_send.form.php changed (mode: 100644) (index a5c9e35..73dd898)
... ... if (count($errmsg) > 0)
5 5 $_form .= '<span class="error">' . implode("<br />\n", $errmsg) . '</span><br /><br />' . "\n"; $_form .= '<span class="error">' . implode("<br />\n", $errmsg) . '</span><br /><br />' . "\n";
6 6
7 7 $_form .= ' $_form .= '
8 <form method="post" action="' . $_SERVER['PHP_SELF'] . '">
8 <form method="post" action="' . rg_re_post("forgotsend") . '">
9 9 <input type="hidden" name="op" value="forgotsend" /> <input type="hidden" name="op" value="forgotsend" />
10 10 <input type="hidden" name="subop" value="2" /> <input type="hidden" name="subop" value="2" />
11 11 <input type="hidden" name="doit" value="1" /> <input type="hidden" name="doit" value="1" />
File inc/user/home-page.php changed (mode: 100644) (index 363b011..386d6a2)
1 1 <?php <?php
2 2 rg_log("/inc/user/home-page"); rg_log("/inc/user/home-page");
3 3
4 $user = rg_var_str("user");
5
6 4 $_home = ""; $_home = "";
7 5
8 6 $ui = rg_user_info($db, 0, $user, ""); $ui = rg_user_info($db, 0, $user, "");
 
... ... if ($ui['uid'] == $rg_ui['uid']) {
16 14 $second_menu = array( $second_menu = array(
17 15 "edit_info" => array( "edit_info" => array(
18 16 "text" => "Edit info", "text" => "Edit info",
19 "url" => "&amp;subop=edit_info"
17 "url" => "/edit_info"
20 18 ), ),
21 19 "change_pass" => array( "change_pass" => array(
22 20 "text" => "Change password", "text" => "Change password",
23 "url" => "&amp;subop=change_pass"
21 "url" => "/change_pass"
24 22 ), ),
25 23 "keys" => array( "keys" => array(
26 24 "text" => "SSH keys", "text" => "SSH keys",
27 "url" => "&amp;subop=keys"
25 "url" => "/keys"
28 26 ) )
29 27 ); );
30 28 } }
31 29
32 $_home .= "<h1>" . htmlspecialchars($user) . "</h1>\n";
30 $_home .= "<h1>" . $user . "</h1>\n";
33 31
34 32 // list of repositories // list of repositories
35 33 $_home .= rg_repo_list($db, "", $ui); $_home .= rg_repo_list($db, "", $ui);
File inc/user/keys/add.form.php changed (mode: 100644) (index 13fbc1a..9e66bea)
1 1 <?php <?php
2 $_form = '<div class="formarea">';
2 $_form = '<div class="formarea">' . "\n"; // TODO: add \n in all other forms
3 3
4 4 if (count($errmsg) > 0) if (count($errmsg) > 0)
5 5 $_form .= '<span class="error">' . implode("<br />\n", $errmsg) . '</span><br /><br />' . "\n"; $_form .= '<span class="error">' . implode("<br />\n", $errmsg) . '</span><br /><br />' . "\n";
6 6
7 7 $_form .= ' $_form .= '
8 <form method="post" action="' . $_SERVER['PHP_SELF'] . '">
8 <form method="post" action="' . rg_re_post($op) . '">
9 9 <input type="hidden" name="op" value="' . $op . '" /> <input type="hidden" name="op" value="' . $op . '" />
10 10 <input type="hidden" name="subop" value="' . $subop . '" /> <input type="hidden" name="subop" value="' . $subop . '" />
11 <input type="hidden" name="doit" value="1" />
11 <input type="hidden" name="add" value="1" />
12 12 <input type="hidden" name="token" value="' . rg_token_get($db, $sid) . '" /> <input type="hidden" name="token" value="' . rg_token_get($db, $sid) . '" />
13 13
14 14 <label for="key"> <label for="key">
15 <span class="form_item_title">Key (starts with ssh-...)</span><br />
15 <span class="form_item_title">Add key (starts with ssh-...)</span><br />
16 16 <textarea name="key" value="' . $key . '" rows="4" cols="50"></textarea> <textarea name="key" value="' . $key . '" rows="4" cols="50"></textarea>
17 17 </label> </label>
18 18 <br /> <br />
 
... ... $_form .= '
23 23 </label> </label>
24 24
25 25 </form> </form>
26 </viv>
26 </div>
27 27 '; ';
28 28
29 29
File inc/user/keys/keys.php changed (mode: 100644) (index f78451d..142c929)
1 1 <?php <?php
2 rg_log("/inc/keys/keys");
2 rg_log("/inc/user/keys/keys");
3 3
4 $_keys = "";
4 $errmsg = array();
5 5
6 if ($rg_ui['uid'] == 0) {
7 $_keys .= "You do not have access here!";
8 return;
9 }
6 $_keys = "";
10 7
11 8 $key = rg_var_str("key"); $key = rg_var_str("key");
12 9 $key = preg_replace("|[^/A-Za-z0-9 @/+_\.\=,-]|", "", $key); $key = preg_replace("|[^/A-Za-z0-9 @/+_\.\=,-]|", "", $key);
 
... ... $key_id = rg_var_uint("key_id");
15 12 // menu // menu
16 13 $_url = rg_re_url($op); $_url = rg_re_url($op);
17 14
18 $second_menu = array(
19 "add_key" => array(
20 "text" => "Add key",
21 "url" => "&amp;subop=1"
22 ),
23 "list_keys" => array(
24 "text" => "List keys",
25 "url" => "&amp;subop=2"
26 )
27 );
28
29 $_body = "";
15 $_keys = "";
30 16 $errmsg = array(); $errmsg = array();
31 17
32 switch ($subop) {
33 case 1: // add
34 if ($doit == 1) {
35 $_r = rg_keys_add($db, $rg_ui, $key);
36 if ($_r === FALSE)
37 $_body .= rg_keys_error();
38 else
39 $_body = "OK!";
40 }
41
42 include($INC . "/keys/add.form.php");
43 $_body .= $_form;
44 break;
45
46 case 2: // list
47 if (rg_var_uint("delete") == 1) {
48 if (rg_keys_remove($db, $rg_ui, $key_id) === FALSE)
49 $_body .= "Bad: " . rg_keys_error() . "!<br />\n";
50 }
51
52 $_body .= rg_keys_list($db, $rg_ui, $_url . "&amp;subop=2");
53 break;
54
18 if (rg_var_uint("add") == 1) {
19 $_r = rg_keys_add($db, $rg_ui, $key);
20 if ($_r === FALSE)
21 $errmsg[] = rg_keys_error();
22 } else if (rg_var_uint("delete") == 1) {
23 if (rg_keys_remove($db, $rg_ui, $key_id) !== TRUE)
24 $errmsg[] = rg_keys_error();
55 25 } }
56 26
57 $_keys .= $_body;
27
28 $_keys .= rg_keys_list($db, $rg_ui, $_url . "&amp;subop=$subop");
29
30 include($INC . "/user/keys/add.form.php");
31 $_keys .= $_form;
58 32 ?> ?>
File inc/user/pass.form.php deleted (index 5206d86..0000000)
1 <?php
2 $_chpass_form = '<div class="formarea">';
3
4 if (count($errmsg) > 0)
5 $_chpass_form .= '<span class="error">' . implode("<br />\n", $errmsg) . '</span><br /><br />' . "\n";
6
7 $_chpass_form .= '
8 <form method="post" action="' . $_SERVER['PHP_SELF'] . '">
9 <input type="hidden" name="op" value="' . $op . '" />
10 <input type="hidden" name="doit" value="1" />
11 <input type="hidden" name="token" value="' . rg_token_get($db, $sid) . '" />
12
13 <label for="old_pass">
14 <span class="form_item_title">Old password</span><br />
15 <input type="password" name="old_pass" value="" />
16 </label>
17 <br />
18 <br />
19
20 <label for="pass1">
21 <span class="form_item_title">New password</span><br />
22 <input type="password" name="pass1" value="" />
23 </label>
24 <br />
25 <br />
26
27 <label for="pass2">
28 <span class="form_item_title">New password (re-type)</span><br />
29 <input type="password" name="pass2" value="" />
30 </label>
31 <br />
32 <br />
33
34 <label for="button">
35 <input type="submit" name="button" value="Change password" />
36 </label>
37
38 </form>
39 </div>
40 ';
41
42 ?>
File inc/user/repo-page.php changed (mode: 100644) (index 430eeca..85aa2e4)
1 1 <?php <?php
2 2 rg_log("/inc/user/repo-page"); rg_log("/inc/user/repo-page");
3 3
4 $user = rg_var_str("user");
5 $repo = rg_var_str("repo");
6
7 4 $_home = ""; $_home = "";
8 5
9 if (rg_user_ok($repo) !== TRUE) {
10 $_home .= "Invalid repo!";
6 if (rg_user_ok($user) !== TRUE) {
7 $_home .= "Invalid user!";
11 8 return; return;
12 9 } }
13 10
 
... ... if (rg_repo_ok($repo) !== TRUE) {
16 13 return; return;
17 14 } }
18 15
19 $_home .= "<h1>" . htmlspecialchars($repo) . "</h1>\n";
16 $rr = array("user" => $user, "repo" => $repo);
17 $ri = rg_repo_info($db, $rr);
18 if ($ri === FALSE) {
19 $_home .= "Internal error!";
20 return;
21 }
20 22
21 $rr = array("type" => "user", "user" => $user, "repo" => $repo);
23 $_more = array(
24 "owner" => $user,
25 "url" => rg_re_repopage($ri['organization'], $user, $repo),
26 );
27 $_home .= rg_template($THEME . "/repo/main.html", $ri, $_more);
28
29 $type = ($ri['organization'] == 1) ? "" : "user";
30 $rr = array("type" => $type, "user" => $user, "repo" => $repo);
22 31 $repo_dir = rg_repo_name2base($rr) . $repo . ".git"; $repo_dir = rg_repo_name2base($rr) . $repo . ".git";
23 $_tree = rg_git_ls_tree($repo_dir, "");
24 $_more = array("url" => "xxxxx");
25 $_home .= rg_template($THEME . "/repo/tree", $_tree, $_more);
32
33 putenv("GIT_DIR=$repo_dir");
34
35 if (strcmp($subop, "tree") == 0) {
36 $obj = rg_git_reference($paras[0]);
37 $_tree = rg_git_ls_tree($obj);
38 $_home .= rg_template_table($THEME . "/repo/tree", $_tree, $_more);
39 } else if (strcmp($subop, "blob") == 0) {
40 $obj = rg_git_reference($paras[0]);
41 $blob = array(
42 "obj" => $obj,
43 "content" => rg_git_content($obj)
44 );
45 $_home .= rg_template($THEME . "/repo/blob.html", $blob, $_more);
46 } else { // log
47 $log = rg_git_log(10, FALSE);
48 rg_log("log: " . print_r($log, TRUE));
49 $_home .= rg_git_log_template($log, $THEME . "/repo/log", $_more);
50 }
26 51
27 52 ?> ?>
28 53
File inc/util.inc.php changed (mode: 100644) (index 41c1b09..70db616)
... ... function rg_load()
76 76 */ */
77 77 function rg_re_url($op) function rg_re_url($op)
78 78 { {
79 if (isset($_REQUEST['rewrite_engine']))
80 return "/+" . $op;
79 if (isset($_REQUEST['rwe']))
80 return "/op/" . $op;
81 81
82 return $_SERVER['PHP_SELF'] . "?op=" . $op;
82 return "/?op=" . $op;
83 83 } }
84 84
85 85 /* /*
 
... ... function rg_re_url($op)
87 87 */ */
88 88 function rg_re_post($op) function rg_re_post($op)
89 89 { {
90 if (isset($_REQUEST['rewrite_engine']))
91 return "/+" . $op;
90 if (isset($_REQUEST['rwe']))
91 return "/op/" . $op;
92 92
93 return $_SERVER['PHP_SELF'];
93 return "/";
94 94 } }
95 95
96 function rg_re_repopage($repo_id, $repo_name)
96 function rg_re_repopage($org, $owner, $repo_name)
97 97 { {
98 if (isset($_REQUEST['rewrite_engine']))
99 return "/" . $repo_name;
98 if ($org == 0)
99 $prefix = "/user";
100 else
101 $prefix = "";
100 102
101 return $_SERVER['PHP_SELF'] . "?op=repopage&amp;name=" . $repo_name;
103 $s = $prefix . "/" . $owner . "/" . $repo_name;
104
105 if (isset($_REQUEST['rwe']))
106 return $s;
107
108 return $_SERVER['PHP_SELF'] . "?vv=$s";
102 109 } }
103 110
104 111 function rg_var_str($name) function rg_var_str($name)
 
... ... function rg_menu($a, $rg_ui)
228 235 return $ret; return $ret;
229 236 } }
230 237
238 /*
239 * Builds a html output based on a template with header, footer and line
240 */
241 function rg_template_table($dir, $data, $more)
242 {
243 $head = @file_get_contents($dir . "/header.html");
244 if ($head === FALSE)
245 $head = "";
246
247 $line = @file_get_contents($dir . "/line.html");
248 if ($line === FALSE)
249 $line = "";
250
251 $foot = @file_get_contents($dir . "/footer.html");
252 if ($foot === FALSE)
253 $foot = "";
254
255 foreach ($more as $k => $v) {
256 $m_what[] = "/@@" . $k . "@@/";
257 $m_values[] = htmlspecialchars($v);
258 }
259
260 $head = preg_replace($m_what, $m_values, $head);
261 $foot = preg_replace($m_what, $m_values, $foot);
262
263 $body = "";
264 foreach ($data as $index => $info) {
265 $what = $m_what;
266 $values = $m_values;
267
268 foreach ($info as $k => $v) {
269 $what[] = "/@@" . $k . "@@/";
270 $values[] = htmlspecialchars($v);
271 }
272
273 $body .= preg_replace($what, $values, $line);
274 }
275
276 return $head . $body . $foot;
277 }
278
279 function rg_template($file, $data, $more)
280 {
281 $body = @file_get_contents($file);
282 if ($body === FALSE)
283 return "";
284
285 $what = array();
286 $values = array();
287
288 foreach ($more as $k => $v) {
289 $what[] = "/@@" . $k . "@@/";
290 $values[] = htmlspecialchars($v);
291 }
292
293 foreach ($data as $k => $v) {
294 $what[] = "/@@" . $k . "@@/";
295 $values[] = htmlspecialchars($v);
296 }
297
298 return preg_replace($what, $values, $body);
299 }
300
231 301 ?> ?>
File root/index.php changed (mode: 100644) (index 4b44b8d..7ebccc7)
... ... $ROOT = dirname(__FILE__);
9 9
10 10 $THEME_NAME = "default"; $THEME_NAME = "default";
11 11 $THEME = $ROOT . "/themes/" . $THEME_NAME; $THEME = $ROOT . "/themes/" . $THEME_NAME;
12 $THEME_URL = "themes/" . $THEME_NAME;
13 $THEME_COMMON = "themes/common";
12 $THEME_URL = "/themes/" . $THEME_NAME;
13 $THEME_COMMON = "/themes/common";
14 14
15 15 require_once("/etc/rocketgit/config.php"); require_once("/etc/rocketgit/config.php");
16 16 require_once($INC . "/log.inc.php"); require_once($INC . "/log.inc.php");
 
... ... include_once($INC . "/token.inc.php");
22 22
23 23 rg_log_set_file("/var/log/rocketgit-web/main.log"); rg_log_set_file("/var/log/rocketgit-web/main.log");
24 24
25 // TODO: make subop and subsubop as strings
26 $op = rg_var_str("op");
27 $subop = rg_var_uint("subop");
28 $subsubop = rg_var_uint("subsubop");
25 // Init variables
26 $op = ""; $subop = ""; $subsubop = "";
27 $user = ""; $repo = "";
28 $paras = array();
29
30 // We have variable 'vv' passed from webserver - build 'op' and rest of paras
31 $vv = rg_var_str("vv");
32 if (strncmp($vv, "/op/", 4) == 0) { // command
33 $op = substr($vv, 4);
34 $_t = explode("/", $op);
35 $op = $_t[0];
36 if (isset($_t[1])) {
37 $subop = $_t[1];
38 if (isset($_t[2]))
39 $subsubop = $_t[2];
40 }
41 } else { // user or organization
42 if (strncmp($vv, "/user/", 6) == 0)
43 $vv = substr($vv, 6);
44 $_t = explode("/", $vv);
45 $user = $_t[0];
46 if (isset($_t[1])) {
47 $repo = $_t[1];
48 $op = "repo-page";
49
50 if (isset($_t[2])) {
51 $subop = $_t[2];
52
53 // pass rest of vv to lower layers
54 $i = 3;
55 while (isset($_t[$i])) {
56 $paras[] = $_t[$i];
57 $i++;
58 }
59 }
60 } else {
61 $op = "home-page";
62 }
63 }
64
29 65 $doit = rg_var_uint("doit"); $doit = rg_var_uint("doit");
30 66 $sid = rg_var_re("sid", "/[^A-Za-z0-9]/"); $sid = rg_var_re("sid", "/[^A-Za-z0-9]/");
31 67 $token = rg_var_re("token", "/[^A-Za-z0-9]/"); $token = rg_var_re("token", "/[^A-Za-z0-9]/");
 
... ... $token = rg_var_re("token", "/[^A-Za-z0-9]/");
33 69 rg_log("IP: " . @$_SERVER['REMOTE_ADDR']); rg_log("IP: " . @$_SERVER['REMOTE_ADDR']);
34 70 rg_log("_REQUEST: " . trim(print_r($_REQUEST, TRUE))); rg_log("_REQUEST: " . trim(print_r($_REQUEST, TRUE)));
35 71 rg_log("_COOKIE: " . trim(print_r($_COOKIE, TRUE))); rg_log("_COOKIE: " . trim(print_r($_COOKIE, TRUE)));
36 rg_log("Start! op=$op/$subop/$subsubop, doit=$doit, sid=$sid...");
72 rg_log("Start! op=$op/$subop/$subsubop, user=$user repo=$repo doit=$doit, sid=$sid...");
73 rg_log("paras: " . implode("|", $paras));
37 74
38 75
39 76 // database connection // database connection
 
... ... do {
60 97 // menu // menu
61 98 $first_menu = array( $first_menu = array(
62 99 "login" => array("text" => "Login", "uid0" => 1), "login" => array("text" => "Login", "uid0" => 1),
63 "personal" => array("text" => "Personal"),
100 "home-page" => array("text" => "Personal"),
64 101 "repo" => array("text" => "Repositories"), "repo" => array("text" => "Repositories"),
65 "keys" => array("text" => "SSH keys"),
66 102 "admin" => array("text" => "Admin", "needs_admin" => 1), "admin" => array("text" => "Admin", "needs_admin" => 1),
67 103 "suggestion"=> array("text" => "Suggestion"), "suggestion"=> array("text" => "Suggestion"),
68 104 "logout" => array("text" => "Logout") "logout" => array("text" => "Logout")
69 105 ); );
70 106 $first_menu[$op]['sub'] = $second_menu; $first_menu[$op]['sub'] = $second_menu;
71 107 $menu = implode("\t<br />\n", rg_menu($first_menu, $rg_ui)); $menu = implode("\t<br />\n", rg_menu($first_menu, $rg_ui));
108 $menu .= "<!-- TODO menu ends -->\n";
72 109
73 110 if ($rg_ui['uid'] > 0) if ($rg_ui['uid'] > 0)
74 111 $rg_username = $rg_ui['username']; $rg_username = $rg_ui['username'];
File root/themes/default/main.css changed (mode: 100644) (index e84eb41..1e0332e)
... ... th, td {
32 32 color: red; color: red;
33 33 background-color: yellow; background-color: yellow;
34 34 padding: 3px 20px; padding: 3px 20px;
35 border-radius: 5px 5px 5px 5px;
35 border-radius: 4px 4px 4px 4px;
36 36 border: 1px solid #cccccc; border: 1px solid #cccccc;
37 37 margin: 1px; margin: 1px;
38 box-shadow: 2px 2px 3px #aaa;
38 #box-shadow: 2px 2px 3px #aaa;
39 39 } }
40 40
41 41 .menu:hover { .menu:hover {
 
... ... th, td {
43 43 } }
44 44
45 45 .formarea { .formarea {
46 margin: 20px auto;
46 margin: 5px auto;
47 47 background-color: yellow; background-color: yellow;
48 48 padding: 5px; padding: 5px;
49 49 width: 400px; width: 400px;
50 border-radius: 5px 5px 5px 5px;
50 border-radius: 4px 4px 4px 4px;
51 51 border: 1px solid #cccccc; border: 1px solid #cccccc;
52 box-shadow: 2px 2px 3px #aaa;
52 #box-shadow: 2px 2px 3px #aaa;
53 53 } }
54 54
55 55 .header { .header {
 
... ... th, td {
58 58 border: 1px solid #ffffcc; border: 1px solid #ffffcc;
59 59 background-color: #ffffcc; background-color: #ffffcc;
60 60 padding: 5px 5px; padding: 5px 5px;
61 border-top: 2px solid #ff0000;
61 62 } }
62 63
63 64 .main { .main {
64 65 width: 900px; width: 900px;
65 66 margin: 0 auto; margin: 0 auto;
66 67 background-color: #ffffcc; background-color: #ffffcc;
67 padding: 20px 5px;
68 padding: 10px 5px;
68 69 } }
69 70
70 71 .footer { .footer {
71 72 width: 900px; width: 900px;
72 border-top: 2px solid #cccccc;
73 border-top: 2px solid #ff0000;
73 74 margin: 0 auto; margin: 0 auto;
74 75 background-color: #ffffcc; background-color: #ffffcc;
75 76 padding: 5px 5px; padding: 5px 5px;
 
... ... th, td {
77 78
78 79 .profiling { .profiling {
79 80 width: 900px; width: 900px;
80 border-top: 2px solid #cccccc;
81 border-top: 2px solid #ff0000;
81 82 margin: 0 auto; margin: 0 auto;
82 83 background-color: #ffffcc; background-color: #ffffcc;
83 84 padding: 5px 5px; padding: 5px 5px;
 
... ... th, td {
92 93 font-weight: bold; font-weight: bold;
93 94 } }
94 95
96 .rg_keys_list {
97 margin: 20px auto;
98 background-color: yellow;
99 padding: 5px;
100 width: 600px;
101 border-radius: 4px 4px 4px 4px;
102 border: 1px solid #cccccc;
103 #box-shadow: 2px 2px 3px #aaa;
104 }
105
106 .repo_title {
107 font-size: 15px;
108 font-weight: bold;
109 color: red;
110 }
111
112 .repo_desc {
113 font-size: 12px;
114 color: #888888;
115 }
116
117 .blob_title {
118 font-size: 14px;
119 color: red;
120 }
File root/themes/default/repo/blob.html added (mode: 100644) (index 0000000..2e5dc1c)
1 <span class="blob_title">Blob <a href="@@url@@/blob/@@obj@@">@@obj@@</a></span><br />
2 <br />
3
4 <pre>
5 @@content@@
6 </pre>
File root/themes/default/repo/list/header.html changed (mode: 100644) (index bc86541..e988ebc)
1 1 <table> <table>
2 2 <tr> <tr>
3 <th>Mode</th>
4 <th>Type</th>
5 <th>Size</th>
6 <th>File</th>
7 <th>Ref</th>
3 <th>User / name</th>
4 <th>Description</th>
5 <th>Clone of</th>
6 <th>Creation date (UTC)</th>
7 <th>Default rights</th>
8 <th>Disk used/max</th>
9 <th>Max commit size</th>
10 <th>Max users</th>
8 11 </tr> </tr>
9 12
File root/themes/default/repo/list/line.html changed (mode: 100644) (index adfb29f..fd69ccd)
1 1 <tr> <tr>
2 <td><a href="@@url@@">@@owner@@/@@name@@</a></td>
3 <td>@@description@@</td>
2 <td><a href="@@link@@">@@owner@@/@@name@@</a></td>
3 <td><small>@@description@@</small></td>
4 4 <td>@@clone_of@@</td> <td>@@clone_of@@</td>
5 5 <td>@@creation@@</td> <td>@@creation@@</td>
6 6 <td>@@rights@@</td> <td>@@rights@@</td>
File root/themes/default/repo/log/footer.html copied from file root/themes/default/repo/list/footer.html (similarity 100%)
File root/themes/default/repo/log/header.html added (mode: 100644) (index 0000000..f79e995)
1 <table >
2 <tr>
3 <th>Subject</th>
4 <th>SHA-1</th>
5 <th>Author</th>
6 <th>Date</th>
7 <th>Files changed</th>
8 <th>Lines added</th>
9 <th>Lines deleted</th>
10 </tr>
File root/themes/default/repo/log/line.html added (mode: 100644) (index 0000000..1f68ab2)
1 <tr>
2 <td>@@subject@@</td>
3 <td>@@sha1_short@@</td>
4 <td>@@author name@@ (@@author email@@)</td>
5 <td>@@author date UTC@@</td>
6 <td>@@files_changed@@</td>
7 <td>@@lines_add@@</td>
8 <td>@@lines_del@@</td>
9 </tr>
File root/themes/default/repo/main.html added (mode: 100644) (index 0000000..86622d7)
1 <span class="repo_title"><a href="@@url@@">@@owner@@/@@name@@</a></span><br />
2 <span class="repo_desc">@@description@@</span><br />
3 <br />
4
5 <a href="@@url@@/log">Log</a>
6 <a href="@@url@@/tree">Tree</a>
7 <a href="@@url@@/stats">Stats</a>
8 <br />
9 <br />
File root/themes/default/repo/tree/header.html changed (mode: 100644) (index bc86541..80d0cdf)
3 3 <th>Mode</th> <th>Mode</th>
4 4 <th>Type</th> <th>Type</th>
5 5 <th>Size</th> <th>Size</th>
6 <th>File</th>
7 6 <th>Ref</th> <th>Ref</th>
7 <th>File</th>
8 8 </tr> </tr>
9
File root/themes/default/repo/tree/line.html changed (mode: 100644) (index 2812c1d..0a87018)
2 2 <td>@@mode@@</td> <td>@@mode@@</td>
3 3 <td>@@type@@</td> <td>@@type@@</td>
4 4 <td>@@size@@</td> <td>@@size@@</td>
5 <td>@@file@@</td>
6 5 <td>@@ref@@</td> <td>@@ref@@</td>
6 <td><a href="@@url@@/@@type@@/@@ref@@">@@file@@</a></td>
7 7 </tr> </tr>
File samples/config.php changed (mode: 100644) (index a402042..201e3ae)
4 4 // Base // Base
5 5 $rg_base = "/home/rocketgit"; $rg_base = "/home/rocketgit";
6 6
7 // Base for repositories
8 $rg_base_repo = $rg_base . "/repositories";
9
10 7 // Database // Database
11 8 $rg_sql = "user=rocketgit dbname=rocketgit"; $rg_sql = "user=rocketgit dbname=rocketgit";
12 9 $rg_sql_debug = 1; $rg_sql_debug = 1;
13 10
14 11 // Session // Session
15 $rg_session_time = 3600;
12 $rg_session_time = 7200;
16 13
17 14 // Keys // Keys
18 15 $rg_keys_file = $rg_base . "/.ssh/authorized_keys"; $rg_keys_file = $rg_base . "/.ssh/authorized_keys";
 
... ... $rg_scripts = "/usr/share/rocketgit";
24 21 $rg_repo_allow = '/^[A-Za-z0-9_.-]*$/'; $rg_repo_allow = '/^[A-Za-z0-9_.-]*$/';
25 22
26 23 // Allowed repo name length // Allowed repo name length
24 $rg_repo_min_len = 2;
27 25 $rg_repo_max_len = 64; $rg_repo_max_len = 64;
28 26
29 27 // Allowed user names (regular expression) // Allowed user names (regular expression)
 
... ... $rg_pass_key = "reigjmn9483jfisendfhwefhefhesfuhfskhjukhtw4khfwkur";
43 41 $rg_admin_name = "RocketGit Admin"; $rg_admin_name = "RocketGit Admin";
44 42 $rg_admin_email = "admin@site.tld"; $rg_admin_email = "admin@site.tld";
45 43
46 // Set to 1 to allow any visitor to create an account
44 // Set to 1 to allow any visitor to create an account.
45 // Else, only the admin can create accounts.
47 46 $rg_account_allow_creation = 1; $rg_account_allow_creation = 1;
48 47
48 // Maximum number of keys per user
49 $rg_max_ssh_keys = 10;
50
49 51 ?> ?>
File samples/rg.conf changed (mode: 100644) (index c125f16..a56d1b2)
13 13 </Directory> </Directory>
14 14
15 15 RewriteEngine On RewriteEngine On
16 RewriteLog /var/log/httpd/rg-Rewrite.log
17 RewriteLogLevel 3
16 #RewriteLog /var/log/httpd/rg-Rewrite.log
17 #RewriteLogLevel 3
18 18
19 19 # Allow .ico and 'themes' folder # Allow .ico and 'themes' folder
20 20 RewriteCond %{REQUEST_URI} ^/(favicon\.ico|themes) RewriteCond %{REQUEST_URI} ^/(favicon\.ico|themes)
 
22 22
23 23 # index.php is special # index.php is special
24 24 RewriteCond %{REQUEST_URI} ^/index\.php RewriteCond %{REQUEST_URI} ^/index\.php
25 RewriteRule .* /index.php?rewrite_engine=1 [L,QSA]
25 RewriteRule .* /index.php?rwe=1 [L,QSA]
26 26
27 RewriteCond %{REQUEST_URI} ^/\+
28 RewriteRule ^/\+(.*) /index.php?rewrite_engine=1&op=$1 [L,QSA]
27 # all rest
28 RewriteRule (.*) /index.php?rwe=1&vv=$1 [L,QSA]
29 29
30 RewriteCond %{REQUEST_URI} ^/.+
31 RewriteRule ^/(.+) /index.php?rewrite_engine=1&op=repopage&name=$1 [L,QSA]
32 30
33 31 # Compress # Compress
34 32 AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript
File scripts/cron.php changed (mode: 100644) (index b1affcd..621be94)
... ... if ($db === FALSE) {
31 31 if (date("H") == 0) { if (date("H") == 0) {
32 32 rg_log("Compute repository sizes if dirty..."); rg_log("Compute repository sizes if dirty...");
33 33 // delete 'dirty' files // delete 'dirty' files
34 $sql = "SELECT * FROM repos";
34 $sql = "SELECT a.*, b.username, b.organization"
35 . " FROM repos a, users b"
36 . " WHERE a.uid = b.uid";
35 37 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
36 38 if ($res === FALSE) { if ($res === FALSE) {
37 39 rg_log("Cannot run query (" . rg_sql_error() . ")!"); rg_log("Cannot run query (" . rg_sql_error() . ")!");
38 40 } else { } else {
39 41 while (($row = rg_sql_fetch_array($res))) { while (($row = rg_sql_fetch_array($res))) {
40 rg_log("Processing repository [" . $row['name'] . "]...");
41 $repo_path = rg_repo_name2base($row['name']) . $row['name'] . ".git";
42 $type = ($row['organization'] == 1) ? "org" : "user";
43
44 rg_log("Processing $type/" . $row['username']
45 . "/" . $row['name'] . "...");
46 $repo_path = rg_repo_name2base($row['username'], $row['name']) . $row['name'] . ".git";
42 47 $disk_used_mb = rg_repo_disk_mb($repo_path); $disk_used_mb = rg_repo_disk_mb($repo_path);
43 48 $sql = "UPDATE repos SET disk_used_mb = $disk_used_mb" $sql = "UPDATE repos SET disk_used_mb = $disk_used_mb"
44 49 . " WHERE repo_id = " . $row['repo_id']; . " WHERE repo_id = " . $row['repo_id'];
File scripts/q.php changed (mode: 100644) (index 2fd1d85..cc553b1)
... ... if ($db === FALSE) {
29 29 exit(1); exit(1);
30 30 } }
31 31
32 // Limit the number of runs, so we can upgrade the software and this script will
33 // restart.
34 $runs = 1;
35 while ($runs-- > 0) {
36 // check machine load - if too big we will delay
37 while (1) {
38 $load = rg_load();
39 if ($load < 10)
40 break;
32 $original_mtime = filemtime(__FILE__);
33
34 // Check our mtime so we can upgrade the software and this script will restart.
35 while (TRUE) {
36 $mtime = filemtime(__FILE__);
37 if ($mtime != $original_mtime) {
38 rg_log("File changed. Exiting...");
39 break;
40 }
41 41
42 rg_log("\tLoad too big!");
42 // check machine load - if too big we will delay
43 $load = rg_load();
44 if ($load > 10) {
45 rg_log("\tLoad too big!");
43 46 sleep(10); sleep(10);
47 continue;
44 48 } }
45 49
46 50 rg_log("Check to create not-yet-created repos..."); rg_log("Check to create not-yet-created repos...");
47 51 // Ordered by master to create masters first // Ordered by master to create masters first
48 $sql = "SELECT repo_id, master, name FROM repos"
49 . " WHERE deleted = 0"
50 . " AND git_dir_done = 0"
51 . " ORDER BY master";
52 $sql = "SELECT a.repo_id, a.master, a.name, b.username, b.organization"
53 . " FROM repos a, users b"
54 . " WHERE a.uid = b.uid"
55 . " AND a.deleted = 0"
56 . " AND a.git_dir_done = 0"
57 . " ORDER BY a.master";
52 58 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
53 59 if ($res === FALSE) { if ($res === FALSE) {
54 60 rg_log("\tCannot query (" . rg_sql_error() . ")!"); rg_log("\tCannot query (" . rg_sql_error() . ")!");
55 61 exit(1); exit(1);
56 62 } }
57 63 while (($row = rg_sql_fetch_array($res))) { while (($row = rg_sql_fetch_array($res))) {
58 rg_log("\tProcess repo " . $row['name'] . "...");
64 $type = ($row['organization'] == 1) ? "org" : "user";
65
66 rg_log("\tProcessing $type/" . $row['username']
67 . "/" . $row['name'] . "...");
59 68
60 $dst = rg_repo_name2base($row['name']) . $row['name'] . ".git";
69 $rr = array("type" => $type,
70 "user" => $row['username'],
71 "repo" => $row['name']);
72 $dst = rg_repo_name2base($rr) . $row['name'] . ".git";
61 73 if ($row['master'] == 0) { if ($row['master'] == 0) {
62 74 $r = rg_git_init($dst); $r = rg_git_init($dst);
63 75 if ($r === FALSE) { if ($r === FALSE) {
64 76 rg_log("\tCannot init master!"); rg_log("\tCannot init master!");
65 } else {
66 rg_repo_git_done($db, $row['repo_id']);
77 continue;
67 78 } }
79
80 rg_repo_git_done($db, $row['repo_id']);
68 81 } else { } else {
69 $mi = rg_repo_info($db, $row['master'], "");
82 $rr = array("repo_id" => $row['master']);
83 $mi = rg_repo_info($db, $rr);
70 84 if ($mi['exists'] != 1) { if ($mi['exists'] != 1) {
71 85 rg_log("\tCannot find master!"); rg_log("\tCannot find master!");
72 } else {
73 $src = rg_repo_name2base($mi['name']) . $mi['name'] . ".git";
74 $r = rg_git_clone($src, $dst);
75 if ($r === FALSE) {
76 rg_log("\tCould not create repo!");
77 } else {
78 rg_repo_git_done($db, $row['repo_id']);
79 }
86 continue;
80 87 } }
88
89 $type = ($mi['organization'] == 1) ? "org" : "user";
90 $ui = rg_user_info($db, $mi['uid'], "", "");
91 if ($ui['ok'] != 1) {
92 rg_log("\tCannot lookup uid "
93 . $mi['uid'] . " (" . rg_user_info() . ")!");
94 continue;
95 }
96
97 $rr = array("type" => $type,
98 "user" => $ui['username'],
99 "repo" => $mi['name']);
100 $src = rg_repo_name2base($rr) . $mi['name'] . ".git";
101 $r = rg_git_clone($src, $dst);
102 if ($r === FALSE) {
103 rg_log("\tCould not create repo!");
104 continue;
105 }
106
107 rg_repo_git_done($db, $row['repo_id']);
81 108 } }
82 109 } }
83 110 rg_sql_free_result($res); rg_sql_free_result($res);
File scripts/remote.php changed (mode: 100644) (index d8c8822..79c7ee6)
... ... if (strncmp($cmd_repo, "git-upload-pack", 15) == 0) {
96 96 } }
97 97
98 98 // extract repository name // extract repository name
99 $repo = substr($cmd_repo, strlen($cmd));
100 $repo = trim($repo, "' ");
101 $repo = ltrim($repo, "/");
102 $repo = preg_replace('/\.git$/' , '', $repo);
99 $_t = substr($cmd_repo, strlen($cmd));
100 $_t = trim($_t, "' ");
101 $_t = ltrim($_t, "/");
102 $_t = preg_replace('/\.git$/' , '', $_t);
103 $_t = explode("/", $_t);
104 $type = $_t[0];
105 $user = $_t[1];
106 $repo = $_t[2];
103 107
104 rg_log("host=[$host] cmd=[$cmd] repo=[$repo].");
108 rg_log("host=[$host] cmd=[$cmd] type=[$type] user=[$user] repo=[$repo].");
105 109
106 110 // validity/security checks // validity/security checks
111 if ((strcmp($type, "user") != 0) && (strcmp($type, "org") != 0))
112 fatal("URL is incorrect. You may want to replace [$type] with 'org' or 'user'!");
113
114 if (rg_user_ok($user) !== TRUE)
115 fatal("User [$user] is invalid (" . rg_user_error() . ")!");
116
107 117 if (rg_repo_ok($repo) !== TRUE) if (rg_repo_ok($repo) !== TRUE)
108 118 fatal("Repo [$repo] is invalid (" . rg_repo_error() . ")"); fatal("Repo [$repo] is invalid (" . rg_repo_error() . ")");
109 119
 
... ... $db = rg_sql_open($rg_sql);
111 121 if ($db === FALSE) if ($db === FALSE)
112 122 fatal("Internal error (db)!"); fatal("Internal error (db)!");
113 123
114 // load info about the repository
115 $ri = rg_repo_info($db, 0, $repo);
124 // Loading info about the repository
125 $rr = array("type" => $type, "user" => $user, "repo" => $repo);
126 $ri = rg_repo_info($db, $rr);
116 127 if ($ri['ok'] != 1) if ($ri['ok'] != 1)
117 128 fatal("Temporary error!"); fatal("Temporary error!");
118 129 if ($ri['exists'] != 1) if ($ri['exists'] != 1)
 
... ... if (rg_rights_allow($rights, $needed_rights) === FALSE)
132 143
133 144 // TODO: limit time and/or cpu // TODO: limit time and/or cpu
134 145
135 $repo_base = rg_repo_name2base($repo);
146 $repo_base = rg_repo_name2base($rr);
136 147 $repo_path = $repo_base . $repo . ".git"; $repo_path = $repo_base . $repo . ".git";
137 148 rg_log("repo_path=$repo_path."); rg_log("repo_path=$repo_path.");
138 149
File tests/Makefile changed (mode: 100644) (index 1af6ef6..ce989f6)
... ... hook_update:
31 31 ./hook_update.sh ./hook_update.sh
32 32
33 33 hook_pre-receive: hook_pre-receive:
34 ./hook_pre_receive.sh
34 ./hook_pre-receive.sh
35 35
36 36
37 37 .PHONY: clean .PHONY: clean
File tests/git.php changed (mode: 100644) (index 603b14e..ad4d370)
... ... if ($r !== TRUE) {
18 18 system("rm -rf git.tmp"); system("rm -rf git.tmp");
19 19
20 20
21 echo "OK\n";
21 echo "git: OK\n";
22 22 ?> ?>
File tests/hook_pre-receive.sh changed (mode: 100755) (index e752891..29522c7)
... ... echo "Rights=${ROCKETGIT_RIGHTS}."
35 35
36 36 rm -rf hook_pre-receive_*.git rm -rf hook_pre-receive_*.git
37 37
38 echo "Done!"
38 echo "hook_pre-receive: OK!"
File tests/hook_update.sh changed (mode: 100755) (index 36b13a1..5341187)
... ... echo "Rights=${ROCKETGIT_RIGHTS}."
168 168
169 169 rm -rf hook_update_*.git rm -rf hook_update_*.git
170 170
171 echo "Done!"
171 echo "hook_pre-update: OK!";
File tests/keys.php changed (mode: 100644) (index c3eb80f..1e6d561)
... ... if ($r === FALSE) {
78 78 } }
79 79
80 80
81 // test rg_max_ssh_keys
82 $rg_max_ssh_keys = 1;
83 // insert a key - should succeed
84 $rg_ui = array("uid" => 10, "is_admin" => 0);
85 $key = "aaa 'bbb' first_key";
86 $key_id1 = rg_keys_add($db, $rg_ui, $key);
87 if ($key_id1 === FALSE) {
88 echo "Cannot add key 1 (" . rg_keys_error() . ")!\n";
89 exit(1);
90 }
91 // insert a key - must fail
92 $rg_ui = array("uid" => 10, "is_admin" => 0);
93 $key = "aaa 'bbb' second_key";
94 $key_id2 = rg_keys_add($db, $rg_ui, $key);
95 if ($key_id2 !== FALSE) {
96 echo "Seems we can add more keys than allowed!\n";
97 exit(1);
98 }
99
100
101
81 102 rg_sql_close($db); rg_sql_close($db);
82 103
83 104 echo "keys: OK\n"; echo "keys: OK\n";
File tests/repo.php changed (mode: 100644) (index 819e53c..e3f10bd)
... ... $rg_sql_debug = 1;
12 12
13 13 // defaults // defaults
14 14 $rg_repo_max_len = 100; $rg_repo_max_len = 100;
15 $rg_base_repo = "/u";
15 $rg_base = "/base";
16 16
17 17
18 18 rg_log("name2base1"); rg_log("name2base1");
19 $e = "/u/a/a/";
20 $c = rg_repo_name2base("aa");
19 $rr = array("type" => "user", "user" => "user1", "repo" => "junk");
20 $e = "/base/users/u/s/user1/repos/";
21 $c = rg_repo_name2base($rr);
21 22 if (strcmp($c, $e) != 0) { if (strcmp($c, $e) != 0) {
22 23 rg_log("name2base1 is not working correctly: c=$c e=$e."); rg_log("name2base1 is not working correctly: c=$c e=$e.");
23 24 exit(1); exit(1);
24 25 } }
25 26
26 27 rg_log("name2base2"); rg_log("name2base2");
27 $e = "/u/a/_/";
28 $c = rg_repo_name2base("a");
28 $rr = array("type" => "org", "user" => "u", "repo" => "junk");
29 $e = "/base/orgs/u/_/u/repos/";
30 $c = rg_repo_name2base($rr);
29 31 if (strcmp($c, $e) != 0) { if (strcmp($c, $e) != 0) {
30 32 rg_log("name2base2 is not working correctly: c=$c e=$e."); rg_log("name2base2 is not working correctly: c=$c e=$e.");
31 33 exit(1); exit(1);
 
... ... if ($res === FALSE) {
105 107
106 108 rg_log("test giving rights"); rg_log("test giving rights");
107 109 $repo_id = 1; $repo_id = 1;
108 $ri = rg_repo_info($db, $repo_id, "");
110 $rr = array("repo_id" => $repo_id);
111 $ri = rg_repo_info($db, $rr);
109 112 $uid = 10; $uid = 10;
110 113 $v = rg_repo_rights_set($db, $ri, $uid, "P"); $v = rg_repo_rights_set($db, $ri, $uid, "P");
111 114 if ($v === FALSE) { if ($v === FALSE) {
 
... ... if ($r !== FALSE) {
173 176
174 177 rg_sql_close($db); rg_sql_close($db);
175 178
176 echo "repo: done!\n";
179 echo "repo: OK!\n";
177 180 ?> ?>
File tests/rights.php changed (mode: 100644) (index 984c62e..ed9fa58)
... ... if ($r !== TRUE) {
55 55 exit(1); exit(1);
56 56 } }
57 57
58 echo "rights: OK\n";
58 echo "rights: OK!\n";
59 59 ?> ?>
File tests/state.php changed (mode: 100644) (index 0b1d963..89502f9)
... ... if (strcmp($r, "cucu") != 0) {
55 55
56 56 rg_sql_close($db); rg_sql_close($db);
57 57
58 echo "state: OK\n";
58 echo "state: OK!\n";
59 59 ?> ?>
File tests/user.php changed (mode: 100644) (index 1f9f35c..3bfd693)
... ... $rg_user_max_len = 20;
12 12 $rg_pass_key = "aaa"; $rg_pass_key = "aaa";
13 13 $rg_session_time = 3600; $rg_session_time = 3600;
14 14 $rg_user_allow = '/^[A-Za-z0-9_.-]*$/'; $rg_user_allow = '/^[A-Za-z0-9_.-]*$/';
15 $rg_admin_email = "admin@localhost";
16 $rg_admin_name = "RocketGit Admin";
15 17
16 18
17 19 $db = rg_sql_open("dbname=trg"); $db = rg_sql_open("dbname=trg");
 
... ... $uid = rg_sql_last_id($db);
39 41
40 42 $v = rg_user_forgot_pass_mail($db, "rg@localhost"); $v = rg_user_forgot_pass_mail($db, "rg@localhost");
41 43 if ($v === FALSE) { if ($v === FALSE) {
42 echo "Error: " . user_error() . "!\n";
44 echo "Error: " . rg_user_error() . "!\n";
43 45 exit(1); exit(1);
44 46 } }
45 47
 
... ... if ($r['uid'] != $uid) {
118 120 exit(1); exit(1);
119 121 } }
120 122
121 echo "user: OK\n";
123 // test name2path
124 $rg_base = "/base"; $user = "b"; $e = "/base/users/b/_/b";
125 $rr = array("type" => "user", "user" => $user);
126 $r = rg_user_name2path($rr);
127 if (strcmp($r, $e) != 0) {
128 echo "name2path: e=[$e] != r=[$r]!\n";
129 exit(1);
130 }
131
132 echo "user: OK!\n";
122 133 ?> ?>
File tests/util.php changed (mode: 100644) (index d1b73e1..979ec2f)
... ... if ($r !== TRUE) {
23 23 exit(1); exit(1);
24 24 } }
25 25
26 echo "util: OK\n";
26 echo "util: OK!\n";
27 27 ?> ?>
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/catalinux/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/rocketgit

Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/rocketgit

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