Make WordPress Core


Ignore:
Timestamp:
09/13/2008 06:06:20 PM (18 years ago)
Author:
ryan
Message:

ssh2 fs fixes from ShaneF and DD32. see #7690

File:
1 edited

Legend:

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

    r8865 r8880  
    6464                $this->errors = new WP_Error();
    6565
    66                 //Check if possible to use ftp functions.
     66                //Check if possible to use ssh2 functions.
    6767                if ( ! extension_loaded('ssh2') ) {
    6868                        $this->errors->add('no_ssh2_ext', __('The ssh2 PHP extension is not available'));
    … …  
    9090                        $this->options['username'] = $opt['username'];
    9191
    92                 if (( !empty ($opt['public_key']) ) && ( !empty ($opt['private_key']) )) {
     92                if ( ( !empty ($opt['public_key']) ) && ( !empty ($opt['private_key']) ) ) {
    9393                        $this->options['public_key'] = $opt['public_key'];     
    9494                        $this->options['private_key'] = $opt['private_key'];
    … …  
    100100
    101101
    102                 if ( empty ($opt['password']) )
     102                if ( empty ($opt['password']) ) {
    103103                        if ( !$this->keys )     //       password can be blank if we are using keys
    104104                                $this->errors->add('empty_password', __('SSH2 password is required'));
    105                 else
     105                } else {
    106106                        $this->options['password'] = $opt['password'];
     107                }
    107108                       
    108109        }
    … …  
    110111        function connect() {
    111112                $this->debug("connect();");
    112                 if ( ! $this->keys )
    113                         $this->link = @ssh2_connect($this->options['hostname'], $this->options['port']);
    114                 else
    115                         $this->link = @ssh2_connect($this->options['hostname'], $this->options['port'], $this->options['hostkey']);     
     113               
     114                if ( ! $this->keys ) {
     115                        $this->link = @ssh2_connect($this->options['hostname'], $this->options['port']);                       
     116                } else {
     117                        $this->link = @ssh2_connect($this->options['hostname'], $this->options['port'], $this->options['hostkey']);                     
     118                }
    116119                       
    117120                if ( ! $this->link ) {
    … …  
    203206
    204207        function put_contents($file, $contents, $type = '' ) {
    205                 $this->debug("put_contents();");
     208                $this->debug("put_contents($file);");
    206209                $tempfile = wp_tempnam( $file );
    207210                $temp = fopen($tempfile, 'w');
    … …  
    327330                $this->debug("is_dir();");
    328331                //DO NOT RELY ON dirlist()!
    329                 $list = $this->parselisting($this->run_command($this->link, sprintf('ls -lad %s', rtrim($path, '/'))));
     332                $list = $this->parselisting($this->run_command($this->link, sprintf('ls -lad %s', untrailingslashit($path))));
    330333                if ( ! $list )
    331334                        return false;
    … …  
    360363        function mkdir($path, $chmod = null, $chown = false, $chgrp = false) {
    361364                $this->debug("mkdir();");
    362                 $path = trim($path, '/');
     365                $path = untrailingslashit($path);
    363366                if( ! ssh2_sftp_mkdir($this->sftp_link, $path, $chmod, true) )
    364367                        return false;
Note: See TracChangeset for help on using the changeset viewer.