aboutsummaryrefslogtreecommitdiff
blob: 99b9cf0a592082eb5e52df03acd7836a1ee6c47f (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
<?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
            );
                
            $stmt = $db->prepare("SELECT id FROM builds WHERE ipaddress = ?");
            $stmt->bind_param("s", $ipaddress);
            $stmt->execute();
            $stmt->store_result();
                        
            if ($stmt->num_rows == 1) {
                    $stmt->bind_result($buildID);
                    $stmt->fetch();
                    $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>".$timezone."</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 (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">
                                <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="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="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>