Ticket #7690: 7690.14.diff
| File 7690.14.diff, 4.7 KB (added by , 18 years ago) |
|---|
-
wp-admin/includes/class-wp-filesystem-ssh2.php
63 63 $this->method = 'ssh2'; 64 64 $this->errors = new WP_Error(); 65 65 66 //Check if possible to use ftpfunctions.66 //Check if possible to use ssh2 functions. 67 67 if ( ! extension_loaded('ssh2') ) { 68 68 $this->errors->add('no_ssh2_ext', __('The ssh2 PHP extension is not available')); 69 69 return false; … … 89 89 else 90 90 $this->options['username'] = $opt['username']; 91 91 92 if ( ( !empty ($opt['public_key']) ) && ( !empty ($opt['private_key']) )) {92 if ( ( !empty ($opt['public_key']) ) && ( !empty ($opt['private_key']) ) ) { 93 93 $this->options['public_key'] = $opt['public_key']; 94 94 $this->options['private_key'] = $opt['private_key']; 95 95 … … 99 99 } 100 100 101 101 102 if ( empty ($opt['password']) ) 102 if ( empty ($opt['password']) ) { 103 103 if ( !$this->keys ) // password can be blank if we are using keys 104 104 $this->errors->add('empty_password', __('SSH2 password is required')); 105 else105 } else { 106 106 $this->options['password'] = $opt['password']; 107 } 107 108 108 109 } 109 110 110 111 function connect() { 111 112 $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 } 116 119 117 120 if ( ! $this->link ) { 118 121 $this->errors->add('connect', sprintf(__('Failed to connect to SSH2 Server %1$s:%2$s'), $this->options['hostname'], $this->options['port'])); … … 326 329 function is_dir($path) { 327 330 $this->debug("is_dir();"); 328 331 //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', untrailinslashit($path)))); 330 333 if ( ! $list ) 331 334 return false; 332 335 else … … 359 362 360 363 function mkdir($path, $chmod = null, $chown = false, $chgrp = false) { 361 364 $this->debug("mkdir();"); 362 $path = trim($path, '/');365 $path = untrailingslashit($path); 363 366 if( ! ssh2_sftp_mkdir($this->sftp_link, $path, $chmod, true) ) 364 367 return false; 365 368 if( $chown ) -
wp-admin/includes/file.php
386 386 if ( 0 == count($archive_files) ) 387 387 return new WP_Error('empty_archive', __('Empty archive')); 388 388 389 $path = explode('/', $to);389 $path = explode('/', untrailingslashit($to)); 390 390 for ( $i = count($path); $i > 0; $i-- ) { //>0 = first element is empty allways for paths starting with '/' 391 391 $tmppath = implode('/', array_slice($path, 0, $i) ); 392 392 if ( $fs->is_dir($tmppath) ) { //Found the highest folder that exists, Create from here(ie +1) … … 401 401 402 402 $to = trailingslashit($to); 403 403 foreach ($archive_files as $file) { 404 $path = explode('/', $file['filename']);404 $path = explode('/', untrailingslashit($file['filename'])); 405 405 for ( $i = count($path) - 1; $i >= 0; $i-- ) { //>=0 as the first element contains data, count()-1, as we do not want the file component 406 406 $tmppath = $to . implode('/', array_slice($path, 0, $i) ); 407 407 if ( $fs->is_dir($tmppath) ) {//Found the highest folder that exists, Create from here … … 521 521 $credentials['connection_type'] = 'ssh'; 522 522 else if ( defined('FTP_SSL') || (isset($_POST['connection_type']) && 'ftps' == $_POST['connection_type']) ) 523 523 $credentials['connection_type'] = 'ftps'; 524 else 524 else if ( ! isset($_POST['connection_type']) || 'ftp' == $_POST['connection_type'] ) 525 525 $credentials['connection_type'] = 'ftp'; 526 526 527 527 if ( ! $error && !empty($credentials['password']) && !empty($credentials['username']) && !empty($credentials['hostname']) ) { … … 566 566 </script> 567 567 <form action="<?php echo $form_post ?>" method="post"> 568 568 <div class="wrap"> 569 <h2><?php _e(' FTPConnection Information') ?></h2>570 <p><?php _e('To perform the requested action, FTPconnection information is required.') ?></p>569 <h2><?php _e('Connection Information') ?></h2> 570 <p><?php _e('To perform the requested action, connection information is required.') ?></p> 571 571 <table class="form-table"> 572 572 <tr valign="top"> 573 573 <th scope="row"><label for="hostname"><?php _e('Hostname') ?></label></th>