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