Changeset 7164

Show
Ignore:
Timestamp:
03/06/08 06:06:13 (6 months ago)
Author:
ryan
Message:

wpfs fixes from DD32. see #5586

Files:

Legend:

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

    r7155 r7164  
    8686 
    8787    function find_base_dir($base = '.',$echo = false){ 
     88        $abspath = str_replace('\\','/',ABSPATH); //windows: Straighten up the paths.. 
     89        if( strpos($abspath, ':') ){ //Windows, Strip out the driveletter 
     90            if( preg_match("|.{1}\:(.+)|i", $abspath, $mat) ) 
     91                $abspath = $mat[1]; 
     92        } 
     93     
    8894        if( empty( $base ) || '.' == $base ) $base = $this->cwd(); 
    8995        if( empty( $base ) ) $base = '/'; 
    9096        if( '/' != substr($base, -1) ) $base .= '/'; 
    9197 
    92         if($echo) echo sprintf(__('Changing to %s'), $base) .'<br>'; 
    93         if( false === ftp_chdir($this->link, $base) ) 
     98        if($echo) echo __('Changing to ') . $base .'<br>'; 
     99        if( false === $this->chdir($base) ) 
    94100            return false; 
    95101 
    96102        if( $this->exists($base . 'wp-settings.php') ){ 
    97             if($echo) echo sprintf(__('Found %s'), $base . 'wp-settings.php') . '<br>'; 
     103            if($echo) echo __('Found ') . $base . 'wp-settings.php<br>'; 
    98104            $this->wp_base = $base; 
    99105            return $this->wp_base; 
    100106        } 
    101107 
    102         if( strpos(ABSPATH, $base) > 0) 
    103             $arrPath = split('/',substr(ABSPATH,strpos(ABSPATH, $base))); 
     108        if( strpos($abspath, $base) > 0) 
     109            $arrPath = split('/',substr($abspath,strpos($abspath, $base))); 
    104110        else 
    105             $arrPath = split('/',ABSPATH); 
     111            $arrPath = split('/',$abspath); 
    106112 
    107113        for($i = 0; $i <= count($arrPath); $i++) 
     
    110116        foreach($arrPath as $key=>$folder){ 
    111117            if( $this->is_dir($base . $folder) ){ 
    112                 if($echo) echo sprintf(__('Found %s'), $folder) . ' ' . sprintf(__('Changing to %s'), $base . $folder . '/') . '<br>'; 
     118                if($echo) echo __('Found ') . $folder . ' ' . __('Changing to') . ' ' . $base . $folder . '/<br>'; 
    113119                return $this->find_base_dir($base .  $folder . '/',$echo); 
    114120            } 
     
    159165        return ftp_pwd($this->link); 
    160166    } 
     167    function chdir($dir){ 
     168        return @ftp_chdir($dir); 
     169    } 
    161170    function chgrp($file,$group,$recursive=false){ 
    162171        return false; 
     
    171180        if ( ! $recursive || ! $this->is_dir($file) ){ 
    172181            if (!function_exists('ftp_chmod')) 
    173                 return ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file)); 
    174             return ftp_chmod($this->link,$mode,$file); 
     182                return @ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file)); 
     183            return @ftp_chmod($this->link,$mode,$file); 
    175184        } 
    176185        //Is a directory, and we want recursive 
     
    268277        if( ! $overwrite && $this->exists($destination) ) 
    269278            return false; 
    270         if ( !$content = $this->get_contents($source) ) 
     279        $content = $this->get_contents($source); 
     280        if( false === $content) 
    271281            return false; 
    272282        return $this->put_contents($destination,$content); 
  • trunk/wp-admin/includes/class-wp-filesystem-ftpsockets.php

    r7155 r7164  
    8888 
    8989    function find_base_dir($base = '.',$echo = false) { 
     90        $abspath = str_replace('\\','/',ABSPATH); //windows: Straighten up the paths.. 
     91        if( strpos($abspath, ':') ){ //Windows, Strip out the driveletter 
     92            if( preg_match("|.{1}\:(.+)|i", $abspath, $mat) ) 
     93                $abspath = $mat[1]; 
     94        } 
     95     
    9096        if( empty( $base ) || '.' == $base ) $base = $this->cwd(); 
    9197        if( empty( $base ) ) $base = '/'; 
     
    9399 
    94100        if($echo) echo __('Changing to ') . $base  .'<br>'; 
    95         if( false === $this->ftp->chdir($base) ) 
     101        if( false === $this->chdir($base) ) 
    96102            return false; 
    97103 
     
    102108        } 
    103109 
    104         if( strpos(ABSPATH, $base) > 0) 
    105             $arrPath = split('/',substr(ABSPATH,strpos(ABSPATH, $base))); 
     110        if( strpos($abspath, $base) > 0) 
     111            $arrPath = split('/',substr($abspath,strpos($abspath, $base))); 
    106112        else 
    107             $arrPath = split('/',ABSPATH); 
     113            $arrPath = split('/',$abspath); 
    108114 
    109115        for($i = 0; $i <= count($arrPath); $i++) 
     
    130136 
    131137    function get_contents($file,$type='',$resumepos=0){ 
     138        if( ! $this->exists($file) ) 
     139            return false; 
     140 
    132141        if( empty($type) ){ 
    133142            $extension = substr(strrchr($filename, "."), 1); 
     
    138147        if ( ! $this->ftp->fget($temp, $file) ) { 
    139148            fclose($temp); 
    140             return false; 
     149            return ''; //Blank document, File does exist, Its just blank. 
    141150        } 
    142151        fseek($temp, 0); //Skip back to the start of the file being written to 
     
    288297 
    289298        $content = $this->get_contents($source); 
    290         if ( !$content ) 
     299        if ( false === $content ) 
    291300            return false; 
    292301