aboutsummaryrefslogtreecommitdiff
blob: 6bb2f9fd8d9baaf8109026d06478be53e44ccea6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
<?php
    require_once "config.php";
    
    if (RECAPTCHA_ENABLED) {
        require_once "recaptcha.php";
    }

    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
            );
                
            $query = "SELECT id, handle ".
                     "FROM builds WHERE ipaddress = ?";
            $stmt = $db->prepare($query);
            $stmt->bind_param("s", $ipaddress);
            $stmt->execute();
            $stmt->store_result();
                        
            if ($stmt->num_rows == 1) {
                    $stmt->bind_result($buildID, $handle);
                    $stmt->fetch();
                    $client = new GearmanClient();
                    $client->addServer();
                    $status = $client->jobStatus($handle);
                    if ($status[0]) {
                        $url = "status.php?uuid=".$buildID."&simultaneous=true";
                        header("Location: ".$url);
                    }
            }
            $stmt->close();
    }

    $timezones = array();
    $zonetab = file(ZONETAB);
    foreach ($zonetab as $buf) {
        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];
        }
        $timezones[$key] = $val;
        ksort($timezones);
    }
    $timezoneOption = "";
    foreach ($timezones as $timezone => $description) {
        $timezoneOption .= "<option";
        if ($timezone == DEFAULT_TIMEZONE) {
            $timezoneOption .= " selected";
        }
        $timezoneOption .= ">".$timezone."</option>\n";
    }
    $layoutLines = file(GENTOASTER_PATH."/res/keyboard.lst");
    $keyboardOption = "";
    $layouts = array();
    
    foreach($layoutLines as $layout) {
        $layoutdata = explode("\t", $layout);
        $layouts[$layoutdata[0]] = $layoutdata[1];
    }
    asort($layouts);
     
    foreach($layouts as $layoutCode => $layoutName) {   
        $keyboardOption .= "<option value=\"".$layoutCode."\"";
        if ($layoutCode == DEFAULT_KEYBOARD) {
            $keyboardOption .= " selected";
        }
        $keyboardOption .= ">".trim($layoutName)."</option>\n";
    }
?>
<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.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(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) {
                        ?>
                        <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>

                            <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">
                                <?php echo $keyboardOption; ?>
                            </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="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_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="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="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="expert" class="step">
                            <h1>Expert</h1>

                            <label for="expert_use">USE flags</label>
                            <br />
                            <textarea id="expert_use" name="use"
                                style="width: 680px; height: 60px;"><?php 
                                    echo DEFAULT_USE;
                                ?></textarea>
                            <br><br />
                            <label for="expert_puse">Package USE</label>
                            <br />
                            <textarea id="expert_puse" name="puse"
                                style="width: 680px; height: 60px;"><?php 
                                    echo DEFAULT_PACKAGE_USE;
                                ?></textarea>
                            <br><br />
                            <label for="expert_features">Features</label>
                            <br />
                            <textarea id="expert_features" name="features"
                                style="width: 680px; height: 60px;"><?php 
                                    echo DEFAULT_FEATURES;
                                ?></textarea>
                            <br><br />
                            <label for="expert_keywords">Accept Keywords</label>
                            <br />
                            <textarea id="expert_keywords" name="keywords"
                                style="width: 680px; height: 60px;"><?php 
                                    echo DEFAULT_KEYWORDS;
                                ?></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>
</html>