Compare commits

...

4 commits

19 changed files with 40 additions and 111 deletions

6
composer.lock generated
View file

@ -457,11 +457,11 @@
}, },
{ {
"name": "flashwave/index", "name": "flashwave/index",
"version": "v0.2410.42339", "version": "v0.2410.51409",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://patchii.net/flash/index.git", "url": "https://patchii.net/flash/index.git",
"reference": "d3e4d0985a1189d15fb8ed9eb105830c9dc38c4d" "reference": "c43c6eb334f85edf8fa7b5e4058b3ba35a27d960"
}, },
"require": { "require": {
"ext-mbstring": "*", "ext-mbstring": "*",
@ -500,7 +500,7 @@
], ],
"description": "Composer package for the common library for my projects.", "description": "Composer package for the common library for my projects.",
"homepage": "https://railgun.sh/index", "homepage": "https://railgun.sh/index",
"time": "2024-10-04T23:39:32+00:00" "time": "2024-10-05T14:10:08+00:00"
}, },
{ {
"name": "guzzlehttp/psr7", "name": "guzzlehttp/psr7",

View file

@ -3,7 +3,7 @@ namespace Misuzu;
use RuntimeException; use RuntimeException;
use Index\Colour\Colour; use Index\Colour\Colour;
use Index\Colour\ColourRGB; use Index\Colour\ColourRgb;
use Misuzu\Perm; use Misuzu\Perm;
$authInfo = $msz->getAuthInfo(); $authInfo = $msz->getAuthInfo();
@ -86,7 +86,7 @@ while($_SERVER['REQUEST_METHOD'] === 'POST' && CSRF::validateRequest()) {
$roleColour = $colourInherit $roleColour = $colourInherit
? Colour::none() ? Colour::none()
: new ColourRGB($colourRed, $colourGreen, $colourBlue); : new ColourRgb($colourRed, $colourGreen, $colourBlue);
if(mb_strlen($roleDesc) > 1000) { if(mb_strlen($roleDesc) > 1000) {
echo 'Description may not be longer than 1000 characters.'; echo 'Description may not be longer than 1000 characters.';

View file

@ -3,7 +3,6 @@ namespace Misuzu\AuditLog;
use InvalidArgumentException; use InvalidArgumentException;
use Index\Db\{DbConnection,DbStatementCache}; use Index\Db\{DbConnection,DbStatementCache};
use Index\Net\IPAddress;
use Misuzu\Pagination; use Misuzu\Pagination;
use Misuzu\Users\UserInfo; use Misuzu\Users\UserInfo;
@ -16,12 +15,10 @@ class AuditLog {
public function countLogs( public function countLogs(
UserInfo|string|null $userInfo = null, UserInfo|string|null $userInfo = null,
IPAddress|string|null $remoteAddr = null ?string $remoteAddr = null
): int { ): int {
if($userInfo instanceof UserInfo) if($userInfo instanceof UserInfo)
$userInfo = $userInfo->getId(); $userInfo = $userInfo->getId();
if($remoteAddr instanceof IPAddress)
$remoteAddr = (string)$remoteAddr;
$hasUserInfo = $userInfo !== null; $hasUserInfo = $userInfo !== null;
$hasRemoteAddr = $remoteAddr !== null; $hasRemoteAddr = $remoteAddr !== null;
@ -57,13 +54,11 @@ class AuditLog {
public function getLogs( public function getLogs(
UserInfo|string|null $userInfo = null, UserInfo|string|null $userInfo = null,
IPAddress|string|null $remoteAddr = null, ?string $remoteAddr = null,
?Pagination $pagination = null ?Pagination $pagination = null
): iterable { ): iterable {
if($userInfo instanceof UserInfo) if($userInfo instanceof UserInfo)
$userInfo = $userInfo->getId(); $userInfo = $userInfo->getId();
if($remoteAddr instanceof IPAddress)
$remoteAddr = (string)$remoteAddr;
$hasUserInfo = $userInfo !== null; $hasUserInfo = $userInfo !== null;
$hasRemoteAddr = $remoteAddr !== null; $hasRemoteAddr = $remoteAddr !== null;
@ -104,13 +99,11 @@ class AuditLog {
UserInfo|string|null $userInfo, UserInfo|string|null $userInfo,
string $action, string $action,
array $params = [], array $params = [],
IPAddress|string $remoteAddr = '::1', string $remoteAddr = '::1',
string $countryCode = 'XX' string $countryCode = 'XX'
): void { ): void {
if($userInfo instanceof UserInfo) if($userInfo instanceof UserInfo)
$userInfo = $userInfo->getId(); $userInfo = $userInfo->getId();
if($remoteAddr instanceof IPAddress)
$remoteAddr = (string)$remoteAddr;
// action names should have stricter validation, // action names should have stricter validation,
// i do want to switch to a lowercase colon separated format later but i'll save that for the unified log in Hanyuu // i do want to switch to a lowercase colon separated format later but i'll save that for the unified log in Hanyuu

View file

@ -4,7 +4,6 @@ namespace Misuzu\AuditLog;
use ValueError; use ValueError;
use Carbon\CarbonImmutable; use Carbon\CarbonImmutable;
use Index\Db\DbResult; use Index\Db\DbResult;
use Index\Net\IPAddress;
class AuditLogInfo { class AuditLogInfo {
public function __construct( public function __construct(
@ -51,14 +50,10 @@ class AuditLogInfo {
return CarbonImmutable::createFromTimestampUTC($this->created); return CarbonImmutable::createFromTimestampUTC($this->created);
} }
public function getRemoteAddressRaw(): string { public function getRemoteAddress(): string {
return $this->address; return $this->address;
} }
public function getRemoteAddress(): IPAddress {
return IPAddress::parse($this->address);
}
public function getCountryCode(): string { public function getCountryCode(): string {
return $this->country; return $this->country;
} }

View file

@ -4,7 +4,6 @@ namespace Misuzu\Auth;
use Misuzu\ClientInfo; use Misuzu\ClientInfo;
use Carbon\CarbonImmutable; use Carbon\CarbonImmutable;
use Index\Db\DbResult; use Index\Db\DbResult;
use Index\Net\IPAddress;
class LoginAttemptInfo { class LoginAttemptInfo {
public function __construct( public function __construct(
@ -41,14 +40,10 @@ class LoginAttemptInfo {
return $this->success; return $this->success;
} }
public function getRemoteAddressRaw(): string { public function getRemoteAddress(): string {
return $this->remoteAddr; return $this->remoteAddr;
} }
public function getRemoteAddress(): IPAddress {
return IPAddress::parse($this->remoteAddr);
}
public function getCountryCode(): string { public function getCountryCode(): string {
return $this->countryCode; return $this->countryCode;
} }

View file

@ -2,7 +2,6 @@
namespace Misuzu\Auth; namespace Misuzu\Auth;
use Index\Db\{DbConnection,DbStatementCache}; use Index\Db\{DbConnection,DbStatementCache};
use Index\Net\IPAddress;
use Misuzu\ClientInfo; use Misuzu\ClientInfo;
use Misuzu\Pagination; use Misuzu\Pagination;
use Misuzu\Users\UserInfo; use Misuzu\Users\UserInfo;
@ -20,13 +19,11 @@ class LoginAttempts {
public function countAttempts( public function countAttempts(
?bool $success = null, ?bool $success = null,
UserInfo|string|null $userInfo = null, UserInfo|string|null $userInfo = null,
IPAddress|string|null $remoteAddr = null, ?string $remoteAddr = null,
int|null $timeRange = null int|null $timeRange = null
): int { ): int {
if($userInfo instanceof UserInfo) if($userInfo instanceof UserInfo)
$userInfo = $userInfo->getId(); $userInfo = $userInfo->getId();
if($remoteAddr instanceof IPAddress)
$remoteAddr = (string)$remoteAddr;
$hasSuccess = $success !== null; $hasSuccess = $success !== null;
$hasUserInfo = $userInfo !== null; $hasUserInfo = $userInfo !== null;
@ -65,7 +62,7 @@ class LoginAttempts {
return $count; return $count;
} }
public function countRemainingAttempts(IPAddress|string $remoteAddr): int { public function countRemainingAttempts(string $remoteAddr): int {
return self::REMAINING_MAX - $this->countAttempts( return self::REMAINING_MAX - $this->countAttempts(
success: false, success: false,
timeRange: self::REMAINING_WINDOW, timeRange: self::REMAINING_WINDOW,
@ -76,14 +73,12 @@ class LoginAttempts {
public function getAttempts( public function getAttempts(
?bool $success = null, ?bool $success = null,
UserInfo|string|null $userInfo = null, UserInfo|string|null $userInfo = null,
IPAddress|string|null $remoteAddr = null, ?string $remoteAddr = null,
int|null $timeRange = null, ?int $timeRange = null,
?Pagination $pagination = null ?Pagination $pagination = null
): iterable { ): iterable {
if($userInfo instanceof UserInfo) if($userInfo instanceof UserInfo)
$userInfo = $userInfo->getId(); $userInfo = $userInfo->getId();
if($remoteAddr instanceof IPAddress)
$remoteAddr = (string)$remoteAddr;
$hasSuccess = $success !== null; $hasSuccess = $success !== null;
$hasUserInfo = $userInfo !== null; $hasUserInfo = $userInfo !== null;
@ -126,14 +121,12 @@ class LoginAttempts {
public function recordAttempt( public function recordAttempt(
bool $success, bool $success,
IPAddress|string $remoteAddr, string $remoteAddr,
string $countryCode, string $countryCode,
string $userAgentString, string $userAgentString,
?ClientInfo $clientInfo = null, ?ClientInfo $clientInfo = null,
UserInfo|string|null $userInfo = null UserInfo|string|null $userInfo = null
): void { ): void {
if($remoteAddr instanceof IPAddress)
$remoteAddr = (string)$remoteAddr;
if($userInfo instanceof UserInfo) if($userInfo instanceof UserInfo)
$userInfo = $userInfo->getId(); $userInfo = $userInfo->getId();

View file

@ -3,7 +3,6 @@ namespace Misuzu\Auth;
use Carbon\CarbonImmutable; use Carbon\CarbonImmutable;
use Index\Db\DbResult; use Index\Db\DbResult;
use Index\Net\IPAddress;
class RecoveryTokenInfo { class RecoveryTokenInfo {
public const LIFETIME = 60 * 60; public const LIFETIME = 60 * 60;
@ -24,14 +23,10 @@ class RecoveryTokenInfo {
return $this->userId; return $this->userId;
} }
public function getRemoteAddressRaw(): string { public function getRemoteAddress(): string {
return $this->remoteAddr; return $this->remoteAddr;
} }
public function getRemoteAddress(): IPAddress {
return IPAddress::parse($this->remoteAddr);
}
public function getCreatedTime(): int { public function getCreatedTime(): int {
return $this->created; return $this->created;
} }

View file

@ -5,7 +5,6 @@ use InvalidArgumentException;
use RuntimeException; use RuntimeException;
use Index\Base32; use Index\Base32;
use Index\Db\{DbConnection,DbStatementCache}; use Index\Db\{DbConnection,DbStatementCache};
use Index\Net\IPAddress;
use Misuzu\ClientInfo; use Misuzu\ClientInfo;
use Misuzu\Pagination; use Misuzu\Pagination;
use Misuzu\Users\UserInfo; use Misuzu\Users\UserInfo;
@ -24,14 +23,12 @@ class RecoveryTokens {
public function getToken( public function getToken(
UserInfo|string|null $userInfo = null, UserInfo|string|null $userInfo = null,
IPAddress|string|null $remoteAddr = null, ?string $remoteAddr = null,
?string $verifyCode = null, ?string $verifyCode = null,
?bool $isUnused = null ?bool $isUnused = null
): RecoveryTokenInfo { ): RecoveryTokenInfo {
if($userInfo instanceof UserInfo) if($userInfo instanceof UserInfo)
$userInfo = $userInfo->getId(); $userInfo = $userInfo->getId();
if($remoteAddr instanceof IPAddress)
$remoteAddr = (string)$remoteAddr;
$hasUserInfo = $userInfo !== null; $hasUserInfo = $userInfo !== null;
$hasRemoteAddr = $remoteAddr !== null; $hasRemoteAddr = $remoteAddr !== null;
@ -75,12 +72,11 @@ class RecoveryTokens {
public function createToken( public function createToken(
UserInfo|string $userInfo, UserInfo|string $userInfo,
IPAddress|string $remoteAddr string $remoteAddr
): RecoveryTokenInfo { ): RecoveryTokenInfo {
if($userInfo instanceof UserInfo) if($userInfo instanceof UserInfo)
$userInfo = $userInfo->getId(); $userInfo = $userInfo->getId();
if($remoteAddr instanceof IPAddress)
$remoteAddr = (string)$remoteAddr;
$verifyCode = self::generateCode(); $verifyCode = self::generateCode();
$stmt = $this->cache->get('INSERT INTO msz_users_password_resets (user_id, reset_ip, verification_code) VALUES (?, INET6_ATON(?), ?)'); $stmt = $this->cache->get('INSERT INTO msz_users_password_resets (user_id, reset_ip, verification_code) VALUES (?, INET6_ATON(?), ?)');

View file

@ -4,7 +4,6 @@ namespace Misuzu\Auth;
use Misuzu\ClientInfo; use Misuzu\ClientInfo;
use Carbon\CarbonImmutable; use Carbon\CarbonImmutable;
use Index\Db\DbResult; use Index\Db\DbResult;
use Index\Net\IPAddress;
class SessionInfo { class SessionInfo {
public function __construct( public function __construct(
@ -51,26 +50,18 @@ class SessionInfo {
return $this->token; return $this->token;
} }
public function getFirstRemoteAddressRaw(): string { public function getFirstRemoteAddress(): string {
return $this->firstRemoteAddr; return $this->firstRemoteAddr;
} }
public function getFirstRemoteAddress(): IPAddress {
return IPAddress::parse($this->firstRemoteAddr);
}
public function hasLastRemoteAddress(): bool { public function hasLastRemoteAddress(): bool {
return $this->lastRemoteAddr !== null; return $this->lastRemoteAddr !== null;
} }
public function getLastRemoteAddressRaw(): string { public function getLastRemoteAddress(): ?string {
return $this->lastRemoteAddr; return $this->lastRemoteAddr;
} }
public function getLastRemoteAddress(): ?IPAddress {
return $this->lastRemoteAddr === null ? null : IPAddress::parse($this->lastRemoteAddr);
}
public function getUserAgentString(): string { public function getUserAgentString(): string {
return $this->userAgent; return $this->userAgent;
} }

View file

@ -5,7 +5,6 @@ use InvalidArgumentException;
use RuntimeException; use RuntimeException;
use Index\XString; use Index\XString;
use Index\Db\{DbConnection,DbStatementCache,DbTools}; use Index\Db\{DbConnection,DbStatementCache,DbTools};
use Index\Net\IPAddress;
use Misuzu\ClientInfo; use Misuzu\ClientInfo;
use Misuzu\Pagination; use Misuzu\Pagination;
use Misuzu\Users\UserInfo; use Misuzu\Users\UserInfo;
@ -121,15 +120,13 @@ class Sessions {
public function createSession( public function createSession(
UserInfo|string $userInfo, UserInfo|string $userInfo,
IPAddress|string $remoteAddr, string $remoteAddr,
string $countryCode, string $countryCode,
string $userAgentString, string $userAgentString,
?ClientInfo $clientInfo = null ?ClientInfo $clientInfo = null
): SessionInfo { ): SessionInfo {
if($userInfo instanceof UserInfo) if($userInfo instanceof UserInfo)
$userInfo = $userInfo->getId(); $userInfo = $userInfo->getId();
if($remoteAddr instanceof IPAddress)
$remoteAddr = (string)$remoteAddr;
$sessionToken = self::generateToken(); $sessionToken = self::generateToken();
$clientInfo = json_encode($clientInfo ?? ClientInfo::parse($userAgentString)); $clientInfo = json_encode($clientInfo ?? ClientInfo::parse($userAgentString));
@ -241,7 +238,7 @@ class Sessions {
public function recordSessionActivity( public function recordSessionActivity(
SessionInfo|string|null $sessionInfo = null, SessionInfo|string|null $sessionInfo = null,
?string $sessionToken = null, ?string $sessionToken = null,
IPAddress|string|null $remoteAddr = null ?string $remoteAddr = null
): void { ): void {
if($sessionInfo === null && $sessionToken === null) if($sessionInfo === null && $sessionToken === null)
throw new InvalidArgumentException('Either $sessionInfo or $sessionToken needs to be set.'); throw new InvalidArgumentException('Either $sessionInfo or $sessionToken needs to be set.');
@ -249,8 +246,6 @@ class Sessions {
throw new InvalidArgumentException('Only one of $sessionInfo and $sessionToken may be set at once.'); throw new InvalidArgumentException('Only one of $sessionInfo and $sessionToken may be set at once.');
if($sessionInfo instanceof SessionInfo) if($sessionInfo instanceof SessionInfo)
$sessionInfo = $sessionInfo->getId(); $sessionInfo = $sessionInfo->getId();
if($remoteAddr instanceof IPAddress)
$remoteAddr = (string)$remoteAddr;
$hasSessionInfo = $sessionInfo !== null; $hasSessionInfo = $sessionInfo !== null;
$hasSessionToken = $sessionToken !== null; $hasSessionToken = $sessionToken !== null;

View file

@ -22,7 +22,7 @@ class CommentsPostInfo {
) {} ) {}
public static function fromResult( public static function fromResult(
IDbResult $result, DbResult $result,
bool $includeRepliesCount = false, bool $includeRepliesCount = false,
bool $includeVotesCount = false bool $includeVotesCount = false
): CommentsPostInfo { ): CommentsPostInfo {

View file

@ -5,7 +5,6 @@ use Misuzu\Parsers\Parser;
use Carbon\CarbonImmutable; use Carbon\CarbonImmutable;
use Index\XDateTime; use Index\XDateTime;
use Index\Db\DbResult; use Index\Db\DbResult;
use Index\Net\IPAddress;
class ForumPostInfo { class ForumPostInfo {
public function __construct( public function __construct(
@ -58,14 +57,10 @@ class ForumPostInfo {
return $this->userId; return $this->userId;
} }
public function getRemoteAddressRaw(): string { public function getRemoteAddress(): string {
return $this->remoteAddr; return $this->remoteAddr;
} }
public function getRemoteAddress(): IPAddress {
return IPAddress::parse($this->remoteAddr);
}
public function getBody(): string { public function getBody(): string {
return $this->body; return $this->body;
} }

View file

@ -6,7 +6,6 @@ use RuntimeException;
use stdClass; use stdClass;
use Carbon\CarbonImmutable; use Carbon\CarbonImmutable;
use Index\Db\{DbConnection,DbStatementCache,DbTools}; use Index\Db\{DbConnection,DbStatementCache,DbTools};
use Index\Net\IPAddress;
use Misuzu\Pagination; use Misuzu\Pagination;
use Misuzu\Users\UserInfo; use Misuzu\Users\UserInfo;
@ -265,7 +264,7 @@ class ForumPosts {
public function createPost( public function createPost(
ForumTopicInfo|string $topicInfo, ForumTopicInfo|string $topicInfo,
UserInfo|string|null $userInfo, UserInfo|string|null $userInfo,
IPAddress|string $remoteAddr, string $remoteAddr,
string $body, string $body,
int $bodyParser, int $bodyParser,
bool $displaySignature, bool $displaySignature,
@ -283,9 +282,6 @@ class ForumPosts {
if($userInfo instanceof UserInfo) if($userInfo instanceof UserInfo)
$userInfo = $userInfo->getId(); $userInfo = $userInfo->getId();
if($remoteAddr instanceof IPAddress)
$remoteAddr = (string)$remoteAddr;
$stmt = $this->cache->get('INSERT INTO msz_forum_posts (topic_id, forum_id, user_id, post_ip, post_text, post_parse, post_display_signature) VALUES (?, ?, ?, INET6_ATON(?), ?, ?, ?)'); $stmt = $this->cache->get('INSERT INTO msz_forum_posts (topic_id, forum_id, user_id, post_ip, post_text, post_parse, post_display_signature) VALUES (?, ?, ?, INET6_ATON(?), ?, ?, ?)');
$stmt->addParameter(1, $topicInfo); $stmt->addParameter(1, $topicInfo);
$stmt->addParameter(2, $categoryInfo); $stmt->addParameter(2, $categoryInfo);
@ -301,7 +297,7 @@ class ForumPosts {
public function updatePost( public function updatePost(
ForumPostInfo|string $postInfo, ForumPostInfo|string $postInfo,
IPAddress|string|null $remoteAddr = null, ?string $remoteAddr = null,
?string $body = null, ?string $body = null,
?int $bodyParser = null, ?int $bodyParser = null,
?bool $displaySignature = null, ?bool $displaySignature = null,
@ -314,9 +310,6 @@ class ForumPosts {
$values = []; $values = [];
if($remoteAddr !== null) { if($remoteAddr !== null) {
if($remoteAddr instanceof IPAddress)
$remoteAddr = (string)$remoteAddr;
$fields[] = 'post_ip = INET6_ATON(?)'; $fields[] = 'post_ip = INET6_ATON(?)';
$values[] = $remoteAddr; $values[] = $remoteAddr;
} }

View file

@ -2,16 +2,18 @@
namespace Misuzu; namespace Misuzu;
use Index\Http\Routing\{HttpGet,RouteHandler,RouteHandlerTrait}; use Index\Http\Routing\{HttpGet,RouteHandler,RouteHandlerTrait};
use Index\Urls\{UrlFormat,UrlRegistry,UrlSource,UrlSourceTrait}; use Index\Urls\{UrlFormat,UrlRegistry,UrlSource};
class LegacyRoutes implements RouteHandler, UrlSource { class LegacyRoutes implements RouteHandler, UrlSource {
use RouteHandlerTrait, UrlSourceTrait; use RouteHandlerTrait;
public function __construct( public function __construct(
private UrlRegistry $urls private UrlRegistry $urls
) {} ) {}
public function registerUrls(UrlRegistry $urls): void { public function registerUrls(UrlRegistry $urls): void {
UrlFormat::register($urls, $this);
// eventually this should be handled by context classes // eventually this should be handled by context classes
$urls->register('search-index', '/search.php'); $urls->register('search-index', '/search.php');
$urls->register('search-query', '/search.php', ['q' => '<query>'], '<section>'); $urls->register('search-query', '/search.php', ['q' => '<query>'], '<section>');

View file

@ -5,7 +5,6 @@ use Misuzu\Parsers\Parser;
use Carbon\CarbonImmutable; use Carbon\CarbonImmutable;
use Index\Colour\Colour; use Index\Colour\Colour;
use Index\Db\DbResult; use Index\Db\DbResult;
use Index\Net\IPAddress;
class UserInfo { class UserInfo {
public function __construct( public function __construct(
@ -86,22 +85,14 @@ class UserInfo {
return $this->emailAddr; return $this->emailAddr;
} }
public function getRegisterRemoteAddressRaw(): string { public function getRegisterRemoteAddress(): string {
return $this->registerRemoteAddr; return $this->registerRemoteAddr;
} }
public function getRegisterRemoteAddress(): IPAddress { public function getLastRemoteAddress(): string {
return IPAddress::parse($this->registerRemoteAddr);
}
public function getLastRemoteAddressRaw(): string {
return $this->lastRemoteAddr; return $this->lastRemoteAddr;
} }
public function getLastRemoteAddress(): IPAddress {
return IPAddress::parse($this->lastRemoteAddr);
}
public function isSuperUser(): bool { public function isSuperUser(): bool {
return $this->super; return $this->super;
} }

View file

@ -7,7 +7,6 @@ use DateTimeInterface;
use Index\XString; use Index\XString;
use Index\Colour\Colour; use Index\Colour\Colour;
use Index\Db\{DbConnection,DbStatementCache,DbTools}; use Index\Db\{DbConnection,DbStatementCache,DbTools};
use Index\Net\IPAddress;
use Misuzu\Pagination; use Misuzu\Pagination;
use Misuzu\Tools; use Misuzu\Tools;
use Misuzu\Parsers\Parser; use Misuzu\Parsers\Parser;
@ -282,12 +281,10 @@ class Users {
string $name, string $name,
string $password, string $password,
string $email, string $email,
IPAddress|string $remoteAddr, string $remoteAddr,
string $countryCode, string $countryCode,
RoleInfo|string|null $displayRoleInfo = null RoleInfo|string|null $displayRoleInfo = null
): UserInfo { ): UserInfo {
if($remoteAddr instanceof IPAddress)
$remoteAddr = (string)$remoteAddr;
if($displayRoleInfo instanceof RoleInfo) if($displayRoleInfo instanceof RoleInfo)
$displayRoleInfo = $displayRoleInfo->getId(); $displayRoleInfo = $displayRoleInfo->getId();
elseif($displayRoleInfo === null) elseif($displayRoleInfo === null)
@ -436,12 +433,10 @@ class Users {
public function recordUserActivity( public function recordUserActivity(
UserInfo|string $userInfo, UserInfo|string $userInfo,
IPAddress|string $remoteAddr string $remoteAddr
): void { ): void {
if($userInfo instanceof UserInfo) if($userInfo instanceof UserInfo)
$userInfo = $userInfo->getId(); $userInfo = $userInfo->getId();
if($remoteAddr instanceof IPAddress)
$remoteAddr = (string)$remoteAddr;
$stmt = $this->cache->get('UPDATE msz_users SET user_active = NOW(), last_ip = INET6_ATON(?) WHERE user_id = ?'); $stmt = $this->cache->get('UPDATE msz_users SET user_active = NOW(), last_ip = INET6_ATON(?) WHERE user_id = ?');
$stmt->addParameter(1, $remoteAddr); $stmt->addParameter(1, $remoteAddr);

View file

@ -6,7 +6,7 @@ use Misuzu\SiteInfo;
use Misuzu\Users\Assets\UserAvatarAsset; use Misuzu\Users\Assets\UserAvatarAsset;
use Aiwass\Server\{RpcActionHandler,RpcQuery}; use Aiwass\Server\{RpcActionHandler,RpcQuery};
use Index\XArray; use Index\XArray;
use Index\Colour\{Colour,ColourRGB}; use Index\Colour\{Colour,ColourRgb};
use Index\Urls\UrlRegistry; use Index\Urls\UrlRegistry;
final class UsersRpcActions extends RpcActionHandler { final class UsersRpcActions extends RpcActionHandler {
@ -35,7 +35,7 @@ final class UsersRpcActions extends RpcActionHandler {
} else { } else {
// Index doesn't have a proper toRawRGB func??? // Index doesn't have a proper toRawRGB func???
$colourRaw = Colour::toMisuzu($colour) & 0xFFFFFF; $colourRaw = Colour::toMisuzu($colour) & 0xFFFFFF;
$colourCSS = (string)ColourRGB::convert($colour); $colourCSS = (string)ColourRgb::convert($colour);
} }
$baseUrl = $this->siteInfo->getURL(); $baseUrl = $this->siteInfo->getURL();

View file

@ -28,13 +28,13 @@
<div class="manage__user-item__detail"> <div class="manage__user-item__detail">
<i class="fas fa-user-plus fa-fw"></i> <i class="fas fa-user-plus fa-fw"></i>
<time datetime="{{ user.info.createdTime|date('c') }}" title="{{ user.info.createdTime|date('r') }}">{{ user.info.createdTime|time_format }}</time> / <time datetime="{{ user.info.createdTime|date('c') }}" title="{{ user.info.createdTime|date('r') }}">{{ user.info.createdTime|time_format }}</time> /
<span>{{ user.info.registerRemoteAddressRaw }}</span> <span>{{ user.info.registerRemoteAddress }}</span>
</div> </div>
{% if user.info.hasLastActive %} {% if user.info.hasLastActive %}
<div class="manage__user-item__detail"> <div class="manage__user-item__detail">
<i class="fas fa-user-clock fa-fw"></i> <i class="fas fa-user-clock fa-fw"></i>
<time datetime="{{ user.info.lastActiveTime|date('c') }}" title="{{ user.info.lastActiveTime|date('r') }}">{{ user.info.lastActiveTime|time_format }}</time> / <time datetime="{{ user.info.lastActiveTime|date('c') }}" title="{{ user.info.lastActiveTime|date('r') }}">{{ user.info.lastActiveTime|time_format }}</time> /
<span>{{ user.info.lastRemoteAddressRaw }}</span> <span>{{ user.info.lastRemoteAddress }}</span>
</div> </div>
{% endif %} {% endif %}
{% if user.info.isDeleted %} {% if user.info.isDeleted %}

View file

@ -189,7 +189,7 @@
IP Address IP Address
</div> </div>
<div class="settings__login-attempt__detail__value"> <div class="settings__login-attempt__detail__value">
{{ attempt.remoteAddressRaw }} {{ attempt.remoteAddress }}
</div> </div>
</div> </div>