本文整理汇总了PHP中avatar_upload函数的典型用法代码示例。如果您正苦于以下问题:PHP avatar_upload函数的具体用法?PHP avatar_upload怎么用?PHP avatar_upload使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了avatar_upload函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
//.........这里部分代码省略.........
${'s_limit_' . $sort_option . '_days'} .= '<option value="' . $day . '"' . $selected . '>' . $text . '</option>';
}
${'s_limit_' . $sort_option . '_days'} .= '</select>';
${'s_sort_' . $sort_option . '_key'} = '<select name="' . $sort_option . '_sk">';
foreach (${'sort_by_' . $sort_option . '_text'} as $key => $text) {
$selected = ${$sort_option . '_sk'} == $key ? ' selected="selected"' : '';
${'s_sort_' . $sort_option . '_key'} .= '<option value="' . $key . '"' . $selected . '>' . $text . '</option>';
}
${'s_sort_' . $sort_option . '_key'} .= '</select>';
${'s_sort_' . $sort_option . '_dir'} = '<select name="' . $sort_option . '_sd">';
foreach ($sort_dir_text as $key => $value) {
$selected = ${$sort_option . '_sd'} == $key ? ' selected="selected"' : '';
${'s_sort_' . $sort_option . '_dir'} .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
}
${'s_sort_' . $sort_option . '_dir'} .= '</select>';
}
$template->assign_vars(array('S_PREFS' => true, 'S_JABBER_DISABLED' => $config['jab_enable'] && $user->data['user_jabber'] && @extension_loaded('xml') ? false : true, 'VIEW_EMAIL' => isset($data['viewemail']) ? $data['viewemail'] : $user_row['user_allow_viewemail'], 'MASS_EMAIL' => isset($data['massemail']) ? $data['massemail'] : $user_row['user_allow_massemail'], 'ALLOW_PM' => isset($data['allowpm']) ? $data['allowpm'] : $user_row['user_allow_pm'], 'HIDE_ONLINE' => isset($data['hideonline']) ? $data['hideonline'] : !$user_row['user_allow_viewonline'], 'NOTIFY_EMAIL' => $notify_method == NOTIFY_EMAIL ? true : false, 'NOTIFY_IM' => $notify_method == NOTIFY_IM ? true : false, 'NOTIFY_BOTH' => $notify_method == NOTIFY_BOTH ? true : false, 'NOTIFY_PM' => isset($data['notifypm']) ? $data['notifypm'] : $user_row['user_notify_pm'], 'POPUP_PM' => isset($data['popuppm']) ? $data['popuppm'] : $this->optionget($user_row, 'popuppm'), 'DST' => isset($data['dst']) ? $data['dst'] : $user_row['user_dst'], 'BBCODE' => isset($data['bbcode']) ? $data['bbcode'] : $this->optionget($user_row, 'bbcode'), 'SMILIES' => isset($data['smilies']) ? $data['smilies'] : $this->optionget($user_row, 'smilies'), 'ATTACH_SIG' => isset($data['sig']) ? $data['sig'] : $this->optionget($user_row, 'attachsig'), 'NOTIFY' => isset($data['notify']) ? $data['notify'] : $user_row['user_notify'], 'VIEW_IMAGES' => isset($data['view_images']) ? $data['view_images'] : $this->optionget($user_row, 'viewimg'), 'VIEW_FLASH' => isset($data['view_flash']) ? $data['view_flash'] : $this->optionget($user_row, 'viewflash'), 'VIEW_SMILIES' => isset($data['view_smilies']) ? $data['view_smilies'] : $this->optionget($user_row, 'viewsmilies'), 'VIEW_SIGS' => isset($data['view_sigs']) ? $data['view_sigs'] : $this->optionget($user_row, 'viewsigs'), 'VIEW_AVATARS' => isset($data['view_avatars']) ? $data['view_avatars'] : $this->optionget($user_row, 'viewavatars'), 'VIEW_WORDCENSOR' => isset($data['view_wordcensor']) ? $data['view_wordcensor'] : $this->optionget($user_row, 'viewcensors'), 'S_TOPIC_SORT_DAYS' => $s_limit_topic_days, 'S_TOPIC_SORT_KEY' => $s_sort_topic_key, 'S_TOPIC_SORT_DIR' => $s_sort_topic_dir, 'S_POST_SORT_DAYS' => $s_limit_post_days, 'S_POST_SORT_KEY' => $s_sort_post_key, 'S_POST_SORT_DIR' => $s_sort_post_dir, 'DATE_FORMAT' => $dateformat, 'S_DATEFORMAT_OPTIONS' => $dateformat_options, 'S_CUSTOM_DATEFORMAT' => $s_custom, 'DEFAULT_DATEFORMAT' => $config['default_dateformat'], 'A_DEFAULT_DATEFORMAT' => addslashes($config['default_dateformat']), 'S_LANG_OPTIONS' => language_select($lang), 'S_STYLE_OPTIONS' => style_select($style), 'S_TZ_OPTIONS' => tz_select($tz)));
break;
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', '');
$var_ary = array('uploadurl' => (string) '', 'remotelink' => (string) '', 'width' => (string) '', 'height' => (string) '');
foreach ($var_ary as $var => $default) {
$data[$var] = request_var($var, $default);
}
$var_ary = 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));
$error = validate_data($data, $var_ary);
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)) {
// 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 . '
示例2: main
//.........这里部分代码省略.........
}
list(, $row) = each($row);
if (!$row['group_leader']) {
trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page);
}
$file_uploads = @ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on' ? true : false;
$user->add_lang(array('acp/groups', 'acp/common'));
$data = $submit_ary = array();
$update = isset($_POST['update']) ? true : false;
$error = array();
$avatar_select = basename(request_var('avatar_select', ''));
$category = basename(request_var('category', ''));
$can_upload = file_exists($phpbb_root_path . $config['avatar_path']) && @is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads ? true : false;
// Did we submit?
if ($update) {
$group_name = utf8_normalize_nfc(request_var('group_name', '', true));
$group_desc = utf8_normalize_nfc(request_var('group_desc', '', true));
$group_type = request_var('group_type', GROUP_FREE);
$allow_desc_bbcode = request_var('desc_parse_bbcode', false);
$allow_desc_urls = request_var('desc_parse_urls', false);
$allow_desc_smilies = request_var('desc_parse_smilies', false);
$submit_ary = array('colour' => request_var('group_colour', ''), 'rank' => request_var('group_rank', 0), 'receive_pm' => isset($_REQUEST['group_receive_pm']) ? 1 : 0, 'message_limit' => request_var('group_message_limit', 0), 'max_recipients' => request_var('group_max_recipients', 0));
$data['uploadurl'] = request_var('uploadurl', '');
$data['remotelink'] = request_var('remotelink', '');
$data['width'] = request_var('width', '');
$data['height'] = request_var('height', '');
$delete = request_var('delete', '');
if (!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl'] || $data['remotelink']) {
// Avatar stuff
$var_ary = 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 (!($error = validate_data($data, $var_ary))) {
$data['user_id'] = "g{$group_id}";
if ((!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl']) && $can_upload) {
list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_upload($data, $error);
} else {
if ($data['remotelink']) {
list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_remote($data, $error);
}
}
}
} else {
if ($avatar_select && $config['allow_avatar_local']) {
// check avatar gallery
if (is_dir($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category)) {
$submit_ary['avatar_type'] = AVATAR_GALLERY;
list($submit_ary['avatar_width'], $submit_ary['avatar_height']) = getimagesize($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category . '/' . $avatar_select);
$submit_ary['avatar'] = $category . '/' . $avatar_select;
}
} else {
if ($delete) {
$submit_ary['avatar'] = '';
$submit_ary['avatar_type'] = $submit_ary['avatar_width'] = $submit_ary['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']);
}
}
示例3: avatar_process_user
/**
* 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', 0), 'height' => request_var('height', 0));
$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();
if ($custom_userdata === false) {
$userdata =& $user->data;
} else {
$userdata =& $custom_userdata;
}
$data['user_id'] = $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_writable($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 (!empty($userdata['user_avatar'])) {
// Only update the dimensions
if (empty($data['width']) || empty($data['height'])) {
if ($dims = avatar_get_dimensions($userdata['user_avatar'], $userdata['user_avatar_type'], $error, $data['width'], $data['height'])) {
list($guessed_x, $guessed_y) = $dims;
if (empty($data['width'])) {
$data['width'] = $guessed_x;
}
if (empty($data['height'])) {
$data['height'] = $guessed_y;
}
}
}
if (($config['avatar_max_width'] || $config['avatar_max_height']) && ($data['width'] != $userdata['user_avatar_width'] || $data['height'] != $userdata['user_avatar_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)) {
$ext_new = $ext_old = '';
if (isset($sql_ary['user_avatar'])) {
$userdata = $custom_userdata === false ? $user->data : $custom_userdata;
$ext_new = empty($sql_ary['user_avatar']) ? '' : substr(strrchr($sql_ary['user_avatar'], '.'), 1);
$ext_old = empty($userdata['user_avatar']) ? '' : substr(strrchr($userdata['user_avatar'], '.'), 1);
if ($userdata['user_avatar_type'] == AVATAR_UPLOAD) {
// Delete old avatar if present
if (!empty($userdata['user_avatar']) && empty($sql_ary['user_avatar']) || !empty($userdata['user_avatar']) && !empty($sql_ary['user_avatar']) && $ext_new !== $ext_old) {
avatar_delete('user', $userdata);
}
}
}
$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);
}
}
//.........这里部分代码省略.........
示例4: main
//.........这里部分代码省略.........
case 'edit':
case 'add':
$data = $submit_ary = array();
if ($action == 'edit' && !$group_id) {
trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action));
}
if ($action == 'add' && !$auth->acl_get('a_groupadd')) {
trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action));
}
$error = array();
$user->add_lang('ucp');
$avatar_select = basename(request_var('avatar_select', ''));
$category = basename(request_var('category', ''));
// Did we submit?
if ($update) {
$group_name = request_var('group_name', '', true);
$group_desc = request_var('group_desc', '', true);
$group_type = request_var('group_type', GROUP_FREE);
$allow_desc_bbcode = request_var('desc_parse_bbcode', false);
$allow_desc_urls = request_var('desc_parse_urls', false);
$allow_desc_smilies = request_var('desc_parse_smilies', false);
$data['uploadurl'] = request_var('uploadurl', '');
$data['remotelink'] = request_var('remotelink', '');
$delete = request_var('delete', '');
$submit_ary = array('colour' => request_var('group_colour', ''), 'rank' => request_var('group_rank', 0), 'receive_pm' => isset($_REQUEST['group_receive_pm']) ? 1 : 0, 'legend' => isset($_REQUEST['group_legend']) ? 1 : 0, 'message_limit' => request_var('group_message_limit', 0));
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), 'remotelink' => array('string', true, 5, 255), 'width' => array('string', true, 1, 3), 'height' => array('string', true, 1, 3));
if (!($error = validate_data($data, $var_ary))) {
$data['user_id'] = "g{$group_id}";
if ((!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl']) && $can_upload) {
list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_upload($data, $error);
} else {
if ($data['remotelink']) {
list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_remote($data, $error);
}
}
}
} else {
if ($avatar_select && $config['allow_avatar_local']) {
// check avatar gallery
if (is_dir($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category)) {
$submit_ary['avatar_type'] = AVATAR_GALLERY;
list($submit_ary['avatar_width'], $submit_ary['avatar_height']) = getimagesize($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category . '/' . $avatar_select);
$submit_ary['avatar'] = $category . '/' . $avatar_select;
}
} else {
if ($delete) {
$submit_ary['avatar'] = '';
$submit_ary['avatar_type'] = $submit_ary['avatar_width'] = $submit_ary['avatar_height'] = 0;
}
}
}
if (isset($submit_ary['avatar']) && $submit_ary['avatar'] && (!isset($group_row['group_avatar']) || $group_row['group_avatar'] != $submit_ary['avatar']) || $delete) {
if (isset($group_row['group_avatar']) && $group_row['group_avatar']) {
avatar_delete($group_row['group_avatar']);
}
}
if (!sizeof($error)) {
// Only set the rank, colour, etc. if it's changed or if we're adding a new
// group. This prevents existing group members being updated if no changes
// were made.
$group_attributes = array();
$test_variables = array('rank', 'colour', 'avatar', 'avatar_type', 'avatar_width', 'avatar_height', 'receive_pm', 'legend', 'message_limit');
示例5: trim
* modifier un avatar
*/
if ($op == "modify") {
$avatar_error = false;
$avatar_upload = !empty($_POST['avatarurl']) ? trim($_POST['avatarurl']) : ($_FILES['avatar']['tmp_name'] != "none" ? $_FILES['avatar']['tmp_name'] : '');
$avatar_remoteurl = !empty($_POST['avatarremoteurl']) ? trim(htmlspecialchars($_POST['avatarremoteurl'])) : '';
$avatar_gallerie = !empty($_POST['avatargallerie']) ? htmlspecialchars($_POST['avatargallerie']) : '';
$avatar_name = !empty($_FILES['avatar']['name']) ? $_FILES['avatar']['name'] : '';
$avatar_size = !empty($_FILES['avatar']['size']) ? $_FILES['avatar']['size'] : 0;
$avatar_filetype = !empty($_FILES['avatar']['type']) ? $_FILES['avatar']['type'] : '';
$avatar_mode = !empty($avatar_name) ? 'local' : 'remote';
$avatar_sql = '';
/*** si l'avatar est de type UPLOAD ***/
if ((!empty($avatar_upload) || !empty($avatar_name)) && $config['avatar_upload']) {
if (!empty($avatar_upload)) {
$avatar_sql = avatar_upload($avatar_mode, $ficheX->avatar, $ficheX->avatar_type, $avatar_upload, $avatar_name, $avatar_size, $avatar_filetype, $avatar_error);
} elseif (!empty($avatar_name)) {
$avatar_error = true;
show_erreur($strAvatarErreurFileSize);
}
} elseif ($avatar_remoteurl != '' && $config['avatar_remote']) {
if (@file_exists($config['avatars_path'] . '/' . $ficheX->avatar)) {
@unlink($config['avatars_path'] . '/' . $ficheX->avatar);
}
$avatar_sql = avatar_url($avatar_remoteurl, &$avatar_error);
} elseif ($avatar_gallerie != '' && $config['avatar_gallerie']) {
if (@file_exists($config['avatars_path'] . '/' . $ficheX->avatar)) {
@unlink($config['avatars_path'] . '/' . $ficheX->avatar);
}
$avatar_sql = avatar_gallery($avatar_gallerie);
}
示例6: ucp_profile
//.........这里部分代码省略.........
$message = $_CLASS['core_user']->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($_CLASS['core_user']->lang['RETURN_UCP'], '<a href="' . $module_link . '\\>', '</a>');
trigger_error($message);
}
// Replace "error" strings with their real, localised form
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$_CLASS['core_user']->lang['\\1'])) ? \$_CLASS['core_user']->lang['\\1'] : '\\1'", $error);
}
$signature_preview = '';
if ($preview && $signature) {
// Now parse it for displaying
$signature_preview = $message_parser->format_display($enable_html, $enable_bbcode, $enable_urls, $enable_smilies, false);
unset($message_parser);
}
decode_message($signature, $_CLASS['core_user']->data['user_sig_bbcode_uid']);
$_CLASS['core_template']->assign(array('ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'SIGNATURE' => $signature, 'SIGNATURE_PREVIEW' => $signature_preview, 'S_HTML_CHECKED' => !$enable_html ? 'checked="checked"' : '', 'S_BBCODE_CHECKED' => !$enable_bbcode ? 'checked="checked"' : '', 'S_SMILIES_CHECKED' => !$enable_smilies ? 'checked="checked"' : '', 'S_MAGIC_URL_CHECKED' => !$enable_urls ? 'checked="checked"' : '', 'HTML_STATUS' => $config['allow_sig_html'] ? $_CLASS['core_user']->lang['HTML_IS_ON'] : $_CLASS['core_user']->lang['HTML_IS_OFF'], 'BBCODE_STATUS' => $config['allow_sig_bbcode'] ? sprintf($_CLASS['core_user']->lang['BBCODE_IS_ON'], '<a href="' . generate_link('Forums&file=faq&mode=bbcode') . '" target="_phpbbcode">', '</a>') : sprintf($_CLASS['core_user']->lang['BBCODE_IS_OFF'], '<a href="' . generate_link('Forums&file=faq&mode=bbcode') . '" target="_phpbbcode">', '</a>'), 'SMILIES_STATUS' => $config['allow_sig_smilies'] ? $_CLASS['core_user']->lang['SMILIES_ARE_ON'] : $_CLASS['core_user']->lang['SMILIES_ARE_OFF'], 'IMG_STATUS' => $config['allow_sig_img'] ? $_CLASS['core_user']->lang['IMAGES_ARE_ON'] : $_CLASS['core_user']->lang['IMAGES_ARE_OFF'], 'FLASH_STATUS' => $config['allow_sig_flash'] ? $_CLASS['core_user']->lang['FLASH_IS_ON'] : $_CLASS['core_user']->lang['FLASH_IS_OFF'], 'L_SIGNATURE_EXPLAIN' => sprintf($_CLASS['core_user']->lang['SIGNATURE_EXPLAIN'], $config['max_sig_chars']), 'S_HTML_ALLOWED' => $config['allow_sig_html'], 'S_BBCODE_ALLOWED' => $config['allow_sig_bbcode'], 'S_SMILIES_ALLOWED' => $config['allow_sig_smilies']));
break;
case 'avatar':
$display_gallery = isset($_POST['display_gallery']);
$folder = isset($_REQUEST['category']) ? str_replace(array('../', '..\\', './', '.\\'), '', $_REQUEST['category']) : false;
$delete = isset($_POST['delete']);
// Can we upload?
$can_upload = file_exists($config['avatar_path']) && is_writeable($config['avatar_path']) && @ini_get('file_uploads') ? true : false;
if ($submit) {
$gallery_avatar = isset($_POST['avatarselect']) ? str_replace(array('../', '..\\', './', '.\\'), '', $_POST['avatarselect']) : false;
if ($config['allow_avatar_local'] && $gallery_avatar) {
if (!file_exists($config['avatar_gallery_path'] . '/' . $gallery_avatar)) {
$error[] = 'BAD_AVATAR';
} else {
$type = AVATAR_GALLERY;
$filename = $gallery_avatar;
list($width, $height) = getimagesize($config['avatar_gallery_path'] . '/' . $gallery_avatar);
}
} else {
$data['uploadurl'] = get_variable('uploadurl', 'POST', false);
$data['remotelink'] = get_variable('remotelink', 'POST', '');
$data['width'] = get_variable('width', 'POST', '');
$data['height'] = get_variable('height', 'POST', '');
$data['user_id'] = $_CLASS['core_user']->data['user_id'];
require_once $site_file_root . 'includes/forums/functions_user.php';
if ((!empty($_FILES['uploadfile']['name']) || $data['uploadurl']) && $can_upload) {
list($type, $filename, $width, $height) = avatar_upload($data, $error);
} elseif ($data['remotelink'] && $config['allow_avatar_remote']) {
list($type, $filename, $width, $height) = avatar_remote($data, $error);
} elseif ($delete) {
$type = $filename = $width = $height = '';
} else {
$error[] = 'IM_LOST';
}
}
if (empty($error)) {
$sql_ary = array('user_avatar' => $filename, 'user_avatar_type' => $type, 'user_avatar_width' => $width, 'user_avatar_height' => $height);
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $_CLASS['core_db']->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . $_CLASS['core_user']->data['user_id'];
$_CLASS['core_db']->sql_query($sql);
// Delete old avatar if present
if ($_CLASS['core_user']->data['user_avatar'] && $filename != $_CLASS['core_user']->data['user_avatar'] && $_CLASS['core_user']->data['user_avatar_type'] != AVATAR_GALLERY) {
avatar_delete($_CLASS['core_user']->data['user_avatar']);
}
$_CLASS['core_display']->meta_refresh(3, $module_link);
$message = $_CLASS['core_user']->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($_CLASS['core_user']->lang['RETURN_UCP'], '<a href="' . $module_link . '">', '</a>');
trigger_error($message);
}
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$_CLASS['core_user']->lang['\\1'])) ? \$_CLASS['core_user']->lang['\\1'] : '\\1'", $error);
}
// Generate users avatar
$avatar_img = '';
if ($_CLASS['core_user']->data['user_avatar']) {
switch ($_CLASS['core_user']->data['user_avatar_type']) {
case AVATAR_UPLOAD:
$avatar_img = $config['avatar_path'] . '/';
break;
case AVATAR_GALLERY:
$avatar_img = $config['avatar_gallery_path'] . '/';
break;
}
$avatar_img .= $_CLASS['core_user']->data['user_avatar'];
$avatar_img = '<img src="' . $avatar_img . '" width="' . $_CLASS['core_user']->data['user_avatar_width'] . '" height="' . $_CLASS['core_user']->data['user_avatar_height'] . '" border="0" alt="" />';
}
$_CLASS['core_template']->assign(array('ERROR' => empty($error) ? '' : implode('<br />', $error), 'AVATAR' => $avatar_img, 'AVATAR_SIZE' => $config['avatar_filesize'], 'S_FORM_ENCTYPE' => $can_upload ? ' enctype="multipart/form-data"' : '', 'L_AVATAR_EXPLAIN' => sprintf($_CLASS['core_user']->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], round($config['avatar_filesize'] / 1024))));
if ($display_gallery && $config['allow_avatar_local']) {
require_once $site_file_root . 'includes/functions_user.php';
$avatar_list = avatar_gallery($folder, $folders, $error);
array_unshift($folders, '');
$s_category_options = '';
foreach ($folders as $cat) {
$s_category_options .= '<option value="' . $cat . '"' . ($cat == $folder ? ' selected="selected"' : '') . '>' . ($cat ? $cat : '--') . '</option>';
}
$_CLASS['core_template']->assign(array('S_DISPLAY_GALLERY' => true, 'S_CAT_OPTIONS' => $s_category_options));
foreach ($avatar_list as $avatar) {
$_CLASS['core_template']->assign_vars_array('avatar', array('AVATAR_IMAGE' => $config['avatar_gallery_path'] . '/' . $avatar['file'], 'AVATAR_NAME' => $avatar['name'], 'AVATAR_FILE' => $avatar['file']));
}
unset($avatar_list);
} else {
$_CLASS['core_template']->assign(array('AVATAR' => $avatar_img, 'AVATAR_SIZE' => $config['avatar_filesize'], 'WIDTH' => $_CLASS['core_user']->data['user_avatar_width'], 'HEIGHT' => $_CLASS['core_user']->data['user_avatar_height'], 'S_CAN_UPLOAD' => $can_upload, 'S_LINK_AVATAR' => $config['allow_avatar_remote'], 'S_GALLERY_AVATAR' => $config['allow_avatar_local']));
}
break;
}
$_CLASS['core_template']->assign_array(array('L_TITLE' => $_CLASS['core_user']->lang['UCP_PROFILE_' . strtoupper($mode)], 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_UCP_ACTION' => $module_link));
$this->display($_CLASS['core_user']->lang['UCP_PROFILE'], 'ucp_profile_' . $mode . '.html');
}
示例7: main
//.........这里部分代码省略.........
if ($action == 'add' && !$auth->acl_get('a_groupadd')) {
trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
}
$error = array();
$user->add_lang('ucp');
$avatar_select = basename(request_var('avatar_select', ''));
$category = basename(request_var('category', ''));
// Did we submit?
if ($update) {
if (!check_form_key($form_key)) {
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}
$group_name = utf8_normalize_nfc(request_var('group_name', '', true));
$group_desc = utf8_normalize_nfc(request_var('group_desc', '', true));
$group_type = request_var('group_type', GROUP_FREE);
$allow_desc_bbcode = request_var('desc_parse_bbcode', false);
$allow_desc_urls = request_var('desc_parse_urls', false);
$allow_desc_smilies = request_var('desc_parse_smilies', false);
$data['uploadurl'] = request_var('uploadurl', '');
$data['remotelink'] = request_var('remotelink', '');
$data['width'] = request_var('width', '');
$data['height'] = request_var('height', '');
$delete = request_var('delete', '');
$submit_ary = array('colour' => request_var('group_colour', ''), 'rank' => request_var('group_rank', 0), 'receive_pm' => isset($_REQUEST['group_receive_pm']) ? 1 : 0, 'legend' => isset($_REQUEST['group_legend']) ? 1 : 0, 'message_limit' => request_var('group_message_limit', 0), 'max_recipients' => request_var('group_max_recipients', 0), 'founder_manage' => 0, 'skip_auth' => request_var('group_skip_auth', 0));
if ($user->data['user_type'] == USER_FOUNDER) {
$submit_ary['founder_manage'] = isset($_REQUEST['group_founder_manage']) ? 1 : 0;
}
if (!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl'] || $data['remotelink']) {
// Avatar stuff
$var_ary = 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 (!($error = validate_data($data, $var_ary))) {
$data['user_id'] = "g{$group_id}";
if ((!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl']) && $can_upload) {
list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_upload($data, $error);
} else {
if ($data['remotelink']) {
list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_remote($data, $error);
}
}
}
} else {
if ($avatar_select && $config['allow_avatar_local']) {
// check avatar gallery
if (is_dir($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category)) {
$submit_ary['avatar_type'] = AVATAR_GALLERY;
list($submit_ary['avatar_width'], $submit_ary['avatar_height']) = getimagesize($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category . '/' . $avatar_select);
$submit_ary['avatar'] = $category . '/' . $avatar_select;
}
} else {
if ($delete) {
$submit_ary['avatar'] = '';
$submit_ary['avatar_type'] = $submit_ary['avatar_width'] = $submit_ary['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']);
}
}
示例8: switch
} else {
if ($action == "avatar") {
// Trying to submit an avatar
if (isset($_POST['avatar'])) {
switch ($config['avatar_use']) {
case "username":
$status = avatar_upload($user_data['username'], $_FILES);
break;
case "email":
$status = avatar_upload($user_data['email'], $_FILES);
break;
case "id":
$status = avatar_upload($user_data['id'], $_FILES);
break;
default:
$status = avatar_upload($user_data['username'], $_FILES);
break;
}
switch ($status) {
case "NO_FILE":
$error = lang('error_no_file');
break;
case "NOT_IMAGE":
$error = lang('error_filetype');
break;
case "TOO_LARGE":
$error = lang_parse('error_file_size', array($config['avatar_max_size']));
break;
case "WRONG_DIMENSIONS":
$error = lang_parse('error_file_wxh', array($config['avatar_max_width'], $config['avatar_max_height']));
break;
示例9: list
if ($gallery_avatar) {
if (!file_exists($config['avatar_gallery_path'] . '/' . $gallery_avatar)) {
$error[] = 'BAD_AVATAR';
} else {
$type = AVATAR_GALLERY;
$filename = $gallery_avatar;
list($width, $height) = getimagesize($_CORE_CONFIG['global']['path_avatar_gallery'] . '/' . $gallery_avatar);
}
} else {
$data['uploadurl'] = get_variable('uploadurl', 'POST', false);
$data['remotelink'] = get_variable('remotelink', 'POST', '');
$data['width'] = get_variable('width', 'POST', '');
$data['height'] = get_variable('height', 'POST', '');
$data['user_id'] = $_CLASS['core_user']->data['user_id'];
if ((!empty($_FILES['uploadfile']['name']) || $data['uploadurl']) && $can_upload) {
list($type, $filename, $width, $height) = avatar_upload($data, $error);
} elseif ($data['remotelink'] && $config['allow_avatar_remote']) {
list($type, $filename, $width, $height) = avatar_remote($data, $error);
} elseif ($delete) {
$filename = '';
$type = $width = $height = 0;
} else {
$error[] = 'IM_LOST';
}
}
if (empty($error)) {
$sql_ary = array('user_avatar' => (string) $filename, 'user_avatar_type' => (int) $type, 'user_avatar_width' => (int) $width, 'user_avatar_height' => (int) $height);
$sql = 'UPDATE ' . CORE_USERS_TABLE . '
SET ' . $_CLASS['core_db']->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . $_CLASS['core_user']->data['user_id'];
$_CLASS['core_db']->sql_query($sql);
示例10: main
//.........这里部分代码省略.........
$message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
trigger_error($message);
}
}
// Replace "error" strings with their real, localised form
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
}
$signature_preview = '';
if ($preview) {
// Now parse it for displaying
$signature_preview = $message_parser->format_display($enable_bbcode, $enable_urls, $enable_smilies, false);
unset($message_parser);
}
decode_message($signature, $user->data['user_sig_bbcode_uid']);
$template->assign_vars(array('ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'SIGNATURE' => $signature, 'SIGNATURE_PREVIEW' => $signature_preview, 'S_BBCODE_CHECKED' => !$enable_bbcode ? 'checked="checked"' : '', 'S_SMILIES_CHECKED' => !$enable_smilies ? 'checked="checked"' : '', 'S_MAGIC_URL_CHECKED' => !$enable_urls ? 'checked="checked"' : '', 'BBCODE_STATUS' => $config['allow_sig_bbcode'] ? sprintf($user->lang['BBCODE_IS_ON'], '<a href="' . append_sid("{$phpbb_root_path}faq.{$phpEx}", 'mode=bbcode') . '" onclick="target=\'_phpbbcode\';">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid("{$phpbb_root_path}faq.{$phpEx}", 'mode=bbcode') . '" onclick="target=\'_phpbbcode\';">', '</a>'), 'SMILIES_STATUS' => $config['allow_sig_smilies'] ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], 'IMG_STATUS' => $config['allow_sig_img'] ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], 'FLASH_STATUS' => $config['allow_sig_flash'] ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], 'L_SIGNATURE_EXPLAIN' => sprintf($user->lang['SIGNATURE_EXPLAIN'], $config['max_sig_chars']), 'S_BBCODE_ALLOWED' => $config['allow_sig_bbcode'], 'S_SMILIES_ALLOWED' => $config['allow_sig_smilies'], 'S_BBCODE_IMG' => $config['allow_sig_img'] ? true : false, 'S_BBCODE_FLASH' => $config['allow_sig_flash'] ? true : false));
// Build custom bbcodes array
$sql = 'SELECT bbcode_id, bbcode_tag
FROM ' . BBCODES_TABLE . '
WHERE display_on_posting = 1';
$result = $db->sql_query($sql);
$i = 0;
while ($row = $db->sql_fetchrow($result)) {
$template->assign_block_vars('custom_tags', array('BBCODE_NAME' => "'[{$row['bbcode_tag']}]', '[/" . str_replace('=', '', $row['bbcode_tag']) . "]'", 'BBCODE_ID' => 22 + $i * 2, 'BBCODE_TAG' => $row['bbcode_tag']));
$i++;
}
$db->sql_freeresult($result);
break;
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) {
$var_ary = array('uploadurl' => (string) '', 'remotelink' => (string) '', 'width' => (string) '', 'height' => (string) '');
foreach ($var_ary as $var => $default) {
$data[$var] = request_var($var, $default);
}
$var_ary = 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));
$error = validate_data($data, $var_ary);
if (!sizeof($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();
示例11: saveuser
function saveuser(&$userinfo)
{
global $db, $user_prefix, $MAIN_CFG, $allowusertheme, $CPG_SESS, $SESS;
$mode = isset($_POST['save']) ? $_POST['save'] : 'profile';
if ($mode == 'admin' && !defined('ADMIN_PAGES')) {
$mode = 'profile';
}
if ($mode == 'profile') {
$section = 'section=1 OR section=2';
} elseif ($mode == 'private') {
$section = 'section=3';
} elseif ($mode == 'prefs') {
$section = 'section=5';
}
$sql = $pass_change = false;
if ($mode == 'reg_details') {
global $allowmailchange;
$current_password = isset($_POST['current_password']) ? md5($_POST['current_password']) : '';
if (isset($_POST['new_password'])) {
$new_password = $_POST['new_password'];
$verify_password = isset($_POST['verify_password']) ? $_POST['verify_password'] : '';
if ($new_password != $verify_password) {
cpg_error(_PASSDIFFERENT, 'ERROR: Password mismatch');
} elseif ($new_password != '') {
if (strlen($new_password) < $MAIN_CFG['member']['minpass']) {
cpg_error(_YOUPASSMUSTBE . ' <b>' . $MAIN_CFG['member']['minpass'] . '</b> ' . _CHARLONG, 'ERROR: Password too short');
}
$new_password = md5($new_password);
if ($new_password != $userinfo['user_password']) {
if (!defined('ADMIN_PAGES') && $current_password != $userinfo['user_password']) {
cpg_error('Password incorrect');
}
$sql = " user_password='{$new_password}'";
$pass_change = true;
}
}
}
$user_email = isset($_POST['user_email']) ? $_POST['user_email'] : $userinfo['user_email'];
if (($allowmailchange || defined('ADMIN_PAGES')) && $user_email != $userinfo['user_email']) {
if ($current_password != $userinfo['user_password'] && !defined('ADMIN_PAGES')) {
cpg_error('Password incorrect');
}
if (is_email($user_email) < 1) {
cpg_error(_ERRORINVEMAIL);
}
if ($sql) {
$sql .= ', ';
}
$sql .= "user_email='{$user_email}'";
}
if (defined('ADMIN_PAGES') && isset($_POST['username']) && $_POST['username'] != $userinfo['username']) {
if (preg_match('#(\\ |\\*|#|\\\\|%|"|\'|`|&|\\^|@)', $_POST['username'])) {
cpg_error(_ERRORINVNICK);
}
if ($db->sql_count($user_prefix . '_users u, ' . $user_prefix . '_users_temp t', "u.username='{$_POST['username']}' OR t.username='{$_POST['username']}' LIMIT 1") > 0) {
cpg_error(_NICKTAKEN);
}
if ($sql) {
$sql .= ', ';
}
$sql .= "username='{$_POST['username']}'";
}
} elseif ($mode == 'avatar') {
require_once 'modules/' . basename(dirname(__FILE__)) . '/avatars.php';
// Local avatar?
$avatar_local = isset($_POST['user_avatar']) ? $_POST['user_avatar'] : '';
// Remote avatar?
$avatar_remoteurl = !empty($_POST['avatarremoteurl']) ? htmlprepare($_POST['avatarremoteurl']) : '';
// Upload avatar thru remote or upload?
$avatar_upload = !empty($_POST['avatarurl']) ? trim($_POST['avatarurl']) : (!empty($_FILES['avatar']) && $_FILES['avatar']['tmp_name'] != "none" ? $_FILES['avatar']['tmp_name'] : '');
$avatar_name = !empty($_FILES['avatar']['name']) ? $_FILES['avatar']['name'] : '';
// 0 = USER_AVATAR_NONE
if (isset($_POST['avatardel']) || $avatar_local == '') {
$sql = avatar_delete($userinfo);
}
// 1 = USER_AVATAR_UPLOAD
if ((!empty($avatar_upload) || !empty($avatar_name)) && $MAIN_CFG['avatar']['allow_upload']) {
if (!empty($avatar_upload)) {
$sql = avatar_upload(empty($avatar_name), $userinfo, $avatar_upload, $_FILES['avatar']);
} elseif (!empty($avatar_name)) {
cpg_error(sprintf(_AVATAR_FILESIZE, round($MAIN_CFG['avatar']['filesize'] / 1024)), 'ERROR: Filesize');
}
} elseif ($avatar_remoteurl != $userinfo['user_avatar'] && $avatar_remoteurl != '' && $MAIN_CFG['avatar']['allow_remote']) {
if (!preg_match('#^(http)|(ftp):\\/\\/#i', $avatar_remoteurl)) {
$avatar_remoteurl = 'http://' . $avatar_remoteurl;
}
if (preg_match('#^((http)|(ftp):\\/\\/[\\w\\-]+?\\.([\\w\\-]+\\.)+[\\w]+(:[0-9]+)*\\/.*?\\.(gif|jpg|jpeg|png)$)#is', $avatar_remoteurl)) {
if (in_array('getimagesize', explode(',', ini_get('disable_functions'))) || ini_get('disable_functions') == 'getimagesize') {
cpg_error('getimagesize is disabled', _AVATAR_ERR_URL);
} elseif (!getimagesize($avatar_remoteurl)) {
cpg_error('Image has wrong filetype', _AVATAR_ERR_URL);
} elseif (!($file_data = get_fileinfo($avatar_remoteurl, !$MAIN_CFG['avatar']['animated']))) {
cpg_error(_AVATAR_ERR_URL);
} elseif ($file_data['size'] > $MAIN_CFG['avatar']['filesize']) {
cpg_error(sprintf(_AVATAR_FILESIZE, round($MAIN_CFG['avatar']['filesize'] / 1024)));
} elseif (!$MAIN_CFG['avatar']['animated'] && $file_data['animation']) {
cpg_error('Animated avatar not allowed');
}
if (avatar_size($avatar_remoteurl)) {
avatar_delete($userinfo);
//.........这里部分代码省略.........
示例12: ucp_profile
//.........这里部分代码省略.........
$_CLASS['core_db']->sql_query($sql);
$message = $_CLASS['core_user']->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($_CLASS['core_user']->lang['RETURN_UCP'], '<a href="' . $module_link . '">', '</a>');
trigger_error($message);
}
}
if ($preview && $signature) {
// Now parse it for displaying
$signature_preview = $message_parser->format_display($enable_html, $enable_bbcode, $enable_urls, $enable_smilies, false);
unset($message_parser);
}
if ($signature) {
decode_message($signature, $_CLASS['core_user']->data['user_sig_bbcode_uid']);
}
$_CLASS['core_template']->assign_array(array('ERROR' => empty($error) ? '' : implode('<br />', $error), 'SIGNATURE' => $signature, 'SIGNATURE_PREVIEW' => $signature_preview, 'S_HTML_CHECKED' => $enable_html ? '' : 'checked="checked"', 'S_BBCODE_CHECKED' => $enable_bbcode ? '' : 'checked="checked"', 'S_SMILIES_CHECKED' => $enable_smilies ? '' : 'checked="checked"', 'S_MAGIC_URL_CHECKED' => $enable_urls ? '' : 'checked="checked"', 'HTML_STATUS' => true ? $_CLASS['core_user']->get_lang('HTML_IS_ON') : $_CLASS['core_user']->get_lang('HTML_IS_OFF'), 'BBCODE_STATUS' => true ? sprintf($_CLASS['core_user']->get_lang('BBCODE_IS_ON'), '<a href="' . generate_link('Forums&file=faq&mode=bbcode') . '" target="_phpbbcode">', '</a>') : sprintf($_CLASS['core_user']->get_lang('BBCODE_IS_OFF'), '<a href="' . generate_link('Forums&file=faq&mode=bbcode') . '" target="_phpbbcode">', '</a>'), 'SMILIES_STATUS' => true ? $_CLASS['core_user']->get_lang('SMILIES_ARE_ON') : $_CLASS['core_user']->get_lang('SMILIES_ARE_OFF'), 'IMG_STATUS' => true ? $_CLASS['core_user']->get_lang('IMAGES_ARE_ON') : $_CLASS['core_user']->get_lang('IMAGES_ARE_OFF'), 'FLASH_STATUS' => true ? $_CLASS['core_user']->get_lang('FLASH_IS_ON') : $_CLASS['core_user']->get_lang('FLASH_IS_OFF'), 'L_SIGNATURE_EXPLAIN' => sprintf($_CLASS['core_user']->lang['SIGNATURE_EXPLAIN'], $config['max_sig_chars']), 'S_HTML_ALLOWED' => true, 'S_BBCODE_ALLOWED' => true, 'S_SMILIES_ALLOWED' => true));
break;
case 'avatar':
$display_gallery = isset($_POST['display_gallery']);
$folder = isset($_POST['category']) ? str_replace(array('../', '..\\', './', '.\\'), '', $_POST['category']) : false;
$delete = isset($_POST['delete']);
// Can we upload?
$can_upload = file_exists($config['avatar_path']) && is_writeable($config['avatar_path']) && @ini_get('file_uploads') ? true : false;
if ($submit) {
$gallery_avatar = isset($_POST['avatarselect']) ? str_replace(array('../', '..\\', './', '.\\'), '', $_POST['avatarselect']) : false;
if ($config['allow_avatar_local'] && $gallery_avatar) {
if (!file_exists($config['avatar_gallery_path'] . '/' . $gallery_avatar)) {
$error[] = 'BAD_AVATAR';
} else {
$type = AVATAR_GALLERY;
$filename = $gallery_avatar;
list($width, $height) = getimagesize($config['avatar_gallery_path'] . '/' . $gallery_avatar);
}
} else {
$data['uploadurl'] = get_variable('uploadurl', 'POST', false);
$data['remotelink'] = get_variable('remotelink', 'POST', '');
$data['width'] = get_variable('width', 'POST', '');
$data['height'] = get_variable('height', 'POST', '');
$data['user_id'] = $_CLASS['core_user']->data['user_id'];
if ((!empty($_FILES['uploadfile']['name']) || $data['uploadurl']) && $can_upload) {
list($type, $filename, $width, $height) = avatar_upload($data, $error);
} elseif ($data['remotelink'] && $config['allow_avatar_remote']) {
list($type, $filename, $width, $height) = avatar_remote($data, $error);
} elseif ($delete) {
$filename = '';
$type = $width = $height = 0;
} else {
$error[] = 'IM_LOST';
}
}
if (empty($error)) {
$sql_ary = array('user_avatar' => (string) $filename, 'user_avatar_type' => (int) $type, 'user_avatar_width' => (int) $width, 'user_avatar_height' => (int) $height);
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $_CLASS['core_db']->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . $_CLASS['core_user']->data['user_id'];
$_CLASS['core_db']->sql_query($sql);
// Delete old avatar if present
if ($_CLASS['core_user']->data['user_avatar'] && $filename != $_CLASS['core_user']->data['user_avatar'] && $_CLASS['core_user']->data['user_avatar_type'] != AVATAR_GALLERY) {
avatar_delete($_CLASS['core_user']->data['user_avatar']);
}
$_CLASS['core_display']->meta_refresh(3, $module_link);
$message = $_CLASS['core_user']->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($_CLASS['core_user']->lang['RETURN_UCP'], '<a href="' . $module_link . '">', '</a>');
trigger_error($message);
}
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$_CLASS['core_user']->lang['\\1'])) ? \$_CLASS['core_user']->lang['\\1'] : '\\1'", $error);
}
// Generate users avatar
$avatar_img = '';
if ($_CLASS['core_user']->data['user_avatar']) {
switch ($_CLASS['core_user']->data['user_avatar_type']) {
case AVATAR_UPLOAD:
$avatar_img = $config['avatar_path'] . '/';
break;
case AVATAR_GALLERY:
$avatar_img = $config['avatar_gallery_path'] . '/';
break;
}
$avatar_img .= $_CLASS['core_user']->data['user_avatar'];
$avatar_img = '<img src="' . $avatar_img . '" width="' . $_CLASS['core_user']->data['user_avatar_width'] . '" height="' . $_CLASS['core_user']->data['user_avatar_height'] . '" border="0" alt="" />';
}
$_CLASS['core_template']->assign_array(array('ERROR' => empty($error) ? '' : implode('<br />', $error), 'AVATAR' => $avatar_img, 'AVATAR_SIZE' => $config['avatar_filesize'], 'S_FORM_ENCTYPE' => $can_upload ? ' enctype="multipart/form-data"' : '', 'L_AVATAR_EXPLAIN' => sprintf($_CLASS['core_user']->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], round($config['avatar_filesize'] / 1024))));
if ($display_gallery && $config['allow_avatar_local']) {
require_once $site_file_root . 'includes/functions_user.php';
$avatar_list = avatar_gallery($folder, $folders, $error);
array_unshift($folders, '');
$s_category_options = '';
foreach ($folders as $cat) {
$s_category_options .= '<option value="' . $cat . '"' . ($cat == $folder ? ' selected="selected"' : '') . '>' . ($cat ? $cat : '--') . '</option>';
}
$_CLASS['core_template']->assign_array(array('S_DISPLAY_GALLERY' => true, 'S_CAT_OPTIONS' => $s_category_options));
foreach ($avatar_list as $avatar) {
$_CLASS['core_template']->assign_vars_array('avatar', array('AVATAR_IMAGE' => $config['avatar_gallery_path'] . '/' . $avatar['file'], 'AVATAR_NAME' => $avatar['name'], 'AVATAR_FILE' => $avatar['file']));
}
unset($avatar_list);
} else {
$_CLASS['core_template']->assign_array(array('AVATAR' => $avatar_img, 'AVATAR_SIZE' => $config['avatar_filesize'], 'WIDTH' => $_CLASS['core_user']->data['user_avatar_width'], 'HEIGHT' => $_CLASS['core_user']->data['user_avatar_height'], 'S_CAN_UPLOAD' => $can_upload, 'S_LINK_AVATAR' => $config['allow_avatar_remote'], 'S_GALLERY_AVATAR' => $config['allow_avatar_local']));
}
break;
}
$_CLASS['core_template']->assign_array(array('L_TITLE' => $_CLASS['core_user']->lang['UCP_PROFILE_' . strtoupper($mode)], 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_UCP_ACTION' => $module_link));
$this->display($_CLASS['core_user']->lang['UCP_PROFILE'], 'ucp_profile_' . $mode . '.html');
}