aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiam McLoughlin <hexxeh@hexxeh.net>2011-07-27 22:40:22 +0100
committerLiam McLoughlin <hexxeh@hexxeh.net>2011-07-27 22:40:22 +0100
commit5af0df843f05f6f1650ccb63498741431bb9d58a (patch)
tree75487bb61aa8e6787b59a94415d3d41aba785478
parentFix broken shell filter (diff)
downloadgentoaster-5af0df843f05f6f1650ccb63498741431bb9d58a.tar.gz
gentoaster-5af0df843f05f6f1650ccb63498741431bb9d58a.tar.bz2
gentoaster-5af0df843f05f6f1650ccb63498741431bb9d58a.zip
Making everything Zend compliant again
-rw-r--r--client.php9
-rw-r--r--daemon.php24
-rw-r--r--status.php9
-rw-r--r--web/config.php5
-rw-r--r--web/finished.php13
-rw-r--r--web/index.php283
-rw-r--r--web/js/jquery-ui-1.8.14.js (renamed from web/js/jquery-ui-1.8.14.custom.min.js)0
-rw-r--r--web/js/jquery.wizard.js (renamed from web/js/jquery.form.wizard.js)0
-rw-r--r--web/process.php66
-rw-r--r--web/status.php78
-rw-r--r--web/testdrive.php104
11 files changed, 366 insertions, 225 deletions
diff --git a/client.php b/client.php
index 56313ae..2245f61 100644
--- a/client.php
+++ b/client.php
@@ -21,8 +21,13 @@
echo "Job sent, handle was ".$handle." - hash ".$handlehash."\n";
- $db = new mysqli(MYSQL_HOSTNAME, MYSQL_USERNAME,
- MYSQL_PASSWORD, MYSQL_DATABASE);
+ $db = new mysqli(
+ MYSQL_HOSTNAME,
+ MYSQL_USERNAME,
+ MYSQL_PASSWORD,
+ MYSQL_DATABASE
+ );
+
if (mysqli_connect_errno()) {
die("Could not connect to database ".mysqli_connect_error());
}
diff --git a/daemon.php b/daemon.php
index 5fa09b2..cac2adf 100644
--- a/daemon.php
+++ b/daemon.php
@@ -18,8 +18,13 @@
$result = trim($result);
echo "A job finished with return code ".$returncode.": ".$result."\n";
- $db = new mysqli(MYSQL_HOSTNAME, MYSQL_USERNAME,
- MYSQL_PASSWORD, MYSQL_DATABASE);
+ $db = new mysqli(
+ MYSQL_HOSTNAME,
+ MYSQL_USERNAME,
+ MYSQL_PASSWORD,
+ MYSQL_DATABASE
+ );
+
if (mysqli_connect_errno()) {
die("Could not connect to database ".mysqli_connect_error());
}
@@ -87,7 +92,11 @@
unlink("config.ini");
- return update_result($handle, $returncode, $nonstatusOutput);
+ return update_result(
+ $handle,
+ $returncode,
+ $nonstatusOutput
+ );
} else {
$error = "Configured build path is not writable";
return update_result($handle, -2, $error);
@@ -109,8 +118,13 @@
$insert = false;
$update = false;
- $db = new mysqli(MYSQL_HOSTNAME, MYSQL_USERNAME,
- MYSQL_PASSWORD, MYSQL_DATABASE);
+ $db = new mysqli(
+ MYSQL_HOSTNAME,
+ MYSQL_USERNAME,
+ MYSQL_PASSWORD,
+ MYSQL_DATABASE
+ );
+
if (mysqli_connect_errno()) {
die("Could not connect to database ".mysqli_connect_error());
}
diff --git a/status.php b/status.php
index 66d55f8..2a49fd8 100644
--- a/status.php
+++ b/status.php
@@ -9,8 +9,13 @@
die("No handle hash given\n");
}
- $db = new mysqli(MYSQL_HOSTNAME, MYSQL_USERNAME,
- MYSQL_PASSWORD, MYSQL_DATABASE);
+ $db = new mysqli(
+ MYSQL_HOSTNAME,
+ MYSQL_USERNAME,
+ MYSQL_PASSWORD,
+ MYSQL_DATABASE
+ );
+
if (mysqli_connect_errno()) {
die("Could not connect to database ".mysqli_connect_error());
}
diff --git a/web/config.php b/web/config.php
index c31e60b..1d1cb2e 100644
--- a/web/config.php
+++ b/web/config.php
@@ -9,6 +9,9 @@
// Should we allow multiple simultaneous builds for a user?
define("SIMULTANEOUS_BUILDS", false);
+ // What should we set as the default list of packages?
+ define("DEFAULT_PACKAGES", "dhcpd");
+
// What should we limit the virtual machine disk size to?
define("MAX_DISK_SIZE", 16384);
@@ -20,5 +23,5 @@
// Set the RECAPTCHA keys that should be used, if enabled
define("RECAPTCHA_ENABLED", false);
- define("RECAPTCHA_PUBLIC_KEY","REPLACE_ME");
+ define("RECAPTCHA_PUBLIC_KEY", "REPLACE_ME");
define("RECAPTCHA_PRIVATE_KEY", "REPLACE_ME"); \ No newline at end of file
diff --git a/web/finished.php b/web/finished.php
index fa953c7..5d2309b 100644
--- a/web/finished.php
+++ b/web/finished.php
@@ -1,3 +1,9 @@
+<?php
+
+$buildID = filter_input(INPUT_GET, "uuid", FILTER_UNSAFE_RAW);
+$buildID = urlencode($buildID);
+
+?>
<html>
<head>
<title>Gentoaster</title>
@@ -11,11 +17,12 @@
<div id="finished" class="step">
<h1>That's it!</h1>
<p>
- That's all there is to it! We've sent your configuration down to the kitchen to be
- toasted, come back later to get your image.
+ That's all there is to it! We've sent your configuration down to
+ the kitchen to be toasted, come back later to get your image.
</p>
<p>
- You can also click <a href="status.php?uuid=<?php echo htmlspecialchars($_GET["uuid"]); ?>">here</a> to
+ You can also click
+ <a href="status.php?uuid=<?php echo $buildID; ?>">here</a> to
view the status of your build.
</p>
</div>
diff --git a/web/index.php b/web/index.php
index a68a219..99b9cf0 100644
--- a/web/index.php
+++ b/web/index.php
@@ -5,15 +5,23 @@
require_once "recaptcha.php";
}
- if(!SIMULTANEOUS_BUILDS) {
- $db = new mysqli(MYSQL_HOSTNAME, MYSQL_USERNAME,
- MYSQL_PASSWORD, MYSQL_DATABASE);
+ if (!SIMULTANEOUS_BUILDS) {
+ $db = new mysqli(
+ MYSQL_HOSTNAME,
+ MYSQL_USERNAME,
+ MYSQL_PASSWORD,
+ MYSQL_DATABASE
+ );
+
if (mysqli_connect_errno()) {
die("Could not connect to database ".mysqli_connect_error());
}
- $ipaddress = filter_input(INPUT_SERVER, "REMOTE_ADDR",
- FILTER_VALIDATE_IP);
+ $ipaddress = filter_input(
+ INPUT_SERVER,
+ "REMOTE_ADDR",
+ FILTER_VALIDATE_IP
+ );
$stmt = $db->prepare("SELECT id FROM builds WHERE ipaddress = ?");
$stmt->bind_param("s", $ipaddress);
@@ -23,7 +31,8 @@
if ($stmt->num_rows == 1) {
$stmt->bind_result($buildID);
$stmt->fetch();
- header("Location: status.php?uuid=".$buildID."&simultaneous=true");
+ $url = "status.php?uuid=".$buildID."&simultaneous=true";
+ header("Location: ".$url);
}
$stmt->close();
}
@@ -50,135 +59,169 @@
}
?>
<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.form.js"></script>
- <script type="text/javascript" src="/js/jquery.validate.js"></script>
- <script type="text/javascript" src="/js/bbq.js"></script>
- <script type="text/javascript" src="/js/jquery-ui-1.8.14.custom.min.js"></script>
- <script type="text/javascript" src=" /js/jquery.form.wizard.js"></script>
+ <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.form.js"></script>
+ <script type="text/javascript" src="/js/jquery.validate.js"></script>
+ <script type="text/javascript" src="/js/bbq.js"></script>
+ <script type="text/javascript" src="/js/jquery-ui-1.8.14.js"></script>
+ <script type="text/javascript" src=" /js/jquery.wizard.js"></script>
<script type="text/javascript">
var RecaptchaOptions = {
theme : 'clean'
};
</script>
- </head>
- <body>
- <div id="container">
- <div id="header"></div>
- <form id="wizard" method="post" action="process.php" class="bbq">
- <div id="content">
- <div id="main">
- <div id="welcome" class="step">
- <h1>Welcome to Gentoaster!</h1>
- <p>This wizard will guide you through the creation of your own personalised
- Gentoo virtual machine image.</p>
- </div>
- <?php
- if (RECAPTCHA_ENABLED) {
- ?>
- <div id="human" class="step">
- <h1>Verification</h1>
+ </head>
+ <body>
+ <div id="container">
+ <div id="header"></div>
+ <form id="wizard" method="post" action="process.php" class="bbq">
+ <div id="content">
+ <div id="main">
+ <div id="welcome" class="step">
+ <h1>Welcome to Gentoaster!</h1>
+ <p>This wizard will guide you through the creation
+ of your own personalised Gentoo virtual machine
+ image.</p>
+ </div>
+ <?php
+ if (RECAPTCHA_ENABLED) {
+ ?>
+ <div id="human" class="step">
+ <h1>Verification</h1>
- <?php
- echo recaptcha_get_html(RECAPTCHA_PUBLIC_KEY);
- ?>
- <br>
- </div>
- <?php
- }
- ?>
- <div id="locale" class="step">
- <h1>Locale</h1>
+ <?php
+ echo recaptcha_get_html(RECAPTCHA_PUBLIC_KEY);
+ ?>
+ <br>
+ </div>
+ <?php
+ }
+ ?>
+ <div id="locale" class="step">
+ <h1>Locale</h1>
- <label for="locale_language">Language</label><br />
- <select id="locale_language" class="required" name="language">
- <option>English (UK)</option>
- </select>
- <br>
+ <label for="locale_language">Language</label>
+ <br />
+ <select id="locale_language" class="required"
+ name="language">
+ <option>English (UK)</option>
+ </select>
+ <br>
- <label for="locale_keyboard">Keyboard Layout</label><br />
- <select id="locale_keyboard" class="required" name="keyboard">
- <option>United Kingdom</option>
- </select>
- <br>
+ <label for="locale_keyboard">Keyboard Layout</label>
+ <br />
+ <select id="locale_keyboard" class="required"
+ name="keyboard">
+ <option>United Kingdom</option>
+ </select>
+ <br>
- <label for="locale_timezone">Timezone</label><br />
- <select id="locale_timezone" class="required" name="timezone">
- <?php echo $timezoneOption; ?>
- </select>
- <br>
- </div>
- <div id="user" class="step">
- <h1>User details</h1>
+ <label for="locale_timezone">Timezone</label>
+ <br />
+ <select id="locale_timezone" class="required"
+ name="timezone">
+ <?php echo $timezoneOption; ?>
+ </select>
+ <br>
+ </div>
+ <div id="user" class="step">
+ <h1>User details</h1>
- <label for="user_username">Username</label><br />
- <input id="user_username" class="required" type="text" name="username"><br>
+ <label for="user_username">Username</label><br />
+ <input id="user_username" class="required"
+ type="text" name="username"><br>
- <label for="user_password">Password</label><br />
- <input id="user_password" class="required" type="password" name="password">
- <input id="user_confirmpassword" class="required" type="password" name="confirmpassword"><br>
+ <label for="user_password">Password</label><br />
+ <input id="user_password" class="required"
+ type="password" name="password">
+
+ <input id="user_confirmpassword" class="required"
+ type="password" name="confirmpassword"><br>
- <label for="user_rootpassword">Root Password</label><br />
- <input id="user_rootpassword" class="required" type="password" name="rootpassword">
- <input id="user_confirmrootpassword" class="required" type="password" name="confirmrootpassword"><br>
- </div>
- <div id="network" class="step">
- <h1>Network</h1>
+ <label for="user_rootpassword">Root Password</label>
+ <br />
+ <input id="user_rootpassword" class="required"
+ type="password" name="rootpassword">
+
+ <input id="user_confirmrootpassword"
+ class="required" type="password"
+ name="confirmrootpassword"><br>
+ </div>
+ <div id="network" class="step">
+ <h1>Network</h1>
- <label for="network_hostname">Hostname</label><br />
- <input id="network_hostname" class="required" type="text" name="hostname"><br>
- </div>
- <div id="partitioning" class="step">
- <h1>Partitioning</h1>
+ <label for="network_hostname">Hostname</label><br />
+ <input id="network_hostname" class="required"
+ type="text" name="hostname"><br>
+ </div>
+ <div id="partitioning" class="step">
+ <h1>Partitioning</h1>
- <label for="partitioning_size">Disk size</label><br />
- <input id="partitioning_size" class="required" type="text" name="image_size" value="4096"><br>
+ <label for="partitioning_size">Disk size</label>
+ <br />
+ <input id="partitioning_size" class="required"
+ type="text" name="image_size" value="4096"><br>
- <label for="">Split</label><br /><br />
- <div id="partitioning_split" name="split"></div><br /><br />
- <div id="partitioning_display">Not yet updated</div><br />
- <input type="hidden" id="partitioning_boot" name="boot_size" value="0"><br />
- <input type="hidden" id="partitioning_swap" name="swap_size" value="0"><br />
- <input type="hidden" id="partitioning_root" name="root_size" value="0"><br />
- </div>
- <div id="packages" class="step">
- <h1>Packages</h1>
+ <label for="">Split</label><br /><br />
+ <div id="partitioning_split" name="split"></div>
+ <br /><br />
+ <div id="partitioning_display">Not yet updated</div>
+ <br />
+ <input type="hidden" id="partitioning_boot"
+ name="boot_size" value="0"><br />
+ <input type="hidden" id="partitioning_swap"
+ name="swap_size" value="0"><br />
+ <input type="hidden" id="partitioning_root"
+ name="root_size" value="0"><br />
+ </div>
+ <div id="packages" class="step">
+ <h1>Packages</h1>
- <label for="packages_packages">Packages list</label><br /><br />
- <textarea id="packages_packages" name="packages" style="width: 680px; height: 330px;">dhcpcd</textarea>
- <br>
- </div>
- <div id="format" class="step submit_step">
- <h1>Image format</h1>
+ <label for="packages_packages">Packages list</label>
+ <br /><br />
+ <textarea id="packages_packages" name="packages"
+ style="width: 680px; height: 330px;"><?php
+ echo DEFAULT_PACKAGES;
+ ?></textarea>
+ <br>
+ </div>
+ <div id="format" class="step submit_step">
+ <h1>Image format</h1>
- <label for="format_format">Output format</label><br />
- <select id="format_format" class="required" name="format">
- <option value="raw">Raw</option>
- <option value="vmware">VirtualBox</option>
- <option value="vbox">VMWare</option>
- </select>
- <br>
- </div>
- <div id="complete" class="step">
- <h1>That's it!</h1>
- <p>That's all there is to it! We've sent your configuration down to the kitchen to be
- cooked, and we'll email you once it's finished cooking.</p>
- </div>
- </div>
- <div id="navigation">
- <button id="forwardbutton" class="navigationbutton" type="submit">Next</button>
- <button id="backbutton" class="navigationbutton" type="reset">Back</button>
- </div>
- </div>
- </form>
- </div>
- <script type="text/javascript">
- MAX_DISK_SIZE = <?php echo MAX_DISK_SIZE; ?>;
- </script>
- <script type="text/javascript" src=" /js/gentoaster.js"></script>
- </body>
+ <label for="format_format">Output format</label>
+ <br />
+ <select id="format_format" class="required"
+ name="format">
+ <option value="raw">Raw</option>
+ <option value="vmware">VirtualBox</option>
+ <option value="vbox">VMWare</option>
+ </select>
+ <br>
+ </div>
+ <div id="complete" class="step">
+ <h1>That's it!</h1>
+ <p>That's all there is to it! We've sent your
+ configuration down to the kitchen to be cooked, and
+ we'll email you once it's finished cooking.</p>
+ </div>
+ </div>
+ <div id="navigation">
+ <button id="forwardbutton" class="navigationbutton"
+ type="submit">Next</button>
+ <button id="backbutton" class="navigationbutton"
+ type="reset">Back</button>
+ </div>
+ </div>
+ </form>
+ </div>
+ <script type="text/javascript">
+ MAX_DISK_SIZE = <?php echo MAX_DISK_SIZE; ?>;
+ </script>
+ <script type="text/javascript" src=" /js/gentoaster.js"></script>
+ </body>
</html>
diff --git a/web/js/jquery-ui-1.8.14.custom.min.js b/web/js/jquery-ui-1.8.14.js
index f9e4f1e..f9e4f1e 100644
--- a/web/js/jquery-ui-1.8.14.custom.min.js
+++ b/web/js/jquery-ui-1.8.14.js
diff --git a/web/js/jquery.form.wizard.js b/web/js/jquery.wizard.js
index 2eea9e8..2eea9e8 100644
--- a/web/js/jquery.form.wizard.js
+++ b/web/js/jquery.wizard.js
diff --git a/web/process.php b/web/process.php
index cadbf98..a005319 100644
--- a/web/process.php
+++ b/web/process.php
@@ -5,45 +5,56 @@
require_once "config.php";
- $ipaddress = filter_input(INPUT_SERVER, "REMOTE_ADDR",
- FILTER_VALIDATE_IP);
+ $ipaddress = filter_input(
+ INPUT_SERVER,
+ "REMOTE_ADDR",
+ FILTER_VALIDATE_IP
+ );
if (RECAPTCHA_ENABLED) {
require_once "recaptcha.php";
- $challenge = filter_input(INPUT_POST,
- "recaptcha_challenge_field",
- FILTER_UNSAFE_RAW);
- $response = filter_input(INPUT_POST,
- "recaptcha_response_field",
- FILTER_UNSAFE_RAW);
+ $challenge = filter_input(
+ INPUT_POST,
+ "recaptcha_challenge_field",
+ FILTER_UNSAFE_RAW
+ );
- $resp = recaptcha_check_answer(RECAPTCHA_PRIVATE_KEY,
- $ipaddress,
- $challenge,
- $response);
+ $response = filter_input(
+ INPUT_POST,
+ "recaptcha_response_field",
+ FILTER_UNSAFE_RAW
+ );
+
+ $resp = recaptcha_check_answer(
+ RECAPTCHA_PRIVATE_KEY,
+ $ipaddress,
+ $challenge,
+ $response
+ );
if (!$resp->is_valid) {
die("CAPTCHA was incorrect");
}
}
- function sanitize_shellarg($arg) {
+ function sanitize_shellarg($arg)
+ {
return escapeshellarg($arg);
}
- $shellfilter = array("options" => "sanitize_shellarg");
+ $sfi = array("options" => "sanitize_shellarg");
$buildID = uniqid();
$bootMegabytes = filter_input(INPUT_POST, "boot_size", FILTER_VALIDATE_INT);
$swapMegabytes = filter_input(INPUT_POST, "swap_size", FILTER_VALIDATE_INT);
$rootMegabytes = filter_input(INPUT_POST, "root_size", FILTER_VALIDATE_INT);
- $timezone = filter_input(INPUT_POST, "timezone", FILTER_CALLBACK, $shellfilter);
- $hostname = filter_input(INPUT_POST, "hostname", FILTER_CALLBACK, $shellfilter);
- $username = filter_input(INPUT_POST, "username", FILTER_CALLBACK, $shellfilter);
- $password = filter_input(INPUT_POST, "password", FILTER_CALLBACK, $shellfilter);
- $rootPass = filter_input(INPUT_POST, "rootpassword", FILTER_CALLBACK, $shellfilter);
- $packagesList = filter_input(INPUT_POST, "packages", FILTER_CALLBACK, $shellfilter);
- $outputFormat = filter_input(INPUT_POST, "format", FILTER_CALLBACK, $shellfilter);
+ $timezone = filter_input(INPUT_POST, "timezone", FILTER_CALLBACK, $sfi);
+ $hostname = filter_input(INPUT_POST, "hostname", FILTER_CALLBACK, $sfi);
+ $username = filter_input(INPUT_POST, "username", FILTER_CALLBACK, $sfi);
+ $password = filter_input(INPUT_POST, "password", FILTER_CALLBACK, $sfi);
+ $rootPass = filter_input(INPUT_POST, "rootpassword", FILTER_CALLBACK, $sfi);
+ $packagesList = filter_input(INPUT_POST, "packages", FILTER_CALLBACK, $sfi);
+ $outputFormat = filter_input(INPUT_POST, "format", FILTER_CALLBACK, $sfi);
$packagesList = str_replace("\r\n", " ", $packagesList);
$packagesList = str_replace("\n", " ", $packagesList);
@@ -70,13 +81,20 @@ OUTPUT_FORMAT=$outputFormat";
$client->addServer();
$handle = $client->doBackground("invoke_image_build", $iniString);
- $db = new mysqli(MYSQL_HOSTNAME, MYSQL_USERNAME,
- MYSQL_PASSWORD, MYSQL_DATABASE);
+ $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("INSERT INTO builds (id, handle, ipaddress) VALUES(?, ?, ?)");
+ $query = "INSERT INTO builds (id, handle, ipaddress) ".
+ "VALUES(?, ?, ?)";
+ $stmt = $db->prepare($query);
$stmt->bind_param("sss", $buildID, $handle, $ipaddress);
$stmt->execute();
$stmt->close();
diff --git a/web/status.php b/web/status.php
index d2e8715..ab57a1e 100644
--- a/web/status.php
+++ b/web/status.php
@@ -6,19 +6,29 @@
require_once "config.php";
$buildID = filter_input(INPUT_GET, "uuid", FILTER_UNSAFE_RAW);
- $simultaneous = filter_input(INPUT_GET, "simultaneous", FILTER_VALIDATE_BOOLEAN);
- $buildresult = "Unknown!";
+ $simultaneous = filter_input(
+ INPUT_GET,
+ "simultaneous",
+ FILTER_VALIDATE_BOOLEAN
+ );
+ $bres = "Unknown!";
$inprogress = false;
$builddone = false;
$simultaneousString = "";
- if($simultaneous && !SIMULTANEOUS_BUILDS) {
- $simultaneousString = "You were redirected to this page because you already have a ".
- "build in progress. Simultaneous builds are disabled on this server.<br/><br/>";
+ if ($simultaneous && !SIMULTANEOUS_BUILDS) {
+ $simultaneousString = "You were redirected to this page because you ".
+ "already have a build in progress. Simultaneous ".
+ "builds are disabled on this server.<br/><br/>";
}
- $db = new mysqli(MYSQL_HOSTNAME, MYSQL_USERNAME,
- MYSQL_PASSWORD, MYSQL_DATABASE);
+ $db = new mysqli(
+ MYSQL_HOSTNAME,
+ MYSQL_USERNAME,
+ MYSQL_PASSWORD,
+ MYSQL_DATABASE
+ );
+
if (mysqli_connect_errno()) {
die("Could not connect to database ".mysqli_connect_error());
}
@@ -38,14 +48,16 @@
if ($status[0]) {
if ($status[3] != 0) {
$percentage = ceil($status[2]/$status[3]*100);
- $buildresult = "Your build is currently running".
+ $bres = "Your build is currently running".
" and is ".$percentage."% complete";
$inprogress = true;
} else {
- $buildresult = "Task has not yet been processed";
+ $bres = "Task has not yet been processed";
}
} else {
- $stmt = $db->prepare("SELECT returncode, result FROM builds WHERE id = ?");
+ $query = "SELECT returncode, result ".
+ "FROM builds WHERE id = ?";
+ $stmt = $db->prepare($query);
$stmt->bind_param("s", $buildID);
$stmt->execute();
$stmt->bind_result($returncode, $result);
@@ -53,29 +65,36 @@
$stmt->close();
if ($returncode !== null) {
if ($returncode == 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>";
+ $bres = "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 ".$returncode.": ".$result;
+ $bres = "Job returned with code ".
+ $returncode.": ".$result;
}
} else {
- $buildresult = "Job failed";
+ $bres = "Job failed";
}
}
} else {
$stmt->close();
- $buildresult = "Invalid handle hash";
+ $bres = "Invalid handle hash";
}
$db->close();
@@ -90,9 +109,10 @@
<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>
+ <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.js"></script>
<?php
if ($inprogress) {
echo '<script>
@@ -112,7 +132,7 @@
<h1><?php echo $titleString; ?></h1>
<p>
<?php echo $simultaneousString; ?>
- <?php echo $buildresult; ?>
+ <?php echo $bres; ?>
<div id="progressbar"></div>
</p>
</div>
diff --git a/web/testdrive.php b/web/testdrive.php
index 3847b69..7610811 100644
--- a/web/testdrive.php
+++ b/web/testdrive.php
@@ -9,8 +9,13 @@
$buildresult = "Unknown!";
$inprogress = false;
- $db = new mysqli(MYSQL_HOSTNAME, MYSQL_USERNAME,
- MYSQL_PASSWORD, MYSQL_DATABASE);
+ $db = new mysqli(
+ MYSQL_HOSTNAME,
+ MYSQL_USERNAME,
+ MYSQL_PASSWORD,
+ MYSQL_DATABASE
+ );
+
if (mysqli_connect_errno()) {
die("Could not connect to database ".mysqli_connect_error());
}
@@ -30,7 +35,9 @@
if ($status[0]) {
header("Location: status.php?uuid=".$buildID);
} else {
- $stmt = $db->prepare("SELECT returncode, result FROM builds WHERE id = ?");
+ $query = "SELECT returncode, result ".
+ "FROM builds WHERE id = ?";
+ $stmt = $db->prepare($query);
$stmt->bind_param("s", $buildID);
$stmt->execute();
$stmt->bind_result($returncode, $result);
@@ -41,7 +48,10 @@
// we're built, let's do this
$client = new GearmanClient();
$client->addServer();
- $server = $client->do("invoke_start_image", $buildID);
+ $server = $client->do(
+ "invoke_start_image",
+ $buildID
+ );
$server = unserialize($server);
} else {
header("Location: status.php?uuid=".$buildID);
@@ -61,9 +71,10 @@
<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>
+ <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.js"></script>
<script type="text/javascript" src="include/vnc.js"></script>
</head>
<body>
@@ -75,16 +86,24 @@
<h1>Let's fire her up!</h1>
<center>
<div id="VNC_screen">
- <div id="VNC_status_bar" class="VNC_status_bar" style="margin-top: -25px;">
+ <div id="VNC_status_bar" class="VNC_status_bar"
+ style="margin-top: -25px;">
<table border=0 width="100%"><tr>
- <td><div id="VNC_status" style="display: none;">Loading</div></td>
+ <td>
+ <div id="VNC_status"
+ style="display: none;">
+ Loading
+ </div>
+ </td>
<td width="1%"><div id="VNC_buttons">
- <input type=button value="Send CtrlAltDel"
+ <input type=button
+ value="Send CtrlAltDel"
id="sendCtrlAltDelButton">
</div></td>
</tr></table>
</div>
- <canvas id="VNC_canvas" width="640px" height="20px">
+ <canvas id="VNC_canvas" width="640px"
+ height="20px">
Canvas not supported.
</canvas>
</div>
@@ -97,21 +116,11 @@
var rfb;
- function passwordRequired(rfb) {
- var msg;
- msg = '<form onsubmit="return setPassword();"';
- msg += ' style="margin-bottom: 0px">';
- msg += 'Password Required: ';
- msg += '<input type=password size=10 id="password_input" class="VNC_status">';
- msg += '<\/form>';
- $D('VNC_status_bar').setAttribute("class", "VNC_status_warn");
- $D('VNC_status').innerHTML = msg;
- }
function setPassword() {
rfb.sendPassword($D('password_input').value);
return false;
}
- function sendCtrlAltDel() {
+ function sendCAD() {
rfb.sendCtrlAltDel();
return false;
}
@@ -121,19 +130,35 @@
sb = $D('VNC_status_bar');
cad = $D('sendCtrlAltDelButton');
switch (state) {
- case 'failed': level = "error"; break;
- case 'fatal': level = "error"; break;
- case 'normal': level = "normal"; break;
- case 'disconnected': level = "normal"; break;
- case 'loaded': level = "normal"; break;
- default: level = "warn"; break;
+ case 'failed':
+ level = "error";
+ break;
+ case 'fatal':
+ level = "error";
+ break;
+ case 'normal':
+ level = "normal";
+ break;
+ case 'disconnected':
+ level = "normal";
+ break;
+ case 'loaded':
+ level = "normal";
+ break;
+ default:
+ level = "warn";
+ break;
}
- if (state === "normal") { cad.disabled = false; }
- else { cad.disabled = true; }
+ if (state === "normal") {
+ cad.disabled = false;
+ } else {
+ cad.disabled = true;
+ }
if (typeof(msg) !== 'undefined') {
- sb.setAttribute("class", "VNC_status_" + level);
+ attr = "VNC_status_" + level;
+ sb.setAttribute("class", attr);
s.innerHTML = msg;
}
}
@@ -141,19 +166,20 @@
function connect() {
var host, port, password;
- $D('sendCtrlAltDelButton').onclick = sendCtrlAltDel;
+ $D('sendCtrlAltDelButton').onclick = sendCAD;
host = "<?php echo $server[0]; ?>";
port = <?php echo $server[1]; ?>;
password = "";
- rfb = new RFB({'target': $D('VNC_canvas'),
- 'encrypt': WebUtil.getQueryVar('encrypt', false),
- 'true_color': WebUtil.getQueryVar('true_color', true),
- 'local_cursor': WebUtil.getQueryVar('cursor', true),
- 'shared': WebUtil.getQueryVar('shared', true),
- 'updateState': updateState,
- 'onPasswordRequired': passwordRequired});
+ gqv = WebUtil.getQueryVar;
+
+ rfb = new RFB({'target':$D('VNC_canvas'),
+ 'encrypt': gqv('encrypt',false),
+ 'true_color': gqv('true_color',true),
+ 'local_cursor': gqv('cursor',true),
+ 'shared': gqv('shared',true),
+ 'updateState': updateState,
rfb.connect(host, port, password);
};