Location: PHPKode > projects > TVEz - Media Library > tvez-0.2.1/html/movies/portlets/dir_size.php
<?php

// RETURNS THE TOTAL SIZE OF ALL FILES
// WITHIN A DIRECTORY AND SUBSEQUENT CHILD DIRECTORIES
// LIMITED TO DIRECTORIES READABLE BY APACHE
function dir_size($DIR = FALSE) {
	// IF DIR IS TRUE AND IS A DIRECTORY
	if ($DIR && is_dir($DIR)) {
		// ADD TRAILING SLASH
		if (substr($DIR,-1) != "/") $DIR .= "/";
		// IF THE DIR IS NOT READABLE, RETURN
		if (! is_readable($DIR)) return 0;
		// OPEN DIRECTORY
		if ($DIR_ID = opendir($DIR)) {
			// LOOP THROUGH CONTENTS OF DIR
			while (($ITEM = readdir($DIR_ID)) !== FALSE) {
				// IF ITEM IS A DIRECTORY
				if (is_readable($DIR . $ITEM))
					if (is_dir($DIR . $ITEM) && $ITEM != "." && $ITEM != "..") {
						// CALL FUNCTION RECURSIVELY
						$SIZE += dir_size($DIR . $ITEM);
					} else {
						// ADD SIZE OF FILE
						$SIZE += filesize($DIR . $ITEM);
					}
			}
			// CLOSE DIRECTORY
			closedir($DIR_ID);
		}
	}
	// RETURN SIZE
	return $SIZE;
}

?>
Return current item: TVEz - Media Library