Einzelnen Beitrag anzeigen
  #5  
Alt 16.11.2007, 14:24:18
pmneo pmneo ist offline
Anfänger
 
Registriert seit: Sep 2007
Beiträge: 9
AW: Entferntes Verzeichniss rekursiv auslesen.

Hey Großer Meister ;)

Denke so könnte es gehen, nen link auf file:// sollte klappen, die leutz müssen halt berechtigt sein ;)

PHP-Code:
<?

$base_path = "C:\\";

function concatPathes($path1,$path2)
{
    if(substr($path1,-1) == "\\")
        $path1 = substr($path1,0,-1);

    if(substr($path2,0,1) == "\\")
        $path2 = substr($path2,1);

    return $path1."\\".$path2;
}
function getParentFolder($path)
{
    $folders = explode("\\",$path);
    $new_path = "";
    for($i=0;$i<sizeof($folders)-1;$i++)
    {
        if($new_path != "") $new_path .= "\\";
        $new_path .= $folders[$i];
    }
    return $new_path;
}

$path = $base_path;

if(isset($_GET["sub_path"]))
{

    $new_path = concatPathes($base_path,stripslashes($_GET["sub_path"]));

    if(is_dir($new_path))
        $path = $new_path;
}

echo "Current Path: ".$path."<br>";

$dir = dir($path);
if($dir)
{
    echo "<a href=\"?sub_path=".getParentFolder(substr($path,strlen($base_path)))."\">..</a><br>";
    while(($entry = $dir->read()) !== false)
    {
        if($entry != "." && $entry != "..")
        {
            $tmp_path = concatPathes($path,$entry);
            if(is_dir($tmp_path))
                echo "<a href=\"?sub_path=".substr($tmp_path,strlen($base_path))."\" style=\"color: green;\">".$entry."</a><br>";
            else
                echo "<a href=\"file://".$tmp_path."\">".$entry."</a><br>";

        }

    }
}

?>
Gruß
Mit Zitat antworten