Changeset 14016
- Timestamp:
- 04/06/2010 11:20:51 AM (15 years ago)
- Location:
- trunk/wp-admin/includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/class-wp-filesystem-ftpext.php
r13869 r14016 93 93 $type = FTP_BINARY; 94 94 95 $temp = tmpfile(); 95 $tempfile = wp_tempnam($file); 96 $temp = fopen($tempfile, 'w+'); 97 96 98 if ( ! $temp ) 97 99 return false; … … 107 109 108 110 fclose($temp); 111 unlink($tempfile); 109 112 return $contents; 110 113 } … … 114 117 115 118 function put_contents($file, $contents, $mode = false ) { 116 $temp = tmpfile(); 119 $tempfile = wp_tempnam($file); 120 $temp = fopen($tempfile, 'w+'); 117 121 if ( ! $temp ) 118 122 return false; … … 125 129 126 130 fclose($temp); 131 unlink($tempfile); 127 132 128 133 $this->chmod($file, $mode); -
trunk/wp-admin/includes/file.php
r13994 r14016 150 150 */ 151 151 function get_temp_dir() { 152 static $temp; 152 153 if ( defined('WP_TEMP_DIR') ) 153 154 return trailingslashit(WP_TEMP_DIR); 155 156 if ( $temp ) 157 return trailingslashit($temp); 154 158 155 159 $temp = WP_CONTENT_DIR . '/'; … … 157 161 return $temp; 158 162 159 if ( function_exists('sys_get_temp_dir') ) 160 return trailingslashit(sys_get_temp_dir()); 163 if ( function_exists('sys_get_temp_dir') ) { 164 $temp = sys_get_temp_dir(); 165 if ( is_writable($temp) ) 166 return trailingslashit($temp); 167 } 161 168 162 169 $temp = ini_get('upload_tmp_dir'); 163 if ( is_dir($temp) ) // always writable170 if ( is_dir($temp) && is_writable($temp) ) 164 171 return trailingslashit($temp); 165 172 166 return '/tmp/'; 173 $temp = '/tmp/'; 174 return $temp; 167 175 } 168 176 … … 180 188 * @return string a writable filename 181 189 */ 182 function wp_tempnam($filename = '', $dir = '') {190 function wp_tempnam($filename = '', $dir = '') { 183 191 if ( empty($dir) ) 184 192 $dir = get_temp_dir(); … … 604 612 605 613 if ( ! $wp_filesystem->put_contents( $to . $info['name'], $contents, FS_CHMOD_FILE) ) 606 return new WP_Error('copy_failed', __('Could not copy file.'), $to . $ file['filename']);614 return new WP_Error('copy_failed', __('Could not copy file.'), $to . $info['filename']); 607 615 } 608 616
Note: See TracChangeset
for help on using the changeset viewer.