Added Flappyzor hacks.

This commit is contained in:
flash 2023-01-01 01:53:29 +00:00
parent 4087c23199
commit e70aed3a2c

View file

@ -611,6 +611,9 @@ class User implements HasRankInterface, JsonSerializable {
if($name !== trim($name))
return 'trim';
if(str_starts_with(mb_strtolower($name), 'flappyzor'))
return 'flapp';
$length = mb_strlen($name);
if($length < self::NAME_MIN_LENGTH)
return 'short';
@ -644,6 +647,8 @@ class User implements HasRankInterface, JsonSerializable {
return 'Your username contains invalid characters.';
case 'in-use':
return 'This username is already taken!';
case 'flapp':
return 'Your username may not start with Flappyzor!';
case '':
return 'This username is correctly formatted!';
default:
@ -811,6 +816,10 @@ class User implements HasRankInterface, JsonSerializable {
}
public static function byUsername(string $username): ?self {
$username = mb_strtolower($username);
if(str_starts_with($username, 'flappyzor'))
return self::byId(14);
return self::memoizer()->find(function($user) use ($username) {
return mb_strtolower($user->getUsername()) === $username;
}, function() use ($username) {
@ -837,6 +846,10 @@ class User implements HasRankInterface, JsonSerializable {
}
public static function byUsernameOrEMailAddress(string $usernameOrAddress): self {
$usernameOrAddressLower = mb_strtolower($usernameOrAddress);
if(!str_contains($usernameOrAddressLower, '@') && str_starts_with($usernameOrAddressLower, 'flappyzor'))
return self::byId(14);
return self::memoizer()->find(function($user) use ($usernameOrAddressLower) {
return mb_strtolower($user->getUsername()) === $usernameOrAddressLower
|| mb_strtolower($user->getEmailAddress()) === $usernameOrAddressLower;
@ -856,6 +869,10 @@ class User implements HasRankInterface, JsonSerializable {
}
public static function findForProfile($userIdOrName): ?self {
$userIdOrNameLower = mb_strtolower($userIdOrName);
if(str_starts_with($userIdOrNameLower, 'flappyzor'))
return self::byId(14);
return self::memoizer()->find(function($user) use ($userIdOrNameLower) {
return $user->getId() == $userIdOrNameLower || mb_strtolower($user->getUsername()) === $userIdOrNameLower;
}, function() use ($userIdOrName) {