Skip to content

Commit

Permalink
Merge pull request #39 from dimayakovlev/dimayakovlev/issue34
Browse files Browse the repository at this point in the history
Fix notice in function toBytes()
  • Loading branch information
dimayakovlev authored Aug 13, 2021
2 parents bc7fcfd + ba12664 commit ada1f1b
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions admin/inc/basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -1084,20 +1084,23 @@ function get_site_version($echo = true) {

/**
* Convert to Bytes
* Convert M/G/K byte string to bytes
*
* @since 3.0
* @since 3.5.0 Fix notice
*
* @param $str string
* @return string
* @param mixed $str
* @return mixed
*/
function toBytes($str) {
$val = trim($str);
$last = strtolower($str[strlen($str)-1]);
switch($last) {
case 'g': $val *= 1024;
case 'm': $val *= 1024;
case 'k': $val *= 1024;
}
if (is_numeric($str)) return (int)$str;
$val = (int)trim($str, 'gmkGMK');
$last = strtolower($str[strlen($str) - 1]);
switch ($last) {
case 'g': $val *= 1024;
case 'm': $val *= 1024;
case 'k': $val *= 1024;
}
return $val;
}

Expand Down

1 comment on commit ada1f1b

@dimayakovlev
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.