index.php: simplify format_size()

SEE also Issue149
This commit is contained in:
Alick Zhao 2011-12-10 18:15:04 +09:00 committed by XU Benda
parent 6f495bff6a
commit e1b074082a

View File

@ -145,16 +145,7 @@ function initialize_status($status_file, $ftp3_status_file)
function format_size($size)
{
$size = explode(' ', $size);
if ($size[0] === 'na') {
return 'na';
}
$size = (float)$size[0];
$size /= 1048576;
if ($size <= 1000)
return sprintf("%.2f MB", $size);
$size /= 1024;
return sprintf("%.2f GB", $size);
return str_replace(' bytes', 'B', $size);
}
?>