From 352e9956748b29672f71762ae18bec331a47f337 Mon Sep 17 00:00:00 2001 From: javiexin Date: Fri, 3 Jul 2015 19:40:09 +0200 Subject: [PATCH 1/2] [ticket/13980] Uploaded avatar not removed when new is uploaded Remove the previously uploaded avatar when a new one with a different extension is uploaded PHPBB3-13980 --- phpBB/phpbb/avatar/driver/upload.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/phpBB/phpbb/avatar/driver/upload.php b/phpBB/phpbb/avatar/driver/upload.php index ee36243844..eae96cd794 100644 --- a/phpBB/phpbb/avatar/driver/upload.php +++ b/phpBB/phpbb/avatar/driver/upload.php @@ -161,6 +161,16 @@ class upload extends \phpbb\avatar\driver\driver return false; } + $ext = substr(strrchr($row['avatar'], '.'), 1); + if ($ext && $ext !== $file->get('extension')) + { + $filename = $this->phpbb_root_path . $this->config['avatar_path'] . '/' . $this->config['avatar_salt'] . '_' . $row['id'] . '.' . $ext; + if (file_exists($filename)) + { + @unlink($filename); + } + } + return array( 'avatar' => $row['id'] . '_' . time() . '.' . $file->get('extension'), 'avatar_width' => $file->get('width'), From d0cdc5553a15de8b8cb9b26da24cbf4085b0813c Mon Sep 17 00:00:00 2001 From: javiexin Date: Thu, 9 Jul 2015 15:31:28 +0200 Subject: [PATCH 2/2] [ticket/13980] Uploaded avatar not removed when new is uploaded Remove the previously uploaded avatar when a new one with a different extension is uploaded, using existing delete method PHPBB3-13980 --- phpBB/phpbb/avatar/driver/upload.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/phpBB/phpbb/avatar/driver/upload.php b/phpBB/phpbb/avatar/driver/upload.php index eae96cd794..73147a85a0 100644 --- a/phpBB/phpbb/avatar/driver/upload.php +++ b/phpBB/phpbb/avatar/driver/upload.php @@ -161,14 +161,11 @@ class upload extends \phpbb\avatar\driver\driver return false; } + // Delete current avatar if not overwritten $ext = substr(strrchr($row['avatar'], '.'), 1); if ($ext && $ext !== $file->get('extension')) { - $filename = $this->phpbb_root_path . $this->config['avatar_path'] . '/' . $this->config['avatar_salt'] . '_' . $row['id'] . '.' . $ext; - if (file_exists($filename)) - { - @unlink($filename); - } + $this->delete($row); } return array(