mirror of
https://github.com/e107inc/e107.git
synced 2025-04-20 04:32:01 +02:00
Bugtracker #4545 - uniform way of displaying file sizes
This commit is contained in:
parent
4b814e4347
commit
fa72c3395f
39
download.php
39
download.php
@ -11,8 +11,8 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/download.php,v $
|
||||
| $Revision: 1.22 $
|
||||
| $Date: 2008-10-17 19:19:54 $
|
||||
| $Revision: 1.23 $
|
||||
| $Date: 2008-10-19 11:35:00 $
|
||||
| $Author: e107steved $
|
||||
|
|
||||
+----------------------------------------------------------------------------+
|
||||
@ -613,7 +613,7 @@ function parse_download_mirror_table($row, $mirrorstring, $mirrorList)
|
||||
$DOWNLOAD_MIRROR_LOCATION = ($mirror_location ? $mirror_location : "");
|
||||
$DOWNLOAD_MIRROR_DESCRIPTION = ($mirror_description ? $mirror_description : "");
|
||||
|
||||
$DOWNLOAD_MIRROR_FILESIZE = parsesize($row['download_filesize']);
|
||||
$DOWNLOAD_MIRROR_FILESIZE = $e107->parseMemorySize($row['download_filesize']);
|
||||
$DOWNLOAD_MIRROR_LINK = "<a href='".e_BASE."request.php?mirror.{$row['download_id']}.{$mirrorHost_id}' title='".LAN_dl_32."'><img src='".IMAGE_DOWNLOAD."' alt='' style='border:0' /></a>";
|
||||
|
||||
$DOWNLOAD_MIRROR_REQUESTS = (ADMIN ? LAN_dl_73.$mirrorRequests : "");
|
||||
@ -622,37 +622,12 @@ function parse_download_mirror_table($row, $mirrorstring, $mirrorList)
|
||||
return(preg_replace("/\{(.*?)\}/e", '$\1', $DOWNLOAD_MIRROR));
|
||||
}
|
||||
|
||||
function parsesize($size) {
|
||||
$kb = 1024;
|
||||
$mb = 1024 * $kb;
|
||||
$gb = 1024 * $mb;
|
||||
$tb = 1024 * $gb;
|
||||
if(!$size)
|
||||
{
|
||||
return '0';
|
||||
}
|
||||
if ($size < $kb) {
|
||||
return $size." ".CORE_LAN_B;
|
||||
}
|
||||
else if($size < $mb) {
|
||||
return round($size/$kb, 2)." ".CORE_LAN_KB;
|
||||
}
|
||||
else if($size < $gb) {
|
||||
return round($size/$mb, 2)." ".CORE_LAN_MB;
|
||||
}
|
||||
else if($size < $tb) {
|
||||
return round($size/$gb, 2)." ".CORE_LAN_GB;
|
||||
} else {
|
||||
return round($size/$tb, 2)." ".CORE_LAN_TB;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function parse_download_cat_parent_table($row)
|
||||
{
|
||||
global $tp,$current_row,$DOWNLOAD_CAT_PARENT_TABLE;
|
||||
global $tp,$e107,$current_row,$DOWNLOAD_CAT_PARENT_TABLE;
|
||||
extract($row);
|
||||
$current_row = ($current_row) ? 0 : 1; // Alternating CSS for each row.(backwards compatible)
|
||||
|
||||
@ -699,7 +674,7 @@ function parse_download_cat_parent_table($row)
|
||||
|
||||
function parse_download_cat_child_table($row)
|
||||
{
|
||||
global $tp,$current_row, $DOWNLOAD_CAT_CHILD_TABLE, $DOWNLOAD_CAT_SUBSUB_TABLE;
|
||||
global $tp,$e107,$current_row, $DOWNLOAD_CAT_CHILD_TABLE, $DOWNLOAD_CAT_SUBSUB_TABLE;
|
||||
|
||||
$current_row = ($current_row) ? 0 : 1; // Alternating CSS for each row.(backwards compatible)
|
||||
$template = ($current_row == 1) ? $DOWNLOAD_CAT_CHILD_TABLE : str_replace("forumheader3","forumheader3 forumheader3_alt",$DOWNLOAD_CAT_CHILD_TABLE);
|
||||
@ -711,7 +686,7 @@ function parse_download_cat_child_table($row)
|
||||
$DOWNLOAD_CAT_SUB_NAME_LINKED = "<a href='".e_BASE."download.php?list.".$row['download_category_id']."'>".$dcatname."</a>";
|
||||
$DOWNLOAD_CAT_SUB_DESCRIPTION = $tp->toHTML($row['download_category_description'],TRUE,'description');
|
||||
$DOWNLOAD_CAT_SUB_COUNT = $row['d_count'];
|
||||
$DOWNLOAD_CAT_SUB_SIZE = parsesize( $row['d_size']);
|
||||
$DOWNLOAD_CAT_SUB_SIZE = $e107->parseMemorySize($row['d_size']);
|
||||
$DOWNLOAD_CAT_SUB_DOWNLOADED = intval( $row['d_requests']);
|
||||
$DOWNLOAD_CAT_SUBSUB = "";
|
||||
// check for subsub cats ...
|
||||
@ -720,7 +695,7 @@ function parse_download_cat_child_table($row)
|
||||
$DOWNLOAD_CAT_SUBSUB_ICON = get_cat_icons($subrow['download_category_icon'],$subrow['d_count']);
|
||||
$DOWNLOAD_CAT_SUBSUB_DESCRIPTION = $tp->toHTML($subrow['download_category_description'],TRUE,'description');
|
||||
$DOWNLOAD_CAT_SUBSUB_COUNT = intval($subrow['d_count']);
|
||||
$DOWNLOAD_CAT_SUBSUB_SIZE = parsesize($subrow['d_size']);
|
||||
$DOWNLOAD_CAT_SUBSUB_SIZE = $e107->parseMemorySize($subrow['d_size']);
|
||||
$DOWNLOAD_CAT_SUBSUB_DOWNLOADED = intval($subrow['d_requests']);
|
||||
|
||||
$DOWNLOAD_CAT_SUBSUB_NEW_ICON = check_new_download($subrow['d_last']);
|
||||
|
@ -11,8 +11,8 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_admin/fileinspector.php,v $
|
||||
| $Revision: 1.12 $
|
||||
| $Date: 2008-01-05 21:09:54 $
|
||||
| $Revision: 1.13 $
|
||||
| $Date: 2008-10-19 11:35:00 $
|
||||
| $Author: e107steved $
|
||||
|
||||
Includes standalone function - needs finishing
|
||||
@ -696,7 +696,7 @@ class file_inspector {
|
||||
|
||||
function scan_results()
|
||||
{
|
||||
global $ns, $rs, $core_image, $deprecated_image, $imode, $tp;
|
||||
global $ns, $rs, $core_image, $deprecated_image, $imode, $tp, $e107;
|
||||
$scan_text = $this -> inspect($core_image, $deprecated_image, 0, $this -> root_dir);
|
||||
|
||||
// if ($_POST['type'] == 'tree')
|
||||
@ -748,19 +748,19 @@ class file_inspector {
|
||||
}
|
||||
|
||||
if ($_POST['core'] != 'none') {
|
||||
$text .= "<tr><td class='f'><img src='".e_IMAGE."packs/".$imode."/fileinspector/file_core.png' class='i' alt='' /> ".FR_LAN_4.": ".($this -> count['core']['num'] ? $this -> count['core']['num'] : FR_LAN_21)." </td><td class='s'>".$this -> parsesize($this -> count['core']['size'], 2)."</td></tr>";
|
||||
$text .= "<tr><td class='f'><img src='".e_IMAGE."packs/".$imode."/fileinspector/file_core.png' class='i' alt='' /> ".FR_LAN_4.": ".($this -> count['core']['num'] ? $this -> count['core']['num'] : FR_LAN_21)." </td><td class='s'>".$e107->parseMemorySize($this -> count['core']['size'], 2)."</td></tr>";
|
||||
}
|
||||
if ($_POST['missing']) {
|
||||
$text .= "<tr><td class='f' colspan='2'><img src='".e_IMAGE."packs/".$imode."/fileinspector/file_missing.png' class='i' alt='' /> ".FR_LAN_22.": ".($this -> count['missing']['num'] ? $this -> count['missing']['num'] : FR_LAN_21)." </td></tr>";
|
||||
}
|
||||
if ($_POST['noncore']) {
|
||||
$text .= "<tr><td class='f'><img src='".e_IMAGE."packs/".$imode."/fileinspector/file_unknown.png' class='i' alt='' /> ".FR_LAN_5.": ".($this -> count['unknown']['num'] ? $this -> count['unknown']['num'] : FR_LAN_21)." </td><td class='s'>".$this -> parsesize($this -> count['unknown']['size'], 2)."</td></tr>";
|
||||
$text .= "<tr><td class='f'><img src='".e_IMAGE."packs/".$imode."/fileinspector/file_unknown.png' class='i' alt='' /> ".FR_LAN_5.": ".($this -> count['unknown']['num'] ? $this -> count['unknown']['num'] : FR_LAN_21)." </td><td class='s'>".$e107->parseMemorySize($this -> count['unknown']['size'], 2)."</td></tr>";
|
||||
}
|
||||
if ($_POST['oldcore']) {
|
||||
$text .= "<tr><td class='f'><img src='".e_IMAGE."packs/".$imode."/fileinspector/file_old.png' class='i' alt='' /> ".FR_LAN_24.": ".($this -> count['deprecated']['num'] ? $this -> count['deprecated']['num'] : FR_LAN_21)." </td><td class='s'>".$this -> parsesize($this -> count['deprecated']['size'], 2)."</td></tr>";
|
||||
$text .= "<tr><td class='f'><img src='".e_IMAGE."packs/".$imode."/fileinspector/file_old.png' class='i' alt='' /> ".FR_LAN_24.": ".($this -> count['deprecated']['num'] ? $this -> count['deprecated']['num'] : FR_LAN_21)." </td><td class='s'>".$e107->parseMemorySize($this -> count['deprecated']['size'], 2)."</td></tr>";
|
||||
}
|
||||
if ($_POST['core'] == 'all') {
|
||||
$text .= "<tr><td class='f'><img src='".e_IMAGE."packs/".$imode."/fileinspector/file.png' class='i' alt='' /> ".FR_LAN_6.": ".($this -> count['core']['num'] + $this -> count['unknown']['num'] + $this -> count['deprecated']['num'])." </td><td class='s'>".$this -> parsesize($this -> count['core']['size'] + $this -> count['unknown']['size'] + $this -> count['deprecated']['size'], 2)."</td></tr>";
|
||||
$text .= "<tr><td class='f'><img src='".e_IMAGE."packs/".$imode."/fileinspector/file.png' class='i' alt='' /> ".FR_LAN_6.": ".($this -> count['core']['num'] + $this -> count['unknown']['num'] + $this -> count['deprecated']['num'])." </td><td class='s'>".$e107->parseMemorySize($this -> count['core']['size'] + $this -> count['unknown']['size'] + $this -> count['deprecated']['size'], 2)."</td></tr>";
|
||||
}
|
||||
if ($_POST['regex']) {
|
||||
$text .= "<tr><td class='f'><img src='".e_IMAGE."packs/".$imode."/fileinspector/file.png' class='i' alt='' /> ".FR_LAN_29.": ".($this -> results)." </td><td class='s'> </td></tr>";
|
||||
@ -773,7 +773,7 @@ class file_inspector {
|
||||
$text .= "<tr><td style='padding-left: 4px' colspan='2'>
|
||||
<img src='".e_IMAGE."packs/".$imode."/fileinspector/warning.png' class='i' alt='' /> <b>".FR_LAN_26."</b></td></tr>";
|
||||
|
||||
$text .= "<tr><td class='f'><img src='".e_IMAGE."packs/".$imode."/fileinspector/file_warning.png' class='i' alt='' /> ".FR_LAN_28.": ".($this -> count['warning']['num'] ? $this -> count['warning']['num'] : FR_LAN_21)." </td><td class='s'>".$this -> parsesize($this -> count['warning']['size'], 2)."</td></tr>";
|
||||
$text .= "<tr><td class='f'><img src='".e_IMAGE."packs/".$imode."/fileinspector/file_warning.png' class='i' alt='' /> ".FR_LAN_28.": ".($this -> count['warning']['num'] ? $this -> count['warning']['num'] : FR_LAN_21)." </td><td class='s'>".$e107->parseMemorySize($this -> count['warning']['size'], 2)."</td></tr>";
|
||||
|
||||
$text .= "<tr><td class='w' colspan='2'><img src='".e_IMAGE."packs/".$imode."/fileinspector/info.png' class='i' alt='' /> ".FR_LAN_27."</td></tr>";
|
||||
|
||||
@ -785,9 +785,9 @@ class file_inspector {
|
||||
$text .= "<tr><td class='f' style='padding-left: 4px' colspan='2'>
|
||||
<img src='".e_IMAGE."packs/".$imode."/fileinspector/".$integrity_icon."' class='i' alt='' /> <b>".FR_LAN_7."</b> ".$integrity_text."</td></tr>";
|
||||
|
||||
$text .= "<tr><td class='f'><img src='".e_IMAGE."packs/".$imode."/fileinspector/file_check.png' class='i' alt='' /> ".FR_LAN_8.": ".($this -> count['pass']['num'] ? $this -> count['pass']['num'] : FR_LAN_21)." </td><td class='s'>".$this -> parsesize($this -> count['pass']['size'], 2)."</td></tr>";
|
||||
$text .= "<tr><td class='f'><img src='".e_IMAGE."packs/".$imode."/fileinspector/file_fail.png' class='i' alt='' /> ".FR_LAN_9.": ".($this -> count['fail']['num'] ? $this -> count['fail']['num'] : FR_LAN_21)." </td><td class='s'>".$this -> parsesize($this -> count['fail']['size'], 2)."</td></tr>";
|
||||
$text .= "<tr><td class='f'><img src='".e_IMAGE."packs/".$imode."/fileinspector/file_uncalc.png' class='i' alt='' /> ".FR_LAN_25.": ".($this -> count['uncalculable']['num'] ? $this -> count['uncalculable']['num'] : FR_LAN_21)." </td><td class='s'>".$this -> parsesize($this -> count['uncalculable']['size'], 2)."</td></tr>";
|
||||
$text .= "<tr><td class='f'><img src='".e_IMAGE."packs/".$imode."/fileinspector/file_check.png' class='i' alt='' /> ".FR_LAN_8.": ".($this -> count['pass']['num'] ? $this -> count['pass']['num'] : FR_LAN_21)." </td><td class='s'>".$e107->parseMemorySize($this -> count['pass']['size'], 2)."</td></tr>";
|
||||
$text .= "<tr><td class='f'><img src='".e_IMAGE."packs/".$imode."/fileinspector/file_fail.png' class='i' alt='' /> ".FR_LAN_9.": ".($this -> count['fail']['num'] ? $this -> count['fail']['num'] : FR_LAN_21)." </td><td class='s'>".$e107->parseMemorySize($this -> count['fail']['size'], 2)."</td></tr>";
|
||||
$text .= "<tr><td class='f'><img src='".e_IMAGE."packs/".$imode."/fileinspector/file_uncalc.png' class='i' alt='' /> ".FR_LAN_25.": ".($this -> count['uncalculable']['num'] ? $this -> count['uncalculable']['num'] : FR_LAN_21)." </td><td class='s'>".$e107->parseMemorySize($this -> count['uncalculable']['size'], 2)."</td></tr>";
|
||||
|
||||
$text .= "<tr><td colspan='2'> </td></tr>";
|
||||
|
||||
@ -884,7 +884,7 @@ class file_inspector {
|
||||
else
|
||||
{
|
||||
$text .= "</td>
|
||||
<td class='s'>".$this -> parsesize($stext['size']);
|
||||
<td class='s'>".$e107->parseMemorySize($stext['size']);
|
||||
}
|
||||
$text .= "</td></tr>";
|
||||
}
|
||||
@ -949,8 +949,8 @@ class file_inspector {
|
||||
$data .= "| GNU General Public License (http://gnu.org).\n";
|
||||
$data .= "|\n";
|
||||
$data .= "| \$Source: /cvs_backup/e107_0.8/e107_admin/fileinspector.php,v $\n";
|
||||
$data .= "| \$Revision: 1.12 $\n";
|
||||
$data .= "| \$Date: 2008-01-05 21:09:54 $\n";
|
||||
$data .= "| \$Revision: 1.13 $\n";
|
||||
$data .= "| \$Date: 2008-10-19 11:35:00 $\n";
|
||||
$data .= "| \$Author: e107steved $\n";
|
||||
$data .= "+----------------------------------------------------------------------------+\n";
|
||||
$data .= "*/\n\n";
|
||||
@ -1079,25 +1079,7 @@ class file_inspector {
|
||||
$checksum = md5(str_replace(array(chr(13),chr(10)), "", file_get_contents($filename)));
|
||||
return $checksum;
|
||||
}
|
||||
|
||||
function parsesize($size, $dec = 0) {
|
||||
$size = $size ? $size : 0;
|
||||
$kb = 1024;
|
||||
$mb = 1024 * $kb;
|
||||
$gb = 1024 * $mb;
|
||||
$tb = 1024 * $gb;
|
||||
if ($size < $kb) {
|
||||
return $size." b";
|
||||
} else if($size < $mb) {
|
||||
return round($size/$kb)." kb";
|
||||
} else if($size < $gb) {
|
||||
return round($size/$mb, $dec)." mb";
|
||||
} else if($size < $tb) {
|
||||
return round($size/$gb, $dec)." gb";
|
||||
} else {
|
||||
return round($size/$tb, $dec)." tb";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function regex_match($file) {
|
||||
$file_content = file_get_contents($file);
|
||||
|
@ -11,8 +11,8 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_admin/filemanager.php,v $
|
||||
| $Revision: 1.4 $
|
||||
| $Date: 2008-05-25 09:04:16 $
|
||||
| $Revision: 1.5 $
|
||||
| $Date: 2008-10-19 11:35:00 $
|
||||
| $Author: e107steved $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@ -272,7 +272,7 @@ while ($files[$c]) {
|
||||
if (!$img || !preg_match("/css|exe|gif|htm|jpg|js|php|png|txt|xml|zip/i", $img)) {
|
||||
$img = "def";
|
||||
}
|
||||
$size = parsesize(filesize(e_BASE.$path."/".$files[$c]));
|
||||
$size = $e107->parseMemorySize(filesize(e_BASE.$path."/".$files[$c]));
|
||||
$text .= "<tr>
|
||||
<td class=\"forumheader3\" style=\"vertical-align:middle; text-align:center; width:5%\">
|
||||
<img src=\"".$imagedir.$img.".png\" alt=\"".$files[$c]."\" style=\"border:0\" />
|
||||
@ -343,7 +343,10 @@ while ($files[$c]) {
|
||||
|
||||
$ns->tablerender(FMLAN_29.": <b>root/".$pathd."</b> [ ".count($dirs)." ".$dstr.", ".count($files)." ".$cstr." ]", $text);
|
||||
|
||||
function dirsize($dir) {
|
||||
|
||||
function dirsize($dir)
|
||||
{
|
||||
global $e107;
|
||||
$_SERVER["DOCUMENT_ROOT"].e_HTTP.$dir;
|
||||
$dh = @opendir($_SERVER["DOCUMENT_ROOT"].e_HTTP.$dir);
|
||||
$size = 0;
|
||||
@ -358,7 +361,7 @@ function dirsize($dir) {
|
||||
}
|
||||
}
|
||||
@closedir($dh);
|
||||
return parsesize($size);
|
||||
return $e107->parseMemorySize($size);
|
||||
}
|
||||
|
||||
|
||||
|
@ -11,8 +11,8 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_admin/upload.php,v $
|
||||
| $Revision: 1.4 $
|
||||
| $Date: 2008-04-22 20:32:39 $
|
||||
| $Revision: 1.5 $
|
||||
| $Date: 2008-10-19 11:35:00 $
|
||||
| $Author: e107steved $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@ -363,7 +363,7 @@ switch ($action)
|
||||
|
||||
<tr>
|
||||
<td class='forumheader3'>".UPLLAN_11."</td>
|
||||
<td class='forumheader3'>".parsesize($upload_filesize)."</td>
|
||||
<td class='forumheader3'>".$e107->parseMemorySize($upload_filesize)."</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -442,7 +442,7 @@ switch ($action)
|
||||
<td class='forumheader3'>".$poster."</td>
|
||||
<td class='forumheader3'><a href='".e_SELF."?view.".$upload_id."'>".$upload_name ."</a></td>
|
||||
<td class='forumheader3'>".$upload_file ."</td>
|
||||
<td class='forumheader3'>".parsesize($upload_filesize)."</td>
|
||||
<td class='forumheader3'>".$e107->parseMemorySize($upload_filesize)."</td>
|
||||
<td class='forumheader3'>
|
||||
<form action='".e_SELF."?dis.{$upload_id}' id='uploadform_{$upload_id}' method='post'>
|
||||
<div><a href='".e_SELF."?dlm.{$upload_id}'><img src='".e_IMAGE."packs/".$imode."/admin_images/downloads_16.png' alt='".UPLAN_COPYTODLS."' title='".UPLAN_COPYTODLS."' style='border:0' /></a>
|
||||
|
@ -11,8 +11,8 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_files/shortcode/batch/download_shortcodes.php,v $
|
||||
| $Revision: 1.13 $
|
||||
| $Date: 2008-09-23 19:31:59 $
|
||||
| $Revision: 1.14 $
|
||||
| $Date: 2008-10-19 11:35:00 $
|
||||
| $Author: e107steved $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@ -72,8 +72,8 @@ SC_END
|
||||
|
||||
|
||||
SC_BEGIN DOWNLOAD_LIST_FILESIZE
|
||||
global $row;
|
||||
return parsesize($row['download_filesize']);
|
||||
global $row, $e107;
|
||||
return $e107->parseMemorySize($row['download_filesize']);
|
||||
SC_END
|
||||
|
||||
|
||||
@ -282,7 +282,7 @@ SC_END
|
||||
|
||||
SC_BEGIN DOWNLOAD_VIEW_FILESIZE
|
||||
global $dl;
|
||||
return ($dl['download_filesize']) ? parsesize($dl['download_filesize']) : "";
|
||||
return ($dl['download_filesize']) ? $e107->parseMemorySize($dl['download_filesize']) : "";
|
||||
SC_END
|
||||
|
||||
SC_BEGIN DOWNLOAD_VIEW_RATING
|
||||
|
@ -11,8 +11,8 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_handlers/e107_class.php,v $
|
||||
| $Revision: 1.18 $
|
||||
| $Date: 2008-05-16 19:40:39 $
|
||||
| $Revision: 1.19 $
|
||||
| $Date: 2008-10-19 11:35:00 $
|
||||
| $Author: e107steved $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@ -351,34 +351,47 @@ class e107
|
||||
return $this->_ip_cache;
|
||||
}
|
||||
|
||||
function get_host_name($ip_address) {
|
||||
if(!$this->_host_name_cache[$ip_address]) {
|
||||
|
||||
function get_host_name($ip_address)
|
||||
{
|
||||
if(!$this->_host_name_cache[$ip_address])
|
||||
{
|
||||
$this->_host_name_cache[$ip_address] = gethostbyaddr($ip_address);
|
||||
}
|
||||
return $this->_host_name_cache[$ip_address];
|
||||
}
|
||||
|
||||
|
||||
// Return a memory value formatted helpfully
|
||||
function ret_memory_text($memusage)
|
||||
// $dp overrides the number of decimal places displayed - realistically, only 0..3 are sensible
|
||||
function parseMemorySize($size, $dp = 2)
|
||||
{
|
||||
$memunit = CORE_LAN_B;
|
||||
if ($memusage > 65536)
|
||||
{
|
||||
$memusage = $memusage / 1024; // more than 64k, show in k
|
||||
if (!$size) { $size = 0; }
|
||||
if ($size < 4096)
|
||||
{ // Fairly arbitrary limit below which we always return number of bytes
|
||||
return number_format($size, 0).CORE_LAN_B;
|
||||
}
|
||||
|
||||
$size = $size / 1024;
|
||||
$memunit = CORE_LAN_KB;
|
||||
}
|
||||
if ($memusage > 1024)
|
||||
{ /* 1.002 mb, etc */
|
||||
$memusage = $memusage / 1024;
|
||||
$memunit = CORE_LAN_MB;
|
||||
}
|
||||
if ($memusage > 1024)
|
||||
{ /* show in GB if >1GB */
|
||||
$memusage = $memusage / 1024;
|
||||
$memunit = CORE_LAN_GB;
|
||||
}
|
||||
return (number_format($memusage, ($memunit=='b'? 0 : 3)).$memunit);
|
||||
}
|
||||
|
||||
if ($size > 1024)
|
||||
{ /* 1.002 mb, etc */
|
||||
$size = $size / 1024;
|
||||
$memunit = CORE_LAN_MB;
|
||||
}
|
||||
if ($size > 1024)
|
||||
{ /* show in GB if >1GB */
|
||||
$size = $size / 1024;
|
||||
$memunit = CORE_LAN_GB;
|
||||
}
|
||||
if ($size > 1024)
|
||||
{ /* show in TB if >1TB */
|
||||
$size = $size / 1024;
|
||||
$memunit = CORE_LAN_TB;
|
||||
}
|
||||
return (number_format($size, $dp).$memunit);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -386,12 +399,13 @@ class e107
|
||||
*
|
||||
* @return string memory usage
|
||||
*/
|
||||
function get_memory_usage(){
|
||||
function get_memory_usage()
|
||||
{
|
||||
if(function_exists("memory_get_usage"))
|
||||
{
|
||||
$ret = $this->ret_memory_text(memory_get_usage());
|
||||
$ret = $this->parseMemorySize(memory_get_usage());
|
||||
// With PHP>=5.2.0, can show peak usage as well
|
||||
if (function_exists("memory_get_peak_usage")) $ret .= '/'.$this->ret_memory_text(memory_get_peak_usage(TRUE));
|
||||
if (function_exists("memory_get_peak_usage")) $ret .= '/'.$this->parseMemorySize(memory_get_peak_usage(TRUE));
|
||||
return $ret;
|
||||
}
|
||||
else
|
||||
|
@ -12,8 +12,8 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_handlers/upload_handler.php,v $
|
||||
| $Revision: 1.17 $
|
||||
| $Date: 2008-10-04 16:10:55 $
|
||||
| $Revision: 1.18 $
|
||||
| $Date: 2008-10-19 11:35:00 $
|
||||
| $Author: e107steved $
|
||||
+---------------------------------------------------------------+
|
||||
*/
|
||||
@ -657,29 +657,6 @@ function file_size_decode($source, $compare = 0, $action = '')
|
||||
|
||||
|
||||
|
||||
function parsesize($size)
|
||||
{
|
||||
$kb = 1024;
|
||||
$mb = 1024 * $kb;
|
||||
$gb = 1024 * $mb;
|
||||
$tb = 1024 * $gb;
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Similar to get_allowed_filetypes(), but expects an XML file
|
||||
// Returns an array where key is the file extension; value is max upload size
|
||||
function get_XML_filetypes($def_file = FALSE, $file_mask = '')
|
||||
|
@ -4,8 +4,8 @@
|
||||
| e107 website system - Language File.
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_languages/English/English.php,v $
|
||||
| $Revision: 1.5 $
|
||||
| $Date: 2008-10-15 21:23:51 $
|
||||
| $Revision: 1.6 $
|
||||
| $Date: 2008-10-19 11:35:00 $
|
||||
| $Author: e107steved $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@ -43,11 +43,11 @@ define("CORE_LAN16", "Memory: ");
|
||||
define('CORE_LAN17', '[ image disabled ]');
|
||||
define('CORE_LAN18', 'Image: ');
|
||||
|
||||
define("CORE_LAN_B", "b");
|
||||
define("CORE_LAN_KB", "kb");
|
||||
define("CORE_LAN_MB", "Mb");
|
||||
define("CORE_LAN_GB", "Gb");
|
||||
define("CORE_LAN_TB", "Tb");
|
||||
define("CORE_LAN_B", "B");
|
||||
define("CORE_LAN_KB", "kB");
|
||||
define("CORE_LAN_MB", "MB");
|
||||
define("CORE_LAN_GB", "GB");
|
||||
define("CORE_LAN_TB", "TB");
|
||||
|
||||
|
||||
define("LAN_WARNING", "Warning!");
|
||||
|
@ -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];
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -11,8 +11,8 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/upload.php,v $
|
||||
| $Revision: 1.5 $
|
||||
| $Date: 2008-04-22 20:32:40 $
|
||||
| $Revision: 1.6 $
|
||||
| $Date: 2008-10-19 11:35:00 $
|
||||
| $Author: e107steved $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@ -191,7 +191,7 @@ if (ADMIN)
|
||||
$allowed_filetypes = "<table><tr><td>".LAN_UL_023." </td><td style='text-align:right'>".LAN_UL_024."</td></tr>";
|
||||
foreach ($a_filetypes as $type => $size)
|
||||
{
|
||||
$allowed_filetypes .= "<tr><td>{$type}</td><td style='text-align:right'>".parsesize($size)."</td></tr>";
|
||||
$allowed_filetypes .= "<tr><td>{$type}</td><td style='text-align:right'>".$e107->parseMemorySize($size,0)."</td></tr>";
|
||||
}
|
||||
$allowed_filetypes .= "</table>";
|
||||
}
|
||||
@ -202,7 +202,7 @@ else
|
||||
}
|
||||
|
||||
$text .= " ".$allowed_filetypes."<br />".LAN_407."<br />
|
||||
".LAN_418.parsesize($max_upload_size)." (".LAN_UL_022.")<br />";
|
||||
".LAN_418.$e107->parseMemorySize($max_upload_size,0)." (".LAN_UL_022.")<br />";
|
||||
|
||||
$text .= "<span style='text-decoration:underline'>".LAN_408."</span> ".LAN_420."</td>
|
||||
</tr>";
|
||||
|
Loading…
x
Reference in New Issue
Block a user