Make WordPress Core


Ignore:
Timestamp:
05/27/2008 05:55:24 PM (14 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-ftpsockets.php

    r7443 r7999  
    8787    }
    8888
    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       
    9093        //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 driveletter
    93             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];
    9598        }
    9699   
     
    100103
    101104        //Can we see the Current directory as part of the ABSPATH?
    102         $location = strpos($abspath, $base);
     105        $location = strpos($path, $base);
    103106        if( false !== $location ) {
    104             $newbase = path_join($base, substr($abspath, $location + strlen($base)));
     107            $newbase = path_join($base, substr($path, $location + strlen($base)));
    105108
    106109            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.
     
    119122        $files = $this->dirlist($base);
    120123       
    121         $arrPath = explode('/', $abspath);
     124        $arrPath = explode('/', $path);
    122125        foreach($arrPath as $key){
    123126            //Working from /home/ to /user/ to /wordpress/ see if that file exists within the current folder,
     
    129132                $folder = path_join($base, $key);
    130133                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);
    132135                if( $ret )
    133136                    return $ret;
     
    142145            return false;//Prevent tihs function looping again.
    143146        //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){
    148151        if( defined('FTP_BASE') )
    149152            $this->wp_base = FTP_BASE;
    150153        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);
    152155        return $this->wp_base;
    153156    }
Note: See TracChangeset for help on using the changeset viewer.