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