Changeset 7443

Show
Ignore:
Timestamp:
03/21/08 05:15:21 (4 months ago)
Author:
ryan
Message:

FTP find_base_dir fixes from DD32. see #5586

Files:

Legend:

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

    r7403 r7443  
    8585    } 
    8686 
    87     function find_base_dir($base = '.',$echo = false) { 
     87    function find_base_dir($base = '.',$echo = false, $loop = false) { 
    8888        //Sanitize the Windows path formats, This allows easier conparison and aligns it to FTP output. 
    8989        $abspath = str_replace('\\','/',ABSPATH); //windows: Straighten up the paths.. 
     
    9999        //Can we see the Current directory as part of the ABSPATH? 
    100100        $location = strpos($abspath, $base); 
    101         if( false !== $location )
     101        if( false !== $location )
    102102            $newbase = path_join($base, substr($abspath, $location + strlen($base))); 
    103103 
     
    127127                $folder = path_join($base, $key); 
    128128                if($echo) printf( __('Changing to %s') . '<br/>', $folder ); 
    129                 $ret = $this->find_base_dir( $folder, $echo); 
     129                $ret = $this->find_base_dir( $folder, $echo, $loop); 
    130130                if( $ret ) 
    131131                    return $ret; 
     
    137137            return $base; 
    138138        } 
    139         return false; 
     139        if( $loop ) 
     140            return false;//Prevent tihs function looping again. 
     141        //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);  
    140143    } 
    141144 
  • trunk/wp-admin/includes/class-wp-filesystem-ftpsockets.php

    r7403 r7443  
    8787    } 
    8888 
    89     function find_base_dir($base = '.',$echo = false) { 
     89    function find_base_dir($base = '.',$echo = false, $loop = false) { 
    9090        //Sanitize the Windows path formats, This allows easier conparison and aligns it to FTP output. 
    9191        $abspath = str_replace('\\','/',ABSPATH); //windows: Straighten up the paths.. 
     
    101101        //Can we see the Current directory as part of the ABSPATH? 
    102102        $location = strpos($abspath, $base); 
    103         if( false !== $location )
     103        if( false !== $location )
    104104            $newbase = path_join($base, substr($abspath, $location + strlen($base))); 
    105105 
     
    129129                $folder = path_join($base, $key); 
    130130                if($echo) printf( __('Changing to %s') . '<br/>', $folder ); 
    131                 $ret = $this->find_base_dir( $folder, $echo); 
     131                $ret = $this->find_base_dir( $folder, $echo, $loop); 
    132132                if( $ret ) 
    133133                    return $ret; 
     
    139139            return $base; 
    140140        } 
    141         return false; 
     141        if( $loop ) 
     142            return false;//Prevent tihs function looping again. 
     143        //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);  
    142145    } 
    143146