summaryrefslogtreecommitdiffstats
path: root/inc/util.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/util.inc.php')
-rw-r--r--inc/util.inc.php21
1 files changed, 16 insertions, 5 deletions
diff --git a/inc/util.inc.php b/inc/util.inc.php
index 69eaf941..9f6f63db 100644
--- a/inc/util.inc.php
+++ b/inc/util.inc.php
@@ -179,6 +179,13 @@ SADFACE;
$location .= '&' . implode('&', self::$redirectParams);
}
}
+ if (CONFIG_DEBUG) {
+ global $global_start;
+ $duration = microtime(true) - $global_start;
+ error_log('Redirect: ' . round($duration, 3) . 's, '
+ . Database::getQueryCount() . ' queries, '
+ . round(Database::getQueryTime(), 3) . 's query time total');
+ }
Header('Location: ' . $location);
exit(0);
}
@@ -227,18 +234,22 @@ SADFACE;
*
* @param float|int $bytes numeric value of the filesize to make readable
* @param int $decimals number of decimals to show, -1 for automatic
- * @return string human readable string representing the given filesize
+ * @return string human readable string representing the given file size
*/
public static function readableFileSize($bytes, $decimals = -1)
{
+ $bytes = round($bytes);
static $sz = array('Byte', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB');
$factor = (int)floor((strlen($bytes) - 1) / 3);
- if ($factor == 0) {
+ if ($factor === 0) {
$decimals = 0;
- } elseif ($decimals === -1) {
- $decimals = 2 - floor((strlen($bytes) - 1) % 3);
+ } else {
+ $bytes = $bytes / pow(1024, $factor);
+ if ($decimals === -1) {
+ $decimals = 2 - floor(strlen((int)$bytes) - 1);
+ }
}
- return sprintf("%.{$decimals}f ", $bytes / pow(1024, $factor)) . $sz[$factor];
+ return sprintf("%.{$decimals}f", $bytes) . "\xe2\x80\x89" . $sz[$factor];
}
public static function sanitizeFilename($name)