From 85910829a74dfca553506de482f6303bd276cabe Mon Sep 17 00:00:00 2001 From: botanic Date: Fri, 5 Sep 2014 01:30:54 -0700 Subject: [PATCH] Made filesize friendly --- code/web/private_php/ams/autoload/ticket.php | 12 ++++++++++++ code/web/public_php/.htaccess | 2 -- code/web/public_php/ams/templates/show_ticket.tpl | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) delete mode 100644 code/web/public_php/.htaccess diff --git a/code/web/private_php/ams/autoload/ticket.php b/code/web/private_php/ams/autoload/ticket.php index 013dad842..e6af8e188 100644 --- a/code/web/private_php/ams/autoload/ticket.php +++ b/code/web/private_php/ams/autoload/ticket.php @@ -216,6 +216,18 @@ class Ticket{ foreach ($fetchall as &$value) { $webUser = new WebUsers($value['Uploader']); $fetchall[$base]['Username'] = $webUser->getUsername(); + + $bytes = $fetchall[$base]['Filesize']; + $precision = 2; + $units = array('B', 'KB', 'MB', 'GB', 'TB'); + + $bytes = max($bytes, 0); + $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); + $pow = min($pow, count($units) - 1); + + $bytes /= pow(1024, $pow); + + $fetchall[$base]['Filesize'] = round($bytes, $precision) . ' ' . $units[$pow];; $base++; } return $fetchall; diff --git a/code/web/public_php/.htaccess b/code/web/public_php/.htaccess deleted file mode 100644 index c0b74b60d..000000000 --- a/code/web/public_php/.htaccess +++ /dev/null @@ -1,2 +0,0 @@ -RewriteEngine On -RewriteRule ^$ /ams [R=301,L] diff --git a/code/web/public_php/ams/templates/show_ticket.tpl b/code/web/public_php/ams/templates/show_ticket.tpl index b832f29b1..deed7c0af 100644 --- a/code/web/public_php/ams/templates/show_ticket.tpl +++ b/code/web/public_php/ams/templates/show_ticket.tpl @@ -42,7 +42,7 @@ {$array['Filename']} {$array['Timestamp']} - {$array['Filesize']} Bytes + {$array['Filesize']} {if $permission > 1} {$array['Username']} {else}