add_error('captcha',_("Error Captcha Required"));
}
if (isset ($captcha)) {
if ($captcha) {
$msg="SUCCESS";
}
else {
$GLOBALS['error']->add_error('captcha',_("Error Captcha Failed"));
}
} // end if we've got captcha
} // end if it's enabled
if(conf('user_agreement')) {
if(!$accept_agreement) {
$GLOBALS['error']->add_error('user_agreement',_("You must accept the user agreement"));
}
} // if they have to agree to something
if(!$username) {
$GLOBALS['error']->add_error('username',_("You did not enter a username"));
}
if(!$fullname) {
$GLOBALS['error']->add_error('fullname',_("Please fill in your full name (Firstname Lastname)"));
}
/* Check the mail for correct address formation. */
$attempt = 0;
$max_attempts = 3;
$response_code = "";
while ( $response_code == "" || strstr( $response_code, "fsockopen error" )) {
$validate_results = validateEmail( $email );
$response_code = $validate_results[1];
if($attempt == $max_attempts) {
break;
}
$attempt++;
}
if ($validate_results[0]) {
$mmsg = "MAILOK";
}
else {
$GLOBALS['error']->add_error('email',_("Error Email address not confirmed
$validate_results[1]"));
}
/* End of mailcheck */
if(!$pass1){
$GLOBALS['error']->add_error('password',_("You must enter a password"));
}
if ( $pass1 != $pass2 ) {
$GLOBALS['error']->add_error('password',_("Your passwords do not match"));
}
if (!check_username($username)) {
$GLOBALS['error']->add_error('duplicate_user',_("Error Username already exists"));
}
if($GLOBALS['error']->error_state){
show_user_registration($values);
break;
}
/* Attempt to create the new user */
$access = 'disabled';
if (conf('auto_user')) { $access = '5'; }
$new_user = $GLOBALS['user']->create($username,$fullname,$email,$pass1,$access);
if (!$new_user) {
$GLOBALS['error']->add_error('duplicate_user',_("Error: Insert Failed"));
show_user_registration($values);
break;
}
$user_object = new User($new_user);
$validation = str_rand(20);
$user_object->update_validation($validation);
$message = 'Your account has been created. However, this forum requires account activation.' .
' An activation key has been sent to the e-mail address you provided. ' .
'Please check your e-mail for further information';
send_confirmation($username, $fullname, $email, $pass1, $validation);
show_template('style');
show_confirmation(_('Registration Complete'),$message,'/login.php');
break;
case 'show_add_user':
default:
$values = array('type'=>"new_user");
show_user_registration($values);
break;
} // end switch on action
?>