- 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-ftpsockets.php
r8645 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_ftpsockets($opt = '') { 41 26 $this->method = 'ftpsockets'; … … 106 91 return false; 107 92 108 if( empty($type) ){ 109 $extension = substr(strrchr($file, '.'), 1); 110 $type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_AUTOASCII; 111 } 93 if( empty($type) ) 94 $type = FTP_AUTOASCII; 112 95 $this->ftp->SetType($type); 96 113 97 $temp = wp_tempnam( $file ); 98 114 99 if ( ! $temphandle = fopen($temp, 'w+') ) 115 100 return false; 101 116 102 if ( ! $this->ftp->fget($temphandle, $file) ) { 117 103 fclose($temphandle); … … 119 105 return ''; //Blank document, File does exist, Its just blank. 120 106 } 107 121 108 fseek($temphandle, 0); //Skip back to the start of the file being written to 122 109 $contents = ''; 110 123 111 while ( ! feof($temphandle) ) 124 112 $contents .= fread($temphandle, 8192); 113 125 114 fclose($temphandle); 126 115 unlink($temp); … … 133 122 134 123 function put_contents($file, $contents, $type = '' ) { 135 if( empty($type) ){ 136 $extension = substr(strrchr($file, '.'), 1); 137 $type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_AUTOASCII; 138 } 124 if( empty($type) ) 125 $type = $this->is_binary($contents) ? FTP_BINARY : FTP_ASCII; 126 139 127 $this->ftp->SetType($type); 140 128 … … 144 132 return false; 145 133 } 134 146 135 fwrite($temphandle, $contents); 147 136 fseek($temphandle, 0); //Skip back to the start of the file being written to 137 148 138 $ret = $this->ftp->fput($file, $temphandle); 139 149 140 fclose($temphandle); 150 141 unlink($temp);
Note: See TracChangeset
for help on using the changeset viewer.