Example #1
0
function all_disk_files($media_folder, $media_path, $subfolders, $filter)
{
    return scan_dirs(WT_DATA_DIR . $media_folder . $media_path, $subfolders == 'include', $filter);
}
Example #2
0
/**
 * @param $rootDir
 * @param array $allData
 * @return array
 */
function scan_dirs($rootDir, $allData = array())
{
	// set filenames invisible if you want
	$invisibleFileNames = array(".", "..", ".htaccess", ".htpasswd");
	// run through content of root directory
	$dirContent = scandir($rootDir);
	foreach ($dirContent as $key => $content) {
		// filter all files not accessible
		$path = $rootDir . '/' . $content;
		if (!in_array($content, $invisibleFileNames)) {
			// if content is file & readable, add to array
			if (is_file($path) && is_readable($path)) {
				// save file name with path
				$allData[] = $path;
				// if content is a directory and readable, add path and name
			} elseif (is_dir($path) && is_readable($path)) {
				// recursive callback to open new directory
				$allData = scan_dirs($path, $allData);
			}
		}
	}
	return $allData;
}