mirror of
https://github.com/e107inc/e107.git
synced 2025-09-01 18:32:44 +02:00
Bugtracker #4545 - uniform way of displaying file sizes
This commit is contained in:
@@ -11,8 +11,8 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_stats.php,v $
|
||||
| $Revision: 1.3 $
|
||||
| $Date: 2008-06-26 19:59:11 $
|
||||
| $Revision: 1.4 $
|
||||
| $Date: 2008-10-19 11:35:00 $
|
||||
| $Author: e107steved $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@@ -63,8 +63,8 @@ foreach($array as $table)
|
||||
{
|
||||
if($table['Name'] == MPREFIX."forum_t")
|
||||
{
|
||||
$db_size = parsesize($table['Data_length']);
|
||||
$avg_row_len = parsesize($table['Avg_row_length']);
|
||||
$db_size = $e107->parseMemorySize($table['Data_length']);
|
||||
$avg_row_len = $e107->parseMemorySize($table['Avg_row_length']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -353,30 +353,6 @@ $ns -> tablerender(FSLAN_23, $text);
|
||||
|
||||
require_once(FOOTERF);
|
||||
|
||||
function parsesize($size) {
|
||||
$kb = 1024;
|
||||
$mb = 1024 * $kb;
|
||||
$gb = 1024 * $mb;
|
||||
$tb = 1024 * $gb;
|
||||
if(!$size)
|
||||
{
|
||||
return '0';
|
||||
}
|
||||
if ($size < $kb) {
|
||||
return $size." b";
|
||||
}
|
||||
else if($size < $mb) {
|
||||
return round($size/$kb, 2)." kb";
|
||||
}
|
||||
else if($size < $gb) {
|
||||
return round($size/$mb, 2)." mb";
|
||||
}
|
||||
else if($size < $tb) {
|
||||
return round($size/$gb, 2)." gb";
|
||||
} else {
|
||||
return round($size/$tb, 2)." tb";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
@@ -9,12 +9,12 @@
|
||||
// ------------------------------------------------
|
||||
// www.j-cons.com
|
||||
// ================================================
|
||||
// $Revision: 1.2 $Date: 2004/10/04
|
||||
// $Revision: 1.3 $Date: 2004/10/04
|
||||
// ================================================
|
||||
//
|
||||
// $Source: /cvs_backup/e107_0.8/e107_plugins/tinymce/plugins/ibrowser/ibrowser.php,v $
|
||||
// $Revision: 1.2 $
|
||||
// $Date: 2007-08-09 19:09:56 $
|
||||
// $Revision: 1.3 $
|
||||
// $Date: 2008-10-19 11:35:00 $
|
||||
// $Author: e107steved $
|
||||
// +----------------------------------------------------------------------------+
|
||||
// Major Re-work by CaMer0n
|
||||
@@ -323,7 +323,7 @@ $errors = array();
|
||||
$size = getimagesize($_root.$imglib.$entry);
|
||||
$fsize = filesize($_root.$imglib.$entry);
|
||||
?>
|
||||
<option value="<?php echo $size[0]; ?>|<?php echo $size[1]; ?>|<?php echo filesize_h($fsize,2); ?>|<?php echo $entry?>" <?php echo ($entry == $img)?'selected':''?>><?php echo $entry?></option>
|
||||
<option value="<?php echo $size[0]; ?>|<?php echo $size[1]; ?>|<?php echo $e107->parseMemorySize($fsize,2); ?>|<?php echo $entry?>" <?php echo ($entry == $img)?'selected':''?>><?php echo $entry?></option>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
@@ -455,22 +455,5 @@ function liboptions($arr, $prefix = '', $sel = '')
|
||||
}
|
||||
|
||||
|
||||
// Return the human readable size of a file
|
||||
// @param int $size a file size
|
||||
// @param int $dec a number of decimal places
|
||||
|
||||
function filesize_h($size, $dec = 1)
|
||||
{
|
||||
$sizes = array('byte(s)', 'kb', 'mb', 'gb');
|
||||
$count = count($sizes);
|
||||
$i = 0;
|
||||
|
||||
while ($size >= 1024 && ($i < $count - 1)) {
|
||||
$size /= 1024;
|
||||
$i++;
|
||||
}
|
||||
|
||||
return round($size, $dec) . ' ' . $sizes[$i];
|
||||
}
|
||||
|
||||
?>
|
||||
|
Reference in New Issue
Block a user