WordPress 4.7.1-scripts
[autoinstalls/wordpress.git] / wp-admin / includes / class-wp-filesystem-ftpsockets.php
index 29ac7888ab4b0fb4bbb69d4e8ab5d4456b7cfcdb..ff0b882414be3c22453a6eed50adb7fb1711039e 100644 (file)
@@ -39,7 +39,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
                if ( empty($opt['port']) )
                        $this->options['port'] = 21;
                else
-                       $this->options['port'] = $opt['port'];
+                       $this->options['port'] = (int) $opt['port'];
 
                if ( empty($opt['hostname']) )
                        $this->errors->add('empty_hostname', __('FTP hostname is required'));
@@ -121,8 +121,10 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
 
                $temp = wp_tempnam( $file );
 
-               if ( ! $temphandle = fopen($temp, 'w+') )
+               if ( ! $temphandle = fopen( $temp, 'w+' ) ) {
+                       unlink( $temp );
                        return false;
+               }
 
                mbstring_binary_safe_encoding();
 
@@ -342,7 +344,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
         * @return bool
         */
        public function exists( $file ) {
-               $list = $this->ftp->rawlist( $file, '-a' );
+               $list = $this->ftp->nlist( $file );
 
                if ( empty( $list ) && $this->is_dir( $file ) ) {
                        return true; // File is an empty directory.