php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18803 FTP function ftp_rawlist takes very long in some cases
Submitted: 2002-08-08 09:36 UTC Modified: 2002-08-10 09:30 UTC
From: dennisre at gmx dot de Assigned:
Status: Closed Package: FTP related
PHP Version: 4.2.2 OS: red hat 7.1
Private report: No CVE-ID: None
 [2002-08-08 09:36 UTC] dennisre at gmx dot de
My scripts contains this code. It should copy the $filename file to the $dest file on the FTP server, and then get a raw list of files in the current directory.

  $filename = "";
  $dest = "";
  $server = "";
  $user = "";
  $password = "";
  
  $ftp = @ftp_connect($server);
  @ftp_login($ftp, $user, $password);
  
  $tmpfile = tempnam("/tmp", "ftp");
  @ftp_get($ftp, $tmpfile, $filename, FTP_BINARY);
  @ftp_put($ftp, $dest, $tmpfile, FTP_BINARY);
  @unlink($tmpfile);
  $list = @ftp_rawlist($ftp, ".");
  @ftp_close($ftp);

When this script is executed, it takes about 5 minutes and the ftp_rawlist() function returns an empty list.
It should be completed in less then one second (FTP server was local when I tested). Also the return rawlist should not be empty.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-08 09:47 UTC] kalowsky@php.net
Unable to reproduce on OSX and FreeBSD 4.6.

You realize that your $list is never printed, correct?
 [2002-08-08 12:13 UTC] dennisre at gmx dot de
>You realize that your $list is never printed, correct?

Yes. The main problem is that it takes about 5 min to execute this code. When you try to reproduce, it is important that:
1) $filename file is a existing file
2) $dest file does not exist
3) the FTP login succeeds

also the OS is red hat 7.1 with proftpd 1.2.2
 [2002-08-08 12:38 UTC] kalowsky@php.net
Again, neither test platform for me fails on this test.

Can you try something other than ProFTPd?
 [2002-08-08 18:22 UTC] dennisre at gmx dot de
I have tested it with an IIS 5.0 FTP Server and it seams to work.
 [2002-08-08 18:46 UTC] dennisre at gmx dot de
Also the file I used for testing is 800KB in size. It took exactly 1 min 30 (seemed to me like 5 mins) with the local proftpd server. There is no problem with small files (15KB). Also after 1 min 30, ftp_rawlist returns a list with one entry, which is an empty string.
 [2002-08-09 00:29 UTC] kalowsky@php.net
yet again, unable to re-produce on any of my test machines.  Can someone with Linux try this as well?

And can you please try using a non-ProFTPd server?  Just curious if it's specific to ProFTP or not.
 [2002-08-09 10:14 UTC] dennisre at gmx dot de
I have tested it with an IIS 5.0 FTP Server and it seams to work.
 [2002-08-09 10:18 UTC] kalowsky@php.net
I can't reproduce this and you can't seem to on other machines.  I'm going to say this looks like a local user configuration issue, and not a PHP issue.  
 [2002-08-09 21:15 UTC] dennisre at gmx dot de
I am pretty sure that there is a problem with PHP. I was able to reproduce this on Windows 2000 if I use the local FTP server. It's the same with Red Hat 7.1. If I use the local FTP server it doesn't work, if I use an non-local FTP server it works.
 [2002-08-10 07:18 UTC] wez@php.net
If it is only a problem when using a local server, perhaps
you should check your DNS settings on that machine:
I suspect that your ftp server is trying to reverse map
the ip address of the machine running your script and that
is the cause of the delay.
There are two solutions: correct the DNS configuration, or
disable name resolution and reverse mapping in your ftp
server configuration.
 [2002-08-10 09:30 UTC] kalowsky@php.net
I have now tried this on 3 different architectures, all with local ftp servers, all downloading a 15MB file.  It takes mere seconds on each of them.

MacOSX 10.1.5
FreeBSD 4.6
Windows2000

I cannot reproduce either of these two problems on any of these architectures.  Thus I believe it is an end user configuration and not a PHP bug.   I've even been using your test script.   
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 12:01:30 2024 UTC