Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
mcp_ban.php
001 <?php
002 /**
003 *
004 * This file is part of the phpBB Forum Software package.
005 *
006 * @copyright (c) phpBB Limited <https://www.phpbb.com>
007 * @license GNU General Public License, version 2 (GPL-2.0)
008 *
009 * For full copyright and license information, please see
010 * the docs/CREDITS.txt file.
011 *
012 */
013
014 /**
015 * @ignore
016 */
017 if (!defined('IN_PHPBB'))
018 {
019 exit;
020 }
021
022 class mcp_ban
023 {
024 var $u_action;
025
026 function main($id, $mode)
027 {
028 global $db, $user, $auth, $template, $request, $phpbb_dispatcher;
029 global $phpbb_root_path, $phpEx;
030
031 include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
032
033 // Include the admin banning interface...
034 include($phpbb_root_path . 'includes/acp/acp_ban.' . $phpEx);
035
036 $bansubmit = $request->is_set_post('bansubmit');
037 $unbansubmit = $request->is_set_post('unbansubmit');
038
039 $user->add_lang(array('acp/ban', 'acp/users'));
040 $this->tpl_name = 'mcp_ban';
041
042 /**
043 * Use this event to pass perform actions when a ban is issued or revoked
044 *
045 * @event core.mcp_ban_main
046 * @var bool bansubmit True if a ban is issued
047 * @var bool unbansubmit True if a ban is removed
048 * @var string mode Mode of the ban that is being worked on
049 * @since 3.1.0-RC5
050 */
051 $vars = array(
052 'bansubmit',
053 'unbansubmit',
054 'mode',
055 );
056 extract($phpbb_dispatcher->trigger_event('core.mcp_ban_main', compact($vars)));
057
058 // Ban submitted?
059 if ($bansubmit)
060 {
061 // Grab the list of entries
062 $ban = $request->variable('ban', '', $mode === 'user');
063 $ban_length = $request->variable('banlength', 0);
064 $ban_length_other = $request->variable('banlengthother', '');
065 $ban_exclude = $request->variable('banexclude', 0);
066 $ban_reason = $request->variable('banreason', '', true);
067 $ban_give_reason = $request->variable('bangivereason', '', true);
068
069 if ($ban)
070 {
071 if (confirm_box(true))
072 {
073 $abort_ban = false;
074 /**
075 * Use this event to modify the ban details before the ban is performed
076 *
077 * @event core.mcp_ban_before
078 * @var string mode One of the following: user, ip, email
079 * @var string ban Either string or array with usernames, ips or email addresses
080 * @var int ban_length Ban length in minutes
081 * @var string ban_length_other Ban length as a date (YYYY-MM-DD)
082 * @var bool ban_exclude Are we banning or excluding from another ban
083 * @var string ban_reason Ban reason displayed to moderators
084 * @var string ban_give_reason Ban reason displayed to the banned user
085 * @var mixed abort_ban Either false, or an error message that is displayed to the user.
086 * If a string is given the bans are not issued.
087 * @since 3.1.0-RC5
088 */
089 $vars = array(
090 'mode',
091 'ban',
092 'ban_length',
093 'ban_length_other',
094 'ban_exclude',
095 'ban_reason',
096 'ban_give_reason',
097 'abort_ban',
098 );
099 extract($phpbb_dispatcher->trigger_event('core.mcp_ban_before', compact($vars)));
100
101 if ($abort_ban)
102 {
103 trigger_error($abort_ban);
104 }
105 user_ban($mode, $ban, $ban_length, $ban_length_other, $ban_exclude, $ban_reason, $ban_give_reason);
106
107 /**
108 * Use this event to perform actions after the ban has been performed
109 *
110 * @event core.mcp_ban_after
111 * @var string mode One of the following: user, ip, email
112 * @var string ban Either string or array with usernames, ips or email addresses
113 * @var int ban_length Ban length in minutes
114 * @var string ban_length_other Ban length as a date (YYYY-MM-DD)
115 * @var bool ban_exclude Are we banning or excluding from another ban
116 * @var string ban_reason Ban reason displayed to moderators
117 * @var string ban_give_reason Ban reason displayed to the banned user
118 * @since 3.1.0-RC5
119 */
120 $vars = array(
121 'mode',
122 'ban',
123 'ban_length',
124 'ban_length_other',
125 'ban_exclude',
126 'ban_reason',
127 'ban_give_reason',
128 );
129 extract($phpbb_dispatcher->trigger_event('core.mcp_ban_after', compact($vars)));
130
131 trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . '<br /><br /><a href="' . $this->u_action . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>');
132 }
133 else
134 {
135 $hidden_fields = array(
136 'mode' => $mode,
137 'ban' => $ban,
138 'bansubmit' => true,
139 'banlength' => $ban_length,
140 'banlengthother' => $ban_length_other,
141 'banexclude' => $ban_exclude,
142 'banreason' => $ban_reason,
143 'bangivereason' => $ban_give_reason,
144 );
145
146 /**
147 * Use this event to pass data from the ban form to the confirmation screen
148 *
149 * @event core.mcp_ban_confirm
150 * @var array hidden_fields Hidden fields that are passed through the confirm screen
151 * @since 3.1.0-RC5
152 */
153 $vars = array('hidden_fields');
154 extract($phpbb_dispatcher->trigger_event('core.mcp_ban_confirm', compact($vars)));
155
156 confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($hidden_fields));
157 }
158 }
159 }
160 else if ($unbansubmit)
161 {
162 $ban = $request->variable('unban', array(''));
163
164 if ($ban)
165 {
166 if (confirm_box(true))
167 {
168 user_unban($mode, $ban);
169
170 trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . '<br /><br /><a href="' . $this->u_action . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>');
171 }
172 else
173 {
174 confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
175 'mode' => $mode,
176 'unbansubmit' => true,
177 'unban' => $ban)));
178 }
179 }
180 }
181
182 // Ban length options
183 $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'] . ' -> ');
184
185 $ban_end_options = '';
186 foreach ($ban_end_text as $length => $text)
187 {
188 $ban_end_options .= '<option value="' . $length . '">' . $text . '</option>';
189 }
190
191 // Define language vars
192 $this->page_title = $user->lang[strtoupper($mode) . '_BAN'];
193
194 $l_ban_explain = $user->lang[strtoupper($mode) . '_BAN_EXPLAIN'];
195 $l_ban_exclude_explain = $user->lang[strtoupper($mode) . '_BAN_EXCLUDE_EXPLAIN'];
196 $l_unban_title = $user->lang[strtoupper($mode) . '_UNBAN'];
197 $l_unban_explain = $user->lang[strtoupper($mode) . '_UNBAN_EXPLAIN'];
198 $l_no_ban_cell = $user->lang[strtoupper($mode) . '_NO_BANNED'];
199
200 switch ($mode)
201 {
202 case 'user':
203 $l_ban_cell = $user->lang['USERNAME'];
204 break;
205
206 case 'ip':
207 $l_ban_cell = $user->lang['IP_HOSTNAME'];
208 break;
209
210 case 'email':
211 $l_ban_cell = $user->lang['EMAIL_ADDRESS'];
212 break;
213 }
214
215 acp_ban::display_ban_options($mode);
216
217 $template->assign_vars(array(
218 'L_TITLE' => $this->page_title,
219 'L_EXPLAIN' => $l_ban_explain,
220 'L_UNBAN_TITLE' => $l_unban_title,
221 'L_UNBAN_EXPLAIN' => $l_unban_explain,
222 'L_BAN_CELL' => $l_ban_cell,
223 'L_BAN_EXCLUDE_EXPLAIN' => $l_ban_exclude_explain,
224 'L_NO_BAN_CELL' => $l_no_ban_cell,
225
226 'S_USERNAME_BAN' => ($mode == 'user') ? true : false,
227
228 'U_ACTION' => $this->u_action,
229 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=mcp_ban&field=ban'),
230 ));
231
232 if ($mode === 'email' && !$auth->acl_get('a_user'))
233 {
234 return;
235 }
236
237 // As a "service" we will check if any post id is specified and populate the username of the poster id if given
238 $post_id = $request->variable('p', 0);
239 $user_id = $request->variable('u', 0);
240 $pre_fill = false;
241
242 if ($user_id && $user_id <> ANONYMOUS)
243 {
244 $sql = 'SELECT username, user_email, user_ip
245 FROM ' . USERS_TABLE . '
246 WHERE user_id = ' . $user_id;
247 $result = $db->sql_query($sql);
248 switch ($mode)
249 {
250 case 'user':
251 $pre_fill = (string) $db->sql_fetchfield('username');
252 break;
253
254 case 'ip':
255 $pre_fill = (string) $db->sql_fetchfield('user_ip');
256 break;
257
258 case 'email':
259 $pre_fill = (string) $db->sql_fetchfield('user_email');
260 break;
261 }
262 $db->sql_freeresult($result);
263 }
264 else if ($post_id)
265 {
266 $post_info = phpbb_get_post_data($post_id, 'm_ban');
267
268 if (sizeof($post_info) && !empty($post_info[$post_id]))
269 {
270 switch ($mode)
271 {
272 case 'user':
273 $pre_fill = $post_info[$post_id]['username'];
274 break;
275
276 case 'ip':
277 $pre_fill = $post_info[$post_id]['poster_ip'];
278 break;
279
280 case 'email':
281 $pre_fill = $post_info[$post_id]['user_email'];
282 break;
283 }
284
285 }
286 }
287
288 if ($pre_fill)
289 {
290 // left for legacy template compatibility
291 $template->assign_var('USERNAMES', $pre_fill);
292 $template->assign_var('BAN_QUANTIFIER', $pre_fill);
293 }
294 }
295 }
296