6 * @copyright (c) 2005 phpBB Group
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 if (!defined('IN_PHPBB'))
26 function main($id, $mode)
28 include(PHPBB_ROOT_PATH
. 'includes/functions_user.' . PHP_EXT
);
30 // Include the admin banning interface...
31 include(PHPBB_ROOT_PATH
. 'includes/acp/acp_ban.' . PHP_EXT
);
33 $bansubmit = phpbb_request
::is_set_post('bansubmit');
34 $unbansubmit = phpbb_request
::is_set_post('unbansubmit');
35 $current_time = time();
37 phpbb
::$user->add_lang(array('acp/ban', 'acp/users'));
38 $this->tpl_name
= 'mcp_ban';
43 // Grab the list of entries
44 $ban = request_var('ban', '', ($mode === 'user') ?
true : false);
48 $ban = utf8_normalize_nfc($ban);
51 $ban_len = request_var('banlength', 0);
52 $ban_len_other = request_var('banlengthother', '');
53 $ban_exclude = request_var('banexclude', 0);
54 $ban_reason = utf8_normalize_nfc(request_var('banreason', '', true));
55 $ban_give_reason = utf8_normalize_nfc(request_var('bangivereason', '', true));
59 if (confirm_box(true))
61 user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reason, $ban_give_reason);
63 trigger_error(phpbb
::$user->lang
['BAN_UPDATE_SUCCESSFUL'] . '<br /><br /><a href="' . $this->u_action
. '">« ' . phpbb
::$user->lang
['BACK_TO_PREV'] . '</a>');
67 confirm_box(false, phpbb
::$user->lang
['CONFIRM_OPERATION'], build_hidden_fields(array(
71 'banlength' => $ban_len,
72 'banlengthother' => $ban_len_other,
73 'banexclude' => $ban_exclude,
74 'banreason' => $ban_reason,
75 'bangivereason' => $ban_give_reason)));
79 else if ($unbansubmit)
81 $ban = request_var('unban', array(''));
85 if (confirm_box(true))
87 user_unban($mode, $ban);
89 trigger_error(phpbb
::$user->lang
['BAN_UPDATE_SUCCESSFUL'] . '<br /><br /><a href="' . $this->u_action
. '">« ' . phpbb
::$user->lang
['BACK_TO_PREV'] . '</a>');
93 confirm_box(false, phpbb
::$user->lang
['CONFIRM_OPERATION'], build_hidden_fields(array(
95 'unbansubmit' => true,
101 // Ban length options
102 $ban_end_text = array(0 => phpbb
::$user->lang
['PERMANENT'], 30 => phpbb
::$user->lang
['30_MINS'], 60 => phpbb
::$user->lang
['1_HOUR'], 360 => phpbb
::$user->lang
['6_HOURS'], 1440 => phpbb
::$user->lang
['1_DAY'], 10080 => phpbb
::$user->lang
['7_DAYS'], 20160 => phpbb
::$user->lang
['2_WEEKS'], 40320 => phpbb
::$user->lang
['1_MONTH'], -1 => phpbb
::$user->lang
['UNTIL'] . ' -> ');
104 $ban_end_options = '';
105 foreach ($ban_end_text as $length => $text)
107 $ban_end_options .= '<option value="' . $length . '">' . $text . '</option>';
110 // Define language vars
111 $this->page_title
= phpbb
::$user->lang
[strtoupper($mode) . '_BAN'];
113 $l_ban_explain = phpbb
::$user->lang
[strtoupper($mode) . '_BAN_EXPLAIN'];
114 $l_ban_exclude_explain = phpbb
::$user->lang
[strtoupper($mode) . '_BAN_EXCLUDE_EXPLAIN'];
115 $l_unban_title = phpbb
::$user->lang
[strtoupper($mode) . '_UNBAN'];
116 $l_unban_explain = phpbb
::$user->lang
[strtoupper($mode) . '_UNBAN_EXPLAIN'];
117 $l_no_ban_cell = phpbb
::$user->lang
[strtoupper($mode) . '_NO_BANNED'];
122 $l_ban_cell = phpbb
::$user->lang
['USERNAME'];
126 $l_ban_cell = phpbb
::$user->lang
['IP_HOSTNAME'];
130 $l_ban_cell = phpbb
::$user->lang
['EMAIL_ADDRESS'];
134 acp_ban
::display_ban_options($mode);
136 $template->assign_vars(array(
137 'L_TITLE' => $this->page_title
,
138 'L_EXPLAIN' => $l_ban_explain,
139 'L_UNBAN_TITLE' => $l_unban_title,
140 'L_UNBAN_EXPLAIN' => $l_unban_explain,
141 'L_BAN_CELL' => $l_ban_cell,
142 'L_BAN_EXCLUDE_EXPLAIN' => $l_ban_exclude_explain,
143 'L_NO_BAN_CELL' => $l_no_ban_cell,
145 'S_USERNAME_BAN' => ($mode == 'user') ?
true : false,
147 'U_ACTION' => $this->u_action
,
148 'U_FIND_USERNAME' => append_sid('memberlist', 'mode=searchuser&form=mcp_ban&field=ban'),
151 if ($mode === 'email' && !phpbb
::$acl->acl_get('a_user'))
156 // As a "service" we will check if any post id is specified and populate the username of the poster id if given
157 $post_id = request_var('p', 0);
158 $user_id = request_var('u', 0);
159 $username = $pre_fill = false;
161 if ($user_id && $user_id <> ANONYMOUS
)
163 $sql = 'SELECT username, user_email, user_ip
164 FROM ' . USERS_TABLE
. '
165 WHERE user_id = ' . $user_id;
166 $result = $db->sql_query($sql);
170 $pre_fill = (string) $db->sql_fetchfield('username');
174 $pre_fill = (string) $db->sql_fetchfield('user_ip');
178 $pre_fill = (string) $db->sql_fetchfield('user_email');
181 $db->sql_freeresult($result);
185 $post_info = get_post_data($post_id, 'm_ban');
187 if (sizeof($post_info) && !empty($post_info[$post_id]))
192 $pre_fill = $post_info[$post_id]['username'];
196 $pre_fill = $post_info[$post_id]['poster_ip'];
200 $pre_fill = $post_info[$post_id]['user_email'];
209 $template->assign_var('BAN_QUANTIFIER', $pre_fill);