.
// BOINC's remote job submission system allows users to:
// 1) manage a set of files on the server,
// with physical names that are isolated from other users
// 2) submit batches of jobs
//
// These features can be provided by a "portal" web site
// that is distinct from the BOINC server.
//
// This file contains library functions that can be used by portals.
// It communicates (using HTTP/XML) with the BOINC server.
//
// Functions:
// boinc_abort_batch(): abort a batch
// boinc_estimate_batch(); estimate completion time of a batch
// boinc_get_output_file(): get the URL for an output file
// boinc_get_output_files(): get the URL for zipped batch output
// boinc_query_batch(): get detaills of a batch
// boinc_query_batches(): get list of batches
// boinc_query_job(): get details of a job
// boinc_retire_batch(): retire a batch; delete output files
// boinc_submit_batch(): submit a batch
//// Implementation stuff follows
function req_to_xml($req, $op) {
$x = "<$op>
$req->authenticator$req->app_name$req->batch_name
";
foreach ($req->jobs as $job) {
$x .= " $job->rsc_fpops_est$job->command_line
";
foreach ($job->input_files as $file) {
$x .= "
";
}
$x .= "
";
}
$x .= "
$op>
";
return $x;
}
function validate_request($req) {
if (!is_object($req)) return "req is not an object";
if (!array_key_exists('project', $req)) return "missing req->project";
if (!array_key_exists('authenticator', $req)) return "missing req->authenticator";
if (!array_key_exists('app_name', $req)) return "missing req->app_name";
if (!array_key_exists('jobs', $req)) return "missing req->jobs";
if (!is_array($req->jobs)) return "req->jobs is not an array";
foreach ($req->jobs as $job) {
// other checks
}
return null;
}
function do_http_op($project, $xml) {
$ch = curl_init("$project/submit_rpc_handler.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "request=$xml");
$reply = curl_exec($ch);
if (!$reply) return array(null, "HTTP error");
$r = simplexml_load_string($reply);
if (!$r) return array(null, "Can't parse reply XML: