Make WordPress Core


Ignore:
File:
1 edited

Legend:

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

    r11063 r11633  
    1414 * @contrib http://kevin.vanzonneveld.net/techblog/article/make_ssh_connections_with_php/ - Installation Notes
    1515 *
    16  * Complie libssh2 (Note: Only 0.14 is officaly working with PHP 5.2.6+ right now.)
     16 * Complie libssh2 (Note: Only 0.14 is officaly working with PHP 5.2.6+ right now, But many users have found the latest versions work)
    1717 *
    1818 * cd /usr/src
     
    2323 * make all install
    2424 *
    25  * Note: No not leave the directory yet!
     25 * Note: Do not leave the directory yet!
    2626 *
    2727 * Enter: pecl install -f ssh2
     
    3434 * Check phpinfo() streams to confirm that: ssh2.shell, ssh2.exec, ssh2.tunnel, ssh2.scp, ssh2.sftp  exist.
    3535 *
     36 * Note: as of WordPress 2.8, This utilises the PHP5+ function 'stream_get_contents'
    3637 *
    3738 * @since 2.7
     
    4647    var $keys = false;
    4748    /*
    48      * This is the timeout value for ssh results to comeback.
     49     * This is the timeout value for ssh results.
    4950     * Slower servers might need this incressed, but this number otherwise should not change.
    5051     *
     
    6768            return false;
    6869        }
    69         if ( ! version_compare(phpversion(), '5', '>=') ) {
    70             $this->errors->add('ssh2_php_requirement', __('The ssh2 PHP extension is available, however requires PHP 5+'));
     70        if ( !function_exists('stream_get_contents') ) {
     71            $this->errors->add('ssh2_php_requirement', __('The ssh2 PHP extension is available, however, we require the PHP5 function <code>stream_get_contents()</code>'));
    7172            return false;
    7273        }
     
    102103
    103104        if ( empty ($opt['password']) ) {
    104             if ( !$this->keys ) //   password can be blank if we are using keys
     105            if ( !$this->keys ) //password can be blank if we are using keys
    105106                $this->errors->add('empty_password', __('SSH2 password is required'));
    106107        } else {
     
    129130        } else {
    130131            if ( ! @ssh2_auth_pubkey_file($this->link, $this->options['username'], $this->options['public_key'], $this->options['private_key'], $this->options['password'] ) ) {
    131                 $this->errors->add('auth', sprintf(__('Public and Private keys incorrent for %s'), $this->options['username']));
     132                $this->errors->add('auth', sprintf(__('Public and Private keys incorrect for %s'), $this->options['username']));
    132133                return false;
    133134            }
     
    149150            stream_set_blocking( $stream, true );
    150151            stream_set_timeout( $stream, $this->timeout );
    151             $data = stream_get_contents($stream);
     152            $data = stream_get_contents( $stream );
     153            fclose( $stream );
    152154
    153155            if ( $returnbool )
    154                 return '' != trim($data);
     156                return ( $data === false ) ? false : '' != trim($data);
    155157            else
    156158                return $data;
     
    167169    function get_contents($file, $type = '', $resumepos = 0 ) {
    168170        $file = ltrim($file, '/');
    169         return file_get_contents('ssh2.sftp://' . $this->sftp_link .'/' . $file);
     171        return file_get_contents('ssh2.sftp://' . $this->sftp_link . '/' . $file);
    170172    }
    171173
    172174    function get_contents_array($file) {
    173175        $file = ltrim($file, '/');
    174         return file('ssh2.sftp://' . $this->sftp_link .'/' . $file);
     176        return file('ssh2.sftp://' . $this->sftp_link . '/' . $file);
    175177    }
    176178
    177179    function put_contents($file, $contents, $type = '' ) {
    178180        $file = ltrim($file, '/');
    179         return file_put_contents('ssh2.sftp://' . $this->sftp_link .'/' . $file, $contents);
     181        return file_put_contents('ssh2.sftp://' . $this->sftp_link . '/' . $file, $contents);
    180182    }
    181183
     
    271273
    272274    function exists($file) {
    273         //return $this->run_command(sprintf('ls -lad %s', escapeshellarg($file)), true);
    274         $file = ltrim($file, '/');
    275         return file_exists('ssh2.sftp://' . $this->sftp_link .'/' . $file);
     275        $file = ltrim($file, '/');
     276        return file_exists('ssh2.sftp://' . $this->sftp_link . '/' . $file);
    276277    }
    277278
    278279    function is_file($file) {
    279280        $file = ltrim($file, '/');
    280         return is_file('ssh2.sftp://' . $this->sftp_link .'/' . $file);
     281        return is_file('ssh2.sftp://' . $this->sftp_link . '/' . $file);
    281282    }
    282283
    283284    function is_dir($path) {
    284285        $path = ltrim($path, '/');
    285         return is_dir('ssh2.sftp://' . $this->sftp_link .'/' . $path);
     286        return is_dir('ssh2.sftp://' . $this->sftp_link . '/' . $path);
    286287    }
    287288
    288289    function is_readable($file) {
    289290        $file = ltrim($file, '/');
    290         return is_readable('ssh2.sftp://' . $this->sftp_link .'/' . $file);
     291        return is_readable('ssh2.sftp://' . $this->sftp_link . '/' . $file);
    291292    }
    292293
    293294    function is_writable($file) {
    294295        $file = ltrim($file, '/');
    295         return is_writable('ssh2.sftp://' . $this->sftp_link .'/' . $file);
     296        return is_writable('ssh2.sftp://' . $this->sftp_link . '/' . $file);
    296297    }
    297298
    298299    function atime($file) {
    299300        $file = ltrim($file, '/');
    300         return fileatime('ssh2.sftp://' . $this->sftp_link .'/' . $file);
     301        return fileatime('ssh2.sftp://' . $this->sftp_link . '/' . $file);
    301302    }
    302303
    303304    function mtime($file) {
    304305        $file = ltrim($file, '/');
    305         return filemtime('ssh2.sftp://' . $this->sftp_link .'/' . $file);
     306        return filemtime('ssh2.sftp://' . $this->sftp_link . '/' . $file);
    306307    }
    307308
    308309    function size($file) {
    309310        $file = ltrim($file, '/');
    310         return filesize('ssh2.sftp://' . $this->sftp_link .'/' . $file);
     311        return filesize('ssh2.sftp://' . $this->sftp_link . '/' . $file);
    311312    }
    312313
Note: See TracChangeset for help on using the changeset viewer.