Changeset 6785

Show
Ignore:
Timestamp:
02/11/08 08:46:11 (6 months ago)
Author:
ryan
Message:

ftp fs tweaks. see #5586

Files:

Legend:

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

    r6779 r6785  
    274274        return ftp_rename($this->link,$source,$destination); 
    275275    } 
    276     function delete($file,$recursive=false){ 
    277         if( $this->is_file($file) ) 
     276 
     277    function delete($file,$recursive=false) { 
     278        if ( $this->is_file($file) ) 
    278279            return ftp_delete($this->link,$file); 
    279         if( !$recursive ) 
     280        if ( !$recursive ) 
    280281            return ftp_rmdir($this->link,$file); 
    281282        $filelist = $this->dirlist($file); 
    282         foreach($filelist as $filename => $fileinfo){ 
    283             echo "Delete $file/$filename<br />"; 
     283        foreach ($filelist as $filename => $fileinfo) { 
    284284            $this->delete($file.'/'.$filename,$recursive); 
    285285        } 
    286286        return ftp_rmdir($this->link,$file); 
    287287    } 
     288 
    288289    function exists($file){ 
    289290        $list = ftp_rawlist($this->link,$file,false); 
  • trunk/wp-admin/includes/class-wp-filesystem-ftpsockets.php

    r6779 r6785  
    2424                            ); 
    2525     
    26     function WP_Filesystem_ftpsockets($opt='')
     26    function WP_Filesystem_ftpsockets($opt='')
    2727        //Check if possible to use ftp functions. 
    2828        if( ! @include_once ABSPATH . 'wp-admin/includes/class-ftp.php' ) 
    2929                return false; 
    3030        $this->ftp = new FTP(); 
     31 
    3132        //Set defaults: 
    32         if( ! isset($opt['port']) || empty($opt['port']) ) 
     33        if ( empty($opt['port']) ) 
    3334            $this->options['port'] = 21; 
    3435        else 
    3536            $this->options['port'] = $opt['port']; 
    3637 
    37         if( ! isset($opt['hostname']) || empty($opt['hostname']) ) 
    38             $this->errors['require']['hostname'] = __('Hostname'); 
     38        if ( empty($opt['hostname']) ) 
     39            $this->errors->add('empty_hostname', __('FTP hostname is required')); 
    3940        else 
    4041            $this->options['hostname'] = $opt['hostname']; 
    4142 
    42         if( isset($opt['base']) && ! empty($opt['base']) ) 
     43        if ( isset($opt['base']) && ! empty($opt['base']) ) 
    4344            $this->wp_base = $opt['base']; 
    4445 
    45         //Check if the options provided are OK. 
    46         if( ! isset($opt['username']) || empty ($opt['username']) ) 
    47             $this->errors['require']['username'] = __('Username'); 
     46        // Check if the options provided are OK. 
     47        if ( empty ($opt['username']) ) 
     48            $this->errors->add('empty_username', __('FTP username is required')); 
    4849        else 
    4950            $this->options['username'] = $opt['username']; 
    5051 
    51         if( ! isset($opt['password']) || empty ($opt['password']) ) 
    52             $this->errors['require']['password'] = __('Password');     
     52        if ( empty ($opt['password']) ) 
     53            $this->errors->add('empty_password', __('FTP password is required'));  
    5354        else 
    5455            $this->options['password'] = $opt['password']; 
    5556    } 
    56     function connect(){ 
    57         if( ! $this->ftp ) 
     57 
     58    function connect() { 
     59        if ( ! $this->ftp ) 
    5860            return false; 
    5961             
    60         if( ! $this->ftp->connect($this->options['hostname'], $this->options['port'], $this->timeout) ){ 
    61             $this->errors['server'] = __('Failed to connect to FTP Server') . ' ' . $this->options['hostname'] . ':' . $this->options['port']; 
    62             return false; 
    63         } 
    64         if( ! $this->ftp->login($this->options['username'], $this->options['password']) ){ 
    65             $this->errors['auth'] = __('Username/Password incorrect') . ' ' .  
    66                 $this->options['username'] . ':********@' .$this->options['hostname'] . ':' . $this->options['port']; 
    67             return false; 
    68         } 
    69         return true; 
    70     } 
    71     function setDefaultPermissions($perm){ 
     62        if ( ! $this->ftp->connect($this->options['hostname'], $this->options['port'], $this->timeout) ) { 
     63            $this->errors->add('connect', sprintf(__('Failed to connect to FTP Server %1$s:%2$s'), $this->options['hostname'], $this->options['port'])); 
     64            return false; 
     65        } 
     66 
     67        if ( ! $this->ftp->login($this->options['username'], $this->options['password']) ) { 
     68            $this->errors->add('auth', sprintf(__('Username/Password incorrect for %s'), $this->options['username'])); 
     69            return false; 
     70        } 
     71 
     72        return true; 
     73    } 
     74 
     75    function setDefaultPermissions($perm) { 
    7276        $this->permission = $perm; 
    7377    } 
    74     function find_base_dir($base = '.',$echo = false){ 
     78 
     79    function find_base_dir($base = '.',$echo = false) { 
    7580        if( empty( $base ) || '.' == $base ) $base = $this->cwd(); 
    7681        if( empty( $base ) ) $base = '/'; 
     
    254259        return $this->ftp->rename($source,$destination); 
    255260    } 
    256     function delete($file,$recursive=false){ 
    257         if( $this->is_file($file) ) 
     261 
     262    function delete($file,$recursive=false) { 
     263        if ( $this->is_file($file) ) 
    258264            return $this->ftp->delete($file); 
    259         if( !$recursive ) 
     265        if ( !$recursive ) 
    260266            return $this->ftp->rmdir($file); 
    261267        $filelist = $this->dirlist($file); 
    262         foreach($filelist as $filename)
     268        foreach ($filelist as $filename)
    263269            $this->delete($file.'/'.$filename,$recursive); 
    264270        } 
    265     } 
     271        return $this->ftp->rmdir($file); 
     272    } 
     273 
    266274    function exists($file){ 
    267275        return $this->ftp->is_exists($file);