| File Makefile.in changed (mode: 100644) (index 5d69a2d..1ff9dbc) | |||
| ... | ... | install: all | |
| 23 | 23 | cp -vd --no-clobber samples/config.php $(I_ETC)/rocketgit/ | 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 --no-clobber samples/logrotate $(I_ETC)/logrotate.d/rocketgit | ||
| 26 | cp -vd samples/logrotate $(I_ETC)/logrotate.d/rocketgit | ||
| 27 | 27 | @mkdir -p --mode=0700 $(I_VAR_LOG)/$(PRJ) | @mkdir -p --mode=0700 $(I_VAR_LOG)/$(PRJ) |
| 28 | 28 | @chown rocketgit:rocketgit $(I_VAR_LOG)/$(PRJ) | @chown rocketgit:rocketgit $(I_VAR_LOG)/$(PRJ) |
| 29 | 29 | @chmod 0700 $(I_VAR_LOG)/$(PRJ) | @chmod 0700 $(I_VAR_LOG)/$(PRJ) |
| File TODO changed (mode: 100644) (index 5c17875..d9694e6) | |||
| 1 | 1 | == BEFORE FIRST RELEASE! == | == BEFORE FIRST RELEASE! == |
| 2 | [ ] When we have a fatal/internal error, we must also record the log in the e-mail. | ||
| 3 | [ ] Where rocketgit repo disappeared on r1?! | ||
| 4 | [ ] Log in YYYY-MM-DD files and ask logrotate to only delete them. | ||
| 5 | Or, set a policy in config.php and do the cleaning by ourselves. | ||
| 6 | [ ] repo.php tests does not say "ok". | ||
| 7 | [ ] Functions from util.inc.php set rg_util_error(). Use it. | ||
| 8 | [ ] Rempove all "exit(?)" calls. | ||
| 9 | [ ] Locking is done in global dirs for tests. Use a local folder! | ||
| 10 | [ ] We must provide a way to propagate errors from events! | ||
| 11 | [ ] repo.inc should not depend on user.inc! | ||
| 12 | [ ] rg_repo_info will have almost the same paras as rg_user_info! | ||
| 13 | [ ] Check if there are unused paramters after name2base(_path). | ||
| 14 | [ ] Remove any trace of $rr. | ||
| 15 | [ ] After the switch from username to uid, should we pass uid into forms? | ||
| 16 | [ ] How to deal with browser accessing an old name (after rename)? | ||
| 17 | [ ] $rr is a mess! Switch to repo_id and use cache. | ||
| 18 | [ ] repo_invalidate_cache does an implode that can reorder. Use repo_id as key? | ||
| 19 | No. But use some combinations of paras. | ||
| 20 | [ ] Why we use "FOR UPDATE" on 'events' table?! events.php is the only user. | ||
| 21 | [ ] We need to parallelize the event processing. | ||
| 2 | [ ] Remove last form in PHP: user.form.php. | ||
| 3 | [ ] type=1400 audit(1357428371.130:170): avc: denied { connectto } for pid=20687 comm="httpd" path="/var/lib/rocketgit/sockets/event.sock" scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:system_r:system_cronjob_t:s0-s0:c0.c1023 tclass=unix_stream_socket | ||
| 4 | [ ] type=1400 audit(1357428371.166:171): avc: denied { read write } for pid=18085 comm="sendmail" path="/var/lib/rocketgit/locks/events.sh.lock" dev="sda3" ino=50862906 scontext=system_u:system_r:system_mail_t:s0-s0:c0.c1023 tcontext=system_u:object_r:cron_var_lib_t:s0 tclass=file | ||
| 5 | [ ] Current menu is not correctly shown as selected. | ||
| 6 | [ ] Use (organization, user, repo) instead of user/repo only. | ||
| 7 | [ ] Big confusion! An logged in user has a different ID than the one of the repo | ||
| 8 | and it may have admin rights! Audit everything (rg_ui/login_ui/$uid). | ||
| 9 | [ ] X-Authentication-Warning: r1.dyn.embedromix.ro: rocketgit set sender to | ||
| 10 | rg1@embedromix.ro using -f | ||
| 22 | 11 | [ ] Checking mtime of event.php is not enough. Maybe checking version. | [ ] Checking mtime of event.php is not enough. Maybe checking version. |
| 23 | 12 | Think of includes that may change. | Think of includes that may change. |
| 24 | [ ] Create a unique index on users(username,organization)? | ||
| 25 | [ ] Do not allow duplicated ssh keys. | ||
| 26 | [ ] We have a little problem: we need the ssh keyring to regenerate fast but | ||
| 27 | we may have a big events queue. We may want to signal directly | ||
| 28 | the regeneration script and to not store mark-dirty state. Hm. | ||
| 29 | [ ] Optimize keyring invalidation. | ||
| 30 | [ ] Put "create user" on login page! | ||
| 31 | [ ] We should make stuff more robust. For example: CREATE REPO + HISTORY_INSERT. | ||
| 32 | [ ] What happens if we unlock an unlocked resource? | ||
| 33 | [ ] Renaming a repo! | ||
| 34 | If we move to numbers, and the names are links, we may have problems | ||
| 35 | when we create a repo with the same name. | ||
| 36 | If we just rename the folder, the current/future clients could not | ||
| 37 | access the repo. Maybe this is the best idea. If a user creates a | ||
| 38 | repo with the same name, this is life. | ||
| 39 | We have to record the renaming in the repo history. | ||
| 40 | [ ] What happends if a user is doing a downgrade? Must not allow it. | ||
| 41 | [ ] Use another home page for logged in users. | ||
| 42 | [ ] Check if same user can create two repos with the same name! | ||
| 43 | [ ] When we are altering keys table and we upgrade, the file will not be rebuilt. | ||
| 44 | We have to dirty it. | ||
| 45 | 13 | [ ] Fix this shit: isset($_REQUEST['rights']) ? rg_rights_a2s(rg_var_str("rights")) : $rg | [ ] Fix this shit: isset($_REQUEST['rights']) ? rg_rights_a2s(rg_var_str("rights")) : $rg |
| 46 | [ ] when you add a bug, state 'any' should not be present. | ||
| 47 | 14 | [ ] bug tracker is private? | [ ] bug tracker is private? |
| 48 | [ ] When I visit bug page, I auto add a save search. Bad! (doit == 1) | ||
| 49 | [ ] Is not clear that the owner has full rights (repo->admin->edit). | ||
| 15 | [ ] It is not clear that the owner has full rights (repo->admin->edit). | ||
| 50 | 16 | [ ] Checking for "rg_ui['uid'] == 0" may not be enough. | [ ] Checking for "rg_ui['uid'] == 0" may not be enough. |
| 51 | 17 | Maybe rg_ui[['uid'] = repo['uid']? | Maybe rg_ui[['uid'] = repo['uid']? |
| 18 | Or, everywhere add 'uid = ?' in queries. | ||
| 52 | 19 | [ ] List on the first page the latest commits. | [ ] List on the first page the latest commits. |
| 53 | 20 | Do not forget to exclude private repos. | Do not forget to exclude private repos. |
| 54 | 21 | [ ] bug_update does not update labels! | [ ] bug_update does not update labels! |
| 55 | 22 | [ ] Integrate remote_add.html. | [ ] Integrate remote_add.html. |
| 56 | 23 | [ ] Should we expire the reset password token? Why? | [ ] Should we expire the reset password token? Why? |
| 57 | 24 | Somebody can request another one! | Somebody can request another one! |
| 58 | [ ] All internal error should show a special page? | ||
| 59 | [ ] Deleting SSH key should be done with token: | ||
| 60 | First, invalidate it, second delete it. Maybe show an undelete page? | ||
| 61 | Or, allow delete and move it to deleted list and allow undelete and | ||
| 62 | then delete? Hm. | ||
| 63 | 25 | [ ] All operations must be verified with tokens. | [ ] All operations must be verified with tokens. |
| 64 | 26 | [ ] If the confirmation code is truncated, an internal error is generated | [ ] If the confirmation code is truncated, an internal error is generated |
| 65 | 27 | instead of a user error! | instead of a user error! |
| 66 | 28 | [ ] Third option: anybody can create an account but must be validated by admin. | [ ] Third option: anybody can create an account but must be validated by admin. |
| 67 | 29 | [ ] After creating the account, keep the user logged in and allow login | [ ] After creating the account, keep the user logged in and allow login |
| 68 | 30 | even if is not confirmed (option in config). | even if is not confirmed (option in config). |
| 69 | [ ] Fix the mail headers (+dkim) to avoid spam. | ||
| 70 | [ ] logrotate is not working. | ||
| 71 | [ ] Build a function to store data in a processing queue: | ||
| 72 | dirs like YYYY/MM/DD/HH/MM/job | ||
| 73 | [ ] Use some named pipes to signal q.php/cron.php to do some stuff. | ||
| 74 | 31 | [ ] Check if we can give rights for a non-owning repo! | [ ] Check if we can give rights for a non-owning repo! |
| 75 | 32 | We should check if the user that gives rights is the owner! | We should check if the user that gives rights is the owner! |
| 76 | [ ] | ||
| 33 | [ ] Add possibility to close a bug. Maybe also when adding a note. | ||
| 34 | [ ] Add possibility to edit a bug. | ||
| 35 | [ ] Add possibility to add/remove labels to a bug. Also whwn adding a note. | ||
| 77 | 36 | ||
| 78 | 37 | ||
| 79 | 38 | == Medium == | == Medium == |
| 39 | [ ] Allow editing of bug searches. | ||
| 40 | [ ] Admin: add a feature to become any user. This way we will not duplicate | ||
| 41 | a lot of code for editing users/repos/etc. Allow admin to switch | ||
| 42 | identities at will. | ||
| 43 | [ ] Admin: add a feature to reset all passwords. | ||
| 44 | [ ] Forgot link must use paras and not a parameter. This way we short the URL. | ||
| 45 | Maybe send both HTML and plain e-mails? | ||
| 46 | [ ] Check best practices for salt/pass/forgot pass etc. | ||
| 47 | [ ] Create a unique index on users(username,organization)? | ||
| 48 | [ ] We have a little problem: we need the ssh keyring to regenerate fast but | ||
| 49 | we may have a big events queue. We may want to signal directly | ||
| 50 | the regeneration script and to not store mark-dirty state. Hm. | ||
| 51 | [ ] Optimize keyring invalidation. | ||
| 52 | [ ] Put "create user" on login page! | ||
| 53 | [ ] We should make stuff more robust. For example: CREATE REPO + HISTORY_INSERT. | ||
| 54 | [ ] What happens if we unlock an unlocked resource? | ||
| 55 | [ ] We have to record the renaming in the repo history. | ||
| 56 | [ ] What happends if a user is doing a downgrade? Must not allow it. | ||
| 57 | [ ] Use another home page for logged in users. | ||
| 58 | [ ] repo_invalidate_cache does an implode that can reorder. Use repo_id as key? | ||
| 59 | No. But use some combinations of paras. | ||
| 60 | [ ] Why we use "FOR UPDATE" on 'events' table?! events.php is the only user. | ||
| 61 | [ ] We need to parallelize the event processing. | ||
| 62 | [ ] We need to add organization parameters next to repo_name! | ||
| 63 | [ ] Check if there are unused parameters after name2base(_path). | ||
| 64 | [ ] Remove any trace of $rr. | ||
| 65 | [ ] After the switch from username to uid, should we pass uid into forms? | ||
| 66 | [ ] How to deal with browser accessing an old name (after rename)? | ||
| 67 | [ ] repo.php tests does not say "ok". | ||
| 68 | [ ] Functions from util.inc.php set rg_util_error(). Use it. | ||
| 69 | [ ] Remove all "exit(?)" calls. | ||
| 70 | [ ] Locking is done in global dirs for tests. Use a local folder! | ||
| 71 | [ ] We must provide a way to propagate errors from events! | ||
| 72 | [ ] repo.inc should not depend on user.inc! | ||
| 73 | [ ] rg_repo_info will have almost the same paras as rg_user_info! | ||
| 74 | [ ] Add a maximum time to keep logs. | ||
| 75 | [ ] Do not allow double ssh keys in database! Because when we output them | ||
| 76 | in authorized_keys ssh will use the first one! | ||
| 77 | [ ] Move everything 1 month back to simulate next month for slave tables. | ||
| 78 | Better, do a unit test. | ||
| 79 | [ ] To not wake up many times (for every sub-event), cache what was done | ||
| 80 | (or max(id)) and ignore that wakeups. Of course, W will become W<ev_id>. | ||
| 81 | [ ] If session expired and the user is trying to access a repo page, PHP errors | ||
| 82 | occures. I think is related to login_ui/repo_ui. | ||
| 83 | [ ] Unify repo_create with repo_update, as user_*. | ||
| 84 | [ ] Clean notification inputs before starting to work to not receive a lot of | ||
| 85 | them after processing is done. | ||
| 86 | [ ] Description should not be present anywhere (web). Takes space. | ||
| 87 | [ ] Seems that ls \.\. works. Check from security pov. | ||
| 88 | [ ] Profiling in not reentrant. We should use a stack! | ||
| 89 | [ ] We should not store repo_id0 into cache! | ||
| 90 | [ ] We are redirecting the user to history page. Do not wait for git dir! | ||
| 91 | [ ] Implement a cache like event.php. | ||
| 92 | [ ] Set a policy in config.php and do the cleaning/compress of the log files. | ||
| 93 | [ ] Fix the mail headers (+dkim) to avoid spam. | ||
| 80 | 94 | [ ] http://joeyh.name/blog/entry/git_push_over_XMPP/ (ialbescu) | [ ] http://joeyh.name/blog/entry/git_push_over_XMPP/ (ialbescu) |
| 81 | 95 | [ ] Graphics with database/table/index sizes. | [ ] Graphics with database/table/index sizes. |
| 82 | 96 | [ ] Add history also for user. | [ ] Add history also for user. |
| File inc/admin/admin.php changed (mode: 100644) (index 0f30e1c..27d63e7) | |||
| ... | ... | rg_log("/inc/admin/admin"); | |
| 3 | 3 | ||
| 4 | 4 | $_admin = ""; | $_admin = ""; |
| 5 | 5 | ||
| 6 | if ($rg_ui['is_admin'] != 1) { | ||
| 7 | $_admin .= "You do not have access here!"; | ||
| 6 | if ($login_ui['is_admin'] != 1) { | ||
| 7 | $_admin .= rg_warning("You do not have access here!"); | ||
| 8 | 8 | return; | return; |
| 9 | 9 | } | } |
| 10 | 10 | ||
| 11 | $_subop = empty($paras) ? "users" : array_shift($paras); | ||
| 11 | 12 | ||
| 12 | 13 | // menu | // menu |
| 13 | $_admin_url = rg_re_url("/op/admin"); | ||
| 14 | $_admin_menu = ""; | ||
| 15 | $_admin_menu .= "[<a href=\"$_admin_url&subop=1\">Users</a>]"; | ||
| 16 | $_admin_menu .= " [<a href=\"$_admin_url&subop=2\">Repos</a>]"; | ||
| 17 | $_admin_menu .= "<br />\n"; | ||
| 18 | |||
| 19 | |||
| 20 | $_admin_body = ""; | ||
| 21 | |||
| 22 | switch ($subop) { | ||
| 23 | case 1: // users | ||
| 14 | $_m = array( | ||
| 15 | "users" => array( | ||
| 16 | "text" => "Users", | ||
| 17 | "op" => "users" | ||
| 18 | ), | ||
| 19 | "repos" => array( | ||
| 20 | "text" => "Repositories", | ||
| 21 | "op" => "repos" | ||
| 22 | ) | ||
| 23 | ); | ||
| 24 | rg_menu_add($rg_menu, $_m, $_subop); | ||
| 25 | |||
| 26 | switch ($_subop) { | ||
| 27 | case 'users': // users | ||
| 24 | 28 | include($INC . "/admin/users/users.php"); | include($INC . "/admin/users/users.php"); |
| 25 | $_admin_body .= $_admin_users; | ||
| 29 | $_admin .= $_admin_users; | ||
| 26 | 30 | break; | break; |
| 27 | 31 | ||
| 28 | case 2: // repos | ||
| 32 | case 'repos': // repos | ||
| 29 | 33 | include($INC . "/admin/repos/repos.php"); | include($INC . "/admin/repos/repos.php"); |
| 30 | $_admin_body .= $_admin_repos; | ||
| 34 | $_admin .= $_admin_repos; | ||
| 31 | 35 | break; | break; |
| 32 | 36 | } | } |
| 33 | 37 | ||
| 34 | $_admin .= $_admin_menu . $_admin_body; | ||
| 35 | 38 | ?> | ?> |
| File inc/admin/repos/repos.php changed (mode: 100644) (index b28755a..7d45a3c) | |||
| 1 | 1 | <?php | <?php |
| 2 | 2 | rg_log("/admin/repos"); | rg_log("/admin/repos"); |
| 3 | 3 | ||
| 4 | $_admin_repos = ""; | ||
| 4 | 5 | ||
| 5 | // menu | ||
| 6 | $_admin_repos_url = $_admin_url . "&subop=$subop"; | ||
| 7 | $_admin_repos_menu = ""; | ||
| 8 | $_admin_repos_menu .= "[<a href=\"$_admin_repos_url&subsubop=1\">List</a>]"; | ||
| 9 | //$_admin_repos_menu .= " [<a href=\"$_admin_repos_url&subsubop=2\">Add</a>]"; | ||
| 10 | $_admin_repos_menu .= "<br />\n"; | ||
| 11 | $_admin_repos_menu .= "<br />\n"; | ||
| 12 | |||
| 6 | $_op = empty($paras) ? "list" : array_shift($paras); | ||
| 13 | 7 | ||
| 14 | $_admin_repos_body = ""; | ||
| 8 | // menu | ||
| 9 | $_m = array( | ||
| 10 | "list" => array( | ||
| 11 | "text" => "List repositories", | ||
| 12 | "op" => "list" | ||
| 13 | ), | ||
| 14 | "add" => array( | ||
| 15 | "text" => "Add repository", | ||
| 16 | "op" => "add" | ||
| 17 | ) | ||
| 18 | ); | ||
| 19 | rg_menu_add($rg_menu, $_m, $_op); | ||
| 15 | 20 | ||
| 16 | switch ($subsubop) { | ||
| 17 | case 1: // list | ||
| 21 | switch ($_op) { | ||
| 22 | case 'list': // list | ||
| 18 | 23 | $_uid = 0; | $_uid = 0; |
| 19 | $_admin_repos_body .= rg_repo_list($db, | ||
| 20 | $_admin_repos_url . "&subsubop=$subsubop", $_uid); | ||
| 24 | $_admin_repos .= rg_repo_list($db, "TODO: fix url", $_uid); | ||
| 21 | 25 | break; | break; |
| 22 | 26 | } | } |
| 23 | 27 | ||
| 24 | $_admin_repos = $_admin_repos_menu . $_admin_repos_body; | ||
| 25 | 28 | ?> | ?> |
| File inc/admin/users/user.form.php changed (mode: 100644) (index 08cda64..08f947c) | |||
| ... | ... | if ($admin_mode == 1) { | |
| 15 | 15 | $_form .= rg_template_errmsg($errmsg); | $_form .= rg_template_errmsg($errmsg); |
| 16 | 16 | ||
| 17 | 17 | $_form .= ' | $_form .= ' |
| 18 | <form method="post" action="' . rg_re_post($cop) . '"> | ||
| 18 | <form method="post" action="' . rg_re_post($sparas) . '"> | ||
| 19 | 19 | <input type="hidden" name="doit" value="1" /> | <input type="hidden" name="doit" value="1" /> |
| 20 | 20 | <input type="hidden" name="token" value="' . rg_token_get($db, $sid) . '" /> | <input type="hidden" name="token" value="' . rg_token_get($db, $sid) . '" /> |
| 21 | 21 | '; | '; |
| File inc/admin/users/users.php changed (mode: 100644) (index 15b8f60..2c4a863) | |||
| 1 | 1 | <?php | <?php |
| 2 | 2 | rg_log("/inc/admin/users/users"); | rg_log("/inc/admin/users/users"); |
| 3 | 3 | ||
| 4 | $_admin_users = ""; | ||
| 4 | 5 | ||
| 5 | // menu | ||
| 6 | $_admin_users_url = $_admin_url . "&subop=$subop"; | ||
| 7 | $_admin_users_menu = ""; | ||
| 8 | $_admin_users_menu .= "[<a href=\"$_admin_users_url&subsubop=1\">List</a>]"; | ||
| 9 | $_admin_users_menu .= " [<a href=\"$_admin_users_url&subsubop=2\">Add</a>]"; | ||
| 10 | $_admin_users_menu .= "<br />\n"; | ||
| 11 | $_admin_users_menu .= "<br />\n"; | ||
| 12 | |||
| 6 | $_op = empty($paras) ? "list" : array_shift($paras); | ||
| 13 | 7 | ||
| 14 | $_admin_users_body = ""; | ||
| 15 | |||
| 16 | switch ($subsubop) { | ||
| 17 | case 1: // list | ||
| 18 | $_admin_users_body .= rg_user_list($db, $_admin_users_url); | ||
| 8 | // menu | ||
| 9 | $_m = array( | ||
| 10 | "list" => array( | ||
| 11 | "text" => "List users", | ||
| 12 | "op" => "list" | ||
| 13 | ), | ||
| 14 | "add" => array( | ||
| 15 | "text" => "Add user", | ||
| 16 | "op" => "add" | ||
| 17 | ) | ||
| 18 | ); | ||
| 19 | rg_menu_add($rg_menu, $_m, $_op); | ||
| 20 | |||
| 21 | switch ($_op) { | ||
| 22 | case 'list': // list | ||
| 23 | // TODO: load template! | ||
| 24 | $_admin_users .= rg_user_list($db, $_admin_users_url); | ||
| 19 | 25 | break; | break; |
| 20 | 26 | ||
| 21 | case 2: // add | ||
| 27 | case 'add': // add | ||
| 22 | 28 | include($INC . "/admin/users/add.php"); | include($INC . "/admin/users/add.php"); |
| 23 | $_admin_users_body .= $_user_add; | ||
| 29 | $_admin_users .= $_user_add; | ||
| 24 | 30 | break; | break; |
| 25 | 31 | ||
| 26 | case 3: // edit | ||
| 32 | case 'edit': // edit | ||
| 27 | 33 | include($INC . "/admin/users/edit.php"); | include($INC . "/admin/users/edit.php"); |
| 28 | $_admin_users_body .= $_user_edit; | ||
| 34 | $_admin_users .= $_user_edit; | ||
| 29 | 35 | break; | break; |
| 30 | 36 | } | } |
| 31 | 37 | ||
| 32 | $_admin_users = $_admin_users_menu . $_admin_users_body; | ||
| 33 | 38 | ?> | ?> |
| File inc/bug.inc.php changed (mode: 100644) (index 11c5bc9..898c800) | |||
| ... | ... | function rg_bug_state($v) | |
| 41 | 41 | ||
| 42 | 42 | /* | /* |
| 43 | 43 | * Returns a select for state | * Returns a select for state |
| 44 | * @exclude - array that contains keys that must be excluded | ||
| 44 | 45 | */ | */ |
| 45 | function rg_bug_state_select($value) | ||
| 46 | function rg_bug_state_select($value, $exclude) | ||
| 46 | 47 | { | { |
| 47 | 48 | global $rg_bug_states; | global $rg_bug_states; |
| 48 | 49 | ||
| 49 | 50 | $ret = ""; | $ret = ""; |
| 50 | 51 | $ret .= "<select name=\"state\">\n"; | $ret .= "<select name=\"state\">\n"; |
| 51 | 52 | foreach ($rg_bug_states as $key => $name) { | foreach ($rg_bug_states as $key => $name) { |
| 53 | if (in_array($key, $exclude)) | ||
| 54 | continue; | ||
| 55 | |||
| 52 | 56 | $add = ""; | $add = ""; |
| 53 | 57 | if (strcmp($value, $key) == 0) | if (strcmp($value, $key) == 0) |
| 54 | 58 | $add = " selected"; | $add = " selected"; |
| ... | ... | function rg_bug_update($db, $repo_id, $bug_id, $data) | |
| 375 | 379 | /* | /* |
| 376 | 380 | * List bugs | * List bugs |
| 377 | 381 | */ | */ |
| 378 | function rg_bug_list_query($db, $url, $sql) | ||
| 382 | function rg_bug_list_query($db, $sql) | ||
| 379 | 383 | { | { |
| 380 | 384 | rg_prof_start("bug_list_query"); | rg_prof_start("bug_list_query"); |
| 381 | rg_log("bug_list_query: url=$url, sql=$sql..."); | ||
| 385 | rg_log("bug_list_query: sql=$sql..."); | ||
| 382 | 386 | ||
| 383 | 387 | $ret = FALSE; | $ret = FALSE; |
| 384 | 388 | do { | do { |
| ... | ... | function rg_bug_list_query($db, $url, $sql) | |
| 388 | 392 | break; | break; |
| 389 | 393 | } | } |
| 390 | 394 | ||
| 391 | $d = array(); | ||
| 395 | $ret = array(); | ||
| 392 | 396 | while (($row = rg_sql_fetch_array($res))) { | while (($row = rg_sql_fetch_array($res))) { |
| 393 | 397 | rg_bug_cosmetic($db, $row); | rg_bug_cosmetic($db, $row); |
| 394 | $row['url_bug'] = $url . "/bug/" . $row['bug_id']; | ||
| 395 | $d[] = $row; | ||
| 398 | $ret[] = $row; | ||
| 396 | 399 | } | } |
| 397 | 400 | rg_sql_free_result($res); | rg_sql_free_result($res); |
| 398 | $ret = TRUE; | ||
| 399 | 401 | } while (0); | } while (0); |
| 400 | 402 | ||
| 401 | if ($ret !== FALSE) | ||
| 402 | $ret = rg_template_table("repo/bug/list", $d, array()); | ||
| 403 | |||
| 403 | rg_log("DEBUG: list_query return " . rg_array2string($ret)); | ||
| 404 | 404 | rg_prof_end("bug_list_query"); | rg_prof_end("bug_list_query"); |
| 405 | 405 | return $ret; | return $ret; |
| 406 | 406 | } | } |
| ... | ... | function rg_bug_list_query($db, $url, $sql) | |
| 408 | 408 | /* | /* |
| 409 | 409 | * Loads all saved searches | * Loads all saved searches |
| 410 | 410 | */ | */ |
| 411 | function rg_bug_search_load_all($db, $repo_id, $uid, $url) | ||
| 411 | function rg_bug_search_load_all($db, $repo_id, $uid) | ||
| 412 | 412 | { | { |
| 413 | 413 | rg_prof_start("bug_search_load_all"); | rg_prof_start("bug_search_load_all"); |
| 414 | rg_log("bug_search_load_all: repo_id=$repo_id uid=$uid url=$url"); | ||
| 414 | rg_log("bug_search_load_all: repo_id=$repo_id uid=$uid"); | ||
| 415 | 415 | ||
| 416 | 416 | $ret = FALSE; | $ret = FALSE; |
| 417 | 417 | do { | do { |
| ... | ... | function rg_bug_search_load_all($db, $repo_id, $uid, $url) | |
| 438 | 438 | ||
| 439 | 439 | $ret = array(); | $ret = array(); |
| 440 | 440 | foreach ($data as $name => $junk) | foreach ($data as $name => $junk) |
| 441 | $ret[] = array("HTML:name" => "<a href=" . $url | ||
| 442 | . "/list/" . $name . ">" . $name . "</a>"); | ||
| 441 | $ret[] = array("name" => $name); | ||
| 443 | 442 | ||
| 444 | 443 | rg_sql_free_result($res); | rg_sql_free_result($res); |
| 445 | 444 | } while (0); | } while (0); |
| ... | ... | function rg_bug_search_load($db, $repo_id, $uid, $name) | |
| 468 | 467 | "title_string" => "", | "title_string" => "", |
| 469 | 468 | "body_string" => "", | "body_string" => "", |
| 470 | 469 | "bugs_per_page" => 25, | "bugs_per_page" => 25, |
| 471 | "global" => 0, | ||
| 472 | 470 | "for_all_users" => 1, | "for_all_users" => 1, |
| 471 | "global" => 0, | ||
| 473 | 472 | "standard" => 1, | "standard" => 1, |
| 474 | 473 | "uid" => 0 | "uid" => 0 |
| 475 | 474 | ); | ); |
| ... | ... | function rg_bug_search_load($db, $repo_id, $uid, $name) | |
| 513 | 512 | break; | break; |
| 514 | 513 | } | } |
| 515 | 514 | $ret = $_data; | $ret = $_data; |
| 516 | $ret['name'] = $row['name']; //TODO: escape?! | ||
| 515 | $ret['uid'] = $row['uid']; | ||
| 516 | $ret['name'] = $row['name']; // TODO: escape?! | ||
| 517 | 517 | $ret['for_all_users'] = $row['for_all_users']; | $ret['for_all_users'] = $row['for_all_users']; |
| 518 | 518 | $ret['standard'] = 0; | $ret['standard'] = 0; |
| 519 | 519 | } else { | } else { |
| ... | ... | function rg_bug_search_save($db, $repo_id, $uid, $q) | |
| 551 | 551 | $e_name = rg_sql_escape($db, $name); | $e_name = rg_sql_escape($db, $name); |
| 552 | 552 | ||
| 553 | 553 | // Global? | // Global? |
| 554 | if (isset($q['global']) && ($q['global'] == 0)) | ||
| 555 | $e_repo_id = $repo_id; | ||
| 556 | else | ||
| 554 | if (isset($q['global']) && (strcmp($q['global'], "on") == 0)) | ||
| 557 | 555 | $e_repo_id = 0; | $e_repo_id = 0; |
| 556 | else | ||
| 557 | $e_repo_id = $repo_id; | ||
| 558 | 558 | ||
| 559 | if (isset($q['for_all_users']) && ($q['for_all_users'] == 1)) | ||
| 559 | if (isset($q['for_all_users']) && (strcmp($q['for_all_users'], "on") == 0)) | ||
| 560 | 560 | $e_for_all_users = 1; | $e_for_all_users = 1; |
| 561 | 561 | else | else |
| 562 | 562 | $e_for_all_users = 0; | $e_for_all_users = 0; |
| 563 | 563 | ||
| 564 | 564 | // We will not overwrite somebody else's search | // We will not overwrite somebody else's search |
| 565 | rg_log("DEBUG: old: " . rg_array2string($old)); | ||
| 565 | 566 | if (empty($old) || ($old['uid'] != $uid)) { | if (empty($old) || ($old['uid'] != $uid)) { |
| 566 | 567 | $sql = "INSERT INTO bug_search (repo_id, uid, name" | $sql = "INSERT INTO bug_search (repo_id, uid, name" |
| 567 | 568 | . ", data, for_all_users)" | . ", data, for_all_users)" |
| ... | ... | function rg_bug_search_save($db, $repo_id, $uid, $q) | |
| 591 | 592 | /* | /* |
| 592 | 593 | * Search for bugs | * Search for bugs |
| 593 | 594 | */ | */ |
| 594 | function rg_bug_search($db, $url, $repo_id, $uid, $q) | ||
| 595 | function rg_bug_search($db, $repo_id, $uid, $q) | ||
| 595 | 596 | { | { |
| 596 | 597 | rg_prof_start("bug_search"); | rg_prof_start("bug_search"); |
| 597 | rg_log("bug_search: url=$url repo_id=$repo_id uid=$uid" | ||
| 598 | rg_log("bug_search: repo_id=$repo_id uid=$uid" | ||
| 598 | 599 | . " q=" . rg_array2string($q)); | . " q=" . rg_array2string($q)); |
| 599 | 600 | ||
| 600 | 601 | $add = array(); | $add = array(); |
| ... | ... | function rg_bug_search($db, $url, $repo_id, $uid, $q) | |
| 676 | 677 | . " LIMIT $limit"; | . " LIMIT $limit"; |
| 677 | 678 | ||
| 678 | 679 | // TODO: order | // TODO: order |
| 679 | $ret = TRUE; | ||
| 680 | } while (0); | ||
| 681 | 680 | ||
| 682 | if ($ret !== FALSE) | ||
| 683 | $ret = rg_bug_list_query($db, $url, $sql); | ||
| 681 | $ret = rg_bug_list_query($db, $sql); | ||
| 682 | if ($ret === FALSE) | ||
| 683 | break; | ||
| 684 | } while (0); | ||
| 684 | 685 | ||
| 685 | 686 | rg_prof_end("bug_search"); | rg_prof_end("bug_search"); |
| 686 | 687 | return $ret; | return $ret; |
| File inc/dispatch/dispatch.php changed (mode: 100644) (index fb56ea9..cf1a781) | |||
| 1 | 1 | <?php | <?php |
| 2 | 2 | rg_log("/inc/dispatch/dispatch"); | rg_log("/inc/dispatch/dispatch"); |
| 3 | 3 | ||
| 4 | switch ($op) { | ||
| 5 | case 'main': | ||
| 6 | $body .= rg_template("main.html", $more); | ||
| 7 | break; | ||
| 8 | |||
| 4 | switch ($_op) { | ||
| 9 | 5 | case 'login': | case 'login': |
| 10 | 6 | include($INC . "/login/login.php"); | include($INC . "/login/login.php"); |
| 11 | 7 | $body .= $_login; | $body .= $_login; |
| 12 | 8 | break; | break; |
| 13 | 9 | ||
| 14 | 10 | case 'logout': | case 'logout': |
| 15 | if (rg_sess_destroy($db, $sid, $rg_ui)) { | ||
| 11 | if (rg_sess_destroy($db, $sid, $login_ui)) { | ||
| 16 | 12 | $body .= rg_template("user/logout.html", $more); | $body .= rg_template("user/logout.html", $more); |
| 17 | 13 | } else { | } else { |
| 18 | 14 | $body .= rg_template("user/logout_err.html", $more); | $body .= rg_template("user/logout_err.html", $more); |
| ... | ... | case 'suggestion': | |
| 59 | 55 | $body .= $_suggestion; | $body .= $_suggestion; |
| 60 | 56 | break; | break; |
| 61 | 57 | ||
| 62 | case 'repo-page': | ||
| 63 | include($INC . "/user/repo-page.php"); | ||
| 64 | $body .= $_repo_page; | ||
| 58 | case 'settings': | ||
| 59 | include($INC . "/user/settings.php"); | ||
| 60 | $body .= $_settings; | ||
| 65 | 61 | break; | break; |
| 66 | 62 | ||
| 67 | case 'home-page': | ||
| 68 | include($INC . "/user/home-page.php"); | ||
| 69 | $body .= $_home; | ||
| 70 | break; | ||
| 63 | default: // can be the main page or user page or repo page | ||
| 64 | rg_log("DEBUG:paras=" . rg_array2string($paras)); | ||
| 65 | $type = empty($paras) ? "" : $paras[0]; | ||
| 66 | rg_log("DEBUG: type=[$type]"); | ||
| 67 | if (strcmp($type, "user") == 0) { | ||
| 68 | array_shift($paras); | ||
| 69 | $user = empty($paras) ? "" : array_shift($paras); | ||
| 70 | $repo = empty($paras) ? "" : array_shift($paras); | ||
| 71 | } else if (empty($type)) { | ||
| 72 | $body .= rg_template("main.html", $more); | ||
| 73 | } else { | ||
| 74 | // organization | ||
| 75 | $organization = 1; | ||
| 76 | $user = empty($paras) ? "" : array_shift($paras); | ||
| 77 | $repo = empty($paras) ? "" : array_shift($paras); | ||
| 78 | } | ||
| 71 | 79 | ||
| 72 | case 'personal': | ||
| 73 | include($INC . "/user/personal.php"); | ||
| 74 | $body .= $_personal; | ||
| 75 | break; | ||
| 80 | if (!empty($user)) { | ||
| 81 | rg_log("DEBUG: user=[$user] repo=[$repo]"); | ||
| 82 | if (empty($repo)) { | ||
| 83 | include($INC . "/user/home-page.php"); | ||
| 84 | $body .= $_home; | ||
| 85 | } else { | ||
| 86 | // TODO: destroy repo-page | ||
| 87 | // TODO: repo-page: use $paras | ||
| 88 | include($INC . "/user/repo-page.php"); | ||
| 89 | $body .= $_repo_page; | ||
| 90 | } | ||
| 91 | } | ||
| 76 | 92 | ||
| 77 | default: | ||
| 78 | rg_log("Invalid operation [$op]!"); | ||
| 93 | break; | ||
| 79 | 94 | } | } |
| 80 | 95 | ||
| 81 | 96 | ?> | ?> |
| File inc/events.inc.php changed (mode: 100644) (index 5daecd1..9a17fef) | |||
| ... | ... | function rg_event_register_functions($functions) | |
| 48 | 48 | ||
| 49 | 49 | /* | /* |
| 50 | 50 | * Signals the daemon that there is some work to do | * Signals the daemon that there is some work to do |
| 51 | * if @event_id > 0, we will wait for the finish of the event | ||
| 51 | 52 | */ | */ |
| 52 | function rg_event_signal_daemon() | ||
| 53 | function rg_event_signal_daemon($ev_id, $timeout) | ||
| 53 | 54 | { | { |
| 54 | 55 | global $rg_event_socket; | global $rg_event_socket; |
| 55 | 56 | ||
| 57 | rg_prof_start("event_signal_daemon"); | ||
| 58 | rg_log("event_signal_daemon: event_id=[$ev_id] timeout=$timeout"); | ||
| 59 | |||
| 56 | 60 | $ret = FALSE; | $ret = FALSE; |
| 57 | 61 | do { | do { |
| 58 | $socket = socket_create(AF_UNIX, SOCK_DGRAM, 0); | ||
| 62 | $socket = socket_create(AF_UNIX, SOCK_STREAM, 0); | ||
| 59 | 63 | if ($socket === FALSE) { | if ($socket === FALSE) { |
| 60 | 64 | rg_log("Could not create socket!"); | rg_log("Could not create socket!"); |
| 61 | 65 | break; | break; |
| 62 | 66 | } | } |
| 63 | 67 | ||
| 64 | $r = socket_connect($socket, $rg_event_socket); | ||
| 68 | // try 3 times | ||
| 69 | $tries = 3; | ||
| 70 | while ($tries > 0) { | ||
| 71 | $r = socket_connect($socket, $rg_event_socket); | ||
| 72 | if ($r === FALSE) { | ||
| 73 | $tries--; | ||
| 74 | usleep(200000); | ||
| 75 | continue; | ||
| 76 | } | ||
| 77 | |||
| 78 | break; | ||
| 79 | } | ||
| 65 | 80 | if ($r === FALSE) { | if ($r === FALSE) { |
| 66 | 81 | rg_log("Could not connect the socket!"); | rg_log("Could not connect the socket!"); |
| 67 | 82 | break; | break; |
| 68 | 83 | } | } |
| 69 | 84 | ||
| 70 | $buf = "W"; $len = strlen($buf); | ||
| 85 | if (empty($ev_id)) | ||
| 86 | $buf = "W"; | ||
| 87 | else | ||
| 88 | $buf = "NOTIFY " . $ev_id; | ||
| 89 | $len = strlen($buf); | ||
| 71 | 90 | $r = socket_send($socket, $buf, $len, 0); | $r = socket_send($socket, $buf, $len, 0); |
| 72 | 91 | if ($r !== $len) { | if ($r !== $len) { |
| 73 | 92 | rg_log("Could not send!"); | rg_log("Could not send!"); |
| 74 | 93 | break; | break; |
| 75 | 94 | } | } |
| 76 | 95 | ||
| 96 | if (empty($ev_id)) { | ||
| 97 | rg_log("We do not have to wait. Exit."); | ||
| 98 | $ret = TRUE; | ||
| 99 | socket_close($socket); | ||
| 100 | break; | ||
| 101 | } | ||
| 102 | |||
| 103 | $reads = array($socket); $writes = array(); $ex = array(); | ||
| 104 | $r = socket_select($reads, $writes, $ex, $timeout, 0); | ||
| 105 | if ($r === FALSE) { | ||
| 106 | rg_log("Cannot select!"); | ||
| 107 | socket_close($socket); | ||
| 108 | break; | ||
| 109 | } | ||
| 110 | |||
| 111 | if ($r === 0) { // timeout | ||
| 112 | rg_log("Timeout!"); | ||
| 113 | socket_close($socket); | ||
| 114 | break; | ||
| 115 | } | ||
| 116 | |||
| 117 | if (!in_array($socket, $reads)) { | ||
| 118 | rg_log("Select returned > 0 and my socket is not in reads"); | ||
| 119 | socket_close($socket); | ||
| 120 | break; | ||
| 121 | } | ||
| 122 | |||
| 123 | $r = socket_recv($socket, $buf, 1024, 0); | ||
| 124 | if ($r === FALSE) { | ||
| 125 | rg_log("Cannot receive!"); | ||
| 126 | break; | ||
| 127 | } | ||
| 128 | rg_log("Received [$buf]"); | ||
| 129 | |||
| 77 | 130 | socket_close($socket); | socket_close($socket); |
| 78 | 131 | $ret = TRUE; | $ret = TRUE; |
| 79 | 132 | } while (0); | } while (0); |
| ... | ... | function rg_event_add($db, $event) | |
| 104 | 157 | } | } |
| 105 | 158 | rg_sql_free_result($res); | rg_sql_free_result($res); |
| 106 | 159 | ||
| 107 | rg_event_signal_daemon(); | ||
| 160 | rg_event_signal_daemon("", 0); | ||
| 108 | 161 | ||
| 109 | 162 | $ret = TRUE; | $ret = TRUE; |
| 110 | 163 | } while (0); | } while (0); |
| ... | ... | function rg_event_process($db, $event) | |
| 165 | 218 | return $ret; | return $ret; |
| 166 | 219 | } | } |
| 167 | 220 | ||
| 221 | /* | ||
| 222 | * Cleans the notification list | ||
| 223 | */ | ||
| 224 | function rg_event_notify_clean(&$notify_list) | ||
| 225 | { | ||
| 226 | if (empty($notify_list)) | ||
| 227 | return; | ||
| 228 | |||
| 229 | $limit = time() - 5 * 60; | ||
| 230 | |||
| 231 | foreach ($notify_list as $ev_id => $ei) { | ||
| 232 | if (empty($ei)) { | ||
| 233 | unset($notify_list[$ev_id]); | ||
| 234 | continue; | ||
| 235 | } | ||
| 236 | |||
| 237 | foreach ($ei as $index => $info) { | ||
| 238 | if ($info['itime'] < $limit) { | ||
| 239 | unset($notify_list[$ev_id][$index]); | ||
| 240 | socket_close($info['fd']); | ||
| 241 | } | ||
| 242 | } | ||
| 243 | } | ||
| 244 | } | ||
| 245 | |||
| 246 | /* | ||
| 247 | * Tries to notify a client if requested | ||
| 248 | */ | ||
| 249 | function rg_event_notify(&$notify_list, $ev_id) | ||
| 250 | { | ||
| 251 | if (!isset($notify_list[$ev_id])) | ||
| 252 | return; | ||
| 253 | |||
| 254 | $buf = "DONE $ev_id\n"; | ||
| 255 | $buf_len = strlen($buf); | ||
| 256 | foreach ($notify_list[$ev_id] as $index => $info) { | ||
| 257 | $fd = $info['fd']; | ||
| 258 | rg_log("\tNotify [$ev_id] [fd=$fd]..."); | ||
| 259 | socket_send($fd, $buf, $buf_len, 0); | ||
| 260 | socket_shutdown($fd, 1); | ||
| 261 | } | ||
| 262 | |||
| 263 | return; | ||
| 264 | } | ||
| 265 | |||
| 168 | 266 | /* | /* |
| 169 | 267 | * Process events queue | * Process events queue |
| 170 | 268 | * reset id to 1 if queue is empty? | * reset id to 1 if queue is empty? |
| 171 | 269 | * Returns FALSE on error, else, the number of events processed | * Returns FALSE on error, else, the number of events processed |
| 270 | * @notify_list: Will be used to signal the finish of an event | ||
| 172 | 271 | */ | */ |
| 173 | function rg_event_process_queue($db) | ||
| 272 | function rg_event_process_queue($db, &$notify_list) | ||
| 174 | 273 | { | { |
| 175 | 274 | rg_prof_start("event_process_queue"); | rg_prof_start("event_process_queue"); |
| 176 | rg_log("event_process_queue"); | ||
| 275 | rg_log("event_process_queue: notify_list: " | ||
| 276 | . rg_array2string($notify_list)); | ||
| 177 | 277 | ||
| 178 | 278 | $ret = FALSE; | $ret = FALSE; |
| 179 | 279 | $do_rollback = 0; | $do_rollback = 0; |
| ... | ... | function rg_event_process_queue($db) | |
| 212 | 312 | break; | break; |
| 213 | 313 | } | } |
| 214 | 314 | ||
| 315 | if (isset($ev['notification'])) | ||
| 316 | rg_event_notify($notify_list, $ev['notification']); | ||
| 317 | |||
| 215 | 318 | $sql = "DELETE FROM events WHERE id = " . $row['id']; | $sql = "DELETE FROM events WHERE id = " . $row['id']; |
| 216 | 319 | $res2 = rg_sql_query($db, $sql); | $res2 = rg_sql_query($db, $sql); |
| 217 | 320 | rg_sql_free_result($res2); | rg_sql_free_result($res2); |
| File inc/feedback/suggestion.form.php deleted (index 8ae813e..0000000) | |||
| 1 | <?php | ||
| 2 | $_form = '<div class="formarea">' . "\n"; | ||
| 3 | |||
| 4 | $_form .= '<div class="formarea_title">Send a suggestion</div><br />' . "\n"; | ||
| 5 | |||
| 6 | $_form .= rg_template_errmsg($errmsg); | ||
| 7 | |||
| 8 | $_form .= ' | ||
| 9 | <form method="post" action="' . rg_re_post($cop) . '"> | ||
| 10 | <input type="hidden" name="doit" value="1" /> | ||
| 11 | <input type="hidden" name="token" value="' . rg_token_get($db, $sid) . '" /> | ||
| 12 | |||
| 13 | <label for="email" class="form_item_title">Your e-mail</label><br /> | ||
| 14 | <input type="text" name="email" value="' . $email . '" /> | ||
| 15 | <br /> | ||
| 16 | <br /> | ||
| 17 | |||
| 18 | <label for="suggestion" class="form_item_title">Suggestion</label><br /> | ||
| 19 | <textarea name="suggestion" rows="6" cols="50">' . $suggestion . '</textarea> | ||
| 20 | <br /> | ||
| 21 | <br /> | ||
| 22 | |||
| 23 | <input type="submit" name="button" value="Send" /> | ||
| 24 | |||
| 25 | </form> | ||
| 26 | </div> | ||
| 27 | '; | ||
| 28 | |||
| 29 | ?> | ||
| File inc/feedback/suggestion.php changed (mode: 100644) (index 1b34a83..7b73329) | |||
| 1 | 1 | <?php | <?php |
| 2 | 2 | rg_log("/feedback/suggestion"); | rg_log("/feedback/suggestion"); |
| 3 | 3 | ||
| 4 | $suggestion_more = $more; | ||
| 4 | 5 | $_suggestion = ""; | $_suggestion = ""; |
| 5 | 6 | ||
| 6 | 7 | $errmsg = array(); | $errmsg = array(); |
| 7 | 8 | $show_form = 1; | $show_form = 1; |
| 8 | 9 | ||
| 9 | 10 | if ($doit == 1) { | if ($doit == 1) { |
| 10 | $email = rg_var_str("email"); | ||
| 11 | 11 | $suggestion = rg_var_str("suggestion"); | $suggestion = rg_var_str("suggestion"); |
| 12 | 12 | ||
| 13 | 13 | do { | do { |
| ... | ... | if ($doit == 1) { | |
| 16 | 16 | break; | break; |
| 17 | 17 | } | } |
| 18 | 18 | ||
| 19 | if (empty($email)) { | ||
| 20 | $errmsg[] = "invalid e-mail"; | ||
| 21 | break; | ||
| 22 | } | ||
| 23 | |||
| 24 | 19 | if (empty($suggestion)) { | if (empty($suggestion)) { |
| 25 | 20 | $errmsg[] = "empty suggestion"; | $errmsg[] = "empty suggestion"; |
| 26 | 21 | break; | break; |
| 27 | 22 | } | } |
| 28 | 23 | ||
| 29 | $r = rg_user_suggestion($db, $rg_ui['uid'], $email, $suggestion); | ||
| 24 | $r = rg_user_suggestion($db, $login_ui['uid'], $suggestion); | ||
| 30 | 25 | if ($r === FALSE) { | if ($r === FALSE) { |
| 31 | 26 | $errmsg[] = "could not add suggestion (" . rg_user_error() . ")!"; | $errmsg[] = "could not add suggestion (" . rg_user_error() . ")!"; |
| 32 | 27 | break; | break; |
| ... | ... | if ($doit == 1) { | |
| 36 | 31 | $_suggestion .= "Thank you very much!"; | $_suggestion .= "Thank you very much!"; |
| 37 | 32 | } while (0); | } while (0); |
| 38 | 33 | } else { | } else { |
| 39 | $email = ""; | ||
| 34 | // defaults for form | ||
| 40 | 35 | $suggestion = ""; | $suggestion = ""; |
| 41 | 36 | } | } |
| 42 | 37 | ||
| 43 | 38 | if ($show_form == 1) { | if ($show_form == 1) { |
| 44 | include($INC . "/feedback/suggestion.form.php"); | ||
| 45 | $_suggestion .= $_form; | ||
| 39 | $suggestion_more['suggestion'] = $suggestion; | ||
| 40 | $suggestion_more['HTML:errmsg'] = rg_template_errmsg($errmsg); | ||
| 41 | $suggestion_more['rg_form_token'] = rg_token_get($db, $sid); | ||
| 42 | $_suggestion .= rg_template("suggestion.html", $suggestion_more); | ||
| 46 | 43 | } | } |
| 47 | 44 | ||
| 48 | 45 | ?> | ?> |
| File inc/fixes.inc.php changed (mode: 100644) (index 3fc64cb..e762e8c) | |||
| 1 | 1 | <?php | <?php |
| 2 | 2 | // | // |
| 3 | 3 | // This is a set of fixes that must be applied when the software is upgraded. | // This is a set of fixes that must be applied when the software is upgraded. |
| 4 | // If the structure of authorized_keys may change, we must add a fix to mark | ||
| 5 | // the stat dirty. | ||
| 4 | 6 | // | // |
| 5 | 7 | include_once($INC . "/sql.inc.php"); | include_once($INC . "/sql.inc.php"); |
| 6 | 8 | include_once($INC . "/state.inc.php"); | include_once($INC . "/state.inc.php"); |
| File inc/keys.inc.php changed (mode: 100644) (index cb411aa..00a5127) | |||
| ... | ... | function rg_keys_mark_dirty($db) | |
| 156 | 156 | } | } |
| 157 | 157 | ||
| 158 | 158 | /* | /* |
| 159 | * Remove a key from database | ||
| 159 | * Remove a key from database for user 'ui' | ||
| 160 | 160 | * TODO: Remove "multi" function and make this accepts an array of keys. | * TODO: Remove "multi" function and make this accepts an array of keys. |
| 161 | 161 | * TODO: Here we must have a transaction! | * TODO: Here we must have a transaction! |
| 162 | 162 | */ | */ |
| 163 | function rg_keys_remove($db, $rg_ui, $key_id, $flags) | ||
| 163 | function rg_keys_remove($db, $ui, $key_id, $flags) | ||
| 164 | 164 | { | { |
| 165 | 165 | rg_prof_start("keys_remove"); | rg_prof_start("keys_remove"); |
| 166 | 166 | rg_log("keys_remove: key_id=$key_id flags=" . rg_array2string($flags)); | rg_log("keys_remove: key_id=$key_id flags=" . rg_array2string($flags)); |
| ... | ... | function rg_keys_remove($db, $rg_ui, $key_id, $flags) | |
| 172 | 172 | $e_key_id = sprintf("%u", $key_id); | $e_key_id = sprintf("%u", $key_id); |
| 173 | 173 | ||
| 174 | 174 | $sql = "DELETE FROM keys" | $sql = "DELETE FROM keys" |
| 175 | . " WHERE uid = " . $rg_ui['uid'] | ||
| 175 | . " WHERE uid = " . $ui['uid'] | ||
| 176 | 176 | . " AND key_id = $e_key_id"; | . " AND key_id = $e_key_id"; |
| 177 | 177 | $res = rg_sql_query($db, $sql); | $res = rg_sql_query($db, $sql); |
| 178 | 178 | if ($res === FALSE) { | if ($res === FALSE) { |
| ... | ... | function rg_keys_remove($db, $rg_ui, $key_id, $flags) | |
| 182 | 182 | rg_sql_free_result($res); | rg_sql_free_result($res); |
| 183 | 183 | ||
| 184 | 184 | $event = array("category" => 1001, "prio" => 50, | $event = array("category" => 1001, "prio" => 50, |
| 185 | "email" => $rg_ui['email'], | ||
| 185 | "email" => $ui['email'], | ||
| 186 | 186 | "IP" => rg_var_str("REMOTE_ADDR"), | "IP" => rg_var_str("REMOTE_ADDR"), |
| 187 | 187 | "key_id" => $key_id); | "key_id" => $key_id); |
| 188 | 188 | $r = rg_event_add($db, $event); | $r = rg_event_add($db, $event); |
| ... | ... | function rg_keys_remove($db, $rg_ui, $key_id, $flags) | |
| 202 | 202 | /* | /* |
| 203 | 203 | * Remove multiple keys from database | * Remove multiple keys from database |
| 204 | 204 | */ | */ |
| 205 | function rg_keys_remove_multi($db, $rg_ui, $list) | ||
| 205 | function rg_keys_remove_multi($db, $ui, $list) | ||
| 206 | 206 | { | { |
| 207 | 207 | rg_prof_start("keys_remove_multi"); | rg_prof_start("keys_remove_multi"); |
| 208 | 208 | rg_log("keys_remove_multi: list=" . rg_array2string($list)); | rg_log("keys_remove_multi: list=" . rg_array2string($list)); |
| ... | ... | function rg_keys_remove_multi($db, $rg_ui, $list) | |
| 216 | 216 | ||
| 217 | 217 | $flags = array("no_dirty" => 1); | $flags = array("no_dirty" => 1); |
| 218 | 218 | foreach ($list as $key_id => $junk) { | foreach ($list as $key_id => $junk) { |
| 219 | $r = rg_keys_remove($db, $rg_ui, $key_id, $flags); | ||
| 219 | $r = rg_keys_remove($db, $ui, $key_id, $flags); | ||
| 220 | 220 | if ($r !== TRUE) | if ($r !== TRUE) |
| 221 | 221 | break; | break; |
| 222 | 222 | } | } |
| ... | ... | function rg_keys_count($db, $uid) | |
| 261 | 261 | * Returns the key_id of the key. | * Returns the key_id of the key. |
| 262 | 262 | * TODO: Transaction! | * TODO: Transaction! |
| 263 | 263 | */ | */ |
| 264 | function rg_keys_add($db, $rg_ui, $key) | ||
| 264 | function rg_keys_add($db, $ui, $key) | ||
| 265 | 265 | { | { |
| 266 | 266 | global $rg_max_ssh_keys; | global $rg_max_ssh_keys; |
| 267 | 267 | ||
| ... | ... | function rg_keys_add($db, $rg_ui, $key) | |
| 281 | 281 | // the config after update may not have this defined. | // the config after update may not have this defined. |
| 282 | 282 | if ($rg_max_ssh_keys == 0) | if ($rg_max_ssh_keys == 0) |
| 283 | 283 | $rg_max_ssh_keys = 10; | $rg_max_ssh_keys = 10; |
| 284 | $no_of_keys = rg_keys_count($db, $rg_ui['uid']); | ||
| 284 | $no_of_keys = rg_keys_count($db, $ui['uid']); | ||
| 285 | 285 | if ($no_of_keys === FALSE) | if ($no_of_keys === FALSE) |
| 286 | 286 | break; | break; |
| 287 | 287 | ||
| ... | ... | function rg_keys_add($db, $rg_ui, $key) | |
| 291 | 291 | } | } |
| 292 | 292 | ||
| 293 | 293 | $sql = "INSERT INTO keys (itime, uid, key)" | $sql = "INSERT INTO keys (itime, uid, key)" |
| 294 | . " VALUES ($itime, " . $rg_ui['uid'] . ", '$e_key')" | ||
| 294 | . " VALUES ($itime, " . $ui['uid'] . ", '$e_key')" | ||
| 295 | 295 | . " RETURNING key_id"; | . " RETURNING key_id"; |
| 296 | 296 | $res = rg_sql_query($db, $sql); | $res = rg_sql_query($db, $sql); |
| 297 | 297 | if ($res === FALSE) { | if ($res === FALSE) { |
| ... | ... | function rg_keys_add($db, $rg_ui, $key) | |
| 303 | 303 | rg_sql_free_result($res); | rg_sql_free_result($res); |
| 304 | 304 | ||
| 305 | 305 | $event = array("category" => 1000, "prio" => 50, | $event = array("category" => 1000, "prio" => 50, |
| 306 | "email" => $rg_ui['email'], | ||
| 306 | "email" => $ui['email'], | ||
| 307 | 307 | "IP" => rg_var_str("REMOTE_ADDR"), | "IP" => rg_var_str("REMOTE_ADDR"), |
| 308 | 308 | "key_id" => $key_id); | "key_id" => $key_id); |
| 309 | 309 | $r = rg_event_add($db, $event); | $r = rg_event_add($db, $event); |
| ... | ... | function rg_keys_regen($db) | |
| 439 | 439 | /* | /* |
| 440 | 440 | * List keys | * List keys |
| 441 | 441 | */ | */ |
| 442 | function rg_keys_list($db, $rg_ui) | ||
| 442 | function rg_keys_list($db, $ui) | ||
| 443 | 443 | { | { |
| 444 | 444 | rg_prof_start("keys_list"); | rg_prof_start("keys_list"); |
| 445 | rg_log("keys_list: rg_uid[uid]=" . $rg_ui['uid']); | ||
| 445 | rg_log("keys_list: uid=" . $ui['uid']); | ||
| 446 | 446 | ||
| 447 | 447 | $ret = FALSE; | $ret = FALSE; |
| 448 | 448 | do { | do { |
| 449 | $sql = "SELECT * FROM keys WHERE uid = " . $rg_ui['uid'] | ||
| 449 | $sql = "SELECT * FROM keys WHERE uid = " . $ui['uid'] | ||
| 450 | 450 | . " ORDER BY itime DESC"; | . " ORDER BY itime DESC"; |
| 451 | 451 | $res = rg_sql_query($db, $sql); | $res = rg_sql_query($db, $sql); |
| 452 | 452 | if ($res === FALSE) { | if ($res === FALSE) { |
| File inc/log.inc.php changed (mode: 100644) (index 4005e9f..59ac935) | |||
| ... | ... | if (!isset($rg_web_log_dir)) | |
| 10 | 10 | $rg_log_file = $rg_log_dir . "/fallback.log"; | $rg_log_file = $rg_log_dir . "/fallback.log"; |
| 11 | 11 | $rg_log_fd = FALSE; | $rg_log_fd = FALSE; |
| 12 | 12 | $rg_log_sid = rg_id(6); | $rg_log_sid = rg_id(6); |
| 13 | $rg_log_buf = ""; | ||
| 14 | $rg_log_last_date = ""; | ||
| 15 | |||
| 16 | /* | ||
| 17 | * Allow forcing sid, so we can spread the logs to multiple file | ||
| 18 | * or to supress the output of it. | ||
| 19 | */ | ||
| 20 | function rg_log_set_sid($v) | ||
| 21 | { | ||
| 22 | global $rg_log_sid; | ||
| 23 | $rg_log_sid = $v; | ||
| 24 | } | ||
| 25 | |||
| 26 | /* | ||
| 27 | * When we generate fatal/warn e-mails, we need to insert also the logs. | ||
| 28 | */ | ||
| 29 | function rg_log_buffer() | ||
| 30 | { | ||
| 31 | global $rg_log_buf; | ||
| 32 | return $rg_log_buf; | ||
| 33 | } | ||
| 13 | 34 | ||
| 14 | 35 | function rg_log_set_file($file) | function rg_log_set_file($file) |
| 15 | 36 | { | { |
| ... | ... | function rg_log($str) | |
| 23 | 44 | global $rg_log_file; | global $rg_log_file; |
| 24 | 45 | global $rg_log_fd; | global $rg_log_fd; |
| 25 | 46 | global $rg_log_sid; | global $rg_log_sid; |
| 47 | global $rg_log_buf; | ||
| 48 | global $rg_log_last_date; | ||
| 26 | 49 | ||
| 50 | $date = gmdate("Ymd"); | ||
| 27 | 51 | if ($rg_log_fd === FALSE) { | if ($rg_log_fd === FALSE) { |
| 28 | $rg_log_fd = @fopen($rg_log_file, "a"); | ||
| 52 | $_pi = pathinfo($rg_log_file); | ||
| 53 | $lf = $_pi['dirname'] . "/" . $_pi['filename'] | ||
| 54 | . "-" . $date . "." . $_pi['extension']; | ||
| 55 | $rg_log_fd = fopen($lf, "a"); | ||
| 29 | 56 | if ($rg_log_fd === FALSE) | if ($rg_log_fd === FALSE) |
| 30 | 57 | return; | return; |
| 31 | 58 | // write an empty line | // write an empty line |
| 32 | 59 | fwrite($rg_log_fd, "\n"); | fwrite($rg_log_fd, "\n"); |
| 60 | $rg_log_last_date = $date; | ||
| 61 | $rg_log_last_sid = $rg_log_sid; | ||
| 62 | } else if (strcmp($rg_log_sid, "000000") == 0) { // we reopen log only if sid=000000 (long running tasks) | ||
| 63 | if ((strcmp($date, $rg_log_last_date) != 0)) { | ||
| 64 | // date changed, we need to reopen the log file | ||
| 65 | fclose($rg_log_fd); | ||
| 66 | $rg_log_fd = FALSE; | ||
| 67 | return rg_log($str); | ||
| 68 | } | ||
| 33 | 69 | } | } |
| 34 | 70 | ||
| 35 | 71 | $t = gettimeofday(); | $t = gettimeofday(); |
| 36 | 72 | ||
| 37 | 73 | $buf0 = gmdate("Y-m-d H:i:s", $t['sec']) . "." . sprintf("%03u", $t['usec'] / 1000); | $buf0 = gmdate("Y-m-d H:i:s", $t['sec']) . "." . sprintf("%03u", $t['usec'] / 1000); |
| 38 | $buf0 .= " " . $rg_log_sid . " "; | ||
| 74 | if (strcmp($rg_log_sid, "000000") != 0) | ||
| 75 | $buf0 .= " " . $rg_log_sid; | ||
| 39 | 76 | $buf = ""; | $buf = ""; |
| 40 | 77 | $str = preg_replace_callback('/[^\pL\pN\pP\pS \t]/uU', "rg_callback_hexa", $str); | $str = preg_replace_callback('/[^\pL\pN\pP\pS \t]/uU', "rg_callback_hexa", $str); |
| 41 | $buf .= $buf0 . $str . "\n"; | ||
| 78 | $buf .= $buf0 . " " . $str . "\n"; | ||
| 79 | |||
| 80 | $rg_log_buf .= $buf; | ||
| 42 | 81 | ||
| 43 | 82 | if ($rg_log_fd !== NULL) | if ($rg_log_fd !== NULL) |
| 44 | 83 | fwrite($rg_log_fd, $buf); | fwrite($rg_log_fd, $buf); |
| ... | ... | function rg_log_ml($str) | |
| 60 | 99 | function rg_fatal($msg) | function rg_fatal($msg) |
| 61 | 100 | { | { |
| 62 | 101 | global $rg_admin_email; | global $rg_admin_email; |
| 102 | global $rg_log_buf; | ||
| 63 | 103 | ||
| 64 | 104 | rg_log("FATAL: $msg"); | rg_log("FATAL: $msg"); |
| 65 | 105 | ||
| 66 | 106 | $bt = debug_backtrace(); | $bt = debug_backtrace(); |
| 67 | 107 | rg_log_ml("Backtrace: " . print_r($bt, TRUE)); | rg_log_ml("Backtrace: " . print_r($bt, TRUE)); |
| 68 | mail("rg_fatal@embedromix.ro", "FATAL ERROR: $msg", | ||
| 69 | print_r($bt, TRUE), "", "-f $rg_admin_email"); | ||
| 108 | mail("rg_fatal@embedromix.ro", "FATAL ERROR", | ||
| 109 | $msg | ||
| 110 | . "\n" . rg_log_buffer() | ||
| 111 | . "\n" . print_r($bt, TRUE), "", "-f $rg_admin_email"); | ||
| 70 | 112 | exit(1); | exit(1); |
| 71 | 113 | } | } |
| 72 | 114 | ||
| ... | ... | function rg_internal_error($msg) | |
| 78 | 120 | ||
| 79 | 121 | $bt = debug_backtrace(); | $bt = debug_backtrace(); |
| 80 | 122 | rg_log_ml("Backtrace: " . print_r($bt, TRUE)); | rg_log_ml("Backtrace: " . print_r($bt, TRUE)); |
| 81 | mail("rg_ie@embedromix.ro", "INTERNAL ERROR: $msg", | ||
| 82 | print_r($bt, TRUE), "", "-f $rg_admin_email"); | ||
| 123 | mail("rg_ie@embedromix.ro", "INTERNAL ERROR", | ||
| 124 | $msg | ||
| 125 | . "\n" . rg_log_buffer() | ||
| 126 | . "\n" . print_r($bt, TRUE), "", "-f $rg_admin_email"); | ||
| 83 | 127 | } | } |
| 84 | 128 | ||
| 85 | 129 | // TODO: send mail or store all data in database | // TODO: send mail or store all data in database |
| ... | ... | function rg_security_violation($msg) | |
| 91 | 135 | ||
| 92 | 136 | $bt = debug_backtrace(); | $bt = debug_backtrace(); |
| 93 | 137 | rg_log_ml("Backtrace: " . print_r($bt, TRUE)); | rg_log_ml("Backtrace: " . print_r($bt, TRUE)); |
| 94 | mail("rg_sec@embedromix.ro", "SECURITY VIOLATION: $msg", | ||
| 95 | print_r($bt, TRUE), "", "-f $rg_admin_email"); | ||
| 138 | mail("rg_sec@embedromix.ro", "SECURITY VIOLATION", | ||
| 139 | $msg | ||
| 140 | . "\n" . rg_log_buffer() | ||
| 141 | . "\n" . print_r($bt, TRUE), "", "-f $rg_admin_email"); | ||
| 96 | 142 | exit(1); | exit(1); |
| 97 | 143 | } | } |
| 98 | 144 | ||
| File inc/login/login.php changed (mode: 100644) (index 9011af9..f114b72) | |||
| 1 | 1 | <?php | <?php |
| 2 | 2 | rg_log("/inc/login/login"); | rg_log("/inc/login/login"); |
| 3 | 3 | ||
| 4 | $my_more = $more; | ||
| 4 | $login_more = $more; | ||
| 5 | 5 | ||
| 6 | 6 | $user = rg_var_str("user"); | $user = rg_var_str("user"); |
| 7 | 7 | $pass = rg_var_str("pass"); | $pass = rg_var_str("pass"); |
| ... | ... | $_login = ""; | |
| 11 | 11 | $errmsg = array(); | $errmsg = array(); |
| 12 | 12 | ||
| 13 | 13 | if ($doit == 1) { | if ($doit == 1) { |
| 14 | $r = rg_user_login_by_user_pass($db, $user, $pass, $rg_ui); | ||
| 14 | $r = rg_user_login_by_user_pass($db, $user, $pass, $login_ui); | ||
| 15 | 15 | if ($r === FALSE) { | if ($r === FALSE) { |
| 16 | 16 | $errmsg[] = rg_user_error(); | $errmsg[] = rg_user_error(); |
| 17 | 17 | } else { | } else { |
| 18 | 18 | // redirect to home page | // redirect to home page |
| 19 | $url = rg_re_userpage($rg_ui); | ||
| 19 | $url = rg_re_userpage($login_ui); | ||
| 20 | 20 | rg_redirect($url); | rg_redirect($url); |
| 21 | 21 | } | } |
| 22 | 22 | } | } |
| 23 | 23 | ||
| 24 | $my_more['user'] = $user; | ||
| 25 | $my_more['pass'] = $pass; | ||
| 26 | $my_more['rg_action'] = rg_re_post($cop); // TODO: do I use r66_re_post everywhere? | ||
| 27 | $my_more['HTML:errmsg'] = rg_template_errmsg($errmsg); | ||
| 28 | $my_more['forgot_send'] = rg_re_url("/op/forgot_send"); | ||
| 29 | $my_more['create_account'] = rg_re_url("/op/create_account"); | ||
| 30 | $my_more['allow_creation'] = $rg_account_allow_creation; | ||
| 31 | $_login .= rg_template("user/login.html", $my_more); | ||
| 24 | $login_more['user'] = $user; | ||
| 25 | $login_more['pass'] = $pass; | ||
| 26 | $login_more['HTML:errmsg'] = rg_template_errmsg($errmsg); | ||
| 27 | $login_more['forgot_send'] = rg_re_url("/op/forgot_send"); | ||
| 28 | $login_more['create_account'] = rg_re_url("/op/create_account"); | ||
| 29 | $login_more['allow_creation'] = $rg_account_allow_creation; | ||
| 30 | $_login .= rg_template("user/login.html", $login_more); | ||
| 32 | 31 | ?> | ?> |
| File inc/repo.inc.php changed (mode: 100644) (index 9dfe13a..0ad540d) | |||
| ... | ... | rg_rights_register("repo", $rg_repo_rights); | |
| 35 | 35 | ||
| 36 | 36 | // Repo history categories | // Repo history categories |
| 37 | 37 | define('REPO_CAT_CREATE', 1); | define('REPO_CAT_CREATE', 1); |
| 38 | define('REPO_CAT_CLONED', 2); | ||
| 39 | define('REPO_CAT_PUSH', 3); | ||
| 38 | define('REPO_CAT_CLONED', 2); | ||
| 39 | define('REPO_CAT_PUSH', 3); | ||
| 40 | 40 | define('REPO_CAT_RENAME', 4); | define('REPO_CAT_RENAME', 4); |
| 41 | 41 | define('REPO_CAT_BUG_ADDED', 10); | define('REPO_CAT_BUG_ADDED', 10); |
| 42 | 42 | define('REPO_CAT_BUG_CLOSED', 11); | define('REPO_CAT_BUG_CLOSED', 11); |
| ... | ... | function rg_repo_error() | |
| 61 | 61 | $rg_repo_functions = array( | $rg_repo_functions = array( |
| 62 | 62 | 3000 => "rg_repo_event_new", | 3000 => "rg_repo_event_new", |
| 63 | 63 | 3001 => "rg_repo_event_del", | 3001 => "rg_repo_event_del", |
| 64 | 3002 => "rg_repo_event_rename", | ||
| 65 | 3003 => "rg_repo_event_notify_user" | ||
| 64 | 3002 => "rg_repo_event_update", | ||
| 65 | 3003 => "rg_repo_event_notify_user", | ||
| 66 | 3004 => "rg_repo_event_symlink_by_name", | ||
| 67 | 3005 => "rg_repo_event_storage_create" | ||
| 66 | 68 | ); | ); |
| 67 | 69 | rg_event_register_functions($rg_repo_functions); | rg_event_register_functions($rg_repo_functions); |
| 68 | 70 | ||
| ... | ... | function rg_repo_event_new($db, $event) | |
| 74 | 76 | $ret = array(); | $ret = array(); |
| 75 | 77 | ||
| 76 | 78 | $event['op'] = "new"; | $event['op'] = "new"; |
| 79 | |||
| 80 | // Create git dir | ||
| 81 | $x = $event; | ||
| 82 | $x['category'] = 3005; | ||
| 83 | $x['prio'] = 20; | ||
| 84 | $x['notification'] .= "-git"; | ||
| 85 | $ret[] = $x; | ||
| 86 | |||
| 87 | // make symlink by name | ||
| 88 | $x = $event; | ||
| 89 | $x['category'] = 3004; | ||
| 90 | $x['prio'] = 200; | ||
| 91 | $x['notification'] .= "-symlink"; | ||
| 92 | $ret[] = $x; | ||
| 93 | |||
| 77 | 94 | // notify user | // notify user |
| 78 | $ret[] = array_merge($event, array("category" => 3003, "prio" => 100)); | ||
| 95 | $x = $event; | ||
| 96 | $x['category'] = 3003; | ||
| 97 | $x['prio'] = 100; | ||
| 98 | $x['notification'] .= "-notify"; | ||
| 99 | $ret[] = $x; | ||
| 100 | |||
| 79 | 101 | // TODO: notify watchers | // TODO: notify watchers |
| 80 | 102 | ||
| 81 | 103 | return $ret; | return $ret; |
| ... | ... | function rg_repo_event_del($db, $event) | |
| 91 | 113 | $event['op'] = "del"; | $event['op'] = "del"; |
| 92 | 114 | // notify user | // notify user |
| 93 | 115 | $ret[] = array_merge($event, array("category" => 3003, "prio" => 100)); | $ret[] = array_merge($event, array("category" => 3003, "prio" => 100)); |
| 116 | |||
| 94 | 117 | // TODO: notify watchers | // TODO: notify watchers |
| 95 | 118 | ||
| 96 | 119 | return $ret; | return $ret; |
| 97 | 120 | } | } |
| 98 | 121 | ||
| 122 | /* | ||
| 123 | * Make a symlink by name (by_name/name -> ../by_id/xx/xx/xx/xx/xxxxxxxx.git) | ||
| 124 | */ | ||
| 125 | function rg_repo_event_symlink_by_name($db, $e) | ||
| 126 | { | ||
| 127 | rg_prof_start("repo_event_symlink_by_name"); | ||
| 128 | |||
| 129 | $id_path = rg_repo_path_by_id($e['ui.uid'], $e['ri.repo_id']); | ||
| 130 | $id_path_rel = rg_repo_path_by_id_rel($e['ui.uid'], $e['ri.repo_id']); | ||
| 131 | $new_path = rg_repo_path_by_name($e['ui.uid'], $e['ri.name']); | ||
| 132 | |||
| 133 | $ret = FALSE; | ||
| 134 | rg_repo_set_error("internal error"); // TODO: we should do this everywhere? | ||
| 135 | do { | ||
| 136 | // Check if we already did the rename | ||
| 137 | if (file_exists($new_path)) { | ||
| 138 | if (!is_link($new_path)) { | ||
| 139 | rg_internal_error("$new_path is not a link!"); | ||
| 140 | break; | ||
| 141 | } | ||
| 142 | |||
| 143 | $v = readlink($new_path); | ||
| 144 | if ($v === FALSE) { | ||
| 145 | rg_internal_error("Cannot read link $new_path!"); | ||
| 146 | break; | ||
| 147 | } | ||
| 148 | rg_log("new_path points to [$v]"); | ||
| 149 | |||
| 150 | if (strcmp($id_path_rel, $v) == 0) { | ||
| 151 | // Link already done | ||
| 152 | $ret = array(); | ||
| 153 | break; | ||
| 154 | } | ||
| 155 | |||
| 156 | // Seems that new_path points to other place | ||
| 157 | $r = rename($new_path, $new_path . ".BOGUS." . time()); | ||
| 158 | if ($r !== TRUE) { | ||
| 159 | rg_internal_error("Cannot rename bogus!"); | ||
| 160 | break; | ||
| 161 | } | ||
| 162 | } | ||
| 163 | |||
| 164 | // Create links' parent | ||
| 165 | $new_path_parent = dirname($new_path); | ||
| 166 | if (!is_dir($new_path_parent)) { | ||
| 167 | $r = mkdir($new_path_parent, 0755, TRUE); | ||
| 168 | if ($r === FALSE) { | ||
| 169 | rg_repo_set_error("cannot create links' parent"); | ||
| 170 | break; | ||
| 171 | } | ||
| 172 | } | ||
| 173 | |||
| 174 | // Now, the new name is free, do the link | ||
| 175 | $r = symlink($id_path_rel, $new_path); | ||
| 176 | if ($r !== TRUE) { | ||
| 177 | rg_internal_error("Cannot symlink $id_path -> $new_path ($php_errormsg)!"); | ||
| 178 | break; | ||
| 179 | } | ||
| 180 | |||
| 181 | $ret = array(); | ||
| 182 | } while (0); | ||
| 183 | |||
| 184 | rg_prof_end("repo_event_symlink_by_name"); | ||
| 185 | return $ret; | ||
| 186 | } | ||
| 187 | |||
| 188 | /* | ||
| 189 | * Creates git dir storage | ||
| 190 | */ | ||
| 191 | function rg_repo_event_storage_create($db, $e) | ||
| 192 | { | ||
| 193 | rg_prof_start("repo_event_storage_create"); | ||
| 194 | rg_log("repo_event_storage_create: e=" . rg_array2string($e)); | ||
| 195 | |||
| 196 | $ret = FALSE; | ||
| 197 | do { | ||
| 198 | $by_id_path = rg_repo_path_by_id($e['ui.uid'], $e['ri.repo_id']); | ||
| 199 | if (!is_dir($by_id_path)) { | ||
| 200 | if (mkdir($by_id_path, 0755, TRUE) === FALSE) { | ||
| 201 | rg_repo_set_error("could not create folder $dst"); | ||
| 202 | break; | ||
| 203 | } | ||
| 204 | } | ||
| 205 | |||
| 206 | if ($e['ri.master'] == 0) { | ||
| 207 | $r = rg_git_init($by_id_path); | ||
| 208 | if ($r === FALSE) { | ||
| 209 | rg_repo_set_error("cannot init master" | ||
| 210 | . " (" . rg_git_error() . ")"); | ||
| 211 | break; | ||
| 212 | } | ||
| 213 | } else { | ||
| 214 | $mi = rg_repo_info($db, $e['ui.uid'], $e['ri.master'], ""); | ||
| 215 | if ($mi['exists'] != 1) { | ||
| 216 | rg_repo_set_error("cannot find master (" . rg_repo_error() . ")"); | ||
| 217 | break; | ||
| 218 | } | ||
| 219 | |||
| 220 | $master_by_id_path = rg_repo_path_by_id($mi['uid'], $mi['repo_id']); | ||
| 221 | $r = rg_git_clone($master_by_id_path, $by_id_path); | ||
| 222 | if ($r === FALSE) { | ||
| 223 | rg_repo_set_error("could not create repo (" . rg_git_error() . ")"); | ||
| 224 | break; | ||
| 225 | } | ||
| 226 | |||
| 227 | } | ||
| 228 | |||
| 229 | $r = rg_repo_event_symlink_by_name($db, $e); | ||
| 230 | if ($r === FALSE) | ||
| 231 | break; | ||
| 232 | |||
| 233 | $r = rg_repo_git_done($db, $e['ri.repo_id']); | ||
| 234 | if ($r !== TRUE) | ||
| 235 | break; | ||
| 236 | |||
| 237 | $ret = array(); | ||
| 238 | } while (0); | ||
| 239 | |||
| 240 | return $ret; | ||
| 241 | |||
| 242 | rg_prof_end("repo_event_storage_create"); | ||
| 243 | return array(); | ||
| 244 | } | ||
| 245 | |||
| 99 | 246 | /* | /* |
| 100 | 247 | * Event for renaming a repo | * Event for renaming a repo |
| 101 | 248 | */ | */ |
| 102 | function rg_repo_event_rename($db, $event) | ||
| 249 | function rg_repo_event_update($db, $event) | ||
| 103 | 250 | { | { |
| 104 | 251 | $ret = array(); | $ret = array(); |
| 105 | 252 | ||
| 106 | $event['op'] = "rename"; | ||
| 253 | $event['op'] = "update"; | ||
| 254 | |||
| 255 | // make symlink by name | ||
| 256 | $ret[] = array_merge($event, array("category" => 3004, "prio" => 200)); | ||
| 257 | |||
| 107 | 258 | // notify user | // notify user |
| 108 | 259 | $ret[] = array_merge($event, array("category" => 3003, "prio" => 100)); | $ret[] = array_merge($event, array("category" => 3003, "prio" => 100)); |
| 260 | |||
| 109 | 261 | // TODO: notify watchers | // TODO: notify watchers |
| 110 | 262 | ||
| 111 | 263 | return $ret; | return $ret; |
| ... | ... | function rg_repo_path_by_name($uid, $repo_name) | |
| 271 | 423 | } | } |
| 272 | 424 | ||
| 273 | 425 | $rg_repo_info_cache = array(); | $rg_repo_info_cache = array(); |
| 274 | function rg_repo_invalidate_cache($rr) | ||
| 426 | function rg_repo_invalidate_cache($uid, $repo_id) | ||
| 275 | 427 | { | { |
| 276 | 428 | global $rg_repo_info_cache; | global $rg_repo_info_cache; |
| 277 | 429 | ||
| 278 | $key = implode("__", $rr); | ||
| 430 | $key = $uid . " " . $repo_id; | ||
| 279 | 431 | if (isset($rg_repo_info_cache[$key])) | if (isset($rg_repo_info_cache[$key])) |
| 280 | 432 | unset($rg_repo_info_cache[$key]); | unset($rg_repo_info_cache[$key]); |
| 433 | |||
| 434 | //rg_log_ml("DEBUG: rg_repo_info_cache: " . print_r($rg_repo_info_cache, TRUE)); | ||
| 281 | 435 | } | } |
| 282 | 436 | ||
| 283 | 437 | /* | /* |
| ... | ... | function rg_repo_info($db, $uid, $repo_id, $repo_name) | |
| 290 | 444 | rg_prof_start("repo_info"); | rg_prof_start("repo_info"); |
| 291 | 445 | rg_log("repo_info: uid=$uid repo_id=$repo_id repo_name=$repo_name."); | rg_log("repo_info: uid=$uid repo_id=$repo_id repo_name=$repo_name."); |
| 292 | 446 | ||
| 293 | $key1 = $uid . "-" . $repo_id; | ||
| 294 | if (isset($rg_repo_info_cache[$key1])) | ||
| 295 | return $rg_repo_info_cache[$key1]; | ||
| 296 | $key2 = $uid . "-" . $repo_name; | ||
| 297 | if (isset($rg_repo_info_cache[$key2])) | ||
| 298 | return $rg_repo_info_cache[$key2]; | ||
| 299 | |||
| 300 | 447 | $ret['ok'] = 0; | $ret['ok'] = 0; |
| 301 | 448 | $ret['exists'] = 0; | $ret['exists'] = 0; |
| 449 | do { | ||
| 450 | if ($repo_id > 0) { | ||
| 451 | $key = $uid . " " . $repo_id; | ||
| 452 | if (isset($rg_repo_info_cache[$key])) { | ||
| 453 | $ret = $rg_repo_info_cache[$key]; | ||
| 454 | $ret['from_cache'] = 1; | ||
| 455 | break; | ||
| 456 | } | ||
| 457 | } | ||
| 302 | 458 | ||
| 303 | $rg_repo_info_cache[$key1] = $ret; | ||
| 304 | $rg_repo_info_cache[$key2] = $ret; | ||
| 305 | |||
| 306 | if ($repo_id > 0) { | ||
| 307 | $add = " AND repo_id = $repo_id"; | ||
| 308 | } else if (!empty($repo_name)) { | ||
| 309 | $e_repo = rg_sql_escape($db, $repo_name); | ||
| 310 | $add = " AND name = '$e_repo'"; | ||
| 311 | } else { | ||
| 312 | rg_repo_set_error("no repo_id or user/repo specified!"); | ||
| 313 | return $ret; | ||
| 314 | } | ||
| 459 | if ($repo_id > 0) { | ||
| 460 | $add = " AND repo_id = $repo_id"; | ||
| 461 | } else if (!empty($repo_name)) { | ||
| 462 | $e_repo = rg_sql_escape($db, $repo_name); | ||
| 463 | $add = " AND name = '$e_repo'"; | ||
| 464 | } else { | ||
| 465 | rg_repo_set_error("no repo_id or user/repo specified!"); | ||
| 466 | break; | ||
| 467 | } | ||
| 315 | 468 | ||
| 316 | $sql = "SELECT * FROM repos WHERE uid = $uid" . $add; | ||
| 317 | $res = rg_sql_query($db, $sql); | ||
| 318 | if ($res === FALSE) { | ||
| 319 | rg_repo_set_error("cannot query (" . rg_sql_error() . ")"); | ||
| 320 | return $ret; | ||
| 321 | } | ||
| 322 | $ret['ok'] = 1; | ||
| 323 | $rows = rg_sql_num_rows($res); | ||
| 324 | if ($rows > 0) | ||
| 325 | $row = rg_sql_fetch_array($res); | ||
| 326 | rg_sql_free_result($res); | ||
| 327 | if (($rows == 0) && ($repo_id == 0)) { | ||
| 328 | // Repo not found, maybe it was renamed | ||
| 329 | $_repo_id = rg_repo_lookup_by_old_name($db, $uid, $repo_name); | ||
| 330 | if (($_repo_id === FALSE) || ($_repo_id == 0)) { | ||
| 331 | rg_log("\tRepo not found!"); | ||
| 332 | return $ret; | ||
| 469 | $sql = "SELECT * FROM repos WHERE uid = $uid" . $add; | ||
| 470 | $res = rg_sql_query($db, $sql); | ||
| 471 | if ($res === FALSE) { | ||
| 472 | rg_repo_set_error("cannot query (" . rg_sql_error() . ")"); | ||
| 473 | break; | ||
| 333 | 474 | } | } |
| 475 | $ret['ok'] = 1; | ||
| 476 | $rows = rg_sql_num_rows($res); | ||
| 477 | if ($rows > 0) | ||
| 478 | $ret = rg_sql_fetch_array($res); | ||
| 479 | rg_sql_free_result($res); | ||
| 480 | if (($rows == 0) && ($repo_id == 0)) { | ||
| 481 | // Repo not found, maybe it was renamed | ||
| 482 | $_repo_id = rg_repo_lookup_by_old_name($db, $uid, $repo_name); | ||
| 483 | if (($_repo_id === FALSE) || ($_repo_id == 0)) { | ||
| 484 | rg_log("\tRepo not found!"); | ||
| 485 | break; | ||
| 486 | } | ||
| 334 | 487 | ||
| 335 | return rg_repo_info($db, $uid, $_repo_id, ""); | ||
| 336 | } | ||
| 488 | $ret = rg_repo_info($db, $uid, $_repo_id, ""); | ||
| 489 | break; | ||
| 490 | } | ||
| 337 | 491 | ||
| 338 | // small fixes | ||
| 339 | $row['HTML:description'] = nl2br($row['description']); | ||
| 492 | // small fixes | ||
| 493 | if ($rows > 0) | ||
| 494 | $ret['HTML:description'] = nl2br($ret['description']); | ||
| 340 | 495 | ||
| 341 | $row['exists'] = 1; | ||
| 342 | $row['ok'] = 1; | ||
| 496 | $ret['exists'] = 1; | ||
| 497 | $ret['ok'] = 1; | ||
| 498 | } while (0); | ||
| 343 | 499 | ||
| 344 | $rg_repo_info_cache[$key1] = $row; | ||
| 345 | $rg_repo_info_cache[$key2] = $row; | ||
| 500 | if (($repo_id > 0) && !isset($ret['from_cache'])) | ||
| 501 | $rg_repo_info_cache[$key] = $ret; | ||
| 346 | 502 | ||
| 347 | 503 | rg_prof_end("repo_info"); | rg_prof_end("repo_info"); |
| 348 | return $row; | ||
| 504 | return $ret; | ||
| 349 | 505 | } | } |
| 350 | 506 | ||
| 351 | 507 | /* | /* |
| 352 | * Check if a uid has access to repository | ||
| 508 | * Check if a user has access to repository | ||
| 353 | 509 | */ | */ |
| 354 | function rg_repo_allow($db, $ri, $rg_ui, $needed_rights) | ||
| 510 | function rg_repo_allow($db, $ri, $ui, $needed_rights) | ||
| 355 | 511 | { | { |
| 356 | 512 | rg_prof_start("repo_allow"); | rg_prof_start("repo_allow"); |
| 357 | 513 | ||
| 358 | 514 | rg_log("repo_allow: repo_id=" . $ri['repo_id'] | rg_log("repo_allow: repo_id=" . $ri['repo_id'] |
| 359 | . " rg_uid=" . $rg_ui['uid'] | ||
| 515 | . " uid=" . $ui['uid'] | ||
| 360 | 516 | . ", needed_rights=$needed_rights..."); | . ", needed_rights=$needed_rights..."); |
| 361 | 517 | ||
| 362 | if ($rg_ui['is_admin'] == 1) { | ||
| 518 | if ($ui['is_admin'] == 1) { | ||
| 363 | 519 | rg_log("\tUser is admin, allow!"); | rg_log("\tUser is admin, allow!"); |
| 364 | 520 | return TRUE; | return TRUE; |
| 365 | 521 | } | } |
| ... | ... | function rg_repo_allow($db, $ri, $rg_ui, $needed_rights) | |
| 370 | 526 | } | } |
| 371 | 527 | ||
| 372 | 528 | // anonymous acess (git://...) | // anonymous acess (git://...) |
| 373 | if ($rg_ui['uid'] == 0) { | ||
| 529 | if ($ui['uid'] == 0) { | ||
| 374 | 530 | $db_rights = $ri['default_rights']; | $db_rights = $ri['default_rights']; |
| 375 | 531 | } else { | } else { |
| 376 | $rr = rg_repo_rights_get($db, $ri, $rg_ui['uid'], 0); | ||
| 532 | $rr = rg_repo_rights_get($db, $ri, $ui['uid'], 0); | ||
| 377 | 533 | if ($rr['ok'] != 1) { | if ($rr['ok'] != 1) { |
| 378 | 534 | rg_repo_set_error("cannot get rights from db"); | rg_repo_set_error("cannot get rights from db"); |
| 379 | 535 | return FALSE; | return FALSE; |
| ... | ... | function rg_repo_allow($db, $ri, $rg_ui, $needed_rights) | |
| 396 | 552 | ||
| 397 | 553 | /* | /* |
| 398 | 554 | * Add a repository | * Add a repository |
| 399 | * @master - makes sense only for clones - who is the master. | ||
| 555 | * @master - makes sense only for clones: who is the master repo. | ||
| 400 | 556 | * TODO: put all fields into an array! | * TODO: put all fields into an array! |
| 401 | 557 | */ | */ |
| 402 | function rg_repo_create($db, $master, $rg_ui, $name, $max_commit_size, | ||
| 558 | function rg_repo_create($db, $master, $ui, $name, $max_commit_size, | ||
| 403 | 559 | $description, $rights, $max_users) | $description, $rights, $max_users) |
| 404 | 560 | { | { |
| 405 | 561 | rg_prof_start("repo_create"); | rg_prof_start("repo_create"); |
| 406 | 562 | ||
| 407 | 563 | // TODO: reorder parameters - are not logical | // TODO: reorder parameters - are not logical |
| 408 | rg_log("repo_create: rg_uid=" . $rg_ui['uid'] | ||
| 564 | rg_log("repo_create: uid=" . $ui['uid'] | ||
| 409 | 565 | . ", name=[$name], master=$master" | . ", name=[$name], master=$master" |
| 410 | 566 | . ", max_commit_size=$max_commit_size" | . ", max_commit_size=$max_commit_size" |
| 411 | 567 | . ", description=[$description]" | . ", description=[$description]" |
| ... | ... | function rg_repo_create($db, $master, $rg_ui, $name, $max_commit_size, | |
| 419 | 575 | break; | break; |
| 420 | 576 | ||
| 421 | 577 | // First, test if it already exists | // First, test if it already exists |
| 422 | $ri = rg_repo_info($db, $rg_ui['uid'], 0, $name); | ||
| 578 | $ri = rg_repo_info($db, $ui['uid'], 0, $name); | ||
| 423 | 579 | if ($ri['ok'] != 1) | if ($ri['ok'] != 1) |
| 424 | 580 | break; | break; |
| 425 | 581 | if ($ri['exists'] == 1) { | if ($ri['exists'] == 1) { |
| ... | ... | function rg_repo_create($db, $master, $rg_ui, $name, $max_commit_size, | |
| 428 | 584 | } | } |
| 429 | 585 | ||
| 430 | 586 | $e_name = rg_sql_escape($db, $name); | $e_name = rg_sql_escape($db, $name); |
| 587 | $description = trim($description); | ||
| 431 | 588 | $e_description = rg_sql_escape($db, $description); | $e_description = rg_sql_escape($db, $description); |
| 432 | 589 | ||
| 433 | 590 | $itime = time(); | $itime = time(); |
| ... | ... | function rg_repo_create($db, $master, $rg_ui, $name, $max_commit_size, | |
| 435 | 592 | $sql = "INSERT INTO repos (uid, master, name" | $sql = "INSERT INTO repos (uid, master, name" |
| 436 | 593 | . ", itime, max_commit_size, description, git_dir_done" | . ", itime, max_commit_size, description, git_dir_done" |
| 437 | 594 | . ", default_rights, max_users)" | . ", default_rights, max_users)" |
| 438 | . " VALUES (" . $rg_ui['uid'] . ", $master, '$e_name'" | ||
| 595 | . " VALUES (" . $ui['uid'] . ", $master, '$e_name'" | ||
| 439 | 596 | . ", $itime, $max_commit_size, '$e_description', 0" | . ", $itime, $max_commit_size, '$e_description', 0" |
| 440 | 597 | . ", '$rights', $max_users)" | . ", '$rights', $max_users)" |
| 441 | 598 | . " RETURNING repo_id"; | . " RETURNING repo_id"; |
| ... | ... | function rg_repo_create($db, $master, $rg_ui, $name, $max_commit_size, | |
| 448 | 605 | rg_sql_free_result($res); | rg_sql_free_result($res); |
| 449 | 606 | ||
| 450 | 607 | $event = array("category" => 3000, "prio" => 50, | $event = array("category" => 3000, "prio" => 50, |
| 451 | "name" => $name, | ||
| 452 | "description" => $description, | ||
| 453 | "rights" => implode("\n", rg_rights_text("repo", $rights)), | ||
| 454 | "email" => $rg_ui['email'], | ||
| 455 | "IP" => rg_var_str("REMOTE_ADDR"), | ||
| 456 | "repo_id" => $row['repo_id']); | ||
| 608 | "notification" => "repo_create-" . $ui['uid'] . "-" . $row['repo_id'], | ||
| 609 | "ui.uid" => $ui['uid'], | ||
| 610 | "ui.email" => $ui['email'], | ||
| 611 | "ri.name" => $name, | ||
| 612 | "ri.master" => $master, | ||
| 613 | "ri.description" => $description, | ||
| 614 | "ri.rights_text" => implode("\n", rg_rights_text("repo", $rights)), | ||
| 615 | "ri.repo_id" => $row['repo_id'], | ||
| 616 | "IP" => rg_var_str("REMOTE_ADDR")); | ||
| 457 | 617 | $r = rg_event_add($db, $event); | $r = rg_event_add($db, $event); |
| 458 | 618 | if ($r !== TRUE) { | if ($r !== TRUE) { |
| 459 | 619 | rg_repo_set_error("cannot add event" | rg_repo_set_error("cannot add event" |
| ... | ... | function rg_repo_create($db, $master, $rg_ui, $name, $max_commit_size, | |
| 468 | 628 | $ret = $row['repo_id']; | $ret = $row['repo_id']; |
| 469 | 629 | } while (0); | } while (0); |
| 470 | 630 | ||
| 471 | // git repo creation will be delayed for speed reasons | ||
| 472 | // and for permission reasons (we are 'web' user here). | ||
| 473 | |||
| 474 | 631 | rg_prof_end("repo_create"); | rg_prof_end("repo_create"); |
| 475 | 632 | return $ret; | return $ret; |
| 476 | 633 | } | } |
| ... | ... | function rg_repo_create($db, $master, $rg_ui, $name, $max_commit_size, | |
| 478 | 635 | /* | /* |
| 479 | 636 | * Delete a repo | * Delete a repo |
| 480 | 637 | */ | */ |
| 481 | function rg_repo_delete($db, $repo_id, $rg_ui) | ||
| 638 | function rg_repo_delete($db, $repo_id, $ui) | ||
| 482 | 639 | { | { |
| 483 | 640 | rg_prof_start("repo_delete"); | rg_prof_start("repo_delete"); |
| 484 | rg_log("repo_delete: rg_uid=" . $rg_ui['uid'] . ", repo_id=$repo_id"); | ||
| 641 | rg_log("repo_delete: uid=" . $ui['uid'] . ", repo_id=$repo_id"); | ||
| 485 | 642 | ||
| 486 | 643 | $ret = FALSE; | $ret = FALSE; |
| 487 | 644 | do { | do { |
| 488 | 645 | // TODO: Check rights | // TODO: Check rights |
| 646 | // TODO: Transaction? | ||
| 489 | 647 | ||
| 490 | 648 | // Only mark it as such, deletion will happen in background | // Only mark it as such, deletion will happen in background |
| 491 | 649 | $sql = "UPDATE repos SET deleted = 1 WHERE repo_id = $repo_id"; | $sql = "UPDATE repos SET deleted = 1 WHERE repo_id = $repo_id"; |
| ... | ... | function rg_repo_delete($db, $repo_id, $rg_ui) | |
| 497 | 655 | rg_sql_free_result($res); | rg_sql_free_result($res); |
| 498 | 656 | ||
| 499 | 657 | $event = array("category" => 3001, "prio" => 50, | $event = array("category" => 3001, "prio" => 50, |
| 500 | "name" => $name, | ||
| 501 | "description" => $description, | ||
| 502 | "email" => $rg_ui['email'], | ||
| 503 | 658 | "IP" => rg_var_str("REMOTE_ADDR"), | "IP" => rg_var_str("REMOTE_ADDR"), |
| 504 | "repo_id" => $repo_id); | ||
| 659 | "ui.email" => $ui['email'], | ||
| 660 | "ri.name" => $name, | ||
| 661 | "ri.repo_id" => $repo_id); | ||
| 505 | 662 | $r = rg_event_add($db, $event); | $r = rg_event_add($db, $event); |
| 506 | 663 | if ($r !== TRUE) { | if ($r !== TRUE) { |
| 507 | 664 | rg_repo_set_error("cannot add event" | rg_repo_set_error("cannot add event" |
| ... | ... | function rg_repo_insert_rename($db, $uid, $repo_id, $old_name) | |
| 596 | 753 | } | } |
| 597 | 754 | ||
| 598 | 755 | /* | /* |
| 599 | * Rename a repo | ||
| 600 | * We keep the old name around, so the clients do not break. | ||
| 601 | * TODO: When we create a new repo, we should remove any links! | ||
| 602 | */ | ||
| 603 | function rg_repo_rename($db, $uid, $repo_id, $old_name, $new_name) | ||
| 604 | { | ||
| 605 | rg_prof_start("repo_rename"); | ||
| 606 | rg_log("repo_rename: uid=$uid repo_id=$repo_id" | ||
| 607 | . " from=[" . $old_name . "]" | ||
| 608 | . " to=[" . $new_name . "]"); | ||
| 609 | |||
| 610 | $id_path = rg_repo_path_by_id($uid, $repo_id); | ||
| 611 | $id_path_rel = rg_repo_path_by_id_rel($uid, $repo_id); | ||
| 612 | $new_path = rg_repo_path_by_name($uid, $new_name); | ||
| 613 | |||
| 614 | $ret = FALSE; | ||
| 615 | do { | ||
| 616 | $do_link = TRUE; | ||
| 617 | |||
| 618 | // Check if we already did the rename | ||
| 619 | if (file_exists($new_path)) { | ||
| 620 | if (!is_link($new_path)) { | ||
| 621 | rg_internal_error("$new_path is not a link!"); | ||
| 622 | break; | ||
| 623 | } | ||
| 624 | |||
| 625 | $v = readlink($new_path); | ||
| 626 | if ($v === FALSE) { | ||
| 627 | rg_internal_error("Cannot read link $new_path!"); | ||
| 628 | break; | ||
| 629 | } | ||
| 630 | rg_log("new_path points to [$v]"); | ||
| 631 | |||
| 632 | if (strcmp($id_path_rel, $v) == 0) { | ||
| 633 | // Link already done | ||
| 634 | $do_link = FALSE; | ||
| 635 | } else { | ||
| 636 | // Seems that new_path points to other place | ||
| 637 | $r = rename($new_path, $new_path . ".BOGUS." . time()); | ||
| 638 | if ($r !== TRUE) { | ||
| 639 | rg_internal_error("Cannot rename bogus!"); | ||
| 640 | break; | ||
| 641 | } | ||
| 642 | } | ||
| 643 | } | ||
| 644 | |||
| 645 | if ($do_link === TRUE) { | ||
| 646 | // Now, the new name is free, do the link | ||
| 647 | $r = symlink($id_path_rel, $new_path); | ||
| 648 | if ($r !== TRUE) { | ||
| 649 | rg_internal_error("Cannot symlink $id_path -> $new_path ($php_errormsg)!"); | ||
| 650 | break; | ||
| 651 | } | ||
| 652 | } | ||
| 653 | |||
| 654 | // TOOD: transaction? | ||
| 655 | $r = rg_repo_insert_rename($db, $uid, $repo_id, $old_name); | ||
| 656 | if ($r !== TRUE) | ||
| 657 | break; | ||
| 658 | |||
| 659 | $event = array("category" => 3002, "prio" => 50, | ||
| 660 | "rename_uid" => $uid, | ||
| 661 | "rename_from" => $old_name, | ||
| 662 | "rename_to" => $new_name, | ||
| 663 | "IP" => rg_var_str("REMOTE_ADDR"), | ||
| 664 | "repo_id" => $repo_id); | ||
| 665 | $r = rg_event_add($db, $event); | ||
| 666 | if ($r !== TRUE) { | ||
| 667 | rg_repo_set_error("cannot add event" | ||
| 668 | . " (" . rg_event_error() . ")"); | ||
| 669 | break; | ||
| 670 | } | ||
| 671 | |||
| 672 | $ret = TRUE; | ||
| 673 | } while (0); | ||
| 674 | |||
| 675 | rg_prof_end("repo_rename"); | ||
| 676 | return $ret; | ||
| 677 | } | ||
| 678 | |||
| 679 | /* | ||
| 680 | * Update a repository | ||
| 681 | * @login_ui - info of the user logged in | ||
| 756 | * Updates a repository | ||
| 757 | * @login_ui - info of the user doing the update. | ||
| 758 | * Warning, it may not be the owner. | ||
| 682 | 759 | * TODO: check rights - also for create? | * TODO: check rights - also for create? |
| 683 | 760 | */ | */ |
| 684 | 761 | function rg_repo_update($db, $login_ui, &$new) | function rg_repo_update($db, $login_ui, &$new) |
| ... | ... | function rg_repo_update($db, $login_ui, &$new) | |
| 688 | 765 | . " new=" . rg_array2string($new)); | . " new=" . rg_array2string($new)); |
| 689 | 766 | ||
| 690 | 767 | $ret = FALSE; | $ret = FALSE; |
| 768 | rg_repo_set_error(""); // TODO: should we do this anywhere? | ||
| 691 | 769 | do { | do { |
| 692 | 770 | if (rg_repo_ok($new['name']) !== TRUE) | if (rg_repo_ok($new['name']) !== TRUE) |
| 693 | 771 | break; | break; |
| ... | ... | function rg_repo_update($db, $login_ui, &$new) | |
| 712 | 790 | } | } |
| 713 | 791 | ||
| 714 | 792 | // Check if the user renamed the repo | // Check if the user renamed the repo |
| 793 | $renamed = 0; | ||
| 715 | 794 | if (strcmp($new['name'], $ri['name']) != 0) { | if (strcmp($new['name'], $ri['name']) != 0) { |
| 716 | $r = rg_repo_rename($db, $rg_ui['uid'], $new['repo_id'], | ||
| 717 | $ri['name'], $new['name']); | ||
| 718 | if ($r === FALSE) | ||
| 795 | $renamed = 1; | ||
| 796 | $r = rg_repo_insert_rename($db, $login_ui['uid'], | ||
| 797 | $new['repo_id'], $ri['name']); | ||
| 798 | if ($r !== TRUE) | ||
| 719 | 799 | break; | break; |
| 720 | 800 | } | } |
| 721 | 801 | ||
| 722 | 802 | $e_name = rg_sql_escape($db, $new['name']); | $e_name = rg_sql_escape($db, $new['name']); |
| 803 | $new['description'] = trim($new['description']); | ||
| 723 | 804 | $e_description = rg_sql_escape($db, $new['description']); | $e_description = rg_sql_escape($db, $new['description']); |
| 724 | 805 | ||
| 725 | 806 | $sql = "UPDATE repos SET name = '$e_name'" | $sql = "UPDATE repos SET name = '$e_name'" |
| ... | ... | function rg_repo_update($db, $login_ui, &$new) | |
| 735 | 816 | } | } |
| 736 | 817 | rg_sql_free_result($res); | rg_sql_free_result($res); |
| 737 | 818 | ||
| 738 | $ret = TRUE; | ||
| 819 | $event = array("category" => 3002, "prio" => 50, | ||
| 820 | "ui.uid" => $login_ui['uid'], | ||
| 821 | "ui.email" => $login_ui['email'], | ||
| 822 | "IP" => rg_var_str("REMOTE_ADDR")); | ||
| 823 | $event = rg_array_merge($event, "ri.old", $ri); | ||
| 824 | $event = rg_array_merge($event, "ri", $new); | ||
| 825 | $event['ri.old.description_md5'] = md5($ri['description']); | ||
| 826 | $event['ri.description_md5'] = md5($new['description']); | ||
| 827 | $event['ri.rights_text'] = implode("\n", rg_rights_text("repo", $new['default_rights'])); | ||
| 828 | $r = rg_event_add($db, $event); | ||
| 829 | if ($r !== TRUE) { | ||
| 830 | rg_repo_set_error("cannot add event" | ||
| 831 | . " (" . rg_event_error() . ")"); | ||
| 832 | break; | ||
| 833 | } | ||
| 834 | |||
| 835 | $ret = array("renamed" => $renamed); | ||
| 739 | 836 | } while (0); | } while (0); |
| 740 | 837 | ||
| 741 | 838 | rg_prof_end("repo_update"); | rg_prof_end("repo_update"); |
| ... | ... | function rg_repo_list_query($db, $url, $sql) | |
| 809 | 906 | } | } |
| 810 | 907 | ||
| 811 | 908 | /* | /* |
| 812 | * | ||
| 909 | * List repos of user 'ui'. | ||
| 813 | 910 | */ | */ |
| 814 | function rg_repo_list($db, $url, $rg_ui) | ||
| 911 | function rg_repo_list($db, $url, $ui) | ||
| 815 | 912 | { | { |
| 816 | rg_log("repo_list: url=$url, rg_uid=" . $rg_ui['uid']); | ||
| 913 | rg_log("repo_list: url=$url, uid=" . $ui['uid']); | ||
| 817 | 914 | ||
| 818 | 915 | $add = ""; | $add = ""; |
| 819 | if ($rg_ui['uid'] > 0) | ||
| 820 | $add = " AND uid = " . $rg_ui['uid']; | ||
| 916 | if ($ui['uid'] > 0) | ||
| 917 | $add = " AND uid = " . $ui['uid']; | ||
| 821 | 918 | ||
| 822 | 919 | $sql = "SELECT * FROM repos" | $sql = "SELECT * FROM repos" |
| 823 | 920 | . " WHERE deleted = 0" | . " WHERE deleted = 0" |
| ... | ... | function rg_repo_list($db, $url, $rg_ui) | |
| 828 | 925 | } | } |
| 829 | 926 | ||
| 830 | 927 | /* | /* |
| 831 | * Search in all repositories | ||
| 832 | * We need to not find private repositories. | ||
| 928 | * Search in all repositories owned by 'ui' or public | ||
| 929 | * We need to exclude private repositories. | ||
| 833 | 930 | */ | */ |
| 834 | function rg_repo_search($db, $rg_ui, $q) | ||
| 931 | function rg_repo_search($db, $ui, $q) | ||
| 835 | 932 | { | { |
| 836 | 933 | rg_prof_start("repo_search"); | rg_prof_start("repo_search"); |
| 837 | 934 | rg_log("repo_search: q=$q..."); | rg_log("repo_search: q=$q..."); |
| ... | ... | function rg_repo_search($db, $rg_ui, $q) | |
| 841 | 938 | $sql = "SELECT * FROM repos" | $sql = "SELECT * FROM repos" |
| 842 | 939 | . " WHERE deleted = 0" | . " WHERE deleted = 0" |
| 843 | 940 | . " AND (name ILIKE '%$e_q%' OR description ILIKE '%$e_q%')" | . " AND (name ILIKE '%$e_q%' OR description ILIKE '%$e_q%')" |
| 844 | . " AND (uid = " . $rg_ui['uid'] . " OR default_rights LIKE '%F%')" | ||
| 941 | . " AND (uid = " . $ui['uid'] . " OR default_rights LIKE '%F%')" | ||
| 845 | 942 | . " ORDER BY master, name" | . " ORDER BY master, name" |
| 846 | 943 | . " LIMIT 10"; | . " LIMIT 10"; |
| 847 | 944 | ||
| ... | ... | function rg_repo_stats_push2file($a) | |
| 1016 | 1113 | return $file; | return $file; |
| 1017 | 1114 | } | } |
| 1018 | 1115 | ||
| 1019 | /* | ||
| 1020 | * Creates git folder | ||
| 1021 | */ | ||
| 1022 | function rg_repo_storage_create($db, $ri) | ||
| 1023 | { | ||
| 1024 | rg_prof_start("repo_storage_create"); | ||
| 1025 | rg_log("repo_storage_create: ri=" . rg_array2string($ri)); | ||
| 1026 | |||
| 1027 | $ret = FALSE; | ||
| 1028 | do { | ||
| 1029 | $by_id_path = rg_repo_path_by_id($ri['uid'], $ri['repo_id']); | ||
| 1030 | if (!is_dir($by_id_path)) { | ||
| 1031 | if (mkdir($by_id_path, 0755, TRUE) === FALSE) { | ||
| 1032 | rg_repo_set_error("could not create folder $dst"); | ||
| 1033 | break; | ||
| 1034 | } | ||
| 1035 | } | ||
| 1036 | |||
| 1037 | if ($ri['master'] == 0) { | ||
| 1038 | $r = rg_git_init($by_id_path); | ||
| 1039 | if ($r === FALSE) { | ||
| 1040 | rg_repo_set_error("cannot init master" | ||
| 1041 | . " (" . rg_git_error() . ")"); | ||
| 1042 | break; | ||
| 1043 | } | ||
| 1044 | } else { | ||
| 1045 | $mi = rg_repo_info($db, $ri['uid'], $ri['master'], ""); | ||
| 1046 | if ($mi['exists'] != 1) { | ||
| 1047 | rg_repo_set_error("cannot find master (" . rg_repo_error() . ")"); | ||
| 1048 | break; | ||
| 1049 | } | ||
| 1050 | |||
| 1051 | $master_by_id_path = rg_repo_path_by_id($mi['uid'], $mi['repo_id']); | ||
| 1052 | $r = rg_git_clone($master_by_id_path, $by_id_path); | ||
| 1053 | if ($r === FALSE) { | ||
| 1054 | rg_repo_set_error("could not create repo (" . rg_git_error() . ")"); | ||
| 1055 | break; | ||
| 1056 | } | ||
| 1057 | |||
| 1058 | } | ||
| 1059 | |||
| 1060 | // Link by name | ||
| 1061 | $link = rg_repo_path_by_name($ri['uid'], $ri['name']); | ||
| 1062 | $link_parent = dirname($link); | ||
| 1063 | if (!is_dir($link_parent)) { | ||
| 1064 | $r = mkdir($link_parent, 0755, TRUE); | ||
| 1065 | if ($r === FALSE) { | ||
| 1066 | rg_repo_set_error("cannot create links' parent"); | ||
| 1067 | break; | ||
| 1068 | } | ||
| 1069 | } | ||
| 1070 | |||
| 1071 | $master = rg_repo_path_by_id_rel($ri['uid'], $ri['repo_id']); | ||
| 1072 | $r = symlink($master, $link); | ||
| 1073 | if ($r === FALSE) { | ||
| 1074 | rg_repo_set_error("cannot symlink($master, $link) ($php_errormsg)"); | ||
| 1075 | break; | ||
| 1076 | } | ||
| 1077 | |||
| 1078 | $r = rg_repo_git_done($db, $ri['repo_id']); | ||
| 1079 | if ($r !== TRUE) | ||
| 1080 | break; | ||
| 1081 | |||
| 1082 | $ret = TRUE; | ||
| 1083 | } while (0); | ||
| 1084 | |||
| 1085 | rg_prof_end("repo_storage_create"); | ||
| 1086 | return $ret; | ||
| 1087 | } | ||
| 1088 | 1116 | ||
| 1089 | 1117 | ?> | ?> |
| File inc/repo/repo.form.php deleted (index 4b67312..0000000) | |||
| 1 | <?php | ||
| 2 | $_form = '<div class="formarea">' . "\n"; | ||
| 3 | |||
| 4 | $_form .= '<div class="formarea_title">' . $_action . ' repository</div><br />' . "\n"; | ||
| 5 | |||
| 6 | $_form .= rg_template_errmsg($errmsg); | ||
| 7 | |||
| 8 | $_form .= ' | ||
| 9 | <form method="post" action="' . rg_re_post($cop) . '"> | ||
| 10 | <input type="hidden" name="repo_id" value="' . $repo_id . '" /> | ||
| 11 | <input type="hidden" name="master_repo_id" value="' . $master_repo_id . '" /> | ||
| 12 | <input type="hidden" name="doit" value="1" /> | ||
| 13 | <input type="hidden" name="token" value="' . rg_token_get($db, $sid) . '" /> | ||
| 14 | |||
| 15 | '; | ||
| 16 | |||
| 17 | if ($master_repo_id > 0) { | ||
| 18 | $master_name = $master_repo_id; | ||
| 19 | $_mi = repo_info($db, $master_repo_id, ""); | ||
| 20 | if ($_mi['exists'] == 1) | ||
| 21 | $master_name = $_mi['name']; | ||
| 22 | $_form .= 'Master repo:' . $master_name . '<br />'; | ||
| 23 | } | ||
| 24 | |||
| 25 | $_form .= ' | ||
| 26 | <label for="name" class="form_item_title">Name</label><br /> | ||
| 27 | <input type="text" name="name" value="' . $name . '" /> | ||
| 28 | <br /> | ||
| 29 | <br /> | ||
| 30 | |||
| 31 | <label for="max_commit_size" class="form_item_title">Max commit size (bytes)</label><br /> | ||
| 32 | <input type="text" name="max_commit_size" value="' . $max_commit_size . '" /> | ||
| 33 | <br /> | ||
| 34 | <br /> | ||
| 35 | |||
| 36 | <label for="max_users" class="form_item_title">Max number of users</label><br /> | ||
| 37 | <input type="text" name="max_users" value="' . $max_users . '" /> | ||
| 38 | <br /> | ||
| 39 | <br /> | ||
| 40 | |||
| 41 | <label for="description" class="form_item_title">Description</label><br /> | ||
| 42 | <textarea name="description" value="' . $description . '" rows="4" cols="30">' . $description . '</textarea> | ||
| 43 | <br /> | ||
| 44 | <br /> | ||
| 45 | |||
| 46 | |||
| 47 | <label for="default_rights" class="form_item_title">Default rights for anonymous access</label><br /> | ||
| 48 | (un-check all for private repositories)<br /> | ||
| 49 | ' . rg_rights_checkboxes("repo", $rights) . ' | ||
| 50 | <br /> | ||
| 51 | |||
| 52 | <input type="submit" name="button" value="' . $_action . '" /> | ||
| 53 | |||
| 54 | </form> | ||
| 55 | </div> | ||
| 56 | '; | ||
| 57 | |||
| 58 | ?> | ||
| File inc/repo/repo.php changed (mode: 100644) (index 7f0c843..1197706) | |||
| 1 | 1 | <?php | <?php |
| 2 | 2 | rg_log("/inc/repo/repo"); | rg_log("/inc/repo/repo"); |
| 3 | 3 | ||
| 4 | $repo_more = $more; | ||
| 4 | 5 | $_repo = ""; | $_repo = ""; |
| 5 | 6 | ||
| 6 | if ($rg_ui['uid'] == 0) { | ||
| 7 | $_repo .= "You do not have access here!"; | ||
| 7 | if ($login_ui['uid'] == 0) { | ||
| 8 | $_repo .= rg_warning("You do not have access here!"); | ||
| 8 | 9 | return; | return; |
| 9 | 10 | } | } |
| 10 | 11 | ||
| ... | ... | $master_repo_id = rg_var_uint("master_repo_id"); | |
| 16 | 17 | $rights = isset($_REQUEST['rights']) ? rg_rights_a2s(rg_var_str("rights")) : $rg_repo_rights_default; | $rights = isset($_REQUEST['rights']) ? rg_rights_a2s(rg_var_str("rights")) : $rg_repo_rights_default; |
| 17 | 18 | $repo_id = rg_var_uint("repo_id"); | $repo_id = rg_var_uint("repo_id"); |
| 18 | 19 | ||
| 19 | if (empty($subop)) | ||
| 20 | $subop = "list"; | ||
| 20 | $errmsg = array(); | ||
| 21 | |||
| 22 | $_subop = empty($paras) ? "list" : array_shift($paras); | ||
| 21 | 23 | ||
| 22 | 24 | // menu | // menu |
| 23 | $second_menu = array( | ||
| 24 | "create_repo" => array( | ||
| 25 | "text" => "Create", | ||
| 26 | "op" => "create" | ||
| 27 | ), | ||
| 28 | "list_repos" => array( | ||
| 25 | $_m = array( | ||
| 26 | "list" => array( | ||
| 29 | 27 | "text" => "List", | "text" => "List", |
| 30 | 28 | "op" => "list" | "op" => "list" |
| 31 | 29 | ), | ), |
| 32 | "search_repo" => array( | ||
| 30 | "create" => array( | ||
| 31 | "text" => "Create", | ||
| 32 | "op" => "create" | ||
| 33 | ), | ||
| 34 | "search" => array( | ||
| 33 | 35 | "text" => "Search", | "text" => "Search", |
| 34 | 36 | "op" => "search" | "op" => "search" |
| 35 | 37 | ) | ) |
| 36 | 38 | ); | ); |
| 39 | rg_menu_add($rg_menu, $_m, $_subop); | ||
| 37 | 40 | ||
| 38 | $errmsg = array(); | ||
| 41 | switch ($_subop) { | ||
| 42 | case 'list': | ||
| 43 | $_repo .= rg_repo_list($db, "", $login_ui); | ||
| 44 | break; | ||
| 39 | 45 | ||
| 40 | switch ($subop) { | ||
| 41 | 46 | case 'create': | case 'create': |
| 42 | 47 | while ($doit == 1) { | while ($doit == 1) { |
| 43 | $_r = rg_repo_create($db, $master_repo_id, $rg_ui, $name, | ||
| 48 | $_r = rg_repo_create($db, $master_repo_id, $login_ui, $name, | ||
| 44 | 49 | $max_commit_size, $description, $rights, $max_users); | $max_commit_size, $description, $rights, $max_users); |
| 45 | 50 | if ($_r === FALSE) { | if ($_r === FALSE) { |
| 46 | 51 | $errmsg[] = rg_repo_error(); | $errmsg[] = rg_repo_error(); |
| ... | ... | case 'create': | |
| 48 | 53 | } | } |
| 49 | 54 | ||
| 50 | 55 | // redirect to repo page | // redirect to repo page |
| 51 | $url = rg_re_repopage($rg_ui, $name); | ||
| 56 | $url = rg_re_repopage($login_ui, $name); | ||
| 52 | 57 | rg_redirect($url); | rg_redirect($url); |
| 53 | 58 | } | } |
| 54 | 59 | ||
| 55 | $_action = "Create"; | ||
| 56 | include($INC . "/repo/repo.form.php"); | ||
| 57 | $_repo .= $_form; | ||
| 58 | break; | ||
| 60 | if ($master_repo_id > 0) { | ||
| 61 | $master_name = $master_repo_id; | ||
| 62 | $_mi = repo_info($db, $master_repo_id, ""); | ||
| 63 | if ($_mi['exists'] == 1) | ||
| 64 | $master_name = $_mi['name']; | ||
| 65 | $repo_more['master_name'] = $master_name; | ||
| 66 | } else { | ||
| 67 | $repo_more['master_name'] = ""; | ||
| 68 | } | ||
| 59 | 69 | ||
| 60 | case 'list': | ||
| 61 | $_repo .= rg_repo_list($db, "", $rg_ui); | ||
| 70 | $repo_more['title'] = "Create repository"; | ||
| 71 | $repo_more['button'] = "Create"; | ||
| 72 | $repo_more['name'] = $name; | ||
| 73 | $repo_more['max_commit_size'] = $max_commit_size; | ||
| 74 | $repo_more['max_users'] = $max_users; | ||
| 75 | $repo_more['description'] = $description; | ||
| 76 | $repo_more['master_repo_id'] = $master_repo_id; | ||
| 77 | $repo_more['HTML:rights'] = rg_rights_checkboxes("repo", $rights); | ||
| 78 | $repo_more['repo_id'] = $repo_id; | ||
| 79 | $repo_more['HTML:errmsg'] = rg_template_errmsg($errmsg); | ||
| 80 | $repo_more['rg_form_token'] = rg_token_get($db, $sid); | ||
| 81 | $_repo .= rg_template("repo/add_edit.html", $repo_more); | ||
| 62 | 82 | break; | break; |
| 63 | 83 | ||
| 64 | 84 | case 'search': | case 'search': |
| 65 | 85 | $q = rg_var_str("q"); | $q = rg_var_str("q"); |
| 66 | 86 | ||
| 67 | 87 | while ($doit == 1) { | while ($doit == 1) { |
| 68 | $_t = rg_repo_search($db, $rg_ui, $q); | ||
| 88 | $_t = rg_repo_search($db, $login_ui, $q); | ||
| 69 | 89 | if ($_t === FALSE) { | if ($_t === FALSE) { |
| 70 | 90 | $errmsg[] = rg_repo_error(); | $errmsg[] = rg_repo_error(); |
| 71 | 91 | break; | break; |
| ... | ... | case 'search': | |
| 75 | 95 | break; | break; |
| 76 | 96 | } | } |
| 77 | 97 | ||
| 78 | include($INC . "/repo/search.form.php"); | ||
| 79 | $_repo .= $_form; | ||
| 98 | $repo_more['q'] = $q; | ||
| 99 | $repo_more['HTML:errmsg'] = rg_template_errmsg($errmsg); | ||
| 100 | $_repo .= rg_template("repo/search.html", $repo_more); | ||
| 80 | 101 | break; | break; |
| 81 | 102 | } | } |
| 82 | 103 | ||
| File inc/repo/search.form.php deleted (index c00ba79..0000000) | |||
| 1 | <?php | ||
| 2 | $_form = '<div class="formarea">' . "\n"; | ||
| 3 | |||
| 4 | $_form .= '<div class="formarea_title">Search for repositories</div><br />' . "\n"; | ||
| 5 | |||
| 6 | $_form .= rg_template_errmsg($errmsg); | ||
| 7 | |||
| 8 | $_form .= ' | ||
| 9 | <form method="post" action="' . rg_re_post($cop) . '"> | ||
| 10 | <input type="hidden" name="doit" value="1" /> | ||
| 11 | |||
| 12 | <label for="q" class="form_item_title">Name</label><br /> | ||
| 13 | <input type="text" name="q" value="" /> | ||
| 14 | <br /> | ||
| 15 | <br /> | ||
| 16 | |||
| 17 | <input type="submit" name="button" value="Search" /> | ||
| 18 | |||
| 19 | </form> | ||
| 20 | </div> | ||
| 21 | '; | ||
| 22 | |||
| 23 | ?> | ||
| File inc/sess.inc.php changed (mode: 100644) (index 4a0164d..7a8451b) | |||
| ... | ... | function rg_sess_update($db, $sid) | |
| 97 | 97 | /* | /* |
| 98 | 98 | * Destroy session | * Destroy session |
| 99 | 99 | */ | */ |
| 100 | function rg_sess_destroy($db, $sid, &$rg_ui) | ||
| 100 | function rg_sess_destroy($db, $sid, &$ui) | ||
| 101 | 101 | { | { |
| 102 | 102 | rg_prof_start("sess_destroy"); | rg_prof_start("sess_destroy"); |
| 103 | 103 | ||
| ... | ... | function rg_sess_destroy($db, $sid, &$rg_ui) | |
| 116 | 116 | // Delete all tokens associated with this session | // Delete all tokens associated with this session |
| 117 | 117 | rg_token_delete($db, $sid, ""); | rg_token_delete($db, $sid, ""); |
| 118 | 118 | ||
| 119 | $rg_ui = array(); | ||
| 120 | $rg_ui['uid'] = 0; | ||
| 121 | $rg_ui['is_admin'] = 0; | ||
| 119 | $ui = array(); | ||
| 120 | $ui['uid'] = 0; | ||
| 121 | $ui['is_admin'] = 0; | ||
| 122 | 122 | ||
| 123 | 123 | rg_prof_end("sess_destroy"); | rg_prof_end("sess_destroy"); |
| 124 | 124 | ||
| File inc/struct.inc.php changed (mode: 100644) (index ece4516..86026e9) | |||
| ... | ... | function rg_sql_struct_update($db, $flags) | |
| 362 | 362 | return TRUE; | return TRUE; |
| 363 | 363 | ||
| 364 | 364 | // If we cannot lock, return error | // If we cannot lock, return error |
| 365 | if (rg_lock("schema_upgrade.lock") === FALSE) | ||
| 365 | if (rg_lock("schema_update.lock") === FALSE) | ||
| 366 | 366 | return FALSE; | return FALSE; |
| 367 | 367 | ||
| 368 | 368 | $ret = FALSE; | $ret = FALSE; |
| ... | ... | function rg_sql_struct_update($db, $flags) | |
| 395 | 395 | if ($rollback == 1) | if ($rollback == 1) |
| 396 | 396 | rg_sql_rollback($db); | rg_sql_rollback($db); |
| 397 | 397 | ||
| 398 | rg_unlock("schema_upgrade.lock"); | ||
| 398 | rg_unlock("schema_update.lock"); | ||
| 399 | 399 | ||
| 400 | 400 | return $ret; | return $ret; |
| 401 | 401 | } | } |
| ... | ... | function rg_sql_struct_slaves_update($db) | |
| 409 | 409 | global $rg_sql_struct_slaves; | global $rg_sql_struct_slaves; |
| 410 | 410 | ||
| 411 | 411 | rg_prof_start("sql_struct_slaves_update"); | rg_prof_start("sql_struct_slaves_update"); |
| 412 | rg_log("sql_struct_update"); | ||
| 412 | rg_log("sql_struct_slaves_update"); | ||
| 413 | 413 | ||
| 414 | 414 | $ret = FALSE; | $ret = FALSE; |
| 415 | 415 | $rollback = 0; | $rollback = 0; |
| 416 | $locked = FALSE; | ||
| 416 | 417 | do { | do { |
| 417 | 418 | if (empty($rg_sql_struct_slaves)) { | if (empty($rg_sql_struct_slaves)) { |
| 418 | 419 | $ret = TRUE; | $ret = TRUE; |
| 419 | 420 | break; | break; |
| 420 | 421 | } | } |
| 421 | 422 | ||
| 423 | // If we cannot lock, return error | ||
| 424 | if (rg_lock("slave_create.lock") === FALSE) | ||
| 425 | break; | ||
| 426 | $locked = TRUE; | ||
| 427 | |||
| 422 | 428 | $last_ts = rg_state_get($db, "slaves_create_last_ts"); | $last_ts = rg_state_get($db, "slaves_create_last_ts"); |
| 423 | 429 | if ($last_ts === FALSE) | if ($last_ts === FALSE) |
| 424 | 430 | break; | break; |
| 425 | 431 | ||
| 426 | 432 | $last_ts = intval($last_ts); | $last_ts = intval($last_ts); |
| 427 | 433 | if ($last_ts == 0) | if ($last_ts == 0) |
| 428 | $last_ts = gmmktime(0, 0, 0, gmdate("m"), 1, gmdate("Y")); | ||
| 434 | $last_ts = gmmktime(0, 0, 0, gmdate("m") - 1, 1, gmdate("Y")); | ||
| 435 | rg_log("last_ts=$last_ts (" . gmdate("Y-m-d", $last_ts) . ")"); | ||
| 429 | 436 | ||
| 430 | // First second of next month | ||
| 431 | $next_month_ts = gmmktime(0, 0, 0, gmdate("m") + 1, gmdate("d"), gmdate("Y")); | ||
| 437 | // First second of current month | ||
| 438 | $current_month_ts = gmmktime(0, 0, 0, gmdate("m"), 1, gmdate("Y")); | ||
| 439 | rg_log("current_month_ts=$current_month_ts (" . gmdate("Y-m-d", $current_month_ts) . ")"); | ||
| 432 | 440 | ||
| 433 | if ($next_month_ts == $last_ts) { | ||
| 434 | rg_log(" No update needed!"); | ||
| 441 | // Do we have current month and the next one covered? | ||
| 442 | if ($current_month_ts < $last_ts) { | ||
| 443 | rg_log("\tNo update needed!"); | ||
| 435 | 444 | $ret = TRUE; | $ret = TRUE; |
| 436 | 445 | break; | break; |
| 437 | 446 | } | } |
| 438 | 447 | ||
| 439 | // If we cannot lock, return error | ||
| 440 | if (rg_lock("slave_create.lock") === FALSE) | ||
| 441 | return FALSE; | ||
| 442 | |||
| 443 | 448 | if (rg_sql_begin($db) !== TRUE) | if (rg_sql_begin($db) !== TRUE) |
| 444 | 449 | break; | break; |
| 445 | 450 | $rollback = 1; | $rollback = 1; |
| 446 | 451 | ||
| 447 | 452 | $ok = TRUE; | $ok = TRUE; |
| 448 | $month = gmdate("m", $last_ts); | ||
| 453 | $month = gmdate("m", $last_ts) + 1; | ||
| 449 | 454 | $year = gmdate("Y", $last_ts); | $year = gmdate("Y", $last_ts); |
| 450 | 455 | $ts = gmmktime(0, 0, 0, $month, 1, $year); | $ts = gmmktime(0, 0, 0, $month, 1, $year); |
| 451 | do { | ||
| 456 | $stop_ts = gmmktime(0, 0, 0, gmdate("m") + 1, 1, $year); | ||
| 457 | while ($ts <= $stop_ts) { | ||
| 452 | 458 | $month++; | $month++; |
| 453 | 459 | $next_ts = gmmktime(0, 0, 0, $month, 1, $year); | $next_ts = gmmktime(0, 0, 0, $month, 1, $year); |
| 454 | 460 | ||
| 455 | 461 | foreach ($rg_sql_struct_slaves as $table) { | foreach ($rg_sql_struct_slaves as $table) { |
| 456 | $slave_table = $table . "_" . gmdate("Y", $ts) . "_" . gmdate("m", $ts); | ||
| 462 | $slave_table = $table . "_" . gmdate("Y_m", $ts); | ||
| 457 | 463 | $sql = "CREATE TABLE " . $slave_table | $sql = "CREATE TABLE " . $slave_table |
| 458 | 464 | . " (CHECK(itime >= $ts AND itime <= " . ($next_ts - 1) . "))" | . " (CHECK(itime >= $ts AND itime <= " . ($next_ts - 1) . "))" |
| 459 | 465 | . " INHERITS (" . $table . ")"; | . " INHERITS (" . $table . ")"; |
| ... | ... | function rg_sql_struct_slaves_update($db) | |
| 475 | 481 | rg_sql_free_result($res); | rg_sql_free_result($res); |
| 476 | 482 | } | } |
| 477 | 483 | $ts = $next_ts; | $ts = $next_ts; |
| 478 | } while ($ts < $next_month_ts); | ||
| 484 | } | ||
| 479 | 485 | if ($ok === FALSE) | if ($ok === FALSE) |
| 480 | 486 | break; | break; |
| 481 | 487 | ||
| 482 | $r = rg_state_set($db, "slaves_create_last_ts", $next_month_ts); | ||
| 488 | $r = rg_state_set($db, "slaves_create_last_ts", $stop_ts); | ||
| 483 | 489 | if ($r !== TRUE) { | if ($r !== TRUE) { |
| 484 | 490 | rg_log("Cannot create slave (" . rg_state_error() . ")"); | rg_log("Cannot create slave (" . rg_state_error() . ")"); |
| 485 | 491 | break; | break; |
| ... | ... | function rg_sql_struct_slaves_update($db) | |
| 495 | 501 | if ($rollback == 1) | if ($rollback == 1) |
| 496 | 502 | rg_sql_rollback($db); | rg_sql_rollback($db); |
| 497 | 503 | ||
| 498 | rg_unlock("slave_create.lock"); | ||
| 504 | if ($locked === TRUE) | ||
| 505 | rg_unlock("slave_create.lock"); | ||
| 499 | 506 | ||
| 500 | 507 | rg_prof_end("sql_struct_slaves_update"); | rg_prof_end("sql_struct_slaves_update"); |
| 501 | 508 | return $ret; | return $ret; |
| File inc/user.inc.php changed (mode: 100644) (index 3a428e9..fe23013) | |||
| ... | ... | function rg_user_rename($db, $ui, $new_name) | |
| 359 | 359 | ||
| 360 | 360 | // TODO: Check if all parameters are used. | // TODO: Check if all parameters are used. |
| 361 | 361 | $event = array("category" => 2005, "prio" => 50, | $event = array("category" => 2005, "prio" => 50, |
| 362 | "rename_from" => $ui['username'], | ||
| 363 | "rename_to" => $new_name, | ||
| 362 | "ui.rename_from" => $ui['username'], | ||
| 363 | "ui.rename_to" => $new_name, | ||
| 364 | 364 | "IP" => rg_var_str("REMOTE_ADDR"), | "IP" => rg_var_str("REMOTE_ADDR"), |
| 365 | "uid" => $ui['uid']); | ||
| 365 | "ui.uid" => $ui['uid']); | ||
| 366 | 366 | $r = rg_event_add($db, $event); | $r = rg_event_add($db, $event); |
| 367 | 367 | if ($r !== TRUE) { | if ($r !== TRUE) { |
| 368 | 368 | rg_repo_set_error("cannot add event" | rg_repo_set_error("cannot add event" |
| ... | ... | function rg_user_edit($db, $d) | |
| 462 | 462 | ||
| 463 | 463 | if ($d['uid'] == 0) { // add | if ($d['uid'] == 0) { // add |
| 464 | 464 | $event = array("category" => 2000, "prio" => 50, | $event = array("category" => 2000, "prio" => 50, |
| 465 | "uid" => $d['uid'], | ||
| 466 | "username" => $d['username'], | ||
| 467 | "email" => $d['email'] | ||
| 465 | "ui.uid" => $d['uid'], | ||
| 466 | "ui.username" => $d['username'], | ||
| 467 | "ui.email" => $d['email'] | ||
| 468 | 468 | ); | ); |
| 469 | 469 | $r = rg_event_add($db, $event); | $r = rg_event_add($db, $event); |
| 470 | 470 | if ($r === FALSE) { | if ($r === FALSE) { |
| ... | ... | function rg_user_info($db, $uid, $user, $email) | |
| 579 | 579 | } | } |
| 580 | 580 | ||
| 581 | 581 | /* | /* |
| 582 | * Loads rg_ui based on sid, if possible | ||
| 582 | * Loads ui based on sid, if possible | ||
| 583 | 583 | */ | */ |
| 584 | function rg_user_login_by_sid($db, $sid, &$rg_ui) | ||
| 584 | function rg_user_login_by_sid($db, $sid, &$ui) | ||
| 585 | 585 | { | { |
| 586 | 586 | rg_log("user_login_by_sid: sid=$sid..."); | rg_log("user_login_by_sid: sid=$sid..."); |
| 587 | 587 | ||
| 588 | 588 | // Make sure it is not passed by client | // Make sure it is not passed by client |
| 589 | $rg_ui = array(); | ||
| 590 | $rg_ui['uid'] = 0; | ||
| 591 | $rg_ui['is_admin'] = 0; | ||
| 592 | $rg_ui['username'] = ""; | ||
| 589 | $ui = array(); | ||
| 590 | $ui['uid'] = 0; | ||
| 591 | $ui['is_admin'] = 0; | ||
| 592 | $ui['username'] = ""; | ||
| 593 | 593 | ||
| 594 | 594 | if (empty($sid)) { | if (empty($sid)) { |
| 595 | 595 | rg_log("\tNo sid!"); | rg_log("\tNo sid!"); |
| ... | ... | function rg_user_login_by_sid($db, $sid, &$rg_ui) | |
| 600 | 600 | if ($uid == 0) | if ($uid == 0) |
| 601 | 601 | return FALSE; | return FALSE; |
| 602 | 602 | ||
| 603 | $rg_ui = rg_user_info($db, $uid, "", ""); | ||
| 604 | if ($rg_ui['exists'] != 1) { | ||
| 603 | $ui = rg_user_info($db, $uid, "", ""); | ||
| 604 | if ($ui['exists'] != 1) { | ||
| 605 | 605 | rg_log("\tUid $uid does not exists (" . rg_user_error() . ")!"); | rg_log("\tUid $uid does not exists (" . rg_user_error() . ")!"); |
| 606 | 606 | rg_user_set_error("invalid uid"); | rg_user_set_error("invalid uid"); |
| 607 | 607 | return FALSE; | return FALSE; |
| ... | ... | function rg_user_login_by_sid($db, $sid, &$rg_ui) | |
| 609 | 609 | ||
| 610 | 610 | rg_sess_update($db, $sid); | rg_sess_update($db, $sid); |
| 611 | 611 | ||
| 612 | rg_user_set_last_seen($db, $rg_ui['uid']); | ||
| 612 | rg_user_set_last_seen($db, $ui['uid']); | ||
| 613 | 613 | ||
| 614 | 614 | return TRUE; | return TRUE; |
| 615 | 615 | } | } |
| ... | ... | function rg_user_pass_valid($db, $uid, $pass) | |
| 645 | 645 | /* | /* |
| 646 | 646 | * Auto login the user | * Auto login the user |
| 647 | 647 | */ | */ |
| 648 | function rg_user_auto_login($db, $uid, &$rg_ui) | ||
| 648 | function rg_user_auto_login($db, $uid, &$ui) | ||
| 649 | 649 | { | { |
| 650 | $rg_ui = rg_user_info($db, $uid, "", ""); | ||
| 651 | if ($rg_ui['ok'] != 1) | ||
| 650 | $ui = rg_user_info($db, $uid, "", ""); | ||
| 651 | if ($ui['ok'] != 1) | ||
| 652 | 652 | return FALSE; | return FALSE; |
| 653 | 653 | ||
| 654 | if ($rg_ui['exists'] != 1) | ||
| 654 | if ($ui['exists'] != 1) | ||
| 655 | 655 | return FALSE; | return FALSE; |
| 656 | 656 | ||
| 657 | 657 | $secure = FALSE; | $secure = FALSE; |
| ... | ... | function rg_user_auto_login($db, $uid, &$rg_ui) | |
| 659 | 659 | $secure = TRUE; | $secure = TRUE; |
| 660 | 660 | ||
| 661 | 661 | $sid = rg_id(40); | $sid = rg_id(40); |
| 662 | rg_sess_add($db, $uid, $sid, $rg_ui['session_time']); | ||
| 662 | rg_sess_add($db, $uid, $sid, $ui['session_time']); | ||
| 663 | 663 | setcookie("sid", $sid, 0, "/", $_SERVER['SERVER_NAME'], | setcookie("sid", $sid, 0, "/", $_SERVER['SERVER_NAME'], |
| 664 | 664 | $secure, TRUE /* httponly */); | $secure, TRUE /* httponly */); |
| 665 | 665 | ||
| ... | ... | function rg_user_auto_login($db, $uid, &$rg_ui) | |
| 669 | 669 | /* | /* |
| 670 | 670 | * Test if login is OK | * Test if login is OK |
| 671 | 671 | */ | */ |
| 672 | function rg_user_login_by_user_pass($db, $user, $pass, &$rg_ui) | ||
| 672 | function rg_user_login_by_user_pass($db, $user, $pass, &$ui) | ||
| 673 | 673 | { | { |
| 674 | 674 | rg_log("user_login_by_user_pass: user=$user, pass=$pass..."); | rg_log("user_login_by_user_pass: user=$user, pass=$pass..."); |
| 675 | 675 | ||
| 676 | $rg_ui = array(); | ||
| 677 | $rg_ui['uid'] = 0; | ||
| 678 | $rg_ui['is_admin'] = 0; | ||
| 676 | $ui = array(); | ||
| 677 | $ui['uid'] = 0; | ||
| 678 | $ui['is_admin'] = 0; | ||
| 679 | 679 | ||
| 680 | 680 | if (empty($user) || empty($pass)) { | if (empty($user) || empty($pass)) { |
| 681 | 681 | rg_user_set_error("invalid user or pass"); | rg_user_set_error("invalid user or pass"); |
| 682 | 682 | return FALSE; | return FALSE; |
| 683 | 683 | } | } |
| 684 | 684 | ||
| 685 | $rg_ui0 = rg_user_info($db, 0, $user, ""); | ||
| 686 | if ($rg_ui0['ok'] != 1) { | ||
| 685 | $ui0 = rg_user_info($db, 0, $user, ""); | ||
| 686 | if ($ui0['ok'] != 1) { | ||
| 687 | 687 | rg_user_set_error("internal error"); | rg_user_set_error("internal error"); |
| 688 | 688 | return FALSE; | return FALSE; |
| 689 | 689 | } | } |
| 690 | if ($rg_ui0['exists'] != 1) { | ||
| 690 | if ($ui0['exists'] != 1) { | ||
| 691 | 691 | rg_user_set_error("invalid user or pass"); | rg_user_set_error("invalid user or pass"); |
| 692 | 692 | return FALSE; | return FALSE; |
| 693 | 693 | } | } |
| 694 | 694 | ||
| 695 | if ($rg_ui0['suspended'] > 0) { | ||
| 695 | if ($ui0['suspended'] > 0) { | ||
| 696 | 696 | rg_user_set_error("invalid user or pass"); | rg_user_set_error("invalid user or pass"); |
| 697 | 697 | return FALSE; | return FALSE; |
| 698 | 698 | } | } |
| 699 | 699 | ||
| 700 | if ($rg_ui0['confirmed'] == 0) { | ||
| 700 | if ($ui0['confirmed'] == 0) { | ||
| 701 | 701 | rg_user_set_error("invalid user or pass"); | rg_user_set_error("invalid user or pass"); |
| 702 | 702 | return FALSE; | return FALSE; |
| 703 | 703 | } | } |
| 704 | 704 | ||
| 705 | $sha1pass = rg_user_pass($rg_ui0['salt'], $pass); | ||
| 706 | if (strcmp($sha1pass, $rg_ui0['pass']) != 0) { | ||
| 705 | $sha1pass = rg_user_pass($ui0['salt'], $pass); | ||
| 706 | if (strcmp($sha1pass, $ui0['pass']) != 0) { | ||
| 707 | 707 | rg_user_set_error("invalid user or pass"); | rg_user_set_error("invalid user or pass"); |
| 708 | 708 | return FALSE; | return FALSE; |
| 709 | 709 | } | } |
| 710 | 710 | ||
| 711 | $rg_ui = $rg_ui0; | ||
| 712 | rg_user_auto_login($db, $rg_ui['uid'], $rg_ui); | ||
| 711 | $ui = $ui0; | ||
| 712 | rg_user_auto_login($db, $ui['uid'], $ui); | ||
| 713 | 713 | ||
| 714 | rg_user_set_last_seen($db, $rg_ui['uid']); | ||
| 714 | rg_user_set_last_seen($db, $ui['uid']); | ||
| 715 | 715 | ||
| 716 | 716 | return TRUE; | return TRUE; |
| 717 | 717 | } | } |
| File inc/user/confirm.php changed (mode: 100644) (index 447a648..c21f2c7) | |||
| ... | ... | $_confirm = ""; | |
| 8 | 8 | $uid = rg_user_confirm($db, $token); | $uid = rg_user_confirm($db, $token); |
| 9 | 9 | if ($uid !== FALSE) { | if ($uid !== FALSE) { |
| 10 | 10 | // auto-login | // auto-login |
| 11 | if (rg_user_auto_login($db, $uid, $rg_ui)) { | ||
| 12 | $url = rg_re_userpage($rg_ui); | ||
| 11 | if (rg_user_auto_login($db, $uid, $login_ui)) { | ||
| 12 | $url = rg_re_userpage($login_ui); | ||
| 13 | 13 | rg_redirect($url); | rg_redirect($url); |
| 14 | 14 | } | } |
| 15 | 15 | } | } |
| File inc/user/forgot.form.php deleted (index 6850766..0000000) | |||
| 1 | <?php | ||
| 2 | $_forgot_form = '<div class="formarea">' . "\n"; | ||
| 3 | |||
| 4 | $_forgot_form .= '<div class="formarea_title">Change password</div><br />' . "\n"; | ||
| 5 | |||
| 6 | $_forgot_form .= rg_template_errmsg($errmsg); | ||
| 7 | |||
| 8 | $_forgot_form .= ' | ||
| 9 | <form method="post" action="' . rg_re_post($cop) . '"> | ||
| 10 | <input type="hidden" name="forgot_token" value="' . $forgot_token . '" /> | ||
| 11 | <input type="hidden" name="doit" value="1" /> | ||
| 12 | <input type="hidden" name="token" value="' . rg_token_get($db, $sid) . '" /> | ||
| 13 | |||
| 14 | <label for="pass1" class="form_item_title">New password</label><br /> | ||
| 15 | <input type="password" name="pass1" value="" /> | ||
| 16 | <br /> | ||
| 17 | <br /> | ||
| 18 | |||
| 19 | <label for="pass2" class="form_item_title">New password (re-type)</label><br /> | ||
| 20 | <input type="password" name="pass2" value="" /> | ||
| 21 | <br /> | ||
| 22 | <br /> | ||
| 23 | |||
| 24 | <input type="submit" name="button" value="Change password" /> | ||
| 25 | |||
| 26 | </form> | ||
| 27 | </div> | ||
| 28 | '; | ||
| 29 | |||
| 30 | ?> | ||
| File inc/user/forgot.php changed (mode: 100644) (index 114122c..38f8c0f) | |||
| 1 | 1 | <?php | <?php |
| 2 | 2 | rg_log("/inc/user/forgot"); | rg_log("/inc/user/forgot"); |
| 3 | 3 | ||
| 4 | $forgot_more = $more; | ||
| 4 | 5 | $forgot_token = rg_var_re("forgot_token", "/[^A-Za-z0-9]/"); | $forgot_token = rg_var_re("forgot_token", "/[^A-Za-z0-9]/"); |
| 5 | 6 | $pass1 = rg_var_str("pass1"); | $pass1 = rg_var_str("pass1"); |
| 6 | 7 | $pass2 = rg_var_str("pass2"); | $pass2 = rg_var_str("pass2"); |
| ... | ... | if ($doit == 1) { | |
| 31 | 32 | ||
| 32 | 33 | rg_user_forgot_pass_destroy($db, $r['uid']); | rg_user_forgot_pass_destroy($db, $r['uid']); |
| 33 | 34 | // auto-login | // auto-login |
| 34 | if (!rg_user_auto_login($db, $r['uid'], $rg_ui)) { | ||
| 35 | if (!rg_user_auto_login($db, $r['uid'], $login_ui)) { | ||
| 35 | 36 | $_forgot = rg_template("msg/internal.txt"); | $_forgot = rg_template("msg/internal.txt"); |
| 36 | 37 | return; | return; |
| 37 | 38 | } | } |
| 38 | 39 | ||
| 39 | 40 | // redirect to home | // redirect to home |
| 40 | $url = rg_re_userpage($rg_ui); | ||
| 41 | $url = rg_re_userpage($login_ui); | ||
| 41 | 42 | rg_redirect($url); | rg_redirect($url); |
| 42 | 43 | } | } |
| 43 | 44 | } | } |
| 44 | 45 | ||
| 45 | include($INC . "/user/forgot.form.php"); | ||
| 46 | $_forgot .= $_forgot_form; | ||
| 47 | |||
| 46 | $forgot_more['forgot_token'] = $forgot_token; | ||
| 47 | $forgot_more['pass1'] = $pass1; | ||
| 48 | $forgot_more['pass2'] = $pass2; | ||
| 49 | $forgot_more['HTML:errmsg'] = rg_template_errmsg($errmsg); | ||
| 50 | $_forgot .= rg_template("user/forgot.html", $forgot_more); | ||
| 48 | 51 | ?> | ?> |
| File inc/user/forgot_send.form.php deleted (index 68d6bdb..0000000) | |||
| 1 | <?php | ||
| 2 | $_form = '<div class="formarea">' . "\n"; | ||
| 3 | |||
| 4 | $_form .= '<div class="formarea_title">Forgot password</div><br />' . "\n"; | ||
| 5 | |||
| 6 | $_form .= rg_template_errmsg($errmsg); | ||
| 7 | |||
| 8 | $_form .= ' | ||
| 9 | <form method="post" action="' . rg_re_post($cop . "/forgot_send") . '"> | ||
| 10 | <input type="hidden" name="doit" value="1" /> | ||
| 11 | |||
| 12 | <label for="email" class="form_item_title">E-mail</label><br /> | ||
| 13 | <input type="text" name="email" value="' . $email . '" /> | ||
| 14 | <br /> | ||
| 15 | <br /> | ||
| 16 | |||
| 17 | <input type="submit" name="button" value="Recover password" /> | ||
| 18 | |||
| 19 | </form> | ||
| 20 | </div> | ||
| 21 | '; | ||
| 22 | |||
| 23 | ?> | ||
| File inc/user/forgot_send.php changed (mode: 100644) (index 8993da1..0f964f4) | |||
| 1 | 1 | <?php | <?php |
| 2 | 2 | rg_log("/inc/user/forgot_send"); | rg_log("/inc/user/forgot_send"); |
| 3 | 3 | ||
| 4 | $forgot_send_more = $more; | ||
| 4 | 5 | $email = rg_var_str("email"); | $email = rg_var_str("email"); |
| 5 | 6 | ||
| 6 | 7 | $_forgot = ""; | $_forgot = ""; |
| 7 | 8 | ||
| 8 | 9 | $errmsg = array(); | $errmsg = array(); |
| 9 | $show_form = 1; | ||
| 10 | 10 | ||
| 11 | $_show_form = 1; | ||
| 11 | 12 | if ($doit == 1) { | if ($doit == 1) { |
| 12 | 13 | $r = rg_user_forgot_pass_mail($db, $email); | $r = rg_user_forgot_pass_mail($db, $email); |
| 13 | 14 | if ($r['ok'] == 0) { | if ($r['ok'] == 0) { |
| ... | ... | if ($doit == 1) { | |
| 15 | 16 | } else if ($r['exists'] == 0) { | } else if ($r['exists'] == 0) { |
| 16 | 17 | $errmsg[] = "E-mail does not exists."; | $errmsg[] = "E-mail does not exists."; |
| 17 | 18 | } else { | } else { |
| 18 | $_forgot .= "E-mail was sent!"; | ||
| 19 | $show_form = 0; | ||
| 19 | $_forgot .= rg_ok("Check your inbox and follow the instructions!"); | ||
| 20 | $_show_form = 0; | ||
| 20 | 21 | } | } |
| 21 | 22 | } else { | } else { |
| 22 | 23 | // defaults | // defaults |
| 23 | 24 | $email = ""; | $email = ""; |
| 24 | 25 | } | } |
| 25 | 26 | ||
| 26 | if ($show_form == 1) { | ||
| 27 | include($INC ."/user/forgot_send.form.php"); | ||
| 28 | $_forgot .= $_form; | ||
| 27 | if ($_show_form == 1) { | ||
| 28 | $forgot_send_more['email'] = $email; | ||
| 29 | $forgot_send_more['HTML:errmsg'] = rg_template_errmsg($errmsg); | ||
| 30 | $_forgot .= rg_template("user/forgot_send.html", $forgot_send_more); | ||
| 29 | 31 | } | } |
| 30 | 32 | ||
| 31 | 33 | ?> | ?> |
| File inc/user/home-page.php changed (mode: 100644) (index 7b15357..8e89d93) | |||
| ... | ... | rg_log("/inc/user/home-page"); | |
| 3 | 3 | ||
| 4 | 4 | $_home = ""; | $_home = ""; |
| 5 | 5 | ||
| 6 | $ui = rg_user_info($db, 0, $rr['user'], ""); | ||
| 7 | if ($ui === FALSE) { | ||
| 6 | $page_ui = rg_user_info($db, 0, $user, ""); | ||
| 7 | if ($page_ui === FALSE) { | ||
| 8 | 8 | $_home .= rg_warning("Invalid user!"); | $_home .= rg_warning("Invalid user!"); |
| 9 | 9 | return; | return; |
| 10 | 10 | } | } |
| 11 | 11 | ||
| 12 | 12 | // list of repositories | // list of repositories |
| 13 | $_home .= rg_repo_list($db, "", $ui); | ||
| 13 | $_home .= rg_repo_list($db, "", $page_ui); | ||
| 14 | 14 | ?> | ?> |
| File inc/user/info/info.php changed (mode: 100644) (index d883155..adf149b) | |||
| ... | ... | $errmsg = array(); | |
| 5 | 5 | ||
| 6 | 6 | $_info = ""; | $_info = ""; |
| 7 | 7 | ||
| 8 | $_show_form = 1; | ||
| 8 | 9 | if ($doit == 1) { | if ($doit == 1) { |
| 9 | 10 | if (!rg_token_valid($db, $sid, $token)) { | if (!rg_token_valid($db, $sid, $token)) { |
| 10 | 11 | $_info .= "Invalid token. Try again."; | $_info .= "Invalid token. Try again."; |
| ... | ... | if ($doit == 1) { | |
| 14 | 15 | $xuser = rg_var_str("xuser"); | $xuser = rg_var_str("xuser"); |
| 15 | 16 | $realname = rg_var_str("realname"); | $realname = rg_var_str("realname"); |
| 16 | 17 | $email = rg_var_str("email"); | $email = rg_var_str("email"); |
| 17 | $is_admin = $rg_ui['is_admin']; // TODO: doesn't seems too elegant | ||
| 18 | $disk_quota_mb = $rg_ui['disk_quota_mb']; | ||
| 19 | $rights = $rg_ui['rights']; | ||
| 18 | $is_admin = $login_ui['is_admin']; // TODO: doesn't seems too elegant | ||
| 19 | $disk_quota_mb = $login_ui['disk_quota_mb']; | ||
| 20 | $rights = $login_ui['rights']; | ||
| 20 | 21 | $session_time = rg_var_uint("session_time"); | $session_time = rg_var_uint("session_time"); |
| 21 | 22 | ||
| 22 | 23 | do { | do { |
| 23 | 24 | $_u = array(); | $_u = array(); |
| 24 | $_u['uid'] = $rg_ui['uid']; | ||
| 25 | $_u['uid'] = $login_ui['uid']; | ||
| 25 | 26 | $_u['username'] = $xuser; | $_u['username'] = $xuser; |
| 26 | 27 | $_u['realname'] = $realname; | $_u['realname'] = $realname; |
| 27 | 28 | $_u['email'] = $email; | $_u['email'] = $email; |
| ... | ... | if ($doit == 1) { | |
| 35 | 36 | break; | break; |
| 36 | 37 | } | } |
| 37 | 38 | ||
| 38 | $_info .= "Information was updated!<br />"; | ||
| 39 | $_info .= rg_ok("Information was updated!"); | ||
| 40 | $_show_form = 0; | ||
| 39 | 41 | } while (0); | } while (0); |
| 40 | 42 | } else { | } else { |
| 41 | $xuser = $rg_ui['username']; | ||
| 42 | $realname = $rg_ui['realname']; | ||
| 43 | $email = $rg_ui['email']; | ||
| 44 | $is_admin = $rg_ui['is_admin']; | ||
| 45 | $disk_quota_mb = $rg_ui['disk_quota_mb']; | ||
| 46 | $rights = $rg_ui['rights']; | ||
| 47 | $session_time = $rg_ui['session_time']; | ||
| 43 | $xuser = $login_ui['username']; | ||
| 44 | $realname = $login_ui['realname']; | ||
| 45 | $email = $login_ui['email']; | ||
| 46 | $is_admin = $login_ui['is_admin']; | ||
| 47 | $disk_quota_mb = $login_ui['disk_quota_mb']; | ||
| 48 | $rights = $login_ui['rights']; | ||
| 49 | $session_time = $login_ui['session_time']; | ||
| 48 | 50 | } | } |
| 49 | 51 | ||
| 50 | $create_mode = 0; | ||
| 51 | $admin_mode = 0; | ||
| 52 | $pass_mode = 0; | ||
| 53 | include($INC . "/admin/users/user.form.php"); | ||
| 54 | $_info .= $_form; | ||
| 52 | if ($_show_form == 1) { | ||
| 53 | $create_mode = 0; | ||
| 54 | $admin_mode = 0; | ||
| 55 | $pass_mode = 0; | ||
| 56 | include($INC . "/admin/users/user.form.php"); | ||
| 57 | $_info .= $_form; | ||
| 58 | } | ||
| 55 | 59 | ||
| 56 | 60 | ?> | ?> |
| File inc/user/keys/keys.php changed (mode: 100644) (index f0c9326..6cebcc1) | |||
| ... | ... | $key_id = rg_var_uint("key_id"); | |
| 13 | 13 | $key_delete_ids = rg_var_str("key_delete_ids"); | $key_delete_ids = rg_var_str("key_delete_ids"); |
| 14 | 14 | ||
| 15 | 15 | // menu | // menu |
| 16 | $_url = rg_re_url($cop); | ||
| 16 | $_url = rg_re_url($sparas); | ||
| 17 | 17 | ||
| 18 | 18 | if (rg_var_uint("add") == 1) { | if (rg_var_uint("add") == 1) { |
| 19 | 19 | do { | do { |
| ... | ... | if (rg_var_uint("add") == 1) { | |
| 22 | 22 | break; | break; |
| 23 | 23 | } | } |
| 24 | 24 | ||
| 25 | $_r = rg_keys_add($db, $rg_ui, $key); | ||
| 25 | $_r = rg_keys_add($db, $login_ui, $key); | ||
| 26 | 26 | if ($_r === FALSE) | if ($_r === FALSE) |
| 27 | 27 | $add_errmsg[] = rg_keys_error(); | $add_errmsg[] = rg_keys_error(); |
| 28 | 28 | } while (0); | } while (0); |
| ... | ... | if (rg_var_uint("add") == 1) { | |
| 38 | 38 | break; | break; |
| 39 | 39 | } | } |
| 40 | 40 | ||
| 41 | if (rg_keys_remove_multi($db, $rg_ui, $key_delete_ids) !== TRUE) { | ||
| 41 | if (rg_keys_remove_multi($db, $login_ui, $key_delete_ids) !== TRUE) { | ||
| 42 | 42 | $del_errmsg[] = rg_keys_error(); | $del_errmsg[] = rg_keys_error(); |
| 43 | 43 | break; | break; |
| 44 | 44 | } | } |
| ... | ... | $_my_more['HTML:del_errmsg'] = rg_template_errmsg($del_errmsg); | |
| 50 | 50 | ||
| 51 | 51 | $_my_more['HTML:add_form'] = rg_template("user/keys/add.html", $_my_more); | $_my_more['HTML:add_form'] = rg_template("user/keys/add.html", $_my_more); |
| 52 | 52 | ||
| 53 | $keys_list = rg_keys_list($db, $rg_ui); | ||
| 53 | $keys_list = rg_keys_list($db, $login_ui); | ||
| 54 | 54 | if ($keys_list === FALSE) | if ($keys_list === FALSE) |
| 55 | 55 | $_my_more['HTML:keys'] = rg_warning("Could not load keys. Try later."); // TODO | $_my_more['HTML:keys'] = rg_warning("Could not load keys. Try later."); // TODO |
| 56 | 56 | else | else |
| ... | ... | if ($rg_ssh_port != 0) | |
| 61 | 61 | $hints[]['HTML:hint'] = rg_template("hints/ssh/key.html", $_my_more); | $hints[]['HTML:hint'] = rg_template("hints/ssh/key.html", $_my_more); |
| 62 | 62 | $_my_more['HTML:hints'] = rg_template_table("hints/list", $hints, $_my_more); | $_my_more['HTML:hints'] = rg_template_table("hints/list", $hints, $_my_more); |
| 63 | 63 | ||
| 64 | $_my_more['rg_action'] = rg_re_post($cop); | ||
| 65 | 64 | $_my_more['rg_form_token'] = rg_token_get($db, $sid); | $_my_more['rg_form_token'] = rg_token_get($db, $sid); |
| 66 | 65 | $_my_more['key'] = $key; | $_my_more['key'] = $key; |
| 67 | 66 | ||
| File inc/user/pass/pass.php changed (mode: 100644) (index 28f3b0d..1370214) | |||
| ... | ... | if ($doit == 1) { | |
| 24 | 24 | break; | break; |
| 25 | 25 | } | } |
| 26 | 26 | ||
| 27 | if (!rg_user_pass_valid($db, $rg_ui['uid'], $old_pass)) { | ||
| 27 | if (!rg_user_pass_valid($db, $login_ui['uid'], $old_pass)) { | ||
| 28 | 28 | $errmsg[] = "old password is invalid"; | $errmsg[] = "old password is invalid"; |
| 29 | 29 | break; | break; |
| 30 | 30 | } | } |
| 31 | 31 | ||
| 32 | if (!rg_user_set_pass($db, $rg_ui['uid'], $pass1)) { | ||
| 32 | if (!rg_user_set_pass($db, $login_ui['uid'], $pass1)) { | ||
| 33 | 33 | $errmsg[] = rg_user_error(); | $errmsg[] = rg_user_error(); |
| 34 | 34 | break; | break; |
| 35 | 35 | } | } |
| ... | ... | if ($doit == 1) { | |
| 40 | 40 | } | } |
| 41 | 41 | ||
| 42 | 42 | if ($show_form == 1) { | if ($show_form == 1) { |
| 43 | $user_pass_more['rg_action'] = rg_re_post($cop); | ||
| 44 | 43 | $user_pass_more['HTML:errmsg'] = rg_template_errmsg($errmsg); | $user_pass_more['HTML:errmsg'] = rg_template_errmsg($errmsg); |
| 45 | 44 | $user_pass_more['rg_form_token'] = rg_token_get($db, $sid); | $user_pass_more['rg_form_token'] = rg_token_get($db, $sid); |
| 46 | 45 | $user_pass_more['old_pass'] = $old_pass; | $user_pass_more['old_pass'] = $old_pass; |
| File inc/user/repo-page.php changed (mode: 100644) (index 757ed81..86f6901) | |||
| ... | ... | rg_log("/inc/user/repo-page"); | |
| 3 | 3 | ||
| 4 | 4 | $_repo_page = ""; | $_repo_page = ""; |
| 5 | 5 | $repo_more = $more; | $repo_more = $more; |
| 6 | rg_log("DEBUG: repo_more: " . rg_array2string($repo_more)); | ||
| 6 | 7 | ||
| 7 | if (rg_user_ok($rr['user']) !== TRUE) { | ||
| 8 | if (rg_user_ok($user) !== TRUE) { | ||
| 8 | 9 | $_repo_page .= rg_warning("Invalid user!"); | $_repo_page .= rg_warning("Invalid user!"); |
| 9 | 10 | return; | return; |
| 10 | 11 | } | } |
| 11 | 12 | ||
| 12 | if (rg_repo_ok($rr['repo']) !== TRUE) { | ||
| 13 | if (rg_repo_ok($repo) !== TRUE) { | ||
| 13 | 14 | $_repo_page .= rg_warning("Invalid repo!"); | $_repo_page .= rg_warning("Invalid repo!"); |
| 14 | 15 | return; | return; |
| 15 | 16 | } | } |
| 16 | 17 | ||
| 17 | // Git dir is done asynchronous, loop till is OK | ||
| 18 | while (1) { | ||
| 19 | $ri = rg_repo_info($db, $rg_ui['uid'], 0, $rr['repo']); | ||
| 20 | if ($ri === FALSE) { | ||
| 21 | $_repo_page .= "Internal error!"; | ||
| 22 | return; | ||
| 23 | } | ||
| 18 | $ri = rg_repo_info($db, $login_ui['uid'], 0, $repo); | ||
| 19 | if ($ri === FALSE) { | ||
| 20 | $_repo_page .= rg_warning("Internal error!"); | ||
| 21 | return; | ||
| 22 | } | ||
| 24 | 23 | ||
| 25 | if (($ri['ok'] != 1) || ($ri['exists'] != 1) || ($ri['deleted'] == 1)) { | ||
| 26 | $_repo_page .= "Invalid repository!"; | ||
| 24 | if ($ri['git_dir_done'] == 0) { | ||
| 25 | // We will wait a little for the git dir to be done | ||
| 26 | // TODO: Should we really wait for this?! | ||
| 27 | // We may just consider that the repo is empty. Hm. | ||
| 28 | $ev_id = "repo_create-" . $login_ui['uid'] . "-" . $ri['repo_id'] . "-git"; | ||
| 29 | $timeout = 10; // seconds | ||
| 30 | $r = rg_event_signal_daemon($ev_id, $timeout); | ||
| 31 | if ($r === FALSE) { | ||
| 32 | // Seems we did not get the notification | ||
| 33 | $_repo_page .= rg_warning("Internal error!"); | ||
| 27 | 34 | return; | return; |
| 28 | 35 | } | } |
| 29 | |||
| 30 | if ($ri['git_dir_done'] == 1) | ||
| 31 | break; | ||
| 32 | |||
| 33 | rg_log("git dir is not ready yet. Sleep 1 second and loop."); | ||
| 34 | sleep(1); | ||
| 35 | rg_repo_invalidate_cache($rr); | ||
| 36 | 36 | } | } |
| 37 | 37 | ||
| 38 | 38 | // We must not allow access to a private repo (check for fetch) | // We must not allow access to a private repo (check for fetch) |
| 39 | if (rg_repo_allow($db, $ri, $rg_ui, "F") !== TRUE) { | ||
| 39 | if (rg_repo_allow($db, $ri, $login_ui, "F") !== TRUE) { | ||
| 40 | 40 | $_repo_page .= rg_warning("Not existent repo!"); | $_repo_page .= rg_warning("Not existent repo!"); |
| 41 | 41 | return; | return; |
| 42 | 42 | } | } |
| 43 | 43 | ||
| 44 | $page_ui = rg_user_info($db, 0, $rr['user'], ""); | ||
| 44 | $page_ui = rg_user_info($db, 0, $user, ""); | ||
| 45 | 45 | if ($page_ui === FALSE) { | if ($page_ui === FALSE) { |
| 46 | 46 | $_repo_page .= rg_warning("Invalid user!"); | $_repo_page .= rg_warning("Invalid user!"); |
| 47 | 47 | return; | return; |
| 48 | 48 | } | } |
| 49 | 49 | // TODO: should we test against $ri?! | // TODO: should we test against $ri?! |
| 50 | $can_admin = (rg_repo_allow($db, $ri, $rg_ui, "A") === TRUE) ? 1 : 0; | ||
| 50 | $can_admin = (rg_repo_allow($db, $ri, $login_ui, "A") === TRUE) ? 1 : 0; | ||
| 51 | 51 | ||
| 52 | $repo_more = array( | ||
| 53 | "owner" => $rr['user'], | ||
| 52 | $_t = array( | ||
| 53 | "owner" => $user, | ||
| 54 | 54 | "url_user" => rg_re_userpage($page_ui), | "url_user" => rg_re_userpage($page_ui), |
| 55 | "url_repo" => rg_re_repopage($page_ui, $rr['repo']), | ||
| 56 | "ssh" => rg_re_repo_ssh($rr), | ||
| 57 | "git" => rg_re_repo_git($rr), | ||
| 55 | "url_repo" => rg_re_repopage($page_ui, $repo), | ||
| 56 | "ssh" => rg_re_repo_ssh($organization, $user, $repo), | ||
| 57 | "git" => rg_re_repo_git($organization, $user, $repo), | ||
| 58 | 58 | "can_admin" => $can_admin | "can_admin" => $can_admin |
| 59 | 59 | ); | ); |
| 60 | $repo_more = array_merge($repo_more, $_t); | ||
| 60 | 61 | $repo_more = array_merge($repo_more, $ri); | $repo_more = array_merge($repo_more, $ri); |
| 61 | 62 | $repo_more['default_rights'] = implode(", ", rg_rights_text("repo", $ri['default_rights'])); | $repo_more['default_rights'] = implode(", ", rg_rights_text("repo", $ri['default_rights'])); |
| 62 | 63 | $repo_more['max_commit_size'] = $ri['max_commit_size'] == 0 ? "unlimited" : rg_1024($ri['max_commit_size']); | $repo_more['max_commit_size'] = $ri['max_commit_size'] == 0 ? "unlimited" : rg_1024($ri['max_commit_size']); |
| 63 | $repo_more['max_users'] = $ri['max_users'] == 0 ? "unlimited" : rg_1000($ri['max_users']); | ||
| 64 | $repo_more['max_users'] = $ri['max_users'] == 0 ? "unlimited" : $ri['max_users']; | ||
| 64 | 65 | $repo_more['hints'] = ""; | $repo_more['hints'] = ""; |
| 65 | 66 | ||
| 66 | 67 | $repo_path = rg_repo_path_by_id($ri['uid'], $ri['repo_id']); | $repo_path = rg_repo_path_by_id($ri['uid'], $ri['repo_id']); |
| ... | ... | if ($rg_git_port != 0) | |
| 81 | 82 | $urls[]['HTML:url'] = '<a href="' . $repo_more['git'] . '">' . $repo_more['git'] . '</a>'; | $urls[]['HTML:url'] = '<a href="' . $repo_more['git'] . '">' . $repo_more['git'] . '</a>'; |
| 82 | 83 | $repo_more['HTML:urls'] = rg_template_table("repo/urls", $urls, $repo_more); | $repo_more['HTML:urls'] = rg_template_table("repo/urls", $urls, $repo_more); |
| 83 | 84 | ||
| 84 | // default is "source" tab | ||
| 85 | if (empty($subop)) | ||
| 86 | $subop = "history"; | ||
| 85 | // default tab | ||
| 86 | $_subop = empty($paras) ? "history" : array_shift($paras); | ||
| 87 | 87 | ||
| 88 | if (strcmp($subop, "history") == 0) { | ||
| 88 | if (strcmp($_subop, "history") == 0) { | ||
| 89 | 89 | $hist = rg_repo_history_load($db, $ri['repo_id'], 0, 20, 0); | $hist = rg_repo_history_load($db, $ri['repo_id'], 0, 20, 0); |
| 90 | 90 | if ($hist === FALSE) | if ($hist === FALSE) |
| 91 | 91 | $_repo_body .= rg_warning("Cannot load history. Try again later."); | $_repo_body .= rg_warning("Cannot load history. Try again later."); |
| 92 | 92 | else | else |
| 93 | 93 | $_repo_body .= rg_template_table("repo/history", $hist, $repo_more); | $_repo_body .= rg_template_table("repo/history", $hist, $repo_more); |
| 94 | } else if (strcmp($subop, "admin") == 0) { | ||
| 94 | } else if (strcmp($_subop, "admin") == 0) { | ||
| 95 | 95 | include($INC . "/user/repo/admin/admin.php"); | include($INC . "/user/repo/admin/admin.php"); |
| 96 | 96 | $_repo_body .= $_admin; | $_repo_body .= $_admin; |
| 97 | } else if (strcmp($subop, "source") == 0) { | ||
| 98 | $subop = array_shift($paras); | ||
| 97 | } else if (strcmp($_subop, "source") == 0) { | ||
| 98 | $_subsubop = empty($paras) ? "" : array_shift($paras); | ||
| 99 | 99 | ||
| 100 | 100 | $type_ref = rg_git_parse_ref($paras); | $type_ref = rg_git_parse_ref($paras); |
| 101 | 101 | $ref = $type_ref['ref_path']; | $ref = $type_ref['ref_path']; |
| ... | ... | if (strcmp($subop, "history") == 0) { | |
| 114 | 114 | if (rg_rights_allow($ri['default_rights'], "H")) // anonymous push? | if (rg_rights_allow($ri['default_rights'], "H")) // anonymous push? |
| 115 | 115 | $hints[]['HTML:hint'] = rg_template("hints/repo/anon_push.html", $repo_more); | $hints[]['HTML:hint'] = rg_template("hints/repo/anon_push.html", $repo_more); |
| 116 | 116 | $repo_more['HTML:hints'] = rg_template_table("hints/list", $hints, $repo_more); | $repo_more['HTML:hints'] = rg_template_table("hints/list", $hints, $repo_more); |
| 117 | //rg_log("DEBUG: hints: " . $repo_more['HTML:hints']); | ||
| 118 | 117 | ||
| 119 | 118 | $_repo_body .= rg_template("repo/source.html", $repo_more); | $_repo_body .= rg_template("repo/source.html", $repo_more); |
| 120 | 119 | ||
| 121 | rg_log("DEBUG: subop=[$subop]"); | ||
| 122 | if (strcmp($subop, "tree") == 0) { | ||
| 120 | rg_log("DEBUG: _subsubop=[$_subsubop]"); | ||
| 121 | if (strcmp($_subsubop, "tree") == 0) { | ||
| 123 | 122 | $type = array_shift($paras); | $type = array_shift($paras); |
| 124 | 123 | rg_log("DEBUG: tree: type=$type"); | rg_log("DEBUG: tree: type=$type"); |
| 125 | 124 | if (strcmp($type, "blob") == 0) { | if (strcmp($type, "blob") == 0) { |
| ... | ... | if (strcmp($subop, "history") == 0) { | |
| 217 | 216 | } | } |
| 218 | 217 | } | } |
| 219 | 218 | $_repo_right = rg_template("repo/source_r.html", $repo_more); | $_repo_right = rg_template("repo/source_r.html", $repo_more); |
| 220 | } else if (strcmp($subop, "bug") == 0) { | ||
| 219 | } else if (strcmp($_subop, "bug") == 0) { | ||
| 221 | 220 | include($INC . "/user/repo/bug/main.php"); | include($INC . "/user/repo/bug/main.php"); |
| 222 | 221 | $_repo_body .= $bug_body; | $_repo_body .= $bug_body; |
| 223 | } else if (strcmp($subop, "stats") == 0) { | ||
| 222 | } else if (strcmp($_subop, "stats") == 0) { | ||
| 224 | 223 | $_repo_body .= rg_template("repo/stats.html", $repo_more); | $_repo_body .= rg_template("repo/stats.html", $repo_more); |
| 225 | } else if (strcmp($subop, "mr") == 0) { | ||
| 226 | if (empty($paras[0])) { | ||
| 224 | } else if (strcmp($_subop, "mr") == 0) { | ||
| 225 | if (empty($paras)) { | ||
| 227 | 226 | $_repo_body .= rg_template("repo/mrs.html", $repo_more); | $_repo_body .= rg_template("repo/mrs.html", $repo_more); |
| 228 | 227 | ||
| 229 | 228 | $r = rg_mr_load($db, $ri['repo_id'], 20); | $r = rg_mr_load($db, $ri['repo_id'], 20); |
| ... | ... | if (strcmp($subop, "history") == 0) { | |
| 234 | 233 | $_repo_body .= rg_template_table("repo/mr/list", $r, $repo_more); | $_repo_body .= rg_template_table("repo/mr/list", $r, $repo_more); |
| 235 | 234 | } | } |
| 236 | 235 | } else { | } else { |
| 237 | $mr = preg_replace('/[^0-9a-zA-Z_]/', '', $paras[0]); | ||
| 236 | $mr = preg_replace('/[^0-9a-zA-Z_]/', '', array_shift($paras)); | ||
| 238 | 237 | do { | do { |
| 239 | 238 | $mri = rg_mr_load_one($db, $ri['repo_id'], $mr); | $mri = rg_mr_load_one($db, $ri['repo_id'], $mr); |
| 240 | 239 | if ($mri === FALSE) { | if ($mri === FALSE) { |
| File inc/user/repo/admin/admin.php changed (mode: 100644) (index 1ef6589..3b46283) | |||
| ... | ... | rg_log("/inc/user/repo/admin/admin"); | |
| 4 | 4 | $_admin_body = ""; | $_admin_body = ""; |
| 5 | 5 | $repo_admin_more = $repo_more; | $repo_admin_more = $repo_more; |
| 6 | 6 | ||
| 7 | if (rg_repo_allow($db, $ri, $rg_ui, "A") !== TRUE) { | ||
| 7 | if (rg_repo_allow($db, $ri, $login_ui, "A") !== TRUE) { | ||
| 8 | 8 | // Probably the user is not logged in | // Probably the user is not logged in |
| 9 | 9 | $_url = rg_re_url("/op/login"); | $_url = rg_re_url("/op/login"); |
| 10 | 10 | rg_redirect($_url); | rg_redirect($_url); |
| ... | ... | if (rg_repo_allow($db, $ri, $rg_ui, "A") !== TRUE) { | |
| 12 | 12 | } | } |
| 13 | 13 | ||
| 14 | 14 | // TODO: we must set the url globally, in index.php! | // TODO: we must set the url globally, in index.php! |
| 15 | $_url_admin = rg_re_repopage($rg_ui, $rr['repo']) . "/admin"; | ||
| 15 | $_url_admin = rg_re_repopage($login_ui, $repo) . "/admin"; | ||
| 16 | 16 | ||
| 17 | 17 | $repo_admin_more = array_merge($repo_admin_more, $ri); | $repo_admin_more = array_merge($repo_admin_more, $ri); |
| 18 | 18 | $repo_admin_more['url_admin'] = $_url_admin; | $repo_admin_more['url_admin'] = $_url_admin; |
| 19 | 19 | ||
| 20 | $_op = empty($paras) ? "" : $paras[0]; | ||
| 20 | $_op = empty($paras) ? "" : array_shift($paras); | ||
| 21 | 21 | switch ($_op) { | switch ($_op) { |
| 22 | 22 | case 'edit': | case 'edit': |
| 23 | 23 | include($INC . "/user/repo/admin/edit/edit.php"); | include($INC . "/user/repo/admin/edit/edit.php"); |
| ... | ... | default: | |
| 45 | 45 | $_admin_menu = rg_template("repo/admin.html", $repo_admin_more); | $_admin_menu = rg_template("repo/admin.html", $repo_admin_more); |
| 46 | 46 | ||
| 47 | 47 | $_admin = $_admin_menu . $_admin_body; | $_admin = $_admin_menu . $_admin_body; |
| 48 | |||
| 49 | 48 | ?> | ?> |
| File inc/user/repo/admin/delete/delete.php changed (mode: 100644) (index c410e1d..c3c5010) | |||
| ... | ... | if ($doit == 1) { | |
| 20 | 20 | break; | break; |
| 21 | 21 | } | } |
| 22 | 22 | ||
| 23 | $r = rg_repo_delete($db, $ri['repo_id'], $rg_ui); | ||
| 23 | $r = rg_repo_delete($db, $ri['repo_id'], $login_ui); | ||
| 24 | 24 | if ($r === FALSE) { | if ($r === FALSE) { |
| 25 | 25 | $errmsg[] = rg_repo_error(); | $errmsg[] = rg_repo_error(); |
| 26 | 26 | break; | break; |
| File inc/user/repo/admin/edit/edit.php changed (mode: 100644) (index 4396929..57ead1a) | |||
| 1 | 1 | <?php | <?php |
| 2 | 2 | rg_log("/inc/user/repo/admin/edit/edit"); | rg_log("/inc/user/repo/admin/edit/edit"); |
| 3 | 3 | ||
| 4 | $_op = empty($paras) ? "" : array_shift($paras); | ||
| 5 | |||
| 4 | 6 | $_edit = ""; | $_edit = ""; |
| 5 | 7 | $repo_edit_more = $repo_admin_more; | $repo_edit_more = $repo_admin_more; |
| 8 | $_url_admin_edit = $_url_admin . "/edit"; | ||
| 6 | 9 | ||
| 7 | 10 | $errmsg = array(); | $errmsg = array(); |
| 8 | 11 | ||
| 9 | 12 | $_show_form = 1; | $_show_form = 1; |
| 10 | if ($doit == 1) { | ||
| 13 | if (strcmp($_op, "rename_done") == 0) { | ||
| 14 | $_edit .= rg_ok("The repository was updated with success!"); | ||
| 15 | $_show_form = 0; | ||
| 16 | } else if ($doit == 1) { | ||
| 11 | 17 | $repo_id = rg_var_uint("repo_id"); | $repo_id = rg_var_uint("repo_id"); |
| 12 | 18 | $master_repo_id = 0; | $master_repo_id = 0; |
| 13 | 19 | $name = rg_var_str("name"); | $name = rg_var_str("name"); |
| ... | ... | if ($doit == 1) { | |
| 23 | 29 | } | } |
| 24 | 30 | ||
| 25 | 31 | // lookup user | // lookup user |
| 26 | $_ui = rg_user_info($db, 0, $rr['user'], ""); | ||
| 32 | $_ui = rg_user_info($db, 0, $user, ""); | ||
| 27 | 33 | if ($_ui['ok'] != 1) { | if ($_ui['ok'] != 1) { |
| 28 | 34 | $errmsg[] = "internal error"; | $errmsg[] = "internal error"; |
| 29 | 35 | break; | break; |
| ... | ... | if ($doit == 1) { | |
| 45 | 51 | ||
| 46 | 52 | $_edit .= rg_ok("The repository was updated with success!"); | $_edit .= rg_ok("The repository was updated with success!"); |
| 47 | 53 | $_show_form = 0; | $_show_form = 0; |
| 54 | |||
| 55 | if ($_r['renamed'] == 1) { | ||
| 56 | $_url = rg_re_repopage($login_ui, $name) | ||
| 57 | . "/admin/edit/rename_done"; | ||
| 58 | rg_redirect($_url); | ||
| 59 | } | ||
| 48 | 60 | } while (0); | } while (0); |
| 49 | 61 | } else { | } else { |
| 50 | 62 | // load variables | // load variables |
| ... | ... | if ($doit == 1) { | |
| 58 | 70 | } | } |
| 59 | 71 | ||
| 60 | 72 | if ($_show_form == 1) { | if ($_show_form == 1) { |
| 61 | $_action = "Update"; | ||
| 62 | include($INC . "/repo/repo.form.php"); | ||
| 63 | $_edit .= $_form; | ||
| 73 | if ($master_repo_id > 0) { | ||
| 74 | $master_name = $master_repo_id; | ||
| 75 | $_mi = repo_info($db, $master_repo_id, ""); | ||
| 76 | if ($_mi['exists'] == 1) | ||
| 77 | $master_name = $_mi['name']; | ||
| 78 | $repo_edit_more['master_name'] = $master_name; | ||
| 79 | } else { | ||
| 80 | $repo_edit_more['master_name'] = ""; | ||
| 81 | } | ||
| 82 | |||
| 83 | $repo_edit_more['title'] = "Edit repository"; | ||
| 84 | $repo_edit_more['button'] = "Update"; | ||
| 85 | $repo_edit_more['name'] = $name; | ||
| 86 | $repo_edit_more['max_commit_size'] = $max_commit_size; | ||
| 87 | $repo_edit_more['max_users'] = $max_users; | ||
| 88 | $repo_edit_more['description'] = $description; | ||
| 89 | $repo_edit_more['master_repo_id'] = $master_repo_id; | ||
| 90 | $repo_edit_more['HTML:rights'] = rg_rights_checkboxes("repo", $rights); | ||
| 91 | $repo_edit_more['repo_id'] = $repo_id; | ||
| 92 | $repo_edit_more['HTML:errmsg'] = rg_template_errmsg($errmsg); | ||
| 93 | $repo_edit_more['rg_form_token'] = rg_token_get($db, $sid); | ||
| 94 | $_edit .= rg_template("repo/add_edit.html", $repo_edit_more); | ||
| 64 | 95 | } | } |
| 65 | 96 | ||
| 66 | 97 | ?> | ?> |
| File inc/user/repo/bug/add/add.php changed (mode: 100644) (index 846945a..6d79e85) | |||
| ... | ... | if ($doit == 0) { | |
| 41 | 41 | break; | break; |
| 42 | 42 | } | } |
| 43 | 43 | ||
| 44 | $bug_id = rg_bug_add($db, $ri['repo_id'], $rg_ui['uid'], $_x); | ||
| 44 | $bug_id = rg_bug_add($db, $ri['repo_id'], $login_ui['uid'], $_x); | ||
| 45 | 45 | if ($bug_id === FALSE) { | if ($bug_id === FALSE) { |
| 46 | 46 | $bug_errmsg[] = "Cannot add bug (" . rg_bug_error() . ")."; | $bug_errmsg[] = "Cannot add bug (" . rg_bug_error() . ")."; |
| 47 | 47 | break; | break; |
| ... | ... | if ($doit == 0) { | |
| 56 | 56 | $bug_add_more = array_merge($bug_add_more, $_x); | $bug_add_more = array_merge($bug_add_more, $_x); |
| 57 | 57 | $bug_add_more['HTML:bug_errmsg'] = rg_template_errmsg($bug_errmsg); | $bug_add_more['HTML:bug_errmsg'] = rg_template_errmsg($bug_errmsg); |
| 58 | 58 | $bug_add_more['bug_action'] = "Add bug"; | $bug_add_more['bug_action'] = "Add bug"; |
| 59 | $bug_add_more['rg_action'] = rg_re_post($cop); | ||
| 60 | 59 | $bug_add_more['rg_form_token'] = rg_token_get($db, $sid); | $bug_add_more['rg_form_token'] = rg_token_get($db, $sid); |
| 61 | $bug_add_more['HTML:state_select'] = rg_bug_state_select($_x['state']); | ||
| 60 | $_exclude = array(0); // exclude "Any" | ||
| 61 | $bug_add_more['HTML:state_select'] = rg_bug_state_select($_x['state'], $_exclude); | ||
| 62 | 62 | $_bug_add .= rg_template("repo/bug/bug_add.html", $bug_add_more); | $_bug_add .= rg_template("repo/bug/bug_add.html", $bug_add_more); |
| 63 | 63 | ?> | ?> |
| File inc/user/repo/bug/main.php changed (mode: 100644) (index 17d539b..a19b8f5) | |||
| ... | ... | rg_log("/inc/user/repo/bug/main"); | |
| 4 | 4 | $repo_bug_more = $repo_more; | $repo_bug_more = $repo_more; |
| 5 | 5 | $_bug_body = ""; | $_bug_body = ""; |
| 6 | 6 | ||
| 7 | $repo_bug_more['can_save'] = $rg_ui['uid'] > 0 ? 1 : 0; | ||
| 7 | $repo_bug_more['can_save'] = $login_ui['uid'] > 0 ? 1 : 0; | ||
| 8 | 8 | ||
| 9 | 9 | $_op = empty($paras) ? "list" : array_shift($paras); | $_op = empty($paras) ? "list" : array_shift($paras); |
| 10 | 10 | switch ($_op) { | switch ($_op) { |
| ... | ... | case 'list': /* list */ | |
| 29 | 29 | exit(1); // security_violation! | exit(1); // security_violation! |
| 30 | 30 | } | } |
| 31 | 31 | ||
| 32 | $r = rg_bug_search_remove($db, $ri['repo_id'], $rg_ui['uid'], | ||
| 32 | $r = rg_bug_search_remove($db, $ri['repo_id'], $login_ui['uid'], | ||
| 33 | 33 | $_search); | $_search); |
| 34 | 34 | if ($r === FALSE) | if ($r === FALSE) |
| 35 | 35 | $_bug_body .= rg_warning("Error: cannot delete search!"); // TODO | $_bug_body .= rg_warning("Error: cannot delete search!"); // TODO |
| 36 | 36 | } | } |
| 37 | 37 | ||
| 38 | $_url = rg_re_repopage($page_ui, $ri['name']) . "/bug"; | ||
| 39 | $r = rg_bug_search_load_all($db, $ri['repo_id'], $rg_ui['uid'], $_url); | ||
| 38 | $r = rg_bug_search_load_all($db, $ri['repo_id'], $login_ui['uid']); | ||
| 40 | 39 | if ($r === FALSE) { | if ($r === FALSE) { |
| 41 | 40 | $_bug_body .= rg_warning("Error: cannot load all searches!"); // TODO | $_bug_body .= rg_warning("Error: cannot load all searches!"); // TODO |
| 42 | 41 | } else { | } else { |
| ... | ... | case 'list': /* list */ | |
| 44 | 43 | $r, $repo_bug_more); | $r, $repo_bug_more); |
| 45 | 44 | } | } |
| 46 | 45 | ||
| 47 | $filter = rg_bug_search_load($db, $ri['repo_id'], $rg_ui['uid'], $_search); | ||
| 46 | $filter = rg_bug_search_load($db, $ri['repo_id'], $login_ui['uid'], $_search); | ||
| 48 | 47 | if ($filter === FALSE) { | if ($filter === FALSE) { |
| 49 | 48 | $_bug_body .= rg_warning("Error: cannot load search!"); // TODO | $_bug_body .= rg_warning("Error: cannot load search!"); // TODO |
| 50 | 49 | $filter = array(); | $filter = array(); |
| ... | ... | case 'list': /* list */ | |
| 53 | 52 | if (isset($filter['name'])) | if (isset($filter['name'])) |
| 54 | 53 | $repo_bug_more['search_name'] = $filter['name']; | $repo_bug_more['search_name'] = $filter['name']; |
| 55 | 54 | ||
| 56 | $r = rg_bug_search($db, $repo_bug_more['url_repo'], $ri['repo_id'], | ||
| 57 | $rg_ui['uid'], $filter); | ||
| 55 | $r = rg_bug_search($db, $ri['repo_id'], $login_ui['uid'], $filter); | ||
| 58 | 56 | if ($r === FALSE) | if ($r === FALSE) |
| 59 | 57 | $_bug_body .= rg_warning("Error: Cannot search bugs!"); // TODO: do something OK here! | $_bug_body .= rg_warning("Error: Cannot search bugs!"); // TODO: do something OK here! |
| 60 | 58 | else | else |
| 61 | $_bug_body .= $r; | ||
| 59 | $_bug_body .= rg_template_table("repo/bug/list", $r, $repo_bug_more); | ||
| 62 | 60 | ||
| 63 | 61 | // Show remove for custom search | // Show remove for custom search |
| 64 | 62 | if (isset($filter['standard']) && ($filter['standard'] == 0)) { | if (isset($filter['standard']) && ($filter['standard'] == 0)) { |
| 65 | 63 | $_remove_more = $repo_bug_more; | $_remove_more = $repo_bug_more; |
| 66 | $_remove_more['rg_action'] = $_url . "/list/" . $filter['name']; | ||
| 67 | 64 | $_remove_more['rg_form_token'] = rg_token_get($db, $sid); | $_remove_more['rg_form_token'] = rg_token_get($db, $sid); |
| 68 | 65 | $_remove_more['search_remove_errmsg'] = ""; | $_remove_more['search_remove_errmsg'] = ""; |
| 69 | 66 | $_bug_body .= rg_template("repo/bug/search/remove.html", | $_bug_body .= rg_template("repo/bug/search/remove.html", |
| ... | ... | case 'list': /* list */ | |
| 73 | 70 | ||
| 74 | 71 | default: // go directly to a bug | default: // go directly to a bug |
| 75 | 72 | $bug_id = intval($_op); | $bug_id = intval($_op); |
| 76 | if ($bug_id == 0) { | ||
| 77 | rg_log("BAD, invalid op=$_op!"); | ||
| 78 | } else { | ||
| 73 | if ($bug_id > 0) { | ||
| 79 | 74 | include($INC . "/user/repo/bug/show/show.php"); | include($INC . "/user/repo/bug/show/show.php"); |
| 80 | 75 | $_bug_body .= $_bug_show; | $_bug_body .= $_bug_show; |
| 81 | 76 | } | } |
| File inc/user/repo/bug/search/search.php changed (mode: 100644) (index e76bd77..8731370) | |||
| ... | ... | if ($doit == 0) { | |
| 19 | 19 | $_x['title_string'] = ""; | $_x['title_string'] = ""; |
| 20 | 20 | $_x['body_string'] = ""; | $_x['body_string'] = ""; |
| 21 | 21 | $_x['bugs_per_page'] = 25; | $_x['bugs_per_page'] = 25; |
| 22 | $_x['global'] = 0; | ||
| 22 | $_x['for_all_users'] = "off"; | ||
| 23 | $_x['global'] = "off"; | ||
| 23 | 24 | $_x['name'] = ""; | $_x['name'] = ""; |
| 24 | 25 | } else { | } else { |
| 25 | 26 | $_x['reported_by'] = rg_var_str("reported_by"); | $_x['reported_by'] = rg_var_str("reported_by"); |
| ... | ... | if ($doit == 0) { | |
| 33 | 34 | $_x['title_string'] = rg_var_str("title_string"); | $_x['title_string'] = rg_var_str("title_string"); |
| 34 | 35 | $_x['body_string'] = rg_var_str("body_string"); | $_x['body_string'] = rg_var_str("body_string"); |
| 35 | 36 | $_x['bugs_per_page'] = rg_var_uint("bugs_per_page"); | $_x['bugs_per_page'] = rg_var_uint("bugs_per_page"); |
| 36 | $_x['global'] = rg_var_uint("global"); | ||
| 37 | $_x['for_all_users'] = rg_var_str("for_all_users"); | ||
| 38 | $_x['global'] = rg_var_str("global"); | ||
| 37 | 39 | $_x['name'] = rg_var_str("name"); | $_x['name'] = rg_var_str("name"); |
| 40 | $_x['standard'] = 0; | ||
| 38 | 41 | ||
| 39 | 42 | do { | do { |
| 40 | /* | ||
| 41 | if (empty($_x['title'])) { | ||
| 42 | $bug_errmsg[] = "Title too short."; | ||
| 43 | break; | ||
| 44 | } | ||
| 45 | */ | ||
| 46 | |||
| 47 | $bugs = rg_bug_search($db, $_more['url_repo'], $ri['repo_id'], | ||
| 48 | $rg_ui['uid'], $_x); | ||
| 43 | $bugs = rg_bug_search($db, $ri['repo_id'], $login_ui['uid'], $_x); | ||
| 49 | 44 | if ($bugs === FALSE) { | if ($bugs === FALSE) { |
| 50 | 45 | $bug_errmsg[] = "Cannot search bug (" . rg_bug_error() . ")."; | $bug_errmsg[] = "Cannot search bug (" . rg_bug_error() . ")."; |
| 51 | 46 | break; | break; |
| 52 | 47 | } | } |
| 53 | 48 | ||
| 54 | 49 | // Show bugs | // Show bugs |
| 55 | $_bug_search .= $bugs; | ||
| 50 | $_bug_search .= rg_template_table("repo/bug/list", $bugs, | ||
| 51 | $bug_search_more); | ||
| 56 | 52 | } while (0); | } while (0); |
| 57 | 53 | } | } |
| 58 | 54 | ||
| 59 | 55 | $bug_search_more = array_merge($bug_search_more, $_x); | $bug_search_more = array_merge($bug_search_more, $_x); |
| 60 | 56 | $bug_search_more['HTML:bug_errmsg'] = rg_template_errmsg($bug_errmsg); | $bug_search_more['HTML:bug_errmsg'] = rg_template_errmsg($bug_errmsg); |
| 61 | $bug_search_more['rg_action'] = rg_re_post($cop); | ||
| 62 | $bug_search_more['HTML:state_select'] = rg_bug_state_select($_x['state']); | ||
| 57 | $_exclude = array(); | ||
| 58 | $bug_search_more['HTML:state_select'] = rg_bug_state_select($_x['state'], $_exclude); | ||
| 63 | 59 | $_bug_search .= rg_template("repo/bug/search/search.html", $bug_search_more); | $_bug_search .= rg_template("repo/bug/search/search.html", $bug_search_more); |
| 64 | 60 | ?> | ?> |
| File inc/user/repo/bug/show/show.php changed (mode: 100644) (index 0d6bf78..cfa6f1c) | |||
| ... | ... | if ($doit == 0) { | |
| 40 | 40 | // add note | // add note |
| 41 | 41 | $_d = array(); | $_d = array(); |
| 42 | 42 | $_d['note'] = $note; | $_d['note'] = $note; |
| 43 | $ret = rg_bug_note_add($db, $ri['repo_id'], $bug_id, $rg_ui['uid'], $_d); | ||
| 43 | $ret = rg_bug_note_add($db, $ri['repo_id'], $bug_id, $login_ui['uid'], $_d); | ||
| 44 | 44 | if ($ret === FALSE) { | if ($ret === FALSE) { |
| 45 | 45 | $note_errmsg[] = "Cannot add note (" . rg_bug_error() . ")"; | $note_errmsg[] = "Cannot add note (" . rg_bug_error() . ")"; |
| 46 | 46 | break; | break; |
| ... | ... | else | |
| 68 | 68 | // add note form | // add note form |
| 69 | 69 | $repo_bug_show_more['HTML:note_errmsg'] = rg_template_errmsg($note_errmsg); | $repo_bug_show_more['HTML:note_errmsg'] = rg_template_errmsg($note_errmsg); |
| 70 | 70 | ||
| 71 | $repo_bug_show_more['rg_action'] = rg_re_post($cop); | ||
| 72 | 71 | $repo_bug_show_more['rg_form_token'] = rg_token_get($db, $sid); | $repo_bug_show_more['rg_form_token'] = rg_token_get($db, $sid); |
| 73 | 72 | $repo_bug_show_more['note'] = $note; | $repo_bug_show_more['note'] = $note; |
| 74 | 73 | $repo_bug_show_more['HTML:note_add'] = rg_template("repo/bug/note_add.html", $repo_bug_show_more); | $repo_bug_show_more['HTML:note_add'] = rg_template("repo/bug/note_add.html", $repo_bug_show_more); |
| File inc/user/settings.php renamed from inc/user/personal.php (similarity 57%) (mode: 100644) (index 7fcad9b..3e7da32) | |||
| 1 | 1 | <?php | <?php |
| 2 | rg_log("/inc/user/personal"); | ||
| 2 | rg_log("/inc/user/settings"); | ||
| 3 | 3 | ||
| 4 | $_personal = ""; | ||
| 4 | $_settings = ""; | ||
| 5 | 5 | ||
| 6 | if ($rg_ui['uid'] == 0) { | ||
| 7 | $_personal .= "You have no access here!"; | ||
| 6 | if ($login_ui['uid'] == 0) { | ||
| 7 | $_settings .= rg_warning("You have no access here!"); | ||
| 8 | 8 | return; | return; |
| 9 | 9 | } | } |
| 10 | 10 | ||
| 11 | $errmsg = array(); | ||
| 12 | |||
| 13 | $_subop = empty($paras) ? "edit_info" : array_shift($paras); | ||
| 14 | |||
| 11 | 15 | // menu | // menu |
| 12 | $second_menu = array( | ||
| 16 | $_m = array( | ||
| 13 | 17 | "edit_info" => array( | "edit_info" => array( |
| 14 | 18 | "text" => "Edit info", | "text" => "Edit info", |
| 15 | 19 | "op" => "edit_info" | "op" => "edit_info" |
| 16 | ), | ||
| 20 | ), | ||
| 17 | 21 | "change_pass" => array( | "change_pass" => array( |
| 18 | 22 | "text" => "Change password", | "text" => "Change password", |
| 19 | 23 | "op" => "change_pass" | "op" => "change_pass" |
| 20 | ), | ||
| 24 | ), | ||
| 21 | 25 | "keys" => array( | "keys" => array( |
| 22 | 26 | "text" => "SSH keys", | "text" => "SSH keys", |
| 23 | 27 | "op" => "keys" | "op" => "keys" |
| 24 | ) | ||
| 28 | ) | ||
| 25 | 29 | ); | ); |
| 30 | rg_menu_add($rg_menu, $_m, $_subop); | ||
| 26 | 31 | ||
| 27 | $errmsg = array(); | ||
| 28 | |||
| 29 | if (empty($subop)) | ||
| 30 | $subop = "edit_info"; | ||
| 31 | |||
| 32 | switch ($subop) { | ||
| 32 | switch ($_subop) { | ||
| 33 | 33 | case 'edit_info': | case 'edit_info': |
| 34 | 34 | include($INC . "/user/info/info.php"); | include($INC . "/user/info/info.php"); |
| 35 | $_personal .= $_info; | ||
| 35 | $_settings .= $_info; | ||
| 36 | 36 | break; | break; |
| 37 | 37 | ||
| 38 | 38 | case 'change_pass': | case 'change_pass': |
| 39 | 39 | include($INC . "/user/pass/pass.php"); | include($INC . "/user/pass/pass.php"); |
| 40 | $_personal .= $_pass; | ||
| 40 | $_settings .= $_pass; | ||
| 41 | 41 | break; | break; |
| 42 | 42 | ||
| 43 | 43 | case 'keys': | case 'keys': |
| 44 | 44 | include($INC . "/user/keys/keys.php"); | include($INC . "/user/keys/keys.php"); |
| 45 | $_personal .= $_keys; | ||
| 45 | $_settings .= $_keys; | ||
| 46 | 46 | break; | break; |
| 47 | 47 | } | } |
| 48 | 48 | ||
| 49 | 49 | ?> | ?> |
| 50 | |||
| File inc/util.inc.php changed (mode: 100644) (index a0f3380..bbe1d5c) | |||
| ... | ... | function rg_re_bugpage($ui, $ri, $bug_id) | |
| 192 | 192 | return $_SERVER['PHP_SELF'] . "?vv=$s"; | return $_SERVER['PHP_SELF'] . "?vv=$s"; |
| 193 | 193 | } | } |
| 194 | 194 | ||
| 195 | function rg_re_repo_ssh($rr) | ||
| 195 | function rg_re_repo_ssh($organization, $user, $repo) | ||
| 196 | 196 | { | { |
| 197 | 197 | global $rg_ssh_host; | global $rg_ssh_host; |
| 198 | 198 | global $rg_ssh_port; | global $rg_ssh_port; |
| ... | ... | function rg_re_repo_ssh($rr) | |
| 201 | 201 | $port = ""; | $port = ""; |
| 202 | 202 | else | else |
| 203 | 203 | $port = ":" . $rg_ssh_port; | $port = ":" . $rg_ssh_port; |
| 204 | |||
| 205 | if ($organization == 1) | ||
| 206 | $prefix = "/org"; | ||
| 207 | else | ||
| 208 | $prefix = ""; | ||
| 209 | |||
| 204 | 210 | return "ssh://rocketgit@" . $rg_ssh_host . $port | return "ssh://rocketgit@" . $rg_ssh_host . $port |
| 205 | . $rr['prefix'] . "/" . $rr['user'] . "/" . $rr['repo']; | ||
| 211 | . $prefix . "/" . $user . "/" . $repo; | ||
| 206 | 212 | } | } |
| 207 | 213 | ||
| 208 | function rg_re_repo_git($rr) | ||
| 214 | function rg_re_repo_git($organization, $user, $repo) | ||
| 209 | 215 | { | { |
| 210 | 216 | global $rg_git_port; | global $rg_git_port; |
| 211 | 217 | ||
| ... | ... | function rg_re_repo_git($rr) | |
| 214 | 220 | else | else |
| 215 | 221 | $port = ":" . $rg_git_port; | $port = ":" . $rg_git_port; |
| 216 | 222 | ||
| 223 | if ($organization == 1) | ||
| 224 | $prefix = "/org"; | ||
| 225 | else | ||
| 226 | $prefix = ""; | ||
| 227 | |||
| 217 | 228 | return "git://" . $_SERVER['SERVER_NAME'] . $port | return "git://" . $_SERVER['SERVER_NAME'] . $port |
| 218 | . $rr['prefix'] . "/" . $rr['user'] . "/" . $rr['repo']; | ||
| 229 | . $prefix . "/" . $user . "/" . $repo; | ||
| 219 | 230 | } | } |
| 220 | 231 | ||
| 221 | 232 | function rg_var_str($name) | function rg_var_str($name) |
| ... | ... | function rg_rmdir($dir) | |
| 279 | 290 | rg_log("rmdir: $dir"); | rg_log("rmdir: $dir"); |
| 280 | 291 | ||
| 281 | 292 | if (!is_dir($dir)) { | if (!is_dir($dir)) { |
| 282 | rg_util_set_error("asked to remove a non-existing dir ($dir)"); | ||
| 283 | return FALSE; | ||
| 293 | rg_util_set_error("WARN: asked to remove a non-existing dir ($dir)"); | ||
| 294 | return TRUE; | ||
| 284 | 295 | } | } |
| 285 | 296 | ||
| 286 | 297 | $scan = glob($dir . "/*"); | $scan = glob($dir . "/*"); |
| ... | ... | function rg_rmdir($dir) | |
| 315 | 326 | return TRUE; | return TRUE; |
| 316 | 327 | } | } |
| 317 | 328 | ||
| 329 | /* | ||
| 330 | * Adds an submenu | ||
| 331 | * It is normal op to be empty | ||
| 332 | */ | ||
| 333 | function rg_menu_add(&$menu, $sub, $op) | ||
| 334 | { | ||
| 335 | //rg_log_ml("DEBUG: rg_menu_add (op=$op): " . print_r($sub, TRUE)); | ||
| 336 | |||
| 337 | if (isset($sub[$op])) | ||
| 338 | $sub[$op]['active'] = 1; | ||
| 339 | |||
| 340 | if (empty($menu)) { | ||
| 341 | $menu = $sub; | ||
| 342 | return; | ||
| 343 | } | ||
| 344 | |||
| 345 | // search for last active menu | ||
| 346 | foreach ($menu as $_op => $_info) { | ||
| 347 | if (!isset($_info['active'])) | ||
| 348 | continue; | ||
| 349 | |||
| 350 | if (!isset($_info['sub'])) { | ||
| 351 | // we found the correct place | ||
| 352 | $menu[$_op]['sub'] = $sub; | ||
| 353 | break; | ||
| 354 | } | ||
| 355 | |||
| 356 | // we are on parent of the correct menu | ||
| 357 | rg_menu_add($menu[$_op], $sub, $op); | ||
| 358 | break; | ||
| 359 | } | ||
| 360 | } | ||
| 361 | |||
| 318 | 362 | /* | /* |
| 319 | 363 | * Generates a menu | * Generates a menu |
| 320 | 364 | */ | */ |
| 321 | function rg_menu($a, $rg_ui, $op, $subop) | ||
| 365 | function rg_menu($a, $url, $ui) | ||
| 322 | 366 | { | { |
| 323 | rg_log("menu: op=$op subop=$subop"); | ||
| 367 | rg_log_ml("DEBUG: rg_menu: url=$url a=" . print_r($a, TRUE)); | ||
| 368 | |||
| 369 | $ret = array(); | ||
| 370 | $submenu = array(); | ||
| 324 | 371 | ||
| 325 | 372 | $menu = "<div class=\"menu\">\n"; | $menu = "<div class=\"menu\">\n"; |
| 326 | 373 | $menu .= "\t<ul>\n"; | $menu .= "\t<ul>\n"; |
| 327 | $menu2 = ""; | ||
| 328 | 374 | foreach ($a as $_id => $_info) { | foreach ($a as $_id => $_info) { |
| 329 | 375 | // we ignore fake menus like 'home' | // we ignore fake menus like 'home' |
| 330 | 376 | if (!isset($_info['text'])) | if (!isset($_info['text'])) |
| 331 | 377 | continue; | continue; |
| 332 | 378 | ||
| 333 | if (isset($_info['needs_admin']) && ($rg_ui['is_admin'] == 0)) | ||
| 379 | if (isset($_info['needs_admin']) && ($ui['is_admin'] == 0)) | ||
| 334 | 380 | continue; | continue; |
| 335 | 381 | ||
| 336 | if (isset($_info['uid0']) && ($rg_ui['uid'] > 0)) | ||
| 382 | if (isset($_info['uid0']) && ($ui['uid'] > 0)) | ||
| 337 | 383 | continue; | continue; |
| 338 | 384 | ||
| 339 | if (!isset($_info['uid0']) && ($rg_ui['uid'] == 0)) | ||
| 385 | if (!isset($_info['uid0']) && ($ui['uid'] == 0)) | ||
| 340 | 386 | continue; | continue; |
| 341 | 387 | ||
| 342 | 388 | $_text = $_info['text']; | $_text = $_info['text']; |
| 343 | $_url = rg_re_url($_info['op']); | ||
| 389 | $prefix = empty($url) ? "" : $url . "/"; | ||
| 390 | $_url = $prefix . rg_re_url($_info['op']); | ||
| 344 | 391 | //$menu .= "<!-- op=" . $_info['op'] . " url=$_url." . " -->\n"; | //$menu .= "<!-- op=" . $_info['op'] . " url=$_url." . " -->\n"; |
| 345 | 392 | ||
| 346 | 393 | //rg_log("\tDEBUG: compare with [" . $_info['op'] . "]"); | //rg_log("\tDEBUG: compare with [" . $_info['op'] . "]"); |
| 347 | 394 | $add = ""; | $add = ""; |
| 348 | if (strcmp($_info['op'], "/op/" . $op) == 0) | ||
| 395 | if (isset($_info['active'])) | ||
| 349 | 396 | $add = " class=\"selected\"";; | $add = " class=\"selected\"";; |
| 350 | 397 | $menu .= "\t\t<li><a href=\"" . $_url . "\"" . $add . ">" | $menu .= "\t\t<li><a href=\"" . $_url . "\"" . $add . ">" |
| 351 | 398 | . $_text . "</a></li>\n"; | . $_text . "</a></li>\n"; |
| ... | ... | function rg_menu($a, $rg_ui, $op, $subop) | |
| 353 | 400 | if (!isset($_info['sub']) || (count($_info['sub']) == 0)) | if (!isset($_info['sub']) || (count($_info['sub']) == 0)) |
| 354 | 401 | continue; | continue; |
| 355 | 402 | ||
| 356 | $menu2 .= "\t<div class=\"menu\">\n"; | ||
| 357 | $menu2 .= "\t<ul>\n"; | ||
| 358 | foreach ($_info['sub'] as $junk => $_info2) { | ||
| 359 | $_text2 = $_info2['text']; | ||
| 360 | $_url2 = $_url . "/" . $_info2['op']; | ||
| 361 | $add = ""; | ||
| 362 | //rg_log("\tDEBUG: compare with [" . $_info2['op'] . "]"); | ||
| 363 | if (strcmp($_info2['op'], $subop) == 0) | ||
| 364 | $add = " class=\"selected\"";; | ||
| 365 | $menu2 .= "\t\t<li><a href=\"" | ||
| 366 | . $_url2 | ||
| 367 | . "\"" . $add . ">" . $_text2 . "</a></li>\n"; | ||
| 368 | } | ||
| 369 | $menu2 .= "\t</ul>\n"; | ||
| 370 | $menu2 .= "\t</div>\n"; | ||
| 403 | // submenu | ||
| 404 | $submenu = rg_menu($_info['sub'], $_url, $ui); | ||
| 371 | 405 | } | } |
| 372 | 406 | $menu .= "\t</ul>\n"; | $menu .= "\t</ul>\n"; |
| 373 | 407 | $menu .= "\t</div>\n"; | $menu .= "\t</div>\n"; |
| 408 | $ret[] = $menu; | ||
| 374 | 409 | ||
| 375 | $ret = array(); | ||
| 376 | $ret[0] = $menu; | ||
| 377 | if (!empty($menu2)) | ||
| 378 | $ret[1] = $menu2; | ||
| 410 | if (!empty($submenu)) { | ||
| 411 | foreach ($submenu as $_index => $_menu) | ||
| 412 | $ret[] = $_menu; | ||
| 413 | } | ||
| 379 | 414 | ||
| 380 | 415 | return $ret; | return $ret; |
| 381 | 416 | } | } |
| 382 | 417 | ||
| 383 | 418 | /* | /* |
| 384 | * Provides a link to a image, taking in consideration the theme | ||
| 419 | * Provides a link to an image, taking in consideration the theme | ||
| 385 | 420 | * Used by rg_prepare_image. | * Used by rg_prepare_image. |
| 386 | 421 | */ | */ |
| 387 | 422 | function rg_image_callback($matches) | function rg_image_callback($matches) |
| ... | ... | function rg_redirect($url) | |
| 835 | 870 | exit(0); | exit(0); |
| 836 | 871 | } | } |
| 837 | 872 | ||
| 873 | /* | ||
| 874 | * Force browser to redirect to another page, using a HTML header | ||
| 875 | */ | ||
| 876 | function rg_redirect_html($seconds, $url) | ||
| 877 | { | ||
| 878 | global $more; | ||
| 879 | |||
| 880 | $more['rg_redirect_html'] = 1; | ||
| 881 | $more['rg_redirect_html_seconds'] = $seconds; | ||
| 882 | $more['rg_redirect_html_url'] = $url; | ||
| 883 | } | ||
| 884 | |||
| 838 | 885 | /* | /* |
| 839 | 886 | * Transforms strange chars to hexa | * Transforms strange chars to hexa |
| 840 | 887 | */ | */ |
| ... | ... | function rg_error_handler($no, $str, $file, $line) | |
| 978 | 1025 | $msg = "PHP ERROR: $file:$line: $str (errno=$no)"; | $msg = "PHP ERROR: $file:$line: $str (errno=$no)"; |
| 979 | 1026 | rg_log($msg); | rg_log($msg); |
| 980 | 1027 | ||
| 981 | mail("rg_error@embedromix.ro", $msg, | ||
| 982 | "", "", "-f $rg_admin_email"); | ||
| 1028 | mail("rg_error@embedromix.ro", "PHP ERROR", | ||
| 1029 | $msg | ||
| 1030 | . "\n" . rg_log_buffer(), | ||
| 1031 | "", "-f $rg_admin_email"); | ||
| 983 | 1032 | ||
| 984 | 1033 | if ($no == E_ERROR) | if ($no == E_ERROR) |
| 985 | 1034 | die(); | die(); |
| ... | ... | function rg_mail($template, $more) | |
| 1053 | 1102 | ||
| 1054 | 1103 | $subject = rg_template($template . ".subj.txt", $more); | $subject = rg_template($template . ".subj.txt", $more); |
| 1055 | 1104 | $subject = "=?UTF-8?B?" . base64_encode(trim($subject)) . "?="; | $subject = "=?UTF-8?B?" . base64_encode(trim($subject)) . "?="; |
| 1056 | $header = rg_template($template . ".head.txt", $more); | ||
| 1105 | $header = rg_template("mail/common.head.txt", $more); | ||
| 1106 | $header .= rg_template($template . ".head.txt", $more); | ||
| 1057 | 1107 | $body = rg_template($template . ".body.txt", $more); | $body = rg_template($template . ".body.txt", $more); |
| 1058 | 1108 | ||
| 1059 | $ret = mail($more['email'], $subject, $body, $header, "-f $rg_admin_email"); | ||
| 1109 | $ret = mail($more['ui.email'], $subject, $body, $header, "-f $rg_admin_email"); | ||
| 1060 | 1110 | if ($ret === FALSE) | if ($ret === FALSE) |
| 1061 | 1111 | rg_log("Sending mail failed!"); | rg_log("Sending mail failed!"); |
| 1062 | 1112 | ||
| ... | ... | function rg_mail($template, $more) | |
| 1064 | 1114 | return $ret; | return $ret; |
| 1065 | 1115 | } | } |
| 1066 | 1116 | ||
| 1117 | /* | ||
| 1118 | * Merges an array (a) into another (src), using a namespace | ||
| 1119 | */ | ||
| 1120 | function rg_array_merge($src, $namespace, $a) | ||
| 1121 | { | ||
| 1122 | $ret = $src; | ||
| 1123 | |||
| 1124 | if (empty($a)) | ||
| 1125 | return $ret; | ||
| 1126 | |||
| 1127 | foreach ($a as $k => $v) | ||
| 1128 | $ret[$namespace . "." . $k] = $v; | ||
| 1129 | |||
| 1130 | return $ret; | ||
| 1131 | } | ||
| 1132 | |||
| 1067 | 1133 | ?> | ?> |
| File rocketgit.spec.in changed (mode: 100644) (index ca06a83..e492886) | |||
| ... | ... | BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot | |
| 10 | 10 | BuildArch: noarch | BuildArch: noarch |
| 11 | 11 | Requires: httpd, php, php-cli, php-pgsql, php-gd, xinetd | Requires: httpd, php, php-cli, php-pgsql, php-gd, xinetd |
| 12 | 12 | Requires: shadow-utils, git, postgresql-server, policycoreutils-python | Requires: shadow-utils, git, postgresql-server, policycoreutils-python |
| 13 | Requires: util-linux | ||
| 13 | 14 | ||
| 14 | 15 | ||
| 15 | 16 | %description | %description |
| ... | ... | rm -rf ${RPM_BUILD_ROOT} | |
| 57 | 58 | %attr(0755,root,root) %config(noreplace) @ETC@/@PRJ@/config.php | %attr(0755,root,root) %config(noreplace) @ETC@/@PRJ@/config.php |
| 58 | 59 | %attr(0755,root,root) @ETC@/@PRJ@/config.php.sample | %attr(0755,root,root) @ETC@/@PRJ@/config.php.sample |
| 59 | 60 | %attr(0755,root,root) @ETC@/cron.d/rocketgit | %attr(0755,root,root) @ETC@/cron.d/rocketgit |
| 61 | %attr(0755,root,root) @ETC@/logrotate.d/rocketgit | ||
| 60 | 62 | %attr(0755,roor,root) %config(noreplace) @ETC@/xinetd.d/rocketgit | %attr(0755,roor,root) %config(noreplace) @ETC@/xinetd.d/rocketgit |
| 61 | 63 | %attr(0755,root,root) %config(noreplace) @ETC@/httpd/conf.d/rocketgit.conf | %attr(0755,root,root) %config(noreplace) @ETC@/httpd/conf.d/rocketgit.conf |
| 62 | %attr(0755,root,root) %config(noreplace) @ETC@/logrotate.d/rocketgit | ||
| 63 | 64 | %attr(0700,rocketgit,rocketgit) %dir @VAR_LOG@/@PRJ@ | %attr(0700,rocketgit,rocketgit) %dir @VAR_LOG@/@PRJ@ |
| 64 | 65 | %attr(0700,apache,apache) %dir @VAR_LOG@/@PRJ@-web | %attr(0700,apache,apache) %dir @VAR_LOG@/@PRJ@-web |
| 65 | 66 | %attr(0755,rocketgit,rocketgit) %dir @VAR_LIB@/@PRJ@ | %attr(0755,rocketgit,rocketgit) %dir @VAR_LIB@/@PRJ@ |
| File root/index.php changed (mode: 100644) (index 4b7768a..b4f0b6a) | |||
| ... | ... | rg_log_set_file($rg_web_log_dir . "/main.log"); | |
| 24 | 24 | ||
| 25 | 25 | // Init variables | // Init variables |
| 26 | 26 | $THEME_URL = "/themes/" . $rg_theme; | $THEME_URL = "/themes/" . $rg_theme; |
| 27 | $op = ""; $subop = ""; $subsubop = ""; $cop = ""; | ||
| 28 | $rr = array("user" => "", "repo" => "", "prefix" => ""); | ||
| 29 | $paras = array(); | ||
| 30 | $rg_ui = array(); | ||
| 27 | $sparas = ""; | ||
| 28 | $login_ui = array(); | ||
| 31 | 29 | ||
| 32 | 30 | // 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 |
| 33 | $vv = rg_var_str("vv"); | ||
| 34 | rg_log("DEBUG: vv=$vv."); | ||
| 35 | if (strcmp($vv, "/") == 0) { // main page for site (not for user) | ||
| 36 | $op = "main"; | ||
| 37 | } else if (strncmp($vv, "/op/", 4) == 0) { // command | ||
| 38 | $_t = substr($vv, 4); | ||
| 39 | $_t = explode("/", $_t); | ||
| 40 | $op = $_t[0]; | ||
| 41 | if (isset($_t[1])) { | ||
| 42 | $subop = $_t[1]; | ||
| 43 | if (isset($_t[2])) | ||
| 44 | $subsubop = $_t[2]; | ||
| 45 | } | ||
| 46 | $cop = rtrim("/op/" . $op . "/" . $subop . "/" . $subsubop, "/"); | ||
| 47 | } else { // user or organization | ||
| 48 | if (strncmp($vv, "/user/", 6) == 0) { | ||
| 49 | $vv6 = substr($vv, 6); | ||
| 50 | $rr['prefix'] = "/user"; | ||
| 51 | } else { | ||
| 52 | $vv6 = $vv; | ||
| 53 | $rr['prefix'] = ""; | ||
| 54 | } | ||
| 55 | $_t = explode("/", $vv6); | ||
| 56 | $rr['user'] = $_t[0]; | ||
| 57 | $op = "home-page"; | ||
| 58 | if (isset($_t[1])) { | ||
| 59 | $rr['repo'] = $_t[1]; | ||
| 60 | $op = "repo-page"; | ||
| 61 | |||
| 62 | if (isset($_t[2])) { | ||
| 63 | $subop = $_t[2]; | ||
| 64 | |||
| 65 | // pass rest of vv to lower layers | ||
| 66 | $i = 3; | ||
| 67 | while (isset($_t[$i])) { | ||
| 68 | $paras[] = $_t[$i]; | ||
| 69 | $i++; | ||
| 70 | } | ||
| 71 | } | ||
| 72 | } | ||
| 73 | $cop = $vv; | ||
| 31 | $sparas = rg_var_str("vv"); | ||
| 32 | rg_log("DEBUG: sparas=$sparas."); | ||
| 33 | $more['url'] = $sparas; | ||
| 34 | $paras = explode("/", trim($sparas, "/")); | ||
| 35 | $_t = empty($paras) ? "" : $paras[0]; | ||
| 36 | rg_log("DEBUG: paras: " . rg_array2string($paras)); | ||
| 37 | if (strcmp($_t, "op") == 0) { | ||
| 38 | array_shift($paras); | ||
| 39 | $_op = empty($paras) ? "" : array_shift($paras); | ||
| 40 | } else { | ||
| 41 | $_op = ""; | ||
| 74 | 42 | } | } |
| 75 | $more['url'] = $cop; | ||
| 76 | |||
| 77 | 43 | ||
| 78 | 44 | $doit = rg_var_uint("doit"); | $doit = rg_var_uint("doit"); |
| 79 | 45 | $sid = rg_var_re("sid", "/[^A-Za-z0-9]/"); | $sid = rg_var_re("sid", "/[^A-Za-z0-9]/"); |
| 80 | 46 | $token = rg_var_re("token", "/[^A-Za-z0-9]/"); | $token = rg_var_re("token", "/[^A-Za-z0-9]/"); |
| 47 | $user = ""; $repo = ""; $organization = 0; | ||
| 81 | 48 | ||
| 82 | 49 | rg_log("IP: " . @$_SERVER['REMOTE_ADDR']); | rg_log("IP: " . @$_SERVER['REMOTE_ADDR']); |
| 83 | 50 | rg_log("_REQUEST: " . rg_array2string($_REQUEST)); | rg_log("_REQUEST: " . rg_array2string($_REQUEST)); |
| 84 | 51 | rg_log("_COOKIE: " . rg_array2string($_COOKIE)); | rg_log("_COOKIE: " . rg_array2string($_COOKIE)); |
| 85 | rg_log("Start! cop=[$cop] op=$op subop=$subop subsubop=$subsubop" | ||
| 86 | . " doit=$doit sid=$sid rr: " . rg_array2string($rr)); | ||
| 87 | rg_log("paras: " . implode("|", $paras)); | ||
| 52 | rg_log("Start! sid=$sid"); | ||
| 88 | 53 | ||
| 89 | 54 | ||
| 90 | 55 | // database connection | // database connection |
| ... | ... | while (1) { | |
| 106 | 71 | sleep(1); | sleep(1); |
| 107 | 72 | } | } |
| 108 | 73 | ||
| 109 | rg_user_login_by_sid($db, $sid, $rg_ui); | ||
| 110 | rg_log("After login_by_sid, rg_ui=" . rg_array2string($rg_ui)); | ||
| 74 | rg_user_login_by_sid($db, $sid, $login_ui); | ||
| 75 | rg_log("After login_by_sid, login_ui=" . rg_array2string($login_ui)); | ||
| 111 | 76 | ||
| 112 | 77 | ||
| 113 | 78 | $body = ""; | $body = ""; |
| 114 | $second_menu = array(); | ||
| 115 | rg_log("Dispatching to [$op]"); | ||
| 116 | include($INC . "/dispatch/dispatch.php"); | ||
| 117 | |||
| 118 | |||
| 119 | // menu | ||
| 120 | $first_menu = array( | ||
| 79 | $rg_menu = array(); | ||
| 80 | // first level menu | ||
| 81 | $_m = array( | ||
| 121 | 82 | "login" => array( | "login" => array( |
| 122 | 83 | "text" => "Login", | "text" => "Login", |
| 123 | 84 | "uid0" => 1, | "uid0" => 1, |
| 124 | 85 | "op" => "/op/login"), | "op" => "/op/login"), |
| 125 | "home-page" => array( | ||
| 126 | "text" => "Home", | ||
| 127 | "op" => $rr['prefix'] . "/" . $rr['user']), | ||
| 128 | "personal" => array( | ||
| 129 | "text" => "Personal", | ||
| 130 | "op" => "/op/personal"), | ||
| 86 | "settings" => array( | ||
| 87 | "text" => "Settings", | ||
| 88 | "op" => "/op/settings"), | ||
| 131 | 89 | "repo" => array( | "repo" => array( |
| 132 | 90 | "text" => "Repositories", | "text" => "Repositories", |
| 133 | 91 | "op" => "/op/repo"), | "op" => "/op/repo"), |
| ... | ... | $first_menu = array( | |
| 142 | 100 | "text" => "Logout", | "text" => "Logout", |
| 143 | 101 | "op" => "/op/logout") | "op" => "/op/logout") |
| 144 | 102 | ); | ); |
| 145 | $first_menu[$op]['sub'] = $second_menu; | ||
| 146 | $more['HTML:rg_menu'] = implode("", rg_menu($first_menu, $rg_ui, $op, $subop)); | ||
| 103 | rg_menu_add($rg_menu, $_m, $_op); | ||
| 147 | 104 | ||
| 148 | if ($rg_ui['uid'] > 0) | ||
| 149 | $more['rg_username'] = $rg_ui['username']; | ||
| 150 | else | ||
| 105 | |||
| 106 | rg_log("Dispatching to [$_op]"); | ||
| 107 | include($INC . "/dispatch/dispatch.php"); | ||
| 108 | |||
| 109 | |||
| 110 | $_m = rg_menu($rg_menu, "", $login_ui); | ||
| 111 | $more['HTML:rg_menu'] = implode("", $_m); | ||
| 112 | |||
| 113 | if ($login_ui['uid'] > 0) { | ||
| 114 | $more['rg_username'] = $login_ui['username']; | ||
| 115 | $more['rg_homepage'] = rg_re_userpage($login_ui); | ||
| 116 | } else { | ||
| 151 | 117 | $more['rg_username'] = ""; | $more['rg_username'] = ""; |
| 118 | $more['rg_homepage'] = ""; | ||
| 119 | } | ||
| 152 | 120 | ||
| 121 | // home page | ||
| 153 | 122 | ||
| 154 | 123 | // Some variables from the database | // Some variables from the database |
| 155 | 124 | $r = rg_state_get_uint($db, "first_install"); | $r = rg_state_get_uint($db, "first_install"); |
| File root/themes/default/index.html changed (mode: 100644) (index d25643e..4c782a0) | |||
| 3 | 3 | <head> | <head> |
| 4 | 4 | <title>RocketGit</title> | <title>RocketGit</title> |
| 5 | 5 | <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> | <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> |
| 6 | @@if(@@rg_redirect_html@@ == 1){{<meta http-equiv="refresh" content="@@rg_redirect_html_seconds@@; url=@@rg_redirect_html_url@@">}}{{}} | ||
| 6 | 7 | <link rel="stylesheet" type="text/css" href="@@rg_theme_url@@/main.css" /> | <link rel="stylesheet" type="text/css" href="@@rg_theme_url@@/main.css" /> |
| 7 | 8 | </head> | </head> |
| 8 | 9 | ||
| 20 | 21 | ||
| 21 | 22 | @@if("@@rg_username@@" != ""){{ | @@if("@@rg_username@@" != ""){{ |
| 22 | 23 | <td> | <td> |
| 23 | <div class="user"><a href="/">@@rg_username@@</a></div> | ||
| 24 | <div class="user"><a href="@@rg_homepage@@">@@rg_username@@</a></div> | ||
| 24 | 25 | </td> | </td> |
| 25 | 26 | }}{{}} | }}{{}} |
| 26 | 27 | ||
| File root/themes/default/mail/common.head.txt copied from file root/themes/default/mail/user/key/del.head.txt (similarity 53%) (mode: 100644) (index 8f86db1..574dd76) | |||
| 1 | From: @@utf8_rg_admin_name@@ <@@rg_admin_email@@> | ||
| 2 | 1 | MIME-Version: 1.0 | MIME-Version: 1.0 |
| 3 | 2 | Content-type: text/plain; charset=UTF-8 | Content-type: text/plain; charset=UTF-8 |
| File root/themes/default/mail/user/key/del.head.txt changed (mode: 100644) (index 8f86db1..eec6d37) | |||
| 1 | 1 | From: @@utf8_rg_admin_name@@ <@@rg_admin_email@@> | From: @@utf8_rg_admin_name@@ <@@rg_admin_email@@> |
| 2 | MIME-Version: 1.0 | ||
| 3 | Content-type: text/plain; charset=UTF-8 | ||
| File root/themes/default/mail/user/key/new.head.txt changed (mode: 100644) (index 8f86db1..eec6d37) | |||
| 1 | 1 | From: @@utf8_rg_admin_name@@ <@@rg_admin_email@@> | From: @@utf8_rg_admin_name@@ <@@rg_admin_email@@> |
| 2 | MIME-Version: 1.0 | ||
| 3 | Content-type: text/plain; charset=UTF-8 | ||
| File root/themes/default/mail/user/repo/del.body.txt copied from file root/themes/default/mail/user/key/del.body.txt (similarity 63%) (mode: 100644) (index 0bd1a33..b782131) | |||
| 1 | 1 | Hello! | Hello! |
| 2 | 2 | ||
| 3 | A SSH key was removed from your account. | ||
| 3 | Repository '@@ri.name@@' was delete. | ||
| 4 | 4 | ||
| 5 | 5 | IP: @@IP@@ | IP: @@IP@@ |
| 6 | 6 | ||
| File root/themes/default/mail/user/repo/del.head.txt added (mode: 100644) (index 0000000..eec6d37) | |||
| 1 | From: @@utf8_rg_admin_name@@ <@@rg_admin_email@@> | ||
| File root/themes/default/mail/user/repo/del.subj.txt added (mode: 100644) (index 0000000..0df07b4) | |||
| 1 | '@@ri.name@@' repo was deleted | ||
| File root/themes/default/mail/user/repo/new.body.txt changed (mode: 100644) (index 60dae36..5cef38c) | |||
| 1 | 1 | Hello! | Hello! |
| 2 | 2 | ||
| 3 | Repository '@@name@@' was created. | ||
| 3 | Repository '@@ri.name@@' was created. | ||
| 4 | 4 | ||
| 5 | 5 | Anonymous rights: | Anonymous rights: |
| 6 | @@rights@@ | ||
| 6 | @@ri.rights_text@@ | ||
| 7 | 7 | ||
| 8 | 8 | Description: | Description: |
| 9 | @@description@@ | ||
| 9 | @@ri.description@@ | ||
| 10 | 10 | ||
| 11 | 11 | IP: @@IP@@ | IP: @@IP@@ |
| 12 | 12 | ||
| File root/themes/default/mail/user/repo/new.head.txt changed (mode: 100644) (index 8f86db1..eec6d37) | |||
| 1 | 1 | From: @@utf8_rg_admin_name@@ <@@rg_admin_email@@> | From: @@utf8_rg_admin_name@@ <@@rg_admin_email@@> |
| 2 | MIME-Version: 1.0 | ||
| 3 | Content-type: text/plain; charset=UTF-8 | ||
| File root/themes/default/mail/user/repo/new.subj.txt changed (mode: 100644) (index 21bd798..b6e53b6) | |||
| 1 | '@@name@@' repo was created | ||
| 1 | '@@ri.name@@' repo was created | ||
| File root/themes/default/mail/user/repo/update.body.txt added (mode: 100644) (index 0000000..ab12058) | |||
| 1 | Hello! | ||
| 2 | |||
| 3 | @@if(@@ri.old.name@@ != @@ri.name@@){{Repository '@@ri.old.name@@' was renamed to '@@ri.name@@.}}{{}} | ||
| 4 | @@if(@@ri.old.description_md5@@ != @@ri.description_md5@@){{ | ||
| 5 | Description changed to: | ||
| 6 | @@ri.description@@}}{{}} | ||
| 7 | @@if(@@ri.old.rights@@ != @@ri.rights@@){{ | ||
| 8 | New anonymous rights: | ||
| 9 | @@ri.rights_text@@ | ||
| 10 | }}{{}} | ||
| 11 | IP: @@IP@@ | ||
| 12 | |||
| 13 | Thank you! | ||
| 14 | |||
| 15 | -- | ||
| 16 | RocketGit Team | ||
| 17 | http://rocketgit.net | ||
| File root/themes/default/mail/user/repo/update.head.txt added (mode: 100644) (index 0000000..eec6d37) | |||
| 1 | From: @@utf8_rg_admin_name@@ <@@rg_admin_email@@> | ||
| File root/themes/default/mail/user/repo/update.subj.txt added (mode: 100644) (index 0000000..ee59d51) | |||
| 1 | '@@ri.old.name@@' repo was changed | ||
| File root/themes/default/mail/user/welcome.head.txt changed (mode: 100644) (index 8f86db1..eec6d37) | |||
| 1 | 1 | From: @@utf8_rg_admin_name@@ <@@rg_admin_email@@> | From: @@utf8_rg_admin_name@@ <@@rg_admin_email@@> |
| 2 | MIME-Version: 1.0 | ||
| 3 | Content-type: text/plain; charset=UTF-8 | ||
| File root/themes/default/repo/add_edit.html added (mode: 100644) (index 0000000..62c4daf) | |||
| 1 | <div class="formarea"> | ||
| 2 | |||
| 3 | <div class="formarea_title">@@title@@</div><br /> | ||
| 4 | |||
| 5 | @@errmsg@@ | ||
| 6 | |||
| 7 | <form method="post" action="@@url@@"> | ||
| 8 | <input type="hidden" name="repo_id" value="@@repo_id@@" /> | ||
| 9 | <input type="hidden" name="master_repo_id" value="@@master_repo_id@@" /> | ||
| 10 | <input type="hidden" name="doit" value="1" /> | ||
| 11 | <input type="hidden" name="token" value="@@rg_form_token@@" /> | ||
| 12 | |||
| 13 | @@if(@@master_name@@ != ){{Master repo: @@master_name@@<br />}}{{}} | ||
| 14 | |||
| 15 | <label for="name" class="form_item_title">Name</label><br /> | ||
| 16 | <input type="text" name="name" value="@@name@@" /> | ||
| 17 | <br /> | ||
| 18 | <br /> | ||
| 19 | |||
| 20 | <label for="max_commit_size" class="form_item_title">Max commit size (bytes)</label><br /> | ||
| 21 | <input type="text" name="max_commit_size" value="@@max_commit_size@@" /> | ||
| 22 | <br /> | ||
| 23 | <br /> | ||
| 24 | |||
| 25 | <label for="max_users" class="form_item_title">Max number of users</label><br /> | ||
| 26 | <input type="text" name="max_users" value="@@max_users@@" /> | ||
| 27 | <br /> | ||
| 28 | <br /> | ||
| 29 | |||
| 30 | <label for="description" class="form_item_title">Description</label><br /> | ||
| 31 | <textarea name="description" rows="4" cols="30">@@description@@</textarea> | ||
| 32 | <br /> | ||
| 33 | <br /> | ||
| 34 | |||
| 35 | |||
| 36 | <label for="default_rights" class="form_item_title">Default rights for anonymous access</label><br /> | ||
| 37 | (un-check all for private repositories)<br /> | ||
| 38 | @@rights@@ | ||
| 39 | <br /> | ||
| 40 | |||
| 41 | <input type="submit" name="button" value="@@button@@" /> | ||
| 42 | |||
| 43 | </form> | ||
| 44 | </div> | ||
| File root/themes/default/repo/bug/bug_add.html changed (mode: 100644) (index b99eeaf..a415abe) | |||
| 4 | 4 | ||
| 5 | 5 | @@bug_errmsg@@ | @@bug_errmsg@@ |
| 6 | 6 | ||
| 7 | <form method="post" action="@@rg_action@@"> | ||
| 7 | <form method="post" action="@@url@@"> | ||
| 8 | 8 | <input type="hidden" name="doit" value="1" /> | <input type="hidden" name="doit" value="1" /> |
| 9 | 9 | <input type="hidden" name="token" value="@@rg_form_token@@" /> | <input type="hidden" name="token" value="@@rg_form_token@@" /> |
| 10 | 10 | ||
| File root/themes/default/repo/bug/list/line.html changed (mode: 100644) (index 78d2600..7608c3d) | |||
| 1 | <!-- @@DUMP-DISABLED@@ --> | ||
| 2 | 1 | <tr> | <tr> |
| 3 | <td><a href="@@url_bug@@">@@bug_id@@</a></td> | ||
| 2 | <td><a href="@@url_repo@@/bug/@@bug_id@@">@@bug_id@@</a></td> | ||
| 4 | 3 | <td>@@creation@@</td> | <td>@@creation@@</td> |
| 5 | <td><a href="@@url_bug@@">@@title@@</a></td> | ||
| 4 | <td><a href="@@url_repo@@/bug/@@bug_id@@">@@title@@</a></td> | ||
| 6 | 5 | <td>@@state@@</td> | <td>@@state@@</td> |
| 7 | 6 | <td>@@owner@@</td> | <td>@@owner@@</td> |
| 8 | 7 | <td>@@assigned_to@@</td> | <td>@@assigned_to@@</td> |
| File root/themes/default/repo/bug/note_add.html changed (mode: 100644) (index f8b31e1..0f2c978) | |||
| 4 | 4 | ||
| 5 | 5 | @@note_errmsg@@ | @@note_errmsg@@ |
| 6 | 6 | ||
| 7 | <form method="post" action="@@rg_action@@"> | ||
| 7 | <form method="post" action="@@url@@"> | ||
| 8 | 8 | <input type="hidden" name="doit" value="1" /> | <input type="hidden" name="doit" value="1" /> |
| 9 | 9 | <input type="hidden" name="token" value="@@rg_form_token@@" /> | <input type="hidden" name="token" value="@@rg_form_token@@" /> |
| 10 | 10 | ||
| File root/themes/default/repo/bug/search/list/line.html changed (mode: 100644) (index 40decf0..d22fdf5) | |||
| 1 | <li>@@name@@</li> | ||
| 1 | <li><a href="@@url_repo@@/bug/list/@@name@@">@@name@@</a></li> | ||
| File root/themes/default/repo/bug/search/remove.html changed (mode: 100644) (index bd79288..e88e3a3) | |||
| 1 | 1 | @@search_remove_errmsg@@ | @@search_remove_errmsg@@ |
| 2 | 2 | ||
| 3 | <form method="post" action="@@rg_action@@"> | ||
| 3 | <form method="post" action="@@url@@"> | ||
| 4 | 4 | <input type="hidden" name="remove" value="1" /> | <input type="hidden" name="remove" value="1" /> |
| 5 | 5 | <input type="hidden" name="token" value="@@rg_form_token@@" /> | <input type="hidden" name="token" value="@@rg_form_token@@" /> |
| 6 | 6 | <input type="hidden" name="name" value="@@search_name@@" /> | <input type="hidden" name="name" value="@@search_name@@" /> |
| File root/themes/default/repo/bug/search/search.html changed (mode: 100644) (index 3afe7fb..b387d70) | |||
| 4 | 4 | ||
| 5 | 5 | @@bug_errmsg@@ | @@bug_errmsg@@ |
| 6 | 6 | ||
| 7 | <form method="post" action="@@rg_action@@"> | ||
| 7 | <form method="post" action="@@url@@"> | ||
| 8 | 8 | <input type="hidden" name="doit" value="1" /> | <input type="hidden" name="doit" value="1" /> |
| 9 | 9 | ||
| 10 | 10 | <label for="reported_by" class="form_item_title">Reported by</label><br /> | <label for="reported_by" class="form_item_title">Reported by</label><br /> |
| 54 | 54 | ||
| 55 | 55 | @@if(@@can_save@@ == 1){{ | @@if(@@can_save@@ == 1){{ |
| 56 | 56 | <label for="for_all_users" class="form_item_title">Make this search public (available for other users)?</label><br /> | <label for="for_all_users" class="form_item_title">Make this search public (available for other users)?</label><br /> |
| 57 | <input type="checkbox" name="for_all_users" @@if(@@for_all_users@@ == 1){{checked="checked"}}{{}} /> | ||
| 57 | <input type="checkbox" name="for_all_users"@@if(@@for_all_users@@ == on){{ checked="checked"}}{{}} /> | ||
| 58 | 58 | <br /> | <br /> |
| 59 | 59 | <br /> | <br /> |
| 60 | 60 | ||
| 61 | 61 | <label for="global" class="form_item_title">Make this search available also for other repos?</label><br /> | <label for="global" class="form_item_title">Make this search available also for other repos?</label><br /> |
| 62 | <input type="checkbox" name="global" @@if(@@global@@ == 1){{checked="checked"}}{{}} /> | ||
| 62 | <input type="checkbox" name="global"@@if(@@global@@ == on){{ checked="checked"}}{{}} /> | ||
| 63 | 63 | <br /> | <br /> |
| 64 | 64 | <br /> | <br /> |
| 65 | 65 | ||
| File root/themes/default/repo/not_init.html changed (mode: 100644) (index 2e2332a..868ead5) | |||
| 1 | 1 | <!-- This is shown when the repo contains no commit --> | <!-- This is shown when the repo contains no commit --> |
| 2 | 2 | ||
| 3 | <div class="warning"> | ||
| 3 | 4 | This repo contains no commits. | This repo contains no commits. |
| 5 | </div> | ||
| File root/themes/default/repo/search.html added (mode: 100644) (index 0000000..d712ad7) | |||
| 1 | <div class="formarea"> | ||
| 2 | |||
| 3 | <div class="formarea_title">Search for repositories</div><br /> | ||
| 4 | |||
| 5 | @@errmsg@@ | ||
| 6 | |||
| 7 | <form method="post" action="@@url@@"> | ||
| 8 | <input type="hidden" name="doit" value="1" /> | ||
| 9 | |||
| 10 | <label for="q" class="form_item_title">Keyword</label><br /> | ||
| 11 | <input type="text" name="q" value="@@q@@" /> | ||
| 12 | <br /> | ||
| 13 | <br /> | ||
| 14 | |||
| 15 | <input type="submit" name="button" value="Search" /> | ||
| 16 | |||
| 17 | </form> | ||
| 18 | </div> | ||
| File root/themes/default/suggestion.html added (mode: 100644) (index 0000000..2d5e2e5) | |||
| 1 | <div class="formarea"> | ||
| 2 | |||
| 3 | <div class="formarea_title">Send a suggestion</div><br /> | ||
| 4 | |||
| 5 | @@errmsg@@ | ||
| 6 | |||
| 7 | <form method="post" action="@@url@@"> | ||
| 8 | <input type="hidden" name="doit" value="1" /> | ||
| 9 | <input type="hidden" name="token" value="@@rg_form_token@@" /> | ||
| 10 | |||
| 11 | <label for="suggestion" class="form_item_title">Suggestion</label><br /> | ||
| 12 | <textarea name="suggestion" rows="6" cols="50">@@suggestion@@</textarea> | ||
| 13 | <br /> | ||
| 14 | <br /> | ||
| 15 | |||
| 16 | <input type="submit" name="button" value="Send" /> | ||
| 17 | |||
| 18 | </form> | ||
| 19 | </div> | ||
| File root/themes/default/user/forgot.html copied from file root/themes/default/user/pass.html (similarity 66%) (mode: 100644) (index ba0cc9c..9810fc2) | |||
| 4 | 4 | ||
| 5 | 5 | @@errmsg@@ | @@errmsg@@ |
| 6 | 6 | ||
| 7 | <form method="post" action="@@rg_action@@"> | ||
| 7 | <form method="post" action="@@url@@"> | ||
| 8 | <input type="hidden" name="forgot_token" value="@@forgot_token@@" /> | ||
| 8 | 9 | <input type="hidden" name="doit" value="1" /> | <input type="hidden" name="doit" value="1" /> |
| 9 | <input type="hidden" name="token" value="@@rg_form_token@@" /> | ||
| 10 | |||
| 11 | <label for="old_pass" class="form_item_title">Old password</label><br /> | ||
| 12 | <input type="password" name="old_pass" value="@@old_pass@@" /> | ||
| 13 | <br /> | ||
| 14 | <br /> | ||
| 15 | 10 | ||
| 16 | 11 | <label for="pass1" class="form_item_title">New password</label><br /> | <label for="pass1" class="form_item_title">New password</label><br /> |
| 17 | 12 | <input type="password" name="pass1" value="@@pass1@@" /> | <input type="password" name="pass1" value="@@pass1@@" /> |
| File root/themes/default/user/forgot_send.html added (mode: 100644) (index 0000000..00e018b) | |||
| 1 | <div class="formarea"> | ||
| 2 | |||
| 3 | <div class="formarea_title">Forgot password</div><br /> | ||
| 4 | |||
| 5 | @@errmsg@@ | ||
| 6 | |||
| 7 | <form method="post" action="@@url@@"> | ||
| 8 | <input type="hidden" name="doit" value="1" /> | ||
| 9 | |||
| 10 | <label for="email" class="form_item_title">E-mail</label><br /> | ||
| 11 | <input type="text" name="email" value="@@email@@" /> | ||
| 12 | <br /> | ||
| 13 | <br /> | ||
| 14 | |||
| 15 | <input type="submit" name="button" value="Recover password" /> | ||
| 16 | |||
| 17 | </form> | ||
| 18 | </div> | ||
| File root/themes/default/user/keys/add.html changed (mode: 100644) (index 3d06fe9..c70b229) | |||
| 4 | 4 | ||
| 5 | 5 | @@add_errmsg@@ | @@add_errmsg@@ |
| 6 | 6 | ||
| 7 | <form method="post" action="@@rg_action@@"> | ||
| 7 | <form method="post" action="@@url@@"> | ||
| 8 | 8 | <input type="hidden" name="add" value="1" /> | <input type="hidden" name="add" value="1" /> |
| 9 | 9 | <input type="hidden" name="token" value="@@rg_form_token@@" /> | <input type="hidden" name="token" value="@@rg_form_token@@" /> |
| 10 | 10 | ||
| File root/themes/default/user/keys/list/header.html changed (mode: 100644) (index 0d20c77..8fe9fa7) | |||
| 2 | 2 | ||
| 3 | 3 | @@del_errmsg@@ | @@del_errmsg@@ |
| 4 | 4 | ||
| 5 | <form method="post" action="@@rg_action@@"> | ||
| 5 | <form method="post" action="@@url@@"> | ||
| 6 | 6 | <input type="hidden" name="delete" value="1" /> | <input type="hidden" name="delete" value="1" /> |
| 7 | 7 | <input type="hidden" name="token" value="@@rg_form_token@@" /> | <input type="hidden" name="token" value="@@rg_form_token@@" /> |
| 8 | 8 | ||
| File root/themes/default/user/login.html changed (mode: 100644) (index 9fe9133..dac1e84) | |||
| 4 | 4 | ||
| 5 | 5 | @@errmsg@@ | @@errmsg@@ |
| 6 | 6 | ||
| 7 | <form method="post" action="@@rg_action@@"> | ||
| 8 | <input type="hidden" name="subop" value="1" /> | ||
| 7 | <form method="post" action="@@url@@"> | ||
| 9 | 8 | <input type="hidden" name="doit" value="1" /> | <input type="hidden" name="doit" value="1" /> |
| 10 | 9 | ||
| 11 | 10 | <label for="username" class="form_item_title">Username</label><br /> | <label for="username" class="form_item_title">Username</label><br /> |
| File root/themes/default/user/pass.html changed (mode: 100644) (index ba0cc9c..0d73a62) | |||
| 4 | 4 | ||
| 5 | 5 | @@errmsg@@ | @@errmsg@@ |
| 6 | 6 | ||
| 7 | <form method="post" action="@@rg_action@@"> | ||
| 7 | <form method="post" action="@@url@@"> | ||
| 8 | 8 | <input type="hidden" name="doit" value="1" /> | <input type="hidden" name="doit" value="1" /> |
| 9 | 9 | <input type="hidden" name="token" value="@@rg_form_token@@" /> | <input type="hidden" name="token" value="@@rg_form_token@@" /> |
| 10 | 10 | ||
| File samples/cron changed (mode: 100644) (index 85fa189..f423640) | |||
| 1 | 1 | * * * * * rocketgit php /usr/share/rocketgit/scripts/cron.php | * * * * * rocketgit php /usr/share/rocketgit/scripts/cron.php |
| 2 | 2 | * * * * * rocketgit php /usr/share/rocketgit/scripts/q.php | * * * * * rocketgit php /usr/share/rocketgit/scripts/q.php |
| 3 | * * * * * rocketgit php /usr/share/rocketgit/scripts/events.php | ||
| 3 | * * * * * rocketgit /usr/share/rocketgit/scripts/events.sh | ||
| File samples/logrotate changed (mode: 100644) (index 0b1bab5..24e5e14) | |||
| 1 | /var/log/rocketgit/*.log { | ||
| 2 | weekly | ||
| 3 | missingok | ||
| 4 | rotate 4 | ||
| 5 | compress | ||
| 6 | delaycompress | ||
| 7 | } | ||
| 8 | |||
| 9 | /var/log/rocketgit-web/*.log { | ||
| 10 | weekly | ||
| 11 | missingok | ||
| 12 | rotate 4 | ||
| 13 | compress | ||
| 14 | delaycompress | ||
| 15 | } | ||
| 1 | # Files will be rotated baesd on config.php file | ||
| File scripts/cron.php changed (mode: 100644) (index 14bf6af..d7e089c) | |||
| ... | ... | require_once($INC . "/keys.inc.php"); | |
| 17 | 17 | require_once($INC . "/fixes.inc.php"); | require_once($INC . "/fixes.inc.php"); |
| 18 | 18 | ||
| 19 | 19 | rg_log_set_file($rg_log_dir . "/cron.log"); | rg_log_set_file($rg_log_dir . "/cron.log"); |
| 20 | rg_log_set_sid("000000"); // to spread the logs | ||
| 20 | 21 | ||
| 21 | 22 | // locking | // locking |
| 22 | 23 | rg_lock_or_exit("cron.lock"); | rg_lock_or_exit("cron.lock"); |
| ... | ... | $r = rg_fixes_update($db); | |
| 38 | 39 | if ($r !== TRUE) | if ($r !== TRUE) |
| 39 | 40 | exit(1); | exit(1); |
| 40 | 41 | ||
| 41 | if (date("H") == 4) { | ||
| 42 | if (gmdate("H") == 4) { | ||
| 42 | 43 | do { | do { |
| 43 | 44 | rg_log("Compute repository sizes if dirty..."); | rg_log("Compute repository sizes if dirty..."); |
| 44 | 45 | // delete 'dirty' files | // delete 'dirty' files |
| ... | ... | if (date("H") == 4) { | |
| 94 | 95 | // TODO | // TODO |
| 95 | 96 | //rg_log("Sending notifications..."); | //rg_log("Sending notifications..."); |
| 96 | 97 | ||
| 97 | if (date("H") == 3) { | ||
| 98 | if (gmdate("H") == 3) { | ||
| 98 | 99 | rg_log("Clean old forget_pass entries..."); | rg_log("Clean old forget_pass entries..."); |
| 99 | 100 | $sql = "DELETE FROM forgot_pass WHERE expire < $now"; | $sql = "DELETE FROM forgot_pass WHERE expire < $now"; |
| 100 | 101 | $res = rg_sql_query($db, $sql); | $res = rg_sql_query($db, $sql); |
| 101 | 102 | rg_sql_free_result($res); | rg_sql_free_result($res); |
| 102 | 103 | } | } |
| 103 | 104 | ||
| 104 | if (date("H") == 1) { | ||
| 105 | if (gmdate("H") == 1) { | ||
| 105 | 106 | rg_log("Clean old tokens..."); | rg_log("Clean old tokens..."); |
| 106 | 107 | $sql = "DELETE FROM tokens WHERE expire < $now"; | $sql = "DELETE FROM tokens WHERE expire < $now"; |
| 107 | 108 | $res = rg_sql_query($db, $sql); | $res = rg_sql_query($db, $sql); |
| 108 | 109 | rg_sql_free_result($res); | rg_sql_free_result($res); |
| 109 | 110 | } | } |
| 110 | 111 | ||
| 111 | if (date("H") == 1) { | ||
| 112 | if (gmdate("H") == 1) { | ||
| 112 | 113 | rg_log("Clean old sess entries..."); | rg_log("Clean old sess entries..."); |
| 113 | 114 | $sql = "DELETE FROM sess WHERE expire < $now"; | $sql = "DELETE FROM sess WHERE expire < $now"; |
| 114 | 115 | $res = rg_sql_query($db, $sql); | $res = rg_sql_query($db, $sql); |
| 115 | 116 | rg_sql_free_result($res); | rg_sql_free_result($res); |
| 116 | 117 | } | } |
| 117 | 118 | ||
| 118 | if (date("H") == 2) | ||
| 119 | |||
| 120 | if (gmdate("H") == 4) | ||
| 119 | 121 | rg_sql_struct_slaves_update($db); | rg_sql_struct_slaves_update($db); |
| 120 | 122 | ||
| 123 | |||
| 121 | 124 | rg_keys_regen($db); | rg_keys_regen($db); |
| 122 | 125 | ||
| 123 | 126 | // Arhive deleted repositories | // Arhive deleted repositories |
| 124 | if (date("H") == 23) { | ||
| 127 | if (gmdate("H") == 23) { | ||
| 125 | 128 | //TODO: rg_log("Delete repositories..."); | //TODO: rg_log("Delete repositories..."); |
| 126 | 129 | } | } |
| 127 | 130 | ||
| File scripts/events.php changed (mode: 100644) (index ef1f324..226d58b) | |||
| ... | ... | require_once($INC . "/fixes.inc.php"); | |
| 27 | 27 | rg_prof_start("MAIN"); | rg_prof_start("MAIN"); |
| 28 | 28 | ||
| 29 | 29 | rg_log_set_file($rg_log_dir . "/events.log"); | rg_log_set_file($rg_log_dir . "/events.log"); |
| 30 | |||
| 31 | // locking | ||
| 32 | rg_lock_or_exit("events.lock"); | ||
| 30 | rg_log_set_sid("000000"); // to spread the logs | ||
| 33 | 31 | ||
| 34 | 32 | rg_log("Start..."); | rg_log("Start..."); |
| 35 | 33 | ||
| ... | ... | if (file_exists($rg_event_socket)) | |
| 52 | 50 | unlink($rg_event_socket); | unlink($rg_event_socket); |
| 53 | 51 | ||
| 54 | 52 | // Prepare socket for signaling | // Prepare socket for signaling |
| 55 | $socket = socket_create(AF_UNIX, SOCK_DGRAM, 0); | ||
| 53 | $socket = socket_create(AF_UNIX, SOCK_STREAM, 0); | ||
| 56 | 54 | if ($socket === FALSE) { | if ($socket === FALSE) { |
| 57 | 55 | rg_internal_error("Cannot create events socket!"); | rg_internal_error("Cannot create events socket!"); |
| 58 | 56 | exit(1); | exit(1); |
| ... | ... | if ($r === FALSE) { | |
| 64 | 62 | exit(1); | exit(1); |
| 65 | 63 | } | } |
| 66 | 64 | ||
| 65 | $r = socket_listen($socket, 128); | ||
| 66 | if ($r === FALSE) { | ||
| 67 | rg_internal_error("Cannot set queue length on socket!"); | ||
| 68 | exit(1); | ||
| 69 | } | ||
| 70 | |||
| 67 | 71 | // Allow apache to connect to socket | // Allow apache to connect to socket |
| 68 | 72 | $r = chmod($rg_event_socket, 0666); | $r = chmod($rg_event_socket, 0666); |
| 69 | 73 | if ($r === FALSE) { | if ($r === FALSE) { |
| ... | ... | if ($r === FALSE) { | |
| 78 | 82 | } | } |
| 79 | 83 | ||
| 80 | 84 | $original_mtime = filemtime(__FILE__); | $original_mtime = filemtime(__FILE__); |
| 85 | $notify_list = array(); | ||
| 81 | 86 | do { | do { |
| 82 | 87 | // Check our mtime so we can upgrade the software and this script | // Check our mtime so we can upgrade the software and this script |
| 83 | 88 | // will restart. | // will restart. |
| ... | ... | do { | |
| 92 | 97 | // check machine load - if too big we will delay | // check machine load - if too big we will delay |
| 93 | 98 | $load = rg_load(); | $load = rg_load(); |
| 94 | 99 | if ($load > 10) { | if ($load > 10) { |
| 95 | rg_log("\tLoad too big!"); | ||
| 100 | rg_log("\tLoad too big! Sleeping 10s."); | ||
| 96 | 101 | sleep(10); | sleep(10); |
| 97 | 102 | continue; | continue; |
| 98 | 103 | } | } |
| 99 | 104 | ||
| 100 | 105 | do { | do { |
| 101 | $r = rg_event_process_queue($db); | ||
| 106 | $r = rg_event_process_queue($db, $notify_list); | ||
| 102 | 107 | if ($r === FALSE) | if ($r === FALSE) |
| 103 | 108 | break; | break; |
| 104 | 109 | } while ($r > 0); | } while ($r > 0); |
| ... | ... | do { | |
| 107 | 112 | ||
| 108 | 113 | // Wait for signal | // Wait for signal |
| 109 | 114 | rg_log("Waiting for signal..."); | rg_log("Waiting for signal..."); |
| 110 | socket_recvfrom($socket, $buf, 1024, 0, $from); | ||
| 115 | $client = socket_accept($socket); | ||
| 116 | if ($client === FALSE) { | ||
| 117 | rg_log("Connection seems broken!"); | ||
| 118 | continue; | ||
| 119 | } | ||
| 120 | |||
| 121 | // TODO: this will be used with select | ||
| 122 | //socket_set_nonblock($client); | ||
| 123 | |||
| 124 | $close = 1; | ||
| 125 | $r = socket_recv($client, $buf, 1024, 0); | ||
| 126 | if ($r === 0) { // remote close the connection | ||
| 127 | rg_log("Remote closed the connection."); | ||
| 128 | } else if ($r === FALSE) { | ||
| 129 | $errno = socket_last_error($client); | ||
| 130 | rg_log("Error in receive (" . socket_strerror($errno) . ")."); | ||
| 131 | } else { | ||
| 132 | rg_log("Received $r byte(s): [$buf]."); | ||
| 133 | if (strncmp($buf, "NOTIFY ", 7) == 0) { | ||
| 134 | $ev_id = trim(substr($buf, 7)); | ||
| 135 | $notify_list[$ev_id][] = array("fd" => $client, "itime" => time()); | ||
| 136 | $close = 0; | ||
| 137 | |||
| 138 | // It is possible that we already executed the task | ||
| 139 | rg_event_notify($notify_list, $ev_id); | ||
| 140 | } | ||
| 141 | } | ||
| 142 | |||
| 143 | if ($close == 1) | ||
| 144 | socket_close($client); | ||
| 145 | |||
| 146 | // clean up notify_list | ||
| 147 | rg_event_notify_clean($notify_list); | ||
| 111 | 148 | } while (1); | } while (1); |
| 112 | 149 | ||
| 113 | 150 | socket_close($socket); | socket_close($socket); |
| 114 | 151 | ||
| 152 | rg_log("Exiting..."); | ||
| 153 | |||
| 115 | 154 | rg_prof_end("MAIN"); | rg_prof_end("MAIN"); |
| 116 | 155 | rg_prof_log("rg_log"); | rg_prof_log("rg_log"); |
| 117 | 156 | ?> | ?> |
| File scripts/events.sh added (mode: 100755) (index 0000000..640f032) | |||
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | # This is a wrapper for events.php, to not wait a lot after it exists | ||
| 4 | |||
| 5 | exec 100<>/var/lib/rocketgit/locks/events.lock | ||
| 6 | |||
| 7 | flock --exclusive --nonblock 100 | ||
| 8 | if [ "${?}" != "0" ]; then | ||
| 9 | exit 0 | ||
| 10 | fi | ||
| 11 | |||
| 12 | while [ 1 ]; do | ||
| 13 | php /usr/share/rocketgit/scripts/events.php | ||
| 14 | |||
| 15 | # in case of errors, we will wait, to not go into an infinite loop | ||
| 16 | if [ "${?}" != "0" ]; then | ||
| 17 | sleep 30 | ||
| 18 | fi | ||
| 19 | done | ||
| 20 | |||
| 21 | flock --unlock 100 | ||
| File scripts/q.php changed (mode: 100644) (index c213f44..082cc5b) | |||
| ... | ... | require_once($INC . "/fixes.inc.php"); | |
| 22 | 22 | rg_prof_start("MAIN"); | rg_prof_start("MAIN"); |
| 23 | 23 | ||
| 24 | 24 | rg_log_set_file($rg_log_dir . "/q.log"); | rg_log_set_file($rg_log_dir . "/q.log"); |
| 25 | rg_log_set_sid("000000"); // to spread the logs | ||
| 25 | 26 | ||
| 26 | 27 | // locking | // locking |
| 27 | 28 | rg_lock_or_exit("q.lock"); | rg_lock_or_exit("q.lock"); |
| ... | ... | while (TRUE) { | |
| 63 | 64 | continue; | continue; |
| 64 | 65 | } | } |
| 65 | 66 | ||
| 67 | // TODO: move it as an event and remove this script | ||
| 66 | 68 | rg_mr_queue_process($db); | rg_mr_queue_process($db); |
| 67 | 69 | ||
| 68 | rg_log("Check to create not-yet-created repos..."); | ||
| 69 | // Ordered by master to create masters first | ||
| 70 | $sql = "SELECT a.repo_id, a.master, a.name, b.username, b.organization" | ||
| 71 | . " FROM repos a, users b" | ||
| 72 | . " WHERE a.uid = b.uid" | ||
| 73 | . " AND a.deleted = 0" | ||
| 74 | . " AND a.git_dir_done = 0" | ||
| 75 | . " ORDER BY a.master"; | ||
| 76 | $res = rg_sql_query($db, $sql); | ||
| 77 | if ($res === FALSE) { | ||
| 78 | rg_log("\tCannot query (" . rg_sql_error() . ")!"); | ||
| 79 | exit(1); | ||
| 80 | } | ||
| 81 | |||
| 82 | while (($row = rg_sql_fetch_array($res))) | ||
| 83 | rg_repo_storage_create($db, $row); | ||
| 84 | |||
| 85 | rg_sql_free_result($res); | ||
| 86 | |||
| 87 | 70 | sleep(1); | sleep(1); |
| 88 | 71 | } | } |
| 89 | 72 | ||
| File scripts/wake.php added (mode: 100644) (index 0000000..04e15e6) | |||
| 1 | <?php | ||
| 2 | // This script wakes the event daemon | ||
| 3 | // Mostly used for debugging | ||
| 4 | error_reporting(E_ALL); | ||
| 5 | ini_set("track_errors", "On"); | ||
| 6 | |||
| 7 | $now = time(); | ||
| 8 | $_s = microtime(TRUE); | ||
| 9 | |||
| 10 | require_once("/etc/rocketgit/config.php"); | ||
| 11 | |||
| 12 | $INC = dirname(__FILE__) . "/../inc"; | ||
| 13 | require_once($INC . "/init.inc.php"); | ||
| 14 | require_once($INC . "/log.inc.php"); | ||
| 15 | require_once($INC . "/sql.inc.php"); | ||
| 16 | require_once($INC . "/struct.inc.php"); | ||
| 17 | require_once($INC . "/events.inc.php"); | ||
| 18 | require_once($INC . "/repo.inc.php"); | ||
| 19 | require_once($INC . "/prof.inc.php"); | ||
| 20 | require_once($INC . "/mr.inc.php"); | ||
| 21 | require_once($INC . "/keys.inc.php"); | ||
| 22 | require_once($INC . "/user.inc.php"); | ||
| 23 | require_once($INC . "/fixes.inc.php"); | ||
| 24 | |||
| 25 | rg_log_set_file($rg_log_dir . "/wake.log"); | ||
| 26 | rg_log_set_sid("000000"); // to spread the logs | ||
| 27 | |||
| 28 | rg_event_signal_daemon("", 0); | ||
| 29 | |||
| 30 | ?> | ||
| File tests/bug.php changed (mode: 100644) (index b0b7b48..4fa4747) | |||
| ... | ... | rg_log_set_file("bug.log"); | |
| 13 | 13 | ||
| 14 | 14 | $rg_sql_debug = 1; | $rg_sql_debug = 1; |
| 15 | 15 | ||
| 16 | // Defaults | ||
| 17 | $rg_admin_email = "rg@embedromix.ro"; | ||
| 18 | |||
| 16 | 19 | $db = rg_sql_open("dbname=trg"); | $db = rg_sql_open("dbname=trg"); |
| 17 | 20 | if ($db === FALSE) { | if ($db === FALSE) { |
| 18 | 21 | rg_log("Cannot create a database (" . rg_sql_error() . ")!"); | rg_log("Cannot create a database (" . rg_sql_error() . ")!"); |
| File tests/email.php changed (mode: 100644) (index 836fb25..e29020b) | |||
| ... | ... | $rg_theme = "default"; | |
| 11 | 11 | ||
| 12 | 12 | rg_log_set_file("email.log"); | rg_log_set_file("email.log"); |
| 13 | 13 | ||
| 14 | // Defaults | ||
| 15 | $rg_admin_email = "admin@embedromix.ro"; | ||
| 16 | $rg_admin_name = "Cătă"; | ||
| 17 | |||
| 14 | 18 | $more = array( | $more = array( |
| 15 | 19 | "to" => "xxx@embedromix.ro" | "to" => "xxx@embedromix.ro" |
| 16 | 20 | ); | ); |
| 17 | 21 | ||
| 18 | $rg_admin_email = "admin@embedromix.ro"; | ||
| 19 | $rg_admin_name = "Cătă"; | ||
| 20 | |||
| 21 | 22 | $r = rg_mail("mail/user/key/new", $more); | $r = rg_mail("mail/user/key/new", $more); |
| 22 | 23 | print_r($r); | print_r($r); |
| 23 | 24 | ?> | ?> |
| File tests/event.php changed (mode: 100644) (index 471bdfd..40813d0) | |||
| ... | ... | rg_log_set_file("event.log"); | |
| 16 | 16 | ||
| 17 | 17 | $rg_sql_debug = 1; | $rg_sql_debug = 1; |
| 18 | 18 | ||
| 19 | // Defaults | ||
| 20 | $rg_admin_email = "rg@embedromix.ro"; | ||
| 21 | |||
| 19 | 22 | $db = rg_sql_open("dbname=trg"); | $db = rg_sql_open("dbname=trg"); |
| 20 | 23 | if ($db === FALSE) { | if ($db === FALSE) { |
| 21 | 24 | rg_log("Cannot create a database (" . rg_sql_error() . ")!"); | rg_log("Cannot create a database (" . rg_sql_error() . ")!"); |
| ... | ... | if ($r !== TRUE) { | |
| 80 | 83 | $event = array( | $event = array( |
| 81 | 84 | "prio" => 1, | "prio" => 1, |
| 82 | 85 | "category" => 1, | "category" => 1, |
| 83 | "repo_id" => 200 | ||
| 86 | "ri.repo_id" => 200 | ||
| 84 | 87 | ); | ); |
| 85 | 88 | ||
| 86 | 89 | $r = rg_event_add($db, $event); | $r = rg_event_add($db, $event); |
| ... | ... | if ($r !== TRUE) { | |
| 89 | 92 | exit(1); | exit(1); |
| 90 | 93 | } | } |
| 91 | 94 | ||
| 92 | $r = rg_event_process_queue($db); | ||
| 95 | $notify_list = array(); | ||
| 96 | $r = rg_event_process_queue($db, $notify_list); | ||
| 93 | 97 | if ($r === FALSE) { | if ($r === FALSE) { |
| 94 | 98 | echo "Cannot process queue (" . rg_event_error() . ")!\n"; | echo "Cannot process queue (" . rg_event_error() . ")!\n"; |
| 95 | 99 | exit(1); | exit(1); |
| File tests/git.php changed (mode: 100644) (index ccf0775..36b9aba) | |||
| ... | ... | require_once($INC . "/git.inc.php"); | |
| 8 | 8 | ||
| 9 | 9 | rg_log_set_file("git.log"); | rg_log_set_file("git.log"); |
| 10 | 10 | ||
| 11 | // Defaults | ||
| 11 | 12 | $rg_scripts = "/usr/share/rocketgit"; | $rg_scripts = "/usr/share/rocketgit"; |
| 13 | $rg_admin_email = "rg@embedromix.ro"; | ||
| 12 | 14 | ||
| 13 | 15 | echo "[*] Checking if git-init works...\n"; | echo "[*] Checking if git-init works...\n"; |
| 14 | 16 | $r = rg_git_init("git.tmp"); | $r = rg_git_init("git.tmp"); |
| File tests/git2.php changed (mode: 100644) (index 10b0780..10b12e6) | |||
| ... | ... | require_once($INC . "/git.inc.php"); | |
| 8 | 8 | ||
| 9 | 9 | rg_log_set_file("git2.log"); | rg_log_set_file("git2.log"); |
| 10 | 10 | ||
| 11 | // Defaults | ||
| 11 | 12 | $rg_scripts = "/usr/share/rocketgit"; | $rg_scripts = "/usr/share/rocketgit"; |
| 13 | $rg_admin_email = "rg@embedromix.ro"; | ||
| 12 | 14 | ||
| 13 | 15 | system("./git2.sh"); | system("./git2.sh"); |
| 14 | 16 | ||
| File tests/keys.php changed (mode: 100644) (index 10a1832..6737510) | |||
| ... | ... | rg_log_set_file("keys.log"); | |
| 14 | 14 | ||
| 15 | 15 | $rg_sql_debug = 1; | $rg_sql_debug = 1; |
| 16 | 16 | ||
| 17 | // Defaults | ||
| 18 | $rg_admin_email = "rg@embedromix.ro"; | ||
| 19 | |||
| 17 | 20 | $db = rg_sql_open("dbname=trg"); | $db = rg_sql_open("dbname=trg"); |
| 18 | 21 | if ($db === FALSE) { | if ($db === FALSE) { |
| 19 | 22 | echo "Cannot create a database (" . rg_sql_error() . ")!\n"; | echo "Cannot create a database (" . rg_sql_error() . ")!\n"; |
| File tests/log.php changed (mode: 100644) (index 192a08b..5f1047c) | |||
| ... | ... | require_once($INC . "/log.inc.php"); | |
| 9 | 9 | ||
| 10 | 10 | rg_log_set_file("log.log"); | rg_log_set_file("log.log"); |
| 11 | 11 | ||
| 12 | // Defaults | ||
| 12 | 13 | $rg_scripts = "."; | $rg_scripts = "."; |
| 13 | 14 | $rg_theme = "util"; | $rg_theme = "util"; |
| 15 | $rg_admin_email = "rg@embedromix.ro"; | ||
| 14 | 16 | ||
| 15 | 17 | $n = "șacal\n\t"; | $n = "șacal\n\t"; |
| 16 | 18 | rg_log($n); | rg_log($n); |
| File tests/prof.php changed (mode: 100644) (index dfccd18..0843f82) | |||
| ... | ... | require_once($INC . "/prof.inc.php"); | |
| 10 | 10 | ||
| 11 | 11 | rg_log_set_file("prof.log"); | rg_log_set_file("prof.log"); |
| 12 | 12 | ||
| 13 | // Defaults | ||
| 14 | $rg_admin_email = "rg@embedromix.ro"; | ||
| 13 | 15 | ||
| 14 | 16 | rg_prof_start("label1"); | rg_prof_start("label1"); |
| 15 | 17 | sleep(.1); | sleep(.1); |
| File tests/repo.php changed (mode: 100644) (index 4663b0c..0f497be) | |||
| ... | ... | rg_log_set_file("repo.log"); | |
| 14 | 14 | $rg_sql_debug = 1; | $rg_sql_debug = 1; |
| 15 | 15 | ||
| 16 | 16 | // defaults | // defaults |
| 17 | $rg_admin_email = "rg@embedromix.ro"; | ||
| 17 | 18 | $rg_scripts = dirname(dirname(__FILE__)); | $rg_scripts = dirname(dirname(__FILE__)); |
| 18 | 19 | $rg_repo_max_len = 100; | $rg_repo_max_len = 100; |
| 19 | 20 | $rg_repos = "base"; | $rg_repos = "base"; |
| ... | ... | if ($r['ok'] != 1) { | |
| 151 | 152 | } | } |
| 152 | 153 | ||
| 153 | 154 | rg_log("Creating git folder."); | rg_log("Creating git folder."); |
| 154 | $r = rg_repo_storage_create($db, $ri); | ||
| 155 | $e = array(); | ||
| 156 | $e = rg_array_merge($e, "ri", $ri); | ||
| 157 | $e['ui.uid'] = $rg_ui['uid']; | ||
| 158 | $r = rg_repo_event_storage_create($db, $e); | ||
| 155 | 159 | if ($r !== TRUE) { | if ($r !== TRUE) { |
| 156 | 160 | echo "Cannot create storage dir (" . rg_repo_error() . ")!\n"; | echo "Cannot create storage dir (" . rg_repo_error() . ")!\n"; |
| 157 | 161 | exit(1); | exit(1); |
| ... | ... | if ($r['repo_id'] != 3000) { | |
| 249 | 253 | } | } |
| 250 | 254 | ||
| 251 | 255 | // Testing the rename of the repos | // Testing the rename of the repos |
| 252 | // Create history table | ||
| 253 | $sql = "CREATE TABLE repo_history_" . date("Y-m") . " INHERITS (repo_history)"; | ||
| 254 | $res = rg_sql_query($db, $sql); | ||
| 255 | if ($res === FALSE) { | ||
| 256 | echo "Cannot create repo_history table (" . rg_sql_error() . ")!\n"; | ||
| 257 | exit(1); | ||
| 258 | } | ||
| 259 | |||
| 260 | 256 | $rg_repos = "repos"; | $rg_repos = "repos"; |
| 261 | $r = mkdir($rg_repos . "/users/u/s/user-$uid/repos/by_id/$repo_id.git", 0755, TRUE); | ||
| 257 | $_path = rg_repo_path_by_id($uid, $repo_id); | ||
| 258 | $r = mkdir($_path, 0755, TRUE); | ||
| 262 | 259 | if ($r !== TRUE) { | if ($r !== TRUE) { |
| 263 | echo "Cannot create fake dir!\n"; | ||
| 260 | echo "Cannot create fake dir ($_path)!\n"; | ||
| 264 | 261 | exit(1); | exit(1); |
| 265 | 262 | } | } |
| 266 | $r = mkdir($rg_repos . "/users/u/s/user-$uid/repos/by_name", 0755, TRUE); | ||
| 263 | $_path = dirname(rg_repo_path_by_name($uid, $repo_name)); | ||
| 264 | $r = mkdir($_path, 0755, TRUE); | ||
| 267 | 265 | if ($r !== TRUE) { | if ($r !== TRUE) { |
| 268 | echo "Cannot create fake dir 2!\n"; | ||
| 266 | echo "Cannot create fake dir 2 ($_path)!\n"; | ||
| 269 | 267 | exit(1); | exit(1); |
| 270 | 268 | } | } |
| 271 | $rg_repo_max_len = 100; | ||
| 272 | $r = rg_repo_rename($db, $rg_ui['uid'], $repo_id, $repo_name, $repo_name . "-b"); | ||
| 273 | if ($r !== TRUE) { | ||
| 269 | $new = $ri; | ||
| 270 | $new['rights'] = "F"; | ||
| 271 | // Do first rename | ||
| 272 | $new['name'] = $repo_name . "b"; | ||
| 273 | $r = rg_repo_update($db, $rg_ui, $new); | ||
| 274 | if ($r === FALSE) { | ||
| 274 | 275 | echo "Cannot rename repository (" . rg_repo_error() . ")!\n"; | echo "Cannot rename repository (" . rg_repo_error() . ")!\n"; |
| 275 | 276 | exit(1); | exit(1); |
| 276 | 277 | } | } |
| 277 | 278 | // Do a second rename | // Do a second rename |
| 278 | $r = rg_repo_rename($db, $rg_ui['uid'], $repo_id, $repo_name, $repo_name . "-c"); | ||
| 279 | if ($r !== TRUE) { | ||
| 279 | $new['name'] = $repo_name . "c"; | ||
| 280 | $r = rg_repo_update($db, $rg_ui, $new); | ||
| 281 | if ($r === FALSE) { | ||
| 280 | 282 | echo "Cannot rename repository (" . rg_repo_error() . ")!\n"; | echo "Cannot rename repository (" . rg_repo_error() . ")!\n"; |
| 281 | 283 | exit(1); | exit(1); |
| 282 | 284 | } | } |
| File tests/rights.php changed (mode: 100644) (index 2863c50..bb48d34) | |||
| ... | ... | require_once($INC . "/rights.inc.php"); | |
| 8 | 8 | ||
| 9 | 9 | rg_log_set_file("rights.log"); | rg_log_set_file("rights.log"); |
| 10 | 10 | ||
| 11 | // Defaults | ||
| 12 | $rg_admin_email = "rg@embedromix.ro"; | ||
| 13 | |||
| 11 | 14 | rg_log("test if combine works correctly (1)"); | rg_log("test if combine works correctly (1)"); |
| 12 | 15 | $a = "AF"; $b = "AD"; $e = "AFD"; | $a = "AF"; $b = "AD"; $e = "AFD"; |
| 13 | 16 | $r = rg_rights_combine($a, $b); | $r = rg_rights_combine($a, $b); |
| File tests/sql.php changed (mode: 100644) (index d6e99ad..b393c12) | |||
| ... | ... | require_once($INC . "/sql.inc.php"); | |
| 9 | 9 | ||
| 10 | 10 | rg_log_set_file("sql.log"); | rg_log_set_file("sql.log"); |
| 11 | 11 | ||
| 12 | // Defaults | ||
| 13 | $rg_admin_email = "rg@embedromix.ro"; | ||
| 14 | |||
| 12 | 15 | echo "db: open connection...\n"; | echo "db: open connection...\n"; |
| 13 | 16 | $db = rg_sql_open("dbname=trg"); | $db = rg_sql_open("dbname=trg"); |
| 14 | 17 | if ($db === FALSE) { | if ($db === FALSE) { |
| File tests/state.php changed (mode: 100644) (index 867926e..a27948e) | |||
| ... | ... | require_once($INC . "/state.inc.php"); | |
| 11 | 11 | ||
| 12 | 12 | rg_log_set_file("state.log"); | rg_log_set_file("state.log"); |
| 13 | 13 | ||
| 14 | // Defaults | ||
| 15 | $rg_admin_email = "rg@embedromix.ro"; | ||
| 14 | 16 | $rg_sql_debug = 1; | $rg_sql_debug = 1; |
| 15 | 17 | $rg_lock_dir = "."; | $rg_lock_dir = "."; |
| 16 | 18 | ||
| File tests/user.php changed (mode: 100644) (index e6d935a..106b95f) | |||
| ... | ... | $rg_sql_debug = 1; | |
| 13 | 13 | ||
| 14 | 14 | rg_log_set_file("user.log"); | rg_log_set_file("user.log"); |
| 15 | 15 | ||
| 16 | // Defaults | ||
| 16 | 17 | $rg_repos = "ubase"; | $rg_repos = "ubase"; |
| 17 | 18 | $rg_user_max_len = 20; | $rg_user_max_len = 20; |
| 18 | 19 | $rg_session_time = 3600; | $rg_session_time = 3600; |
| 19 | 20 | $rg_user_allow = '/^[A-Za-z0-9_.-]*$/'; | $rg_user_allow = '/^[A-Za-z0-9_.-]*$/'; |
| 20 | $rg_admin_email = "admin@localhost"; | ||
| 21 | $rg_admin_email = "rg@embedromix.ro"; | ||
| 21 | 22 | $rg_admin_name = "RocketGit Admin"; | $rg_admin_name = "RocketGit Admin"; |
| 22 | 23 | $_SERVER['HTTP_HOST'] = "fake.tld"; | $_SERVER['HTTP_HOST'] = "fake.tld"; |
| 23 | 24 | ||
| File tests/util.php changed (mode: 100644) (index 2a3ed7e..81979dd) | |||
| ... | ... | require_once($INC . "/log.inc.php"); | |
| 9 | 9 | ||
| 10 | 10 | rg_log_set_file("util.log"); | rg_log_set_file("util.log"); |
| 11 | 11 | ||
| 12 | // Defaults | ||
| 12 | 13 | $rg_scripts = "."; | $rg_scripts = "."; |
| 13 | 14 | $rg_theme = "util"; | $rg_theme = "util"; |
| 14 | 15 | $rg_admin_email = "rg@embedromix.ro"; | $rg_admin_email = "rg@embedromix.ro"; |