function process_batch($b) { $app = BoincApp::lookup_id($b->app_id); if (!$app) { echo "no app for batch {$b->id}\n"; return; } if ($b->fraction_done > 0 && $b->credit_canonical > 0) { $credit_total = $b->credit_canonical / $b->fraction_done; $fpops_total = $credit_total * (86400000000000.0 / 200); } else { $db = BoincDb::get(); $fpops_total = $db->sum("workunit", "rsc_fpops_est*target_nresults", "where batch={$b->id}"); } echo "batch {$b->id} fpops_total {$fpops_total}\n"; if ($fpops_total == 0) { return; } // adjust the user's logical start time // $user = BoincUser::lookup_id($b->user_id); if (!$user) { die("no user {$b->user_id}\n"); } $us = BoincUserSubmit::lookup_userid("{$user->id}"); if (!$us) { die("no user submit record\n"); } $lst = $us->logical_start_time; $cmd = "cd ../../bin; ./adjust_user_priority --user {$user->id} --flops {$fpops_total} --app {$app->name}"; system($cmd); $us = BoincUserSubmit::lookup_userid("{$user->id}"); $let = $us->logical_start_time; $let = (int) $let; // set the priority of workunits and results in this batch // to the user's new logical start time // $clause = "priority={$let} where batch={$b->id}"; BoincResult::update_aux($clause); BoincWorkunit::update_aux($clause); }
function authenticate_user($r, $app) { $auth = (string) $r->authenticator; if (!$auth) { error("no authenticator"); } $user = BoincUser::lookup("authenticator='{$auth}'"); if (!$user) { error("bad authenticator"); } $user_submit = BoincUserSubmit::lookup_userid($user->id); if (!$user_submit) { error("no submit access"); } if ($app && !$user_submit->submit_all) { $usa = BoincUserSubmitApp::lookup("user_id={$user->id} and app_id={$app->id}"); if (!$usa) { error("no submit access"); } } return array($user, $user_submit); }
$dir = sandbox_dir($user); list($error, $size, $md5) = sandbox_parse_link_file("{$dir}/{$name}"); if ($error) { error_page("no such link file"); } $p = sandbox_physical_path($user, $md5); if (!is_file($p)) { error_page("no such physical file"); } echo "<pre>\n"; readfile($p); echo "</pre>\n"; } $user = get_logged_in_user(); //print_r($user); $user_submit = BoincUserSubmit::lookup_userid($user->id); if (!$user_submit) { error_page("no job submission access"); } $action = get_str('action', true); if (!$action) { $action = post_str('action', true); } switch ($action) { case '': list_files($user, ""); break; case 'upload_file': upload_file($user); break; case 'delete_file':
function handle_add_action() { $user_id = get_int('user_id'); $user = BoincUser::lookup_id($user_id); if (!$user) { error_page("no such user"); } $us = BoincUserSubmit::lookup_userid($user_id); if (!$us) { if (!BoincUserSubmit::insert("(user_id) values ({$user_id})")) { error_page("Insert failed"); } } header("Location: manage_project.php?action=edit_form&user_id={$user_id}"); }
foreach ($batches as $batch) { if ($abort_all || get_str("abort_{$batch->id}", true)) { abort_batch($batch); } } page_head("Update successful"); echo "\n <a href=manage_app.php?app_id={$app->id}>Return to application management page</a>\n "; page_tail(); } $user = get_logged_in_user(); $app_id = get_int("app_id"); $app = BoincApp::lookup_id($app_id); if (!$app) { error_page("no such app"); } $bus = BoincUserSubmit::lookup_userid($user->id); if (!$bus) { error_page("no access"); } if (!$bus->manage_all) { $busa = BoincUserSubmitApp::lookup("user_id={$user->id} and app_id={$app_id}"); if (!$busa || !$busa->manage) { error_page("no access"); } } $action = get_str("action", true); switch ($action) { //case "": // main_page($app); break; case "app_version_form": app_version_form($app);
function eligible_apps() { global $user; $apps = BoincApp::enum("deprecated = 0"); $user_submit = BoincUserSubmit::lookup_userid($user->id); if (!$user_submit) { return null; } $a = array(); foreach ($apps as $app) { if ($user_submit->submit_all) { $a[] = $app; } else { if (BoincUserSubmitApp::lookup("user_id={$user->id} and app_id={$app->id}")) { $a[] = $app; } } } return $a; }
function check_access($user, $batch) { if ($user->id == $batch->user_id) { return; } $user_submit = BoincUserSubmit::lookup_userid($user->id); if ($user_submit->manage_all) { return; } $usa = BoincUserSubmitApp::lookup("user_id={$user->id} and app_id={$batch->app_id}"); if ($usa->manage) { return; } error_page("no access"); }