aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'web/status.php')
-rw-r--r--web/status.php135
1 files changed, 79 insertions, 56 deletions
diff --git a/web/status.php b/web/status.php
index 7371c16..20aacec 100644
--- a/web/status.php
+++ b/web/status.php
@@ -1,38 +1,55 @@
<?php
- $build_id = $_GET["uuid"];
- $buildresult = "Unknown!";
- $inprogress = false;
- $builddone = false;
+ $buildID = $_GET["uuid"];
+ $buildresult = "Unknown!";
+ $inprogress = false;
+ $builddone = false;
- $db = mysql_connect("localhost","gentoaster","");
- if(!$db) die("Could not connect to database ".mysql_error()."\n");
+ $db = mysql_connect("localhost", "gentoaster", "");
+ if (!$db) die("Could not connect to database ".mysql_error()."\n");
mysql_select_db("gentoaster");
- $result = mysql_query("SELECT handle FROM builds WHERE id = '".mysql_real_escape_string($build_id)."'");
- if(mysql_num_rows($result) == 1) {
+ $query = "SELECT handle FROM builds ".
+ "WHERE id = '".mysql_real_escape_string($buildID)."'";
+ $result = mysql_query($query);
+ if (mysql_num_rows($result) == 1) {
$handles = mysql_fetch_array($result);
$handle = $handles[0];
$client = new GearmanClient();
$client->addServer();
$status = $client->jobStatus($handle);
- if($status[0]) {
- if($status[3] != 0) {
+ if ($status[0]) {
+ if ($status[3] != 0) {
$percentage = ceil($status[2]/$status[3]*100);
- $buildresult = "Your build is currently running and is ".$percentage."% complete";
+ $buildresult = "Your build is currently running".
+ " and is ".$percentage."% complete";
$inprogress = true;
} else {
$buildresult = "Task has not yet been processed";
}
} else {
- $result = mysql_query("SELECT returncode, result FROM builds WHERE id = '".mysql_real_escape_string($build_id)."'");
+ $cleanBuildID = mysql_real_escape_string($buildID);
+ $query = "SELECT returncode, result FROM builds ".
+ "WHERE id = '".$cleanBuildID."'";
+ $result = mysql_query($query);
$jobres = mysql_fetch_array($result);
- if($jobres[0] !== NULL) {
- if($jobres[0] == 0) {
- $buildresult = "Your build is complete! What would you like to do now?<br /><br /><center><table><tr><td><a href=\"/gentoaster/".$build_id."/".$build_id.".tar.gz\"><img style=\"padding: 10px;\" src=\"img/icons/download.png\"></a></td><td><a href=\"testdrive.php?uuid=".$build_id."\"><img style=\"padding: 10px;\" src=\"img/icons/testdrive.png\"></a></td></tr><tr><td>Download</td><td>Testdrive</td></tr></table></center>";
- $builddone = true;
+ if ($jobres[0] !== NULL) {
+ if ($jobres[0] == 0) {
+ $buildresult = "Your build is complete! ".
+ "What would you like to do now?".
+ "<br /><br /><center>".
+ "<table><tr><td>".
+ "<a href=\"/gentoaster/".$buildID."/".$buildID.".tar.gz\">".
+ "<img style=\"padding: 10px;\" src=\"img/icons/download.png\">".
+ "</a></td><td>".
+ "<a href=\"testdrive.php?uuid=".$buildID."\">".
+ "<img style=\"padding: 10px;\" src=\"img/icons/testdrive.png\">".
+ "</a></td></tr>".
+ "<tr><td>Download</td><td>Testdrive</td></tr>".
+ "</table></center>";
+ $builddone = true;
} else {
- $buildresult = "Job returned with code ".$jobres[0].": ".$jobres[1];
+ $buildresult = "Job returned with code ".$jobres[0].": ".$jobres[1];
}
} else {
$buildresult = "Job failed";
@@ -44,44 +61,50 @@
?>
<html>
- <head>
- <title>Gentoaster</title>
- <link rel="stylesheet" type="text/css" href="css/style.css">
- <link rel="stylesheet" type="text/css" href="css/ui-lightness/jquery-ui-1.8.14.custom.css">
- <script type="text/javascript" src="/js/jquery-1.5.1.min.js"></script>
- <script type="text/javascript" src="/js/jquery-ui-1.8.14.custom.min.js"></script>
- <?php
- if($inprogress) {
- echo '<script>
- $(document).ready(function() {
- $("#progressbar").progressbar({ value: '.$percentage.' });
- });
- </script>';
- }
- ?>
- </head>
- <body>
- <div id="container">
- <div id="header"></div>
- <div id="content">
- <div id="main">
- <div id="status" class="step">
- <?php if(!$builddone) { ?>
- <h1>How's things?</h1>
- <?php } else { ?>
- <h1>It's showtime!</h1>
- <?php } ?>
- <p>
- <?php echo $buildresult; ?>
- <div id="progressbar"></div>
- </p>
- </div>
- </div>
- <div id="navigation">
+ <head>
+ <title>Gentoaster</title>
+ <link rel="stylesheet" type="text/css" href="css/style.css">
+ <link rel="stylesheet" type="text/css" href="css/ui-lightness/jquery-ui-1.8.14.custom.css">
+ <script type="text/javascript" src="/js/jquery-1.5.1.min.js"></script>
+ <script type="text/javascript" src="/js/jquery-ui-1.8.14.custom.min.js"></script>
+ <?php
+ if ($inprogress) {
+ echo '<script>
+ $(document).ready(function() {
+ $("#progressbar").progressbar({ value: '.$percentage.' });
+ });
+ </script>';
+ }
+ ?>
+ </head>
+ <body>
+ <div id="container">
+ <div id="header"></div>
+ <div id="content">
+ <div id="main">
+ <div id="status" class="step">
+ <?php
+ if (!$builddone) {
+ ?>
+ <h1>How's things?</h1>
+ <?php
+ } else {
+ ?>
+ <h1>It's showtime!</h1>
+ <?php
+ }
+ ?>
+ <p>
+ <?php echo $buildresult; ?>
+ <div id="progressbar"></div>
+ </p>
+ </div>
+ </div>
+ <div id="navigation">
- </div>
- </div>
- </div>
- </script>
- </body>
+ </div>
+ </div>
+ </div>
+ </script>
+ </body>
</html> \ No newline at end of file