* [gentoo-commits] proj/gentoaster:webui commit in: /, web/
2011-08-12 23:18 [gentoo-commits] proj/gentoaster:master commit in: /, web/ Liam McLoughlin
@ 2011-08-10 17:39 ` Liam McLoughlin
0 siblings, 0 replies; 8+ messages in thread
From: Liam McLoughlin @ 2011-08-10 17:39 UTC (permalink / raw
To: gentoo-commits
commit: 7f2c98b0d095c5c173fed07a0f8f32d51798d97e
Author: Liam McLoughlin <hexxeh <AT> hexxeh <DOT> net>
AuthorDate: Wed Aug 10 17:39:11 2011 +0000
Commit: Liam McLoughlin <hexxeh <AT> hexxeh <DOT> net>
CommitDate: Wed Aug 10 17:39:11 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoaster.git;a=commit;h=7f2c98b0
Combine configs, fix image download path via a new config option, add initscript
---
config.php | 9 ++++++++-
gentoaster | 35 +++++++++++++++++++++++++++++++++++
gentoaster.sql | 20 ++++++++++++++++++++
web/config.php | 11 ++++-------
web/index.php | 1 -
web/status.php | 2 +-
6 files changed, 68 insertions(+), 10 deletions(-)
diff --git a/config.php b/config.php
index c1807fa..96b5728 100644
--- a/config.php
+++ b/config.php
@@ -5,12 +5,19 @@
// Set the publically viewable URL for this Gentoaster instance
define("GENTOASTER_URL", "http://192.168.2.169");
+
+ // Set the publically viewable URL for images to be downloaded
+ // This should point to the same folder as CONFIGURATIONS_PATH
+ define("IMAGES_URL", "http://192.168.2.169/images");
// Set the path that completed images should be stored at
define("CONFIGURATIONS_PATH", "/var/www/gentoaster/images");
// Set the path to the folder the Gentoaster tool is at
- define("GENTOASTER_PATH", "/usr/share/gentoaster");
+ // As long as we're not being used by the WebUI
+ if (!defined("GENTOASTER_PATH")) {
+ define("GENTOASTER_PATH", "/usr/share/gentoaster");
+ }
// Set the name of the image creation tool
define("BUILD_TOOL_NAME", "create_image.sh");
diff --git a/gentoaster b/gentoaster
new file mode 100755
index 0000000..32d7d63
--- /dev/null
+++ b/gentoaster
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+USER=root
+GENTOASTER=/usr/share/gentoaster/daemon.php
+RETVAL=0
+
+start() {
+ echo "Starting Gentoaster"
+ start-stop-daemon --quiet --start --background --chuid "$USER" --exec /usr/bin/php -- -f $GENTOASTER
+ RETVAL=$?
+}
+stop() {
+ echo "Stopping Gentoaster"
+ killall -q -w -u $USER $GENTOASTER
+ RETVAL=$?
+}
+
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ *)
+ echo "Usage: gentoaster {start|stop|restart}"
+ exit 1
+ ;;
+esac
+exit $RETVAL
+
diff --git a/gentoaster.sql b/gentoaster.sql
new file mode 100644
index 0000000..17034b8
--- /dev/null
+++ b/gentoaster.sql
@@ -0,0 +1,20 @@
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `builds` (
+ `id` varchar(32) NOT NULL,
+ `handle` varchar(32) NOT NULL,
+ `returncode` int(11) DEFAULT NULL,
+ `result` text,
+ `ipaddress` varchar(15) DEFAULT NULL,
+ `email` varchar(50) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `ports` (
+ `id` varchar(32) NOT NULL,
+ `port` int(11) NOT NULL,
+ `pid` int(11) NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
diff --git a/web/config.php b/web/config.php
index 38076e8..9c5ef50 100644
--- a/web/config.php
+++ b/web/config.php
@@ -36,13 +36,10 @@
// What should we limit the virtual machine disk size to?
define("MAX_DISK_SIZE", 16384);
- // Set the MySQL access details that should be used
- define("MYSQL_HOSTNAME", "localhost");
- define("MYSQL_USERNAME", "gentoaster");
- define("MYSQL_PASSWORD", "");
- define("MYSQL_DATABASE", "gentoaster");
-
// Set the RECAPTCHA keys that should be used, if enabled
define("RECAPTCHA_ENABLED", false);
define("RECAPTCHA_PUBLIC_KEY", "REPLACE_ME");
- define("RECAPTCHA_PRIVATE_KEY", "REPLACE_ME");
\ No newline at end of file
+ define("RECAPTCHA_PRIVATE_KEY", "REPLACE_ME");
+
+ // Load all the configuration for the daemon, too
+ require_once GENTOASTER_PATH."/config.php";
\ No newline at end of file
diff --git a/web/index.php b/web/index.php
index f46af2b..6bb2f9f 100644
--- a/web/index.php
+++ b/web/index.php
@@ -1,6 +1,5 @@
<?php
require_once "config.php";
- require_once GENTOASTER_PATH."/config.php";
if (RECAPTCHA_ENABLED) {
require_once "recaptcha.php";
diff --git a/web/status.php b/web/status.php
index 69e8afc..bde0ad2 100644
--- a/web/status.php
+++ b/web/status.php
@@ -69,7 +69,7 @@
"What would you like to do now?".
"<br /><br /><center>".
"<table><tr><td>".
- "<a href=\"/gentoaster/".
+ "<a href=\"".IMAGES_URL."/".
$buildID."/".$buildID.
".tar.gz\">".
"<img style=\"padding: 10px;\" ".
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [gentoo-commits] proj/gentoaster:master commit in: /, web/
@ 2011-08-12 23:17 Liam McLoughlin
0 siblings, 0 replies; 8+ messages in thread
From: Liam McLoughlin @ 2011-08-12 23:17 UTC (permalink / raw
To: gentoo-commits
commit: 449e4f5e6178dd60455c728234a78f65883faaca
Author: Liam McLoughlin <hexxeh <AT> hexxeh <DOT> net>
AuthorDate: Sun Jul 24 01:43:17 2011 +0000
Commit: Liam McLoughlin <hexxeh <AT> hexxeh <DOT> net>
CommitDate: Sun Jul 24 01:43:17 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoaster.git;a=commit;h=449e4f5e
Use config file, defines to control settings, more Zend standards work
---
config.php | 29 +++++++++++++++++++++++++++++
web/config.php | 11 +++++++++++
2 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/config.php b/config.php
new file mode 100644
index 0000000..760c1e2
--- /dev/null
+++ b/config.php
@@ -0,0 +1,29 @@
+<?php
+
+ // Gentoaster build daemon settings
+ // Licensed under GPL v3, see COPYING file
+
+ // Set the path that completed images should be stored at
+ define("CONFIGURATIONS_PATH", "/var/www/gentoaster/images");
+
+ // Set the path to the folder the Gentoaster tool is at
+ define("GENTOASTER_PATH", "/usr/share/gentoaster");
+
+ // Set the name of the image creation tool
+ define("BUILD_TOOL_NAME", "create_image.sh");
+
+ // Set the name of the testdrive wrapper
+ define("WRAP_TOOL_NAME", "wrap.sh");
+
+ // Set the externally accessible IP/host of this machine
+ define("EXTERNAL_HOST", "192.168.2.169");
+
+ // Set the port range that should be used for testdrives
+ define("LOW_PORT", 5900);
+ define("HIGH_PORT", 5999);
+
+ // Set the MySQL access details that should be used
+ define("MYSQL_HOSTNAME", "localhost");
+ define("MYSQL_USERNAME", "gentoaster");
+ define("MYSQL_PASSWORD", "");
+ define("MYSQL_DATABASE", "gentoaster");
\ No newline at end of file
diff --git a/web/config.php b/web/config.php
new file mode 100644
index 0000000..7e0058a
--- /dev/null
+++ b/web/config.php
@@ -0,0 +1,11 @@
+<?php
+
+ // Gentoaster web interface settings
+ // Licensed under GPL v3, see COPYING file
+
+ define("ZONETAB", "/usr/share/zoneinfo/zone.tab");
+
+ define("MYSQL_HOSTNAME", "localhost");
+ define("MYSQL_USERNAME", "gentoaster");
+ define("MYSQL_PASSWORD", "");
+ define("MYSQL_DATABASE", "gentoaster");
\ No newline at end of file
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [gentoo-commits] proj/gentoaster:master commit in: /, web/
@ 2011-08-12 23:17 Liam McLoughlin
0 siblings, 0 replies; 8+ messages in thread
From: Liam McLoughlin @ 2011-08-12 23:17 UTC (permalink / raw
To: gentoo-commits
commit: 5099c71493abe193f23b7f0a7381e539bc67bb33
Author: Liam McLoughlin <hexxeh <AT> hexxeh <DOT> net>
AuthorDate: Wed Jul 27 19:29:49 2011 +0000
Commit: Liam McLoughlin <hexxeh <AT> hexxeh <DOT> net>
CommitDate: Wed Jul 27 19:29:49 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoaster.git;a=commit;h=5099c714
Moved to using mysqli and prepared statements
---
client.php | 19 +++++----
daemon.php | 108 ++++++++++++++++++++++++++++++++++------------------
status.php | 40 ++++++++++++--------
web/config.php | 2 +-
web/process.php | 60 +++++++++++++++++++----------
web/status.php | 61 +++++++++++++++---------------
web/testdrive.php | 39 ++++++++++++-------
7 files changed, 200 insertions(+), 129 deletions(-)
diff --git a/client.php b/client.php
index e2284b4..56313ae 100644
--- a/client.php
+++ b/client.php
@@ -21,13 +21,16 @@
echo "Job sent, handle was ".$handle." - hash ".$handlehash."\n";
- $db = mysql_connect(MYSQL_HOSTNAME, MYSQL_USERNAME, MYSQL_PASSWORD);
- if (!$db) {
- die("Could not connect to database ".mysql_error());
+ $db = new mysqli(MYSQL_HOSTNAME, MYSQL_USERNAME,
+ MYSQL_PASSWORD, MYSQL_DATABASE);
+ if (mysqli_connect_errno()) {
+ die("Could not connect to database ".mysqli_connect_error());
}
- mysql_select_db(MYSQL_DATABASE);
- $query = "INSERT INTO builds (id, handle)".
- ." VALUES('".$handlehash."','".$handle."')";
- mysql_query($query);
- echo "Job handle mapping added to database\n";
+ $query = "INSERT INTO builds (id, handle) VALUES(?, ?)";
+ $stmt = $db->prepare($query);
+ $stmt->bind_param("ss", $handlehash, $handle);
+ $stmt->execute();
+ $stmt->close();
+ $db->close();
+ echo "Job handle mapping added to database\n";
\ No newline at end of file
diff --git a/daemon.php b/daemon.php
index 1936864..5fa09b2 100644
--- a/daemon.php
+++ b/daemon.php
@@ -17,16 +17,22 @@
{
$result = trim($result);
echo "A job finished with return code ".$returncode.": ".$result."\n";
- $db = mysql_connect(MYSQL_HOSTNAME, MYSQL_USERNAME, MYSQL_PASSWORD);
- if (!$db) {
- die("Could not connect to database ".mysql_error());
+
+ $db = new mysqli(MYSQL_HOSTNAME, MYSQL_USERNAME,
+ MYSQL_PASSWORD, MYSQL_DATABASE);
+ if (mysqli_connect_errno()) {
+ die("Could not connect to database ".mysqli_connect_error());
}
- mysql_select_db(MYSQL_DATABASE);
- $result = mysql_real_escape_string($result);
- $query = "UPDATE builds".
- " SET result = '".$result."', returncode = '".$returncode.
- "' WHERE handle = '".mysql_real_escape_string($handle)."'";
- mysql_query($query);
+
+ $query = "UPDATE builds SET result = ?, returncode = ? ".
+ "WHERE handle = ?";
+
+ $stmt = $db->prepare($query);
+ $stmt->bind_param("sds", $result, $returncode, $handle);
+ $stmt->execute();
+ $stmt->close();
+ $db->close();
+
return serialize(array($returncode, $result));
}
@@ -103,26 +109,42 @@
$insert = false;
$update = false;
- $db = mysql_connect(MYSQL_HOSTNAME, MYSQL_USERNAME, MYSQL_PASSWORD);
- if (!$db) {
- die("Could not connect to database ".mysql_error());
+ $db = new mysqli(MYSQL_HOSTNAME, MYSQL_USERNAME,
+ MYSQL_PASSWORD, MYSQL_DATABASE);
+ if (mysqli_connect_errno()) {
+ die("Could not connect to database ".mysqli_connect_error());
}
- mysql_select_db(MYSQL_DATABASE);
+
+ $query = "UPDATE builds SET result = ?, returncode = ? ".
+ "WHERE handle = ?";
+
+ $stmt = $db->prepare($query);
+ $stmt->bind_param("sds", $result, $returncode, $handle);
+ $stmt->execute();
+ $stmt->close();
+ $db->close();
+
$query = "SELECT port FROM ports ORDER BY port DESC LIMIT 1";
- $result = mysql_query($query);
- if (mysql_num_rows($result) == 0) {
+ $stmt = $db->prepare($query);
+ $stmt->execute();
+ if ($stmt->num_rows == 0) {
// no ports! assign a new one
+ $stmt->close();
$port = LOW_PORT;
$insert = true;
echo "No ports! Assigning ".$port."\n";
} else {
// we have a port! let's check if our vm has one
- $ports = mysql_fetch_array($result);
- $lastport = $ports[0];
- $query = "SELECT port, pid FROM ports WHERE id = '".$buildID."'";
- $result = mysql_query($query);
- if (mysql_num_rows($result) == 0) {
+ $stmt->bind_result($lastport);
+ $stmt->fetch();
+ $stmt->close();
+ $query = "SELECT port, pid FROM ports WHERE id = ?";
+ $stmt = $db->prepare($query);
+ $stmt->bind_param("s", $buildID);
+ $stmt->execute();
+ if ($stmt->num_rows == 0) {
// vm doesn't have one, assign one!
+ $stmt->close();
$port = $lastport+1;
if ($port > HIGH_PORT) {
$port = LOW_PORT;
@@ -131,18 +153,18 @@
echo "Assigning new port ".$port."\n";
} else {
// vm already has one, return it
- $ports = mysql_fetch_array($result);
- $port = $ports[0];
- $pid = $ports[1];
- $running = true;
- if (!check_pid($pid)) {
- $running = false;
- $update = true;
- echo "VM is not running, PID ".$pid." is dead!\n";
- } else {
- echo "VM is running on PID ".$pid."\n";
- }
- echo "VM already has port ".$port."\n";
+ $stmt->bind_result($port, $pid);
+ $stmt->fetch();
+ $stmt->close();
+ $running = true;
+ if (!check_pid($pid)) {
+ $running = false;
+ $update = true;
+ echo "VM is not running, PID ".$pid." is dead!\n";
+ } else {
+ echo "VM is running on PID ".$pid."\n";
+ }
+ echo "VM already has port ".$port."\n";
}
}
@@ -162,17 +184,27 @@
$pid = $pid + 2;
if ($insert) {
- $query = "DELETE FROM ports WHERE port = ".$port;
- $result = mysql_query($query);
- $query = "INSERT INTO ports (id, port, pid) VALUES('".mysql_real_escape_string($buildID)."', ".$port.", ".$pid.")";
- $result = mysql_query($query);
+ $query = "DELETE FROM ports WHERE port = ?";
+ $stmt = $db->prepare($query);
+ $stmt->bind_param("d", $port);
+ $stmt->execute();
+ $stmt->close();
+ $query = "INSERT INTO ports (id, port, pid) VALUES(?, ?, ?)";
+ $stmt = $db->prepare($query);
+ $stmt->bind_param("sdd", $buildID, $port, $pid);
+ $stmt->execute();
+ $stmt->close();
echo "Doing insert!\n";
} elseif ($update) {
- $query = "UPDATE ports SET pid = ".$pid." WHERE id = '".$buildID."'";
- $result = mysql_query($query);
+ $query = "UPDATE ports SET pid = ? WHERE id = ?";
+ $stmt = $db->prepare($query);
+ $stmt->bind_param("ds", $pid, $buildID);
+ $stmt->execute();
+ $stmt->close();
echo "Doing update\n";
}
+ $db->close();
$port = $port+1000;
return serialize(array(EXTERNAL_HOST, $port));
}
diff --git a/status.php b/status.php
index 48f4dff..66d55f8 100644
--- a/status.php
+++ b/status.php
@@ -8,17 +8,21 @@
if (!isset($argv[1])) {
die("No handle hash given\n");
}
- $db = mysql_connect(MYSQL_HOSTNAME, MYSQL_USERNAME, MYSQL_PASSWORD);
- if (!$db) {
- die("Could not connect to database ".mysql_error()."\n");
+
+ $db = new mysqli(MYSQL_HOSTNAME, MYSQL_USERNAME,
+ MYSQL_PASSWORD, MYSQL_DATABASE);
+ if (mysqli_connect_errno()) {
+ die("Could not connect to database ".mysqli_connect_error());
}
- mysql_select_db(MYSQL_DATABASE);
- $query = "SELECT handle FROM builds ".
- "WHERE id = '".mysql_real_escape_string($argv[1])."'";
- $result = mysql_query($query);
- if (mysql_num_rows($result) == 1) {
- $handles = mysql_fetch_array($result);
- $handle = $handles[0];
+
+ $query = "SELECT handle FROM builds WHERE id = ?";
+ $stmt = $db->prepare($query);
+ $stmt->bind_param("s", $argv[1]);
+ $stmt->execute();
+ $stmt->store_result();
+ if ($stmt->num_rows == 1) {
+ $stmt->bind_result($handle);
+ $stmt->close();
$client = new GearmanClient();
$client->addServer();
@@ -33,11 +37,14 @@
}
} else {
$query = "SELECT returncode, result FROM builds ".
- "WHERE id = '".mysql_real_escape_string($argv[1])."'";
- $result = mysql_query($query);
- $jobres = mysql_fetch_array($result);
- if ($jobres[0] !== null) {
- echo "Job returned with code ".$jobres[0].": ".$jobres[1]."\n";
+ "WHERE id = ?";
+ $stmt = $db->prepare($query);
+ $stmt->bind_param("s", $argv[1]);
+ $stmt->execute();
+ $stmt->bind_result($returncode, $result);
+ $stmt->fetch();
+ if ($returncode !== null) {
+ echo "Job returned with code ".$returncode.": ".$result."\n";
} else {
echo "Job failed\n";
}
@@ -45,4 +52,5 @@
} else {
echo "Invalid handle hash\n";
}
-
+
+ $db->close();
\ No newline at end of file
diff --git a/web/config.php b/web/config.php
index 6d5735c..30d6aa4 100644
--- a/web/config.php
+++ b/web/config.php
@@ -16,6 +16,6 @@
define("MYSQL_DATABASE", "gentoaster");
// Set the RECAPTCHA keys that should be used, if enabled
- define("RECAPTCHA_ENABLED", true);
+ define("RECAPTCHA_ENABLED", false);
define("RECAPTCHA_PUBLIC_KEY","REPLACE_ME");
define("RECAPTCHA_PRIVATE_KEY", "REPLACE_ME");
\ No newline at end of file
diff --git a/web/process.php b/web/process.php
index 43827b9..238e843 100644
--- a/web/process.php
+++ b/web/process.php
@@ -8,27 +8,42 @@
if (RECAPTCHA_ENABLED) {
require_once "recaptcha.php";
+ $remoteAddress = filter_input(INPUT_SERVER,
+ "remote_addr",
+ FILTER_VALIDATE_IP);
+ $challenge = filter_input(INPUT_POST,
+ "recaptcha_challenge_field",
+ FILTER_UNSAFE_RAW);
+ $response = filter_input(INPUT_POST,
+ "recaptcha_response_field",
+ FILTER_UNSAFE_RAW);
+
$resp = recaptcha_check_answer(RECAPTCHA_PRIVATE_KEY,
- $_SERVER["REMOTE_ADDR"],
- $_POST["recaptcha_challenge_field"],
- $_POST["recaptcha_response_field"]);
+ $remoteAddress,
+ $challenge,
+ $response);
if (!$resp->is_valid) {
die("CAPTCHA was incorrect");
}
}
+ function sanitize_shellarg($arg) {
+ return escapeshellarg($arg);
+ }
+ define("FILTER_SANITIZE_SHELL", array("options" => "sanitize_shellarg"));
+
$buildID = uniqid();
- $bootMegabytes = intval($_POST["boot_size"]);
- $swapMegabytes = intval($_POST["swap_size"]);
- $rootMegabytes = intval($_POST["root_size"]);
- $timezone = escapeshellarg($_POST["timezone"]);
- $hostname = escapeshellarg($_POST["hostname"]);
- $username = escapeshellarg($_POST["username"]);
- $password = escapeshellarg($_POST["password"]);
- $rootPassword = escapeshellarg($_POST["rootpassword"]);
- $packagesList = escapeshellarg($_POST["packages"]);
- $outputFormat = escapeshellarg($_POST["format"]);
+ $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_SANITIZE_SHELL);
+ $hostname = filter_input(INPUT_POST, "hostname", FILTER_SANITIZE_SHELL);
+ $username = filter_input(INPUT_POST, "username", FILTER_SANITIZE_SHELL);
+ $password = filter_input(INPUT_POST, "password", FILTER_SANITIZE_SHELL);
+ $rootPass = filter_input(INPUT_POST, "rootpassword", FILTER_SANITIZE_SHELL);
+ $packagesList = filter_input(INPUT_POST, "packages", FILTER_SANITIZE_SHELL);
+ $outputFormat = filter_input(INPUT_POST, "format", FILTER_SANITIZE_SHELL);
$packagesList = str_replace("\r\n", " ", $packagesList);
$packagesList = str_replace("\n", " ", $packagesList);
@@ -41,7 +56,7 @@ SWAP_MEGABYTES='$swapMegabytes'
ROOT_MEGABYTES='$rootMegabytes'
TIMEZONE=$timezone
HOSTNAME=$hostname
-ROOT_PASSWORD=$rootPassword
+ROOT_PASSWORD=$rootPass
DEFAULT_USERNAME=$username
DEFAULT_PASSWORD=$password
USE_FLAGS=''
@@ -55,13 +70,16 @@ OUTPUT_FORMAT=$outputFormat";
$client->addServer();
$handle = $client->doBackground("invoke_image_build", $iniString);
- $db = mysql_connect(MYSQL_HOSTNAME, MYSQL_USERNAME, MYSQL_PASSWORD);
- if (!$db) {
- die("Could not connect to database ".mysql_error());
+ $db = new mysqli(MYSQL_HOSTNAME, MYSQL_USERNAME,
+ MYSQL_PASSWORD, MYSQL_DATABASE);
+ if (mysqli_connect_errno()) {
+ die("Could not connect to database ".mysqli_connect_error());
}
- mysql_select_db(MYSQL_DATABASE);
- $query = "INSERT INTO builds (id, handle) ".
- "VALUES('".$buildID."','".$handle."')";
- mysql_query($query);
+
+ $stmt = $db->prepare("INSERT INTO builds (id, handle) VALUES(?, ?)");
+ $stmt->bind_param("ss", $buildID, $handle);
+ $stmt->execute();
+ $stmt->close();
+ $db->close();
header("Location: finished.php?uuid=".$buildID);
\ No newline at end of file
diff --git a/web/status.php b/web/status.php
index 86e7e0e..719afe6 100644
--- a/web/status.php
+++ b/web/status.php
@@ -5,22 +5,24 @@
require_once "config.php";
- $buildID = $_GET["uuid"];
+ $buildID = filter_input(INPUT_GET, "uuid", FILTER_UNSAFE_RAW);
$buildresult = "Unknown!";
$inprogress = false;
$builddone = false;
- $db = mysql_connect(MYSQL_HOSTNAME, MYSQL_USERNAME, MYSQL_PASSWORD);
- if (!$db) {
- die("Could not connect to database ".mysql_error()."\n");
+ $db = new mysqli(MYSQL_HOSTNAME, MYSQL_USERNAME,
+ MYSQL_PASSWORD, MYSQL_DATABASE);
+ if (mysqli_connect_errno()) {
+ die("Could not connect to database ".mysqli_connect_error());
}
- mysql_select_db(MYSQL_DATABASE);
- $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];
+
+ $stmt = $db->prepare("SELECT handle FROM builds WHERE id = ?");
+ $stmt->bind_param("s", $buildID);
+ $stmt->execute();
+ if ($stmt->num_rows == 1) {
+ $stmt->bind_result($handle);
+ $stmt->fetch();
+ $stmt->close();
$client = new GearmanClient();
$client->addServer();
@@ -35,13 +37,14 @@
$buildresult = "Task has not yet been processed";
}
} else {
- $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) {
+ $stmt = $db->prepare("SELECT returncode, result FROM builds WHERE id = ?");
+ $stmt->bind_param("s", $buildID);
+ $stmt->execute();
+ $stmt->bind_result($returncode, $result);
+ $stmt->fetch();
+ $stmt->close();
+ if ($returncode !== null) {
+ if ($returncode == 0) {
$buildresult = "Your build is complete! ".
"What would you like to do now?".
"<br /><br /><center>".
@@ -56,16 +59,24 @@
"</table></center>";
$builddone = true;
} else {
- $buildresult = "Job returned with code ".$jobres[0].": ".$jobres[1];
+ $buildresult = "Job returned with code ".$returncode.": ".$result;
}
} else {
$buildresult = "Job failed";
}
}
} else {
+ $stmt->close();
$buildresult = "Invalid handle hash";
}
+ $db->close();
+
+ if (!$builddone) {
+ $titleString = "How's things?";
+ } else {
+ $titleString = "It's showtime!";
+ }
?>
<html>
<head>
@@ -90,17 +101,7 @@
<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
- }
- ?>
+ <h1><?php echo $titleString; ?></h1>
<p>
<?php echo $buildresult; ?>
<div id="progressbar"></div>
diff --git a/web/testdrive.php b/web/testdrive.php
index 066dd4c..8f3c718 100644
--- a/web/testdrive.php
+++ b/web/testdrive.php
@@ -5,19 +5,24 @@
require_once "config.php";
- $buildID = $_GET["uuid"];
+ $buildID = filter_input(INPUT_GET, "uuid", FILTER_UNSAFE_RAW);
$buildresult = "Unknown!";
$inprogress = false;
- $db = mysql_connect(MYSQL_HOSTNAME, MYSQL_USERNAME, MYSQL_PASSWORD);
- if (!$db) {
- die("Could not connect to database ".mysql_error()."\n");
+ $db = new mysqli(MYSQL_HOSTNAME, MYSQL_USERNAME,
+ MYSQL_PASSWORD, MYSQL_DATABASE);
+ if (mysqli_connect_errno()) {
+ die("Could not connect to database ".mysqli_connect_error());
}
- mysql_select_db(MYSQL_DATABASE);
- $result = mysql_query("SELECT handle FROM builds WHERE id = '".mysql_real_escape_string($buildID)."'");
- if (mysql_num_rows($result) == 1) {
- $handles = mysql_fetch_array($result);
- $handle = $handles[0];
+
+ $stmt = $db->prepare("SELECT handle FROM builds WHERE id = ?");
+ $stmt->bind_param("s", $buildID);
+ $stmt->execute();
+
+ if ($stmt->num_rows == 1) {
+ $stmt->bind_result($handle);
+ $stmt->fetch();
+ $stmt->close();
$client = new GearmanClient();
$client->addServer();
@@ -25,12 +30,14 @@
if ($status[0]) {
header("Location: status.php?uuid=".$buildID);
} else {
- $cleanBuildID = mysql_real_escape_string($buildID);
- $query = "SELECT returncode, result FROM builds WHERE id = '".$cleanBuildID."'";
- $result = mysql_query();
- $jobres = mysql_fetch_array($result);
- if ($jobres[0] !== null) {
- if ($jobres[0] == 0) {
+ $stmt = $db->prepare("SELECT returncode, result FROM builds WHERE id = ?");
+ $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();
@@ -44,9 +51,11 @@
}
}
} else {
+ $stmt->close();
die("Invalid handle hash");
}
+ $db->close();
?>
<html>
<head>
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [gentoo-commits] proj/gentoaster:master commit in: /, web/
2011-07-24 2:43 [gentoo-commits] proj/gentoaster:webui " Liam McLoughlin
@ 2011-08-12 23:17 ` Liam McLoughlin
0 siblings, 0 replies; 8+ messages in thread
From: Liam McLoughlin @ 2011-08-12 23:17 UTC (permalink / raw
To: gentoo-commits
commit: bc79e5240cd4544c9f953c48ecafdf4693bd1d64
Author: Liam McLoughlin <hexxeh <AT> hexxeh <DOT> net>
AuthorDate: Sun Jul 24 02:10:52 2011 +0000
Commit: Liam McLoughlin <hexxeh <AT> hexxeh <DOT> net>
CommitDate: Sun Jul 24 02:34:15 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoaster.git;a=commit;h=bc79e524
Adding RECAPTCHA, more standards work
---
client.php | 14 ++-
daemon.php | 164 +++++++++++++++----------------
status.php | 20 +++-
web/config.php | 12 ++-
web/index.php | 28 +++++-
web/process.php | 26 +++++-
web/recaptcha.php | 277 +++++++++++++++++++++++++++++++++++++++++++++++++++++
web/status.php | 15 ++-
web/testdrive.php | 15 ++-
9 files changed, 462 insertions(+), 109 deletions(-)
diff --git a/client.php b/client.php
index ce4bc1f..e2284b4 100644
--- a/client.php
+++ b/client.php
@@ -3,7 +3,11 @@
// Gentoaster build daemon client
// Licensed under GPL v3, see COPYING file
- if(!isset($argv[1])) die("No config file provided\n");
+ require_once "config.php";
+
+ if (!isset($argv[1])) {
+ die("No config file provided\n");
+ }
$client= new GearmanClient();
$client->addServer();
@@ -17,9 +21,11 @@
echo "Job sent, handle was ".$handle." - hash ".$handlehash."\n";
- $db = mysql_connect("localhost", "gentoaster", "");
- if(!$db) die("Could not connect to database ".mysql_error());
- mysql_select_db("gentoaster");
+ $db = mysql_connect(MYSQL_HOSTNAME, MYSQL_USERNAME, MYSQL_PASSWORD);
+ if (!$db) {
+ die("Could not connect to database ".mysql_error());
+ }
+ mysql_select_db(MYSQL_DATABASE);
$query = "INSERT INTO builds (id, handle)".
." VALUES('".$handlehash."','".$handle."')";
mysql_query($query);
diff --git a/daemon.php b/daemon.php
index 6570185..1936864 100644
--- a/daemon.php
+++ b/daemon.php
@@ -3,31 +3,25 @@
// Gentoaster build daemon worker
// Licensed under GPL v3, see COPYING file
- $configurationsPath = "/var/www/gentoaster/images";
- $gentoasterPath = "/usr/share/gentoaster";
- $buildToolName = "create_image.sh";
- $wrapToolName = "wrap.sh";
- $externalHost = "192.168.2.169";
- $lowPort = 5900;
- $highPort = 5999;
-
- // DO NOT EDIT BELOW THIS LINE
-
- $progressMagic = 23;
+ require_once "config.php";
$worker = new GearmanWorker();
$worker->addServer();
$worker->addFunction("invoke_image_build", "image_build");
$worker->addFunction("invoke_start_image", "start_image");
- while ($worker->work());
+ while ($worker->work()) {
+ // Do nothing!
+ };
function update_result($handle, $returncode, $result)
{
$result = trim($result);
echo "A job finished with return code ".$returncode.": ".$result."\n";
- $db = mysql_connect("localhost", "gentoaster", "");
- if(!$db) die("Could not connect to database ".mysql_error());
- mysql_select_db("gentoaster");
+ $db = mysql_connect(MYSQL_HOSTNAME, MYSQL_USERNAME, MYSQL_PASSWORD);
+ if (!$db) {
+ die("Could not connect to database ".mysql_error());
+ }
+ mysql_select_db(MYSQL_DATABASE);
$result = mysql_real_escape_string($result);
$query = "UPDATE builds".
" SET result = '".$result."', returncode = '".$returncode.
@@ -36,19 +30,19 @@
return serialize(array($returncode, $result));
}
- function check_pid($pid)
- {
- $cmd = "ps $pid";
- exec($cmd, $output, $result);
- if(count($output) >= 2){
- return true;
- }
- return false;
- }
+ function check_pid($pid)
+ {
+ $cmd = "ps $pid";
+ exec($cmd, $output, $result);
+ if (count($output) >= 2) {
+ return true;
+ }
+ return false;
+ }
function image_build($job)
{
- global $configurationsPath, $gentoasterPath, $buildToolName, $progressMagic;
+ $progressMagic = 23;
$handle = $job->handle();
$handlehash = md5($handle);
@@ -58,17 +52,17 @@
$configurationString = $job->workload();
$configurationArray = parse_ini_string($configurationString);
- if ($configurationArray !== FALSE) {
+ if ($configurationArray !== false) {
if (isset($configurationArray["BUILD_ID"])) {
$buildID = $configurationArray["BUILD_ID"];
- $buildPath = $configurationsPath."/".$buildID;
+ $buildPath = CONFIGURATIONS_PATH."/".$buildID;
@mkdir($buildPath, 0777, true);
if (is_writable($buildPath)) {
chdir($buildPath);
file_put_contents("config.ini", $configurationString);
$toolArgs = "--config config.ini --compress";
- $cmd = $gentoasterPath."/".$buildToolName." ".$toolArgs;
+ $cmd = GENTOASTER_PATH."/".BUILD_TOOL_NAME." ".$toolArgs;
$processHandle = popen($cmd." 2>&1", "r");
$nonstatusOutput = "";
@@ -104,83 +98,83 @@
function start_image($job)
{
- global $configurationsPath, $gentoasterPath, $wrapToolName;
- global $externalHost, $lowPort, $highPort;
-
$buildID = $job->workload();
$running = false;
$insert = false;
$update = false;
- $db = mysql_connect("localhost", "gentoaster", "");
- if(!$db) die("Could not connect to database ".mysql_error());
- mysql_select_db("gentoaster");
+ $db = mysql_connect(MYSQL_HOSTNAME, MYSQL_USERNAME, MYSQL_PASSWORD);
+ if (!$db) {
+ die("Could not connect to database ".mysql_error());
+ }
+ mysql_select_db(MYSQL_DATABASE);
$query = "SELECT port FROM ports ORDER BY port DESC LIMIT 1";
$result = mysql_query($query);
- if(mysql_num_rows($result) == 0) {
- // no ports! assign a new one
- $port = $lowPort;
- $insert = true;
- echo "No ports! Assigning ".$port."\n";
+ if (mysql_num_rows($result) == 0) {
+ // no ports! assign a new one
+ $port = LOW_PORT;
+ $insert = true;
+ echo "No ports! Assigning ".$port."\n";
} else {
- // we have a port! let's check if our vm has one
- $ports = mysql_fetch_array($result);
- $lastport = $ports[0];
- $query = "SELECT port, pid FROM ports WHERE id = '".$buildID."'";
- $result = mysql_query($query);
- if (mysql_num_rows($result) == 0) {
- // vm doesn't have one, assign one!
- $port = $lastport+1;
- if ($port > $highPort) {
- $port = $lowPort;
- }
- $insert = true;
- echo "Assigning new port ".$port."\n";
- } else {
- // vm already has one, return it
- $ports = mysql_fetch_array($result);
- $port = $ports[0];
- $pid = $ports[1];
- $running = true;
- if(!check_pid($pid)) {
- $running = false;
- $update = true;
- echo "VM is not running, PID ".$pid." is dead!\n";
- } else {
- echo "VM is running on PID ".$pid."\n";
- }
- echo "VM already has port ".$port."\n";
- }
+ // we have a port! let's check if our vm has one
+ $ports = mysql_fetch_array($result);
+ $lastport = $ports[0];
+ $query = "SELECT port, pid FROM ports WHERE id = '".$buildID."'";
+ $result = mysql_query($query);
+ if (mysql_num_rows($result) == 0) {
+ // vm doesn't have one, assign one!
+ $port = $lastport+1;
+ if ($port > HIGH_PORT) {
+ $port = LOW_PORT;
+ }
+ $insert = true;
+ echo "Assigning new port ".$port."\n";
+ } else {
+ // vm already has one, return it
+ $ports = mysql_fetch_array($result);
+ $port = $ports[0];
+ $pid = $ports[1];
+ $running = true;
+ if (!check_pid($pid)) {
+ $running = false;
+ $update = true;
+ echo "VM is not running, PID ".$pid." is dead!\n";
+ } else {
+ echo "VM is running on PID ".$pid."\n";
+ }
+ echo "VM already has port ".$port."\n";
+ }
}
if (!$running || $update) {
- $cmd = $gentoasterPath."/".$wrapToolName." ".
- $configurationsPath."/".$buildID."/".$buildID.".image ".
- $port." &";
- $handle = proc_open($cmd, array(), $foo);
- $status = proc_get_status($handle);
- $pid = $status["pid"];
- echo "New process spawned with PID ".$pid."\n";
- proc_close($handle);
+ $cmd = GENTOASTER_PATH."/".WRAP_TOOL_NAME." ".
+ CONFIGURATIONS_PATH."/".$buildID."/".$buildID.".image ".
+ $port." &";
+ $handle = proc_open($cmd, array(), $foo);
+ $status = proc_get_status($handle);
+ $pid = $status["pid"];
+ echo "New process spawned with PID ".$pid."\n";
+ proc_close($handle);
}
// qemu pid is two up
+ // hacky? works for now though
$pid = $pid + 2;
if ($insert) {
- $query = "DELETE FROM ports WHERE port = ".$port;
- $result = mysql_query($query);
- $query = "INSERT INTO ports (id, port, pid) VALUES('".mysql_real_escape_string($buildID)."', ".$port.", ".$pid.")";
- $result = mysql_query($query);
- echo "Doing insert!\n";
- } elseif($update) {
- $query = "UPDATE ports SET pid = ".$pid." WHERE id = '".$buildID."'";
- $result = mysql_query($query);
- echo "Doing update\n";
+ $query = "DELETE FROM ports WHERE port = ".$port;
+ $result = mysql_query($query);
+ $query = "INSERT INTO ports (id, port, pid) VALUES('".mysql_real_escape_string($buildID)."', ".$port.", ".$pid.")";
+ $result = mysql_query($query);
+ echo "Doing insert!\n";
+ } elseif ($update) {
+ $query = "UPDATE ports SET pid = ".$pid." WHERE id = '".$buildID."'";
+ $result = mysql_query($query);
+ echo "Doing update\n";
}
$port = $port+1000;
- return serialize(array($externalHost, $port));
+ return serialize(array(EXTERNAL_HOST, $port));
}
diff --git a/status.php b/status.php
index a69bc35..48f4dff 100644
--- a/status.php
+++ b/status.php
@@ -1,8 +1,18 @@
<?php
- if (!isset($argv[1])) die("No handle hash given\n");
- $db = mysql_connect("localhost", "gentoaster", "");
- if (!$db) die("Could not connect to database ".mysql_error()."\n");
- mysql_select_db("gentoaster");
+
+ // Gentoaster build daemon status
+ // Licensed under GPL v3, see COPYING file
+
+ require_once "config.php";
+
+ if (!isset($argv[1])) {
+ die("No handle hash given\n");
+ }
+ $db = mysql_connect(MYSQL_HOSTNAME, MYSQL_USERNAME, MYSQL_PASSWORD);
+ if (!$db) {
+ die("Could not connect to database ".mysql_error()."\n");
+ }
+ mysql_select_db(MYSQL_DATABASE);
$query = "SELECT handle FROM builds ".
"WHERE id = '".mysql_real_escape_string($argv[1])."'";
$result = mysql_query($query);
@@ -26,7 +36,7 @@
"WHERE id = '".mysql_real_escape_string($argv[1])."'";
$result = mysql_query($query);
$jobres = mysql_fetch_array($result);
- if ($jobres[0] !== NULL) {
+ if ($jobres[0] !== null) {
echo "Job returned with code ".$jobres[0].": ".$jobres[1]."\n";
} else {
echo "Job failed\n";
diff --git a/web/config.php b/web/config.php
index 7e0058a..6d5735c 100644
--- a/web/config.php
+++ b/web/config.php
@@ -3,9 +3,19 @@
// Gentoaster web interface settings
// Licensed under GPL v3, see COPYING file
+ // Path to the zonetab file
define("ZONETAB", "/usr/share/zoneinfo/zone.tab");
+ // What should we limit the virtual machine disk size to?
+ define("MAX_DISK_SIZE", 16384);
+
+ // Set the MySQL access details that should be used
define("MYSQL_HOSTNAME", "localhost");
define("MYSQL_USERNAME", "gentoaster");
define("MYSQL_PASSWORD", "");
- define("MYSQL_DATABASE", "gentoaster");
\ No newline at end of file
+ define("MYSQL_DATABASE", "gentoaster");
+
+ // Set the RECAPTCHA keys that should be used, if enabled
+ define("RECAPTCHA_ENABLED", true);
+ define("RECAPTCHA_PUBLIC_KEY","REPLACE_ME");
+ define("RECAPTCHA_PRIVATE_KEY", "REPLACE_ME");
\ No newline at end of file
diff --git a/web/index.php b/web/index.php
index 1fd4d7d..43be192 100644
--- a/web/index.php
+++ b/web/index.php
@@ -1,15 +1,23 @@
<?php
- define("ZONETAB", "/usr/share/zoneinfo/zone.tab");
+ require_once "config.php";
+
+ if (RECAPTCHA_ENABLED) {
+ require_once "recaptcha.php";
+ }
$timezones = array();
$zonetab = file(ZONETAB);
foreach ($zonetab as $buf) {
- if (substr($buf, 0, 1)=='#') continue;
+ if (substr($buf, 0, 1)=='#') {
+ continue;
+ }
$rec = preg_split('/\s+/', $buf);
$key = $rec[2];
$val = $rec[2];
$c = count($rec);
- for ($i=3;$i<$c;$i++) $val.= ' '.$rec[$i];
+ for ($i=3;$i<$c;$i++) {
+ $val.= ' '.$rec[$i];
+ }
$timezones[$key] = $val;
ksort($timezones);
}
@@ -41,6 +49,20 @@
<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>
diff --git a/web/process.php b/web/process.php
index 93c5d68..43827b9 100644
--- a/web/process.php
+++ b/web/process.php
@@ -1,5 +1,23 @@
<?php
+ // Gentoaster web interface config processor
+ // Licensed under GPL v3, see COPYING file
+
+ require_once "config.php";
+
+ if (RECAPTCHA_ENABLED) {
+ require_once "recaptcha.php";
+
+ $resp = recaptcha_check_answer(RECAPTCHA_PRIVATE_KEY,
+ $_SERVER["REMOTE_ADDR"],
+ $_POST["recaptcha_challenge_field"],
+ $_POST["recaptcha_response_field"]);
+
+ if (!$resp->is_valid) {
+ die("CAPTCHA was incorrect");
+ }
+ }
+
$buildID = uniqid();
$bootMegabytes = intval($_POST["boot_size"]);
$swapMegabytes = intval($_POST["swap_size"]);
@@ -37,9 +55,11 @@ OUTPUT_FORMAT=$outputFormat";
$client->addServer();
$handle = $client->doBackground("invoke_image_build", $iniString);
- $db = mysql_connect("localhost", "gentoaster", "");
- if(!$db) die("Could not connect to database ".mysql_error());
- mysql_select_db("gentoaster");
+ $db = mysql_connect(MYSQL_HOSTNAME, MYSQL_USERNAME, MYSQL_PASSWORD);
+ if (!$db) {
+ die("Could not connect to database ".mysql_error());
+ }
+ mysql_select_db(MYSQL_DATABASE);
$query = "INSERT INTO builds (id, handle) ".
"VALUES('".$buildID."','".$handle."')";
mysql_query($query);
diff --git a/web/recaptcha.php b/web/recaptcha.php
new file mode 100644
index 0000000..32c4f4d
--- /dev/null
+++ b/web/recaptcha.php
@@ -0,0 +1,277 @@
+<?php
+/*
+ * This is a PHP library that handles calling reCAPTCHA.
+ * - Documentation and latest version
+ * http://recaptcha.net/plugins/php/
+ * - Get a reCAPTCHA API Key
+ * https://www.google.com/recaptcha/admin/create
+ * - Discussion group
+ * http://groups.google.com/group/recaptcha
+ *
+ * Copyright (c) 2007 reCAPTCHA -- http://recaptcha.net
+ * AUTHORS:
+ * Mike Crawford
+ * Ben Maurer
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+/**
+ * The reCAPTCHA server URL's
+ */
+define("RECAPTCHA_API_SERVER", "http://www.google.com/recaptcha/api");
+define("RECAPTCHA_API_SECURE_SERVER", "https://www.google.com/recaptcha/api");
+define("RECAPTCHA_VERIFY_SERVER", "www.google.com");
+
+/**
+ * Encodes the given data into a query string format
+ * @param $data - array of string elements to be encoded
+ * @return string - encoded request
+ */
+function _recaptcha_qsencode ($data) {
+ $req = "";
+ foreach ( $data as $key => $value )
+ $req .= $key . '=' . urlencode( stripslashes($value) ) . '&';
+
+ // Cut the last '&'
+ $req=substr($req,0,strlen($req)-1);
+ return $req;
+}
+
+
+
+/**
+ * Submits an HTTP POST to a reCAPTCHA server
+ * @param string $host
+ * @param string $path
+ * @param array $data
+ * @param int port
+ * @return array response
+ */
+function _recaptcha_http_post($host, $path, $data, $port = 80) {
+
+ $req = _recaptcha_qsencode ($data);
+
+ $http_request = "POST $path HTTP/1.0\r\n";
+ $http_request .= "Host: $host\r\n";
+ $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n";
+ $http_request .= "Content-Length: " . strlen($req) . "\r\n";
+ $http_request .= "User-Agent: reCAPTCHA/PHP\r\n";
+ $http_request .= "\r\n";
+ $http_request .= $req;
+
+ $response = '';
+ if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) {
+ die ('Could not open socket');
+ }
+
+ fwrite($fs, $http_request);
+
+ while ( !feof($fs) )
+ $response .= fgets($fs, 1160); // One TCP-IP packet
+ fclose($fs);
+ $response = explode("\r\n\r\n", $response, 2);
+
+ return $response;
+}
+
+
+
+/**
+ * Gets the challenge HTML (javascript and non-javascript version).
+ * This is called from the browser, and the resulting reCAPTCHA HTML widget
+ * is embedded within the HTML form it was called from.
+ * @param string $pubkey A public key for reCAPTCHA
+ * @param string $error The error given by reCAPTCHA (optional, default is null)
+ * @param boolean $use_ssl Should the request be made over ssl? (optional, default is false)
+
+ * @return string - The HTML to be embedded in the user's form.
+ */
+function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false)
+{
+ if ($pubkey == null || $pubkey == '') {
+ die ("To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>");
+ }
+
+ if ($use_ssl) {
+ $server = RECAPTCHA_API_SECURE_SERVER;
+ } else {
+ $server = RECAPTCHA_API_SERVER;
+ }
+
+ $errorpart = "";
+ if ($error) {
+ $errorpart = "&error=" . $error;
+ }
+ return '<script type="text/javascript" src="'. $server . '/challenge?k=' . $pubkey . $errorpart . '"></script>
+
+ <noscript>
+ <iframe src="'. $server . '/noscript?k=' . $pubkey . $errorpart . '" height="300" width="500" frameborder="0"></iframe><br/>
+ <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
+ <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
+ </noscript>';
+}
+
+
+
+
+/**
+ * A ReCaptchaResponse is returned from recaptcha_check_answer()
+ */
+class ReCaptchaResponse {
+ var $is_valid;
+ var $error;
+}
+
+
+/**
+ * Calls an HTTP POST function to verify if the user's guess was correct
+ * @param string $privkey
+ * @param string $remoteip
+ * @param string $challenge
+ * @param string $response
+ * @param array $extra_params an array of extra variables to post to the server
+ * @return ReCaptchaResponse
+ */
+function recaptcha_check_answer ($privkey, $remoteip, $challenge, $response, $extra_params = array())
+{
+ if ($privkey == null || $privkey == '') {
+ die ("To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>");
+ }
+
+ if ($remoteip == null || $remoteip == '') {
+ die ("For security reasons, you must pass the remote ip to reCAPTCHA");
+ }
+
+
+
+ //discard spam submissions
+ if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) {
+ $recaptcha_response = new ReCaptchaResponse();
+ $recaptcha_response->is_valid = false;
+ $recaptcha_response->error = 'incorrect-captcha-sol';
+ return $recaptcha_response;
+ }
+
+ $response = _recaptcha_http_post (RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify",
+ array (
+ 'privatekey' => $privkey,
+ 'remoteip' => $remoteip,
+ 'challenge' => $challenge,
+ 'response' => $response
+ ) + $extra_params
+ );
+
+ $answers = explode ("\n", $response [1]);
+ $recaptcha_response = new ReCaptchaResponse();
+
+ if (trim ($answers [0]) == 'true') {
+ $recaptcha_response->is_valid = true;
+ }
+ else {
+ $recaptcha_response->is_valid = false;
+ $recaptcha_response->error = $answers [1];
+ }
+ return $recaptcha_response;
+
+}
+
+/**
+ * gets a URL where the user can sign up for reCAPTCHA. If your application
+ * has a configuration page where you enter a key, you should provide a link
+ * using this function.
+ * @param string $domain The domain where the page is hosted
+ * @param string $appname The name of your application
+ */
+function recaptcha_get_signup_url ($domain = null, $appname = null) {
+ return "https://www.google.com/recaptcha/admin/create?" . _recaptcha_qsencode (array ('domains' => $domain, 'app' => $appname));
+}
+
+function _recaptcha_aes_pad($val) {
+ $block_size = 16;
+ $numpad = $block_size - (strlen ($val) % $block_size);
+ return str_pad($val, strlen ($val) + $numpad, chr($numpad));
+}
+
+/* Mailhide related code */
+
+function _recaptcha_aes_encrypt($val,$ky) {
+ if (! function_exists ("mcrypt_encrypt")) {
+ die ("To use reCAPTCHA Mailhide, you need to have the mcrypt php module installed.");
+ }
+ $mode=MCRYPT_MODE_CBC;
+ $enc=MCRYPT_RIJNDAEL_128;
+ $val=_recaptcha_aes_pad($val);
+ return mcrypt_encrypt($enc, $ky, $val, $mode, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");
+}
+
+
+function _recaptcha_mailhide_urlbase64 ($x) {
+ return strtr(base64_encode ($x), '+/', '-_');
+}
+
+/* gets the reCAPTCHA Mailhide url for a given email, public key and private key */
+function recaptcha_mailhide_url($pubkey, $privkey, $email) {
+ if ($pubkey == '' || $pubkey == null || $privkey == "" || $privkey == null) {
+ die ("To use reCAPTCHA Mailhide, you have to sign up for a public and private key, " .
+ "you can do so at <a href='http://www.google.com/recaptcha/mailhide/apikey'>http://www.google.com/recaptcha/mailhide/apikey</a>");
+ }
+
+
+ $ky = pack('H*', $privkey);
+ $cryptmail = _recaptcha_aes_encrypt ($email, $ky);
+
+ return "http://www.google.com/recaptcha/mailhide/d?k=" . $pubkey . "&c=" . _recaptcha_mailhide_urlbase64 ($cryptmail);
+}
+
+/**
+ * gets the parts of the email to expose to the user.
+ * eg, given johndoe@example,com return ["john", "example.com"].
+ * the email is then displayed as john...@example.com
+ */
+function _recaptcha_mailhide_email_parts ($email) {
+ $arr = preg_split("/@/", $email );
+
+ if (strlen ($arr[0]) <= 4) {
+ $arr[0] = substr ($arr[0], 0, 1);
+ } else if (strlen ($arr[0]) <= 6) {
+ $arr[0] = substr ($arr[0], 0, 3);
+ } else {
+ $arr[0] = substr ($arr[0], 0, 4);
+ }
+ return $arr;
+}
+
+/**
+ * Gets html to display an email address given a public an private key.
+ * to get a key, go to:
+ *
+ * http://www.google.com/recaptcha/mailhide/apikey
+ */
+function recaptcha_mailhide_html($pubkey, $privkey, $email) {
+ $emailparts = _recaptcha_mailhide_email_parts ($email);
+ $url = recaptcha_mailhide_url ($pubkey, $privkey, $email);
+
+ return htmlentities($emailparts[0]) . "<a href='" . htmlentities ($url) .
+ "' onclick=\"window.open('" . htmlentities ($url) . "', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;\" title=\"Reveal this e-mail address\">...</a>@" . htmlentities ($emailparts [1]);
+
+}
+
+
+?>
diff --git a/web/status.php b/web/status.php
index 20aacec..86e7e0e 100644
--- a/web/status.php
+++ b/web/status.php
@@ -1,13 +1,20 @@
<?php
+ // Gentoaster web interface finished stage
+ // Licensed under GPL v3, see COPYING file
+
+ require_once "config.php";
+
$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");
- mysql_select_db("gentoaster");
+ $db = mysql_connect(MYSQL_HOSTNAME, MYSQL_USERNAME, MYSQL_PASSWORD);
+ if (!$db) {
+ die("Could not connect to database ".mysql_error()."\n");
+ }
+ mysql_select_db(MYSQL_DATABASE);
$query = "SELECT handle FROM builds ".
"WHERE id = '".mysql_real_escape_string($buildID)."'";
$result = mysql_query($query);
@@ -33,7 +40,7 @@
"WHERE id = '".$cleanBuildID."'";
$result = mysql_query($query);
$jobres = mysql_fetch_array($result);
- if ($jobres[0] !== NULL) {
+ if ($jobres[0] !== null) {
if ($jobres[0] == 0) {
$buildresult = "Your build is complete! ".
"What would you like to do now?".
diff --git a/web/testdrive.php b/web/testdrive.php
index a313f39..066dd4c 100644
--- a/web/testdrive.php
+++ b/web/testdrive.php
@@ -1,12 +1,19 @@
<?php
+ // Gentoaster web interface testdrive
+ // Licensed under GPL v3, see COPYING file
+
+ require_once "config.php";
+
$buildID = $_GET["uuid"];
$buildresult = "Unknown!";
$inprogress = false;
- $db = mysql_connect("localhost", "gentoaster", "");
- if (!$db) die("Could not connect to database ".mysql_error()."\n");
- mysql_select_db("gentoaster");
+ $db = mysql_connect(MYSQL_HOSTNAME, MYSQL_USERNAME, MYSQL_PASSWORD);
+ if (!$db) {
+ die("Could not connect to database ".mysql_error()."\n");
+ }
+ mysql_select_db(MYSQL_DATABASE);
$result = mysql_query("SELECT handle FROM builds WHERE id = '".mysql_real_escape_string($buildID)."'");
if (mysql_num_rows($result) == 1) {
$handles = mysql_fetch_array($result);
@@ -22,7 +29,7 @@
$query = "SELECT returncode, result FROM builds WHERE id = '".$cleanBuildID."'";
$result = mysql_query();
$jobres = mysql_fetch_array($result);
- if ($jobres[0] !== NULL) {
+ if ($jobres[0] !== null) {
if ($jobres[0] == 0) {
// we're built, let's do this
$client = new GearmanClient();
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [gentoo-commits] proj/gentoaster:master commit in: /, web/
@ 2011-08-12 23:18 Liam McLoughlin
0 siblings, 0 replies; 8+ messages in thread
From: Liam McLoughlin @ 2011-08-12 23:18 UTC (permalink / raw
To: gentoo-commits
commit: ee02363d07131379c1e2537cffa20c453f596cad
Author: Liam McLoughlin <hexxeh <AT> hexxeh <DOT> net>
AuthorDate: Fri Aug 5 23:37:00 2011 +0000
Commit: Liam McLoughlin <hexxeh <AT> hexxeh <DOT> net>
CommitDate: Fri Aug 5 23:37:00 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoaster.git;a=commit;h=ee02363d
Add email notification support
---
config.php | 12 +++++++++++-
daemon.php | 28 ++++++++++++++++++++++++++++
web/index.php | 12 ++++++++++++
web/process.php | 7 ++++---
4 files changed, 55 insertions(+), 4 deletions(-)
diff --git a/config.php b/config.php
index 760c1e2..c1807fa 100644
--- a/config.php
+++ b/config.php
@@ -3,6 +3,9 @@
// Gentoaster build daemon settings
// Licensed under GPL v3, see COPYING file
+ // Set the publically viewable URL for this Gentoaster instance
+ define("GENTOASTER_URL", "http://192.168.2.169");
+
// Set the path that completed images should be stored at
define("CONFIGURATIONS_PATH", "/var/www/gentoaster/images");
@@ -26,4 +29,11 @@
define("MYSQL_HOSTNAME", "localhost");
define("MYSQL_USERNAME", "gentoaster");
define("MYSQL_PASSWORD", "");
- define("MYSQL_DATABASE", "gentoaster");
\ No newline at end of file
+ define("MYSQL_DATABASE", "gentoaster");
+
+ // Set the SMTP details that should be used for notifications
+ define("SMTP_ENABLED", false);
+ define("SMTP_HOST", "");
+ define("SMTP_USERNAME", "");
+ define("SMTP_PASSWORD", "");
+ define("SMTP_EMAIL", "");
\ No newline at end of file
diff --git a/daemon.php b/daemon.php
index 65d7d2b..4041317 100644
--- a/daemon.php
+++ b/daemon.php
@@ -4,6 +4,7 @@
// Licensed under GPL v3, see COPYING file
require_once "config.php";
+ require_once "Mail.php";
$worker = new GearmanWorker();
$worker->addServer();
@@ -36,6 +37,33 @@
$stmt->bind_param("sds", $result, $returncode, $handle);
$stmt->execute();
$stmt->close();
+
+ $query = "SELECT id, email FROM builds WHERE handle = ?";
+ $stmt = $db->prepare($query);
+ $stmt->bind_param("s", $handle);
+ $stmt->execute();
+ $stmt->bind_result($buildID, $email);
+ $stmt->fetch();
+
+ if($email != null) {
+ $headers = array('From' => SMTP_EMAIL,
+ 'To' => $email,
+ 'Subject' => "Your Gentoaster build has completed");
+
+ $smtp = Mail::factory('smtp',
+ array ('host' => SMTP_HOST,
+ 'auth' => true,
+ 'username' => SMTP_USERNAME,
+ 'password' => SMTP_PASSWORD));
+
+ $body = "Your Gentoaster build has finished.\n\n"
+ ."You can view the results at ".GENTOASTER_URL
+ ."/status.php?uuid=".$buildID;
+
+ $mail = $smtp->send($email, $headers, $body);
+ }
+
+ $stmt->close();
$db->close();
return serialize(array($returncode, $result));
diff --git a/web/index.php b/web/index.php
index dcaae6b..f46af2b 100644
--- a/web/index.php
+++ b/web/index.php
@@ -1,5 +1,6 @@
<?php
require_once "config.php";
+ require_once GENTOASTER_PATH."/config.php";
if (RECAPTCHA_ENABLED) {
require_once "recaptcha.php";
@@ -116,6 +117,17 @@
of your own personalised Gentoo virtual machine
image.</p>
</div>
+ <?php if(SMTP_ENABLED) { ?>
+ <div id="notifications" class="step">
+ <h1>Notifications</h1>
+ Want us to email you when your image has finished toasting?
+ Pop your email in here. If you don't want an email, simply
+ leave this field blank.<br /><br />
+ <label for="notifications_email">E-Mail</label>
+ <br />
+ <input type="text" name="email" id="notifications_email">
+ </div>
+ <?php } ?>
<?php
if (RECAPTCHA_ENABLED) {
?>
diff --git a/web/process.php b/web/process.php
index c590bee..de8ea90 100644
--- a/web/process.php
+++ b/web/process.php
@@ -62,6 +62,7 @@
$features = filter_input(INPUT_POST, "features", FILTER_CALLBACK, $sfi);
$keywords = filter_input(INPUT_POST, "keywords", FILTER_CALLBACK, $sfi);
$outputFormat = filter_input(INPUT_POST, "format", FILTER_CALLBACK, $sfi);
+ $email = filter_input(INPUT_POST, "email", FILTER_VALIDATE_EMAIL);
$iniString = "[vmconfig]
@@ -97,10 +98,10 @@ OUTPUT_FORMAT=$outputFormat";
die("Could not connect to database ".mysqli_connect_error());
}
- $query = "INSERT INTO builds (id, handle, ipaddress) ".
- "VALUES(?, ?, ?)";
+ $query = "INSERT INTO builds (id, handle, ipaddress, email) ".
+ "VALUES(?, ?, ?, ?)";
$stmt = $db->prepare($query);
- $stmt->bind_param("sss", $buildID, $handle, $ipaddress);
+ $stmt->bind_param("ssss", $buildID, $handle, $ipaddress, $email);
$stmt->execute();
$stmt->close();
$db->close();
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [gentoo-commits] proj/gentoaster:master commit in: /, web/
@ 2011-08-12 23:18 Liam McLoughlin
2011-08-10 17:39 ` [gentoo-commits] proj/gentoaster:webui " Liam McLoughlin
0 siblings, 1 reply; 8+ messages in thread
From: Liam McLoughlin @ 2011-08-12 23:18 UTC (permalink / raw
To: gentoo-commits
commit: 7f2c98b0d095c5c173fed07a0f8f32d51798d97e
Author: Liam McLoughlin <hexxeh <AT> hexxeh <DOT> net>
AuthorDate: Wed Aug 10 17:39:11 2011 +0000
Commit: Liam McLoughlin <hexxeh <AT> hexxeh <DOT> net>
CommitDate: Wed Aug 10 17:39:11 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoaster.git;a=commit;h=7f2c98b0
Combine configs, fix image download path via a new config option, add initscript
---
config.php | 9 ++++++++-
gentoaster | 35 +++++++++++++++++++++++++++++++++++
gentoaster.sql | 20 ++++++++++++++++++++
web/config.php | 11 ++++-------
web/index.php | 1 -
web/status.php | 2 +-
6 files changed, 68 insertions(+), 10 deletions(-)
diff --git a/config.php b/config.php
index c1807fa..96b5728 100644
--- a/config.php
+++ b/config.php
@@ -5,12 +5,19 @@
// Set the publically viewable URL for this Gentoaster instance
define("GENTOASTER_URL", "http://192.168.2.169");
+
+ // Set the publically viewable URL for images to be downloaded
+ // This should point to the same folder as CONFIGURATIONS_PATH
+ define("IMAGES_URL", "http://192.168.2.169/images");
// Set the path that completed images should be stored at
define("CONFIGURATIONS_PATH", "/var/www/gentoaster/images");
// Set the path to the folder the Gentoaster tool is at
- define("GENTOASTER_PATH", "/usr/share/gentoaster");
+ // As long as we're not being used by the WebUI
+ if (!defined("GENTOASTER_PATH")) {
+ define("GENTOASTER_PATH", "/usr/share/gentoaster");
+ }
// Set the name of the image creation tool
define("BUILD_TOOL_NAME", "create_image.sh");
diff --git a/gentoaster b/gentoaster
new file mode 100755
index 0000000..32d7d63
--- /dev/null
+++ b/gentoaster
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+USER=root
+GENTOASTER=/usr/share/gentoaster/daemon.php
+RETVAL=0
+
+start() {
+ echo "Starting Gentoaster"
+ start-stop-daemon --quiet --start --background --chuid "$USER" --exec /usr/bin/php -- -f $GENTOASTER
+ RETVAL=$?
+}
+stop() {
+ echo "Stopping Gentoaster"
+ killall -q -w -u $USER $GENTOASTER
+ RETVAL=$?
+}
+
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ *)
+ echo "Usage: gentoaster {start|stop|restart}"
+ exit 1
+ ;;
+esac
+exit $RETVAL
+
diff --git a/gentoaster.sql b/gentoaster.sql
new file mode 100644
index 0000000..17034b8
--- /dev/null
+++ b/gentoaster.sql
@@ -0,0 +1,20 @@
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `builds` (
+ `id` varchar(32) NOT NULL,
+ `handle` varchar(32) NOT NULL,
+ `returncode` int(11) DEFAULT NULL,
+ `result` text,
+ `ipaddress` varchar(15) DEFAULT NULL,
+ `email` varchar(50) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `ports` (
+ `id` varchar(32) NOT NULL,
+ `port` int(11) NOT NULL,
+ `pid` int(11) NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
diff --git a/web/config.php b/web/config.php
index 38076e8..9c5ef50 100644
--- a/web/config.php
+++ b/web/config.php
@@ -36,13 +36,10 @@
// What should we limit the virtual machine disk size to?
define("MAX_DISK_SIZE", 16384);
- // Set the MySQL access details that should be used
- define("MYSQL_HOSTNAME", "localhost");
- define("MYSQL_USERNAME", "gentoaster");
- define("MYSQL_PASSWORD", "");
- define("MYSQL_DATABASE", "gentoaster");
-
// Set the RECAPTCHA keys that should be used, if enabled
define("RECAPTCHA_ENABLED", false);
define("RECAPTCHA_PUBLIC_KEY", "REPLACE_ME");
- define("RECAPTCHA_PRIVATE_KEY", "REPLACE_ME");
\ No newline at end of file
+ define("RECAPTCHA_PRIVATE_KEY", "REPLACE_ME");
+
+ // Load all the configuration for the daemon, too
+ require_once GENTOASTER_PATH."/config.php";
\ No newline at end of file
diff --git a/web/index.php b/web/index.php
index f46af2b..6bb2f9f 100644
--- a/web/index.php
+++ b/web/index.php
@@ -1,6 +1,5 @@
<?php
require_once "config.php";
- require_once GENTOASTER_PATH."/config.php";
if (RECAPTCHA_ENABLED) {
require_once "recaptcha.php";
diff --git a/web/status.php b/web/status.php
index 69e8afc..bde0ad2 100644
--- a/web/status.php
+++ b/web/status.php
@@ -69,7 +69,7 @@
"What would you like to do now?".
"<br /><br /><center>".
"<table><tr><td>".
- "<a href=\"/gentoaster/".
+ "<a href=\"".IMAGES_URL."/".
$buildID."/".$buildID.
".tar.gz\">".
"<img style=\"padding: 10px;\" ".
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [gentoo-commits] proj/gentoaster:master commit in: /, web/
@ 2011-08-15 1:17 Liam McLoughlin
0 siblings, 0 replies; 8+ messages in thread
From: Liam McLoughlin @ 2011-08-15 1:17 UTC (permalink / raw
To: gentoo-commits
commit: 59ef3756049e55206ce30f9caceb6c2fa4566729
Author: Liam McLoughlin <hexxeh <AT> hexxeh <DOT> net>
AuthorDate: Mon Aug 15 01:17:34 2011 +0000
Commit: Liam McLoughlin <hexxeh <AT> hexxeh <DOT> net>
CommitDate: Mon Aug 15 01:17:34 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoaster.git;a=commit;h=59ef3756
Add default disk size option, fix daemon kernel config bug
---
daemon.php | 2 ++
web/config.php | 3 +++
web/index.php | 2 +-
3 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/daemon.php b/daemon.php
index 60c1616..04e0f4c 100644
--- a/daemon.php
+++ b/daemon.php
@@ -111,6 +111,8 @@
preg_match("/Step (.+):/", $progressLine, $matches);
if (sizeof($matches) > 0) {
$job->sendStatus($matches[1], $progressMagic);
+ } elseif (substr($progressLine, 0, 5) == "yes: ") {
+ // do nothing
} else {
$nonstatusOutput .= $progressLine;
}
diff --git a/web/config.php b/web/config.php
index bdb5b47..9d86c0c 100644
--- a/web/config.php
+++ b/web/config.php
@@ -33,6 +33,9 @@
// What should we set as the default list of packages?
define("DEFAULT_KEYWORDS", "");
+ // What should the default virtual machine disk size be?
+ define("DEFAULT_DISK_SIZE", 8192);
+
// What should we limit the virtual machine disk size to?
define("MAX_DISK_SIZE", 16384);
diff --git a/web/index.php b/web/index.php
index aa17151..8b50ba9 100644
--- a/web/index.php
+++ b/web/index.php
@@ -120,7 +120,7 @@
<label for="partitioning_size">Disk size</label>
<br />
<input id="partitioning_size" class="required"
- type="text" name="image_size" value="4096"><br>
+ type="text" name="image_size" value="<?php echo DEFAULT_DISK_SIZE; ?>"><br>
<label for="">Split</label><br /><br />
<div id="partitioning_split" name="split"></div>
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [gentoo-commits] proj/gentoaster:master commit in: /, web/
@ 2011-08-15 1:20 Liam McLoughlin
0 siblings, 0 replies; 8+ messages in thread
From: Liam McLoughlin @ 2011-08-15 1:20 UTC (permalink / raw
To: gentoo-commits
commit: 47445a62cf44af317b057d26a076948e006a9df9
Author: Liam McLoughlin <hexxeh <AT> hexxeh <DOT> net>
AuthorDate: Mon Aug 15 01:17:34 2011 +0000
Commit: Liam McLoughlin <hexxeh <AT> hexxeh <DOT> net>
CommitDate: Mon Aug 15 01:20:38 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoaster.git;a=commit;h=47445a62
Add default disk size option, fix daemon kernel config bug
---
daemon.php | 2 ++
web/config.php | 3 +++
web/index.php | 5 +++--
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/daemon.php b/daemon.php
index 60c1616..04e0f4c 100644
--- a/daemon.php
+++ b/daemon.php
@@ -111,6 +111,8 @@
preg_match("/Step (.+):/", $progressLine, $matches);
if (sizeof($matches) > 0) {
$job->sendStatus($matches[1], $progressMagic);
+ } elseif (substr($progressLine, 0, 5) == "yes: ") {
+ // do nothing
} else {
$nonstatusOutput .= $progressLine;
}
diff --git a/web/config.php b/web/config.php
index bdb5b47..9d86c0c 100644
--- a/web/config.php
+++ b/web/config.php
@@ -33,6 +33,9 @@
// What should we set as the default list of packages?
define("DEFAULT_KEYWORDS", "");
+ // What should the default virtual machine disk size be?
+ define("DEFAULT_DISK_SIZE", 8192);
+
// What should we limit the virtual machine disk size to?
define("MAX_DISK_SIZE", 16384);
diff --git a/web/index.php b/web/index.php
index aa17151..cdeecd3 100644
--- a/web/index.php
+++ b/web/index.php
@@ -120,7 +120,8 @@
<label for="partitioning_size">Disk size</label>
<br />
<input id="partitioning_size" class="required"
- type="text" name="image_size" value="4096"><br>
+ type="text" name="image_size" value="<?php echo DEFAULT_DISK_SIZE; ?>">
+ <br>
<label for="">Split</label><br /><br />
<div id="partitioning_split" name="split"></div>
@@ -211,4 +212,4 @@
</script>
<script type="text/javascript" src=" /js/gentoaster.js"></script>
</body>
-</html>
+</html>
\ No newline at end of file
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-08-15 1:21 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-12 23:18 [gentoo-commits] proj/gentoaster:master commit in: /, web/ Liam McLoughlin
2011-08-10 17:39 ` [gentoo-commits] proj/gentoaster:webui " Liam McLoughlin
-- strict thread matches above, loose matches on Subject: below --
2011-08-15 1:20 [gentoo-commits] proj/gentoaster:master " Liam McLoughlin
2011-08-15 1:17 Liam McLoughlin
2011-08-12 23:18 Liam McLoughlin
2011-08-12 23:17 Liam McLoughlin
2011-08-12 23:17 Liam McLoughlin
2011-07-24 2:43 [gentoo-commits] proj/gentoaster:webui " Liam McLoughlin
2011-08-12 23:17 ` [gentoo-commits] proj/gentoaster:master " Liam McLoughlin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox