diff --git a/lib/index b/lib/index index 8f908d7..1cd1695 160000 --- a/lib/index +++ b/lib/index @@ -1 +1 @@ -Subproject commit 8f908d7f688bd95fdedd868c5bf8d25a3b500b99 +Subproject commit 1cd1695429b5a313ac357f3f3faba365e425f504 diff --git a/public/profile.php b/public/profile.php index 29ffb91..5852706 100644 --- a/public/profile.php +++ b/public/profile.php @@ -2,6 +2,7 @@ namespace Misuzu; use InvalidArgumentException; +use Index\ByteFormat; use Misuzu\Parsers\Parser; use Misuzu\Users\User; use Misuzu\Users\UserNotFoundException; @@ -183,7 +184,7 @@ if($isEditing) { break; case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: - $notices[] = sprintf('Your avatar is not allowed to be larger in file size than %s!', byte_symbol($avatarInfo->getMaxBytes(), true)); + $notices[] = sprintf('Your avatar is not allowed to be larger in file size than %s!', ByteFormat::format($avatarInfo->getMaxBytes())); break; default: $notices[] = 'Unable to save your avatar, contact an administator!'; @@ -199,7 +200,7 @@ if($isEditing) { } catch(UserImageAssetInvalidDimensionsException $ex) { $notices[] = sprintf('Your avatar can\'t be larger than %dx%d!', $avatarInfo->getMaxWidth(), $avatarInfo->getMaxHeight()); } catch(UserImageAssetFileTooLargeException $ex) { - $notices[] = sprintf('Your avatar is not allowed to be larger in file size than %s!', byte_symbol($avatarInfo->getMaxBytes(), true)); + $notices[] = sprintf('Your avatar is not allowed to be larger in file size than %s!', ByteFormat::format($avatarInfo->getMaxBytes())); } catch(UserImageAssetException $ex) { $notices[] = 'Unable to save your avatar, contact an administator!'; } @@ -228,7 +229,7 @@ if($isEditing) { break; case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: - $notices[] = sprintf('Your background is not allowed to be larger in file size than %s!', byte_symbol($backgroundProps['max_size'], true)); + $notices[] = sprintf('Your background is not allowed to be larger in file size than %s!', ByteFormat::format($backgroundProps['max_size'])); break; default: $notices[] = 'Unable to save your background, contact an administator!'; @@ -244,7 +245,7 @@ if($isEditing) { } catch(UserImageAssetInvalidDimensionsException $ex) { $notices[] = sprintf('Your background can\'t be larger than %dx%d!', $backgroundInfo->getMaxWidth(), $backgroundInfo->getMaxHeight()); } catch(UserImageAssetFileTooLargeException $ex) { - $notices[] = sprintf('Your background is not allowed to be larger in file size than %2$s!', byte_symbol($backgroundInfo->getMaxBytes(), true)); + $notices[] = sprintf('Your background is not allowed to be larger in file size than %2$s!', ByteFormat::format($backgroundInfo->getMaxBytes())); } catch(UserImageAssetException $ex) { $notices[] = 'Unable to save your background, contact an administator!'; } diff --git a/src/TwigMisuzu.php b/src/TwigMisuzu.php index af77cd2..ce69db3 100644 --- a/src/TwigMisuzu.php +++ b/src/TwigMisuzu.php @@ -7,6 +7,7 @@ use Twig\TwigFunction; use Twig\Environment as TwigEnvironment; use Misuzu\Parsers\Parser; use Misuzu\MisuzuContext; +use Index\ByteFormat; use Index\Environment; final class TwigMisuzu extends AbstractExtension { @@ -20,7 +21,6 @@ final class TwigMisuzu extends AbstractExtension { return [ new TwigFilter('html_colour', 'html_colour'), new TwigFilter('country_name', 'get_country_name'), - new TwigFilter('byte_symbol', 'byte_symbol'), new TwigFilter('parse_text', fn(string $text, int $parser): string => Parser::instance($parser)->parseText($text)), new TwigFilter('perms_check', 'perms_check'), new TwigFilter('time_diff', [$this, 'timeDiff'], ['needs_environment' => true]), @@ -40,6 +40,7 @@ final class TwigMisuzu extends AbstractExtension { new TwigFunction('startup_time', fn(float $time = MSZ_STARTUP) => microtime(true) - $time), new TwigFunction('sql_query_count', fn() => DB::queries() + $this->ctx->getDbQueryCount()), new TwigFunction('ndx_version', fn() => Environment::getIndexVersion()), + new TwigFunction('byte_symbol', fn($bytes, $decimal = ByteFormat::DECIMAL_DEFAULT) => ByteFormat::format($bytes, $decimal)), ]; } diff --git a/src/Users/Assets/UserAvatarAsset.php b/src/Users/Assets/UserAvatarAsset.php index d52a99c..474d382 100644 --- a/src/Users/Assets/UserAvatarAsset.php +++ b/src/Users/Assets/UserAvatarAsset.php @@ -17,7 +17,7 @@ class UserAvatarAsset extends UserImageAsset implements UserAssetScalableInterfa ]; private const MAX_RES = 2000; - private const MAX_BYTES = 1048576; + private const MAX_BYTES = 1000000; public function getMaxWidth(): int { return Config::get('avatar.max_res', IConfig::T_INT, self::MAX_RES); diff --git a/src/Users/Assets/UserBackgroundAsset.php b/src/Users/Assets/UserBackgroundAsset.php index 786d68f..2f1a15a 100644 --- a/src/Users/Assets/UserBackgroundAsset.php +++ b/src/Users/Assets/UserBackgroundAsset.php @@ -16,7 +16,7 @@ class UserBackgroundAsset extends UserImageAsset { private const MAX_WIDTH = 3840; private const MAX_HEIGHT = 2160; - private const MAX_BYTES = 1048576; + private const MAX_BYTES = 1500000; public const ATTACH_NONE = 0x00; public const ATTACH_COVER = 0x01; diff --git a/templates/profile/index.twig b/templates/profile/index.twig index b2cad28..1f96501 100644 --- a/templates/profile/index.twig +++ b/templates/profile/index.twig @@ -48,19 +48,19 @@ {% if perms.edit_avatar %} {% endif %} {% if perms.edit_background %} {% endif %} diff --git a/utility.php b/utility.php index e298f9b..2d03633 100644 --- a/utility.php +++ b/utility.php @@ -1,18 +1,6 @@