php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8874 ftp_nlist and rawlist not working
Submitted: 2001-01-23 22:23 UTC Modified: 2001-08-16 18:37 UTC
From: steve at szabos dot com Assigned:
Status: Closed Package: FTP related
PHP Version: 4.0.4 OS: Windows 2000 Advanced Server
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: steve at szabos dot com
New email:
PHP Version: OS:

 

 [2001-01-23 22:23 UTC] steve at szabos dot com
The ftp_nlist and ftp_rawlist functions failed to work for me.  I am using PHP.EXE v4.0.4 from a Windows 2000 machine connecting to a Free BSD box running the following FTP server:

Our.ftp.server FTP server (Version wu-2.6.1(1) Mon Jul 3 03:07:01 EDT 2000)

Both ftp_nlist and ftp_rawlist return a single blank string ("") into the result array.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-07-21 21:27 UTC] andy@php.net
Please submit a short script for me the analyze.  This will
also clarify your bug a little bit.
 [2001-07-22 00:23 UTC] steve at szabos dot com
Thanks for responding.  I no longer have access to the FreeBSD FTP server that I was connecting to, so it is no longer an issue (for me).  My script is attached below.   If you do see an issue with the code, I am still interested in your response.

<?
$bDebug = 1;

$aDomain = array (
   "xyz.com", "z"
   );

if ($bDebug)
  echo "Number in array =" . count ($aDomain) . "<BR>";

for ( $i=0; $i < count ($aDomain) ; )
  {
  
  if ( $bDebug )
    echo "Openning \"" . $aDomain[$i] . "\"...<BR>";

  $nFTP = ftp_connect ( $aDomain[$i] );

  if ( $nFTP == 0 )
    {
    echo "Failed to open $aDomain[$i]. Aborting...<BR>";
    exit();
    }

  $nResult = ftp_login ( $nFTP, $aDomain[$i+1], "password" );
  if ( $nResult == 0 )
    {
    echo "Failed to login to $aDomain[$i]. Aborting...<BR>";
    exit();
    }
  else
    echo "Login to $aDomain[$i] succeeded.<BR>";

  if ( $bDebug)
    echo "<BR>ftp_pwd=" . ftp_pwd ( $nFTP ) . "<BR>".

  $nResult = ftp_chdir ( $nFTP, "logs");
  if ( $nResult == 0)
    {
    echo "ftp_chdir failed.  Aborting...<BR>";
    exit();
    }

  if ( $bDebug)
    echo "<BR>ftp_pwd=" . ftp_pwd ( $nFTP ) . "<BR>".

  $aFiles = Array( "Oct100.log.gz",
                   "Nov100.log.gz",
                   "Dec100.log.gz",
                   "mtd.log");

  // $aFiles = ftp_rawlist ( $nFTP, "/mnt/web/guide/accumeddata/logs/*.gz");
  // echo "rawlist = " . count ( $aFileList ) . "<BR>";
  // $aFiles = ftp_nlist ( $nFTP, "*.gz");

  if ( $bDebug )
    {
    echo "count(aFiles)=" . count ($aFiles ) . "<BR>";
    for ( $j=0; $j <= count($aFiles); $j++ )
      echo "$j=\"$aFiles[$j]\"<BR>"; 
    }

  // Get all the Monthly archives (*.GZ)
  for ( $j=0; $j < count($aFiles); $j++ )
    {

    $sLocalFile = $aDomain[$i] . "-" . $aFiles[$j];
    $sLocalFile = str_replace ( "/", "-", $sLocalFile );
    $sRemoteFile = $aFiles[$j];

    if ( $bDebug)
      {
      echo "sLocalFile=\"$sLocalFile\"<BR>";
      echo "sRemoteFile=\"$sRemoteFile\"<BR>";
      }    

    $nResult = ftp_get ( $nFTP, $sLocalFile, $sRemoteFile, FTP_BINARY );

    if ( $nResult == 0)   
      {
      echo "ftp_get failed.  Aborting...";
      exit();
      }
    }

  // Get the current month also.
  $nResult = ftp_get ( $nFTP, $sLocalFile, "mtd.log", FTP_BINARY );

  if ( $nResult == 0)   
    {
    echo "ftp_get of mtd.log failed.  Aborting...";
    exit();
    }

  $nResult = ftp_quit ( $nFTP );
  if ( $nResult == 0 )   
    {
    echo "ftp_quit failed.  Aborting...";
    exit();
    }

  $i = $i + 2;
  }


