diff options
-rw-r--r-- | etc/inc/util.inc | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc index f6063ea..9810ede 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -662,4 +662,16 @@ function resolve_retry($hostname, $retries = 5) { return false; } -?> +function format_bytes($bytes) { + if ($bytes >= 1073741824) { + return sprintf("%.2f GB", $bytes/1073741824); + } else if ($bytes >= 1048576) { + return sprintf("%.2f MB", $bytes/1048576); + } else if ($bytes >= 1024) { + return sprintf("%.0f KB", $bytes/1024); + } else { + return sprintf("%d bytes", $bytes); + } +} + +?>
\ No newline at end of file |