diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index 93ac355d25..b5c128cf46 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -357,18 +357,9 @@ class ucp extends user
{
global $config, $db, $user;
- $avatar = explode(':', $user->data['user_avatar']);
- $avatar_type = array_shift($avatar);
-
- if ($avatar_type != 'upload')
+ if (@file_exists('./' . $config['avatar_path'] . '/' . $user->data['user_avatar']))
{
- return;
- }
-
- $avatar = implode('', $avatar);
- if (@file_exists('./' . $config['avatar_path'] . '/' . $avatar))
- {
- @unlink('./' . $config['avatar_path'] . '/' . $avatar);
+ @unlink('./' . $config['avatar_path'] . '/' . $user->data['user_avatar']);
}
}
@@ -387,11 +378,16 @@ class ucp extends user
return true;
}
- if (!($data['width'] || $data['height']) && ($config['avatar_max_width'] || $config['avatar_max_height']))
+ if ((!($data['width'] || $data['height']) || $data['remotelink'] != $user->data['user_avatar']) && ($config['avatar_max_width'] || $config['avatar_max_height']))
{
list($width, $height) = @getimagesize($data['remotelink']);
- if ($width > $config['avatar_max_width'] || $height > $config['avatar_max_height'])
+ if (!$width || !$height)
+ {
+ $this->error[] = $user->lang['AVATAR_NO_SIZE'];
+ return true;
+ }
+ else if ($width > $config['avatar_max_width'] || $height > $config['avatar_max_height'])
{
$this->error[] = sprintf($user->lang['AVATAR_WRONG_SIZE'], $config['avatar_max_width'], $config['avatar_max_height']);
return true;
@@ -526,6 +522,7 @@ class ucp extends user
$filesize = filesize('./' . $config['avatar_path'] . '/' . $data['filename']);
if (!$filesize || $filesize > $config['avatar_filesize'])
{
+ @unlink('./' . $config['avatar_path'] . '/' . $data['filename']);
$this->error[] = sprintf($user->lang['AVATAR_WRONG_FILESIZE'], $config['avatar_filesize']);
return true;
}
diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php
index a2e811cdbb..d5e757b326 100644
--- a/phpBB/includes/ucp/ucp_profile.php
+++ b/phpBB/includes/ucp/ucp_profile.php
@@ -361,6 +361,7 @@ class ucp_profile extends ucp
)
);
$data = $this->normalise_data($_POST, $normalise);
+
$this->avatar_upload($data);
}
else if (!empty($_POST['remotelink']))
@@ -373,12 +374,12 @@ class ucp_profile extends ucp
)
);
$data = $this->normalise_data($_POST, $normalise);
+
$this->avatar_remote($data);
}
else if (!empty($_POST['delete']))
{
$data['filename'] = $data['width'] = $data['height'] = '';
- $this->avatar_delete();
}
if (!sizeof($this->error))
@@ -395,8 +396,11 @@ class ucp_profile extends ucp
WHERE user_id = ' . $user->data['user_id'];
$db->sql_query($sql);
- // Delete an existing avatar if present
- $this->avatar_delete();
+ // Delete old avatar if present
+ if ($user->data['user_avatar'] != '' && $data['filename'] != $user->data['user_avatar'])
+ {
+ $this->avatar_delete();
+ }
meta_refresh(3, "ucp.$phpEx$SID&i=$id&mode=$submode");
$message = $user->lang['PROFILE_UPDATED'] . '
' . sprintf($user->lang['RETURN_UCP'], "", '');
@@ -450,7 +454,7 @@ class ucp_profile extends ucp
'AVATAR' => $avatar_img,
'AVATAR_SIZE' => $config['avatar_filesize'],
'AVATAR_URL' => (isset($uploadurl)) ? $uploadurl : '',
- 'AVATAR_REMOTE' => (isset($remotelink)) ? $remotelink : (($user->data['user_avatar_type'] == AVATAR_REMOTE) ? $avatar_img : ''),
+ 'AVATAR_REMOTE' => (isset($remotelink)) ? $remotelink : (($user->data['user_avatar_type'] == AVATAR_REMOTE) ? $user->data['user_avatar'] : ''),
'WIDTH' => (isset($width)) ? $width : $user->data['user_avatar_width'],
'HEIGHT' => (isset($height)) ? $height : $user->data['user_avatar_height'],
diff --git a/phpBB/language/en/lang_main.php b/phpBB/language/en/lang_main.php
index 34b8541e6a..8043c73be4 100644
--- a/phpBB/language/en/lang_main.php
+++ b/phpBB/language/en/lang_main.php
@@ -720,7 +720,8 @@ $lang = array(
'AVATAR_URL_INVALID' => 'The URL you specified is invalid.',
'AVATAR_NOT_UPLOADED' => 'Avatar could not be uploaded.',
'AVATAR_WRONG_SIZE' => 'The avatar must be at most %1$d pixels wide and %2$d pixels high.',
- 'AVATAR_WRONG_FILESIZE' => 'The avatar must be between 0 and %d bytes.',
+ 'AVATAR_WRONG_FILESIZE' => 'The avatar must be between 0 and %d bytes.',
+ 'AVATAR_NO_SIZE' => 'Could not obtain width or height of linked avatar, please enter them manually.',
'PROFILE_UPDATED' => 'Your profile has been updated.',