@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * The main handler and designator for AJAX stuff - jumpto, message icons and previews |
@@ -32,8 +33,9 @@ discard block |
||
32 | 33 | // Easy adding of sub actions. |
33 | 34 | call_integration_hook('integrate_XMLhttpMain_subActions', array(&$subActions)); |
34 | 35 | |
35 | - if (!isset($_REQUEST['sa'], $subActions[$_REQUEST['sa']])) |
|
36 | - fatal_lang_error('no_access', false); |
|
36 | + if (!isset($_REQUEST['sa'], $subActions[$_REQUEST['sa']])) { |
|
37 | + fatal_lang_error('no_access', false); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | call_helper($subActions[$_REQUEST['sa']]); |
39 | 41 | } |
@@ -57,8 +59,9 @@ discard block |
||
57 | 59 | foreach ($context['jump_to'] as $id_cat => $cat) |
58 | 60 | { |
59 | 61 | $context['jump_to'][$id_cat]['name'] = un_htmlspecialchars(strip_tags($cat['name'])); |
60 | - foreach ($cat['boards'] as $id_board => $board) |
|
61 | - $context['jump_to'][$id_cat]['boards'][$id_board]['name'] = un_htmlspecialchars(strip_tags($board['name'])); |
|
62 | + foreach ($cat['boards'] as $id_board => $board) { |
|
63 | + $context['jump_to'][$id_cat]['boards'][$id_board]['name'] = un_htmlspecialchars(strip_tags($board['name'])); |
|
64 | + } |
|
62 | 65 | } |
63 | 66 | |
64 | 67 | $context['sub_template'] = 'jump_to'; |
@@ -95,8 +98,9 @@ discard block |
||
95 | 98 | |
96 | 99 | $context['sub_template'] = 'generic_xml'; |
97 | 100 | |
98 | - if (!isset($_POST['item']) || !in_array($_POST['item'], $items)) |
|
99 | - return false; |
|
101 | + if (!isset($_POST['item']) || !in_array($_POST['item'], $items)) { |
|
102 | + return false; |
|
103 | + } |
|
100 | 104 | |
101 | 105 | $_POST['item'](); |
102 | 106 | } |
@@ -112,10 +116,11 @@ discard block |
||
112 | 116 | |
113 | 117 | $errors = array(); |
114 | 118 | $news = !isset($_POST['news'])? '' : $smcFunc['htmlspecialchars']($_POST['news'], ENT_QUOTES); |
115 | - if (empty($news)) |
|
116 | - $errors[] = array('value' => 'no_news'); |
|
117 | - else |
|
118 | - preparsecode($news); |
|
119 | + if (empty($news)) { |
|
120 | + $errors[] = array('value' => 'no_news'); |
|
121 | + } else { |
|
122 | + preparsecode($news); |
|
123 | + } |
|
119 | 124 | |
120 | 125 | $context['xml_data'] = array( |
121 | 126 | 'news' => array( |
@@ -148,10 +153,12 @@ discard block |
||
148 | 153 | $context['send_pm'] = !empty($_POST['send_pm']) ? 1 : 0; |
149 | 154 | $context['send_html'] = !empty($_POST['send_html']) ? 1 : 0; |
150 | 155 | |
151 | - if (empty($_POST['subject'])) |
|
152 | - $context['post_error']['messages'][] = $txt['error_no_subject']; |
|
153 | - if (empty($_POST['message'])) |
|
154 | - $context['post_error']['messages'][] = $txt['error_no_message']; |
|
156 | + if (empty($_POST['subject'])) { |
|
157 | + $context['post_error']['messages'][] = $txt['error_no_subject']; |
|
158 | + } |
|
159 | + if (empty($_POST['message'])) { |
|
160 | + $context['post_error']['messages'][] = $txt['error_no_message']; |
|
161 | + } |
|
155 | 162 | |
156 | 163 | prepareMailingForPreview(); |
157 | 164 | |
@@ -196,38 +203,41 @@ discard block |
||
196 | 203 | $preview_signature = !empty($_POST['signature']) ? $_POST['signature'] : $txt['no_signature_preview']; |
197 | 204 | $validation = profileValidateSignature($preview_signature); |
198 | 205 | |
199 | - if ($validation !== true && $validation !== false) |
|
200 | - $errors[] = array('value' => $txt['profile_error_' . $validation], 'attributes' => array('type' => 'error')); |
|
206 | + if ($validation !== true && $validation !== false) { |
|
207 | + $errors[] = array('value' => $txt['profile_error_' . $validation], 'attributes' => array('type' => 'error')); |
|
208 | + } |
|
201 | 209 | |
202 | 210 | censorText($preview_signature); |
203 | 211 | $preview_signature = parse_bbc($preview_signature, true, 'sig' . $user); |
204 | - } |
|
205 | - elseif (!$can_change) |
|
212 | + } elseif (!$can_change) |
|
206 | 213 | { |
207 | - if ($is_owner) |
|
208 | - $errors[] = array('value' => $txt['cannot_profile_extra_own'], 'attributes' => array('type' => 'error')); |
|
209 | - else |
|
210 | - $errors[] = array('value' => $txt['cannot_profile_extra_any'], 'attributes' => array('type' => 'error')); |
|
214 | + if ($is_owner) { |
|
215 | + $errors[] = array('value' => $txt['cannot_profile_extra_own'], 'attributes' => array('type' => 'error')); |
|
216 | + } else { |
|
217 | + $errors[] = array('value' => $txt['cannot_profile_extra_any'], 'attributes' => array('type' => 'error')); |
|
218 | + } |
|
219 | + } else { |
|
220 | + $errors[] = array('value' => $txt['no_user_selected'], 'attributes' => array('type' => 'error')); |
|
211 | 221 | } |
212 | - else |
|
213 | - $errors[] = array('value' => $txt['no_user_selected'], 'attributes' => array('type' => 'error')); |
|
214 | 222 | |
215 | 223 | $context['xml_data']['signatures'] = array( |
216 | 224 | 'identifier' => 'signature', |
217 | 225 | 'children' => array() |
218 | 226 | ); |
219 | - if (isset($current_signature)) |
|
220 | - $context['xml_data']['signatures']['children'][] = array( |
|
227 | + if (isset($current_signature)) { |
|
228 | + $context['xml_data']['signatures']['children'][] = array( |
|
221 | 229 | 'value' => $current_signature, |
222 | 230 | 'attributes' => array('type' => 'current'), |
223 | 231 | ); |
224 | - if (isset($preview_signature)) |
|
225 | - $context['xml_data']['signatures']['children'][] = array( |
|
232 | + } |
|
233 | + if (isset($preview_signature)) { |
|
234 | + $context['xml_data']['signatures']['children'][] = array( |
|
226 | 235 | 'value' => $preview_signature, |
227 | 236 | 'attributes' => array('type' => 'preview'), |
228 | 237 | ); |
229 | - if (!empty($errors)) |
|
230 | - $context['xml_data']['errors'] = array( |
|
238 | + } |
|
239 | + if (!empty($errors)) { |
|
240 | + $context['xml_data']['errors'] = array( |
|
231 | 241 | 'identifier' => 'error', |
232 | 242 | 'children' => array_merge( |
233 | 243 | array( |
@@ -239,7 +249,8 @@ discard block |
||
239 | 249 | $errors |
240 | 250 | ), |
241 | 251 | ); |
242 | -} |
|
252 | + } |
|
253 | + } |
|
243 | 254 | |
244 | 255 | /** |
245 | 256 | * Handles previewing user warnings |
@@ -261,15 +272,17 @@ discard block |
||
261 | 272 | $context['preview_subject'] = !empty($_POST['title']) ? trim($smcFunc['htmlspecialchars']($_POST['title'])) : ''; |
262 | 273 | if (isset($_POST['issuing'])) |
263 | 274 | { |
264 | - if (empty($_POST['title']) || empty($_POST['body'])) |
|
265 | - $context['post_error']['messages'][] = $txt['warning_notify_blank']; |
|
266 | - } |
|
267 | - else |
|
275 | + if (empty($_POST['title']) || empty($_POST['body'])) { |
|
276 | + $context['post_error']['messages'][] = $txt['warning_notify_blank']; |
|
277 | + } |
|
278 | + } else |
|
268 | 279 | { |
269 | - if (empty($_POST['title'])) |
|
270 | - $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_title']; |
|
271 | - if (empty($_POST['body'])) |
|
272 | - $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_body']; |
|
280 | + if (empty($_POST['title'])) { |
|
281 | + $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_title']; |
|
282 | + } |
|
283 | + if (empty($_POST['body'])) { |
|
284 | + $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_body']; |
|
285 | + } |
|
273 | 286 | // Add in few replacements. |
274 | 287 | /** |
275 | 288 | * These are the defaults: |
@@ -300,9 +313,9 @@ discard block |
||
300 | 313 | $warning_body = parse_bbc($warning_body, true); |
301 | 314 | } |
302 | 315 | $context['preview_message'] = $warning_body; |
316 | + } else { |
|
317 | + $context['post_error']['messages'][] = array('value' => $txt['cannot_issue_warning'], 'attributes' => array('type' => 'error')); |
|
303 | 318 | } |
304 | - else |
|
305 | - $context['post_error']['messages'][] = array('value' => $txt['cannot_issue_warning'], 'attributes' => array('type' => 'error')); |
|
306 | 319 | |
307 | 320 | $context['sub_template'] = 'warning'; |
308 | 321 | } |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Put this user in the online log. |
@@ -33,8 +34,9 @@ discard block |
||
33 | 34 | // Don't update for every page - this isn't wholly accurate but who cares. |
34 | 35 | if ($topic) |
35 | 36 | { |
36 | - if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) |
|
37 | - $force = false; |
|
37 | + if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) { |
|
38 | + $force = false; |
|
39 | + } |
|
38 | 40 | $_SESSION['last_topic_id'] = $topic; |
39 | 41 | } |
40 | 42 | } |
@@ -47,22 +49,24 @@ discard block |
||
47 | 49 | } |
48 | 50 | |
49 | 51 | // Don't mark them as online more than every so often. |
50 | - if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) |
|
51 | - return; |
|
52 | + if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) { |
|
53 | + return; |
|
54 | + } |
|
52 | 55 | |
53 | 56 | if (!empty($modSettings['who_enabled'])) |
54 | 57 | { |
55 | 58 | $serialized = $_GET + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']); |
56 | 59 | |
57 | 60 | // In the case of a dlattach action, session_var may not be set. |
58 | - if (!isset($context['session_var'])) |
|
59 | - $context['session_var'] = $_SESSION['session_var']; |
|
61 | + if (!isset($context['session_var'])) { |
|
62 | + $context['session_var'] = $_SESSION['session_var']; |
|
63 | + } |
|
60 | 64 | |
61 | 65 | unset($serialized['sesc'], $serialized[$context['session_var']]); |
62 | 66 | $serialized = json_encode($serialized); |
67 | + } else { |
|
68 | + $serialized = ''; |
|
63 | 69 | } |
64 | - else |
|
65 | - $serialized = ''; |
|
66 | 70 | |
67 | 71 | // Guests use 0, members use their session ID. |
68 | 72 | $session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id(); |
@@ -102,17 +106,18 @@ discard block |
||
102 | 106 | ); |
103 | 107 | |
104 | 108 | // Guess it got deleted. |
105 | - if ($smcFunc['db_affected_rows']() == 0) |
|
109 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
110 | + $_SESSION['log_time'] = 0; |
|
111 | + } |
|
112 | + } else { |
|
106 | 113 | $_SESSION['log_time'] = 0; |
107 | 114 | } |
108 | - else |
|
109 | - $_SESSION['log_time'] = 0; |
|
110 | 115 | |
111 | 116 | // Otherwise, we have to delete and insert. |
112 | 117 | if (empty($_SESSION['log_time'])) |
113 | 118 | { |
114 | - if ($do_delete || !empty($user_info['id'])) |
|
115 | - $smcFunc['db_query']('', ' |
|
119 | + if ($do_delete || !empty($user_info['id'])) { |
|
120 | + $smcFunc['db_query']('', ' |
|
116 | 121 | DELETE FROM {db_prefix}log_online |
117 | 122 | WHERE ' . ($do_delete ? 'log_time < {int:log_time}' : '') . ($do_delete && !empty($user_info['id']) ? ' OR ' : '') . (empty($user_info['id']) ? '' : 'id_member = {int:current_member}'), |
118 | 123 | array( |
@@ -120,6 +125,7 @@ discard block |
||
120 | 125 | 'log_time' => time() - $modSettings['lastActive'] * 60, |
121 | 126 | ) |
122 | 127 | ); |
128 | + } |
|
123 | 129 | |
124 | 130 | $smcFunc['db_insert']($do_delete ? 'ignore' : 'replace', |
125 | 131 | '{db_prefix}log_online', |
@@ -133,21 +139,24 @@ discard block |
||
133 | 139 | $_SESSION['log_time'] = time(); |
134 | 140 | |
135 | 141 | // Well, they are online now. |
136 | - if (empty($_SESSION['timeOnlineUpdated'])) |
|
137 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
142 | + if (empty($_SESSION['timeOnlineUpdated'])) { |
|
143 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
144 | + } |
|
138 | 145 | |
139 | 146 | // Set their login time, if not already done within the last minute. |
140 | 147 | if (SMF != 'SSI' && !empty($user_info['last_login']) && $user_info['last_login'] < time() - 60 && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('.xml', 'login2', 'logintfa')))) |
141 | 148 | { |
142 | 149 | // Don't count longer than 15 minutes. |
143 | - if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) |
|
144 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
150 | + if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) { |
|
151 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
152 | + } |
|
145 | 153 | |
146 | 154 | $user_settings['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
147 | 155 | updateMemberData($user_info['id'], array('last_login' => time(), 'member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'], 'total_time_logged_in' => $user_settings['total_time_logged_in'])); |
148 | 156 | |
149 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
150 | - cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
157 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
158 | + cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
159 | + } |
|
151 | 160 | |
152 | 161 | $user_info['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
153 | 162 | $_SESSION['timeOnlineUpdated'] = time(); |
@@ -184,8 +193,7 @@ discard block |
||
184 | 193 | // Oops. maybe we have no more disk space left, or some other troubles, troubles... |
185 | 194 | // Copy the file back and run for your life! |
186 | 195 | @copy($boarddir . '/db_last_error_bak.php', $boarddir . '/db_last_error.php'); |
187 | - } |
|
188 | - else |
|
196 | + } else |
|
189 | 197 | { |
190 | 198 | @touch($boarddir . '/' . 'Settings.php'); |
191 | 199 | return true; |
@@ -205,22 +213,27 @@ discard block |
||
205 | 213 | global $db_cache, $db_count, $cache_misses, $cache_count_misses, $db_show_debug, $cache_count, $cache_hits, $smcFunc, $txt; |
206 | 214 | |
207 | 215 | // Add to Settings.php if you want to show the debugging information. |
208 | - if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) |
|
209 | - return; |
|
216 | + if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) { |
|
217 | + return; |
|
218 | + } |
|
210 | 219 | |
211 | - if (empty($_SESSION['view_queries'])) |
|
212 | - $_SESSION['view_queries'] = 0; |
|
213 | - if (empty($context['debug']['language_files'])) |
|
214 | - $context['debug']['language_files'] = array(); |
|
215 | - if (empty($context['debug']['sheets'])) |
|
216 | - $context['debug']['sheets'] = array(); |
|
220 | + if (empty($_SESSION['view_queries'])) { |
|
221 | + $_SESSION['view_queries'] = 0; |
|
222 | + } |
|
223 | + if (empty($context['debug']['language_files'])) { |
|
224 | + $context['debug']['language_files'] = array(); |
|
225 | + } |
|
226 | + if (empty($context['debug']['sheets'])) { |
|
227 | + $context['debug']['sheets'] = array(); |
|
228 | + } |
|
217 | 229 | |
218 | 230 | $files = get_included_files(); |
219 | 231 | $total_size = 0; |
220 | 232 | for ($i = 0, $n = count($files); $i < $n; $i++) |
221 | 233 | { |
222 | - if (file_exists($files[$i])) |
|
223 | - $total_size += filesize($files[$i]); |
|
234 | + if (file_exists($files[$i])) { |
|
235 | + $total_size += filesize($files[$i]); |
|
236 | + } |
|
224 | 237 | $files[$i] = strtr($files[$i], array($boarddir => '.', $sourcedir => '(Sources)', $cachedir => '(Cache)', $settings['actual_theme_dir'] => '(Current Theme)')); |
225 | 238 | } |
226 | 239 | |
@@ -229,8 +242,9 @@ discard block |
||
229 | 242 | { |
230 | 243 | foreach ($db_cache as $q => $qq) |
231 | 244 | { |
232 | - if (!empty($qq['w'])) |
|
233 | - $warnings += count($qq['w']); |
|
245 | + if (!empty($qq['w'])) { |
|
246 | + $warnings += count($qq['w']); |
|
247 | + } |
|
234 | 248 | } |
235 | 249 | |
236 | 250 | $_SESSION['debug'] = &$db_cache; |
@@ -251,12 +265,14 @@ discard block |
||
251 | 265 | ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),' |
252 | 266 | ', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>'; |
253 | 267 | |
254 | - if (function_exists('memory_get_peak_usage')) |
|
255 | - echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
268 | + if (function_exists('memory_get_peak_usage')) { |
|
269 | + echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
270 | + } |
|
256 | 271 | |
257 | 272 | // What tokens are active? |
258 | - if (isset($_SESSION['token'])) |
|
259 | - echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
273 | + if (isset($_SESSION['token'])) { |
|
274 | + echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
275 | + } |
|
260 | 276 | |
261 | 277 | if (!empty($modSettings['cache_enable']) && !empty($cache_hits)) |
262 | 278 | { |
@@ -269,10 +285,12 @@ discard block |
||
269 | 285 | $total_t += $cache_hit['t']; |
270 | 286 | $total_s += $cache_hit['s']; |
271 | 287 | } |
272 | - if (!isset($cache_misses)) |
|
273 | - $cache_misses = array(); |
|
274 | - foreach ($cache_misses as $missed) |
|
275 | - $missed_entires[] = $missed['d'] . ' ' . $missed['k']; |
|
288 | + if (!isset($cache_misses)) { |
|
289 | + $cache_misses = array(); |
|
290 | + } |
|
291 | + foreach ($cache_misses as $missed) { |
|
292 | + $missed_entires[] = $missed['d'] . ' ' . $missed['k']; |
|
293 | + } |
|
276 | 294 | |
277 | 295 | echo ' |
278 | 296 | ', $txt['debug_cache_hits'], $cache_count, ': ', sprintf($txt['debug_cache_seconds_bytes_total'], comma_format($total_t, 5), comma_format($total_s)), ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_cache_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_cache_info" style="display: none;"><em>', implode('</em>, <em>', $entries), '</em></span>)<br> |
@@ -283,38 +301,44 @@ discard block |
||
283 | 301 | <a href="', $scripturl, '?action=viewquery" target="_blank" class="new_win">', $warnings == 0 ? sprintf($txt['debug_queries_used'], (int) $db_count) : sprintf($txt['debug_queries_used_and_warnings'], (int) $db_count, $warnings), '</a><br> |
284 | 302 | <br>'; |
285 | 303 | |
286 | - if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) |
|
287 | - foreach ($db_cache as $q => $qq) |
|
304 | + if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) { |
|
305 | + foreach ($db_cache as $q => $qq) |
|
288 | 306 | { |
289 | 307 | $is_select = strpos(trim($qq['q']), 'SELECT') === 0 || preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+SELECT .+$~s', trim($qq['q'])) != 0; |
308 | + } |
|
290 | 309 | // Temporary tables created in earlier queries are not explainable. |
291 | 310 | if ($is_select) |
292 | 311 | { |
293 | - foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) |
|
294 | - if (strpos(trim($qq['q']), $tmp) !== false) |
|
312 | + foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) { |
|
313 | + if (strpos(trim($qq['q']), $tmp) !== false) |
|
295 | 314 | { |
296 | 315 | $is_select = false; |
316 | + } |
|
297 | 317 | break; |
298 | 318 | } |
299 | 319 | } |
300 | 320 | // But actual creation of the temporary tables are. |
301 | - elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) |
|
302 | - $is_select = true; |
|
321 | + elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) { |
|
322 | + $is_select = true; |
|
323 | + } |
|
303 | 324 | |
304 | 325 | // Make the filenames look a bit better. |
305 | - if (isset($qq['f'])) |
|
306 | - $qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']); |
|
326 | + if (isset($qq['f'])) { |
|
327 | + $qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']); |
|
328 | + } |
|
307 | 329 | |
308 | 330 | echo ' |
309 | 331 | <strong>', $is_select ? '<a href="' . $scripturl . '?action=viewquery;qq=' . ($q + 1) . '#qq' . $q . '" target="_blank" class="new_win" style="text-decoration: none;">' : '', nl2br(str_replace("\t", ' ', $smcFunc['htmlspecialchars'](ltrim($qq['q'], "\n\r")))) . ($is_select ? '</a></strong>' : '</strong>') . '<br> |
310 | 332 | '; |
311 | - if (!empty($qq['f']) && !empty($qq['l'])) |
|
312 | - echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']); |
|
333 | + if (!empty($qq['f']) && !empty($qq['l'])) { |
|
334 | + echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']); |
|
335 | + } |
|
313 | 336 | |
314 | - if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at'])) |
|
315 | - echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>'; |
|
316 | - elseif (isset($qq['t'])) |
|
317 | - echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>'; |
|
337 | + if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at'])) { |
|
338 | + echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>'; |
|
339 | + } elseif (isset($qq['t'])) { |
|
340 | + echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>'; |
|
341 | + } |
|
318 | 342 | echo ' |
319 | 343 | <br>'; |
320 | 344 | } |
@@ -339,12 +363,14 @@ discard block |
||
339 | 363 | global $modSettings, $smcFunc; |
340 | 364 | static $cache_stats = array(); |
341 | 365 | |
342 | - if (empty($modSettings['trackStats'])) |
|
343 | - return false; |
|
344 | - if (!empty($stats)) |
|
345 | - return $cache_stats = array_merge($cache_stats, $stats); |
|
346 | - elseif (empty($cache_stats)) |
|
347 | - return false; |
|
366 | + if (empty($modSettings['trackStats'])) { |
|
367 | + return false; |
|
368 | + } |
|
369 | + if (!empty($stats)) { |
|
370 | + return $cache_stats = array_merge($cache_stats, $stats); |
|
371 | + } elseif (empty($cache_stats)) { |
|
372 | + return false; |
|
373 | + } |
|
348 | 374 | |
349 | 375 | $setStringUpdate = ''; |
350 | 376 | $insert_keys = array(); |
@@ -357,10 +383,11 @@ discard block |
||
357 | 383 | $setStringUpdate .= ' |
358 | 384 | ' . $field . ' = ' . ($change === '+' ? $field . ' + 1' : '{int:' . $field . '}') . ','; |
359 | 385 | |
360 | - if ($change === '+') |
|
361 | - $cache_stats[$field] = 1; |
|
362 | - else |
|
363 | - $update_parameters[$field] = $change; |
|
386 | + if ($change === '+') { |
|
387 | + $cache_stats[$field] = 1; |
|
388 | + } else { |
|
389 | + $update_parameters[$field] = $change; |
|
390 | + } |
|
364 | 391 | $insert_keys[$field] = 'int'; |
365 | 392 | } |
366 | 393 | |
@@ -424,43 +451,50 @@ discard block |
||
424 | 451 | ); |
425 | 452 | |
426 | 453 | // Make sure this particular log is enabled first... |
427 | - if (empty($modSettings['modlog_enabled'])) |
|
428 | - unset ($log_types['moderate']); |
|
429 | - if (empty($modSettings['userlog_enabled'])) |
|
430 | - unset ($log_types['user']); |
|
431 | - if (empty($modSettings['adminlog_enabled'])) |
|
432 | - unset ($log_types['admin']); |
|
454 | + if (empty($modSettings['modlog_enabled'])) { |
|
455 | + unset ($log_types['moderate']); |
|
456 | + } |
|
457 | + if (empty($modSettings['userlog_enabled'])) { |
|
458 | + unset ($log_types['user']); |
|
459 | + } |
|
460 | + if (empty($modSettings['adminlog_enabled'])) { |
|
461 | + unset ($log_types['admin']); |
|
462 | + } |
|
433 | 463 | |
434 | 464 | call_integration_hook('integrate_log_types', array(&$log_types)); |
435 | 465 | |
436 | 466 | foreach ($logs as $log) |
437 | 467 | { |
438 | - if (!isset($log_types[$log['log_type']])) |
|
439 | - return false; |
|
468 | + if (!isset($log_types[$log['log_type']])) { |
|
469 | + return false; |
|
470 | + } |
|
440 | 471 | |
441 | - if (!is_array($log['extra'])) |
|
442 | - trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
472 | + if (!is_array($log['extra'])) { |
|
473 | + trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
474 | + } |
|
443 | 475 | |
444 | 476 | // Pull out the parts we want to store separately, but also make sure that the data is proper |
445 | 477 | if (isset($log['extra']['topic'])) |
446 | 478 | { |
447 | - if (!is_numeric($log['extra']['topic'])) |
|
448 | - trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
479 | + if (!is_numeric($log['extra']['topic'])) { |
|
480 | + trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
481 | + } |
|
449 | 482 | $topic_id = empty($log['extra']['topic']) ? 0 : (int) $log['extra']['topic']; |
450 | 483 | unset($log['extra']['topic']); |
484 | + } else { |
|
485 | + $topic_id = 0; |
|
451 | 486 | } |
452 | - else |
|
453 | - $topic_id = 0; |
|
454 | 487 | |
455 | 488 | if (isset($log['extra']['message'])) |
456 | 489 | { |
457 | - if (!is_numeric($log['extra']['message'])) |
|
458 | - trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
490 | + if (!is_numeric($log['extra']['message'])) { |
|
491 | + trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
492 | + } |
|
459 | 493 | $msg_id = empty($log['extra']['message']) ? 0 : (int) $log['extra']['message']; |
460 | 494 | unset($log['extra']['message']); |
495 | + } else { |
|
496 | + $msg_id = 0; |
|
461 | 497 | } |
462 | - else |
|
463 | - $msg_id = 0; |
|
464 | 498 | |
465 | 499 | // @todo cache this? |
466 | 500 | // Is there an associated report on this? |
@@ -487,23 +521,26 @@ discard block |
||
487 | 521 | $smcFunc['db_free_result']($request); |
488 | 522 | } |
489 | 523 | |
490 | - if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) |
|
491 | - trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
524 | + if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) { |
|
525 | + trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
526 | + } |
|
492 | 527 | |
493 | 528 | if (isset($log['extra']['board'])) |
494 | 529 | { |
495 | - if (!is_numeric($log['extra']['board'])) |
|
496 | - trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
530 | + if (!is_numeric($log['extra']['board'])) { |
|
531 | + trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
532 | + } |
|
497 | 533 | $board_id = empty($log['extra']['board']) ? 0 : (int) $log['extra']['board']; |
498 | 534 | unset($log['extra']['board']); |
535 | + } else { |
|
536 | + $board_id = 0; |
|
499 | 537 | } |
500 | - else |
|
501 | - $board_id = 0; |
|
502 | 538 | |
503 | 539 | if (isset($log['extra']['board_to'])) |
504 | 540 | { |
505 | - if (!is_numeric($log['extra']['board_to'])) |
|
506 | - trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
541 | + if (!is_numeric($log['extra']['board_to'])) { |
|
542 | + trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
543 | + } |
|
507 | 544 | if (empty($board_id)) |
508 | 545 | { |
509 | 546 | $board_id = empty($log['extra']['board_to']) ? 0 : (int) $log['extra']['board_to']; |
@@ -511,10 +548,11 @@ discard block |
||
511 | 548 | } |
512 | 549 | } |
513 | 550 | |
514 | - if (isset($log['extra']['member_affected'])) |
|
515 | - $memID = $log['extra']['member_affected']; |
|
516 | - else |
|
517 | - $memID = $user_info['id']; |
|
551 | + if (isset($log['extra']['member_affected'])) { |
|
552 | + $memID = $log['extra']['member_affected']; |
|
553 | + } else { |
|
554 | + $memID = $user_info['id']; |
|
555 | + } |
|
518 | 556 | |
519 | 557 | $inserts[] = array( |
520 | 558 | time(), $log_types[$log['log_type']], $memID, $user_info['ip'], $log['action'], |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Delete one of more membergroups. |
@@ -31,15 +32,16 @@ discard block |
||
31 | 32 | global $smcFunc, $modSettings, $txt; |
32 | 33 | |
33 | 34 | // Make sure it's an array. |
34 | - if (!is_array($groups)) |
|
35 | - $groups = array((int) $groups); |
|
36 | - else |
|
35 | + if (!is_array($groups)) { |
|
36 | + $groups = array((int) $groups); |
|
37 | + } else |
|
37 | 38 | { |
38 | 39 | $groups = array_unique($groups); |
39 | 40 | |
40 | 41 | // Make sure all groups are integer. |
41 | - foreach ($groups as $key => $value) |
|
42 | - $groups[$key] = (int) $value; |
|
42 | + foreach ($groups as $key => $value) { |
|
43 | + $groups[$key] = (int) $value; |
|
44 | + } |
|
43 | 45 | } |
44 | 46 | |
45 | 47 | // Some groups are protected (guests, administrators, moderators, newbies). |
@@ -56,15 +58,17 @@ discard block |
||
56 | 58 | 'is_protected' => 1, |
57 | 59 | ) |
58 | 60 | ); |
59 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
60 | - $protected_groups[] = $row['id_group']; |
|
61 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
62 | + $protected_groups[] = $row['id_group']; |
|
63 | + } |
|
61 | 64 | $smcFunc['db_free_result']($request); |
62 | 65 | } |
63 | 66 | |
64 | 67 | // Make sure they don't delete protected groups! |
65 | 68 | $groups = array_diff($groups, array_unique($protected_groups)); |
66 | - if (empty($groups)) |
|
67 | - return 'no_group_found'; |
|
69 | + if (empty($groups)) { |
|
70 | + return 'no_group_found'; |
|
71 | + } |
|
68 | 72 | |
69 | 73 | // Make sure they don't try to delete a group attached to a paid subscription. |
70 | 74 | $subscriptions = array(); |
@@ -74,13 +78,14 @@ discard block |
||
74 | 78 | ORDER BY name'); |
75 | 79 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
76 | 80 | { |
77 | - if (in_array($row['id_group'], $groups)) |
|
78 | - $subscriptions[] = $row['name']; |
|
79 | - else |
|
81 | + if (in_array($row['id_group'], $groups)) { |
|
82 | + $subscriptions[] = $row['name']; |
|
83 | + } else |
|
80 | 84 | { |
81 | 85 | $add_groups = explode(',', $row['add_groups']); |
82 | - if (count(array_intersect($add_groups, $groups)) != 0) |
|
83 | - $subscriptions[] = $row['name']; |
|
86 | + if (count(array_intersect($add_groups, $groups)) != 0) { |
|
87 | + $subscriptions[] = $row['name']; |
|
88 | + } |
|
84 | 89 | } |
85 | 90 | } |
86 | 91 | $smcFunc['db_free_result']($request); |
@@ -101,8 +106,9 @@ discard block |
||
101 | 106 | 'group_list' => $groups, |
102 | 107 | ) |
103 | 108 | ); |
104 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
105 | - logAction('delete_group', array('group' => $row['group_name']), 'admin'); |
|
109 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
110 | + logAction('delete_group', array('group' => $row['group_name']), 'admin'); |
|
111 | + } |
|
106 | 112 | $smcFunc['db_free_result']($request); |
107 | 113 | |
108 | 114 | call_integration_hook('integrate_delete_membergroups', array($groups)); |
@@ -187,12 +193,14 @@ discard block |
||
187 | 193 | ) |
188 | 194 | ); |
189 | 195 | $updates = array(); |
190 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
191 | - $updates[$row['additional_groups']][] = $row['id_member']; |
|
196 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
197 | + $updates[$row['additional_groups']][] = $row['id_member']; |
|
198 | + } |
|
192 | 199 | $smcFunc['db_free_result']($request); |
193 | 200 | |
194 | - foreach ($updates as $additional_groups => $memberArray) |
|
195 | - updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), $groups)))); |
|
201 | + foreach ($updates as $additional_groups => $memberArray) { |
|
202 | + updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), $groups)))); |
|
203 | + } |
|
196 | 204 | |
197 | 205 | // No boards can provide access to these membergroups anymore. |
198 | 206 | $request = $smcFunc['db_query']('', ' |
@@ -204,12 +212,13 @@ discard block |
||
204 | 212 | ) |
205 | 213 | ); |
206 | 214 | $updates = array(); |
207 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
208 | - $updates[$row['member_groups']][] = $row['id_board']; |
|
215 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
216 | + $updates[$row['member_groups']][] = $row['id_board']; |
|
217 | + } |
|
209 | 218 | $smcFunc['db_free_result']($request); |
210 | 219 | |
211 | - foreach ($updates as $member_groups => $boardArray) |
|
212 | - $smcFunc['db_query']('', ' |
|
220 | + foreach ($updates as $member_groups => $boardArray) { |
|
221 | + $smcFunc['db_query']('', ' |
|
213 | 222 | UPDATE {db_prefix}boards |
214 | 223 | SET member_groups = {string:member_groups} |
215 | 224 | WHERE id_board IN ({array_int:board_lists})', |
@@ -218,6 +227,7 @@ discard block |
||
218 | 227 | 'member_groups' => implode(',', array_diff(explode(',', $member_groups), $groups)), |
219 | 228 | ) |
220 | 229 | ); |
230 | + } |
|
221 | 231 | |
222 | 232 | // Recalculate the post groups, as they likely changed. |
223 | 233 | updateStats('postgroups'); |
@@ -225,8 +235,9 @@ discard block |
||
225 | 235 | // Make a note of the fact that the cache may be wrong. |
226 | 236 | $settings_update = array('settings_updated' => time()); |
227 | 237 | // Have we deleted the spider group? |
228 | - if (isset($modSettings['spider_group']) && in_array($modSettings['spider_group'], $groups)) |
|
229 | - $settings_update['spider_group'] = 0; |
|
238 | + if (isset($modSettings['spider_group']) && in_array($modSettings['spider_group'], $groups)) { |
|
239 | + $settings_update['spider_group'] = 0; |
|
240 | + } |
|
230 | 241 | |
231 | 242 | updateSettings($settings_update); |
232 | 243 | |
@@ -250,22 +261,24 @@ discard block |
||
250 | 261 | global $smcFunc, $modSettings, $sourcedir; |
251 | 262 | |
252 | 263 | // You're getting nowhere without this permission, unless of course you are the group's moderator. |
253 | - if (!$permissionCheckDone) |
|
254 | - isAllowedTo('manage_membergroups'); |
|
264 | + if (!$permissionCheckDone) { |
|
265 | + isAllowedTo('manage_membergroups'); |
|
266 | + } |
|
255 | 267 | |
256 | 268 | // Assume something will happen. |
257 | 269 | updateSettings(array('settings_updated' => time())); |
258 | 270 | |
259 | 271 | // Cleaning the input. |
260 | - if (!is_array($members)) |
|
261 | - $members = array((int) $members); |
|
262 | - else |
|
272 | + if (!is_array($members)) { |
|
273 | + $members = array((int) $members); |
|
274 | + } else |
|
263 | 275 | { |
264 | 276 | $members = array_unique($members); |
265 | 277 | |
266 | 278 | // Cast the members to integer. |
267 | - foreach ($members as $key => $value) |
|
268 | - $members[$key] = (int) $value; |
|
279 | + foreach ($members as $key => $value) { |
|
280 | + $members[$key] = (int) $value; |
|
281 | + } |
|
269 | 282 | } |
270 | 283 | |
271 | 284 | // Before we get started, let's check we won't leave the admin group empty! |
@@ -277,14 +290,15 @@ discard block |
||
277 | 290 | // Remove any admins if there are too many. |
278 | 291 | $non_changing_admins = array_diff(array_keys($admins), $members); |
279 | 292 | |
280 | - if (empty($non_changing_admins)) |
|
281 | - $members = array_diff($members, array_keys($admins)); |
|
293 | + if (empty($non_changing_admins)) { |
|
294 | + $members = array_diff($members, array_keys($admins)); |
|
295 | + } |
|
282 | 296 | } |
283 | 297 | |
284 | 298 | // Just in case. |
285 | - if (empty($members)) |
|
286 | - return false; |
|
287 | - elseif ($groups === null) |
|
299 | + if (empty($members)) { |
|
300 | + return false; |
|
301 | + } elseif ($groups === null) |
|
288 | 302 | { |
289 | 303 | // Wanna remove all groups from these members? That's easy. |
290 | 304 | $smcFunc['db_query']('', ' |
@@ -306,20 +320,21 @@ discard block |
||
306 | 320 | updateStats('postgroups', $members); |
307 | 321 | |
308 | 322 | // Log what just happened. |
309 | - foreach ($members as $member) |
|
310 | - logAction('removed_all_groups', array('member' => $member), 'admin'); |
|
323 | + foreach ($members as $member) { |
|
324 | + logAction('removed_all_groups', array('member' => $member), 'admin'); |
|
325 | + } |
|
311 | 326 | |
312 | 327 | return true; |
313 | - } |
|
314 | - elseif (!is_array($groups)) |
|
315 | - $groups = array((int) $groups); |
|
316 | - else |
|
328 | + } elseif (!is_array($groups)) { |
|
329 | + $groups = array((int) $groups); |
|
330 | + } else |
|
317 | 331 | { |
318 | 332 | $groups = array_unique($groups); |
319 | 333 | |
320 | 334 | // Make sure all groups are integer. |
321 | - foreach ($groups as $key => $value) |
|
322 | - $groups[$key] = (int) $value; |
|
335 | + foreach ($groups as $key => $value) { |
|
336 | + $groups[$key] = (int) $value; |
|
337 | + } |
|
323 | 338 | } |
324 | 339 | |
325 | 340 | // Fetch a list of groups members cannot be assigned to explicitly, and the group names of the ones we want. |
@@ -335,10 +350,11 @@ discard block |
||
335 | 350 | $group_names = array(); |
336 | 351 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
337 | 352 | { |
338 | - if ($row['min_posts'] != -1) |
|
339 | - $implicitGroups[] = $row['id_group']; |
|
340 | - else |
|
341 | - $group_names[$row['id_group']] = $row['group_name']; |
|
353 | + if ($row['min_posts'] != -1) { |
|
354 | + $implicitGroups[] = $row['id_group']; |
|
355 | + } else { |
|
356 | + $group_names[$row['id_group']] = $row['group_name']; |
|
357 | + } |
|
342 | 358 | } |
343 | 359 | $smcFunc['db_free_result']($request); |
344 | 360 | |
@@ -357,8 +373,9 @@ discard block |
||
357 | 373 | ) |
358 | 374 | ); |
359 | 375 | $protected_groups = array(1); |
360 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
361 | - $protected_groups[] = $row['id_group']; |
|
376 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
377 | + $protected_groups[] = $row['id_group']; |
|
378 | + } |
|
362 | 379 | $smcFunc['db_free_result']($request); |
363 | 380 | |
364 | 381 | // If you're not an admin yourself, you can't touch protected groups! |
@@ -366,8 +383,9 @@ discard block |
||
366 | 383 | } |
367 | 384 | |
368 | 385 | // Only continue if there are still groups and members left. |
369 | - if (empty($groups) || empty($members)) |
|
370 | - return false; |
|
386 | + if (empty($groups) || empty($members)) { |
|
387 | + return false; |
|
388 | + } |
|
371 | 389 | |
372 | 390 | // First, reset those who have this as their primary group - this is the easy one. |
373 | 391 | $log_inserts = array(); |
@@ -381,8 +399,9 @@ discard block |
||
381 | 399 | 'member_list' => $members, |
382 | 400 | ) |
383 | 401 | ); |
384 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
385 | - $log_inserts[] = array('group' => $group_names[$row['id_group']], 'member' => $row['id_member']); |
|
402 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
403 | + $log_inserts[] = array('group' => $group_names[$row['id_group']], 'member' => $row['id_member']); |
|
404 | + } |
|
386 | 405 | $smcFunc['db_free_result']($request); |
387 | 406 | |
388 | 407 | $smcFunc['db_query']('', ' |
@@ -414,16 +433,17 @@ discard block |
||
414 | 433 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
415 | 434 | { |
416 | 435 | // What log entries must we make for this one, eh? |
417 | - foreach (explode(',', $row['additional_groups']) as $group) |
|
418 | - if (in_array($group, $groups)) |
|
436 | + foreach (explode(',', $row['additional_groups']) as $group) { |
|
437 | + if (in_array($group, $groups)) |
|
419 | 438 | $log_inserts[] = array('group' => $group_names[$group], 'member' => $row['id_member']); |
439 | + } |
|
420 | 440 | |
421 | 441 | $updates[$row['additional_groups']][] = $row['id_member']; |
422 | 442 | } |
423 | 443 | $smcFunc['db_free_result']($request); |
424 | 444 | |
425 | - foreach ($updates as $additional_groups => $memberArray) |
|
426 | - $smcFunc['db_query']('', ' |
|
445 | + foreach ($updates as $additional_groups => $memberArray) { |
|
446 | + $smcFunc['db_query']('', ' |
|
427 | 447 | UPDATE {db_prefix}members |
428 | 448 | SET additional_groups = {string:additional_groups} |
429 | 449 | WHERE id_member IN ({array_int:member_list})', |
@@ -432,6 +452,7 @@ discard block |
||
432 | 452 | 'additional_groups' => implode(',', array_diff(explode(',', $additional_groups), $groups)), |
433 | 453 | ) |
434 | 454 | ); |
455 | + } |
|
435 | 456 | |
436 | 457 | // Their post groups may have changed now... |
437 | 458 | updateStats('postgroups', $members); |
@@ -440,8 +461,9 @@ discard block |
||
440 | 461 | if (!empty($log_inserts) && !empty($modSettings['modlog_enabled'])) |
441 | 462 | { |
442 | 463 | require_once($sourcedir . '/Logging.php'); |
443 | - foreach ($log_inserts as $extra) |
|
444 | - logAction('removed_from_group', $extra, 'admin'); |
|
464 | + foreach ($log_inserts as $extra) { |
|
465 | + logAction('removed_from_group', $extra, 'admin'); |
|
466 | + } |
|
445 | 467 | } |
446 | 468 | |
447 | 469 | // Mission successful. |
@@ -477,21 +499,23 @@ discard block |
||
477 | 499 | global $smcFunc, $sourcedir; |
478 | 500 | |
479 | 501 | // Show your licence, but only if it hasn't been done yet. |
480 | - if (!$permissionCheckDone) |
|
481 | - isAllowedTo('manage_membergroups'); |
|
502 | + if (!$permissionCheckDone) { |
|
503 | + isAllowedTo('manage_membergroups'); |
|
504 | + } |
|
482 | 505 | |
483 | 506 | // Make sure we don't keep old stuff cached. |
484 | 507 | updateSettings(array('settings_updated' => time())); |
485 | 508 | |
486 | - if (!is_array($members)) |
|
487 | - $members = array((int) $members); |
|
488 | - else |
|
509 | + if (!is_array($members)) { |
|
510 | + $members = array((int) $members); |
|
511 | + } else |
|
489 | 512 | { |
490 | 513 | $members = array_unique($members); |
491 | 514 | |
492 | 515 | // Make sure all members are integer. |
493 | - foreach ($members as $key => $value) |
|
494 | - $members[$key] = (int) $value; |
|
516 | + foreach ($members as $key => $value) { |
|
517 | + $members[$key] = (int) $value; |
|
518 | + } |
|
495 | 519 | } |
496 | 520 | $group = (int) $group; |
497 | 521 | |
@@ -508,20 +532,23 @@ discard block |
||
508 | 532 | $group_names = array(); |
509 | 533 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
510 | 534 | { |
511 | - if ($row['min_posts'] != -1) |
|
512 | - $implicitGroups[] = $row['id_group']; |
|
513 | - else |
|
514 | - $group_names[$row['id_group']] = $row['group_name']; |
|
535 | + if ($row['min_posts'] != -1) { |
|
536 | + $implicitGroups[] = $row['id_group']; |
|
537 | + } else { |
|
538 | + $group_names[$row['id_group']] = $row['group_name']; |
|
539 | + } |
|
515 | 540 | } |
516 | 541 | $smcFunc['db_free_result']($request); |
517 | 542 | |
518 | 543 | // Sorry, you can't join an implicit group. |
519 | - if (in_array($group, $implicitGroups) || empty($members)) |
|
520 | - return false; |
|
544 | + if (in_array($group, $implicitGroups) || empty($members)) { |
|
545 | + return false; |
|
546 | + } |
|
521 | 547 | |
522 | 548 | // Only admins can add admins... |
523 | - if (!allowedTo('admin_forum') && $group == 1) |
|
524 | - return false; |
|
549 | + if (!allowedTo('admin_forum') && $group == 1) { |
|
550 | + return false; |
|
551 | + } |
|
525 | 552 | // ... and assign protected groups! |
526 | 553 | elseif (!allowedTo('admin_forum') && !$ignoreProtected) |
527 | 554 | { |
@@ -539,13 +566,14 @@ discard block |
||
539 | 566 | $smcFunc['db_free_result']($request); |
540 | 567 | |
541 | 568 | // Is it protected? |
542 | - if ($is_protected == 1) |
|
543 | - return false; |
|
569 | + if ($is_protected == 1) { |
|
570 | + return false; |
|
571 | + } |
|
544 | 572 | } |
545 | 573 | |
546 | 574 | // Do the actual updates. |
547 | - if ($type == 'only_additional') |
|
548 | - $smcFunc['db_query']('', ' |
|
575 | + if ($type == 'only_additional') { |
|
576 | + $smcFunc['db_query']('', ' |
|
549 | 577 | UPDATE {db_prefix}members |
550 | 578 | SET additional_groups = CASE WHEN additional_groups = {string:blank_string} THEN {string:id_group_string} ELSE CONCAT(additional_groups, {string:id_group_string_extend}) END |
551 | 579 | WHERE id_member IN ({array_int:member_list}) |
@@ -559,8 +587,8 @@ discard block |
||
559 | 587 | 'blank_string' => '', |
560 | 588 | ) |
561 | 589 | ); |
562 | - elseif ($type == 'only_primary' || $type == 'force_primary') |
|
563 | - $smcFunc['db_query']('', ' |
|
590 | + } elseif ($type == 'only_primary' || $type == 'force_primary') { |
|
591 | + $smcFunc['db_query']('', ' |
|
564 | 592 | UPDATE {db_prefix}members |
565 | 593 | SET id_group = {int:id_group} |
566 | 594 | WHERE id_member IN ({array_int:member_list})' . ($type == 'force_primary' ? '' : ' |
@@ -572,8 +600,8 @@ discard block |
||
572 | 600 | 'regular_group' => 0, |
573 | 601 | ) |
574 | 602 | ); |
575 | - elseif ($type == 'auto') |
|
576 | - $smcFunc['db_query']('', ' |
|
603 | + } elseif ($type == 'auto') { |
|
604 | + $smcFunc['db_query']('', ' |
|
577 | 605 | UPDATE {db_prefix}members |
578 | 606 | SET |
579 | 607 | id_group = CASE WHEN id_group = {int:regular_group} THEN {int:id_group} ELSE id_group END, |
@@ -592,9 +620,11 @@ discard block |
||
592 | 620 | 'id_group_string_extend' => ',' . $group, |
593 | 621 | ) |
594 | 622 | ); |
623 | + } |
|
595 | 624 | // Ack!!? What happened? |
596 | - else |
|
597 | - trigger_error('addMembersToGroup(): Unknown type \'' . $type . '\'', E_USER_WARNING); |
|
625 | + else { |
|
626 | + trigger_error('addMembersToGroup(): Unknown type \'' . $type . '\'', E_USER_WARNING); |
|
627 | + } |
|
598 | 628 | |
599 | 629 | call_integration_hook('integrate_add_members_to_group', array($members, $group, &$group_names)); |
600 | 630 | |
@@ -603,8 +633,9 @@ discard block |
||
603 | 633 | |
604 | 634 | // Log the data. |
605 | 635 | require_once($sourcedir . '/Logging.php'); |
606 | - foreach ($members as $member) |
|
607 | - logAction('added_to_group', array('group' => $group_names[$group], 'member' => $member), 'admin'); |
|
636 | + foreach ($members as $member) { |
|
637 | + logAction('added_to_group', array('group' => $group_names[$group], 'member' => $member), 'admin'); |
|
638 | + } |
|
608 | 639 | |
609 | 640 | return true; |
610 | 641 | } |
@@ -632,8 +663,9 @@ discard block |
||
632 | 663 | ) |
633 | 664 | ); |
634 | 665 | $members = array(); |
635 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
636 | - $members[$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
666 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
667 | + $members[$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
668 | + } |
|
637 | 669 | $smcFunc['db_free_result']($request); |
638 | 670 | |
639 | 671 | // If there are more than $limit members, add a 'more' link. |
@@ -641,10 +673,10 @@ discard block |
||
641 | 673 | { |
642 | 674 | array_pop($members); |
643 | 675 | return true; |
676 | + } else { |
|
677 | + return false; |
|
678 | + } |
|
644 | 679 | } |
645 | - else |
|
646 | - return false; |
|
647 | -} |
|
648 | 680 | |
649 | 681 | /** |
650 | 682 | * Retrieve a list of (visible) membergroups used by the cache. |
@@ -669,8 +701,9 @@ discard block |
||
669 | 701 | ) |
670 | 702 | ); |
671 | 703 | $groupCache = array(); |
672 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
673 | - $groupCache[] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_group'] . '" ' . ($row['online_color'] ? 'style="color: ' . $row['online_color'] . '"' : '') . '>' . $row['group_name'] . '</a>'; |
|
704 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
705 | + $groupCache[] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_group'] . '" ' . ($row['online_color'] ? 'style="color: ' . $row['online_color'] . '"' : '') . '>' . $row['group_name'] . '</a>'; |
|
706 | + } |
|
674 | 707 | $smcFunc['db_free_result']($request); |
675 | 708 | |
676 | 709 | return array( |
@@ -718,8 +751,9 @@ discard block |
||
718 | 751 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
719 | 752 | { |
720 | 753 | // We only list the groups they can see. |
721 | - if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) |
|
722 | - continue; |
|
754 | + if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) { |
|
755 | + continue; |
|
756 | + } |
|
723 | 757 | |
724 | 758 | $row['icons'] = explode('#', $row['icons']); |
725 | 759 | |
@@ -754,12 +788,11 @@ discard block |
||
754 | 788 | 'group_list' => $group_ids, |
755 | 789 | ) |
756 | 790 | ); |
757 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
758 | - $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
791 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
792 | + $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
793 | + } |
|
759 | 794 | $smcFunc['db_free_result']($query); |
760 | - } |
|
761 | - |
|
762 | - else |
|
795 | + } else |
|
763 | 796 | { |
764 | 797 | $query = $smcFunc['db_query']('', ' |
765 | 798 | SELECT id_group, COUNT(*) AS num_members |
@@ -770,8 +803,9 @@ discard block |
||
770 | 803 | 'group_list' => $group_ids, |
771 | 804 | ) |
772 | 805 | ); |
773 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
774 | - $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
806 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
807 | + $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
808 | + } |
|
775 | 809 | $smcFunc['db_free_result']($query); |
776 | 810 | |
777 | 811 | // Only do additional groups if we can moderate... |
@@ -790,8 +824,9 @@ discard block |
||
790 | 824 | 'blank_string' => '', |
791 | 825 | ) |
792 | 826 | ); |
793 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
794 | - $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
827 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
828 | + $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
829 | + } |
|
795 | 830 | $smcFunc['db_free_result']($query); |
796 | 831 | } |
797 | 832 | } |
@@ -805,8 +840,9 @@ discard block |
||
805 | 840 | 'group_list' => $group_ids, |
806 | 841 | ) |
807 | 842 | ); |
808 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
809 | - $groups[$row['id_group']]['moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
843 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
844 | + $groups[$row['id_group']]['moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
845 | + } |
|
810 | 846 | $smcFunc['db_free_result']($query); |
811 | 847 | } |
812 | 848 | |
@@ -815,8 +851,9 @@ discard block |
||
815 | 851 | { |
816 | 852 | $sort_ascending = strpos($sort, 'DESC') === false; |
817 | 853 | |
818 | - foreach ($groups as $group) |
|
819 | - $sort_array[] = $group['id_group'] != 3 ? (int) $group['num_members'] : -1; |
|
854 | + foreach ($groups as $group) { |
|
855 | + $sort_array[] = $group['id_group'] != 3 ? (int) $group['num_members'] : -1; |
|
856 | + } |
|
820 | 857 | |
821 | 858 | array_multisort($sort_array, $sort_ascending ? SORT_ASC : SORT_DESC, SORT_REGULAR, $groups); |
822 | 859 | } |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Get the latest post made on the system |
@@ -44,8 +45,9 @@ discard block |
||
44 | 45 | 'is_approved' => 1, |
45 | 46 | ) |
46 | 47 | ); |
47 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
48 | - return array(); |
|
48 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
49 | + return array(); |
|
50 | + } |
|
49 | 51 | $row = $smcFunc['db_fetch_assoc']($request); |
50 | 52 | $smcFunc['db_free_result']($request); |
51 | 53 | |
@@ -54,8 +56,9 @@ discard block |
||
54 | 56 | censorText($row['body']); |
55 | 57 | |
56 | 58 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled']), array('<br>' => ' '))); |
57 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
58 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
59 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
60 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
61 | + } |
|
59 | 62 | |
60 | 63 | // Send the data. |
61 | 64 | return array( |
@@ -83,15 +86,17 @@ discard block |
||
83 | 86 | |
84 | 87 | $context['is_redirect'] = false; |
85 | 88 | |
86 | - if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) |
|
87 | - $_REQUEST['start'] = 95; |
|
89 | + if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) { |
|
90 | + $_REQUEST['start'] = 95; |
|
91 | + } |
|
88 | 92 | |
89 | 93 | $query_parameters = array(); |
90 | 94 | if (!empty($_REQUEST['c']) && empty($board)) |
91 | 95 | { |
92 | 96 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
93 | - foreach ($_REQUEST['c'] as $i => $c) |
|
94 | - $_REQUEST['c'][$i] = (int) $c; |
|
97 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
98 | + $_REQUEST['c'][$i] = (int) $c; |
|
99 | + } |
|
95 | 100 | |
96 | 101 | if (count($_REQUEST['c']) == 1) |
97 | 102 | { |
@@ -107,8 +112,9 @@ discard block |
||
107 | 112 | list ($name) = $smcFunc['db_fetch_row']($request); |
108 | 113 | $smcFunc['db_free_result']($request); |
109 | 114 | |
110 | - if (empty($name)) |
|
111 | - fatal_lang_error('no_access', false); |
|
115 | + if (empty($name)) { |
|
116 | + fatal_lang_error('no_access', false); |
|
117 | + } |
|
112 | 118 | |
113 | 119 | $context['linktree'][] = array( |
114 | 120 | 'url' => $scripturl . '#c' . (int) $_REQUEST['c'], |
@@ -140,8 +146,9 @@ discard block |
||
140 | 146 | } |
141 | 147 | $smcFunc['db_free_result']($request); |
142 | 148 | |
143 | - if (empty($boards)) |
|
144 | - fatal_lang_error('error_no_boards_selected'); |
|
149 | + if (empty($boards)) { |
|
150 | + fatal_lang_error('error_no_boards_selected'); |
|
151 | + } |
|
145 | 152 | |
146 | 153 | $query_this_board = 'b.id_board IN ({array_int:boards})'; |
147 | 154 | $query_parameters['boards'] = $boards; |
@@ -155,12 +162,12 @@ discard block |
||
155 | 162 | } |
156 | 163 | |
157 | 164 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;c=' . implode(',', $_REQUEST['c']), $_REQUEST['start'], min(100, $total_cat_posts), 10, false); |
158 | - } |
|
159 | - elseif (!empty($_REQUEST['boards'])) |
|
165 | + } elseif (!empty($_REQUEST['boards'])) |
|
160 | 166 | { |
161 | 167 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
162 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
163 | - $_REQUEST['boards'][$i] = (int) $b; |
|
168 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
169 | + $_REQUEST['boards'][$i] = (int) $b; |
|
170 | + } |
|
164 | 171 | |
165 | 172 | $request = $smcFunc['db_query']('', ' |
166 | 173 | SELECT b.id_board, b.num_posts |
@@ -184,8 +191,9 @@ discard block |
||
184 | 191 | } |
185 | 192 | $smcFunc['db_free_result']($request); |
186 | 193 | |
187 | - if (empty($boards)) |
|
188 | - fatal_lang_error('error_no_boards_selected'); |
|
194 | + if (empty($boards)) { |
|
195 | + fatal_lang_error('error_no_boards_selected'); |
|
196 | + } |
|
189 | 197 | |
190 | 198 | $query_this_board = 'b.id_board IN ({array_int:boards})'; |
191 | 199 | $query_parameters['boards'] = $boards; |
@@ -199,8 +207,7 @@ discard block |
||
199 | 207 | } |
200 | 208 | |
201 | 209 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;boards=' . implode(',', $_REQUEST['boards']), $_REQUEST['start'], min(100, $total_posts), 10, false); |
202 | - } |
|
203 | - elseif (!empty($board)) |
|
210 | + } elseif (!empty($board)) |
|
204 | 211 | { |
205 | 212 | $request = $smcFunc['db_query']('', ' |
206 | 213 | SELECT num_posts, redirect |
@@ -233,8 +240,7 @@ discard block |
||
233 | 240 | } |
234 | 241 | |
235 | 242 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;board=' . $board . '.%1$d', $_REQUEST['start'], min(100, $total_posts), 10, true); |
236 | - } |
|
237 | - else |
|
243 | + } else |
|
238 | 244 | { |
239 | 245 | $query_this_board = '{query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' |
240 | 246 | AND b.id_board != {int:recycle_board}' : ''). ' |
@@ -269,8 +275,9 @@ discard block |
||
269 | 275 | ); |
270 | 276 | |
271 | 277 | // If you selected a redirection board, don't try getting posts for it... |
272 | - if ($context['is_redirect']) |
|
273 | - $messages = 0; |
|
278 | + if ($context['is_redirect']) { |
|
279 | + $messages = 0; |
|
280 | + } |
|
274 | 281 | |
275 | 282 | $key = 'recent-' . $user_info['id'] . '-' . md5(json_encode(array_diff_key($query_parameters, array('max_id_msg' => 0)))) . '-' . (int) $_REQUEST['start']; |
276 | 283 | if (!$context['is_redirect'] && (empty($modSettings['cache_enable']) || ($messages = cache_get_data($key, 120)) == null)) |
@@ -301,16 +308,18 @@ discard block |
||
301 | 308 | $query_this_board = str_replace('AND m.id_msg >= {int:max_id_msg}', '', $query_this_board); |
302 | 309 | $cache_results = true; |
303 | 310 | unset($query_parameters['max_id_msg']); |
311 | + } else { |
|
312 | + $done = true; |
|
304 | 313 | } |
305 | - else |
|
306 | - $done = true; |
|
307 | 314 | } |
308 | 315 | $messages = array(); |
309 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
310 | - $messages[] = $row['id_msg']; |
|
316 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
317 | + $messages[] = $row['id_msg']; |
|
318 | + } |
|
311 | 319 | $smcFunc['db_free_result']($request); |
312 | - if (!empty($cache_results)) |
|
313 | - cache_put_data($key, $messages, 120); |
|
320 | + if (!empty($cache_results)) { |
|
321 | + cache_put_data($key, $messages, 120); |
|
322 | + } |
|
314 | 323 | } |
315 | 324 | |
316 | 325 | // Nothing here... Or at least, nothing you can see... |
@@ -397,8 +406,9 @@ discard block |
||
397 | 406 | 'css_class' => 'windowbg', |
398 | 407 | ); |
399 | 408 | |
400 | - if ($user_info['id'] == $row['id_first_member']) |
|
401 | - $board_ids['own'][$row['id_board']][] = $row['id_msg']; |
|
409 | + if ($user_info['id'] == $row['id_first_member']) { |
|
410 | + $board_ids['own'][$row['id_board']][] = $row['id_msg']; |
|
411 | + } |
|
402 | 412 | $board_ids['any'][$row['id_board']][] = $row['id_msg']; |
403 | 413 | } |
404 | 414 | $smcFunc['db_free_result']($request); |
@@ -424,20 +434,23 @@ discard block |
||
424 | 434 | $boards = boardsAllowedTo($permission); |
425 | 435 | |
426 | 436 | // If 0 is the only thing in the array, they can do it everywhere! |
427 | - if (!empty($boards) && $boards[0] == 0) |
|
428 | - $boards = array_keys($board_ids[$type]); |
|
437 | + if (!empty($boards) && $boards[0] == 0) { |
|
438 | + $boards = array_keys($board_ids[$type]); |
|
439 | + } |
|
429 | 440 | |
430 | 441 | // Go through the boards, and look for posts they can do this on. |
431 | 442 | foreach ($boards as $board_id) |
432 | 443 | { |
433 | 444 | // Hmm, they have permission, but there are no topics from that board on this page. |
434 | - if (!isset($board_ids[$type][$board_id])) |
|
435 | - continue; |
|
445 | + if (!isset($board_ids[$type][$board_id])) { |
|
446 | + continue; |
|
447 | + } |
|
436 | 448 | |
437 | 449 | // Okay, looks like they can do it for these posts. |
438 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
439 | - if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id']) |
|
450 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
451 | + if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id']) |
|
440 | 452 | $context['posts'][$counter][$allowed] = true; |
453 | + } |
|
441 | 454 | } |
442 | 455 | } |
443 | 456 | } |
@@ -480,17 +493,19 @@ discard block |
||
480 | 493 | $context['showing_all_topics'] = isset($_GET['all']); |
481 | 494 | $context['start'] = (int) $_REQUEST['start']; |
482 | 495 | $context['topics_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
483 | - if ($_REQUEST['action'] == 'unread') |
|
484 | - $context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit']; |
|
485 | - else |
|
486 | - $context['page_title'] = $txt['unread_replies']; |
|
496 | + if ($_REQUEST['action'] == 'unread') { |
|
497 | + $context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit']; |
|
498 | + } else { |
|
499 | + $context['page_title'] = $txt['unread_replies']; |
|
500 | + } |
|
487 | 501 | |
488 | - if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) |
|
489 | - fatal_lang_error('loadavg_allunread_disabled', false); |
|
490 | - elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) |
|
491 | - fatal_lang_error('loadavg_unreadreplies_disabled', false); |
|
492 | - elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) |
|
493 | - fatal_lang_error('loadavg_unread_disabled', false); |
|
502 | + if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) { |
|
503 | + fatal_lang_error('loadavg_allunread_disabled', false); |
|
504 | + } elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) { |
|
505 | + fatal_lang_error('loadavg_unreadreplies_disabled', false); |
|
506 | + } elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) { |
|
507 | + fatal_lang_error('loadavg_unread_disabled', false); |
|
508 | + } |
|
494 | 509 | |
495 | 510 | // Parameters for the main query. |
496 | 511 | $query_parameters = array(); |
@@ -503,12 +518,14 @@ discard block |
||
503 | 518 | if (!empty($_REQUEST['boards'])) |
504 | 519 | { |
505 | 520 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
506 | - foreach ($_REQUEST['boards'] as $b) |
|
507 | - $boards[] = (int) $b; |
|
521 | + foreach ($_REQUEST['boards'] as $b) { |
|
522 | + $boards[] = (int) $b; |
|
523 | + } |
|
508 | 524 | } |
509 | 525 | |
510 | - if (!empty($board)) |
|
511 | - $boards[] = (int) $board; |
|
526 | + if (!empty($board)) { |
|
527 | + $boards[] = (int) $board; |
|
528 | + } |
|
512 | 529 | |
513 | 530 | // The easiest thing is to just get all the boards they can see, but since we've specified the top of tree we ignore some of them |
514 | 531 | $request = $smcFunc['db_query']('', ' |
@@ -525,30 +542,31 @@ discard block |
||
525 | 542 | ) |
526 | 543 | ); |
527 | 544 | |
528 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
529 | - if (in_array($row['id_parent'], $boards)) |
|
545 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
546 | + if (in_array($row['id_parent'], $boards)) |
|
530 | 547 | $boards[] = $row['id_board']; |
548 | + } |
|
531 | 549 | |
532 | 550 | $smcFunc['db_free_result']($request); |
533 | 551 | |
534 | - if (empty($boards)) |
|
535 | - fatal_lang_error('error_no_boards_selected'); |
|
552 | + if (empty($boards)) { |
|
553 | + fatal_lang_error('error_no_boards_selected'); |
|
554 | + } |
|
536 | 555 | |
537 | 556 | $query_this_board = 'id_board IN ({array_int:boards})'; |
538 | 557 | $query_parameters['boards'] = $boards; |
539 | 558 | $context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%d'; |
540 | - } |
|
541 | - elseif (!empty($board)) |
|
559 | + } elseif (!empty($board)) |
|
542 | 560 | { |
543 | 561 | $query_this_board = 'id_board = {int:board}'; |
544 | 562 | $query_parameters['board'] = $board; |
545 | 563 | $context['querystring_board_limits'] = ';board=' . $board . '.%1$d'; |
546 | - } |
|
547 | - elseif (!empty($_REQUEST['boards'])) |
|
564 | + } elseif (!empty($_REQUEST['boards'])) |
|
548 | 565 | { |
549 | 566 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
550 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
551 | - $_REQUEST['boards'][$i] = (int) $b; |
|
567 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
568 | + $_REQUEST['boards'][$i] = (int) $b; |
|
569 | + } |
|
552 | 570 | |
553 | 571 | $request = $smcFunc['db_query']('', ' |
554 | 572 | SELECT b.id_board |
@@ -560,22 +578,24 @@ discard block |
||
560 | 578 | ) |
561 | 579 | ); |
562 | 580 | $boards = array(); |
563 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
564 | - $boards[] = $row['id_board']; |
|
581 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
582 | + $boards[] = $row['id_board']; |
|
583 | + } |
|
565 | 584 | $smcFunc['db_free_result']($request); |
566 | 585 | |
567 | - if (empty($boards)) |
|
568 | - fatal_lang_error('error_no_boards_selected'); |
|
586 | + if (empty($boards)) { |
|
587 | + fatal_lang_error('error_no_boards_selected'); |
|
588 | + } |
|
569 | 589 | |
570 | 590 | $query_this_board = 'id_board IN ({array_int:boards})'; |
571 | 591 | $query_parameters['boards'] = $boards; |
572 | 592 | $context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%1$d'; |
573 | - } |
|
574 | - elseif (!empty($_REQUEST['c'])) |
|
593 | + } elseif (!empty($_REQUEST['c'])) |
|
575 | 594 | { |
576 | 595 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
577 | - foreach ($_REQUEST['c'] as $i => $c) |
|
578 | - $_REQUEST['c'][$i] = (int) $c; |
|
596 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
597 | + $_REQUEST['c'][$i] = (int) $c; |
|
598 | + } |
|
579 | 599 | |
580 | 600 | $see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board'; |
581 | 601 | $request = $smcFunc['db_query']('', ' |
@@ -588,18 +608,19 @@ discard block |
||
588 | 608 | ) |
589 | 609 | ); |
590 | 610 | $boards = array(); |
591 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
592 | - $boards[] = $row['id_board']; |
|
611 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
612 | + $boards[] = $row['id_board']; |
|
613 | + } |
|
593 | 614 | $smcFunc['db_free_result']($request); |
594 | 615 | |
595 | - if (empty($boards)) |
|
596 | - fatal_lang_error('error_no_boards_selected'); |
|
616 | + if (empty($boards)) { |
|
617 | + fatal_lang_error('error_no_boards_selected'); |
|
618 | + } |
|
597 | 619 | |
598 | 620 | $query_this_board = 'id_board IN ({array_int:boards})'; |
599 | 621 | $query_parameters['boards'] = $boards; |
600 | 622 | $context['querystring_board_limits'] = ';c=' . implode(',', $_REQUEST['c']) . ';start=%1$d'; |
601 | - } |
|
602 | - else |
|
623 | + } else |
|
603 | 624 | { |
604 | 625 | $see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board'; |
605 | 626 | // Don't bother to show deleted posts! |
@@ -613,12 +634,14 @@ discard block |
||
613 | 634 | ) |
614 | 635 | ); |
615 | 636 | $boards = array(); |
616 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
617 | - $boards[] = $row['id_board']; |
|
637 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
638 | + $boards[] = $row['id_board']; |
|
639 | + } |
|
618 | 640 | $smcFunc['db_free_result']($request); |
619 | 641 | |
620 | - if (empty($boards)) |
|
621 | - fatal_lang_error('error_no_boards_available', false); |
|
642 | + if (empty($boards)) { |
|
643 | + fatal_lang_error('error_no_boards_available', false); |
|
644 | + } |
|
622 | 645 | |
623 | 646 | $query_this_board = 'id_board IN ({array_int:boards})'; |
624 | 647 | $query_parameters['boards'] = $boards; |
@@ -680,13 +703,14 @@ discard block |
||
680 | 703 | 'name' => $_REQUEST['action'] == 'unread' ? $txt['unread_topics_visit'] : $txt['unread_replies'] |
681 | 704 | ); |
682 | 705 | |
683 | - if ($context['showing_all_topics']) |
|
684 | - $context['linktree'][] = array( |
|
706 | + if ($context['showing_all_topics']) { |
|
707 | + $context['linktree'][] = array( |
|
685 | 708 | 'url' => $scripturl . '?action=' . $_REQUEST['action'] . ';all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'], |
686 | 709 | 'name' => $txt['unread_topics_all'] |
687 | 710 | ); |
688 | - else |
|
689 | - $txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'])); |
|
711 | + } else { |
|
712 | + $txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'])); |
|
713 | + } |
|
690 | 714 | |
691 | 715 | loadTemplate('Recent'); |
692 | 716 | loadTemplate('MessageIndex'); |
@@ -694,8 +718,9 @@ discard block |
||
694 | 718 | |
695 | 719 | // Setup the default topic icons... for checking they exist and the like ;) |
696 | 720 | $context['icon_sources'] = array(); |
697 | - foreach ($context['stable_icons'] as $icon) |
|
698 | - $context['icon_sources'][$icon] = 'images_url'; |
|
721 | + foreach ($context['stable_icons'] as $icon) { |
|
722 | + $context['icon_sources'][$icon] = 'images_url'; |
|
723 | + } |
|
699 | 724 | |
700 | 725 | $is_topics = $_REQUEST['action'] == 'unread'; |
701 | 726 | |
@@ -725,8 +750,7 @@ discard block |
||
725 | 750 | ); |
726 | 751 | list ($earliest_msg) = $smcFunc['db_fetch_row']($request); |
727 | 752 | $smcFunc['db_free_result']($request); |
728 | - } |
|
729 | - else |
|
753 | + } else |
|
730 | 754 | { |
731 | 755 | $request = $smcFunc['db_query']('', ' |
732 | 756 | SELECT MIN(lmr.id_msg) |
@@ -742,14 +766,14 @@ discard block |
||
742 | 766 | } |
743 | 767 | |
744 | 768 | // This is needed in case of topics marked unread. |
745 | - if (empty($earliest_msg)) |
|
746 | - $earliest_msg = 0; |
|
747 | - else |
|
769 | + if (empty($earliest_msg)) { |
|
770 | + $earliest_msg = 0; |
|
771 | + } else |
|
748 | 772 | { |
749 | 773 | // Using caching, when possible, to ignore the below slow query. |
750 | - if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) |
|
751 | - $earliest_msg2 = $_SESSION['cached_log_time'][1]; |
|
752 | - else |
|
774 | + if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) { |
|
775 | + $earliest_msg2 = $_SESSION['cached_log_time'][1]; |
|
776 | + } else |
|
753 | 777 | { |
754 | 778 | // This query is pretty slow, but it's needed to ensure nothing crucial is ignored. |
755 | 779 | $request = $smcFunc['db_query']('', ' |
@@ -764,8 +788,9 @@ discard block |
||
764 | 788 | $smcFunc['db_free_result']($request); |
765 | 789 | |
766 | 790 | // In theory this could be zero, if the first ever post is unread, so fudge it ;) |
767 | - if ($earliest_msg2 == 0) |
|
768 | - $earliest_msg2 = -1; |
|
791 | + if ($earliest_msg2 == 0) { |
|
792 | + $earliest_msg2 = -1; |
|
793 | + } |
|
769 | 794 | |
770 | 795 | $_SESSION['cached_log_time'] = array(time(), $earliest_msg2); |
771 | 796 | } |
@@ -803,9 +828,9 @@ discard block |
||
803 | 828 | 'db_error_skip' => true, |
804 | 829 | )) |
805 | 830 | ) !== false; |
831 | + } else { |
|
832 | + $have_temp_table = false; |
|
806 | 833 | } |
807 | - else |
|
808 | - $have_temp_table = false; |
|
809 | 834 | |
810 | 835 | if ($context['showing_all_topics'] && $have_temp_table) |
811 | 836 | { |
@@ -851,14 +876,15 @@ discard block |
||
851 | 876 | |
852 | 877 | $context['topics'] = array(); |
853 | 878 | $context['no_topic_listing'] = true; |
854 | - if ($context['querystring_board_limits'] == ';start=%1$d') |
|
855 | - $context['querystring_board_limits'] = ''; |
|
856 | - else |
|
857 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
879 | + if ($context['querystring_board_limits'] == ';start=%1$d') { |
|
880 | + $context['querystring_board_limits'] = ''; |
|
881 | + } else { |
|
882 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
883 | + } |
|
858 | 884 | return; |
885 | + } else { |
|
886 | + $min_message = (int) $min_message; |
|
859 | 887 | } |
860 | - else |
|
861 | - $min_message = (int) $min_message; |
|
862 | 888 | |
863 | 889 | $request = $smcFunc['db_query']('substring', ' |
864 | 890 | SELECT ' . $select_clause . ' |
@@ -887,8 +913,7 @@ discard block |
||
887 | 913 | 'limit' => $context['topics_per_page'], |
888 | 914 | )) |
889 | 915 | ); |
890 | - } |
|
891 | - elseif ($is_topics) |
|
916 | + } elseif ($is_topics) |
|
892 | 917 | { |
893 | 918 | $request = $smcFunc['db_query']('', ' |
894 | 919 | SELECT COUNT(*), MIN(t.id_last_msg) |
@@ -939,14 +964,15 @@ discard block |
||
939 | 964 | |
940 | 965 | $context['topics'] = array(); |
941 | 966 | $context['no_topic_listing'] = true; |
942 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
943 | - $context['querystring_board_limits'] = ''; |
|
944 | - else |
|
945 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
967 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
968 | + $context['querystring_board_limits'] = ''; |
|
969 | + } else { |
|
970 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
971 | + } |
|
946 | 972 | return; |
973 | + } else { |
|
974 | + $min_message = (int) $min_message; |
|
947 | 975 | } |
948 | - else |
|
949 | - $min_message = (int) $min_message; |
|
950 | 976 | |
951 | 977 | $request = $smcFunc['db_query']('substring', ' |
952 | 978 | SELECT ' . $select_clause . ' |
@@ -976,8 +1002,7 @@ discard block |
||
976 | 1002 | 'limit' => $context['topics_per_page'], |
977 | 1003 | )) |
978 | 1004 | ); |
979 | - } |
|
980 | - else |
|
1005 | + } else |
|
981 | 1006 | { |
982 | 1007 | if ($modSettings['totalMessages'] > 100000) |
983 | 1008 | { |
@@ -1029,8 +1054,8 @@ discard block |
||
1029 | 1054 | ) !== false; |
1030 | 1055 | |
1031 | 1056 | // If that worked, create a sample of the log_topics table too. |
1032 | - if ($have_temp_table) |
|
1033 | - $have_temp_table = $smcFunc['db_query']('', ' |
|
1057 | + if ($have_temp_table) { |
|
1058 | + $have_temp_table = $smcFunc['db_query']('', ' |
|
1034 | 1059 | CREATE TEMPORARY TABLE {db_prefix}log_topics_posted_in ( |
1035 | 1060 | PRIMARY KEY (id_topic) |
1036 | 1061 | ) |
@@ -1043,6 +1068,7 @@ discard block |
||
1043 | 1068 | 'db_error_skip' => true, |
1044 | 1069 | ) |
1045 | 1070 | ) !== false; |
1071 | + } |
|
1046 | 1072 | } |
1047 | 1073 | |
1048 | 1074 | if (!empty($have_temp_table)) |
@@ -1058,8 +1084,7 @@ discard block |
||
1058 | 1084 | ); |
1059 | 1085 | list ($num_topics) = $smcFunc['db_fetch_row']($request); |
1060 | 1086 | $smcFunc['db_free_result']($request); |
1061 | - } |
|
1062 | - else |
|
1087 | + } else |
|
1063 | 1088 | { |
1064 | 1089 | $request = $smcFunc['db_query']('unread_fetch_topic_count', ' |
1065 | 1090 | SELECT COUNT(DISTINCT t.id_topic), MIN(t.id_last_msg) |
@@ -1100,15 +1125,16 @@ discard block |
||
1100 | 1125 | { |
1101 | 1126 | $context['topics'] = array(); |
1102 | 1127 | $context['no_topic_listing'] = true; |
1103 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
1104 | - $context['querystring_board_limits'] = ''; |
|
1105 | - else |
|
1106 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1128 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
1129 | + $context['querystring_board_limits'] = ''; |
|
1130 | + } else { |
|
1131 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1132 | + } |
|
1107 | 1133 | return; |
1108 | 1134 | } |
1109 | 1135 | |
1110 | - if (!empty($have_temp_table)) |
|
1111 | - $request = $smcFunc['db_query']('', ' |
|
1136 | + if (!empty($have_temp_table)) { |
|
1137 | + $request = $smcFunc['db_query']('', ' |
|
1112 | 1138 | SELECT t.id_topic |
1113 | 1139 | FROM {db_prefix}topics_posted_in AS t |
1114 | 1140 | LEFT JOIN {db_prefix}log_topics_posted_in AS lt ON (lt.id_topic = t.id_topic) |
@@ -1122,8 +1148,8 @@ discard block |
||
1122 | 1148 | 'limit' => $context['topics_per_page'], |
1123 | 1149 | )) |
1124 | 1150 | ); |
1125 | - else |
|
1126 | - $request = $smcFunc['db_query']('', ' |
|
1151 | + } else { |
|
1152 | + $request = $smcFunc['db_query']('', ' |
|
1127 | 1153 | SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'].' |
1128 | 1154 | FROM {db_prefix}topics AS t |
1129 | 1155 | INNER JOIN {db_prefix}messages AS m ON (m.id_topic = t.id_topic AND m.id_member = {int:current_member})' . (strpos($_REQUEST['sort'], 'ms.') === false ? '' : ' |
@@ -1147,10 +1173,12 @@ discard block |
||
1147 | 1173 | 'sort' => $_REQUEST['sort'], |
1148 | 1174 | )) |
1149 | 1175 | ); |
1176 | + } |
|
1150 | 1177 | |
1151 | 1178 | $topics = array(); |
1152 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1153 | - $topics[] = $row['id_topic']; |
|
1179 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1180 | + $topics[] = $row['id_topic']; |
|
1181 | + } |
|
1154 | 1182 | $smcFunc['db_free_result']($request); |
1155 | 1183 | |
1156 | 1184 | // Sanity... where have you gone? |
@@ -1158,10 +1186,11 @@ discard block |
||
1158 | 1186 | { |
1159 | 1187 | $context['topics'] = array(); |
1160 | 1188 | $context['no_topic_listing'] = true; |
1161 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
1162 | - $context['querystring_board_limits'] = ''; |
|
1163 | - else |
|
1164 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1189 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
1190 | + $context['querystring_board_limits'] = ''; |
|
1191 | + } else { |
|
1192 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1193 | + } |
|
1165 | 1194 | return; |
1166 | 1195 | } |
1167 | 1196 | |
@@ -1195,8 +1224,9 @@ discard block |
||
1195 | 1224 | |
1196 | 1225 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1197 | 1226 | { |
1198 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
1199 | - continue; |
|
1227 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
1228 | + continue; |
|
1229 | + } |
|
1200 | 1230 | |
1201 | 1231 | $topic_ids[] = $row['id_topic']; |
1202 | 1232 | |
@@ -1204,11 +1234,13 @@ discard block |
||
1204 | 1234 | { |
1205 | 1235 | // Limit them to 128 characters - do this FIRST because it's a lot of wasted censoring otherwise. |
1206 | 1236 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
1207 | - if ($smcFunc['strlen']($row['first_body']) > 128) |
|
1208 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...'; |
|
1237 | + if ($smcFunc['strlen']($row['first_body']) > 128) { |
|
1238 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...'; |
|
1239 | + } |
|
1209 | 1240 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
1210 | - if ($smcFunc['strlen']($row['last_body']) > 128) |
|
1211 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...'; |
|
1241 | + if ($smcFunc['strlen']($row['last_body']) > 128) { |
|
1242 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...'; |
|
1243 | + } |
|
1212 | 1244 | |
1213 | 1245 | // Censor the subject and message preview. |
1214 | 1246 | censorText($row['first_subject']); |
@@ -1219,23 +1251,22 @@ discard block |
||
1219 | 1251 | { |
1220 | 1252 | $row['last_subject'] = $row['first_subject']; |
1221 | 1253 | $row['last_body'] = $row['first_body']; |
1222 | - } |
|
1223 | - else |
|
1254 | + } else |
|
1224 | 1255 | { |
1225 | 1256 | censorText($row['last_subject']); |
1226 | 1257 | censorText($row['last_body']); |
1227 | 1258 | } |
1228 | - } |
|
1229 | - else |
|
1259 | + } else |
|
1230 | 1260 | { |
1231 | 1261 | $row['first_body'] = ''; |
1232 | 1262 | $row['last_body'] = ''; |
1233 | 1263 | censorText($row['first_subject']); |
1234 | 1264 | |
1235 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
1236 | - $row['last_subject'] = $row['first_subject']; |
|
1237 | - else |
|
1238 | - censorText($row['last_subject']); |
|
1265 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
1266 | + $row['last_subject'] = $row['first_subject']; |
|
1267 | + } else { |
|
1268 | + censorText($row['last_subject']); |
|
1269 | + } |
|
1239 | 1270 | } |
1240 | 1271 | |
1241 | 1272 | // Decide how many pages the topic should have. |
@@ -1247,22 +1278,24 @@ discard block |
||
1247 | 1278 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $topic_length, $messages_per_page, true, false); |
1248 | 1279 | |
1249 | 1280 | // If we can use all, show all. |
1250 | - if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) |
|
1251 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
1281 | + if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) { |
|
1282 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
1283 | + } |
|
1284 | + } else { |
|
1285 | + $pages = ''; |
|
1252 | 1286 | } |
1253 | 1287 | |
1254 | - else |
|
1255 | - $pages = ''; |
|
1256 | - |
|
1257 | 1288 | // We need to check the topic icons exist... you can never be too sure! |
1258 | 1289 | if (!empty($modSettings['messageIconChecks_enable'])) |
1259 | 1290 | { |
1260 | 1291 | // First icon first... as you'd expect. |
1261 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
1262 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1292 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
1293 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1294 | + } |
|
1263 | 1295 | // Last icon... last... duh. |
1264 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
1265 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1296 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
1297 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1298 | + } |
|
1266 | 1299 | } |
1267 | 1300 | |
1268 | 1301 | // Force the recycling icon if appropriate |
@@ -1276,12 +1309,14 @@ discard block |
||
1276 | 1309 | $colorClass = 'windowbg'; |
1277 | 1310 | |
1278 | 1311 | // Sticky topics should get a different color, too. |
1279 | - if ($row['is_sticky']) |
|
1280 | - $colorClass .= ' sticky'; |
|
1312 | + if ($row['is_sticky']) { |
|
1313 | + $colorClass .= ' sticky'; |
|
1314 | + } |
|
1281 | 1315 | |
1282 | 1316 | // Locked topics get special treatment as well. |
1283 | - if ($row['locked']) |
|
1284 | - $colorClass .= ' locked'; |
|
1317 | + if ($row['locked']) { |
|
1318 | + $colorClass .= ' locked'; |
|
1319 | + } |
|
1285 | 1320 | |
1286 | 1321 | // And build the array. |
1287 | 1322 | $context['topics'][$row['id_topic']] = array( |
@@ -1378,8 +1413,9 @@ discard block |
||
1378 | 1413 | ); |
1379 | 1414 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
1380 | 1415 | { |
1381 | - if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) |
|
1382 | - $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
1416 | + if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) { |
|
1417 | + $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
1418 | + } |
|
1383 | 1419 | } |
1384 | 1420 | $smcFunc['db_free_result']($result); |
1385 | 1421 | } |
@@ -1394,28 +1430,30 @@ discard block |
||
1394 | 1430 | 'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']), |
1395 | 1431 | ); |
1396 | 1432 | |
1397 | - if ($context['showCheckboxes']) |
|
1398 | - $context['recent_buttons']['markselectread'] = array( |
|
1433 | + if ($context['showCheckboxes']) { |
|
1434 | + $context['recent_buttons']['markselectread'] = array( |
|
1399 | 1435 | 'text' => 'quick_mod_markread', |
1400 | 1436 | 'image' => 'markselectedread.png', |
1401 | 1437 | 'url' => 'javascript:document.quickModForm.submit();', |
1402 | 1438 | ); |
1439 | + } |
|
1403 | 1440 | |
1404 | - if (!empty($context['topics']) && !$context['showing_all_topics']) |
|
1405 | - $context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true); |
|
1406 | - } |
|
1407 | - elseif (!$is_topics && isset($context['topics_to_mark'])) |
|
1441 | + if (!empty($context['topics']) && !$context['showing_all_topics']) { |
|
1442 | + $context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true); |
|
1443 | + } |
|
1444 | + } elseif (!$is_topics && isset($context['topics_to_mark'])) |
|
1408 | 1445 | { |
1409 | 1446 | $context['recent_buttons'] = array( |
1410 | 1447 | 'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']), |
1411 | 1448 | ); |
1412 | 1449 | |
1413 | - if ($context['showCheckboxes']) |
|
1414 | - $context['recent_buttons']['markselectread'] = array( |
|
1450 | + if ($context['showCheckboxes']) { |
|
1451 | + $context['recent_buttons']['markselectread'] = array( |
|
1415 | 1452 | 'text' => 'quick_mod_markread', |
1416 | 1453 | 'image' => 'markselectedread.png', |
1417 | 1454 | 'url' => 'javascript:document.quickModForm.submit();', |
1418 | 1455 | ); |
1456 | + } |
|
1419 | 1457 | } |
1420 | 1458 | |
1421 | 1459 | // Allow mods to add additional buttons here |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Prepares the information from the moderation log for viewing. |
@@ -32,14 +33,16 @@ discard block |
||
32 | 33 | |
33 | 34 | // Are we looking at the moderation log or the administration log. |
34 | 35 | $context['log_type'] = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 3 : 1; |
35 | - if ($context['log_type'] == 3) |
|
36 | - isAllowedTo('admin_forum'); |
|
36 | + if ($context['log_type'] == 3) { |
|
37 | + isAllowedTo('admin_forum'); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | // These change dependant on whether we are viewing the moderation or admin log. |
39 | - if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') |
|
40 | - $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
41 | - else |
|
42 | - $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
41 | + if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') { |
|
42 | + $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
43 | + } else { |
|
44 | + $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
45 | + } |
|
43 | 46 | |
44 | 47 | $context['can_delete'] = allowedTo('admin_forum'); |
45 | 48 | |
@@ -67,8 +70,7 @@ discard block |
||
67 | 70 | $log_type = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 'admin' : 'moderate'; |
68 | 71 | logAction('clearlog_' . $log_type, array(), $log_type); |
69 | 72 | |
70 | - } |
|
71 | - elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
73 | + } elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
72 | 74 | { |
73 | 75 | checkSession(); |
74 | 76 | validateToken('mod-ml'); |
@@ -114,15 +116,17 @@ discard block |
||
114 | 116 | 'ip' => array('sql' => 'lm.ip', 'label' => $txt['modlog_ip']) |
115 | 117 | ); |
116 | 118 | |
117 | - if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) |
|
118 | - $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
119 | - else |
|
120 | - $search_params_string = $search_params['string']; |
|
119 | + if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) { |
|
120 | + $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
121 | + } else { |
|
122 | + $search_params_string = $search_params['string']; |
|
123 | + } |
|
121 | 124 | |
122 | - if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) |
|
123 | - $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
124 | - else |
|
125 | - $search_params_type = $search_params['type']; |
|
125 | + if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { |
|
126 | + $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
127 | + } else { |
|
128 | + $search_params_type = $search_params['type']; |
|
129 | + } |
|
126 | 130 | |
127 | 131 | $search_params_column = $searchTypes[$search_params_type]['sql']; |
128 | 132 | $search_params = array( |
@@ -297,13 +301,14 @@ discard block |
||
297 | 301 | $context['sub_template'] = 'show_list'; |
298 | 302 | $context['default_list'] = 'moderation_log_list'; |
299 | 303 | |
300 | - if (isset($context['moderation_menu_name'])) |
|
301 | - $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
304 | + if (isset($context['moderation_menu_name'])) { |
|
305 | + $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
302 | 306 | 'title' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log'], |
303 | 307 | 'help' => $context['log_type'] == 3 ? 'adminlog' : 'modlog', |
304 | 308 | 'description' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log_desc'] |
305 | 309 | ); |
306 | -} |
|
310 | + } |
|
311 | + } |
|
307 | 312 | |
308 | 313 | /** |
309 | 314 | * Get the number of mod log entries. |
@@ -407,30 +412,35 @@ discard block |
||
407 | 412 | // Add on some of the column stuff info |
408 | 413 | if (!empty($row['id_board'])) |
409 | 414 | { |
410 | - if ($row['action'] == 'move') |
|
411 | - $row['extra']['board_to'] = $row['id_board']; |
|
412 | - else |
|
413 | - $row['extra']['board'] = $row['id_board']; |
|
415 | + if ($row['action'] == 'move') { |
|
416 | + $row['extra']['board_to'] = $row['id_board']; |
|
417 | + } else { |
|
418 | + $row['extra']['board'] = $row['id_board']; |
|
419 | + } |
|
414 | 420 | } |
415 | 421 | |
416 | - if (!empty($row['id_topic'])) |
|
417 | - $row['extra']['topic'] = $row['id_topic']; |
|
418 | - if (!empty($row['id_msg'])) |
|
419 | - $row['extra']['message'] = $row['id_msg']; |
|
422 | + if (!empty($row['id_topic'])) { |
|
423 | + $row['extra']['topic'] = $row['id_topic']; |
|
424 | + } |
|
425 | + if (!empty($row['id_msg'])) { |
|
426 | + $row['extra']['message'] = $row['id_msg']; |
|
427 | + } |
|
420 | 428 | |
421 | 429 | // Is this associated with a topic? |
422 | - if (isset($row['extra']['topic'])) |
|
423 | - $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
424 | - if (isset($row['extra']['new_topic'])) |
|
425 | - $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
430 | + if (isset($row['extra']['topic'])) { |
|
431 | + $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
432 | + } |
|
433 | + if (isset($row['extra']['new_topic'])) { |
|
434 | + $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
435 | + } |
|
426 | 436 | |
427 | 437 | // How about a member? |
428 | 438 | if (isset($row['extra']['member'])) |
429 | 439 | { |
430 | 440 | // Guests don't have names! |
431 | - if (empty($row['extra']['member'])) |
|
432 | - $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
433 | - else |
|
441 | + if (empty($row['extra']['member'])) { |
|
442 | + $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
443 | + } else |
|
434 | 444 | { |
435 | 445 | // Try to find it... |
436 | 446 | $members[(int) $row['extra']['member']][] = $row['id_action']; |
@@ -438,35 +448,42 @@ discard block |
||
438 | 448 | } |
439 | 449 | |
440 | 450 | // Associated with a board? |
441 | - if (isset($row['extra']['board_to'])) |
|
442 | - $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
443 | - if (isset($row['extra']['board_from'])) |
|
444 | - $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
445 | - if (isset($row['extra']['board'])) |
|
446 | - $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
451 | + if (isset($row['extra']['board_to'])) { |
|
452 | + $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
453 | + } |
|
454 | + if (isset($row['extra']['board_from'])) { |
|
455 | + $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
456 | + } |
|
457 | + if (isset($row['extra']['board'])) { |
|
458 | + $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
459 | + } |
|
447 | 460 | |
448 | 461 | // A message? |
449 | - if (isset($row['extra']['message'])) |
|
450 | - $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
462 | + if (isset($row['extra']['message'])) { |
|
463 | + $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
464 | + } |
|
451 | 465 | |
452 | 466 | // IP Info? |
453 | - if (isset($row['extra']['ip_range'])) |
|
454 | - if ($seeIP) |
|
467 | + if (isset($row['extra']['ip_range'])) { |
|
468 | + if ($seeIP) |
|
455 | 469 | $row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>'; |
456 | - else |
|
457 | - $row['extra']['ip_range'] = $txt['logged']; |
|
470 | + } else { |
|
471 | + $row['extra']['ip_range'] = $txt['logged']; |
|
472 | + } |
|
458 | 473 | |
459 | 474 | // Email? |
460 | - if (isset($row['extra']['email'])) |
|
461 | - $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
475 | + if (isset($row['extra']['email'])) { |
|
476 | + $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
477 | + } |
|
462 | 478 | |
463 | 479 | // Bans are complex. |
464 | 480 | if ($row['action'] == 'ban' || $row['action'] == 'banremove') |
465 | 481 | { |
466 | 482 | $row['action_text'] = $txt['modlog_ac_ban' . ($row['action'] == 'banremove' ? '_remove' : '')]; |
467 | - foreach (array('member', 'email', 'ip_range', 'hostname') as $type) |
|
468 | - if (isset($row['extra'][$type])) |
|
483 | + foreach (array('member', 'email', 'ip_range', 'hostname') as $type) { |
|
484 | + if (isset($row['extra'][$type])) |
|
469 | 485 | $row['action_text'] .= $txt['modlog_ac_ban_trigger_' . $type]; |
486 | + } |
|
470 | 487 | } |
471 | 488 | |
472 | 489 | // The array to go to the template. Note here that action is set to a "default" value of the action doesn't match anything in the descriptions. Allows easy adding of logging events with basic details. |
@@ -502,12 +519,13 @@ discard block |
||
502 | 519 | foreach ($boards[$row['id_board']] as $action) |
503 | 520 | { |
504 | 521 | // Make the board number into a link - dealing with moving too. |
505 | - if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) |
|
506 | - $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
507 | - elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) |
|
508 | - $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
509 | - elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) |
|
510 | - $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
522 | + if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) { |
|
523 | + $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
524 | + } elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) { |
|
525 | + $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
526 | + } elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) { |
|
527 | + $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
528 | + } |
|
511 | 529 | } |
512 | 530 | } |
513 | 531 | $smcFunc['db_free_result']($request); |
@@ -541,10 +559,11 @@ discard block |
||
541 | 559 | ); |
542 | 560 | |
543 | 561 | // Make the topic number into a link - dealing with splitting too. |
544 | - if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) |
|
545 | - $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
546 | - elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) |
|
547 | - $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
562 | + if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) { |
|
563 | + $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
564 | + } elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) { |
|
565 | + $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
566 | + } |
|
548 | 567 | } |
549 | 568 | } |
550 | 569 | $smcFunc['db_free_result']($request); |
@@ -577,8 +596,9 @@ discard block |
||
577 | 596 | ); |
578 | 597 | |
579 | 598 | // Make the message number into a link. |
580 | - if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) |
|
581 | - $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
599 | + if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) { |
|
600 | + $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
601 | + } |
|
582 | 602 | } |
583 | 603 | } |
584 | 604 | $smcFunc['db_free_result']($request); |
@@ -618,25 +638,29 @@ discard block |
||
618 | 638 | foreach ($entries as $k => $entry) |
619 | 639 | { |
620 | 640 | // Make any message info links so its easier to go find that message. |
621 | - if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) |
|
622 | - $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
641 | + if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) { |
|
642 | + $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
643 | + } |
|
623 | 644 | |
624 | 645 | // Mark up any deleted members, topics and boards. |
625 | - foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) |
|
626 | - if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
646 | + foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) { |
|
647 | + if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
627 | 648 | $entries[$k]['extra'][$type] = sprintf($txt['modlog_id'], $entry['extra'][$type]); |
649 | + } |
|
628 | 650 | |
629 | 651 | if (isset($entry['extra']['report'])) |
630 | 652 | { |
631 | 653 | // Member profile reports go in a different area |
632 | - if (stristr($entry['action'], 'user_report')) |
|
633 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
634 | - else |
|
635 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
654 | + if (stristr($entry['action'], 'user_report')) { |
|
655 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
656 | + } else { |
|
657 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
658 | + } |
|
636 | 659 | } |
637 | 660 | |
638 | - if (empty($entries[$k]['action_text'])) |
|
639 | - $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
661 | + if (empty($entries[$k]['action_text'])) { |
|
662 | + $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
663 | + } |
|
640 | 664 | $entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i', |
641 | 665 | function ($matches) use ($entries, $k) |
642 | 666 | { |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Class browser_detector |
@@ -55,20 +56,25 @@ discard block |
||
55 | 56 | $this->_browsers['needs_size_fix'] = false; |
56 | 57 | |
57 | 58 | // One at a time, one at a time, and in this order too |
58 | - if ($this->isOpera()) |
|
59 | - $this->setupOpera(); |
|
59 | + if ($this->isOpera()) { |
|
60 | + $this->setupOpera(); |
|
61 | + } |
|
60 | 62 | // Meh... |
61 | - elseif ($this->isEdge()) |
|
62 | - $this->setupEdge(); |
|
63 | + elseif ($this->isEdge()) { |
|
64 | + $this->setupEdge(); |
|
65 | + } |
|
63 | 66 | // Them webkits need to be set up too |
64 | - elseif ($this->isWebkit()) |
|
65 | - $this->setupWebkit(); |
|
67 | + elseif ($this->isWebkit()) { |
|
68 | + $this->setupWebkit(); |
|
69 | + } |
|
66 | 70 | // We may have work to do on Firefox... |
67 | - elseif ($this->isFirefox()) |
|
68 | - $this->setupFirefox(); |
|
71 | + elseif ($this->isFirefox()) { |
|
72 | + $this->setupFirefox(); |
|
73 | + } |
|
69 | 74 | // Old friend, old frenemy |
70 | - elseif ($this->isIe()) |
|
71 | - $this->setupIe(); |
|
75 | + elseif ($this->isIe()) { |
|
76 | + $this->setupIe(); |
|
77 | + } |
|
72 | 78 | |
73 | 79 | // Just a few mobile checks |
74 | 80 | $this->isOperaMini(); |
@@ -84,11 +90,12 @@ discard block |
||
84 | 90 | $this->_browsers['possibly_robot'] = !empty($user_info['possibly_robot']); |
85 | 91 | |
86 | 92 | // Robots shouldn't be logging in or registering. So, they aren't a bot. Better to be wrong than sorry (or people won't be able to log in!), anyway. |
87 | - if ((isset($_REQUEST['action']) && in_array($_REQUEST['action'], array('login', 'login2', 'register', 'signup'))) || !$user_info['is_guest']) |
|
88 | - $this->_browsers['possibly_robot'] = false; |
|
93 | + if ((isset($_REQUEST['action']) && in_array($_REQUEST['action'], array('login', 'login2', 'register', 'signup'))) || !$user_info['is_guest']) { |
|
94 | + $this->_browsers['possibly_robot'] = false; |
|
95 | + } |
|
96 | + } else { |
|
97 | + $this->_browsers['possibly_robot'] = false; |
|
89 | 98 | } |
90 | - else |
|
91 | - $this->_browsers['possibly_robot'] = false; |
|
92 | 99 | |
93 | 100 | // Fill out the historical array as needed to support old mods that don't use isBrowser |
94 | 101 | $this->fillInformation(); |
@@ -106,8 +113,9 @@ discard block |
||
106 | 113 | */ |
107 | 114 | function isOpera() |
108 | 115 | { |
109 | - if (!isset($this->_browsers['is_opera'])) |
|
110 | - $this->_browsers['is_opera'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false; |
|
116 | + if (!isset($this->_browsers['is_opera'])) { |
|
117 | + $this->_browsers['is_opera'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false; |
|
118 | + } |
|
111 | 119 | return $this->_browsers['is_opera']; |
112 | 120 | } |
113 | 121 | |
@@ -118,8 +126,9 @@ discard block |
||
118 | 126 | function isIe() |
119 | 127 | { |
120 | 128 | // I'm IE, Yes I'm the real IE; All you other IEs are just imitating. |
121 | - if (!isset($this->_browsers['is_ie'])) |
|
122 | - $this->_browsers['is_ie'] = !$this->isOpera() && !$this->isGecko() && !$this->isWebTv() && preg_match('~MSIE \d+~', $_SERVER['HTTP_USER_AGENT']) === 1; |
|
129 | + if (!isset($this->_browsers['is_ie'])) { |
|
130 | + $this->_browsers['is_ie'] = !$this->isOpera() && !$this->isGecko() && !$this->isWebTv() && preg_match('~MSIE \d+~', $_SERVER['HTTP_USER_AGENT']) === 1; |
|
131 | + } |
|
123 | 132 | return $this->_browsers['is_ie']; |
124 | 133 | } |
125 | 134 | |
@@ -131,8 +140,9 @@ discard block |
||
131 | 140 | { |
132 | 141 | // IE11 is a bit different than earlier versions |
133 | 142 | // The isGecko() part is to ensure we get this right... |
134 | - if (!isset($this->_browsers['is_ie11'])) |
|
135 | - $this->_browsers['is_ie11'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== false && $this->isGecko(); |
|
143 | + if (!isset($this->_browsers['is_ie11'])) { |
|
144 | + $this->_browsers['is_ie11'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== false && $this->isGecko(); |
|
145 | + } |
|
136 | 146 | return $this->_browsers['is_ie11']; |
137 | 147 | } |
138 | 148 | |
@@ -142,8 +152,9 @@ discard block |
||
142 | 152 | */ |
143 | 153 | function isEdge() |
144 | 154 | { |
145 | - if (!isset($this->_browsers['is_edge'])) |
|
146 | - $this->_browsers['is_edge'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Edge') !== false; |
|
155 | + if (!isset($this->_browsers['is_edge'])) { |
|
156 | + $this->_browsers['is_edge'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Edge') !== false; |
|
157 | + } |
|
147 | 158 | return $this->_browsers['is_edge']; |
148 | 159 | } |
149 | 160 | |
@@ -153,8 +164,9 @@ discard block |
||
153 | 164 | */ |
154 | 165 | function isWebkit() |
155 | 166 | { |
156 | - if (!isset($this->_browsers['is_webkit'])) |
|
157 | - $this->_browsers['is_webkit'] = strpos($_SERVER['HTTP_USER_AGENT'], 'AppleWebKit') !== false; |
|
167 | + if (!isset($this->_browsers['is_webkit'])) { |
|
168 | + $this->_browsers['is_webkit'] = strpos($_SERVER['HTTP_USER_AGENT'], 'AppleWebKit') !== false; |
|
169 | + } |
|
158 | 170 | return $this->_browsers['is_webkit']; |
159 | 171 | } |
160 | 172 | |
@@ -164,8 +176,9 @@ discard block |
||
164 | 176 | */ |
165 | 177 | function isFirefox() |
166 | 178 | { |
167 | - if (!isset($this->_browsers['is_firefox'])) |
|
168 | - $this->_browsers['is_firefox'] = preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)/~', $_SERVER['HTTP_USER_AGENT']) === 1 && $this->isGecko(); |
|
179 | + if (!isset($this->_browsers['is_firefox'])) { |
|
180 | + $this->_browsers['is_firefox'] = preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)/~', $_SERVER['HTTP_USER_AGENT']) === 1 && $this->isGecko(); |
|
181 | + } |
|
169 | 182 | return $this->_browsers['is_firefox']; |
170 | 183 | } |
171 | 184 | |
@@ -175,8 +188,9 @@ discard block |
||
175 | 188 | */ |
176 | 189 | function isWebTv() |
177 | 190 | { |
178 | - if (!isset($this->_browsers['is_web_tv'])) |
|
179 | - $this->_browsers['is_web_tv'] = strpos($_SERVER['HTTP_USER_AGENT'], 'WebTV') !== false; |
|
191 | + if (!isset($this->_browsers['is_web_tv'])) { |
|
192 | + $this->_browsers['is_web_tv'] = strpos($_SERVER['HTTP_USER_AGENT'], 'WebTV') !== false; |
|
193 | + } |
|
180 | 194 | return $this->_browsers['is_web_tv']; |
181 | 195 | } |
182 | 196 | |
@@ -186,8 +200,9 @@ discard block |
||
186 | 200 | */ |
187 | 201 | function isKonqueror() |
188 | 202 | { |
189 | - if (!isset($this->_browsers['is_konqueror'])) |
|
190 | - $this->_browsers['is_konqueror'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Konqueror') !== false; |
|
203 | + if (!isset($this->_browsers['is_konqueror'])) { |
|
204 | + $this->_browsers['is_konqueror'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Konqueror') !== false; |
|
205 | + } |
|
191 | 206 | return $this->_browsers['is_konqueror']; |
192 | 207 | } |
193 | 208 | |
@@ -197,8 +212,9 @@ discard block |
||
197 | 212 | */ |
198 | 213 | function isGecko() |
199 | 214 | { |
200 | - if (!isset($this->_browsers['is_gecko'])) |
|
201 | - $this->_browsers['is_gecko'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false && !$this->isWebkit() && !$this->isKonqueror(); |
|
215 | + if (!isset($this->_browsers['is_gecko'])) { |
|
216 | + $this->_browsers['is_gecko'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false && !$this->isWebkit() && !$this->isKonqueror(); |
|
217 | + } |
|
202 | 218 | return $this->_browsers['is_gecko']; |
203 | 219 | } |
204 | 220 | |
@@ -208,10 +224,12 @@ discard block |
||
208 | 224 | */ |
209 | 225 | function isOperaMini() |
210 | 226 | { |
211 | - if (!isset($this->_browsers['is_opera_mini'])) |
|
212 | - $this->_browsers['is_opera_mini'] = (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']) || stripos($_SERVER['HTTP_USER_AGENT'], 'opera mini') !== false); |
|
213 | - if ($this->_browsers['is_opera_mini']) |
|
214 | - $this->_is_mobile = true; |
|
227 | + if (!isset($this->_browsers['is_opera_mini'])) { |
|
228 | + $this->_browsers['is_opera_mini'] = (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']) || stripos($_SERVER['HTTP_USER_AGENT'], 'opera mini') !== false); |
|
229 | + } |
|
230 | + if ($this->_browsers['is_opera_mini']) { |
|
231 | + $this->_is_mobile = true; |
|
232 | + } |
|
215 | 233 | return $this->_browsers['is_opera_mini']; |
216 | 234 | } |
217 | 235 | |
@@ -221,10 +239,12 @@ discard block |
||
221 | 239 | */ |
222 | 240 | function isOperaMobi() |
223 | 241 | { |
224 | - if (!isset($this->_browsers['is_opera_mobi'])) |
|
225 | - $this->_browsers['is_opera_mobi'] = stripos($_SERVER['HTTP_USER_AGENT'], 'opera mobi') !== false; |
|
226 | - if ($this->_browsers['is_opera_mobi']) |
|
227 | - $this->_is_mobile = true; |
|
242 | + if (!isset($this->_browsers['is_opera_mobi'])) { |
|
243 | + $this->_browsers['is_opera_mobi'] = stripos($_SERVER['HTTP_USER_AGENT'], 'opera mobi') !== false; |
|
244 | + } |
|
245 | + if ($this->_browsers['is_opera_mobi']) { |
|
246 | + $this->_is_mobile = true; |
|
247 | + } |
|
228 | 248 | return $this->_browsers['is_opera_mini']; |
229 | 249 | } |
230 | 250 | |
@@ -244,8 +264,9 @@ discard block |
||
244 | 264 | ); |
245 | 265 | |
246 | 266 | // blackberry, playbook, iphone, nokia, android and ipods set a mobile flag |
247 | - if ($this->_browsers['is_iphone'] || $this->_browsers['is_blackberry'] || $this->_browsers['is_android'] || $this->_browsers['is_nokia']) |
|
248 | - $this->_is_mobile = true; |
|
267 | + if ($this->_browsers['is_iphone'] || $this->_browsers['is_blackberry'] || $this->_browsers['is_android'] || $this->_browsers['is_nokia']) { |
|
268 | + $this->_is_mobile = true; |
|
269 | + } |
|
249 | 270 | |
250 | 271 | // @todo what to do with the blaPad? ... for now leave it detected as Safari ... |
251 | 272 | $this->_browsers['is_safari'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== false && !$this->_browsers['is_chrome'] && !$this->_browsers['is_iphone']; |
@@ -254,15 +275,17 @@ discard block |
||
254 | 275 | // if Chrome, get the major version |
255 | 276 | if ($this->_browsers['is_chrome']) |
256 | 277 | { |
257 | - if (preg_match('~chrome[/]([0-9][0-9]?[.])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) |
|
258 | - $this->_browsers['is_chrome' . (int) $match[1]] = true; |
|
278 | + if (preg_match('~chrome[/]([0-9][0-9]?[.])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) { |
|
279 | + $this->_browsers['is_chrome' . (int) $match[1]] = true; |
|
280 | + } |
|
259 | 281 | } |
260 | 282 | |
261 | 283 | // or if Safari get its major version |
262 | 284 | if ($this->_browsers['is_safari']) |
263 | 285 | { |
264 | - if (preg_match('~version/?(.*)safari.*~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) |
|
265 | - $this->_browsers['is_safari' . (int) trim($match[1])] = true; |
|
286 | + if (preg_match('~version/?(.*)safari.*~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) { |
|
287 | + $this->_browsers['is_safari' . (int) trim($match[1])] = true; |
|
288 | + } |
|
266 | 289 | } |
267 | 290 | } |
268 | 291 | |
@@ -291,8 +314,9 @@ discard block |
||
291 | 314 | $this->_browsers['is_ie' . ((int) $trident_match[1] + 4)] = true; |
292 | 315 | |
293 | 316 | // If trident is set, see the (if any) msie tag in the user agent matches ... if not its in some compatibility view |
294 | - if (isset($msie_match[1]) && ($msie_match[1] < $trident_match[1] + 4)) |
|
295 | - $this->_browsers['is_ie_compat_view'] = true; |
|
317 | + if (isset($msie_match[1]) && ($msie_match[1] < $trident_match[1] + 4)) { |
|
318 | + $this->_browsers['is_ie_compat_view'] = true; |
|
319 | + } |
|
296 | 320 | } |
297 | 321 | |
298 | 322 | // Detect true IE6 and IE7 and not IE in compat mode. |
@@ -326,8 +350,9 @@ discard block |
||
326 | 350 | */ |
327 | 351 | private function setupFirefox() |
328 | 352 | { |
329 | - if (preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)[\/ \(]([^ ;\)]+)~', $_SERVER['HTTP_USER_AGENT'], $match) === 1) |
|
330 | - $this->_browsers['is_firefox' . (int) $match[1]] = true; |
|
353 | + if (preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)[\/ \(]([^ ;\)]+)~', $_SERVER['HTTP_USER_AGENT'], $match) === 1) { |
|
354 | + $this->_browsers['is_firefox' . (int) $match[1]] = true; |
|
355 | + } |
|
331 | 356 | } |
332 | 357 | |
333 | 358 | /** |
@@ -338,11 +363,13 @@ discard block |
||
338 | 363 | private function setupOpera() |
339 | 364 | { |
340 | 365 | // Opera 10+ uses the version tag at the end of the string |
341 | - if (preg_match('~\sVersion/([0-9]+)\.[0-9]+(?:\s*|$)~', $_SERVER['HTTP_USER_AGENT'], $match)) |
|
342 | - $this->_browsers['is_opera' . (int) $match[1]] = true; |
|
366 | + if (preg_match('~\sVersion/([0-9]+)\.[0-9]+(?:\s*|$)~', $_SERVER['HTTP_USER_AGENT'], $match)) { |
|
367 | + $this->_browsers['is_opera' . (int) $match[1]] = true; |
|
368 | + } |
|
343 | 369 | // Opera pre 10 is supposed to uses the Opera tag alone, as do some spoofers |
344 | - elseif (preg_match('~Opera[ /]([0-9]+)(?!\\.[89])~', $_SERVER['HTTP_USER_AGENT'], $match)) |
|
345 | - $this->_browsers['is_opera' . (int) $match[1]] = true; |
|
370 | + elseif (preg_match('~Opera[ /]([0-9]+)(?!\\.[89])~', $_SERVER['HTTP_USER_AGENT'], $match)) { |
|
371 | + $this->_browsers['is_opera' . (int) $match[1]] = true; |
|
372 | + } |
|
346 | 373 | |
347 | 374 | // Needs size fix? |
348 | 375 | $this->_browsers['needs_size_fix'] = !empty($this->_browsers['is_opera6']); |
@@ -353,8 +380,9 @@ discard block |
||
353 | 380 | */ |
354 | 381 | private function setupEdge() |
355 | 382 | { |
356 | - if (preg_match('~Edge[\/]([0-9][0-9]?[\.][0-9][0-9])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) |
|
357 | - $this->_browsers['is_edge' . (int) $match[1]] = true; |
|
383 | + if (preg_match('~Edge[\/]([0-9][0-9]?[\.][0-9][0-9])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) { |
|
384 | + $this->_browsers['is_edge' . (int) $match[1]] = true; |
|
385 | + } |
|
358 | 386 | } |
359 | 387 | |
360 | 388 | /** |
@@ -367,9 +395,9 @@ discard block |
||
367 | 395 | { |
368 | 396 | global $context; |
369 | 397 | |
370 | - if ($this->_is_mobile) |
|
371 | - $context['browser_body_id'] = 'mobile'; |
|
372 | - else |
|
398 | + if ($this->_is_mobile) { |
|
399 | + $context['browser_body_id'] = 'mobile'; |
|
400 | + } else |
|
373 | 401 | { |
374 | 402 | // add in any specific detection conversions here if you want a special body id e.g. 'is_opera9' => 'opera9' |
375 | 403 | $browser_priority = array( |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Add the file functions to the $smcFunc array. |
@@ -23,28 +24,32 @@ discard block |
||
23 | 24 | { |
24 | 25 | global $smcFunc; |
25 | 26 | |
26 | - if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query') |
|
27 | - $smcFunc += array( |
|
27 | + if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query') { |
|
28 | + $smcFunc += array( |
|
28 | 29 | 'db_search_query' => 'smf_db_search_query', |
29 | 30 | 'db_search_support' => 'smf_db_search_support', |
30 | 31 | 'db_create_word_search' => 'smf_db_create_word_search', |
31 | 32 | 'db_support_ignore' => false, |
32 | 33 | ); |
34 | + } |
|
33 | 35 | |
34 | 36 | db_extend(); |
35 | 37 | |
36 | 38 | //pg 9.5 got ignore support |
37 | 39 | $version = $smcFunc['db_get_version'](); |
38 | 40 | // if we got a Beta Version |
39 | - if (stripos($version, 'beta') !== false) |
|
40 | - $version = substr($version, 0, stripos($version, 'beta')).'.0'; |
|
41 | + if (stripos($version, 'beta') !== false) { |
|
42 | + $version = substr($version, 0, stripos($version, 'beta')).'.0'; |
|
43 | + } |
|
41 | 44 | // or RC |
42 | - if (stripos($version, 'rc') !== false) |
|
43 | - $version = substr($version, 0, stripos($version, 'rc')).'.0'; |
|
45 | + if (stripos($version, 'rc') !== false) { |
|
46 | + $version = substr($version, 0, stripos($version, 'rc')).'.0'; |
|
47 | + } |
|
44 | 48 | |
45 | - if (version_compare($version,'9.5.0','>=')) |
|
46 | - $smcFunc['db_support_ignore'] = true; |
|
47 | -} |
|
49 | + if (version_compare($version,'9.5.0','>=')) { |
|
50 | + $smcFunc['db_support_ignore'] = true; |
|
51 | + } |
|
52 | + } |
|
48 | 53 | |
49 | 54 | /** |
50 | 55 | * This function will tell you whether this database type supports this search type. |
@@ -103,16 +108,16 @@ discard block |
||
103 | 108 | ), |
104 | 109 | ); |
105 | 110 | |
106 | - if (isset($replacements[$identifier])) |
|
107 | - $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
111 | + if (isset($replacements[$identifier])) { |
|
112 | + $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
113 | + } |
|
108 | 114 | if (preg_match('~^\s*INSERT\sIGNORE~i', $db_string) != 0) |
109 | 115 | { |
110 | 116 | $db_string = preg_replace('~^\s*INSERT\sIGNORE~i', 'INSERT', $db_string); |
111 | 117 | if ($smcFunc['db_support_ignore']){ |
112 | 118 | //pg style "INSERT INTO.... ON CONFLICT DO NOTHING" |
113 | 119 | $db_string = $db_string.' ON CONFLICT DO NOTHING'; |
114 | - } |
|
115 | - else |
|
120 | + } else |
|
116 | 121 | { |
117 | 122 | // Don't error on multi-insert. |
118 | 123 | $db_values['db_error_skip'] = true; |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 3 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * Main dispatcher. This function checks permissions and passes control through to the relevant section. |
@@ -245,8 +246,9 @@ discard block |
||
245 | 246 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
246 | 247 | { |
247 | 248 | // Private PM/email subjects and similar shouldn't be shown in the mailbox area. |
248 | - if (!empty($row['private'])) |
|
249 | - $row['subject'] = $txt['personal_message']; |
|
249 | + if (!empty($row['private'])) { |
|
250 | + $row['subject'] = $txt['personal_message']; |
|
251 | + } |
|
250 | 252 | |
251 | 253 | $mails[] = $row; |
252 | 254 | } |
@@ -300,8 +302,9 @@ discard block |
||
300 | 302 | $element = substr($key, strrpos($key, '_') + 1); |
301 | 303 | $processedBirthdayEmails[$index][$element] = $value; |
302 | 304 | } |
303 | - foreach ($processedBirthdayEmails as $index => $dummy) |
|
304 | - $emails[$index] = $index; |
|
305 | + foreach ($processedBirthdayEmails as $index => $dummy) { |
|
306 | + $emails[$index] = $index; |
|
307 | + } |
|
305 | 308 | |
306 | 309 | $config_vars = array( |
307 | 310 | // Mail queue stuff, this rocks ;) |
@@ -322,8 +325,9 @@ discard block |
||
322 | 325 | |
323 | 326 | call_integration_hook('integrate_modify_mail_settings', array(&$config_vars)); |
324 | 327 | |
325 | - if ($return_config) |
|
326 | - return $config_vars; |
|
328 | + if ($return_config) { |
|
329 | + return $config_vars; |
|
330 | + } |
|
327 | 331 | |
328 | 332 | // Saving? |
329 | 333 | if (isset($_GET['save'])) |
@@ -398,9 +402,9 @@ discard block |
||
398 | 402 | ); |
399 | 403 | list ($_GET['te']) = $smcFunc['db_fetch_row']($request); |
400 | 404 | $smcFunc['db_free_result']($request); |
405 | + } else { |
|
406 | + $_GET['te'] = (int) $_GET['te']; |
|
401 | 407 | } |
402 | - else |
|
403 | - $_GET['te'] = (int) $_GET['te']; |
|
404 | 408 | |
405 | 409 | $_GET['sent'] = isset($_GET['sent']) ? (int) $_GET['sent'] : 0; |
406 | 410 | |
@@ -424,12 +428,14 @@ discard block |
||
424 | 428 | |
425 | 429 | // Try get more time... |
426 | 430 | @set_time_limit(600); |
427 | - if (function_exists('apache_reset_timeout')) |
|
428 | - @apache_reset_timeout(); |
|
431 | + if (function_exists('apache_reset_timeout')) { |
|
432 | + @apache_reset_timeout(); |
|
433 | + } |
|
429 | 434 | |
430 | 435 | // Have we already used our maximum time? |
431 | - if (time() - array_sum(explode(' ', $time_start)) < 5) |
|
432 | - return; |
|
436 | + if (time() - array_sum(explode(' ', $time_start)) < 5) { |
|
437 | + return; |
|
438 | + } |
|
433 | 439 | |
434 | 440 | $context['continue_get_data'] = '?action=admin;area=mailqueue;sa=clear;te=' . $_GET['te'] . ';sent=' . $_GET['sent'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
435 | 441 | $context['page_title'] = $txt['not_done_title']; |
@@ -459,8 +465,9 @@ discard block |
||
459 | 465 | { |
460 | 466 | global $txt; |
461 | 467 | |
462 | - if ($time_diff < 0) |
|
463 | - $time_diff = 0; |
|
468 | + if ($time_diff < 0) { |
|
469 | + $time_diff = 0; |
|
470 | + } |
|
464 | 471 | |
465 | 472 | // Just do a bit of an if fest... |
466 | 473 | if ($time_diff > 86400) |
@@ -481,8 +488,9 @@ discard block |
||
481 | 488 | return sprintf($minutes == 1 ? $txt['mq_minute'] : $txt['mq_minutes'], $minutes); |
482 | 489 | } |
483 | 490 | // Otherwise must be second |
484 | - else |
|
485 | - return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff); |
|
486 | -} |
|
491 | + else { |
|
492 | + return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff); |
|
493 | + } |
|
494 | + } |
|
487 | 495 | |
488 | 496 | ?> |
@@ -18,8 +18,9 @@ discard block |
||
18 | 18 | * @version 2.1 Beta 3 |
19 | 19 | */ |
20 | 20 | |
21 | -if (!defined('SMF')) |
|
21 | +if (!defined('SMF')) { |
|
22 | 22 | die('No direct access...'); |
23 | +} |
|
23 | 24 | |
24 | 25 | /** |
25 | 26 | * downloads a file from a url and stores it locally for avatar use by id_member. |
@@ -44,8 +45,9 @@ discard block |
||
44 | 45 | $destName = 'avatar_' . $memID . '_' . time() . '.' . $ext; |
45 | 46 | |
46 | 47 | // Just making sure there is a non-zero member. |
47 | - if (empty($memID)) |
|
48 | - return false; |
|
48 | + if (empty($memID)) { |
|
49 | + return false; |
|
50 | + } |
|
49 | 51 | |
50 | 52 | require_once($sourcedir . '/ManageAttachments.php'); |
51 | 53 | removeAttachments(array('id_member' => $memID)); |
@@ -76,10 +78,11 @@ discard block |
||
76 | 78 | $destName = $modSettings['custom_avatar_dir'] . '/' . $destName . '.tmp'; |
77 | 79 | |
78 | 80 | // Resize it. |
79 | - if (!empty($modSettings['avatar_download_png'])) |
|
80 | - $success = resizeImageFile($url, $destName, $max_width, $max_height, 3); |
|
81 | - else |
|
82 | - $success = resizeImageFile($url, $destName, $max_width, $max_height); |
|
81 | + if (!empty($modSettings['avatar_download_png'])) { |
|
82 | + $success = resizeImageFile($url, $destName, $max_width, $max_height, 3); |
|
83 | + } else { |
|
84 | + $success = resizeImageFile($url, $destName, $max_width, $max_height); |
|
85 | + } |
|
83 | 86 | |
84 | 87 | // Remove the .tmp extension. |
85 | 88 | $destName = substr($destName, 0, -4); |
@@ -108,11 +111,10 @@ discard block |
||
108 | 111 | ) |
109 | 112 | ); |
110 | 113 | return true; |
114 | + } else { |
|
115 | + return false; |
|
111 | 116 | } |
112 | - else |
|
113 | - return false; |
|
114 | - } |
|
115 | - else |
|
117 | + } else |
|
116 | 118 | { |
117 | 119 | $smcFunc['db_query']('', ' |
118 | 120 | DELETE FROM {db_prefix}attachments |
@@ -144,17 +146,18 @@ discard block |
||
144 | 146 | $destName = $source . '_thumb.tmp'; |
145 | 147 | |
146 | 148 | // Do the actual resize. |
147 | - if (!empty($modSettings['attachment_thumb_png'])) |
|
148 | - $success = resizeImageFile($source, $destName, $max_width, $max_height, 3); |
|
149 | - else |
|
150 | - $success = resizeImageFile($source, $destName, $max_width, $max_height); |
|
149 | + if (!empty($modSettings['attachment_thumb_png'])) { |
|
150 | + $success = resizeImageFile($source, $destName, $max_width, $max_height, 3); |
|
151 | + } else { |
|
152 | + $success = resizeImageFile($source, $destName, $max_width, $max_height); |
|
153 | + } |
|
151 | 154 | |
152 | 155 | // Okay, we're done with the temporary stuff. |
153 | 156 | $destName = substr($destName, 0, -4); |
154 | 157 | |
155 | - if ($success && @rename($destName . '.tmp', $destName)) |
|
156 | - return true; |
|
157 | - else |
|
158 | + if ($success && @rename($destName . '.tmp', $destName)) { |
|
159 | + return true; |
|
160 | + } else |
|
158 | 161 | { |
159 | 162 | @unlink($destName . '.tmp'); |
160 | 163 | @touch($destName); |
@@ -176,18 +179,21 @@ discard block |
||
176 | 179 | { |
177 | 180 | if (!resizeImageFile($fileName, $fileName . '.tmp', null, null, $preferred_format)) |
178 | 181 | { |
179 | - if (file_exists($fileName . '.tmp')) |
|
180 | - unlink($fileName . '.tmp'); |
|
182 | + if (file_exists($fileName . '.tmp')) { |
|
183 | + unlink($fileName . '.tmp'); |
|
184 | + } |
|
181 | 185 | |
182 | 186 | return false; |
183 | 187 | } |
184 | 188 | |
185 | - if (!unlink($fileName)) |
|
186 | - return false; |
|
189 | + if (!unlink($fileName)) { |
|
190 | + return false; |
|
191 | + } |
|
187 | 192 | |
188 | - if (!rename($fileName . '.tmp', $fileName)) |
|
189 | - return false; |
|
190 | -} |
|
193 | + if (!rename($fileName . '.tmp', $fileName)) { |
|
194 | + return false; |
|
195 | + } |
|
196 | + } |
|
191 | 197 | |
192 | 198 | /** |
193 | 199 | * Searches through the file to see if there's potentially harmful non-binary content. |
@@ -200,8 +206,9 @@ discard block |
||
200 | 206 | function checkImageContents($fileName, $extensiveCheck = false) |
201 | 207 | { |
202 | 208 | $fp = fopen($fileName, 'rb'); |
203 | - if (!$fp) |
|
204 | - fatal_lang_error('attach_timeout'); |
|
209 | + if (!$fp) { |
|
210 | + fatal_lang_error('attach_timeout'); |
|
211 | + } |
|
205 | 212 | |
206 | 213 | $prev_chunk = ''; |
207 | 214 | while (!feof($fp)) |
@@ -217,8 +224,7 @@ discard block |
||
217 | 224 | fclose($fp); |
218 | 225 | return false; |
219 | 226 | } |
220 | - } |
|
221 | - else |
|
227 | + } else |
|
222 | 228 | { |
223 | 229 | // Check for potential infection |
224 | 230 | if (preg_match('~(iframe|(?<!cellTextIs)html|eval|body|script\W|[CF]WS[\x01-\x0C])~i', $prev_chunk . $cur_chunk) === 1) |
@@ -245,8 +251,9 @@ discard block |
||
245 | 251 | global $gd2; |
246 | 252 | |
247 | 253 | // Check to see if GD is installed and what version. |
248 | - if (($extensionFunctions = get_extension_funcs('gd')) === false) |
|
249 | - return false; |
|
254 | + if (($extensionFunctions = get_extension_funcs('gd')) === false) { |
|
255 | + return false; |
|
256 | + } |
|
250 | 257 | |
251 | 258 | // Also determine if GD2 is installed and store it in a global. |
252 | 259 | $gd2 = in_array('imagecreatetruecolor', $extensionFunctions) && function_exists('imagecreatetruecolor'); |
@@ -318,8 +325,9 @@ discard block |
||
318 | 325 | global $sourcedir; |
319 | 326 | |
320 | 327 | // Nothing to do without GD or IM/MW |
321 | - if (!checkGD() && !checkImagick() && !checkMagickWand()) |
|
322 | - return false; |
|
328 | + if (!checkGD() && !checkImagick() && !checkMagickWand()) { |
|
329 | + return false; |
|
330 | + } |
|
323 | 331 | |
324 | 332 | static $default_formats = array( |
325 | 333 | '1' => 'gif', |
@@ -341,38 +349,39 @@ discard block |
||
341 | 349 | fclose($fp_destination); |
342 | 350 | |
343 | 351 | $sizes = @getimagesize($destination); |
344 | - } |
|
345 | - elseif ($fp_destination) |
|
352 | + } elseif ($fp_destination) |
|
346 | 353 | { |
347 | 354 | $sizes = @getimagesize($source); |
348 | 355 | |
349 | 356 | $fp_source = fopen($source, 'rb'); |
350 | 357 | if ($fp_source !== false) |
351 | 358 | { |
352 | - while (!feof($fp_source)) |
|
353 | - fwrite($fp_destination, fread($fp_source, 8192)); |
|
359 | + while (!feof($fp_source)) { |
|
360 | + fwrite($fp_destination, fread($fp_source, 8192)); |
|
361 | + } |
|
354 | 362 | fclose($fp_source); |
363 | + } else { |
|
364 | + $sizes = array(-1, -1, -1); |
|
355 | 365 | } |
356 | - else |
|
357 | - $sizes = array(-1, -1, -1); |
|
358 | 366 | fclose($fp_destination); |
359 | 367 | } |
360 | 368 | // We can't get to the file. |
361 | - else |
|
362 | - $sizes = array(-1, -1, -1); |
|
369 | + else { |
|
370 | + $sizes = array(-1, -1, -1); |
|
371 | + } |
|
363 | 372 | |
364 | 373 | // See if we have -or- can get the needed memory for this operation |
365 | 374 | // ImageMagick isn't subject to PHP's memory limits :) |
366 | - if (!(checkIMagick() || checkMagickWand()) && checkGD() && !imageMemoryCheck($sizes)) |
|
367 | - return false; |
|
375 | + if (!(checkIMagick() || checkMagickWand()) && checkGD() && !imageMemoryCheck($sizes)) { |
|
376 | + return false; |
|
377 | + } |
|
368 | 378 | |
369 | 379 | // A known and supported format? |
370 | 380 | // @todo test PSD and gif. |
371 | 381 | if ((checkImagick() || checkMagickWand()) && isset($default_formats[$sizes[2]])) |
372 | 382 | { |
373 | 383 | return resizeImage(null, $destination, null, null, $max_width, $max_height, true, $preferred_format); |
374 | - } |
|
375 | - elseif (checkGD() && isset($default_formats[$sizes[2]]) && function_exists('imagecreatefrom' . $default_formats[$sizes[2]])) |
|
384 | + } elseif (checkGD() && isset($default_formats[$sizes[2]]) && function_exists('imagecreatefrom' . $default_formats[$sizes[2]])) |
|
376 | 385 | { |
377 | 386 | $imagecreatefrom = 'imagecreatefrom' . $default_formats[$sizes[2]]; |
378 | 387 | if ($src_img = @$imagecreatefrom($destination)) |
@@ -425,14 +434,14 @@ discard block |
||
425 | 434 | $dest_width = empty($max_width) ? $src_width : $max_width; |
426 | 435 | $dest_height = empty($max_height) ? $src_height : $max_height; |
427 | 436 | |
428 | - if ($default_formats[$preferred_format] == 'jpeg') |
|
429 | - $imagick->setCompressionQuality(!empty($modSettings['avatar_jpeg_quality']) ? $modSettings['avatar_jpeg_quality'] : 82); |
|
437 | + if ($default_formats[$preferred_format] == 'jpeg') { |
|
438 | + $imagick->setCompressionQuality(!empty($modSettings['avatar_jpeg_quality']) ? $modSettings['avatar_jpeg_quality'] : 82); |
|
439 | + } |
|
430 | 440 | |
431 | 441 | $imagick->setImageFormat($default_formats[$preferred_format]); |
432 | 442 | $imagick->resizeImage($dest_width, $dest_height, Imagick::FILTER_LANCZOS, 1, true); |
433 | 443 | $success = $imagick->writeImage($destName); |
434 | - } |
|
435 | - else |
|
444 | + } else |
|
436 | 445 | { |
437 | 446 | $magick_wand = newMagickWand(); |
438 | 447 | MagickReadImage($magick_wand, $destName); |
@@ -441,8 +450,9 @@ discard block |
||
441 | 450 | $dest_width = empty($max_width) ? $src_width : $max_width; |
442 | 451 | $dest_height = empty($max_height) ? $src_height : $max_height; |
443 | 452 | |
444 | - if ($default_formats[$preferred_format] == 'jpeg') |
|
445 | - MagickSetCompressionQuality($magick_wand, !empty($modSettings['avatar_jpeg_quality']) ? $modSettings['avatar_jpeg_quality'] : 82); |
|
453 | + if ($default_formats[$preferred_format] == 'jpeg') { |
|
454 | + MagickSetCompressionQuality($magick_wand, !empty($modSettings['avatar_jpeg_quality']) ? $modSettings['avatar_jpeg_quality'] : 82); |
|
455 | + } |
|
446 | 456 | |
447 | 457 | MagickSetImageFormat($magick_wand, $default_formats[$preferred_format]); |
448 | 458 | MagickResizeImage($magick_wand, $dest_width, $dest_height, MW_LanczosFilter, 1, true); |
@@ -450,8 +460,7 @@ discard block |
||
450 | 460 | } |
451 | 461 | |
452 | 462 | return !empty($success); |
453 | - } |
|
454 | - elseif (checkGD()) |
|
463 | + } elseif (checkGD()) |
|
455 | 464 | { |
456 | 465 | $success = false; |
457 | 466 | |
@@ -462,8 +471,7 @@ discard block |
||
462 | 471 | { |
463 | 472 | $dst_width = $max_width; |
464 | 473 | $dst_height = round($src_height * $max_width / $src_width); |
465 | - } |
|
466 | - elseif (!empty($max_height)) |
|
474 | + } elseif (!empty($max_height)) |
|
467 | 475 | { |
468 | 476 | $dst_width = round($src_width * $max_height / $src_height); |
469 | 477 | $dst_height = $max_height; |
@@ -481,44 +489,48 @@ discard block |
||
481 | 489 | if ((!empty($preferred_format)) && ($preferred_format == 3)) |
482 | 490 | { |
483 | 491 | imagealphablending($dst_img, false); |
484 | - if (function_exists('imagesavealpha')) |
|
485 | - imagesavealpha($dst_img, true); |
|
492 | + if (function_exists('imagesavealpha')) { |
|
493 | + imagesavealpha($dst_img, true); |
|
494 | + } |
|
486 | 495 | } |
496 | + } else { |
|
497 | + $dst_img = imagecreate($dst_width, $dst_height); |
|
487 | 498 | } |
488 | - else |
|
489 | - $dst_img = imagecreate($dst_width, $dst_height); |
|
490 | 499 | |
491 | 500 | // Resize it! |
492 | - if ($gd2) |
|
493 | - imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height); |
|
494 | - else |
|
495 | - imagecopyresamplebicubic($dst_img, $src_img, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height); |
|
501 | + if ($gd2) { |
|
502 | + imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height); |
|
503 | + } else { |
|
504 | + imagecopyresamplebicubic($dst_img, $src_img, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height); |
|
505 | + } |
|
506 | + } else { |
|
507 | + $dst_img = $src_img; |
|
496 | 508 | } |
497 | - else |
|
498 | - $dst_img = $src_img; |
|
509 | + } else { |
|
510 | + $dst_img = $src_img; |
|
499 | 511 | } |
500 | - else |
|
501 | - $dst_img = $src_img; |
|
502 | 512 | |
503 | 513 | // Save the image as ... |
504 | - if (!empty($preferred_format) && ($preferred_format == 3) && function_exists('imagepng')) |
|
505 | - $success = imagepng($dst_img, $destName); |
|
506 | - elseif (!empty($preferred_format) && ($preferred_format == 1) && function_exists('imagegif')) |
|
507 | - $success = imagegif($dst_img, $destName); |
|
508 | - elseif (function_exists('imagejpeg')) |
|
509 | - $success = imagejpeg($dst_img, $destName, !empty($modSettings['avatar_jpeg_quality']) ? $modSettings['avatar_jpeg_quality'] : 82); |
|
514 | + if (!empty($preferred_format) && ($preferred_format == 3) && function_exists('imagepng')) { |
|
515 | + $success = imagepng($dst_img, $destName); |
|
516 | + } elseif (!empty($preferred_format) && ($preferred_format == 1) && function_exists('imagegif')) { |
|
517 | + $success = imagegif($dst_img, $destName); |
|
518 | + } elseif (function_exists('imagejpeg')) { |
|
519 | + $success = imagejpeg($dst_img, $destName, !empty($modSettings['avatar_jpeg_quality']) ? $modSettings['avatar_jpeg_quality'] : 82); |
|
520 | + } |
|
510 | 521 | |
511 | 522 | // Free the memory. |
512 | 523 | imagedestroy($src_img); |
513 | - if ($dst_img != $src_img) |
|
514 | - imagedestroy($dst_img); |
|
524 | + if ($dst_img != $src_img) { |
|
525 | + imagedestroy($dst_img); |
|
526 | + } |
|
515 | 527 | |
516 | 528 | return $success; |
517 | - } |
|
518 | - else |
|
519 | - // Without GD, no image resizing at all. |
|
529 | + } else { |
|
530 | + // Without GD, no image resizing at all. |
|
520 | 531 | return false; |
521 | -} |
|
532 | + } |
|
533 | + } |
|
522 | 534 | |
523 | 535 | /** |
524 | 536 | * Copy image. |
@@ -572,8 +584,9 @@ discard block |
||
572 | 584 | $color = imagecolorresolve($dst_img, $red, $green, $blue); |
573 | 585 | if ($color == -1) |
574 | 586 | { |
575 | - if ($palsize++ < 256) |
|
576 | - imagecolorallocate($dst_img, $red, $green, $blue); |
|
587 | + if ($palsize++ < 256) { |
|
588 | + imagecolorallocate($dst_img, $red, $green, $blue); |
|
589 | + } |
|
577 | 590 | $color = imagecolorclosest($dst_img, $red, $green, $blue); |
578 | 591 | } |
579 | 592 | |
@@ -603,13 +616,15 @@ discard block |
||
603 | 616 | $header = unpack('vtype/Vsize/Vreserved/Voffset', fread($fp, 14)); |
604 | 617 | $info = unpack('Vsize/Vwidth/Vheight/vplanes/vbits/Vcompression/Vimagesize/Vxres/Vyres/Vncolor/Vcolorimportant', fread($fp, 40)); |
605 | 618 | |
606 | - if ($header['type'] != 0x4D42) |
|
607 | - return false; |
|
619 | + if ($header['type'] != 0x4D42) { |
|
620 | + return false; |
|
621 | + } |
|
608 | 622 | |
609 | - if ($gd2) |
|
610 | - $dst_img = imagecreatetruecolor($info['width'], $info['height']); |
|
611 | - else |
|
612 | - $dst_img = imagecreate($info['width'], $info['height']); |
|
623 | + if ($gd2) { |
|
624 | + $dst_img = imagecreatetruecolor($info['width'], $info['height']); |
|
625 | + } else { |
|
626 | + $dst_img = imagecreate($info['width'], $info['height']); |
|
627 | + } |
|
613 | 628 | |
614 | 629 | $palette_size = $header['offset'] - 54; |
615 | 630 | $info['ncolor'] = $palette_size / 4; |
@@ -635,8 +650,9 @@ discard block |
||
635 | 650 | fseek($fp, $header['offset'] + ($scan_line_size + $scan_line_align) * $l); |
636 | 651 | $scan_line = fread($fp, $scan_line_size); |
637 | 652 | |
638 | - if (strlen($scan_line) < $scan_line_size) |
|
639 | - continue; |
|
653 | + if (strlen($scan_line) < $scan_line_size) { |
|
654 | + continue; |
|
655 | + } |
|
640 | 656 | |
641 | 657 | if ($info['bits'] == 32) |
642 | 658 | { |
@@ -654,14 +670,14 @@ discard block |
||
654 | 670 | $color = imagecolorallocate($dst_img, $r, $g, $b); |
655 | 671 | |
656 | 672 | // Gah! Out of colors? Stupid GD 1... try anyhow. |
657 | - if ($color == -1) |
|
658 | - $color = imagecolorclosest($dst_img, $r, $g, $b); |
|
673 | + if ($color == -1) { |
|
674 | + $color = imagecolorclosest($dst_img, $r, $g, $b); |
|
675 | + } |
|
659 | 676 | } |
660 | 677 | |
661 | 678 | imagesetpixel($dst_img, $x, $y, $color); |
662 | 679 | } |
663 | - } |
|
664 | - elseif ($info['bits'] == 24) |
|
680 | + } elseif ($info['bits'] == 24) |
|
665 | 681 | { |
666 | 682 | $x = 0; |
667 | 683 | for ($j = 0; $j < $scan_line_size; $x++) |
@@ -676,14 +692,14 @@ discard block |
||
676 | 692 | $color = imagecolorallocate($dst_img, $r, $g, $b); |
677 | 693 | |
678 | 694 | // Gah! Out of colors? Stupid GD 1... try anyhow. |
679 | - if ($color == -1) |
|
680 | - $color = imagecolorclosest($dst_img, $r, $g, $b); |
|
695 | + if ($color == -1) { |
|
696 | + $color = imagecolorclosest($dst_img, $r, $g, $b); |
|
697 | + } |
|
681 | 698 | } |
682 | 699 | |
683 | 700 | imagesetpixel($dst_img, $x, $y, $color); |
684 | 701 | } |
685 | - } |
|
686 | - elseif ($info['bits'] == 16) |
|
702 | + } elseif ($info['bits'] == 16) |
|
687 | 703 | { |
688 | 704 | $x = 0; |
689 | 705 | for ($j = 0; $j < $scan_line_size; $x++) |
@@ -704,20 +720,20 @@ discard block |
||
704 | 720 | $color = imagecolorallocate($dst_img, $r, $g, $b); |
705 | 721 | |
706 | 722 | // Gah! Out of colors? Stupid GD 1... try anyhow. |
707 | - if ($color == -1) |
|
708 | - $color = imagecolorclosest($dst_img, $r, $g, $b); |
|
723 | + if ($color == -1) { |
|
724 | + $color = imagecolorclosest($dst_img, $r, $g, $b); |
|
725 | + } |
|
709 | 726 | } |
710 | 727 | |
711 | 728 | imagesetpixel($dst_img, $x, $y, $color); |
712 | 729 | } |
713 | - } |
|
714 | - elseif ($info['bits'] == 8) |
|
730 | + } elseif ($info['bits'] == 8) |
|
715 | 731 | { |
716 | 732 | $x = 0; |
717 | - for ($j = 0; $j < $scan_line_size; $x++) |
|
718 | - imagesetpixel($dst_img, $x, $y, $palette[ord($scan_line{$j++})]); |
|
719 | - } |
|
720 | - elseif ($info['bits'] == 4) |
|
733 | + for ($j = 0; $j < $scan_line_size; $x++) { |
|
734 | + imagesetpixel($dst_img, $x, $y, $palette[ord($scan_line{$j++})]); |
|
735 | + } |
|
736 | + } elseif ($info['bits'] == 4) |
|
721 | 737 | { |
722 | 738 | $x = 0; |
723 | 739 | for ($j = 0; $j < $scan_line_size; $x++) |
@@ -725,11 +741,11 @@ discard block |
||
725 | 741 | $byte = ord($scan_line{$j++}); |
726 | 742 | |
727 | 743 | imagesetpixel($dst_img, $x, $y, $palette[(int) ($byte / 16)]); |
728 | - if (++$x < $info['width']) |
|
729 | - imagesetpixel($dst_img, $x, $y, $palette[$byte & 15]); |
|
744 | + if (++$x < $info['width']) { |
|
745 | + imagesetpixel($dst_img, $x, $y, $palette[$byte & 15]); |
|
746 | + } |
|
730 | 747 | } |
731 | - } |
|
732 | - elseif ($info['bits'] == 1) |
|
748 | + } elseif ($info['bits'] == 1) |
|
733 | 749 | { |
734 | 750 | $x = 0; |
735 | 751 | for ($j = 0; $j < $scan_line_size; $x++) |
@@ -738,7 +754,9 @@ discard block |
||
738 | 754 | |
739 | 755 | imagesetpixel($dst_img, $x, $y, $palette[(($byte) & 128) != 0]); |
740 | 756 | for ($shift = 1; $shift < 8; $shift++) { |
741 | - if (++$x < $info['width']) imagesetpixel($dst_img, $x, $y, $palette[(($byte << $shift) & 128) != 0]); |
|
757 | + if (++$x < $info['width']) { |
|
758 | + imagesetpixel($dst_img, $x, $y, $palette[(($byte << $shift) & 128) != 0]); |
|
759 | + } |
|
742 | 760 | } |
743 | 761 | } |
744 | 762 | } |
@@ -762,15 +780,18 @@ discard block |
||
762 | 780 | */ |
763 | 781 | function gif_outputAsPng($gif, $lpszFileName, $background_color = -1) |
764 | 782 | { |
765 | - if (!isset($gif) || @get_class($gif) != 'cgif' || !$gif->loaded || $lpszFileName == '') |
|
766 | - return false; |
|
783 | + if (!isset($gif) || @get_class($gif) != 'cgif' || !$gif->loaded || $lpszFileName == '') { |
|
784 | + return false; |
|
785 | + } |
|
767 | 786 | |
768 | 787 | $fd = $gif->get_png_data($background_color); |
769 | - if (strlen($fd) <= 0) |
|
770 | - return false; |
|
788 | + if (strlen($fd) <= 0) { |
|
789 | + return false; |
|
790 | + } |
|
771 | 791 | |
772 | - if (!($fh = @fopen($lpszFileName, 'wb'))) |
|
773 | - return false; |
|
792 | + if (!($fh = @fopen($lpszFileName, 'wb'))) { |
|
793 | + return false; |
|
794 | + } |
|
774 | 795 | |
775 | 796 | @fwrite($fh, $fd, strlen($fd)); |
776 | 797 | @fflush($fh); |
@@ -797,8 +818,9 @@ discard block |
||
797 | 818 | // What type are we going to be doing? |
798 | 819 | $imageType = $modSettings['visual_verification_type']; |
799 | 820 | // Special case to allow the admin center to show samples. |
800 | - if ($user_info['is_admin'] && isset($_GET['type'])) |
|
801 | - $imageType = (int) $_GET['type']; |
|
821 | + if ($user_info['is_admin'] && isset($_GET['type'])) { |
|
822 | + $imageType = (int) $_GET['type']; |
|
823 | + } |
|
802 | 824 | |
803 | 825 | // Some quick references for what we do. |
804 | 826 | // Do we show no, low or high noise? |
@@ -832,25 +854,28 @@ discard block |
||
832 | 854 | $character_spacing = 1; |
833 | 855 | |
834 | 856 | // What color is the background - generally white unless we're on "hard". |
835 | - if ($simpleBGColor) |
|
836 | - $background_color = array(255, 255, 255); |
|
837 | - else |
|
838 | - $background_color = isset($settings['verification_background']) ? $settings['verification_background'] : array(236, 237, 243); |
|
857 | + if ($simpleBGColor) { |
|
858 | + $background_color = array(255, 255, 255); |
|
859 | + } else { |
|
860 | + $background_color = isset($settings['verification_background']) ? $settings['verification_background'] : array(236, 237, 243); |
|
861 | + } |
|
839 | 862 | |
840 | 863 | // The color of the characters shown (red, green, blue). |
841 | - if ($simpleFGColor) |
|
842 | - $foreground_color = array(0, 0, 0); |
|
843 | - else |
|
864 | + if ($simpleFGColor) { |
|
865 | + $foreground_color = array(0, 0, 0); |
|
866 | + } else |
|
844 | 867 | { |
845 | 868 | $foreground_color = array(64, 101, 136); |
846 | 869 | |
847 | 870 | // Has the theme author requested a custom color? |
848 | - if (isset($settings['verification_foreground'])) |
|
849 | - $foreground_color = $settings['verification_foreground']; |
|
871 | + if (isset($settings['verification_foreground'])) { |
|
872 | + $foreground_color = $settings['verification_foreground']; |
|
873 | + } |
|
850 | 874 | } |
851 | 875 | |
852 | - if (!is_dir($settings['default_theme_dir'] . '/fonts')) |
|
853 | - return false; |
|
876 | + if (!is_dir($settings['default_theme_dir'] . '/fonts')) { |
|
877 | + return false; |
|
878 | + } |
|
854 | 879 | |
855 | 880 | // Get a list of the available fonts. |
856 | 881 | $font_dir = dir($settings['default_theme_dir'] . '/fonts'); |
@@ -861,25 +886,28 @@ discard block |
||
861 | 886 | { |
862 | 887 | if (preg_match('~^(.+)\.gdf$~', $entry, $matches) === 1) |
863 | 888 | { |
864 | - if ($endian ^ (strpos($entry, '_end.gdf') === false)) |
|
865 | - $font_list[] = $entry; |
|
889 | + if ($endian ^ (strpos($entry, '_end.gdf') === false)) { |
|
890 | + $font_list[] = $entry; |
|
891 | + } |
|
892 | + } elseif (preg_match('~^(.+)\.ttf$~', $entry, $matches) === 1) { |
|
893 | + $ttfont_list[] = $entry; |
|
866 | 894 | } |
867 | - elseif (preg_match('~^(.+)\.ttf$~', $entry, $matches) === 1) |
|
868 | - $ttfont_list[] = $entry; |
|
869 | 895 | } |
870 | 896 | |
871 | - if (empty($font_list)) |
|
872 | - return false; |
|
897 | + if (empty($font_list)) { |
|
898 | + return false; |
|
899 | + } |
|
873 | 900 | |
874 | 901 | // For non-hard things don't even change fonts. |
875 | 902 | if (!$varyFonts) |
876 | 903 | { |
877 | 904 | $font_list = array($font_list[0]); |
878 | 905 | // Try use Screenge if we can - it looks good! |
879 | - if (in_array('AnonymousPro.ttf', $ttfont_list)) |
|
880 | - $ttfont_list = array('AnonymousPro.ttf'); |
|
881 | - else |
|
882 | - $ttfont_list = empty($ttfont_list) ? array() : array($ttfont_list[0]); |
|
906 | + if (in_array('AnonymousPro.ttf', $ttfont_list)) { |
|
907 | + $ttfont_list = array('AnonymousPro.ttf'); |
|
908 | + } else { |
|
909 | + $ttfont_list = empty($ttfont_list) ? array() : array($ttfont_list[0]); |
|
910 | + } |
|
883 | 911 | |
884 | 912 | } |
885 | 913 | |
@@ -897,14 +925,16 @@ discard block |
||
897 | 925 | } |
898 | 926 | |
899 | 927 | // Load all fonts and determine the maximum font height. |
900 | - foreach ($loaded_fonts as $font_index => $dummy) |
|
901 | - $loaded_fonts[$font_index] = imageloadfont($settings['default_theme_dir'] . '/fonts/' . $font_list[$font_index]); |
|
928 | + foreach ($loaded_fonts as $font_index => $dummy) { |
|
929 | + $loaded_fonts[$font_index] = imageloadfont($settings['default_theme_dir'] . '/fonts/' . $font_list[$font_index]); |
|
930 | + } |
|
902 | 931 | |
903 | 932 | // Determine the dimensions of each character. |
904 | - if ($imageType == 4 || $imageType == 5) |
|
905 | - $extra = 80; |
|
906 | - else |
|
907 | - $extra = 45; |
|
933 | + if ($imageType == 4 || $imageType == 5) { |
|
934 | + $extra = 80; |
|
935 | + } else { |
|
936 | + $extra = 45; |
|
937 | + } |
|
908 | 938 | |
909 | 939 | $total_width = $character_spacing * strlen($code) + $extra; |
910 | 940 | $max_height = 0; |
@@ -925,13 +955,15 @@ discard block |
||
925 | 955 | imagefilledrectangle($code_image, 0, 0, $total_width - 1, $max_height - 1, $bg_color); |
926 | 956 | |
927 | 957 | // Randomize the foreground color a little. |
928 | - for ($i = 0; $i < 3; $i++) |
|
929 | - $foreground_color[$i] = mt_rand(max($foreground_color[$i] - 3, 0), min($foreground_color[$i] + 3, 255)); |
|
958 | + for ($i = 0; $i < 3; $i++) { |
|
959 | + $foreground_color[$i] = mt_rand(max($foreground_color[$i] - 3, 0), min($foreground_color[$i] + 3, 255)); |
|
960 | + } |
|
930 | 961 | $fg_color = imagecolorallocate($code_image, $foreground_color[0], $foreground_color[1], $foreground_color[2]); |
931 | 962 | |
932 | 963 | // Color for the dots. |
933 | - for ($i = 0; $i < 3; $i++) |
|
934 | - $dotbgcolor[$i] = $background_color[$i] < $foreground_color[$i] ? mt_rand(0, max($foreground_color[$i] - 20, 0)) : mt_rand(min($foreground_color[$i] + 20, 255), 255); |
|
964 | + for ($i = 0; $i < 3; $i++) { |
|
965 | + $dotbgcolor[$i] = $background_color[$i] < $foreground_color[$i] ? mt_rand(0, max($foreground_color[$i] - 20, 0)) : mt_rand(min($foreground_color[$i] + 20, 255), 255); |
|
966 | + } |
|
935 | 967 | $randomness_color = imagecolorallocate($code_image, $dotbgcolor[0], $dotbgcolor[1], $dotbgcolor[2]); |
936 | 968 | |
937 | 969 | // Some squares/rectanges for new extreme level |
@@ -957,10 +989,11 @@ discard block |
||
957 | 989 | $can_do_ttf = function_exists('imagettftext'); |
958 | 990 | |
959 | 991 | // How much rotation will we give? |
960 | - if ($rotationType == 'none') |
|
961 | - $angle = 0; |
|
962 | - else |
|
963 | - $angle = mt_rand(-100, 100) / ($rotationType == 'high' ? 6 : 10); |
|
992 | + if ($rotationType == 'none') { |
|
993 | + $angle = 0; |
|
994 | + } else { |
|
995 | + $angle = mt_rand(-100, 100) / ($rotationType == 'high' ? 6 : 10); |
|
996 | + } |
|
964 | 997 | |
965 | 998 | // What color shall we do it? |
966 | 999 | if ($fontColorType == 'cyclic') |
@@ -974,51 +1007,56 @@ discard block |
||
974 | 1007 | array(0, 0, 0), |
975 | 1008 | array(143, 39, 31), |
976 | 1009 | ); |
977 | - if (!isset($last_index)) |
|
978 | - $last_index = -1; |
|
1010 | + if (!isset($last_index)) { |
|
1011 | + $last_index = -1; |
|
1012 | + } |
|
979 | 1013 | $new_index = $last_index; |
980 | - while ($last_index == $new_index) |
|
981 | - $new_index = mt_rand(0, count($colors) - 1); |
|
1014 | + while ($last_index == $new_index) { |
|
1015 | + $new_index = mt_rand(0, count($colors) - 1); |
|
1016 | + } |
|
982 | 1017 | $char_fg_color = $colors[$new_index]; |
983 | 1018 | $last_index = $new_index; |
1019 | + } elseif ($fontColorType == 'random') { |
|
1020 | + $char_fg_color = array(mt_rand(max($foreground_color[0] - 2, 0), $foreground_color[0]), mt_rand(max($foreground_color[1] - 2, 0), $foreground_color[1]), mt_rand(max($foreground_color[2] - 2, 0), $foreground_color[2])); |
|
1021 | + } else { |
|
1022 | + $char_fg_color = array($foreground_color[0], $foreground_color[1], $foreground_color[2]); |
|
984 | 1023 | } |
985 | - elseif ($fontColorType == 'random') |
|
986 | - $char_fg_color = array(mt_rand(max($foreground_color[0] - 2, 0), $foreground_color[0]), mt_rand(max($foreground_color[1] - 2, 0), $foreground_color[1]), mt_rand(max($foreground_color[2] - 2, 0), $foreground_color[2])); |
|
987 | - else |
|
988 | - $char_fg_color = array($foreground_color[0], $foreground_color[1], $foreground_color[2]); |
|
989 | 1024 | |
990 | 1025 | if (!empty($can_do_ttf)) |
991 | 1026 | { |
992 | 1027 | // GD2 handles font size differently. |
993 | - if ($fontSizeRandom) |
|
994 | - $font_size = $gd2 ? mt_rand(17, 19) : mt_rand(18, 25); |
|
995 | - else |
|
996 | - $font_size = $gd2 ? 18 : 24; |
|
1028 | + if ($fontSizeRandom) { |
|
1029 | + $font_size = $gd2 ? mt_rand(17, 19) : mt_rand(18, 25); |
|
1030 | + } else { |
|
1031 | + $font_size = $gd2 ? 18 : 24; |
|
1032 | + } |
|
997 | 1033 | |
998 | 1034 | // Work out the sizes - also fix the character width cause TTF not quite so wide! |
999 | 1035 | $font_x = $fontHorSpace == 'minus' && $cur_x > 0 ? $cur_x - 3 : $cur_x + 5; |
1000 | 1036 | $font_y = $max_height - ($fontVerPos == 'vrandom' ? mt_rand(2, 8) : ($fontVerPos == 'random' ? mt_rand(3, 5) : 5)); |
1001 | 1037 | |
1002 | 1038 | // What font face? |
1003 | - if (!empty($ttfont_list)) |
|
1004 | - $fontface = $settings['default_theme_dir'] . '/fonts/' . $ttfont_list[mt_rand(0, count($ttfont_list) - 1)]; |
|
1039 | + if (!empty($ttfont_list)) { |
|
1040 | + $fontface = $settings['default_theme_dir'] . '/fonts/' . $ttfont_list[mt_rand(0, count($ttfont_list) - 1)]; |
|
1041 | + } |
|
1005 | 1042 | |
1006 | 1043 | // What color are we to do it in? |
1007 | 1044 | $is_reverse = $showReverseChars ? mt_rand(0, 1) : false; |
1008 | 1045 | $char_color = function_exists('imagecolorallocatealpha') && $fontTrans ? imagecolorallocatealpha($code_image, $char_fg_color[0], $char_fg_color[1], $char_fg_color[2], 50) : imagecolorallocate($code_image, $char_fg_color[0], $char_fg_color[1], $char_fg_color[2]); |
1009 | 1046 | |
1010 | 1047 | $fontcord = @imagettftext($code_image, $font_size, $angle, $font_x, $font_y, $char_color, $fontface, $character['id']); |
1011 | - if (empty($fontcord)) |
|
1012 | - $can_do_ttf = false; |
|
1013 | - elseif ($is_reverse) |
|
1048 | + if (empty($fontcord)) { |
|
1049 | + $can_do_ttf = false; |
|
1050 | + } elseif ($is_reverse) |
|
1014 | 1051 | { |
1015 | 1052 | imagefilledpolygon($code_image, $fontcord, 4, $fg_color); |
1016 | 1053 | // Put the character back! |
1017 | 1054 | imagettftext($code_image, $font_size, $angle, $font_x, $font_y, $randomness_color, $fontface, $character['id']); |
1018 | 1055 | } |
1019 | 1056 | |
1020 | - if ($can_do_ttf) |
|
1021 | - $cur_x = max($fontcord[2], $fontcord[4]) + ($angle == 0 ? 0 : 3); |
|
1057 | + if ($can_do_ttf) { |
|
1058 | + $cur_x = max($fontcord[2], $fontcord[4]) + ($angle == 0 ? 0 : 3); |
|
1059 | + } |
|
1022 | 1060 | } |
1023 | 1061 | |
1024 | 1062 | if (!$can_do_ttf) |
@@ -1037,8 +1075,9 @@ discard block |
||
1037 | 1075 | } |
1038 | 1076 | |
1039 | 1077 | // Sorry, no rotation available. |
1040 | - else |
|
1041 | - imagechar($code_image, $loaded_fonts[$character['font']], $cur_x, floor(($max_height - $character['height']) / 2), $character['id'], imagecolorallocate($code_image, $char_fg_color[0], $char_fg_color[1], $char_fg_color[2])); |
|
1078 | + else { |
|
1079 | + imagechar($code_image, $loaded_fonts[$character['font']], $cur_x, floor(($max_height - $character['height']) / 2), $character['id'], imagecolorallocate($code_image, $char_fg_color[0], $char_fg_color[1], $char_fg_color[2])); |
|
1080 | + } |
|
1042 | 1081 | $cur_x += $character['width'] + $character_spacing; |
1043 | 1082 | } |
1044 | 1083 | } |
@@ -1051,17 +1090,22 @@ discard block |
||
1051 | 1090 | } |
1052 | 1091 | |
1053 | 1092 | // Make the background color transparent on the hard image. |
1054 | - if (!$simpleBGColor) |
|
1055 | - imagecolortransparent($code_image, $bg_color); |
|
1056 | - if ($hasBorder) |
|
1057 | - imagerectangle($code_image, 0, 0, $total_width - 1, $max_height - 1, $fg_color); |
|
1093 | + if (!$simpleBGColor) { |
|
1094 | + imagecolortransparent($code_image, $bg_color); |
|
1095 | + } |
|
1096 | + if ($hasBorder) { |
|
1097 | + imagerectangle($code_image, 0, 0, $total_width - 1, $max_height - 1, $fg_color); |
|
1098 | + } |
|
1058 | 1099 | |
1059 | 1100 | // Add some noise to the background? |
1060 | 1101 | if ($noiseType != 'none') |
1061 | 1102 | { |
1062 | - for ($i = mt_rand(0, 2); $i < $max_height; $i += mt_rand(1, 2)) |
|
1063 | - for ($j = mt_rand(0, 10); $j < $total_width; $j += mt_rand(1, 10)) |
|
1064 | - imagesetpixel($code_image, $j, $i, mt_rand(0, 1) ? $fg_color : $randomness_color); |
|
1103 | + for ($i = mt_rand(0, 2); $i < $max_height; $i += mt_rand(1, 2)) { |
|
1104 | + for ($j = mt_rand(0, 10); |
|
1105 | + } |
|
1106 | + $j < $total_width; $j += mt_rand(1, 10)) { |
|
1107 | + imagesetpixel($code_image, $j, $i, mt_rand(0, 1) ? $fg_color : $randomness_color); |
|
1108 | + } |
|
1065 | 1109 | |
1066 | 1110 | // Put in some lines too? |
1067 | 1111 | if ($noiseType != 'extreme') |
@@ -1074,8 +1118,7 @@ discard block |
||
1074 | 1118 | $x1 = mt_rand(0, $total_width); |
1075 | 1119 | $x2 = mt_rand(0, $total_width); |
1076 | 1120 | $y1 = 0; $y2 = $max_height; |
1077 | - } |
|
1078 | - else |
|
1121 | + } else |
|
1079 | 1122 | { |
1080 | 1123 | $y1 = mt_rand(0, $max_height); |
1081 | 1124 | $y2 = mt_rand(0, $max_height); |
@@ -1084,8 +1127,7 @@ discard block |
||
1084 | 1127 | imagesetthickness($code_image, mt_rand(1, 2)); |
1085 | 1128 | imageline($code_image, $x1, $y1, $x2, $y2, mt_rand(0, 1) ? $fg_color : $randomness_color); |
1086 | 1129 | } |
1087 | - } |
|
1088 | - else |
|
1130 | + } else |
|
1089 | 1131 | { |
1090 | 1132 | // Put in some ellipse |
1091 | 1133 | $num_ellipse = $noiseType == 'extreme' ? mt_rand(6, 12) : mt_rand(2, 6); |
@@ -1105,8 +1147,7 @@ discard block |
||
1105 | 1147 | { |
1106 | 1148 | header('Content-type: image/gif'); |
1107 | 1149 | imagegif($code_image); |
1108 | - } |
|
1109 | - else |
|
1150 | + } else |
|
1110 | 1151 | { |
1111 | 1152 | header('Content-type: image/png'); |
1112 | 1153 | imagepng($code_image); |
@@ -1129,25 +1170,29 @@ discard block |
||
1129 | 1170 | { |
1130 | 1171 | global $settings; |
1131 | 1172 | |
1132 | - if (!is_dir($settings['default_theme_dir'] . '/fonts')) |
|
1133 | - return false; |
|
1173 | + if (!is_dir($settings['default_theme_dir'] . '/fonts')) { |
|
1174 | + return false; |
|
1175 | + } |
|
1134 | 1176 | |
1135 | 1177 | // Get a list of the available font directories. |
1136 | 1178 | $font_dir = dir($settings['default_theme_dir'] . '/fonts'); |
1137 | 1179 | $font_list = array(); |
1138 | - while ($entry = $font_dir->read()) |
|
1139 | - if ($entry[0] !== '.' && is_dir($settings['default_theme_dir'] . '/fonts/' . $entry) && file_exists($settings['default_theme_dir'] . '/fonts/' . $entry . '.gdf')) |
|
1180 | + while ($entry = $font_dir->read()) { |
|
1181 | + if ($entry[0] !== '.' && is_dir($settings['default_theme_dir'] . '/fonts/' . $entry) && file_exists($settings['default_theme_dir'] . '/fonts/' . $entry . '.gdf')) |
|
1140 | 1182 | $font_list[] = $entry; |
1183 | + } |
|
1141 | 1184 | |
1142 | - if (empty($font_list)) |
|
1143 | - return false; |
|
1185 | + if (empty($font_list)) { |
|
1186 | + return false; |
|
1187 | + } |
|
1144 | 1188 | |
1145 | 1189 | // Pick a random font. |
1146 | 1190 | $random_font = $font_list[array_rand($font_list)]; |
1147 | 1191 | |
1148 | 1192 | // Check if the given letter exists. |
1149 | - if (!file_exists($settings['default_theme_dir'] . '/fonts/' . $random_font . '/' . $letter . '.png')) |
|
1150 | - return false; |
|
1193 | + if (!file_exists($settings['default_theme_dir'] . '/fonts/' . $random_font . '/' . $letter . '.png')) { |
|
1194 | + return false; |
|
1195 | + } |
|
1151 | 1196 | |
1152 | 1197 | // Include it! |
1153 | 1198 | header('Content-type: image/png'); |