Ticket #25237: 25237.diff
| File 25237.diff, 5.1 KB (added by , 13 years ago) |
|---|
-
src/wp-admin/includes/class-wp-filesystem-direct.php
59 59 * @param int $mode (optional) The file permissions as octal number, usually 0644. 60 60 * @return bool False upon failure. 61 61 */ 62 function put_contents($file, $contents, $mode = false ) { 63 if ( ! ($fp = @fopen($file, 'w')) ) 62 function put_contents( $file, $contents, $mode = false ) { 63 $fp = @fopen( $file, 'wb' ); 64 if ( ! $fp ) 64 65 return false; 65 @fwrite($fp, $contents); 66 @fclose($fp); 67 $this->chmod($file, $mode); 66 67 $bytes_written = fwrite( $fp, $contents ); 68 69 fclose( $fp ); 70 71 if ( false === $bytes_written || $bytes_written != strlen( $contents ) ) 72 return false; 73 74 $this->chmod( $file, $mode ); 75 68 76 return true; 69 77 } 70 78 /** -
src/wp-admin/includes/class-wp-filesystem-ftpext.php
88 88 return true; 89 89 } 90 90 91 function get_contents($file, $type = '', $resumepos = 0 ) { 92 if ( empty($type) ) 93 $type = FTP_BINARY; 94 91 function get_contents( $file ) { 95 92 $tempfile = wp_tempnam($file); 96 93 $temp = fopen($tempfile, 'w+'); 97 94 98 95 if ( ! $temp ) 99 96 return false; 100 97 101 if ( ! @ftp_fget($this->link, $temp, $file, $type, $resumepos) )98 if ( ! @ftp_fget($this->link, $temp, $file, FTP_BINARY ) ) 102 99 return false; 103 100 104 101 fseek($temp, 0); //Skip back to the start of the file being written to … … 117 114 118 115 function put_contents($file, $contents, $mode = false ) { 119 116 $tempfile = wp_tempnam($file); 120 $temp = fopen( $tempfile, 'w+');117 $temp = fopen( $tempfile, 'wb+' ); 121 118 if ( ! $temp ) 122 119 return false; 123 120 124 fwrite($temp, $contents); 125 fseek($temp, 0); //Skip back to the start of the file being written to 121 $bytes_written = fwrite( $temp, $contents ); 122 if ( false === $bytes_written || $bytes_written != strlen( $contents ) ) { 123 fclose( $temp ); 124 unlink( $tempfile ); 125 return false; 126 } 126 127 128 fseek( $temp, 0 ); // Skip back to the start of the file being written to 129 127 130 $type = $this->is_binary($contents) ? FTP_BINARY : FTP_ASCII; 128 131 $ret = @ftp_fput($this->link, $file, $temp, $type); 129 132 … … 187 190 if ( ! $overwrite && $this->exists($destination) ) 188 191 return false; 189 192 $content = $this->get_contents($source); 190 if ( false === $content )193 if ( false === $content ) 191 194 return false; 192 195 return $this->put_contents($destination, $content, $mode); 193 196 } -
src/wp-admin/includes/class-wp-filesystem-ftpsockets.php
75 75 return false; 76 76 } 77 77 78 $this->ftp->SetType(FTP_AUTOASCII); 78 // ASCII mode will auto-convert line endings 79 $this->ftp->SetType(FTP_BINARY); 79 80 $this->ftp->Passive(true); 80 81 $this->ftp->setTimeout(FS_TIMEOUT); 81 82 return true; 82 83 } 83 84 84 function get_contents( $file, $type = '', $resumepos = 0) {85 function get_contents( $file ) { 85 86 if ( ! $this->exists($file) ) 86 87 return false; 87 88 88 if ( empty($type) ) 89 $type = FTP_AUTOASCII; 90 $this->ftp->SetType($type); 89 // Always transfer in Binary, otherwise the ftp class will normalize line endings 90 $this->ftp->SetType( FTP_BINARY ); 91 91 92 92 $temp = wp_tempnam( $file ); 93 93 … … 122 122 return false; 123 123 } 124 124 125 fwrite($temphandle, $contents); 126 fseek($temphandle, 0); //Skip back to the start of the file being written to 125 $bytes_written = fwrite( $temphandle, $contents ); 126 if ( false === $bytes_written || $bytes_written != strlen( $contents ) ) { 127 fclose( $temphandle ); 128 unlink( $temp ); 129 return false; 130 } 127 131 128 $type = $this->is_binary($contents) ? FTP_BINARY : FTP_ASCII; 129 $this->ftp->SetType($type); 132 fseek( $temphandle, 0 ); // Skip back to the start of the file being written to 130 133 134 // Always transfer in Binary, otherwise the ftp class will normalize line endings 135 $this->ftp->SetType( FTP_BINARY ); 136 131 137 $ret = $this->ftp->fput($file, $temphandle); 132 138 133 139 fclose($temphandle); -
src/wp-admin/includes/class-wp-filesystem-ssh2.php
150 150 return false; 151 151 } 152 152 153 function get_contents( $file, $type = '', $resumepos = 0) {153 function get_contents( $file ) { 154 154 $file = ltrim($file, '/'); 155 155 return file_get_contents('ssh2.sftp://' . $this->sftp_link . '/' . $file); 156 156 } … … 164 164 $file = ltrim($file, '/'); 165 165 $ret = file_put_contents('ssh2.sftp://' . $this->sftp_link . '/' . $file, $contents); 166 166 167 if ( false === $ret || $ret != strlen( $contents ) ) 168 return false; 169 167 170 $this->chmod($file, $mode); 168 171 169 return false !== $ret;172 return true; 170 173 } 171 174 172 175 function cwd() {
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)