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