List of commits:
Subject Hash Author Date (UTC)
Bulk 0923407bff68a58a0b7b034f8a6b4489ece5b237 Catalin(ux) M. BOIE 2012-02-12 22:21:44
Bulk update 30310488bca37cefeba96b52b71c9c3e72c32907 Catalin(ux) M. BOIE 2011-12-15 23:34:03
Profiling tests. afd1df2940fe440cde9b8ede988ff24c051a10d6 Catalin(ux) M. BOIE 2011-11-03 22:10:13
More bulk updates. a2a2e2545eaad61d0c675ea2afb801f207534515 Catalin(ux) M. BOIE 2011-11-03 22:09:34
Another round of bulk updates. 45bb00a88c420d439b4dd19971808722e4a70895 Catalin(ux) M. BOIE 2011-10-24 22:31:14
Bulk update. Mostly css. 04734cd7cfc4fd4ec55dad70a3490f3065027639 Catalin(ux) M. BOIE 2011-10-03 23:18:26
Added rg_exec function and converted all calls from exec to rg_exec. 097157e5886dace2b9f67ca238a1063a3baff4a0 Catalin(ux) M. BOIE 2011-09-28 03:28:49
Another round of bulk updates cb9dbb75518ab3c214167646197ca7eb0de8e4e6 Catalin(ux) M. BOIE 2011-09-26 19:22:12
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
Commit 0923407bff68a58a0b7b034f8a6b4489ece5b237 - Bulk
Author: Catalin(ux) M. BOIE
Author date (UTC): 2012-02-12 22:21
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2012-02-13 00:09
Parent(s): 30310488bca37cefeba96b52b71c9c3e72c32907
Signer:
Signing key:
Signing status: N
Tree: 1fedbc97e9eca4b6411bfa782281e05d4293bcb4
File Lines added Lines deleted
Makefile.in 1 1
TODO 48 13
hooks/post-receive 2 2
hooks/pre-receive 7 7
hooks/update 14 14
inc/admin/users/user.form.php 8 26
inc/db/struct.inc.php 8 3
inc/dispatch/dispatch.php 3 8
inc/feedback/suggestion.form.php 2 8
inc/git.inc.php 30 6
inc/keys.inc.php 1 1
inc/log.inc.php 28 0
inc/login/login.form.php 2 8
inc/login/login.php 5 8
inc/mr.inc.php 30 0
inc/prof.inc.php 2 1
inc/repo.inc.php 32 24
inc/repo/repo.form.php 1 1
inc/repo/repo.php 31 24
inc/repo/repo_page.php 0 175
inc/repo/search.form.php 2 6
inc/rights.inc.php 7 3
inc/sql.inc.php 3 1
inc/user.inc.php 43 4
inc/user/confirm.php 8 8
inc/user/forgot.php 10 11
inc/user/home-page.php 3 3
inc/user/repo-page.php 55 22
inc/user/repo/admin.php 37 0
inc/user/repo/delete/delete.php 27 0
inc/user/repo/edit/edit.php 68 0
inc/user/repo/rights/rights.form.php 4 10
inc/user/repo/rights/rights.php 76 0
inc/util.inc.php 81 65
root/index.php 24 39
root/themes/default/index.php 1 1
root/themes/default/logo/rg1.png 0 0
root/themes/default/logo/rg16x16.png 0 0
root/themes/default/logo/rg2.png 0 0
root/themes/default/logo/rg4.png 0 0
root/themes/default/logo/rg5.png 0 0
root/themes/default/main.css 6 1
root/themes/default/msg/internal.txt 1 0
root/themes/default/msg/push_merge_request.txt 0 0
root/themes/default/msg/push_not_allowed.txt 0 0
root/themes/default/repo/admin.html 7 0
root/themes/default/repo/blob.html 1 1
root/themes/default/repo/list/header.html 1 1
root/themes/default/repo/list/line.html 1 1
root/themes/default/repo/log/line.html 1 1
root/themes/default/repo/main.html 12 7
root/themes/default/repo/mr/footer.html 0 0
root/themes/default/repo/mr/header.html 7 0
root/themes/default/repo/mr/line.html 5 0
root/themes/default/repo/mr/nodata.html 1 1
root/themes/default/repo/tree/line.html 1 1
samples/config.php 6 0
scripts/cron.php 7 3
scripts/q.php 3 3
scripts/remote.php 5 5
tests/hook_pre-receive.sh 1 1
tests/keys.php 2 1
tests/prof.php 5 1
tests/repo.php 3 3
tests/root/themes/util/t1/nodata.html 0 0
tests/root/themes/util/t2/footer.html 0 0
tests/root/themes/util/t2/header.html 0 0
tests/root/themes/util/t2/line.html 0 0
tests/root/themes/util/t3/c1 1 0
tests/sql.php 1 0
tests/state.php 1 1
tests/user.php 6 4
tests/util.php 24 3
File Makefile.in changed (mode: 100644) (index 9b340fc..c42fcbd)
... ... clean:
12 12
13 13 install: all install: all
14 14 @mkdir -p $(I_USR_SHARE)/$(PRJ) @mkdir -p $(I_USR_SHARE)/$(PRJ)
15 cp -vdr admin inc hooks root scripts lang $(I_USR_SHARE)/$(PRJ)
15 cp -vdr admin inc hooks root scripts $(I_USR_SHARE)/$(PRJ)
16 16 @mkdir -p $(I_ETC)/xinetd.d @mkdir -p $(I_ETC)/xinetd.d
17 17 cp -vd --no-clobber samples/rg $(I_ETC)/xinetd.d/rocketgit cp -vd --no-clobber samples/rg $(I_ETC)/xinetd.d/rocketgit
18 18 @mkdir -p $(I_ETC)/cron.d @mkdir -p $(I_ETC)/cron.d
File TODO changed (mode: 100644) (index e53f848..8eaf29a)
8 8 [ ] $rg_pass_key should be done in init.php [ ] $rg_pass_key should be done in init.php
9 9 [ ] Changing repo name probably is not working right. [ ] Changing repo name probably is not working right.
10 10 [ ] Run update.php before rpm upgrade the scripts. [ ] Run update.php before rpm upgrade the scripts.
11 [ ] Check if /var/run/rocketgit is really created. Maybe is boot related.
12 Locking is working right? Because seems the repo were created!
13 11 [ ] rg_repo_allow seems to not be used. [ ] rg_repo_allow seems to not be used.
14 12 [ ] Deny any operation till schema update is done. [ ] Deny any operation till schema update is done.
15 13 [ ] Test and fix update.php script. [ ] Test and fix update.php script.
16 14 [ ] Check if rewinds are working as expected. [ ] Check if rewinds are working as expected.
17 [ ] Add rg_mr_queue_process function and call it in cron.php or q.php.
15 [ ] Fix the "edit repo" page!
16 [ ] With FMH rights, seems that we insert a merge request, but create branch is
17 rejected in next hook!
18 [ ] Update of databse must be done from a global init function, not by admin.
19 [ ] Switch all menus to templates!
20 [ ] 'cop' variable is not good - I do not remember what it means!
21 [ ] Why is not working to access a user page ("invalid repo")?!
22 [ ] Delay connection to database.
23 [ ] Fix <label></label> and set class form_item_title!
24 [ ] Get memory statistics from /proc.
25 [ ] CSRF token is not used in admin page for an ordinary user!
26 [ ] Differentiate between owner of a repository, currently logged in user and admin.
27 [ ] Warn before deleting a repo!
28 [ ] Update structure at any function call (after an upgrade).
29 [ ] Store by uid the repos, and make links to them. Make a function to rename
30 a username. We have to keep track of renames so old links will
31 still work.
32 [ ] Move repos to /var/lib
18 33 [ ] [ ]
19 34
20 35 == Normal priority == == Normal priority ==
36 [ ] Put form error messages next to the label.
37 [ ] Get rid of $rr!
38 [ ] favicon.ico is not in theme!
39 [ ] Create unit testing for all functions.
40 [ ] Test error code for rg_sql_query.
41 [ ] Log $ret['errmsg'] for rg_exec
42 [ ] Audit code to replace parts with rg_internal_error.
43 [ ] TODO feature for projects.
44 [ ] Allow SSH keys per repository (only)?
45 [ ] Allow remote 'gc' of a repo, besides an automatic one.
46 [ ] Take care of caching of passwords. Maybe allow a purge of a file from browser?
21 47 [ ] "Lock" button to temporary block access to repository. [ ] "Lock" button to temporary block access to repository.
22 48 Only owner will have access. Only owner will have access.
23 49 We may add also a text that will be output to clients. We may add also a text that will be output to clients.
 
44 70 [ ] Allow to configure to refuse commits with broken spaces/tab mixes. [ ] Allow to configure to refuse commits with broken spaces/tab mixes.
45 71 [ ] Add a repo_prop_set/get function that will set/get a file in .git folder. [ ] Add a repo_prop_set/get function that will set/get a file in .git folder.
46 72 This way we can speed up some lookups (no need for database). Hm. This way we can speed up some lookups (no need for database). Hm.
47 [ ] When we delete an repository, we will do repo_prop_set(repo, disabled) and we will
73 [ ] When we delete a repository, we will do repo_prop_set(repo, disabled) and we will
48 74 return OK, in the background we will do the removing. return OK, in the background we will do the removing.
49 75 Do not forget to also remove clones. Hm. Do not forget to also remove clones. Hm.
50 76 [ ] E-mail aliases section. [ ] E-mail aliases section.
 
61 87 [ ] Do not allow session updates/any command if user is suspended after his/her login. [ ] Do not allow session updates/any command if user is suspended after his/her login.
62 88 [ ] Timeout for connections (ssh/git-daemon/etc.)! [ ] Timeout for connections (ssh/git-daemon/etc.)!
63 89 [ ] Check if we have to respect 4HEXA also on SSH. I think not. [ ] Check if we have to respect 4HEXA also on SSH. I think not.
64 [ ] Limit number of simultaneously connection per repo and per user. Maybe also the time!
90 [ ] Limit number of simultaneously connection per repo and per user.
91 Maybe also the time!
65 92 [ ] Make everywhere present a "Make a sugestion" area. [ ] Make everywhere present a "Make a sugestion" area.
66 93 [ ] On rocketgit website, add "Feedback" area. [ ] On rocketgit website, add "Feedback" area.
67 94 [ ] Allow multiple virtual hosts, with different configurations. [ ] Allow multiple virtual hosts, with different configurations.
 
72 99 [ ] Check http://plathrop.tertiusfamily.net/blog/2010/05/11/git-hooks-branch-acls-and-more/ to block updates that have not pull - a la SVN [ ] Check http://plathrop.tertiusfamily.net/blog/2010/05/11/git-hooks-branch-acls-and-more/ to block updates that have not pull - a la SVN
73 100 [ ] Maybe we should mark the repository as dirty, only in the post-receive hook? Or update is the best place? [ ] Maybe we should mark the repository as dirty, only in the post-receive hook? Or update is the best place?
74 101 [ ] Limit number of commits per push. [ ] Limit number of commits per push.
75 [ ] In %post section we may want to run a script that will do the update of the
76 database, for example.
77 102 [ ] Compute disk_used_mb per user. [ ] Compute disk_used_mb per user.
78 103 [ ] Enforce disk quota. [ ] Enforce disk quota.
79 104 [ ] RSS [ ] RSS
 
90 115 [ ] Undo SELinux stuff when uninstalling applications. [ ] Undo SELinux stuff when uninstalling applications.
91 116 [ ] 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
92 117 [ ] git-notes may be used to attach messages to commits. Nice. [ ] git-notes may be used to attach messages to commits. Nice.
93 [ ] Store also the size of the patch aong history/commit info.
118 [ ] Store also the size of the patch along history/commit info.
94 119 [ ] Check SELinux MLS [ ] Check SELinux MLS
95 120 [ ] Store users and repositories to /var/lib/rocketgit so we can set a proper [ ] Store users and repositories to /var/lib/rocketgit so we can set a proper
96 121 SELinux context on that folder. SELinux context on that folder.
 
