Move last online bump into a function.
This commit is contained in:
parent
09490a7599
commit
cbda92f72e
2 changed files with 14 additions and 9 deletions
10
misuzu.php
10
misuzu.php
|
@ -276,15 +276,7 @@ MIG;
|
|||
$app->startSession((int)$_COOKIE['msz_uid'], $_COOKIE['msz_sid']);
|
||||
|
||||
if ($app->hasActiveSession()) {
|
||||
$bumpUserLast = Database::prepare('
|
||||
UPDATE `msz_users` SET
|
||||
`last_seen` = NOW(),
|
||||
`last_ip` = INET6_ATON(:last_ip)
|
||||
WHERE `user_id` = :user_id
|
||||
');
|
||||
$bumpUserLast->bindValue('last_ip', Net\IPAddress::remote()->getString());
|
||||
$bumpUserLast->bindValue('user_id', $app->getUserId());
|
||||
$bumpUserLast->execute();
|
||||
user_bump_last_active($app->getUserId());
|
||||
|
||||
$getUserDisplayInfo = Database::prepare('
|
||||
SELECT
|
||||
|
|
|
@ -69,6 +69,19 @@ function user_id_from_username(string $username): int
|
|||
return $getId->execute() ? (int)$getId->fetchColumn() : 0;
|
||||
}
|
||||
|
||||
function user_bump_last_active(int $userId, string $ipAddress = null): void
|
||||
{
|
||||
$bumpUserLast = Database::prepare('
|
||||
UPDATE `msz_users`
|
||||
SET `last_seen` = NOW(),
|
||||
`last_ip` = INET6_ATON(:last_ip)
|
||||
WHERE `user_id` = :user_id
|
||||
');
|
||||
$bumpUserLast->bindValue('last_ip', $ipAddress ?? $_SERVER['REMOTE_ADDR'] ?? '::1');
|
||||
$bumpUserLast->bindValue('user_id', $userId);
|
||||
$bumpUserLast->execute();
|
||||
}
|
||||
|
||||
define('MSZ_USER_AVATAR_FORMAT', '%d.msz');
|
||||
|
||||
function user_avatar_delete(int $userId): void
|
||||
|
|
Loading…
Reference in a new issue