function scan_local_files($local_root)
{
    $local_files = scanLocal($local_root);
    //Scan local files.
    if (empty($local_files)) {
        $html = "No local files found!<br/>";
    } else {
        $_SESSION['local_files'] = $local_files;
        // save for later
        $html = count($local_files) . " local files found!<br/>";
    }
    return $html;
}
Ejemplo n.º 2
0
function scanLocal($dir, $rootLength = null)
{
    $dir = clearPath($dir);
    if (is_null($rootLength)) {
        $rootLength = strlen($dir);
    }
    // check whether $root is a valid directory
    if (!is_dir($dir)) {
        echo "{$dir} is not a valid directory\n";
        die;
    }
    //scan dir, create file modification time view
    $files = array();
    $curDirList = scandir($dir);
    foreach ($curDirList as $n) {
        if ($n[0] == '.') {
            continue;
        }
        // jump the hidden directory and file
        $n = $dir . $n;
        $fileName = substr($n, $rootLength);
        $files[$fileName] = filemtime($n);
        if (is_dir($n)) {
            $files = array_merge($files, scanLocal($n, $rootLength));
        }
    }
    return $files;
}