-1)) { if (@filetype($startdir . $file) == "dir") { //build your directory array however you choose; //add other file details that you want. $directorylist[$startdir . $file]['level'] = $level; $directorylist[$startdir . $file]['dir'] = 1; $directorylist[$startdir . $file]['name'] = $file; $directorylist[$startdir . $file]['path'] = $startdir; if ($searchSubdirs) { if ((($maxlevel) == "all") or ($maxlevel > $level)) { filelist($startdir . $file . "/", $searchSubdirs, $directoriesonly, $maxlevel, ($level + 1), 0); } } } else { if (!$directoriesonly) { // echo substr(strrchr($file, "."), 1); //if you want to include files; build your file array //however you choose; add other file details that you want. $directorylist[$startdir . $file]['level'] = $level; $directorylist[$startdir . $file]['dir'] = 0; $directorylist[$startdir . $file]['name'] = $file; $directorylist[$startdir . $file]['path'] = $startdir; }}}} closedir($dh); }} if(!empty($reset)){ $r = $directorylist; $directorylist = array(); return($r); } } // Copy from source to destination function copydir($source, $destination){ $source = (substr($source, -1) == '/' || substr($source, -1) == '\\' ? $source : $source.'/'); $destination = (substr($destination, -1) == '/' || substr($destination, -1) == '\\' ? $destination : $destination.'/'); $source_ = substr($source, 0, -1); $destination_ = substr($destination, 0, -1); if(!is_dir($destination)){ mkdir($destination); } resetfilelist(); $files = filelist($source, 1, 1, 'all'); $files = (!is_array($files) ? array() : $files); // Make the folders foreach($files as $k => $v){ mkdir_recursive(str_replace($source_, $destination_, $k), $globals['dirchmod']); @chmod(str_replace($source_, $destination_, $k), fileperms($k)); } @clearstatcache(); resetfilelist(); $files = filelist($source, 1, 0, 'all'); $files = (!is_array($files) ? array() : $files); // Copy the files foreach($files as $k => $v){ if(file_exists($k) && is_file($k) && @filetype($k) == "file"){ copy($k, str_replace($source_, $destination_, $k)); @chmod(str_replace($source_, $destination_, $k), fileperms($k)); } } @clearstatcache(); resetfilelist(); return true; } function mkdir_recursive($pathname, $mode){ is_dir(dirname($pathname)) || mkdir_recursive(dirname($pathname), $mode); return is_dir($pathname) || @mkdir($pathname, $mode); }