Make WordPress Core


Ignore:
File:
1 edited

Legend:

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

    r29206 r25560  
    3636class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
    3737
    38         public $link = false;
    39         public $sftp_link = false;
    40         public $keys = false;
    41         public $errors = array();
    42         public $options = array();
    43 
    44         public function __construct($opt='') {
     38        var $link = false;
     39        var $sftp_link = false;
     40        var $keys = false;
     41        var $errors = array();
     42        var $options = array();
     43
     44        function __construct($opt='') {
    4545                $this->method = 'ssh2';
    4646                $this->errors = new WP_Error();
    … …  
    8686
    8787                if ( empty ($opt['password']) ) {
    88                         // Password can be blank if we are using keys.
    89                         if ( !$this->keys )
     88                        if ( !$this->keys )     //password can be blank if we are using keys
    9089                                $this->errors->add('empty_password', __('SSH2 password is required'));
    9190                } else {
    … …  
    9594        }
    9695
    97         public function connect() {
     96        function connect() {
    9897                if ( ! $this->keys ) {
    9998                        $this->link = @ssh2_connect($this->options['hostname'], $this->options['port']);
    … …  
    124123        }
    125124
    126         public function run_command( $command, $returnbool = false) {
     125        function run_command( $command, $returnbool = false) {
    127126
    128127                if ( ! $this->link )
    … …  
    145144        }
    146145
    147         public function get_contents( $file ) {
     146        function get_contents( $file ) {
    148147                $file = ltrim($file, '/');
    149148                return file_get_contents('ssh2.sftp://' . $this->sftp_link . '/' . $file);
    150149        }
    151150
    152         public function get_contents_array($file) {
     151        function get_contents_array($file) {
    153152                $file = ltrim($file, '/');
    154153                return file('ssh2.sftp://' . $this->sftp_link . '/' . $file);
    155154        }
    156155
    157         public function put_contents($file, $contents, $mode = false ) {
     156        function put_contents($file, $contents, $mode = false ) {
    158157                $ret = file_put_contents( 'ssh2.sftp://' . $this->sftp_link . '/' . ltrim( $file, '/' ), $contents );
    159158
    … …  
    166165        }
    167166
    168         public function cwd() {
     167        function cwd() {
    169168                $cwd = $this->run_command('pwd');
    170169                if ( $cwd )
    … …  
    173172        }
    174173
    175         public function chdir($dir) {
     174        function chdir($dir) {
    176175                return $this->run_command('cd ' . $dir, true);
    177176        }
    178177
    179         public function chgrp($file, $group, $recursive = false ) {
     178        function chgrp($file, $group, $recursive = false ) {
    180179                if ( ! $this->exists($file) )
    181180                        return false;
    … …  
    185184        }
    186185
    187         public function chmod($file, $mode = false, $recursive = false) {
     186        function chmod($file, $mode = false, $recursive = false) {
    188187                if ( ! $this->exists($file) )
    189188                        return false;
    … …  
    213212         * @return bool Returns true on success or false on failure.
    214213         */
    215         public function chown( $file, $owner, $recursive = false ) {
     214        function chown( $file, $owner, $recursive = false ) {
    216215                if ( ! $this->exists($file) )
    217216                        return false;
    … …  
    221220        }
    222221
    223         public function owner($file) {
     222        function owner($file) {
    224223                $owneruid = @fileowner('ssh2.sftp://' . $this->sftp_link . '/' . ltrim($file, '/'));
    225224                if ( ! $owneruid )
    … …  
    231230        }
    232231
    233         public function getchmod($file) {
    234                 return substr( decoct( @fileperms( 'ssh2.sftp://' . $this->sftp_link . '/' . ltrim( $file, '/' ) ) ), -3 );
    235         }
    236 
    237         public function group($file) {
     232        function getchmod($file) {
     233                return substr(decoct(@fileperms( 'ssh2.sftp://' . $this->sftp_link . '/' . ltrim($file, '/') )),3);
     234        }
     235
     236        function group($file) {
    238237                $gid = @filegroup('ssh2.sftp://' . $this->sftp_link . '/' . ltrim($file, '/'));
    239238                if ( ! $gid )
    … …  
    245244        }
    246245
    247         public function copy($source, $destination, $overwrite = false, $mode = false) {
     246        function copy($source, $destination, $overwrite = false, $mode = false) {
    248247                if ( ! $overwrite && $this->exists($destination) )
    249248                        return false;
    … …  
    254253        }
    255254
    256         public function move($source, $destination, $overwrite = false) {
     255        function move($source, $destination, $overwrite = false) {
    257256                return @ssh2_sftp_rename($this->link, $source, $destination);
    258257        }
    259258
    260         public function delete($file, $recursive = false, $type = false) {
     259        function delete($file, $recursive = false, $type = false) {
    261260                if ( 'f' == $type || $this->is_file($file) )
    262261                        return ssh2_sftp_unlink($this->sftp_link, $file);
    … …  
    272271        }
    273272
    274         public function exists($file) {
     273        function exists($file) {
    275274                $file = ltrim($file, '/');
    276275                return file_exists('ssh2.sftp://' . $this->sftp_link . '/' . $file);
    277276        }
    278277
    279         public function is_file($file) {
     278        function is_file($file) {
    280279                $file = ltrim($file, '/');
    281280                return is_file('ssh2.sftp://' . $this->sftp_link . '/' . $file);
    282281        }
    283282
    284         public function is_dir($path) {
     283        function is_dir($path) {
    285284                $path = ltrim($path, '/');
    286285                return is_dir('ssh2.sftp://' . $this->sftp_link . '/' . $path);
    287286        }
    288287
    289         public function is_readable($file) {
     288        function is_readable($file) {
    290289                $file = ltrim($file, '/');
    291290                return is_readable('ssh2.sftp://' . $this->sftp_link . '/' . $file);
    292291        }
    293292
    294         public function is_writable($file) {
     293        function is_writable($file) {
    295294                $file = ltrim($file, '/');
    296295                return is_writable('ssh2.sftp://' . $this->sftp_link . '/' . $file);
    297296        }
    298297
    299         public function atime($file) {
     298        function atime($file) {
    300299                $file = ltrim($file, '/');
    301300                return fileatime('ssh2.sftp://' . $this->sftp_link . '/' . $file);
    302301        }
    303302
    304         public function mtime($file) {
     303        function mtime($file) {
    305304                $file = ltrim($file, '/');
    306305                return filemtime('ssh2.sftp://' . $this->sftp_link . '/' . $file);
    307306        }
    308307
    309         public function size($file) {
     308        function size($file) {
    310309                $file = ltrim($file, '/');
    311310                return filesize('ssh2.sftp://' . $this->sftp_link . '/' . $file);
    312311        }
    313312
    314         public function touch($file, $time = 0, $atime = 0) {
     313        function touch($file, $time = 0, $atime = 0) {
    315314                //Not implemented.
    316315        }
    317316
    318         public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
     317        function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
    319318                $path = untrailingslashit($path);
    320319                if ( empty($path) )
    … …  
    332331        }
    333332
    334         public function rmdir($path, $recursive = false) {
     333        function rmdir($path, $recursive = false) {
    335334                return $this->delete($path, $recursive);
    336335        }
    337336
    338         public function dirlist($path, $include_hidden = true, $recursive = false) {
     337        function dirlist($path, $include_hidden = true, $recursive = false) {
    339338                if ( $this->is_file($path) ) {
    340339                        $limit_file = basename($path);
Note: See TracChangeset for help on using the changeset viewer.