diff options
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/acp/acp_forums.php | 2 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_groups.php | 35 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_prune.php | 2 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_users.php | 88 | ||||
-rw-r--r-- | phpBB/includes/functions.php | 2 | ||||
-rw-r--r-- | phpBB/includes/functions_convert.php | 152 | ||||
-rw-r--r-- | phpBB/includes/functions_privmsgs.php | 4 | ||||
-rw-r--r-- | phpBB/includes/functions_user.php | 121 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_profile.php | 85 |
9 files changed, 226 insertions, 265 deletions
diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 20b463d82a..9b1388a13d 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -224,7 +224,7 @@ class acp_forums $auth->acl_clear_prefetch(); $cache->destroy('sql', FORUMS_TABLE); - $acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_data['forum_id'] . '&select_all_groups=1'; + $acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_data['forum_id']; $message = ($action == 'add') ? $user->lang['FORUM_CREATED'] : $user->lang['FORUM_UPDATED']; diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 63aec2db97..06761d0fac 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -261,7 +261,9 @@ class acp_groups $allow_desc_smilies = request_var('desc_parse_smilies', false); $data['uploadurl'] = request_var('uploadurl', ''); - $data['remotelink'] = request_var('remotelink', ''); + $data['remotelink'] = request_var('remotelink', ''); + $data['width'] = request_var('width', ''); + $data['height'] = request_var('height', ''); $delete = request_var('delete', ''); $submit_ary = array( @@ -283,9 +285,6 @@ class acp_groups if (!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl'] || $data['remotelink']) { - $data['width'] = request_var('width', ''); - $data['height'] = request_var('height', ''); - // Avatar stuff $var_ary = array( 'uploadurl' => array('string', true, 5, 255), @@ -319,6 +318,34 @@ class acp_groups $submit_ary['avatar'] = $category . '/' . $avatar_select; } } + else if ($data['width'] && $data['height']) + { + // Only update the dimensions? + if ($config['avatar_max_width'] || $config['avatar_max_height']) + { + if ($data['width'] > $config['avatar_max_width'] || $data['height'] > $config['avatar_max_height']) + { + $error[] = sprintf($user->lang['AVATAR_WRONG_SIZE'], $config['avatar_min_width'], $config['avatar_min_height'], $config['avatar_max_width'], $config['avatar_max_height'], $data['width'], $data['height']); + } + } + + if (!sizeof($error)) + { + if ($config['avatar_min_width'] || $config['avatar_min_height']) + { + if ($data['width'] < $config['avatar_min_width'] || $data['height'] < $config['avatar_min_height']) + { + $error[] = sprintf($user->lang['AVATAR_WRONG_SIZE'], $config['avatar_min_width'], $config['avatar_min_height'], $config['avatar_max_width'], $config['avatar_max_height'], $data['width'], $data['height']); + } + } + } + + if (!sizeof($error)) + { + $submit_ary['avatar_width'] = $data['width']; + $submit_ary['avatar_height'] = $data['height']; + } + } else if ($delete) { $submit_ary['avatar'] = ''; diff --git a/phpBB/includes/acp/acp_prune.php b/phpBB/includes/acp/acp_prune.php index e71fe33557..851671e36d 100644 --- a/phpBB/includes/acp/acp_prune.php +++ b/phpBB/includes/acp/acp_prune.php @@ -53,7 +53,7 @@ class acp_prune { $prune_posted = request_var('prune_days', 0); $prune_viewed = request_var('prune_vieweddays', 0); - $prune_all = !$prune_posted && !$prune_viewed; + $prune_all = (!$prune_posted && !$prune_viewed) ? true : false; $prune_flags = 0; $prune_flags += (request_var('prune_old_polls', 0)) ? 2 : 0; diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index ec07baae5e..a1bb85ad1c 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1373,95 +1373,13 @@ class acp_users case 'avatar': - $avatar_select = basename(request_var('avatar_select', '')); - $category = basename(request_var('category', '')); $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && is_writeable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false; - $data = array(); - if ($submit) { - $delete = request_var('delete', ''); - - $data = array( - 'uploadurl' => request_var('uploadurl', ''), - 'remotelink' => request_var('remotelink', ''), - 'width' => request_var('width', ''), - 'height' => request_var('height', ''), - ); - - $error = validate_data($data, array( - 'uploadurl' => array('string', true, 5, 255), - 'remotelink' => array('string', true, 5, 255), - 'width' => array('string', true, 1, 3), - 'height' => array('string', true, 1, 3), - )); - - if (!sizeof($error)) - { - $data['user_id'] = $user_id; - - if ((!empty($_FILES['uploadfile']['name']) || $data['uploadurl']) && $can_upload && $config['allow_avatar_upload']) - { - list($type, $filename, $width, $height) = avatar_upload($data, $error); - } - else if ($data['remotelink'] && $config['allow_avatar_remote']) - { - list($type, $filename, $width, $height) = avatar_remote($data, $error); - } - else if ($avatar_select && $config['allow_avatar_local']) - { - $type = AVATAR_GALLERY; - $filename = $avatar_select; - - // check avatar gallery - if (!is_dir($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category)) - { - $type = $width = $height = 0; - $filename = ''; - } - else - { - list($width, $height) = getimagesize($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category . '/' . $filename); - $filename = $category . '/' . $filename; - } - } - else if ($delete) - { - $filename = ''; - $type = $width = $height = 0; - } - else - { - $data = array(); - } - } - - if (!sizeof($error)) + if (avatar_process_user($error, $user_row)) { - // Do we actually have any data to update? - if (sizeof($data)) - { - $sql_ary = array( - 'user_avatar' => $filename, - 'user_avatar_type' => $type, - 'user_avatar_width' => $width, - 'user_avatar_height' => $height, - ); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . $user_id; - $db->sql_query($sql); - - // Delete old avatar if present - if ($user_row['user_avatar'] && $filename != $user_row['user_avatar'] && $user_row['user_avatar_type'] != AVATAR_GALLERY) - { - avatar_delete('user', $user_row); - } - } - - trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); + trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_row['user_id'])); } // Replace "error" strings with their real, localised form @@ -1493,6 +1411,8 @@ class acp_users } $display_gallery = (isset($_POST['display_gallery'])) ? true : false; + $avatar_select = basename(request_var('avatar_select', '')); + $category = basename(request_var('category', '')); if ($config['allow_avatar_local'] && $display_gallery) { diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 7a99a551cc..db34574b72 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3678,8 +3678,6 @@ function page_header($page_title = '', $display_online_list = true) 'S_USERNAME' => $user->data['username'], 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'], 'S_CONTENT_ENCODING' => 'UTF-8', - 'S_CONTENT_DIR_LEFT' => $user->lang['LEFT'], - 'S_CONTENT_DIR_RIGHT' => $user->lang['RIGHT'], 'S_TIMEZONE' => ($user->data['user_dst'] || ($user->data['user_id'] == ANONYMOUS && $config['board_dst'])) ? sprintf($user->lang['ALL_TIMES'], $user->lang['tz'][$tz], $user->lang['tz']['dst']) : sprintf($user->lang['ALL_TIMES'], $user->lang['tz'][$tz], ''), 'S_DISPLAY_ONLINE_LIST' => ($l_online_time) ? 1 : 0, 'S_DISPLAY_SEARCH' => (!$config['load_search']) ? 0 : (isset($auth) ? ($auth->acl_get('u_search') && $auth->acl_getf_global('f_search')) : 1), diff --git a/phpBB/includes/functions_convert.php b/phpBB/includes/functions_convert.php index 499d62de3d..f4a63d27e0 100644 --- a/phpBB/includes/functions_convert.php +++ b/phpBB/includes/functions_convert.php @@ -541,61 +541,43 @@ function base64_unpack($string) return $number; } -function import_attachment($source, $target = '') +function _import_check($config_var, $source, $use_target) { - if (empty($source)) - { - return ''; - } + global $convert, $config; - global $convert, $phpbb_root_path, $config, $user; + $result = array( + 'orig_source' => $source, + 'copy' => false, + 'relative_path' => (empty($convert->convertor['source_path_absolute'])) ? true : false, + ); - $relative_path = empty($convert->convertor['source_path_absolute']); + $target = $config[$config_var] . '/' . basename(($use_target === false) ? $source : $use_target); - if (empty($convert->convertor['upload_path'])) + if (!empty($convert->convertor[$config_var]) && strpos($source, $convert->convertor[$config_var]) !== 0) { - $convert->p_master->error(sprintf($user->lang['CONV_ERROR_NO_UPLOAD_DIR'], 'import_attachment()'), __LINE__, __FILE__); + $source = $convert->convertor[$config_var] . $source; } - $target = $config['upload_path'] . '/' . basename(empty($target) ? $source : $target); + $result['source'] = $source; - if (strpos($source, $convert->convertor['upload_path']) !== 0) + if (file_exists(relative_base($source, $result['relative_path'], __LINE__, __FILE__))) { - $source = $convert->convertor['upload_path'] . $source; + $result['copied'] = copy_file($source, $target, false, false, $result['relative_path']); } - if (file_exists(relative_base($source, $relative_path, __LINE__, __FILE__))) + if ($result['copied']) { - if ($result = copy_file($source, $target, false, false, $relative_path)) - { - // Thumbnails? - if (is_array($convert->convertor['thumbnails'])) - { - $thumb_dir = $convert->convertor['thumbnails'][0]; - $thumb_prefix = $convert->convertor['thumbnails'][1]; - $thumb_source = $thumb_dir . $thumb_prefix . basename($source); - - if (strpos($thumb_source, $convert->convertor['upload_path']) !== 0) - { - $thumb_source = $convert->convertor['upload_path'] . $thumb_source; - } - $thumb_target = $config['upload_path'] . '/thumb_' . basename($target); - - if (file_exists(relative_base($thumb_source, $relative_path, __LINE__, __FILE__))) - { - copy_file($thumb_source, $thumb_target, false, false, $relative_path); - } - } - - return basename($target); - } + $result['target'] = basename($target); + } + else + { + $result['target'] = ($use_target !== false) ? $result['orig_source'] : basename($target); } - // Even though the image might not be displayed, the admin is able to manually copy the relevant files - return $source; + return $result; } -function import_rank($source, $target = '') +function import_attachment($source, $use_target = false) { if (empty($source)) { @@ -604,33 +586,39 @@ function import_rank($source, $target = '') global $convert, $phpbb_root_path, $config, $user; - $relative_path = empty($convert->convertor['source_path_absolute']); - - if (!isset($convert->convertor['ranks_path'])) + if (empty($convert->convertor['upload_path'])) { - $convert->p_master->error(sprintf($user->lang['CONV_ERROR_NO_RANKS_PATH'], 'import_rank()'), __LINE__, __FILE__); + $convert->p_master->error(sprintf($user->lang['CONV_ERROR_NO_UPLOAD_DIR'], 'import_attachment()'), __LINE__, __FILE__); } - $target = $config['ranks_path'] . '/' . basename(empty($target) ? $source : $target); - - if (!empty($convert->convertor['ranks_path']) && strpos($source, $convert->convertor['ranks_path']) !== 0) - { - $source = $convert->convertor['ranks_path'] . $source; - } + $result = _import_check('upload_path', $source, $use_target); - if (file_exists(relative_base($source, $relative_path, __LINE__, __FILE__))) + if ($result['copied']) { - if ($result = copy_file($source, $target, false, false, $relative_path)) + // Thumbnails? + if (is_array($convert->convertor['thumbnails'])) { - return basename($target); + $thumb_dir = $convert->convertor['thumbnails'][0]; + $thumb_prefix = $convert->convertor['thumbnails'][1]; + $thumb_source = $thumb_dir . $thumb_prefix . basename($result['source']); + + if (strpos($thumb_source, $convert->convertor['upload_path']) !== 0) + { + $thumb_source = $convert->convertor['upload_path'] . $thumb_source; + } + $thumb_target = $config['upload_path'] . '/thumb_' . $result['target']; + + if (file_exists(relative_base($thumb_source, $result['relative_path'], __LINE__, __FILE__))) + { + copy_file($thumb_source, $thumb_target, false, false, $result['relative_path']); + } } } - // Even though the image might not be displayed, the admin is able to manually copy the relevant files - return $source; + return $result['target']; } -function import_smiley($source, $target = '') +function import_rank($source, $use_target = false) { if (empty($source)) { @@ -639,32 +627,34 @@ function import_smiley($source, $target = '') global $convert, $phpbb_root_path, $config, $user; - $relative_path = empty($convert->convertor['source_path_absolute']); - - if (!isset($convert->convertor['smilies_path'])) + if (!isset($convert->convertor['ranks_path'])) { - $convert->p_master->error(sprintf($user->lang['CONV_ERROR_NO_SMILIES_PATH'], 'import_smiley()'), __LINE__, __FILE__); + $convert->p_master->error(sprintf($user->lang['CONV_ERROR_NO_RANKS_PATH'], 'import_rank()'), __LINE__, __FILE__); } - $target = $config['smilies_path'] . '/' . basename(empty($target) ? $source : $target); + $result = _import_check('ranks_path', $source, $use_target); + return $result['target']; +} - if (!empty($convert->convertor['smilies_path']) && strpos($source, $convert->convertor['smilies_path']) !== 0) +function import_smiley($source, $use_target = false) +{ + if (empty($source)) { - $source = $convert->convertor['smilies_path'] . $source; + return ''; } - if (file_exists(relative_base($source, $relative_path, __LINE__, __FILE__))) + global $convert, $phpbb_root_path, $config, $user; + + if (!isset($convert->convertor['smilies_path'])) { - if ($result = copy_file($source, $target, false, false, $relative_path)) - { - return basename($target); - } + $convert->p_master->error(sprintf($user->lang['CONV_ERROR_NO_SMILIES_PATH'], 'import_smiley()'), __LINE__, __FILE__); } - return $source; + $result = _import_check('smilies_path', $source, $use_target); + return $result['target']; } -function import_avatar($source, $target = '') +function import_avatar($source, $use_target = false) { if (empty($source) || preg_match('#^https?:#i', $source) || preg_match('#blank\.(gif|png)$#i', $source)) { @@ -673,29 +663,13 @@ function import_avatar($source, $target = '') global $convert, $phpbb_root_path, $config, $user; - $relative_path = empty($convert->convertor['source_path_absolute']); - if (!isset($convert->convertor['avatar_path'])) { $convert->p_master->error(sprintf($user->lang['CONV_ERROR_NO_AVATAR_PATH'], 'import_avatar()'), __LINE__, __FILE__); } - $target = $config['avatar_path'] . '/' . basename(empty($target) ? $source : $target); - - if (!empty($convert->convertor['avatar_path']) && strpos($source, $convert->convertor['avatar_path']) !== 0) - { - $source = $convert->convertor['avatar_path'] . $source; - } - - if (file_exists(relative_base($source, $relative_path, __LINE__, __FILE__))) - { - if ($result = copy_file($source, $target, false, false, $relative_path)) - { - return basename($target); - } - } - - return $source; + $result = _import_check('avatar_path', $source, $use_target); + return $result['target']; } /** @@ -1657,6 +1631,8 @@ function add_bots() { global $db, $convert, $user, $config, $phpbb_root_path, $phpEx; + $db->sql_query($convert->truncate_statement . BOTS_TABLE); + $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " WHERE group_name = 'BOTS'"; $result = $db->sql_query($sql); $group_id = (int) $db->sql_fetchfield('group_id', 0, $result); @@ -1755,8 +1731,6 @@ function add_bots() if ($user_id) { - add_user_group($group_id, $user_id, false); - $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $db->sql_build_array('INSERT', array( 'bot_active' => 1, 'bot_name' => $bot_name, diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index d0923f7d36..9296d254e5 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -539,7 +539,7 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false) if (sizeof($important_ids)) { $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' - SET pm_marked = !pm_marked + SET pm_marked = 1 - pm_marked WHERE folder_id = ' . PRIVMSGS_NO_BOX . " AND user_id = $user_id AND " . $db->sql_in_set('msg_id', $important_ids); @@ -845,7 +845,7 @@ function handle_mark_actions($user_id, $mark_action) case 'mark_important': $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . " - SET pm_marked = !pm_marked + SET pm_marked = 1 - pm_marked WHERE folder_id = $cur_folder_id AND user_id = $user_id AND " . $db->sql_in_set('msg_id', $msg_ids); diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 3e60580293..7cceda0dd2 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1585,6 +1585,127 @@ function avatar_gallery($category, $avatar_select, $items_per_column, $block_var return $avatar_list; } +/** +* Uploading/Changing user avatar +*/ +function avatar_process_user(&$error, $custom_userdata = false) +{ + global $config, $phpbb_root_path, $auth, $user, $db; + + $data = array( + 'uploadurl' => request_var('uploadurl', ''), + 'remotelink' => request_var('remotelink', ''), + 'width' => request_var('width', ''), + 'height' => request_var('height', ''), + ); + + $error = validate_data($data, array( + 'uploadurl' => array('string', true, 5, 255), + 'remotelink' => array('string', true, 5, 255), + 'width' => array('string', true, 1, 3), + 'height' => array('string', true, 1, 3), + )); + + if (sizeof($error)) + { + return false; + } + + $sql_ary = array(); + $data['user_id'] = ($custom_userdata === false) ? $user->data['user_id'] : $custom_userdata['user_id']; + $change_avatar = ($custom_userdata === false) ? $auth->acl_get('u_chgavatar') : true; + $avatar_select = basename(request_var('avatar_select', '')); + + // Can we upload? + $can_upload = ($config['allow_avatar_upload'] && file_exists($phpbb_root_path . $config['avatar_path']) && is_writeable($phpbb_root_path . $config['avatar_path']) && $change_avatar && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false; + + if ((!empty($_FILES['uploadfile']['name']) || $data['uploadurl']) && $can_upload) + { + list($sql_ary['user_avatar_type'], $sql_ary['user_avatar'], $sql_ary['user_avatar_width'], $sql_ary['user_avatar_height']) = avatar_upload($data, $error); + } + else if ($data['remotelink'] && $change_avatar && $config['allow_avatar_remote']) + { + list($sql_ary['user_avatar_type'], $sql_ary['user_avatar'], $sql_ary['user_avatar_width'], $sql_ary['user_avatar_height']) = avatar_remote($data, $error); + } + else if ($avatar_select && $change_avatar && $config['allow_avatar_local']) + { + $category = basename(request_var('category', '')); + + $sql_ary['user_avatar_type'] = AVATAR_GALLERY; + $sql_ary['user_avatar'] = $avatar_select; + + // check avatar gallery + if (!is_dir($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category)) + { + $sql_ary['user_avatar'] = ''; + $sql_ary['user_avatar_type'] = $sql_ary['user_avatar_width'] = $sql_ary['user_avatar_height'] = 0; + } + else + { + list($sql_ary['user_avatar_width'], $sql_ary['user_avatar_height']) = getimagesize($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category . '/' . $sql_ary['user_avatar']); + $sql_ary['user_avatar'] = $category . '/' . $sql_ary['user_avatar']; + } + } + else if (isset($_POST['delete']) && $change_avatar) + { + $sql_ary['user_avatar'] = ''; + $sql_ary['user_avatar_type'] = $sql_ary['user_avatar_width'] = $sql_ary['user_avatar_height'] = 0; + } + else if ($data['width'] && $data['height']) + { + // Only update the dimensions? + if ($config['avatar_max_width'] || $config['avatar_max_height']) + { + if ($data['width'] > $config['avatar_max_width'] || $data['height'] > $config['avatar_max_height']) + { + $error[] = sprintf($user->lang['AVATAR_WRONG_SIZE'], $config['avatar_min_width'], $config['avatar_min_height'], $config['avatar_max_width'], $config['avatar_max_height'], $data['width'], $data['height']); + } + } + + if (!sizeof($error)) + { + if ($config['avatar_min_width'] || $config['avatar_min_height']) + { + if ($data['width'] < $config['avatar_min_width'] || $data['height'] < $config['avatar_min_height']) + { + $error[] = sprintf($user->lang['AVATAR_WRONG_SIZE'], $config['avatar_min_width'], $config['avatar_min_height'], $config['avatar_max_width'], $config['avatar_max_height'], $data['width'], $data['height']); + } + } + } + + if (!sizeof($error)) + { + $sql_ary['user_avatar_width'] = $data['width']; + $sql_ary['user_avatar_height'] = $data['height']; + } + } + + if (!sizeof($error)) + { + // Do we actually have any data to update? + if (sizeof($sql_ary)) + { + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE user_id = ' . (($custom_userdata === false) ? $user->data['user_id'] : $custom_userdata['user_id']); + $db->sql_query($sql); + + if (isset($sql_ary['user_avatar'])) + { + $userdata = ($custom_userdata === false) ? $user->data : $custom_userdata; + + // Delete old avatar if present + if ($userdata['user_avatar'] && $sql_ary['user_avatar'] != $userdata['user_avatar'] && $userdata['user_avatar_type'] != AVATAR_GALLERY) + { + avatar_delete('user', $userdata); + } + } + } + } + + return (sizeof($error)) ? false : true; +} + // // Usergroup functions // diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index b5d2ae19d8..a69068b526 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -488,94 +488,15 @@ class ucp_profile case 'avatar': $display_gallery = (isset($_POST['display_gallery'])) ? true : false; - $delete = (isset($_POST['delete'])) ? true : false; - $avatar_select = basename(request_var('avatar_select', '')); $category = basename(request_var('category', '')); - // Can we upload? $can_upload = ($config['allow_avatar_upload'] && file_exists($phpbb_root_path . $config['avatar_path']) && is_writeable($phpbb_root_path . $config['avatar_path']) && $auth->acl_get('u_chgavatar') && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false; if ($submit) { - $data = array( - 'uploadurl' => request_var('uploadurl', ''), - 'remotelink' => request_var('remotelink', ''), - 'width' => request_var('width', ''), - 'height' => request_var('height', ''), - ); - - $error = validate_data($data, array( - 'uploadurl' => array('string', true, 5, 255), - 'remotelink' => array('string', true, 5, 255), - 'width' => array('string', true, 1, 3), - 'height' => array('string', true, 1, 3), - )); - - if (!sizeof($error)) + if (avatar_process_user($error)) { - $data['user_id'] = $user->data['user_id']; - - if ((!empty($_FILES['uploadfile']['name']) || $data['uploadurl']) && $can_upload) - { - list($type, $filename, $width, $height) = avatar_upload($data, $error); - } - else if ($data['remotelink'] && $auth->acl_get('u_chgavatar') && $config['allow_avatar_remote']) - { - list($type, $filename, $width, $height) = avatar_remote($data, $error); - } - else if ($avatar_select && $auth->acl_get('u_chgavatar') && $config['allow_avatar_local']) - { - $type = AVATAR_GALLERY; - $filename = $avatar_select; - - // check avatar gallery - if (!is_dir($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category)) - { - $filename = ''; - $type = $width = $height = 0; - } - else - { - list($width, $height) = getimagesize($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category . '/' . $filename); - $filename = $category . '/' . $filename; - } - } - else if ($delete && $auth->acl_get('u_chgavatar')) - { - $filename = ''; - $type = $width = $height = 0; - } - else - { - $data = array(); - } - } - - if (!sizeof($error)) - { - // Do we actually have any data to update? - if (sizeof($data)) - { - $sql_ary = array( - 'user_avatar' => $filename, - 'user_avatar_type' => $type, - 'user_avatar_width' => $width, - 'user_avatar_height' => $height, - ); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . $user->data['user_id']; - $db->sql_query($sql); - - // Delete old avatar if present - if ($user->data['user_avatar'] && $filename != $user->data['user_avatar'] && $user->data['user_avatar_type'] != AVATAR_GALLERY) - { - avatar_delete('user', $user->data); - } - } - meta_refresh(3, $this->u_action); $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); trigger_error($message); @@ -624,8 +545,8 @@ class ucp_profile $template->assign_vars(array( 'AVATAR' => $avatar_img, 'AVATAR_SIZE' => $config['avatar_filesize'], - 'WIDTH' => (isset($data['width'])) ? $data['width'] : $user->data['user_avatar_width'], - 'HEIGHT' => (isset($data['height'])) ? $data['height'] : $user->data['user_avatar_height'], + 'WIDTH' => request_var('width', $user->data['user_avatar_width']), + 'HEIGHT' => request_var('height', $user->data['user_avatar_height']), 'S_UPLOAD_AVATAR_FILE' => $can_upload, 'S_UPLOAD_AVATAR_URL' => $can_upload, |