~canonical-sysadmins/wordpress/3.9.x

« back to all changes in this revision

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

  • Committer: Paul Collins
  • Date: 2011-07-13 02:31:10 UTC
  • Revision ID: paul.collins@canonical.com-20110713023110-rvp7cjj31rsaomkr
import Wordpress 3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
        var $errors = array();
49
49
        var $options = array();
50
50
 
51
 
        function WP_Filesystem_SSH2($opt='') {
 
51
        function __construct($opt='') {
52
52
                $this->method = 'ssh2';
53
53
                $this->errors = new WP_Error();
54
54
 
238
238
                return $grouparray['name'];
239
239
        }
240
240
 
241
 
        function copy($source, $destination, $overwrite = false ) {
 
241
        function copy($source, $destination, $overwrite = false, $mode = false) {
242
242
                if ( ! $overwrite && $this->exists($destination) )
243
243
                        return false;
244
244
                $content = $this->get_contents($source);
245
245
                if ( false === $content)
246
246
                        return false;
247
 
                return $this->put_contents($destination, $content);
 
247
                return $this->put_contents($destination, $content, $mode);
248
248
        }
249
249
 
250
250
        function move($source, $destination, $overwrite = false) {
251
251
                return @ssh2_sftp_rename($this->link, $source, $destination);
252
252
        }
253
253
 
254
 
        function delete($file, $recursive = false) {
255
 
                if ( $this->is_file($file) )
 
254
        function delete($file, $recursive = false, $type = false) {
 
255
                if ( 'f' == $type || $this->is_file($file) )
256
256
                        return ssh2_sftp_unlink($this->sftp_link, $file);
257
257
                if ( ! $recursive )
258
258
                         return ssh2_sftp_rmdir($this->sftp_link, $file);
259
259
                $filelist = $this->dirlist($file);
260
260
                if ( is_array($filelist) ) {
261
261
                        foreach ( $filelist as $filename => $fileinfo) {
262
 
                                $this->delete($file . '/' . $filename, $recursive);
 
262
                                $this->delete($file . '/' . $filename, $recursive, $fileinfo['type']);
263
263
                        }
264
264
                }
265
265
                return ssh2_sftp_rmdir($this->sftp_link, $file);