¿Cuanto pesa las carpetas individualmente (moodledata) del moodle?

Seguramente a quienes programan en moodle y almacenan gran información en su servidor desean saber cuanto pesa cada curso en el servidor web.
Para ello, a partir de un script generamos los tamaños de los archivos para moodle.

function size($path, $formated = true, $retstring = null){
if(!is_dir($path) || !is_readable($path)){
if(is_file($path) || file_exists($path)){
$size = filesize($path);
} else {
return false;
}
} else {
$path_stack[] = $path;
$size = 0;
do {
$path = array_shift($path_stack);
$handle = opendir($path);
while(false !== ($file = readdir($handle))) {
if($file != '.' && $file != '..' && is_readable($path . DIRECTORY_SEPARATOR . $file)) {
if(is_dir($path . DIRECTORY_SEPARATOR . $file)){ $path_stack[] = $path . DIRECTORY_SEPARATOR . $file; }
$size += filesize($path . DIRECTORY_SEPARATOR . $file);
}
}
closedir($handle);
} while (count($path_stack)> 0);
}

if($formated){
$sizes = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
if($retstring == null) { $retstring = '%01.2f %s'; }
$lastsizestring = end($sizes);
foreach($sizes as $sizestring){
if($size <1024){ sizestring ="="" retstring =" '%01d" size =" sprintf($retstring,">

Luego generamos una consulta "SELECT * FROM mdl_course"
para vincularlo en la carpeta de moodledata
$espacio = size("ruta/moodledata".$id_curso."/");
echo $espacio;

No hay comentarios

Con la tecnología de Blogger.