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

Lots of changes.
Author: Catalin(ux) M. BOIE
Author date (UTC): 2011-07-03 00:03
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2011-07-03 00:03
Parent(s): b272b9915498fb0a811be2e2687554bbaf887bf1
Signing key:
Tree: e875203f3e85cd31091364d52cde03962dd20579
File Lines added Lines deleted
Makefile.in 8 8
README 35 11
TODO 10 1
admin/init.php 3 2
duilder 1 1
duilder.conf 1 1
hooks/update 19 23
inc/admin/users/add.php 4 1
inc/admin/users/edit.php 4 2
inc/admin/users/user.form.php 14 6
inc/db.inc.php 16 2
inc/db/struct.inc.php 16 15
inc/dispatch/dispatch.php 8 4
inc/git.inc.php 50 32
inc/keys.inc.php 2 2
inc/log.inc.php 2 1
inc/login/login.form.php 2 11
inc/personal/personal.php 21 11
inc/repo.inc.php 12 11
inc/repo/repo.form.php 1 1
inc/repo/repo.php 3 4
inc/repo/repo_page.php 3 3
inc/rights.inc.php 17 1
inc/token.inc.php 6 8
inc/user.inc.php 35 21
inc/user/forgot.form.php 3 3
inc/user/forgot.php 10 10
inc/user/forgot_mail.php 0 16
inc/user/forgot_send.form.php 18 0
inc/user/forgot_send.php 26 0
inc/util.inc.php 22 5
rocketgit.spec.in 3 2
root/index.php 1 0
samples/config.php 4 0
samples/rg 1 1
samples/rg.conf 3 2
scripts/cron.php 2 2
scripts/q.php 0 8
scripts/remote.php 1 1
tests/Makefile 4 1
tests/db.php 1 0
tests/git.php 22 0
tests/keys.php 3 2
tests/repo.php 1 0
tests/rights.php 9 0
tests/state.php 1 0
tests/user.php 4 3
tests/util.php 13 0
File Makefile.in changed (mode: 100644) (index 19dfd01..8e1c27b)
... ... install: all
14 14 @mkdir -p $(I_USR_SHARE)/$(PRJ) @mkdir -p $(I_USR_SHARE)/$(PRJ)
15 15 cp -vdr admin inc hooks root scripts $(I_USR_SHARE)/$(PRJ) 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 cp -vd samples/rg $(I_ETC)/xinetd.d/rocketgit
17 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
19 cp -vd samples/cron $(I_ETC)/cron.d/rocketgit
19 cp -vd --no-clobber samples/cron $(I_ETC)/cron.d/rocketgit
20 20 @mkdir -p $(I_ETC)/httpd/conf.d @mkdir -p $(I_ETC)/httpd/conf.d
21 cp -vd samples/rg.conf $(I_ETC)/httpd/conf.d/rocketgit.conf
21 cp -vd --no-clobber samples/rg.conf $(I_ETC)/httpd/conf.d/rocketgit.conf
22 22 @mkdir -p $(I_ETC)/rocketgit @mkdir -p $(I_ETC)/rocketgit
23 cp -vd samples/config.php $(I_ETC)/rocketgit/
23 cp -vd --no-clobber samples/config.php $(I_ETC)/rocketgit/
24 24 cp -vd samples/config.php $(I_ETC)/rocketgit/config.php.sample cp -vd samples/config.php $(I_ETC)/rocketgit/config.php.sample
25 25 @mkdir -p $(I_ETC)/logrotate.d @mkdir -p $(I_ETC)/logrotate.d
26 cp -vd samples/logrotate $(I_ETC)/logrotate.d/rocketgit
26 cp -vd --no-clobber samples/logrotate $(I_ETC)/logrotate.d/rocketgit
27 27 @mkdir -p $(I_VAR_LOG)/$(PRJ) @mkdir -p $(I_VAR_LOG)/$(PRJ)
28 @chown rocketgit:rocketgit $(I_VAR_LOG)/$(PRJ)
28 @-chown rocketgit:rocketgit $(I_VAR_LOG)/$(PRJ)
29 29 @chmod 0700 $(I_VAR_LOG)/$(PRJ) @chmod 0700 $(I_VAR_LOG)/$(PRJ)
30 30 @mkdir -p $(I_VAR_LOG)/$(PRJ)-web @mkdir -p $(I_VAR_LOG)/$(PRJ)-web
31 @chown apache:apache $(I_VAR_LOG)/$(PRJ)-web
31 @-chown apache:apache $(I_VAR_LOG)/$(PRJ)-web
32 32 @chmod 0700 $(I_VAR_LOG)/$(PRJ)-web @chmod 0700 $(I_VAR_LOG)/$(PRJ)-web
33 33 @mkdir -p $(I_VAR_RUN)/$(PRJ) @mkdir -p $(I_VAR_RUN)/$(PRJ)
34 @chown rocketgit:rocketgit $(I_VAR_RUN)/$(PRJ)
34 @-chown rocketgit:rocketgit $(I_VAR_RUN)/$(PRJ)
File README changed (mode: 100644) (index 897b3b7..619aed8)
1 == Rights ==
2 A - Admin - can edit repo info, can add/remove rights for users
3 F - Fetch
4 P - Push
5 D - Delete branch
6 Z - Forced push (history rewriting)
1 == About ==
2 . Website: http://kernel.embedromix.ro/us/
3 . Author: Catalin(ux) M. BOIE
4 . Description: Light and fast Git hosting solution
5 . Language: PHP
6 . Database: PostgreSQL
7
8
9 == Features ==
10 . No Java
11 . No Javascript
12 . Very little dependencies
13 . SELinux friendly
14 .
7 15
8 Notes:
9 - For anonymous access, we store rights directly in repo info row.
10 16
11 17 == Install == == Install ==
18 . Edit /etc/rocketgit/config.php
19
12 20 . Install and configure PostgreSQL server . Install and configure PostgreSQL server
21 # yum install postgresql-server
22 # systemctl enable postgresql.service
23 # service postgresql initdb (TAKE CARE! YOU MAY DESTROY ALL YOUR DATA!)
24 # systemctl start postgresql.service
25
13 26 . Create a rocketgit user . Create a rocketgit user
14 27 # su - postgres # su - postgres
15 $ createuser -d -R -S -W rocketgit
28 $ createuser -d -R -S rocketgit
16 29
17 30 . Create the database . Create the database
18 31 # su - postgres # su - postgres
19 32 $ createdb -O rocketgit rocketgit $ createdb -O rocketgit rocketgit
20 33
21 . Set correct rights in pg_hba.conf:
22 local rocketgit rocketgit trust
34 . Set correct rights in pg_ident.conf/pg_hba.conf and restart:
35 Add the following lines in pg_ident.conf:
36 rg apache rocketgit
37 rg rocketgit rocketgit
38 rg root rocketgit
39
40 Add the following line, before wildcard matches, in pg_hba.conf:
41 local rocketgit rocketgit ident map=rg
42
43 systemctl reload postgresql.service
23 44
24 45 . Run instalation script . Run instalation script
25 46 # php /usr/share/rocketgit/admin/init.php # php /usr/share/rocketgit/admin/init.php
26 47
27 48 . SELinux . SELinux
49 # setsebool -P httpd_can_network_connect_db on
50 # setsebool -P httpd_can_network_memcache on
51 # setsebool -P httpd_can_sendmail on
File TODO changed (mode: 100644) (index a330e13..935536b)
1 1 == BEFORE FIRST RELEASE! == == BEFORE FIRST RELEASE! ==
2 [ ] Take care of PHP's time limit to not interfere with the rest.
2 3 [ ] Validate e-mails. [ ] Validate e-mails.
3 4 [ ] You cannot admin rights of a repository if is not yours. [ ] You cannot admin rights of a repository if is not yours.
4 5 [ ] Check XSRF attacks and other types. [ ] Check XSRF attacks and other types.
5 6 [ ] Edit repo (rights) does not work. [ ] Edit repo (rights) does not work.
7 [ ] Postgresql pg_hba.conf fixes.
8 [ ] $rg_pass_key should be done in init.php
9 [ ] Decide what fields to show when editting a user info (user.form.php).
6 10 [ ] [ ]
7 11
8 12 == Low priority == == Low priority ==
13 [ ] rg_forgot_email
9 14 [ ] We should make a repo dirty ony if user pushed something with success. [ ] We should make a repo dirty ony if user pushed something with success.
10 15 [ ] <link rel="icon" type="image/png" id="favicon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8%2F9hAAAACGFjVEwAAAASAAAAAJNtBPIAAAAaZmNUTAAAAAAAAAAQAAAAEAAAAAAAAAAALuAD6AABhIDeugAAALhJREFUOI2Nk8sNxCAMRDlGohauXFOMpfTiAlxICqAELltHLqlgctg1InzMRhpFAc%2BLGWTnmoeZYamt78zXdZmaQtQMADlnU0OIAlbmJUBEcO4bRKQY2rUXIPmAGnDuG%2FBx3%2FfvOPVaDUg%2BoAPUf1PArIMCSD5glMEsUGaG%2BkyAFWIBaCsKuA%2BHGCNijLgP133XgOEtaPFMy2vUolEGJoCIzBmoRUR9%2B7rxj16DZaW%2FmgtmxnJ8V3oAnApQwNS5zpcAAAAaZmNUTAAAAAEAAAAQAAAAEAAAAAAAAAAAAB4D6AIB52fclgAAACpmZEFUAAAAAjiNY2AYBVhBc3Pzf2LEcGreqcbwH1kDNjHauWAUjAJyAADymxf9WF%2Bu8QAAABpmY1RMAAAAAwAAABAAAAAQAAAAAAAAAAAAHgPoAgEK8Q9%2FAAAAFmZkQVQAAAAEOI1jYBgFo2AUjAIIAAAEEAAB0xIn4wAAABpmY1RMAAAABQAAABAAAAAQAAAAAAAAAAAAHgPoAgHnO30FAAAAQGZkQVQAAAAGOI1jYBieYKcaw39ixHCC%2F6cwFWMTw2rz%2F1MM%2F6Vu%2Ff%2F%2F%2FxTD%2F51qEIwuRjsXILuEGLFRMApgAADhNCsVfozYcAAAABpmY1RMAAAABwAAABAAAAAQAAAAAAAAAAAAHgPoAgEKra7sAAAAFmZkQVQAAAAIOI1jYBgFo2AUjAIIAAAEEAABM9s3hAAAABpmY1RMAAAACQAAABAAAAAQAAAAAAAAAAAAHgPoAgHn3p%2BwAAAAKmZkQVQAAAAKOI1jYBgFWEFzc%2FN%2FYsRwat6pxvAfWQM2Mdq5YBSMAnIAAPKbF%2F1BhPl6AAAAGmZjVEwAAAALAAAAEAAAABAAAAAAAAAAAAAeA%2BgCAQpITFkAAAAWZmRBVAAAAAw4jWNrgAWjYBSMArgAAAQQAAHaszpmAAAAGmZjVEwAAAANAAAAEAAAABAAAAAAAAAAAAAeA%2BgCAeeCPiMAAABAZmRBVAAAAA44jWNrgJ5gpxrDf2LEcIL%2FpzAVYxPDavP%2FUwz%2FpW79%2F%2F%2F%2FFMP%2FnWoQjC5GOxcgu4QYsVEwCmAAAOE0KxUmBL0KAAAAGmZjVEwAAAAPAAAAEAAAABAAAAAAAAAAAAAeA%2BgCAQoU7coAAAAWZmRBVAAAABA4jWNrgAWjYBSMArgAAAQQAAEpOBELAAAAGmZjVEwAAAARAAAAEAAAABAAAAAAAAAAAAAeA%2BgCAeYVWtoAAAAqZmRBVAAAABI4jWNrgAVYQXNz839ixHBq3qnG8B9ZAzYx2rlgFIwCcgAA8psX%2FWvpAecAAAAaZmNUTAAAABMAAAAQAAAAEAAAAAAAAAAAAB4D6AIBC4OJMwAAABZmZEFUAAAAFDiNY2AYBaNgFIwCCAAABBAAAcBQHOkAAAAaZmNUTAAAABUAAAAQAAAAEAAAAAAAAAAAAB4D6AIB5kn7SQAAAEBmZEFUAAAAFjiNY2AYnmCnGsN%2FYsRwgv%2BnMBVjE8Nq8%2F9TDP%2Blbv3%2F%2F%2F8Uw%2F%2BdahCMLkY7FyC7hBixUTAKYAAA4TQrFc%2BcEoQAAAAaZmNUTAAAABcAAAAQAAAAEAAAAAAAAAAAAB4D6AIBC98ooAAAABZmZEFUAAAAGDiNY2AYBaNgFIwCCAAABBAAASCZDI4AAAAaZmNUTAAAABkAAAAQAAAAEAAAAAAAAAAAAB4D6AIB5qwZ%2FAAAACpmZEFUAAAAGjiNY2AYBVhBc3Pzf2LEcGreqcbwH1kDNjHauWAUjAJyAADymxf9cjJWbAAAABpmY1RMAAAAGwAAABAAAAAQAAAAAAAAAAAAHgPoAgELOsoVAAAAFmZkQVQAAAAcOI1jYBgFo2AUjAIIAAAEEAAByfEBbAAAABpmY1RMAAAAHQAAABAAAAAQAAAAAAAAAAAAHgPoAgHm8LhvAAAAQGZkQVQAAAAeOI1jYBieYKcaw39ixHCC%2F6cwFWMTw2rz%2F1MM%2F6Vu%2Ff%2F%2F%2FxTD%2F51qEIwuRjsXILuEGLFRMApgAADhNCsVlxR3%2FgAAABpmY1RMAAAAHwAAABAAAAAQAAAAAAAAAAAAHgPoAgELZmuGAAAAFmZkQVQAAAAgOI1jYBgFo2AUjAIIAAAEEAABHP5cFQAAABpmY1RMAAAAIQAAABAAAAAQAAAAAAAAAAAAHgPoAgHlgtAOAAAAKmZkQVQAAAAiOI1jYBgFWEFzc%2FN%2FYsRwat6pxvAfWQM2Mdq5YBSMAnIAAPKbF%2F0%2FMvDdAAAAAElFTkSuQmCC"/> [ ] <link rel="icon" type="image/png" id="favicon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8%2F9hAAAACGFjVEwAAAASAAAAAJNtBPIAAAAaZmNUTAAAAAAAAAAQAAAAEAAAAAAAAAAALuAD6AABhIDeugAAALhJREFUOI2Nk8sNxCAMRDlGohauXFOMpfTiAlxICqAELltHLqlgctg1InzMRhpFAc%2BLGWTnmoeZYamt78zXdZmaQtQMADlnU0OIAlbmJUBEcO4bRKQY2rUXIPmAGnDuG%2FBx3%2FfvOPVaDUg%2BoAPUf1PArIMCSD5glMEsUGaG%2BkyAFWIBaCsKuA%2BHGCNijLgP133XgOEtaPFMy2vUolEGJoCIzBmoRUR9%2B7rxj16DZaW%2FmgtmxnJ8V3oAnApQwNS5zpcAAAAaZmNUTAAAAAEAAAAQAAAAEAAAAAAAAAAAAB4D6AIB52fclgAAACpmZEFUAAAAAjiNY2AYBVhBc3Pzf2LEcGreqcbwH1kDNjHauWAUjAJyAADymxf9WF%2Bu8QAAABpmY1RMAAAAAwAAABAAAAAQAAAAAAAAAAAAHgPoAgEK8Q9%2FAAAAFmZkQVQAAAAEOI1jYBgFo2AUjAIIAAAEEAAB0xIn4wAAABpmY1RMAAAABQAAABAAAAAQAAAAAAAAAAAAHgPoAgHnO30FAAAAQGZkQVQAAAAGOI1jYBieYKcaw39ixHCC%2F6cwFWMTw2rz%2F1MM%2F6Vu%2Ff%2F%2F%2FxTD%2F51qEIwuRjsXILuEGLFRMApgAADhNCsVfozYcAAAABpmY1RMAAAABwAAABAAAAAQAAAAAAAAAAAAHgPoAgEKra7sAAAAFmZkQVQAAAAIOI1jYBgFo2AUjAIIAAAEEAABM9s3hAAAABpmY1RMAAAACQAAABAAAAAQAAAAAAAAAAAAHgPoAgHn3p%2BwAAAAKmZkQVQAAAAKOI1jYBgFWEFzc%2FN%2FYsRwat6pxvAfWQM2Mdq5YBSMAnIAAPKbF%2F1BhPl6AAAAGmZjVEwAAAALAAAAEAAAABAAAAAAAAAAAAAeA%2BgCAQpITFkAAAAWZmRBVAAAAAw4jWNrgAWjYBSMArgAAAQQAAHaszpmAAAAGmZjVEwAAAANAAAAEAAAABAAAAAAAAAAAAAeA%2BgCAeeCPiMAAABAZmRBVAAAAA44jWNrgJ5gpxrDf2LEcIL%2FpzAVYxPDavP%2FUwz%2FpW79%2F%2F%2F%2FFMP%2FnWoQjC5GOxcgu4QYsVEwCmAAAOE0KxUmBL0KAAAAGmZjVEwAAAAPAAAAEAAAABAAAAAAAAAAAAAeA%2BgCAQoU7coAAAAWZmRBVAAAABA4jWNrgAWjYBSMArgAAAQQAAEpOBELAAAAGmZjVEwAAAARAAAAEAAAABAAAAAAAAAAAAAeA%2BgCAeYVWtoAAAAqZmRBVAAAABI4jWNrgAVYQXNz839ixHBq3qnG8B9ZAzYx2rlgFIwCcgAA8psX%2FWvpAecAAAAaZmNUTAAAABMAAAAQAAAAEAAAAAAAAAAAAB4D6AIBC4OJMwAAABZmZEFUAAAAFDiNY2AYBaNgFIwCCAAABBAAAcBQHOkAAAAaZmNUTAAAABUAAAAQAAAAEAAAAAAAAAAAAB4D6AIB5kn7SQAAAEBmZEFUAAAAFjiNY2AYnmCnGsN%2FYsRwgv%2BnMBVjE8Nq8%2F9TDP%2Blbv3%2F%2F%2F8Uw%2F%2BdahCMLkY7FyC7hBixUTAKYAAA4TQrFc%2BcEoQAAAAaZmNUTAAAABcAAAAQAAAAEAAAAAAAAAAAAB4D6AIBC98ooAAAABZmZEFUAAAAGDiNY2AYBaNgFIwCCAAABBAAASCZDI4AAAAaZmNUTAAAABkAAAAQAAAAEAAAAAAAAAAAAB4D6AIB5qwZ%2FAAAACpmZEFUAAAAGjiNY2AYBVhBc3Pzf2LEcGreqcbwH1kDNjHauWAUjAJyAADymxf9cjJWbAAAABpmY1RMAAAAGwAAABAAAAAQAAAAAAAAAAAAHgPoAgELOsoVAAAAFmZkQVQAAAAcOI1jYBgFo2AUjAIIAAAEEAAByfEBbAAAABpmY1RMAAAAHQAAABAAAAAQAAAAAAAAAAAAHgPoAgHm8LhvAAAAQGZkQVQAAAAeOI1jYBieYKcaw39ixHCC%2F6cwFWMTw2rz%2F1MM%2F6Vu%2Ff%2F%2F%2FxTD%2F51qEIwuRjsXILuEGLFRMApgAADhNCsVlxR3%2FgAAABpmY1RMAAAAHwAAABAAAAAQAAAAAAAAAAAAHgPoAgELZmuGAAAAFmZkQVQAAAAgOI1jYBgFo2AUjAIIAAAEEAABHP5cFQAAABpmY1RMAAAAIQAAABAAAAAQAAAAAAAAAAAAHgPoAgHlgtAOAAAAKmZkQVQAAAAiOI1jYBgFWEFzc%2FN%2FYsRwat6pxvAfWQM2Mdq5YBSMAnIAAPKbF%2F0%2FMvDdAAAAAElFTkSuQmCC"/>
11 16 [ ] Add key form may be joined with list keys command! [ ] Add key form may be joined with list keys command!
 
