<?php
date_default_timezone_set("Etc/GMT-8");
$root = '../../assets/建置資料/公路工程';
//$folder = $_GET["folder"];
$plan = '';
FindPath($root, '17032-縣道157線拓寬改建專管', $plan);
function FindPath($root, $folder, $plan)
{
    $rootPath = $root . "/" . $folder;
    $paths = array_diff(scandir($rootPath), array('.', '..', 'Thumbs.db'));
    echo ("<ul>");
    foreach ($paths as $path) {

        if (is_file($rootPath . '/' . $path)) {
            if (!str_contains($path, ".xls")) {
                $href = substr($rootPath, 4) . "/" . $path;
                echo ("<li class='node-hidden' data-jstree='{ " . '"type" : "file"' . " }' >");
                $path = "<a time='" . date("Y/m/d H:i:s", filemtime($rootPath . '/' . $path)) . "'plan='" . $plan . "' href='" . $href . "'>" . $path . "</a>";
                echo ($path);
                echo ("</li>");
            }
        } else {
            if (str_contains($path, '-')) {
                $plan = $path;
            }
            echo ("<li>");
            echo ($path);
            FindPath($rootPath, $path, $plan);
            echo ("</li>");
        }
    }
    echo ("</ul>");
}