|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
*
|
|
|
4c79b5 |
* @package acp
|
|
|
4c79b5 |
* @version $Id: acp_ban.php 8479 2008-03-29 00:22:48Z naderman $
|
|
|
4c79b5 |
* @copyright (c) 2005 phpBB Group
|
|
|
4c79b5 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
|
4c79b5 |
*
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* @ignore
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
if (!defined('IN_PHPBB'))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
exit;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* @package acp
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
class acp_ban
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
var $u_action;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
function main($id, $mode)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $config, $db, $user, $auth, $template, $cache;
|
|
|
4c79b5 |
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$bansubmit = (isset($_POST['bansubmit'])) ? true : false;
|
|
|
4c79b5 |
$unbansubmit = (isset($_POST['unbansubmit'])) ? true : false;
|
|
|
4c79b5 |
$current_time = time();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$user->add_lang(array('acp/ban', 'acp/users'));
|
|
|
4c79b5 |
$this->tpl_name = 'acp_ban';
|
|
|
4c79b5 |
$form_key = 'acp_ban';
|
|
|
4c79b5 |
add_form_key($form_key);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (($bansubmit || $unbansubmit) && !check_form_key($form_key))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Ban submitted?
|
|
|
4c79b5 |
if ($bansubmit)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Grab the list of entries
|
|
|
4c79b5 |
$ban = utf8_normalize_nfc(request_var('ban', '', true));
|
|
|
4c79b5 |
$ban_len = request_var('banlength', 0);
|
|
|
4c79b5 |
$ban_len_other = request_var('banlengthother', '');
|
|
|
4c79b5 |
$ban_exclude = request_var('banexclude', 0);
|
|
|
4c79b5 |
$ban_reason = utf8_normalize_nfc(request_var('banreason', '', true));
|
|
|
4c79b5 |
$ban_give_reason = utf8_normalize_nfc(request_var('bangivereason', '', true));
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($ban)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reason, $ban_give_reason);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . adm_back_link($this->u_action));
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else if ($unbansubmit)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$ban = request_var('unban', array(''));
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($ban)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
user_unban($mode, $ban);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . adm_back_link($this->u_action));
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Define language vars
|
|
|
4c79b5 |
$this->page_title = $user->lang[strtoupper($mode) . '_BAN'];
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$l_ban_explain = $user->lang[strtoupper($mode) . '_BAN_EXPLAIN'];
|
|
|
4c79b5 |
$l_ban_exclude_explain = $user->lang[strtoupper($mode) . '_BAN_EXCLUDE_EXPLAIN'];
|
|
|
4c79b5 |
$l_unban_title = $user->lang[strtoupper($mode) . '_UNBAN'];
|
|
|
4c79b5 |
$l_unban_explain = $user->lang[strtoupper($mode) . '_UNBAN_EXPLAIN'];
|
|
|
4c79b5 |
$l_no_ban_cell = $user->lang[strtoupper($mode) . '_NO_BANNED'];
|
|
|
4c79b5 |
|
|
|
4c79b5 |
switch ($mode)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
case 'user':
|
|
|
4c79b5 |
$l_ban_cell = $user->lang['USERNAME'];
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'ip':
|
|
|
4c79b5 |
$l_ban_cell = $user->lang['IP_HOSTNAME'];
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'email':
|
|
|
4c79b5 |
$l_ban_cell = $user->lang['EMAIL_ADDRESS'];
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$this->display_ban_options($mode);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$template->assign_vars(array(
|
|
|
4c79b5 |
'L_TITLE' => $this->page_title,
|
|
|
4c79b5 |
'L_EXPLAIN' => $l_ban_explain,
|
|
|
4c79b5 |
'L_UNBAN_TITLE' => $l_unban_title,
|
|
|
4c79b5 |
'L_UNBAN_EXPLAIN' => $l_unban_explain,
|
|
|
4c79b5 |
'L_BAN_CELL' => $l_ban_cell,
|
|
|
4c79b5 |
'L_BAN_EXCLUDE_EXPLAIN' => $l_ban_exclude_explain,
|
|
|
4c79b5 |
'L_NO_BAN_CELL' => $l_no_ban_cell,
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'S_USERNAME_BAN' => ($mode == 'user') ? true : false,
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'U_ACTION' => $this->u_action,
|
|
|
4c79b5 |
'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=acp_ban&field=ban'),
|
|
|
4c79b5 |
));
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Display ban options
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function display_ban_options($mode)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $user, $db, $template;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Ban length options
|
|
|
4c79b5 |
$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'] . ' -> ');
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$ban_end_options = '';
|
|
|
4c79b5 |
foreach ($ban_end_text as $length => $text)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$ban_end_options .= '<option value="' . $length . '">' . $text . '</option>';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
switch ($mode)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
case 'user':
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$field = 'username';
|
|
|
4c79b5 |
$l_ban_cell = $user->lang['USERNAME'];
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql = 'SELECT b.*, u.user_id, u.username, u.username_clean
|
|
|
4c79b5 |
FROM ' . BANLIST_TABLE . ' b, ' . USERS_TABLE . ' u
|
|
|
4c79b5 |
WHERE (b.ban_end >= ' . time() . '
|
|
|
4c79b5 |
OR b.ban_end = 0)
|
|
|
4c79b5 |
AND u.user_id = b.ban_userid
|
|
|
4c79b5 |
ORDER BY u.username_clean ASC';
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'ip':
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$field = 'ban_ip';
|
|
|
4c79b5 |
$l_ban_cell = $user->lang['IP_HOSTNAME'];
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql = 'SELECT *
|
|
|
4c79b5 |
FROM ' . BANLIST_TABLE . '
|
|
|
4c79b5 |
WHERE (ban_end >= ' . time() . "
|
|
|
4c79b5 |
OR ban_end = 0)
|
|
|
4c79b5 |
AND ban_ip <> ''";
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'email':
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$field = 'ban_email';
|
|
|
4c79b5 |
$l_ban_cell = $user->lang['EMAIL_ADDRESS'];
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql = 'SELECT *
|
|
|
4c79b5 |
FROM ' . BANLIST_TABLE . '
|
|
|
4c79b5 |
WHERE (ban_end >= ' . time() . "
|
|
|
4c79b5 |
OR ban_end = 0)
|
|
|
4c79b5 |
AND ban_email <> ''";
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$result = $db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$banned_options = '';
|
|
|
4c79b5 |
$ban_length = $ban_reasons = $ban_give_reasons = array();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
while ($row = $db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$banned_options .= '<option' . (($row['ban_exclude']) ? ' class="sep"' : '') . ' value="' . $row['ban_id'] . '">' . $row[$field] . '</option>';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$time_length = ($row['ban_end']) ? ($row['ban_end'] - $row['ban_start']) / 60 : 0;
|
|
|
4c79b5 |
$ban_length[$row['ban_id']] = (isset($ban_end_text[$time_length])) ? $ban_end_text[$time_length] : $user->lang['UNTIL'] . ' -> ' . $user->format_date($row['ban_end']);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$ban_reasons[$row['ban_id']] = $row['ban_reason'];
|
|
|
4c79b5 |
$ban_give_reasons[$row['ban_id']] = $row['ban_give_reason'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (sizeof($ban_length))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
foreach ($ban_length as $ban_id => $length)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$template->assign_block_vars('ban_length', array(
|
|
|
4c79b5 |
'BAN_ID' => (int) $ban_id,
|
|
|
4c79b5 |
'LENGTH' => $length,
|
|
|
4c79b5 |
'A_LENGTH' => addslashes($length),
|
|
|
4c79b5 |
));
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (sizeof($ban_reasons))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
foreach ($ban_reasons as $ban_id => $reason)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$template->assign_block_vars('ban_reason', array(
|
|
|
4c79b5 |
'BAN_ID' => $ban_id,
|
|
|
4c79b5 |
'REASON' => $reason,
|
|
|
4c79b5 |
'A_REASON' => addslashes(htmlspecialchars_decode($reason)),
|
|
|
4c79b5 |
));
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (sizeof($ban_give_reasons))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
foreach ($ban_give_reasons as $ban_id => $reason)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$template->assign_block_vars('ban_give_reason', array(
|
|
|
4c79b5 |
'BAN_ID' => $ban_id,
|
|
|
4c79b5 |
'REASON' => $reason,
|
|
|
4c79b5 |
'A_REASON' => addslashes(htmlspecialchars_decode($reason)),
|
|
|
4c79b5 |
));
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$template->assign_vars(array(
|
|
|
4c79b5 |
'S_BAN_END_OPTIONS' => $ban_end_options,
|
|
|
4c79b5 |
'S_BANNED_OPTIONS' => ($banned_options) ? true : false,
|
|
|
4c79b5 |
'BANNED_OPTIONS' => $banned_options)
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
?>
|