diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2006-12-21 10:37:50 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2006-12-21 10:37:50 +0000 |
commit | 515085a2a2d4b06989566a60b8add3fa4864f1e3 (patch) | |
tree | 9000d688dc33511560a9d08191b87d1340f70af3 /phpBB/includes/functions_upload.php | |
parent | 2e1eef2713f7891ce9d78736ceae6d2faf93fc4b (diff) | |
download | forums-515085a2a2d4b06989566a60b8add3fa4864f1e3.tar forums-515085a2a2d4b06989566a60b8add3fa4864f1e3.tar.gz forums-515085a2a2d4b06989566a60b8add3fa4864f1e3.tar.bz2 forums-515085a2a2d4b06989566a60b8add3fa4864f1e3.tar.xz forums-515085a2a2d4b06989566a60b8add3fa4864f1e3.zip |
- some fixes
- important bugfix for the mcp and determining allowed ids in general (if global announcements are included)
git-svn-id: file:///svn/phpbb/trunk@6787 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions_upload.php')
-rw-r--r-- | phpBB/includes/functions_upload.php | 75 |
1 files changed, 39 insertions, 36 deletions
diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php index ff32e4447d..e1cffaf710 100644 --- a/phpBB/includes/functions_upload.php +++ b/phpBB/includes/functions_upload.php @@ -214,10 +214,11 @@ class filespec * The phpbb_root_path variable will be applied to the destination path * * @param string $destination_path Destination path, for example $config['avatar_path'] + * @param bool $overwrite If set to true, an already existing file will be overwritten * @param octal $chmod Permission mask for chmodding the file after a successful move * @access public */ - function move_file($destination, $chmod = 0666) + function move_file($destination, $overwrite = false, $chmod = 0666) { global $user, $phpbb_root_path; @@ -241,62 +242,64 @@ class filespec $this->destination_file = $this->destination_path . '/' . basename($this->realname); // Check if the file already exist, else there is something wrong... - if (file_exists($this->destination_file)) + if (file_exists($this->destination_file) && !$overwrite) { @unlink($this->filename); - return false; } - - switch ($upload_mode) + else { - case 'copy': + if (file_exists($this->destination_file)) + { + @unlink($this->destination_file); + } + + switch ($upload_mode) + { + case 'copy': + + if (!@copy($this->filename, $this->destination_file)) + { + if (!@move_uploaded_file($this->filename, $this->destination_file)) + { + $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file); + return false; + } + } + + @unlink($this->filename); + + break; + + case 'move': - if (!@copy($this->filename, $this->destination_file)) - { if (!@move_uploaded_file($this->filename, $this->destination_file)) { - $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file); - return false; + if (!@copy($this->filename, $this->destination_file)) + { + $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file); + return false; + } } - } - else - { + @unlink($this->filename); - } - break; + break; - case 'move': + case 'local': - if (!@move_uploaded_file($this->filename, $this->destination_file)) - { if (!@copy($this->filename, $this->destination_file)) { $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file); return false; } - else - { - @unlink($this->filename); - } - } - - break; - - case 'local': + @unlink($this->filename); - if (!@copy($this->filename, $this->destination_file)) - { - $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file); - return false; - } - @unlink($this->filename); + break; + } - break; + @chmod($this->destination_file, $chmod); } - @chmod($this->destination_file, $chmod); - // Try to get real filesize from destination folder $this->filesize = (@filesize($this->destination_file)) ? @filesize($this->destination_file) : $this->filesize; |