Update register page

This commit is contained in:
DariusIII
2017-08-05 23:59:26 +02:00
parent 9bec9124ba
commit 6e682dfa81
+23 -23
View File
@@ -13,20 +13,20 @@ if ($page->users->isLoggedIn()) {
$error = $userName = $password = $confirmPassword = $email = $inviteCode = $inviteCodeQuery = '';
$showRegister = 1;
if (Settings::value('..registerstatus') == Settings::REGISTER_STATUS_CLOSED || Settings::value('..registerstatus') == Settings::REGISTER_STATUS_API_ONLY) {
$error = "Registrations are currently disabled.";
if ((int)Settings::value('..registerstatus') === Settings::REGISTER_STATUS_CLOSED || (int)Settings::value('..registerstatus') === Settings::REGISTER_STATUS_API_ONLY) {
$error = 'Registrations are currently disabled.';
$showRegister = 0;
} elseif (Settings::value('..registerstatus') == Settings::REGISTER_STATUS_INVITE && (!isset($_REQUEST["invitecode"]) || empty($_REQUEST['invitecode']))) {
$error = "Registrations are currently invite only.";
} elseif (Settings::value('..registerstatus') === Settings::REGISTER_STATUS_INVITE && (!isset($_REQUEST['invitecode']) || empty($_REQUEST['invitecode']))) {
$error = 'Registrations are currently invite only.';
$showRegister = 0;
}
if ($showRegister == 1) {
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view';
if ($showRegister === 1) {
$action = $_REQUEST['action'] ?? 'view';
//Be sure to persist the invite code in the event of multiple form submissions. (errors)
if (isset($_REQUEST['invitecode'])) {
$inviteCodeQuery = '&invitecode=' . $_REQUEST["invitecode"];
$inviteCodeQuery = '&invitecode=' . $_REQUEST['invitecode'];
}
$captcha = new Captcha($page);
@@ -43,8 +43,8 @@ if ($showRegister == 1) {
}
// Check uname/email isn't in use, password valid. If all good create new user account and redirect back to home page.
if ($password != $confirmPassword) {
$error = "Password Mismatch";
if ($password !== $confirmPassword) {
$error = 'Password Mismatch';
} else {
// Get the default user role.
$userDefault = $page->users->getDefaultRole();
@@ -55,29 +55,29 @@ if ($showRegister == 1) {
if ($ret > 0) {
$page->users->login($ret, $_SERVER['REMOTE_ADDR']);
header("Location: " . WWW_TOP . "/");
header('Location: ' . WWW_TOP . '/');
} else {
switch ($ret) {
case Users::ERR_SIGNUP_BADUNAME:
$error = "Your username must be at least five characters.";
$error = 'Your username must be at least five characters.';
break;
case Users::ERR_SIGNUP_BADPASS:
$error = "Your password must be longer than eight characters.";
$error = 'Your password must be longer than eight characters.';
break;
case Users::ERR_SIGNUP_BADEMAIL:
$error = "Your email is not a valid format.";
$error = 'Your email is not a valid format.';
break;
case Users::ERR_SIGNUP_UNAMEINUSE:
$error = "Sorry, the username is already taken.";
$error = 'Sorry, the username is already taken.';
break;
case Users::ERR_SIGNUP_EMAILINUSE:
$error = "Sorry, the email is already in use.";
$error = 'Sorry, the email is already in use.';
break;
case Users::ERR_SIGNUP_BADINVITECODE:
$error = "Sorry, the invite code is old or has been used.";
$error = 'Sorry, the invite code is old or has been used.';
break;
default:
$error = "Failed to register.";
$error = 'Failed to register.';
break;
}
}
@@ -85,15 +85,15 @@ if ($showRegister == 1) {
}
break;
case "view": {
$inviteCode = isset($_GET["invitecode"]) ? $_GET["invitecode"] : null;
$inviteCode = $_GET["invitecode"] ?? null;
if (isset($inviteCode)) {
// See if it is a valid invite.
$invite = $page->users->getInvite($inviteCode);
if (!$invite) {
$error = sprintf("Bad or invite code older than %d days.", Users::DEFAULT_INVITE_EXPIRY_DAYS);
$error = sprintf('Bad or invite code older than %d days.', Users::DEFAULT_INVITE_EXPIRY_DAYS);
$showRegister = 0;
} else {
$inviteCode = $invite["guid"];
$inviteCode = $invite['guid'];
}
}
break;
@@ -111,9 +111,9 @@ $page->smarty->assign([
'error' => $error
]
);
$page->meta_title = "Register";
$page->meta_keywords = "register,signup,registration";
$page->meta_description = "Register";
$page->meta_title = 'Register';
$page->meta_keywords = 'register,signup,registration';
$page->meta_description = 'Register';
$page->content = $page->smarty->fetch('register.tpl');
$page->render();