mirror of
https://github.com/HaschekSolutions/pictshare.git
synced 2025-11-18 14:08:01 +00:00
removed bcmath requirement
This commit is contained in:
@@ -5,7 +5,6 @@
|
|||||||
* This tool uploads all local images to backblaze if they don't exist yet
|
* This tool uploads all local images to backblaze if they don't exist yet
|
||||||
* You can use this to backup your images to backblaze or set it up as your data source for scaling
|
* You can use this to backup your images to backblaze or set it up as your data source for scaling
|
||||||
*
|
*
|
||||||
* This scripts needs the "bcmath" library. install it with: apt-get install php-bcmath
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if(php_sapi_name() !== 'cli') exit('This script can only be called via CLI');
|
if(php_sapi_name() !== 'cli') exit('This script can only be called via CLI');
|
||||||
@@ -59,17 +58,20 @@ foreach($localfiles as $hash)
|
|||||||
if($sim!==true)
|
if($sim!==true)
|
||||||
$b->upload($hash);
|
$b->upload($hash);
|
||||||
$uploadsize+=filesize($dir.$hash.DS.$hash);
|
$uploadsize+=filesize($dir.$hash.DS.$hash);
|
||||||
echo " done.\tUploaded so far: ".renderSize($uploadsize,2,false)."\n";
|
echo " done.\tUploaded so far: ".renderSize($uploadsize)."\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function renderSize($bytes, $precision = 2) {
|
||||||
|
$units = array('B', 'KB', 'MB', 'GB', 'TB');
|
||||||
|
|
||||||
function renderSize($byte,$precision=2,$mibi=true)
|
$bytes = max($bytes, 0);
|
||||||
{
|
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
|
||||||
$base = (string)($mibi?1024:1000);
|
$pow = min($pow, count($units) - 1);
|
||||||
$labels = array('K','M','G','T','P','E','Z','Y');
|
|
||||||
for($i=8;$i>=1;$i--)
|
// Uncomment one of the following alternatives
|
||||||
if(bccomp($byte,bcpow($base, $i))>=0)
|
$bytes /= pow(1024, $pow);
|
||||||
return bcdiv($byte,bcpow($base, $i), $precision).' '.$labels[$i-1].($mibi?'iB':'B');
|
// $bytes /= (1 << (10 * $pow));
|
||||||
return $byte.' Byte';
|
|
||||||
|
return round($bytes, $precision) . ' ' . $units[$pow];
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user