Exemplo n.º 1
0
function get_wu_output_file($wu_name, $file_num, $auth_str)
{
    $wu_name = BoincDb::escape_string($wu_name);
    $wu = BoincWorkunit::lookup("name='{$wu_name}'");
    if (!$wu) {
        die("no workunit {$wu_name}");
    }
    $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}");
    }
    if ($user->authenticator != $auth_str) {
        die("bad auth str: x={$x}, auth_str={$auth_str}");
    }
    $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);
    $path = dir_hier_path($names[$file_num], $upload_dir, $fanout);
    if (file_exists($path)) {
        do_download($path);
    } else {
        echo "no such file: {$path}";
    }
}
Exemplo n.º 2
0
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    ";
}