Guest User

Untitled

a guest
Jun 22nd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. <?php
  2.  
  3. function searchdir($directory)
  4. {
  5.  
  6. // create an array to hold directory list
  7. $results = array();
  8.  
  9. // create a handler for the directory
  10. $handler = opendir($directory);
  11.  
  12. // keep going until all files in directory have been read
  13. while ($file = readdir($handler)) {
  14.  
  15. // if $file isn't this directory or its parent,
  16. // add it to the results array
  17. if ($file != '.' && $file != '..')
  18. $results[] = $file;
  19. }
  20.  
  21. // tidy up: close the handler
  22. closedir($handler);
  23.  
  24. // done!
  25. return $results;
  26.  
  27. }
  28.  
  29. // Directory Scanner Function. Recursively acquires folders and files from the specified directory
  30. function index($directory) {
  31.  
  32. $result = null;
  33. $scan = searchdir($directory);
  34.  
  35. foreach ($scan as $key=>$value) {
  36. // Custom list of files to ignore
  37. if($value != "." && $value != ".." && $value != "index.php" && $value != ".DS_Store" && $value != ".svn" && $value != "thumbs.db" && $value != "thumb.jpg") {
  38.  
  39. if (is_dir($directory.'/'.$value))
  40. $result[$value] = index($directory.'/'.$value);
  41. else
  42. //FIXME Recode regular expression
  43. //$result[$value] = str_replace('_',' ',preg_replace('', '', $value));
  44. $result[$value] = str_replace('_',' ',$value);
  45.  
  46. }
  47. }
  48.  
  49. return $result;
  50. }
  51. ?>
Add Comment
Please, Sign In to add comment