Advertisement
Guest User

Untitled

a guest
Apr 21st, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. function scan($path,&$res, $type="*",
  2. $type_sort="small", $lines=0) {
  3. $mass=scandir($path);
  4. for($i=0;$i<=count($mass)-1;$i++) {
  5. if($mass[$i]!=".." &&
  6. $mass[$i]!=".") {
  7. if(strtolower($type_sort)=="small")
  8. {
  9. if($type=="*" || strstr(strtolower($mass[$i]),$type))
  10. array_push($res,array($lines,$mass[$i]));
  11. } else
  12. if($type=="*" || strstr(strtolower($mass[$i]),$type))
  13. array_push($res,array($lines,$path.$mass[$i]));
  14. } if(!strstr($mass[$i],"."))
  15. if(is_dir($path.'/'.$mass[$i]))
  16. scan($path.'/'.$mass[$i],$res,$type,$type_sort,$lines+1);
  17. }
  18.  
  19. }
  20.  
  21. function scan( $path, $ex = '*', $type_sort = 'small', $level = 0 ){
  22. $res = Array();
  23. $files = scandir( $path );
  24. $path_add = ( strtolower( $type_sort ) == 'small' ) ? $path : '';
  25.  
  26. for ( $i = 0; $i < count( $files ); $i++ ){
  27. if ( $files[$i] != ".." && $files[$i] != "." ) {
  28. if ( $ex == "*" || strstr( strtolower( $files[$i] ), $ex ) ){
  29. $res[] = array( $level, $path_add . $files[$i] );
  30. }
  31. }
  32.  
  33. if ( !strstr( $files[$i], "." ) && is_dir( $path.'/'.$files[$i] ) ){
  34. array_merge(
  35. scan( $path.'/'.$files[$i], $ex, $type_sort, $level + 1 );
  36. );
  37. }
  38. }
  39.  
  40. return $res;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement