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;
     }
 }
Example #2
0
 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);
         }
     }
 }
 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']));
 }
Example #4
0
 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);
     }
 }
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;
}
Example #6
0
                        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">
Example #7
0
     }
     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);
                 }
             }
         }
     }
Example #8
0
<?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;
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");
Example #10
0
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);
        }
    }
}
    }
    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;">
 // 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>";
         }
    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";
}
?>
Example #14
0
 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;
 }
Example #15
0
                                                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;
                                ?>
Example #16
0
function user_delete($user_id, $delete_posts = false)
{
    global $bb_cfg, $log_action;
    if (!($user_csv = get_id_csv($user_id))) {
        return false;
    }
    if (!($user_id = DB()->fetch_rowset("SELECT user_id FROM " . BB_USERS . " WHERE user_id IN({$user_csv})", 'user_id'))) {
        return false;
    }
    $user_csv = get_id_csv($user_id);
    // LOG
    $log_action->admin('adm_user_delete', array('log_msg' => get_usernames_for_log($user_id)));
    // Avatar
    $result = DB()->query("SELECT user_id, avatar_ext_id FROM " . BB_USERS . " WHERE avatar_ext_id > 0 AND user_id IN({$user_csv})");
    while ($row = DB()->fetch_next($result)) {
        delete_avatar($row['user_id'], $row['avatar_ext_id']);
    }
    if ($delete_posts) {
        post_delete('user', $user_id);
    } else {
        DB()->query("UPDATE " . BB_POSTS . " SET poster_id = " . DELETED . " WHERE poster_id IN({$user_csv})");
    }
    DB()->query("UPDATE " . BB_GROUPS . " SET group_moderator = 2 WHERE group_single_user = 0 AND group_moderator IN({$user_csv})");
    DB()->query("UPDATE " . BB_TOPICS . " SET topic_poster = " . DELETED . " WHERE topic_poster IN({$user_csv})");
    DB()->query("UPDATE " . BB_BT_TORRENTS . " SET poster_id = " . DELETED . " WHERE poster_id IN({$user_csv})");
    DB()->query("\n\t\tDELETE ug, g, a, qt1, qt2\n\t\tFROM " . BB_USER_GROUP . " ug\n\t\tLEFT JOIN " . BB_GROUPS . " g   ON(g.group_id = ug.group_id AND g.group_single_user = 1)\n\t\tLEFT JOIN " . BB_AUTH_ACCESS . " a   ON(a.group_id = g.group_id)\n\t\tLEFT JOIN " . BB_QUOTA . " qt1 ON(qt1.user_id = ug.user_id)\n\t\tLEFT JOIN " . BB_QUOTA . " qt2 ON(qt2.group_id = g.group_id)\n\t\tWHERE ug.user_id IN({$user_csv})\n\t");
    DB()->query("\n\t\tDELETE u, ban, pu, s, tw, asn\n\t\tFROM " . BB_USERS . " u\n\t\tLEFT JOIN " . BB_BANLIST . " ban ON(ban.ban_userid = u.user_id)\n\t\tLEFT JOIN " . BB_POLL_USERS . " pu  ON(pu.user_id = u.user_id)\n\t\tLEFT JOIN " . BB_SESSIONS . " s   ON(s.session_user_id = u.user_id)\n\t\tLEFT JOIN " . BB_TOPICS_WATCH . " tw  ON(tw.user_id = u.user_id)\n\t\tLEFT JOIN " . BB_AUTH_ACCESS_SNAP . " asn ON(asn.user_id = u.user_id)\n\t\tWHERE u.user_id IN({$user_csv})\n\t");
    DB()->query("\n\t\tDELETE btu, tr\n\t\tFROM " . BB_BT_USERS . " btu\n\t\tLEFT JOIN " . BB_BT_TRACKER . " tr  ON(tr.user_id = btu.user_id)\n\t\tWHERE btu.user_id IN({$user_csv})\n\t");
    // PM
    DB()->query("\n\t\tDELETE pm, pmt\n\t\tFROM " . BB_PRIVMSGS . " pm\n\t\tLEFT JOIN " . BB_PRIVMSGS_TEXT . " pmt ON(pmt.privmsgs_text_id = pm.privmsgs_id)\n\t\tWHERE pm.privmsgs_from_userid IN({$user_csv})\n\t\t\tAND pm.privmsgs_type IN(" . PRIVMSGS_SENT_MAIL . ',' . PRIVMSGS_SAVED_OUT_MAIL . ")\n\t");
    DB()->query("\n\t\tDELETE pm, pmt\n\t\tFROM " . BB_PRIVMSGS . " pm\n\t\tLEFT JOIN " . BB_PRIVMSGS_TEXT . " pmt ON(pmt.privmsgs_text_id = pm.privmsgs_id)\n\t\tWHERE pm.privmsgs_to_userid IN({$user_csv})\n\t\t\tAND pm.privmsgs_type IN(" . PRIVMSGS_READ_MAIL . ',' . PRIVMSGS_SAVED_IN_MAIL . ")\n\t");
    DB()->query("UPDATE " . BB_PRIVMSGS . " SET privmsgs_from_userid = " . DELETED . " WHERE privmsgs_from_userid IN({$user_csv})");
    DB()->query("UPDATE " . BB_PRIVMSGS . " SET privmsgs_to_userid = " . DELETED . " WHERE privmsgs_to_userid IN({$user_csv})");
    // Delete user feed
    foreach (explode(',', $user_csv) as $user_id) {
        $file_path = $bb_cfg['atom']['path'] . '/u/' . floor($user_id / 5000) . '/' . $user_id % 100 . '/' . $user_id . '.atom';
        @unlink($file_path);
    }
}
Example #17
0
                     unset($cur_moderators[$username]);
                     unset($cur_moderators['groups'][$uid_stay]);
                     if (empty($cur_moderators['groups'])) {
                         unset($cur_moderators['groups']);
                     }
                     $cur_moderators = !empty($cur_moderators) ? serialize($cur_moderators) : null;
                     $update = array('moderators' => $cur_moderators);
                 } else {
                     $cur_moderators['groups'][$id] = $user_merge['group_id'];
                     $update = array('moderators' => serialize($cur_moderators));
                 }
                 $db->update('forums', $update, 'id=:id', $data);
             }
         }
     }
     delete_avatar($uid_merge);
     require PANTHER_ROOT . 'include/email.php';
     $info = array('message' => array('<username>' => $user_merge['username'], '<password>' => $new_password, '<admin>' => $panther_user['username'], '<merged_user>' => $user_stay['username']));
     $mail_tpl = $mailer->parse(PANTHER_ROOT . 'lang/' . $panther_user['language'] . '/mail_templates/account_merged_full.tpl', $info);
     $mailer->send($user_merge['email'], $mail_subject, $mail_message);
     $info = array('message' => array('<username>' => $user_stay['username'], '<password>' => $new_password, '<admin>' => $panther_user['username'], '<merged_user>' => $user_merge['username']));
     $mail_tpl = $mailer->parse(PANTHER_ROOT . 'lang/' . $panther_user['language'] . '/mail_templates/account_merged.tpl', $info);
     $mailer->send($user_stay['email'], $mail_subject, $mail_message);
     $data = array(':id' => $uid_merge);
     //Finally, the very last thing we do is delete the old user..
     $db->delete('users', 'id=:id', $data);
     generate_users_info_cache();
     redirect(panther_link($panther_url['admin_maintenance']), $lang_admin_maintenance['users merged redirect']);
 }
 $data = array(':id' => $uid_merge);
 $ps = $db->select('users', 'username', $data, 'id=:id');