46 51 [ ] 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?
47 52 [ ] Limit number of commits per push. [ ] Limit number of commits per push.
48 53 [ ] logrotate [ ] logrotate
49 [ ]
54 [ ] In %post section we may want to run a script that will do the update of the
55 database, for example.
56 [ ] Compute disk_used_mb per user.
57 [ ] Enforce disk quota.
58 [ ]
File admin/init.php changed (mode: 100644) (index 53c015c..7b21afd)
... ... rg_log_set_file("init.log");
16 16
17 17 $db = rg_sql_open($rg_db); $db = rg_sql_open($rg_db);
18 18 if ($db === FALSE) { if ($db === FALSE) {
19 echo "Internal error (" . rg_sql_error() . ")!";
19 echo "Internal error (" . rg_sql_error() . ")!\n";
20 20 exit(1); exit(1);
21 21 } }
22 22
 
... ... $disk_quota_mb = 0;
32 32 $rights = rg_rights_all("user"); $rights = rg_rights_all("user");
33 33 $user = "admin"; $user = "admin";
34 34 $email = ""; $email = "";
35 $session_time = 3600;
35 36 while (1) { while (1) {
36 37 $user0 = readline("User [$user]: "); $user0 = readline("User [$user]: ");
37 38 if (!empty($user0)) if (!empty($user0))
 
... ... while (1) {
60 61 } }
61 62
62 63 $r = rg_user_edit($db, $uid, $user, $email, $pass, $is_admin, $r = rg_user_edit($db, $uid, $user, $email, $pass, $is_admin,
63 $disk_quota_mb, $rights);
64 $disk_quota_mb, $rights, $session_time);
64 65 if ($r !== TRUE) { if ($r !== TRUE) {
65 66 echo "Cannot create user (" . rg_user_error() . ")!\n"; echo "Cannot create user (" . rg_user_error() . ")!\n";
66 67 continue; continue;
File duilder changed (mode: 100755) (index a15834c..dbdd391)
... ... function duilder_srpm()
179 179 rpmbuild -ts "${P}.tar.gz" rpmbuild -ts "${P}.tar.gz"
180 180 echo echo
181 181
182 PKG="${RPMBUILD}/SRPMS/${P}-1.src.rpm"
182 PKG="${RPMBUILD}/SRPMS/${P}-${REV}.src.rpm"
183 183
184 184 # Run a rpmlint on it # Run a rpmlint on it
185 185 if [ -x /usr/bin/rpmlint ]; then if [ -x /usr/bin/rpmlint ]; then
File duilder.conf changed (mode: 100644) (index 76d9310..50711fc)
1 1 PRJ="rocketgit" PRJ="rocketgit"
2 VER="0.3"
2 VER="0.6"
3 3 REV="1" REV="1"
4 4 EXCLUDE=".exclude" EXCLUDE=".exclude"
5 5 EXPORT_PATH="/data/www/umbrella/kernel/us/rocketgit" EXPORT_PATH="/data/www/umbrella/kernel/us/rocketgit"
File hooks/update changed (mode: 100755) (index e86a3d8..976b872)
1 1 #!/usr/bin/php #!/usr/bin/php
2 2 <?php <?php
3 3 // This is called by 'update' hook // This is called by 'update' hook
4 // Inspired by upate.sample in git package
4 // Inspired by update.sample in git package
5 5 error_reporting(E_ALL); error_reporting(E_ALL);
6 6 ini_set("track_errors", "On"); ini_set("track_errors", "On");
7 7
 
... ... rg_log("_SERVER: " . print_r($_SERVER, TRUE));
22 22
23 23 umask(0022); umask(0022);
24 24
25 $refname = rg_git_ref(@$_SERVER['argv'][1]);
26 $old_rev = rg_git_ref(@$_SERVER['argv'][2]);
27 $new_rev = rg_git_ref(@$_SERVER['argv'][3]);
25 $refname = @$_SERVER['argv'][1];
26 $old_rev = rg_git_rev(@$_SERVER['argv'][2]);
27 $new_rev = rg_git_rev(@$_SERVER['argv'][3]);
28 28 rg_log("refname=$refname old_rev=$old_rev new_rev=$new_rev."); rg_log("refname=$refname old_rev=$old_rev new_rev=$new_rev.");
29 29
30 if ((empty($refname) || empty($old_rev) || empty($new_rev)) {
30 if (empty($refname) || empty($old_rev) || empty($new_rev)) {
31 31 echo "rg: Invalid parameters!\n"; echo "rg: Invalid parameters!\n";
32 32 exit(1); exit(1);
33 33 } }
 
... ... if (strcmp($rg_repo_zero, $new_rev) == 0)
36 36 $new_rev_type = "delete"; $new_rev_type = "delete";
37 37 else else
38 38 $new_rev_type = rg_git_type($new_rev); $new_rev_type = rg_git_type($new_rev);
39 rg_log("new_reg_type=$new_reg_type.");
39 rg_log("new_rev_type=$new_rev_type.");
40 40
41 41 if (strcmp($new_rev_type, "commit") == 0) { if (strcmp($new_rev_type, "commit") == 0) {
42 rg_log("It's a commit...");
42 43 if (strncmp($refname, "refs/tags/", 10) == 0) { if (strncmp($refname, "refs/tags/", 10) == 0) {
43 44 // This is an not annoted tag - we can reject it // This is an not annoted tag - we can reject it
44 45 rg_log("Un-annotated tag..."); rg_log("Un-annotated tag...");
45 }
46
47 if (strncmp($refname, "refs/heads/", 11) == 0) {
46 } else if (strncmp($refname, "refs/heads/", 11) == 0) {
48 47 if (strcmp($old_rev, $rg_repo_zero) == 0) { if (strcmp($old_rev, $rg_repo_zero) == 0) {
49 48 rg_log("Creating a branch..."); rg_log("Creating a branch...");
50 }
51
52 if (rg_git_ref_ok($new_ref . "^2")) {
49 } else if (rg_git_rev_ok($new_rev . "^2")) {
53 50 rg_log("Merge commit..."); rg_log("Merge commit...");
54 }
55
56 if (rg_git_bad_whitespace($old_ref, $new_ref)) {
57 rg_log("Bad whitespace...");
51 } else {
52 rg_log("Normal commit...");
53 if (!rg_git_whitespace_ok($old_rev, $new_rev)) {
54 rg_log("Bad whitespace...");
55 }
58 56 } }
59 57 } }
60 58
61 59 // refs/remotes/* // refs/remotes/*
62 60 } else if (strcmp($new_rev_type, "delete") == 0) { } else if (strcmp($new_rev_type, "delete") == 0) {
61 rg_log("It's a delete...");
63 62 if (strncmp($refname, "refs/tags/", 10) == 0) { if (strncmp($refname, "refs/tags/", 10) == 0) {
64 63 rg_log("Deleting a tag..."); rg_log("Deleting a tag...");
65 }
66
67 if (strncmp($refname, "refs/heads/", 11) == 0) {
64 } else if (strncmp($refname, "refs/heads/", 11) == 0) {
68 65 rg_log("Deleting a branch..."); rg_log("Deleting a branch...");
69 }
70
71 if (strncmp($refname, "refs/remotes/", 13) == 0) {
66 } else if (strncmp($refname, "refs/remotes/", 13) == 0) {
72 67 rg_log("Deleting a tracking branch..."); rg_log("Deleting a tracking branch...");
73 68 } }
74 69 } else if (strcmp($new_rev_type, "tag") == 0) { } else if (strcmp($new_rev_type, "tag") == 0) {
70 rg_log("It's a tag...");
75 71 if (strncmp($refname, "refs/tags/", 10) == 0) { if (strncmp($refname, "refs/tags/", 10) == 0) {
76 72 rg_log("Modify tag..."); rg_log("Modify tag...");
77 73 } }
 
... ... rg_log("Took " . $diff . "ms.");
88 84 "repo: " . $repo . " ($repo_path)" "repo: " . $repo . " ($repo_path)"
89 85 . "\nat: " . sprintf("%u", $_start) . "\nat: " . sprintf("%u", $_start)
90 86 . "\nuid: " . $uid . "\nuid: " . $uid
91 . "\ncmd: $refname $old_ref $new_ref"
87 . "\npara: $refname $old_rev $new_rev"
92 88 . "\nTook: " . $diff . "ms"); . "\nTook: " . $diff . "ms");
93 89
94 90 // Mark repository dirty for disk statistics and other stuff // Mark repository dirty for disk statistics and other stuff
File inc/admin/users/add.php changed (mode: 100644) (index 2619c7b..34a9bd7)
... ... if ($doit == 1) {
15 15 $is_admin = rg_var_uint("is_admin"); $is_admin = rg_var_uint("is_admin");
16 16 $disk_quota_mb = rg_var_uint("disk_quota_mb"); $disk_quota_mb = rg_var_uint("disk_quota_mb");
17 17 $rights = @rg_rights_a2s($_REQUEST['rights']); $rights = @rg_rights_a2s($_REQUEST['rights']);
18 $session_time = rg_var_uint("session_time");
18 19
19 20 $_ui = rg_user_info($db, 0, $xuser, ""); $_ui = rg_user_info($db, 0, $xuser, "");
20 21 if ($_ui['ok'] == 0) { if ($_ui['ok'] == 0) {
21 22 $_user_add .= "Error: Internal error!"; $_user_add .= "Error: Internal error!";
22 23 } else if ($_ui['exists'] == 0) { } else if ($_ui['exists'] == 0) {
23 24 if (rg_user_edit($db, 0, $xuser, $email, $xpass, $is_admin, if (rg_user_edit($db, 0, $xuser, $email, $xpass, $is_admin,
24 $disk_quota_mb, $rights)) {
25 $disk_quota_mb, $rights, $session_time)) {
25 26 $_user_add .= "OK!<br />"; $_user_add .= "OK!<br />";
26 27 } }
27 28 } else { } else {
 
... ... if ($doit == 1) {
35 36 $is_admin = 0; $is_admin = 0;
36 37 $disk_quota_mb = 0; $disk_quota_mb = 0;
37 38 $rights = ""; $rights = "";
39 $session_time = $rg_session_time;
38 40 } }
39 41
40 42 $uid = 0; $uid = 0;
41 43
44 $user_form_add = 1;
42 45 include($INC . "/admin/users/user.form.php"); include($INC . "/admin/users/user.form.php");
43 46 $_user_add .= $_form; $_user_add .= $_form;
44 47
File inc/admin/users/edit.php changed (mode: 100644) (index cd62055..da77793)
... ... if ($doit == 1) {
18 18 $is_admin = rg_var_uint("is_admin"); $is_admin = rg_var_uint("is_admin");
19 19 $disk_quota_mb = rg_var_uint("disk_quota_mb"); $disk_quota_mb = rg_var_uint("disk_quota_mb");
20 20 $rights = @rg_rights_a2s($_REQUEST['rights']); $rights = @rg_rights_a2s($_REQUEST['rights']);
21 $session_time = rg_var_uint("session_time");
21 22
22 23 $_ui = rg_user_info($db, 0, $xuser, ""); $_ui = rg_user_info($db, 0, $xuser, "");
23 24 if ($_ui['ok'] == 0) { if ($_ui['ok'] == 0) {
 
... ... if ($doit == 1) {
27 28 $_user_edit .= "Error: User does not exists!"; $_user_edit .= "Error: User does not exists!";
28 29 } else { } else {
29 30 if (rg_user_edit($db, $uid, $xuser, $email, $xpass, if (rg_user_edit($db, $uid, $xuser, $email, $xpass,
30 $is_admin, $disk_quota_mb, $rights)) {
31 $is_admin, $disk_quota_mb, $rights, $session_time)) {
31 32 $_user_edit .= "OK!<br />"; $_user_edit .= "OK!<br />";
32 33 } }
33 34 } }
 
... ... if ($doit == 1) {
38 39 if ($_ui['ok'] == 0) { if ($_ui['ok'] == 0) {
39 40 $_user_edit .= "Error: Internal error!"; $_user_edit .= "Error: Internal error!";
40 41 } else if ($_ui['exists'] == 0) { } else if ($_ui['exists'] == 0) {
41 $_user_edit .= "User does not exists!<br />";
42 $_user_edit .= "User does not exist!<br />";
42 43 } else { } else {
43 44 $xuser = $_ui['username']; $xuser = $_ui['username'];
44 45 $email = $_ui['email']; $email = $_ui['email'];
 
... ... if ($doit == 1) {
50 51 } }
51 52 } }
52 53
54 $user_form_add = 1;
53 55 include($INC . "/admin/users/user.form.php"); include($INC . "/admin/users/user.form.php");
54 56 $_user_edit .= $_form; $_user_edit .= $_form;
55 57
File inc/admin/users/user.form.php changed (mode: 100644) (index b973195..6a0d1b2)
1 1 <?php <?php
2 2
3 $sel_is_admin = array(0 => "", 1 => "");
4 $sel_is_admin[$is_admin] = " selected=\"selected\"";
5
3 6 $_form = ' $_form = '
4 7 <form method="post" action="' . $_SERVER['PHP_SELF'] . '"> <form method="post" action="' . $_SERVER['PHP_SELF'] . '">
5 8 <input type="hidden" name="op" value="' . $op . '"> <input type="hidden" name="op" value="' . $op . '">
 
... ... $_form = '
19 22 <td>E-mail:</td> <td>E-mail:</td>
20 23 <td><input type="text" name="email" value="' . $email . '"/></td> <td><input type="text" name="email" value="' . $email . '"/></td>
21 24 </tr> </tr>
25 ';
22 26
27 if ($user_form_add == 1) {
28 $_form .= '
23 29 <tr> <tr>
24 30 <td>Password:</td> <td>Password:</td>
25 31 <td><input type="password" name="xpass" value="' . $xpass . '"/></td> <td><input type="password" name="xpass" value="' . $xpass . '"/></td>
26 32 </tr> </tr>
27 ';
28 33
29 if ($rg_ui['is_admin'] == 1) {
30 $_form .= '
31 34 <tr> <tr>
32 35 <td>Admin?</td> <td>Admin?</td>
33 36 <td> <td>
34 37 <select name="is_admin"> <select name="is_admin">
35 <option value="0">No</option>
36 <option value="1">Yes</option>
38 <option value="0"' . $sel_is_admin[0] . '>No</option>
39 <option value="1"' . $sel_is_admin[1] . '>Yes</option>
37 40 </select> </select>
38 41 </td> </td>
39 42 </tr> </tr>
 
... ... $_form .= '
52 55
53 56 $_form .= ' $_form .= '
54 57 <tr> <tr>
55 <td colspan="2"><input type="submit" value="Go!"/></td>
58 <td>Preferred session time (in seconds):</td>
59 <td><input type="text" name="session_time" value="' . $session_time . '"/></td>
60 </tr>
61
62 <tr>
63 <td colspan="2" align="center"><input type="submit" value="Go!"/></td>
56 64 </tr> </tr>
57 65 </table> </table>
58 66 </form> </form>
File inc/db.inc.php changed (mode: 100644) (index c549c4a..8fbb4e8)
... ... function rg_sql_query($db, $sql)
60 60 { {
61 61 global $rg_sql_debug; global $rg_sql_debug;
62 62
63 if ($rg_sql_debug > 0)
64 rg_log("DB: running [$sql]...");
63 if ($rg_sql_debug > 0) {
64 rg_log("\tDB: running [$sql]...");
65 $_s = microtime(TRUE);
66 }
65 67
66 68 $res = @pg_query($db, $sql); $res = @pg_query($db, $sql);
67 69 if ($res === FALSE) { if ($res === FALSE) {
 
... ... function rg_sql_query($db, $sql)
69 71 return FALSE; return FALSE;
70 72 } }
71 73
74 if ($rg_sql_debug > 0) {
75 $diff = sprintf("%u", (microtime(TRUE) - $_s) * 1000);
76 $rows = rg_sql_num_rows($res);
77 $arows = rg_sql_affected_rows($res);
78 rg_log("\tDB: Took " . $diff . "ms, $rows row(s), $arows affected");
79 }
80
72 81 return $res; return $res;
73 82 } }
74 83
 
... ... function rg_sql_num_rows($res)
113 122 return pg_num_rows($res); return pg_num_rows($res);
114 123 } }
115 124
125 function rg_sql_affected_rows($res)
126 {
127 return pg_affected_rows($res);
128 }
129
116 130 ?> ?>
File inc/db/struct.inc.php changed (mode: 100644) (index a5dc4bd..e47ced6)
... ... $rg_db_struct[0] = array(
7 7 . ", name TEXT UNIQUE NOT NULL" . ", name TEXT UNIQUE NOT NULL"
8 8 . ", uid INTEGER NOT NULL" . ", uid INTEGER NOT NULL"
9 9 . ", itime INTEGER NOT NULL" . ", itime INTEGER NOT NULL"
10 . ", disk_quota_mb INTEGER NOT NULL"
11 . ", max_commit_size INTEGER NOT NULL"
12 . ", master INTEGER NOT NULL"
13 . ", description TEXT NOT NULL"
14 . ", git_dir_done INTEGER NOT NULL"
15 . ", default_rights TEXT NOT NULL"
16 . ", deleted INTEGER NOT NULL"
17 . ", max_users INTEGER NOT NULL"
10 . ", disk_quota_mb INTEGER DEFAULT 0"
11 . ", disk_used_mb INTEGER NOT NULL DEFAULT 0"
12 . ", max_commit_size INTEGER DEFAULT 0"
13 . ", master INTEGER NOT NULL DEFAULT 0"
14 . ", description TEXT NOT NULL DEFAULT ''"
15 . ", git_dir_done INTEGER NOT NULL DEFAULT 0"
16 . ", default_rights TEXT NOT NULL DEFAULT ''"
17 . ", deleted INTEGER NOT NULL DEFAULT 0"
18 . ", max_users INTEGER NOT NULL DEFAULT 0"
18 19 . ")", . ")",
19 20 "rights" => "CREATE TABLE rights" "rights" => "CREATE TABLE rights"
20 21 . " (type TEXT NOT NULL" . " (type TEXT NOT NULL"
 
... ... $rg_db_struct[0] = array(
29 30 . " (key_id SERIAL PRIMARY KEY" . " (key_id SERIAL PRIMARY KEY"
30 31 . ", itime INTEGER NOT NULL" . ", itime INTEGER NOT NULL"
31 32 . ", uid INTEGER NOT NULL" . ", uid INTEGER NOT NULL"
32 . ", key TEXT NOT NULL)",
33 . ", key TEXT UNIQUE NOT NULL)",
33 34 "users" => "CREATE TABLE users" "users" => "CREATE TABLE users"
34 35 . " (uid SERIAL PRIMARY KEY" . " (uid SERIAL PRIMARY KEY"
35 36 . ", username TEXT UNIQUE NOT NULL" . ", username TEXT UNIQUE NOT NULL"
 
... ... $rg_db_struct[0] = array(
37 38 . ", pass TEXT NOT NULL" . ", pass TEXT NOT NULL"
38 39 . ", email TEXT NOT NULL" . ", email TEXT NOT NULL"
39 40 . ", itime INTEGER NOT NULL" . ", itime INTEGER NOT NULL"
40 . ", suspended INTEGER NOT NULL"
41 . ", session_time INTEGER DEFAULT 3600 NOT NULL"
42 . ", last_seen INTEGER NOT NULL"
43 . ", is_admin INTEGER NOT NULL"
44 . ", disk_quota_mb INTEGER NOT NULL"
45 . ", disk_mb INTEGER NOT NULL"
41 . ", suspended INTEGER NOT NULL DEFAULT 0"
42 . ", session_time INTEGER NOT NULL DEFAULT 3600"
43 . ", last_seen INTEGER NOT NULL DEFAULT 0"
44 . ", is_admin INTEGER NOT NULL DEFAULT 0"
45 . ", disk_quota_mb INTEGER NOT NULL DEFAULT 0"
46 . ", disk_used_mb INTEGER NOT NULL DEFAULT 0"
46 47 . ", rights TEXT NOT NULL" . ", rights TEXT NOT NULL"
47 48 . ")", . ")",
48 49 "sess" => "CREATE TABLE sess" "sess" => "CREATE TABLE sess"
File inc/dispatch/dispatch.php changed (mode: 100644) (index b369a1f..3e3586f)
... ... case 'keys':
42 42 $body .= $_keys; $body .= $_keys;
43 43 break; break;
44 44
45 case 'forgotlink': // forgot pass link
45 case 'forgot_link': // forgot pass link
46 46 include($INC . "/user/forgot.php"); include($INC . "/user/forgot.php");
47 47 $body .= $_forgot; $body .= $_forgot;
48 48 break; break;
49 49
50 case 'forgotmail': // forgot pass - send mail
51 include($INC . "/user/forgot_mail.php");
50 case 'forgot_send': // forgot pass - send mail
51 include($INC . "/user/forgot_send.php");
52 52 $body .= $_forgot; $body .= $_forgot;
53 53 break; break;
54 54
 
... ... case 'personal':
61 61 include($INC . "/personal/personal.php"); include($INC . "/personal/personal.php");
62 62 $body .= $_personal; $body .= $_personal;
63 63 break; break;
64
65 default:
66 rg_log("Invalid operation!");
64 67 } }
65 68
66 69 $op = $new_op; $op = $new_op;
67 rg_log("new op=$op.");
70 if (!empty($op))
71 rg_log("new op=$op.");
68 72 ?> ?>
File inc/git.inc.php changed (mode: 100644) (index d5e14df..8acf049)
... ... function rg_git_error()
20 20
21 21 function rg_git_install_hooks($dst) function rg_git_install_hooks($dst)
22 22 { {
23 global $rg_scripts;
24
23 25 rg_log("git_install_hooks: dst=$dst..."); rg_log("git_install_hooks: dst=$dst...");
24 26
25 rg_log("\tNot yet implemented!");
27 if (file_exists($dst . "/hooks")) {
28 //rg_log("hooks folder exists...");
29 $_dir = @readlink($dst . "/hooks");
30 if ($_dir !== FALSE) {
31 //rg_log("\treadlink returned=[$_dir]");
32 if (strcmp($_dir, $rg_scripts . "/hooks") == 0)
33 return TRUE;
34 }
35
36 rg_log("\tNot a link to scripts one, make it...");
37 if (!rg_rmdir($dst . "/hooks")) {
38 rg_git_set_error("cannot remove hooks dir ($php_errormsg)");
39 return FALSE;
40 }
41 }
42
43 if (!@symlink($rg_scripts . "/hooks", $dst . "/hooks")) {
44 rg_git_set_error("cannot make symlink [$rg_scripts/hooks]"
45 . "->[$dst/] ($php_errormsg).");
46 return FALSE;
47 }
48
26 49 return TRUE; return TRUE;
27 50 } }
28 51
 
... ... function rg_git_init($dst)
34 57 if (!file_exists($dir)) { if (!file_exists($dir)) {
35 58 $r = @mkdir($dir, 0755, TRUE); $r = @mkdir($dir, 0755, TRUE);
36 59 if ($r === FALSE) { if ($r === FALSE) {
37 rg_log("\tCannot create dir [$dir] ($php_errormsg)!");
60 rg_git_set_error("cannot create dir [$dir] ($php_errormsg)");
38 61 return FALSE; return FALSE;
39 62 } }
40 63 } }
41 64
42 if (file_exists($dst . "/rocketgit")) {
43 rg_log("\tGit repo was created OK. Skip cloning.");
44 } else {
65 if (!file_exists($dst . "/rocketgit")) {
45 66 $cmd = "git init --bare '" . escapeshellcmd($dst) . "'"; $cmd = "git init --bare '" . escapeshellcmd($dst) . "'";
46 67 rg_log("\texec $cmd..."); rg_log("\texec $cmd...");
47 68 $a = exec($cmd, $output, $err); $a = exec($cmd, $output, $err);
48 69 if ($err != 0) { if ($err != 0) {
49 rg_log("\tError $err (" . implode("|", $output) . " ($a)!");
70 rg_git_set_error("crror $err (" . implode("|", $output) . " ($a)");
50 71 return FALSE; return FALSE;
51 72 } }
52 73
53 74 if (!@mkdir($dst . "/rocketgit")) { if (!@mkdir($dst . "/rocketgit")) {
54 rg_log("\tCannot create '$dst/rocketgit' dir ($php_errormsg)!");
75 rg_git_set_error("cannot create '$dst/rocketgit' dir ($php_errormsg)");
55 76 return FALSE; return FALSE;
56 77 } }
57 78 } }
58 79
59 if (rg_git_install_hooks($dst) === FALSE)
80 if (rg_git_install_hooks($dst) !== TRUE)
60 81 return FALSE; return FALSE;
61 82
62 83 return TRUE; return TRUE;
 
... ... function rg_git_clone($src, $dst)
70 91 if (!file_exists($dir)) { if (!file_exists($dir)) {
71 92 $r = @mkdir($dir, 0755, TRUE); $r = @mkdir($dir, 0755, TRUE);
72 93 if ($r === FALSE) { if ($r === FALSE) {
73 rg_log("\tCannot create dir [$dir] ($php_errormsg)!");
94 rg_git_set_error("cannot create dir [$dir] ($php_errormsg)");
74 95 return FALSE; return FALSE;
75 96 } }
76 97 } }
77 98
78 if (file_exists($dst . "/rocketgit")) {
79 rg_log("\tGit repo was created OK. Skip cloning.");
80 } else {
99 if (!file_exists($dst . "/rocketgit")) {
81 100 $cmd = "git clone --bare '" . escapeshellcmd($src) . "'" $cmd = "git clone --bare '" . escapeshellcmd($src) . "'"
82 101 . " '" . escapeshellcmd($dst) . "'"; . " '" . escapeshellcmd($dst) . "'";
83 102 rg_log("\texec $cmd..."); rg_log("\texec $cmd...");
84 103 $a = exec($cmd); $a = exec($cmd);
85 104 if ($err != 0) { if ($err != 0) {
86 rg_log("\tError $err (" . implode("|", $output) . " ($a)!");
105 rg_git_set_error("error $err (" . implode("|", $output) . " ($a)");
87 106 return FALSE; return FALSE;
88 107 } }
89 108
90 if (!@mkdir($dst . "/rocketgit")) {
91 rg_log("\tCannot create '$dst/rocketgit' dir ($php_errormsg)!");
109 if (!@mkdir($dst . "/rocketgit", 0700)) {
110 rg_git_set_error("cannot create '$dst/rocketgit' dir ($php_errormsg)");
92 111 return FALSE; return FALSE;
93 112 } }
94 113 } }
95 114
96 if (rg_git_install_hooks($dst) === FALSE)
115 if (rg_git_install_hooks($dst) !== TRUE)
97 116 return FALSE; return FALSE;
98 117
99 118 return TRUE; return TRUE;
 
... ... function rg_git_clone($src, $dst)
104 123 */ */
105 124 function rg_git_type($obj) function rg_git_type($obj)
106 125 { {
107 $cmd = "git cat-file -t '" . escapeshellcmd($obj) . "'";
126 $cmd = "git cat-file -t '" . $obj . "'";
108 127 rg_log("\texec $cmd..."); rg_log("\texec $cmd...");
109 128 $a = exec($cmd, $output, $err); $a = exec($cmd, $output, $err);
110 129 if ($err != 0) { if ($err != 0) {
111 rg_log("\tError $err (" . implode("|", $output) . " ($a)!");
130 rg_git_set_error("error $err (" . implode("|", $output) . " ($a)");
112 131 return FALSE; return FALSE;
113 132 } }
114 133
 
... ... function rg_git_type($obj)
116 135 } }
117 136
118 137 /* /*
119 * Corrects a ref
138 * Corrects a revision
120 139 */ */
121 function rg_git_ref($s)
140 function rg_git_rev($rev)
122 141 { {
123 return preg_replace("/[^a-zA-Z0-9^~]/", "", $s);
142 return preg_replace("/[^a-zA-Z0-9^~]/", "", $rev);
124 143 } }
125 144
126 // Check a ref if is OK
145 // Check a revision if is OK
127 146 // TODO: Unit testing // TODO: Unit testing
128 function rg_git_ref_ok($ref)
147 function rg_git_rev_ok($rev)
129 148 { {
130 $cmd = "git rev-parse --verify --quiet " . escapeshellcmd($ref);
149 $cmd = "git rev-parse --verify --quiet '" . $rev . "'";
131 150 rg_log("\texec $cmd..."); rg_log("\texec $cmd...");
132 $a = exec($cmd, $output, $err);
151 $a = @exec($cmd, $output, $err);
133 152 if ($err != 0) { if ($err != 0) {
134 rg_log("\tError $err (" . implode("|", $output) . " ($a)!");
153 rg_git_set_error("error $err out=[" . implode("|", $output) . "] a=[$a]");
135 154 return FALSE; return FALSE;
136 155 } }
137 156
138 157 return TRUE; return TRUE;
139 158 } }
140 159
141 // returns TRUE if bad whitespace detected
160 // returns FALSE if bad whitespace detected
142 161 // TODO: Unit testing // TODO: Unit testing
143 function rg_git_bad_whitespace($old, $new)
162 function rg_git_whitespace_ok($old, $new)
144 163 { {
145 $cmd = "git diff --check --quiet " . escapeshellcmd($old) . " "
146 . escapeshellcmd($new);
164 $cmd = "git diff --check " . $old . " " . $new . "";
147 165 rg_log("\texec $cmd..."); rg_log("\texec $cmd...");
148 $a = exec($cmd, $output, $err);
166 $a = @exec($cmd, $output, $err);
149 167 if ($err != 0) { if ($err != 0) {
150 rg_log("\tError $err (" . implode("|", $output) . " ($a)!");
168 rg_git_set_error("error $err out=[" . implode("|", $output) . "] a=[$a]");
151 169 return FALSE; return FALSE;
152 170 } }
153 171
File inc/keys.inc.php changed (mode: 100644) (index eea7b98..cc67061)
... ... function rg_keys_regen($db)
123 123 global $rg_ssh_paras; global $rg_ssh_paras;
124 124
125 125 $dirty = rg_state_get($db, "authorized_keys"); $dirty = rg_state_get($db, "authorized_keys");
126 if ($dirty === 0) {
126 if ($dirty == 0) {
127 127 rg_log("Skip generation because is not dirty!"); rg_log("Skip generation because is not dirty!");
128 128 return TRUE; return TRUE;
129 129 } }
 
... ... function rg_keys_regen($db)
159 159 } }
160 160 while (($row = rg_sql_fetch_array($res))) { while (($row = rg_sql_fetch_array($res))) {
161 161 rg_log("Writing key [" . $row['key'] . "] for uid " . $row['uid']); rg_log("Writing key [" . $row['key'] . "] for uid " . $row['uid']);
162 $buf = "command=\"/usr/bin/php " . $rg_scripts . "/ssh.php"
162 $buf = "command=\"/usr/bin/php " . $rg_scripts . "/remote.php"
163 163 . " " . $row['uid'] . "\"" . " " . $row['uid'] . "\""
164 164 . "," . $rg_ssh_paras . "," . $rg_ssh_paras
165 165 . " " . $row['key'] . "\n"; . " " . $row['key'] . "\n";
File inc/log.inc.php changed (mode: 100644) (index 4ecc45a..b8bdd47)
... ... function rg_log($str)
22 22 $rg_log_fd = @fopen($rg_log_file, "a+"); $rg_log_fd = @fopen($rg_log_file, "a+");
23 23 if ($rg_log_fd === FALSE) if ($rg_log_fd === FALSE)
24 24 return; return;
25 @chmod($rg_log_file, 0600);
25 26 // write an empty line // write an empty line
26 27 fwrite($rg_log_fd, "\n"); fwrite($rg_log_fd, "\n");
27 28 } }
28 29
29 30 $t = gettimeofday(); $t = gettimeofday();
30 $buf = gmdate("Y-m-d H:i:s", $t['sec']) . "." . sprintf("%06d", $t['usec']);
31 $buf = gmdate("Y-m-d H:i:s", $t['sec']) . "." . sprintf("%03u", $t['usec'] / 1000);
31 32 $buf .= " " . $rg_log_sid . " " . $str . "\n"; $buf .= " " . $rg_log_sid . " " . $str . "\n";
32 33
33 34 fwrite($rg_log_fd, $buf); fwrite($rg_log_fd, $buf);
File inc/login/login.form.php changed (mode: 100644) (index fb7b17c..7723ef5)
... ... if (count($errmsg) > 0)
7 7 $_form .= ' $_form .= '
8 8 <form method="post" action="' . $_SERVER['PHP_SELF'] . '"> <form method="post" action="' . $_SERVER['PHP_SELF'] . '">
9 9 <input type="hidden" name="op" value="' . $op . '"> <input type="hidden" name="op" value="' . $op . '">
10 <input type="hidden" name="subop" value="1">
10 11 <input type="hidden" name="doit" value="1"> <input type="hidden" name="doit" value="1">
11 12 <input type="hidden" name="token" value="' . rg_token_get($db, $sid) . '"> <input type="hidden" name="token" value="' . rg_token_get($db, $sid) . '">
12 13
 
... ... Password: <input type="password" name="pass" value="' . $pass . '"><br />
15 16 <input type="submit" value="Login"> <input type="submit" value="Login">
16 17 </form> </form>
17 18 <br /> <br />
18
19 Forgot your password?<br />
20 <form method="post" action="' . $_SERVER['PHP_SELF'] . '">
21 <input type="hidden" name="op" value="forgotmail">
22 <input type="hidden" name="doit" value="1">
23 <input type="hidden" name="token" value="' . rg_token_get($db, $sid) . '">
24
25 E-mail: <input type="text" name="email" value=""><br />
26 <input type="submit" value="Recover password">
27 </form>
19 <a href="' . rg_re_url("forgot_send") . '">Forgot your password?</a>
28 20 '; ';
29 21
30
31 22 ?> ?>
File inc/personal/personal.php changed (mode: 100644) (index 3bb262f..cd6b44c)
... ... case 1: // edit info
31 31
32 32 $xuser = rg_var_str("xuser"); $xuser = rg_var_str("xuser");
33 33 $email = rg_var_str("email"); $email = rg_var_str("email");
34 $xpass = rg_var_str("xpass");
35 34 $is_admin = $rg_ui['is_admin']; // TODO: doesn't seems too elegant $is_admin = $rg_ui['is_admin']; // TODO: doesn't seems too elegant
36 35 $disk_quota_mb = $rg_ui['disk_quota_mb']; $disk_quota_mb = $rg_ui['disk_quota_mb'];
37 36 $rights = $rg_ui['rights']; $rights = $rg_ui['rights'];
37 $session_time = rg_var_uint("session_time");
38 38
39 $xpass = "";
39 40 if (rg_user_edit($db, $rg_ui['uid'], $xuser, $email, $xpass, if (rg_user_edit($db, $rg_ui['uid'], $xuser, $email, $xpass,
40 $is_admin, $disk_quota_mb, $rights)) {
41 $is_admin, $disk_quota_mb, $rights, $session_time)) {
41 42 $_body .= "OK!<br />"; $_body .= "OK!<br />";
42 43 } }
43 44 } else { } else {
44 // TODO: Check if user has the right to edit this info!
45
46 45 $xuser = $rg_ui['username']; $xuser = $rg_ui['username'];
47 46 $email = $rg_ui['email']; $email = $rg_ui['email'];
48 $xpass = "";
47 $is_admin = $rg_ui['is_admin'];
48 $disk_quota_mb = $rg_ui['disk_quota_mb'];
49 $rights = $rg_ui['rights'];
49 50 $session_time = $rg_ui['session_time']; $session_time = $rg_ui['session_time'];
50 51 } }
51 52
53 $user_form_add = 0;
52 54 include($INC . "/admin/users/user.form.php"); include($INC . "/admin/users/user.form.php");
53 55 $_body .= $_form; $_body .= $_form;
54 56 break; break;
55 57
56 58 case 2: // change password case 2: // change password
59 $show_form = 1;
57 60 $error = array(); $error = array();
58 61 if ($doit == 1) { if ($doit == 1) {
59 62 $old_pass = rg_var_str("old_pass"); $old_pass = rg_var_str("old_pass");
 
... ... case 2: // change password
66 69 break; break;
67 70 } }
68 71
69 if (!rg_user_pass_valid($db, $rg_ui['uid'], $old_pass)) {
70 $error[] = "Old password is invalid!";
72 if (strcmp($pass1, $pass2) != 0) {
73 $error[] = "Passwords does not match!";
71 74 break; break;
72 75 } }
73 76
74 if (strcmp($pass1, $pass2) != 0) {
75 $error[] = "Passwords does not match!";
77 if (!rg_user_pass_valid($db, $rg_ui['uid'], $old_pass)) {
78 $error[] = "Old password is invalid!";
76 79 break; break;
77 80 } }
78 81
 
... ... case 2: // change password
80 83 $error[] = rg_user_error(); $error[] = rg_user_error();
81 84 break; break;
82 85 } }
86
87 $_body .= "OK!<br />";
88 $show_form = 0;
89 break;
83 90 } }
84 91 } }
85 92
86 include($INC . "/personal/pass.form.php");
87 $_body .= $_chpass_form;
93 if ($show_form == 1) {
94 include($INC . "/personal/pass.form.php");
95 $_body .= $_chpass_form;
96 }
97
88 98 break; break;
89 99 } }
90 100
File inc/repo.inc.php changed (mode: 100644) (index 6af30b2..20d39e9)
... ... function rg_repo_allow($db, $ri, $rg_ui, $needed_rights)
175 175 * @master - makes sense only for clones - who is the master. * @master - makes sense only for clones - who is the master.
176 176 * TODO: put all fields into an array! * TODO: put all fields into an array!
177 177 */ */
178 function rg_repo_create($db, $master, $rg_ui, $name, $max_commit_size, $desc,
179 $rights, $max_users)
178 function rg_repo_create($db, $master, $rg_ui, $name, $max_commit_size,
179 $description, $rights, $max_users)
180 180 { {
181 181 // TODO: reorder parameters - are not logical // TODO: reorder parameters - are not logical
182 182 rg_log("repo_create: rg_uid=" . $rg_ui['uid'] rg_log("repo_create: rg_uid=" . $rg_ui['uid']
183 183 . ", name=[$name], master=$master" . ", name=[$name], master=$master"
184 . ", max_commit_size=$max_commit_size, desc=[$desc]"
184 . ", max_commit_size=$max_commit_size"
185 . ", description=[$description]"
185 186 . ", rights=$rights, max_users=$max_users..."); . ", rights=$rights, max_users=$max_users...");
186 187
187 188 // TODO: test if user is allowed to add a repository // TODO: test if user is allowed to add a repository
 
... ... function rg_repo_create($db, $master, $rg_ui, $name, $max_commit_size, $desc,
199 200 } }
200 201
201 202 $e_name = rg_sql_escape($db, $name); $e_name = rg_sql_escape($db, $name);
202 $e_desc = rg_sql_escape($db, $desc);
203 $e_description = rg_sql_escape($db, $description);
203 204
204 205 $itime = time(); $itime = time();
205 206
 
... ... function rg_repo_create($db, $master, $rg_ui, $name, $max_commit_size, $desc,
207 208 . ", max_commit_size, description, git_dir_done, default_rights" . ", max_commit_size, description, git_dir_done, default_rights"
208 209 . ", max_users)" . ", max_users)"
209 210 . " VALUES (" . $rg_ui['uid'] . ", $master, '$e_name', $itime" . " VALUES (" . $rg_ui['uid'] . ", $master, '$e_name', $itime"
210 . ", $max_commit_size, '$e_desc', 0, '$rights', $max_users)";
211 . ", $max_commit_size, '$e_description', 0, '$rights', $max_users)";
211 212 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
212 213 if ($res === FALSE) { if ($res === FALSE) {
213 214 rg_repo_set_error("Cannot insert (" . rg_sql_error() . ")"); rg_repo_set_error("Cannot insert (" . rg_sql_error() . ")");
 
... ... function rg_repo_update($db, &$new)
251 252 rg_log("repo_update: repo_id=" . $new['repo_id'] rg_log("repo_update: repo_id=" . $new['repo_id']
252 253 . ", name=[" . $new['name'] . "]" . ", name=[" . $new['name'] . "]"
253 254 . ", max_commit_size=" . $new['max_commit_size'] . ", max_commit_size=" . $new['max_commit_size']
254 . ", desc=[" . $new['desc'] . "]"
255 . ", description=[" . $new['description'] . "]"
255 256 . ", default_rights=" . $new['default_rights'] . ", default_rights=" . $new['default_rights']
256 257 . ", max_users=" . $new['max_users']); . ", max_users=" . $new['max_users']);
257 258
 
... ... function rg_repo_update($db, &$new)
277 278 } }
278 279
279 280 $e_name = rg_sql_escape($db, $new['name']); $e_name = rg_sql_escape($db, $new['name']);
280 $e_desc = rg_sql_escape($db, $new['desc']);
281 $e_description = rg_sql_escape($db, $new['description']);
281 282
282 283 $sql = "UPDATE repos SET name = '$e_name'" $sql = "UPDATE repos SET name = '$e_name'"
283 284 . ", max_commit_size = " . $new['max_commit_size'] . ", max_commit_size = " . $new['max_commit_size']
284 . ", description = '$e_desc'"
285 . ", description = '$e_description'"
285 286 . ", default_rights = '" . $new['default_rights'] . "'" . ", default_rights = '" . $new['default_rights'] . "'"
286 287 . ", max_users = " . $new['max_users'] . ", max_users = " . $new['max_users']
287 288 . " WHERE repo_id = " . $new['repo_id']; . " WHERE repo_id = " . $new['repo_id'];
 
... ... function rg_repo_list_query($db, $url, $sql)
321 322 $ret .= " <th>Clone of</th>\n"; $ret .= " <th>Clone of</th>\n";
322 323 $ret .= " <th>Creation date (UTC)</th>\n"; $ret .= " <th>Creation date (UTC)</th>\n";
323 324 $ret .= " <th>Default rights</th>\n"; $ret .= " <th>Default rights</th>\n";
324 $ret .= " <th>Disk current/max</th>\n";
325 $ret .= " <th>Disk used/max</th>\n";
325 326 $ret .= " <th>Max commit size</th>\n"; $ret .= " <th>Max commit size</th>\n";
326 327 $ret .= " <th>Max users</th>\n"; $ret .= " <th>Max users</th>\n";
327 328 $ret .= "</tr>\n"; $ret .= "</tr>\n";
 
... ... function rg_repo_list_query($db, $url, $sql)
354 355
355 356 $_max = "ulimited"; $_max = "ulimited";
356 357 if ($row['disk_quota_mb'] > 0) if ($row['disk_quota_mb'] > 0)
357 $_max = rg_1024($row['disk_quota_mb']);
358 $ret .= " <td>" . $row['disk_mb'] . "/" . $_max . "</td>\n";
358 $_max = rg_1024($row['disk_quota_mb'] * 1024 * 1024);
359 $ret .= " <td>" . $row['disk_used_mb'] . "/" . $_max . "</td>\n";
359 360
360 361 $_v = "ulimited"; $_v = "ulimited";
361 362 if ($row['max_commit_size'] > 0) if ($row['max_commit_size'] > 0)
File inc/repo/repo.form.php changed (mode: 100644) (index a6d7aa0..666c841)
... ... $_form .= '
45 45 <tr> <tr>
46 46 <td>Description:</td> <td>Description:</td>
47 47 <td> <td>
48 <textarea name="desc" value="' . $desc . '" rows="4" cols="30">' . $desc . '</textarea><br />
48 <textarea name="description" value="' . $description . '" rows="4" cols="30">' . $description . '</textarea><br />
49 49 </td> </td>
50 50 </tr> </tr>
51 51
File inc/repo/repo.php changed (mode: 100644) (index 3d05e09..473a0c3)
... ... if ($rg_ui['uid'] == 0) {
11 11 $name = rg_var_str("name"); $name = rg_var_str("name");
12 12 $max_commit_size = rg_var_uint("max_commit_size"); $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 $desc = rg_var_str("desc");
14 $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_var_str("rights");
17 $rights = rg_rights_a2s($rights);
16 $rights = @rg_rights_a2s($_REQUEST['rights']);
18 17 $repo_id = rg_var_uint("repo_id"); $repo_id = rg_var_uint("repo_id");
19 18 $q = rg_var_str("q"); $q = rg_var_str("q");
20 19 $masters = rg_var_uint("masters"); $masters = rg_var_uint("masters");
 
... ... switch ($subop) {
35 34 case 1: // create case 1: // create
36 35 if ($doit == 1) { if ($doit == 1) {
37 36 $_r = rg_repo_create($db, $master_repo_id, $rg_ui, $name, $_r = rg_repo_create($db, $master_repo_id, $rg_ui, $name,
38 $max_commit_size, $desc, $rights, $max_users);
37 $max_commit_size, $description, $rights, $max_users);
39 38 if ($_r === FALSE) if ($_r === FALSE)
40 39 $_body .= rg_repo_error(); $_body .= rg_repo_error();
41 40 else else
File inc/repo/repo_page.php changed (mode: 100644) (index 7ddfab8..910d698)
... ... $repo = rg_var_str("repo");
5 5 $repo_id = rg_var_uint("repo_id"); $repo_id = rg_var_uint("repo_id");
6 6 $name = rg_var_str("name"); $name = rg_var_str("name");
7 7 $max_commit_size = rg_var_uint("max_commit_size"); $max_commit_size = rg_var_uint("max_commit_size");
8 $desc = rg_var_str("desc");
8 $description = rg_var_str("description");
9 9 $rights = @rg_rights_a2s($_REQUEST['rights']); $rights = @rg_rights_a2s($_REQUEST['rights']);
10 10 $max_users = rg_var_uint("max_users"); $max_users = rg_var_uint("max_users");
11 11 $user = rg_var_str("user"); $user = rg_var_str("user");
 
... ... case 1: // edit
43 43
44 44 $ri['name'] = $name; // TODO: filter name! $ri['name'] = $name; // TODO: filter name!
45 45 $ri['max_commit_size'] = $max_commit_size; $ri['max_commit_size'] = $max_commit_size;
46 $ri['desc'] = $desc; // TODO: filter
46 $ri['description'] = $description; // TODO: filter
47 47 $ri['default_rights'] = $rights; // TODO: filter $ri['default_rights'] = $rights; // TODO: filter
48 48 $ri['max_users'] = $max_users; $ri['max_users'] = $max_users;
49 49 $_r = rg_repo_update($db, $ri); $_r = rg_repo_update($db, $ri);
 
... ... case 1: // edit
61 61 $rights = $ri['default_rights']; $rights = $ri['default_rights'];
62 62 $max_commit_size = $ri['max_commit_size']; $max_commit_size = $ri['max_commit_size'];
63 63 $max_users = $ri['max_users']; $max_users = $ri['max_users'];
64 $desc = $ri['desc'];
64 $description = $ri['description'];
65 65
66 66 $_action = "Update"; $_action = "Update";
67 67 include($INC . "/repo/repo.form.php"); include($INC . "/repo/repo.form.php");
File inc/rights.inc.php changed (mode: 100644) (index 3d8c054..9d20553)
... ... function rg_rights_checkboxes($type, $passed_rights)
91 91 foreach ($rg_rights[$type] as $right => $info) { foreach ($rg_rights[$type] as $right => $info) {
92 92 $add = ""; $add = "";
93 93 if (strstr($passed_rights, $right)) if (strstr($passed_rights, $right))
94 $add = " checked";
94 $add = " checked=\"checked\"";
95 95 $ret .= "<input type=\"checkbox\" name=\"rights[$right]\"" $ret .= "<input type=\"checkbox\" name=\"rights[$right]\""
96 96 . $add . " />$info<br />\n"; . $add . " />$info<br />\n";
97 97 } }
 
... ... function rg_rights_a2s($a)
129 129 { {
130 130 $rights = ""; $rights = "";
131 131
132 // TODO - log backtrace instead being silent
132 133 if (is_array($a)) if (is_array($a))
133 134 foreach ($a as $right => $junk) foreach ($a as $right => $junk)
134 135 $rights .= $right; $rights .= $right;
 
... ... function rg_rights_list($db, $type, $obj_id, $url)
271 272 return $ret; return $ret;
272 273 } }
273 274
275 /*
276 * Filters var using mask
277 * Example ("ABCDE", "AEZ") => "AE"
278 */
279 function rg_rights_mask($val, $mask)
280 {
281 $ret = "";
282 $len = strlen($val);
283 for ($i = 0; $i < $len; $i++)
284 if (strstr($mask, $val[$i]))
285 $ret .= $val[$i];
286
287 return $ret;
288 }
289
274 290 ?> ?>
File inc/token.inc.php changed (mode: 100644) (index 2f2e042..6e7c67b)
... ... function rg_token_delete($db, $sid, $token)
38 38 . $add_token; . $add_token;
39 39 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
40 40 if ($res === FALSE) { if ($res === FALSE) {
41 rg_token_set_error("Cannot delete token (" . rg_sql_error() . ")!");
41 rg_token_set_error("cannot delete token (" . rg_sql_error() . ")");
42 42 return $ret; return $ret;
43 43 } }
44 44 rg_sql_free_result($res); rg_sql_free_result($res);
 
... ... function rg_token_delete($db, $sid, $token)
49 49 } }
50 50
51 51 /* /*
52 * Returns if the token is valid
52 * Returns TRUE if the token is valid
53 53 */ */
54 54 function rg_token_valid($db, $sid, $token) function rg_token_valid($db, $sid, $token)
55 55 { {
 
... ... function rg_token_valid($db, $sid, $token)
60 60 . " AND sid = '$sid'"; . " AND sid = '$sid'";
61 61 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
62 62 if ($res === FALSE) { if ($res === FALSE) {
63 rg_token_set_error("Cannot get token (" . rg_sql_error() . ")!");
63 rg_token_set_error("cannot get token (" . rg_sql_error() . ")");
64 64 return FALSE; return FALSE;
65 65 } }
66 66
67 67 $ret['ok'] = 1; $ret['ok'] = 1;
68 68 $ret['exists'] = 0; $ret['exists'] = 0;
69 $row = rg_sql_fetch_array($res);
69 $rows = rg_sql_num_rows($res);
70 70 rg_sql_free_result($res); rg_sql_free_result($res);
71 if (!isset($row['junk'])) {
72 rg_token_set_error("Token not found!");
73 return TRUE;
74 }
71 if ($rows == 0)
72 return FALSE;
75 73
76 74 return TRUE; return TRUE;
77 75 } }
File inc/user.inc.php changed (mode: 100644) (index 63568c8..cf88590)
... ... function rg_user_ok($user)
81 81 * If uid > 0 - edit, else, add * If uid > 0 - edit, else, add
82 82 */ */
83 83 function rg_user_edit($db, $uid, $user, $email, $pass, $is_admin, function rg_user_edit($db, $uid, $user, $email, $pass, $is_admin,
84 $disk_quota_mb, $rights)
84 $disk_quota_mb, $rights, $session_time)
85 85 { {
86 global $rg_session_time;
87
88 86 rg_log("user_edit: uid=$uid, user=$user email=$email" rg_log("user_edit: uid=$uid, user=$user email=$email"
89 87 . " pass=$pass is_admin=$is_admin" . " pass=$pass is_admin=$is_admin"
90 . " disk_quota_mb=$disk_quota_mb rights=$rights...");
88 . " disk_quota_mb=$disk_quota_mb rights=$rights"
89 . " session_time=$session_time...");
91 90
92 91 if (rg_user_ok($user) !== TRUE) if (rg_user_ok($user) !== TRUE)
93 92 return FALSE; return FALSE;
 
... ... function rg_user_edit($db, $uid, $user, $email, $pass, $is_admin,
97 96 $e_pass = rg_user_pass($e_salt, $pass); $e_pass = rg_user_pass($e_salt, $pass);
98 97 $e_email = rg_sql_escape($db, $email); $e_email = rg_sql_escape($db, $email);
99 98 $e_rights = rg_sql_escape($db, $rights); $e_rights = rg_sql_escape($db, $rights);
100 $e_session_time = $rg_session_time;
101 99
102 100 if ($uid == 0) { // add if ($uid == 0) { // add
103 101 if (rg_user_pass_ok($pass) !== TRUE) if (rg_user_pass_ok($pass) !== TRUE)
 
... ... function rg_user_edit($db, $uid, $user, $email, $pass, $is_admin,
108 106 . ", is_admin, disk_quota_mb, rights, session_time)" . ", is_admin, disk_quota_mb, rights, session_time)"
109 107 . " VALUES ('$e_user', '$e_salt', '$e_pass'" . " VALUES ('$e_user', '$e_salt', '$e_pass'"
110 108 . ", '$e_email', $now, $is_admin, $disk_quota_mb" . ", '$e_email', $now, $is_admin, $disk_quota_mb"
111 . ", '$e_rights', $e_session_time)";
109 . ", '$e_rights', $session_time)";
112 110 } else { // edit } else { // edit
113 111 $salt_pass_add = ""; $salt_pass_add = "";
114 112 if (!empty($pass)) if (!empty($pass))
 
... ... function rg_user_edit($db, $uid, $user, $email, $pass, $is_admin,
120 118 . ", is_admin = $is_admin" . ", is_admin = $is_admin"
121 119 . ", disk_quota_mb = $disk_quota_mb" . ", disk_quota_mb = $disk_quota_mb"
122 120 . ", rights = '$e_rights'" . ", rights = '$e_rights'"
123 . ", session_time = $e_session_time"
121 . ", session_time = $session_time"
124 122 . " WHERE uid = $uid"; . " WHERE uid = $uid";
125 123 } }
126 124
 
... ... function rg_user_pass_valid($db, $uid, $pass)
240 238 { {
241 239 rg_log("user_pass_valid: uid=$uid, pass=$pass..."); rg_log("user_pass_valid: uid=$uid, pass=$pass...");
242 240
243 if (empty($pass))
241 if (empty($pass)) {
242 rg_log("\tPassword is empty.");
244 243 return FALSE; return FALSE;
244 }
245 245
246 246 $ui = rg_user_info($db, $uid, "", ""); $ui = rg_user_info($db, $uid, "", "");
247 if ($ui['exists'] != 1)
247 if ($ui['exists'] != 1) {
248 rg_log("\tUser does not exists.");
248 249 return FALSE; return FALSE;
250 }
249 251
250 252 $sha1pass = rg_user_pass($ui['salt'], $pass); $sha1pass = rg_user_pass($ui['salt'], $pass);
251 if (strcmp($sha1pass, $ui['pass']) != 0)
253 if (strcmp($sha1pass, $ui['pass']) != 0) {
254 rg_log("\tPassword is not ok [$sha1pass] != [" . $ui['pass'] . "].");
252 255 return FALSE; return FALSE;
256 }
253 257
258 rg_log("\tPass is valid.");
254 259 return TRUE; return TRUE;
255 260 } }
256 261
 
... ... function rg_user_login_by_user_pass($db, $user, $pass, &$rg_ui)
291 296 $sid = rg_id(40); $sid = rg_id(40);
292 297 rg_sess_add($db, $rg_ui['uid'], $sid, $rg_ui['session_time']); rg_sess_add($db, $rg_ui['uid'], $sid, $rg_ui['session_time']);
293 298 setcookie("sid", $sid, 0, "/", $_SERVER['HTTP_HOST'], setcookie("sid", $sid, 0, "/", $_SERVER['HTTP_HOST'],
294 strcmp($_SERVER['HTTPS'], "on") == 0 /* secure */,
299 @strcmp($_SERVER['HTTPS'], "on") == 0 /* secure */,
295 300 TRUE /* httponly */); TRUE /* httponly */);
296 301
297 302 rg_user_set_last_seen($db, $rg_ui['uid']); rg_user_set_last_seen($db, $rg_ui['uid']);
 
... ... function rg_user_list($db, $url)
426 431 $ret .= " <td>" . ($row['is_admin'] == 1 ? "Yes" : "No") . "</td>\n"; $ret .= " <td>" . ($row['is_admin'] == 1 ? "Yes" : "No") . "</td>\n";
427 432 $ret .= " <td>" . gmdate("Y-m-d H:i:s", $row['itime']) . "</td>\n"; $ret .= " <td>" . gmdate("Y-m-d H:i:s", $row['itime']) . "</td>\n";
428 433 if ($row['disk_quota_mb'] > 0) if ($row['disk_quota_mb'] > 0)
429 $_v = rg_1024($row['disk_quota_mb']);
434 $_v = rg_1024($row['disk_quota_mb'] * 1024 * 1024);
430 435 else else
431 436 $_v = "unlimited"; $_v = "unlimited";
432 437 $ret .= " <td>" . $_v . "</td>\n"; $ret .= " <td>" . $_v . "</td>\n";
 
... ... function rg_user_forgot_pass_mail_prepare($db, $email)
543 548 */ */
544 549 function rg_user_forgot_pass_mail($db, $email) function rg_user_forgot_pass_mail($db, $email)
545 550 { {
551 global $rg_admin_name, $rg_admin_email;
552
546 553 rg_log("user_forgot_pass_mail: email=$email"); rg_log("user_forgot_pass_mail: email=$email");
547 554
548 $token = rg_user_forgot_pass_mail_prepare($db, $email);
549 if ($token === FALSE)
555 $forgot_token = rg_user_forgot_pass_mail_prepare($db, $email);
556 if ($forgot_token === FALSE)
550 557 return FALSE; return FALSE;
551 558
552 if (!mail($email, "Forgot password",
553 "Hello!\nIf you want to reset the password, follow:\n"
559 $headers = "From: $rg_admin_name <$rg_admin_email>";
560
561 if (!mail($email,
562 "Forgot password",
563 "Hello!\n"
564 . "If you want to reset the password, follow:\n"
554 565 . "http://" . @$_SERVER['SERVER_NAME'] . "http://" . @$_SERVER['SERVER_NAME']
555 . "/" . @$_SERVER['PHP_SELF']
556 . "?op=6&token=$token")) {
557 rg_user_set_error("Cannot send mail!");
566 . rg_re_url("forgot_link") . "&forgot_token=$forgot_token",
567 $headers,
568 "-f $rg_admin_email")) {
569 rg_user_set_error("Cannot send mail ($php_errormsg)!");
558 570 return FALSE; return FALSE;
559 571 } }
560 572
 
... ... function rg_user_forgot_pass_mail($db, $email)
566 578 */ */
567 579 function rg_user_forgot_pass_destroy($db, $uid) function rg_user_forgot_pass_destroy($db, $uid)
568 580 { {
569 rg_log("user_forgot_pass_destroy: token=$token");
581 rg_log("user_forgot_pass_destroy: uid=$uid");
570 582
571 583 $sql = "DELETE FROM forgot_pass WHERE uid = $uid"; $sql = "DELETE FROM forgot_pass WHERE uid = $uid";
572 584 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
 
... ... function rg_user_set_pass($db, $uid, $pass)
591 603 . ", pass = '$e_sha1pass'" . ", pass = '$e_sha1pass'"
592 604 . " WHERE uid = " . $uid; . " WHERE uid = " . $uid;
593 605 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
594 if ($res === FALSE)
606 if ($res === FALSE) {
607 rg_user_set_error("cannot update pass (" . rg_sql_error() . ")");
595 608 return FALSE; return FALSE;
609 }
596 610 rg_sql_free_result($res); rg_sql_free_result($res);
597 611
598 612 return TRUE; return TRUE;
File inc/user/forgot.form.php changed (mode: 100644) (index 6285035..5baca36)
2 2
3 3 $_forgot_form = ""; $_forgot_form = "";
4 4
5 if (!empty($error))
6 $_forgot_form .= "<font color=red>$error</font><br />\n";
5 if (count($errmsg) > 0)
6 $_forgot_form .= "<font color=red>" . implode("<br />\n", $errmsg) . "</font><br />\n";
7 7
8 8 $_forgot_form .= ' $_forgot_form .= '
9 9 <form method="post" action="' . $_SERVER['PHP_SELF'] . '"> <form method="post" action="' . $_SERVER['PHP_SELF'] . '">
10 10 <input type="hidden" name="op" value="' . $op . '"> <input type="hidden" name="op" value="' . $op . '">
11 <input type="hidden" name="ftoken" value="' . $ftoken . '">
11 <input type="hidden" name="forgot_token" value="' . $forgot_token . '">
12 12 <input type="hidden" name="doit" value="1"> <input type="hidden" name="doit" value="1">
13 13 <input type="hidden" name="token" value="' . rg_token_get($db, $sid) . '"> <input type="hidden" name="token" value="' . rg_token_get($db, $sid) . '">
14 14
File inc/user/forgot.php changed (mode: 100644) (index 9b7d719..f2a2a65)
1 1 <?php <?php
2 2 rg_log("/inc/user/forgot.php"); rg_log("/inc/user/forgot.php");
3 3
4 $ftoken = rg_var_str("ftoken");
4 $forgot_token = rg_var_str("forgot_token");
5 5 $pass1 = rg_var_str("pass1"); $pass1 = rg_var_str("pass1");
6 6 $pass2 = rg_var_str("pass2"); $pass2 = rg_var_str("pass2");
7 7
8 8 $_forgot = "<br />\n"; $_forgot = "<br />\n";
9 9
10 10 $_hide_form = 0; $_hide_form = 0;
11 $errmsg = array();
11 12
12 13 if ($doit == 1) { if ($doit == 1) {
13 $error = "";
14 14 if (strcmp($pass1, $pass2) != 0) { if (strcmp($pass1, $pass2) != 0) {
15 $error .= "Passwords mismatch.";
15 $errmsg[] = "Passwords mismatch.";
16 16 } else { } else {
17 $r = user_forgot_pass_uid($db, $ftoken);
17 $r = rg_user_forgot_pass_uid($db, $forgot_token);
18 18 if ($r['ok'] != 1) { if ($r['ok'] != 1) {
19 $error .= "Internal error, try again later.";
19 $errmsg[] = "Internal error, try again later.";
20 20 } else if ($r['uid'] == 0) { } else if ($r['uid'] == 0) {
21 $error .= "Invalid (or expired) reset pass URL!";
21 $errmsg[] = "Invalid (or expired) reset pass URL!";
22 22 } else { } else {
23 if (user_set_pass($db, $r['uid'], $pass1)) {
24 user_forgot_pass_destroy($db, $r['uid']);
23 if (rg_user_set_pass($db, $r['uid'], $pass1)) {
24 rg_user_forgot_pass_destroy($db, $r['uid']);
25 25 // auto-login // auto-login
26 $rg_ui = user_info($db, $r['uid'], "", "");
26 $rg_ui = rg_user_info($db, $r['uid'], "", "");
27 27 $_forgot .= "OK!"; $_forgot .= "OK!";
28 28 $_hide_form = 1; $_hide_form = 1;
29 29 } else { } else {
30 $error .= "Internal error - try later!";
30 $errmsg[] = "Internal error - try later!";
31 31 } }
32 32 } }
33 33 } }
File inc/user/forgot_mail.php deleted (index ca8df55..0000000)
1 <?php
2 rg_log("/inc/user/forgot_mail.php");
3
4 $email = rg_var_str("email");
5
6 $_forgot = "<br />\n";
7
8 if ($doit == 1) {
9 $r = user_forgot_pass_mail($db, $email);
10 if ($r === FALSE)
11 $_forgot .= "Cannot send mail!";
12 else
13 $_forgot .= "E-mail was sent!";
14 }
15
16 ?>
File inc/user/forgot_send.form.php added (mode: 100644) (index 0000000..ff806d6)
1 <?php
2 $_form = '';
3
4 if (count($errmsg) > 0)
5 $_form .= "<font color=red>" . implode("<br />\n", $errmsg) . "</font>\n";
6
7 $_form .= '
8 <form method="post" action="' . $_SERVER['PHP_SELF'] . '">
9 <input type="hidden" name="op" value="forgotsend">
10 <input type="hidden" name="subop" value="2">
11 <input type="hidden" name="doit" value="1">
12
13 E-mail: <input type="text" name="email" value=""><br />
14 <input type="submit" value="Recover password">
15 </form>
16 ';
17
18 ?>
File inc/user/forgot_send.php added (mode: 100644) (index 0000000..ad344f2)
1 <?php
2 rg_log("/inc/user/forgot_send.php");
3
4 $email = rg_var_str("email");
5
6 $_forgot = "<br />\n";
7
8 $show_form = 1;
9 $errmsg = array();
10
11 if ($doit == 1) {
12 $r = rg_user_forgot_pass_mail($db, $email);
13 if ($r === FALSE) {
14 $errmsg[] = "Cannot send mail!";
15 } else {
16 $_forgot .= "E-mail was sent!";
17 $show_form = 0;
18 }
19 }
20
21 if ($show_form == 1) {
22 include($INC ."/user/forgot_send.form.php");
23 $_forgot .= $_form;
24 }
25
26 ?>
File inc/util.inc.php changed (mode: 100644) (index 6b1a456..f47325c)
... ... function rg_re_repopage($repo_id, $repo_name)
87 87 if (isset($_REQUEST['rewrite_engine'])) if (isset($_REQUEST['rewrite_engine']))
88 88 return "/" . $repo_name; return "/" . $repo_name;
89 89
90 return $_SERVER['PHP_SELF'] . "?op=repo&amp;subop=2&amp;repo_id=" . $repo_id;
90 return $_SERVER['PHP_SELF'] . "?op=repo&amp;subop=2&amp;repo_name=" . $repo_name;
91 91 } }
92 92
93 93 function rg_var_str($name) function rg_var_str($name)
 
... ... function rg_chars_allow($name, $allowed_regexp)
138 138 */ */
139 139 function rg_rmdir($dir) function rg_rmdir($dir)
140 140 { {
141 $scan = glob($dir);
142 foreach ($scan as $junk => $path)
143 @unlink($path);
144 @rmdir($dir);
141 $scan = glob($dir . "/*");
142 if ($scan === FALSE) {
143 rg_log("\tInvalid pattern [$dir/*]!");
144 return FALSE;
145 }
146
147 if (count($scan) > 0) {
148 foreach ($scan as $junk => $path) {
149 if (!@unlink($path)) {
150 rg_log("\tCannot remove [$path] ($php_errormsg)!");
151 return FALSE;
152 }
153 }
154 }
155
156 if (!@rmdir($dir)) {
157 rg_log("\tCannot remove main dir ($php_errormsg)!");
158 return FALSE;
159 }
160
161 return TRUE;
145 162 } }
146 163
147 164 ?> ?>
File rocketgit.spec.in changed (mode: 100644) (index 63a2589..b679ef4)
... ... Source: http://kernel.embedromix.ro/us/rocketgit/%{name}-%{version}.tar.gz
8 8 URL: http://kernel.embedromix.ro/us/ URL: http://kernel.embedromix.ro/us/
9 9 BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot
10 10 BuildArch: noarch BuildArch: noarch
11 Requires: httpd, php-process, php-cli, php-pgsql, xinetd, shadow-utils
11 Requires: httpd, php, php-process, php-cli, php-pgsql, xinetd, shadow-utils, git, postgresql-server
12 12
13 13
14 14 %description %description
 
... ... getent passwd rocketgit || useradd -r -g rocketgit -s /sbin/nologin -m -d /home/
21 21 %post %post
22 22 if [ $1 -ne 0 ]; then if [ $1 -ne 0 ]; then
23 23 /sbin/service xinetd reload &>/dev/null || : /sbin/service xinetd reload &>/dev/null || :
24 /sbin/service httpd reload &>/dev/null || :
24 25 fi fi
25 26
26 27 %postun %postun
 
... ... rm -rf ${RPM_BUILD_ROOT}
50 51 %dir /etc/@PRJ@ %dir /etc/@PRJ@
51 52 %config(noreplace) /etc/@PRJ@/config.php %config(noreplace) /etc/@PRJ@/config.php
52 53 /etc/@PRJ@/config.php.sample /etc/@PRJ@/config.php.sample
53 %config /etc/cron.d/rocketgit
54 %config(noreplace) /etc/cron.d/rocketgit
54 55 %config(noreplace) /etc/xinetd.d/rocketgit %config(noreplace) /etc/xinetd.d/rocketgit
55 56 %config(noreplace) /etc/httpd/conf.d/rocketgit.conf %config(noreplace) /etc/httpd/conf.d/rocketgit.conf
56 57 %attr(0700,rocketgit,rocketgit) %dir /var/run/@PRJ@ %attr(0700,rocketgit,rocketgit) %dir /var/run/@PRJ@
File root/index.php changed (mode: 100644) (index 54189af..3d2a92b)
1 1 <?php <?php
2 2 error_reporting(E_ALL); error_reporting(E_ALL);
3 ini_set("track_errors", "On");
3 4 //phpinfo(); //phpinfo();
4 5
5 6 $_s = microtime(TRUE); $_s = microtime(TRUE);
File samples/config.php changed (mode: 100644) (index a7548de..38105f3)
... ... $rg_ssh_paras = "no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty
37 37 // Random key that will be used for encription of the password for better security // Random key that will be used for encription of the password for better security
38 38 $rg_pass_key = "reigjmn9483jfisendfhwefhefhesfuhfskhjukhtw4khfwkur"; $rg_pass_key = "reigjmn9483jfisendfhwefhefhesfuhfskhjukhtw4khfwkur";
39 39
40 // From what address we will send mails (forgot pass etc.)?
41 $rg_admin_name = "RocketGit Admin";
42 $rg_admin_email = "admin@site.tld";
43
40 44 ?> ?>
File samples/rg changed (mode: 100644) (index c837a42..3d45693)
... ... service git
10 10 wait = no wait = no
11 11 user = rocketgit user = rocketgit
12 12 server = /usr/bin/php server = /usr/bin/php
13 server_args = /usr/share/rocketgit/scripts/ssh.php
13 server_args = /usr/share/rocketgit/scripts/remote.php
14 14 log_on_failure += USERID log_on_failure += USERID
15 15 } }
File samples/rg.conf changed (mode: 100644) (index 48733a5..c90f9b5)
1 1 # This is the apache configuration file for RocketGit # This is the apache configuration file for RocketGit
2 2
3 3 <VirtualHost *:80> <VirtualHost *:80>
4 ServerName rg.embedromix.ro
4 ServerName rg.domain.tld
5 5 ServerAlias rg ServerAlias rg
6 6 DocumentRoot /usr/share/rocketgit/root/ DocumentRoot /usr/share/rocketgit/root/
7
7 ErrorLog logs/rocketgit-error_log
8 CustomLog logs/rocketgit-access_log common
8 9 <Directory "/usr/share/rocketgit/root"> <Directory "/usr/share/rocketgit/root">
9 10 AllowOverride All AllowOverride All
10 11 Order allow,deny Order allow,deny
File scripts/cron.php changed (mode: 100644) (index ecbfc7f..fd64f31)
... ... if (date("H") == 0) {
41 41 while (($row = rg_sql_fetch_array($res))) { while (($row = rg_sql_fetch_array($res))) {
42 42 rg_log("Processing repository [" . $row['name'] . "]..."); rg_log("Processing repository [" . $row['name'] . "]...");
43 43 $repo_path = rg_repo_name2base($row['name']) . $row['name'] . ".git"; $repo_path = rg_repo_name2base($row['name']) . $row['name'] . ".git";
44 $disk_mb = rg_repo_disk_mb($repo_path);
45 $sql = "UPDATE repos SET disk_mb = $disk_mb"
44 $disk_used_mb = rg_repo_disk_mb($repo_path);
45 $sql = "UPDATE repos SET disk_used_mb = $disk_used_mb"
46 46 . " WHERE repo_id = " . $row['repo_id']; . " WHERE repo_id = " . $row['repo_id'];
47 47 $res2 = rg_sql_query($db, $sql); $res2 = rg_sql_query($db, $sql);
48 48 if ($res2 === FALSE) { if ($res2 === FALSE) {
File scripts/q.php changed (mode: 100644) (index 8ec6388..5ccf0c7)
... ... while ($runs-- > 0) {
81 81 } }
82 82 } }
83 83 } }
84
85 rg_log("Make hooks links...");
86 $_dir = @readlink($dst . "/hooks");
87 if (strcmp($_dir, $rg_scripts . "/hooks") != 0) {
88 rg_log("\thooks is not a link to scripts one, make it...");
89 @rg_rmdir($dst . "/hooks");
90 symlink($rg_scripts . "/hooks", $dst . "/");
91 }
92 84 } }
93 85 rg_sql_free_result($res); rg_sql_free_result($res);
94 86
File scripts/remote.php renamed from scripts/ssh.php (similarity 98%) (mode: 100644) (index 9f9e45d..04fa37b)
... ... require_once($INC . "/log.inc.php");
13 13 require_once($INC . "/db.inc.php"); require_once($INC . "/db.inc.php");
14 14 require_once($INC . "/repo.inc.php"); require_once($INC . "/repo.inc.php");
15 15
16 rg_log_set_file("/var/log/rocketgit/ssh.log");
16 rg_log_set_file("/var/log/rocketgit/remote.log");
17 17
18 18 $rg_sql_debug = $rg_db_debug; $rg_sql_debug = $rg_db_debug;
19 19
File tests/Makefile changed (mode: 100644) (index 4f735a9..6981152)
1 tests := util db keys repo rights state user
1 tests := util db keys repo rights state user git
2 2 .PHONY: $(tests) .PHONY: $(tests)
3 3
4 4 all: $(tests) all: $(tests)
 
... ... state:
23 23
24 24 user: user:
25 25 php user.php php user.php
26
27 git:
28 php git.php
File tests/db.php changed (mode: 100644) (index c83320d..5a4661f)
1 1 <?php <?php
2 2 error_reporting(E_ALL | E_STRICT); error_reporting(E_ALL | E_STRICT);
3 ini_set("track_errors", "On");
3 4
4 5 $INC = "../inc"; $INC = "../inc";
5 6 require_once($INC . "/db.inc.php"); require_once($INC . "/db.inc.php");
File tests/git.php added (mode: 100644) (index 0000000..603b14e)
1 <?php
2 error_reporting(E_ALL | E_STRICT);
3 ini_set("track_errors", "On");
4
5 $INC = "../inc";
6 require_once($INC . "/git.inc.php");
7
8 rg_log_set_file("git.log");
9
10 $rg_scripts = "/usr/share/rocketgit";
11
12 // check if git-init works
13 $r = rg_git_init("git.tmp");
14 if ($r !== TRUE) {
15 echo "Cannot run rg_git_init (" . rg_git_error() . ")!\n";
16 exit(1);
17 }
18 system("rm -rf git.tmp");
19
20
21 echo "OK\n";
22 ?>
File tests/keys.php changed (mode: 100644) (index ecdb581..cda4317)
1 1 <?php <?php
2 2 error_reporting(E_ALL | E_STRICT); error_reporting(E_ALL | E_STRICT);
3 ini_set("track_errors", "On");
3 4
4 5 $INC = "../inc"; $INC = "../inc";
5 6 require_once($INC . "/keys.inc.php"); require_once($INC . "/keys.inc.php");
 
... ... if ($c === FALSE) {
55 56 echo "Cannot regenerate file: " . rg_keys_error() . "!\n"; echo "Cannot regenerate file: " . rg_keys_error() . "!\n";
56 57 exit(1); exit(1);
57 58 } }
58 $e = "command=\"/usr/bin/php " . $rg_scripts . "/ssh.php 1\"," . $rg_ssh_paras . " aaa 'bbb' first_key\n"
59 . "command=\"/usr/bin/php " . $rg_scripts . "/ssh.php 2\"," . $rg_ssh_paras . " aaa 'bbb' second_key\n";
59 $e = "command=\"/usr/bin/php " . $rg_scripts . "/remote.php 1\"," . $rg_ssh_paras . " aaa 'bbb' first_key\n"
60 . "command=\"/usr/bin/php " . $rg_scripts . "/remote.php 2\"," . $rg_ssh_paras . " aaa 'bbb' second_key\n";
60 61 if (strcmp($c, $e) != 0) { if (strcmp($c, $e) != 0) {
61 62 echo "Generated file does not seems OK\n"; echo "Generated file does not seems OK\n";
62 63 exit(1); exit(1);
File tests/repo.php changed (mode: 100644) (index 11363db..4c73d48)
1 1 <?php <?php
2 2 error_reporting(E_ALL | E_STRICT); error_reporting(E_ALL | E_STRICT);
3 ini_set("track_errors", "On");
3 4
4 5 $INC = "../inc"; $INC = "../inc";
5 6 require_once($INC . "/repo.inc.php"); require_once($INC . "/repo.inc.php");
File tests/rights.php changed (mode: 100644) (index 8917b72..7afbac0)
1 1 <?php <?php
2 2 error_reporting(E_ALL | E_STRICT); error_reporting(E_ALL | E_STRICT);
3 ini_set("track_errors", "On");
3 4
4 5 $INC = "../inc"; $INC = "../inc";
5 6 require_once($INC . "/rights.inc.php"); require_once($INC . "/rights.inc.php");
 
... ... if (strcmp($r, $e) != 0) {
30 31 exit(1); exit(1);
31 32 } }
32 33
34 rg_log("testing mask...");
35 $a = "ABCDE"; $mask = "AEZ"; $e = "AE";
36 $r = rg_rights_mask($a, $mask);
37 if (strcmp($e, $e) != 0) {
38 echo "mask is not working right [$r] != [$e]!\n";
39 exit(1);
40 }
41
33 42 echo "rights: OK\n"; echo "rights: OK\n";
34 43 ?> ?>
File tests/state.php changed (mode: 100644) (index 6a77217..f48c70e)
1 1 <?php <?php
2 2 error_reporting(E_ALL | E_STRICT); error_reporting(E_ALL | E_STRICT);
3 ini_set("track_errors", "On");
3 4
4 5 $INC = "../inc"; $INC = "../inc";
5 6 require_once($INC . "/log.inc.php"); require_once($INC . "/log.inc.php");
File tests/user.php changed (mode: 100644) (index 585cd32..d6387be)
1 1 <?php <?php
2 2 error_reporting(E_ALL | E_STRICT); error_reporting(E_ALL | E_STRICT);
3 ini_set("track_errors", "On");
3 4
4 5 $INC = "../inc"; $INC = "../inc";
5 6 require_once($INC . "/user.inc.php"); require_once($INC . "/user.inc.php");
 
... ... if ($r === FALSE) {
26 27 } }
27 28
28 29 // add user // add user
29 $r = rg_user_edit($db, 0, "userA", "rg@localhost", "pass1", 1, 100, "C");
30 $r = rg_user_edit($db, 0, "userA", "rg@localhost", "pass1", 1, 100, "C", 3600);
30 31 if ($r !== TRUE) { if ($r !== TRUE) {
31 32 echo "Cannot add user (" . rg_user_error() . ")!\n"; echo "Cannot add user (" . rg_user_error() . ")!\n";
32 33 exit(1); exit(1);
 
... ... $salt = $_ui['salt'];
48 49 $pass = $_ui['pass']; $pass = $_ui['pass'];
49 50
50 51 // edit user - empty pass // edit user - empty pass
51 $r = rg_user_edit($db, $uid, "userA", "rg@localhost", "", 1, 100, "C");
52 $r = rg_user_edit($db, $uid, "userA", "rg@localhost", "", 1, 100, "C", 3600);
52 53 if ($r !== TRUE) { if ($r !== TRUE) {
53 54 echo "Cannot edit user with empty pass (" . rg_user_error() . ")!\n"; echo "Cannot edit user with empty pass (" . rg_user_error() . ")!\n";
54 55 exit(1); exit(1);
 
... ... if (strcmp($pass, $_ui['pass']) != 0) {
69 70 } }
70 71
71 72 // edit user - no empty pass // edit user - no empty pass
72 $r = rg_user_edit($db, $uid, "userA", "rg@localhost", "pass2", 1, 100, "C");
73 $r = rg_user_edit($db, $uid, "userA", "rg@localhost", "pass2", 1, 100, "C", 3600);
73 74 if ($r !== TRUE) { if ($r !== TRUE) {
74 75 echo "Cannot edit user with not empty pass (" . rg_user_error() . ")!\n"; echo "Cannot edit user with not empty pass (" . rg_user_error() . ")!\n";
75 76 exit(1); exit(1);
File tests/util.php changed (mode: 100644) (index 776327b..d1b73e1)
1 1 <?php <?php
2 2 error_reporting(E_ALL | E_STRICT); error_reporting(E_ALL | E_STRICT);
3 ini_set("track_errors", "On");
3 4
4 5 $INC = "../inc"; $INC = "../inc";
5 6 require_once($INC . "/util.inc.php"); require_once($INC . "/util.inc.php");
7 require_once($INC . "/log.inc.php");
8
9 rg_log_set_file("util.log");
6 10
7 11 $id = rg_id(16); $id = rg_id(16);
8 12 if (strlen($id) != 16) { if (strlen($id) != 16) {
 
... ... if (strlen($id) != 16) {
10 14 exit(1); exit(1);
11 15 } }
12 16
17 @mkdir("util.tmp", 0700, TRUE);
18 file_put_contents("util.tmp/file1", "aaa");
19 file_put_contents("util.tmp/file2", "bbb");
20 $r = rg_rmdir("util.tmp");
21 if ($r !== TRUE) {
22 echo "Cannot delete dir!\n";
23 exit(1);
24 }
25
13 26 echo "util: OK\n"; echo "util: OK\n";
14 27 ?> ?>
Hints

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

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

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

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