php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41352 Warning: ftp_get() PORT command successful
Submitted: 2007-05-10 13:06 UTC Modified: 2007-06-07 07:33 UTC
Votes:2
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: guy dot vleugels at kaneka dot be Assigned:
Status: Closed Package: FTP related
PHP Version: 5.2.2 OS: RH9
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: guy dot vleugels at kaneka dot be
New email:
PHP Version: OS:

 

 [2007-05-10 13:06 UTC] guy dot vleugels at kaneka dot be
Description:
------------
After upgrading to PHP 5.2.2 on my RH9-machine the following error warning occurs on post-script files using ftp_get:

Warning: ftp_get() [function.ftp-get]: PORT command successful

As a result, the post-script file won't be downloaded to my machine.

If I do a downgrade to < PHP5.2.2, everything works perfectly.

Reproduce code:
---------------
	$ftpcnn = ftp_connect("ftp-server", "4559");
	
	// login with username and password
	$ftprs = ftp_login($ftpcnn, "user", "passwd");
	
	// check connection
	if( (!$ftpcnn) || (!$ftprs) )
	{
		echo "FTP connection has failed!<br />";
		exit;
	}
	
	
	// Firstly download txt-file
	ftp_get( $ftpcnn, "/mydir/txtfile", "/ftpdir/txtfileonftp", FTP_BINARY );
	
	// ---- Do some extra stuff -----------------------
	// Get the name of the postscript-file
	$lines = file( "mydir/txtfile" );

	foreach( $lines as $line )
	{
		if( strstr($line, "!postscript") !== FALSE )	// ea. $line = "!postscript:0::docq/doc1764.ps"
		{
			$temp = explode( ":", $line );
			
			$psfile = $temp[3];
		}
	}
	// --- End some extra stuff -------------------


	// Code which causes the warning:
	// Warning: ftp_get() [function.ftp-get]: PORT command successful.

	// Download the ps file
	ftp_get( $ftpcnn, "/mydir/psfile", $psfile, FTP_BINARY ); 
	
	// close the connection
	ftp_close( $ftpcnn );

Expected result:
----------------
// Downloading of a file specified by arguments in ftp_get()

Actual result:
--------------
Warning: ftp_get() [function.ftp-get]: PORT command successful

File won't be downloaded

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-10 20:13 UTC] tony2001@php.net
Where can we reproduce it?
 [2007-05-11 06:00 UTC] guy dot vleugels at kaneka dot be
To be honest, there is no real location to reproduce this possible bug, because the website is only on our companie's intranet.
 [2007-05-11 08:06 UTC] tony2001@php.net
Is there a public FTP server (or is it possible to create one) which demonstrates the same problem?
 [2007-05-11 09:15 UTC] guy dot vleugels at kaneka dot be
This should be a working example with existing files on our ftp-server.
It reproduces the possible bug.

Please change "<aCertainDirectory>" with a directory which is writable for you php-user.

// ---------------------------------------------------------------

	// ftp connection
	$ftpcnn = ftp_connect("ftp.kaneka.be", "21");
	
	// login with username and password
	$ftprs = ftp_login($ftpcnn, "anonymous", "myemailaddress");
	
	// check connection
	if( (!$ftpcnn) || (!$ftprs) )
	{
		echo "FTP connection has failed!<br />";
		echo "Attempted to connect to the build-in ftp server of Hylafax!";
		exit;
	}
	
	
	// Download q-file which contains name of ps-file
	ftp_get( $ftpcnn, "<aCertainDirectory>/q1950", "/pub/q1950", FTP_ASCII );

	// Get the name of the postscript-file which contains the actual document data
	$lines = file( "<aCertainDirectory>/q1950" );	// file ? Reads entire file into an array
	
	
	foreach( $lines as $line )
	{
		if( strstr($line, "!postscript") !== FALSE )	// ea. $line = "!postscript:0::docxxxx.ps"
		{
			$temp = explode( ":", $line );
			
			$psfile = $temp[3];
			
			echo $psfile;
		}
	}	
	
	
	// Download the ps file 
	ftp_get( $ftpcnn, "<aCertainDirectory>/$psfile", "/pub/$psfile", FTP_ASCII ); // ftp_get() retrieves a remote file from the FTP server, and saves it into a local file.
	
	
	// close the connection
	ftp_close( $ftpcnn );

// ---------------------------------------------------------
 [2007-05-11 11:26 UTC] tony2001@php.net
The server is in passive mode, so your starts working fine as soon as I add ftp_pasv($ftpcnn, true);.

 [2007-05-19 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2007-05-23 09:39 UTC] tobylewis at logogriph dot com
Running PHP 5.0.4 (from www.entropy.ch) on Mac OS X 10.4.9

I am also seeing this error but on just about all ftp commands.

I suspect some ftp servers return a status string "PORT command successful" which php is passing along as a warning but since this message is not intended as a warning it is annoying to receive the "error".  Trying to block the unwanted error with the at symbol is not ideal since that would deflect genuine errors too.
 [2007-06-07 07:33 UTC] guy dot vleugels at kaneka dot be
I've found what seemed to be the problem.

When a text-file is downloaded through the ftp_get()-function and the file is loaded into an array using the file()-function, the separate lines of the array aren't trimmed by default (so you have to use the trim()-function on each line of the array).

So this isn't a bug, but only a behaviour change of the file()-function or the ftp_get()-function as of PHP > 5.2.1
 [2011-07-31 14:38 UTC] fijo dot com at googlemail dot com
> Is there a public FTP server (or is it possible to create one) which 
demonstrates the same problem?

I got this problem while using my ftp-server on funpic.de

Thats a free hosting service (so you can use it to reproduce that exeption) from 
that it produces those errors for me, too.

XAMPP 1.7.4; PHP 5.3.5; linux
 [2011-07-31 14:44 UTC] fijo dot com at googlemail dot com
2 my last comment - it works fine using pasive mode and it takes mutch shorter 
(nonpassive: ~ 90sec+ ; passive: ~ 5sec - same operation - note, that nonpassive 
is not sucessfull)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Apr 19 15:01:27 2025 UTC