[ 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 acp_ban 23 { 24 var $u_action; 25 26 function main($id, $mode) 27 { 28 global $user, $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 $bansubmit = $request->is_set_post('bansubmit'); 37 $unbansubmit = $request->is_set_post('unbansubmit'); 38 39 $user->add_lang(array('acp/ban', 'acp/users')); 40 $this->tpl_name = 'acp_ban'; 41 $form_key = 'acp_ban'; 42 add_form_key($form_key); 43 44 if (($bansubmit || $unbansubmit) && !check_form_key($form_key)) 45 { 46 trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); 47 } 48 49 // Ban submitted? 50 if ($bansubmit) 51 { 52 // Grab the list of entries 53 $ban = $request->variable('ban', '', true); 54 $ban_length = $request->variable('banlength', 0); 55 $ban_length_other = $request->variable('banlengthother', ''); 56 $ban_exclude = $request->variable('banexclude', 0); 57 $ban_reason = $request->variable('banreason', '', true); 58 $ban_give_reason = $request->variable('bangivereason', '', true); 59 60 if ($ban) 61 { 62 $abort_ban = false; 63 /** 64 * Use this event to modify the ban details before the ban is performed 65 * 66 * @event core.acp_ban_before 67 * @var string mode One of the following: user, ip, email 68 * @var string ban Either string or array with usernames, ips or email addresses 69 * @var int ban_length Ban length in minutes 70 * @var string ban_length_other Ban length as a date (YYYY-MM-DD) 71 * @var bool ban_exclude Are we banning or excluding from another ban 72 * @var string ban_reason Ban reason displayed to moderators 73 * @var string ban_give_reason Ban reason displayed to the banned user 74 * @var mixed abort_ban Either false, or an error message that is displayed to the user. 75 * If a string is given the bans are not issued. 76 * @since 3.1.0-RC5 77 */ 78 $vars = array( 79 'mode', 80 'ban', 81 'ban_length', 82 'ban_length_other', 83 'ban_exclude', 84 'ban_reason', 85 'ban_give_reason', 86 'abort_ban', 87 ); 88 extract($phpbb_dispatcher->trigger_event('core.acp_ban_before', compact($vars))); 89 90 if ($abort_ban) 91 { 92 trigger_error($abort_ban . adm_back_link($this->u_action)); 93 } 94 user_ban($mode, $ban, $ban_length, $ban_length_other, $ban_exclude, $ban_reason, $ban_give_reason); 95 96 /** 97 * Use this event to perform actions after the ban has been performed 98 * 99 * @event core.acp_ban_after 100 * @var string mode One of the following: user, ip, email 101 * @var string ban Either string or array with usernames, ips or email addresses 102 * @var int ban_length Ban length in minutes 103 * @var string ban_length_other Ban length as a date (YYYY-MM-DD) 104 * @var bool ban_exclude Are we banning or excluding from another ban 105 * @var string ban_reason Ban reason displayed to moderators 106 * @var string ban_give_reason Ban reason displayed to the banned user 107 * @since 3.1.0-RC5 108 */ 109 $vars = array( 110 'mode', 111 'ban', 112 'ban_length', 113 'ban_length_other', 114 'ban_exclude', 115 'ban_reason', 116 'ban_give_reason', 117 ); 118 extract($phpbb_dispatcher->trigger_event('core.acp_ban_after', compact($vars))); 119 120 trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . adm_back_link($this->u_action)); 121 } 122 } 123 else if ($unbansubmit) 124 { 125 $ban = $request->variable('unban', array('')); 126 127 if ($ban) 128 { 129 user_unban($mode, $ban); 130 131 trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . adm_back_link($this->u_action)); 132 } 133 } 134 135 // Define language vars 136 $this->page_title = $user->lang[strtoupper($mode) . '_BAN']; 137 138 $l_ban_explain = $user->lang[strtoupper($mode) . '_BAN_EXPLAIN']; 139 $l_ban_exclude_explain = $user->lang[strtoupper($mode) . '_BAN_EXCLUDE_EXPLAIN']; 140 $l_unban_title = $user->lang[strtoupper($mode) . '_UNBAN']; 141 $l_unban_explain = $user->lang[strtoupper($mode) . '_UNBAN_EXPLAIN']; 142 $l_no_ban_cell = $user->lang[strtoupper($mode) . '_NO_BANNED']; 143 144 switch ($mode) 145 { 146 case 'user': 147 $l_ban_cell = $user->lang['USERNAME']; 148 break; 149 150 case 'ip': 151 $l_ban_cell = $user->lang['IP_HOSTNAME']; 152 break; 153 154 case 'email': 155 $l_ban_cell = $user->lang['EMAIL_ADDRESS']; 156 break; 157 } 158 159 self::display_ban_options($mode); 160 161 $template->assign_vars(array( 162 'L_TITLE' => $this->page_title, 163 'L_EXPLAIN' => $l_ban_explain, 164 'L_UNBAN_TITLE' => $l_unban_title, 165 'L_UNBAN_EXPLAIN' => $l_unban_explain, 166 'L_BAN_CELL' => $l_ban_cell, 167 'L_BAN_EXCLUDE_EXPLAIN' => $l_ban_exclude_explain, 168 'L_NO_BAN_CELL' => $l_no_ban_cell, 169 170 'S_USERNAME_BAN' => ($mode == 'user') ? true : false, 171 172 'U_ACTION' => $this->u_action, 173 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=acp_ban&field=ban'), 174 )); 175 } 176 177 /** 178 * Display ban options 179 */ 180 static public function display_ban_options($mode) 181 { 182 global $user, $db, $template; 183 184 // Ban length options 185 $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'] . ' -> '); 186 187 $ban_end_options = ''; 188 foreach ($ban_end_text as $length => $text) 189 { 190 $ban_end_options .= '<option value="' . $length . '">' . $text . '</option>'; 191 } 192 193 switch ($mode) 194 { 195 case 'user': 196 197 $field = 'username'; 198 $l_ban_cell = $user->lang['USERNAME']; 199 200 $sql = 'SELECT b.*, u.user_id, u.username, u.username_clean 201 FROM ' . BANLIST_TABLE . ' b, ' . USERS_TABLE . ' u 202 WHERE (b.ban_end >= ' . time() . ' 203 OR b.ban_end = 0) 204 AND u.user_id = b.ban_userid 205 ORDER BY u.username_clean ASC'; 206 break; 207 208 case 'ip': 209 210 $field = 'ban_ip'; 211 $l_ban_cell = $user->lang['IP_HOSTNAME']; 212 213 $sql = 'SELECT * 214 FROM ' . BANLIST_TABLE . ' 215 WHERE (ban_end >= ' . time() . " 216 OR ban_end = 0) 217 AND ban_ip <> '' 218 ORDER BY ban_ip"; 219 break; 220 221 case 'email': 222 223 $field = 'ban_email'; 224 $l_ban_cell = $user->lang['EMAIL_ADDRESS']; 225 226 $sql = 'SELECT * 227 FROM ' . BANLIST_TABLE . ' 228 WHERE (ban_end >= ' . time() . " 229 OR ban_end = 0) 230 AND ban_email <> '' 231 ORDER BY ban_email"; 232 break; 233 } 234 $result = $db->sql_query($sql); 235 236 $banned_options = $excluded_options = array(); 237 while ($row = $db->sql_fetchrow($result)) 238 { 239 $option = '<option value="' . $row['ban_id'] . '">' . $row[$field] . '</option>'; 240 241 if ($row['ban_exclude']) 242 { 243 $excluded_options[] = $option; 244 } 245 else 246 { 247 $banned_options[] = $option; 248 } 249 250 $time_length = ($row['ban_end']) ? ($row['ban_end'] - $row['ban_start']) / 60 : 0; 251 252 if ($time_length == 0) 253 { 254 // Banned permanently 255 $ban_length = $user->lang['PERMANENT']; 256 } 257 else if (isset($ban_end_text[$time_length])) 258 { 259 // Banned for a given duration 260 $ban_length = $user->lang('BANNED_UNTIL_DURATION', $ban_end_text[$time_length], $user->format_date($row['ban_end'], false, true)); 261 } 262 else 263 { 264 // Banned until given date 265 $ban_length = $user->lang('BANNED_UNTIL_DATE', $user->format_date($row['ban_end'], false, true)); 266 } 267 268 $template->assign_block_vars('bans', array( 269 'BAN_ID' => (int) $row['ban_id'], 270 'LENGTH' => $ban_length, 271 'A_LENGTH' => addslashes($ban_length), 272 'REASON' => $row['ban_reason'], 273 'A_REASON' => addslashes($row['ban_reason']), 274 'GIVE_REASON' => $row['ban_give_reason'], 275 'A_GIVE_REASON' => addslashes($row['ban_give_reason']), 276 )); 277 } 278 $db->sql_freeresult($result); 279 280 $options = ''; 281 if ($excluded_options) 282 { 283 $options .= '<optgroup label="' . $user->lang['OPTIONS_EXCLUDED'] . '">'; 284 $options .= implode('', $excluded_options); 285 $options .= '</optgroup>'; 286 } 287 288 if ($banned_options) 289 { 290 $options .= '<optgroup label="' . $user->lang['OPTIONS_BANNED'] . '">'; 291 $options .= implode('', $banned_options); 292 $options .= '</optgroup>'; 293 } 294 295 $template->assign_vars(array( 296 'S_BAN_END_OPTIONS' => $ban_end_options, 297 'S_BANNED_OPTIONS' => ($banned_options || $excluded_options) ? true : false, 298 'BANNED_OPTIONS' => $options, 299 )); 300 } 301 }
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 |