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