diff options
| author | 2013-12-02 18:27:03 +0100 | |
|---|---|---|
| committer | 2013-12-02 18:27:03 +0100 | |
| commit | b40783e8889b64f813c898ee2ce7e967582ef34e (patch) | |
| tree | 946db408eb849a2644519ef591179c13ed1e849f /lib/lib_rss.php | |
| parent | 1a270309a53cca0124758b026512d781a595ec70 (diff) | |
Affiche la taille de la base de données
Diffstat (limited to 'lib/lib_rss.php')
| -rw-r--r-- | lib/lib_rss.php | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/lib_rss.php b/lib/lib_rss.php index ea5a1ffd0..3e23f7542 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -47,6 +47,21 @@ function small_hash ($txt) { return strtr ($t, '+/', '-_'); } +function formatBytes($bytes, $precision = 2, $system = 'IEC') { + if ($system === 'IEC') { + $base = 1024; + $units = array('B', 'KiB', 'MiB', 'GiB', 'TiB'); + } elseif ($system === 'SI') { + $base = 1000; + $units = array('B', 'KB', 'MB', 'GB', 'TB'); + } + $bytes = max(intval($bytes), 0); + $pow = $bytes === 0 ? 0 : floor(log($bytes) / log($base)); + $pow = min($pow, count($units) - 1); + $bytes /= pow($base, $pow); + return round($bytes, $precision) . ' ' . $units[$pow]; +} + function timestamptodate ($t, $hour = true) { $month = Translate::t (date('M', $t)); if ($hour) { |
