Changeset 702 for trunk/forum/includes/functions_transfer.php
- Timestamp:
- Mar 31, 2010, 6:32:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/forum/includes/functions_transfer.php
r400 r702 3 3 * 4 4 * @package phpBB3 5 * @version $Id : functions_transfer.php 8479 2008-03-29 00:22:48Z naderman$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 207 207 208 208 $this->_chdir($directory); 209 $result = $this->_ls( '');209 $result = $this->_ls(); 210 210 211 211 if ($result !== false && is_array($result)) … … 317 317 } 318 318 319 // login to the server 320 if (!@ftp_login($this->connection, $this->username, $this->password)) 321 { 322 return 'ERR_UNABLE_TO_LOGIN'; 323 } 324 319 325 // attempt to turn pasv mode on 320 326 @ftp_pasv($this->connection, true); 321 322 // login to the server323 if (!@ftp_login($this->connection, $this->username, $this->password))324 {325 return 'ERR_UNABLE_TO_LOGIN';326 }327 327 328 328 // change to the root directory … … 461 461 function _ls($dir = './') 462 462 { 463 return @ftp_nlist($this->connection, $dir); 463 $list = @ftp_nlist($this->connection, $dir); 464 465 // See bug #46295 - Some FTP daemons don't like './' 466 if ($dir === './') 467 { 468 // Let's try some alternatives 469 $list = (empty($list)) ? @ftp_nlist($this->connection, '.') : $list; 470 $list = (empty($list)) ? @ftp_nlist($this->connection, '') : $list; 471 } 472 473 // Return on error 474 if ($list === false) 475 { 476 return false; 477 } 478 479 // Remove path if prepended 480 foreach ($list as $key => $item) 481 { 482 // Use same separator for item and dir 483 $item = str_replace('\\', '/', $item); 484 $dir = str_replace('\\', '/', $dir); 485 486 if (!empty($dir) && strpos($item, $dir) === 0) 487 { 488 $item = substr($item, strlen($dir)); 489 } 490 491 $list[$key] = $item; 492 } 493 494 return $list; 464 495 } 465 496 … … 707 738 while (!@feof($this->data_connection)) 708 739 { 709 $list[] = preg_replace('#[\r\n]#', '', @fgets($this->data_connection, 512)); 740 $filename = preg_replace('#[\r\n]#', '', @fgets($this->data_connection, 512)); 741 742 if ($filename !== '') 743 { 744 $list[] = $filename; 745 } 710 746 } 711 747 $this->_close_data_connection(); 748 749 // Clear buffer 750 $this->_check_command(); 751 752 // See bug #46295 - Some FTP daemons don't like './' 753 if ($dir === './' && empty($list)) 754 { 755 // Let's try some alternatives 756 $list = $this->_ls('.'); 757 758 if (empty($list)) 759 { 760 $list = $this->_ls(''); 761 } 762 763 return $list; 764 } 765 766 // Remove path if prepended 767 foreach ($list as $key => $item) 768 { 769 // Use same separator for item and dir 770 $item = str_replace('\\', '/', $item); 771 $dir = str_replace('\\', '/', $dir); 772 773 if (!empty($dir) && strpos($item, $dir) === 0) 774 { 775 $item = substr($item, strlen($dir)); 776 } 777 778 $list[$key] = $item; 779 } 712 780 713 781 return $list; … … 792 860 $response .= $result; 793 861 } 794 while (substr($res ponse, 3, 1) != ' ');862 while (substr($result, 3, 1) !== ' '); 795 863 796 864 if (!preg_match('#^[123]#', $response))
Note:
See TracChangeset
for help on using the changeset viewer.