\PHP
directory_size.txt
This function get the total size of the specified directory and all directorys contained within the specified directory.
Example:
echo get_dir_size("./"); // gets the size of the current web directory
Questions, Contact JoshS@santsys.com
function get_dir_size($dir)
{
global $file_count, $dir_count;
$size = 0;
if(is_dir($dir))
{
$handle = opendir($dir);
while(($file = readdir($handle)) != false)
{
if(($file != ".") && ($file != ".."))
{
if(is_dir($dir."/".$file))
{
$size += get_dir_size($dir."/".$file);
$dir_count++;
}
if(is_file($dir."/".$file))
{
$size += filesize($dir."/".$file);
$file_count++;
}
}
}
closedir($handle);
}
else
{
$size += filesize($dir);
}
return $size;
}