]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/includes/class-wp-filesystem-ftpext.php
WordPress 4.3
[autoinstalls/wordpress.git] / wp-admin / includes / class-wp-filesystem-ftpext.php
index 90e3de02745456272f92284b54dbd34f03a48cf6..62ade49136ec5a9c6143529280811ae3a2d1a6c7 100644 (file)
  */
 class WP_Filesystem_FTPext extends WP_Filesystem_Base {
        public $link;
  */
 class WP_Filesystem_FTPext extends WP_Filesystem_Base {
        public $link;
-       public $errors = null;
-       public $options = array();
 
 
-       public function __construct($opt='') {
+       /**
+        *
+        * @param array $opt
+        */
+       public function __construct( $opt = '' ) {
                $this->method = 'ftpext';
                $this->errors = new WP_Error();
 
                // Check if possible to use ftp functions.
                if ( ! extension_loaded('ftp') ) {
                        $this->errors->add('no_ftp_ext', __('The ftp PHP extension is not available'));
                $this->method = 'ftpext';
                $this->errors = new WP_Error();
 
                // Check if possible to use ftp functions.
                if ( ! extension_loaded('ftp') ) {
                        $this->errors->add('no_ftp_ext', __('The ftp PHP extension is not available'));
-                       return false;
+                       return;
                }
 
                // This Class uses the timeout on a per-connection basis, Others use it on a per-action basis.
                }
 
                // This Class uses the timeout on a per-connection basis, Others use it on a per-action basis.
@@ -44,9 +46,6 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
                else
                        $this->options['hostname'] = $opt['hostname'];
 
                else
                        $this->options['hostname'] = $opt['hostname'];
 
-               if ( ! empty($opt['base']) )
-                       $this->wp_base = $opt['base'];
-
                // Check if the options provided are OK.
                if ( empty($opt['username']) )
                        $this->errors->add('empty_username', __('FTP username is required'));
                // Check if the options provided are OK.
                if ( empty($opt['username']) )
                        $this->errors->add('empty_username', __('FTP username is required'));
@@ -63,6 +62,10 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
                        $this->options['ssl'] = true;
        }
 
                        $this->options['ssl'] = true;
        }
 
+       /**
+        *
+        * @return bool
+        */
        public function connect() {
                if ( isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect') )
                        $this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT);
        public function connect() {
                if ( isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect') )
                        $this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT);
@@ -89,7 +92,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
 
        /**
         * @param string $file
 
        /**
         * @param string $file
-        * @return bool|string
+        * @return false|string
         */
        public function get_contents( $file ) {
                $tempfile = wp_tempnam($file);
         */
        public function get_contents( $file ) {
                $tempfile = wp_tempnam($file);
@@ -175,15 +178,6 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
                return @ftp_chdir($this->link, $dir);
        }
 
                return @ftp_chdir($this->link, $dir);
        }
 
-       /**
-        * @param string $file
-        * @param bool $group
-        * @param bool $recursive
-        */
-       public function chgrp($file, $group, $recursive = false ) {
-               return false;
-       }
-
        /**
         * @param string $file
         * @param int $mode
        /**
         * @param string $file
         * @param int $mode
@@ -289,6 +283,11 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
         */
        public function exists($file) {
                $list = @ftp_nlist($this->link, $file);
         */
        public function exists($file) {
                $list = @ftp_nlist($this->link, $file);
+
+               if ( empty( $list ) && $this->is_dir( $file ) ) {
+                       return true; // File is an empty directory.
+               }
+
                return !empty($list); //empty list = no file, so invert.
        }
        /**
                return !empty($list); //empty list = no file, so invert.
        }
        /**
@@ -370,10 +369,6 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
                if ( !@ftp_mkdir($this->link, $path) )
                        return false;
                $this->chmod($path, $chmod);
                if ( !@ftp_mkdir($this->link, $path) )
                        return false;
                $this->chmod($path, $chmod);
-               if ( $chown )
-                       $this->chown($path, $chown);
-               if ( $chgrp )
-                       $this->chgrp($path, $chgrp);
                return true;
        }
 
                return true;
        }
 
@@ -389,10 +384,10 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
        /**
         * @staticvar bool $is_windows
         * @param string $line
        /**
         * @staticvar bool $is_windows
         * @param string $line
-        * @return string
+        * @return array
         */
        public function parselisting($line) {
         */
        public function parselisting($line) {
-               static $is_windows;
+               static $is_windows = null;
                if ( is_null($is_windows) )
                        $is_windows = stripos( ftp_systype($this->link), 'win') !== false;
 
                if ( is_null($is_windows) )
                        $is_windows = stripos( ftp_systype($this->link), 'win') !== false;
 
@@ -431,6 +426,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
                        else
                                $b['type'] = 'f';
                        $b['perms'] = $lucifer[0];
                        else
                                $b['type'] = 'f';
                        $b['perms'] = $lucifer[0];
+                       $b['permsn'] = $this->getnumchmodfromh( $b['perms'] );
                        $b['number'] = $lucifer[1];
                        $b['owner'] = $lucifer[2];
                        $b['group'] = $lucifer[3];
                        $b['number'] = $lucifer[1];
                        $b['owner'] = $lucifer[2];
                        $b['group'] = $lucifer[3];
@@ -519,6 +515,9 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
                return $ret;
        }
 
                return $ret;
        }
 
+       /**
+        * @access public
+        */
        public function __destruct() {
                if ( $this->link )
                        ftp_close($this->link);
        public function __destruct() {
                if ( $this->link )
                        ftp_close($this->link);