FTP find_base_dir fixes from DD32. see #5586

git-svn-id: http://svn.automattic.com/wordpress/trunk@7443 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-03-21 05:15:21 +00:00
parent 2cc2f543c2
commit c69821c5e0
2 changed files with 14 additions and 8 deletions

View File

@ -84,7 +84,7 @@ class WP_Filesystem_FTPext{
$this->permission = $perm;
}
function find_base_dir($base = '.',$echo = false) {
function find_base_dir($base = '.',$echo = false, $loop = false) {
//Sanitize the Windows path formats, This allows easier conparison and aligns it to FTP output.
$abspath = str_replace('\\','/',ABSPATH); //windows: Straighten up the paths..
if( strpos($abspath, ':') ){ //Windows, Strip out the driveletter
@ -126,7 +126,7 @@ class WP_Filesystem_FTPext{
//Lets try that folder:
$folder = path_join($base, $key);
if($echo) printf( __('Changing to %s') . '<br/>', $folder );
$ret = $this->find_base_dir( $folder, $echo);
$ret = $this->find_base_dir( $folder, $echo, $loop);
if( $ret )
return $ret;
}
@ -136,7 +136,10 @@ class WP_Filesystem_FTPext{
if($echo) printf( __('Found %s'), $base . 'wp-settings.php<br/>' );
return $base;
}
return false;
if( $loop )
return false;//Prevent tihs function looping again.
//As an extra last resort, Change back to / if the folder wasnt found. This comes into effect when the CWD is /home/user/ but WP is at /var/www/.... mainly dedicated setups.
return $this->find_base_dir('/', $echo, true);
}
function get_base_dir($base = '.', $echo = false){

View File

@ -86,7 +86,7 @@ class WP_Filesystem_ftpsockets{
$this->permission = $perm;
}
function find_base_dir($base = '.',$echo = false) {
function find_base_dir($base = '.',$echo = false, $loop = false) {
//Sanitize the Windows path formats, This allows easier conparison and aligns it to FTP output.
$abspath = str_replace('\\','/',ABSPATH); //windows: Straighten up the paths..
if( strpos($abspath, ':') ){ //Windows, Strip out the driveletter
@ -128,7 +128,7 @@ class WP_Filesystem_ftpsockets{
//Lets try that folder:
$folder = path_join($base, $key);
if($echo) printf( __('Changing to %s') . '<br/>', $folder );
$ret = $this->find_base_dir( $folder, $echo);
$ret = $this->find_base_dir( $folder, $echo, $loop);
if( $ret )
return $ret;
}
@ -138,7 +138,10 @@ class WP_Filesystem_ftpsockets{
if($echo) printf( __('Found %s'), $base . 'wp-settings.php<br/>' );
return $base;
}
return false;
if( $loop )
return false;//Prevent tihs function looping again.
//As an extra last resort, Change back to / if the folder wasnt found. This comes into effect when the CWD is /home/user/ but WP is at /var/www/.... mainly dedicated setups.
return $this->find_base_dir('/', $echo, true);
}
function get_base_dir($base = '.', $echo = false){