From 7bd71684a827681c0fce7f9ac49c8c1e7a566ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armando=20L=C3=BCscher?= Date: Wed, 14 Oct 2020 04:11:12 +0200 Subject: [PATCH] Improve human_filesize function, add anchor ids to FAQ and Archive titles --- index.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/index.php b/index.php index 26eb8b9..fff1a99 100644 --- a/index.php +++ b/index.php @@ -67,13 +67,14 @@ function human_filesize($bytes, $decimals = 2) return ''; } - $sz = 'BKMGTP'; - $factor = floor((strlen($bytes) - 1) / 3); - $suff = @$sz[$factor]; - if ($suff != 'B') { - $suff .= 'iB'; + $sizes = 'BKMGTP'; + $factor = floor((strlen($bytes) - 1) / 3) ?: 0; + $suffix = @$sizes[$factor]; + if ($suffix === 'B') { + return "{$bytes}B"; } - return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . $suff; + + return sprintf("%.{$decimals}f", $bytes / (1024 ** $factor)) . "{$suffix}iB"; } function get_dl_link($flavor, $version, $file = null) @@ -162,7 +163,7 @@ save_binaries_json($files, $stable); -

Frequently Asked Questions

+

Frequently Asked Questions

Which version should I choose?

There is probably only one version that's going to run on your device. Run uname -m and choose the version that's named similar to the output. @@ -192,7 +193,7 @@ save_binaries_json($files, $stable); Yes, but please use this JSON representation in stead of this website. Also, please note that excessive polling might get you banned.
-

Archive

+

Archive

(show unstable builds)