|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Simple Machines Forum (SMF) |
|
4
|
|
|
* |
|
5
|
|
|
* @package SMF |
|
6
|
|
|
* @author Simple Machines https://www.simplemachines.org |
|
7
|
|
|
* @copyright 2022 Simple Machines and individual contributors |
|
8
|
|
|
* @license https://www.simplemachines.org/about/smf/license.php BSD |
|
9
|
|
|
* |
|
10
|
|
|
* @version 2.1 RC4 |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Add or edit a ban |
|
15
|
|
|
*/ |
|
16
|
|
|
function template_ban_edit() |
|
17
|
|
|
{ |
|
18
|
|
|
global $context, $scripturl, $txt, $modSettings; |
|
19
|
|
|
|
|
20
|
|
|
echo ' |
|
21
|
|
|
<div id="manage_bans"> |
|
22
|
|
|
<form id="admin_form_wrapper" action="', $context['form_url'], '" method="post" accept-charset="', $context['character_set'], '" onsubmit="return confirmBan(this);">'; |
|
23
|
|
|
|
|
24
|
|
|
// If there were errors creating the ban, show them. |
|
25
|
|
|
if (!empty($context['error_messages'])) |
|
26
|
|
|
{ |
|
27
|
|
|
echo ' |
|
28
|
|
|
<div class="errorbox"> |
|
29
|
|
|
<strong>', $txt['ban_errors_detected'], '</strong> |
|
30
|
|
|
<ul>'; |
|
31
|
|
|
|
|
32
|
|
|
foreach ($context['error_messages'] as $error) |
|
33
|
|
|
echo ' |
|
34
|
|
|
<li class="error">', $error, '</li>'; |
|
35
|
|
|
|
|
36
|
|
|
echo ' |
|
37
|
|
|
</ul> |
|
38
|
|
|
</div>'; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
echo ' |
|
42
|
|
|
<div class="cat_bar"> |
|
43
|
|
|
<h3 class="catbg"> |
|
44
|
|
|
', $context['ban']['is_new'] ? $txt['ban_add_new'] : $txt['ban_edit'] . ' \'' . $context['ban']['name'] . '\'', ' |
|
45
|
|
|
</h3> |
|
46
|
|
|
</div>'; |
|
47
|
|
|
|
|
48
|
|
|
if ($context['ban']['is_new']) |
|
49
|
|
|
echo ' |
|
50
|
|
|
<div class="information noup">', $txt['ban_add_notes'], '</div>'; |
|
51
|
|
|
|
|
52
|
|
|
echo ' |
|
53
|
|
|
<div class="windowbg noup"> |
|
54
|
|
|
<dl class="settings"> |
|
55
|
|
|
<dt id="ban_name_label"> |
|
56
|
|
|
<strong>', $txt['ban_name'], ':</strong> |
|
57
|
|
|
</dt> |
|
58
|
|
|
<dd> |
|
59
|
|
|
<input type="text" id="ban_name" name="ban_name" value="', $context['ban']['name'], '" size="45" maxlength="60"> |
|
60
|
|
|
</dd>'; |
|
61
|
|
|
|
|
62
|
|
|
if (isset($context['ban']['reason'])) |
|
63
|
|
|
echo ' |
|
64
|
|
|
<dt> |
|
65
|
|
|
<strong><label for="reason">', $txt['ban_reason'], ':</label></strong><br> |
|
66
|
|
|
<span class="smalltext">', $txt['ban_reason_desc'], '</span> |
|
67
|
|
|
</dt> |
|
68
|
|
|
<dd> |
|
69
|
|
|
<textarea name="reason" id="reason" cols="40" rows="3">', $context['ban']['reason'], '</textarea> |
|
70
|
|
|
</dd>'; |
|
71
|
|
|
|
|
72
|
|
|
if (isset($context['ban']['notes'])) |
|
73
|
|
|
echo ' |
|
74
|
|
|
<dt> |
|
75
|
|
|
<strong><label for="ban_notes">', $txt['ban_notes'], ':</label></strong><br> |
|
76
|
|
|
<span class="smalltext">', $txt['ban_notes_desc'], '</span> |
|
77
|
|
|
</dt> |
|
78
|
|
|
<dd> |
|
79
|
|
|
<textarea name="notes" id="ban_notes" cols="40" rows="3">', $context['ban']['notes'], '</textarea> |
|
80
|
|
|
</dd>'; |
|
81
|
|
|
|
|
82
|
|
|
echo ' |
|
83
|
|
|
</dl> |
|
84
|
|
|
<fieldset class="ban_settings floatleft"> |
|
85
|
|
|
<legend> |
|
86
|
|
|
', $txt['ban_expiration'], ' |
|
87
|
|
|
</legend> |
|
88
|
|
|
<input type="radio" name="expiration" value="never" id="never_expires" onclick="fUpdateStatus();"', $context['ban']['expiration']['status'] == 'never' ? ' checked' : '', '> <label for="never_expires">', $txt['never'], '</label><br> |
|
89
|
|
|
<input type="radio" name="expiration" value="one_day" id="expires_one_day" onclick="fUpdateStatus();"', $context['ban']['expiration']['status'] == 'one_day' ? ' checked' : '', '> <label for="expires_one_day">', $txt['ban_will_expire_within'], '</label>: <input type="number" name="expire_date" id="expire_date" size="3" value="', $context['ban']['expiration']['days'], '"> ', $txt['ban_days'], '<br> |
|
90
|
|
|
<input type="radio" name="expiration" value="expired" id="already_expired" onclick="fUpdateStatus();"', $context['ban']['expiration']['status'] == 'expired' ? ' checked' : '', '> <label for="already_expired">', $txt['ban_expired'], '</label> |
|
91
|
|
|
</fieldset> |
|
92
|
|
|
<fieldset class="ban_settings floatright"> |
|
93
|
|
|
<legend> |
|
94
|
|
|
', $txt['ban_restriction'], ' |
|
95
|
|
|
</legend> |
|
96
|
|
|
<input type="radio" name="full_ban" id="full_ban" value="1" onclick="fUpdateStatus();"', $context['ban']['cannot']['access'] ? ' checked' : '', '> <label for="full_ban">', $txt['ban_full_ban'], '</label><br> |
|
97
|
|
|
<input type="radio" name="full_ban" id="partial_ban" value="0" onclick="fUpdateStatus();"', !$context['ban']['cannot']['access'] ? ' checked' : '', '> <label for="partial_ban">', $txt['ban_partial_ban'], '</label><br> |
|
98
|
|
|
<input type="checkbox" name="cannot_post" id="cannot_post" value="1"', $context['ban']['cannot']['post'] ? ' checked' : '', ' class="ban_restriction"> <label for="cannot_post">', $txt['ban_cannot_post'], '</label> (<a href="', $scripturl, '?action=helpadmin;help=ban_cannot_post" onclick="return reqOverlayDiv(this.href);">?</a>)<br> |
|
99
|
|
|
<input type="checkbox" name="cannot_register" id="cannot_register" value="1"', $context['ban']['cannot']['register'] ? ' checked' : '', ' class="ban_restriction"> <label for="cannot_register">', $txt['ban_cannot_register'], '</label><br> |
|
100
|
|
|
<input type="checkbox" name="cannot_login" id="cannot_login" value="1"', $context['ban']['cannot']['login'] ? ' checked' : '', ' class="ban_restriction"> <label for="cannot_login">', $txt['ban_cannot_login'], '</label><br> |
|
101
|
|
|
</fieldset> |
|
102
|
|
|
<br class="clear_right">'; |
|
103
|
|
|
|
|
104
|
|
|
if (!empty($context['ban_suggestions'])) |
|
105
|
|
|
{ |
|
106
|
|
|
echo ' |
|
107
|
|
|
<fieldset> |
|
108
|
|
|
<legend> |
|
109
|
|
|
<input type="checkbox" onclick="invertAll(this, this.form, \'ban_suggestion\');"> ', $txt['ban_triggers'], ' |
|
110
|
|
|
</legend> |
|
111
|
|
|
<dl class="settings"> |
|
112
|
|
|
<dt> |
|
113
|
|
|
<input type="checkbox" name="ban_suggestions[]" id="main_ip_check" value="main_ip"', !empty($context['ban_suggestions']['main_ip']) ? ' checked' : '', '> |
|
114
|
|
|
<label for="main_ip_check">', $txt['ban_on_ip'], '</label> |
|
115
|
|
|
</dt> |
|
116
|
|
|
<dd> |
|
117
|
|
|
<input type="text" name="main_ip" value="', $context['ban_suggestions']['main_ip'], '" size="44" onfocus="document.getElementById(\'main_ip_check\').checked = true;"> |
|
118
|
|
|
</dd>'; |
|
119
|
|
|
|
|
120
|
|
|
if (empty($modSettings['disableHostnameLookup'])) |
|
121
|
|
|
echo ' |
|
122
|
|
|
<dt> |
|
123
|
|
|
<input type="checkbox" name="ban_suggestions[]" id="hostname_check" value="hostname"', !empty($context['ban_suggestions']['hostname']) ? ' checked' : '', '> |
|
124
|
|
|
<label for="hostname_check">', $txt['ban_on_hostname'], '</label> |
|
125
|
|
|
</dt> |
|
126
|
|
|
<dd> |
|
127
|
|
|
<input type="text" name="hostname" value="', $context['ban_suggestions']['hostname'], '" size="44" onfocus="document.getElementById(\'hostname_check\').checked = true;"> |
|
128
|
|
|
</dd>'; |
|
129
|
|
|
|
|
130
|
|
|
echo ' |
|
131
|
|
|
<dt> |
|
132
|
|
|
<input type="checkbox" name="ban_suggestions[]" id="email_check" value="email"', !empty($context['ban_suggestions']['email']) ? ' checked' : '', '> |
|
133
|
|
|
<label for="email_check">', $txt['ban_on_email'], '</label> |
|
134
|
|
|
</dt> |
|
135
|
|
|
<dd> |
|
136
|
|
|
<input type="email" name="email" value="', $context['ban_suggestions']['email'], '" size="44" onfocus="document.getElementById(\'email_check\').checked = true;"> |
|
137
|
|
|
</dd> |
|
138
|
|
|
<dt> |
|
139
|
|
|
<input type="checkbox" name="ban_suggestions[]" id="user_check" value="user"', !empty($context['ban_suggestions']['user']) || isset($context['ban']['from_user']) ? ' checked' : '', '> |
|
140
|
|
|
<label for="user_check">', $txt['ban_on_username'], '</label>: |
|
141
|
|
|
</dt> |
|
142
|
|
|
<dd> |
|
143
|
|
|
<input type="text" ', isset($context['ban']['from_user']) ? 'readonly value="' . $context['ban_suggestions']['member']['name'] . '"' : ' value=""', ' name="user" id="user" size="44"> |
|
144
|
|
|
</dd> |
|
145
|
|
|
</dl>'; |
|
146
|
|
|
|
|
147
|
|
|
if (!empty($context['ban_suggestions']['other_ips'])) |
|
148
|
|
|
{ |
|
149
|
|
|
foreach ($context['ban_suggestions']['other_ips'] as $key => $ban_ips) |
|
150
|
|
|
{ |
|
151
|
|
|
if (!empty($ban_ips)) |
|
152
|
|
|
{ |
|
153
|
|
|
echo ' |
|
154
|
|
|
<div>', $txt[$key], ':</div> |
|
155
|
|
|
<dl class="settings">'; |
|
156
|
|
|
|
|
157
|
|
|
$count = 0; |
|
158
|
|
|
foreach ($ban_ips as $ip) |
|
159
|
|
|
echo ' |
|
160
|
|
|
<dt> |
|
161
|
|
|
<input type="checkbox" id="suggestions_', $key, '_', $count, '" name="ban_suggestions[', $key, '][]"', !empty($context['ban_suggestions']['saved_triggers'][$key]) && in_array($ip, $context['ban_suggestions']['saved_triggers'][$key]) ? ' checked' : '', ' value="', $ip, '"> |
|
162
|
|
|
</dt> |
|
163
|
|
|
<dd> |
|
164
|
|
|
<label for="suggestions_', $key, '_', $count++, '">', $ip, '</label> |
|
165
|
|
|
</dd>'; |
|
166
|
|
|
|
|
167
|
|
|
echo ' |
|
168
|
|
|
</dl>'; |
|
169
|
|
|
} |
|
170
|
|
|
} |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
echo ' |
|
174
|
|
|
</fieldset>'; |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
echo ' |
|
178
|
|
|
<input type="submit" name="', $context['ban']['is_new'] ? 'add_ban' : 'modify_ban', '" value="', $context['ban']['is_new'] ? $txt['ban_add'] : $txt['ban_modify'], '" class="button"> |
|
179
|
|
|
<input type="hidden" name="old_expire" value="', $context['ban']['expiration']['days'], '"> |
|
180
|
|
|
<input type="hidden" name="bg" value="', $context['ban']['id'], '">', isset($context['ban']['from_user']) ? ' |
|
181
|
|
|
<input type="hidden" name="u" value="' . $context['ban_suggestions']['member']['id'] . '">' : '', ' |
|
182
|
|
|
<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
|
183
|
|
|
<input type="hidden" name="', $context['admin-bet_token_var'], '" value="', $context['admin-bet_token'], '"> |
|
184
|
|
|
</div><!-- .windowbg --> |
|
185
|
|
|
</form>'; |
|
186
|
|
|
|
|
187
|
|
|
if (!$context['ban']['is_new'] && empty($context['ban_suggestions'])) |
|
188
|
|
|
{ |
|
189
|
|
|
echo ' |
|
190
|
|
|
<br>'; |
|
191
|
|
|
template_show_list('ban_items'); |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
echo ' |
|
195
|
|
|
</div><!-- #manage_bans --> |
|
196
|
|
|
<script> |
|
197
|
|
|
var fUpdateStatus = function () |
|
198
|
|
|
{ |
|
199
|
|
|
document.getElementById("expire_date").disabled = !document.getElementById("expires_one_day").checked; |
|
200
|
|
|
document.getElementById("cannot_post").disabled = document.getElementById("full_ban").checked; |
|
201
|
|
|
document.getElementById("cannot_register").disabled = document.getElementById("full_ban").checked; |
|
202
|
|
|
document.getElementById("cannot_login").disabled = document.getElementById("full_ban").checked; |
|
203
|
|
|
} |
|
204
|
|
|
addLoadEvent(fUpdateStatus);'; |
|
205
|
|
|
|
|
206
|
|
|
// Auto suggest only needed for adding new bans, not editing |
|
207
|
|
|
if ($context['ban']['is_new'] && empty($_REQUEST['u'])) |
|
208
|
|
|
echo ' |
|
209
|
|
|
var oAddMemberSuggest = new smc_AutoSuggest({ |
|
210
|
|
|
sSelf: \'oAddMemberSuggest\', |
|
211
|
|
|
sSessionId: smf_session_id, |
|
212
|
|
|
sSessionVar: smf_session_var, |
|
213
|
|
|
sSuggestId: \'user\', |
|
214
|
|
|
sControlId: \'user\', |
|
215
|
|
|
sSearchType: \'member\', |
|
216
|
|
|
sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\', |
|
217
|
|
|
bItemList: false |
|
218
|
|
|
}); |
|
219
|
|
|
|
|
220
|
|
|
function onUpdateName(oAutoSuggest) |
|
221
|
|
|
{ |
|
222
|
|
|
document.getElementById(\'user_check\').checked = true; |
|
223
|
|
|
return true; |
|
224
|
|
|
} |
|
225
|
|
|
oAddMemberSuggest.registerCallback(\'onBeforeUpdate\', \'onUpdateName\');'; |
|
226
|
|
|
|
|
227
|
|
|
echo ' |
|
228
|
|
|
function confirmBan(aForm) |
|
229
|
|
|
{ |
|
230
|
|
|
if (aForm.ban_name.value == \'\') |
|
231
|
|
|
{ |
|
232
|
|
|
alert(\'', $txt['ban_name_empty'], '\'); |
|
233
|
|
|
return false; |
|
234
|
|
|
} |
|
235
|
|
|
|
|
236
|
|
|
if (aForm.partial_ban.checked && !(aForm.cannot_post.checked || aForm.cannot_register.checked || aForm.cannot_login.checked)) |
|
237
|
|
|
{ |
|
238
|
|
|
alert(\'', $txt['ban_restriction_empty'], '\'); |
|
239
|
|
|
return false; |
|
240
|
|
|
} |
|
241
|
|
|
} |
|
242
|
|
|
</script>'; |
|
243
|
|
|
} |
|
244
|
|
|
|
|
245
|
|
|
/** |
|
246
|
|
|
* Add or edit a ban trigger |
|
247
|
|
|
*/ |
|
248
|
|
|
function template_ban_edit_trigger() |
|
249
|
|
|
{ |
|
250
|
|
|
global $context, $txt, $modSettings; |
|
251
|
|
|
|
|
252
|
|
|
echo ' |
|
253
|
|
|
<div id="manage_bans"> |
|
254
|
|
|
<form id="admin_form_wrapper" action="', $context['form_url'], '" method="post" accept-charset="', $context['character_set'], '"> |
|
255
|
|
|
<div class="cat_bar"> |
|
256
|
|
|
<h3 class="catbg"> |
|
257
|
|
|
', $context['ban_trigger']['is_new'] ? $txt['ban_add_trigger'] : $txt['ban_edit_trigger_title'], ' |
|
258
|
|
|
</h3> |
|
259
|
|
|
</div> |
|
260
|
|
|
<div class="windowbg"> |
|
261
|
|
|
<fieldset>'; |
|
262
|
|
|
if ($context['ban_trigger']['is_new']) |
|
263
|
|
|
echo ' |
|
264
|
|
|
<legend> |
|
265
|
|
|
<input type="checkbox" onclick="invertAll(this, this.form, \'ban_suggestion\');"> ', $txt['ban_triggers'], ' |
|
266
|
|
|
</legend>'; |
|
267
|
|
|
echo ' |
|
268
|
|
|
<dl class="settings">'; |
|
269
|
|
|
if ($context['ban_trigger']['is_new'] || $context['ban_trigger']['ip']['selected']) |
|
270
|
|
|
echo ' |
|
271
|
|
|
<dt> |
|
272
|
|
|
<input type="checkbox" name="ban_suggestions[]" id="main_ip_check" value="main_ip"', $context['ban_trigger']['ip']['selected'] ? ' checked' : '', '> |
|
273
|
|
|
<label for="main_ip_check">', $txt['ban_on_ip'], '</label> |
|
274
|
|
|
</dt> |
|
275
|
|
|
<dd> |
|
276
|
|
|
<input type="text" name="main_ip" value="', $context['ban_trigger']['ip']['value'], '" size="44" onfocus="document.getElementById(\'main_ip_check\').checked = true;"> |
|
277
|
|
|
</dd>'; |
|
278
|
|
|
|
|
279
|
|
|
if (empty($modSettings['disableHostnameLookup']) && ($context['ban_trigger']['is_new'] || $context['ban_trigger']['hostname']['selected'])) |
|
280
|
|
|
echo ' |
|
281
|
|
|
<dt> |
|
282
|
|
|
<input type="checkbox" name="ban_suggestions[]" id="hostname_check" value="hostname"', $context['ban_trigger']['hostname']['selected'] ? ' checked' : '', '> |
|
283
|
|
|
<label for="hostname_check">', $txt['ban_on_hostname'], '</label> |
|
284
|
|
|
</dt> |
|
285
|
|
|
<dd> |
|
286
|
|
|
<input type="text" name="hostname" value="', $context['ban_trigger']['hostname']['value'], '" size="44" onfocus="document.getElementById(\'hostname_check\').checked = true;"> |
|
287
|
|
|
</dd>'; |
|
288
|
|
|
if ($context['ban_trigger']['is_new'] || $context['ban_trigger']['email']['selected']) |
|
289
|
|
|
echo ' |
|
290
|
|
|
<dt> |
|
291
|
|
|
<input type="checkbox" name="ban_suggestions[]" id="email_check" value="email"', $context['ban_trigger']['email']['selected'] ? ' checked' : '', '> |
|
292
|
|
|
<label for="email_check">', $txt['ban_on_email'], '</label> |
|
293
|
|
|
</dt> |
|
294
|
|
|
<dd> |
|
295
|
|
|
<input type="email" name="email" value="', $context['ban_trigger']['email']['value'], '" size="44" onfocus="document.getElementById(\'email_check\').checked = true;"> |
|
296
|
|
|
</dd>'; |
|
297
|
|
|
if ($context['ban_trigger']['is_new'] || $context['ban_trigger']['banneduser']['selected']) |
|
298
|
|
|
echo ' |
|
299
|
|
|
<dt> |
|
300
|
|
|
<input type="checkbox" name="ban_suggestions[]" id="user_check" value="user"', $context['ban_trigger']['banneduser']['selected'] ? ' checked' : '', '> |
|
301
|
|
|
<label for="user_check">', $txt['ban_on_username'], '</label>: |
|
302
|
|
|
</dt> |
|
303
|
|
|
<dd> |
|
304
|
|
|
<input type="text" value="' . $context['ban_trigger']['banneduser']['value'] . '" name="user" id="user" size="44" onfocus="document.getElementById(\'user_check\').checked = true;"> |
|
305
|
|
|
</dd>'; |
|
306
|
|
|
echo ' |
|
307
|
|
|
</dl> |
|
308
|
|
|
</fieldset> |
|
309
|
|
|
<input type="submit" name="', $context['ban_trigger']['is_new'] ? 'add_new_trigger' : 'edit_trigger', '" value="', $context['ban_trigger']['is_new'] ? $txt['ban_add_trigger_submit'] : $txt['ban_edit_trigger_submit'], '" class="button"> |
|
310
|
|
|
</div><!-- .windowbg --> |
|
311
|
|
|
<input type="hidden" name="bi" value="' . $context['ban_trigger']['id'] . '"> |
|
312
|
|
|
<input type="hidden" name="bg" value="' . $context['ban_trigger']['group'] . '"> |
|
313
|
|
|
<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '"> |
|
314
|
|
|
<input type="hidden" name="', $context['admin-bet_token_var'], '" value="', $context['admin-bet_token'], '"> |
|
315
|
|
|
</form> |
|
316
|
|
|
</div><!-- #manage_bans --> |
|
317
|
|
|
<script> |
|
318
|
|
|
var oAddMemberSuggest = new smc_AutoSuggest({ |
|
319
|
|
|
sSelf: \'oAddMemberSuggest\', |
|
320
|
|
|
sSessionId: smf_session_id, |
|
321
|
|
|
sSessionVar: smf_session_var, |
|
322
|
|
|
sSuggestId: \'username\', |
|
323
|
|
|
sControlId: \'user\', |
|
324
|
|
|
sSearchType: \'member\', |
|
325
|
|
|
sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\', |
|
326
|
|
|
bItemList: false |
|
327
|
|
|
}); |
|
328
|
|
|
|
|
329
|
|
|
function onUpdateName(oAutoSuggest) |
|
330
|
|
|
{ |
|
331
|
|
|
document.getElementById(\'user_check\').checked = true; |
|
332
|
|
|
return true; |
|
333
|
|
|
} |
|
334
|
|
|
oAddMemberSuggest.registerCallback(\'onBeforeUpdate\', \'onUpdateName\'); |
|
335
|
|
|
</script>'; |
|
336
|
|
|
} |
|
337
|
|
|
|
|
338
|
|
|
?> |