- Timestamp:
- 04/17/2019 04:12:27 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-filesystem-ftpext.php
r42343 r45226 15 15 */ 16 16 class WP_Filesystem_FTPext extends WP_Filesystem_Base { 17 18 /** 19 * @since 2.5.0 20 * @var resource 21 */ 17 22 public $link; 18 23 19 24 /** 25 * Constructor. 26 * 27 * @since 2.5.0 28 * 20 29 * @param array $opt 21 30 */ … … 68 77 69 78 /** 70 * @return bool 79 * Connects filesystem. 80 * 81 * @since 2.5.0 82 * 83 * @return bool True on success, false on failure. 71 84 */ 72 85 public function connect() { … … 111 124 112 125 /** 113 * Re trieves the file contents.114 * 115 * @since 2.5.0 116 * 117 * @param string $file Filename.118 * @return string|false File contents on success, false if no tempfile could be opened,126 * Reads entire file into a string. 127 * 128 * @since 2.5.0 129 * 130 * @param string $file Name of the file to read. 131 * @return string|false Read data on success, false if no temporary file could be opened, 119 132 * or if the file couldn't be retrieved. 120 133 */ … … 138 151 139 152 while ( ! feof( $temp ) ) { 140 $contents .= fread( $temp, 8 192);153 $contents .= fread( $temp, 8 * KB_IN_BYTES ); 141 154 } 142 155 … … 147 160 148 161 /** 149 * @param string $file 150 * @return array 162 * Reads entire file into an array. 163 * 164 * @since 2.5.0 165 * 166 * @param string $file Path to the file. 167 * @return array|false File contents in an array on success, false on failure. 151 168 */ 152 169 public function get_contents_array( $file ) { … … 155 172 156 173 /** 157 * @param string $file 158 * @param string $contents 159 * @param bool|int $mode 160 * @return bool 174 * Writes a string to a file. 175 * 176 * @since 2.5.0 177 * 178 * @param string $file Remote path to the file where to write the data. 179 * @param string $contents The data to write. 180 * @param int|false $mode Optional. The file permissions as octal number, usually 0644. 181 * Default false. 182 * @return bool True on success, false on failure. 161 183 */ 162 184 public function put_contents( $file, $contents, $mode = false ) { … … 195 217 196 218 /** 197 * @return string 219 * Gets the current working directory. 220 * 221 * @since 2.5.0 222 * 223 * @return string|false The current working directory on success, false on failure. 198 224 */ 199 225 public function cwd() { … … 206 232 207 233 /** 208 * @param string $dir 209 * @return bool 234 * Changes current directory. 235 * 236 * @since 2.5.0 237 * 238 * @param string $dir The new current directory. 239 * @return bool True on success, false on failure. 210 240 */ 211 241 public function chdir( $dir ) { … … 214 244 215 245 /** 216 * @param string $file 217 * @param int $mode 218 * @param bool $recursive 219 * @return bool 246 * Changes filesystem permissions. 247 * 248 * @since 2.5.0 249 * 250 * @param string $file Path to the file. 251 * @param int|false $mode Optional. The permissions as octal number, usually 0644 for files, 252 * 0755 for directories. Default false. 253 * @param bool $recursive Optional. If set to true, changes file group recursively. 254 * Default false. 255 * @return bool True on success, false on failure. 220 256 */ 221 257 public function chmod( $file, $mode = false, $recursive = false ) { … … 246 282 247 283 /** 248 * @param string $file 249 * @return string 284 * Gets the file owner. 285 * 286 * @since 2.5.0 287 * 288 * @param string $file Path to the file. 289 * @return string|false Username of the owner on success, false on failure. 250 290 */ 251 291 public function owner( $file ) { … … 253 293 return $dir[ $file ]['owner']; 254 294 } 255 /** 256 * @param string $file 257 * @return string 295 296 /** 297 * Gets the permissions of the specified file or filepath in their octal format. 298 * 299 * @since 2.5.0 300 * 301 * @param string $file Path to the file. 302 * @return string Mode of the file (the last 3 digits). 258 303 */ 259 304 public function getchmod( $file ) { … … 263 308 264 309 /** 265 * @param string $file 266 * @return string 310 * Gets the file's group. 311 * 312 * @since 2.5.0 313 * 314 * @param string $file Path to the file. 315 * @return string|false The group on success, false on failure. 267 316 */ 268 317 public function group( $file ) { … … 272 321 273 322 /** 274 * @param string $source 275 * @param string $destination 276 * @param bool $overwrite 277 * @param string|bool $mode 278 * @return bool 323 * Copies a file. 324 * 325 * @since 2.5.0 326 * 327 * @param string $source Path to the source file. 328 * @param string $destination Path to the destination file. 329 * @param bool $overwrite Optional. Whether to overwrite the destination file if it exists. 330 * Default false. 331 * @param int|false $mode Optional. The permissions as octal number, usually 0644 for files, 332 * 0755 for dirs. Default false. 333 * @return bool True on success, false on failure. 279 334 */ 280 335 public function copy( $source, $destination, $overwrite = false, $mode = false ) { … … 290 345 291 346 /** 292 * @param string $source 293 * @param string $destination 294 * @param bool $overwrite 295 * @return bool 347 * Moves a file. 348 * 349 * @since 2.5.0 350 * 351 * @param string $source Path to the source file. 352 * @param string $destination Path to the destination file. 353 * @param bool $overwrite Optional. Whether to overwrite the destination file if it exists. 354 * Default false. 355 * @return bool True on success, false on failure. 296 356 */ 297 357 public function move( $source, $destination, $overwrite = false ) { … … 300 360 301 361 /** 302 * @param string $file 303 * @param bool $recursive 304 * @param string $type 305 * @return bool 362 * Deletes a file or directory. 363 * 364 * @since 2.5.0 365 * 366 * @param string $file Path to the file or directory. 367 * @param bool $recursive Optional. If set to true, changes file group recursively. 368 * Default false. 369 * @param string|false $type Type of resource. 'f' for file, 'd' for directory. 370 * Default false. 371 * @return bool True on success, false on failure. 306 372 */ 307 373 public function delete( $file, $recursive = false, $type = false ) { … … 326 392 327 393 /** 328 * @param string $file 329 * @return bool 394 * Checks if a file or directory exists. 395 * 396 * @since 2.5.0 397 * 398 * @param string $file Path to file or directory. 399 * @return bool Whether $file exists or not. 330 400 */ 331 401 public function exists( $file ) { … … 340 410 341 411 /** 342 * @param string $file 343 * @return bool 412 * Checks if resource is a file. 413 * 414 * @since 2.5.0 415 * 416 * @param string $file File path. 417 * @return bool Whether $file is a file. 344 418 */ 345 419 public function is_file( $file ) { … … 348 422 349 423 /** 350 * @param string $path 351 * @return bool 424 * Checks if resource is a directory. 425 * 426 * @since 2.5.0 427 * 428 * @param string $path Directory path. 429 * @return bool Whether $path is a directory. 352 430 */ 353 431 public function is_dir( $path ) { … … 362 440 363 441 /** 364 * @param string $file 365 * @return bool 442 * Checks if a file is readable. 443 * 444 * @since 2.5.0 445 * 446 * @param string $file Path to file. 447 * @return bool Whether $file is readable. 366 448 */ 367 449 public function is_readable( $file ) { … … 370 452 371 453 /** 372 * @param string $file 373 * @return bool 454 * Checks if a file or directory is writable. 455 * 456 * @since 2.5.0 457 * 458 * @param string $file Path to file or directory. 459 * @return bool Whether $file is writable. 374 460 */ 375 461 public function is_writable( $file ) { … … 378 464 379 465 /** 380 * @param string $file 381 * @return bool 466 * Gets the file's last access time. 467 * 468 * @since 2.5.0 469 * 470 * @param string $file Path to file. 471 * @return int|false Unix timestamp representing last access time, false on failure. 382 472 */ 383 473 public function atime( $file ) { … … 386 476 387 477 /** 388 * @param string $file 389 * @return int 478 * Gets the file modification time. 479 * 480 * @since 2.5.0 481 * 482 * @param string $file Path to file. 483 * @return int|false Unix timestamp representing modification time, false on failure. 390 484 */ 391 485 public function mtime( $file ) { … … 394 488 395 489 /** 396 * @param string $file 397 * @return int 490 * Gets the file size (in bytes). 491 * 492 * @since 2.5.0 493 * 494 * @param string $file Path to file. 495 * @return int|false Size of the file in bytes on success, false on failure. 398 496 */ 399 497 public function size( $file ) { … … 402 500 403 501 /** 404 * @param string $file 405 * @return bool 502 * Sets the access and modification times of a file. 503 * 504 * Note: If $file doesn't exist, it will be created. 505 * 506 * @since 2.5.0 507 * 508 * @param string $file Path to file. 509 * @param int $time Optional. Modified time to set for file. 510 * Default 0. 511 * @param int $atime Optional. Access time to set for file. 512 * Default 0. 513 * @return bool True on success, false on failure. 406 514 */ 407 515 public function touch( $file, $time = 0, $atime = 0 ) { … … 410 518 411 519 /** 412 * @param string $path 413 * @param mixed $chmod 414 * @param mixed $chown 415 * @param mixed $chgrp 416 * @return bool 520 * Creates a directory. 521 * 522 * @since 2.5.0 523 * 524 * @param string $path Path for new directory. 525 * @param int|false $chmod Optional. The permissions as octal number (or false to skip chmod). 526 * Default false. 527 * @param string|int $chown Optional. A user name or number (or false to skip chown). 528 * Default false. 529 * @param string|int $chgrp Optional. A group name or number (or false to skip chgrp). 530 * Default false. 531 * @return bool True on success, false on failure. 417 532 */ 418 533 public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) { … … 430 545 431 546 /** 432 * @param string $path 433 * @param bool $recursive 434 * @return bool 547 * Deletes a directory. 548 * 549 * @since 2.5.0 550 * 551 * @param string $path Path to directory. 552 * @param bool $recursive Optional. Whether to recursively remove files/directories. 553 * Default false. 554 * @return bool True on success, false on failure. 435 555 */ 436 556 public function rmdir( $path, $recursive = false ) { … … 524 644 525 645 /** 526 * @param string $path 527 * @param bool $include_hidden 528 * @param bool $recursive 529 * @return bool|array 646 * Gets details for files in a directory or a specific file. 647 * 648 * @since 2.5.0 649 * 650 * @param string $path Path to directory or file. 651 * @param bool $include_hidden Optional. Whether to include details of hidden ("." prefixed) files. 652 * Default true. 653 * @param bool $recursive Optional. Whether to recursively include file details in nested directories. 654 * Default false. 655 * @return array|false { 656 * Array of files. False if unable to list directory contents. 657 * 658 * @type string $name Name of the file or directory. 659 * @type string $perms *nix representation of permissions. 660 * @type int $permsn Octal representation of permissions. 661 * @type string $owner Owner name or ID. 662 * @type int $size Size of file in bytes. 663 * @type int $lastmodunix Last modified unix timestamp. 664 * @type mixed $lastmod Last modified month (3 letter) and day (without leading 0). 665 * @type int $time Last modified time. 666 * @type string $type Type of resource. 'f' for file, 'd' for directory. 667 * @type mixed $files If a directory and $recursive is true, contains another array of files. 668 * } 530 669 */ 531 670 public function dirlist( $path = '.', $include_hidden = true, $recursive = false ) { … … 538 677 539 678 $pwd = @ftp_pwd( $this->link ); 540 if ( ! @ftp_chdir( $this->link, $path ) ) { // Can t change to folder = folder doesn't exist679 if ( ! @ftp_chdir( $this->link, $path ) ) { // Can't change to folder = folder doesn't exist. 541 680 return false; 542 681 } … … 544 683 @ftp_chdir( $this->link, $pwd ); 545 684 546 if ( empty( $list ) ) { // Empty array = non-existent folder (real folder will show . at least) 685 if ( empty( $list ) ) { // Empty array = non-existent folder (real folder will show . at least). 547 686 return false; 548 687 } … … 586 725 587 726 /** 727 * Destructor. 728 * 729 * @since 2.5.0 588 730 */ 589 731 public function __destruct() {
Note: See TracChangeset
for help on using the changeset viewer.