20))
{
setError(t("username_must_be_between_6_and_20_characters", "Your username must be between 6 and 20 characters"));
}
else
{
$checkEmail = UserPeer::loadUserByEmailAddress($emailAddress);
if ($checkEmail)
{
// username exists
setError(t("email_address_already_exists", "Email address already exists"));
}
else
{
$checkUser = UserPeer::loadUserByUsername($username);
if ($checkUser)
{
// username exists
setError(t("username_already_exists", "Username already exists"));
}
}
}
// check captcha
if((!isErrors()) && (SITE_CONFIG_REGISTER_FORM_SHOW_CAPTCHA == 'yes'))
{
if (!isset($_REQUEST['g-recaptcha-response']))
{
setError(t("invalid_captcha", "Captcha confirmation text is invalid."));
}
else
{
$resp = verifyCaptcha($_POST["g-recaptcha-response"]);
if ($resp == false)
{
setError(t("invalid_captcha", "Captcha confirmation text is invalid."));
}
}
}
// create the account
if (!isErrors())
{
$newPassword = createPassword();
$newUser = UserPeer::create($username, $newPassword, $emailAddress, $title, $firstname, $lastname);
if ($newUser)
{
$subject = "Account details for " . SITE_CONFIG_SITE_NAME;
$defaultContent = "Dear [[[FIRSTNAME]]],
";
$defaultContent .= "Your account on [[[SITE_CONFIG_SITE_NAME]]] has been created. Use the details below to login to your new account:
";
$defaultContent .= "Url: [[[WEB_ROOT]]]
";
$defaultContent .= "Username: [[[NEW_USERNAME]]]
";
$defaultContent .= "Password: [[[NEW_PASSWORD]]]
";
$defaultContent .= "Feel free to contact us if you need any support with your account.
";
$defaultContent .= "Regards,
";
$defaultContent .= "[[[SITE_CONFIG_SITE_NAME]]] Admin";
$replacements = array();
$replacements['NEW_PASSWORD'] = $newPassword;
$replacements['NEW_USERNAME'] = $username;
$replacements['WEB_ROOT'] = WEB_ROOT;
$replacements['SITE_CONFIG_SITE_NAME'] = SITE_CONFIG_SITE_NAME;
$replacements['FIRSTNAME'] = $firstname;
$htmlMsg = t('email_content_new_registration', $defaultContent, $replacements);
send_html_mail($emailAddress, $subject, $htmlMsg, SITE_CONFIG_DEFAULT_EMAIL_ADDRESS_FROM, strip_tags(str_replace("
", "\n", $htmlMsg)));
redirect(WEB_ROOT . "/register_complete." . SITE_CONFIG_PAGE_EXTENSION);
}
else
{
setError(t("problem_creating_your_account_try_again_later", "There was a problem creating your account, please try again later"));
}
}
}
require_once('_header.php');
?>