Browse Source

Fix a non well formatted numeric value encountered & Notice: Undefined offset in `fm_get_filesize()` (#681)

For non `well formatted numeric value encountered`, see #670
For `Notice: Undefined offset 9` (current implementation result) see: https://3v4l.org/1qHit#v5.0.0
For new impementation result, see: https://3v4l.org/d0UBh#v5.0.0
pull/686/head
Suyadi 1 month ago
committed by GitHub
parent
commit
08cb4b0fce
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      tinyfilemanager.php

3
tinyfilemanager.php

@ -2501,7 +2501,8 @@ function fm_get_filesize($size)
{
$size = (float) $size;
$units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
$power = $size > 0 ? floor(log($size, 1024)) : 0;
$power = ($size > 0) ? floor(log($size, 1024)) : 0;
$power = ($power > (count($units) - 1)) ? (count($units) - 1) : $power;
return sprintf('%s %s', round($size / pow(1024, $power), 2), $units[$power]);
}

Loading…
Cancel
Save