From 352e9956748b29672f71762ae18bec331a47f337 Mon Sep 17 00:00:00 2001 From: javiexin Date: Fri, 3 Jul 2015 19:40:09 +0200 Subject: [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(+) (limited to 'phpBB/phpbb/avatar/driver/upload.php') 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'), -- cgit v1.2.1