diff options
Diffstat (limited to 'web/process.php')
-rw-r--r-- | web/process.php | 26 |
1 files changed, 23 insertions, 3 deletions
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); |