Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.4.1

Bug #263 Net_FTP listing errors
Submitted: 2003-11-17 03:22 UTC
From: mattias dot guns at student dot kuleuven dot ac dot be Assigned: toby
Status: Closed Package: Net_FTP
PHP Version: 4.3.2 OS: Linux
Roadmaps: (Not assigned)    

 [2003-11-17 03:22 UTC] mattias dot guns at student dot kuleuven dot ac dot be
Description: ------------ When you use the Net_FTP package to connect to an ftp server, and you ask for a listing [$ftp->ls($dir)] This will fail with error: Raw directory-list in wrong format. if one of the directory's in this listing has a 'sticky bit' Because the defined constant 'NET_FTP_DIR_EREG' is not set up in a way to recognize the letter 's' in the representation of the properties of a dir (dwrxr-s---) And apparently there can be a 't' in there too... [that's all i know about] The following line (line 11 in Net_FTP 1.2): define("NET_FTP_DIR_EREG", "([-dl])([rwx-]{9})[ ]*([0-9]*)[ ]*([a-zA-Z0-9_-]*)[ ]*([a-zA-Z0-9_-]*)[ ]*([0-9]*)[ ]*([A-Za-z]+ [0-9: ]*) (.+)", true); should be changed to: define("NET_FTP_DIR_EREG", "([-dl])([rwxst-]{9})[ ]*([0-9]*)[ ]*([a-zA-Z0-9_-]*)[ ]*([a-zA-Z0-9_-]*)[ ]*([0-9]*)[ ]*([A-Za-z]+ [0-9: ]*) (.+)", true); (notice the change from [rwx-] to [rwxst-] ) Once this is fixed, it will still fail, because the server first sais 'total <nr>' before it starts listing.. Net_FTP sees this and stops with an error.. If you look at line 926 and following, u see the problem, it is fixed by adding following 3 lines: //if server prepends with 'total <nr>' shift it of if (substr($dir_list[0], 0, 6) == 'total ') array_shift($dir_list); <after which starts the foreach> foreach ($dir_list as $entry) { u can get the 2 in one patch at: Reproduce code: --------------- $ftp = new Net_FTP('', '21'); $ftp->connect(); $ftp->login('anon', 'ymous'); print_r($ftp->ls()); Expected result: ---------------- the listing of the ftp server: (too much to paste) Actual result: -------------- 's' sticky bit problem: (from another server:) string(56) "drwxrwsr-x 8 ftpadm ftpadm 280 Aug 24 12:07 ." Raw directory-list in wrong format. 't' bit problem: string(63) "d-wx-wx-wt 3 BELNET Archive 512 Nov 17 03:13 incoming" Raw directory-list in wrong format. 'total' problem: string(8) "total 45" Raw directory-list in wrong format.


 [2003-11-28 12:51 UTC] bs at hi dot is
The bits 'S' and 'T' are bits that have to be considered too.
 [2003-11-28 12:57 UTC] toby
Is this a windows or *nix FTP server you connect to? Which FTP server software is used?
 [2004-01-05 23:04 UTC] toby
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on In case this was a website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better.