tags:

views:

18

answers:

1

Alright well, I connect to 3 different ip's when I run this script.

It copys files from directorys and downloads them to the website.

I'm having a slight problem with two of them ip's...

I have turned on ftp passive but it still seems to come back as bool(false)

Updating server 1
bool(false) 
Warning: ftp_get() [function.ftp-get]: Filename cannot be empty in updater.php on line     42

Warning: ftp_get() [function.ftp-get]: Error opening in updater.php on line 42
Updated cache...
bool(false) 
Warning: ftp_get() [function.ftp-get]: Filename cannot be empty in updater.php on line     60

Warning: ftp_get() [function.ftp-get]: Error opening in updater.php on line 60
BZh9rE8PUpdated maps...
Updating server 2
bool(false) 
Warning: ftp_get() [function.ftp-get]: Filename cannot be empty in updater.php on line     103

Warning: ftp_get() [function.ftp-get]: Error opening in updater.php on line 103
Updated cache...
bool(false) 
Warning: ftp_get() [function.ftp-get]: Filename cannot be empty in updater.php on line     121

Warning: ftp_get() [function.ftp-get]: Error opening in updater.php on line 121
BZh9rE8PUpdated maps...
Updating server 3
array(1) { [0]=> string(36) "1ba90fa2e972b50cdaa6bb23c403296b.dua" } Updated cache...
array(8) { [0]=> string(6) "graphs" [1]=> string(22) "sb_Forlorn_sb3_R2L.bsp" [2]=>     string(17) "sb_gooniverse.bsp" [3]=> string(22) "sb_lostinspace_rc5.bsp" [4]=> string(19)     "sb_new_worlds_2.bsp" [5]=> string(22) "sb_Spacewar_SB3_V1.bsp" [6]=> string(21)     "sb_twinsuns_fixed.bsp" [7]=> string(10) "soundcache" } Updated maps...

. Part of the script:

ftp_pasv($conn, true); 
ftp_chdir($conn,"$DIR/maps/"); 

$files = ftp_nlist($conn,"*.*"); 
var_dump($files);

chdir('sandbox/cache/');

for($i=0;$i<count($files);$i++){ 
    if(!ftp_is_dir($files[$i])){
        usleep(500000); 
        if(!file_exists($files[$i])){
            ftp_get($conn,$files[$i],$files[$i],FTP_ASCII); 
        }
    }
} 

echo "Updated cache...<br />";
A: 

You are not using ftp_nlist() correctly.

The manual for ftp_nlist() specifies the second argument to be a directory name (represented by a string). It looks as if you are instead trying to denote a filename pattern.

Your code is using:

$files = ftp_nlist($conn,"*.*"); 

Unless you do have a directory named *.* this will not work.

You should replace *.* with a valid directory name relative to the FTP user's home directory.

For example:

$files = ftp_nlist($conn, ".");

will list files in the current directory, which is likely to be $DIR/maps/ with respect to your example code.

You may also need to switch to FTP passive mode to cope with firewall issues between the host from which your script is running and the FTP host. Refer to the manual for ftp_pasv() for details.

Jon Cram