";
}
$db = new mysqli(
MYSQL_HOSTNAME,
MYSQL_USERNAME,
MYSQL_PASSWORD,
MYSQL_DATABASE
);
if (mysqli_connect_errno()) {
die("Could not connect to database ".mysqli_connect_error());
}
$stmt = $db->prepare("SELECT handle FROM builds WHERE id = ?");
$stmt->bind_param("s", $buildID);
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows == 1) {
$stmt->bind_result($handle);
$stmt->fetch();
$stmt->close();
$client = new GearmanClient();
$client->addServer();
$status = $client->jobStatus($handle);
if ($status[0]) {
if ($status[3] != 0) {
$percentage = ceil($status[2]/$status[3]*100);
$bres = "Your build is currently running".
" and is ".$percentage."% complete";
$inprogress = true;
} else {
$bres = "Task has not yet been processed";
}
} else {
$query = "SELECT returncode, result ".
"FROM builds WHERE id = ?";
$stmt = $db->prepare($query);
$stmt->bind_param("s", $buildID);
$stmt->execute();
$stmt->bind_result($returncode, $result);
$stmt->fetch();
$stmt->close();
if ($returncode !== null) {
if ($returncode == 0) {
$bres = "Your build is complete! ".
"What would you like to do now?".
"
".
"";
$builddone = true;
} else {
$bres = "Job returned with code ".
$returncode.": ".$result;
}
} else {
$bres = "Job failed";
}
}
} else {
$stmt->close();
$bres = "Invalid handle hash";
}
$db->close();
if (!$builddone) {
$titleString = "How's things?";
} else {
$titleString = "It's showtime!";
}
?>