X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/76aea3697c6043c1613370f172395b4f65ee71f0..11be8dc178e77d0b46189bbd8e33a216a9b90942:/wp-admin/includes/class-wp-filesystem-ftpext.php diff --git a/wp-admin/includes/class-wp-filesystem-ftpext.php b/wp-admin/includes/class-wp-filesystem-ftpext.php index 20699351..a2805da8 100644 --- a/wp-admin/includes/class-wp-filesystem-ftpext.php +++ b/wp-admin/includes/class-wp-filesystem-ftpext.php @@ -1,5 +1,20 @@ FTP_ASCII, - 'css'=>FTP_ASCII, - 'txt'=>FTP_ASCII, - 'js'=>FTP_ASCII, - 'html'=>FTP_ASCII, - 'htm'=>FTP_ASCII, - 'xml'=>FTP_ASCII, - - 'jpg'=>FTP_BINARY, - 'png'=>FTP_BINARY, - 'gif'=>FTP_BINARY, - 'bmp'=>FTP_BINARY - ); - function WP_Filesystem_FTPext($opt='') { $this->method = 'ftpext'; $this->errors = new WP_Error(); @@ -57,7 +57,11 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base{ else $this->options['password'] = $opt['password']; - $this->options['ssl'] = ( !empty($opt['ssl']) ); + $this->options['ssl'] = false; + if ( isset($opt['ssl']) ) + $this->options['ssl'] = ( !empty($opt['ssl']) ); + elseif ( isset( $opt['connection_type']) ) + $this->options['ssl'] = ( 'ftps' == $opt['connection_type'] ); } function connect() { @@ -76,28 +80,33 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base{ return false; } + //Set the Connection to use Passive FTP + @ftp_pasv( $this->link, true ); + return true; } function setDefaultPermissions($perm) { $this->permission = $perm; } - + function get_contents($file, $type = '', $resumepos = 0 ){ - if( empty($type) ){ - $extension = substr(strrchr($file, "."), 1); - $type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_ASCII; - } + if( empty($type) ) + $type = FTP_BINARY; + $temp = tmpfile(); if ( ! $temp ) return false; + if( ! @ftp_fget($this->link, $temp, $file, $type, $resumepos) ) return false; + fseek($temp, 0); //Skip back to the start of the file being written to $contents = ''; - while (!feof($temp)) { + + while ( ! feof($temp) ) $contents .= fread($temp, 8192); - } + fclose($temp); return $contents; } @@ -105,21 +114,23 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base{ return explode("\n", $this->get_contents($file)); } function put_contents($file, $contents, $type = '' ) { - if( empty($type) ) { - $extension = substr(strrchr($file, "."), 1); - $type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_ASCII; - } + if( empty($type) ) + $type = $this->is_binary($contents) ? FTP_BINARY : FTP_ASCII; + $temp = tmpfile(); if ( ! $temp ) return false; + fwrite($temp, $contents); fseek($temp, 0); //Skip back to the start of the file being written to + $ret = @ftp_fput($this->link, $file, $temp, $type); + fclose($temp); return $ret; } function cwd() { - $cwd = ftp_pwd($this->link); + $cwd = @ftp_pwd($this->link); if( $cwd ) $cwd = trailingslashit($cwd); return $cwd;