diff options
author | Liam McLoughlin <hexxeh@hexxeh.net> | 2011-07-24 03:10:52 +0100 |
---|---|---|
committer | Liam McLoughlin <hexxeh@hexxeh.net> | 2011-07-24 03:34:15 +0100 |
commit | bc79e5240cd4544c9f953c48ecafdf4693bd1d64 (patch) | |
tree | bc892a47d623cb16459dc60a8e4e890351ad0a0d /web/process.php | |
parent | Use config file, defines to control settings, more Zend standards work (diff) | |
download | gentoaster-bc79e5240cd4544c9f953c48ecafdf4693bd1d64.tar.gz gentoaster-bc79e5240cd4544c9f953c48ecafdf4693bd1d64.tar.bz2 gentoaster-bc79e5240cd4544c9f953c48ecafdf4693bd1d64.zip |
Adding RECAPTCHA, more standards work
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); |