FTP CWD fixes from DD32. see #6245

git-svn-id: http://svn.automattic.com/wordpress/trunk@7327 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-03-16 09:49:10 +00:00
parent 78c365c7cd
commit 568d64e73e
4 changed files with 17 additions and 11 deletions

View File

@ -317,7 +317,7 @@ class ftp_base {
function pwd() {
if(!$this->_exec("PWD", "pwd")) return FALSE;
if(!$this->_checkCode()) return FALSE;
return ereg_replace("^[0-9]{3} \"(.+)\" .+".CRLF, "\\1", $this->_message);
return ereg_replace("^[0-9]{3} \"(.+)\".+", "\\1", $this->_message);
}
function cdup() {

View File

@ -162,7 +162,10 @@ class WP_Filesystem_FTPext{
return $ret;
}
function cwd(){
return ftp_pwd($this->link);
$cwd = ftp_pwd($this->link);
if( $cwd )
$cwd = trailingslashit($cwd);
return $cwd;
}
function chdir($dir){
return @ftp_chdir($dir);
@ -308,8 +311,9 @@ class WP_Filesystem_FTPext{
}
function is_dir($path){
$cwd = $this->cwd();
@ftp_chdir($this->link, $path);
if ( $this->cwd() != $cwd ) {
$result = @ftp_chdir($this->link, $path);
if( $result && $path == $this->cwd() ||
$this->cwd() != $cwd ) {
@ftp_chdir($this->link, $cwd);
return true;
}
@ -425,9 +429,9 @@ class WP_Filesystem_FTPext{
} else {
$limitFile = false;
}
//if( ! $this->is_dir($path) )
// return false;
$list = ftp_rawlist($this->link , '-a ' . $path, false);
$list = @ftp_rawlist($this->link , '-a ' . $path, false);
if ( $list === false )
return false;

View File

@ -176,7 +176,10 @@ class WP_Filesystem_ftpsockets{
}
function cwd(){
return $this->ftp->pwd();
$cwd = $this->ftp->pwd();
if( $cwd )
$cwd = trailingslashit($cwd);
return $cwd;
}
function chdir($file){
@ -388,8 +391,7 @@ class WP_Filesystem_ftpsockets{
} else {
$limitFile = false;
}
//if( ! $this->is_dir($path) )
// return false;
$list = $this->ftp->dirlist($path);
if( ! $list )
return false;

View File

@ -325,7 +325,7 @@ function get_filesystem_method() {
}
if ( extension_loaded('ftp') ) return 'ftpext';
if ( extension_loaded('sockets') ) return 'ftpsockets';
if ( extension_loaded('sockets') || function_exists('fsockopen') ) return 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread
return false;
}