<?php

$root = '../../assets';
//$folder = $_GET["folder"];

FindPath($root, '建置資料');
function FindPath($root, $folder)
{
    $rootPath = $root . "/" . $folder;
    $paths = array_diff(scandir($rootPath), array('.', '..', 'Thumbs.db'));
    echo ("<ul>");
    foreach ($paths as $path) {

        if (str_contains($path, '.')) {
            echo ("<li data-jstree='{ " . '"type" : "file"' . " }' >");
            $path = "<a href='" . substr($rootPath, 0) . "/" . $path . "'>" . $path . "</a>";
            echo ($path);
            echo ("</li>");
        } else {
            echo ("<li>");
            echo ($path);
            FindPath($rootPath, $path);
            echo ("</li>");
        }
    }
    echo ("</ul>");
}
