From 7fa4f4fecea01fd1b1190704f155da2aed4e548b Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Tue, 18 Mar 2008 00:13:11 +0000 Subject: [PATCH] Basedir location fixes for ftp fs from DD32. see #6245 git-svn-id: https://develop.svn.wordpress.org/trunk@7369 602fd350-edb4-49c9-b593-d223f7449a82 --- .../includes/class-wp-filesystem-ftpext.php | 19 +++++++++++-------- .../class-wp-filesystem-ftpsockets.php | 19 +++++++++++-------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/wp-admin/includes/class-wp-filesystem-ftpext.php b/wp-admin/includes/class-wp-filesystem-ftpext.php index fb326e1862..792dae8e0e 100644 --- a/wp-admin/includes/class-wp-filesystem-ftpext.php +++ b/wp-admin/includes/class-wp-filesystem-ftpext.php @@ -95,20 +95,18 @@ class WP_Filesystem_FTPext{ //Set up the base directory (Which unless specified, is the current one) if( empty( $base ) || '.' == $base ) $base = $this->cwd(); $base = trailingslashit($base); - + //Can we see the Current directory as part of the ABSPATH? $location = strpos($abspath, $base); if( false !== $location ){ $newbase = path_join($base, substr($abspath, $location + strlen($base))); - - if($echo) printf( __('Changing to %s') . '
', $newbase ); + if( false !== $this->chdir($newbase) ){ //chdir sometimes returns null under certain circumstances, even when its changed correctly, FALSE will be returned if it doesnt change correctly. - $base = $newbase; + if($echo) printf( __('Changing to %s') . '
', $newbase ); //Check to see if it exists in that folder. - if( $this->exists($base . 'wp-settings.php') ){ - if($echo) printf( __('Found %s'), $base . 'wp-settings.php
' ); - $this->wp_base = $base; - return $this->wp_base; + if( $this->exists($newbase . 'wp-settings.php') ){ + if($echo) printf( __('Found %s'), $newbase . 'wp-settings.php
' ); + return $newbase; } } } @@ -133,6 +131,11 @@ class WP_Filesystem_FTPext{ return $ret; } } + //Only check this as a last resort, to prevent locating the incorrect install. All above proceeedures will fail quickly if this is the right branch to take. + if(isset( $files[ 'wp-settings.php' ]) ){ + if($echo) printf( __('Found %s'), $base . 'wp-settings.php
' ); + return $base; + } return false; } diff --git a/wp-admin/includes/class-wp-filesystem-ftpsockets.php b/wp-admin/includes/class-wp-filesystem-ftpsockets.php index 80d22b20dc..fbac7b7e41 100644 --- a/wp-admin/includes/class-wp-filesystem-ftpsockets.php +++ b/wp-admin/includes/class-wp-filesystem-ftpsockets.php @@ -97,20 +97,18 @@ class WP_Filesystem_ftpsockets{ //Set up the base directory (Which unless specified, is the current one) if( empty( $base ) || '.' == $base ) $base = $this->cwd(); $base = trailingslashit($base); - + //Can we see the Current directory as part of the ABSPATH? $location = strpos($abspath, $base); if( false !== $location ){ $newbase = path_join($base, substr($abspath, $location + strlen($base))); - - if($echo) printf( __('Changing to %s') . '
', $newbase ); + if( false !== $this->chdir($newbase) ){ //chdir sometimes returns null under certain circumstances, even when its changed correctly, FALSE will be returned if it doesnt change correctly. - $base = $newbase; + if($echo) printf( __('Changing to %s') . '
', $newbase ); //Check to see if it exists in that folder. - if( $this->exists($base . 'wp-settings.php') ){ - if($echo) printf( __('Found %s'), $base . 'wp-settings.php
' ); - $this->wp_base = $base; - return $this->wp_base; + if( $this->exists($newbase . 'wp-settings.php') ){ + if($echo) printf( __('Found %s'), $newbase . 'wp-settings.php
' ); + return $newbase; } } } @@ -135,6 +133,11 @@ class WP_Filesystem_ftpsockets{ return $ret; } } + //Only check this as a last resort, to prevent locating the incorrect install. All above proceeedures will fail quickly if this is the right branch to take. + if(isset( $files[ 'wp-settings.php' ]) ){ + if($echo) printf( __('Found %s'), $base . 'wp-settings.php
' ); + return $base; + } return false; }