100 125 [ ] The rewrite engine should pass a single op for user and for org, but with para org=0 or 1. [ ] The rewrite engine should pass a single op for user and for org, but with para org=0 or 1.
101 126 This is to have the same page for both types of users. This is to have the same page for both types of users.
102 127 [ ] From: http://lwn.net/Articles/460376/ [ ] From: http://lwn.net/Articles/460376/
103 I can confirm that shortcomings with Gitorious' ACL systems were definitely one of the reasons we ended up deciding against it -- it's just not fine-grained enough and made it impossible to achieve the balance of project maintainer / repo manager autonomy and fool-proofness we wanted. gitolite makes us super-happy in that regard now, though.
104 We use a Gitorious instance where I work. One thing that seems impossible to do is have custom hooks. Everything must go through Gitorious' global hooks. If there's a way around this (new version, black magic, whatever), I'd love to hear it.
128 I can confirm that shortcomings with Gitorious' ACL systems were
129 definitely one of the reasons we ended up deciding against it --
130 it's just not fine-grained enough and made it impossible to achieve
131 the balance of project maintainer / repo manager autonomy and
132 fool-proofness we wanted. gitolite makes us super-happy in that regard
133 now, though.
134 We use a Gitorious instance where I work. One thing that seems
135 impossible to do is have custom hooks. Everything must go through
136 Gitorious' global hooks. If there's a way around this (new version,
137 black magic, whatever), I'd love to hear it.
105 138 [ ] Allow git over TLS on a specific port (gits://...). [ ] Allow git over TLS on a specific port (gits://...).
106 139 [ ] KDE: http://news.ycombinator.com/item?id=2972107 [ ] KDE: http://news.ycombinator.com/item?id=2972107
107 140 [ ] To investigate how gitolite is dealing with pushes without custom daemon. [ ] To investigate how gitolite is dealing with pushes without custom daemon.
 
110 143 [ ] Work flows: Allow user to edit workflows. For example: [ ] Work flows: Allow user to edit workflows. For example:
111 144 - A merge request that is approved in a MR queue will make it - A merge request that is approved in a MR queue will make it
112 145 automatically to the specified queues. automatically to the specified queues.
113 [ ] Use $rr['prefix']
114 [ ] At push time we may generate some nice informative output (commits, last time when current user commited etc.)
146 [ ] At push time we may generate some nice informative output (commits,
147 last time when current user commited etc.)
148 [ ] Team suports
149 [ ] Bulk add users/teams/repos/bugs/etc.
115 150
116 151 == Graphics == == Graphics ==
117 152 [ ] http://static.phpcloud.com/images/banner/phpcloudcom-spaceship-banner-970x404px.jpg [ ] http://static.phpcloud.com/images/banner/phpcloudcom-spaceship-banner-970x404px.jpg
 
136 171 Branch File Rights Branch File Rights
137 172 B2 dir/*.png FPA B2 dir/*.png FPA
138 173 * dir2 A * dir2 A
139 * * F
174 * * F
File hooks/post-receive changed (mode: 100755) (index 7b01448..9c4dabd)
... ... umask(0022);
34 34 $f = @fopen("php://stdin", "r"); $f = @fopen("php://stdin", "r");
35 35 if ($f === FALSE) { if ($f === FALSE) {
36 36 rg_log("Error: Cannot open stdin!"); rg_log("Error: Cannot open stdin!");
37 rg_fatal("Internal error!");
37 rg_git_fatal("Internal error!");
38 38 } }
39 39 while (($set = fgets($f))) { while (($set = fgets($f))) {
40 40 $set = trim($set); $set = trim($set);
 
... ... while (($set = fgets($f))) {
48 48 rg_log("refname=$refname old_rev=$old_rev new_rev=$new_rev."); rg_log("refname=$refname old_rev=$old_rev new_rev=$new_rev.");
49 49
50 50 if (empty($refname) || empty($old_rev) || empty($new_rev)) if (empty($refname) || empty($old_rev) || empty($new_rev))
51 rg_fatal("Invalid parameters [$old_rev $new_rev $refname]!");
51 rg_git_fatal("Invalid parameters [$old_rev $new_rev $refname]!");
52 52
53 53 // TODO: What we should do here?! check man githooks and git-receive-pack! // TODO: What we should do here?! check man githooks and git-receive-pack!
54 54 } }
File hooks/pre-receive changed (mode: 100755) (index 6de9178..aa797ac)
... ... umask(0022);
39 39 $f = @fopen("php://stdin", "r"); $f = @fopen("php://stdin", "r");
40 40 if ($f === FALSE) { if ($f === FALSE) {
41 41 rg_log("Error: Cannot open stdin!"); rg_log("Error: Cannot open stdin!");
42 rg_fatal("Internal error!");
42 rg_git_fatal("Internal error!");
43 43 } }
44 44 while (($set = fgets($f))) { while (($set = fgets($f))) {
45 45 $set = trim($set); $set = trim($set);
 
... ... while (($set = fgets($f))) {
53 53 rg_log("refname=$refname old_rev=$old_rev new_rev=$new_rev."); rg_log("refname=$refname old_rev=$old_rev new_rev=$new_rev.");
54 54
55 55 if (empty($refname) || empty($old_rev) || empty($new_rev)) if (empty($refname) || empty($old_rev) || empty($new_rev))
56 rg_fatal("Invalid parameters [$old_rev $new_rev $refname]!");
56 rg_git_fatal("Invalid parameters [$old_rev $new_rev $refname]!");
57 57
58 58 if (rg_rights_allow($rights, "P") === FALSE) { if (rg_rights_allow($rights, "P") === FALSE) {
59 59 if (rg_rights_allow($rights, "H") === FALSE) { if (rg_rights_allow($rights, "H") === FALSE) {
60 $msg = rg_template($rg_scripts . "/lang/en/push_not_allowed.txt", array());
61 rg_fatal($refname. ":\n" . $msg);
60 $msg = rg_template("msg/push_not_allowed.txt", array());
61 rg_git_fatal($refname. ":\n" . $msg);
62 62 } }
63 63
64 64 // anonymous push - create a merge request // anonymous push - create a merge request
65 65 $r = rg_mr_queue_add($repo_id, $namespace, $old_rev, $new_rev, $r = rg_mr_queue_add($repo_id, $namespace, $old_rev, $new_rev,
66 66 $refname, $ip); $refname, $ip);
67 67 if ($r !== TRUE) if ($r !== TRUE)
68 rg_fatal($refname . ":\n" . rg_mr_error());
68 rg_git_fatal($refname . ":\n" . rg_mr_error());
69 69 // TODO: Can we reject individual updates not all of them?! // TODO: Can we reject individual updates not all of them?!
70 70
71 $msg = rg_template($rg_scripts . "/lang/en/push_merge_request.txt", array());
72 rg_info($refname . ":\n" . $msg);
71 $msg = rg_template("msg/push_merge_request.txt", array());
72 rg_git_info($refname . ":\n" . $msg);
73 73 } }
74 74 } }
75 75 fclose($f); fclose($f);
File hooks/update changed (mode: 100755) (index 30b2d1f..695b75d)
... ... $new_rev = rg_git_rev(@$_SERVER['argv'][3]);
37 37 rg_log("refname=$refname old_rev=$old_rev new_rev=$new_rev."); rg_log("refname=$refname old_rev=$old_rev new_rev=$new_rev.");
38 38
39 39 if (empty($refname) || empty($old_rev) || empty($new_rev)) if (empty($refname) || empty($old_rev) || empty($new_rev))
40 rg_fatal("Invalid parameters [$refname $old_rev $new_rev]!");
40 rg_git_fatal("Invalid parameters [$refname $old_rev $new_rev]!");
41 41
42 42 if (strcmp($new_rev, $rg_git_zero) == 0) if (strcmp($new_rev, $rg_git_zero) == 0)
43 43 $new_rev_type = "delete"; $new_rev_type = "delete";
 
... ... if (strcmp($new_rev_type, "commit") == 0) {
56 56 $merge_base = rg_git_merge_base($old_rev, $new_rev); $merge_base = rg_git_merge_base($old_rev, $new_rev);
57 57 if ($merge_base === FALSE) { if ($merge_base === FALSE) {
58 58 rg_log("Error: " . rg_git_error()); rg_log("Error: " . rg_git_error());
59 rg_fatal("Internal error! Try again later!");
59 rg_git_fatal("Internal error! Try again later!");
60 60 } }
61 61
62 62 if (strcmp($merge_base, $old_rev) != 0) if (strcmp($merge_base, $old_rev) != 0)
63 rg_fatal("Non fast-forward is not allowed for $refname!");
63 rg_git_fatal("Non fast-forward is not allowed for $refname!");
64 64 } }
65 65 } }
66 66
 
... ... if (strcmp($new_rev_type, "commit") == 0) {
68 68 rg_log("Un-annotated tag..."); rg_log("Un-annotated tag...");
69 69 if (strcmp($old_rev, $rg_git_zero) == 0) { if (strcmp($old_rev, $rg_git_zero) == 0) {
70 70 if (!rg_rights_allow($rights, "Y")) if (!rg_rights_allow($rights, "Y"))
71 rg_fatal("No rights to create an un-annotated tag!");
71 rg_git_fatal("No rights to create an un-annotated tag!");
72 72 } else { //change } else { //change
73 73 if (!rg_rights_allow($rights, "U")) if (!rg_rights_allow($rights, "U"))
74 rg_fatal("No rights to change an un-annotated tag!");
74 rg_git_fatal("No rights to change an un-annotated tag!");
75 75 } }
76 76 } else if (strncmp($refname, "refs/heads/", 11) == 0) { } else if (strncmp($refname, "refs/heads/", 11) == 0) {
77 77 if (strcmp($old_rev, $rg_git_zero) == 0) { if (strcmp($old_rev, $rg_git_zero) == 0) {
78 78 rg_log("Creating a branch..."); rg_log("Creating a branch...");
79 79 if (!rg_rights_allow($rights, "C")) if (!rg_rights_allow($rights, "C"))
80 rg_fatal("You have no rights to create a branch [$refname]!");
80 rg_git_fatal("You have no rights to create a branch [$refname]!");
81 81 } else if (rg_git_rev_ok($new_rev . "^2")) { } else if (rg_git_rev_ok($new_rev . "^2")) {
82 82 rg_log("Merge commit..."); rg_log("Merge commit...");
83 83 if (!rg_rights_allow($rights, "M")) if (!rg_rights_allow($rights, "M"))
84 rg_fatal("You have no rights to push merge commits in [$refname]!");
84 rg_git_fatal("You have no rights to push merge commits in [$refname]!");
85 85 } else { } else {
86 86 rg_log("Normal commit..."); rg_log("Normal commit...");
87 87 if (!rg_rights_allow($rights, "W")) { if (!rg_rights_allow($rights, "W")) {
88 88 if (!rg_git_whitespace_ok($old_rev, $new_rev)) if (!rg_git_whitespace_ok($old_rev, $new_rev))
89 rg_fatal("Bad whitespace is not allowed!");
89 rg_git_fatal("Bad whitespace is not allowed!");
90 90 } }
91 91 } }
92 92 } else { } else {
93 rg_fatal("Unknown refname provided!");
93 rg_git_fatal("Unknown refname provided!");
94 94 } }
95 95
96 96 // TODO: refs/remotes/* // TODO: refs/remotes/*
 
... ... if (strcmp($new_rev_type, "commit") == 0) {
99 99 if (strncmp($refname, "refs/tags/", 10) == 0) { if (strncmp($refname, "refs/tags/", 10) == 0) {
100 100 rg_log("Deleting an un-annotated tag..."); rg_log("Deleting an un-annotated tag...");
101 101 if (!rg_rights_allow($rights, "u")) if (!rg_rights_allow($rights, "u"))
102 rg_fatal("You have no rights to delete a tag!");
102 rg_git_fatal("You have no rights to delete a tag!");
103 103 } else if (strncmp($refname, "refs/heads/", 11) == 0) { } else if (strncmp($refname, "refs/heads/", 11) == 0) {
104 104 rg_log("Deleting a branch..."); rg_log("Deleting a branch...");
105 105 if (!rg_rights_allow($rights, "D")) if (!rg_rights_allow($rights, "D"))
106 rg_fatal("You have no rights to delete a branch!");
106 rg_git_fatal("You have no rights to delete a branch!");
107 107 } else if (strncmp($refname, "refs/remotes/", 13) == 0) { } else if (strncmp($refname, "refs/remotes/", 13) == 0) {
108 108 rg_log("Deleting a tracking branch..."); rg_log("Deleting a tracking branch...");
109 109 if (!rg_rights_allow($rights, "D")) if (!rg_rights_allow($rights, "D"))
110 rg_fatal("You have no rights to delete a tracking branch!");
110 rg_git_fatal("You have no rights to delete a tracking branch!");
111 111 } }
112 112 } else if (strcmp($new_rev_type, "tag") == 0) { } else if (strcmp($new_rev_type, "tag") == 0) {
113 113 rg_log("It's an annotated tag..."); rg_log("It's an annotated tag...");
114 114 if (strncmp($refname, "refs/tags/", 10) == 0) { if (strncmp($refname, "refs/tags/", 10) == 0) {
115 115 rg_log("Modify tag..."); rg_log("Modify tag...");
116 116 if (!rg_rights_allow($rights, "S")) if (!rg_rights_allow($rights, "S"))
117 rg_fatal("You have no rights to modify a tag!");
117 rg_git_fatal("You have no rights to modify a tag!");
118 118 } }
119 119 } else { } else {
120 120 rg_log("Invalid new_rev type!"); rg_log("Invalid new_rev type!");
121 rg_fatal("Internal error!");
121 rg_git_fatal("Internal error!");
122 122 } }
123 123
124 124
File inc/admin/users/user.form.php changed (mode: 100644) (index cbb4eb9..0cbe6c6)
... ... if ($admin_mode == 1)
21 21 $_form .= '<input type="hidden" name="uid" value="' . $uid . '" />'; $_form .= '<input type="hidden" name="uid" value="' . $uid . '" />';
22 22
23 23 $_form .= ' $_form .= '
24 <label for="xuser">
25 <span class="form_item_title">User name</span><br />
24 <label for="xuser">User name</label><br />
26 25 <input type="text" name="xuser" value="' . $xuser . '" /> <input type="text" name="xuser" value="' . $xuser . '" />
27 </label>
28 26 <br /> <br />
29 27 <br /> <br />
30 28
31 <label for="email">
32 <span class="form_item_title">E-mail</span><br />
29 <label for="email">E-mail</label><br />
33 30 <input type="text" name="email" value="' . $email . '" /> <input type="text" name="email" value="' . $email . '" />
34 </label>
35 31 <br /> <br />
36 32 <br /> <br />
37 33 '; ';
38 34
39 35 if ($pass_mode > 0) { if ($pass_mode > 0) {
40 36 $_form .= ' $_form .= '
41 <label for="xpass">
42 <span class="form_item_title">Password</span><br />
37 <label for="xpass">Password</label><br />
43 38 <input type="password" name="xpass" value="' . $xpass . '" /> <input type="password" name="xpass" value="' . $xpass . '" />
44 </label>
45 39 <br /> <br />
46 40 <br /> <br />
47 41 '; ';
 
... ... $_form .= '
49 43
50 44 if ($pass_mode > 1) { if ($pass_mode > 1) {
51 45 $_form .= ' $_form .= '
52 <label for="xpass2">
53 <span class="form_item_title">Password (confirmation)</span><br />
46 <label for="xpass2">Password (confirmation)</label><br />
54 47 <input type="password" name="xpass2" value="' . $xpass2 . '" /> <input type="password" name="xpass2" value="' . $xpass2 . '" />
55 </label>
56 48 <br /> <br />
57 49 <br /> <br />
58 50 '; ';
 
... ... $_form .= '
60 52
61 53 if ($admin_mode == 1) { if ($admin_mode == 1) {
62 54 $_form .= ' $_form .= '
63 <label for="is_admin">
64 <span class="form_item_title">Admin?</span><br />
55 <label for="is_admin">Admin?</label><br />
65 56 <select name="is_admin"> <select name="is_admin">
66 57 <option value="0"' . $sel_is_admin[0] . '>No</option> <option value="0"' . $sel_is_admin[0] . '>No</option>
67 58 <option value="1"' . $sel_is_admin[1] . '>Yes</option> <option value="1"' . $sel_is_admin[1] . '>Yes</option>
68 59 </select> </select>
69 </label>
70 60 <br /> <br />
71 61 <br /> <br />
72 62
73 <label for="disk_quota_mb">
74 <span class="form_item_title">Disk quota (MiB)</span><br />
63 <label for="disk_quota_mb">Disk quota (MiB)</label><br />
75 64 <input type="text" name="disk_quota_mb" value="' . $disk_quota_mb . '" /> <input type="text" name="disk_quota_mb" value="' . $disk_quota_mb . '" />
76 </label>
77 65 <br /> <br />
78 66 <br /> <br />
79 67
80 <label for="rights">
81 <span class="form_item_title">Rights</span><br />
68 <label for="rights">Rights</label><br />
82 69 ' . rg_rights_checkboxes("user", $rights) . ' ' . rg_rights_checkboxes("user", $rights) . '
83 </label>
84 70 <br /> <br />
85 71 <br /> <br />
86 72 '; ';
87 73 } }
88 74
89 75 $_form .= ' $_form .= '
90 <label for="session_time">
91 <span class="form_item_title">Preferred session time (in seconds)</span><br />
76 <label for="session_time">Preferred session time (in seconds)</label><br />
92 77 <input type="text" name="session_time" value="' . $session_time . '" /> <input type="text" name="session_time" value="' . $session_time . '" />
93 </label>
94 78 <br /> <br />
95 79 <br /> <br />
96 80
97 <label for="button">
98 81 <input type="submit" value="Go!" /> <input type="submit" value="Go!" />
99 </label>
100 82 </form> </form>
101 83 </div> </div>
102 84 '; ';
File inc/db/struct.inc.php changed (mode: 100644) (index 7a4ce72..769176c)
... ... $rg_sql_struct[3]['other'] = array(
84 84
85 85 $rg_sql_struct[4] = array(); $rg_sql_struct[4] = array();
86 86 $rg_sql_struct[4]['tables'] = array( $rg_sql_struct[4]['tables'] = array(
87 "merge requests" => "CREATE TABLE merge_requests ("
87 "merge_requests" => "CREATE TABLE merge_requests ("
88 88 . "repo_id INT NOT NULL" . "repo_id INT NOT NULL"
89 89 . ", itime INT NOT NULL" . ", itime INT NOT NULL"
90 90 . ", namespace TEXT NOT NULL" . ", namespace TEXT NOT NULL"
 
... ... function rg_sql_struct_run($db, $ignore_errors, $drop_tables, $old_schema_ver)
131 131 rg_log("Dropping table [$id]..."); rg_log("Dropping table [$id]...");
132 132 $sql2 = "DROP TABLE IF EXISTS $id"; $sql2 = "DROP TABLE IF EXISTS $id";
133 133 $res = rg_sql_query($db, $sql2); $res = rg_sql_query($db, $sql2);
134 if ($res === FALSE) {
135 rg_log("WARN: Cannot run sql ($sql2) (" . rg_sql_error() . ")!");
136 if (!$ignore_errors)
137 return FALSE;
138 }
134 139 rg_sql_free_result($res); rg_sql_free_result($res);
135 140 } }
136 141
 
... ... function rg_sql_struct_run($db, $ignore_errors, $drop_tables, $old_schema_ver)
140 145 rg_log("WARN: Cannot run sql ($sql) (" . rg_sql_error() . ")!"); rg_log("WARN: Cannot run sql ($sql) (" . rg_sql_error() . ")!");
141 146 if (!$ignore_errors) if (!$ignore_errors)
142 147 return FALSE; return FALSE;
143 } else {
144 rg_sql_free_result($res);
145 148 } }
149
150 rg_sql_free_result($res);
146 151 } }
147 152 } }
148 153 } }
File inc/dispatch/dispatch.php changed (mode: 100644) (index cf54306..1c8ccf9)
... ... case 'login':
14 14
15 15 case 'logout': case 'logout':
16 16 if (rg_sess_destroy($db, $sid, $rg_ui)) { if (rg_sess_destroy($db, $sid, $rg_ui)) {
17 $redispatch = 1;
18 $op = "bye";
17 include($INC . "/bye/bye.php");
18 $body .= $_bye;
19 19 } else { } else {
20 20 $body .= "Cannot log you out. Please clean all cookies" $body .= "Cannot log you out. Please clean all cookies"
21 21 . " and restart browser!"; . " and restart browser!";
 
... ... case 'forgot_send': // forgot pass - send mail
47 47 $body .= $_forgot; $body .= $_forgot;
48 48 break; break;
49 49
50 case 'bye':
51 include($INC . "/bye/bye.php");
52 $body .= $_bye;
53 break;
54
55 50 case 'create_account': case 'create_account':
56 51 include($INC . "/user/create.php"); include($INC . "/user/create.php");
57 52 $body .= $_create; $body .= $_create;
 
... ... case 'suggestion':
69 64
70 65 case 'repo-page': case 'repo-page':
71 66 include($INC . "/user/repo-page.php"); include($INC . "/user/repo-page.php");
72 $body .= $_home;
67 $body .= $_repo_page;
73 68 break; break;
74 69
75 70 case 'home-page': case 'home-page':
File inc/feedback/suggestion.form.php changed (mode: 100644) (index 54c65d0..d6475c2)
... ... $_form .= '
11 11 <input type="hidden" name="doit" value="1" /> <input type="hidden" name="doit" 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 <label for="email">
15 <span class="form_item_title">Your e-mail</span><br />
14 <label for="email">Your e-mail</label><br />
16 15 <input type="text" name="email" value="' . $email . '" /> <input type="text" name="email" value="' . $email . '" />
17 </label>
18 16 <br /> <br />
19 17 <br /> <br />
20 18
21 <label for="suggestion">
22 <span class="form_item_title">Suggestion</span><br />
19 <label for="suggestion">Suggestion</label><br />
23 20 <textarea name="suggestion" rows="6" cols="50">' . $suggestion . '</textarea> <textarea name="suggestion" rows="6" cols="50">' . $suggestion . '</textarea>
24 </label>
25 21 <br /> <br />
26 22 <br /> <br />
27 23
28 <label for="button">
29 24 <input type="submit" name="button" value="Send" /> <input type="submit" name="button" value="Send" />
30 </label>
31 25
32 26 </form> </form>
33 27 </div> </div>
File inc/git.inc.php changed (mode: 100644) (index fe0cf4a..008151d)
... ... function rg_git_error()
21 21 return $rg_git_error; return $rg_git_error;
22 22 } }
23 23
24 function rg_git_fatal($msg)
25 {
26 echo "==========\n";
27 $x = explode("\n", trim($msg));
28 foreach ($x as $line) {
29 rg_log("FATAL: $line");
30 echo "RocketGit: $line\n";
31 }
32 echo "==========\n";
33 exit(1);
34 }
35
36 function rg_git_info($msg)
37 {
38 echo "==========\n";
39 $x = explode("\n", trim($msg));
40 foreach ($x as $line) {
41 rg_log("INFO: $line");
42 echo "RocketGit: $line\n";
43 }
44 echo "==========\n";
45 }
46
24 47 function rg_git_install_hooks($dst) function rg_git_install_hooks($dst)
25 48 { {
26 49 global $rg_scripts; global $rg_scripts;
 
... ... function rg_git_install_hooks($dst)
40 63
41 64 rg_log("\tNot a link to scripts one, make it..."); rg_log("\tNot a link to scripts one, make it...");
42 65 if (!rg_rmdir($dst . "/hooks")) { if (!rg_rmdir($dst . "/hooks")) {
43 rg_git_set_error("cannot remove hooks dir ($php_errormsg)");
66 rg_git_set_error("cannot remove hooks dir"
67 . " (" . rg_util_error() . ")");
44 68 return FALSE; return FALSE;
45 69 } }
46 70 } }
 
... ... function rg_git_log($max, $from, $to, $also_patch)
500 524 /* /*
501 525 * Outputs the result of replacing variables in a template with real variables * Outputs the result of replacing variables in a template with real variables
502 526 */ */
503 function rg_git_log_template($log, $template_dir, $more)
527 function rg_git_log_template($log, $dir, $more)
504 528 { {
505 529 $t = array(); $t = array();
506 530
507 if (count($log) > 0) {
531 if ((is_array($log) && (count($log) > 0))) {
508 532 foreach ($log as $index => $info) { foreach ($log as $index => $info) {
509 533 $v = array(); $v = array();
510 534 foreach ($info['vars'] as $var => $value) foreach ($info['vars'] as $var => $value)
 
... ... function rg_git_log_template($log, $template_dir, $more)
513 537 } }
514 538 } }
515 539
516 return rg_template_table($template_dir, $t, $more);
540 return rg_template_table($dir, $t, $more);
517 541 } }
518 542
519 543 /* /*
 
... ... function rg_git_diff($a, $template_file)
652 676 /* /*
653 677 * Show stats for files changed * Show stats for files changed
654 678 */ */
655 function rg_git_files_stats($a, $theme_dir)
679 function rg_git_files_stats($a, $dir)
656 680 { {
657 681 $t = array(); $t = array();
658 682 foreach ($a as $file => $info) { foreach ($a as $file => $info) {
 
... ... function rg_git_files_stats($a, $theme_dir)
664 688 } }
665 689
666 690 $more = array(); $more = array();
667 return rg_template_table($theme_dir, $t, $more);
691 return rg_template_table($dir, $t, $more);
668 692 } }
669 693
670 694 ?> ?>
File inc/keys.inc.php changed (mode: 100644) (index bfda859..df511a4)
... ... function rg_keys_list($db, $rg_ui, $url)
262 262 $ret .= "</tr>\n"; $ret .= "</tr>\n";
263 263 while (($row = rg_sql_fetch_array($res))) { while (($row = rg_sql_fetch_array($res))) {
264 264 $ret .= "<tr>\n"; $ret .= "<tr>\n";
265 $ret .= " <td>" . gmdate("Y-m-d H:i:s", $row['itime']) . "</td>\n";
265 $ret .= " <td>" . gmdate("Y-m-d H:i", $row['itime']) . "</td>\n";
266 266 $ret .= " <td>" . rg_keys_fingerprint($row['key']) . "</td>\n"; $ret .= " <td>" . rg_keys_fingerprint($row['key']) . "</td>\n";
267 267
268 268 $oper = ""; $oper = "";
File inc/log.inc.php changed (mode: 100644) (index 8696096..ac1a06a)
... ... function rg_log($str)
39 39 fwrite($rg_log_fd, $buf); fwrite($rg_log_fd, $buf);
40 40 } }
41 41
42 function r66_fatal($msg)
43 {
44 rg_log("FATAL: $msg");
45
46 $bt = debug_backtrace();
47 rg_log("Backtrace: " . print_r($bt, TRUE));
48 exit(1);
49 }
50
51 function rg_internal_error($msg)
52 {
53 rg_log("Internal error: $msg");
54
55 $bt = debug_backtrace();
56 rg_log("Backtrace: " . print_r($bt, TRUE));
57 }
58
59 // TODO: send mail or store all data in database
60 function rg_security_violation($msg)
61 {
62 rg_log("Security violation: $msg");
63
64 $bt = debug_backtrace();
65 rg_log("Backtrace: " . print_r($bt, TRUE));
66
67 exit(1);
68 }
69
42 70 ?> ?>
File inc/login/login.form.php changed (mode: 100644) (index bed284e..dc32f70)
... ... $_form .= '
9 9 <input type="hidden" name="subop" value="1" /> <input type="hidden" name="subop" value="1" />
10 10 <input type="hidden" name="doit" value="1" /> <input type="hidden" name="doit" value="1" />
11 11
12 <label for="username">
13 <span class="form_item_title">Username</span><br />
12 <label for="username">Username</label><br />
14 13 <input type="text" name="user" value="' . $user . '" /> <input type="text" name="user" value="' . $user . '" />
15 </label>
16 14 <br /> <br />
17 15 <br /> <br />
18 16
19 <label for="password">
20 <span class="form_item_title">Password</span><br />
17 <label for="password">Password</label><br />
21 18 <input type="password" name="pass" value="' . $pass . '" /> <input type="password" name="pass" value="' . $pass . '" />
22 </label>
23 19 <br /> <br />
24 20 <br /> <br />
25 21
26 <label for="button">
27 22 <input type="submit" name="button" value="Login" /> <input type="submit" name="button" value="Login" />
28 </label>
29 23 </form> </form>
30 24 <br /> <br />
31 25
File inc/login/login.php changed (mode: 100644) (index 6f640c9..485218f)
... ... $pass = rg_var_str("pass");
7 7 $_login = "<br />\n"; $_login = "<br />\n";
8 8
9 9 $errmsg = array(); $errmsg = array();
10 $show_form = 1;
11 10
12 11 if ($doit == 1) { if ($doit == 1) {
13 12 $r = rg_user_login_by_user_pass($db, $user, $pass, $rg_ui); $r = rg_user_login_by_user_pass($db, $user, $pass, $rg_ui);
14 13 if ($r === FALSE) { if ($r === FALSE) {
15 14 $errmsg[] = rg_user_error(); $errmsg[] = rg_user_error();
16 15 } else { } else {
17 $show_form = 0;
18 $redispatch = 1;
19 $op = "home-page"; // redirect to home page
16 // redirect to home page
17 $url = rg_re_userpage($rg_ui);
18 rg_redirect($url);
20 19 } }
21 20 } }
22 21
23 if ($show_form == 1) {
24 include($INC . "/login/login.form.php");
25 $_login .= $_form;
26 }
22 include($INC . "/login/login.form.php");
23 $_login .= $_form;
27 24
28 25 ?> ?>
File inc/mr.inc.php changed (mode: 100644) (index 9d8f058..5a49140)
... ... function rg_mr_queue_process($db)
147 147 return $ret; return $ret;
148 148 } }
149 149
150 /*
151 * Loads merge requests
152 */
153 function rg_mr_load($db, $repo_id, $limit)
154 {
155 rg_log("rg_mr_load: repo_id=$repo_id limit=$limit");
156
157 $sql = "SELECT * FROM merge_requests"
158 . " WHERE repo_id = $repo_id"
159 . " AND done = 0"
160 . " ORDER BY itime"
161 . " LIMIT $limit";
162 $res = rg_sql_query($db, $sql);
163 if ($res === FALSE) {
164 rg_mr_set_error("Cannot load merge requests (" . rg_sql_error() . ")");
165 return FALSE;
166 }
167
168 $ret = array();
169 while (($row = rg_sql_fetch_array($res))) {
170 // compute some fields
171 $row['date_utc'] = gmdate("Y-m-d H:i", $row['itime']);
172
173 $ret[] = $row;
174 }
175 rg_sql_free_result($res);
176
177 return $ret;
178 }
179
150 180 ?> ?>
File inc/prof.inc.php changed (mode: 100644) (index fbd591a..b820bb5)
... ... function rg_prof_log($cb)
82 82 { {
83 83 global $rg_prof_main; global $rg_prof_main;
84 84
85 $cb("Profiling:");
85 86 foreach ($rg_prof_main as $label => $per_label) { foreach ($rg_prof_main as $label => $per_label) {
86 $line = $label . ":";
87 $line = " " . $label . ":";
87 88
88 89 foreach ($per_label as $k => $v) { foreach ($per_label as $k => $v) {
89 90 if ($v > 0) if ($v > 0)
File inc/repo.inc.php changed (mode: 100644) (index 086d0a3..2cd528d)
... ... function rg_repo_name2base($rr)
98 98 * Return info about a repo * Return info about a repo
99 99 * @param rr contains data about user and repo * @param rr contains data about user and repo
100 100 */ */
101 $rg_repo_info_cache = array();
101 102 function rg_repo_info($db, $rr) function rg_repo_info($db, $rr)
102 103 { {
104 global $rg_repo_info_cache;
105
103 106 rg_prof_start("repo_info"); rg_prof_start("repo_info");
104 107
105 rg_log("repo_info: rr:" . implode("|", $rr));
108 $key = implode("__", $rr);
109 if (isset($rg_repo_info_cache[$key]))
110 return $rg_repo_info_cache[$key];
111
112 rg_log("repo_info: rr:" . rg_array2string($rr));
106 113
107 114 $repo_id = isset($rr['repo_id']) ? $rr['repo_id'] : 0; $repo_id = isset($rr['repo_id']) ? $rr['repo_id'] : 0;
108 115 $user = isset($rr['user']) ? $rr['user'] : ""; $user = isset($rr['user']) ? $rr['user'] : "";
 
... ... function rg_repo_info($db, $rr)
111 118 $ret['ok'] = 0; $ret['ok'] = 0;
112 119 $ret['exists'] = 0; $ret['exists'] = 0;
113 120
121 $rg_repo_info_cache[$key] = $ret;
122
114 123 if ($repo_id > 0) { if ($repo_id > 0) {
115 124 $add = " repo_id = $repo_id"; $add = " repo_id = $repo_id";
116 125 } else if (!empty($user) && !empty($repo)) { } else if (!empty($user) && !empty($repo)) {
 
... ... function rg_repo_info($db, $rr)
122 131 $e_repo = rg_sql_escape($db, $repo); $e_repo = rg_sql_escape($db, $repo);
123 132 $add = " uid = " . $ui['uid'] . " AND name = '$e_repo'"; $add = " uid = " . $ui['uid'] . " AND name = '$e_repo'";
124 133 } else { } else {
125 rg_repo_set_error("no repo_id or user/name specified!");
134 rg_repo_set_error("no repo_id or user/repo specified!");
126 135 return $ret; return $ret;
127 136 } }
128 137
 
... ... function rg_repo_info($db, $rr)
143 152 $row['exists'] = 1; $row['exists'] = 1;
144 153 $row['ok'] = 1; $row['ok'] = 1;
145 154
155 $rg_repo_info_cache[$key] = $row;
156
146 157 rg_prof_end("repo_info"); rg_prof_end("repo_info");
147 158
148 159 return $row; return $row;
 
... ... function rg_repo_delete($db, $repo_id, $rg_ui)
280 291 * Update a repository * Update a repository
281 292 * TODO: check rights - also for create? * TODO: check rights - also for create?
282 293 */ */
283 function rg_repo_update($db, &$new)
294 function rg_repo_update($db, $user, &$new)
284 295 { {
285 296 rg_prof_start("repo_update"); rg_prof_start("repo_update");
286 297
287 rg_log("repo_update: repo_id=" . $new['repo_id']
288 . ", name=[" . $new['name'] . "]"
289 . ", max_commit_size=" . $new['max_commit_size']
290 . ", description=[" . $new['description'] . "]"
291 . ", default_rights=" . $new['default_rights']
292 . ", max_users=" . $new['max_users']);
298 rg_log("repo_update: user=" . $user
299 . " repo_id=" . $new['repo_id']
300 . " name=[" . $new['name'] . "]"
301 . " max_commit_size=" . $new['max_commit_size']
302 . " description=[" . $new['description'] . "]"
303 . " default_rights=" . $new['default_rights']
304 . " max_users=" . $new['max_users']);
293 305
294 306 if (rg_repo_ok($new['name']) !== TRUE) if (rg_repo_ok($new['name']) !== TRUE)
295 307 return FALSE; return FALSE;
296 308
297 309 // First, test if it already exists // First, test if it already exists
298 $ri = rg_repo_info($db, 0, $new['name']);
310 $rr = array("user" => $user, "repo" => $new['name']);
311 $ri = rg_repo_info($db, $rr);
299 312 if ($ri['ok'] != 1) if ($ri['ok'] != 1)
300 313 return FALSE; return FALSE;
301 314 if (($ri['exists'] == 1) && ($ri['repo_id'] != $new['repo_id'])) { if (($ri['exists'] == 1) && ($ri['repo_id'] != $new['repo_id'])) {
 
... ... function rg_repo_update($db, &$new)
304 317 } }
305 318
306 319 // Second, test if repo_id is valid // Second, test if repo_id is valid
307 $ri = rg_repo_info($db, $new['repo_id'], "");
320 $rr = array("repo_id" => $new['repo_id']);
321 $ri = rg_repo_info($db, $rr);
308 322 if ($ri['ok'] != 1) if ($ri['ok'] != 1)
309 323 return FALSE; return FALSE;
310 324 if ($ri['exists'] == 0) { if ($ri['exists'] == 0) {
 
... ... function rg_repo_update($db, &$new)
338 352 */ */
339 353 function rg_repo_list_query($db, $url, $sql) function rg_repo_list_query($db, $url, $sql)
340 354 { {
341 global $THEME;
342
343 355 rg_prof_start("repo_list_query"); rg_prof_start("repo_list_query");
344 356
345 357 rg_log("repo_list_query: url=$url, sql=$sql..."); rg_log("repo_list_query: url=$url, sql=$sql...");
 
... ... function rg_repo_list_query($db, $url, $sql)
362 374 rg_repo_set_error("user associated with this repo not found"); rg_repo_set_error("user associated with this repo not found");
363 375 return FALSE; return FALSE;
364 376 } }
365 $_line['owner'] = $_ui['username'];
366
367 $rr = array(
368 "type" => ($_ui['organization'] == 1) ? "org" : "user",
369 "user" => $_ui['username'],
370 "repo" => $row['name']
371 );
372 $_line['link'] = rg_re_repopage($rr);
373 377
378 $_line['owner'] = $_ui['username'];
379 $_line['url_repo'] = rg_re_repopage($_ui, $row['name']);
380 $_line['url_user'] = rg_re_userpage($_ui);
374 381 $_line['HTML:description'] = nl2br(htmlspecialchars($row['description'])); $_line['HTML:description'] = nl2br(htmlspecialchars($row['description']));
375 382
376 383 $master_repo = "-"; $master_repo = "-";
377 384 if ($row['master'] > 0) { if ($row['master'] > 0) {
378 385 $master_repo = "?"; $master_repo = "?";
379 $_mi = rg_repo_info($db, $row['master'], "");
386 $rr = array("repo_id" => $row['master']);
387 $_mi = rg_repo_info($db, $rr);
380 388 if ($_mi['exists'] = 1) if ($_mi['exists'] = 1)
381 389 $master_repo = $_mi['name']; $master_repo = $_mi['name'];
382 390 } }
383 391 $_line['clone_of'] = $master_repo; $_line['clone_of'] = $master_repo;
384 $_line['creation'] = gmdate("Y-m-d H:i:s", $row['itime']);
392 $_line['creation'] = gmdate("Y-m-d", $row['itime']);
385 393
386 394 // rights // rights
387 395 $_line['rights'] = implode(", ", rg_rights_text("repo", $row['default_rights'])); $_line['rights'] = implode(", ", rg_rights_text("repo", $row['default_rights']));
 
... ... function rg_repo_list_query($db, $url, $sql)
405 413
406 414 rg_prof_end("repo_list_query"); rg_prof_end("repo_list_query");
407 415
408 return rg_template_table($THEME . "/repo/list", $d, array());
416 return rg_template_table("repo/list", $d, array());
409 417 } }
410 418
411 419 /* /*
File inc/repo/repo.form.php changed (mode: 100644) (index 9fd5d1c..bb7d48a)
... ... 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="' . rg_re_post($cop . "/create") . '">
8 <form method="post" action="' . rg_re_post($cop) . '">
9 9 <input type="hidden" name="repo_id" value="' . $repo_id . '" /> <input type="hidden" name="repo_id" value="' . $repo_id . '" />
10 10 <input type="hidden" name="master_repo_id" value="' . $master_repo_id . '" /> <input type="hidden" name="master_repo_id" value="' . $master_repo_id . '" />
11 11 <input type="hidden" name="doit" value="1" /> <input type="hidden" name="doit" value="1" />
File inc/repo/repo.php changed (mode: 100644) (index e20fd5a..5116e0d)
... ... $max_commit_size = rg_var_uint("max_commit_size");
13 13 $max_users = rg_var_uint("max_users"); $max_users = rg_var_uint("max_users");
14 14 $description = rg_var_str("description"); $description = rg_var_str("description");
15 15 $master_repo_id = rg_var_uint("master_repo_id"); $master_repo_id = rg_var_uint("master_repo_id");
16 $rights = @rg_rights_a2s($_REQUEST['rights']);
16 $rights = isset($_REQUEST['rights']) ? rg_rights_a2s($_REQUEST['rights']) : $rg_repo_rights_default;
17 17 $repo_id = rg_var_uint("repo_id"); $repo_id = rg_var_uint("repo_id");
18 $q = rg_var_str("q");
19 $masters = rg_var_uint("masters");
20 18
19 if (empty($subop))
20 $subop = "list";
21 21
22 22 // menu // menu
23 23 $second_menu = array( $second_menu = array(
 
... ... $second_menu = array(
35 35 ) )
36 36 ); );
37 37
38 $_body = "";
39
40 38 $errmsg = array(); $errmsg = array();
41 39
42 40 switch ($subop) { switch ($subop) {
43 41 case 'create': case 'create':
44 if ($doit == 1) {
42 while ($doit == 1) {
45 43 $_r = rg_repo_create($db, $master_repo_id, $rg_ui, $name, $_r = rg_repo_create($db, $master_repo_id, $rg_ui, $name,
46 44 $max_commit_size, $description, $rights, $max_users); $max_commit_size, $description, $rights, $max_users);
47 if ($_r === FALSE)
48 $_body .= rg_repo_error();
49 else
50 $_body .= "OK!";
51 } else {
52 $_action = "Create";
53
54 // defaults
55 $rights = $rg_repo_rights_default;
45 if ($_r === FALSE) {
46 $errmsg[] = rg_repo_error();
47 break;
48 }
56 49
57 include($INC . "/repo/repo.form.php");
58 $_body .= $_form;
50 // redirect to repo page
51 $url = rg_re_repopage($rg_ui, $name);
52 rg_redirect($url);
59 53 } }
54
55 $_action = "Create";
56 include($INC . "/repo/repo.form.php");
57 $_repo .= $_form;
60 58 break; break;
61 59
62 60 case 'list': case 'list':
63 $_body .= rg_repo_list($db, "", $rg_ui);
61 $_repo .= rg_repo_list($db, "", $rg_ui);
64 62 break; break;
65 63
66 64 case 'search': case 'search':
67 if ($doit == 1) {
68 $_body .= rg_repo_search($db, $q, $masters);
69 } else {
70 include($INC . "/repo/search.form.php");
71 $_body .= $_form;
65 $q = rg_var_str("q");
66 $masters = rg_var_uint("masters");
67
68 while ($doit == 1) {
69 $_t = rg_repo_search($db, $q, $masters);
70 if ($_t === FALSE) {
71 $errmsg[] = rg_repo_error();
72 break;
73 }
74
75 $_repo .= $_t;
76 break;
72 77 } }
78
79 include($INC . "/repo/search.form.php");
80 $_repo .= $_form;
73 81 break; break;
74 82 } }
75 83
76 $_repo .= $_body;
77 84 ?> ?>
File inc/repo/repo_page.php deleted (index 83df9ba..0000000)
1 <?php
2 rg_log("/inc/repo/repo_page");
3
4 $repo_id = rg_var_uint("repo_id");
5 $name = rg_var_str("name");
6 $max_commit_size = rg_var_uint("max_commit_size");
7 $description = rg_var_str("description");
8 $rights = @rg_rights_a2s($_REQUEST['rights']);
9 $max_users = rg_var_uint("max_users");
10 $user = rg_var_str("user");
11 $master_repo_id = 0;
12
13 // menu - TODO: second_level menu?
14 $_url = rg_re_repopage($repo_id, $name);
15 $_menu = "";
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 $_menu .= "<br />\n";
20 $_menu .= "<br />\n";
21
22 $_body = "";
23
24 $repo_ok = rg_repo_ok($name);
25 if ($repo_ok === TRUE) {
26 $ri = rg_repo_info($db, $repo_id, $name);
27 if (($ri['ok'] != 1) || ($ri['exists'] != 1) || ($ri['deleted'] == 1))
28 $repo_ok = FALSE;
29 }
30
31 if ($repo_ok !== TRUE) {
32 $_repo = "Invalid repository!";
33 return;
34 }
35
36 // we need it in forms
37 $repo_id = $ri['repo_id'];
38
39 $show_repo_info = 1;
40 $errmsg = array();
41
42 switch ($subop) {
43 case 'edit':
44 if ($doit == 1) {
45 while (1) {
46 if (rg_repo_allow($db, $ri, $rg_ui, "A") === FALSE) {
47 $_body .= "Not allowed!<br />\n";
48 break;
49 }
50
51 $ri['name'] = $name; // TODO: filter name!
52 $ri['max_commit_size'] = $max_commit_size;
53 $ri['description'] = $description; // TODO: filter
54 $ri['default_rights'] = $rights; // TODO: filter
55 $ri['max_users'] = $max_users;
56 $_r = rg_repo_update($db, $ri);
57 if ($_r === FALSE) {
58 $_body .= rg_repo_error();
59 break;
60 }
61
62 $_body .= "OK!";
63 break;
64 }
65 } else {
66 // load variables
67 $name = $ri['name'];
68 $rights = $ri['default_rights'];
69 $max_commit_size = $ri['max_commit_size'];
70 $max_users = $ri['max_users'];
71 $description = $ri['description'];
72
73 $_action = "Update";
74 include($INC . "/repo/repo.form.php");
75 $_body .= $_form;
76 }
77 break;
78
79 case 'rights':
80 $remove_uid = rg_var_uint("remove_uid");
81 rg_log("\tDEBUG remove_uid=$remove_uid");
82
83 if ($remove_uid + $doit > 0) {
84 if (rg_repo_allow($db, $ri, $rg_ui, "A") === FALSE) {
85 $errmsg[] = "Not allowed!";
86 // cancel further checking
87 $doit = 0;
88 $remove_uid = 0;
89 }
90 }
91
92 while ($remove_uid > 0) {
93 $e = rg_repo_rights_set($db, $ri, $remove_uid, "");
94 if ($e !== TRUE) {
95 $errmsg[] = rg_repo_error();
96 break;
97 }
98
99 break;
100 }
101
102 while ($doit == 1) {
103 // lookup user
104 $_ui = rg_user_info($db, 0, $user, "");
105 if ($_ui['exists'] != 1) {
106 $errmsg[] = "User <b>$user</b> does not exists!";
107 break;
108 }
109
110 $e = rg_repo_rights_set($db, $ri, $_ui['uid'], $rights);
111 if ($e === FALSE) {
112 $errmsg[] = rg_repo_error();
113 break;
114 }
115
116 break;
117 }
118
119 // list rights
120 $_url = rg_re_repopage($ri['organization'], $ri['repo_id'], $ri['name']);
121 $_body .= rg_repo_rights_list($db, $ri, $_url);
122
123 $_body .= "<br />\n";
124
125 include($INC . "/repo/rights.form.php");
126 $_body .= $_form;
127 break;
128
129 case 'delete':
130 while (1) {
131 if (rg_repo_allow($db, $ri, $rg_ui, "A") === FALSE) {
132 $errmsg[] = "Not allowed!";
133 break;
134 }
135
136 $r = rg_repo_delete($db, $repo_id, $rg_ui);
137 if ($r === FALSE) {
138 $errmsg[] = "Error: " . rg_repo_error();
139 break;
140 }
141
142 break;
143 }
144
145 $_err = implode("<br />\n", $errmsg);
146 if (!empty($_err)) {
147 $_body .= $_err;
148 } else {
149 $_body .= "OK";
150 $show_repo_info = 0;
151 }
152
153 break;
154 }
155
156 $_rt = "";
157 if ($show_repo_info == 1) {
158 $_rt = "Repo <b>" . $ri['name'] . "</b><br />\n";
159 if (!empty($ri['description']))
160 $_rt .= "<small>" . $ri['description'] . "</small><br />\n";
161 $_rt .= "<br />\n";
162 $_dr = rg_rights_text("repo", $ri['default_rights']);
163 $_rt .= "Default rights: " . implode(", ", $_dr) . "<br />\n";
164 $_rt .= "Maxim commit size: " . rg_1024($ri['max_commit_size']) . "<br />\n";
165 $_rt .= "Maxim number of users: " . $ri['max_users'] . "<br />\n";
166 $_url = "git://" . $_SERVER['SERVER_NAME'] . "/" . $ri['name'] . ".git";
167 if (!empty($_dr))
168 $_rt .= "Git URL: <a href=\"$_url\">$_url</a><br />\n";
169 $_url = "ssh://rocketgit@" . $_SERVER['SERVER_NAME'] . "/" . $ri['name'] . ".git";
170 $_rt .= "Git over SSH URL: <a href=\"$_url\">$_url</a><br />\n";
171 $_rt .= "<br />\n";
172 }
173
174 $_repo = $_menu . $_rt . $_body;
175 ?>
File inc/repo/search.form.php changed (mode: 100644) (index f31c09c..b458786)
... ... $_form .= '
8 8 <form method="post" action="' . rg_re_post($cop) . '"> <form method="post" action="' . rg_re_post($cop) . '">
9 9 <input type="hidden" name="doit" value="1" /> <input type="hidden" name="doit" value="1" />
10 10
11 <label for="q">
12 <span class="form_item_title">Name</span><br />
11 <label for="q">Name</label><br />
13 12 <input type="text" name="q" value="" /> <input type="text" name="q" value="" />
14 </label>
15 13 <br /> <br />
16 14 <br /> <br />
17 15
18 <label for="masters">
19 <span class="form_item_title">Only masters?</span><br />
16 <label for="masters">Only masters?</label><br />
20 17 <select name="masters"> <select name="masters">
21 18 <option value="1">Yes</option> <option value="1">Yes</option>
22 19 <option value="0">No</option> <option value="0">No</option>
23 20 </select> </select>
24 </label>
25 21 <br /> <br />
26 22 <br /> <br />
27 23
File inc/rights.inc.php changed (mode: 100644) (index f4442b0..ea626a2)
... ... function rg_rights_checkboxes($type, $passed_rights)
93 93 if (strstr($passed_rights, $right)) if (strstr($passed_rights, $right))
94 94 $add = " checked=\"checked\""; $add = " checked=\"checked\"";
95 95 $ret .= "<input type=\"checkbox\" name=\"rights[$right]\"" $ret .= "<input type=\"checkbox\" name=\"rights[$right]\""
96 . $add . " />$info<br />\n";
96 . $add . " />$info\n";
97 97 } }
98 98
99 99 return $ret; return $ret;
 
... ... function rg_rights_list($db, $type, $obj_id, $url)
262 262 // operations // operations
263 263 // remove // remove
264 264 $ret .= " <td>"; $ret .= " <td>";
265 $_url = $url . "&amp;subop=2";
265 $ret .= " <div class=\"menu\">";
266 $ret .= " <ul>";
266 267 $v = $row['uid']; $v = $row['uid'];
267 $ret .= "[<a href=\"$_url&amp;remove_uid=$v\">Remove</a>]";
268 $ret .= "<li><a href=\"$url?remove_uid=$v\">Remove</a></li>\n";
269 $ret .= "<li><a href=\"$url?edit_uid=$v\">Edit</a></li>\n";
270 $ret .= " </ul>";
271 $ret .= " </div>";
268 272 $ret .= " </td>"; $ret .= " </td>";
269 273 $ret .= "</tr>\n"; $ret .= "</tr>\n";
270 274 } }
File inc/sql.inc.php changed (mode: 100644) (index 0236cd2..88ea9e9)
... ... function rg_sql_query($db, $sql)
89 89
90 90 rg_prof_set(array("queries" => 1, rg_prof_set(array("queries" => 1,
91 91 "rows" => $rows, "rows" => $rows,
92 "affected rows" => $arows,
92 "affected_rows" => $arows,
93 93 "query_time_ms" => $diff)); "query_time_ms" => $diff));
94 94
95 95 return $res; return $res;
 
... ... function rg_sql_close($db)
108 108 */ */
109 109 function rg_sql_free_result($res) function rg_sql_free_result($res)
110 110 { {
111 if (!is_resource($res))
112 r66_fatal("res is not resource!");
111 113 pg_free_result($res); pg_free_result($res);
112 114 } }
113 115
File inc/user.inc.php changed (mode: 100644) (index b790b48..f562999)
... ... function rg_user_name2path($rr)
38 38 if ($len == 1) if ($len == 1)
39 39 $v .= "_"; $v .= "_";
40 40
41 return $rg_base . "/" . $rr['type'] . "s/"
41 if (empty($rr['prefix']))
42 $type = "org";
43 else
44 $type = "user";
45
46 return $rg_base . "/" . $type . "s/"
42 47 . $v[0] . "/" . $v[1] . "/" . $rr['user']; . $v[0] . "/" . $v[1] . "/" . $rr['user'];
43 48 } }
44 49
50 /*
51 * Returns the URL to a user home based on $ui
52 */
53 function rg_user_url($ui)
54 {
55 $prefix = "";
56 if ($ui['organization'] == 0)
57 $prefix = "/user";
58
59 return $prefix . "/" . $ui['username'];
60 }
61
45 62 /* /*
46 63 * Computes password hash * Computes password hash
47 64 */ */
 
... ... function rg_user_ok($user)
99 116 function rg_user_edit($db, $uid, $user, $email, $pass, $is_admin, function rg_user_edit($db, $uid, $user, $email, $pass, $is_admin,
100 117 $disk_quota_mb, $rights, $session_time, $confirm_token) $disk_quota_mb, $rights, $session_time, $confirm_token)
101 118 { {
119 global $rg_user_info_cache;
120
102 121 rg_log("user_edit: uid=$uid, user=$user email=$email" rg_log("user_edit: uid=$uid, user=$user email=$email"
103 122 . " pass=$pass is_admin=$is_admin" . " pass=$pass is_admin=$is_admin"
104 123 . " disk_quota_mb=$disk_quota_mb rights=$rights" . " disk_quota_mb=$disk_quota_mb rights=$rights"
 
... ... function rg_user_edit($db, $uid, $user, $email, $pass, $is_admin,
154 173 } }
155 174 rg_sql_free_result($res); rg_sql_free_result($res);
156 175
176 // invalidate cache
177 $rg_user_info_cache = array();
178
157 179 return TRUE; return TRUE;
158 180 } }
159 181
 
... ... function rg_user_edit($db, $uid, $user, $email, $pass, $is_admin,
162 184 */ */
163 185 function rg_user_remove($db, $uid) function rg_user_remove($db, $uid)
164 186 { {
187 global $rg_user_info_cache;
188
165 189 $uid = sprintf("%u", $uid); $uid = sprintf("%u", $uid);
166 190
167 191 $sql = "DELETE FROM users WHERE uid = $uid"; $sql = "DELETE FROM users WHERE uid = $uid";
 
... ... function rg_user_remove($db, $uid)
172 196 } }
173 197 rg_sql_free_result($res); rg_sql_free_result($res);
174 198
199 // invalidate cache
200 $rg_user_info_cache = array();
201
175 202 return TRUE; return TRUE;
176 203 } }
177 204
178 205 /* /*
179 206 * Returns info about a user (by uid, user or e-mail) * Returns info about a user (by uid, user or e-mail)
180 207 */ */
208 $rg_user_info_cache = array();
181 209 function rg_user_info($db, $uid, $user, $email) function rg_user_info($db, $uid, $user, $email)
182 210 { {
211 global $rg_user_info_cache;
212
213 $key = $uid . "__" . $user . "__" . $email;
214 if (isset($rg_user_info_cache[$key]))
215 return $rg_user_info_cache[$key];
216
183 217 rg_log("user_info: uid/user/email=$uid/$user/$email..."); rg_log("user_info: uid/user/email=$uid/$user/$email...");
184 218
185 219 $ret = array(); $ret = array();
 
... ... function rg_user_info($db, $uid, $user, $email)
188 222 $ret['uid'] = 0; $ret['uid'] = 0;
189 223 $ret['is_admin'] = 0; $ret['is_admin'] = 0;
190 224
225 // in case we return error
226 $rg_user_info_cache[$key] = $ret;
227
191 228 if ($uid > 0) { if ($uid > 0) {
192 229 $add = " AND uid = " . sprintf("%u", $uid); $add = " AND uid = " . sprintf("%u", $uid);
193 230 } else if (!empty($user)) { } else if (!empty($user)) {
 
... ... function rg_user_info($db, $uid, $user, $email)
223 260 $row['ok'] = 1; $row['ok'] = 1;
224 261 $row['exists'] = 1; $row['exists'] = 1;
225 262 rg_log("\tUser found."); rg_log("\tUser found.");
263
264 $rg_user_info_cache[$key] = $row;
265
226 266 return $row; return $row;
227 267 } }
228 268
 
... ... function rg_user_login_by_sid($db, $sid, &$rg_ui)
237 277 $rg_ui = array(); $rg_ui = array();
238 278 $rg_ui['uid'] = 0; $rg_ui['uid'] = 0;
239 279 $rg_ui['is_admin'] = 0; $rg_ui['is_admin'] = 0;
240 $rg_ui['organization'] = 0;
241 280 $rg_ui['username'] = ""; $rg_ui['username'] = "";
242 281
243 282 if (empty($sid)) { if (empty($sid)) {
 
... ... function rg_user_list($db, $url)
494 533 $ret .= " <td>" . $row['username'] . "</td>\n"; $ret .= " <td>" . $row['username'] . "</td>\n";
495 534 $ret .= " <td>" . $row['email'] . "</td>\n"; $ret .= " <td>" . $row['email'] . "</td>\n";
496 535 $ret .= " <td>" . ($row['is_admin'] == 1 ? "Yes" : "No") . "</td>\n"; $ret .= " <td>" . ($row['is_admin'] == 1 ? "Yes" : "No") . "</td>\n";
497 $ret .= " <td>" . gmdate("Y-m-d H:i:s", $row['itime']) . "</td>\n";
536 $ret .= " <td>" . gmdate("Y-m-d", $row['itime']) . "</td>\n";
498 537 if ($row['disk_quota_mb'] > 0) if ($row['disk_quota_mb'] > 0)
499 538 $_v = rg_1024($row['disk_quota_mb'] * 1024 * 1024); $_v = rg_1024($row['disk_quota_mb'] * 1024 * 1024);
500 539 else else
501 540 $_v = "unlimited"; $_v = "unlimited";
502 541 $ret .= " <td>" . $_v . "</td>\n"; $ret .= " <td>" . $_v . "</td>\n";
503 542 $ret .= " <td>" . ($row['suspended'] == 0 ? "No" : "Yes") . "</th>\n"; $ret .= " <td>" . ($row['suspended'] == 0 ? "No" : "Yes") . "</th>\n";
504 $ret .= " <td>" . ($row['confirmed'] == 0 ? "No" : gmdate("Y-m-d H:i:s", $row['confirmed'])) . "</th>\n";
543 $ret .= " <td>" . ($row['confirmed'] == 0 ? "No" : gmdate("Y-m-d", $row['confirmed'])) . "</th>\n";
505 544 $ret .= " <td>" . $row['session_time'] . "s</td>\n"; $ret .= " <td>" . $row['session_time'] . "s</td>\n";
506 545 $v = $row['last_seen'] == 0 ? "-" : gmdate("Y-m-d", $row['last_seen']); $v = $row['last_seen'] == 0 ? "-" : gmdate("Y-m-d", $row['last_seen']);
507 546 $ret .= " <td>" . $v . "</td>\n"; $ret .= " <td>" . $v . "</td>\n";
File inc/user/confirm.php changed (mode: 100644) (index b559f11..a5baee1)
... ... $token = rg_var_re("token", "/[^A-Za-z0-9]/");
6 6 $_confirm = "<br />\n"; $_confirm = "<br />\n";
7 7
8 8 $uid = rg_user_confirm($db, $token); $uid = rg_user_confirm($db, $token);
9 if ($uid === FALSE) {
10 $_confirm .= "Internal error!";
11 } else {
9 if ($uid !== FALSE) {
12 10 // auto-login // auto-login
13 $redispatch = 1;
14 if (rg_user_auto_login($db, $uid, $rg_ui))
15 $op = "home-page";
16 else
17 $op = "login";
11 if (rg_user_auto_login($db, $uid, $rg_ui)) {
12 $url = rg_re_userpage($rg_ui);
13 rg_redirect($url);
14 }
18 15 } }
19 16
17 // error
18 $_confirm = rg_template("msg/internal.txt", array());
19
20 20 ?> ?>
File inc/user/forgot.php changed (mode: 100644) (index 2eacc04..b125826)
... ... $pass2 = rg_var_str("pass2");
7 7
8 8 $_forgot = "<br />\n"; $_forgot = "<br />\n";
9 9
10 $_hide_form = 0;
11 10 $errmsg = array(); $errmsg = array();
12 11
13 12 if ($doit == 1) { if ($doit == 1) {
 
... ... if ($doit == 1) {
32 31
33 32 rg_user_forgot_pass_destroy($db, $r['uid']); rg_user_forgot_pass_destroy($db, $r['uid']);
34 33 // auto-login // auto-login
35 $redispatch = 1;
36 $_hide_form = 1;
37 if (rg_user_auto_login($db, $r['uid'], $rg_ui))
38 $op = "home-page";
39 else
40 $op = "login";
34 if (!rg_user_auto_login($db, $r['uid'], $rg_ui)) {
35 $_forgot = rg_template("msg/internal.txt");
36 return;
37 }
38
39 // redirect to home
40 $url = rg_re_userpage($rg_ui);
41 rg_redirect($url);
41 42 } }
42 43 } }
43 44
44 if ($_hide_form == 0) {
45 include($INC . "/user/forgot.form.php");
46 $_forgot .= $_forgot_form;
47 }
45 include($INC . "/user/forgot.form.php");
46 $_forgot .= $_forgot_form;
48 47
49 48 ?> ?>
File inc/user/home-page.php changed (mode: 100644) (index e485bef..605ccde)
... ... rg_log("/inc/user/home-page");
3 3
4 4 $_home = ""; $_home = "";
5 5
6 $ui = rg_user_info($db, 0, $user, "");
6 $ui = rg_user_info($db, 0, $rr['user'], "");
7 7 if ($ui === FALSE) { if ($ui === FALSE) {
8 8 $_home .= "Invalid user!"; $_home .= "Invalid user!";
9 9 return; return;
10 10 } }
11 11
12 $is_owner = ($ui['uid'] == $rg_ui['uid']) ? 1 : 0;
12 13
13 14 // list of repositories // list of repositories
14 15 $_home .= rg_repo_list($db, "", $ui); $_home .= rg_repo_list($db, "", $ui);
15 16
16 17 // allow operations if the page is owned by the user visiting it // allow operations if the page is owned by the user visiting it
17 if ($ui['uid'] == $rg_ui['uid']) {
18 if ($is_owner == 1) {
18 19 $errmsg = array(); $errmsg = array();
19 20
20 21 switch ($subop) { switch ($subop) {
 
... ... if ($ui['uid'] == $rg_ui['uid']) {
36 37 } }
37 38
38 39 ?> ?>
39
File inc/user/repo-page.php changed (mode: 100644) (index 5c1ef8c..9f8c886)
1 1 <?php <?php
2 2 rg_log("/inc/user/repo-page"); rg_log("/inc/user/repo-page");
3 3
4 $_home = "";
4 $_repo_page = "";
5 $_repo_page_body = "";
5 6
6 if (rg_user_ok($user) !== TRUE) {
7 $_home .= "Invalid user!";
7 if (rg_user_ok($rr['user']) !== TRUE) {
8 $_repo_page .= "Invalid user!";
8 9 return; return;
9 10 } }
10 11
11 if (rg_repo_ok($repo) !== TRUE) {
12 $_home .= "Invalid repo!";
12 if (rg_repo_ok($rr['repo']) !== TRUE) {
13 $_repo_page .= "Invalid repo!";
13 14 return; return;
14 15 } }
15 16
16 17 $ri = rg_repo_info($db, $rr); $ri = rg_repo_info($db, $rr);
17 18 if ($ri === FALSE) { if ($ri === FALSE) {
18 $_home .= "Internal error!";
19 $_repo_page .= "Internal error!";
19 20 return; return;
20 21 } }
22 if (($ri['ok'] != 1) || ($ri['exists'] != 1) || ($ri['deleted'] == 1)) {
23 $_repo_page .= "Invalid repository!";
24 return;
25 }
26
27 $ui = rg_user_info($db, 0, $rr['user'], "");
28 if ($ui === FALSE) {
29 $_repo_page .= "Invalid user!";
30 return;
31 }
32 // TODO: should we test against $ri?!
33 $can_admin = (rg_repo_allow($db, $ri, $rg_ui, "A") === TRUE) ? 1 : 0;
21 34
22 35 $_more = array( $_more = array(
23 "owner" => $user,
24 "url" => rg_re_repopage($rr),
36 "owner" => $rr['user'],
37 "url_user" => rg_re_userpage($rg_ui),
38 "url_repo" => rg_re_repopage($rg_ui, $rr['repo']),
25 39 "ssh" => rg_re_repo_ssh($rr), "ssh" => rg_re_repo_ssh($rr),
26 "git" => rg_re_repo_git($rr)
40 "git" => rg_re_repo_git($rr),
41 "can_admin" => $can_admin
27 42 ); );
28 $ri2 = $ri;
29 $ri2['default_rights'] = implode(", ", rg_rights_text("repo", $ri['default_rights']));
30 $ri2['max_commit_size'] = $ri['max_commit_size'] == 0 ? "unlimited" : rg_1024($ri['max_commit_size']);
31 $ri2['max_users'] = $ri['max_users'] == 0 ? "unlimited" : rg_1000($ri['max_users']);
32 $_home .= rg_template($THEME . "/repo/main.html", array_merge($ri2, $_more));
33 43
34 $repo_dir = rg_repo_name2base($rr) . $repo . ".git";
44 $repo_dir = rg_repo_name2base($rr) . $rr['repo'] . ".git";
35 45 putenv("GIT_DIR=$repo_dir"); putenv("GIT_DIR=$repo_dir");
36 46
37 if (strcmp($subop, "tree") == 0) {
47 if (strcmp($subop, "admin") == 0) {
48 if ($can_admin != 1)
49 rg_security_violation("User is not admin!");
50
51 include($INC . "/user/repo/admin.php");
52 $_repo_page_body .= $_admin;
53 } else if (strcmp($subop, "tree") == 0) {
38 54 if (empty($paras[0])) if (empty($paras[0]))
39 55 $obj = ""; $obj = "";
40 56 else else
41 57 $obj = rg_git_reference($paras[0]); $obj = rg_git_reference($paras[0]);
42 58
43 59 $_tree = rg_git_ls_tree($obj); $_tree = rg_git_ls_tree($obj);
44 $_home .= rg_template_table($THEME . "/repo/tree", $_tree, $_more);
60 $_repo_page_body .= rg_template_table("repo/tree", $_tree, $_more);
45 61 } else if (strcmp($subop, "blob") == 0) { } else if (strcmp($subop, "blob") == 0) {
46 62 $obj = rg_git_reference($paras[0]); $obj = rg_git_reference($paras[0]);
47 63 $c = rg_git_content($obj); $c = rg_git_content($obj);
 
... ... if (strcmp($subop, "tree") == 0) {
49 65 "obj" => $obj, "obj" => $obj,
50 66 "HTML:content" => rg_template_list($c) "HTML:content" => rg_template_list($c)
51 67 ); );
52 $_home .= rg_template($THEME . "/repo/blob.html", array_merge($blob, $_more));
68 $_repo_page_body .= rg_template("repo/blob.html", array_merge($blob, $_more));
69 } else if (strcmp($subop, "stats") == 0) {
70 $_repo_page_body .= "Sorry, not yet implemented!";
71 } else if (strcmp($subop, "mr") == 0) {
72 $r = rg_mr_load($db, $ri['repo_id'], 10);
73 if ($r === FALSE) {
74 $_repo_page_body .= "Error getting merge request list (" . rg_mr_error() . ").";
75 } else {
76 $_repo_page_body .= rg_template_table("repo/mr", $r, $_more);
77 }
53 78 } else { // log } else { // log
54 79 if (empty($paras[0])) { if (empty($paras[0])) {
55 80 rg_log("Show full log"); rg_log("Show full log");
56 81 $log = rg_git_log(10, "", "", FALSE); $log = rg_git_log(10, "", "", FALSE);
57 rg_log("log: " . print_r($log, TRUE));
58 $_home .= rg_git_log_template($log, $THEME . "/repo/log", $_more);
82 rg_log("DEBUG: log: " . print_r($log, TRUE));
83 $_repo_page_body .= rg_git_log_template($log, "repo/log", $_more);
59 84 } else { } else {
60 85 $commit = rg_git_reference($paras[0]); $commit = rg_git_reference($paras[0]);
61 86 rg_log("Show diff for commit [$commit]"); rg_log("Show diff for commit [$commit]");
 
... ... if (strcmp($subop, "tree") == 0) {
64 89 rg_log("log: " . print_r($log, TRUE)); rg_log("log: " . print_r($log, TRUE));
65 90
66 91 // stats // stats
67 $_home .= rg_git_files_stats($log[0]['files'], $THEME . "/repo/fstat");
92 $_repo_page_body .= rg_git_files_stats($log[0]['files'], "repo/fstat");
68 93
69 94 // diff // diff
70 95 //rg_log("patch: " . print_r($log[0]['patches'], TRUE)); //rg_log("patch: " . print_r($log[0]['patches'], TRUE));
71 $_home .= rg_git_diff($log[0]['patches'], $THEME . "/repo/diff.html");
96 $_repo_page_body .= rg_git_diff($log[0]['patches'], "repo/diff.html");
72 97 } }
73 98 } }
74 99
100 $ri2 = $ri;
101 $ri2['default_rights'] = implode(", ", rg_rights_text("repo", $ri['default_rights']));
102 $ri2['max_commit_size'] = $ri['max_commit_size'] == 0 ? "unlimited" : rg_1024($ri['max_commit_size']);
103 $ri2['max_users'] = $ri['max_users'] == 0 ? "unlimited" : rg_1000($ri['max_users']);
104 $_repo_page_head = rg_template("repo/main.html", array_merge($ri2, $_more));
105
106 $_repo_page = $_repo_page_head . $_repo_page_body;
107
75 108 ?> ?>
76 109
File inc/user/repo/admin.php added (mode: 100644) (index 0000000..e7b5793)
1 <?php
2 rg_log("/inc/user/repo/admin");
3
4 $_admin_body = "";
5
6 $_url_admin = rg_re_repopage($rg_ui, $rr['repo']) . "/admin";
7
8 $_admin_more = $ri;
9 $_admin_more['url_admin'] = $_url_admin;
10
11 $_op = @$paras[0];
12 switch ($_op) {
13 case 'edit':
14 include($INC . "/user/repo/edit/edit.php");
15 $_admin_body .= $_edit;
16 break;
17
18 case 'rights':
19 include($INC . "/user/repo/rights/rights.php");
20 $_admin_body .= $_rights;
21 break;
22
23 case 'delete':
24 include($INC . "/user/repo/delete/delete.php");
25 $_admin_body .= $_delete;
26 break;
27
28 default:
29 rg_log("BAD, invalid op=$_op!");
30 }
31
32 // menu
33 $_admin_menu = rg_template("repo/admin.html", $_admin_more);
34
35 $_admin = $_admin_menu . $_admin_body;
36
37 ?>
File inc/user/repo/delete/delete.php added (mode: 100644) (index 0000000..8d5e83c)
1 <?php
2 rg_log("/inc/user/repo/delete/delete");
3
4 $_delete = "";
5
6 $errmsg = array();
7
8 while (1) {
9 $r = rg_repo_delete($db, $ri['repo_id'], $rg_ui);
10 if ($r === FALSE) {
11 $errmsg[] = "Error: " . rg_repo_error();
12 break;
13 }
14
15 break;
16 }
17
18 $_err = implode("<br />\n", $errmsg);
19 if (!empty($_err)) {
20 $_delete .= $_err;
21 } else {
22 // redirect to repo page
23 $url = rg_re_userpage($rg_ui);
24 rg_redirect($url);
25 }
26
27 ?>
File inc/user/repo/edit/edit.php added (mode: 100644) (index 0000000..fdde296)
1 <?php
2 rg_log("/inc/user/repo/edit/edit");
3
4 $_edit = "";
5
6 $errmsg = array();
7
8 $_show_form = 1;
9 if ($doit == 1) {
10 if (!rg_token_valid($db, $sid, $token)) {
11 $_edit .= "Invalid token. Try again.";
12 return;
13 // TODO: call rg_security_violation everywhere!
14 }
15
16 $repo_id = rg_var_uint("repo_id");
17 $master_repo_id = 0;
18 $name = rg_var_str("name");
19 $max_commit_size = rg_var_uint("max_commit_size");
20 $max_users = rg_var_uint("max_users");
21 $description = rg_var_str("description");
22 $rights = @rg_rights_a2s($_REQUEST['rights']);
23
24 while (1) {
25 // lookup user
26 $_ui = rg_user_info($db, 0, $user, "");
27 if ($_ui['ok'] != 1) {
28 $errmsg[] = "Internal error!";
29 break;
30 } else if ($_ui['exists'] != 1) {
31 $errmsg[] = "User <b>$user</b> does not exists!";
32 break;
33 }
34
35 $ri['name'] = $name; // TODO: filter name!
36 $ri['max_commit_size'] = $max_commit_size;
37 $ri['description'] = $description; // TODO: filter
38 $ri['default_rights'] = $rights; // TODO: filter
39 $ri['max_users'] = $max_users;
40 $_r = rg_repo_update($db, $_ui['username'], $ri);
41 if ($_r === FALSE) {
42 $errmsg[] = rg_repo_error();
43 break;
44 }
45
46 $_edit .= "OK!";
47 $_show_form = 0;
48
49 break;
50 }
51 } else {
52 // load variables
53 $repo_id = $ri['repo_id'];
54 $master_repo_id = 0;
55 $name = $ri['name'];
56 $rights = $ri['default_rights'];
57 $max_commit_size = $ri['max_commit_size'];
58 $max_users = $ri['max_users'];
59 $description = $ri['description'];
60 }
61
62 if ($_show_form == 1) {
63 $_action = "Update";
64 include($INC . "/repo/repo.form.php");
65 $_edit .= $_form;
66 }
67
68 ?>
File inc/user/repo/rights/rights.form.php renamed from inc/repo/rights.form.php (similarity 69%) (mode: 100644) (index a1889d2..c08c3b0)
... ... $_form = '<div class="formarea">' . "\n";
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 .= '
7 8 <form method="post" action="' . rg_re_post($cop) . '"> <form method="post" action="' . rg_re_post($cop) . '">
8 9 <input type="hidden" name="repo_id" value="' . $repo_id . '" /> <input type="hidden" name="repo_id" value="' . $repo_id . '" />
9 10 <input type="hidden" name="doit" value="1" /> <input type="hidden" name="doit" value="1" />
10 11 <input type="hidden" name="token" value="' . rg_token_get($db, $sid) . '" /> <input type="hidden" name="token" value="' . rg_token_get($db, $sid) . '" />
11 12
12 <label for="user">
13 <span class="form_item_title">User</span><br />
14 <input type="text" name="user" value="' . $user . '" />
15 </label>
13 <label class="form_item_title" for="target_user">User</label><br />
14 <input type="text" name="target_user" value="' . $target_user . '" />
16 15 <br /> <br />
17 16 <br /> <br />
18 17
19 <label for="rights">
20 <span class="form_item_title">Rights</span><br />
18 <label class="form_item_title" for="rights">Rights</label><br />
21 19 ' . rg_rights_checkboxes("repo", $rights) . ' ' . rg_rights_checkboxes("repo", $rights) . '
22 </label>
23 <br />
24 20 <br /> <br />
25 21
26 <label for="button">
27 22 <input type="submit" name="button" value="Grant" /> <input type="submit" name="button" value="Grant" />
28 </label>
29 23
30 24 </form> </form>
31 25 </div> </div>
File inc/user/repo/rights/rights.php added (mode: 100644) (index 0000000..fcedf44)
1 <?php
2 rg_log("/inc/user/repo/rights/rights");
3
4 $target_user = rg_var_str("target_user");
5 $rights = @rg_rights_a2s($_REQUEST['rights']);
6 $remove_uid = rg_var_uint("remove_uid");
7 $edit_uid = rg_var_uint("edit_uid");
8
9 $_rights = "";
10
11 // we need it in forms
12 $repo_id = $ri['repo_id'];
13
14 $errmsg = array();
15
16 rg_log("\tDEBUG remove_uid=$remove_uid");
17
18 while ($remove_uid > 0) {
19 $e = rg_repo_rights_set($db, $ri, $remove_uid, "");
20 if ($e !== TRUE) {
21 $errmsg[] = rg_repo_error();
22 break;
23 }
24
25 break;
26 }
27
28 while ($edit_uid > 0) {
29 $r = rg_repo_rights_get($db, $ri, $edit_uid, 0);
30 if ($r['ok'] != 1) {
31 $errmsg[] = "User does not exists";
32 rg_log("User does not exists (" . rg_repo_error() . ")!");
33 break;
34 }
35
36 // Find user name
37 $target_ui = rg_user_info($db, $edit_uid, "", "");
38 if ($target_ui['exists'] != 1) {
39 $errmsg[] = "User does not exists anymore";
40 break;
41 }
42
43 $target_user = $target_ui['username'];
44 $rights = $r['rights'];
45 break;
46 }
47
48 while ($doit == 1) {
49 // lookup user
50 $_ui = rg_user_info($db, 0, $target_user, "");
51 if ($_ui['exists'] != 1) {
52 $errmsg[] = "User <b>$target_user</b> does not exists!";
53 rg_log("User $target_user does not exists (" . rg_repo_error() . ")!");
54 break;
55 }
56
57 $e = rg_repo_rights_set($db, $ri, $_ui['uid'], $rights);
58 if ($e === FALSE) {
59 $errmsg[] = rg_repo_error();
60 break;
61 }
62
63 // no need to pre-fill user beause was just added
64 $target_user = "";
65 $rights = "";
66 break;
67 }
68
69 // list rights
70 $_rights .= rg_repo_rights_list($db, $ri, $_url_admin . "/rights");
71
72 $_rights .= "<br />\n";
73
74 include($INC . "/user/repo/rights/rights.form.php");
75 $_rights .= $_form;
76 ?>
File inc/util.inc.php changed (mode: 100644) (index 7b83490..9b0d567)
1 1 <?php <?php
2 2 require_once($INC . "/prof.inc.php"); require_once($INC . "/prof.inc.php");
3 3
4 function rg_util_set_error($str)
5 {
6 global $_rg_util_error;
7 $_rg_util_error = $str;
8 }
9
10 function rg_util_error()
11 {
12 global $_rg_util_error;
13 return $_rg_util_error;
14 }
15
4 16 function rg_1024($v) function rg_1024($v)
5 17 { {
6 18 if ($v <= 9999) if ($v <= 9999)
 
... ... function rg_lock_or_exit($file)
54 66 if (!isset($rg_lock_dir)) if (!isset($rg_lock_dir))
55 67 $rg_lock_dir = "/var/lib/rocketgit"; $rg_lock_dir = "/var/lib/rocketgit";
56 68
57 if ($_lock !== FALSE) {
58 rg_log("\tYou already have a lock on $file! Bad!");
59 exit(1);
60 }
69 // Double locking?
70 if ($_lock !== FALSE)
71 return FALSE;
61 72
62 73 $_lock = @fopen($rg_lock_dir . "/" . $file, "w"); $_lock = @fopen($rg_lock_dir . "/" . $file, "w");
63 if ($_lock === FALSE) {
64 rg_log("\tCannot open $rg_lock_dir/$file!");
65 exit(1);
66 }
74 if ($_lock === FALSE)
75 return FALSE;
67 76
68 77 if (!flock($_lock, LOCK_EX | LOCK_NB)) { if (!flock($_lock, LOCK_EX | LOCK_NB)) {
69 78 fclose($_lock); fclose($_lock);
 
... ... function rg_re_post($op)
100 109 return "/?vv=$op"; return "/?vv=$op";
101 110 } }
102 111
103 function rg_re_userpage($rr)
112 function rg_re_userpage($ui)
104 113 { {
105 if (strcmp($rr['type'], "user") == 0)
114 $prefix = "";
115 if ($ui['organization'] == 0)
106 116 $prefix = "/user"; $prefix = "/user";
107 else
108 $prefix = "";
109 117
110 $s = $prefix . "/" . $rr['user'];
118 $s = $prefix . "/" . $ui['username'];
111 119
112 120 if (isset($_REQUEST['rwe'])) if (isset($_REQUEST['rwe']))
113 121 return $s; return $s;
 
... ... function rg_re_userpage($rr)
115 123 return $_SERVER['PHP_SELF'] . "?vv=$s"; return $_SERVER['PHP_SELF'] . "?vv=$s";
116 124 } }
117 125
118 function rg_re_repopage($rr)
126 function rg_re_repopage($ui, $repo)
119 127 { {
120 if (strcmp($rr['type'], "user") == 0)
121 $prefix = "/user";
122 else
123 $prefix = "";
124
125 $s = $prefix . "/" . $rr['user'] . "/" . $rr['repo'];
128 $s = rg_re_userpage($ui) . "/" . $repo;
126 129
127 130 if (isset($_REQUEST['rwe'])) if (isset($_REQUEST['rwe']))
128 131 return $s; return $s;
 
... ... function rg_re_repopage($rr)
132 135
133 136 function rg_re_repo_ssh($rr) function rg_re_repo_ssh($rr)
134 137 { {
135 if (strcmp($rr['type'], "user") == 0)
136 $prefix = "/user";
137 else
138 $prefix = "";
139
140 return "ssh://rocketgit@" . $_SERVER['SERVER_NAME'] . $prefix . "/" . $rr['user'] . "/" . $rr['repo'];
138 return "ssh://rocketgit@" . $_SERVER['SERVER_NAME']
139 . $rr['prefix'] . "/" . $rr['user'] . "/" . $rr['repo'];
141 140 } }
142 141
143 142 function rg_re_repo_git($rr) function rg_re_repo_git($rr)
144 143 { {
145 if (strcmp($rr['type'], "user") == 0)
146 $prefix = "/user";
147 else
148 $prefix = "";
149
150 return "git://" . $_SERVER['SERVER_NAME'] . $prefix . "/" . $rr['user'] . "/" . $rr['repo'];
144 return "git://" . $_SERVER['SERVER_NAME']
145 . $rr['prefix'] . "/" . $rr['user'] . "/" . $rr['repo'];
151 146 } }
152 147
153 148 function rg_var_str($name) function rg_var_str($name)
 
... ... function rg_rmdir($dir)
200 195 { {
201 196 $scan = glob($dir . "/*"); $scan = glob($dir . "/*");
202 197 if ($scan === FALSE) { if ($scan === FALSE) {
203 rg_log("\tInvalid pattern [$dir/*]!");
198 rg_util_set_error("invalid pattern [$dir/*]");
204 199 return FALSE; return FALSE;
205 200 } }
206 201
207 202 if (count($scan) > 0) { if (count($scan) > 0) {
208 203 foreach ($scan as $junk => $path) { foreach ($scan as $junk => $path) {
209 204 if (!@unlink($path)) { if (!@unlink($path)) {
210 rg_log("\tCannot remove [$path] ($php_errormsg)!");
205 rg_util_set_error("cannot remove [$path] ($php_errormsg)");
211 206 return FALSE; return FALSE;
212 207 } }
213 208 } }
214 209 } }
215 210
216 211 if (!@rmdir($dir)) { if (!@rmdir($dir)) {
217 rg_log("\tCannot remove main dir ($php_errormsg)!");
212 rg_util_set_error("cannot remove main dir ($php_errormsg)");
218 213 return FALSE; return FALSE;
219 214 } }
220 215
221 216 return TRUE; return TRUE;
222 217 } }
223 218
224 function rg_fatal($msg)
225 {
226 echo "==========\n";
227 $x = explode("\n", trim($msg));
228 foreach ($x as $line) {
229 rg_log("FATAL: $line");
230 echo "RocketGit: $line\n";
231 }
232 echo "==========\n";
233 exit(1);
234 }
235
236 function rg_info($msg)
237 {
238 echo "==========\n";
239 $x = explode("\n", trim($msg));
240 foreach ($x as $line) {
241 rg_log("INFO: $line");
242 echo "RocketGit: $line\n";
243 }
244 echo "==========\n";
245 }
246
247 219 /* /*
248 220 * Generates a menu * Generates a menu
249 221 */ */
 
... ... function rg_menu($a, $rg_ui)
297 269 return $ret; return $ret;
298 270 } }
299 271
272 /*
273 * Replace conditionals
274 * @@if(X)_@@A@@_@@B@@ - if X is 0 will return @@B@@, else @@A@@
275 */
276 function rg_prepare_conditionals(&$data, &$what, &$values)
277 {
278 $what[] = "/@@if\(0\){{(.*)}}{{(.*)}}/U";
279 $values[] = "\\2";
280
281 $what[] = "/@@if\(.*\){{(.*)}}{{(.*)}}/U";
282 $values[] = "\\1";
283 }
284
300 285 function rg_prepare_replace(&$data, &$what, &$values) function rg_prepare_replace(&$data, &$what, &$values)
301 286 { {
302 287 if (count($data) == 0) if (count($data) == 0)
 
... ... function rg_prepare_replace(&$data, &$what, &$values)
308 293 } else { } else {
309 294 $v = htmlspecialchars($v); $v = htmlspecialchars($v);
310 295 } }
311 $what[] = "/@@" . $k . "@@/";
296 $what[] = "/@@" . $k . "@@/U";
312 297 $values[] = $v; $values[] = $v;
313 298 } }
314 299 } }
 
... ... function rg_prepare_replace(&$data, &$what, &$values)
318 303 */ */
319 304 function rg_template_table($dir, $data, $more) function rg_template_table($dir, $data, $more)
320 305 { {
321 rg_log("template_table($dir)");
306 global $rg_theme;
307 global $rg_scripts;
308
309 $dir = $rg_scripts . "/root/themes/" . $rg_theme . "/" . $dir;
310 if (!is_dir($dir))
311 $dir = $rg_scripts . "/themes/default/" . $dir;
322 312
323 313 $m_what = array(); $m_values = array(); $m_what = array(); $m_values = array();
324 314 rg_prepare_replace($more, $m_what, $m_values); rg_prepare_replace($more, $m_what, $m_values);
315 rg_prepare_conditionals($more, $m_what, $m_values);
325 316
326 if (empty($data)) {
317 if (!is_array($data) || (count($data) == 0)) {
327 318 $no_data = @file_get_contents($dir . "/nodata.html"); $no_data = @file_get_contents($dir . "/nodata.html");
328 319 if ($no_data === FALSE) if ($no_data === FALSE)
329 320 $no_data = ""; $no_data = "";
 
... ... function rg_template_table($dir, $data, $more)
350 341 $what = $m_what; $values = $m_values; $what = $m_what; $values = $m_values;
351 342
352 343 rg_prepare_replace($info, $what, $values); rg_prepare_replace($info, $what, $values);
344 rg_prepare_conditionals($info, $what, $values);
353 345
354 346 $body .= preg_replace($what, $values, $line); $body .= preg_replace($what, $values, $line);
355 347 } }
 
... ... function rg_template_table($dir, $data, $more)
359 351
360 352 function rg_template($file, $data) function rg_template($file, $data)
361 353 { {
362 rg_log("template($file)");
354 global $rg_scripts;
355 global $rg_theme;
356
357 $file = $rg_scripts . "/root/themes/" . $rg_theme . "/" . $file;
358 if (!is_file($file))
359 $file = $rg_scripts . "/themes/default/" . $file;
363 360
364 361 $body = @file_get_contents($file); $body = @file_get_contents($file);
365 362 if ($body === FALSE) if ($body === FALSE)
 
... ... function rg_template($file, $data)
369 366 $values = array(); $values = array();
370 367
371 368 rg_prepare_replace($data, $what, $values); rg_prepare_replace($data, $what, $values);
369 rg_prepare_conditionals($data, $what, $values);
372 370
373 371 return preg_replace($what, $values, $body); return preg_replace($what, $values, $body);
374 372 } }
 
... ... function rg_template_list($c)
399 397 */ */
400 398 function rg_exec($cmd) function rg_exec($cmd)
401 399 { {
402 rg_log("exec($cmd)");
403 400 rg_prof_start("exec($cmd)"); rg_prof_start("exec($cmd)");
404 401
405 402 $ret = array(); $ret = array();
 
... ... function rg_exec($cmd)
429 426
430 427 $ret['errmsg'] = "code " . $ret['code'] . ": " . $errmsg; $ret['errmsg'] = "code " . $ret['code'] . ": " . $errmsg;
431 428
432 rg_log("exec returned " . $ret['errmsg']);
433
434 429 rg_prof_end("exec($cmd)"); rg_prof_end("exec($cmd)");
435 430 return $ret; return $ret;
436 431 } }
437 432
433 /*
434 * Force browser to redirect to another page
435 */
436 function rg_redirect($url)
437 {
438 header("Location: $url");
439 exit(0);
440 }
441
442 /*
443 * Transforms an array in a string
444 */
445 function rg_array2string($a)
446 {
447 $ret = "";
448 foreach ($a as $k => $v)
449 $ret .= " $k=$v";
450
451 return $ret;
452 }
453
438 454 ?> ?>
File root/index.php changed (mode: 100644) (index 92e5891..0c2cbb1)
... ... error_reporting(E_ALL);
3 3 ini_set("track_errors", "On"); ini_set("track_errors", "On");
4 4
5 5 $INC = dirname(__FILE__) . "/../inc"; $INC = dirname(__FILE__) . "/../inc";
6 $ROOT = dirname(__FILE__);
7
8 $THEME_NAME = "default";
9 $THEME = $ROOT . "/themes/" . $THEME_NAME;
10 $THEME_URL = "/themes/" . $THEME_NAME;
11 $THEME_COMMON = "/themes/common";
12
13 6 require_once("/etc/rocketgit/config.php"); require_once("/etc/rocketgit/config.php");
14 7 require_once($INC . "/log.inc.php"); require_once($INC . "/log.inc.php");
15 8 include_once($INC . "/sql.inc.php"); include_once($INC . "/sql.inc.php");
 
... ... include_once($INC . "/repo.inc.php");
18 11 include_once($INC . "/keys.inc.php"); include_once($INC . "/keys.inc.php");
19 12 include_once($INC . "/token.inc.php"); include_once($INC . "/token.inc.php");
20 13 include_once($INC . "/prof.inc.php"); include_once($INC . "/prof.inc.php");
14 include_once($INC . "/mr.inc.php");
21 15
22 16 rg_prof_start("MAIN"); rg_prof_start("MAIN");
23 17
24 18 rg_log_set_file($rg_web_log_dir . "/main.log"); rg_log_set_file($rg_web_log_dir . "/main.log");
25 19
26 20 // Init variables // Init variables
21 $THEME_URL = "/themes/" . $rg_theme;
27 22 $op = ""; $subop = ""; $subsubop = ""; $cop = ""; $op = ""; $subop = ""; $subsubop = ""; $cop = "";
28 $type = ""; $prefix = ""; $user = ""; $repo = "";
23 $rr = array("user" => "", "repo" => "", "prefix" => "");
29 24 $paras = array(); $paras = array();
25 $rg_ui = array();
30 26
31 27 // We have variable 'vv' passed from webserver - build 'op' and rest of paras // We have variable 'vv' passed from webserver - build 'op' and rest of paras
32 28 $vv = rg_var_str("vv"); $vv = rg_var_str("vv");
29 rg_log("DEBUG: vv=$vv.");
33 30 if (strcmp($vv, "/") == 0) { // main page for site (not for user) if (strcmp($vv, "/") == 0) { // main page for site (not for user)
31 rg_log("DEBUG: vv: it is the main page");
34 32 $op = "main"; $op = "main";
35 33 } else if (strncmp($vv, "/op/", 4) == 0) { // command } else if (strncmp($vv, "/op/", 4) == 0) { // command
34 rg_log("DEBUG: vv: it is an op");
36 35 $_t = substr($vv, 4); $_t = substr($vv, 4);
37 36 $_t = explode("/", $_t); $_t = explode("/", $_t);
38 37 $op = $_t[0]; $op = $_t[0];
 
... ... if (strcmp($vv, "/") == 0) { // main page for site (not for user)
41 40 if (isset($_t[2])) if (isset($_t[2]))
42 41 $subsubop = $_t[2]; $subsubop = $_t[2];
43 42 } }
43 $cop = rtrim("/op/" . $op . "/" . $subop . "/" . $subsubop, "/");
44 44 } else { // user or organization } else { // user or organization
45 rg_log("DEBUG: vv: user or organization");
45 46 if (strncmp($vv, "/user/", 6) == 0) { if (strncmp($vv, "/user/", 6) == 0) {
46 $vv = substr($vv, 6);
47 $type = "user";
48 $prefix = "/user";
47 $vv6 = substr($vv, 6);
48 $rr['prefix'] = "/user";
49 49 } else { } else {
50 $type = "org";
51 $prefix = "";
50 $vv6 = $vv;
51 $rr['prefix'] = "";
52 52 } }
53 $_t = explode("/", $vv);
54 $user = $_t[0];
53 $_t = explode("/", $vv6);
54 $rr['user'] = $_t[0];
55 $op = "home-page";
55 56 if (isset($_t[1])) { if (isset($_t[1])) {
56 $repo = $_t[1];
57 $rr['repo'] = $_t[1];
57 58 $op = "repo-page"; $op = "repo-page";
58 59
59 60 if (isset($_t[2])) { if (isset($_t[2])) {
 
... ... if (strcmp($vv, "/") == 0) { // main page for site (not for user)
66 67 $i++; $i++;
67 68 } }
68 69 } }
69 } else {
70 $op = "home-page";
71 70 } }
71 $cop = $vv;
72 72 } }
73 $cop = rtrim("/op/" . $op . "/" . $subop . "/" . $subsubop, "/");
74 73
75 $rr = array(
76 "type" => $type,
77 "prefix" => $prefix,
78 "user" => $user,
79 "repo" => $repo);
80 74
81 75 $doit = rg_var_uint("doit"); $doit = rg_var_uint("doit");
82 76 $sid = rg_var_re("sid", "/[^A-Za-z0-9]/"); $sid = rg_var_re("sid", "/[^A-Za-z0-9]/");
 
... ... rg_log("IP: " . @$_SERVER['REMOTE_ADDR']);
86 80 rg_log("_REQUEST: " . trim(print_r($_REQUEST, TRUE))); rg_log("_REQUEST: " . trim(print_r($_REQUEST, TRUE)));
87 81 rg_log("_COOKIE: " . trim(print_r($_COOKIE, TRUE))); rg_log("_COOKIE: " . trim(print_r($_COOKIE, TRUE)));
88 82 rg_log("Start! cop=[$cop] op=$op subop=$subop subsubop=$subsubop" rg_log("Start! cop=[$cop] op=$op subop=$subop subsubop=$subsubop"
89 . " user=$user repo=$repo"
90 . " doit=$doit, sid=$sid...");
83 . " doit=$doit sid=$sid rr:" . rg_array2string($rr));
91 84 rg_log("paras: " . implode("|", $paras)); rg_log("paras: " . implode("|", $paras));
92 85
93 86
 
... ... rg_log("After login_by_sid, rg_ui=" . print_r($rg_ui, TRUE));
103 96
104 97
105 98 $body = ""; $body = "";
106 // Chain dispatching
107 do {
108 rg_log("Dispatching to [$op]");
109
110 $redispatch = 0;
111
112 // Re-init second line menu
113 $second_menu = array();
114
115 include($INC . "/dispatch/dispatch.php");
116 } while ($redispatch == 1);
99 $second_menu = array();
100 rg_log("Dispatching to [$op]");
101 include($INC . "/dispatch/dispatch.php");
117 102
118 103
119 104 // menu // menu
 
... ... $first_menu = array(
124 109 "op" => "/op/login"), "op" => "/op/login"),
125 110 "home-page" => array( "home-page" => array(
126 111 "text" => "Home", "text" => "Home",
127 "op" => ($rg_ui['organization'] == 1) ? "/" : "/user/" . $rg_ui['username']),
112 "op" => $rr['prefix'] . "/" . $rr['user']),
128 113 "personal" => array( "personal" => array(
129 114 "text" => "Personal", "text" => "Personal",
130 115 "op" => "/op/personal"), "op" => "/op/personal"),
 
... ... else
152 137
153 138 rg_prof_end("MAIN"); rg_prof_end("MAIN");
154 139
155 include($THEME . "/index.php");
140 include($rg_scripts . "/root/themes/" . $rg_theme . "/index.php");
156 141
157 142 rg_prof_log("rg_log"); rg_prof_log("rg_log");
158 143 ?> ?>
File root/themes/default/index.php changed (mode: 100644) (index aa76e2a..9b6d28d)
12 12
13 13 <div id="header"> <div id="header">
14 14 <div style="float: left"> <div style="float: left">
15 <img src="<?php echo $THEME_COMMON; ?>/rg4.png" /><br />
15 <img src="<?php echo $THEME_URL; ?>/logo/rg4.png" /><br />
16 16 <b>RocketGit</b> <b>RocketGit</b>
17 17 </div> </div>
18 18
File root/themes/default/logo/rg1.png renamed from root/themes/common/rg1.png (similarity 100%)
File root/themes/default/logo/rg16x16.png renamed from root/themes/common/rg16x16.png (similarity 100%)
File root/themes/default/logo/rg2.png renamed from root/themes/common/rg2.png (similarity 100%)
File root/themes/default/logo/rg4.png renamed from root/themes/common/rg4.png (similarity 100%)
File root/themes/default/logo/rg5.png renamed from root/themes/common/rg5.png (similarity 100%)
File root/themes/default/main.css changed (mode: 100644) (index 570e501..89ebd97)
... ... th, td {
23 23 text-align: left; text-align: left;
24 24 padding: 3px; padding: 3px;
25 25 border: 1px solid #aaaaaa; border: 1px solid #aaaaaa;
26 white-space: pre-wrap;
26 x-white-space: pre-wrap; <!-- Seems that force td cells to be bigger than necessary! -->
27 27 word-wrap: break-word; word-wrap: break-word;
28 28 } }
29 29
 
... ... th, td {
40 40
41 41 .menu { .menu {
42 42 padding: 7px; padding: 7px;
43 white-space: nowrap;
43 44 } }
44 45
45 46 .menu ul { .menu ul {
 
... ... th, td {
64 65 border: 1px solid #999999; border: 1px solid #999999;
65 66 } }
66 67
68 .junk {
69 }
70
67 71 #header { #header {
68 72 border: 1px solid #eeeeee; border: 1px solid #eeeeee;
69 73 background-color: #eeeeee; background-color: #eeeeee;
 
... ... th, td {
91 95 width: 800px; width: 800px;
92 96 border-radius: 4px 4px 4px 4px; border-radius: 4px 4px 4px 4px;
93 97 border: 1px solid #cccccc; border: 1px solid #cccccc;
98 line-height: 120%;
94 99 } }
95 100
96 101 .formarea_title { .formarea_title {
File root/themes/default/msg/internal.txt added (mode: 100644) (index 0000000..2a4f4fb)
1 An internal error occured. Please try again later.
File root/themes/default/msg/push_merge_request.txt renamed from lang/en/push_merge_request.txt (similarity 100%)
File root/themes/default/msg/push_not_allowed.txt renamed from lang/en/push_not_allowed.txt (similarity 100%)
File root/themes/default/repo/admin.html added (mode: 100644) (index 0000000..9da37e4)
1 <div class="menu">
2 <ul>
3 <li><a href="@@url_admin@@/edit">Edit</a></li>
4 <li><a href="@@url_admin@@/rights">Rights</a></li>
5 <li><a href="@@url_admin@@/delete">Delete</a></li>
6 </ul>
7 </div>
File root/themes/default/repo/blob.html changed (mode: 100644) (index 4ea234b..6d26507)
1 <span class="blob_title">Blob <a href="@@url@@/blob/@@obj@@">@@obj@@</a></span><br />
1 <span class="blob_title">Blob <a href="@@url_repo@@/blob/@@obj@@">@@obj@@</a></span><br />
2 2 <br /> <br />
3 3
4 4 <div class="source"> <div class="source">
File root/themes/default/repo/list/header.html changed (mode: 100644) (index a394760..e988ebc)
1 <table width="500px">
1 <table>
2 2 <tr> <tr>
3 3 <th>User / name</th> <th>User / name</th>
4 4 <th>Description</th> <th>Description</th>
File root/themes/default/repo/list/line.html changed (mode: 100644) (index fd69ccd..ca22cee)
1 1 <tr> <tr>
2 <td><a href="@@link@@">@@owner@@/@@name@@</a></td>
2 <td><a href="@@url_user@@">@@owner@@</a>/<a href="@@url_repo@@">@@name@@</a></td>
3 3 <td><small>@@description@@</small></td> <td><small>@@description@@</small></td>
4 4 <td>@@clone_of@@</td> <td>@@clone_of@@</td>
5 5 <td>@@creation@@</td> <td>@@creation@@</td>
File root/themes/default/repo/log/line.html changed (mode: 100644) (index 76683d6..bcf21d5)
1 1 <tr> <tr>
2 2 <td>@@subject@@</td> <td>@@subject@@</td>
3 <td><a href="@@url@@/log/@@sha1_short@@">@@sha1_short@@</a></td>
3 <td><a href="@@url_repo@@/log/@@sha1_short@@">@@sha1_short@@</a></td>
4 4 <td>@@author name@@ (@@author email@@)</td> <td>@@author name@@ (@@author email@@)</td>
5 5 <td>@@author date UTC@@</td> <td>@@author date UTC@@</td>
6 6 <td>@@files_changed@@</td> <td>@@files_changed@@</td>
File root/themes/default/repo/main.html changed (mode: 100644) (index 75d56c4..2d38b33)
1 <span class="repo_title"><a href="@@url@@">@@owner@@/@@name@@</a></span><br />
1 <span class="repo_title"><a href="@@url_user@@">@@owner@@</a>/<a href="@@url_repo@@">@@name@@</a></span><br />
2 2 <span class="repo_desc">@@description@@</span><br /> <span class="repo_desc">@@description@@</span><br />
3 3 <br /> <br />
4 4 Git: <a href="@@git@@">@@git@@</a><br /> Git: <a href="@@git@@">@@git@@</a><br />
 
... ... SSH: <a href="@@ssh@@">@@ssh@@</a><br />
7 7
8 8 Max commit size: @@max_commit_size@@<br /> Max commit size: @@max_commit_size@@<br />
9 9 Maximum number of users: @@max_users@@<br /> Maximum number of users: @@max_users@@<br />
10 Rights: @@default_rights@@<br />
10 Default rights: @@default_rights@@<br />
11 Maximum commit size: @@max_commit_size@@<br />
11 12 <br /> <br />
12 13
13 <a href="@@url@@/log">Log</a>
14 <a href="@@url@@/tree">Tree</a>
15 <a href="@@url@@/stats">Stats</a>
16 <br />
17 <br />
14 <div class="menu">
15 <ul>
16 <li><a href="@@url_repo@@/log">Log</a></li>
17 <li><a href="@@url_repo@@/tree">Tree</a></li>
18 <li><a href="@@url_repo@@/stats">Stats</a></li>
19 <li><a href="@@url_repo@@/mr">Merge requests</a></li>
20 @@if(@@can_admin@@){{<li><a href="@@url_repo@@/admin">Admin</a></li>}}{{}}
21 </ul>
22 </div>
File root/themes/default/repo/mr/footer.html copied from file root/themes/default/repo/fstat/footer.html (similarity 100%)
File root/themes/default/repo/mr/header.html added (mode: 100644) (index 0000000..e590abd)
1 <table>
2 <tr>
3 <th>Date / time</th>
4 <th>Ref</th>
5 <th>IP</th>
6 </tr>
7
File root/themes/default/repo/mr/line.html added (mode: 100644) (index 0000000..353af1b)
1 <tr>
2 <td>@@date_utc@@</td>
3 <td>@@refname@@</td>
4 <td>@@ip@@</td>
5 </tr>
File root/themes/default/repo/mr/nodata.html copied from file root/themes/default/repo/fstat/nodata.html (similarity 53%) (mode: 100644) (index f70717a..c217f3d)
1 1 <div class="warning"> <div class="warning">
2 No file changed.
2 No merge requests found.
3 3 </div> </div>
File root/themes/default/repo/tree/line.html changed (mode: 100644) (index 0a87018..1fc33e1)
3 3 <td>@@type@@</td> <td>@@type@@</td>
4 4 <td>@@size@@</td> <td>@@size@@</td>
5 5 <td>@@ref@@</td> <td>@@ref@@</td>
6 <td><a href="@@url@@/@@type@@/@@ref@@">@@file@@</a></td>
6 <td><a href="@@url_repo@@/@@type@@/@@ref@@">@@file@@</a></td>
7 7 </tr> </tr>
File samples/config.php changed (mode: 100644) (index 2e736f0..b8c665d)
... ... $rg_web_log_dir = "/var/log/rocketgit-web";
55 55 // lock dir // lock dir
56 56 $rg_lock_dir = "/var/lib/rocketgit"; $rg_lock_dir = "/var/lib/rocketgit";
57 57
58 // Default theme
59 $rg_theme = "default";
60
61 // Default language
62 $rg_lang = "en";
63
58 64 ?> ?>
File scripts/cron.php changed (mode: 100644) (index 6d7eb90..f09cba4)
... ... if (date("H") == 0) {
35 35 . " WHERE a.uid = b.uid"; . " WHERE a.uid = b.uid";
36 36 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
37 37 if ($res === FALSE) { if ($res === FALSE) {
38 // TODO: rg_internal_error? it must notify me in case of problems
38 39 rg_log("Cannot run query (" . rg_sql_error() . ")!"); rg_log("Cannot run query (" . rg_sql_error() . ")!");
39 40 } else { } else {
40 41 while (($row = rg_sql_fetch_array($res))) { while (($row = rg_sql_fetch_array($res))) {
41 $type = ($row['organization'] == 1) ? "org" : "user";
42 $prefix = ($row['organization'] == 1) ? "" : "/user";
42 43
43 rg_log("Processing $type/" . $row['username']
44 rg_log("Processing $prefix/" . $row['username']
44 45 . "/" . $row['name'] . "..."); . "/" . $row['name'] . "...");
45 $repo_path = rg_repo_name2base($row['username'], $row['name']) . $row['name'] . ".git";
46 $_rr = array("prefix" => $prefix,
47 "user" => $row['username'],
48 "repo" => $row['name']);
49 $repo_path = rg_repo_name2base($_rr) . $row['name'] . ".git";
46 50 $disk_used_mb = rg_repo_disk_mb($repo_path); $disk_used_mb = rg_repo_disk_mb($repo_path);
47 51 $sql = "UPDATE repos SET disk_used_mb = $disk_used_mb" $sql = "UPDATE repos SET disk_used_mb = $disk_used_mb"
48 52 . " WHERE repo_id = " . $row['repo_id']; . " WHERE repo_id = " . $row['repo_id'];
File scripts/q.php changed (mode: 100644) (index c3dbddd..f90d092)
... ... while (TRUE) {
69 69 } }
70 70 while (($row = rg_sql_fetch_array($res))) { while (($row = rg_sql_fetch_array($res))) {
71 71 $rr = array( $rr = array(
72 "type" => ($row['organization'] == 1) ? "org" : "user",
72 "prefix" => ($row['organization'] == 1) ? "" : "/user",
73 73 "user" => $row['username'], "user" => $row['username'],
74 74 "repo" => $row['name']); "repo" => $row['name']);
75 75
76 rg_log("\tProcessing " . implode("|", $rr) . "...");
76 rg_log("\tProcessing " . rg_array2string($rr));
77 77
78 78 $dst = rg_repo_name2base($rr) . $row['name'] . ".git"; $dst = rg_repo_name2base($rr) . $row['name'] . ".git";
79 79 if ($row['master'] == 0) { if ($row['master'] == 0) {
 
... ... while (TRUE) {
100 100 } }
101 101
102 102 $rr = array( $rr = array(
103 "type" => ($mi['organization'] == 1) ? "org" : "user",
103 "prefix" => ($mi['organization'] == 1) ? "" : "/user",
104 104 "user" => $ui['username'], "user" => $ui['username'],
105 105 "repo" => $mi['name']); "repo" => $mi['name']);
106 106 $src = rg_repo_name2base($rr) . $mi['name'] . ".git"; $src = rg_repo_name2base($rr) . $mi['name'] . ".git";
File scripts/remote.php changed (mode: 100644) (index c17efa5..677badb)
... ... rg_log("_SERVER: " . print_r($_SERVER, TRUE));
38 38 umask(0022); umask(0022);
39 39
40 40 if (isset($_SERVER['SSH_CONNECTION'])) { if (isset($_SERVER['SSH_CONNECTION'])) {
41 rg_log("SSH connection: " . @$_SERVER['SSH_CONNECTION']);
41 rg_log("SSH connection: " . $_SERVER['SSH_CONNECTION']);
42 42 $access_type = 1; $access_type = 1;
43 43
44 44 // we do not have host info // we do not have host info
 
... ... $_t = ltrim($_t, "/");
108 108 $_t = preg_replace('/\.git$/' , '', $_t); $_t = preg_replace('/\.git$/' , '', $_t);
109 109 $_t = explode("/", $_t); $_t = explode("/", $_t);
110 110 if (strcmp($_t[0], "user") == 0) { if (strcmp($_t[0], "user") == 0) {
111 $type = "user";
111 $prefix = "/user";
112 112 $user = $_t[1]; $user = $_t[1];
113 113 $repo = $_t[2]; $repo = $_t[2];
114 114 } else { } else {
115 $type = "org";
115 $prefix = "";
116 116 $user = $_t[0]; $user = $_t[0];
117 117 $repo = $_t[1]; $repo = $_t[1];
118 118 } }
119 119
120 rg_log("host=[$host] cmd=[$cmd] type=[$type] user=[$user] repo=[$repo].");
120 rg_log("host=[$host] cmd=[$cmd] prefix=[$prefix] user=[$user] repo=[$repo].");
121 121
122 122 // validity/security checks // validity/security checks
123 123 if (rg_user_ok($user) !== TRUE) if (rg_user_ok($user) !== TRUE)
 
... ... if ($db === FALSE)
131 131 fatal("Internal error (db)!"); fatal("Internal error (db)!");
132 132
133 133 // Loading info about the repository // Loading info about the repository
134 $rr = array("type" => $type, "user" => $user, "repo" => $repo);
134 $rr = array("prefix" => $prefix, "user" => $user, "repo" => $repo);
135 135 $ri = rg_repo_info($db, $rr); $ri = rg_repo_info($db, $rr);
136 136 if ($ri['ok'] != 1) if ($ri['ok'] != 1)
137 137 fatal("Temporary error!"); fatal("Temporary error!");
File tests/hook_pre-receive.sh changed (mode: 100755) (index 8090618..fee6ab6)
1 1 #!/bin/bash #!/bin/bash
2 2
3 rm -rf hook_pre-receive_*.git
3 rm -rfv hook_pre-receive_*.git
4 4 mkdir hook_pre-receive_dest.git mkdir hook_pre-receive_dest.git
5 5 ( (
6 6 cd hook_pre-receive_dest.git cd hook_pre-receive_dest.git
File tests/keys.php changed (mode: 100644) (index 1e6d561..4c87573)
... ... error_reporting(E_ALL | E_STRICT);
3 3 ini_set("track_errors", "On"); ini_set("track_errors", "On");
4 4
5 5 $INC = "../inc"; $INC = "../inc";
6 require_once($INC . "/util.inc.php");
6 7 require_once($INC . "/keys.inc.php"); require_once($INC . "/keys.inc.php");
7 8 require_once($INC . "/db/struct.inc.php"); require_once($INC . "/db/struct.inc.php");
8 9
 
... ... $drop_tables = TRUE;
22 23 $old_schema_ver = 0; $old_schema_ver = 0;
23 24 $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);
24 25 if ($r === FALSE) { if ($r === FALSE) {
25 echo "Cannot create structure!\n";
26 echo "Cannot create structure (" . rg_sql_error() . ")!\n";
26 27 exit(1); exit(1);
27 28 } }
28 29
File tests/prof.php changed (mode: 100644) (index 2f1d198..06e77c0)
... ... sleep(.1);
15 15 rg_prof_set(array("xxx" => 1)); rg_prof_set(array("xxx" => 1));
16 16 rg_prof_end("label1"); rg_prof_end("label1");
17 17 $t = rg_prof_get(); $t = rg_prof_get();
18 print_r($t);
18 if (!isset($t['label1'])) {
19 print_r($t);
20 echo "Profiling for label 1 is not present!\n";
21 exit(1);
22 }
19 23
20 24 echo "prof: OK!\n"; echo "prof: OK!\n";
21 25 ?> ?>
File tests/repo.php changed (mode: 100644) (index e3f10bd..f378a15)
... ... $rg_base = "/base";
16 16
17 17
18 18 rg_log("name2base1"); rg_log("name2base1");
19 $rr = array("type" => "user", "user" => "user1", "repo" => "junk");
19 $rr = array("prefix" => "/user", "user" => "user1", "repo" => "junk");
20 20 $e = "/base/users/u/s/user1/repos/"; $e = "/base/users/u/s/user1/repos/";
21 21 $c = rg_repo_name2base($rr); $c = rg_repo_name2base($rr);
22 22 if (strcmp($c, $e) != 0) { if (strcmp($c, $e) != 0) {
 
... ... if (strcmp($c, $e) != 0) {
25 25 } }
26 26
27 27 rg_log("name2base2"); rg_log("name2base2");
28 $rr = array("type" => "org", "user" => "u", "repo" => "junk");
28 $rr = array("prefix" => "", "user" => "u", "repo" => "junk");
29 29 $e = "/base/orgs/u/_/u/repos/"; $e = "/base/orgs/u/_/u/repos/";
30 30 $c = rg_repo_name2base($rr); $c = rg_repo_name2base($rr);
31 31 if (strcmp($c, $e) != 0) { if (strcmp($c, $e) != 0) {
 
... ... $drop_tables = TRUE;
90 90 $old_schema_ver = 0; $old_schema_ver = 0;
91 91 $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);
92 92 if ($r === FALSE) { if ($r === FALSE) {
93 rg_log("Cannot create struct!");
93 rg_log("Cannot create struct (" . rg_sql_error() . ")!");
94 94 exit(1); exit(1);
95 95 } }
96 96
File tests/root/themes/util/t1/nodata.html renamed from tests/util/t1/nodata.html (similarity 100%)
File tests/root/themes/util/t2/footer.html renamed from tests/util/t2/footer.html (similarity 100%)
File tests/root/themes/util/t2/header.html renamed from tests/util/t2/header.html (similarity 100%)
File tests/root/themes/util/t2/line.html renamed from tests/util/t2/line.html (similarity 100%)
File tests/root/themes/util/t3/c1 added (mode: 100644) (index 0000000..ef1fe7b)
1 @@if(@@X@@){{@@A@@}}{{@@B@@}}
File tests/sql.php changed (mode: 100644) (index 40fda8b..13ddb9e)
... ... error_reporting(E_ALL | E_STRICT);
3 3 ini_set("track_errors", "On"); ini_set("track_errors", "On");
4 4
5 5 $INC = "../inc"; $INC = "../inc";
6 require_once($INC . "/log.inc.php");
6 7 require_once($INC . "/sql.inc.php"); require_once($INC . "/sql.inc.php");
7 8
8 9 echo "db: open connection...\n"; echo "db: open connection...\n";
File tests/state.php changed (mode: 100644) (index 89502f9..86fb85e)
... ... $drop_tables = TRUE;
24 24 $old_schema_ver = 0; $old_schema_ver = 0;
25 25 $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);
26 26 if ($r === FALSE) { if ($r === FALSE) {
27 echo "Cannot create structure!\n";
27 echo "Cannot create structure (" . rg_sql_error() . ")!\n";
28 28 exit(1); exit(1);
29 29 } }
30 30
File tests/user.php changed (mode: 100644) (index 3bfd693..e96ba35)
... ... $INC = "../inc";
6 6 require_once($INC . "/user.inc.php"); require_once($INC . "/user.inc.php");
7 7 require_once($INC . "/db/struct.inc.php"); require_once($INC . "/db/struct.inc.php");
8 8
9 $rg_sql_debug = 1;
10
9 11 rg_log_set_file("user.log"); rg_log_set_file("user.log");
10 12
11 13 $rg_user_max_len = 20; $rg_user_max_len = 20;
 
... ... $drop_tables = TRUE;
27 29 $old_schema_ver = 0; $old_schema_ver = 0;
28 30 $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);
29 31 if ($r === FALSE) { if ($r === FALSE) {
30 echo "Cannot create structure!\n";
32 echo "Cannot create structure (" . rg_sql_error() . ")!\n";
31 33 exit(1); exit(1);
32 34 } }
33 35
 
... ... if ($_ui['exists'] != 1) {
66 68 exit(1); exit(1);
67 69 } }
68 70 if (strcmp($salt, $_ui['salt']) != 0) { if (strcmp($salt, $_ui['salt']) != 0) {
69 echo "Salt was changed!\n";
71 echo "Salt was changed $salt -> " . $_ui['salt'] . "!\n";
70 72 exit(1); exit(1);
71 73 } }
72 74 if (strcmp($pass, $_ui['pass']) != 0) { if (strcmp($pass, $_ui['pass']) != 0) {
 
... ... if ($_ui['exists'] != 1) {
87 89 exit(1); exit(1);
88 90 } }
89 91 if (strcmp($salt, $_ui['salt']) == 0) { if (strcmp($salt, $_ui['salt']) == 0) {
90 echo "Salt was not changed!\n";
92 echo "Salt was not changed ($salt)!\n";
91 93 exit(1); exit(1);
92 94 } }
93 95 if (strcmp($pass, $_ui['pass']) == 0) { if (strcmp($pass, $_ui['pass']) == 0) {
 
... ... if ($r['uid'] != $uid) {
122 124
123 125 // test name2path // test name2path
124 126 $rg_base = "/base"; $user = "b"; $e = "/base/users/b/_/b"; $rg_base = "/base"; $user = "b"; $e = "/base/users/b/_/b";
125 $rr = array("type" => "user", "user" => $user);
127 $rr = array("prefix" => "/" . $user, "user" => $user);
126 128 $r = rg_user_name2path($rr); $r = rg_user_name2path($rr);
127 129 if (strcmp($r, $e) != 0) { if (strcmp($r, $e) != 0) {
128 130 echo "name2path: e=[$e] != r=[$r]!\n"; echo "name2path: e=[$e] != r=[$r]!\n";
File tests/util.php changed (mode: 100644) (index fad5706..2be2b27)
... ... require_once($INC . "/log.inc.php");
8 8
9 9 rg_log_set_file("util.log"); rg_log_set_file("util.log");
10 10
11 $rg_scripts = ".";
12 $rg_theme = "util";
13
11 14 $id = rg_id(16); $id = rg_id(16);
12 15 if (strlen($id) != 16) { if (strlen($id) != 16) {
13 16 echo "Cannot generate an id!\n"; echo "Cannot generate an id!\n";
 
... ... file_put_contents("util.tmp/file1", "aaa");
19 22 file_put_contents("util.tmp/file2", "bbb"); file_put_contents("util.tmp/file2", "bbb");
20 23 $r = rg_rmdir("util.tmp"); $r = rg_rmdir("util.tmp");
21 24 if ($r !== TRUE) { if ($r !== TRUE) {
22 echo "Cannot delete dir!\n";
25 echo "Cannot delete dir (" . rg_util_error() . ")!\n";
23 26 exit(1); exit(1);
24 27 } }
25 28
 
... ... if ($r['code'] != 5) {
45 48 } }
46 49
47 50 // test rg_template_table($dir, $data, $more) with no data // test rg_template_table($dir, $data, $more) with no data
48 $r = rg_template_table("./util/t1", array(), array("a" => "A"));
51 $r = rg_template_table("t1", array(), array("a" => "A"));
49 52 $e = "XAX"; $e = "XAX";
50 53 if (strcmp($r, $e) != 0) { if (strcmp($r, $e) != 0) {
51 54 echo "util.php: nodata.html is not working (r=$r e=$e)!\n"; echo "util.php: nodata.html is not working (r=$r e=$e)!\n";
 
... ... if (strcmp($r, $e) != 0) {
54 57
55 58 // test rg_template_table($dir, $data, $more) with data // test rg_template_table($dir, $data, $more) with data
56 59 $data = array(array("a" => "A", "b" => "B"), array("a" => "A2", "b" => "B2")); $data = array(array("a" => "A", "b" => "B"), array("a" => "A2", "b" => "B2"));
57 $r = rg_template_table("./util/t2", $data, array("c" => "C"));
60 $r = rg_template_table("t2", $data, array("c" => "C"));
58 61 $e = "HEADCABCA2B2CFOOTC"; $e = "HEADCABCA2B2CFOOTC";
59 62 if (strcmp($r, $e) != 0) { if (strcmp($r, $e) != 0) {
60 63 echo "util.php: rg_template_table is not working (r=$r e=$e)!\n"; echo "util.php: rg_template_table is not working (r=$r e=$e)!\n";
61 64 exit(1); exit(1);
62 65 } }
63 66
67 // test rg_template with conditional formating
68 $data = array("X" => "0", "A" => "Avalue", "B" => "Bvalue");
69 $r = rg_template("t3/c1", $data);
70 $e = "Bvalue";
71 if (strcmp($r, $e) != 0) {
72 echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n";
73 exit(1);
74 }
75
76 // test rg_template with conditional formating
77 $data = array("X" => "34", "A" => "Avalue", "B" => "Bvalue");
78 $r = rg_template("t3/c1", $data);
79 $e = "Avalue";
80 if (strcmp($r, $e) != 0) {
81 echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n";
82 exit(1);
83 }
84
64 85 echo "util: OK!\n"; echo "util: OK!\n";
65 86 ?> ?>
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