~canonical-sysadmins/wordpress/4.2.4

« back to all changes in this revision

Viewing changes to wp-admin/includes/class-wp-filesystem-ssh2.php

  • Committer: Paul Gear
  • Date: 2015-04-24 01:35:20 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: paul.gear@canonical.com-20150424013520-w4p9ksth76zh6opw
Merge new upstream release 4.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
37
37
 
38
38
        public $link = false;
39
 
        public $sftp_link = false;
 
39
        /**
 
40
         * @var resource
 
41
         */
 
42
        public $sftp_link;
40
43
        public $keys = false;
41
 
        public $errors = array();
42
 
        public $options = array();
43
44
 
44
45
        public function __construct($opt='') {
45
46
                $this->method = 'ssh2';
48
49
                //Check if possible to use ssh2 functions.
49
50
                if ( ! extension_loaded('ssh2') ) {
50
51
                        $this->errors->add('no_ssh2_ext', __('The ssh2 PHP extension is not available'));
51
 
                        return false;
 
52
                        return;
52
53
                }
53
54
                if ( !function_exists('stream_get_contents') ) {
54
55
                        $this->errors->add('ssh2_php_requirement', __('The ssh2 PHP extension is available, however, we require the PHP5 function <code>stream_get_contents()</code>'));
55
 
                        return false;
 
56
                        return;
56
57
                }
57
58
 
58
59
                // Set defaults:
66
67
                else
67
68
                        $this->options['hostname'] = $opt['hostname'];
68
69
 
69
 
                if ( ! empty($opt['base']) )
70
 
                        $this->wp_base = $opt['base'];
71
 
 
72
70
                // Check if the options provided are OK.
73
71
                if ( !empty ($opt['public_key']) && !empty ($opt['private_key']) ) {
74
72
                        $this->options['public_key'] = $opt['public_key'];
126
124
        /**
127
125
         * @param string $command
128
126
         * @param bool $returnbool
 
127
         * @return bool|string
129
128
         */
130
129
        public function run_command( $command, $returnbool = false) {
131
130
 
185
184
 
186
185
        public function cwd() {
187
186
                $cwd = $this->run_command('pwd');
188
 
                if ( $cwd )
189
 
                        $cwd = trailingslashit($cwd);
 
187
                if ( $cwd ) {
 
188
                        $cwd = trailingslashit( trim( $cwd ) );
 
189
                }
190
190
                return $cwd;
191
191
        }
192
192
 
193
193
        /**
194
194
         * @param string $dir
195
 
         * @return bool
 
195
         * @return bool|string
196
196
         */
197
197
        public function chdir($dir) {
198
198
                return $this->run_command('cd ' . $dir, true);
215
215
         * @param string $file
216
216
         * @param int $mode
217
217
         * @param bool $recursive
218
 
         * @return bool
 
218
         * @return bool|string
219
219
         */
220
220
        public function chmod($file, $mode = false, $recursive = false) {
221
221
                if ( ! $this->exists($file) )