From 2bb2e4a43b30bd3a686106865c84786de42d50e8 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 22 Jul 2009 01:01:55 +0000 Subject: Do not try to enter passive mode before logging in. Return error if ftp_nlist() returned error. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9819 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_transfer.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/functions_transfer.php') diff --git a/phpBB/includes/functions_transfer.php b/phpBB/includes/functions_transfer.php index c345f81e1d..2146d5fa0b 100644 --- a/phpBB/includes/functions_transfer.php +++ b/phpBB/includes/functions_transfer.php @@ -316,15 +316,15 @@ class ftp extends transfer return 'ERR_CONNECTING_SERVER'; } - // attempt to turn pasv mode on - @ftp_pasv($this->connection, true); - // login to the server if (!@ftp_login($this->connection, $this->username, $this->password)) { return 'ERR_UNABLE_TO_LOGIN'; } + // attempt to turn pasv mode on + @ftp_pasv($this->connection, true); + // change to the root directory if (!$this->_chdir($this->root_path)) { @@ -462,6 +462,12 @@ class ftp extends transfer { $list = @ftp_nlist($this->connection, $dir); + // Return on error + if ($list === false) + { + return false; + } + // Remove path if prepended foreach ($list as $key => $item) { -- cgit v1.2.1 From 81e67fbef141ea47249b5f9d1a4e1cb34263b248 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 22 Jul 2009 01:26:09 +0000 Subject: Fix bug #46295 - Be less strict with FTP daemons when getting directory filelists. Authorised by: bantu ;-) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9820 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_transfer.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'phpBB/includes/functions_transfer.php') diff --git a/phpBB/includes/functions_transfer.php b/phpBB/includes/functions_transfer.php index 2146d5fa0b..c1211eda52 100644 --- a/phpBB/includes/functions_transfer.php +++ b/phpBB/includes/functions_transfer.php @@ -462,6 +462,14 @@ class ftp extends transfer { $list = @ftp_nlist($this->connection, $dir); + // See bug #46295 - Some FTP daemons don't like './' + if ($dir === './') + { + // Let's try some alternatives + $list = (empty($list)) ? @ftp_nlist($this->connection, '.') : $list; + $list = (empty($list)) ? @ftp_nlist($this->connection, '') : $list; + } + // Return on error if ($list === false) { -- cgit v1.2.1 From 2a84b76f3062a87c0069da1db2bdca83509882b1 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 22 Jul 2009 02:57:36 +0000 Subject: Fix two potential problems with the ftp_fsock class. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9821 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_transfer.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_transfer.php') diff --git a/phpBB/includes/functions_transfer.php b/phpBB/includes/functions_transfer.php index c1211eda52..7c5cd329a4 100644 --- a/phpBB/includes/functions_transfer.php +++ b/phpBB/includes/functions_transfer.php @@ -737,7 +737,12 @@ class ftp_fsock extends transfer $list = array(); while (!@feof($this->data_connection)) { - $list[] = preg_replace('#[\r\n]#', '', @fgets($this->data_connection, 512)); + $filename = preg_replace('#[\r\n]#', '', @fgets($this->data_connection, 512)); + + if ($filename !== '') + { + $list[] = $filename; + } } $this->_close_data_connection(); @@ -840,7 +845,7 @@ class ftp_fsock extends transfer $result = @fgets($this->connection, 512); $response .= $result; } - while (substr($response, 3, 1) != ' '); + while (substr($result, 3, 1) !== ' '); if (!preg_match('#^[123]#', $response)) { -- cgit v1.2.1 From 16e393b61d53843dfec3b88257925a0848c027ed Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 22 Jul 2009 03:02:45 +0000 Subject: Also fix bug #46295 in ftp_fsock class. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9822 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_transfer.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_transfer.php') diff --git a/phpBB/includes/functions_transfer.php b/phpBB/includes/functions_transfer.php index 7c5cd329a4..046abede8e 100644 --- a/phpBB/includes/functions_transfer.php +++ b/phpBB/includes/functions_transfer.php @@ -483,7 +483,7 @@ class ftp extends transfer $item = str_replace('\\', '/', $item); $dir = str_replace('\\', '/', $dir); - if (strpos($item, $dir) === 0) + if (!empty($dir) && strpos($item, $dir) === 0) { $item = substr($item, strlen($dir)); } @@ -749,6 +749,20 @@ class ftp_fsock extends transfer // Clear buffer $this->_check_command(); + // See bug #46295 - Some FTP daemons don't like './' + if ($dir === './' && empty($list)) + { + // Let's try some alternatives + $list = $this->_ls('.'); + + if (empty($list)) + { + $list = $this->_ls(''); + } + + return $list; + } + // Remove path if prepended foreach ($list as $key => $item) { @@ -756,7 +770,7 @@ class ftp_fsock extends transfer $item = str_replace('\\', '/', $item); $dir = str_replace('\\', '/', $dir); - if (strpos($item, $dir) === 0) + if (!empty($dir) && strpos($item, $dir) === 0) { $item = substr($item, strlen($dir)); } -- cgit v1.2.1