From 46d7767fd0571eb363a5c6aa62301c12055288df Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Thu, 8 Nov 2018 10:28:49 -0500 Subject: [PATCH] formatBytes calls implement function in new class --- include/api.php | 2 +- mod/photos.php | 4 ++-- mod/profile_photo.php | 3 ++- mod/wall_attach.php | 3 ++- mod/wall_upload.php | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/api.php b/include/api.php index 10ee292871..8ae3c03d44 100644 --- a/include/api.php +++ b/include/api.php @@ -4500,7 +4500,7 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $ // check against max upload size within Friendica instance $maximagesize = Config::get('system', 'maximagesize'); if ($maximagesize && ($filesize > $maximagesize)) { - $formattedBytes = formatBytes($maximagesize); + $formattedBytes = Strings::formatBytes($maximagesize); throw new InternalServerErrorException("image size exceeds Friendica config setting (uploaded size: $formattedBytes)"); } diff --git a/mod/photos.php b/mod/photos.php index 238c735858..1b2e8d52b6 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -780,7 +780,7 @@ function photos_post(App $a) notice(L10n::t('Image exceeds size limit of %s', ini_get('upload_max_filesize')) . EOL); break; case UPLOAD_ERR_FORM_SIZE: - notice(L10n::t('Image exceeds size limit of %s', formatBytes(defaults($_REQUEST, 'MAX_FILE_SIZE', 0))) . EOL); + notice(L10n::t('Image exceeds size limit of %s', Strings::formatBytes(defaults($_REQUEST, 'MAX_FILE_SIZE', 0))) . EOL); break; case UPLOAD_ERR_PARTIAL: notice(L10n::t('Image upload didn\'t complete, please try again') . EOL); @@ -809,7 +809,7 @@ function photos_post(App $a) $maximagesize = Config::get('system', 'maximagesize'); if ($maximagesize && ($filesize > $maximagesize)) { - notice(L10n::t('Image exceeds size limit of %s', formatBytes($maximagesize)) . EOL); + notice(L10n::t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize)) . EOL); @unlink($src); $foo = 0; Addon::callHooks('photo_post_end', $foo); diff --git a/mod/profile_photo.php b/mod/profile_photo.php index 3304e3cab2..d8e236a737 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -16,6 +16,7 @@ use Friendica\Model\Photo; use Friendica\Model\Profile; use Friendica\Object\Image; use Friendica\Util\Security; +use Friendica\Util\Strings; function profile_photo_init(App $a) { @@ -151,7 +152,7 @@ function profile_photo_post(App $a) $maximagesize = Config::get('system', 'maximagesize'); if (($maximagesize) && ($filesize > $maximagesize)) { - notice(L10n::t('Image exceeds size limit of %s', formatBytes($maximagesize)) . EOL); + notice(L10n::t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize)) . EOL); @unlink($src); return; } diff --git a/mod/wall_attach.php b/mod/wall_attach.php index 2a3038e8f6..b4254ba64a 100644 --- a/mod/wall_attach.php +++ b/mod/wall_attach.php @@ -11,6 +11,7 @@ use Friendica\Database\DBA; use Friendica\Model\Contact; use Friendica\Util\DateTimeFormat; use Friendica\Util\Mimetype; +use Friendica\Util\Strings; function wall_attach_post(App $a) { @@ -115,7 +116,7 @@ function wall_attach_post(App $a) { } if ($maxfilesize && $filesize > $maxfilesize) { - $msg = L10n::t('File exceeds size limit of %s', formatBytes($maxfilesize)); + $msg = L10n::t('File exceeds size limit of %s', Strings::formatBytes($maxfilesize)); if ($r_json) { echo json_encode(['error' => $msg]); } else { diff --git a/mod/wall_upload.php b/mod/wall_upload.php index c093d28e3a..0322c66066 100644 --- a/mod/wall_upload.php +++ b/mod/wall_upload.php @@ -194,7 +194,7 @@ function wall_upload_post(App $a, $desktopmode = true) $maximagesize = Config::get('system', 'maximagesize'); if (($maximagesize) && ($filesize > $maximagesize)) { - $msg = L10n::t('Image exceeds size limit of %s', formatBytes($maximagesize)); + $msg = L10n::t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize)); if ($r_json) { echo json_encode(['error' => $msg]); } else {