Hi,
I am currently working on creating an ftp indexer which I will end up using php-cli and run a cron job on the file/script to connect to a given list of ftp servers and index all files which will then be saved to database (mysql/postgresql).
I am testing this script using windows xp, wamp server (apache2, php5, etc.) as well as filezilla ftp server as my local ftp server. If any of you are familiar with filezilla by any chance, you should probably know that one could create mutiple shares for individual users and specify an alias for the given share as well.
I have tested and used the ftp_rawlist function (using the recursive flag as true) on ftp.saix.net which seems to work perfectly fine and return an array with all directories and files. However, when testing on my local ftp filezilla server I seem to be having a problem with the ftp_rawlist function listing all sub directories and files for an alias.
For example...
I have two shares in the filezilla sever settings for the user I am connecting with, one being the actual home directory and another music (which is an alias). The ftp_rawlist function returns all the files and directories from within the set home directory but does not recursively check the actual music alias and doesn't return any files and/or folders in the alias either.
Does any one have an idea of what the problem may be at all? Could it be a possible bug in PHP5 or would it have any effect from the ftp server itself not being compliant with the ftp_rawlist function (or vice-versa)?
Heres the current code I am testing with...
# Configuration directives
set_time_limit(10);
$aConfig = array();
// FTP server details
$aConfig['server'] = "192.168.1.104"; // FTP server
$aConfig['port'] = 21; // FTP server port
$aConfig['timeout'] = 3; // Connection timeout limit
// Login details
$aConfig['username'] = "username"; // Username
$aConfig['password'] = "password"; // Password
# Begin ftp connection and transaction
$rConnection = ftp_connect($aConfig['server'], $aConfig['port'], $aConfig['timeout']) or
die("Couldn't connect to ftp server...");
ftp_login($rConnection, $aConfig['username'], $aConfig['password']) or
die("Couldn't login to ftp server...");
$aRawList = ftp_rawlist($rConnection, '-al', true);
print_r($aRawList);
ftp_close($rConnection);
The current output returned after running the script...
Array
(
[0] => drwxr-xr-x 1 ftp ftp 0 Jul 19 17:22 music
[1] => drwxr-xr-x 1 ftp ftp 0 Jul 19 17:22 test
[2] => -r-xr-xr-x 1 ftp ftp 3228057 Jul 22 20:56 FileZilla_3.0.11.1_win32-setup.exe
[3] => -r-xr-xr-x 1 ftp ftp 2459088 Jul 22 20:53 FileZilla_Server-0_9_26.exe
[4] => -r-xr-xr-x 1 ftp ftp 35328 Jul 21 17:43 winbox.exe
[5] => -r-xr-xr-x 1 ftp ftp 1220952 Jul 22 19:32 XLight.exe
)
As you can see, music is actually recognized as a folder and is listed. However the contents (files & sub dirs for the music dir/alias) are not displayed and returned in the $aRawList variable.
Note...
If I specify the actual music alias in the ftp_rawlist function then it does return all of the files in the alias directory but not the sub-folders. Idealy, I would like the ftp_rawlist to return a list of all files and directories for alias directories recursively (as with default directories) from the root directory.
Example...
$aRawList = @ftp_rawlist($rConnection, "music/", true);
Any help and/or advice would be much appreciated.