[ Index ] |
PHP Cross Reference of phpBB-3.1.12-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * This file is part of the phpBB Forum Software package. 5 * 6 * @copyright (c) phpBB Limited <https://www.phpbb.com> 7 * @license GNU General Public License, version 2 (GPL-2.0) 8 * 9 * For full copyright and license information, please see 10 * the docs/CREDITS.txt file. 11 * 12 */ 13 14 /** 15 * @ignore 16 */ 17 if (!defined('IN_PHPBB')) 18 { 19 exit; 20 } 21 22 class mcp_ban 23 { 24 var $u_action; 25 26 function main($id, $mode) 27 { 28 global $db, $user, $auth, $template, $request, $phpbb_dispatcher; 29 global $phpbb_root_path, $phpEx; 30 31 if (!function_exists('user_ban')) 32 { 33 include($phpbb_root_path . 'includes/functions_user.' . $phpEx); 34 } 35 36 // Include the admin banning interface... 37 include($phpbb_root_path . 'includes/acp/acp_ban.' . $phpEx); 38 39 $bansubmit = $request->is_set_post('bansubmit'); 40 $unbansubmit = $request->is_set_post('unbansubmit'); 41 42 $user->add_lang(array('acp/ban', 'acp/users')); 43 $this->tpl_name = 'mcp_ban'; 44 45 /** 46 * Use this event to pass perform actions when a ban is issued or revoked 47 * 48 * @event core.mcp_ban_main 49 * @var bool bansubmit True if a ban is issued 50 * @var bool unbansubmit True if a ban is removed 51 * @var string mode Mode of the ban that is being worked on 52 * @since 3.1.0-RC5 53 */ 54 $vars = array( 55 'bansubmit', 56 'unbansubmit', 57 'mode', 58 ); 59 extract($phpbb_dispatcher->trigger_event('core.mcp_ban_main', compact($vars))); 60 61 // Ban submitted? 62 if ($bansubmit) 63 { 64 // Grab the list of entries 65 $ban = $request->variable('ban', '', $mode === 'user'); 66 $ban_length = $request->variable('banlength', 0); 67 $ban_length_other = $request->variable('banlengthother', ''); 68 $ban_exclude = $request->variable('banexclude', 0); 69 $ban_reason = $request->variable('banreason', '', true); 70 $ban_give_reason = $request->variable('bangivereason', '', true); 71 72 if ($ban) 73 { 74 if (confirm_box(true)) 75 { 76 $abort_ban = false; 77 /** 78 * Use this event to modify the ban details before the ban is performed 79 * 80 * @event core.mcp_ban_before 81 * @var string mode One of the following: user, ip, email 82 * @var string ban Either string or array with usernames, ips or email addresses 83 * @var int ban_length Ban length in minutes 84 * @var string ban_length_other Ban length as a date (YYYY-MM-DD) 85 * @var bool ban_exclude Are we banning or excluding from another ban 86 * @var string ban_reason Ban reason displayed to moderators 87 * @var string ban_give_reason Ban reason displayed to the banned user 88 * @var mixed abort_ban Either false, or an error message that is displayed to the user. 89 * If a string is given the bans are not issued. 90 * @since 3.1.0-RC5 91 */ 92 $vars = array( 93 'mode', 94 'ban', 95 'ban_length', 96 'ban_length_other', 97 'ban_exclude', 98 'ban_reason', 99 'ban_give_reason', 100 'abort_ban', 101 ); 102 extract($phpbb_dispatcher->trigger_event('core.mcp_ban_before', compact($vars))); 103 104 if ($abort_ban) 105 { 106 trigger_error($abort_ban); 107 } 108 user_ban($mode, $ban, $ban_length, $ban_length_other, $ban_exclude, $ban_reason, $ban_give_reason); 109 110 /** 111 * Use this event to perform actions after the ban has been performed 112 * 113 * @event core.mcp_ban_after 114 * @var string mode One of the following: user, ip, email 115 * @var string ban Either string or array with usernames, ips or email addresses 116 * @var int ban_length Ban length in minutes 117 * @var string ban_length_other Ban length as a date (YYYY-MM-DD) 118 * @var bool ban_exclude Are we banning or excluding from another ban 119 * @var string ban_reason Ban reason displayed to moderators 120 * @var string ban_give_reason Ban reason displayed to the banned user 121 * @since 3.1.0-RC5 122 */ 123 $vars = array( 124 'mode', 125 'ban', 126 'ban_length', 127 'ban_length_other', 128 'ban_exclude', 129 'ban_reason', 130 'ban_give_reason', 131 ); 132 extract($phpbb_dispatcher->trigger_event('core.mcp_ban_after', compact($vars))); 133 134 trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . '<br /><br /><a href="' . $this->u_action . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>'); 135 } 136 else 137 { 138 $hidden_fields = array( 139 'mode' => $mode, 140 'ban' => $ban, 141 'bansubmit' => true, 142 'banlength' => $ban_length, 143 'banlengthother' => $ban_length_other, 144 'banexclude' => $ban_exclude, 145 'banreason' => $ban_reason, 146 'bangivereason' => $ban_give_reason, 147 ); 148 149 /** 150 * Use this event to pass data from the ban form to the confirmation screen 151 * 152 * @event core.mcp_ban_confirm 153 * @var array hidden_fields Hidden fields that are passed through the confirm screen 154 * @since 3.1.0-RC5 155 */ 156 $vars = array('hidden_fields'); 157 extract($phpbb_dispatcher->trigger_event('core.mcp_ban_confirm', compact($vars))); 158 159 confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($hidden_fields)); 160 } 161 } 162 } 163 else if ($unbansubmit) 164 { 165 $ban = $request->variable('unban', array('')); 166 167 if ($ban) 168 { 169 if (confirm_box(true)) 170 { 171 user_unban($mode, $ban); 172 173 trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . '<br /><br /><a href="' . $this->u_action . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>'); 174 } 175 else 176 { 177 confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( 178 'mode' => $mode, 179 'unbansubmit' => true, 180 'unban' => $ban))); 181 } 182 } 183 } 184 185 // Ban length options 186 $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'] . ' -> '); 187 188 $ban_end_options = ''; 189 foreach ($ban_end_text as $length => $text) 190 { 191 $ban_end_options .= '<option value="' . $length . '">' . $text . '</option>'; 192 } 193 194 // Define language vars 195 $this->page_title = $user->lang[strtoupper($mode) . '_BAN']; 196 197 $l_ban_explain = $user->lang[strtoupper($mode) . '_BAN_EXPLAIN']; 198 $l_ban_exclude_explain = $user->lang[strtoupper($mode) . '_BAN_EXCLUDE_EXPLAIN']; 199 $l_unban_title = $user->lang[strtoupper($mode) . '_UNBAN']; 200 $l_unban_explain = $user->lang[strtoupper($mode) . '_UNBAN_EXPLAIN']; 201 $l_no_ban_cell = $user->lang[strtoupper($mode) . '_NO_BANNED']; 202 203 switch ($mode) 204 { 205 case 'user': 206 $l_ban_cell = $user->lang['USERNAME']; 207 break; 208 209 case 'ip': 210 $l_ban_cell = $user->lang['IP_HOSTNAME']; 211 break; 212 213 case 'email': 214 $l_ban_cell = $user->lang['EMAIL_ADDRESS']; 215 break; 216 } 217 218 acp_ban::display_ban_options($mode); 219 220 $template->assign_vars(array( 221 'L_TITLE' => $this->page_title, 222 'L_EXPLAIN' => $l_ban_explain, 223 'L_UNBAN_TITLE' => $l_unban_title, 224 'L_UNBAN_EXPLAIN' => $l_unban_explain, 225 'L_BAN_CELL' => $l_ban_cell, 226 'L_BAN_EXCLUDE_EXPLAIN' => $l_ban_exclude_explain, 227 'L_NO_BAN_CELL' => $l_no_ban_cell, 228 229 'S_USERNAME_BAN' => ($mode == 'user') ? true : false, 230 231 'U_ACTION' => $this->u_action, 232 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=mcp_ban&field=ban'), 233 )); 234 235 if ($mode === 'email' && !$auth->acl_get('a_user')) 236 { 237 return; 238 } 239 240 // As a "service" we will check if any post id is specified and populate the username of the poster id if given 241 $post_id = $request->variable('p', 0); 242 $user_id = $request->variable('u', 0); 243 $pre_fill = false; 244 245 if ($user_id && $user_id <> ANONYMOUS) 246 { 247 $sql = 'SELECT username, user_email, user_ip 248 FROM ' . USERS_TABLE . ' 249 WHERE user_id = ' . $user_id; 250 $result = $db->sql_query($sql); 251 switch ($mode) 252 { 253 case 'user': 254 $pre_fill = (string) $db->sql_fetchfield('username'); 255 break; 256 257 case 'ip': 258 $pre_fill = (string) $db->sql_fetchfield('user_ip'); 259 break; 260 261 case 'email': 262 $pre_fill = (string) $db->sql_fetchfield('user_email'); 263 break; 264 } 265 $db->sql_freeresult($result); 266 } 267 else if ($post_id) 268 { 269 $post_info = phpbb_get_post_data($post_id, 'm_ban'); 270 271 if (sizeof($post_info) && !empty($post_info[$post_id])) 272 { 273 switch ($mode) 274 { 275 case 'user': 276 $pre_fill = $post_info[$post_id]['username']; 277 break; 278 279 case 'ip': 280 $pre_fill = $post_info[$post_id]['poster_ip']; 281 break; 282 283 case 'email': 284 $pre_fill = $post_info[$post_id]['user_email']; 285 break; 286 } 287 288 } 289 } 290 291 if ($pre_fill) 292 { 293 // left for legacy template compatibility 294 $template->assign_var('USERNAMES', $pre_fill); 295 $template->assign_var('BAN_QUANTIFIER', $pre_fill); 296 } 297 } 298 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Jan 11 00:25:41 2018 | Cross-referenced by PHPXref 0.7.1 |