Citation :
<?php
$TotalSize = "1073741824";
$UsedSize = RecursiveSize("." );
$spaceSize = $TotalSize - $UsedSize;
echo 'Espace total: '.round((($TotalSize/1024)/1024),2).'Mo<br>';
echo 'Espace utilisé: '.round((($UsedSize/1024)/1024),2).'Mo<br>';
echo 'Espace libre: '.round((($spaceSize/1024)/1024),2).'Mo<br>';
$taille=200; // par exemple - c'est la largeur voulue en pixel
echo '<img src="rouge.jpg" width="'.(int)($UsedSize/$TotalSize*$taille).'" height="20" alt="'.round(($UsedSize/$TotalSize*100),1).' percents used" />';
echo '<img src="bleu.jpg" width="'.(int)($spaceSize/$TotalSize*$taille).'" height="20" alt="'.round(($spaceSize/$TotalSize*100),1).' percents free" />';
/* int RecursiveSize(int dir); */
function RecursiveSize($dir){
$h = opendir($dir);
while(FALSE !== ($fp = readdir($h))) {
$link = $dir.'/'.$fp;
if($fp != '.' && $fp != '..'){
if(is_dir($link)) $size+=RecursiveSize($link);
else $size+=filesize($link);
}
}
closedir($h);
return $size; // in bytes
}
?>;
|