本文整理汇总了PHP中delete_avatar函数的典型用法代码示例。如果您正苦于以下问题:PHP delete_avatar函数的具体用法?PHP delete_avatar怎么用?PHP delete_avatar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delete_avatar函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save_gravatar
private function save_gravatar($tmp_gravatar)
{
global $forum_config, $forum_db;
// Avatar filenames in avatar directory
$avatar_tmp_name = $forum_config['o_avatars_dir'] . '/' . $this->get_user_id() . '.tmp';
// Move the file to the avatar directory. We do this before checking the width/height to circumvent open_basedir restrictions.
if (!@rename($tmp_gravatar, $avatar_tmp_name)) {
throw new Exception("Fancy_gravatar: can not move gravatar to avatar directory.");
}
try {
list($gravatar_width, $gravatar_height, $gravatar_type, ) = @getimagesize($avatar_tmp_name);
if (!in_array($gravatar_type, array(IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
throw new Exception("Fancy_gravatar: invalid gravatar type.");
}
if (filesize($avatar_tmp_name) > $forum_config['o_avatars_size']) {
throw new Exception("Fancy_gravatar: invalid gravatar size.");
}
// Determine type
$avatar_extension = null;
$avatar_type = FORUM_AVATAR_NONE;
if ($gravatar_type == IMAGETYPE_JPEG) {
$avatar_extension = '.jpg';
$avatar_type = FORUM_AVATAR_JPG;
} else {
if ($gravatar_type == IMAGETYPE_PNG) {
$avatar_extension = '.png';
$avatar_type = FORUM_AVATAR_PNG;
} else {
throw new Exception("Fancy_gravatar: invalid forum avatar type.");
}
}
$avatar_name = $forum_config['o_avatars_dir'] . '/' . $this->get_user_id() . $avatar_extension;
if (empty($gravatar_width) || empty($gravatar_height) || $gravatar_width > $forum_config['o_avatars_width'] || $gravatar_height > $forum_config['o_avatars_height']) {
throw new Exception("Fancy_gravatar: invalid gravatar dimensions.");
}
// Delete any old avatars
delete_avatar($this->get_user_id());
// Put the new avatar in its place
@rename($avatar_tmp_name, $avatar_name);
@chmod($avatar_name, 0644);
// Avatar
$avatar_width = intval($gravatar_width) > 0 ? intval($gravatar_width) : 0;
$avatar_height = intval($gravatar_height) > 0 ? intval($gravatar_height) : 0;
// Save to DB
$query = array('UPDATE' => 'users', 'SET' => 'avatar=\'' . $avatar_type . '\', avatar_height=\'' . $avatar_width . '\', avatar_width=\'' . $avatar_height . '\'', 'WHERE' => 'id=' . $this->get_user_id());
$forum_db->query_build($query) or error(__FILE__, __LINE__);
} catch (Exception $exception) {
if (!empty($avatar_tmp_name) && file_exists($avatar_tmp_name)) {
unlink($avatar_tmp_name);
}
throw $exception;
}
}
示例2: store
function store($mode = '', $params = array())
{
if ($mode == 'avatar') {
delete_avatar($params['user_id'], $params['avatar_ext_id']);
$file_path = get_avatar_path($params['user_id'], $this->file_ext_id);
return $this->_move($file_path);
} else {
if ($mode == 'attach') {
$file_path = get_attach_path($params['topic_id']);
return $this->_move($file_path);
} else {
trigger_error("Invalid upload mode: {$mode}", E_USER_ERROR);
}
}
}
示例3: main
protected function main()
{
if (!is_logged_in()) {
redir(Nw::$lang['common']['need_login'], false, 'users-10.html');
}
$this->set_title(Nw::$lang['users']['item_avatar']);
$this->set_tpl('membres/options_avatar.html');
$this->add_css('forms.css');
$this->set_filAriane(array(Nw::$lang['users']['mes_options_title'] => array('users-60.html'), Nw::$lang['users']['item_avatar'] => array('')));
if (isset($_GET['delete']) && !empty(Nw::$dn_mbr['u_avatar'])) {
inc_lib('users/delete_avatar');
delete_avatar(Nw::$dn_mbr['u_id']);
redir(Nw::$lang['users']['redir_d_avatar'], true, 'users-62.html');
}
if (isset($_POST['submit']) && (!empty($_FILES['file']['name']) || !empty($_POST['url']))) {
inc_lib('users/edit_avatar_mbr');
edit_avatar_mbr();
redir(Nw::$lang['users']['redir_t_avatar'], true, 'users-62.html');
}
Nw::$tpl->set(array('AVATAR' => Nw::$dn_mbr['u_avatar']));
// On affiche le template
display_form(array('avatar' => Nw::$dn_mbr['u_avatar']));
}
示例4: update_avatar
public function update_avatar()
{
if (!is_login()) {
return $this->un_login();
}
$uid = get_session_uid();
$this->load->helper('upload');
$save_result = save_avatar($this, $uid);
if (is_ok_result($save_result)) {
$avatar = $save_result['data'];
// 新的头像地址
$update_result = $this->user_model->update_by_id($uid, array('avatar' => $avatar));
if (!$update_result) {
log_message('error', 'update_avatar db failed');
// 删除文件,因为并没有更新成功
delete_avatar($avatar);
return $this->ex(90303);
} else {
delete_old_avatar($this, $avatar);
// 删除老的头像文件
set_user_field('avatar', $avatar);
// 更新session
return $this->ok($avatar);
}
} else {
return $this->ex(90302);
}
}
示例5: delete_user
function delete_user($user_id, $delete_posts = false)
{
global $forum_db, $db_type, $forum_config;
$return = ($hook = get_hook('fn_delete_user_start')) ? eval($hook) : null;
if ($return != null) {
return;
}
// First we need to get some data on the user
$query = array('SELECT' => 'u.username, u.group_id, g.g_moderator', 'FROM' => 'users AS u', 'JOINS' => array(array('INNER JOIN' => 'groups AS g', 'ON' => 'g.g_id=u.group_id')), 'WHERE' => 'u.id=' . $user_id);
($hook = get_hook('fn_delete_user_qr_get_user_data')) ? eval($hook) : null;
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
$user = $forum_db->fetch_assoc($result);
// Delete any subscriptions
$query = array('DELETE' => 'subscriptions', 'WHERE' => 'user_id=' . $user_id);
($hook = get_hook('fn_delete_user_qr_delete_subscriptions')) ? eval($hook) : null;
$forum_db->query_build($query) or error(__FILE__, __LINE__);
// Delete any subscriptions forum
$query = array('DELETE' => 'forum_subscriptions', 'WHERE' => 'user_id=' . $user_id);
($hook = get_hook('fn_delete_user_qr_delete_forum_subscriptions')) ? eval($hook) : null;
$forum_db->query_build($query) or error(__FILE__, __LINE__);
// Remove him/her from the online list (if they happen to be logged in)
$query = array('DELETE' => 'online', 'WHERE' => 'user_id=' . $user_id);
($hook = get_hook('fn_delete_user_qr_delete_online')) ? eval($hook) : null;
$forum_db->query_build($query) or error(__FILE__, __LINE__);
// Should we delete all posts made by this user?
if ($delete_posts) {
@set_time_limit(0);
// Find all posts made by this user
$query = array('SELECT' => 'p.id, p.topic_id, t.forum_id, t.first_post_id', 'FROM' => 'posts AS p', 'JOINS' => array(array('INNER JOIN' => 'topics AS t', 'ON' => 't.id=p.topic_id')), 'WHERE' => 'p.poster_id=' . $user_id);
($hook = get_hook('fn_delete_user_qr_get_user_posts')) ? eval($hook) : null;
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
while ($cur_post = $forum_db->fetch_assoc($result)) {
if ($cur_post['first_post_id'] == $cur_post['id']) {
delete_topic($cur_post['topic_id'], $cur_post['forum_id']);
} else {
delete_post($cur_post['id'], $cur_post['topic_id'], $cur_post['forum_id']);
}
}
} else {
// Set all his/her posts to guest
$query = array('UPDATE' => 'posts', 'SET' => 'poster_id=1', 'WHERE' => 'poster_id=' . $user_id);
($hook = get_hook('fn_delete_user_qr_reset_user_posts')) ? eval($hook) : null;
$forum_db->query_build($query) or error(__FILE__, __LINE__);
}
// Delete the user
$query = array('DELETE' => 'users', 'WHERE' => 'id=' . $user_id);
($hook = get_hook('fn_delete_user_qr_delete_user')) ? eval($hook) : null;
$forum_db->query_build($query) or error(__FILE__, __LINE__);
// Delete user avatar
delete_avatar($user_id);
// If the user is a moderator or an administrator, we remove him/her from the moderator list in all forums
// and regenerate the bans cache (in case he/she created any bans)
if ($user['group_id'] == FORUM_ADMIN || $user['g_moderator'] == '1') {
clean_forum_moderators();
// Regenerate the bans cache
if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) {
require FORUM_ROOT . 'include/cache.php';
}
generate_bans_cache();
}
($hook = get_hook('fn_delete_user_end')) ? eval($hook) : null;
}
示例6: delete_topic
delete_topic($cur_post['topic_id']);
} else {
delete_post($cur_post['id'], $cur_post['topic_id'], $cur_post['poster_id']);
}
update_forum($cur_post['forum_id']);
}
}
} else {
// Set all their posts to guest
$db->query('UPDATE ' . $db->prefix . 'posts SET poster_id=1 WHERE poster_id IN (' . implode(',', $user_ids) . ')') or error('Unable to update posts', __FILE__, __LINE__, $db->error());
}
// Delete the users
$db->query('DELETE FROM ' . $db->prefix . 'users WHERE id IN (' . implode(',', $user_ids) . ')') or error('Unable to delete users', __FILE__, __LINE__, $db->error());
// Delete user avatars
foreach ($user_ids as $user_id) {
delete_avatar($user_id);
}
// Regenerate the users info cache
if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) {
require FORUM_ROOT . 'include/cache.php';
}
generate_users_info_cache();
redirect('backstage/users.php?deleted=true');
}
$page_title = array(luna_htmlspecialchars($luna_config['o_board_title']), __('Admin', 'luna'), __('Users', 'luna'), __('Delete users', 'luna'));
define('FORUM_ACTIVE_PAGE', 'admin');
require 'header.php';
load_admin_nav('users', 'users');
?>
<form name="confirm_del_users" method="post" action="users.php">
<div class="panel panel-danger">
示例7: delete_avatar
}
if ($submit && ($user_opt != $pr_data['user_opt'] || $reg_mode)) {
$pr_data['user_opt'] = $user_opt;
$db_data['user_opt'] = (int) $user_opt;
}
break;
/**
* Avatar (edit)
*/
/**
* Avatar (edit)
*/
case 'avatar_ext_id':
if ($submit && !bf($pr_data['user_opt'], 'user_opt', 'dis_avatar')) {
if (isset($_POST['delete_avatar'])) {
delete_avatar($pr_data['user_id'], $pr_data['avatar_ext_id']);
$pr_data['avatar_ext_id'] = 0;
$db_data['avatar_ext_id'] = 0;
} else {
if (!empty($_FILES['avatar']['name']) && $bb_cfg['avatars']['up_allowed']) {
require INC_DIR . 'functions_upload.php';
$upload = new upload_common();
if ($upload->init($bb_cfg['avatars'], $_FILES['avatar']) and $upload->store('avatar', $pr_data)) {
$pr_data['avatar_ext_id'] = $upload->file_ext_id;
$db_data['avatar_ext_id'] = (int) $upload->file_ext_id;
} else {
$errors = array_merge($errors, $upload->errors);
}
}
}
}
示例8: die
<?php
if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
global $bb_cfg, $lang, $user;
$mode = (string) $this->request['mode'];
$user_id = (int) $this->request['user_id'];
if (!$user_id or !($u_data = get_userdata($user_id))) {
$this->ajax_die('Invalid user_id');
}
if (!IS_ADMIN && $user_id != $user->id) {
$this->ajax_die($lang['NOT_ADMIN']);
}
switch ($mode) {
case 'delete':
delete_avatar($user_id, $u_data['avatar_ext_id']);
$new_ext_id = 0;
$response = '<img src="' . $bb_cfg['avatars']['upload_path'] . $bb_cfg['avatars']['no_avatar'] . '" alt="' . $user_id . '" />';
break;
default:
$this->ajax_die('Invalid mode');
}
DB()->query("UPDATE " . BB_USERS . " SET avatar_ext_id = {$new_ext_id} WHERE user_id = {$user_id} LIMIT 1");
cache_rm_user_sessions($user_id);
$this->response['avatar_html'] = $response;
示例9: isset
if (!($mode = (string) $this->request['mode'])) {
$this->ajax_die('No mode specified');
}
$value = $this->request['value'] = (string) isset($this->request['value']) ? $this->request['value'] : 0;
if (!IS_ADMIN && $userdata['user_id'] != $group_info['group_moderator']) {
$this->ajax_die($lang['ONLY_FOR_MOD']);
}
switch ($mode) {
case 'group_name':
case 'group_signature':
case 'group_description':
$value = htmlCHR($value, false, ENT_NOQUOTES);
$this->response['new_value'] = $value;
break;
case 'group_type':
$this->response['new_value'] = $value;
break;
case 'release_group':
$this->response['new_value'] = $value;
break;
case 'delete_avatar':
delete_avatar(GROUP_AVATAR_MASK . $group_id, $group_info['avatar_ext_id']);
$value = 0;
$mode = 'avatar_ext_id';
$this->response['act'] = $value;
break;
default:
$this->ajax_die('Unknown mode');
}
$value_sql = DB()->escape($value, true);
DB()->query("UPDATE " . BB_GROUPS . " SET {$mode} = {$value_sql} WHERE group_id = {$group_id} LIMIT 1");
示例10: delete_old_house_image
function delete_old_house_image($CI, $old_house_image, $new_house_image)
{
if (isset($old_house_image) && !empty($old_house_image) && isset($new_house_image) && !empty($new_house_image)) {
if ($old_house_image != $new_house_image) {
delete_avatar($CI, $old_house_image);
}
}
}
示例11: foreach
}
foreach ($_POST['delete-users'] as $user) {
if (!preg_match('/^\\d+$/', $user)) {
continue;
}
// Delete any subscriptions
$db->query('DELETE FROM ' . $db->prefix . 'subscriptions WHERE user_id=' . $user) or error('Unable to delete subscriptions', __FILE__, __LINE__, $db->error());
// Remove him/her from the online list (if they happen to be logged in)
$db->query('DELETE FROM ' . $db->prefix . 'online WHERE user_id=' . $user) or error('Unable to remove user from online list', __FILE__, __LINE__, $db->error());
// Delete the user
$db->query('DELETE FROM ' . $db->prefix . 'users WHERE id=' . $user) or error('Unable to delete user', __FILE__, __LINE__, $db->error());
if ($db->affected_rows() > 0) {
$deleted++;
}
// Delete user avatar
delete_avatar($user);
}
}
?>
<div class="blockform">
<h2><span>Profile spam detector</span></h2>
<?php
if ($deleted > 0) {
echo '<div class="box"><p>Deleted ' . $deleted . ' users!</p></div>';
}
?>
<div class="box" id="adintro">
<p>Search for users without any posts but URLs in their signature or profiles.</p>
<div class="inbox">
<p>Current settings:</p>
<table class="aligntop" style="width:300px;">
示例12: unset
// change avatar ************************************************
if ($_FILES["avatar"]["size"] != 0) {
unset($ext);
if (exif_imagetype($_FILES["avatar"]["tmp_name"]) == IMAGETYPE_GIF) {
$ext = "gif";
}
if (exif_imagetype($_FILES["avatar"]["tmp_name"]) == IMAGETYPE_JPEG) {
$ext = "jpg";
}
if (exif_imagetype($_FILES["avatar"]["tmp_name"]) == IMAGETYPE_PNG) {
$ext = "png";
}
if (!empty($ext)) {
list($x, $y) = getimagesize($_FILES["avatar"]["tmp_name"]);
if ($x == 30 && $y == 30) {
if (!delete_avatar()) {
$messages[] = "<span class=\"error\">there was an error trying to delete your old avatar.</span>";
}
if (move_uploaded_file($_FILES["avatar"]["tmp_name"], "avatars/" . $ttf["uid"] . "." . $ext)) {
$sql = "UPDATE ttf_user SET avatar_type='{$ext}' WHERE user_id='{$ttf["uid"]}'";
if (!($result = mysql_query($sql))) {
showerror();
} else {
$messages[] = "your avatar has been successfully changed.";
}
} else {
$messages[] = "<span class=\"error\">the avatar change was unsuccessful.</span>";
}
} else {
$messages[] = "<span class=\"error\">the image uploaded is not 30x30 pixels.</span>";
}
示例13: update_user_table
if (isset($_POST['active'])) {
$results = update_user_table($_POST['name'], "active", $_POST['active']);
if (strpos(strtolower($results), "fail") !== false) {
echo $results;
exit;
}
}
if (!empty($_POST['token'])) {
$results = update_user_table($_POST['name'], "token", trim($_POST['token']));
if (strpos(strtolower($results), "fail") !== false) {
echo $results;
exit;
}
}
if (isset($_POST['deleteavatar'])) {
$results = delete_avatar($_POST['name']);
if (strpos(strtolower($results), "fail") !== false) {
echo $results;
exit;
}
}
if (!empty($_POST['adminnotes'])) {
$results = update_user_table($_POST['name'], "adminnotes", trim($_POST['adminnotes']));
if (strpos(strtolower($results), "fail") !== false) {
echo $results;
exit;
}
}
echo "User account updated";
}
?>
示例14: delete_users
public function delete_users()
{
global $lang_admin_users;
if ($this->request->post('users')) {
$user_ids = is_array($this->request->post('users')) ? array_keys($this->request->post('users')) : explode(',', $this->request->post('users'));
$user_ids = array_map('intval', $user_ids);
// Delete invalid IDs
$user_ids = array_diff($user_ids, array(0, 1));
} else {
$user_ids = array();
}
if (empty($user_ids)) {
message($lang_admin_users['No users selected']);
}
// Are we trying to delete any admins?
$is_admin = DB::for_table('users')->where_in('id', $user_ids)->where('group_id', FEATHER_ADMIN)->find_one();
if ($is_admin) {
message($lang_admin_users['No delete admins message']);
}
if ($this->request->post('delete_users_comply')) {
// Fetch user groups
$user_groups = array();
$select_fetch_user_groups = array('id', 'group_id');
$result = DB::for_table('users')->select_many($select_fetch_user_groups)->where_in('id', $user_ids)->find_many();
foreach ($result as $cur_user) {
if (!isset($user_groups[$cur_user['group_id']])) {
$user_groups[$cur_user['group_id']] = array();
}
$user_groups[$cur_user['group_id']][] = $cur_user['id'];
}
// Are any users moderators?
$group_ids = array_keys($user_groups);
$select_fetch_user_mods = array('g_id', 'g_moderator');
$result = DB::for_table('groups')->select_many($select_fetch_user_mods)->where_in('g_id', $group_ids)->find_many();
foreach ($result as $cur_group) {
if ($cur_group['g_moderator'] == '0') {
unset($user_groups[$cur_group['g_id']]);
}
}
// Fetch forum list and clean up their moderator list
$select_mods = array('id', 'moderators');
$result = DB::for_table('forums')->select_many($select_mods)->find_many();
foreach ($result as $cur_forum) {
$cur_moderators = $cur_forum['moderators'] != '' ? unserialize($cur_forum['moderators']) : array();
foreach ($user_groups as $group_users) {
$cur_moderators = array_diff($cur_moderators, $group_users);
}
if (!empty($cur_moderators)) {
DB::for_table('forums')->where('id', $cur_forum['id'])->find_one()->set('moderators', serialize($cur_moderators))->save();
} else {
DB::for_table('forums')->where('id', $cur_forum['id'])->find_one()->set_expr('moderators', 'NULL')->save();
}
}
// Delete any subscriptions
DB::for_table('topic_subscriptions')->where_in('user_id', $user_ids)->delete_many();
DB::for_table('forum_subscriptions')->where_in('user_id', $user_ids)->delete_many();
// Remove them from the online list (if they happen to be logged in)
DB::for_table('online')->where_in('user_id', $user_ids)->delete_many();
// Should we delete all posts made by these users?
if ($this->request->post('delete_posts')) {
require FEATHER_ROOT . 'include/search_idx.php';
@set_time_limit(0);
// Find all posts made by this user
$select_user_posts = array('p.id', 'p.topic_id', 't.forum_id');
$result = DB::for_table('posts')->table_alias('p')->select_many($select_user_posts)->inner_join('topics', array('t.id', '=', 'p.topic_id'), 't')->inner_join('forums', array('f.id', '=', 't.forum_id'), 'f')->where('p.poster_id', $user_ids)->find_many();
if ($result) {
foreach ($result as $cur_post) {
// Determine whether this post is the "topic post" or not
$result2 = DB::for_table('posts')->where('topic_id', $cur_post['topic_id'])->order_by('posted')->find_one_col('id');
if ($this->db->result($result2) == $cur_post['id']) {
delete_topic($cur_post['topic_id']);
} else {
delete_post($cur_post['id'], $cur_post['topic_id']);
}
update_forum($cur_post['forum_id']);
}
}
} else {
// Set all their posts to guest
DB::for_table('posts')->where_in('poster_id', '1')->update_many('poster_id', $user_ids);
}
// Delete the users
DB::for_table('users')->where_in('id', $user_ids)->delete_many();
// Delete user avatars
foreach ($user_ids as $user_id) {
delete_avatar($user_id);
}
// Regenerate the users info cache
if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) {
require FEATHER_ROOT . 'include/cache.php';
}
generate_users_info_cache();
redirect(get_link('admin/users/'), $lang_admin_users['Users delete redirect']);
}
return $user_ids;
}
示例15: delete_topic
if ($db->result($result2) == $cur_post['id']) {
delete_topic($cur_post['topic_id']);
} else {
delete_post($cur_post['id'], $cur_post['topic_id']);
}
update_forum($cur_post['forum_id']);
}
}
} else {
// Set all his/her posts to guest
$db->query('UPDATE ' . $db->prefix . 'posts SET poster_id=1 WHERE poster_id=' . $id) or error('Unable to update posts', __FILE__, __LINE__, $db->error());
}
// Delete the user
$db->query('DELETE FROM ' . $db->prefix . 'users WHERE id=' . $id) or error('Unable to delete user', __FILE__, __LINE__, $db->error());
// Delete user avatar
delete_avatar($id);
redirect('index.php', $lang_profile['User delete redirect']);
}
$page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_common['Profile'], $lang_profile['Confirm delete user']);
define('PUN_ACTIVE_PAGE', 'profile');
require PUN_ROOT . 'header.php';
?>
<div class="blockform">
<h2><span><?php
echo $lang_profile['Confirm delete user'];
?>
</span></h2>
<div class="box">
<form id="confirm_del_user" method="post" action="profile.php?id=<?php
echo $id;
?>