Basedir location fixes for ftp fs from DD32. see #6245

git-svn-id: http://svn.automattic.com/wordpress/trunk@7369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-03-18 00:13:11 +00:00
parent 352c9fca90
commit a4dc527de4
2 changed files with 22 additions and 16 deletions

View File

@ -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') . '<br/>', $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') . '<br/>', $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<br/>' );
$this->wp_base = $base;
return $this->wp_base;
if( $this->exists($newbase . 'wp-settings.php') ){
if($echo) printf( __('Found %s'), $newbase . 'wp-settings.php<br/>' );
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<br/>' );
return $base;
}
return false;
}

View File

@ -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') . '<br/>', $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') . '<br/>', $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<br/>' );
$this->wp_base = $base;
return $this->wp_base;
if( $this->exists($newbase . 'wp-settings.php') ){
if($echo) printf( __('Found %s'), $newbase . 'wp-settings.php<br/>' );
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<br/>' );
return $base;
}
return false;
}