[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

/wp-admin/includes/ -> class-wp-filesystem-ftpext.php (source)

   1  <?php
   2  /**
   3   * WordPress FTP Filesystem.
   4   *
   5   * @package WordPress
   6   * @subpackage Filesystem
   7   */
   8  
   9  /**
  10   * WordPress Filesystem Class for implementing FTP.
  11   *
  12   * @since 2.5.0
  13   *
  14   * @see WP_Filesystem_Base
  15   */
  16  class WP_Filesystem_FTPext extends WP_Filesystem_Base {
  17  
  18      /**
  19       * @since 2.5.0
  20       * @var resource
  21       */
  22      public $link;
  23  
  24      /**
  25       * Constructor.
  26       *
  27       * @since 2.5.0
  28       *
  29       * @param array $opt
  30       */
  31  	public function __construct( $opt = '' ) {
  32          $this->method = 'ftpext';
  33          $this->errors = new WP_Error();
  34  
  35          // Check if possible to use ftp functions.
  36          if ( ! extension_loaded( 'ftp' ) ) {
  37              $this->errors->add( 'no_ftp_ext', __( 'The ftp PHP extension is not available' ) );
  38              return;
  39          }
  40  
  41          // This Class uses the timeout on a per-connection basis, Others use it on a per-action basis.
  42  
  43          if ( ! defined( 'FS_TIMEOUT' ) ) {
  44              define( 'FS_TIMEOUT', 240 );
  45          }
  46  
  47          if ( empty( $opt['port'] ) ) {
  48              $this->options['port'] = 21;
  49          } else {
  50              $this->options['port'] = $opt['port'];
  51          }
  52  
  53          if ( empty( $opt['hostname'] ) ) {
  54              $this->errors->add( 'empty_hostname', __( 'FTP hostname is required' ) );
  55          } else {
  56              $this->options['hostname'] = $opt['hostname'];
  57          }
  58  
  59          // Check if the options provided are OK.
  60          if ( empty( $opt['username'] ) ) {
  61              $this->errors->add( 'empty_username', __( 'FTP username is required' ) );
  62          } else {
  63              $this->options['username'] = $opt['username'];
  64          }
  65  
  66          if ( empty( $opt['password'] ) ) {
  67              $this->errors->add( 'empty_password', __( 'FTP password is required' ) );
  68          } else {
  69              $this->options['password'] = $opt['password'];
  70          }
  71  
  72          $this->options['ssl'] = false;
  73          if ( isset( $opt['connection_type'] ) && 'ftps' == $opt['connection_type'] ) {
  74              $this->options['ssl'] = true;
  75          }
  76      }
  77  
  78      /**
  79       * Connects filesystem.
  80       *
  81       * @since 2.5.0
  82       *
  83       * @return bool True on success, false on failure.
  84       */
  85  	public function connect() {
  86          if ( isset( $this->options['ssl'] ) && $this->options['ssl'] && function_exists( 'ftp_ssl_connect' ) ) {
  87              $this->link = @ftp_ssl_connect( $this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT );
  88          } else {
  89              $this->link = @ftp_connect( $this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT );
  90          }
  91  
  92          if ( ! $this->link ) {
  93              $this->errors->add(
  94                  'connect',
  95                  sprintf(
  96                      /* translators: %s: hostname:port */
  97                      __( 'Failed to connect to FTP Server %s' ),
  98                      $this->options['hostname'] . ':' . $this->options['port']
  99                  )
 100              );
 101              return false;
 102          }
 103  
 104          if ( ! @ftp_login( $this->link, $this->options['username'], $this->options['password'] ) ) {
 105              $this->errors->add(
 106                  'auth',
 107                  sprintf(
 108                      /* translators: %s: Username. */
 109                      __( 'Username/Password incorrect for %s' ),
 110                      $this->options['username']
 111                  )
 112              );
 113              return false;
 114          }
 115  
 116          // Set the Connection to use Passive FTP
 117          ftp_pasv( $this->link, true );
 118          if ( @ftp_get_option( $this->link, FTP_TIMEOUT_SEC ) < FS_TIMEOUT ) {
 119              @ftp_set_option( $this->link, FTP_TIMEOUT_SEC, FS_TIMEOUT );
 120          }
 121  
 122          return true;
 123      }
 124  
 125      /**
 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,
 132       *                      or if the file couldn't be retrieved.
 133       */
 134  	public function get_contents( $file ) {
 135          $tempfile = wp_tempnam( $file );
 136          $temp     = fopen( $tempfile, 'w+' );
 137  
 138          if ( ! $temp ) {
 139              unlink( $tempfile );
 140              return false;
 141          }
 142  
 143          if ( ! ftp_fget( $this->link, $temp, $file, FTP_BINARY ) ) {
 144              fclose( $temp );
 145              unlink( $tempfile );
 146              return false;
 147          }
 148  
 149          fseek( $temp, 0 ); // Skip back to the start of the file being written to
 150          $contents = '';
 151  
 152          while ( ! feof( $temp ) ) {
 153              $contents .= fread( $temp, 8 * KB_IN_BYTES );
 154          }
 155  
 156          fclose( $temp );
 157          unlink( $tempfile );
 158          return $contents;
 159      }
 160  
 161      /**
 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.
 168       */
 169  	public function get_contents_array( $file ) {
 170          return explode( "\n", $this->get_contents( $file ) );
 171      }
 172  
 173      /**
 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.
 183       */
 184  	public function put_contents( $file, $contents, $mode = false ) {
 185          $tempfile = wp_tempnam( $file );
 186          $temp     = fopen( $tempfile, 'wb+' );
 187  
 188          if ( ! $temp ) {
 189              unlink( $tempfile );
 190              return false;
 191          }
 192  
 193          mbstring_binary_safe_encoding();
 194  
 195          $data_length   = strlen( $contents );
 196          $bytes_written = fwrite( $temp, $contents );
 197  
 198          reset_mbstring_encoding();
 199  
 200          if ( $data_length !== $bytes_written ) {
 201              fclose( $temp );
 202              unlink( $tempfile );
 203              return false;
 204          }
 205  
 206          fseek( $temp, 0 ); // Skip back to the start of the file being written to
 207  
 208          $ret = ftp_fput( $this->link, $file, $temp, FTP_BINARY );
 209  
 210          fclose( $temp );
 211          unlink( $tempfile );
 212  
 213          $this->chmod( $file, $mode );
 214  
 215          return $ret;
 216      }
 217  
 218      /**
 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.
 224       */
 225  	public function cwd() {
 226          $cwd = ftp_pwd( $this->link );
 227          if ( $cwd ) {
 228              $cwd = trailingslashit( $cwd );
 229          }
 230          return $cwd;
 231      }
 232  
 233      /**
 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.
 240       */
 241  	public function chdir( $dir ) {
 242          return @ftp_chdir( $this->link, $dir );
 243      }
 244  
 245      /**
 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.
 256       */
 257  	public function chmod( $file, $mode = false, $recursive = false ) {
 258          if ( ! $mode ) {
 259              if ( $this->is_file( $file ) ) {
 260                  $mode = FS_CHMOD_FILE;
 261              } elseif ( $this->is_dir( $file ) ) {
 262                  $mode = FS_CHMOD_DIR;
 263              } else {
 264                  return false;
 265              }
 266          }
 267  
 268          // chmod any sub-objects if recursive.
 269          if ( $recursive && $this->is_dir( $file ) ) {
 270              $filelist = $this->dirlist( $file );
 271              foreach ( (array) $filelist as $filename => $filemeta ) {
 272                  $this->chmod( $file . '/' . $filename, $mode, $recursive );
 273              }
 274          }
 275  
 276          // chmod the file or directory
 277          if ( ! function_exists( 'ftp_chmod' ) ) {
 278              return (bool) ftp_site( $this->link, sprintf( 'CHMOD %o %s', $mode, $file ) );
 279          }
 280          return (bool) ftp_chmod( $this->link, $mode, $file );
 281      }
 282  
 283      /**
 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.
 290       */
 291  	public function owner( $file ) {
 292          $dir = $this->dirlist( $file );
 293          return $dir[ $file ]['owner'];
 294      }
 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).
 303       */
 304  	public function getchmod( $file ) {
 305          $dir = $this->dirlist( $file );
 306          return $dir[ $file ]['permsn'];
 307      }
 308  
 309      /**
 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.
 316       */
 317  	public function group( $file ) {
 318          $dir = $this->dirlist( $file );
 319          return $dir[ $file ]['group'];
 320      }
 321  
 322      /**
 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.
 334       */
 335  	public function copy( $source, $destination, $overwrite = false, $mode = false ) {
 336          if ( ! $overwrite && $this->exists( $destination ) ) {
 337              return false;
 338          }
 339          $content = $this->get_contents( $source );
 340          if ( false === $content ) {
 341              return false;
 342          }
 343          return $this->put_contents( $destination, $content, $mode );
 344      }
 345  
 346      /**
 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.
 356       */
 357  	public function move( $source, $destination, $overwrite = false ) {
 358          return ftp_rename( $this->link, $source, $destination );
 359      }
 360  
 361      /**
 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.
 372       */
 373  	public function delete( $file, $recursive = false, $type = false ) {
 374          if ( empty( $file ) ) {
 375              return false;
 376          }
 377          if ( 'f' == $type || $this->is_file( $file ) ) {
 378              return ftp_delete( $this->link, $file );
 379          }
 380          if ( ! $recursive ) {
 381              return ftp_rmdir( $this->link, $file );
 382          }
 383  
 384          $filelist = $this->dirlist( trailingslashit( $file ) );
 385          if ( ! empty( $filelist ) ) {
 386              foreach ( $filelist as $delete_file ) {
 387                  $this->delete( trailingslashit( $file ) . $delete_file['name'], $recursive, $delete_file['type'] );
 388              }
 389          }
 390          return ftp_rmdir( $this->link, $file );
 391      }
 392  
 393      /**
 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.
 400       */
 401  	public function exists( $file ) {
 402          $list = ftp_nlist( $this->link, $file );
 403  
 404          if ( empty( $list ) && $this->is_dir( $file ) ) {
 405              return true; // File is an empty directory.
 406          }
 407  
 408          return ! empty( $list ); //empty list = no file, so invert.
 409      }
 410  
 411      /**
 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.
 418       */
 419  	public function is_file( $file ) {
 420          return $this->exists( $file ) && ! $this->is_dir( $file );
 421      }
 422  
 423      /**
 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.
 430       */
 431  	public function is_dir( $path ) {
 432          $cwd    = $this->cwd();
 433          $result = @ftp_chdir( $this->link, trailingslashit( $path ) );
 434          if ( $result && $path == $this->cwd() || $this->cwd() != $cwd ) {
 435              @ftp_chdir( $this->link, $cwd );
 436              return true;
 437          }
 438          return false;
 439      }
 440  
 441      /**
 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.
 448       */
 449  	public function is_readable( $file ) {
 450          return true;
 451      }
 452  
 453      /**
 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.
 460       */
 461  	public function is_writable( $file ) {
 462          return true;
 463      }
 464  
 465      /**
 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.
 472       */
 473  	public function atime( $file ) {
 474          return false;
 475      }
 476  
 477      /**
 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.
 484       */
 485  	public function mtime( $file ) {
 486          return ftp_mdtm( $this->link, $file );
 487      }
 488  
 489      /**
 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.
 496       */
 497  	public function size( $file ) {
 498          return ftp_size( $this->link, $file );
 499      }
 500  
 501      /**
 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.
 514       */
 515  	public function touch( $file, $time = 0, $atime = 0 ) {
 516          return false;
 517      }
 518  
 519      /**
 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.
 532       */
 533  	public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
 534          $path = untrailingslashit( $path );
 535          if ( empty( $path ) ) {
 536              return false;
 537          }
 538  
 539          if ( ! ftp_mkdir( $this->link, $path ) ) {
 540              return false;
 541          }
 542          $this->chmod( $path, $chmod );
 543          return true;
 544      }
 545  
 546      /**
 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.
 555       */
 556  	public function rmdir( $path, $recursive = false ) {
 557          return $this->delete( $path, $recursive );
 558      }
 559  
 560      /**
 561       * @staticvar bool $is_windows
 562       * @param string $line
 563       * @return array
 564       */
 565  	public function parselisting( $line ) {
 566          static $is_windows = null;
 567          if ( is_null( $is_windows ) ) {
 568              $is_windows = stripos( ftp_systype( $this->link ), 'win' ) !== false;
 569          }
 570  
 571          if ( $is_windows && preg_match( '/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)/', $line, $lucifer ) ) {
 572              $b = array();
 573              if ( $lucifer[3] < 70 ) {
 574                  $lucifer[3] += 2000;
 575              } else {
 576                  $lucifer[3] += 1900; // 4digit year fix
 577              }
 578              $b['isdir'] = ( $lucifer[7] == '<DIR>' );
 579              if ( $b['isdir'] ) {
 580                  $b['type'] = 'd';
 581              } else {
 582                  $b['type'] = 'f';
 583              }
 584              $b['size']   = $lucifer[7];
 585              $b['month']  = $lucifer[1];
 586              $b['day']    = $lucifer[2];
 587              $b['year']   = $lucifer[3];
 588              $b['hour']   = $lucifer[4];
 589              $b['minute'] = $lucifer[5];
 590              $b['time']   = mktime( $lucifer[4] + ( strcasecmp( $lucifer[6], 'PM' ) == 0 ? 12 : 0 ), $lucifer[5], 0, $lucifer[1], $lucifer[2], $lucifer[3] );
 591              $b['am/pm']  = $lucifer[6];
 592              $b['name']   = $lucifer[8];
 593          } elseif ( ! $is_windows ) {
 594              $lucifer = preg_split( '/[ ]/', $line, 9, PREG_SPLIT_NO_EMPTY );
 595              if ( $lucifer ) {
 596                  //echo $line."\n";
 597                  $lcount = count( $lucifer );
 598                  if ( $lcount < 8 ) {
 599                      return '';
 600                  }
 601                  $b           = array();
 602                  $b['isdir']  = $lucifer[0][0] === 'd';
 603                  $b['islink'] = $lucifer[0][0] === 'l';
 604                  if ( $b['isdir'] ) {
 605                      $b['type'] = 'd';
 606                  } elseif ( $b['islink'] ) {
 607                      $b['type'] = 'l';
 608                  } else {
 609                      $b['type'] = 'f';
 610                  }
 611                  $b['perms']  = $lucifer[0];
 612                  $b['permsn'] = $this->getnumchmodfromh( $b['perms'] );
 613                  $b['number'] = $lucifer[1];
 614                  $b['owner']  = $lucifer[2];
 615                  $b['group']  = $lucifer[3];
 616                  $b['size']   = $lucifer[4];
 617                  if ( $lcount == 8 ) {
 618                      sscanf( $lucifer[5], '%d-%d-%d', $b['year'], $b['month'], $b['day'] );
 619                      sscanf( $lucifer[6], '%d:%d', $b['hour'], $b['minute'] );
 620                      $b['time'] = mktime( $b['hour'], $b['minute'], 0, $b['month'], $b['day'], $b['year'] );
 621                      $b['name'] = $lucifer[7];
 622                  } else {
 623                      $b['month'] = $lucifer[5];
 624                      $b['day']   = $lucifer[6];
 625                      if ( preg_match( '/([0-9]{2}):([0-9]{2})/', $lucifer[7], $l2 ) ) {
 626                          $b['year']   = gmdate( 'Y' );
 627                          $b['hour']   = $l2[1];
 628                          $b['minute'] = $l2[2];
 629                      } else {
 630                          $b['year']   = $lucifer[7];
 631                          $b['hour']   = 0;
 632                          $b['minute'] = 0;
 633                      }
 634                      $b['time'] = strtotime( sprintf( '%d %s %d %02d:%02d', $b['day'], $b['month'], $b['year'], $b['hour'], $b['minute'] ) );
 635                      $b['name'] = $lucifer[8];
 636                  }
 637              }
 638          }
 639  
 640          // Replace symlinks formatted as "source -> target" with just the source name
 641          if ( isset( $b['islink'] ) && $b['islink'] ) {
 642              $b['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $b['name'] );
 643          }
 644  
 645          return $b;
 646      }
 647  
 648      /**
 649       * Gets details for files in a directory or a specific file.
 650       *
 651       * @since 2.5.0
 652       *
 653       * @param string $path           Path to directory or file.
 654       * @param bool   $include_hidden Optional. Whether to include details of hidden ("." prefixed) files.
 655       *                               Default true.
 656       * @param bool   $recursive      Optional. Whether to recursively include file details in nested directories.
 657       *                               Default false.
 658       * @return array|false {
 659       *     Array of files. False if unable to list directory contents.
 660       *
 661       *     @type string $name        Name of the file or directory.
 662       *     @type string $perms       *nix representation of permissions.
 663       *     @type int    $permsn      Octal representation of permissions.
 664       *     @type string $owner       Owner name or ID.
 665       *     @type int    $size        Size of file in bytes.
 666       *     @type int    $lastmodunix Last modified unix timestamp.
 667       *     @type mixed  $lastmod     Last modified month (3 letter) and day (without leading 0).
 668       *     @type int    $time        Last modified time.
 669       *     @type string $type        Type of resource. 'f' for file, 'd' for directory.
 670       *     @type mixed  $files       If a directory and $recursive is true, contains another array of files.
 671       * }
 672       */
 673  	public function dirlist( $path = '.', $include_hidden = true, $recursive = false ) {
 674          if ( $this->is_file( $path ) ) {
 675              $limit_file = basename( $path );
 676              $path       = dirname( $path ) . '/';
 677          } else {
 678              $limit_file = false;
 679          }
 680  
 681          $pwd = ftp_pwd( $this->link );
 682          if ( ! @ftp_chdir( $this->link, $path ) ) { // Can't change to folder = folder doesn't exist.
 683              return false;
 684          }
 685          $list = ftp_rawlist( $this->link, '-a', false );
 686          @ftp_chdir( $this->link, $pwd );
 687  
 688          if ( empty( $list ) ) { // Empty array = non-existent folder (real folder will show . at least).
 689              return false;
 690          }
 691  
 692          $dirlist = array();
 693          foreach ( $list as $k => $v ) {
 694              $entry = $this->parselisting( $v );
 695              if ( empty( $entry ) ) {
 696                  continue;
 697              }
 698  
 699              if ( '.' == $entry['name'] || '..' == $entry['name'] ) {
 700                  continue;
 701              }
 702  
 703              if ( ! $include_hidden && '.' == $entry['name'][0] ) {
 704                  continue;
 705              }
 706  
 707              if ( $limit_file && $entry['name'] != $limit_file ) {
 708                  continue;
 709              }
 710  
 711              $dirlist[ $entry['name'] ] = $entry;
 712          }
 713  
 714          $ret = array();
 715          foreach ( (array) $dirlist as $struc ) {
 716              if ( 'd' == $struc['type'] ) {
 717                  if ( $recursive ) {
 718                      $struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive );
 719                  } else {
 720                      $struc['files'] = array();
 721                  }
 722              }
 723  
 724              $ret[ $struc['name'] ] = $struc;
 725          }
 726          return $ret;
 727      }
 728  
 729      /**
 730       * Destructor.
 731       *
 732       * @since 2.5.0
 733       */
 734  	public function __destruct() {
 735          if ( $this->link ) {
 736              ftp_close( $this->link );
 737          }
 738      }
 739  }


Generated: Fri Oct 25 08:20:01 2019 Cross-referenced by PHPXref 0.7