RE: [PHP] code to see files in directories
| From: | Karl Phillipson | Date: | Thu, 09 Aug 2001 06:59:40 +0000 |
| Subject: | RE: [PHP] code to see files in directories | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-61952@lists.php.net to get a copy of this message | ||
p.s this script came from:
// PHP Spider Trapper
// Copyright 2000 MassTraffic.com
// Unlimted Usage Granted By _Owner_
// You May Use the Program For Free
// Under the CAREWARE liceanse.
// Which states that you may use
// the product for free as long
// as you are happy and take care
// of each other && This Script!!
==========================
Karl Phillipson
PHP SQL Programmer
Saffron Hill Ventures
67 Clerkenwell Road
London
EC1R 5BL
Saffron Hill: 0207 693 8300
Direct Line: 0207 693 8318
-----Original Message-----
From: Karl Phillipson [mailto:Karl@SaffronHill.com]
Sent: 08 August 2001 15:30
To: 'Eduardo Kokubo'; php-general@lists.php.net
Subject: RE: [PHP] code to see files in directories
Try this
<?php
$level1 = 0;
$baseurl = "http://$HTTP_HOST";
$base = './';
$basedir = opendir("$base");
while ($file = readdir($basedir)){
if ($file != '.' && $file != '..' &&
eregi(".htm","$file"))
{ print("<a href=$baseurl/$file>$baseurl/$file</a><BR>\n");
flush();
}
if ($file != '.' && $file != '..' &&
is_dir("$base/$file")
&& $file != "_data")
{
$level1 = "$base/$file";
print("<a
href=$baseurl/$file>$baseurl/$file</a><BR>\n"); flush();
$seconddir = opendir("$level1");
while ($folder = readdir($seconddir))
{
if ($folder != '.' && $folder != '..' &&
eregi(".htm","$folder")){ print("<a
href=$baseurl/$file/$folder>$baseurl/$file/$folder</a><BR>\n");
flush();
}
if ($folder != '.' && $folder != '..' &&
is_dir("$base/$file/$folder") && $folder != "_data")
{
$level2 = "$level1/$folder";
print("<a
href=$baseurl/$file/$folder>$baseurl/$file/$folder</a><BR>\n");
flush();
$thirddir = opendir("$level2");
while ($this = readdir($thirddir)){
if ($this != '.' && $this != '..' &&
eregi(".htm","$this"))
{
print("<a
href=$baseurl/$file/$folder/$thibaseurl/$file/$folder/$this>$baseurl/$file/$
folder/$this</a><BR>\n");
flush();
}
if ($this != '.' && $this != '..' &&
is_dir("$base/$file/$folder/$this") && $this != "_data")
{
$level3 = "$level2/$this";
print("<a
href=$baseurl/$file/$folder/$this>$baseurl/$file/$folder/$this</a><BR>\n");
flush();
$forthdir = opendir("$level3");
while ($that = readdir($forthdir))
{
if ($that != '.' && $that != '..' &&
eregi(".htm","$that"))
{
print("<a
href=$baseurl/$file/$folder/$this/$that>$baseurl/$file/$folder/$this/$that</
a><BR>\n");
flush();
}
if ($that != '.' && $that != '..' &&
is_dir("$base/$file/$folder/$this/$that") && $that != "_data")
{
$level4 = "$level3/$that";
print("<a
href=$baseurl/$file/$folder/$this/$that>$baseurl/$file/$folder/$this/$that</
a><BR>\n");
flush();
$fithdir = opendir("$level4");
while ($some = readdir($fithdir)){
if ($some != '.' && $some != '..' &&
eregi(".htm","$some"))
{
print("<a
href=$baseurl/$file/$folder/$this/$that/$some>$baseurl/$file/$folder/$this/$
that/$some</a><BR>\n");
flush();
}
if ($some != '.' && $some != '..' &&
is_dir("$base/$file/$folder/$this/$that/$some") && $some != "_data")
{
$level5 = "$level4/$some";
print("<a
href=$baseurl/$file/$folder/$this/$that/$some>$baseurl/$file/$folder/$this/$
that/$some</a><BR>\n");
flush();
$sixthdir = opendir("$level5");
while ($the = readdir($sixthdir))
{
if ($the != '.' && $the != '..' &&
eregi(".htm","$the")){ print("<a
href=$baseurl/$file/$folder/$this/$that/$some/$this/$that/$some/$the>$baseur
l/$file/$folder/$this/$that/$some/$the</a><BR>\n");
flush();
}
if ($the != '.' && $the != '..' &&
is_dir("$base/$file/$folder/$this/$that/$some/$the") && $the != "_data")
{
$level6 = "$level5/$the";
print("<a
href=$baseurl/$file/$folder/$this/$that/$some/$the>$baseurl/$file/$folder/$t
his/$that/$some/$the</a><BR>\n");
flush();
$seventhdir = opendir("$level6");
while ($it = readdir($seventhdir))
{
if ($it != '.' && $it != '..' &&
eregi(".htm","$it")){ print("<a
href=$baseurl/$file/$folder/$this/$that/$some/$the/$it>$baseurl/$file/$folde
r/$this/$that/$some/$the/$it</a><BR>\n");
flush();
}
if ($it != '.' && $it != '..' &&
is_dir("$base/$file/$folder/$this/$that/$some/$the/$it") && $it !=
"_data")
{
$level7 = "$level6/$it";
print("<a
href=$baseurl/$file/$folder/$this/$that/$some/$the/$it>$baseurl/$file/$folde
r/$this/$that/$some/$the/$it</a><BR>\n"); flush();
$eighthdir = opendir("$level7");
while ($deep =
readdir($eighthdir)){
if ($deep1 != '.' && $deep1 != '..'
&& eregi(".htm","$deep1")){ print("<a
href=$baseurl/$file/$folder/$this/$that/$some/$the/$it/$deep1>$baseurl/$file
/$folder/$this/$that/$some/$the/$it/$deep1</a><BR>\n"); flush(); }
if ($deep1 != '.' && $deep1 != '..'
&& is_dir("$base/$file/$folder/$this/$that/$some/$the/$it/$deep1") &&
$deep1
!= "_data")
{
$level8 = "$level7/$deep1";
print("<a
href=$baseurl/$file/$folder/$this/$that/$some/$the/$it/$deep1>$baseurl/$file
/$folder/$this/$that/$some/$the/$it/$some/$the/$it/$deep1</a><BR>\n");
flush();
}}
}}
}}
}}
}}
}}
}}
}}
?>
==========================
Karl Phillipson
PHP SQL Programmer
Saffron Hill Ventures
67 Clerkenwell Road
London
EC1R 5BL
Saffron Hill: 0207 693 8300
Direct Line: 0207 693 8318
-----Original Message-----
From: Eduardo Kokubo [mailto:kokubo@inf.univali.br]
Sent: 08 August 2001 13:52
To: php-general@lists.php.net
Cc: Eduardo Kokubo
Subject: [PHP] code to see files in directories
I think I saw a code to list the files, subdirectories and the files in the
subdirectories of a simple directory in this list some time ago, but I
didn't save it. Considering the quantitie of messages in this list, It's
quite dificult to find this specific code, so ask the person who did it or
someone else to write this code again.
I'm using this one:
$publico = ftp_nlist ($servidor, "public_html/publico");
$cont = 0;
while ($publico[$cont]){
print "$publico[$cont]<br>";
$cont++;}
This code doesn't show the files in the subdirectories and it requires ftp
connection. Not very efficient.
Thanks in advance.
Is there a problem if I just write "thanks in advance"??? It's easier then
writting back to thanks everybody :)