Example #18
0
 public function delete_user($id)
 {
     global $lang_profile;
     // Get the username and group of the user we are deleting
     $select_info_delete_user = array('group_id', 'username');
     $result = DB::for_table('users')->where('id', $id)->select_many($select_info_delete_user)->find_one();
     $group_id = $result['group_id'];
     $username = $result['username'];
     if ($group_id == FEATHER_ADMIN) {
         message($lang_profile['No delete admin message']);
     }
     if ($this->request->post('delete_user_comply')) {
         // If the user is a moderator or an administrator, we remove him/her from the moderator list in all forums as well
         $group_mod = DB::for_table('groups')->where('g_id', $group_id)->find_one_col('g_moderator');
         if ($group_id == FEATHER_ADMIN || $group_mod == '1') {
             $select_info_delete_moderators = array('id', 'moderators');
             $result = DB::for_table('forums')->select_many($select_info_delete_moderators)->find_many();
             foreach ($result as $cur_forum) {
                 $cur_moderators = $cur_forum['moderators'] != '' ? unserialize($cur_forum['moderators']) : array();
                 if (in_array($id, $cur_moderators)) {
                     unset($cur_moderators[$username]);
                     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('user_id', $id)->delete_many();
         DB::for_table('forum_subscriptions')->where('user_id', $id)->delete_many();
         // Remove him/her from the online list (if they happen to be logged in)
         DB::for_table('online')->where('user_id', $id)->delete_many();
         // Should we delete all posts made by this user?
         if ($this->request->post('delete_posts')) {
             require FEATHER_ROOT . 'include/search_idx.php';
             // Hold on, this could take some time!
             @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', $id)->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 his/her posts to guest
             DB::for_table('posts')->where_in('poster_id', '1')->update_many('poster_id', $id);
         }
         // Delete the user
         DB::for_table('users')->where('id', $id)->delete_many();
         // Delete user avatar
         delete_avatar($id);
         // Regenerate the users info cache
         if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) {
             require FEATHER_ROOT . 'include/cache.php';
         }
         generate_users_info_cache();
         if ($group_id == FEATHER_ADMIN) {
             generate_admins_cache();
         }
         redirect(get_base_url(), $lang_profile['User delete redirect']);
     }
 }