loggedIn())
{
coreFunctions::redirect(WEB_ROOT . '/index.' . SITE_CONFIG_PAGE_EXTENSION);
}
// load theme functions
$themeObj = themeHelper::getLoadedInstance();
// page settings
define("PAGE_NAME", t("register_page_name", "Register"));
define("PAGE_DESCRIPTION", t("register_meta_description", "Register for an account"));
define("PAGE_KEYWORDS", t("register_meta_keywords", "register, account, short, url, user"));
define("HTML_ELEMENT_CLASS", "login-page-wrapper");
// top navigation
require_once(SITE_TEMPLATES_PATH . '/partial/_navigation_header.inc.php');
// register user
$title = '';
if (isset($_REQUEST['submitme']))
{
// validation
$title = trim($_REQUEST['title']);
$firstname = trim($_REQUEST['firstname']);
$lastname = trim($_REQUEST['lastname']);
$emailAddress = trim(strtolower($_REQUEST['emailAddress']));
$emailAddressConfirm = trim(strtolower($_REQUEST['emailAddressConfirm']));
$username = trim(strtolower($_REQUEST['username']));
if (!strlen($title))
{
notification::setError(t("please_enter_your_title", "Please enter your title"));
}
elseif (!strlen($firstname))
{
notification::setError(t("please_enter_your_firstname", "Please enter your firstname"));
}
elseif (!strlen($lastname))
{
notification::setError(t("please_enter_your_lastname", "Please enter your lastname"));
}
elseif (!strlen($emailAddress))
{
notification::setError(t("please_enter_your_email_address", "Please enter your email address"));
}
elseif ($emailAddress != $emailAddressConfirm)
{
notification::setError(t("your_email_address_confirmation_does_not_match", "Your email address confirmation does not match"));
}
elseif (!validation::validEmail($emailAddress))
{
notification::setError(t("your_email_address_is_invalid", "Your email address is invalid"));
}
elseif (!strlen($username))
{
notification::setError(t("please_enter_your_preferred_username", "Please enter your preferred username"));
}
elseif ((strlen($username) < 6) || (strlen($username) > 20))
{
notification::setError(t("username_must_be_between_6_and_20_characters", "Your username must be between 6 and 20 characters"));
}
elseif (!validation::validUsername($username))
{
notification::setError(t("your_username_is_invalid", "Your username can only contact alpha numeric and underscores."));
}
else
{
$checkEmail = UserPeer::loadUserByEmailAddress($emailAddress);
if ($checkEmail)
{
// username exists
notification::setError(t("email_address_already_exists", "Email address already exists on another account"));
}
else
{
$checkUser = UserPeer::loadUserByUsername($username);
if ($checkUser)
{
// username exists
notification::setError(t("username_already_exists", "Username already exists on another account"));
}
}
}
// make sure the username is not reserved
if (!notification::isErrors())
{
if (strlen(SITE_CONFIG_RESERVED_USERNAMES))
{
$reservedUsernames = explode("|", SITE_CONFIG_RESERVED_USERNAMES);
if (in_array($username, $reservedUsernames))
{
// username is reserved
notification::setError(t("username_is_reserved", "Username is reserved and can not be used, please choose another"));
}
}
}
// make sure the email domain isn't banned
if (!notification::isErrors())
{
if (strlen(SITE_CONFIG_SECURITY_BLOCK_REGISTER_EMAIL_DOMAIN))
{
$blockedEmailDomains = explode(",", SITE_CONFIG_SECURITY_BLOCK_REGISTER_EMAIL_DOMAIN);
$emailDomain = strtolower(end(explode('@', $emailAddress)));
if (in_array($emailDomain, $blockedEmailDomains))
{
// email domain is not allowed
notification::setError(t("email_address_not_allowed", "Registration from email addresses on [[[EMAIL_DOMAIN]]] have been blocked on this site.", array('EMAIL_DOMAIN' => $emailDomain)));
}
}
}
// check captcha
if ((!notification::isErrors()) && (SITE_CONFIG_REGISTER_FORM_SHOW_CAPTCHA == 'yes'))
{
if (!isset($_REQUEST['g-recaptcha-response']))
{
notification::setError(t("invalid_captcha", "Captcha confirmation text is invalid."));
}
else
{
$rs = coreFunctions::captchaCheck($_REQUEST["g-recaptcha-response"]);
if (!$rs)
{
notification::setError(t("invalid_captcha", "Captcha confirmation text is invalid."));
}
}
}
// create the account
if (!notification::isErrors())
{
$newPassword = passwordPolicy::generatePassword();
$newUser = UserPeer::create($username, $newPassword, $emailAddress, $title, $firstname, $lastname);
if ($newUser)
{
$subject = t('register_user_email_subject', 'Account details for [[[SITE_NAME]]]', array('SITE_NAME' => SITE_CONFIG_SITE_NAME));
$replacements = array(
'FIRST_NAME' => $firstname,
'SITE_NAME' => SITE_CONFIG_SITE_NAME,
'WEB_ROOT' => WEB_ROOT,
'USERNAME' => $username,
'PASSWORD' => $newPassword
);
$defaultContent = "Dear [[[FIRST_NAME]]],
";
$defaultContent .= "Your account on [[[SITE_NAME]]] has been created. Use the details below to login to your new account:
";
$defaultContent .= "Url: [[[WEB_ROOT]]]
";
$defaultContent .= "Username: [[[USERNAME]]]
";
$defaultContent .= "Password: [[[PASSWORD]]]
";
$defaultContent .= "Feel free to contact us if you need any support with your account.
";
$defaultContent .= "Regards,
";
$defaultContent .= "[[[SITE_NAME]]] Admin";
$htmlMsg = t('register_user_email_content', $defaultContent, $replacements);
coreFunctions::sendHtmlEmail($emailAddress, $subject, $htmlMsg, SITE_CONFIG_DEFAULT_EMAIL_ADDRESS_FROM, strip_tags(str_replace("
", "\n", $htmlMsg)));
// create account welcome notification
$content = t('register_account_notification_text', 'Thanks for registering and welcome to your account! Start uploading files straight away by clicking the \'Upload\' button below. Feel free to contact us if you need any help.');
$link = WEB_ROOT.'/index.'.SITE_CONFIG_PAGE_EXTENSION;
internalNotification::add($newUser->id, $content, $type = 'entypo-thumbs-up', $link);
// confirmation page
coreFunctions::redirect(WEB_ROOT . "/register_complete." . SITE_CONFIG_PAGE_EXTENSION);
}
else
{
notification::setError(t("problem_creating_your_account_try_again_later", "There was a problem creating your account, please try again later"));
}
}
}
// header top
require_once(SITE_TEMPLATES_PATH . '/partial/_header_file_manager_top.inc.php');
?>