Gentoo Archives: gentoo-commits

From: Liam McLoughlin <hexxeh@××××××.net>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gentoaster:webui commit in: web/
Date: Tue, 02 Aug 2011 17:22:20
Message-Id: c626a0b84da7ec05c04543c12594869988b4e886.hexxeh@gentoo
1 commit: c626a0b84da7ec05c04543c12594869988b4e886
2 Author: Liam McLoughlin <hexxeh <AT> hexxeh <DOT> net>
3 AuthorDate: Tue Aug 2 17:21:43 2011 +0000
4 Commit: Liam McLoughlin <hexxeh <AT> hexxeh <DOT> net>
5 CommitDate: Tue Aug 2 17:21:43 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoaster.git;a=commit;h=c626a0b8
7
8 Fix a simultaneous builds bug where failed builds were counted as still being in progress, add keyboard layout support to WebUI.
9
10 ---
11 web/config.php | 3 +++
12 web/index.php | 20 ++++++++++++++++----
13 web/process.php | 2 ++
14 3 files changed, 21 insertions(+), 4 deletions(-)
15
16 diff --git a/web/config.php b/web/config.php
17 index 210d1db..39f505f 100644
18 --- a/web/config.php
19 +++ b/web/config.php
20 @@ -3,6 +3,9 @@
21 // Gentoaster web interface settings
22 // Licensed under GPL v3, see COPYING file
23
24 + // Path to the Gentoaster binaries/resources
25 + define("GENTOASTER_PATH", "/usr/share/gentoaster");
26 +
27 // Path to the zonetab file
28 define("ZONETAB", "/usr/share/zoneinfo/zone.tab");
29
30
31 diff --git a/web/index.php b/web/index.php
32 index 55484d0..b6cb119 100644
33 --- a/web/index.php
34 +++ b/web/index.php
35 @@ -23,12 +23,14 @@
36 FILTER_VALIDATE_IP
37 );
38
39 - $stmt = $db->prepare("SELECT id FROM builds WHERE ipaddress = ?");
40 - $stmt->bind_param("s", $ipaddress);
41 + $query = "SELECT id, returncode ".
42 + "FROM builds WHERE ipaddress = ?";
43 + $stmt = $db->prepare($query);
44 + $stmt->bind_param("sd", $ipaddress, $returncode);
45 $stmt->execute();
46 $stmt->store_result();
47
48 - if ($stmt->num_rows == 1) {
49 + if ($stmt->num_rows == 1 && $returncode === null) {
50 $stmt->bind_result($buildID);
51 $stmt->fetch();
52 $url = "status.php?uuid=".$buildID."&simultaneous=true";
53 @@ -57,6 +59,16 @@
54 foreach ($timezones as $timezone => $description) {
55 $timezoneOption .= "<option>".$timezone."</option>\n";
56 }
57 + $layoutLines = file(GENTOASTER_PATH."/res/keyboard.lst");
58 + $keyboardOption = "";
59 +
60 + foreach($layoutLines as $layout) {
61 + $layoutdata = explode("\t", $layout);
62 + $keyboardOption .= "<option value=\"".$layoutdata[0]."\">";
63 + $keyboardOption .= trim($layoutdata[1])."</option>\n";
64 + }
65 +
66 + asort($layouts);
67 ?>
68 <html>
69 <head>
70 @@ -117,7 +129,7 @@
71 <br />
72 <select id="locale_keyboard" class="required"
73 name="keyboard">
74 - <option>United Kingdom</option>
75 + <?php echo $keyboardOption; ?>
76 </select>
77 <br>
78
79
80 diff --git a/web/process.php b/web/process.php
81 index b16f272..c590bee 100644
82 --- a/web/process.php
83 +++ b/web/process.php
84 @@ -51,6 +51,7 @@
85 $swapMegabytes = filter_input(INPUT_POST, "swap_size", FILTER_VALIDATE_INT);
86 $rootMegabytes = filter_input(INPUT_POST, "root_size", FILTER_VALIDATE_INT);
87 $timezone = filter_input(INPUT_POST, "timezone", FILTER_CALLBACK, $sfi);
88 + $keyboard = filter_input(INPUT_POST, "keyboard", FILTER_CALLBACK, $sfi);
89 $hostname = filter_input(INPUT_POST, "hostname", FILTER_CALLBACK, $sfi);
90 $username = filter_input(INPUT_POST, "username", FILTER_CALLBACK, $sfi);
91 $password = filter_input(INPUT_POST, "password", FILTER_CALLBACK, $sfi);
92 @@ -69,6 +70,7 @@ BOOT_MEGABYTES='$bootMegabytes'
93 SWAP_MEGABYTES='$swapMegabytes'
94 ROOT_MEGABYTES='$rootMegabytes'
95 TIMEZONE=$timezone
96 +KEYBOARD=$keyboard
97 HOSTNAME=$hostname
98 ROOT_PASSWORD=$rootPass
99 DEFAULT_USERNAME=$username