Expand|Select|Wrap|Line Numbers
- <?php
- global $users, $core, $engine;
- $errors = array();
- $messages = array();
- if(empty($_POST["registrationBean_username"]))
- $errors["registration_username"] = "<br/>Please enter a username!";
- elseif(strlen($_POST["registrationBean_username"]) > 25 || !ctype_alnum($_POST["registrationBean_username"]))
- $errors["registration_username"] = "<br/>Please enter a valid username!";
- elseif($engine->num_rows("SELECT null FROM users WHERE username = '" . $engine->secure($_POST["registrationBean_username"]) . "' LIMIT 1") != 0)
- $errors["registration_username"] = "That username is already taken!";
- if(empty($_POST["registrationBean_email"]))
- $errors["registration_email"] = "<br/>Please enter an email address!";
- elseif(!preg_match("/^[a-z0-9_\.-]+@([a-z0-9]+([\-]+[a-z0-9]+)*\.)+[a-z]{2,7}$/i", $_POST["registrationBean_email"]))
- $errors["registration_email"] = "<br/>Please enter a valid email address!";
- elseif($engine->num_rows("SELECT null FROM users WHERE mail = '" . $engine->secure($_POST["registrationBean_email"]) . "' LIMIT 1") != 0)
- $errors["registration_email"] = "<br/>That email address is taken!";
- if(empty($_POST['registrationBean_password']))
- $errors["registration_password"] = "<br/>Please enter a password!";
- elseif(strlen($_POST['registrationBean_password']) < 6)
- $errors["registration_password"] = "<br/>Please enter a password with more than 6 characters!";
- if(empty($_POST['registrationBean_password_confirm']))
- $errors["registration_password_confirm"] = "<br/>Please enter your password again!";
- elseif(!($_POST['registrationBean_password'] === $_POST['registrationBean_password_confirm']))
- $errors["registration_password_confirm"] = "<br/>Please enter a password with more than 6 characters!";
- if($_POST['registrationBean_termsOfServiceSelection'] != "true")
- $errors["registration_termsofservice"] = "Please accept the terms of service.";
- $return = array(
- "registrationErrors" => $errors,
- "registrationMessages" => $messages);
- if(count($errors) == 0) {
- $users->addUser($engine->secure($_POST["registrationBean_username"]),$core->hashed($_POST['registrationBean_password']),$_POST["registrationBean_email"],$_CONFIG['hotel']['motto'],$_CONFIG['hotel']['credits'],$_CONFIG['hotel']['pixels'],1, $_CONFIG['hotel']['figure'], "M","seckey");
- $users->turnOn($engine->secure($_POST["registrationBean_username"]));
- $return['registrationCompletionRedirectUrl'] = "{$_CONFIG['hotel']['url']}/me";
- }
- header('Content-type: application/json');
- echo json_encode($return);
- exit;
- ?>