recursiveScanDir.php 565 B

12345678910111213141516171819202122232425
  1. <?php
  2. include '../auth.php';
  3. $foundFiles = [];
  4. function finddir($target) {
  5. global $foundFiles;
  6. if(is_dir($target)){
  7. $files = glob( $target . '*', GLOB_MARK );
  8. foreach( $files as $file ){
  9. finddir( $file );
  10. }
  11. }elseif(is_file($target)){
  12. $target = str_replace('\\', '/', $target);
  13. array_push($foundFiles,$target);
  14. }
  15. }
  16. if (isset($_GET['relativePath'])){
  17. if (is_dir($_GET['relativePath']) == false){
  18. die("ERROR. Path not found.");
  19. }
  20. finddir($_GET['relativePath']);
  21. header('Content-Type: application/json');
  22. echo json_encode($foundFiles);
  23. }
  24. ?>