Ticket #34976: 34976.diff
File 34976.diff, 2.0 KB (added by , 9 years ago) |
---|
-
src/wp-admin/includes/class-wp-filesystem-ftpext.php
class WP_Filesystem_FTPext extends WP_Fi 322 322 if ( !empty($filelist) ) 323 323 foreach ( $filelist as $delete_file ) 324 324 $this->delete( trailingslashit($file) . $delete_file['name'], $recursive, $delete_file['type'] ); 325 325 return @ftp_rmdir($this->link, $file); 326 326 } 327 327 328 328 /** 329 329 * @access public 330 330 * 331 331 * @param string $file 332 332 * @return bool 333 333 */ 334 334 public function exists( $file ) { 335 335 $path = dirname( $file ); 336 336 $filename = basename( $file ); 337 $hidden = ( '.' === substr( $filename, 0, 1 ) ); 337 338 338 $file_list = @ftp_nlist( $this->link, '-a ' . $path ); 339 // Attempt an NLST, relying upon the server to show hidden files if needed 340 $file_list = @ftp_nlist( $this->link, $path ); 339 341 if ( $file_list ) { 340 342 $file_list = array_map( 'basename', $file_list ); 343 if ( in_array( $filename, $file_list ) ) { 344 return true; 345 } 346 } 347 348 // If it's a hidden file, attempt both NLST and LIST with -a for compat. 349 if ( $hidden ) { 350 // Try NLIST with `-a` 351 $file_list = @ftp_nlist( $this->link, '-a ' . $path ); 352 if ( $file_list ) { 353 $file_list = array_map( 'basename', $file_list ); 354 if ( in_array( $filename, $file_list ) ) { 355 return true; 356 } 357 } 358 359 // Try LIST -a 360 $file_list = @ftp_rawlist( $this->link, '-a ' . $file ); 361 362 if ( empty( $file_list ) && $this->is_dir( $file ) ) { 363 // File is an empty directory. 364 return true; 365 } 366 367 // Empty list = no file, so invert. 368 return !empty( $file_list ); 341 369 } 342 370 343 return $file_list && in_array( $filename, $file_list );371 return false; 344 372 } 345 373 346 374 /** 347 375 * @access public 348 376 * 349 377 * @param string $file 350 378 * @return bool 351 379 */ 352 380 public function is_file($file) { 353 381 return $this->exists($file) && !$this->is_dir($file); 354 382 } 355 383 356 384 /** 357 385 * @access public 358 386 *