From ff657986ff66af876340881d39b8324e3a8e1a1e Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 14 Apr 2009 17:16:44 +0000 Subject: [PATCH] Revert FTP parts of [10919]. fixes #9535 see #9525 git-svn-id: http://svn.automattic.com/wordpress/trunk@10930 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../includes/class-wp-filesystem-ftpext.php | 20 +++++++------------ .../class-wp-filesystem-ftpsockets.php | 14 +++++-------- 2 files changed, 12 insertions(+), 22 deletions(-) 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();