jdarwood007 commited on 2024-01-07 17:47:20
Showing 6 changed files, with 138 additions and 96 deletions.
... | ... |
@@ -22,11 +23,11 @@ class a2ebg |
22 | 23 |
|
23 | 24 |
self::loadLanguage(); |
24 | 25 |
|
25 |
- $config_vars[] = array( |
|
26 |
+ $config_vars[] = [ |
|
26 | 27 |
'select', 'aebg_auto_select', |
27 |
- array('main_ip_check' => $txt['ban_on_ip'], 'hostname_check' => $txt['ban_on_hostname'], 'email_check' => $txt['ban_on_email'], 'user_check' => $txt['ban_on_username']), |
|
28 |
+ ['main_ip_check' => $txt['ban_on_ip'], 'hostname_check' => $txt['ban_on_hostname'], 'email_check' => $txt['ban_on_email'], 'user_check' => $txt['ban_on_username']], |
|
28 | 29 |
'multiple' => true, |
29 |
- ); |
|
30 |
+ ]; |
|
30 | 31 |
} |
31 | 32 |
|
32 | 33 |
// This is called when we edit a ban regardless of if its new or not. |
... | ... |
@@ -38,65 +39,68 @@ class a2ebg |
38 | 39 |
$ban_info['easy_ban_group'] = empty($_POST['easy_ban_group']) ? '0' : '1'; |
39 | 40 |
|
40 | 41 |
// We are adding or modifying a ban normally. |
41 |
- if (empty($_POST['ban_group'])) |
|
42 |
- { |
|
43 |
- if (!empty($_POST['bg'])) |
|
44 |
- { |
|
45 |
- $request = $smcFunc['db_query']('', ' |
|
42 |
+ if (empty($_POST['ban_group'])) { |
|
43 |
+ if (!empty($_POST['bg'])) { |
|
44 |
+ $request = $smcFunc['db_query']( |
|
45 |
+ '', |
|
46 |
+ ' |
|
46 | 47 |
SELECT |
47 | 48 |
bg.id_ban_group, bg.easy_bg |
48 | 49 |
FROM {db_prefix}ban_groups AS bg |
49 | 50 |
WHERE bg.id_ban_group = {int:current_ban}', |
50 |
- array( |
|
51 |
+ [ |
|
51 | 52 |
'current_ban' => (int) $_REQUEST['bg'], |
52 |
- ) |
|
53 |
+ ], |
|
53 | 54 |
); |
54 | 55 |
$row = $smcFunc['db_fetch_assoc']($request); |
55 | 56 |
$smcFunc['db_free_result']($request); |
56 | 57 |
|
57 | 58 |
$context['ban']['id'] = $row['id_ban_group']; |
58 | 59 |
$context['ban']['easy_bg'] = $row['easy_bg']; |
59 |
- } |
|
60 |
- else |
|
60 |
+ } else { |
|
61 | 61 |
$context['ban']['easy_bg'] = 0; |
62 |
+ } |
|
62 | 63 |
|
63 | 64 |
$context['easy_ban_group'] = $ban_info['easy_ban_group']; |
65 |
+ |
|
64 | 66 |
return; |
65 | 67 |
} |
66 | 68 |
|
67 | 69 |
// This occurs when we are "adding" a ban. |
68 |
- $request = $smcFunc['db_query']('', ' |
|
70 |
+ $request = $smcFunc['db_query']( |
|
71 |
+ '', |
|
72 |
+ ' |
|
69 | 73 |
SELECT |
70 | 74 |
bg.id_ban_group, bg.name, bg.ban_time, COALESCE(bg.expire_time, 0) AS expire_time, bg.reason, bg.notes, bg.cannot_access, bg.cannot_register, bg.cannot_login, bg.cannot_post, bg.easy_bg |
71 | 75 |
FROM {db_prefix}ban_groups AS bg |
72 | 76 |
WHERE bg.id_ban_group = {int:current_ban}', |
73 |
- array( |
|
77 |
+ [ |
|
74 | 78 |
'current_ban' => (int) $_REQUEST['ban_group'], |
75 |
- ) |
|
79 |
+ ], |
|
76 | 80 |
); |
77 | 81 |
$row = $smcFunc['db_fetch_assoc']($request); |
78 | 82 |
$smcFunc['db_free_result']($request); |
79 | 83 |
|
80 |
- $context['ban'] = array( |
|
84 |
+ $context['ban'] = [ |
|
81 | 85 |
'id' => $row['id_ban_group'], |
82 | 86 |
'easy_bg' => $row['easy_bg'], |
83 | 87 |
'name' => $row['name'], |
84 |
- 'expiration' => array( |
|
88 |
+ 'expiration' => [ |
|
85 | 89 |
'status' => empty($row['expire_time']) ? 'never' : ($row['expire_time'] < time() ? 'expired' : 'one_day'), |
86 |
- 'days' => $row['expire_time'] > time() ? ($row['expire_time'] - time() < 86400 ? 1 : ceil(($row['expire_time'] - time()) / 86400)) : 0 |
|
87 |
- ), |
|
90 |
+ 'days' => $row['expire_time'] > time() ? ($row['expire_time'] - time() < 86400 ? 1 : ceil(($row['expire_time'] - time()) / 86400)) : 0, |
|
91 |
+ ], |
|
88 | 92 |
'reason' => $row['reason'], |
89 | 93 |
'notes' => $row['notes'], |
90 |
- 'cannot' => array( |
|
94 |
+ 'cannot' => [ |
|
91 | 95 |
'access' => !empty($row['cannot_access']), |
92 | 96 |
'post' => !empty($row['cannot_post']), |
93 | 97 |
'register' => !empty($row['cannot_register']), |
94 | 98 |
'login' => !empty($row['cannot_login']), |
95 |
- ), |
|
99 |
+ ], |
|
96 | 100 |
'is_new' => false, |
97 | 101 |
'hostname' => '', |
98 | 102 |
'email' => '', |
99 |
- ); |
|
103 |
+ ]; |
|
100 | 104 |
|
101 | 105 |
// Setup info for later. |
102 | 106 |
$ban_info = $context['ban']; |
... | ... |
@@ -129,24 +133,28 @@ class a2ebg |
129 | 133 |
loadTemplate('Add2ExistingBanGroup'); |
130 | 134 |
|
131 | 135 |
// Normal way of doing a new one? Skip. |
132 |
- if (empty($context['ban']['from_user'])) |
|
133 |
- { |
|
136 |
+ if (empty($context['ban']['from_user'])) { |
|
134 | 137 |
$context['template_layers'][] = 'easyban_edits'; |
138 |
+ |
|
135 | 139 |
return; |
136 | 140 |
} |
137 | 141 |
|
138 | 142 |
// Find our ban groups we can append. |
139 |
- $request = $smcFunc['db_query']('', ' |
|
143 |
+ $request = $smcFunc['db_query']( |
|
144 |
+ '', |
|
145 |
+ ' |
|
140 | 146 |
SELECT id_ban_group, name |
141 | 147 |
FROM {db_prefix}ban_groups |
142 | 148 |
WHERE easy_bg = {int:one} |
143 | 149 |
ORDER BY name', |
144 |
- array( |
|
150 |
+ [ |
|
145 | 151 |
'one' => '1', |
146 |
- ) |
|
152 |
+ ], |
|
147 | 153 |
); |
148 |
- while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
154 |
+ |
|
155 |
+ while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
149 | 156 |
$context['ban_group_suggestions'][$row['id_ban_group']] = $row['name']; |
157 |
+ } |
|
150 | 158 |
$smcFunc['db_free_result']($request); |
151 | 159 |
|
152 | 160 |
$context['ban_group_auto_selects'] = is_array($modSettings['aebg_auto_select']) ? $modSettings['aebg_auto_select'] : $smcFunc['json_decode']($modSettings['aebg_auto_select']); |
... | ... |
@@ -162,18 +170,21 @@ class a2ebg |
162 | 170 |
{ |
163 | 171 |
global $context, $smcFunc; |
164 | 172 |
|
165 |
- if (!isset($context['easy_ban_group'])) |
|
173 |
+ if (!isset($context['easy_ban_group'])) { |
|
166 | 174 |
return; |
175 |
+ } |
|
167 | 176 |
|
168 |
- $smcFunc['db_query']('', ' |
|
177 |
+ $smcFunc['db_query']( |
|
178 |
+ '', |
|
179 |
+ ' |
|
169 | 180 |
UPDATE {db_prefix}ban_groups |
170 | 181 |
SET |
171 | 182 |
easy_bg = {int:easy_bg} |
172 | 183 |
WHERE id_ban_group = {int:id_ban_group}', |
173 |
- array( |
|
184 |
+ [ |
|
174 | 185 |
'easy_bg' => $context['easy_ban_group'], |
175 | 186 |
'id_ban_group' => $context['ban']['id'], |
176 |
- ) |
|
187 |
+ ], |
|
177 | 188 |
); |
178 | 189 |
} |
179 | 190 |
|
... | ... |
@@ -183,21 +194,26 @@ class a2ebg |
183 | 194 |
global $smcFunc, $context; |
184 | 195 |
|
185 | 196 |
// Main page seems to call this as well. |
186 |
- if (empty($context['ban']['id'])) |
|
197 |
+ if (empty($context['ban']['id'])) { |
|
187 | 198 |
return; |
199 |
+ } |
|
188 | 200 |
|
189 |
- $request = $smcFunc['db_query']('', ' |
|
201 |
+ $request = $smcFunc['db_query']( |
|
202 |
+ '', |
|
203 |
+ ' |
|
190 | 204 |
SELECT |
191 | 205 |
bg.easy_bg |
192 | 206 |
FROM {db_prefix}ban_groups AS bg |
193 | 207 |
WHERE bg.id_ban_group = {int:current_ban} |
194 | 208 |
', |
195 |
- array( |
|
209 |
+ [ |
|
196 | 210 |
'current_ban' => $context['ban']['id'], |
197 |
- ) |
|
211 |
+ ], |
|
198 | 212 |
); |
199 |
- if ($smcFunc['db_num_rows']($request) == 0) |
|
213 |
+ |
|
214 |
+ if ($smcFunc['db_num_rows']($request) == 0) { |
|
200 | 215 |
fatal_lang_error('ban_not_found', false); |
216 |
+ } |
|
201 | 217 |
|
202 | 218 |
$row = $smcFunc['db_fetch_assoc']($request); |
203 | 219 |
$context['ban']['easy_bg'] = $row['easy_bg']; |
... | ... |
@@ -5,8 +5,7 @@ function template_easyban_above() |
5 | 5 |
global $context, $txt; |
6 | 6 |
|
7 | 7 |
// Only allow selecting a ban group if it is new. |
8 |
- if ($context['ban']['is_new'] && !empty($context['ban_group_suggestions'])) |
|
9 |
- { |
|
8 |
+ if ($context['ban']['is_new'] && !empty($context['ban_group_suggestions'])) { |
|
10 | 9 |
echo ' |
11 | 10 |
<div class="cat_bar"> |
12 | 11 |
<h3 class="catbg">', $txt['aebg_add_existing'], '</h3> |
... | ... |
@@ -15,9 +14,10 @@ function template_easyban_above() |
15 | 14 |
<select name="ban_group" onchange="disableOtherFields();" id="ban_group"> |
16 | 15 |
<option value="-1" selected="selected">', $txt['aebg_new_ban_group'], '</option>'; |
17 | 16 |
|
18 |
- foreach ($context['ban_group_suggestions'] as $id_ban_group => $ban_name) |
|
17 |
+ foreach ($context['ban_group_suggestions'] as $id_ban_group => $ban_name) { |
|
19 | 18 |
echo ' |
20 | 19 |
<option value="', $id_ban_group, '" onselect="disableOtherFields();">', $ban_name, '</option>'; |
20 |
+ } |
|
21 | 21 |
echo ' |
22 | 22 |
</select> |
23 | 23 |
</div>'; |
... | ... |
@@ -30,8 +30,7 @@ function template_easyban_below() |
30 | 30 |
global $context, $modSettings; |
31 | 31 |
|
32 | 32 |
// Only allow selecting a ban group if it is new. |
33 |
- if ($context['ban']['is_new'] && !empty($context['ban_group_suggestions'])) |
|
34 |
- { |
|
33 |
+ if ($context['ban']['is_new'] && !empty($context['ban_group_suggestions'])) { |
|
35 | 34 |
echo ' |
36 | 35 |
<script type="text/javascript"> |
37 | 36 |
function disableOtherFields() |
... | ... |
@@ -41,18 +40,21 @@ function template_easyban_below() |
41 | 40 |
$("#manage_bans .windowbg>.ban_settings").toggle(visibility);'; |
42 | 41 |
|
43 | 42 |
// Do we want to auto select some options? |
44 |
- if (!empty($modSettings['aebg_auto_select'])) |
|
45 |
- { |
|
43 |
+ if (!empty($modSettings['aebg_auto_select'])) { |
|
46 | 44 |
// Incase it isn't an array. |
47 |
- $allOptions = array_flip(array('main_ip_check', 'hostname_check', 'email_check', 'user_check')); |
|
48 |
- if (!empty($modSettings['disableHostnameLookup'])) |
|
45 |
+ $allOptions = array_flip(['main_ip_check', 'hostname_check', 'email_check', 'user_check']); |
|
46 |
+ |
|
47 |
+ if (!empty($modSettings['disableHostnameLookup'])) { |
|
49 | 48 |
unset($allOptions['hostname_check']); |
49 |
+ } |
|
50 | 50 |
|
51 | 51 |
$autoSelects = is_array($modSettings['aebg_auto_select']) ? $modSettings['aebg_auto_select'] : json_decode($modSettings['aebg_auto_select'], true); |
52 |
- foreach ($allOptions as $elID => $dummy) |
|
52 |
+ |
|
53 |
+ foreach ($allOptions as $elID => $dummy) { |
|
53 | 54 |
echo ' |
54 | 55 |
$("#', $elID, '").prop("checked", ', (in_array($elID, $autoSelects) ? 'true' : 'false'), ');'; |
55 | 56 |
} |
57 |
+ } |
|
56 | 58 |
|
57 | 59 |
echo ' |
58 | 60 |
} |
... | ... |
@@ -2,32 +3,36 @@ |
2 | 3 |
error_reporting(E_ALL); |
3 | 4 |
|
4 | 5 |
// Hopefully we have the goodies. |
5 |
-if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF')) |
|
6 |
-{ |
|
6 |
+if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF')) { |
|
7 | 7 |
$using_ssi = true; |
8 |
- require_once(dirname(__FILE__) . '/SSI.php'); |
|
9 |
-} |
|
10 |
-elseif (!defined('SMF')) |
|
8 |
+ |
|
9 |
+ require_once dirname(__FILE__) . '/SSI.php'; |
|
10 |
+} elseif (!defined('SMF')) { |
|
11 | 11 |
exit('<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.'); |
12 |
+} |
|
12 | 13 |
|
13 | 14 |
global $db_prefix, $modSettings, $func, $smcFunc; |
14 | 15 |
|
15 |
-if (version_compare('2.0 RC2', $modSettings['smfVersion']) > 0) |
|
16 |
+if (version_compare('2.0 RC2', $modSettings['smfVersion']) > 0) { |
|
16 | 17 |
exit('<b>Error:</b> Cannot install - Your SMF version is not sufficient enough. Please upgrade to SMF 2.0 RC2 or higher'); |
17 |
-elseif (version_compare('2.1 RC2', $modSettings['smfVersion']) > 0 && version_compare('2.1 Beta 1', $modSettings['smfVersion']) < 0) |
|
18 |
+} |
|
19 |
+ |
|
20 |
+if (version_compare('2.1 RC2', $modSettings['smfVersion']) > 0 && version_compare('2.1 Beta 1', $modSettings['smfVersion']) < 0) { |
|
18 | 21 |
exit('<b>Error:</b> Cannot install - Your SMF version is not sufficient enough. Please upgrade to SMF 2.1 RC2 or higher'); |
22 |
+} |
|
19 | 23 |
|
20 | 24 |
// Our column. |
21 | 25 |
$smcFunc['db_add_column']( |
22 |
- $db_prefix . "ban_groups", |
|
23 |
- array( |
|
26 |
+ $db_prefix . 'ban_groups', |
|
27 |
+ [ |
|
24 | 28 |
'name' => 'easy_bg', |
25 | 29 |
'type' => 'smallint', |
26 | 30 |
'size' => '3', |
27 | 31 |
'default' => 0, |
28 |
- ) |
|
32 |
+ ], |
|
29 | 33 |
); |
30 | 34 |
|
31 |
-if (!empty($using_ssi)) |
|
35 |
+if (!empty($using_ssi)) { |
|
32 | 36 |
echo 'If no errors, Success!'; |
37 |
+} |
|
33 | 38 |
?> |
34 | 39 |
\ No newline at end of file |
... | ... |
@@ -34,7 +34,7 @@ class a2ebg |
34 | 34 |
'main_ip_check' => Lang::$txt['ban_on_ip'], |
35 | 35 |
'hostname_check' => Lang::$txt['ban_on_hostname'], |
36 | 36 |
'email_check' => Lang::$txt['ban_on_email'], |
37 |
- 'user_check' => Lang::$txt['ban_on_username'] |
|
37 |
+ 'user_check' => Lang::$txt['ban_on_username'], |
|
38 | 38 |
], |
39 | 39 |
'multiple' => true, |
40 | 40 |
]; |
... | ... |
@@ -47,41 +47,44 @@ class a2ebg |
47 | 47 |
$ban_info['easy_ban_group'] = empty($_POST['easy_ban_group']) ? '0' : '1'; |
48 | 48 |
|
49 | 49 |
// We are adding or modifying a ban normally. |
50 |
- if (empty($_POST['ban_group'])) |
|
51 |
- { |
|
52 |
- if (!empty($_POST['bg'])) |
|
53 |
- { |
|
54 |
- $request = Db::$db->query('', ' |
|
50 |
+ if (empty($_POST['ban_group'])) { |
|
51 |
+ if (!empty($_POST['bg'])) { |
|
52 |
+ $request = Db::$db->query( |
|
53 |
+ '', |
|
54 |
+ ' |
|
55 | 55 |
SELECT |
56 | 56 |
bg.id_ban_group, bg.easy_bg |
57 | 57 |
FROM {db_prefix}ban_groups AS bg |
58 | 58 |
WHERE bg.id_ban_group = {int:current_ban}', |
59 | 59 |
[ |
60 | 60 |
'current_ban' => (int) $_REQUEST['bg'], |
61 |
- ] |
|
61 |
+ ], |
|
62 | 62 |
); |
63 | 63 |
$row = Db::$db->fetch_assoc($request); |
64 | 64 |
Db::$db->free_result($request); |
65 | 65 |
|
66 | 66 |
Utils::$context['ban']['id'] = (int) $row['id_ban_group']; |
67 | 67 |
Utils::$context['ban']['easy_bg'] = $row['easy_bg']; |
68 |
- } |
|
69 |
- else |
|
68 |
+ } else { |
|
70 | 69 |
Utils::$context['ban']['easy_bg'] = 0; |
70 |
+ } |
|
71 | 71 |
|
72 | 72 |
Utils::$context['easy_ban_group'] = $ban_info['easy_ban_group']; |
73 |
+ |
|
73 | 74 |
return; |
74 | 75 |
} |
75 | 76 |
|
76 | 77 |
// This occurs when we are "adding" a ban. |
77 |
- $request = Db::$db->query('', ' |
|
78 |
+ $request = Db::$db->query( |
|
79 |
+ '', |
|
80 |
+ ' |
|
78 | 81 |
SELECT |
79 | 82 |
bg.id_ban_group, bg.name, bg.ban_time, COALESCE(bg.expire_time, 0) AS expire_time, bg.reason, bg.notes, bg.cannot_access, bg.cannot_register, bg.cannot_login, bg.cannot_post, bg.easy_bg |
80 | 83 |
FROM {db_prefix}ban_groups AS bg |
81 | 84 |
WHERE bg.id_ban_group = {int:current_ban}', |
82 | 85 |
[ |
83 | 86 |
'current_ban' => (int) $_REQUEST['ban_group'], |
84 |
- ] |
|
87 |
+ ], |
|
85 | 88 |
); |
86 | 89 |
$row = Db::$db->fetch_assoc($request); |
87 | 90 |
Db::$db->free_result($request); |
... | ... |
@@ -92,7 +95,7 @@ class a2ebg |
92 | 95 |
'name' => $row['name'], |
93 | 96 |
'expiration' => [ |
94 | 97 |
'status' => empty($row['expire_time']) ? 'never' : ($row['expire_time'] < time() ? 'expired' : 'one_day'), |
95 |
- 'days' => (int) ($row['expire_time'] > time() ? ($row['expire_time'] - time() < 86400 ? 1 : ceil(($row['expire_time'] - time()) / 86400)) : 0) |
|
98 |
+ 'days' => (int) ($row['expire_time'] > time() ? ($row['expire_time'] - time() < 86400 ? 1 : ceil(($row['expire_time'] - time()) / 86400)) : 0), |
|
96 | 99 |
], |
97 | 100 |
'reason' => $row['reason'], |
98 | 101 |
'notes' => $row['notes'], |
... | ... |
@@ -134,24 +137,28 @@ class a2ebg |
134 | 137 |
Theme::loadTemplate('Add2ExistingBanGroup'); |
135 | 138 |
|
136 | 139 |
// Normal way of doing a new one? Skip. |
137 |
- if (empty(Utils::$context['ban']['from_user'])) |
|
138 |
- { |
|
140 |
+ if (empty(Utils::$context['ban']['from_user'])) { |
|
139 | 141 |
Utils::$context['template_layers'][] = 'easyban_edits'; |
142 |
+ |
|
140 | 143 |
return; |
141 | 144 |
} |
142 | 145 |
|
143 | 146 |
// Find our ban groups we can append. |
144 |
- $request = Db::$db->query('', ' |
|
147 |
+ $request = Db::$db->query( |
|
148 |
+ '', |
|
149 |
+ ' |
|
145 | 150 |
SELECT id_ban_group, name |
146 | 151 |
FROM {db_prefix}ban_groups |
147 | 152 |
WHERE easy_bg = {int:one} |
148 | 153 |
ORDER BY name', |
149 | 154 |
[ |
150 | 155 |
'one' => '1', |
151 |
- ] |
|
156 |
+ ], |
|
152 | 157 |
); |
153 |
- while ($row = Db::$db->fetch_assoc($request)) |
|
158 |
+ |
|
159 |
+ while ($row = Db::$db->fetch_assoc($request)) { |
|
154 | 160 |
Utils::$context['ban_group_suggestions'][(int) $row['id_ban_group']] = $row['name']; |
161 |
+ } |
|
155 | 162 |
Db::$db->free_result($request); |
156 | 163 |
|
157 | 164 |
Utils::$context['ban_group_auto_selects'] = is_array(Config::$modSettings['aebg_auto_select']) ? Config::$modSettings['aebg_auto_select'] : Utils::jsonDecode(Config::$modSettings['aebg_auto_select']); |
... | ... |
@@ -165,10 +172,13 @@ class a2ebg |
165 | 172 |
// We are saving a ban. Lets update that info if needed. |
166 | 173 |
public static function addToEditBansPost(): void |
167 | 174 |
{ |
168 |
- if (!isset(Utils::$context['easy_ban_group'])) |
|
175 |
+ if (!isset(Utils::$context['easy_ban_group'])) { |
|
169 | 176 |
return; |
177 |
+ } |
|
170 | 178 |
|
171 |
- Db::$db->query('', ' |
|
179 |
+ Db::$db->query( |
|
180 |
+ '', |
|
181 |
+ ' |
|
172 | 182 |
UPDATE {db_prefix}ban_groups |
173 | 183 |
SET |
174 | 184 |
easy_bg = {int:easy_bg} |
... | ... |
@@ -176,7 +186,7 @@ class a2ebg |
176 | 186 |
[ |
177 | 187 |
'easy_bg' => Utils::$context['easy_ban_group'], |
178 | 188 |
'id_ban_group' => (int) Utils::$context['ban']['id'], |
179 |
- ] |
|
189 |
+ ], |
|
180 | 190 |
); |
181 | 191 |
} |
182 | 192 |
|
... | ... |
@@ -184,20 +194,25 @@ class a2ebg |
184 | 194 |
public static function addToBanList(): void |
185 | 195 |
{ |
186 | 196 |
// Main page seems to call this as well. |
187 |
- if (empty(Utils::$context['ban']['id'])) |
|
197 |
+ if (empty(Utils::$context['ban']['id'])) { |
|
188 | 198 |
return; |
199 |
+ } |
|
189 | 200 |
|
190 |
- $request = Db::$db->query('', ' |
|
201 |
+ $request = Db::$db->query( |
|
202 |
+ '', |
|
203 |
+ ' |
|
191 | 204 |
SELECT |
192 | 205 |
bg.easy_bg |
193 | 206 |
FROM {db_prefix}ban_groups AS bg |
194 | 207 |
WHERE bg.id_ban_group = {int:current_ban}', |
195 | 208 |
[ |
196 | 209 |
'current_ban' => (int) Utils::$context['ban']['id'], |
197 |
- ] |
|
210 |
+ ], |
|
198 | 211 |
); |
199 |
- if (Db::$db->num_rows($request) == 0) |
|
212 |
+ |
|
213 |
+ if (Db::$db->num_rows($request) == 0) { |
|
200 | 214 |
ErrorHandler::fatalLang('ban_not_found', false); |
215 |
+ } |
|
201 | 216 |
|
202 | 217 |
$row = Db::$db->fetch_assoc($request); |
203 | 218 |
Utils::$context['ban']['easy_bg'] = $row['easy_bg']; |
... | ... |
@@ -1,14 +1,15 @@ |
1 | 1 |
<?php |
2 | 2 |
|
3 | 3 |
use SMF\Config; |
4 |
-use SMF\Utils; |
|
5 | 4 |
use SMF\Lang; |
5 |
+use SMF\Utils; |
|
6 | 6 |
|
7 | 7 |
function template_easyban_above() |
8 | 8 |
{ |
9 | 9 |
// Only allow selecting a ban group if it is new. |
10 |
- if (!Utils::$context['ban']['is_new'] || empty(Utils::$context['ban_group_suggestions'])) |
|
10 |
+ if (!Utils::$context['ban']['is_new'] || empty(Utils::$context['ban_group_suggestions'])) { |
|
11 | 11 |
return; |
12 |
+ } |
|
12 | 13 |
|
13 | 14 |
echo ' |
14 | 15 |
<script type="text/javascript"> |
... | ... |
@@ -26,18 +27,21 @@ function template_easyban_above() |
26 | 27 |
$("#manage_bans .windowbg>.ban_settings").toggle(visibility);'; |
27 | 28 |
|
28 | 29 |
// Do we want to auto select some options? |
29 |
- if (!empty(Config::$modSettings['aebg_auto_select'])) |
|
30 |
- { |
|
30 |
+ if (!empty(Config::$modSettings['aebg_auto_select'])) { |
|
31 | 31 |
// Incase it isn't an array. |
32 | 32 |
$allOptions = array_flip(['main_ip_check', 'hostname_check', 'email_check', 'user_check']); |
33 |
- if (!empty(Config::$modSettings['disableHostnameLookup'])) |
|
33 |
+ |
|
34 |
+ if (!empty(Config::$modSettings['disableHostnameLookup'])) { |
|
34 | 35 |
unset($allOptions['hostname_check']); |
36 |
+ } |
|
35 | 37 |
|
36 | 38 |
$autoSelects = is_array(Config::$modSettings['aebg_auto_select']) ? Config::$modSettings['aebg_auto_select'] : json_decode(Config::$modSettings['aebg_auto_select'], true); |
37 |
- foreach ($allOptions as $elID => $dummy) |
|
39 |
+ |
|
40 |
+ foreach ($allOptions as $elID => $dummy) { |
|
38 | 41 |
echo ' |
39 | 42 |
$("#', $elID, '").prop("checked", ', (in_array($elID, $autoSelects) ? 'true' : 'false'), ');'; |
40 | 43 |
} |
44 |
+ } |
|
41 | 45 |
|
42 | 46 |
echo ' |
43 | 47 |
} |
... | ... |
@@ -50,9 +54,10 @@ function template_easyban_above() |
50 | 54 |
<select id="temp_ban_group" name="ban_group" onchange="disableOtherFields()" id="ban_group"> |
51 | 55 |
<option value="-1" selected="selected">', Lang::$txt['aebg_new_ban_group'], '</option>'; |
52 | 56 |
|
53 |
- foreach (Utils::$context['ban_group_suggestions'] as $id_ban_group => $ban_name) |
|
57 |
+ foreach (Utils::$context['ban_group_suggestions'] as $id_ban_group => $ban_name) { |
|
54 | 58 |
echo ' |
55 | 59 |
<option value="', $id_ban_group, '" onselect="disableOtherFields()">', $ban_name, '</option>'; |
60 |
+ } |
|
56 | 61 |
echo ' |
57 | 62 |
</select> |
58 | 63 |
</div>'; |
... | ... |
@@ -4,13 +5,13 @@ error_reporting(E_ALL); |
4 | 5 |
use SMF\Db\DatabaseApi as Db; |
5 | 6 |
|
6 | 7 |
// Hopefully we have the goodies. |
7 |
-if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF')) |
|
8 |
-{ |
|
8 |
+if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF')) { |
|
9 | 9 |
$using_ssi = true; |
10 |
- require_once(dirname(__FILE__) . '/SSI.php'); |
|
11 |
-} |
|
12 |
-elseif (!defined('SMF')) |
|
10 |
+ |
|
11 |
+ require_once dirname(__FILE__) . '/SSI.php'; |
|
12 |
+} elseif (!defined('SMF')) { |
|
13 | 13 |
exit('<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.'); |
14 |
+} |
|
14 | 15 |
|
15 | 16 |
// Our column. |
16 | 17 |
Db::$db->add_column( |
... | ... |
@@ -20,8 +21,9 @@ Db::$db->add_column( |
20 | 21 |
'type' => 'smallint', |
21 | 22 |
'size' => '3', |
22 | 23 |
'default' => 0, |
23 |
- ] |
|
24 |
+ ], |
|
24 | 25 |
); |
25 | 26 |
|
26 |
-if (!empty($using_ssi)) |
|
27 |
+if (!empty($using_ssi)) { |
|
27 | 28 |
echo 'If no errors, Success!'; |
29 |
+} |
|
28 | 30 |