Changes from tags/3.7/src/wp-admin/includes/class-wp-filesystem-ssh2.php at r31381 to tags/4.0/src/wp-admin/includes/class-wp-filesystem-ssh2.php at r31381
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tags/4.0/src/wp-admin/includes/class-wp-filesystem-ssh2.php
r31381 r31381 36 36 class WP_Filesystem_SSH2 extends WP_Filesystem_Base { 37 37 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='') {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='') { 45 45 $this->method = 'ssh2'; 46 46 $this->errors = new WP_Error(); … … 86 86 87 87 if ( empty ($opt['password']) ) { 88 if ( !$this->keys ) //password can be blank if we are using keys 88 // Password can be blank if we are using keys. 89 if ( !$this->keys ) 89 90 $this->errors->add('empty_password', __('SSH2 password is required')); 90 91 } else { … … 94 95 } 95 96 96 function connect() {97 public function connect() { 97 98 if ( ! $this->keys ) { 98 99 $this->link = @ssh2_connect($this->options['hostname'], $this->options['port']); … … 123 124 } 124 125 125 function run_command( $command, $returnbool = false) {126 public function run_command( $command, $returnbool = false) { 126 127 127 128 if ( ! $this->link ) … … 144 145 } 145 146 146 function get_contents( $file ) {147 public function get_contents( $file ) { 147 148 $file = ltrim($file, '/'); 148 149 return file_get_contents('ssh2.sftp://' . $this->sftp_link . '/' . $file); 149 150 } 150 151 151 function get_contents_array($file) {152 public function get_contents_array($file) { 152 153 $file = ltrim($file, '/'); 153 154 return file('ssh2.sftp://' . $this->sftp_link . '/' . $file); 154 155 } 155 156 156 function put_contents($file, $contents, $mode = false ) {157 public function put_contents($file, $contents, $mode = false ) { 157 158 $ret = file_put_contents( 'ssh2.sftp://' . $this->sftp_link . '/' . ltrim( $file, '/' ), $contents ); 158 159 … … 165 166 } 166 167 167 function cwd() {168 public function cwd() { 168 169 $cwd = $this->run_command('pwd'); 169 170 if ( $cwd ) … … 172 173 } 173 174 174 function chdir($dir) {175 public function chdir($dir) { 175 176 return $this->run_command('cd ' . $dir, true); 176 177 } 177 178 178 function chgrp($file, $group, $recursive = false ) {179 public function chgrp($file, $group, $recursive = false ) { 179 180 if ( ! $this->exists($file) ) 180 181 return false; … … 184 185 } 185 186 186 function chmod($file, $mode = false, $recursive = false) {187 public function chmod($file, $mode = false, $recursive = false) { 187 188 if ( ! $this->exists($file) ) 188 189 return false; … … 212 213 * @return bool Returns true on success or false on failure. 213 214 */ 214 function chown( $file, $owner, $recursive = false ) {215 public function chown( $file, $owner, $recursive = false ) { 215 216 if ( ! $this->exists($file) ) 216 217 return false; … … 220 221 } 221 222 222 function owner($file) {223 public function owner($file) { 223 224 $owneruid = @fileowner('ssh2.sftp://' . $this->sftp_link . '/' . ltrim($file, '/')); 224 225 if ( ! $owneruid ) … … 230 231 } 231 232 232 function getchmod($file) {233 return substr( decoct(@fileperms( 'ssh2.sftp://' . $this->sftp_link . '/' . ltrim($file, '/') )),3);234 } 235 236 function group($file) {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) { 237 238 $gid = @filegroup('ssh2.sftp://' . $this->sftp_link . '/' . ltrim($file, '/')); 238 239 if ( ! $gid ) … … 244 245 } 245 246 246 function copy($source, $destination, $overwrite = false, $mode = false) {247 public function copy($source, $destination, $overwrite = false, $mode = false) { 247 248 if ( ! $overwrite && $this->exists($destination) ) 248 249 return false; … … 253 254 } 254 255 255 function move($source, $destination, $overwrite = false) {256 public function move($source, $destination, $overwrite = false) { 256 257 return @ssh2_sftp_rename($this->link, $source, $destination); 257 258 } 258 259 259 function delete($file, $recursive = false, $type = false) {260 public function delete($file, $recursive = false, $type = false) { 260 261 if ( 'f' == $type || $this->is_file($file) ) 261 262 return ssh2_sftp_unlink($this->sftp_link, $file); … … 271 272 } 272 273 273 function exists($file) {274 public function exists($file) { 274 275 $file = ltrim($file, '/'); 275 276 return file_exists('ssh2.sftp://' . $this->sftp_link . '/' . $file); 276 277 } 277 278 278 function is_file($file) {279 public function is_file($file) { 279 280 $file = ltrim($file, '/'); 280 281 return is_file('ssh2.sftp://' . $this->sftp_link . '/' . $file); 281 282 } 282 283 283 function is_dir($path) {284 public function is_dir($path) { 284 285 $path = ltrim($path, '/'); 285 286 return is_dir('ssh2.sftp://' . $this->sftp_link . '/' . $path); 286 287 } 287 288 288 function is_readable($file) {289 public function is_readable($file) { 289 290 $file = ltrim($file, '/'); 290 291 return is_readable('ssh2.sftp://' . $this->sftp_link . '/' . $file); 291 292 } 292 293 293 function is_writable($file) {294 public function is_writable($file) { 294 295 $file = ltrim($file, '/'); 295 296 return is_writable('ssh2.sftp://' . $this->sftp_link . '/' . $file); 296 297 } 297 298 298 function atime($file) {299 public function atime($file) { 299 300 $file = ltrim($file, '/'); 300 301 return fileatime('ssh2.sftp://' . $this->sftp_link . '/' . $file); 301 302 } 302 303 303 function mtime($file) {304 public function mtime($file) { 304 305 $file = ltrim($file, '/'); 305 306 return filemtime('ssh2.sftp://' . $this->sftp_link . '/' . $file); 306 307 } 307 308 308 function size($file) {309 public function size($file) { 309 310 $file = ltrim($file, '/'); 310 311 return filesize('ssh2.sftp://' . $this->sftp_link . '/' . $file); 311 312 } 312 313 313 function touch($file, $time = 0, $atime = 0) {314 public function touch($file, $time = 0, $atime = 0) { 314 315 //Not implemented. 315 316 } 316 317 317 function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {318 public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) { 318 319 $path = untrailingslashit($path); 319 320 if ( empty($path) ) … … 331 332 } 332 333 333 function rmdir($path, $recursive = false) {334 public function rmdir($path, $recursive = false) { 334 335 return $this->delete($path, $recursive); 335 336 } 336 337 337 function dirlist($path, $include_hidden = true, $recursive = false) {338 public function dirlist($path, $include_hidden = true, $recursive = false) { 338 339 if ( $this->is_file($path) ) { 339 340 $limit_file = basename($path);
Note: See TracChangeset
for help on using the changeset viewer.