/** * Show all IP addresses a user has used * * @return @e void [Outputs to screen] */ protected function _showIPs() { if (!$this->request['name'] and !$this->request['member_id']) { $this->_toolsIndex($this->lang->words['t_noname']); return false; } if ($this->request['member_id']) { $member = $this->DB->buildAndFetch(array('select' => 'member_id, members_display_name, email, ip_address', 'from' => 'members', 'where' => "member_id=" . intval($this->request['member_id']))); if (!$member['member_id']) { $this->_toolsIndex(sprintf($this->lang->words['t_nonameloc'], intval($this->request['member_id']))); return; } } else { $member = $this->DB->buildAndFetch(array('select' => 'member_id, members_display_name, email, ip_address', 'from' => 'members', 'where' => "members_l_username='******'name'])) . "' OR members_l_display_name='" . $this->DB->addSlashes(mb_strtolower($this->request['name'])) . "'")); if (!$member['member_id']) { $this->_toolsIndex($this->lang->words['t_noexact'], strtolower($this->request['name'])); return; } } $master = array(); $ips = array(); $reg = array(); $allips = IPSMember::findIPAddresses($member['member_id']); $totalips = count($allips); $newips = array(); $st = intval($this->request['st']) >= 0 ? intval($this->request['st']) : 0; $end = 50; $links = $this->registry->output->generatePagination(array('totalItems' => count($allips), 'itemsPerPage' => $end, 'currentStartValue' => $st, 'baseUrl' => $this->settings['base_url'] . $this->form_code . "&do=show_all_ips&member_id={$member['member_id']}")); //----------------------------------------- // Pseudo-pagination and ordering //----------------------------------------- foreach ($allips as $ip => $ipdata) { $newips[$ipdata[1]] = array($ip, $ipdata); } krsort($newips); $newips = array_slice($newips, $st, $end); $allips = array(); foreach ($newips as $ipdate => $ip_to_data) { $allips[$ip_to_data[0]] = $ip_to_data[1]; } if (count($allips) > 0) { foreach ($allips as $ip_address => $count) { $ips[] = "'" . $ip_address . "'"; } $this->DB->build(array('select' => 'ip_address', 'from' => 'members', 'where' => "ip_address IN (" . implode(",", $ips) . ") AND member_id != {$member['member_id']}")); $this->DB->execute(); while ($i = $this->DB->fetch()) { $reg[$i['ip_address']][] = 1; } } $this->registry->output->html .= $this->html->showAllIPs($member, $allips, $links, $reg, $totalips); }
/** * Ban a member [process] * * @access private * @return void [Outputs to screen] */ private function _memberBanDo() { $this->request['member_id'] = intval($this->request['member_id']); if (!$this->request['member_id']) { $this->registry->output->showError($this->lang->words['m_specify'], 11228); } $member = IPSMember::load($this->request['member_id']); if (!$member['member_id']) { $this->registry->output->showError($this->lang->words['m_noid'], 11229); } //----------------------------------------- // Allowed to ban administrators? //----------------------------------------- if ($member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_ban_admin')) { $this->registry->output->global_message = $this->lang->words['m_banadmin']; $this->_memberView(); return; } //----------------------------------------- // Check ban settings... //----------------------------------------- $ban_filters = array('email' => array(), 'name' => array(), 'ip' => array()); $email_banned = false; $ip_banned = array(); $name_banned = false; //----------------------------------------- // Grab existing ban filters //----------------------------------------- $this->DB->build(array('select' => '*', 'from' => 'banfilters')); $this->DB->execute(); while ($r = $this->DB->fetch()) { $ban_filters[$r['ban_type']][] = $r['ban_content']; } //----------------------------------------- // Check name and email address //----------------------------------------- if (in_array($member['email'], $ban_filters['email'])) { $email_banned = true; } if (in_array($member['name'], $ban_filters['name'])) { $name_banned = true; } if ($this->request['ban__email'] and !$email_banned) { $this->DB->insert('banfilters', array('ban_type' => 'email', 'ban_content' => $member['email'], 'ban_date' => time())); } else { if (!$this->request['ban__email'] and $email_banned) { $this->DB->delete('banfilters', "ban_type='email' AND ban_content='{$member['email']}'"); } } if ($this->request['ban__member'] and !$member['member_banned']) { IPSMember::save($member['member_id'], array('core' => array('member_banned' => 1))); } else { if (!$this->request['ban__member'] and $member['member_banned']) { IPSMember::save($member['member_id'], array('core' => array('member_banned' => 0))); } } if ($this->request['ban__name'] and !$name_banned) { $this->DB->insert('banfilters', array('ban_type' => 'name', 'ban_content' => $member['name'], 'ban_date' => time())); } else { if (!$this->request['ban__name'] and $name_banned) { $this->DB->delete('banfilters', "ban_type='name' AND ban_content='{$member['name']}'"); } } if ($this->request['ban__note'] and $this->request['ban__note_field']) { //----------------------------------------- // Format note //----------------------------------------- $save['wlog_notes'] = "<content>{$this->request['ban__note_field']}</content>"; $save['wlog_notes'] .= "<mod></mod>"; $save['wlog_notes'] .= "<post></post>"; $save['wlog_notes'] .= "<susp></susp>"; $save['wlog_mid'] = $member['member_id']; $save['wlog_addedby'] = $this->memberData['member_id']; $save['wlog_type'] = 'note'; $save['wlog_date'] = time(); //----------------------------------------- // Enter into warn loggy poos (eeew - poo) //----------------------------------------- $this->DB->insert('warn_logs', $save); } //----------------------------------------- // Retrieve IP addresses //----------------------------------------- $ip_addresses = IPSMember::findIPAddresses($member['member_id']); //----------------------------------------- // What about IPs? //----------------------------------------- if (is_array($ip_addresses) and count($ip_addresses)) { foreach ($ip_addresses as $ip_address => $count) { if (in_array($ip_address, $ban_filters['ip'])) { if (!$this->request['ban__ip_' . str_replace('.', '_', $ip_address)]) { $this->DB->delete('banfilters', "ban_type='ip' AND ban_content='{$ip_address}'"); } } else { if ($this->request['ban__ip_' . str_replace('.', '_', $ip_address)]) { $this->DB->insert('banfilters', array('ban_type' => 'ip', 'ban_content' => $ip_address, 'ban_date' => time())); } } } } if ($this->request['ban__group'] and $this->request['ban__group_change'] and $this->request['ban__group'] != $member['member_group_id']) { IPSMember::save($member['member_id'], array('core' => array('member_group_id' => intval($this->request['ban__group'])))); } //----------------------------------------- // Redirect //----------------------------------------- ipsRegistry::getClass('adminFunctions')->saveAdminLog(sprintf($this->lang->words['m_bannedlog'], $member['members_display_name'])); $this->registry->output->doneScreen($this->lang->words['m_banned'], $this->lang->words['m_search'], "{$this->form_code}&do=viewmember&member_id={$member['member_id']}", "redirect"); }
/** * Show the form * * @return @e void [Outputs to screen] */ protected function show() { //----------------------------------------- // INIT //----------------------------------------- $name = trim(IPSText::alphanumericalClean($this->request['name'])); $member_id = intval($this->request['member_id']); $output = ''; //----------------------------------------- // Load language and skin //----------------------------------------- $html = $this->registry->output->loadTemplate('cp_skin_member_form'); $this->lang->loadLanguageFile(array('admin_member')); //----------------------------------------- // Get member data //----------------------------------------- $member = IPSMember::load($member_id, 'extendedProfile,customFields'); //----------------------------------------- // Got a member? //----------------------------------------- if (!$member['member_id']) { $this->returnJsonError($this->lang->words['m_noid']); } //----------------------------------------- // Return the form //----------------------------------------- if (method_exists($html, $name)) { $output = $html->{$name}($member); } else { $save_to = ''; $div_id = ''; $form_field = ''; $text = ''; $description = ''; $method = ''; switch ($name) { case 'inline_ban_member': if (!$this->registry->getClass('class_permissions')->checkPermission('member_ban', 'members', 'members')) { $this->returnJsonError($this->lang->words['m_noban']); } if ($member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_ban_admin', 'members', 'members')) { $this->returnJsonError($this->lang->words['m_noban']); } //----------------------------------------- // INIT //----------------------------------------- $ban_filters = array('email' => array(), 'name' => array(), 'ip' => array()); $email_banned = false; $ip_banned = array(); $name_banned = false; //----------------------------------------- // Grab existing ban filters //----------------------------------------- $this->DB->build(array('select' => '*', 'from' => 'banfilters')); $this->DB->execute(); while ($r = $this->DB->fetch()) { $ban_filters[$r['ban_type']][] = $r['ban_content']; } //----------------------------------------- // Check name and email address //----------------------------------------- if (in_array($member['email'], $ban_filters['email'])) { $email_banned = true; } if (in_array($member['name'], $ban_filters['name'])) { $name_banned = true; } //----------------------------------------- // Retrieve IP addresses //----------------------------------------- $ip_addresses = IPSMember::findIPAddresses($member['member_id']); //----------------------------------------- // Start form fields //----------------------------------------- $form['member'] = ipsRegistry::getClass('output')->formCheckbox("ban__member", $member['member_banned']); $form['email'] = ipsRegistry::getClass('output')->formCheckbox("ban__email", $email_banned); $form['name'] = ipsRegistry::getClass('output')->formCheckbox("ban__name", $name_banned); $form['note'] = ipsRegistry::getClass('output')->formCheckbox("ban__note", 0); $form['note_field'] = ipsRegistry::getClass('output')->formTextarea("ban__note_field"); $form['ips'] = array(); //----------------------------------------- // What about IPs? //----------------------------------------- if (is_array($ip_addresses) and count($ip_addresses)) { foreach ($ip_addresses as $ip_address => $count) { if (in_array($ip_address, $ban_filters['ip'])) { $form['ips'][$ip_address] = ipsRegistry::getClass('output')->formCheckbox("ban__ip_" . str_replace('.', '_', $ip_address), true); } else { $form['ips'][$ip_address] = ipsRegistry::getClass('output')->formCheckbox("ban__ip_" . str_replace('.', '_', $ip_address), false); } } } $member_groups = array(); foreach (ipsRegistry::cache()->getCache('group_cache') as $group) { if ($group['g_id'] == $member['member_group_id']) { $member['_group_title'] = $group['g_title']; } /* If it's an admin group, make sure the admin banning can promote to this group */ if ($group['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_move_admin2')) { continue; } $member_groups[] = array($group['g_id'], $group['g_title']); } $form['groups_confirm'] = ipsRegistry::getClass('output')->formCheckbox("ban__group_change", 0); $form['groups'] = ipsRegistry::getClass('output')->formDropdown("ban__group", $member_groups, $member['member_group_id']); $output = $html->inline_ban_member_form($member, $form); break; } if (!$output and $method and method_exists($html, $method)) { $output = $html->{$method}($member, $save_to, $div_id, $form_field, $text, $description); } } //----------------------------------------- // Print... //----------------------------------------- $this->returnHtml($output); }
/** * Ban a member [process] * * @return @e void */ protected function _memberBanDo() { $this->request['member_id'] = intval($this->request['member_id']); if (!$this->request['member_id']) { $this->registry->output->showError($this->lang->words['m_specify'], 11228); } $member = IPSMember::load($this->request['member_id']); if (!$member['member_id']) { $this->registry->output->showError($this->lang->words['m_noid'], 11229); } //----------------------------------------- // Allowed to ban administrators? //----------------------------------------- if ($member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_ban_admin')) { $this->registry->output->global_message = $this->lang->words['m_banadmin']; $this->_memberView(); return; } //----------------------------------------- // Are we banning ourselves ? //----------------------------------------- if ($member['member_id'] == $this->memberData['member_id']) { $this->registry->output->global_message = $this->lang->words['m_banyourself']; $this->_memberView(); return; } //----------------------------------------- // What about demoting or promoting ? //----------------------------------------- if ($this->request['ban__group'] != $member['member_group_id'] && $this->request['ban__group_change']) { // Demote if ($member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_move_admin1')) { $this->registry->output->global_message = $this->lang->words['m_admindemote']; $this->_memberView(); return; } // Promote if (!$member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_move_admin2')) { if ($this->caches['group_cache'][$this->request['ban__group']]['g_access_cp']) { $this->registry->output->global_message = $this->lang->words['m_adminpromote']; $this->_memberView(); return; } } } //----------------------------------------- // Check ban settings... //----------------------------------------- $ban_filters = array('email' => array(), 'name' => array(), 'ip' => array()); $email_banned = false; $ip_banned = array(); $name_banned = false; //----------------------------------------- // Grab existing ban filters //----------------------------------------- $this->DB->build(array('select' => '*', 'from' => 'banfilters')); $this->DB->execute(); while ($r = $this->DB->fetch()) { $ban_filters[$r['ban_type']][] = $r['ban_content']; } //----------------------------------------- // Check name and email address //----------------------------------------- if (in_array($member['email'], $ban_filters['email'])) { $email_banned = true; } if (in_array($member['name'], $ban_filters['name'])) { $name_banned = true; } if ($this->request['ban__email'] and !$email_banned) { $this->DB->insert('banfilters', array('ban_type' => 'email', 'ban_content' => $member['email'], 'ban_date' => time())); } else { if (!$this->request['ban__email'] and $email_banned) { $this->DB->delete('banfilters', "ban_type='email' AND ban_content='{$member['email']}'"); } } if ($this->request['ban__member'] and !$member['member_banned']) { IPSMember::save($member['member_id'], array('core' => array('member_banned' => 1))); } else { if (!$this->request['ban__member'] and $member['member_banned']) { IPSMember::save($member['member_id'], array('core' => array('member_banned' => 0))); /* Also update warn logs to -2 @link http://community.invisionpower.com/resources/bugs.html/_/ip-board/banning-a-member-from-the-acp-shows-the-user-an-incorrect-more-details-link-r42079 */ $this->DB->update('members_warn_logs', array('wl_suspend' => '-2'), "wl_suspend=-1 AND wl_member=" . $member['member_id']); } } if ($this->request['ban__name'] and !$name_banned) { $this->DB->insert('banfilters', array('ban_type' => 'name', 'ban_content' => $member['name'], 'ban_date' => time())); } else { if (!$this->request['ban__name'] and $name_banned) { $this->DB->delete('banfilters', "ban_type='name' AND ban_content='{$member['name']}'"); } } //----------------------------------------- // Retrieve IP addresses //----------------------------------------- $ip_addresses = IPSMember::findIPAddresses($member['member_id']); //----------------------------------------- // What about IPs? //----------------------------------------- if (is_array($ip_addresses) and count($ip_addresses)) { foreach ($ip_addresses as $ip_address => $count) { if (in_array($ip_address, $ban_filters['ip'])) { if (!$this->request['ban__ip_' . str_replace('.', '_', $ip_address)]) { $this->DB->delete('banfilters', "ban_type='ip' AND ban_content='{$ip_address}'"); } } else { if ($this->request['ban__ip_' . str_replace('.', '_', $ip_address)]) { $this->DB->insert('banfilters', array('ban_type' => 'ip', 'ban_content' => $ip_address, 'ban_date' => time())); } } } } if ($this->request['ban__group'] and $this->request['ban__group_change'] and $this->request['ban__group'] != $member['member_group_id']) { IPSMember::save($member['member_id'], array('core' => array('member_group_id' => intval($this->request['ban__group'])))); /* Group has been changed! */ IPSLib::runMemberSync('onGroupChange', $member['member_id'], intval($this->request['ban__group']), $member['member_group_id']); } /* Rebuild the cache */ $this->cache->rebuildCache('banfilters', 'global'); //----------------------------------------- // Redirect //----------------------------------------- ipsRegistry::getClass('adminFunctions')->saveAdminLog(sprintf($this->lang->words['m_bannedlog'], $member['members_display_name'])); $this->registry->output->global_message = $this->lang->words['m_banned']; $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . '&do=viewmember&member_id=' . $member['member_id']); }