|
@@ -362,7 +362,7 @@ function loadProfileFields($force_reload = false)
|
|
|
resetPassword($context[\'id_member\'], $value);
|
|
|
elseif ($value !== null)
|
|
|
{
|
|
|
- validateUsername($context[\'id_member\'], $value);
|
|
|
+ validateUsername($context[\'id_member\'], trim(preg_replace(\'~[\t\n\r \x0B\0\' . ($context[\'utf8\'] ? ($context[\'server\'][\'complex_preg_chars\'] ? \'\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}\' : "\xC2\xA0\xC2\xAD\xE2\x80\x80-\xE2\x80\x8F\xE2\x80\x9F\xE2\x80\xAF\xE2\x80\x9F\xE3\x80\x80\xEF\xBB\xBF") : \'\x00-\x08\x0B\x0C\x0E-\x19\xA0\') . \']+~\' . ($context[\'utf8\'] ? \'u\' : \'\'), \' \', $value)));
|
|
|
updateMemberData($context[\'id_member\'], array(\'member_name\' => $value));
|
|
|
}
|
|
|
}
|
|
@@ -486,7 +486,7 @@ function loadProfileFields($force_reload = false)
|
|
|
'input_validate' => create_function('&$value', '
|
|
|
global $context, $smcFunc, $sourcedir, $cur_profile;
|
|
|
|
|
|
- $value = trim(preg_replace(\'~[\s]~\' . ($context[\'utf8\'] ? \'u\' : \'\'), \' \', $value));
|
|
|
+ $value = trim(preg_replace(\'~[\t\n\r \x0B\0\' . ($context[\'utf8\'] ? ($context[\'server\'][\'complex_preg_chars\'] ? \'\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}\' : "\xC2\xA0\xC2\xAD\xE2\x80\x80-\xE2\x80\x8F\xE2\x80\x9F\xE2\x80\xAF\xE2\x80\x9F\xE3\x80\x80\xEF\xBB\xBF") : \'\x00-\x08\x0B\x0C\x0E-\x19\xA0\') . \']+~\' . ($context[\'utf8\'] ? \'u\' : \'\'), \' \', $value));
|
|
|
|
|
|
if (trim($value) == \'\')
|
|
|
return \'no_name\';
|
|
@@ -2677,13 +2677,14 @@ function profileSaveAvatarData(&$value)
|
|
|
$url = parse_url($_POST['userpicpersonal']);
|
|
|
$contents = fetch_web_data('http://' . $url['host'] . (empty($url['port']) ? '' : ':' . $url['port']) . str_replace(' ', '%20', trim($url['path'])));
|
|
|
|
|
|
- if ($contents != false && $tmpAvatar = fopen($uploadDir . '/avatar_tmp_' . $memID, 'wb'))
|
|
|
+ $new_filename = $uploadDir . '/' . getAttachmentFilename('avatar_tmp_' . $memID, false, null, true);
|
|
|
+ if ($contents != false && $tmpAvatar = fopen($new_filename, 'wb'))
|
|
|
{
|
|
|
fwrite($tmpAvatar, $contents);
|
|
|
fclose($tmpAvatar);
|
|
|
|
|
|
$downloadedExternalAvatar = true;
|
|
|
- $_FILES['attachment']['tmp_name'] = $uploadDir . '/avatar_tmp_' . $memID;
|
|
|
+ $_FILES['attachment']['tmp_name'] = $new_filename;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2767,29 +2768,36 @@ function profileSaveAvatarData(&$value)
|
|
|
if (!is_writable($uploadDir))
|
|
|
fatal_lang_error('attachments_no_write', 'critical');
|
|
|
|
|
|
- if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $uploadDir . '/avatar_tmp_' . $memID))
|
|
|
+ $new_filename = $uploadDir . '/' . getAttachmentFilename('avatar_tmp_' . $memID, false, null, true);
|
|
|
+ if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename))
|
|
|
fatal_lang_error('attach_timeout', 'critical');
|
|
|
|
|
|
- $_FILES['attachment']['tmp_name'] = $uploadDir . '/avatar_tmp_' . $memID;
|
|
|
+ $_FILES['attachment']['tmp_name'] = $new_filename;
|
|
|
}
|
|
|
|
|
|
$sizes = @getimagesize($_FILES['attachment']['tmp_name']);
|
|
|
|
|
|
|
|
|
if ($sizes === false)
|
|
|
+ {
|
|
|
+ @unlink($_FILES['attachment']['tmp_name']);
|
|
|
return 'bad_avatar';
|
|
|
+ }
|
|
|
|
|
|
elseif ((!empty($modSettings['avatar_max_width_upload']) && $sizes[0] > $modSettings['avatar_max_width_upload']) || (!empty($modSettings['avatar_max_height_upload']) && $sizes[1] > $modSettings['avatar_max_height_upload']))
|
|
|
{
|
|
|
if (!empty($modSettings['avatar_resize_upload']))
|
|
|
{
|
|
|
|
|
|
- @chmod($uploadDir . '/avatar_tmp_' . $memID, 0644);
|
|
|
+ @chmod($_FILES['attachment']['tmp_name'], 0644);
|
|
|
|
|
|
|
|
|
require_once($sourcedir . '/Subs-Graphics.php');
|
|
|
- if (!downloadAvatar($uploadDir . '/avatar_tmp_' . $memID, $memID, $modSettings['avatar_max_width_upload'], $modSettings['avatar_max_height_upload']))
|
|
|
+ if (!downloadAvatar($_FILES['attachment']['tmp_name'], $memID, $modSettings['avatar_max_width_upload'], $modSettings['avatar_max_height_upload']))
|
|
|
+ {
|
|
|
+ @unlink($_FILES['attachment']['tmp_name']);
|
|
|
return 'bad_avatar';
|
|
|
+ }
|
|
|
|
|
|
|
|
|
$cur_profile['id_attach'] = $modSettings['new_avatar_data']['id'];
|
|
@@ -2797,7 +2805,10 @@ function profileSaveAvatarData(&$value)
|
|
|
$cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type'];
|
|
|
}
|
|
|
else
|
|
|
+ {
|
|
|
+ @unlink($_FILES['attachment']['tmp_name']);
|
|
|
return 'bad_avatar';
|
|
|
+ }
|
|
|
}
|
|
|
elseif (is_array($sizes))
|
|
|
{
|
|
@@ -2807,12 +2818,18 @@ function profileSaveAvatarData(&$value)
|
|
|
{
|
|
|
|
|
|
if (empty($modSettings['avatar_reencode']) || (!reencodeImage($_FILES['attachment']['tmp_name'], $sizes[2])))
|
|
|
+ {
|
|
|
+ @unlink($_FILES['attachment']['tmp_name']);
|
|
|
return 'bad_avatar';
|
|
|
+ }
|
|
|
|
|
|
$sizes = @getimagesize($_FILES['attachment']['tmp_name']);
|
|
|
|
|
|
if ($sizes === false)
|
|
|
+ {
|
|
|
+ @unlink($_FILES['attachment']['tmp_name']);
|
|
|
return 'bad_avatar';
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$extensions = array(
|
|
@@ -2862,8 +2879,8 @@ function profileSaveAvatarData(&$value)
|
|
|
$profile_vars['avatar'] = '';
|
|
|
|
|
|
|
|
|
- if (file_exists($uploadDir . '/avatar_tmp_' . $memID))
|
|
|
- @unlink($uploadDir . '/avatar_tmp_' . $memID);
|
|
|
+ if (file_exists($_FILES['attachment']['tmp_name']))
|
|
|
+ @unlink($_FILES['attachment']['tmp_name']);
|
|
|
}
|
|
|
|
|
|
else
|