Bash, Shell, PHP, Python, Perl, CGI
schnuffel
Posts: 47 Joined: 2003-09-15 16:52
Post
by schnuffel » 2003-10-22 16:47
hallo zusammen, ich habe ein script zum anzeigen eines Verzeichnisinhaltes. Kann man das so umbauen das ich die gelistetetn Inhalte (html seiten) anklicken kann?
Code: Select all
<?PHP
function show_dir($dir, $pos=2)
{
if($pos == 2)
{
echo "<hr><pre>";
}
$handle = @opendir($dir);
while ($file = @readdir ($handle))
{
if (eregi("^.{1,2}$",$file))
{
continue;
}
if(is_dir($dir.$file))
{
printf ("% ".$pos."s <b>%s</b>n", "|-", $file);
show_dir($dir.$file."/", $pos + 3);
}
else
{
printf ("% ".$pos."s %sn", "|-", $file);
}
}
@closedir($handle);
if($pos == 2)
{
echo "</pre><hr>";
}
}
show_dir("./");
?>
Ich habe da nicht so viel Ahnung,
Danke, Schnuff
Joe User
Project Manager
Posts: 11191 Joined: 2003-02-27 01:00
Location: Hamburg
Contact:
Post
by Joe User » 2003-10-22 19:23
Code: Select all
<?php
function show_dir($dir,$pos=2)
{
if($pos==2)
{
echo "<hr><pre>";
}
$handle=@opendir($dir);
while($file=@readdir($handle))
{
if(eregi("^.{1,2}$",$file))
{
continue;
}
if(is_dir($dir.$file))
{
printf("% ".$pos."s <b>%s</b>n","|-","<a href="$file">$file</a>");
show_dir($dir.$file."/",$pos+3);
}
else
{
printf("% ".$pos."s %sn","|-","<a href="$file">$file</a>");
}
}
@closedir($handle);
if($pos==2)
{
echo "</pre><hr>";
}
}
show_dir("./");
?>
gonzo_ac
Posts: 92 Joined: 2003-06-17 18:43
Post
by gonzo_ac » 2003-10-23 12:07
hi wenn ich noch ne anmerkung geben darf!
Code: Select all
<?php
function show_dir($dir,$pos=2)
{
if($pos==2)
{
echo "<hr><pre>";
}
$handle=@opendir($dir);
while($file=@readdir($handle))
{
if(eregi("^.{1,2}$",$file))
{
continue;
}
if(is_dir($dir.$file))
{
printf("% ".$pos."s <b>%s</b>n","|-","<a href="$file/">$file</a>");
show_dir($dir.$file."/",$pos+3);
}
else
{
printf("% ".$pos."s %sn","|-","<a href="$dir$file">$file</a>");
}
}
@closedir($handle);
if($pos==2)
{
echo "</pre><hr>";
}
}
show_dir("./");
?>
ich hab in den beiden printf-zeilen im breich des <a href>etwas geändert so das die links auch für unterverzeichnisse funktionieren.
gruss gonzo
cpr
Posts: 22 Joined: 2003-08-12 15:39
Post
by cpr » 2003-10-23 12:32
gonzo_ac
Posts: 92 Joined: 2003-06-17 18:43
Post
by gonzo_ac » 2003-10-23 14:21
hi, nettes programm. aber nur weil man den verzsichnisinhalt angezeoigt bekommen möchte ist AutoIndex.php ein wenig komplex.
da finde ich das script von oben ein wenig netter.
gruss gonzo
schnuffel
Posts: 47 Joined: 2003-09-15 16:52
Post
by schnuffel » 2003-10-27 06:58
@ Joe User
@ gonzo_ac
Vielen Dank für eure Hilfe, nun gehts!
:-D :-D
Gruß schnuff