From daa65b272fa29eb6ebcedcef71f4d1e979994a69 Mon Sep 17 00:00:00 2001 From: EA4GKQ Date: Tue, 28 Jun 2016 16:33:17 +0200 Subject: [PATCH] add getSize function --- include/functions.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/functions.php b/include/functions.php index 711829b..c02c47e 100644 --- a/include/functions.php +++ b/include/functions.php @@ -459,6 +459,21 @@ function getActiveYSFReflectors($logLines) { return $reflectorlist; } + + function getSize($filesize, $precision = 2) + { + $units = array('', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'); + + foreach ($units as $idUnit => $unit) + { + if ($filesize > 1024) + $filesize /= 1024; + else + break; + } + + return round($filesize, $precision).' '.$units[$idUnit].'B'; + } //Some basic inits $mmdvmconfigs = getMMDVMConfig(); $logLinesMMDVM = getMMDVMLog();