Ignore:
Timestamp:
Mar 31, 2010, 6:32:40 PM (14 years ago)
Author:
george
Message:
  • Upraveno: Aktualizace fóra.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/forum/includes/functions_upload.php

    r400 r702  
    33*
    44* @package phpBB3
    5 * @version $Id: functions_upload.php 8783 2008-08-23 17:23:40Z acydburn $
     5* @version $Id$
    66* @copyright (c) 2005 phpBB Group
    77* @license http://opensource.org/licenses/gpl-license.php GNU Public License
     
    5959                $this->filename = $upload_ary['tmp_name'];
    6060                $this->filesize = $upload_ary['size'];
    61                 $name = trim(htmlspecialchars(basename($upload_ary['name'])));
     61                $name = trim(utf8_htmlspecialchars(utf8_basename($upload_ary['name'])));
    6262                $this->realname = $this->uploadname = (STRIP) ? stripslashes($name) : $name;
    6363                $this->mimetype = $upload_ary['type'];
     
    291291                $upload_mode = (@ini_get('open_basedir') || @ini_get('safe_mode') || strtolower(@ini_get('safe_mode')) == 'on') ? 'move' : 'copy';
    292292                $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);
    294294
    295295                // Check if the file already exist, else there is something wrong...
     
    314314                                                {
    315315                                                        $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file);
    316                                                         return false;
    317316                                                }
    318317                                        }
    319 
    320                                         @unlink($this->filename);
    321318
    322319                                break;
     
    329326                                                {
    330327                                                        $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file);
    331                                                         return false;
    332328                                                }
    333329                                        }
    334 
    335                                         @unlink($this->filename);
    336330
    337331                                break;
     
    342336                                        {
    343337                                                $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file);
    344                                                 return false;
    345338                                        }
    346                                         @unlink($this->filename);
    347339
    348340                                break;
     341                        }
     342
     343                        // Remove temporary filename
     344                        @unlink($this->filename);
     345
     346                        if (sizeof($this->error))
     347                        {
     348                                return false;
    349349                        }
    350350
     
    418418                if ($this->upload->max_filesize && ($this->get('filesize') > $this->upload->max_filesize || $this->filesize == 0))
    419419                {
    420                         $size_lang = ($this->upload->max_filesize >= 1048576) ? $user->lang['MIB'] : (($this->upload->max_filesize >= 1024) ? $user->lang['KIB'] : $user->lang['BYTES'] );
    421420                        $max_filesize = get_formatted_filesize($this->upload->max_filesize, false);
    422421
    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']);
    424423
    425424                        return false;
     
    595594                if ($file->get('filename') == 'none')
    596595                {
    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]);
    598608                        return $file;
    599609                }
     
    625635                if ($filedata === false)
    626636                {
    627                         $_FILES[$form_name]['name'] = basename($source_file);
     637                        $_FILES[$form_name]['name'] = utf8_basename($source_file);
    628638                        $_FILES[$form_name]['size'] = 0;
    629639                        $mimetype = '';
     
    671681                if ($file->get('filename') == 'none')
    672682                {
    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]);
    674695                        return $file;
    675696                }
     
    726747
    727748                $url['path'] = implode('', $url['path']);
    728                 $upload_ary['name'] = basename($url['path']) . (($ext) ? '.' . $ext : '');
     749                $upload_ary['name'] = utf8_basename($url['path']) . (($ext) ? '.' . $ext : '');
    729750                $filename = $url['path'];
    730751                $filesize = 0;
     
    819840                {
    820841                        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]);
    822854                        break;
    823855
    824856                        case 2:
    825                                 $size_lang = ($this->max_filesize >= 1048576) ? $user->lang['MIB'] : (($this->max_filesize >= 1024) ? $user->lang['KIB'] : $user->lang['BYTES']);
    826857                                $max_filesize = get_formatted_filesize($this->max_filesize, false);
    827858
    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']);
    829860                        break;
    830861
     
    859890                if ($this->max_filesize && ($file->get('filesize') > $this->max_filesize || $file->get('filesize') == 0))
    860891                {
    861                         $size_lang = ($this->max_filesize >= 1048576) ? $user->lang['MIB'] : (($this->max_filesize >= 1024) ? $user->lang['KIB'] : $user->lang['BYTES']);
    862892                        $max_filesize = get_formatted_filesize($this->max_filesize, false);
    863893
    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']);
    865895                }
    866896
Note: See TracChangeset for help on using the changeset viewer.