2012-04-29 17:15:06 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* ZeroBin
|
|
|
|
*
|
|
|
|
* a zero-knowledge paste bin
|
|
|
|
*
|
|
|
|
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
|
|
|
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
|
|
|
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
2013-07-04 23:14:23 +00:00
|
|
|
* @version 0.19
|
2012-04-29 17:15:06 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* filter
|
|
|
|
*
|
|
|
|
* Provides data filtering functions.
|
|
|
|
*/
|
|
|
|
class filter
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* strips slashes deeply
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @static
|
|
|
|
* @param mixed $value
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public static function stripslashes_deep($value)
|
|
|
|
{
|
|
|
|
return is_array($value) ?
|
|
|
|
array_map('filter::stripslashes_deep', $value) :
|
|
|
|
stripslashes($value);
|
|
|
|
}
|
2012-04-30 20:58:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* format a given number of bytes
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @static
|
|
|
|
* @param int $size
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public static function size_humanreadable($size)
|
|
|
|
{
|
|
|
|
$iec = array('B', 'kiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB');
|
2012-08-25 22:49:11 +00:00
|
|
|
$i = 0;
|
|
|
|
while ( ( $size / 1024 ) >= 1 ) {
|
2012-04-30 20:58:08 +00:00
|
|
|
$size = $size / 1024;
|
|
|
|
$i++;
|
|
|
|
}
|
2012-08-25 22:49:11 +00:00
|
|
|
return number_format($size, ($i ? 2 : 0), '.', ' ') . ' ' . $iec[$i];
|
2012-04-30 20:58:08 +00:00
|
|
|
}
|
2012-04-29 17:15:06 +00:00
|
|
|
}
|