?>
 [2001-08-14 20:10 UTC] jmoore@php.net
can you provide a smaller script that produces the bug please. preferably less than ten lines of code which requires nothing other than the bare min.. IE no extenal files etc.
 [2001-08-14 21:07 UTC] steve at szabos dot com
$aFiles = Array( "Oct100.log.gz", "Nov100.log.gz");

// $aFiles = ftp_rawlist  (nFTP, "/mnt/web/guide/accumeddata/logs/*.gz");

$aFiles = ftp_nlist ( $nFTP, "*.gz");

echo "count(aFiles)=" . count ($aFiles ) . "<BR>";


 [2001-08-15 02:07 UTC] sniper@php.net
This bug report was for PHP 4.0.4. There have been a few
changes since that in PHP 4.0.6. Have you tried with it?

And also, these functions do work on most ftp servers. What was the version of the ftp server on which this didn't work?

--Jani

 [2001-08-16 00:26 UTC] steve at szabos dot com
Per my previous message, I no longer have access to the FreeBSD server to try it.
 [2001-08-16 18:37 UTC] sniper@php.net
I must be blind. :) The ftp server information was
in the first comment of yours: wu-2.6.1

I installed this same ftp server to my machine and 
tried with this script:

<?php
  
$conn_id = ftp_connect("localhost");
$login_result = ftp_login($conn_id, "username", "pass");

$rawlist = ftp_rawlist($conn_id,"*.gz");
$nlist   = ftp_nlist($conn_id,"*.gz");
         
ftp_quit($conn_id); 
         
print_r($rawlist);
print_r($nlist);

?>        

And this worked just fine.
So closed. Reopen if you can reproduce this some time.

--Jani

 [2002-03-20 19:37 UTC] ryan at wonko dot com
This bug *is* present in 4.1.1 and 4.1.2, and I've confirmed it personally. This issue needs to be re-opened. I've submitted another bug report about it (http://bugs.php.net/bug.php?id=16057) but it doesn't seem to be getting any attention. This is a *major* blocker for Win32 developers.

Here's a short test script that works fine on UNIX builds but fails on Windows:

<?php
$conn = ftp_connect("ftp.kernel.org");
ftp_login($conn, "anonymous", "anon@anon.com");
$nlist = ftp_nlist($conn, "");
$rawlist = ftp_rawlist($conn, "");

echo "<pre>";
print_r($nlist);
print_r($rawlist);
echo "</pre>";
?>
 [2004-09-28 20:44 UTC] pcatlin at plus dot com
Took a while but have now figured out a work around for this VERY annoying little problem.

PHP or IIS tries to write a temporary file, but NOT in the c:\windows\temp folder.  It writes this file in the C:\ root.  With permissions set to allow which ever user PHP is running as access to write this file, ftp_nlist will work.

It tries to write a file called c:\t3lo

Hope this is useful to other people stuck on this. :)
 [2015-07-13 19:45 UTC] katiaella at aol dot com
I don't know where else to post this, but would someone please tell me what is going on with 1Freehosting.com? When I go to their cpanel, their FTP installer isn't working and neither is the File Manager2, which is how I got here. I bought a hosting package with them on February, my website showed up fine on the internet, but now when I go to it, my website only shows "Account Unavailable." This has been going on for over a week. So, basically I got only five months of service from them. I've sent them three messages to which none have been answered. I've gone to Facebook tried contacting them there and still nothing from them. Can anyone give me an insight? Thank you.

-Ella
 [2015-10-28 09:30 UTC] johnson990999 at gmail dot com
Im having a problem using FTP Its not letting me manage any of my files. i tried to use the FTP Client and nothing happened said that Webhosting refused to connect?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 06:01:30 2024 UTC