From:             [EMAIL PROTECTED]
Operating system: MS Windows XP Pro
PHP version:      4.3.0RC1
PHP Bug Type:     FTP related
Bug description:  fopen with ftp URL returns false despite ftp server executes get

fopen with ftp URL returns false despite ftp server executes get

Tested in loopback with IP 127.0.0.1 and BulletProof ftp server running on
the same machine.
Note, in the server log pasted here below, that the ftp client seems to be
quitting the
connection before the transfer is complete.

Used PHP version: php-4.3.0RC1-Win32.zip
OS.: Microsoft Windows XP Professional 2002

php.ini was a copy of php.ini-recommended with only
following modif.:
extension_dir = C:\PHP
cgi.force_redirect = 0 

============  My PHP program ======================

<?php

$FTPStr = ftp_connect('127.0.0.1');
ftp_login($FTPStr,'anonymous','');
$FileNames = ftp_nlist($FTPStr,'pub/*.txt');
ftp_quit($FTPStr);
foreach ($FileNames as $Current) {
  printf("%s\n",$Current);
}

if (!($File = fopen ('ftp://anonymous:@127.0.0.1/pub/short.txt','r'))) {
  printf("Cant't open file\n");
  return;
}
$Count = 1;
while (!feof ($File)) {
  $line = fgets ($File, 1024);
  printf("%d %s\n",$Count,$line);
  $Count += 1;
}
fclose($File);

?>

============ Running the program

