View Single Post
Old September 14th, 2004, 7:18 AM   #1 (permalink)
Dima
Registered User
Seasoned Poster
 
Dima's Avatar
 
Joined in Sep 2004
43 posts
Gave thanks: 0
Thanked 0 times
PHP Director Lister

Hi all, I need a directory lister for my site... it would be best if the lister can actually connect to the FTP!


I have a code but it doesnt suit me much because it doesnt show me FILE SIZE and TIME STAMP

Here's the code:

PHP Code:
<?php
$ip     
'ftp.domain.com';
$user   'access[at]domain.com';
$pass   'password';
$port   '21';
$path   "";

function 
listDir($dir,$ftp)
{
    echo 
$dir;
    
ftp_pasv($ftp,true);
    
ftp_chdir($ftp,$dir);
    
$list ftp_rawlist($ftp,".");
    foreach(
$list as $item)
    {
        
ereg("([-d])([rwxst-]{9}).* ([0-9]*) ([a-zA-Z]+[0-9: ]* [0-9]{2}:?[0-9]{2}) (.+)"$item$matches);   
             
        if (
$matches[1] == 'd'
        {   
            
listDir($dir.'/'.$matches[5],$ftp);
        }
        else
        {
echo 
'<dd>'.$matches[5].'</dd>';
        }
        
flush();
    }
}

$ftp ftp_connect($ip,$port);
ftp_login($ftp,$user,$pass);

echo 
'<dl>';
listDir($path,$ftp);
echo 
'</dl>';
?>
Thank you in advance
__________________

Last edited by Dima; September 14th, 2004 at 7:20 AM..
Dima is offline   Reply With Quote