- Timestamp:
- 05/27/2008 05:55:24 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/class-wp-filesystem-ftpsockets.php
r7443 r7999 87 87 } 88 88 89 function find_base_dir($base = '.',$echo = false, $loop = false) { 89 function find_base_dir($path = false, $base = '.',$echo = false, $loop = false) { 90 if (!$path) 91 $path = ABSPATH; 92 90 93 //Sanitize the Windows path formats, This allows easier conparison and aligns it to FTP output. 91 $ abspath = str_replace('\\','/',ABSPATH); //windows: Straighten up the paths..92 if( strpos($ abspath, ':') ){ //Windows, Strip out the driveletter93 if( preg_match("|.{1}\:(.+)|i", $ abspath, $mat) )94 $ abspath = $mat[1];94 $path = str_replace('\\','/',$path); //windows: Straighten up the paths.. 95 if( strpos($path, ':') ){ //Windows, Strip out the driveletter 96 if( preg_match("|.{1}\:(.+)|i", $path, $mat) ) 97 $path = $mat[1]; 95 98 } 96 99 … … 100 103 101 104 //Can we see the Current directory as part of the ABSPATH? 102 $location = strpos($ abspath, $base);105 $location = strpos($path, $base); 103 106 if( false !== $location ) { 104 $newbase = path_join($base, substr($ abspath, $location + strlen($base)));107 $newbase = path_join($base, substr($path, $location + strlen($base))); 105 108 106 109 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. … … 119 122 $files = $this->dirlist($base); 120 123 121 $arrPath = explode('/', $ abspath);124 $arrPath = explode('/', $path); 122 125 foreach($arrPath as $key){ 123 126 //Working from /home/ to /user/ to /wordpress/ see if that file exists within the current folder, … … 129 132 $folder = path_join($base, $key); 130 133 if($echo) printf( __('Changing to %s') . '<br/>', $folder ); 131 $ret = $this->find_base_dir( $folder, $echo, $loop);134 $ret = $this->find_base_dir($path, $folder, $echo, $loop); 132 135 if( $ret ) 133 136 return $ret; … … 142 145 return false;//Prevent tihs function looping again. 143 146 //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. 144 return $this->find_base_dir( '/', $echo, true);145 } 146 147 function get_base_dir($ base = '.', $echo = false){147 return $this->find_base_dir($path, '/', $echo, true); 148 } 149 150 function get_base_dir($path = false, $base = '.', $echo = false){ 148 151 if( defined('FTP_BASE') ) 149 152 $this->wp_base = FTP_BASE; 150 153 if( empty($this->wp_base) ) 151 $this->wp_base = $this->find_base_dir($ base, $echo);154 $this->wp_base = $this->find_base_dir($path, $base, $echo); 152 155 return $this->wp_base; 153 156 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)