aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'web/testdrive.php')
-rw-r--r--web/testdrive.php69
1 files changed, 2 insertions, 67 deletions
diff --git a/web/testdrive.php b/web/testdrive.php
index a141af5..4c17bdd 100644
--- a/web/testdrive.php
+++ b/web/testdrive.php
@@ -1,71 +1,6 @@
<?php
-
- // Gentoaster web interface testdrive
- // Licensed under GPL v3, see COPYING file
-
- require_once "config.php";
-
- $buildID = filter_input(INPUT_GET, "uuid", FILTER_UNSAFE_RAW);
- $buildresult = "Unknown!";
- $inprogress = false;
-
- $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]) {
- header("Location: status.php?uuid=".$buildID);
- } 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) {
- // we're built, let's do this
- $client = new GearmanClient();
- $client->addServer();
- $server = $client->do(
- "invoke_start_image",
- $buildID
- );
- $server = unserialize($server);
- } else {
- header("Location: status.php?uuid=".$buildID);
- }
- } else {
- header("Location: status.php?uuid=".$buildID);
- }
- }
- } else {
- $stmt->close();
- die("Invalid handle hash");
- }
-
- $db->close();
+ require_once "config.php";
+ require_once GENTOASTER_PATH."/ui/testdrive.php";
?>
<html>
<head>