Reduced ->value calls.
This commit is contained in:
parent
7bf60765be
commit
af8e86ea09
11 changed files with 39 additions and 39 deletions
|
@ -4,7 +4,7 @@ use Misuzu\Request\RequestVar;
|
|||
|
||||
require_once '../misuzu.php';
|
||||
|
||||
switch (RequestVar::get()->select('m')->value()) {
|
||||
switch (RequestVar::get()->select('m')->string()) {
|
||||
case 'logout':
|
||||
echo tpl_render('auth.logout');
|
||||
break;
|
||||
|
|
|
@ -10,7 +10,7 @@ if (user_session_active()) {
|
|||
|
||||
if (isset(RequestVar::get()->resolve_user)) {
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
echo user_id_from_username(RequestVar::get()->resolve_user->value('string'));
|
||||
echo user_id_from_username(RequestVar::get()->resolve_user->string());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ while (!empty($login->value('array'))) {
|
|||
}
|
||||
|
||||
$userAgent = $_SERVER['HTTP_USER_AGENT'] ?? '';
|
||||
$loginRedirect = $login->redirect->value('string', '');
|
||||
$loginRedirect = $login->redirect->string('');
|
||||
|
||||
if ($login->username->empty() || $login->password->empty()) {
|
||||
$notices[] = "You didn't fill in a username and/or password.";
|
||||
|
@ -40,7 +40,7 @@ while (!empty($login->value('array'))) {
|
|||
break;
|
||||
}
|
||||
|
||||
$loginUsername = $login->username->value('string', '');
|
||||
$loginUsername = $login->username->string('');
|
||||
$userData = user_find_for_login($loginUsername);
|
||||
$attemptsRemainingError = sprintf(
|
||||
"%d attempt%s remaining",
|
||||
|
@ -55,7 +55,7 @@ while (!empty($login->value('array'))) {
|
|||
break;
|
||||
}
|
||||
|
||||
$loginPassword = $login->password->value('string', '');
|
||||
$loginPassword = $login->password->string('');
|
||||
if (!password_verify($loginPassword, $userData['password'])) {
|
||||
user_login_attempt_record(false, $userData['user_id'], $ipAddress, $userAgent);
|
||||
$notices[] = $loginFailedError;
|
||||
|
@ -101,9 +101,9 @@ while (!empty($login->value('array'))) {
|
|||
return;
|
||||
}
|
||||
|
||||
$welcomeMode = RequestVar::get()->welcome->value('bool', false);
|
||||
$loginUsername = $login->username->value('string') ?? RequestVar::get()->username->value('string', '');
|
||||
$loginRedirect = $welcomeMode ? url('index') : RequestVar::get()->redirect->value('string') ?? $_SERVER['HTTP_REFERER'] ?? url('index');
|
||||
$welcomeMode = RequestVar::get()->welcome->bool(false);
|
||||
$loginUsername = $login->username->string() ?? RequestVar::get()->username->string('');
|
||||
$loginRedirect = $welcomeMode ? url('index') : RequestVar::get()->redirect->string() ?? $_SERVER['HTTP_REFERER'] ?? url('index');
|
||||
$sitePrivateMessage = $siteIsPrivate ? config_get_default('', 'Private', 'message') : '';
|
||||
$canResetPassword = $siteIsPrivate ? boolval(config_get_default(false, 'Private', 'password_reset')) : true;
|
||||
$canRegisterAccount = !$siteIsPrivate;
|
||||
|
|
|
@ -8,7 +8,7 @@ if (!user_session_active()) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (csrf_verify('logout', RequestVar::get()->token->value('string', ''))) {
|
||||
if (csrf_verify('logout', RequestVar::get()->token->string())) {
|
||||
setcookie('msz_auth', '', -9001, '/', '', true, true);
|
||||
user_session_stop(true);
|
||||
header(sprintf('Location: %s', url('index')));
|
||||
|
|
|
@ -10,7 +10,7 @@ if (user_session_active()) {
|
|||
|
||||
$reset = RequestVar::post()->reset;
|
||||
$forgot = RequestVar::post()->forgot;
|
||||
$userId = $reset->user->value('int') ?? RequestVar::get()->user->value('int', 0);
|
||||
$userId = $reset->user->int() ?? RequestVar::get()->user->int(0);
|
||||
$username = $userId > 0 ? user_username_from_id($userId) : '';
|
||||
|
||||
if ($userId > 0 && empty($username)) {
|
||||
|
@ -31,15 +31,15 @@ while ($canResetPassword) {
|
|||
break;
|
||||
}
|
||||
|
||||
$verificationCode = $reset->verification->value('string', '');
|
||||
$verificationCode = $reset->verification->string('');
|
||||
|
||||
if (!user_recovery_token_validate($userId, $verificationCode)) {
|
||||
$notices[] = 'Invalid verification code!';
|
||||
break;
|
||||
}
|
||||
|
||||
$passwordNew = $reset->password->new->value('string', '');
|
||||
$passwordConfirm = $reset->password->confirm->value('string', '');
|
||||
$passwordNew = $reset->password->new->string('');
|
||||
$passwordConfirm = $reset->password->confirm->string('');
|
||||
|
||||
if (empty($passwordNew) || empty($passwordConfirm)
|
||||
|| $passwordNew !== $passwordConfirm) {
|
||||
|
@ -83,7 +83,7 @@ while ($canResetPassword) {
|
|||
break;
|
||||
}
|
||||
|
||||
$forgotUser = user_find_for_reset($forgot->email->value('string'));
|
||||
$forgotUser = user_find_for_reset($forgot->email->string());
|
||||
|
||||
if (empty($forgotUser)) {
|
||||
$notices[] = "This e-mail address is not registered with us.";
|
||||
|
@ -129,7 +129,7 @@ MSG;
|
|||
|
||||
echo tpl_render($userId > 0 ? 'auth.password_reset' : 'auth.password_forgot', [
|
||||
'password_notices' => $notices,
|
||||
'password_email' => $forgot->email->value('string', ''),
|
||||
'password_email' => $forgot->email->string(''),
|
||||
'password_attempts_remaining' => $remainingAttempts,
|
||||
'password_user_id' => $userId,
|
||||
'password_username' => $username,
|
||||
|
|
|
@ -31,7 +31,7 @@ while (!$restricted && !empty($register->value('array'))) {
|
|||
break;
|
||||
}
|
||||
|
||||
$checkSpamBot = mb_strtolower($register->question->value('string', ''));
|
||||
$checkSpamBot = mb_strtolower($register->question->string(''));
|
||||
$spamBotValid = [
|
||||
'19', '21', 'nineteen', 'nine-teen', 'nine teen', 'twentyone', 'twenty-one', 'twenty one',
|
||||
];
|
||||
|
@ -41,13 +41,13 @@ while (!$restricted && !empty($register->value('array'))) {
|
|||
break;
|
||||
}
|
||||
|
||||
$username = $register->username->value('string', '');
|
||||
$username = $register->username->string('');
|
||||
$usernameValidation = user_validate_username($username, true);
|
||||
if ($usernameValidation !== '') {
|
||||
$notices[] = MSZ_USER_USERNAME_VALIDATION_STRINGS[$usernameValidation];
|
||||
}
|
||||
|
||||
$email = $register->email->value('string', '');
|
||||
$email = $register->email->string('');
|
||||
$emailValidation = user_validate_email($email, true);
|
||||
if ($emailValidation !== '') {
|
||||
$notices[] = $emailValidation === 'in-use'
|
||||
|
@ -55,7 +55,7 @@ while (!$restricted && !empty($register->value('array'))) {
|
|||
: 'The e-mail address you entered is invalid!';
|
||||
}
|
||||
|
||||
$password = $register->password->value('string', '');
|
||||
$password = $register->password->string('');
|
||||
if (user_validate_password($password) !== '') {
|
||||
$notices[] = 'Your password is too weak!';
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ while (!$restricted && !empty($register->value('array'))) {
|
|||
|
||||
echo tpl_render('auth.register', [
|
||||
'register_notices' => $notices,
|
||||
'register_username' => $register->username->value('string', ''),
|
||||
'register_email' => $register->email->value('string', ''),
|
||||
'register_username' => $register->username->string(''),
|
||||
'register_email' => $register->email->string(''),
|
||||
'register_restricted' => $restricted,
|
||||
]);
|
||||
|
|
|
@ -13,7 +13,7 @@ $notices = [];
|
|||
$ipAddress = ip_remote_address();
|
||||
$remainingAttempts = user_login_attempts_remaining($ipAddress);
|
||||
$tokenInfo = user_auth_tfa_token_info(
|
||||
RequestVar::get()->token->value('string') ?? $twofactor->token->value('string', '')
|
||||
RequestVar::get()->token->string() ?? $twofactor->token->string('')
|
||||
);
|
||||
|
||||
// checking user_totp_key specifically because there's a fringe chance that
|
||||
|
@ -30,7 +30,7 @@ while (!empty($twofactor->value('array'))) {
|
|||
}
|
||||
|
||||
$userAgent = $_SERVER['HTTP_USER_AGENT'] ?? '';
|
||||
$redirect = $twofactor->redirect->value('string', '');
|
||||
$redirect = $twofactor->redirect->string('');
|
||||
|
||||
if ($twofactor->code->empty()) {
|
||||
$notices[] = 'Code field was empty.';
|
||||
|
@ -42,7 +42,7 @@ while (!empty($twofactor->value('array'))) {
|
|||
break;
|
||||
}
|
||||
|
||||
$givenCode = $twofactor->code->value('string', '');
|
||||
$givenCode = $twofactor->code->string('');
|
||||
$currentCode = totp_generate($tokenInfo['user_totp_key']);
|
||||
$previousCode = totp_generate($tokenInfo['user_totp_key'], time() - 30);
|
||||
|
||||
|
@ -81,7 +81,7 @@ while (!empty($twofactor->value('array'))) {
|
|||
|
||||
echo tpl_render('auth.twofactor', [
|
||||
'twofactor_notices' => $notices,
|
||||
'twofactor_redirect' => RequestVar::get()->redirect->value('string') ?? url('index'),
|
||||
'twofactor_redirect' => RequestVar::get()->redirect->string() ?? url('index'),
|
||||
'twofactor_attempts_remaining' => $remainingAttempts,
|
||||
'twofactor_token' => $tokenInfo['tfa_token'],
|
||||
]);
|
||||
|
|
|
@ -3,10 +3,10 @@ use Misuzu\Request\RequestVar;
|
|||
|
||||
require_once '../misuzu.php';
|
||||
|
||||
$changelogChange = RequestVar::get()->select('c')->value('int', 0);
|
||||
$changelogDate = RequestVar::get()->select('d')->value('string', '');
|
||||
$changelogUser = RequestVar::get()->select('u')->value('int', 0);
|
||||
$changelogTags = RequestVar::get()->select('t')->value('string', '');
|
||||
$changelogChange = RequestVar::get()->select('c')->int();
|
||||
$changelogDate = RequestVar::get()->select('d')->string();
|
||||
$changelogUser = RequestVar::get()->select('u')->int();
|
||||
$changelogTags = RequestVar::get()->select('t')->string();
|
||||
|
||||
tpl_var('comments_perms', $commentPerms = comments_get_perms(user_session_current('user_id', 0)));
|
||||
|
||||
|
|
|
@ -39,8 +39,8 @@ if (user_warning_check_expiration($currentUserId, MSZ_WARN_SILENCE) > 0) {
|
|||
header(csrf_http_header('comments'));
|
||||
$commentPerms = comments_get_perms($currentUserId);
|
||||
|
||||
$commentId = RequestVar::get()->select('c')->value('int', 0);
|
||||
$commentMode = RequestVar::get()->select('m')->value();
|
||||
$commentId = RequestVar::get()->select('c')->int();
|
||||
$commentMode = RequestVar::get()->select('m')->string();
|
||||
|
||||
switch ($commentMode) {
|
||||
case 'pin':
|
||||
|
@ -91,7 +91,7 @@ switch ($commentMode) {
|
|||
break;
|
||||
}
|
||||
|
||||
$vote = RequestVar::get()->select('v')->value('int', MSZ_COMMENTS_VOTE_INDIFFERENT);
|
||||
$vote = RequestVar::get()->select('v')->int(MSZ_COMMENTS_VOTE_INDIFFERENT);
|
||||
|
||||
if (!comments_vote_type_valid($vote)) {
|
||||
echo render_info_or_json($isXHR, 'Invalid vote action.', 400);
|
||||
|
|
|
@ -3,7 +3,7 @@ use Misuzu\Request\RequestVar;
|
|||
|
||||
require_once '../../misuzu.php';
|
||||
|
||||
$forumId = RequestVar::get()->select('f')->value('int');
|
||||
$forumId = RequestVar::get()->select('f')->int(0);
|
||||
$forumId = max($forumId, 0);
|
||||
|
||||
if ($forumId === 0) {
|
||||
|
|
|
@ -3,9 +3,9 @@ use Misuzu\Request\RequestVar;
|
|||
|
||||
require_once '../misuzu.php';
|
||||
|
||||
$roleId = RequestVar::get()->select('r')->value('int', MSZ_ROLE_MAIN);
|
||||
$orderBy = RequestVar::get()->select('ss')->value();
|
||||
$orderDir = RequestVar::get()->select('sd')->value();
|
||||
$roleId = RequestVar::get()->select('r')->int(MSZ_ROLE_MAIN);
|
||||
$orderBy = RequestVar::get()->select('ss')->string();
|
||||
$orderDir = RequestVar::get()->select('sd')->string();
|
||||
|
||||
$orderDirs = [
|
||||
'asc' => 'Ascending',
|
||||
|
|
|
@ -5,14 +5,14 @@ require_once '../misuzu.php';
|
|||
|
||||
if (RequestVar::get()->isset('n')) {
|
||||
header(sprintf('Location: %s', url('news-post', [
|
||||
'post' => RequestVar::get()->select('n')->value('int'),
|
||||
'post' => RequestVar::get()->select('n')->int(),
|
||||
])));
|
||||
http_response_code(301);
|
||||
return;
|
||||
}
|
||||
|
||||
$categoryId = RequestVar::get()->select('c')->value('int');
|
||||
$postId = RequestVar::get()->select('p')->value('int');
|
||||
$categoryId = RequestVar::get()->select('c')->int();
|
||||
$postId = RequestVar::get()->select('p')->int();
|
||||
|
||||
if ($postId > 0) {
|
||||
$post = news_post_get($postId);
|
||||
|
|
Loading…
Add table
Reference in a new issue