getDir.php 746 B

1234567891011121314151617181920212223
  1. <?php
  2. include_once '../auth.php';
  3. if (isset($_GET['directory']) && strpos($_GET['directory'],"../") === false){
  4. //If the given directory is within the ArOZ Online root and do not contain ../ (back outside the aor) then allow list dir
  5. $targetDir = "../" . $_GET['directory'];
  6. if (file_exists($targetDir)){
  7. $folders = glob($targetDir . "*");
  8. $result = [];
  9. foreach ($folders as $folder){
  10. if (is_dir($folder)){
  11. array_push($result,[$folder,basename($folder)]);
  12. }
  13. }
  14. header('Content-type: application/json');
  15. echo json_encode($result);
  16. }else{
  17. die("ERROR. Undefined directory");
  18. }
  19. }else{
  20. die("ERROR. Undefined directory path.");
  21. }
  22. ?>