diff --git a/html/inc/submit_util.inc b/html/inc/submit_util.inc index 34f11eae03..281bede8d1 100644 --- a/html/inc/submit_util.inc +++ b/html/inc/submit_util.inc @@ -54,7 +54,25 @@ function job_file_name($md5) { return "jf_$md5"; } -function authenticate_user($r, $app) { +// does user have submit permissions? +// +function submit_permissions($user) { + return BoincUserSubmit::lookup_userid($user->id); +} + +// does user have submit permissions for given app? +// +function submit_permissions_app($user, $app) { + return BoincUserSubmitApp::lookup("user_id=$user->id and app_id=$app->id"); +} + +// check whether user has permissions for a remote job submission +// or job file request. +// $r is a request message that includes an 'authenticator' field +// $app is the app being submitted to (or null if file op) +// returns [user, UserSubmit], or give XML error +// +function check_remote_submit_permissions($r, $app) { $auth = (string)$r->authenticator; if (!$auth) { log_write("no authenticator"); @@ -66,13 +84,13 @@ function authenticate_user($r, $app) { log_write("bad authenticator"); xml_error(-1, "bad authenticator"); } - $user_submit = BoincUserSubmit::lookup_userid($user->id); + $user_submit = submit_permissions($user); if (!$user_submit) { log_write("no submit access"); xml_error(-1, "no submit access"); } if ($app && !$user_submit->submit_all) { - $usa = BoincUserSubmitApp::lookup("user_id=$user->id and app_id=$app->id"); + $usa = submit_permissions_app($user, $app); if (!$usa) { log_write("no app submit access"); xml_error(-1, "no app submit access"); diff --git a/html/user/job_file.php b/html/user/job_file.php index e8c711edb1..630bf442da 100644 --- a/html/user/job_file.php +++ b/html/user/job_file.php @@ -16,7 +16,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with BOINC. If not, see . -// Web RPCs for managing job input files on the server. +// Web RPCs for managing input files for remote job submission // // Issues: // @@ -99,7 +99,7 @@ function upload_error_description($errno) { function query_files($r) { xml_start_tag("query_files"); - list($user, $user_submit) = authenticate_user($r, null); + list($user, $user_submit) = check_remote_submit_permissions($r, null); $absent_files = array(); $now = time(); $delete_time = (int)$r->delete_time; @@ -175,7 +175,7 @@ function delete_uploaded_files() { function upload_files($r) { xml_start_tag("upload_files"); - list($user, $user_submit) = authenticate_user($r, null); + list($user, $user_submit) = check_remote_submit_permissions($r, null); $fanout = parse_config(get_config(), ""); $delete_time = (int)$r->delete_time; $batch_id = (int)$r->batch_id; diff --git a/html/user/sandbox.php b/html/user/sandbox.php index b648b15f53..536793e1bb 100644 --- a/html/user/sandbox.php +++ b/html/user/sandbox.php @@ -37,16 +37,17 @@ ini_set('display_startup_errors', true); require_once("../inc/sandbox.inc"); require_once("../inc/submit_db.inc"); +require_once("../inc/submit_util.inc"); function list_files($user, $err_msg) { $dir = sandbox_dir($user); $d = opendir($dir); if (!$d) error_page("Can't open sandbox directory"); - page_head("File sandbox for $user->name"); + page_head("File sandbox"); echo "
- Upload a file to your sandbox: + Upload files to your sandbox:

@@ -131,7 +132,7 @@ function upload_file($user) { $dir = sandbox_dir($user); $link_path = "$dir/$name"; sandbox_write_link_file($link_path, $size, $md5); - $notice .= "Successfully uploaded file $name!
"; + $notice .= "Uploaded file $name
"; } } list_files($user, $notice); @@ -186,9 +187,7 @@ function view_file($user) { } $user = get_logged_in_user(); -//print_r($user); -$user_submit = BoincUserSubmit::lookup_userid($user->id); -if (!$user_submit) error_page("no job submission access"); +if (!submit_permissions($user)) error_page("no job submission access"); $action = get_str('action', true); if (!$action) $action = post_str('action', true); diff --git a/html/user/submit.php b/html/user/submit.php index 9e59616320..1ea17f4c26 100644 --- a/html/user/submit.php +++ b/html/user/submit.php @@ -206,7 +206,7 @@ function handle_main($user) { if (isset($submit_urls)) { // show links to per-app job submission pages // - echo "

Submit jobs

+ echo "

Submit jobs