Changeset 25304
- Timestamp:
- 09/09/2013 02:42:52 AM (11 years ago)
- Location:
- trunk/src/wp-admin/includes
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-filesystem-direct.php
r23191 r25304 60 60 * @return bool False upon failure. 61 61 */ 62 function put_contents($file, $contents, $mode = false ) { 63 if ( ! ($fp = @fopen($file, 'w')) ) 64 return false; 65 @fwrite($fp, $contents); 66 @fclose($fp); 67 $this->chmod($file, $mode); 62 function put_contents( $file, $contents, $mode = false ) { 63 $fp = @fopen( $file, 'wb' ); 64 if ( ! $fp ) 65 return false; 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 } -
trunk/src/wp-admin/includes/class-wp-filesystem-ftpext.php
r21223 r25304 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+'); … … 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 … … 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 126 127 $type = $this->is_binary($contents) ? FTP_BINARY : FTP_ASCII; 128 $ret = @ftp_fput($this->link, $file, $temp, $type); 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 } 127 128 fseek( $temp, 0 ); // Skip back to the start of the file being written to 129 130 $ret = @ftp_fput( $this->link, $file, $temp, FTP_BINARY ); 129 131 130 132 fclose($temp); … … 188 190 return false; 189 191 $content = $this->get_contents($source); 190 if ( false === $content )192 if ( false === $content ) 191 193 return false; 192 194 return $this->put_contents($destination, $content, $mode); -
trunk/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php
r25274 r25304 76 76 } 77 77 78 $this->ftp->SetType( FTP_AUTOASCII);79 $this->ftp->Passive( true);80 $this->ftp->setTimeout( FS_TIMEOUT);78 $this->ftp->SetType( FTP_BINARY ); 79 $this->ftp->Passive( true ); 80 $this->ftp->setTimeout( FS_TIMEOUT ); 81 81 return true; 82 82 } 83 83 84 function get_contents( $file, $type = '', $resumepos = 0) {84 function get_contents( $file ) { 85 85 if ( ! $this->exists($file) ) 86 86 return false; 87 88 if ( empty($type) )89 $type = FTP_AUTOASCII;90 $this->ftp->SetType($type);91 87 92 88 $temp = wp_tempnam( $file ); … … 123 119 } 124 120 125 fwrite($temphandle, $contents); 126 fseek($temphandle, 0); //Skip back to the start of the file being written to 127 128 $type = $this->is_binary($contents) ? FTP_BINARY : FTP_ASCII; 129 $this->ftp->SetType($type); 121 $bytes_written = fwrite( $temphandle, $contents ); 122 if ( false === $bytes_written || $bytes_written != strlen( $contents ) ) { 123 fclose( $temphandle ); 124 unlink( $temp ); 125 return false; 126 } 127 128 fseek( $temphandle, 0 ); // Skip back to the start of the file being written to 130 129 131 130 $ret = $this->ftp->fput($file, $temphandle); -
trunk/src/wp-admin/includes/class-wp-filesystem-ssh2.php
r24626 r25304 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); … … 165 165 $ret = file_put_contents('ssh2.sftp://' . $this->sftp_link . '/' . $file, $contents); 166 166 167 if ( $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
Note: See TracChangeset
for help on using the changeset viewer.