function get_folder_files($path, $subdirs = false, $fullname = true, $mask = "", $forcelowercase = TRUE) { // Correct path name, if needed $path = str_replace('/', '\\', $path); if (substr($path, -1) != '\\') { $path .= "\\"; } if (!$path || !@is_dir($path)) { return array(); } // Browse the subdiretory list recursively $dir = array(); if ($handle = opendir($path)) { while (($file = readdir($handle)) !== false) { if (!is_dir($path . $file)) { // No directories / subdirectories if ($forcelowercase) { $file = strtolower($file); } if (!$mask) { $dir[] = $fullname ? $path . $file : $file; } else { if ($mask && preg_match($mask, $file)) { $dir[] = $fullname ? $path . $file : $file; } } } else { if ($subdirs && $file[0] != ".") { // Exclude "." and ".." $dir = array_merge($dir, get_folder_files($path . $file, $subdirs, $fullname, $mask)); } } } } closedir($handle); return $dir; }
/** * get folder files * * @param string $username * @param integer $folderid * * @return array */ function webservice_mnet_get_folder_files($username, $folderid) { require_once get_config('docroot') . 'api/xmlrpc/lib.php'; return get_folder_files($username, $folderid); }