Ticket #18476: 18476.diff
| File 18476.diff, 18.1 KB (added by , 12 years ago) |
|---|
-
src/wp-admin/includes/class-wp-filesystem-base.php
12 12 * @since 2.5 13 13 */ 14 14 class WP_Filesystem_Base { 15 15 16 /** 16 17 * Whether to display debug data for the connection. 17 18 * 18 * @since 2.519 19 * @access public 20 * @since 2.5.0 20 21 * @var bool 21 22 */ 22 23 var $verbose = false; 24 23 25 /** 24 26 * Cached list of local filepaths to mapped remote filepaths. 25 27 * 26 * @since 2.727 28 * @access private 29 * @since 2.7.0 28 30 * @var array 29 31 */ 30 32 var $cache = array(); … … 32 34 /** 33 35 * The Access method of the current connection, Set automatically. 34 36 * 35 * @since 2.536 37 * @access public 38 * @since 2.5.0 37 39 * @var string 38 40 */ 39 41 var $method = ''; 40 42 41 43 /** 42 * Returns the path on the remote filesystem of ABSPATH 44 * Constructor (empty). 45 */ 46 function __construct() {} 47 48 /** 49 * Return the path on the remote filesystem of ABSPATH. 43 50 * 44 * @since 2.745 51 * @access public 52 * @since 2.7.0 53 * 46 54 * @return string The location of the remote path. 47 55 */ 48 56 function abspath() { … … 53 61 return $folder; 54 62 } 55 63 /** 56 * Return s the path on the remote filesystem of WP_CONTENT_DIR64 * Return the path on the remote filesystem of WP_CONTENT_DIR. 57 65 * 58 * @since 2.759 66 * @access public 67 * @since 2.7.0 68 * 60 69 * @return string The location of the remote path. 61 70 */ 62 71 function wp_content_dir() { 63 72 return $this->find_folder(WP_CONTENT_DIR); 64 73 } 65 74 /** 66 * Return s the path on the remote filesystem of WP_PLUGIN_DIR75 * Return the path on the remote filesystem of WP_PLUGIN_DIR. 67 76 * 68 * @since 2.769 77 * @access public 78 * @since 2.7.0 70 79 * 71 80 * @return string The location of the remote path. 72 81 */ … … 74 83 return $this->find_folder(WP_PLUGIN_DIR); 75 84 } 76 85 /** 77 * Return s the path on the remote filesystem of the Themes Directory86 * Return the path on the remote filesystem of the Themes Directory. 78 87 * 79 * @since 2.780 88 * @access public 89 * @since 2.7.0 81 90 * 82 * @param string $theme The Theme stylesheet or template for the directory 91 * @param string $theme The Theme stylesheet or template for the directory. 83 92 * @return string The location of the remote path. 84 93 */ 85 94 function wp_themes_dir( $theme = false ) { … … 92 101 return $this->find_folder( $theme_root ); 93 102 } 94 103 /** 95 * Return s the path on the remote filesystem of WP_LANG_DIR104 * Return the path on the remote filesystem of WP_LANG_DIR. 96 105 * 106 * @access public 97 107 * @since 3.2.0 98 * @access public99 108 * 100 109 * @return string The location of the remote path. 101 110 */ … … 104 113 } 105 114 106 115 /** 107 * Locate sa folder on the remote filesystem.116 * Locate a folder on the remote filesystem. 108 117 * 109 * Deprecated; use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() methods instead.110 *111 * @since 2.5112 * @deprecated 2.7113 118 * @access public 119 * @since 2.5.0 120 * @deprecated 2.7.0 use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() instead. 121 * @see WP_Filesystem::abspath() 122 * @see WP_Filesystem::wp_content_dir() 123 * @see WP_Filesystem::wp_plugins_dir() 124 * @see WP_Filesystem::wp_themes_dir() 125 * @see WP_Filesystem::wp_lang_dir() 114 126 * 115 * @param string $base The folder to start searching from 116 * @param bool $echo True to display debug information127 * @param string $base The folder to start searching from. 128 * @param bool $echo True to display debug information. 117 129 * @return string The location of the remote path. 118 130 */ 119 function find_base_dir( $base = '.', $echo = false) {131 function find_base_dir( $base = '.', $echo = false ) { 120 132 _deprecated_function(__FUNCTION__, '2.7', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' ); 121 133 $this->verbose = $echo; 122 134 return $this->abspath(); 123 135 } 124 136 /** 125 * Locate sa folder on the remote filesystem.137 * Locate a folder on the remote filesystem. 126 138 * 127 * Deprecated; use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() methods instead.128 *129 * @since 2.5130 * @deprecated 2.7131 139 * @access public 140 * @since 2.5.0 141 * @deprecated 2.7.0 use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() methods instead. 142 * @see WP_Filesystem::abspath() 143 * @see WP_Filesystem::wp_content_dir() 144 * @see WP_Filesystem::wp_plugins_dir() 145 * @see WP_Filesystem::wp_themes_dir() 146 * @see WP_Filesystem::wp_lang_dir() 132 147 * 133 * @param string $base The folder to start searching from 134 * @param bool $echo True to display debug information148 * @param string $base The folder to start searching from. 149 * @param bool $echo True to display debug information. 135 150 * @return string The location of the remote path. 136 151 */ 137 function get_base_dir( $base = '.', $echo = false) {152 function get_base_dir( $base = '.', $echo = false ) { 138 153 _deprecated_function(__FUNCTION__, '2.7', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' ); 139 154 $this->verbose = $echo; 140 155 return $this->abspath(); 141 156 } 142 157 143 158 /** 144 * Locate sa folder on the remote filesystem.159 * Locate a folder on the remote filesystem. 145 160 * 146 * Assumes that on Windows systems, Stripping off the Drive letter is OK147 * Sanitizes \\ to / in windows filepaths.161 * Assumes that on Windows systems, Stripping off the Drive 162 * letter is OK Sanitizes \\ to / in windows filepaths. 148 163 * 149 * @since 2.7150 164 * @access public 165 * @since 2.7.0 151 166 * 152 * @param string $folder the folder to locate 167 * @param string $folder the folder to locate. 153 168 * @return string The location of the remote path. 154 169 */ 155 function find_folder( $folder) {170 function find_folder( $folder ) { 156 171 157 172 if ( isset( $this->cache[ $folder ] ) ) 158 173 return $this->cache[ $folder ]; … … 209 224 } 210 225 211 226 /** 212 * Locate sa folder on the remote filesystem.227 * Locate a folder on the remote filesystem. 213 228 * 214 * Expects Windows sanitized path 229 * Expects Windows sanitized path. 215 230 * 216 * @since 2.7217 231 * @access private 232 * @since 2.7.0 218 233 * 219 * @param string $folder the folder to locate220 * @param string $base the folder to start searching from221 * @param bool $loop if the function has recursed, Internal use only234 * @param string $folder The folder to locate. 235 * @param string $base The folder to start searching from. 236 * @param bool $loop If the function has recursed, Internal use only. 222 237 * @return string The location of the remote path. 223 238 */ 224 function search_for_folder( $folder, $base = '.', $loop = false ) {239 function search_for_folder( $folder, $base = '.', $loop = false ) { 225 240 if ( empty( $base ) || '.' == $base ) 226 241 $base = trailingslashit($this->cwd()); 227 242 … … 276 291 } 277 292 278 293 /** 279 * Return s the *nix style file permissions for a file294 * Return the *nix-style file permissions for a file. 280 295 * 281 * From the PHP documentation page for fileperms() 296 * From the PHP documentation page for fileperms(). 282 297 * 283 298 * @link http://docs.php.net/fileperms 284 * @since 2.5299 * 285 300 * @access public 301 * @since 2.5.0 286 302 * 287 * @param string $file string filename288 * @return string *nix style representation of permissions303 * @param string $file String filename. 304 * @return string The *nix-style representation of permissions. 289 305 */ 290 function gethchmod( $file){306 function gethchmod( $file ){ 291 307 $perms = $this->getchmod($file); 292 308 if (($perms & 0xC000) == 0xC000) // Socket 293 309 $info = 's'; … … 330 346 } 331 347 332 348 /** 333 * Convert s *nixstyle file permissions to a octal number.349 * Convert *nix-style file permissions to a octal number. 334 350 * 335 351 * Converts '-rw-r--r--' to 0644 336 352 * From "info at rvgate dot nl"'s comment on the PHP documentation for chmod() 337 353 * 338 354 * @link http://docs.php.net/manual/en/function.chmod.php#49614 339 * @since 2.5355 * 340 356 * @access public 357 * @since 2.5.0 341 358 * 342 * @param string $mode string *nix style file permission359 * @param string $mode string The *nix-style file permission. 343 360 * @return int octal representation 344 361 */ 345 362 function getnumchmodfromh($mode) { … … 363 380 } 364 381 365 382 /** 366 * Determine sif the string provided contains binary characters.383 * Determine if the string provided contains binary characters. 367 384 * 368 * @since 2.7369 385 * @access private 386 * @since 2.7.0 370 387 * 371 * @param string $text String to test against 372 * @return bool true if string is binary, false otherwise 388 * @param string $text String to test against. 389 * @return bool true if string is binary, false otherwise. 373 390 */ 374 391 function is_binary( $text ) { 375 392 return (bool) preg_match('|[^\x20-\x7E]|', $text); //chr(32)..chr(127) 376 393 } 394 395 /** 396 * Change the ownership of a file / folder. 397 * 398 * Default behavior is to do nothing, override this in your subclass, if desired. 399 * 400 * @since Unknown 401 * 402 * @param string $file Path to the file. 403 * @param mixed $owner A user name or number. 404 * @param bool $recursive (optional) If set True changes file owner recursivly. Defaults to False. 405 * @return bool Returns true on success or false on failure. 406 */ 407 function chown( $file, $owner, $recursive = false ) { 408 return false; 409 } 410 411 /** 412 * Connect filesystem. 413 * 414 * @since Unknown 415 * 416 * @return bool True on success or false on failure (always true for WP_Filesystem_Direct). 417 */ 418 function connect() { 419 return true; 420 } 421 422 /** 423 * Read entire file into a string. 424 * 425 * @since Unknown 426 * 427 * @param string $file Name of the file to read. 428 * @return string|bool Returns the read data or false on failure. 429 */ 430 function get_contents( $file ) { 431 return false; 432 } 433 434 /** 435 * Read entire file into an array. 436 * 437 * @since Unknown 438 * 439 * @param string $file Path to the file. 440 * @return array|bool the file contents in an array or false on failure. 441 */ 442 function get_contents_array( $file ) { 443 return false; 444 } 445 446 /** 447 * Write a string to a file. 448 * 449 * @since Unknown 450 * 451 * @param string $file Remote path to the file where to write the data. 452 * @param string $contents The data to write. 453 * @param int $mode (optional) The file permissions as octal number, usually 0644. 454 * @return bool False on failure. 455 */ 456 function put_contents( $file, $contents, $mode = false ) { 457 return false; 458 } 459 460 /** 461 * Get the current working directory. 462 * 463 * @since Unknown 464 * 465 * @return string|bool The current working directory on success, or false on failure. 466 */ 467 function cwd() { 468 return false; 469 } 470 471 /** 472 * Change current directory. 473 * 474 * @since Unknown 475 * 476 * @param string $dir The new current directory. 477 * @return bool Returns true on success or false on failure. 478 */ 479 function chdir( $dir ) { 480 return false; 481 } 482 483 /** 484 * Change the file group. 485 * 486 * @since Unknown 487 * 488 * @param string $file Path to the file. 489 * @param mixed $group A group name or number. 490 * @param bool $recursive (optional) If set True changes file group recursivly. Defaults to False. 491 * @return bool Returns true on success or false on failure. 492 */ 493 function chgrp( $file, $group, $recursive = false ) { 494 return false; 495 } 496 497 /** 498 * Change filesystem permissions. 499 * 500 * @since Unknown 501 * 502 * @param string $file Path to the file. 503 * @param int $mode (optional) The permissions as octal number, usually 0644 for files, 0755 for dirs. 504 * @param bool $recursive (optional) If set True changes file group recursivly. Defaults to False. 505 * @return bool Returns true on success or false on failure. 506 */ 507 function chmod( $file, $mode = false, $recursive = false ) { 508 return false; 509 } 510 511 /** 512 * Get the file owner. 513 * 514 * @since Unknown 515 * 516 * @param string $file Path to the file. 517 * @return string|bool Username of the user or false on error. 518 */ 519 function owner($file) { 520 return false; 521 } 522 523 /** 524 * Get the file's group. 525 * 526 * @since Unknown 527 * 528 * @param string $file Path to the file. 529 * @return string|bool The group or false on error. 530 */ 531 function group($file) { 532 return false; 533 } 534 535 /** 536 * Copy a file. 537 * 538 * @since Unknown 539 * 540 * @param string $source 541 * @param string $destination 542 * @param bool $overwrite 543 * @param int $mode 544 * @return bool 545 */ 546 function copy( $source, $destination, $overwrite = false, $mode = false ) { 547 return false; 548 } 549 550 /** 551 * Move a file. 552 * 553 * @since Unknown 554 * 555 * @param string $source 556 * @param string $destination 557 * @param bool $overwrite 558 * @return bool 559 */ 560 function move( $source, $destination, $overwrite = false ) { 561 return false; 562 } 563 564 /** 565 * Delete a file / directory. 566 * 567 * @since Unknown 568 * 569 * @param string $file 570 * @param bool $recursive 571 * @param type $type (f = file, other values = directory). 572 * @return bool 573 */ 574 function delete( $file, $recursive = false, $type = false ) { 575 return false; 576 } 577 578 /** 579 * Check if a file exists. 580 * 581 * @since Unknown 582 * 583 * @param string $file 584 * @return bool 585 */ 586 function exists($file) { 587 return false; 588 } 589 590 /** 591 * Check if a file is a regular file. 592 * 593 * @since Unknown 594 * 595 * @param string $file 596 * @return bool 597 */ 598 function is_file( $file ) { 599 return false; 600 } 601 602 /** 603 * Check if a path is a directory. 604 * 605 * @since Unknown 606 * 607 * @param string $path 608 * @return bool 609 */ 610 function is_dir( $path ) { 611 return false; 612 } 613 614 /** 615 * Check if a file is readable. 616 * 617 * @since Unknown 618 * 619 * @param string $file 620 * @return bool 621 */ 622 function is_readable( $file ) { 623 return false; 624 } 625 626 /** 627 * Check if a file is writable. 628 * 629 * @since Unknown 630 * 631 * @param string $file 632 * @return bool 633 */ 634 function is_writable( $file ) { 635 return false; 636 } 637 638 /** 639 * Get a file's last access time. 640 * 641 * @since Unknown 642 * 643 * @param string $file 644 * @return int|bool 645 */ 646 function atime( $file ) { 647 return false; 648 } 649 650 /** 651 * Get a file's last modified time. 652 * 653 * @since Unknown 654 * 655 * @param string $file 656 * @return int|bool 657 */ 658 function mtime( $file ) { 659 return false; 660 } 661 662 /** 663 * Get a file's size. 664 * 665 * @since Unknown 666 * 667 * @param string $file 668 * @return int|bool 669 */ 670 function size( $file ) { 671 return false; 672 } 673 674 /** 675 * Update a file's access time and modified time. 676 * 677 * @since Unknown 678 * 679 * @param string $file 680 * @param int $time 681 * @param int $atime 682 * @return bool 683 */ 684 function touch( $file, $time = 0, $atime = 0 ) { 685 return false; 686 } 687 688 /** 689 * Create a directory. 690 * 691 * @since Unknown 692 * 693 * @param string $path 694 * @param string|int|false $chmod 695 * @param string|int|false $chown 696 * @param string|int|false $chgrp 697 * @return bool 698 */ 699 function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) { 700 return false; 701 } 702 703 /** 704 * Delete a directory. 705 * 706 * @since Unknown 707 * 708 * @param string $path 709 * @param bool $recursive 710 * @return bool 711 */ 712 function rmdir( $path, $recursive = false ) { 713 return false; 714 } 715 716 /** 717 * Get a recursive directory listing. 718 * 719 * @since Unknown 720 * 721 * @param string $path 722 * @param bool $include_hidden 723 * @param bool $recursive 724 * @return array|bool 725 */ 726 function dirlist( $path, $include_hidden = true, $recursive = false ) { 727 return false; 728 } 377 729 } -
src/wp-admin/includes/class-wp-filesystem-direct.php
15 15 * @uses WP_Filesystem_Base Extends class 16 16 */ 17 17 class WP_Filesystem_Direct extends WP_Filesystem_Base { 18 var $errors = null; 18 19 19 /** 20 20 * constructor 21 21 * … … 26 26 $this->errors = new WP_Error(); 27 27 } 28 28 /** 29 * connect filesystem.30 *31 * @return bool Returns true on success or false on failure (always true for WP_Filesystem_Direct).32 */33 function connect() {34 return true;35 }36 /**37 29 * Reads entire file into a string 38 30 * 39 31 * @param string $file Name of the file to read. … … 161 153 * Gets file owner 162 154 * 163 155 * @param string $file Path to the file. 164 * @return string Username of the user.156 * @return string|bool Username of the user or false on error. 165 157 */ 166 158 function owner($file) { 167 159 $owneruid = @fileowner($file); -
src/wp-admin/includes/class-wp-filesystem-ftpext.php
168 168 return (bool)@ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file)); 169 169 return (bool)@ftp_chmod($this->link, $mode, $file); 170 170 } 171 function chown($file, $owner, $recursive = false ) {172 return false;173 }174 171 function owner($file) { 175 172 $dir = $this->dirlist($file); 176 173 return $dir[$file]['owner']; -
src/wp-admin/includes/class-wp-filesystem-ftpsockets.php
174 174 return $this->ftp->chmod($file, $mode); 175 175 } 176 176 177 function chown($file, $owner, $recursive = false ) {178 return false;179 }180 181 177 function owner($file) { 182 178 $dir = $this->dirlist($file); 183 179 return $dir[$file]['owner']; -
src/wp-admin/includes/class-wp-filesystem-ssh2.php
206 206 return $this->run_command(sprintf('chmod -R %o %s', $mode, escapeshellarg($file)), true); 207 207 } 208 208 209 function chown($file, $owner, $recursive = false ) { 209 /** 210 * Change the ownership of a file / folder. 211 * 212 * @since Unknown 213 * 214 * @param string $file Path to the file. 215 * @param mixed $owner A user name or number. 216 * @param bool $recursive (optional) If set True changes file owner recursivly. Defaults to False. 217 * @return bool Returns true on success or false on failure. 218 */ 219 function chown( $file, $owner, $recursive = false ) { 210 220 if ( ! $this->exists($file) ) 211 221 return false; 212 222 if ( ! $recursive || ! $this->is_dir($file) )