1 |
commit: e27028f91f5fb2149054adbb89d14177f0e6f3db |
2 |
Author: Liam McLoughlin <hexxeh <AT> hexxeh <DOT> net> |
3 |
AuthorDate: Wed Jul 27 20:04:32 2011 +0000 |
4 |
Commit: Liam McLoughlin <hexxeh <AT> hexxeh <DOT> net> |
5 |
CommitDate: Wed Jul 27 20:04:32 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoaster.git;a=commit;h=e27028f9 |
7 |
|
8 |
Added simultaneous build settings |
9 |
|
10 |
--- |
11 |
web/config.php | 3 +++ |
12 |
web/index.php | 23 +++++++++++++++++++++++ |
13 |
web/process.php | 2 +- |
14 |
web/status.php | 9 +++++++++ |
15 |
web/testdrive.php | 2 +- |
16 |
5 files changed, 37 insertions(+), 2 deletions(-) |
17 |
|
18 |
diff --git a/web/config.php b/web/config.php |
19 |
index 30d6aa4..c31e60b 100644 |
20 |
--- a/web/config.php |
21 |
+++ b/web/config.php |
22 |
@@ -6,6 +6,9 @@ |
23 |
// Path to the zonetab file |
24 |
define("ZONETAB", "/usr/share/zoneinfo/zone.tab"); |
25 |
|
26 |
+ // Should we allow multiple simultaneous builds for a user? |
27 |
+ define("SIMULTANEOUS_BUILDS", false); |
28 |
+ |
29 |
// What should we limit the virtual machine disk size to? |
30 |
define("MAX_DISK_SIZE", 16384); |
31 |
|
32 |
|
33 |
diff --git a/web/index.php b/web/index.php |
34 |
index 6b6abec..a68a219 100644 |
35 |
--- a/web/index.php |
36 |
+++ b/web/index.php |
37 |
@@ -5,6 +5,29 @@ |
38 |
require_once "recaptcha.php"; |
39 |
} |
40 |
|
41 |
+ if(!SIMULTANEOUS_BUILDS) { |
42 |
+ $db = new mysqli(MYSQL_HOSTNAME, MYSQL_USERNAME, |
43 |
+ MYSQL_PASSWORD, MYSQL_DATABASE); |
44 |
+ if (mysqli_connect_errno()) { |
45 |
+ die("Could not connect to database ".mysqli_connect_error()); |
46 |
+ } |
47 |
+ |
48 |
+ $ipaddress = filter_input(INPUT_SERVER, "REMOTE_ADDR", |
49 |
+ FILTER_VALIDATE_IP); |
50 |
+ |
51 |
+ $stmt = $db->prepare("SELECT id FROM builds WHERE ipaddress = ?"); |
52 |
+ $stmt->bind_param("s", $ipaddress); |
53 |
+ $stmt->execute(); |
54 |
+ $stmt->store_result(); |
55 |
+ |
56 |
+ if ($stmt->num_rows == 1) { |
57 |
+ $stmt->bind_result($buildID); |
58 |
+ $stmt->fetch(); |
59 |
+ header("Location: status.php?uuid=".$buildID."&simultaneous=true"); |
60 |
+ } |
61 |
+ $stmt->close(); |
62 |
+ } |
63 |
+ |
64 |
$timezones = array(); |
65 |
$zonetab = file(ZONETAB); |
66 |
foreach ($zonetab as $buf) { |
67 |
|
68 |
diff --git a/web/process.php b/web/process.php |
69 |
index 238e843..9ba055b 100644 |
70 |
--- a/web/process.php |
71 |
+++ b/web/process.php |
72 |
@@ -9,7 +9,7 @@ |
73 |
require_once "recaptcha.php"; |
74 |
|
75 |
$remoteAddress = filter_input(INPUT_SERVER, |
76 |
- "remote_addr", |
77 |
+ "REMOTE_ADDR", |
78 |
FILTER_VALIDATE_IP); |
79 |
$challenge = filter_input(INPUT_POST, |
80 |
"recaptcha_challenge_field", |
81 |
|
82 |
diff --git a/web/status.php b/web/status.php |
83 |
index 719afe6..d2e8715 100644 |
84 |
--- a/web/status.php |
85 |
+++ b/web/status.php |
86 |
@@ -6,9 +6,16 @@ |
87 |
require_once "config.php"; |
88 |
|
89 |
$buildID = filter_input(INPUT_GET, "uuid", FILTER_UNSAFE_RAW); |
90 |
+ $simultaneous = filter_input(INPUT_GET, "simultaneous", FILTER_VALIDATE_BOOLEAN); |
91 |
$buildresult = "Unknown!"; |
92 |
$inprogress = false; |
93 |
$builddone = false; |
94 |
+ $simultaneousString = ""; |
95 |
+ |
96 |
+ if($simultaneous && !SIMULTANEOUS_BUILDS) { |
97 |
+ $simultaneousString = "You were redirected to this page because you already have a ". |
98 |
+ "build in progress. Simultaneous builds are disabled on this server.<br/><br/>"; |
99 |
+ } |
100 |
|
101 |
$db = new mysqli(MYSQL_HOSTNAME, MYSQL_USERNAME, |
102 |
MYSQL_PASSWORD, MYSQL_DATABASE); |
103 |
@@ -19,6 +26,7 @@ |
104 |
$stmt = $db->prepare("SELECT handle FROM builds WHERE id = ?"); |
105 |
$stmt->bind_param("s", $buildID); |
106 |
$stmt->execute(); |
107 |
+ $stmt->store_result(); |
108 |
if ($stmt->num_rows == 1) { |
109 |
$stmt->bind_result($handle); |
110 |
$stmt->fetch(); |
111 |
@@ -103,6 +111,7 @@ |
112 |
<div id="status" class="step"> |
113 |
<h1><?php echo $titleString; ?></h1> |
114 |
<p> |
115 |
+ <?php echo $simultaneousString; ?> |
116 |
<?php echo $buildresult; ?> |
117 |
<div id="progressbar"></div> |
118 |
</p> |
119 |
|
120 |
diff --git a/web/testdrive.php b/web/testdrive.php |
121 |
index 8f3c718..3847b69 100644 |
122 |
--- a/web/testdrive.php |
123 |
+++ b/web/testdrive.php |
124 |
@@ -18,7 +18,7 @@ |
125 |
$stmt = $db->prepare("SELECT handle FROM builds WHERE id = ?"); |
126 |
$stmt->bind_param("s", $buildID); |
127 |
$stmt->execute(); |
128 |
- |
129 |
+ $stmt->store_result(); |
130 |
if ($stmt->num_rows == 1) { |
131 |
$stmt->bind_result($handle); |
132 |
$stmt->fetch(); |