note 43688 deleted from function.readdir by tomsommer
| From: | tomsommer@php.net | Date: | Wed, 30 Jun 2004 14:25:56 +0000 |
| Subject: | note 43688 deleted from function.readdir by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72174@lists.php.net to get a copy of this message | ||
Note Submitter: g.ionescu@gmail.com
----
Simple recursive directory browsing:
<?php
function fdirlist( $ppath )
{
chdir($ppath); $cdir=getcwd();
print '<font
color="red"><b>'.$cdir.'</b></font><br>';
if ($handle = opendir($ppath)) {
while ( $file = readdir($handle) ) /* directory listing first */
{
$ffile=$cdir.'/'.$file;
if ( is_dir($ffile) )
{ echo '<a
href="'.$_SERVER['PHP_SELF'].'?calea='.$ffile.'/"><font
color="blue"><b>'.strtoupper($file).'</a></b></font>
<br>'; }
}
}
closedir($handle);
if ($handle = opendir($ppath)) /* files list */
{
while ( $file = readdir($handle) )
{
$ffile=$cdir.'/'.$file;
if ( is_file($ffile) )
{ echo '<font
color="blue">'.strtolower($file).'</font><br>'; }
}
}
closedir($handle);
}
$ppath=getcwd();
if ( !is_null($_REQUEST['calea']) )
{
$ppath=$_REQUEST['calea'];
}
fdirlist($ppath);
?>