Changeset 702 for trunk/forum/includes/functions_upload.php
- Timestamp:
- Mar 31, 2010, 6:32:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/forum/includes/functions_upload.php
r400 r702 3 3 * 4 4 * @package phpBB3 5 * @version $Id : functions_upload.php 8783 2008-08-23 17:23:40Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 59 59 $this->filename = $upload_ary['tmp_name']; 60 60 $this->filesize = $upload_ary['size']; 61 $name = trim( htmlspecialchars(basename($upload_ary['name'])));61 $name = trim(utf8_htmlspecialchars(utf8_basename($upload_ary['name']))); 62 62 $this->realname = $this->uploadname = (STRIP) ? stripslashes($name) : $name; 63 63 $this->mimetype = $upload_ary['type']; … … 291 291 $upload_mode = (@ini_get('open_basedir') || @ini_get('safe_mode') || strtolower(@ini_get('safe_mode')) == 'on') ? 'move' : 'copy'; 292 292 $upload_mode = ($this->local) ? 'local' : $upload_mode; 293 $this->destination_file = $this->destination_path . '/' . basename($this->realname);293 $this->destination_file = $this->destination_path . '/' . utf8_basename($this->realname); 294 294 295 295 // Check if the file already exist, else there is something wrong... … … 314 314 { 315 315 $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file); 316 return false;317 316 } 318 317 } 319 320 @unlink($this->filename);321 318 322 319 break; … … 329 326 { 330 327 $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file); 331 return false;332 328 } 333 329 } 334 335 @unlink($this->filename);336 330 337 331 break; … … 342 336 { 343 337 $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file); 344 return false;345 338 } 346 @unlink($this->filename);347 339 348 340 break; 341 } 342 343 // Remove temporary filename 344 @unlink($this->filename); 345 346 if (sizeof($this->error)) 347 { 348 return false; 349 349 } 350 350 … … 418 418 if ($this->upload->max_filesize && ($this->get('filesize') > $this->upload->max_filesize || $this->filesize == 0)) 419 419 { 420 $size_lang = ($this->upload->max_filesize >= 1048576) ? $user->lang['MIB'] : (($this->upload->max_filesize >= 1024) ? $user->lang['KIB'] : $user->lang['BYTES'] );421 420 $max_filesize = get_formatted_filesize($this->upload->max_filesize, false); 422 421 423 $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'WRONG_FILESIZE'], $max_filesize , $size_lang);422 $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'WRONG_FILESIZE'], $max_filesize['value'], $max_filesize['unit']); 424 423 425 424 return false; … … 595 594 if ($file->get('filename') == 'none') 596 595 { 597 $file->error[] = (@ini_get('upload_max_filesize') == '') ? $user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : sprintf($user->lang[$this->error_prefix . 'PHP_SIZE_OVERRUN'], @ini_get('upload_max_filesize')); 596 $max_filesize = @ini_get('upload_max_filesize'); 597 $unit = 'MB'; 598 599 if (!empty($max_filesize)) 600 { 601 $unit = strtolower(substr($max_filesize, -1, 1)); 602 $max_filesize = (int) $max_filesize; 603 604 $unit = ($unit == 'k') ? 'KB' : (($unit == 'g') ? 'GB' : 'MB'); 605 } 606 607 $file->error[] = (empty($max_filesize)) ? $user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : sprintf($user->lang[$this->error_prefix . 'PHP_SIZE_OVERRUN'], $max_filesize, $user->lang[$unit]); 598 608 return $file; 599 609 } … … 625 635 if ($filedata === false) 626 636 { 627 $_FILES[$form_name]['name'] = basename($source_file);637 $_FILES[$form_name]['name'] = utf8_basename($source_file); 628 638 $_FILES[$form_name]['size'] = 0; 629 639 $mimetype = ''; … … 671 681 if ($file->get('filename') == 'none') 672 682 { 673 $file->error[] = (@ini_get('upload_max_filesize') == '') ? $user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : sprintf($user->lang[$this->error_prefix . 'PHP_SIZE_OVERRUN'], @ini_get('upload_max_filesize')); 683 $max_filesize = @ini_get('upload_max_filesize'); 684 $unit = 'MB'; 685 686 if (!empty($max_filesize)) 687 { 688 $unit = strtolower(substr($max_filesize, -1, 1)); 689 $max_filesize = (int) $max_filesize; 690 691 $unit = ($unit == 'k') ? 'KB' : (($unit == 'g') ? 'GB' : 'MB'); 692 } 693 694 $file->error[] = (empty($max_filesize)) ? $user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : sprintf($user->lang[$this->error_prefix . 'PHP_SIZE_OVERRUN'], $max_filesize, $user->lang[$unit]); 674 695 return $file; 675 696 } … … 726 747 727 748 $url['path'] = implode('', $url['path']); 728 $upload_ary['name'] = basename($url['path']) . (($ext) ? '.' . $ext : '');749 $upload_ary['name'] = utf8_basename($url['path']) . (($ext) ? '.' . $ext : ''); 729 750 $filename = $url['path']; 730 751 $filesize = 0; … … 819 840 { 820 841 case 1: 821 $error = (@ini_get('upload_max_filesize') == '') ? $user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : sprintf($user->lang[$this->error_prefix . 'PHP_SIZE_OVERRUN'], @ini_get('upload_max_filesize')); 842 $max_filesize = @ini_get('upload_max_filesize'); 843 $unit = 'MB'; 844 845 if (!empty($max_filesize)) 846 { 847 $unit = strtolower(substr($max_filesize, -1, 1)); 848 $max_filesize = (int) $max_filesize; 849 850 $unit = ($unit == 'k') ? 'KB' : (($unit == 'g') ? 'GB' : 'MB'); 851 } 852 853 $error = (empty($max_filesize)) ? $user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : sprintf($user->lang[$this->error_prefix . 'PHP_SIZE_OVERRUN'], $max_filesize, $user->lang[$unit]); 822 854 break; 823 855 824 856 case 2: 825 $size_lang = ($this->max_filesize >= 1048576) ? $user->lang['MIB'] : (($this->max_filesize >= 1024) ? $user->lang['KIB'] : $user->lang['BYTES']);826 857 $max_filesize = get_formatted_filesize($this->max_filesize, false); 827 858 828 $error = sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize , $size_lang);859 $error = sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize['value'], $max_filesize['unit']); 829 860 break; 830 861 … … 859 890 if ($this->max_filesize && ($file->get('filesize') > $this->max_filesize || $file->get('filesize') == 0)) 860 891 { 861 $size_lang = ($this->max_filesize >= 1048576) ? $user->lang['MIB'] : (($this->max_filesize >= 1024) ? $user->lang['KIB'] : $user->lang['BYTES']);862 892 $max_filesize = get_formatted_filesize($this->max_filesize, false); 863 893 864 $file->error[] = sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize , $size_lang);894 $file->error[] = sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize['value'], $max_filesize['unit']); 865 895 } 866 896
Note:
See TracChangeset
for help on using the changeset viewer.