trasherdk / phpvirtualbox

A web interface to manage and access Virtualbox machines.
Other
16 stars 2 forks source link

Snippet: Patch for PHP 8.0+ and import dialog hangs when choosing the import image #5

Open trasherdk opened 2 years ago

trasherdk commented 2 years ago
diff --git a/endpoints/jqueryFileTree.php b/endpoints/jqueryFileTree.php
index 875d3db..96c9d8d 100644
--- a/endpoints/jqueryFileTree.php
+++ b/endpoints/jqueryFileTree.php
@@ -222,7 +222,8 @@ echo(json_encode($returnData));
  * Get directory entries
  */
 function getdir($dir, $dirsOnly=false, $recurse=array()) {
-
+       global $allowed_exts;
+
        if(!$dir) $dir = DSEP;

        $entries = getDirEntries($dir, $dirsOnly);
@@ -251,9 +252,9 @@ function getdir($dir, $dirsOnly=false, $recurse=array()) {
                // Push file on to stack
                } else {

-                       $ext = strtolower(preg_replace('/^.*\./', '', $file));
+                       $ext = strtolower(preg_replace('/^.*\./', '', $path));

-                if(count($allowed) && !$allowed['.'.$ext]) continue;
+                if(count($allowed_exts) && !$allowed_exts['.'.$ext]) continue;

                 array_push($dirents, file_entry($path));
                }