else
$this->options['hostname'] = $opt['hostname'];
- if ( isset($opt['base']) && ! empty($opt['base']) )
+ if ( ! empty($opt['base']) )
$this->wp_base = $opt['base'];
// Check if the options provided are OK.
return file('ssh2.sftp://' . $this->sftp_link . '/' . $file);
}
- function put_contents($file, $contents, $type = '' ) {
+ function put_contents($file, $contents, $mode = false ) {
$file = ltrim($file, '/');
- return false !== file_put_contents('ssh2.sftp://' . $this->sftp_link . '/' . $file, $contents);
+ $ret = file_put_contents('ssh2.sftp://' . $this->sftp_link . '/' . $file, $contents);
+
+ $this->chmod($file, $mode);
+
+ return false !== $ret;
}
function cwd() {
$cwd = $this->run_command('pwd');
- if( $cwd )
+ if ( $cwd )
$cwd = trailingslashit($cwd);
return $cwd;
}
}
function copy($source, $destination, $overwrite = false ) {
- if( ! $overwrite && $this->exists($destination) )
+ if ( ! $overwrite && $this->exists($destination) )
return false;
$content = $this->get_contents($source);
- if( false === $content)
+ if ( false === $content)
return false;
return $this->put_contents($destination, $content);
}