Browse Source

formatBytes calls

implement function in new class
tags/2019.01
Adam Magness 2 years ago
parent
commit
46d7767fd0
5 changed files with 8 additions and 6 deletions
  1. +1
    -1
      include/api.php
  2. +2
    -2
      mod/photos.php
  3. +2
    -1
      mod/profile_photo.php
  4. +2
    -1
      mod/wall_attach.php
  5. +1
    -1
      mod/wall_upload.php

+ 1
- 1
include/api.php View File

@@ -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)");
}



+ 2
- 2
mod/photos.php View File

@@ -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);


+ 2
- 1
mod/profile_photo.php View File

@@ -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;
}


+ 2
- 1
mod/wall_attach.php View File

@@ -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 {


+ 1
- 1
mod/wall_upload.php View File

@@ -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 {


Loading…
Cancel
Save