本文整理汇总了PHP中avatar_delete函数的典型用法代码示例。如果您正苦于以下问题:PHP avatar_delete函数的具体用法?PHP avatar_delete怎么用?PHP avatar_delete使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了avatar_delete函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
//.........这里部分代码省略.........
$messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
$messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
$messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($user_row['username'])));
$messenger->send(NOTIFY_EMAIL);
}
}
$message = $user_row['user_type'] == USER_INACTIVE ? 'USER_ADMIN_ACTIVATED' : 'USER_ADMIN_DEACTIVED';
$log = $user_row['user_type'] == USER_INACTIVE ? 'LOG_USER_ACTIVE' : 'LOG_USER_INACTIVE';
add_log('admin', $log, $user_row['username']);
add_log('user', $user_id, $log . '_USER');
trigger_error($user->lang[$message] . adm_back_link($this->u_action . '&u=' . $user_id));
break;
case 'delsig':
if (!check_form_key($form_name)) {
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
}
$sql_ary = array('user_sig' => '', 'user_sig_bbcode_uid' => '', 'user_sig_bbcode_bitfield' => '');
$sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\t\t\tWHERE user_id = {$user_id}";
$db->sql_query($sql);
add_log('admin', 'LOG_USER_DEL_SIG', $user_row['username']);
add_log('user', $user_id, 'LOG_USER_DEL_SIG_USER');
trigger_error($user->lang['USER_ADMIN_SIG_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id));
break;
case 'delavatar':
if (!check_form_key($form_name)) {
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
}
$sql_ary = array('user_avatar' => '', 'user_avatar_type' => 0, 'user_avatar_width' => 0, 'user_avatar_height' => 0);
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\t\t\tWHERE user_id = {$user_id}";
$db->sql_query($sql);
// Delete old avatar if present
if ($user_row['user_avatar'] && $user_row['user_avatar_type'] != AVATAR_GALLERY) {
avatar_delete('user', $user_row);
}
add_log('admin', 'LOG_USER_DEL_AVATAR', $user_row['username']);
add_log('user', $user_id, 'LOG_USER_DEL_AVATAR_USER');
trigger_error($user->lang['USER_ADMIN_AVATAR_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id));
break;
case 'delposts':
if (confirm_box(true)) {
// Delete posts, attachments, etc.
delete_posts('poster_id', $user_id);
add_log('admin', 'LOG_USER_DEL_POSTS', $user_row['username']);
trigger_error($user->lang['USER_POSTS_DELETED'] . adm_back_link($this->u_action . '&u=' . $user_id));
} else {
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'update' => true)));
}
break;
case 'delattach':
if (confirm_box(true)) {
delete_attachments('user', $user_id);
add_log('admin', 'LOG_USER_DEL_ATTACH', $user_row['username']);
trigger_error($user->lang['USER_ATTACHMENTS_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id));
} else {
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'update' => true)));
}
break;
case 'deloutbox':
if (confirm_box(true)) {
$msg_ids = array();
$lang = 'EMPTY';
$sql = 'SELECT msg_id
FROM ' . PRIVMSGS_TO_TABLE . "\n\t\t\t\t\t\t\t\t\tWHERE author_id = {$user_id}\n\t\t\t\t\t\t\t\t\t\tAND folder_id = " . PRIVMSGS_OUTBOX;
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result)) {
示例2: main
//.........这里部分代码省略.........
$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']);
}
}
}
if (!sizeof($error)) {
$submit_ary['avatar_width'] = $data['width'];
$submit_ary['avatar_height'] = $data['height'];
}
}
}
}
}
if (isset($submit_ary['avatar']) && $submit_ary['avatar'] && !isset($group_row['group_avatar']) || $delete) {
if (isset($group_row['group_avatar']) && $group_row['group_avatar']) {
avatar_delete('group', $group_row, true);
}
}
if (!check_form_key('ucp_groups')) {
$error[] = $user->lang['FORM_INVALID'];
}
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', 'max_recipients');
foreach ($test_variables as $test) {
if ($action == 'add' || isset($submit_ary[$test]) && $group_row['group_' . $test] != $submit_ary[$test]) {
$group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test];
}
}
if (!($error = group_create($group_id, $group_type, $group_name, $group_desc, $group_attributes, $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies))) {
$cache->destroy('sql', GROUPS_TABLE);
$message = $action == 'edit' ? 'GROUP_UPDATED' : 'GROUP_CREATED';
trigger_error($user->lang[$message] . $return_page);
}
}
if (sizeof($error)) {
$group_rank = $submit_ary['rank'];
$group_desc_data = array('text' => $group_desc, 'allow_bbcode' => $allow_desc_bbcode, 'allow_smilies' => $allow_desc_smilies, 'allow_urls' => $allow_desc_urls);
}
} else {
if (!$group_id) {
$group_name = utf8_normalize_nfc(request_var('group_name', '', true));
$group_desc_data = array('text' => '', 'allow_bbcode' => true, 'allow_smilies' => true, 'allow_urls' => true);
$group_rank = 0;
$group_type = GROUP_OPEN;
示例3: js_goto
}
if (!$avatar_error) {
if ($avatar_sql) {
$db->update("{$dbprefix}{$type}");
$db->set("{$avatar_sql}");
$db->where("id = {$id}");
$db->exec();
}
if ($op_old == 'galerie') {
echo "<script>this.opener.location=this.opener.location;this.close();</script>";
} else {
js_goto("?page=avatars&id={$id}&mode={$mode}");
}
}
} elseif ($op == "delete") {
$avatar_sql = avatar_delete($ficheX->avatar_type, $ficheX->avatar);
$db->update("{$dbprefix}{$type}");
$db->set("{$avatar_sql}");
$db->where("id = {$id}");
$db->exec();
js_goto("?page=avatars&id={$id}&mode={$mode}");
} elseif ($op == "galerie") {
$dir = @opendir($config['avatars_path'] . '/gallerie');
$avatar_images = array();
while ($file = @readdir($dir)) {
if ($file != '.' && $file != '..' && !is_file($config['avatars_path'] . '/gallerie/' . $file) && !is_link($config['avatars_path'] . '/gallerie/' . $file)) {
$i = 0;
$sub_dir = @opendir($config['avatars_path'] . '/gallerie/' . $file);
while ($sub_file = @readdir($sub_dir)) {
if (preg_match('/(\\.gif$|\\.png$|\\.jpg|\\.jpeg)$/is', $sub_file)) {
$avatar_images[$file][$i] = $file . '/' . $sub_file;
示例4: user_delete
/**
* Remove User
*
* @param string $mode Either 'retain' or 'remove'
* @param mixed $user_ids Either an array of integers or an integer
* @param bool $retain_username
* @return bool
*/
function user_delete($mode, $user_ids, $retain_username = true)
{
global $cache, $config, $db, $user, $phpbb_dispatcher, $phpbb_container;
global $phpbb_root_path, $phpEx;
$db->sql_transaction('begin');
$user_rows = array();
if (!is_array($user_ids)) {
$user_ids = array($user_ids);
}
$user_id_sql = $db->sql_in_set('user_id', $user_ids);
$sql = 'SELECT *
FROM ' . USERS_TABLE . '
WHERE ' . $user_id_sql;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$user_rows[(int) $row['user_id']] = $row;
}
$db->sql_freeresult($result);
if (empty($user_rows)) {
return false;
}
/**
* Event before a user is deleted
*
* @event core.delete_user_before
* @var string mode Mode of deletion (retain/delete posts)
* @var array user_ids IDs of the deleted user
* @var mixed retain_username True if username should be retained
* or false if not
* @since 3.1.0-a1
*/
$vars = array('mode', 'user_ids', 'retain_username');
extract($phpbb_dispatcher->trigger_event('core.delete_user_before', compact($vars)));
// Before we begin, we will remove the reports the user issued.
$sql = 'SELECT r.post_id, p.topic_id
FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p
WHERE ' . $db->sql_in_set('r.user_id', $user_ids) . '
AND p.post_id = r.post_id';
$result = $db->sql_query($sql);
$report_posts = $report_topics = array();
while ($row = $db->sql_fetchrow($result)) {
$report_posts[] = $row['post_id'];
$report_topics[] = $row['topic_id'];
}
$db->sql_freeresult($result);
if (sizeof($report_posts)) {
$report_posts = array_unique($report_posts);
$report_topics = array_unique($report_topics);
// Get a list of topics that still contain reported posts
$sql = 'SELECT DISTINCT topic_id
FROM ' . POSTS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $report_topics) . '
AND post_reported = 1
AND ' . $db->sql_in_set('post_id', $report_posts, true);
$result = $db->sql_query($sql);
$keep_report_topics = array();
while ($row = $db->sql_fetchrow($result)) {
$keep_report_topics[] = $row['topic_id'];
}
$db->sql_freeresult($result);
if (sizeof($keep_report_topics)) {
$report_topics = array_diff($report_topics, $keep_report_topics);
}
unset($keep_report_topics);
// Now set the flags back
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_reported = 0
WHERE ' . $db->sql_in_set('post_id', $report_posts);
$db->sql_query($sql);
if (sizeof($report_topics)) {
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_reported = 0
WHERE ' . $db->sql_in_set('topic_id', $report_topics);
$db->sql_query($sql);
}
}
// Remove reports
$db->sql_query('DELETE FROM ' . REPORTS_TABLE . ' WHERE ' . $user_id_sql);
$num_users_delta = 0;
// Get auth provider collection in case accounts might need to be unlinked
$provider_collection = $phpbb_container->get('auth.provider_collection');
// Some things need to be done in the loop (if the query changes based
// on which user is currently being deleted)
$added_guest_posts = 0;
foreach ($user_rows as $user_id => $user_row) {
if ($user_row['user_avatar'] && $user_row['user_avatar_type'] == 'avatar.driver.upload') {
avatar_delete('user', $user_row);
}
// Unlink accounts
foreach ($provider_collection as $provider_name => $auth_provider) {
$provider_data = $auth_provider->get_auth_link_data($user_id);
if ($provider_data !== null) {
//.........这里部分代码省略.........
示例5: while
if ($config['asacp_ocban_move_to_group']) {
$sql = 'SELECT group_id FROM ' . USER_GROUP_TABLE . ' WHERE user_id = ' . $user_id;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
group_user_del($row['group_id'], array($user_id), array($username));
}
$db->sql_freeresult($result);
group_user_add($config['asacp_ocban_move_to_group'], array($user_id), array($username), false, true);
}
// Delete the user's posts
if ($config['asacp_ocban_delete_posts']) {
delete_posts('poster_id', $user_id);
}
// Delete the user's avatar
if ($config['asacp_ocban_delete_avatar'] && $user_row['user_avatar']) {
avatar_delete('user', $user_row, true);
}
// Delete the user's signature
if ($config['asacp_ocban_delete_signature']) {
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', array('user_sig' => '', 'user_sig_bbcode_uid' => '', 'user_sig_bbcode_bitfield' => '')) . '
WHERE user_id = ' . $user_id;
$db->sql_query($sql);
}
// Delete the user's blog
if ($config['asacp_ocban_blog'] && file_exists($phpbb_root_path . 'blog/includes/functions_admin.' . $phpEx)) {
if (!function_exists('blog_delete_user')) {
include $phpbb_root_path . 'blog/includes/functions_admin.' . $phpEx;
}
blog_delete_user($user_id);
}
示例6: main
//.........这里部分代码省略.........
$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');
foreach ($test_variables as $test) {
if (isset($submit_ary[$test]) && ($action == 'add' || $group_row['group_' . $test] != $submit_ary[$test])) {
$group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test];
}
}
if (!($error = group_create($group_id, $group_type, $group_name, $group_desc, $group_attributes, $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies))) {
$group_perm_from = request_var('group_perm_from', 0);
// Copy permissions?
if ($group_perm_from && $action == 'add') {
// From the mysql documentation:
// Prior to MySQL 4.0.14, the target table of the INSERT statement cannot appear in the FROM clause of the SELECT part of the query. This limitation is lifted in 4.0.14.
// Due to this we stay on the safe side if we do the insertion "the manual way"
// Copy permisisons from/to the acl groups table (only group_id gets changed)
$sql = 'SELECT forum_id, auth_option_id, auth_role_id, auth_setting
FROM ' . ACL_GROUPS_TABLE . '
WHERE group_id = ' . $group_perm_from;
$result = $db->sql_query($sql);
$groups_sql_ary = array();
while ($row = $db->sql_fetchrow($result)) {
$groups_sql_ary[] = array('group_id' => (int) $group_id, 'forum_id' => (int) $row['forum_id'], 'auth_option_id' => (int) $row['auth_option_id'], 'auth_role_id' => (int) $row['auth_role_id'], 'auth_setting' => (int) $row['auth_setting']);
}
$db->sql_freeresult($result);
// Now insert the data
if (sizeof($groups_sql_ary)) {
示例7: main
//.........这里部分代码省略.........
$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']);
}
}
}
if (!sizeof($error)) {
$submit_ary['avatar_width'] = $data['width'];
$submit_ary['avatar_height'] = $data['height'];
}
}
}
}
}
if (isset($submit_ary['avatar']) && $submit_ary['avatar'] && !isset($group_row['group_avatar']) || $delete) {
if (isset($group_row['group_avatar']) && $group_row['group_avatar']) {
avatar_delete('group', $group_row, true);
}
}
// Validate the length of "Maximum number of allowed recipients per private message" setting.
// We use 16777215 as a maximum because it matches MySQL unsigned mediumint maximum value
// which is the lowest amongst DBMSes supported by phpBB3
if ($max_recipients_error = validate_data($submit_ary, array('max_recipients' => array('num', false, 0, 16777215)))) {
// Replace "error" string with its real, localised form
$error = array_merge($error, array_map(array(&$user, 'lang'), $max_recipients_error));
}
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' => 'int', 'colour' => 'string', 'avatar' => 'string', 'avatar_type' => 'int', 'avatar_width' => 'int', 'avatar_height' => 'int', 'receive_pm' => 'int', 'legend' => 'int', 'message_limit' => 'int', 'max_recipients' => 'int', 'founder_manage' => 'int', 'skip_auth' => 'int');
foreach ($test_variables as $test => $type) {
if (isset($submit_ary[$test]) && ($action == 'add' || $group_row['group_' . $test] != $submit_ary[$test])) {
settype($submit_ary[$test], $type);
$group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test];
}
}
if (!($error = group_create($group_id, $group_type, $group_name, $group_desc, $group_attributes, $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies))) {
$group_perm_from = request_var('group_perm_from', 0);
// Copy permissions?
// If the user has the a_authgroups permission and at least one additional permission ability set the permissions are fully transferred.
// We do not limit on one auth category because this can lead to incomplete permissions being tricky to fix for the admin, roles being assigned or added non-default permissions.
// Since the user only has the option to copy permissions from non leader managed groups this seems to be a good compromise.
if ($group_perm_from && $action == 'add' && $auth->acl_get('a_authgroups') && $auth->acl_gets('a_aauth', 'a_fauth', 'a_mauth', 'a_uauth')) {
$sql = 'SELECT group_founder_manage
FROM ' . GROUPS_TABLE . '
WHERE group_id = ' . $group_perm_from;
$result = $db->sql_query($sql);
示例8: group_set_user_default
/**
* Set users default group
*/
function group_set_user_default($group_id, $user_id_ary, $group_attributes = false)
{
global $db;
if (!$user_id_ary) {
return;
}
$attribute_ary = array('group_colour' => 'string', 'group_rank' => 'int', 'group_avatar' => 'string', 'group_avatar_type' => 'int', 'group_avatar_width' => 'int', 'group_avatar_height' => 'int');
$sql_ary = array('group_id' => $group_id);
// Were group attributes passed to the function? If not we need to obtain them
if ($group_attributes === false) {
$sql = 'SELECT ' . implode(', ', array_keys($attribute_ary)) . '
FROM ' . GROUPS_TABLE . "\n\t\t\tWHERE group_id = {$group_id}";
$result = $db->sql_query($sql);
$group_attributes = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
}
foreach ($attribute_ary as $attribute => $type) {
if (isset($group_attributes[$attribute])) {
// If we are about to set an avatar, we will not overwrite user avatars if no group avatar is set...
if (strpos($attribute, 'group_avatar') === 0 && !$group_attributes[$attribute]) {
continue;
}
settype($group_attributes[$attribute], $type);
$sql_ary[str_replace('group_', 'user_', $attribute)] = $group_attributes[$attribute];
}
}
// Before we update the user attributes, we will make a list of those having now the group avatar assigned
if (in_array('user_avatar', array_keys($sql_ary))) {
// Ok, get the original avatar data from users having an uploaded one (we need to remove these from the filesystem)
$sql = 'SELECT user_id, user_avatar
FROM ' . USERS_TABLE . '
WHERE user_id IN (' . implode(', ', $user_id_ary) . ')
AND user_avatar_type = ' . AVATAR_UPLOAD;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
avatar_delete($row['user_avatar']);
}
$db->sql_freeresult($result);
}
$sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id IN (' . implode(', ', $user_id_ary) . ')';
$db->sql_query($sql);
}
示例9: elseif
} 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);
/* 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_user']->data += $sql_ary;
unset($sql_ary);
$_CLASS['core_display']->meta_refresh(3, generate_link($this->link));
$message = $_CLASS['core_user']->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($_CLASS['core_user']->lang['RETURN_UCP'], '<a href="' . generate_link($this->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 = $_CORE_CONFIG['global']['path_avatar_upload'] . '/';
示例10: 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');
}
示例11: main
//.........这里部分代码省略.........
$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();
}
}
}
}
}
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->data['user_avatar']);
}
}
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);
}
extract($data);
unset($data);
// Replace "error" strings with their real, localised form
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
}
// Generate users avatar
$avatar_img = '';
if ($user->data['user_avatar']) {
switch ($user->data['user_avatar_type']) {
case AVATAR_UPLOAD:
$avatar_img = $phpbb_root_path . $config['avatar_path'] . '/';
break;
case AVATAR_GALLERY:
$avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/';
break;
}
$avatar_img .= $user->data['user_avatar'];
$avatar_img = '<img src="' . $avatar_img . '" width="' . $user->data['user_avatar_width'] . '" height="' . $user->data['user_avatar_height'] . '" alt="" />';
}
$template->assign_vars(array('ERROR' => sizeof($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($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], round($config['avatar_filesize'] / 1024))));
if ($display_gallery && $auth->acl_get('u_chgavatar') && $config['allow_avatar_local']) {
avatar_gallery($category, $avatar_select, 4);
} else {
$template->assign_vars(array('AVATAR' => $avatar_img, 'AVATAR_SIZE' => $config['avatar_filesize'], 'WIDTH' => isset($width) ? $width : $user->data['user_avatar_width'], 'HEIGHT' => isset($height) ? $height : $user->data['user_avatar_height'], 'S_UPLOAD_AVATAR_FILE' => $can_upload, 'S_UPLOAD_AVATAR_URL' => $can_upload, 'S_LINK_AVATAR' => $auth->acl_get('u_chgavatar') && $config['allow_avatar_remote'] ? true : false, 'S_GALLERY_AVATAR' => $auth->acl_get('u_chgavatar') && $config['allow_avatar_local'] ? true : false));
}
break;
}
$template->assign_vars(array('L_TITLE' => $user->lang['UCP_PROFILE_' . strtoupper($mode)], 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_UCP_ACTION' => $this->u_action));
// Set desired template
$this->tpl_name = 'ucp_profile_' . $mode;
$this->page_title = 'UCP_PROFILE_' . strtoupper($mode);
}
示例12: 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);
//.........这里部分代码省略.........
示例13: avatar_upload
function avatar_upload($remote, &$userinfo, $avatar_filename, $avatar)
{
require_once CORE_PATH . 'classes/cpg_file.php';
global $MAIN_CFG, $db, $lang;
if ($remote) {
if (!preg_match('/^(http:\\/\\/)?([\\w\\-\\.]+)\\:?([0-9]*)\\/(.*)$/', $avatar_filename, $url_ary) || empty($url_ary[4])) {
cpg_error('The URL you entered is incomplete');
}
$avatar = get_fileinfo($avatar_filename, !$MAIN_CFG['avatar']['animated'], true);
if (!isset($avatar['size'])) {
cpg_error(_AVATAR_ERR_DATA);
} elseif ($avatar['animation'] && !$MAIN_CFG['avatar']['animated']) {
cpg_error('Animated avatar not allowed');
}
$avatar_filesize = $avatar['size'];
$avatar_filetype = $avatar['type'];
$imgtype = check_image_type($avatar_filetype);
if ($avatar['size'] > 0 && $avatar['size'] < $MAIN_CFG['avatar']['filesize']) {
$new_filename = $userinfo['user_id'] . '_' . uniqid(rand()) . $imgtype;
$avatar_filename = $MAIN_CFG['avatar']['path'] . "/{$new_filename}";
if (CPG_File::write($avatar_filename, $avatar['data']) != $avatar['size']) {
trigger_error('Could not write avatar to local storage', E_USER_ERROR);
}
}
} else {
$avatar_filesize = $avatar['size'];
$avatar_filetype = $avatar['type'];
$imgtype = check_image_type($avatar_filetype);
$new_filename = $userinfo['user_id'] . '_' . uniqid(rand()) . $imgtype;
$avatar_filename = $MAIN_CFG['avatar']['path'] . "/{$new_filename}";
if (!CPG_File::move_upload($avatar, $avatar_filename)) {
trigger_error('Could not copy avatar to local storage', E_USER_ERROR);
}
if (!$MAIN_CFG['avatar']['animated'] && ($fp = fopen($avatar_filename, 'rb'))) {
$data = fread($fp, $avatar_filesize);
fclose($fp);
$data = preg_split('/\\x00[\\x00-\\xFF]\\x00\\x2C/', $data);
// split GIF frames
if (count($data) > 2) {
unlink($avatar_filename);
cpg_error('Animated avatar not allowed');
}
unset($data);
}
}
if ($avatar_filesize < 40 || $avatar_filesize > $MAIN_CFG['avatar']['filesize']) {
unlink($avatar_filename);
cpg_error(sprintf(_AVATAR_FILESIZE, round($MAIN_CFG['avatar']['filesize'] / 1024)));
}
avatar_size($avatar_filename, true);
avatar_delete($userinfo);
return "user_avatar='{$new_filename}', user_avatar_type=1";
}
示例14: group_set_user_default
/**
* Set users default group
*
* @access private
*/
function group_set_user_default($group_id, $user_id_ary, $group_attributes = false, $update_listing = false)
{
global $db;
if (empty($user_id_ary)) {
return;
}
$attribute_ary = array('group_colour' => 'string', 'group_rank' => 'int', 'group_avatar' => 'string', 'group_avatar_type' => 'int', 'group_avatar_width' => 'int', 'group_avatar_height' => 'int');
$sql_ary = array('group_id' => $group_id);
// Were group attributes passed to the function? If not we need to obtain them
if ($group_attributes === false) {
$sql = 'SELECT ' . implode(', ', array_keys($attribute_ary)) . '
FROM ' . GROUPS_TABLE . "\n\t\t\tWHERE group_id = {$group_id}";
$result = $db->sql_query($sql);
$group_attributes = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
}
foreach ($attribute_ary as $attribute => $type) {
if (isset($group_attributes[$attribute])) {
// If we are about to set an avatar or rank, we will not overwrite with empty, unless we are not actually changing the default group
if ((strpos($attribute, 'group_avatar') === 0 || strpos($attribute, 'group_rank') === 0) && !$group_attributes[$attribute]) {
continue;
}
settype($group_attributes[$attribute], $type);
$sql_ary[str_replace('group_', 'user_', $attribute)] = $group_attributes[$attribute];
}
}
// Before we update the user attributes, we will make a list of those having now the group avatar assigned
if (isset($sql_ary['user_avatar'])) {
// Ok, get the original avatar data from users having an uploaded one (we need to remove these from the filesystem)
$sql = 'SELECT user_id, group_id, user_avatar
FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', $user_id_ary) . '
AND user_avatar_type = ' . AVATAR_UPLOAD;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
avatar_delete('user', $row);
}
$db->sql_freeresult($result);
} else {
unset($sql_ary['user_avatar_type']);
unset($sql_ary['user_avatar_height']);
unset($sql_ary['user_avatar_width']);
}
$sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
WHERE ' . $db->sql_in_set('user_id', $user_id_ary);
$db->sql_query($sql);
if (isset($sql_ary['user_colour'])) {
// Update any cached colour information for these users
$sql = 'UPDATE ' . FORUMS_TABLE . " SET forum_last_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "'\n\t\t\tWHERE " . $db->sql_in_set('forum_last_poster_id', $user_id_ary);
$db->sql_query($sql);
$sql = 'UPDATE ' . TOPICS_TABLE . " SET topic_first_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "'\n\t\t\tWHERE " . $db->sql_in_set('topic_poster', $user_id_ary);
$db->sql_query($sql);
$sql = 'UPDATE ' . TOPICS_TABLE . " SET topic_last_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "'\n\t\t\tWHERE " . $db->sql_in_set('topic_last_poster_id', $user_id_ary);
$db->sql_query($sql);
global $config;
if (in_array($config['newest_user_id'], $user_id_ary)) {
set_config('newest_user_colour', $sql_ary['user_colour'], true);
}
}
if ($update_listing) {
group_update_listings($group_id);
}
}
示例15: do_ban_hammer_stuff
//.........这里部分代码省略.........
// Get group name for banned users, if any.
$sql = 'SELECT group_id, group_name FROM ' . GROUPS_TABLE . '
WHERE group_id = ' . (int) $settings['group_id'];
$result = $this->db->sql_query($sql);
$group_name = $this->db->sql_fetchfield('group_name');
$this->db->sql_freeresult($result);
if (empty($group_name)) {
$settings['group_id'] = 0;
}
}
if (!$this->request->is_set('bh') || $this->request->is_set('bh') && $this->request->is_set('confirm_key') && !confirm_box(true)) {
$params = array('mode' => 'viewprofile', 'u' => $this->user_id, 'bh' => 1);
$this->template->assign_vars(array('BH_BAN_EMAIL' => $settings['ban_email'], 'BH_BAN_IP' => $settings['ban_ip'], 'BH_DEL_AVATAR' => $settings['del_avatar'], 'BH_DEL_PRIVMSGS' => $settings['del_privmsgs'], 'BH_DEL_POSTS' => $settings['del_posts'], 'BH_DEL_PROFILE' => $settings['del_profile'], 'BH_DEL_SIGNATURE' => $settings['del_signature'], 'L_BH_MOVE_GROUP' => !empty($group_name) ? sprintf($this->user->lang['BH_MOVE_GROUP'], $group_name) : '', 'S_BH_SFS' => !empty($settings['sfs_api_key']) && $curl_exists ? true : false, 'S_SHOW_BH' => true, 'U_HAMMERBAN' => append_sid($this->root_path . 'memberlist.' . $this->php_ext, $params)));
return;
}
// Time to ban a user. But are you sure?
if (!confirm_box(true)) {
$hidden_fields = array('ban_email' => $this->request->variable('ban_email', 0), 'ban_ip' => $this->request->variable('ban_ip', 0), 'bh_reason' => $this->request->variable('bh_reason', '', true), 'bh_reason_user' => $this->request->variable('bh_reason_user', '', true), 'del_avatar' => $this->request->variable('del_avatar', 0), 'del_privmsgs' => $this->request->variable('del_privmsgs', 0), 'del_posts' => $this->request->variable('del_posts', 0), 'del_profile' => $this->request->variable('del_profile', 0), 'del_signature' => $this->request->variable('del_signature', 0), 'mode' => 'viewprofile', 'move_group' => $this->request->variable('move_group', 0), 'sfs_report' => $this->request->variable('sfs_report', 0));
$message = sprintf($this->user->lang['SURE_BAN'], $this->data['username']) . '<br /><br />';
$message .= $this->user->lang['THIS_WILL'] . '' . $this->user->lang['COLON'] . '<br />' . $this->user->lang['BH_BAN_USER'] . '<br />';
$message .= $hidden_fields['ban_email'] ? $this->user->lang['BH_BAN_EMAIL'] . '<br />' : '';
$message .= $hidden_fields['ban_ip'] ? $this->user->lang['BH_BAN_IP'] . '<br />' : '';
$message .= $hidden_fields['bh_reason'] ? sprintf($this->user->lang['BH_REASON'], $hidden_fields['bh_reason']) . '<br />' : '';
$message .= $hidden_fields['bh_reason_user'] ? sprintf($this->user->lang['BH_REASON_USER'], $hidden_fields['bh_reason_user']) . '<br />' : '';
$message .= $hidden_fields['del_avatar'] ? $this->user->lang['BH_DEL_AVATAR'] . '<br />' : '';
$message .= $hidden_fields['del_privmsgs'] ? $this->user->lang['BH_DEL_PRIVMSGS'] . '<br />' : '';
$message .= $hidden_fields['del_posts'] ? $this->user->lang['BH_DEL_POSTS'] . '<br />' : '';
$message .= $hidden_fields['del_profile'] ? $this->user->lang['BH_DEL_PROFILE'] . '<br />' : '';
$message .= $hidden_fields['del_signature'] ? $this->user->lang['BH_DEL_SIGNATURE'] . '<br />' : '';
$message .= !empty($group_name) && $hidden_fields['move_group'] ? sprintf($this->user->lang['BH_MOVE_GROUP'], $group_name) . '<br />' : '';
$message .= $hidden_fields['sfs_report'] && $curl_exists ? $this->user->lang['BH_SUBMIT_SFS'] . '<br />' : '';
confirm_box(false, $message, build_hidden_fields($hidden_fields));
}
// We have a user to ban.
$error = array();
// Any reason for this ban?
$bh_reason = $this->request->variable('bh_reason', '', true);
$bh_reason_user = $this->request->variable('bh_reason_user', '', true);
// The username is the user so it's always banned.
$success = user_ban('user', $this->data['username'], 0, '', false, $bh_reason, $bh_reason_user);
if (!$success) {
$error[] = 'ERROR_BAN_USER';
}
if ($this->request->variable('ban_email', 0)) {
$success = user_ban('email', $this->data['user_email'], 0, '', false, $bh_reason, $bh_reason_user);
if (!$success) {
$error[] = 'ERROR_BAN_EMAIL';
}
}
if ($this->request->variable('ban_ip', 0) && !empty($this->data['user_ip'])) {
$success = user_ban('ip', $this->data['user_ip'], 0, '', false, $bh_reason, $bh_reason_user);
if (!$success) {
$error[] = 'ERROR_BAN_IP';
}
}
if ($this->request->variable('del_posts', 0)) {
$this->bh_del_posts();
}
if ($this->request->variable('del_privmsgs', 0)) {
$this->bh_del_privmsgs();
}
if ($this->request->variable('del_avatar', 0)) {
avatar_delete('user', $this->data, true);
}
if ($this->request->variable('del_signature', 0)) {
$sql = 'UPDATE ' . USERS_TABLE . "\n\t\t\t\t\tSET user_sig = '',\n\t\t\t\t\t\tuser_sig_bbcode_uid = '',\n\t\t\t\t\t\tuser_sig_bbcode_bitfield = ''\n\t\t\t\t\tWHERE user_id = " . $this->user_id;
$this->db->sql_query($sql);
}
if ($this->request->variable('del_profile', 0)) {
$sql = 'DELETE FROM ' . PROFILE_FIELDS_DATA_TABLE . '
WHERE user_id = ' . $this->user_id;
$this->db->sql_query($sql);
}
if ($this->request->variable('move_group', 0) && !empty($group_name)) {
$return = group_user_add($settings['group_id'], array($this->user_id), array($this->data['username']), $group_name, true);
if ($return != false) {
$error[] = $this->user->lang['ERROR_MOVE_GROUP'];
}
}
if ($this->request->variable('sfs_report', 0) && !empty($settings['sfs_api_key']) && $curl_exists) {
// add the spammer to the SFS database
$http_request = 'http://www.stopforumspam.com/add.php';
$http_request .= '?username=' . $this->data['username'];
$http_request .= '&ip_addr=' . $this->data['user_ip'];
$http_request .= '&email=' . $this->data['user_email'];
$http_request .= '&api_key=' . $settings['sfs_api_key'];
$response = $this->get_file($http_request);
if (!$response) {
$error[] = $this->user->lang['ERROR_SFS'];
}
}
// Need to purge the cache.
$this->cache->purge();
// The page needs to be reloaded to show the new banned status.
$args = array('mode' => 'viewprofile', 'u' => $this->user_id, 'bh_res' => empty($error) ? 'success' : urlencode(implode('+', $error)));
$url = generate_board_url();
$url .= (substr($url, -1) == '/' ? '' : '/') . 'memberlist.' . $this->php_ext;
$url = append_sid($url, $args);
redirect($url);
}