C:\PHP>php -f c:\inetpub\wwwroot\ftp_ls_and_wrap_fopen.php
PHP Warning:  fopen() [http://www.php.net/function.fopen]:
php_hostconnect: conn
ect failed in c:\inetpub\wwwroot\ftp_ls_and_wrap_fopen.php on line 11
PHP Warning:  fopen(ftp:[EMAIL PROTECTED]/pub/short.txt)
[http://www.php.net/funct
ion.fopen]: failed to create stream: FTP server reports 227 Entering
Passive Mod
e (127.0.0.1 in c:\inetpub\wwwroot\ftp_ls_and_wrap_fopen.php on line 11
dummy1.txt
dummy2.txt
short.txt
Cant't open file

================ (Pasted) log from BulletProof FTP Server v2.15
========================

21/11/2002 00:33:59 - FTP Server On-line : IP(s) 192.168.1.34, on port 21
(000001) 21/11/2002 00:34:07 - (not logged in) (127.0.0.1) > connected to
ip : 127.0.0.1
(000001) 21/11/2002 00:34:07 - (not logged in) (127.0.0.1) > sending
welcome message.
(000001) 21/11/2002 00:34:07 - (not logged in) (127.0.0.1) > 220
BulletProof FTP Server ready ...
(000001) 21/11/2002 00:34:07 - (not logged in) (127.0.0.1) > USER
anonymous
(000001) 21/11/2002 00:34:07 - (not logged in) (127.0.0.1) > 331 Password
required for anonymous.
(000001) 21/11/2002 00:34:07 - (not logged in) (127.0.0.1) > PASS
********
(000001) 21/11/2002 00:34:07 - anonymous (127.0.0.1) > logged in.
(000001) 21/11/2002 00:34:07 - anonymous (127.0.0.1) > 230 User anonymous
logged in.
(000001) 21/11/2002 00:34:07 - anonymous (127.0.0.1) > PORT
127,0,0,1,10,77
(000001) 21/11/2002 00:34:07 - anonymous (127.0.0.1) > 200 Port command
successful.
(000001) 21/11/2002 00:34:07 - anonymous (127.0.0.1) > NLST pub/*.txt
(000001) 21/11/2002 00:34:07 - anonymous (127.0.0.1) > 150 Opening data
connection for directory list.
(000001) 21/11/2002 00:34:07 - anonymous (127.0.0.1) > 226 Transfer ok
(000001) 21/11/2002 00:34:07 - anonymous (127.0.0.1) > disconnected.
(00:00:00)
(000002) 21/11/2002 00:34:07 - (not logged in) (127.0.0.1) > connected to
ip : 127.0.0.1
(000002) 21/11/2002 00:34:07 - (not logged in) (127.0.0.1) > sending
welcome message.
(000002) 21/11/2002 00:34:07 - (not logged in) (127.0.0.1) > 220
BulletProof FTP Server ready ...
(000002) 21/11/2002 00:34:07 - (not logged in) (127.0.0.1) > USER
anonymous
(000002) 21/11/2002 00:34:07 - (not logged in) (127.0.0.1) > 331 Password
required for anonymous.
(000002) 21/11/2002 00:34:07 - (not logged in) (127.0.0.1) > PASS
********
(000002) 21/11/2002 00:34:07 - anonymous (127.0.0.1) > logged in.
(000002) 21/11/2002 00:34:07 - anonymous (127.0.0.1) > 230 User anonymous
logged in.
(000002) 21/11/2002 00:34:07 - anonymous (127.0.0.1) > TYPE I
(000002) 21/11/2002 00:34:07 - anonymous (127.0.0.1) > 200 Type set to I.
(000002) 21/11/2002 00:34:07 - anonymous (127.0.0.1) > SIZE
/pub/short.txt
(000002) 21/11/2002 00:34:07 - anonymous (127.0.0.1) > 213 24
(000002) 21/11/2002 00:34:07 - anonymous (127.0.0.1) > EPSV 
(000002) 21/11/2002 00:34:07 - anonymous (127.0.0.1) > 500 Unknown
command.
(000002) 21/11/2002 00:34:07 - anonymous (127.0.0.1) > PASV 
(000002) 21/11/2002 00:34:07 - anonymous (127.0.0.1) > 227 Entering
Passive Mode (127,0,0,1,82,146).
(000002) 21/11/2002 00:34:07 - anonymous (127.0.0.1) > RETR
/pub/short.txt
(000002) 21/11/2002 00:34:07 - anonymous (127.0.0.1) > asked to download
'E:\FTPdir\pub\short.txt' --> 

Access allowed.
(000002) 21/11/2002 00:34:07 - anonymous (127.0.0.1) > QUIT 
(000002) 21/11/2002 00:34:07 - anonymous (127.0.0.1) > 221 Bye bye ...
(000002) 21/11/2002 00:34:07 - anonymous (127.0.0.1) > finished
downloading 'E:\FTPdir\pub\short.txt' -  

(00:34:08 - 0.000 KB - 0.000 KBytes/s)
(000002) 21/11/2002 00:34:07 - anonymous (127.0.0.1) > 226 Transfer ok
(000002) 21/11/2002 00:34:07 - anonymous (127.0.0.1) > disconnected.
(00:00:00)


==================== with the basic ftp client of Windows, "get" works and
file is not empty...

C:\PHP>ftp 127.0.0.1
Connected to 127.0.0.1.
220 BulletProof FTP Server ready ...
User (127.0.0.1:(none)): anonymous
331 Password required for anonymous.
Password:
230 User anonymous logged in.
ftp> ls /pub/*.txt
200 Port command successful.
150 Opening data connection for directory list.
dummy1.txt
dummy2.txt
short.txt
226 Transfer ok
ftp: 35 bytes received in 0.00Seconds 35000.00Kbytes/sec.
ftp> get /pub/short.txt
200 Port command successful.
150 Opening data connection for short.txt (24 bytes).
226 Transfer ok
ftp: 24 bytes received in 0.00Seconds 24000.00Kbytes/sec.
ftp> disconnect
221 Bye bye ...
ftp> bye

C:\PHP>type short.txt
Pippo
Pluto
Paperino

C:\PHP>
-- 
Edit bug report at http://bugs.php.net/?id=20526&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=20526&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=20526&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=20526&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=20526&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=20526&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=20526&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=20526&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=20526&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=20526&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=20526&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20526&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=20526&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=20526&r=isapi

Reply via email to