本文整理汇总了PHP中user_ban函数的典型用法代码示例。如果您正苦于以下问题:PHP user_ban函数的具体用法?PHP user_ban怎么用?PHP user_ban使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了user_ban函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
function main($id, $mode)
{
global $config, $db, $user, $auth, $template, $cache;
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix;
include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
$bansubmit = isset($_POST['bansubmit']) ? true : false;
$unbansubmit = isset($_POST['unbansubmit']) ? true : false;
$current_time = time();
$user->add_lang(array('acp/ban', 'acp/users'));
$this->tpl_name = 'acp_ban';
$form_key = 'acp_ban';
add_form_key($form_key);
if (($bansubmit || $unbansubmit) && !check_form_key($form_key)) {
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}
// Ban submitted?
if ($bansubmit) {
// Grab the list of entries
$ban = utf8_normalize_nfc(request_var('ban', '', true));
$ban_len = request_var('banlength', 0);
$ban_len_other = request_var('banlengthother', '');
$ban_exclude = request_var('banexclude', 0);
$ban_reason = utf8_normalize_nfc(request_var('banreason', '', true));
$ban_give_reason = utf8_normalize_nfc(request_var('bangivereason', '', true));
if ($ban) {
user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reason, $ban_give_reason);
trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . adm_back_link($this->u_action));
}
} else {
if ($unbansubmit) {
$ban = request_var('unban', array(''));
if ($ban) {
user_unban($mode, $ban);
trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . adm_back_link($this->u_action));
}
}
}
// Define language vars
$this->page_title = $user->lang[strtoupper($mode) . '_BAN'];
$l_ban_explain = $user->lang[strtoupper($mode) . '_BAN_EXPLAIN'];
$l_ban_exclude_explain = $user->lang[strtoupper($mode) . '_BAN_EXCLUDE_EXPLAIN'];
$l_unban_title = $user->lang[strtoupper($mode) . '_UNBAN'];
$l_unban_explain = $user->lang[strtoupper($mode) . '_UNBAN_EXPLAIN'];
$l_no_ban_cell = $user->lang[strtoupper($mode) . '_NO_BANNED'];
switch ($mode) {
case 'user':
$l_ban_cell = $user->lang['USERNAME'];
break;
case 'ip':
$l_ban_cell = $user->lang['IP_HOSTNAME'];
break;
case 'email':
$l_ban_cell = $user->lang['EMAIL_ADDRESS'];
break;
}
$this->display_ban_options($mode);
$template->assign_vars(array('L_TITLE' => $this->page_title, 'L_EXPLAIN' => $l_ban_explain, 'L_UNBAN_TITLE' => $l_unban_title, 'L_UNBAN_EXPLAIN' => $l_unban_explain, 'L_BAN_CELL' => $l_ban_cell, 'L_BAN_EXCLUDE_EXPLAIN' => $l_ban_exclude_explain, 'L_NO_BAN_CELL' => $l_no_ban_cell, 'S_USERNAME_BAN' => $mode == 'user' ? true : false, 'U_ACTION' => $this->u_action, 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=searchuser&form=acp_ban&field=ban')));
}
示例2: main
function main($id, $mode)
{
global $config, $db, $user, $auth, $template, $cache;
global $phpbb_root_path, $phpEx;
include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
// Include the admin banning interface...
include $phpbb_root_path . 'includes/acp/acp_ban.' . $phpEx;
$bansubmit = isset($_POST['bansubmit']) ? true : false;
$unbansubmit = isset($_POST['unbansubmit']) ? true : false;
$current_time = time();
$user->add_lang('acp/ban');
$this->tpl_name = 'mcp_ban';
// Ban submitted?
if ($bansubmit) {
// Grab the list of entries
$ban = request_var('ban', '');
$ban_len = request_var('banlength', 0);
$ban_len_other = request_var('banlengthother', '');
$ban_exclude = request_var('banexclude', 0);
$ban_reason = request_var('banreason', '', true);
$ban_give_reason = request_var('bangivereason', '', true);
user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reason, $ban_give_reason);
trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . '<br /><br /><a href="' . $this->u_action . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>');
} else {
if ($unbansubmit) {
$ban = request_var('unban', array(''));
user_unban($mode, $ban);
trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . '<br /><br /><a href="' . $this->u_action . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>');
}
}
// Ban length options
$ban_end_text = array(0 => $user->lang['PERMANENT'], 30 => $user->lang['30_MINS'], 60 => $user->lang['1_HOUR'], 360 => $user->lang['6_HOURS'], 1440 => $user->lang['1_DAY'], 10080 => $user->lang['7_DAYS'], 20160 => $user->lang['2_WEEKS'], 40320 => $user->lang['1_MONTH'], -1 => $user->lang['UNTIL'] . ' -> ');
$ban_end_options = '';
foreach ($ban_end_text as $length => $text) {
$ban_end_options .= '<option value="' . $length . '">' . $text . '</option>';
}
// Define language vars
$this->page_title = $user->lang[strtoupper($mode) . '_BAN'];
$l_ban_explain = $user->lang[strtoupper($mode) . '_BAN_EXPLAIN'];
$l_ban_exclude_explain = $user->lang[strtoupper($mode) . '_BAN_EXCLUDE_EXPLAIN'];
$l_unban_title = $user->lang[strtoupper($mode) . '_UNBAN'];
$l_unban_explain = $user->lang[strtoupper($mode) . '_UNBAN_EXPLAIN'];
$l_no_ban_cell = $user->lang[strtoupper($mode) . '_NO_BANNED'];
switch ($mode) {
case 'user':
$l_ban_cell = $user->lang['USERNAME'];
break;
case 'ip':
$l_ban_cell = $user->lang['IP_HOSTNAME'];
break;
case 'email':
$l_ban_cell = $user->lang['EMAIL_ADDRESS'];
break;
}
acp_ban::display_ban_options($mode);
$template->assign_vars(array('L_TITLE' => $this->page_title, 'L_EXPLAIN' => $l_ban_explain, 'L_UNBAN_TITLE' => $l_unban_title, 'L_UNBAN_EXPLAIN' => $l_unban_explain, 'L_BAN_CELL' => $l_ban_cell, 'L_BAN_EXCLUDE_EXPLAIN' => $l_ban_exclude_explain, 'L_NO_BAN_CELL' => $l_no_ban_cell, 'S_USERNAME_BAN' => $mode == 'user' ? true : false, 'U_ACTION' => $this->u_action, 'U_FIND_USER' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=searchuser&form=mcp_ban&field=ban')));
}
示例3: post_funct
public function post_funct($event)
{
if ($this->config['autoban_active'] && $event['user_row']['user_warnings'] + 1 >= $this->config['autoban_count']) {
if (!function_exists('user_ban')) {
include $this->root_path . 'includes/functions_user.' . $this->php_ext;
}
user_ban('user', utf8_normalize_nfc($event['user_row']['username']), $this->config['autoban_duration'] * 60 * 24, '', '', $this->config['autoban_reason'], $this->config['autoban_reason']);
}
}
示例4: main
function main($id, $mode)
{
global $config, $db, $user, $auth, $template, $cache;
global $phpbb_root_path, $phpEx;
include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
// Include the admin banning interface...
include $phpbb_root_path . 'includes/acp/acp_ban.' . $phpEx;
$bansubmit = isset($_POST['bansubmit']) ? true : false;
$unbansubmit = isset($_POST['unbansubmit']) ? true : false;
$current_time = time();
$user->add_lang(array('acp/ban', 'acp/users'));
$this->tpl_name = 'mcp_ban';
// Ban submitted?
if ($bansubmit) {
// Grab the list of entries
$ban = request_var('ban', '', $mode === 'user' ? true : false);
if ($mode === 'user') {
$ban = utf8_normalize_nfc($ban);
}
$ban_len = request_var('banlength', 0);
$ban_len_other = request_var('banlengthother', '');
$ban_exclude = request_var('banexclude', 0);
$ban_reason = utf8_normalize_nfc(request_var('banreason', '', true));
$ban_give_reason = utf8_normalize_nfc(request_var('bangivereason', '', true));
if ($ban) {
if (confirm_box(true)) {
user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reason, $ban_give_reason);
trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . '<br /><br /><a href="' . $this->u_action . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>');
} else {
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('mode' => $mode, 'ban' => $ban, 'bansubmit' => true, 'banlength' => $ban_len, 'banlengthother' => $ban_len_other, 'banexclude' => $ban_exclude, 'banreason' => $ban_reason, 'bangivereason' => $ban_give_reason)));
}
}
} else {
if ($unbansubmit) {
$ban = request_var('unban', array(''));
if ($ban) {
if (confirm_box(true)) {
user_unban($mode, $ban);
trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . '<br /><br /><a href="' . $this->u_action . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>');
} else {
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('mode' => $mode, 'unbansubmit' => true, 'unban' => $ban)));
}
}
}
}
// Ban length options
$ban_end_text = array(0 => $user->lang['PERMANENT'], 30 => $user->lang['30_MINS'], 60 => $user->lang['1_HOUR'], 360 => $user->lang['6_HOURS'], 1440 => $user->lang['1_DAY'], 10080 => $user->lang['7_DAYS'], 20160 => $user->lang['2_WEEKS'], 40320 => $user->lang['1_MONTH'], -1 => $user->lang['UNTIL'] . ' -> ');
$ban_end_options = '';
foreach ($ban_end_text as $length => $text) {
$ban_end_options .= '<option value="' . $length . '">' . $text . '</option>';
}
// Define language vars
$this->page_title = $user->lang[strtoupper($mode) . '_BAN'];
$l_ban_explain = $user->lang[strtoupper($mode) . '_BAN_EXPLAIN'];
$l_ban_exclude_explain = $user->lang[strtoupper($mode) . '_BAN_EXCLUDE_EXPLAIN'];
$l_unban_title = $user->lang[strtoupper($mode) . '_UNBAN'];
$l_unban_explain = $user->lang[strtoupper($mode) . '_UNBAN_EXPLAIN'];
$l_no_ban_cell = $user->lang[strtoupper($mode) . '_NO_BANNED'];
switch ($mode) {
case 'user':
$l_ban_cell = $user->lang['USERNAME'];
break;
case 'ip':
$l_ban_cell = $user->lang['IP_HOSTNAME'];
break;
case 'email':
$l_ban_cell = $user->lang['EMAIL_ADDRESS'];
break;
}
acp_ban::display_ban_options($mode);
$template->assign_vars(array('L_TITLE' => $this->page_title, 'L_EXPLAIN' => $l_ban_explain, 'L_UNBAN_TITLE' => $l_unban_title, 'L_UNBAN_EXPLAIN' => $l_unban_explain, 'L_BAN_CELL' => $l_ban_cell, 'L_BAN_EXCLUDE_EXPLAIN' => $l_ban_exclude_explain, 'L_NO_BAN_CELL' => $l_no_ban_cell, 'S_USERNAME_BAN' => $mode == 'user' ? true : false, 'U_ACTION' => $this->u_action, 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=searchuser&form=mcp_ban&field=ban')));
if ($mode === 'email' && !$auth->acl_get('a_user')) {
return;
}
// As a "service" we will check if any post id is specified and populate the username of the poster id if given
$post_id = request_var('p', 0);
$user_id = request_var('u', 0);
$username = $pre_fill = false;
if ($user_id && $user_id != ANONYMOUS) {
$sql = 'SELECT username, user_email, user_ip
FROM ' . USERS_TABLE . '
WHERE user_id = ' . $user_id;
$result = $db->sql_query($sql);
switch ($mode) {
case 'user':
$pre_fill = (string) $db->sql_fetchfield('username');
break;
case 'ip':
$pre_fill = (string) $db->sql_fetchfield('user_ip');
break;
case 'email':
$pre_fill = (string) $db->sql_fetchfield('user_email');
break;
}
$db->sql_freeresult($result);
} else {
if ($post_id) {
$post_info = get_post_data($post_id, 'm_ban');
if (sizeof($post_info) && !empty($post_info[$post_id])) {
switch ($mode) {
//.........这里部分代码省略.........
示例5: main
//.........这里部分代码省略.........
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'update' => true, 'delete' => 1, 'delete_type' => $delete_type)));
}
}
// Handle quicktool actions
switch ($action) {
case 'banuser':
case 'banemail':
case 'banip':
$ban = array();
switch ($action) {
case 'banuser':
$ban[] = $user_row['username'];
$reason = 'USER_ADMIN_BAN_NAME_REASON';
$log = 'LOG_USER_BAN_USER';
break;
case 'banemail':
$ban[] = $user_row['user_email'];
$reason = 'USER_ADMIN_BAN_EMAIL_REASON';
$log = 'LOG_USER_BAN_EMAIL';
break;
case 'banip':
$ban[] = $user_row['user_ip'];
$sql = 'SELECT DISTINCT poster_ip
FROM ' . POSTS_TABLE . "\n\t\t\t\t\t\t\t\t\t\tWHERE poster_id = {$user_id}";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$ban[] = $row['poster_ip'];
}
$db->sql_freeresult($result);
$reason = 'USER_ADMIN_BAN_IP_REASON';
$log = 'LOG_USER_BAN_IP';
break;
}
user_ban(substr($action, 3), $ban, 0, 0, 0, $user->lang[$reason]);
add_log('admin', $log, $user->lang[$reason]);
add_log('user', $user_id, $log, $user->lang[$reason]);
trigger_error($user->lang['BAN_SUCCESSFUL'] . adm_back_link($this->u_action . '&u=' . $user_id));
break;
case 'reactivate':
if ($config['email_enable']) {
include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
$server_url = generate_board_url();
$user_actkey = gen_rand_string(10);
$key_len = 54 - strlen($server_url);
$key_len = $key_len > 6 ? $key_len : 6;
$user_actkey = substr($user_actkey, 0, $key_len);
if ($user_row['user_type'] != USER_INACTIVE) {
user_active_flip($user_id, $user_row['user_type'], $user_actkey, $user_row['username']);
}
$messenger = new messenger(false);
$messenger->template('user_resend_inactive', $user_row['user_lang']);
$messenger->replyto($config['board_contact']);
$messenger->to($user_row['user_email'], $user_row['username']);
$messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
$messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
$messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
$messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
$messenger->assign_vars(array('SITENAME' => $config['sitename'], 'WELCOME_MSG' => sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename']), 'USERNAME' => html_entity_decode($user_row['username']), 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']), 'U_ACTIVATE' => "{$server_url}/ucp.{$phpEx}?mode=activate&u={$user_row['user_id']}&k={$user_actkey}"));
$messenger->send(NOTIFY_EMAIL);
add_log('admin', 'LOG_USER_REACTIVATE', $user_row['username']);
add_log('user', $user_id, 'LOG_USER_REACTIVATE_USER');
trigger_error($user->lang['FORCE_REACTIVATION_SUCCESS'] . adm_back_link($this->u_action . '&u=' . $user_id));
}
break;
case 'active':
user_active_flip($user_id, $user_row['user_type'], false, $user_row['username']);
示例6: main
function main($id, $mode)
{
global $db, $user, $auth, $template, $request, $phpbb_dispatcher;
global $phpbb_root_path, $phpEx;
include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
// Include the admin banning interface...
include $phpbb_root_path . 'includes/acp/acp_ban.' . $phpEx;
$bansubmit = $request->is_set_post('bansubmit');
$unbansubmit = $request->is_set_post('unbansubmit');
$user->add_lang(array('acp/ban', 'acp/users'));
$this->tpl_name = 'mcp_ban';
/**
* Use this event to pass perform actions when a ban is issued or revoked
*
* @event core.mcp_ban_main
* @var bool bansubmit True if a ban is issued
* @var bool unbansubmit True if a ban is removed
* @var string mode Mode of the ban that is being worked on
* @since 3.1.0-RC5
*/
$vars = array('bansubmit', 'unbansubmit', 'mode');
extract($phpbb_dispatcher->trigger_event('core.mcp_ban_main', compact($vars)));
// Ban submitted?
if ($bansubmit) {
// Grab the list of entries
$ban = $request->variable('ban', '', $mode === 'user');
$ban_length = $request->variable('banlength', 0);
$ban_length_other = $request->variable('banlengthother', '');
$ban_exclude = $request->variable('banexclude', 0);
$ban_reason = $request->variable('banreason', '', true);
$ban_give_reason = $request->variable('bangivereason', '', true);
if ($ban) {
if (confirm_box(true)) {
$abort_ban = false;
/**
* Use this event to modify the ban details before the ban is performed
*
* @event core.mcp_ban_before
* @var string mode One of the following: user, ip, email
* @var string ban Either string or array with usernames, ips or email addresses
* @var int ban_length Ban length in minutes
* @var string ban_length_other Ban length as a date (YYYY-MM-DD)
* @var bool ban_exclude Are we banning or excluding from another ban
* @var string ban_reason Ban reason displayed to moderators
* @var string ban_give_reason Ban reason displayed to the banned user
* @var mixed abort_ban Either false, or an error message that is displayed to the user.
* If a string is given the bans are not issued.
* @since 3.1.0-RC5
*/
$vars = array('mode', 'ban', 'ban_length', 'ban_length_other', 'ban_exclude', 'ban_reason', 'ban_give_reason', 'abort_ban');
extract($phpbb_dispatcher->trigger_event('core.mcp_ban_before', compact($vars)));
if ($abort_ban) {
trigger_error($abort_ban);
}
user_ban($mode, $ban, $ban_length, $ban_length_other, $ban_exclude, $ban_reason, $ban_give_reason);
/**
* Use this event to perform actions after the ban has been performed
*
* @event core.mcp_ban_after
* @var string mode One of the following: user, ip, email
* @var string ban Either string or array with usernames, ips or email addresses
* @var int ban_length Ban length in minutes
* @var string ban_length_other Ban length as a date (YYYY-MM-DD)
* @var bool ban_exclude Are we banning or excluding from another ban
* @var string ban_reason Ban reason displayed to moderators
* @var string ban_give_reason Ban reason displayed to the banned user
* @since 3.1.0-RC5
*/
$vars = array('mode', 'ban', 'ban_length', 'ban_length_other', 'ban_exclude', 'ban_reason', 'ban_give_reason');
extract($phpbb_dispatcher->trigger_event('core.mcp_ban_after', compact($vars)));
trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . '<br /><br /><a href="' . $this->u_action . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>');
} else {
$hidden_fields = array('mode' => $mode, 'ban' => $ban, 'bansubmit' => true, 'banlength' => $ban_length, 'banlengthother' => $ban_length_other, 'banexclude' => $ban_exclude, 'banreason' => $ban_reason, 'bangivereason' => $ban_give_reason);
/**
* Use this event to pass data from the ban form to the confirmation screen
*
* @event core.mcp_ban_confirm
* @var array hidden_fields Hidden fields that are passed through the confirm screen
* @since 3.1.0-RC5
*/
$vars = array('hidden_fields');
extract($phpbb_dispatcher->trigger_event('core.mcp_ban_confirm', compact($vars)));
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($hidden_fields));
}
}
} else {
if ($unbansubmit) {
$ban = $request->variable('unban', array(''));
if ($ban) {
if (confirm_box(true)) {
user_unban($mode, $ban);
trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . '<br /><br /><a href="' . $this->u_action . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>');
} else {
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('mode' => $mode, 'unbansubmit' => true, 'unban' => $ban)));
}
}
}
}
// Ban length options
$ban_end_text = array(0 => $user->lang['PERMANENT'], 30 => $user->lang['30_MINS'], 60 => $user->lang['1_HOUR'], 360 => $user->lang['6_HOURS'], 1440 => $user->lang['1_DAY'], 10080 => $user->lang['7_DAYS'], 20160 => $user->lang['2_WEEKS'], 40320 => $user->lang['1_MONTH'], -1 => $user->lang['UNTIL'] . ' -> ');
//.........这里部分代码省略.........
示例7: main
//.........这里部分代码省略.........
$reason = 'USER_ADMIN_BAN_NAME_REASON';
$log = 'LOG_USER_BAN_USER';
break;
case 'banemail':
$ban[] = $user_row['user_email'];
$reason = 'USER_ADMIN_BAN_EMAIL_REASON';
$log = 'LOG_USER_BAN_EMAIL';
break;
case 'banip':
$ban[] = $user_row['user_ip'];
$sql = 'SELECT DISTINCT poster_ip
FROM ' . POSTS_TABLE . "
WHERE poster_id = $user_id";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$ban[] = $row['poster_ip'];
}
$db->sql_freeresult($result);
$reason = 'USER_ADMIN_BAN_IP_REASON';
$log = 'LOG_USER_BAN_IP';
break;
}
$ban_reason = utf8_normalize_nfc(request_var('ban_reason', $user->lang[$reason], true));
$ban_give_reason = utf8_normalize_nfc(request_var('ban_give_reason', '', true));
// Log not used at the moment, we simply utilize the ban function.
$result = user_ban(substr($action, 3), $ban, 0, 0, 0, $ban_reason, $ban_give_reason);
trigger_error((($result === false) ? $user->lang['BAN_ALREADY_ENTERED'] : $user->lang['BAN_SUCCESSFUL']) . adm_back_link($this->u_action . '&u=' . $user_id));
break;
case 'reactivate':
if ($user_id == $user->data['user_id'])
{
trigger_error($user->lang['CANNOT_FORCE_REACT_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
}
if (!check_form_key($form_name))
{
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
}
if ($user_row['user_type'] == USER_FOUNDER)
{
trigger_error($user->lang['CANNOT_FORCE_REACT_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
}
if ($user_row['user_type'] == USER_IGNORE)
{
trigger_error($user->lang['CANNOT_FORCE_REACT_BOT'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
}
if ($config['email_enable'])
{
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
$server_url = generate_board_url();
示例8: main
function main($id, $mode)
{
global $user, $template, $request, $phpbb_dispatcher;
global $phpbb_root_path, $phpEx;
include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
$bansubmit = $request->is_set_post('bansubmit');
$unbansubmit = $request->is_set_post('unbansubmit');
$user->add_lang(array('acp/ban', 'acp/users'));
$this->tpl_name = 'acp_ban';
$form_key = 'acp_ban';
add_form_key($form_key);
if (($bansubmit || $unbansubmit) && !check_form_key($form_key)) {
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}
// Ban submitted?
if ($bansubmit) {
// Grab the list of entries
$ban = $request->variable('ban', '', true);
$ban_length = $request->variable('banlength', 0);
$ban_length_other = $request->variable('banlengthother', '');
$ban_exclude = $request->variable('banexclude', 0);
$ban_reason = $request->variable('banreason', '', true);
$ban_give_reason = $request->variable('bangivereason', '', true);
if ($ban) {
$abort_ban = false;
/**
* Use this event to modify the ban details before the ban is performed
*
* @event core.acp_ban_before
* @var string mode One of the following: user, ip, email
* @var string ban Either string or array with usernames, ips or email addresses
* @var int ban_length Ban length in minutes
* @var string ban_length_other Ban length as a date (YYYY-MM-DD)
* @var bool ban_exclude Are we banning or excluding from another ban
* @var string ban_reason Ban reason displayed to moderators
* @var string ban_give_reason Ban reason displayed to the banned user
* @var mixed abort_ban Either false, or an error message that is displayed to the user.
* If a string is given the bans are not issued.
* @since 3.1.0-RC5
*/
$vars = array('mode', 'ban', 'ban_length', 'ban_length_other', 'ban_exclude', 'ban_reason', 'ban_give_reason', 'abort_ban');
extract($phpbb_dispatcher->trigger_event('core.acp_ban_before', compact($vars)));
if ($abort_ban) {
trigger_error($abort_ban . adm_back_link($this->u_action));
}
user_ban($mode, $ban, $ban_length, $ban_length_other, $ban_exclude, $ban_reason, $ban_give_reason);
/**
* Use this event to perform actions after the ban has been performed
*
* @event core.acp_ban_after
* @var string mode One of the following: user, ip, email
* @var string ban Either string or array with usernames, ips or email addresses
* @var int ban_length Ban length in minutes
* @var string ban_length_other Ban length as a date (YYYY-MM-DD)
* @var bool ban_exclude Are we banning or excluding from another ban
* @var string ban_reason Ban reason displayed to moderators
* @var string ban_give_reason Ban reason displayed to the banned user
* @since 3.1.0-RC5
*/
$vars = array('mode', 'ban', 'ban_length', 'ban_length_other', 'ban_exclude', 'ban_reason', 'ban_give_reason');
extract($phpbb_dispatcher->trigger_event('core.acp_ban_after', compact($vars)));
trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . adm_back_link($this->u_action));
}
} else {
if ($unbansubmit) {
$ban = $request->variable('unban', array(''));
if ($ban) {
user_unban($mode, $ban);
trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . adm_back_link($this->u_action));
}
}
}
// Define language vars
$this->page_title = $user->lang[strtoupper($mode) . '_BAN'];
$l_ban_explain = $user->lang[strtoupper($mode) . '_BAN_EXPLAIN'];
$l_ban_exclude_explain = $user->lang[strtoupper($mode) . '_BAN_EXCLUDE_EXPLAIN'];
$l_unban_title = $user->lang[strtoupper($mode) . '_UNBAN'];
$l_unban_explain = $user->lang[strtoupper($mode) . '_UNBAN_EXPLAIN'];
$l_no_ban_cell = $user->lang[strtoupper($mode) . '_NO_BANNED'];
switch ($mode) {
case 'user':
$l_ban_cell = $user->lang['USERNAME'];
break;
case 'ip':
$l_ban_cell = $user->lang['IP_HOSTNAME'];
break;
case 'email':
$l_ban_cell = $user->lang['EMAIL_ADDRESS'];
break;
}
self::display_ban_options($mode);
$template->assign_vars(array('L_TITLE' => $this->page_title, 'L_EXPLAIN' => $l_ban_explain, 'L_UNBAN_TITLE' => $l_unban_title, 'L_UNBAN_EXPLAIN' => $l_unban_explain, 'L_BAN_CELL' => $l_ban_cell, 'L_BAN_EXCLUDE_EXPLAIN' => $l_ban_exclude_explain, 'L_NO_BAN_CELL' => $l_no_ban_cell, 'S_USERNAME_BAN' => $mode == 'user' ? true : false, 'U_ACTION' => $this->u_action, 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=searchuser&form=acp_ban&field=ban')));
}
示例9: edit_warning
/**
* Insert the edited warning into the database
*/
function edit_warning($warning_row, $user_row, $warning, $warn_len, $warn_len_other, $warn_type)
{
global $db, $cache;
if (!isset($warning_row) || empty($warning_row)) {
return false;
}
$warn_end = $this->get_warning_end($warn_len, $warn_len_other);
$warning_type_change = false;
if ($warning_row['warning_type'] != $warn_type && in_array($warn_type, array(WARNING, BAN))) {
$warning_type_change = true;
}
$sql_warn_ary = array('warning_end' => (int) $warn_end, 'warning_type' => $warn_type);
$sql_log_ary = array('log_data' => serialize(array($warning)));
if ($warning_row['warning_type'] == BAN) {
$sql = 'SELECT ban_id FROM ' . BANLIST_TABLE . '
WHERE ban_userid = ' . $warning_row['user_id'] . '
AND ban_end = ' . $warning_row['warning_end'];
$result = $db->sql_query($sql);
$ban_id = $db->sql_fetchfield('ban_id');
$db->sql_freeresult($result);
if (!$warning_type_change && $ban_id) {
$sql_ban_ary = array('ban_end' => (int) $warn_end, 'ban_reason' => (string) $warning, 'ban_give_reason' => (string) $warning);
$sql = 'UPDATE ' . BANLIST_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ban_ary) . ' WHERE ban_id = ' . $ban_id;
$db->sql_query($sql);
}
}
if ($warning_type_change) {
if ($warn_type == WARNING && $ban_id) {
user_unban('user', $ban_id);
} else {
if ($warn_type == BAN) {
$ban = utf8_normalize_nfc($user_row['username']);
user_ban('user', $ban, $warn_len, $warn_len_other, 0, $warning, $warning);
}
}
}
// Update warning information - submit new warning and log data to database
$sql = 'UPDATE ' . WARNINGS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_warn_ary) . ' WHERE warning_id = ' . $warning_row['warning_id'];
$db->sql_query($sql);
$sql = 'UPDATE ' . LOG_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_log_ary) . ' WHERE log_id = ' . $warning_row['log_id'];
$db->sql_query($sql);
$cache->destroy('sql', WARNINGS_TABLE);
}
示例10: do_ban_hammer_stuff
public function do_ban_hammer_stuff($event)
{
$this->data = $event['member'];
$this->user_id = (int) $this->data['user_id'];
$curl_exists = function_exists('curl_init') ? true : false;
$admin_mod_array = $this->admin_mod_array();
/**
* Split these up and give error messages? Later maybe.
*/
if (!$this->auth->acl_get('m_ban') || $this->data['user_type'] == USER_FOUNDER && $this->user->data['user_type'] != USER_FOUNDER || $this->user_id == $this->user->data['user_id'] || in_array($this->data['user_id'], $admin_mod_array)) {
// Nothing to see here, move on.
// Only let founders be banned by other founders.
// And don't allow them to ban them selves
return;
}
$this->user->add_lang_ext('phpbbmodders/banhammer', 'banhammer_lang');
// Check if this user already is banned.
if (!function_exists('phpbb_get_banned_user_ids')) {
include $this->root_path . 'includes/functions_user.' . $this->php_ext;
}
$banned = phpbb_get_banned_user_ids(array($this->user_id));
if (!empty($banned)) {
$bh_result = $this->request->variable('bh_res', '');
if (!empty($bh_result)) {
if ($bh_result == 'success') {
$bh_message = $this->user->lang['BANNED_SUCCESS'];
} else {
// One or more actions failed.
$message_ary = explode('+', urldecode($bh_result));
$bh_message = $this->user->lang['BANNED_ERROR'];
foreach ($message_ary as $error) {
$bh_message .= '<br />' . $this->user->lang[$error];
}
}
$this->template->assign_vars(array('BH_STYLE' => ($bh_result == 'success' ? 'green' : '#a92c2c') . '; color: white;"', 'BH_MESSAGE' => $bh_message));
} else {
// It's enough to ban them once.
$this->template->assign_var('BH_MESSAGE', $this->user->lang['BH_BANNED']);
}
return;
}
// Get Ban Hammer settings
$sql = 'SELECT * FROM ' . CONFIG_TEXT_TABLE . "\n\t\t\t\tWHERE config_name = 'banhammer_settings'";
$result = $this->db->sql_query($sql);
$settings = $this->db->sql_fetchfield('config_value');
$this->db->sql_freeresult($result);
$settings = unserialize($settings);
if ($settings['group_id']) {
// 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) {
//.........这里部分代码省略.........
示例11: ban_by_ip
private function ban_by_ip($ip)
{
if (!function_exists('user_ban')) {
include $this->root_path . 'includes/functions_user.' . $this->php_ext;
}
// ban the nub for one hour
user_ban('ip', $ip, 60, 0, false, $this->user->lang['SFS_BANNED'], $this->user->lang['SFS_BANNED']);
return;
}
示例12: ban_user
/**
* Ban user by minimum karma;
*/
function ban_user($user_id = ANONYMOUS)
{
// Ban by minimum karma is disabled
if (!$this->config['ban']) {
return;
}
// We don't have user id
if ($user_id == ANONYMOUS) {
return;
}
global $db, $user;
// Catch username
$sql = 'SELECT username_clean, user_karma, user_karma_powered
FROM ' . USERS_TABLE . '
WHERE user_id = ' . $user_id;
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$clean_name = $row['username_clean'];
$karma = $this->config['power'] ? $row['user_karma'] : $row['user_karma_powered'];
$db->sql_freeresult($result);
// User doesn't have enought karma, so don't ban
if ($karma > $this->config['ban_karma']) {
return;
}
// You can't ban yourself
if ($clean_name == $user->data['username_clean']) {
return;
}
// Create a list of founder...
$sql = 'SELECT user_id, user_email, username_clean
FROM ' . USERS_TABLE . '
WHERE user_type = ' . USER_FOUNDER;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$founder[$row['user_id']] = $row['user_email'];
$founder_names[$row['user_id']] = $row['username_clean'];
}
$db->sql_freeresult($result);
// You can't ban founder
if (in_array($clean_name, $founder_names)) {
return;
}
// Okay, all tests passed and we'll ban user
$mode = 'ban_userid';
// Ban by user id
$ban = $clean_name;
// Banned user
$ban_len = 0;
// Permanent ban
$ben_len_other = '';
// This field user, if baning not permanent
$ban_exclude = '';
// We don't have excludes from banning
$ban_reason = $this->config['ban_reason'];
// Ban reason showed at ACP/MCP
$ban_give_reason = $this->config['ban_give_reason'];
// Ban reason showed to user
// Ban!
user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reason, $ban_give_reason);
}
示例13: insert_ip
/**
* Log IPs and optionally block and/or ban the "fake" IP
*
* Inserts "real" and "fake" IPs in SPECULATIVE_TABLE, blocks and/or bans the "fake" IP session if configured to do so.
* On External IPs (log) page, the first column shows the "fake IP address" and the third column shows the "real IP address".
* The reason we do it in this way is because when you're looking at the IP address of a post, you're going to see the "fake IP address".
*
* We use $db->sql_escape() in all our SQL statements rather than str_replace("\'","''",$_REQUEST['var']) on each var as it comes in.
* This is to avoid confusion and to avoid escaping the same text twice and ending up with too many backslshes in the final result.
*
* @param string $ip_masked The "fake" IP address.
* @param int $mode The test mode used (modes defined in constants.php).
* @param string $ip_direct The "real" IP address.
* @param string $info Additional info like User-Agent string or CGI-Proxy URL(s) - optional.
*/
function insert_ip($ip_masked, $mode, $ip_direct, $info = '')
{
global $phpbb_root_path, $phpEx;
global $db, $sid, $key, $config;
// We don't check $ip_direct as it has just been validated (top of the script) in the case of plugins, or '0.0.0.0' for TOR_DNSEL/PROXY_DNSBL.
// We also don't validate $ip_masked in the case of X_FORWARDED_FOR as that is actually the IP requesting this page (already validated up top)
if ($mode != X_FORWARDED_FOR && !preg_match(get_preg_expression('ipv4'), $ip_masked) && !preg_match(get_preg_expression('ipv6'), $ip_masked)) {
return;
// contains invalid data, return and don't log anything
}
// Validate IP length according to admin ("Session IP Validation" in ACP->Server Configuration->Security Settings)
// session_begin() looks at $config['ip_check'] to see which bits of an IP address to check and so shall we.
// First, check if both addresses are IPv6, else we assume both are IPv4 ($f_ip is the fake, $r_ip is the real)
if (strpos($ip_masked, ':') !== false && strpos($ip_direct, ':') !== false) {
// short_ipv6() from includes/functions.php
$f_ip = short_ipv6($ip_masked, $config['ip_check']);
$r_ip = short_ipv6($ip_direct, $config['ip_check']);
} else {
$f_ip = implode('.', array_slice(explode('.', $ip_masked), 0, $config['ip_check']));
$r_ip = implode('.', array_slice(explode('.', $ip_direct), 0, $config['ip_check']));
}
// If "Session IP Validation" is NOT set to None, and the validated length matches, we return and log nothing
// (see "Select ip validation" in includes/acp/acp_board.php for more info)
if ($config['ip_check'] != 0 && $r_ip === $f_ip) {
return;
}
/**
* In Java, at least, there's a possibility that the main IP we're recording and the "masked" IP address are the same.
* the reason this function would be called, in those cases, is to log $lan_ip. $lan_ip, however, isn't reliable enough
* to block people over (assuming any blocking is taking place). As such, although we log it, we don't update phpbb_sessions.
*/
if ($mode != JAVA_INTERNAL) {
/**
* session_speculative_test will eventually be used to determine whether or not this session ought to be blocked.
* This check is done by performing a bitwise "and" against $config['ip_block']. If the bits that represent the various
* modes 'and' with any of the bits in the bitwise representation of session_speculative_test, a block is done.
* To guarantee that each bit is unique to a specific mode, powers of two are used to represent the modes (see constants.php).
*/
$sql = 'UPDATE ' . SESSIONS_TABLE . " \n\t\t\tSET session_speculative_test = session_speculative_test | " . $db->sql_escape($mode) . " \n\t\t\tWHERE session_id = '" . $db->sql_escape($sid) . "' \n\t\t\t\tAND session_speculative_key = '" . $db->sql_escape($key) . "'";
if (!($result = $db->sql_query($sql))) {
die;
}
// if neither the session_id or the session_speculative_key are valid (as would be revealed by $db->sql_affectedrows being 0),
// we assume the information is not trustworthy and quit.
if (!$db->sql_affectedrows($result)) {
die;
}
// Ban if appropriate
if ($config['ip_ban'] && $mode & $config['ip_block']) {
// $ban_len takes precedence over $ban_len_other unless $ban_len is set to "-1" (other - until $ban_len_other)
// see function user_ban() in functions_user.php for more info
$ban_len = $config['ip_ban_length'];
$ban_len_other = $config['ip_ban_length_other'];
$ban_exclude = 0;
$ban_reason = $config['ip_ban_reason'];
$ban_give_reason = $config['ip_ban_give_reason'];
// user_ban() function from includes/functions_user.php
include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
user_ban('ip', $ip_masked, $ban_len, $ban_len_other, $ban_exclude, $ban_reason, $ban_give_reason);
}
}
// Fetch currently logged entries for the specified IPs/method. Prevent duplicate entries.
$sql = 'SELECT * FROM ' . SPECULATIVE_TABLE . " \n\t\tWHERE ip_address = '" . $db->sql_escape($ip_masked) . "' \n\t\t\tAND method = " . $db->sql_escape($mode) . " \n\t\t\tAND real_ip = '" . $db->sql_escape($ip_direct) . "'";
// Allows duplicate logs of Masked/Real-IP/Method combination if the User-Agent (Browser/Plugin info) differs.
if ($config['ip_log_agent_check'] && $mode != XSS && !empty($info)) {
$sql .= " AND info = '" . $db->sql_escape($info) . "'";
}
$result = $db->sql_query($sql);
if (!($row = $db->sql_fetchrow($result))) {
$sql_ary = array('ip_address' => $ip_masked, 'method' => $mode, 'discovered' => time(), 'real_ip' => $ip_direct, 'info' => $info);
$sql = 'INSERT INTO ' . SPECULATIVE_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
}
}
示例14: urldecode
<?php
require 'C:\\www.citywildlife.org.uk\\includes\\phpbb_header.php';
$email = urldecode($_GET['e']);
$unban = $_GET['unban'];
if (!$unban === 'true') {
$unban = false;
}
/* ban/unban user */
if ($unban) {
//the API function user_unban doesn't seem to work so, with reluctance,
//do it directly
global $db, $cache;
// Delete ban for this user
$sql = 'DELETE FROM ' . BANLIST_TABLE . '
WHERE ban_email = \'' . $email . '\'';
$db->sql_query($sql);
$cache->destroy('sql', BANLIST_TABLE);
echo 'OK';
} else {
/*params: $mode (use, ip, email), $ban (string or array of strings, of type $mode),
$ban_len (minutes), $ban_len_other (expiry date), $ban_exclude (boolean: true is remove ban),
$ban_reason (string)*/
$done = user_ban('email', $email, 10000, '2050-12-31', $unban, 'Lack of respect for mah authoritah!');
echo $done ? 'OK' : 'FAIL';
}
示例15: main
//.........这里部分代码省略.........
trigger_error($user->lang['CANNOT_BAN_ANONYMOUS'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
}
if ($user_row['user_type'] == USER_FOUNDER) {
trigger_error($user->lang['CANNOT_BAN_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
}
if (!check_form_key($form_name)) {
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
}
$ban = array();
switch ($action) {
case 'banuser':
$ban[] = $user_row['username'];
$reason = 'USER_ADMIN_BAN_NAME_REASON';
break;
case 'banemail':
$ban[] = $user_row['user_email'];
$reason = 'USER_ADMIN_BAN_EMAIL_REASON';
break;
case 'banip':
$ban[] = $user_row['user_ip'];
$sql = 'SELECT DISTINCT poster_ip
FROM ' . POSTS_TABLE . "\n\t\t\t\t\t\t\t\t\t\tWHERE poster_id = {$user_id}";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$ban[] = $row['poster_ip'];
}
$db->sql_freeresult($result);
$reason = 'USER_ADMIN_BAN_IP_REASON';
break;
}
$ban_reason = $request->variable('ban_reason', $user->lang[$reason], true);
$ban_give_reason = $request->variable('ban_give_reason', '', true);
// Log not used at the moment, we simply utilize the ban function.
$result = user_ban(substr($action, 3), $ban, 0, 0, 0, $ban_reason, $ban_give_reason);
trigger_error(($result === false ? $user->lang['BAN_ALREADY_ENTERED'] : $user->lang['BAN_SUCCESSFUL']) . adm_back_link($this->u_action . '&u=' . $user_id));
break;
case 'reactivate':
if ($user_id == $user->data['user_id']) {
trigger_error($user->lang['CANNOT_FORCE_REACT_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
}
if (!check_form_key($form_name)) {
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
}
if ($user_row['user_type'] == USER_FOUNDER) {
trigger_error($user->lang['CANNOT_FORCE_REACT_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
}
if ($user_row['user_type'] == USER_IGNORE) {
trigger_error($user->lang['CANNOT_FORCE_REACT_BOT'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
}
if ($config['email_enable']) {
if (!class_exists('messenger')) {
include $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
}
$server_url = generate_board_url();
$user_actkey = gen_rand_string(mt_rand(6, 10));
$email_template = $user_row['user_type'] == USER_NORMAL ? 'user_reactivate_account' : 'user_resend_inactive';
if ($user_row['user_type'] == USER_NORMAL) {
user_active_flip('deactivate', $user_id, INACTIVE_REMIND);
$sql = 'UPDATE ' . USERS_TABLE . "\n\t\t\t\t\t\t\t\t\t\tSET user_actkey = '" . $db->sql_escape($user_actkey) . "'\n\t\t\t\t\t\t\t\t\t\tWHERE user_id = {$user_id}";
$db->sql_query($sql);
} else {
// Grabbing the last confirm key - we only send a reminder
$sql = 'SELECT user_actkey
FROM ' . USERS_TABLE . '
WHERE user_id = ' . $user_id;
$result = $db->sql_query($sql);