function show_batch($user) { $batch_id = get_int('batch_id'); $batch = BoincBatch::lookup_id($batch_id); if (!$batch || $batch->user_id != $user->id) { error_page("no batch"); } page_head("Batch {$batch->id}"); $results = BoincResult::enum("batch={$batch->id} order by workunitid"); $i = 0; result_table_start(true, true, null); foreach ($results as $result) { show_result_row($result, true, true, true, $i++); } end_table(); page_tail(); }
function get_wu_output_files($wu_id, $auth_str) { $wu = BoincWorkunit::lookup_id($wu_id); if (!$wu) { die("no workunit {$wu_id}"); } $batch = BoincBatch::lookup_id($wu->batch); if (!$batch) { die("no batch {$wu->batch}"); } $user = BoincUser::lookup_id($batch->user_id); if (!$user) { die("no user {$batch->user_id}"); } $x = md5($user->authenticator . $wu_id); echo "user authenticator= {$user->authenticator}, wu_id={$wu_id}<br/>"; if ($x != $auth_str) { die("bad auth str: x={$x}, auth_str={$auth_str}"); } $zip_basename = tempnam("/tmp", "boinc_wu_" . $wu->name . "_"); $zip_filename = $zip_basename . ".zip"; $fanout = parse_config(get_config(), "<uldl_dir_fanout>"); $upload_dir = parse_config(get_config(), "<upload_dir>"); if (!$wu->canonical_resultid) { die("no canonical result for wu {$wu->name}"); } $result = BoincResult::lookup_id($wu->canonical_resultid); $names = get_outfile_names($result); foreach ($names as $name) { $path = dir_hier_path($name, $upload_dir, $fanout); if (is_file($path)) { system("nice -9 zip -jq {$zip_basename} {$path}"); } } do_download($zip_filename); unlink($zip_filename); unlink($zip_basename); }
function handle_abort_jobs($r) { xml_start_tag("abort_jobs"); list($user, $user_submit) = authenticate_user($r, null); $batch = null; foreach ($r->job_name as $job_name) { $job_name = BoincDb::escape_string($job_name); $wu = BoincWorkunit::lookup("name='{$job_name}'"); if (!$wu) { xml_error(-1, "No job {$job_name}"); } if (!$wu->batch) { xml_error(-1, "Job {$job_name} is not part of a batch"); } if (!$batch || $wu->batch != $batch->id) { $batch = BoincBatch::lookup_id($wu->batch); } if (!$batch || $batch->user_id != $user->id) { xml_error(-1, "not owner"); } echo "<aborted {$job_name}>\n"; abort_workunit($wu); } echo "<success>1</success>\n </abort_jobs>\n "; }
function handle_retire_batch($user) { $batch_id = get_int('batch_id'); $batch = BoincBatch::lookup_id($batch_id); if (!$batch) { error_page("no such batch"); } check_access($user, $batch); retire_batch($batch); page_head("Batch retired"); echo "<p><a href=submit.php>Return to job control page</a>\n"; page_tail(); }
if (!$user_submit) { error("no submit access"); } $app = BoincApp::lookup("name='{$app_name}'"); if (!$app) { error("no tree_threader app"); } if (!$user_submit->submit_all) { $usa = BoincUserSubmitApp::lookup("user_id={$user->id} and app_id={$app->id}"); if (!$usa) { error("no submit access"); } } switch ((string) $r->action) { case 'submit': handle_submit($r, $user, $app); break; case 'get_output': $batch_id = (int) $r->batch_id; $batch = BoincBatch::lookup_id($batch_id); if (!$batch) { error("no such batch"); } if ($batch->user_id != $user->id) { error("not owner of batch"); } handle_get_output($r, $batch); break; default: error("bad command"); }
function handle_retire_batch($r) { list($user, $user_submit) = authenticate_user($r, null); $batch_id = (int) $r->batch_id; $batch = BoincBatch::lookup_id($batch_id); if ($batch->user_id != $user->id) { error("not owner"); } retire_batch($batch); echo "<success>1</success>"; }