class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
public $link = false;
- public $sftp_link = false;
+ /**
+ * @var resource
+ */
+ public $sftp_link;
public $keys = false;
- public $errors = array();
- public $options = array();
public function __construct($opt='') {
$this->method = 'ssh2';
//Check if possible to use ssh2 functions.
if ( ! extension_loaded('ssh2') ) {
$this->errors->add('no_ssh2_ext', __('The ssh2 PHP extension is not available'));
- return false;
+ return;
}
if ( !function_exists('stream_get_contents') ) {
$this->errors->add('ssh2_php_requirement', __('The ssh2 PHP extension is available, however, we require the PHP5 function <code>stream_get_contents()</code>'));
- return false;
+ return;
}
// Set defaults:
else
$this->options['hostname'] = $opt['hostname'];
- if ( ! empty($opt['base']) )
- $this->wp_base = $opt['base'];
-
// Check if the options provided are OK.
if ( !empty ($opt['public_key']) && !empty ($opt['private_key']) ) {
$this->options['public_key'] = $opt['public_key'];
/**
* @param string $command
* @param bool $returnbool
+ * @return bool|string
*/
public function run_command( $command, $returnbool = false) {
public function cwd() {
$cwd = $this->run_command('pwd');
- if ( $cwd )
- $cwd = trailingslashit($cwd);
+ if ( $cwd ) {
+ $cwd = trailingslashit( trim( $cwd ) );
+ }
return $cwd;
}
/**
* @param string $dir
- * @return bool
+ * @return bool|string
*/
public function chdir($dir) {
return $this->run_command('cd ' . $dir, true);
* @param string $file
* @param int $mode
* @param bool $recursive
- * @return bool
+ * @return bool|string
*/
public function chmod($file, $mode = false, $recursive = false) {
if ( ! $this->exists($file) )