.
$apps = array();
$app_versions = array();
function app_version_string($id) {
global $apps, $app_versions;
if ($id == 0) return "";
if ($id == -1) return "Anonymous platform";
if (array_key_exists($id, $app_versions)) {
$av = $app_versions[$id];
$app = $apps[$av->appid];
} else {
$av = BoincAppVersion::lookup("id=$id");
$app_versions[$id] = $av;
$app = BoincApp::lookup_id($av->appid);
$apps[$av->appid] = $app;
}
$n = $app->user_friendly_name;
$v = sprintf("%d.%02d", $av->version_num/100, $av->version_num%100);
if ($av->plan_class) {
$c = "($av->plan_class)";
} else {
$c = "";
}
return "$n v$v $c";
}
function result_claimed_credit_string($result, $string_to_show) {
if ($result->server_state <> 5) return "---";
switch($result->outcome) {
case 3:
if ($result->exit_status <> -221) {
return $string_to_show; //Client error
}
default:
if ($result->claimed_credit > 0) {
return $string_to_show;
}
return "---"; // no claimed credit
}
}
function result_granted_credit_string($result, $string_to_show) {
if ($result->server_state <> 5) return "---";
switch($result->outcome) {
case 1: //Success
switch ($result->validate_state) {
case 0:
case 4:
return "pending";
}
return $string_to_show;
default:
if ($result->granted_credit > 0) {
return $string_to_show;
}
return "---"; // no claimed credit
}
}
// various states that we allow users to filter on
define("STATE_ALL", 0);
define("STATE_IN_PROGRESS", 1);
define("STATE_PENDING", 2);
define("STATE_VALID", 3);
define("STATE_INVALID", 4);
define("STATE_ERROR", 5);
define("NSTATES", 6);
$state_name = array(
"All",
"In progress",
"Pending",
"Valid",
"Invalid",
"Error",
);
$state_clause = array(
"",
" and server_state=4 ",
" and server_state=5 and outcome=1 and (validate_state=0 or validate_state=4) ",
" and server_state=5 and outcome=1 and validate_state=1 ",
" and server_state=5 and (outcome=6 or (outcome=1 and (validate_state=2 or validate_state=3 or validate_state=5))) ",
" and server_state=5 and (outcome=3 or outcome=4 or outcome=7) ",
);
function state_string($result) {
switch ($result->server_state) {
case 1: return "Inactive";
case 2: return "Unsent";
case 4: return "In progress";
case 5:
switch ($result->outcome) {
case 1:
switch ($result->validate_state) {
case 0: return "Completed, waiting for validation";
case 1: return "Completed and validated";
case 2: return "Completed, marked as invalid";
case 3: return "Completed, can't validate";
case 4: return "Completed, validation inconclusive";
case 5: return "Completed, too late to validate";
}
return "Completed";
case 2: return "Couldn't send";
case 3:
if ($result->exit_status == -221) {
return "Redundant result";
}
switch($result->client_state) {
case 1: return "Error while downloading";
case 2: return "Error while computing";
case 3: return "Error while computing";
case 4: return "Error while uploading";
case 6:
if ($result->exit_status == -221) {
return "Cancelled by server";
}
return "Aborted by user";
}
return "Error";
case 4: return "Timed out - no response";
case 5: return "Didn't need";
case 6: return "Validate error";
case 7: return "Client detached";
}
}
return "Unknown";
}
function result_server_state_string($result) {
switch($result->server_state) {
case 1: return "Inactive";
case 2: return "Unsent";
case 4: return "In progress";
case 5: return "Over";
}
return "Unknown";
}
function result_outcome_string($result) {
switch($result->outcome) {
case 0: return "---";
case 1: return "Success";
case 2: return "Couldn't send";
case 3:
if ($result->exit_status <> -221) {
return "Client error";
}
return "Redundant result";
case 4: return "No reply";
case 5: return "Didn't need";
case 6: return "Validate error";
case 7: return "Client detached";
}
return "Unknown";
}
function result_client_state_string($result) {
switch($result->client_state) {
case 0: return "New";
case 1: return "Downloading";
case 2: return "Computing";
case 3: return "Compute error";
case 4: return "Uploading";
case 5: return "Done";
case 6:
if ($result->exit_status == -221) {
return "Cancelled by server";
}
return "Aborted by user";
}
}
function validate_state_str($result) {
switch($result->validate_state) {
case 0: return "Initial";
case 1: return "Valid";
case 2:
if ($result->exit_status <> -221) {
return "Invalid";
}
return "Not necessary";
case 3: return "Workunit error - check skipped";
case 4: return "Checked, but no consensus yet";
case 5: return "Task was reported too late to validate";
}
return "Unknown";
}
function wu_error_mask_str($s) {
$x = "";
if ($s & 1) {
$x = $x."Couldn't send result ";
$s -= 1;
}
if ($s & 2) {
$x = $x."Too many error results ";
$s -= 2;
}
if ($s & 4) {
$x = $x."Too many success results ";
$s -= 4;
}
if ($s & 8) {
$x = $x."Too many total results ";
$s -= 8;
}
if ($s & 16) {
$x = $x."Cancelled ";
$s -= 16;
}
if ($s) {
$x = $x."Unrecognized Error: $s ";
}
if (!strlen($x)) {
$x="
";
}
return $x;
}
function result_page_url($info) {
$c = $info->clause;
$o = $info->offset;
$sn = $info->show_names;
$st = $info->state;
return "results.php?$c&offset=$o&show_names=$sn&state=$st";
}
function result_table_start($show_wu_link, $show_host_link, $info) {
start_table();
echo "
".htmlspecialchars($result->stderr_out).""); row2("Validate state", validate_state_str($result)); row2("Claimed credit", $result->claimed_credit); row2("Granted credit", $result->granted_credit); row2("application version", app_version_string($result->app_version_id)); end_table(); } function show_result_navigation($info) { global $state_name; echo "