(2003-2009) * @author Froxlor team (2010-) * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt * @package Functions * */ /** * Returns an array of found directories * * This function checks every found directory if they match either $uid or $gid, if they do * the found directory is valid. It uses recursive function calls to find subdirectories. Due * to the recursive behauviour this function may consume much memory. * * @param string path The path to start searching in * @param integer uid The uid which must match the found directories * @param integer gid The gid which must match the found direcotries * @param array _fileList recursive transport array !for internal use only! * @return array Array of found valid pathes * * @author Martin Burchert * @author Manuel Bernhardt */ function findDirs($path, $uid, $gid) { $list = array( $path ); $_fileList = array(); while(sizeof($list) > 0) { $path = array_pop($list); $path = makeCorrectDir($path); if(!is_readable($path) || !is_executable($path)) { //return $_fileList; // only 'skip' this directory, #611 continue; } $dh = opendir($path); if($dh === false) { /* * this should never be called because we checked * 'is_readable' before...but we never know what might happen */ standard_error('cannotreaddir', $path); return null; } else { while(false !== ($file = @readdir($dh))) { if($file == '.' && (fileowner($path . '/' . $file) == $uid || filegroup($path . '/' . $file) == $gid)) { $_fileList[] = makeCorrectDir($path); } if(is_dir($path . '/' . $file) && $file != '..' && $file != '.') { array_push($list, $path . '/' . $file); } } @closedir($dh); } } return $_fileList; }