note 20782 modified in class.dir by goba
| From: | goba@php.net | Date: | Wed, 14 Aug 2002 21:23:59 +0000 |
| Subject: | note 20782 modified in class.dir by goba | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-35035@lists.php.net to get a copy of this message | ||
If the above function hits a recycle bin function it will throw some pretty funny errors
I used it like this in a windows based server . . the only problem is running it on a ROOT windows
directory
it looks cool in a Java pop up window
<html><head><title>Directory Listing</title></head>
<body bgcolor="#000000" text="#CCCCCC" link="#CCCCCC"
vlink="#CCCCCC" alink="#CCCCCC">
<table width="60%" border="0" cellspacing="0"
cellpadding="0" align="center" bgcolor="#006666">
<tr>
<td>
<div align="center"><font face="Arial, Helvetica, sans-serif"
size="2"><b>Directory
Listing</b></font></div>
</td>
</tr>
</table>
<?php
function getDirList ($dirName) {
$d = dir($dirName);
$dirName = strtoupper($dirName);
while($entry = $d->read()) {
if ($entry != "." && $entry != "..") {
if (is_dir($dirName."/".$entry." ")) {
getDirList($dirName."/".$entry);
}
else {
?>
<table width="60%" border="0" cellspacing="0"
cellpadding="0" align="center" bgcolor="#003366">
<tr>
<td>
<div align="left"><font color="#009999"> <a
href="<?php echo $dirName."/".$entry; ?>" target="_blank">
<font size="1" face="Arial, Helvetica, sans-serif">
<b><?php echo $dirName; ?>
</b></font> <font size="1" face="Arial, Helvetica,
sans-serif"><b><?php echo $entry;
?></b></font></a></font></div>
</td>
</tr>
</table>
<?php
}
}
}
$d->close();
}
getDirList(".");
?>
</body></html>
--was--
If the above function hits a recycle bin function it will throw some pretty funny errors
I used it like this in a windows based server . . the only problem is running it on a ROOT windows
directory
it looks cool in a Java pop up window
<html><head><title>Directory Listing</title></head>
<body bgcolor="#000000" text="#CCCCCC" link="#CCCCCC"
vlink="#CCCCCC" alink="#CCCCCC">
<table width="60%" border="0" cellspacing="0"
cellpadding="0" align="center" bgcolor="#006666">
<tr>
<td>
<div align="center"><font face="Arial, Helvetica, sans-serif"
size="2"><b>Directory
Listing</b></font></div>
</td>
</tr>
</table>
<?php
function getDirList ($dirName) {
$d = dir($dirName);
$dirName = strtoupper($dirName);
while($entry = $d->read()) {
if ($entry != "." && $entry != "..") {
if (is_dir($dirName."/".$entry." ")) {
getDirList($dirName."/".$entry);
}
else {
?>
<table width="60%" border="0" cellspacing="0"
cellpadding="0" align="center" bgcolor="#003366">
<tr>
<td>
<div align="left"><font color="#009999"> <a
href="<?php echo $dirName."/".$entry; ?>" target="_blank">
<font size="1" face="Arial, Helvetica, sans-serif">
<b><?php echo $dirName; ?>
</b></font> <font size="1" face="Arial, Helvetica,
sans-serif"><b><?php echo $entry;
?></b></font></a></font></div>
</td>
</tr>
</table>
<?php
}
}
}
$d->close();
}
getDirList(".");
?>
</body></html>
http://www.php.net/manual/en/class.dir.php