Changeset 8990 for trunk/wp-admin/includes/class-wp-filesystem-ftpext.php
- Timestamp:
- 09/26/2008 06:53:57 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/class-wp-filesystem-ftpext.php
r8811 r8990 23 23 var $permission = null; 24 24 25 var $filetypes = array(26 'php'=>FTP_ASCII,27 'css'=>FTP_ASCII,28 'txt'=>FTP_ASCII,29 'js'=>FTP_ASCII,30 'html'=>FTP_ASCII,31 'htm'=>FTP_ASCII,32 'xml'=>FTP_ASCII,33 34 'jpg'=>FTP_BINARY,35 'png'=>FTP_BINARY,36 'gif'=>FTP_BINARY,37 'bmp'=>FTP_BINARY38 );39 40 25 function WP_Filesystem_FTPext($opt='') { 41 26 $this->method = 'ftpext'; … … 104 89 105 90 function get_contents($file, $type = '', $resumepos = 0 ){ 106 if( empty($type) ){ 107 $extension = substr(strrchr($file, "."), 1); 108 $type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_ASCII; 109 } 91 if( empty($type) ) 92 $type = FTP_BINARY; 93 110 94 $temp = tmpfile(); 111 95 if ( ! $temp ) 112 96 return false; 97 113 98 if( ! @ftp_fget($this->link, $temp, $file, $type, $resumepos) ) 114 99 return false; 100 115 101 fseek($temp, 0); //Skip back to the start of the file being written to 116 102 $contents = ''; 117 while (!feof($temp)) { 103 104 while ( ! feof($temp) ) 118 105 $contents .= fread($temp, 8192); 119 } 106 120 107 fclose($temp); 121 108 return $contents; … … 125 112 } 126 113 function put_contents($file, $contents, $type = '' ) { 127 if( empty($type) ) { 128 $extension = substr(strrchr($file, "."), 1); 129 $type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_ASCII; 130 } 114 if( empty($type) ) 115 $type = $this->is_binary($contents) ? FTP_BINARY : FTP_ASCII; 116 131 117 $temp = tmpfile(); 132 118 if ( ! $temp ) 133 119 return false; 120 134 121 fwrite($temp, $contents); 135 122 fseek($temp, 0); //Skip back to the start of the file being written to 123 136 124 $ret = @ftp_fput($this->link, $file, $temp, $type); 125 137 126 fclose($temp); 138 127 return $ret;
Note: See TracChangeset
for help on using the changeset viewer.