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