Refactor
This commit is contained in:
parent
697b801653
commit
a82420b171
2 changed files with 27 additions and 17 deletions
2
src/classes/cache/cache.php
vendored
2
src/classes/cache/cache.php
vendored
|
@ -13,7 +13,7 @@ class Cache
|
||||||
*/
|
*/
|
||||||
protected string $url;
|
protected string $url;
|
||||||
protected string $directory = ROOT . '/src/cache';
|
protected string $directory = ROOT . '/src/cache';
|
||||||
protected int $maxAge = 2592000; // 30 days
|
protected int $maxAge = 2592000; // 30 days
|
||||||
|
|
||||||
protected function getAge(): int
|
protected function getAge(): int
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,10 +24,10 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
|
||||||
$users
|
$users
|
||||||
);
|
);
|
||||||
|
|
||||||
$isHuman = false;
|
$isHuman = false;
|
||||||
$planet = strtolower($_POST['planet']);
|
$planet = strtolower($_POST['planet']);
|
||||||
$planetName = strtoupper($planet[0]) . substr($planet, 1);
|
$planetName = strtoupper($planet[0]) . substr($planet, 1);
|
||||||
$planets = array(
|
$planets = array(
|
||||||
strtolower(__('Mercury')),
|
strtolower(__('Mercury')),
|
||||||
strtolower(__('Venus')),
|
strtolower(__('Venus')),
|
||||||
strtolower(__('Earth')),
|
strtolower(__('Earth')),
|
||||||
|
@ -61,19 +61,23 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
|
||||||
* Password reset
|
* Password reset
|
||||||
*/
|
*/
|
||||||
$user = $database
|
$user = $database
|
||||||
->query('SELECT * FROM `users`
|
->query(
|
||||||
WHERE `email` = "' . $_GET['password-reset'] . '"
|
'SELECT * FROM `users`
|
||||||
AND `password_reset_token` = "' . $_GET['token'] . '";')
|
WHERE `email` = "' . $_GET['password-reset'] . '"
|
||||||
|
AND `password_reset_token` = "' . $_GET['token'] . '";'
|
||||||
|
)
|
||||||
->fetch();
|
->fetch();
|
||||||
|
|
||||||
if ($user) {
|
if (false !== $user) {
|
||||||
if (time() > $user['password_reset_valid_until']) {
|
if (time() > $user['password_reset_valid_until']) {
|
||||||
$database
|
$database
|
||||||
->query('UPDATE `users`
|
->query(
|
||||||
|
'UPDATE `users`
|
||||||
SET `password` = "' . User::generatePassword($_POST['password']) . '",
|
SET `password` = "' . User::generatePassword($_POST['password']) . '",
|
||||||
`password_reset_token` = NULL,
|
`password_reset_token` = NULL,
|
||||||
`password_reset_valid_until` = NULL
|
`password_reset_valid_until` = NULL
|
||||||
WHERE `id` = ' . $user['id'] . ';');
|
WHERE `id` = ' . $user['id'] . ';'
|
||||||
|
);
|
||||||
|
|
||||||
$page->messages[] = Page::success(
|
$page->messages[] = Page::success(
|
||||||
'Password has been successfully reset for <strong>' . $_GET['password-reset'] . '</strong>.',
|
'Password has been successfully reset for <strong>' . $_GET['password-reset'] . '</strong>.',
|
||||||
|
@ -90,7 +94,8 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
|
||||||
* Register
|
* Register
|
||||||
*/
|
*/
|
||||||
if (0 === count($users)) {
|
if (0 === count($users)) {
|
||||||
$database->query('INSERT INTO `users`
|
$database->query(
|
||||||
|
'INSERT INTO `users`
|
||||||
(
|
(
|
||||||
`email`,
|
`email`,
|
||||||
`password`,
|
`password`,
|
||||||
|
@ -100,7 +105,8 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
|
||||||
"' . User::generatePassword($_POST['password']) . '",
|
"' . User::generatePassword($_POST['password']) . '",
|
||||||
100
|
100
|
||||||
)
|
)
|
||||||
;');
|
;'
|
||||||
|
);
|
||||||
$userRegistered = true;
|
$userRegistered = true;
|
||||||
} else {
|
} else {
|
||||||
if (in_array($_POST['email'], $emails)) {
|
if (in_array($_POST['email'], $emails)) {
|
||||||
|
@ -109,7 +115,8 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
|
||||||
__('Invalid email address')
|
__('Invalid email address')
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$database->query('INSERT INTO `users`
|
$database->query(
|
||||||
|
'INSERT INTO `users`
|
||||||
(
|
(
|
||||||
`email`,
|
`email`,
|
||||||
`password`
|
`password`
|
||||||
|
@ -117,7 +124,8 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
|
||||||
"' . $_POST['email'] . '",
|
"' . $_POST['email'] . '",
|
||||||
"' . User::generatePassword($_POST['password']) . '"
|
"' . User::generatePassword($_POST['password']) . '"
|
||||||
)
|
)
|
||||||
;');
|
;'
|
||||||
|
);
|
||||||
$userRegistered = true;
|
$userRegistered = true;
|
||||||
|
|
||||||
$page->messages[] = Page::success(__('Your account was successfully created.'), __('Success'));
|
$page->messages[] = Page::success(__('Your account was successfully created.'), __('Success'));
|
||||||
|
@ -133,7 +141,8 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
|
||||||
$wishlistName = __('My hopes and dreams');
|
$wishlistName = __('My hopes and dreams');
|
||||||
|
|
||||||
$database
|
$database
|
||||||
->query('INSERT INTO `wishlists`
|
->query(
|
||||||
|
'INSERT INTO `wishlists`
|
||||||
(
|
(
|
||||||
`user`,
|
`user`,
|
||||||
`name`,
|
`name`,
|
||||||
|
@ -143,7 +152,8 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
|
||||||
"' . $wishlistName . '",
|
"' . $wishlistName . '",
|
||||||
"' . sha1(time() . $userID . $wishlistName) . '"
|
"' . sha1(time() . $userID . $wishlistName) . '"
|
||||||
)
|
)
|
||||||
;');
|
;'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$page->messages[] = Page::error(
|
$page->messages[] = Page::error(
|
||||||
|
|
Loading…
Reference in a new issue