Subversion Repositories taios

Rev

Rev 505 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php

require '_taios.php';
require_once '_recaptchalib.php';

$page = new Taios_Page('Login');

$username = $_POST['username'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
$email = $_POST['email'];
$name = $_POST['name'];
$maths = $_POST['maths'];

if (empty($username))
{
    $page->redirect('register.php?error=No Username Specified');
}
if (empty($password))
{
    $page->redirect('register.php?error=No Password Specified');
}
if (empty($password2))
{
    $page->redirect('register.php?error=No Repeat Password Specified');
}
if ($password != $password2)
{
    $page->redirect('register.php?error=Passwords do not match');
}
if ($maths != '75')
{
    $page->redirect('register.php?error=Incorrect maths answer');
}

$resp = recaptcha_check_answer(RECAPTCHA_PRIVATEKEY, $_SERVER["REMOTE_ADDR"],
                               $_POST["recaptcha_challenge_field"],
                               $_POST["recaptcha_response_field"]);

if (!$resp->is_valid)
{
    $page->redirect('register.php?error=Incorrect reCAPTCHA response');
}

$salt = $username . "horses";

$args = array(2, $username, $page->saltAndBurn($password, $salt), $salt, $email, $name, $page->rndString(), 0);
$page->query("INSERT INTO Users (AccessID, Username, Password, Salt, EmailAddress, Name, CSRFToken, ChallengeID) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", $args);

$page->redirect('login.php');

?>