diff --git a/wp-admin/includes/class-wp-filesystem-ftpext.php b/wp-admin/includes/class-wp-filesystem-ftpext.php index cd0e92fe42..a2805da80d 100644 --- a/wp-admin/includes/class-wp-filesystem-ftpext.php +++ b/wp-admin/includes/class-wp-filesystem-ftpext.php @@ -169,7 +169,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { } function getchmod($file) { $dir = $this->dirlist($file); - return $this->getnumchmodfromh( $dir[basename($file)]['perms'] ); + return $dir[$file]['permsn']; } function group($file) { $dir = $this->dirlist($file); @@ -187,9 +187,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { return ftp_rename($this->link, $source, $destination); } - function delete($file ,$recursive = false ) { - if ( empty($file) ) - return false; + function delete($file,$recursive=false) { if ( $this->is_file($file) ) return @ftp_delete($this->link, $file); if ( !$recursive ) @@ -323,12 +321,11 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { } function dirlist($path = '.', $incdot = false, $recursive = false) { - - if ( substr($path, -1) !== '/') { - $limit = basename($path); - $path = trailingslashit(dirname($path)); + if( $this->is_file($path) ) { + $limitFile = basename($path); + $path = dirname($path) . '/'; } else { - $limit = false; + $limitFile = false; } $list = @ftp_rawlist($this->link, '-a ' . $path, false); @@ -342,10 +339,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { if ( empty($entry) ) continue; - if ( '.' == $entry['name'] || '..' == $entry['name'] ) - continue; - - if ( $limit && $entry['name'] != $limit ) + if ( '.' == $entry["name"] || '..' == $entry["name"] ) continue; $dirlist[ $entry['name'] ] = $entry; diff --git a/wp-admin/includes/class-wp-filesystem-ftpsockets.php b/wp-admin/includes/class-wp-filesystem-ftpsockets.php index f86d194765..d5ee3f97b4 100644 --- a/wp-admin/includes/class-wp-filesystem-ftpsockets.php +++ b/wp-admin/includes/class-wp-filesystem-ftpsockets.php @@ -186,7 +186,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base { function getchmod($file) { $dir = $this->dirlist($file); - return $this->getnumchmodfromh( $dir[basename($file)]['perms'] ); + return $dir[$file]['permsn']; } function group($file) { @@ -281,25 +281,21 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base { } function dirlist($path = '.', $incdot = false, $recursive = false ) { - - if ( substr($path, -1) !== '/') { - $limit = basename($path); - $path = trailingslashit(dirname($path)); + if( $this->is_file($path) ) { + $limitFile = basename($path); + $path = dirname($path) . '/'; } else { - $limit = false; + $limitFile = false; } $list = $this->ftp->dirlist($path); if( ! $list ) return false; - if( empty($list) ) return array(); $ret = array(); foreach ( $list as $struc ) { - if ( $limit && $struc['name'] != $limit ) - continue; if ( 'd' == $struc['type'] ) { $struc['files'] = array();