- Timestamp:
- 06/19/2020 10:34:26 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-filesystem-ssh2.php
r48031 r48089 133 133 ) 134 134 ); 135 135 136 return false; 136 137 } … … 146 147 ) 147 148 ); 149 148 150 return false; 149 151 } … … 158 160 ) 159 161 ); 162 160 163 return false; 161 164 } … … 163 166 164 167 $this->sftp_link = ssh2_sftp( $this->link ); 168 165 169 if ( ! $this->sftp_link ) { 166 170 $this->errors->add( … … 172 176 ) 173 177 ); 178 174 179 return false; 175 180 } … … 195 200 $path = '/./'; 196 201 } 202 197 203 return 'ssh2.sftp://' . $this->sftp_link . '/' . ltrim( $path, '/' ); 198 204 } … … 212 218 213 219 $stream = ssh2_exec( $this->link, $command ); 220 214 221 if ( ! $stream ) { 215 222 $this->errors->add( … … 233 240 } 234 241 } 242 235 243 return false; 236 244 } … … 293 301 public function cwd() { 294 302 $cwd = ssh2_sftp_realpath( $this->sftp_link, '.' ); 303 295 304 if ( $cwd ) { 296 305 $cwd = trailingslashit( trim( $cwd ) ); 297 306 } 307 298 308 return $cwd; 299 309 } … … 326 336 return false; 327 337 } 338 328 339 if ( ! $recursive || ! $this->is_dir( $file ) ) { 329 340 return $this->run_command( sprintf( 'chgrp %s %s', escapeshellarg( $group ), escapeshellarg( $file ) ), true ); 330 341 } 342 331 343 return $this->run_command( sprintf( 'chgrp -R %s %s', escapeshellarg( $group ), escapeshellarg( $file ) ), true ); 332 344 } … … 362 374 return $this->run_command( sprintf( 'chmod %o %s', $mode, escapeshellarg( $file ) ), true ); 363 375 } 376 364 377 return $this->run_command( sprintf( 'chmod -R %o %s', $mode, escapeshellarg( $file ) ), true ); 365 378 } … … 380 393 return false; 381 394 } 395 382 396 if ( ! $recursive || ! $this->is_dir( $file ) ) { 383 397 return $this->run_command( sprintf( 'chown %s %s', escapeshellarg( $owner ), escapeshellarg( $file ) ), true ); 384 398 } 399 385 400 return $this->run_command( sprintf( 'chown -R %s %s', escapeshellarg( $owner ), escapeshellarg( $file ) ), true ); 386 401 } … … 396 411 public function owner( $file ) { 397 412 $owneruid = @fileowner( $this->sftp_path( $file ) ); 413 398 414 if ( ! $owneruid ) { 399 415 return false; 400 416 } 417 401 418 if ( ! function_exists( 'posix_getpwuid' ) ) { 402 419 return $owneruid; 403 420 } 421 404 422 $ownerarray = posix_getpwuid( $owneruid ); 423 405 424 if ( ! $ownerarray ) { 406 425 return false; 407 426 } 427 408 428 return $ownerarray['name']; 409 429 } … … 431 451 public function group( $file ) { 432 452 $gid = @filegroup( $this->sftp_path( $file ) ); 453 433 454 if ( ! $gid ) { 434 455 return false; 435 456 } 457 436 458 if ( ! function_exists( 'posix_getgrgid' ) ) { 437 459 return $gid; 438 460 } 461 439 462 $grouparray = posix_getgrgid( $gid ); 463 440 464 if ( ! $grouparray ) { 441 465 return false; 442 466 } 467 443 468 return $grouparray['name']; 444 469 } … … 461 486 return false; 462 487 } 488 463 489 $content = $this->get_contents( $source ); 490 464 491 if ( false === $content ) { 465 492 return false; 466 493 } 494 467 495 return $this->put_contents( $destination, $content, $mode ); 468 496 } … … 509 537 return ssh2_sftp_unlink( $this->sftp_link, $file ); 510 538 } 539 511 540 if ( ! $recursive ) { 512 541 return ssh2_sftp_rmdir( $this->sftp_link, $file ); 513 542 } 543 514 544 $filelist = $this->dirlist( $file ); 545 515 546 if ( is_array( $filelist ) ) { 516 547 foreach ( $filelist as $filename => $fileinfo ) { … … 518 549 } 519 550 } 551 520 552 return ssh2_sftp_rmdir( $this->sftp_link, $file ); 521 553 } … … 651 683 public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) { 652 684 $path = untrailingslashit( $path ); 685 653 686 if ( empty( $path ) ) { 654 687 return false; … … 658 691 $chmod = FS_CHMOD_DIR; 659 692 } 693 660 694 if ( ! ssh2_sftp_mkdir( $this->sftp_link, $path, $chmod, true ) ) { 661 695 return false; 662 696 } 697 663 698 if ( $chown ) { 664 699 $this->chown( $path, $chown ); 665 700 } 701 666 702 if ( $chgrp ) { 667 703 $this->chgrp( $path, $chgrp ); 668 704 } 705 669 706 return true; 670 707 } … … 765 802 $ret[ $struc['name'] ] = $struc; 766 803 } 804 767 805 $dir->close(); 768 806 unset( $dir ); 807 769 808 return $ret; 770 809 }
Note: See TracChangeset
for help on using the changeset viewer.