Make WordPress Core


Ignore:
Timestamp:
05/27/2008 05:55:24 PM (18 years ago)
Author:
ryan
Message:

Allow wp-content to exist outside of webroot. Props sambauers. see #6938

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-filesystem-ftpext.php

    r7443 r7999  
    8585        }
    8686
    87         function find_base_dir($base = '.',$echo = false, $loop = false) {
     87        function find_base_dir($path = false, $base = '.',$echo = false, $loop = false) {
     88                if (!$path)
     89                        $path = ABSPATH;
     90               
    8891                //Sanitize the Windows path formats, This allows easier conparison and aligns it to FTP output.
    89                 $abspath = str_replace('\\','/',ABSPATH); //windows: Straighten up the paths..
    90                 if( strpos($abspath, ':') ){ //Windows, Strip out the driveletter
    91                         if( preg_match("|.{1}\:(.+)|i", $abspath, $mat) )
    92                                 $abspath = $mat[1];
     92                $path = str_replace('\\','/',$path); //windows: Straighten up the paths..
     93                if( strpos($path, ':') ){ //Windows, Strip out the driveletter
     94                        if( preg_match("|.{1}\:(.+)|i", $path, $mat) )
     95                                $path = $mat[1];
    9396                }
    9497       
    … …  
    98101
    99102                //Can we see the Current directory as part of the ABSPATH?
    100                 $location = strpos($abspath, $base);
     103                $location = strpos($path, $base);
    101104                if( false !== $location ) {
    102                         $newbase = path_join($base, substr($abspath, $location + strlen($base)));
     105                        $newbase = path_join($base, substr($path, $location + strlen($base)));
    103106
    104107                        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.
    … …  
    117120                $files = $this->dirlist($base);
    118121               
    119                 $arrPath = explode('/', $abspath);
     122                $arrPath = explode('/', $path);
    120123                foreach($arrPath as $key){
    121124                        //Working from /home/ to /user/ to /wordpress/ see if that file exists within the current folder,
    … …  
    127130                                $folder = path_join($base, $key);
    128131                                if($echo) printf( __('Changing to %s') . '<br/>', $folder );
    129                                 $ret = $this->find_base_dir( $folder, $echo, $loop);
     132                                $ret = $this->find_base_dir( $path, $folder, $echo, $loop);
    130133                                if( $ret )
    131134                                        return $ret;
    … …  
    140143                        return false;//Prevent tihs function looping again.
    141144                //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.
    142                 return $this->find_base_dir('/', $echo, true);
    143         }
    144 
    145         function get_base_dir($base = '.', $echo = false){
     145                return $this->find_base_dir($path, '/', $echo, true);
     146        }
     147
     148        function get_base_dir($path = false, $base = '.', $echo = false){
    146149                if( defined('FTP_BASE') )
    147150                        $this->wp_base = FTP_BASE;
    148151                if( empty($this->wp_base) )
    149                         $this->wp_base = $this->find_base_dir($base,$echo);
     152                        $this->wp_base = $this->find_base_dir($path, $base, $echo);
    150153                return $this->wp_base;
    151154        }
Note: See TracChangeset for help on using the changeset viewer.