/usr/share/knowledgeroot/include/function.php is in knowledgeroot 0.9.9.5-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | <?php
/**
*
*
* @package Knowledgeroot
* @author Frank Habermann
* @version $Id: function.php 188 2006-10-30 20:15:33Z koala_s $
*/
/**
*
*/
function getfilesize($byte,$precision = 2) {
$a = 0;
while($byte > 1024) {
$byte = round($byte / 1024,$precision);
$a++;
}
if($a == 0) $size = "B";
elseif($a == 1) $size = "KB";
elseif($a == 2) $size = "MB";
elseif($a == 3) $size = "GB";
else return "Wrong Size";
$bsize = "$byte $size";
return $bsize;
}
/**
* Liefert eine Ziffer mit angehangener Groessenangabe zurueck
*
* @access public
* @param int $size
* @return mix Ziffer+Groessenangabe
*/
function getFormattedSize($size) {
// Setup some common file size measurements.
$kb = 1024; // Kilobyte
$mb = 1024 * $kb; // Megabyte
$gb = 1024 * $mb; // Gigabyte
$tb = 1024 * $gb; // Terabyte
// Get the file size in bytes.
// If it's less than a kb we just return the size, otherwise we keep going until
// the size is in the appropriate measurement range.
switch ($size) {
case $size < $mb: return round($size / $kb, 2)." KBytes"; break;
case $size < $gb: return round($size / $mb, 2)." MBytes"; break;
case $size < $tb: return round($size / $gb, 2)." GBytes"; break;
case $size >= $tb: return round($size / $tb, 2)." TBytes"; break;
default:
case $size < $kb: return $size." Bytes"; break;
}
}
?>
|