function dirsize($url=''){
if(isset($_COOKIE['hdd_value'])){return false;}
$url = (strlen($url) < 1)?"./":$url."/";
$d = dir($url);
$N = 0;
$S = 0;
while($dir=$d->read()){
if($dir != "." && $dir != ".."){
if(filetype($url.$dir) == "file"){
$N++;
$S += filesize($url.$dir);
}
}
}
$d->close();
$size = intval(intval($S/1024)/1024);
$sql = SQL::getInstance();
$arr = array(
'value' => $size
);
$sql->update($arr,'hosting');
$sql->add('name','hdd_used');
$sql->query();
setcookie('hdd_value',true,intval(time()+123200),'/admin');
}
<?
$f = './path/directory';
$io = popen ( '/usr/bin/du -sk ' . $f, 'r' );
$size = fgets ( $io, 4096);
$size = substr ( $size, 0, strpos ( $size, "\t" ) );
pclose ( $io );
echo 'Directory: ' . $f . ' => Size: ' . $size;
?>
<?
$f = 'f:/www/docs';
$obj = new COM ( 'scripting.filesystemobject' );
if ( is_object ( $obj ) )
{
$ref = $obj->getfolder ( $f );
echo 'Directory: ' . $f . ' => Size: ' . $ref->size;
$obj = null;
}
else
{
echo 'can not create object';
}
?>