@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | 'Shitiz "Dragooon" Garg', |
590 | 590 | 'Karl "RegularExpression" Benson', |
591 | 591 | 'Matthew "Labradoodle-360" Kerle', |
592 | - $user_info['is_admin'] ? 'Matt "Grudge" Wolf': 'Grudge', |
|
592 | + $user_info['is_admin'] ? 'Matt "Grudge" Wolf' : 'Grudge', |
|
593 | 593 | 'Michael "Thantos" Miller', |
594 | 594 | 'Norv', |
595 | 595 | 'Peter "Arantor" Spicer', |
@@ -813,13 +813,13 @@ discard block |
||
813 | 813 | $credit_info = smf_json_decode($row['credits'], true); |
814 | 814 | |
815 | 815 | $copyright = empty($credit_info['copyright']) ? '' : $txt['credits_copyright'] . ' © ' . $smcFunc['htmlspecialchars']($credit_info['copyright']); |
816 | - $license = empty($credit_info['license']) ? '' : $txt['credits_license'] . ': ' . (!empty($credit_info['licenseurl']) ? '<a href="'. $smcFunc['htmlspecialchars']($credit_info['licenseurl']) .'">'. $smcFunc['htmlspecialchars']($credit_info['license']) .'</a>' : $smcFunc['htmlspecialchars']($credit_info['license'])); |
|
816 | + $license = empty($credit_info['license']) ? '' : $txt['credits_license'] . ': ' . (!empty($credit_info['licenseurl']) ? '<a href="' . $smcFunc['htmlspecialchars']($credit_info['licenseurl']) . '">' . $smcFunc['htmlspecialchars']($credit_info['license']) . '</a>' : $smcFunc['htmlspecialchars']($credit_info['license'])); |
|
817 | 817 | $version = $txt['credits_version'] . ' ' . $row['version']; |
818 | 818 | $title = (empty($credit_info['title']) ? $row['name'] : $smcFunc['htmlspecialchars']($credit_info['title'])) . ': ' . $version; |
819 | 819 | |
820 | 820 | // build this one out and stash it away |
821 | 821 | $mod_name = empty($credit_info['url']) ? $title : '<a href="' . $credit_info['url'] . '">' . $title . '</a>'; |
822 | - $mods[] = $mod_name . (!empty($license) ? ' | ' . $license : '') . (!empty($copyright) ? ' | ' . $copyright : ''); |
|
822 | + $mods[] = $mod_name . (!empty($license) ? ' | ' . $license : '') . (!empty($copyright) ? ' | ' . $copyright : ''); |
|
823 | 823 | } |
824 | 824 | cache_put_data('mods_credits', $mods, 86400); |
825 | 825 | } |
@@ -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 | * Who's online, and what are they doing? |
@@ -35,8 +36,9 @@ discard block |
||
35 | 36 | isAllowedTo('who_view'); |
36 | 37 | |
37 | 38 | // You can't do anything if this is off. |
38 | - if (empty($modSettings['who_enabled'])) |
|
39 | - fatal_lang_error('who_off', false); |
|
39 | + if (empty($modSettings['who_enabled'])) { |
|
40 | + fatal_lang_error('who_off', false); |
|
41 | + } |
|
40 | 42 | |
41 | 43 | // Load the 'Who' template. |
42 | 44 | loadTemplate('Who'); |
@@ -71,9 +73,9 @@ discard block |
||
71 | 73 | $show_methods['spiders'] = '(lo.id_member = 0 AND lo.id_spider > 0)'; |
72 | 74 | $show_methods['guests'] = '(lo.id_member = 0 AND lo.id_spider = 0)'; |
73 | 75 | $context['show_methods']['spiders'] = $txt['who_show_spiders_only']; |
76 | + } elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') { |
|
77 | + unset($_SESSION['who_online_filter']); |
|
74 | 78 | } |
75 | - elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') |
|
76 | - unset($_SESSION['who_online_filter']); |
|
77 | 79 | |
78 | 80 | // Does the user prefer a different sort direction? |
79 | 81 | if (isset($_REQUEST['sort']) && isset($sort_methods[$_REQUEST['sort']])) |
@@ -97,20 +99,24 @@ discard block |
||
97 | 99 | $context['sort_direction'] = isset($_REQUEST['asc']) || (isset($_REQUEST['sort_dir']) && $_REQUEST['sort_dir'] == 'asc') ? 'up' : 'down'; |
98 | 100 | |
99 | 101 | $conditions = array(); |
100 | - if (!allowedTo('moderate_forum')) |
|
101 | - $conditions[] = '(COALESCE(mem.show_online, 1) = 1)'; |
|
102 | + if (!allowedTo('moderate_forum')) { |
|
103 | + $conditions[] = '(COALESCE(mem.show_online, 1) = 1)'; |
|
104 | + } |
|
102 | 105 | |
103 | 106 | // Fallback to top filter? |
104 | - if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) |
|
105 | - $_REQUEST['show'] = $_REQUEST['show_top']; |
|
107 | + if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) { |
|
108 | + $_REQUEST['show'] = $_REQUEST['show_top']; |
|
109 | + } |
|
106 | 110 | // Does the user wish to apply a filter? |
107 | - if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) |
|
108 | - $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show']; |
|
111 | + if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) { |
|
112 | + $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show']; |
|
113 | + } |
|
109 | 114 | // Perhaps we saved a filter earlier in the session? |
110 | - elseif (isset($_SESSION['who_online_filter'])) |
|
111 | - $context['show_by'] = $_SESSION['who_online_filter']; |
|
112 | - else |
|
113 | - $context['show_by'] = 'members'; |
|
115 | + elseif (isset($_SESSION['who_online_filter'])) { |
|
116 | + $context['show_by'] = $_SESSION['who_online_filter']; |
|
117 | + } else { |
|
118 | + $context['show_by'] = 'members'; |
|
119 | + } |
|
114 | 120 | |
115 | 121 | $conditions[] = $show_methods[$context['show_by']]; |
116 | 122 | |
@@ -156,8 +162,9 @@ discard block |
||
156 | 162 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
157 | 163 | { |
158 | 164 | $actions = smf_json_decode($row['url'], true); |
159 | - if ($actions === false) |
|
160 | - continue; |
|
165 | + if ($actions === false) { |
|
166 | + continue; |
|
167 | + } |
|
161 | 168 | |
162 | 169 | // Send the information to the template. |
163 | 170 | $context['members'][$row['session']] = array( |
@@ -195,8 +202,8 @@ discard block |
||
195 | 202 | $spiderContext = array(); |
196 | 203 | if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) |
197 | 204 | { |
198 | - foreach (smf_json_decode($modSettings['spider_name_cache'], true) as $id => $name) |
|
199 | - $spiderContext[$id] = array( |
|
205 | + foreach (smf_json_decode($modSettings['spider_name_cache'], true) as $id => $name) { |
|
206 | + $spiderContext[$id] = array( |
|
200 | 207 | 'id' => 0, |
201 | 208 | 'name' => $name, |
202 | 209 | 'group' => $txt['spiders'], |
@@ -205,6 +212,7 @@ discard block |
||
205 | 212 | 'email' => $name, |
206 | 213 | 'is_guest' => true |
207 | 214 | ); |
215 | + } |
|
208 | 216 | } |
209 | 217 | |
210 | 218 | $url_data = determineActions($url_data); |
@@ -219,16 +227,18 @@ discard block |
||
219 | 227 | // Put it in the context variables. |
220 | 228 | foreach ($context['members'] as $i => $member) |
221 | 229 | { |
222 | - if ($member['id'] != 0) |
|
223 | - $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0; |
|
230 | + if ($member['id'] != 0) { |
|
231 | + $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0; |
|
232 | + } |
|
224 | 233 | |
225 | 234 | // Keep the IP that came from the database. |
226 | 235 | $memberContext[$member['id']]['ip'] = $member['ip']; |
227 | 236 | $context['members'][$i]['action'] = isset($url_data[$i]) ? $url_data[$i] : $txt['who_hidden']; |
228 | - if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) |
|
229 | - $context['members'][$i] += $spiderContext[$member['id_spider']]; |
|
230 | - else |
|
231 | - $context['members'][$i] += $memberContext[$member['id']]; |
|
237 | + if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) { |
|
238 | + $context['members'][$i] += $spiderContext[$member['id_spider']]; |
|
239 | + } else { |
|
240 | + $context['members'][$i] += $memberContext[$member['id']]; |
|
241 | + } |
|
232 | 242 | } |
233 | 243 | |
234 | 244 | // Some people can't send personal messages... |
@@ -263,8 +273,9 @@ discard block |
||
263 | 273 | { |
264 | 274 | global $txt, $user_info, $modSettings, $smcFunc; |
265 | 275 | |
266 | - if (!allowedTo('who_view')) |
|
267 | - return array(); |
|
276 | + if (!allowedTo('who_view')) { |
|
277 | + return array(); |
|
278 | + } |
|
268 | 279 | loadLanguage('Who'); |
269 | 280 | |
270 | 281 | // Actions that require a specific permission level. |
@@ -292,10 +303,11 @@ discard block |
||
292 | 303 | ); |
293 | 304 | call_integration_hook('who_allowed', array(&$allowedActions)); |
294 | 305 | |
295 | - if (!is_array($urls)) |
|
296 | - $url_list = array(array($urls, $user_info['id'])); |
|
297 | - else |
|
298 | - $url_list = $urls; |
|
306 | + if (!is_array($urls)) { |
|
307 | + $url_list = array(array($urls, $user_info['id'])); |
|
308 | + } else { |
|
309 | + $url_list = $urls; |
|
310 | + } |
|
299 | 311 | |
300 | 312 | // These are done to later query these in large chunks. (instead of one by one.) |
301 | 313 | $topic_ids = array(); |
@@ -307,12 +319,14 @@ discard block |
||
307 | 319 | { |
308 | 320 | // Get the request parameters.. |
309 | 321 | $actions = smf_json_decode($url[0], true); |
310 | - if ($actions === false) |
|
311 | - continue; |
|
322 | + if ($actions === false) { |
|
323 | + continue; |
|
324 | + } |
|
312 | 325 | |
313 | 326 | // If it's the admin or moderation center, and there is an area set, use that instead. |
314 | - if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area'])) |
|
315 | - $actions['action'] = $actions['area']; |
|
327 | + if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area'])) { |
|
328 | + $actions['action'] = $actions['area']; |
|
329 | + } |
|
316 | 330 | |
317 | 331 | // Check if there was no action or the action is display. |
318 | 332 | if (!isset($actions['action']) || $actions['action'] == 'display') |
@@ -332,12 +346,14 @@ discard block |
||
332 | 346 | $board_ids[$actions['board']][$k] = $txt['who_board']; |
333 | 347 | } |
334 | 348 | // It's the board index!! It must be! |
335 | - else |
|
336 | - $data[$k] = $txt['who_index']; |
|
349 | + else { |
|
350 | + $data[$k] = $txt['who_index']; |
|
351 | + } |
|
337 | 352 | } |
338 | 353 | // Probably an error or some goon? |
339 | - elseif ($actions['action'] == '') |
|
340 | - $data[$k] = $txt['who_index']; |
|
354 | + elseif ($actions['action'] == '') { |
|
355 | + $data[$k] = $txt['who_index']; |
|
356 | + } |
|
341 | 357 | // Some other normal action...? |
342 | 358 | else |
343 | 359 | { |
@@ -345,23 +361,25 @@ discard block |
||
345 | 361 | if ($actions['action'] == 'profile') |
346 | 362 | { |
347 | 363 | // Whose? Their own? |
348 | - if (empty($actions['u'])) |
|
349 | - $actions['u'] = $url[1]; |
|
364 | + if (empty($actions['u'])) { |
|
365 | + $actions['u'] = $url[1]; |
|
366 | + } |
|
350 | 367 | |
351 | 368 | $data[$k] = $txt['who_hidden']; |
352 | 369 | $profile_ids[(int) $actions['u']][$k] = $actions['u'] == $url[1] ? $txt['who_viewownprofile'] : $txt['who_viewprofile']; |
353 | - } |
|
354 | - elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board'])) |
|
370 | + } elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board'])) |
|
355 | 371 | { |
356 | 372 | $data[$k] = $txt['who_hidden']; |
357 | 373 | $board_ids[(int) $actions['board']][$k] = isset($actions['poll']) ? $txt['who_poll'] : $txt['who_post']; |
358 | 374 | } |
359 | 375 | // A subaction anyone can view... if the language string is there, show it. |
360 | - elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']])) |
|
361 | - $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']]; |
|
376 | + elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']])) { |
|
377 | + $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']]; |
|
378 | + } |
|
362 | 379 | // An action any old fellow can look at. (if ['whoall_' . $action] exists, we know everyone can see it.) |
363 | - elseif (isset($txt['whoall_' . $actions['action']])) |
|
364 | - $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']]; |
|
380 | + elseif (isset($txt['whoall_' . $actions['action']])) { |
|
381 | + $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']]; |
|
382 | + } |
|
365 | 383 | // Viewable if and only if they can see the board... |
366 | 384 | elseif (isset($txt['whotopic_' . $actions['action']])) |
367 | 385 | { |
@@ -370,8 +388,7 @@ discard block |
||
370 | 388 | |
371 | 389 | $data[$k] = $txt['who_hidden']; |
372 | 390 | $topic_ids[$topic][$k] = $txt['whotopic_' . $actions['action']]; |
373 | - } |
|
374 | - elseif (isset($txt['whopost_' . $actions['action']])) |
|
391 | + } elseif (isset($txt['whopost_' . $actions['action']])) |
|
375 | 392 | { |
376 | 393 | // Find out what message they are accessing. |
377 | 394 | $msgid = (int) (isset($actions['msg']) ? $actions['msg'] : (isset($actions['quote']) ? $actions['quote'] : 0)); |
@@ -394,41 +411,46 @@ discard block |
||
394 | 411 | $data[$k] = sprintf($txt['whopost_' . $actions['action']], $id_topic, $subject); |
395 | 412 | $smcFunc['db_free_result']($result); |
396 | 413 | |
397 | - if (empty($id_topic)) |
|
398 | - $data[$k] = $txt['who_hidden']; |
|
414 | + if (empty($id_topic)) { |
|
415 | + $data[$k] = $txt['who_hidden']; |
|
416 | + } |
|
399 | 417 | } |
400 | 418 | // Viewable only by administrators.. (if it starts with whoadmin, it's admin only!) |
401 | - elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']])) |
|
402 | - $data[$k] = $txt['whoadmin_' . $actions['action']]; |
|
419 | + elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']])) { |
|
420 | + $data[$k] = $txt['whoadmin_' . $actions['action']]; |
|
421 | + } |
|
403 | 422 | // Viewable by permission level. |
404 | 423 | elseif (isset($allowedActions[$actions['action']])) |
405 | 424 | { |
406 | - if (allowedTo($allowedActions[$actions['action']])) |
|
407 | - $data[$k] = $txt['whoallow_' . $actions['action']]; |
|
408 | - elseif (in_array('moderate_forum', $allowedActions[$actions['action']])) |
|
409 | - $data[$k] = $txt['who_moderate']; |
|
410 | - elseif (in_array('admin_forum', $allowedActions[$actions['action']])) |
|
411 | - $data[$k] = $txt['who_admin']; |
|
412 | - else |
|
413 | - $data[$k] = $txt['who_hidden']; |
|
425 | + if (allowedTo($allowedActions[$actions['action']])) { |
|
426 | + $data[$k] = $txt['whoallow_' . $actions['action']]; |
|
427 | + } elseif (in_array('moderate_forum', $allowedActions[$actions['action']])) { |
|
428 | + $data[$k] = $txt['who_moderate']; |
|
429 | + } elseif (in_array('admin_forum', $allowedActions[$actions['action']])) { |
|
430 | + $data[$k] = $txt['who_admin']; |
|
431 | + } else { |
|
432 | + $data[$k] = $txt['who_hidden']; |
|
433 | + } |
|
434 | + } elseif (!empty($actions['action'])) { |
|
435 | + $data[$k] = $txt['who_generic'] . ' ' . $actions['action']; |
|
436 | + } else { |
|
437 | + $data[$k] = $txt['who_unknown']; |
|
414 | 438 | } |
415 | - elseif (!empty($actions['action'])) |
|
416 | - $data[$k] = $txt['who_generic'] . ' ' . $actions['action']; |
|
417 | - else |
|
418 | - $data[$k] = $txt['who_unknown']; |
|
419 | 439 | } |
420 | 440 | |
421 | 441 | if (isset($actions['error'])) |
422 | 442 | { |
423 | - if (isset($txt[$actions['error']])) |
|
424 | - $error_message = str_replace('"', '"', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params'])); |
|
425 | - elseif ($actions['error'] == 'guest_login') |
|
426 | - $error_message = str_replace('"', '"', $txt['who_guest_login']); |
|
427 | - else |
|
428 | - $error_message = str_replace('"', '"', $actions['error']); |
|
429 | - |
|
430 | - if (!empty($error_message)) |
|
431 | - $data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>'; |
|
443 | + if (isset($txt[$actions['error']])) { |
|
444 | + $error_message = str_replace('"', '"', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params'])); |
|
445 | + } elseif ($actions['error'] == 'guest_login') { |
|
446 | + $error_message = str_replace('"', '"', $txt['who_guest_login']); |
|
447 | + } else { |
|
448 | + $error_message = str_replace('"', '"', $actions['error']); |
|
449 | + } |
|
450 | + |
|
451 | + if (!empty($error_message)) { |
|
452 | + $data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>'; |
|
453 | + } |
|
432 | 454 | } |
433 | 455 | |
434 | 456 | // Maybe the action is integrated into another system? |
@@ -439,12 +461,15 @@ discard block |
||
439 | 461 | if (!empty($integrate_action)) |
440 | 462 | { |
441 | 463 | $data[$k] = $integrate_action; |
442 | - if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k])) |
|
443 | - $topic_ids[(int) $actions['topic']][$k] = $integrate_action; |
|
444 | - if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k])) |
|
445 | - $board_ids[(int) $actions['board']][$k] = $integrate_action; |
|
446 | - if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k])) |
|
447 | - $profile_ids[(int) $actions['u']][$k] = $integrate_action; |
|
464 | + if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k])) { |
|
465 | + $topic_ids[(int) $actions['topic']][$k] = $integrate_action; |
|
466 | + } |
|
467 | + if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k])) { |
|
468 | + $board_ids[(int) $actions['board']][$k] = $integrate_action; |
|
469 | + } |
|
470 | + if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k])) { |
|
471 | + $profile_ids[(int) $actions['u']][$k] = $integrate_action; |
|
472 | + } |
|
448 | 473 | break; |
449 | 474 | } |
450 | 475 | } |
@@ -472,8 +497,9 @@ discard block |
||
472 | 497 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
473 | 498 | { |
474 | 499 | // Show the topic's subject for each of the actions. |
475 | - foreach ($topic_ids[$row['id_topic']] as $k => $session_text) |
|
476 | - $data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject'])); |
|
500 | + foreach ($topic_ids[$row['id_topic']] as $k => $session_text) { |
|
501 | + $data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject'])); |
|
502 | + } |
|
477 | 503 | } |
478 | 504 | $smcFunc['db_free_result']($result); |
479 | 505 | } |
@@ -495,8 +521,9 @@ discard block |
||
495 | 521 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
496 | 522 | { |
497 | 523 | // Put the board name into the string for each member... |
498 | - foreach ($board_ids[$row['id_board']] as $k => $session_text) |
|
499 | - $data[$k] = sprintf($session_text, $row['id_board'], $row['name']); |
|
524 | + foreach ($board_ids[$row['id_board']] as $k => $session_text) { |
|
525 | + $data[$k] = sprintf($session_text, $row['id_board'], $row['name']); |
|
526 | + } |
|
500 | 527 | } |
501 | 528 | $smcFunc['db_free_result']($result); |
502 | 529 | } |
@@ -518,23 +545,26 @@ discard block |
||
518 | 545 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
519 | 546 | { |
520 | 547 | // If they aren't allowed to view this person's profile, skip it. |
521 | - if (!$allow_view_any && ($user_info['id'] != $row['id_member'])) |
|
522 | - continue; |
|
548 | + if (!$allow_view_any && ($user_info['id'] != $row['id_member'])) { |
|
549 | + continue; |
|
550 | + } |
|
523 | 551 | |
524 | 552 | // Set their action on each - session/text to sprintf. |
525 | - foreach ($profile_ids[$row['id_member']] as $k => $session_text) |
|
526 | - $data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']); |
|
553 | + foreach ($profile_ids[$row['id_member']] as $k => $session_text) { |
|
554 | + $data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']); |
|
555 | + } |
|
527 | 556 | } |
528 | 557 | $smcFunc['db_free_result']($result); |
529 | 558 | } |
530 | 559 | |
531 | 560 | call_integration_hook('whos_online_after', array(&$urls, &$data)); |
532 | 561 | |
533 | - if (!is_array($urls)) |
|
534 | - return isset($data[0]) ? $data[0] : false; |
|
535 | - else |
|
536 | - return $data; |
|
537 | -} |
|
562 | + if (!is_array($urls)) { |
|
563 | + return isset($data[0]) ? $data[0] : false; |
|
564 | + } else { |
|
565 | + return $data; |
|
566 | + } |
|
567 | + } |
|
538 | 568 | |
539 | 569 | /** |
540 | 570 | * It prepares credit and copyright information for the credits page or the admin page |
@@ -709,8 +739,8 @@ discard block |
||
709 | 739 | ); |
710 | 740 | |
711 | 741 | // Give the translators some credit for their hard work. |
712 | - if (!empty($txt['translation_credits'])) |
|
713 | - $context['credits'][] = array( |
|
742 | + if (!empty($txt['translation_credits'])) { |
|
743 | + $context['credits'][] = array( |
|
714 | 744 | 'title' => $txt['credits_groups_translation'], |
715 | 745 | 'groups' => array( |
716 | 746 | array( |
@@ -719,6 +749,7 @@ discard block |
||
719 | 749 | ), |
720 | 750 | ), |
721 | 751 | ); |
752 | + } |
|
722 | 753 | |
723 | 754 | $context['credits'][] = array( |
724 | 755 | 'title' => $txt['credits_special'], |
@@ -443,7 +443,7 @@ |
||
443 | 443 | { |
444 | 444 | static $ver; |
445 | 445 | |
446 | - if(!empty($ver)) |
|
446 | + if (!empty($ver)) |
|
447 | 447 | return $ver; |
448 | 448 | |
449 | 449 | global $smcFunc; |
@@ -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 functions implemented in this file to the $smcFunc array. |
@@ -23,8 +24,8 @@ discard block |
||
23 | 24 | { |
24 | 25 | global $smcFunc; |
25 | 26 | |
26 | - if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') |
|
27 | - $smcFunc += array( |
|
27 | + if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') { |
|
28 | + $smcFunc += array( |
|
28 | 29 | 'db_backup_table' => 'smf_db_backup_table', |
29 | 30 | 'db_optimize_table' => 'smf_db_optimize_table', |
30 | 31 | 'db_insert_sql' => 'smf_db_insert_sql', |
@@ -33,7 +34,8 @@ discard block |
||
33 | 34 | 'db_get_version' => 'smf_db_get_version', |
34 | 35 | 'db_get_engine' => 'smf_db_get_engine', |
35 | 36 | ); |
36 | -} |
|
37 | + } |
|
38 | + } |
|
37 | 39 | |
38 | 40 | /** |
39 | 41 | * Backup $table to $backup_table. |
@@ -75,8 +77,9 @@ discard block |
||
75 | 77 | )); |
76 | 78 | |
77 | 79 | // Old school or no school? |
78 | - if ($request) |
|
79 | - return $request; |
|
80 | + if ($request) { |
|
81 | + return $request; |
|
82 | + } |
|
80 | 83 | } |
81 | 84 | |
82 | 85 | // At this point, the quick method failed. |
@@ -100,8 +103,9 @@ discard block |
||
100 | 103 | foreach ($create as $k => $l) |
101 | 104 | { |
102 | 105 | // Get the name of the auto_increment column. |
103 | - if (strpos($l, 'auto_increment')) |
|
104 | - $auto_inc = trim($l); |
|
106 | + if (strpos($l, 'auto_increment')) { |
|
107 | + $auto_inc = trim($l); |
|
108 | + } |
|
105 | 109 | |
106 | 110 | // For the engine type, see if we can work out what it is. |
107 | 111 | if (strpos($l, 'ENGINE') !== false || strpos($l, 'TYPE') !== false) |
@@ -109,30 +113,36 @@ discard block |
||
109 | 113 | // Extract the engine type. |
110 | 114 | preg_match('~(ENGINE|TYPE)=(\w+)(\sDEFAULT)?(\sCHARSET=(\w+))?(\sCOLLATE=(\w+))?~', $l, $match); |
111 | 115 | |
112 | - if (!empty($match[1])) |
|
113 | - $engine = $match[1]; |
|
116 | + if (!empty($match[1])) { |
|
117 | + $engine = $match[1]; |
|
118 | + } |
|
114 | 119 | |
115 | - if (!empty($match[2])) |
|
116 | - $engine = $match[2]; |
|
120 | + if (!empty($match[2])) { |
|
121 | + $engine = $match[2]; |
|
122 | + } |
|
117 | 123 | |
118 | - if (!empty($match[5])) |
|
119 | - $charset = $match[5]; |
|
124 | + if (!empty($match[5])) { |
|
125 | + $charset = $match[5]; |
|
126 | + } |
|
120 | 127 | |
121 | - if (!empty($match[7])) |
|
122 | - $collate = $match[7]; |
|
128 | + if (!empty($match[7])) { |
|
129 | + $collate = $match[7]; |
|
130 | + } |
|
123 | 131 | } |
124 | 132 | |
125 | 133 | // Skip everything but keys... |
126 | - if (strpos($l, 'KEY') === false) |
|
127 | - unset($create[$k]); |
|
134 | + if (strpos($l, 'KEY') === false) { |
|
135 | + unset($create[$k]); |
|
136 | + } |
|
128 | 137 | } |
129 | 138 | |
130 | - if (!empty($create)) |
|
131 | - $create = '( |
|
139 | + if (!empty($create)) { |
|
140 | + $create = '( |
|
132 | 141 | ' . implode(' |
133 | 142 | ', $create) . ')'; |
134 | - else |
|
135 | - $create = ''; |
|
143 | + } else { |
|
144 | + $create = ''; |
|
145 | + } |
|
136 | 146 | |
137 | 147 | $request = $smcFunc['db_query']('', ' |
138 | 148 | CREATE TABLE {raw:backup_table} {raw:create} |
@@ -151,8 +161,9 @@ discard block |
||
151 | 161 | |
152 | 162 | if ($auto_inc != '') |
153 | 163 | { |
154 | - if (preg_match('~\`(.+?)\`\s~', $auto_inc, $match) != 0 && substr($auto_inc, -1, 1) == ',') |
|
155 | - $auto_inc = substr($auto_inc, 0, -1); |
|
164 | + if (preg_match('~\`(.+?)\`\s~', $auto_inc, $match) != 0 && substr($auto_inc, -1, 1) == ',') { |
|
165 | + $auto_inc = substr($auto_inc, 0, -1); |
|
166 | + } |
|
156 | 167 | |
157 | 168 | $smcFunc['db_query']('', ' |
158 | 169 | ALTER TABLE {raw:backup_table} |
@@ -196,8 +207,9 @@ discard block |
||
196 | 207 | 'table' => $table, |
197 | 208 | ) |
198 | 209 | ); |
199 | - if (!$request) |
|
200 | - return -1; |
|
210 | + if (!$request) { |
|
211 | + return -1; |
|
212 | + } |
|
201 | 213 | |
202 | 214 | // How much left? |
203 | 215 | $request = $smcFunc['db_query']('', ' |
@@ -240,8 +252,9 @@ discard block |
||
240 | 252 | ) |
241 | 253 | ); |
242 | 254 | $tables = array(); |
243 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
244 | - $tables[] = $row[0]; |
|
255 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
256 | + $tables[] = $row[0]; |
|
257 | + } |
|
245 | 258 | $smcFunc['db_free_result']($request); |
246 | 259 | |
247 | 260 | return $tables; |
@@ -284,8 +297,9 @@ discard block |
||
284 | 297 | // The number of rows, just for record keeping and breaking INSERTs up. |
285 | 298 | $num_rows = $smcFunc['db_num_rows']($result); |
286 | 299 | |
287 | - if ($num_rows == 0) |
|
288 | - return ''; |
|
300 | + if ($num_rows == 0) { |
|
301 | + return ''; |
|
302 | + } |
|
289 | 303 | |
290 | 304 | if ($new_table) |
291 | 305 | { |
@@ -305,12 +319,13 @@ discard block |
||
305 | 319 | foreach ($row as $item) |
306 | 320 | { |
307 | 321 | // Try to figure out the type of each field. (NULL, number, or 'string'.) |
308 | - if (!isset($item)) |
|
309 | - $field_list[] = 'NULL'; |
|
310 | - elseif (is_numeric($item) && (int) $item == $item) |
|
311 | - $field_list[] = $item; |
|
312 | - else |
|
313 | - $field_list[] = '\'' . $smcFunc['db_escape_string']($item) . '\''; |
|
322 | + if (!isset($item)) { |
|
323 | + $field_list[] = 'NULL'; |
|
324 | + } elseif (is_numeric($item) && (int) $item == $item) { |
|
325 | + $field_list[] = $item; |
|
326 | + } else { |
|
327 | + $field_list[] = '\'' . $smcFunc['db_escape_string']($item) . '\''; |
|
328 | + } |
|
314 | 329 | } |
315 | 330 | |
316 | 331 | $data .= '(' . implode(', ', $field_list) . ')' . ',' . $crlf . "\t"; |
@@ -362,8 +377,9 @@ discard block |
||
362 | 377 | if (!empty($row['Default']) || $row['Null'] !== 'YES') |
363 | 378 | { |
364 | 379 | // Make a special case of auto-timestamp. |
365 | - if ($row['Default'] == 'CURRENT_TIMESTAMP') |
|
366 | - $schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */'; |
|
380 | + if ($row['Default'] == 'CURRENT_TIMESTAMP') { |
|
381 | + $schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */'; |
|
382 | + } |
|
367 | 383 | // Text shouldn't have a default. |
368 | 384 | elseif ($row['Default'] !== null) |
369 | 385 | { |
@@ -398,14 +414,16 @@ discard block |
||
398 | 414 | $row['Key_name'] = $row['Key_name'] == 'PRIMARY' ? 'PRIMARY KEY' : (empty($row['Non_unique']) ? 'UNIQUE ' : ($row['Comment'] == 'FULLTEXT' || (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT') ? 'FULLTEXT ' : 'KEY ')) . '`' . $row['Key_name'] . '`'; |
399 | 415 | |
400 | 416 | // Is this the first column in the index? |
401 | - if (empty($indexes[$row['Key_name']])) |
|
402 | - $indexes[$row['Key_name']] = array(); |
|
417 | + if (empty($indexes[$row['Key_name']])) { |
|
418 | + $indexes[$row['Key_name']] = array(); |
|
419 | + } |
|
403 | 420 | |
404 | 421 | // A sub part, like only indexing 15 characters of a varchar. |
405 | - if (!empty($row['Sub_part'])) |
|
406 | - $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')'; |
|
407 | - else |
|
408 | - $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`'; |
|
422 | + if (!empty($row['Sub_part'])) { |
|
423 | + $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')'; |
|
424 | + } else { |
|
425 | + $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`'; |
|
426 | + } |
|
409 | 427 | } |
410 | 428 | $smcFunc['db_free_result']($result); |
411 | 429 | |
@@ -443,8 +461,9 @@ discard block |
||
443 | 461 | { |
444 | 462 | static $ver; |
445 | 463 | |
446 | - if(!empty($ver)) |
|
447 | - return $ver; |
|
464 | + if(!empty($ver)) { |
|
465 | + return $ver; |
|
466 | + } |
|
448 | 467 | |
449 | 468 | global $smcFunc; |
450 | 469 | |
@@ -469,8 +488,9 @@ discard block |
||
469 | 488 | global $smcFunc; |
470 | 489 | static $db_type; |
471 | 490 | |
472 | - if (!empty($db_type)) |
|
473 | - return $db_type; |
|
491 | + if (!empty($db_type)) { |
|
492 | + return $db_type; |
|
493 | + } |
|
474 | 494 | |
475 | 495 | $request = $smcFunc['db_query']('', 'SELECT @@version_comment'); |
476 | 496 | list ($comment) = $smcFunc['db_fetch_row']($request); |
@@ -479,13 +499,15 @@ discard block |
||
479 | 499 | // Skip these if we don't have a comment. |
480 | 500 | if (!empty($comment)) |
481 | 501 | { |
482 | - if (stripos($comment, 'percona') !== false) |
|
483 | - return 'Percona'; |
|
484 | - if (stripos($comment, 'mariadb') !== false) |
|
485 | - return 'MariaDB'; |
|
502 | + if (stripos($comment, 'percona') !== false) { |
|
503 | + return 'Percona'; |
|
504 | + } |
|
505 | + if (stripos($comment, 'mariadb') !== false) { |
|
506 | + return 'MariaDB'; |
|
507 | + } |
|
508 | + } else { |
|
509 | + return 'fail'; |
|
486 | 510 | } |
487 | - else |
|
488 | - return 'fail'; |
|
489 | 511 | |
490 | 512 | return 'MySQL'; |
491 | 513 | } |
@@ -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 | * Format a topic to be printer friendly. |
@@ -32,8 +33,9 @@ discard block |
||
32 | 33 | global $board_info, $smcFunc, $modSettings; |
33 | 34 | |
34 | 35 | // Redirect to the boardindex if no valid topic id is provided. |
35 | - if (empty($topic)) |
|
36 | - redirectexit(); |
|
36 | + if (empty($topic)) { |
|
37 | + redirectexit(); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | if (!empty($modSettings['disable_print_topic'])) |
39 | 41 | { |
@@ -59,8 +61,9 @@ discard block |
||
59 | 61 | ) |
60 | 62 | ); |
61 | 63 | // Redirect to the boardindex if no valid topic id is provided. |
62 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
63 | - redirectexit(); |
|
64 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
65 | + redirectexit(); |
|
66 | + } |
|
64 | 67 | $row = $smcFunc['db_fetch_assoc']($request); |
65 | 68 | $smcFunc['db_free_result']($request); |
66 | 69 | |
@@ -134,20 +137,21 @@ discard block |
||
134 | 137 | foreach ($guestinfo as $i => $guestvoted) |
135 | 138 | { |
136 | 139 | $guestvoted = explode(',', $guestvoted); |
137 | - if ($guestvoted[0] == $row['id_poll']) |
|
138 | - break; |
|
140 | + if ($guestvoted[0] == $row['id_poll']) { |
|
141 | + break; |
|
142 | + } |
|
139 | 143 | } |
140 | 144 | // Has the poll been reset since guest voted? |
141 | 145 | if ($pollinfo['reset_poll'] > $guestvoted[1]) |
142 | 146 | { |
143 | 147 | // Remove the poll info from the cookie to allow guest to vote again |
144 | 148 | unset($guestinfo[$i]); |
145 | - if (!empty($guestinfo)) |
|
146 | - $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
147 | - else |
|
148 | - unset($_COOKIE['guest_poll_vote']); |
|
149 | - } |
|
150 | - else |
|
149 | + if (!empty($guestinfo)) { |
|
150 | + $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
151 | + } else { |
|
152 | + unset($_COOKIE['guest_poll_vote']); |
|
153 | + } |
|
154 | + } else |
|
151 | 155 | { |
152 | 156 | // What did they vote for? |
153 | 157 | unset($guestvoted[0], $guestvoted[1]); |
@@ -233,8 +237,9 @@ discard block |
||
233 | 237 | $context['poster_name'] = $row['poster_name']; |
234 | 238 | $context['post_time'] = timeformat($row['poster_time'], false); |
235 | 239 | $context['parent_boards'] = array(); |
236 | - foreach ($board_info['parent_boards'] as $parent) |
|
237 | - $context['parent_boards'][] = $parent['name']; |
|
240 | + foreach ($board_info['parent_boards'] as $parent) { |
|
241 | + $context['parent_boards'][] = $parent['name']; |
|
242 | + } |
|
238 | 243 | |
239 | 244 | // Split the topics up so we can print them. |
240 | 245 | $request = $smcFunc['db_query']('', ' |
@@ -266,8 +271,9 @@ discard block |
||
266 | 271 | 'id_msg' => $row['id_msg'], |
267 | 272 | ); |
268 | 273 | |
269 | - if (!isset($context['topic_subject'])) |
|
270 | - $context['topic_subject'] = $row['subject']; |
|
274 | + if (!isset($context['topic_subject'])) { |
|
275 | + $context['topic_subject'] = $row['subject']; |
|
276 | + } |
|
271 | 277 | } |
272 | 278 | $smcFunc['db_free_result']($request); |
273 | 279 | |
@@ -275,8 +281,9 @@ discard block |
||
275 | 281 | if (isset($_REQUEST['images']) && !empty($modSettings['attachmentEnable']) && allowedTo('view_attachments')) |
276 | 282 | { |
277 | 283 | $messages = array(); |
278 | - foreach ($context['posts'] as $temp) |
|
279 | - $messages[] = $temp['id_msg']; |
|
284 | + foreach ($context['posts'] as $temp) { |
|
285 | + $messages[] = $temp['id_msg']; |
|
286 | + } |
|
280 | 287 | |
281 | 288 | // build the request |
282 | 289 | $request = $smcFunc['db_query']('', ' |
@@ -295,8 +302,9 @@ discard block |
||
295 | 302 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
296 | 303 | { |
297 | 304 | $temp[$row['id_attach']] = $row; |
298 | - if (!isset($context['printattach'][$row['id_msg']])) |
|
299 | - $context['printattach'][$row['id_msg']] = array(); |
|
305 | + if (!isset($context['printattach'][$row['id_msg']])) { |
|
306 | + $context['printattach'][$row['id_msg']] = array(); |
|
307 | + } |
|
300 | 308 | } |
301 | 309 | $smcFunc['db_free_result']($request); |
302 | 310 | ksort($temp); |
@@ -313,8 +321,7 @@ discard block |
||
313 | 321 | $row['height'] = floor($row['height'] * ($modSettings['max_image_width'] / $row['width'])); |
314 | 322 | $row['width'] = $modSettings['max_image_width']; |
315 | 323 | } |
316 | - } |
|
317 | - elseif (!empty($modSettings['max_image_width'])) |
|
324 | + } elseif (!empty($modSettings['max_image_width'])) |
|
318 | 325 | { |
319 | 326 | if ($row['height'] > $modSettings['max_image_height']) |
320 | 327 | { |
@@ -12,8 +12,9 @@ discard block |
||
12 | 12 | * @version 2.1 Beta 3 |
13 | 13 | */ |
14 | 14 | |
15 | -if (!defined('SMF')) |
|
15 | +if (!defined('SMF')) { |
|
16 | 16 | die('No direct access...'); |
17 | +} |
|
17 | 18 | |
18 | 19 | /** |
19 | 20 | * This is the controlling delegator |
@@ -38,13 +39,15 @@ discard block |
||
38 | 39 | ); |
39 | 40 | |
40 | 41 | // Any subaction? If none, fall through to the main template, which will ask for one. |
41 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
42 | - call_helper($subActions[$_REQUEST['sa']]); |
|
42 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
43 | + call_helper($subActions[$_REQUEST['sa']]); |
|
44 | + } |
|
43 | 45 | |
44 | 46 | // Creating a one time token. |
45 | - else |
|
46 | - createToken('remind'); |
|
47 | -} |
|
47 | + else { |
|
48 | + createToken('remind'); |
|
49 | + } |
|
50 | + } |
|
48 | 51 | |
49 | 52 | /** |
50 | 53 | * Allows the user to pick how they wish to be reminded |
@@ -62,8 +65,7 @@ discard block |
||
62 | 65 | { |
63 | 66 | $where = 'id_member = {int:id_member}'; |
64 | 67 | $where_params['id_member'] = (int) $_REQUEST['uid']; |
65 | - } |
|
66 | - elseif (isset($_POST['user']) && $_POST['user'] != '') |
|
68 | + } elseif (isset($_POST['user']) && $_POST['user'] != '') |
|
67 | 69 | { |
68 | 70 | $where = 'member_name = {string:member_name}'; |
69 | 71 | $where_params['member_name'] = $_POST['user']; |
@@ -71,8 +73,9 @@ discard block |
||
71 | 73 | } |
72 | 74 | |
73 | 75 | // You must enter a username/email address. |
74 | - if (empty($where)) |
|
75 | - fatal_lang_error('username_no_exist', false); |
|
76 | + if (empty($where)) { |
|
77 | + fatal_lang_error('username_no_exist', false); |
|
78 | + } |
|
76 | 79 | |
77 | 80 | // Make sure we are not being slammed |
78 | 81 | // Don't call this if you're coming from the "Choose a reminder type" page - otherwise you'll likely get an error |
@@ -101,8 +104,9 @@ discard block |
||
101 | 104 | LIMIT 1', |
102 | 105 | $where_params |
103 | 106 | ); |
104 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
105 | - fatal_lang_error('no_user_with_email', false); |
|
107 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
108 | + fatal_lang_error('no_user_with_email', false); |
|
109 | + } |
|
106 | 110 | } |
107 | 111 | |
108 | 112 | $row = $smcFunc['db_fetch_assoc']($request); |
@@ -112,16 +116,18 @@ discard block |
||
112 | 116 | if ($row['is_activated'] != 1) |
113 | 117 | { |
114 | 118 | // Awaiting approval... |
115 | - if (trim($row['validation_code']) == '') |
|
116 | - fatal_error(sprintf($txt['registration_not_approved'], $scripturl . '?action=activate;user=' . $_POST['user']), false); |
|
117 | - else |
|
118 | - fatal_error(sprintf($txt['registration_not_activated'], $scripturl . '?action=activate;user=' . $_POST['user']), false); |
|
119 | + if (trim($row['validation_code']) == '') { |
|
120 | + fatal_error(sprintf($txt['registration_not_approved'], $scripturl . '?action=activate;user=' . $_POST['user']), false); |
|
121 | + } else { |
|
122 | + fatal_error(sprintf($txt['registration_not_activated'], $scripturl . '?action=activate;user=' . $_POST['user']), false); |
|
123 | + } |
|
119 | 124 | } |
120 | 125 | |
121 | 126 | // You can't get emailed if you have no email address. |
122 | 127 | $row['email_address'] = trim($row['email_address']); |
123 | - if ($row['email_address'] == '') |
|
124 | - fatal_error($txt['no_reminder_email'] . '<br>' . $txt['send_email'] . ' <a href="mailto:' . $webmaster_email . '">webmaster</a> ' . $txt['to_ask_password'] . '.'); |
|
128 | + if ($row['email_address'] == '') { |
|
129 | + fatal_error($txt['no_reminder_email'] . '<br>' . $txt['send_email'] . ' <a href="mailto:' . $webmaster_email . '">webmaster</a> ' . $txt['to_ask_password'] . '.'); |
|
130 | + } |
|
125 | 131 | |
126 | 132 | // If they have no secret question then they can only get emailed the item, or they are requesting the email, send them an email. |
127 | 133 | if (empty($row['secret_question']) || (isset($_POST['reminder_type']) && $_POST['reminder_type'] == 'email')) |
@@ -176,8 +182,9 @@ discard block |
||
176 | 182 | loadLanguage('Login'); |
177 | 183 | |
178 | 184 | // You need a code! |
179 | - if (!isset($_REQUEST['code'])) |
|
180 | - fatal_lang_error('no_access', false); |
|
185 | + if (!isset($_REQUEST['code'])) { |
|
186 | + fatal_lang_error('no_access', false); |
|
187 | + } |
|
181 | 188 | |
182 | 189 | // Fill the context array. |
183 | 190 | $context += array( |
@@ -203,16 +210,19 @@ discard block |
||
203 | 210 | checkSession(); |
204 | 211 | validateToken('remind-sp'); |
205 | 212 | |
206 | - if (empty($_POST['u']) || !isset($_POST['passwrd1']) || !isset($_POST['passwrd2'])) |
|
207 | - fatal_lang_error('no_access', false); |
|
213 | + if (empty($_POST['u']) || !isset($_POST['passwrd1']) || !isset($_POST['passwrd2'])) { |
|
214 | + fatal_lang_error('no_access', false); |
|
215 | + } |
|
208 | 216 | |
209 | 217 | $_POST['u'] = (int) $_POST['u']; |
210 | 218 | |
211 | - if ($_POST['passwrd1'] != $_POST['passwrd2']) |
|
212 | - fatal_lang_error('passwords_dont_match', false); |
|
219 | + if ($_POST['passwrd1'] != $_POST['passwrd2']) { |
|
220 | + fatal_lang_error('passwords_dont_match', false); |
|
221 | + } |
|
213 | 222 | |
214 | - if ($_POST['passwrd1'] == '') |
|
215 | - fatal_lang_error('no_password', false); |
|
223 | + if ($_POST['passwrd1'] == '') { |
|
224 | + fatal_lang_error('no_password', false); |
|
225 | + } |
|
216 | 226 | |
217 | 227 | loadLanguage('Login'); |
218 | 228 | |
@@ -232,8 +242,9 @@ discard block |
||
232 | 242 | ); |
233 | 243 | |
234 | 244 | // Does this user exist at all? |
235 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
236 | - fatal_lang_error('invalid_userid', false); |
|
245 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
246 | + fatal_lang_error('invalid_userid', false); |
|
247 | + } |
|
237 | 248 | |
238 | 249 | list ($realCode, $username, $email, $flood_value) = $smcFunc['db_fetch_row']($request); |
239 | 250 | $smcFunc['db_free_result']($request); |
@@ -243,8 +254,9 @@ discard block |
||
243 | 254 | $passwordError = validatePassword($_POST['passwrd1'], $username, array($email)); |
244 | 255 | |
245 | 256 | // What - it's not? |
246 | - if ($passwordError != null) |
|
247 | - fatal_lang_error('profile_error_password_' . $passwordError, false); |
|
257 | + if ($passwordError != null) { |
|
258 | + fatal_lang_error('profile_error_password_' . $passwordError, false); |
|
259 | + } |
|
248 | 260 | |
249 | 261 | require_once($sourcedir . '/LogInOut.php'); |
250 | 262 | |
@@ -291,8 +303,9 @@ discard block |
||
291 | 303 | loadLanguage('Login'); |
292 | 304 | |
293 | 305 | // Check they entered something... |
294 | - if (empty($_REQUEST['uid'])) |
|
295 | - fatal_lang_error('username_no_exist', false); |
|
306 | + if (empty($_REQUEST['uid'])) { |
|
307 | + fatal_lang_error('username_no_exist', false); |
|
308 | + } |
|
296 | 309 | |
297 | 310 | // Get the stuff.... |
298 | 311 | $request = $smcFunc['db_query']('', ' |
@@ -304,15 +317,17 @@ discard block |
||
304 | 317 | 'id_member' => (int) $_REQUEST['uid'], |
305 | 318 | ) |
306 | 319 | ); |
307 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
308 | - fatal_lang_error('username_no_exist', false); |
|
320 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
321 | + fatal_lang_error('username_no_exist', false); |
|
322 | + } |
|
309 | 323 | |
310 | 324 | $row = $smcFunc['db_fetch_assoc']($request); |
311 | 325 | $smcFunc['db_free_result']($request); |
312 | 326 | |
313 | 327 | // If there is NO secret question - then throw an error. |
314 | - if (trim($row['secret_question']) == '') |
|
315 | - fatal_lang_error('registration_no_secret_question', false); |
|
328 | + if (trim($row['secret_question']) == '') { |
|
329 | + fatal_lang_error('registration_no_secret_question', false); |
|
330 | + } |
|
316 | 331 | |
317 | 332 | // Ask for the answer... |
318 | 333 | $context['remind_user'] = $row['id_member']; |
@@ -335,8 +350,9 @@ discard block |
||
335 | 350 | validateToken('remind-sai'); |
336 | 351 | |
337 | 352 | // Hacker? How did you get this far without an email or username? |
338 | - if (empty($_REQUEST['uid'])) |
|
339 | - fatal_lang_error('username_no_exist', false); |
|
353 | + if (empty($_REQUEST['uid'])) { |
|
354 | + fatal_lang_error('username_no_exist', false); |
|
355 | + } |
|
340 | 356 | |
341 | 357 | loadLanguage('Login'); |
342 | 358 | |
@@ -350,8 +366,9 @@ discard block |
||
350 | 366 | 'id_member' => $_REQUEST['uid'], |
351 | 367 | ) |
352 | 368 | ); |
353 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
354 | - fatal_lang_error('username_no_exist', false); |
|
369 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
370 | + fatal_lang_error('username_no_exist', false); |
|
371 | + } |
|
355 | 372 | |
356 | 373 | $row = $smcFunc['db_fetch_assoc']($request); |
357 | 374 | $smcFunc['db_free_result']($request); |
@@ -364,20 +381,23 @@ discard block |
||
364 | 381 | } |
365 | 382 | |
366 | 383 | // You can't use a blank one! |
367 | - if (strlen(trim($_POST['passwrd1'])) === 0) |
|
368 | - fatal_lang_error('no_password', false); |
|
384 | + if (strlen(trim($_POST['passwrd1'])) === 0) { |
|
385 | + fatal_lang_error('no_password', false); |
|
386 | + } |
|
369 | 387 | |
370 | 388 | // They have to be the same too. |
371 | - if ($_POST['passwrd1'] != $_POST['passwrd2']) |
|
372 | - fatal_lang_error('passwords_dont_match', false); |
|
389 | + if ($_POST['passwrd1'] != $_POST['passwrd2']) { |
|
390 | + fatal_lang_error('passwords_dont_match', false); |
|
391 | + } |
|
373 | 392 | |
374 | 393 | // Make sure they have a strong enough password. |
375 | 394 | require_once($sourcedir . '/Subs-Auth.php'); |
376 | 395 | $passwordError = validatePassword($_POST['passwrd1'], $row['member_name'], array($row['email_address'])); |
377 | 396 | |
378 | 397 | // Invalid? |
379 | - if ($passwordError != null) |
|
380 | - fatal_lang_error('profile_error_password_' . $passwordError, false); |
|
398 | + if ($passwordError != null) { |
|
399 | + fatal_lang_error('profile_error_password_' . $passwordError, false); |
|
400 | + } |
|
381 | 401 | |
382 | 402 | // Alright, so long as 'yer sure. |
383 | 403 | updateMemberData($row['id_member'], array('passwd' => hash_password($row['member_name'], $_POST['passwrd1']))); |
@@ -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 | * Edit the position and properties of a category. |
@@ -42,8 +43,9 @@ discard block |
||
42 | 43 | $cat_order = array(); |
43 | 44 | |
44 | 45 | // Setting 'move_after' to '0' moves the category to the top. |
45 | - if ($catOptions['move_after'] == 0) |
|
46 | - $cats[] = $category_id; |
|
46 | + if ($catOptions['move_after'] == 0) { |
|
47 | + $cats[] = $category_id; |
|
48 | + } |
|
47 | 49 | |
48 | 50 | // Grab the categories sorted by cat_order. |
49 | 51 | $request = $smcFunc['db_query']('', ' |
@@ -55,17 +57,19 @@ discard block |
||
55 | 57 | ); |
56 | 58 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
57 | 59 | { |
58 | - if ($row['id_cat'] != $category_id) |
|
59 | - $cats[] = $row['id_cat']; |
|
60 | - if ($row['id_cat'] == $catOptions['move_after']) |
|
61 | - $cats[] = $category_id; |
|
60 | + if ($row['id_cat'] != $category_id) { |
|
61 | + $cats[] = $row['id_cat']; |
|
62 | + } |
|
63 | + if ($row['id_cat'] == $catOptions['move_after']) { |
|
64 | + $cats[] = $category_id; |
|
65 | + } |
|
62 | 66 | $cat_order[$row['id_cat']] = $row['cat_order']; |
63 | 67 | } |
64 | 68 | $smcFunc['db_free_result']($request); |
65 | 69 | |
66 | 70 | // Set the new order for the categories. |
67 | - foreach ($cats as $index => $cat) |
|
68 | - if ($index != $cat_order[$cat]) |
|
71 | + foreach ($cats as $index => $cat) { |
|
72 | + if ($index != $cat_order[$cat]) |
|
69 | 73 | $smcFunc['db_query']('', ' |
70 | 74 | UPDATE {db_prefix}categories |
71 | 75 | SET cat_order = {int:new_order} |
@@ -75,6 +79,7 @@ discard block |
||
75 | 79 | 'current_category' => $cat, |
76 | 80 | ) |
77 | 81 | ); |
82 | + } |
|
78 | 83 | |
79 | 84 | // If the category order changed, so did the board order. |
80 | 85 | require_once($sourcedir . '/Subs-Boards.php'); |
@@ -117,8 +122,9 @@ discard block |
||
117 | 122 | )) |
118 | 123 | ); |
119 | 124 | |
120 | - if (empty($catOptions['dont_log'])) |
|
121 | - logAction('edit_cat', array('catname' => isset($catOptions['cat_name']) ? $catOptions['cat_name'] : $category_id), 'admin'); |
|
125 | + if (empty($catOptions['dont_log'])) { |
|
126 | + logAction('edit_cat', array('catname' => isset($catOptions['cat_name']) ? $catOptions['cat_name'] : $category_id), 'admin'); |
|
127 | + } |
|
122 | 128 | } |
123 | 129 | } |
124 | 130 | |
@@ -135,16 +141,20 @@ discard block |
||
135 | 141 | global $smcFunc; |
136 | 142 | |
137 | 143 | // Check required values. |
138 | - if (!isset($catOptions['cat_name']) || trim($catOptions['cat_name']) == '') |
|
139 | - trigger_error('createCategory(): A category name is required', E_USER_ERROR); |
|
144 | + if (!isset($catOptions['cat_name']) || trim($catOptions['cat_name']) == '') { |
|
145 | + trigger_error('createCategory(): A category name is required', E_USER_ERROR); |
|
146 | + } |
|
140 | 147 | |
141 | 148 | // Set default values. |
142 | - if (!isset($catOptions['cat_desc'])) |
|
143 | - $catOptions['cat_desc'] = ''; |
|
144 | - if (!isset($catOptions['move_after'])) |
|
145 | - $catOptions['move_after'] = 0; |
|
146 | - if (!isset($catOptions['is_collapsible'])) |
|
147 | - $catOptions['is_collapsible'] = true; |
|
149 | + if (!isset($catOptions['cat_desc'])) { |
|
150 | + $catOptions['cat_desc'] = ''; |
|
151 | + } |
|
152 | + if (!isset($catOptions['move_after'])) { |
|
153 | + $catOptions['move_after'] = 0; |
|
154 | + } |
|
155 | + if (!isset($catOptions['is_collapsible'])) { |
|
156 | + $catOptions['is_collapsible'] = true; |
|
157 | + } |
|
148 | 158 | // Don't log an edit right after. |
149 | 159 | $catOptions['dont_log'] = true; |
150 | 160 | |
@@ -212,21 +222,24 @@ discard block |
||
212 | 222 | ) |
213 | 223 | ); |
214 | 224 | $boards_inside = array(); |
215 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
216 | - $boards_inside[] = $row['id_board']; |
|
225 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
226 | + $boards_inside[] = $row['id_board']; |
|
227 | + } |
|
217 | 228 | $smcFunc['db_free_result']($request); |
218 | 229 | |
219 | - if (!empty($boards_inside)) |
|
220 | - deleteBoards($boards_inside, null); |
|
230 | + if (!empty($boards_inside)) { |
|
231 | + deleteBoards($boards_inside, null); |
|
232 | + } |
|
221 | 233 | } |
222 | 234 | |
223 | 235 | // Make sure the safe category is really safe. |
224 | - elseif (in_array($moveBoardsTo, $categories)) |
|
225 | - trigger_error('deleteCategories(): You cannot move the boards to a category that\'s being deleted', E_USER_ERROR); |
|
236 | + elseif (in_array($moveBoardsTo, $categories)) { |
|
237 | + trigger_error('deleteCategories(): You cannot move the boards to a category that\'s being deleted', E_USER_ERROR); |
|
238 | + } |
|
226 | 239 | |
227 | 240 | // Move the boards inside the categories to a safe category. |
228 | - else |
|
229 | - $smcFunc['db_query']('', ' |
|
241 | + else { |
|
242 | + $smcFunc['db_query']('', ' |
|
230 | 243 | UPDATE {db_prefix}boards |
231 | 244 | SET id_cat = {int:new_parent_cat} |
232 | 245 | WHERE id_cat IN ({array_int:category_list})', |
@@ -235,6 +248,7 @@ discard block |
||
235 | 248 | 'new_parent_cat' => $moveBoardsTo, |
236 | 249 | ) |
237 | 250 | ); |
251 | + } |
|
238 | 252 | |
239 | 253 | // Do the deletion of the category itself |
240 | 254 | $smcFunc['db_query']('', ' |
@@ -246,8 +260,9 @@ discard block |
||
246 | 260 | ); |
247 | 261 | |
248 | 262 | // Log what we've done. |
249 | - foreach ($categories as $category) |
|
250 | - logAction('delete_cat', array('catname' => $cat_tree[$category]['node']['name']), 'admin'); |
|
263 | + foreach ($categories as $category) { |
|
264 | + logAction('delete_cat', array('catname' => $cat_tree[$category]['node']['name']), 'admin'); |
|
265 | + } |
|
251 | 266 | |
252 | 267 | // Get all boards back into the right order. |
253 | 268 | reorderBoards(); |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | |
248 | 248 | saveSettings($config_vars); |
249 | 249 | $_SESSION['adm-save'] = true; |
250 | - redirectexit('action=admin;area=serversettings;sa=database;' . $context['session_var'] . '=' . $context['session_id'] ); |
|
250 | + redirectexit('action=admin;area=serversettings;sa=database;' . $context['session_var'] . '=' . $context['session_id']); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | // Fill the config array. |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | array('localCookies', $txt['localCookies'], 'db', 'check', false, 'localCookies'), |
273 | 273 | array('globalCookies', $txt['globalCookies'], 'db', 'check', false, 'globalCookies'), |
274 | 274 | array('globalCookiesDomain', $txt['globalCookiesDomain'], 'db', 'text', false, 'globalCookiesDomain'), |
275 | - array('secureCookies', $txt['secureCookies'], 'db', 'check', false, 'secureCookies', 'disabled' => !isset($_SERVER['HTTPS']) || !(strtolower($_SERVER['HTTPS']) == 'on' || strtolower($_SERVER['HTTPS']) == '1')), |
|
275 | + array('secureCookies', $txt['secureCookies'], 'db', 'check', false, 'secureCookies', 'disabled' => !isset($_SERVER['HTTPS']) || !(strtolower($_SERVER['HTTPS']) == 'on' || strtolower($_SERVER['HTTPS']) == '1')), |
|
276 | 276 | array('httponlyCookies', $txt['httponlyCookies'], 'db', 'check', false, 'httponlyCookies'), |
277 | 277 | '', |
278 | 278 | // Sessions |
@@ -59,8 +59,9 @@ discard block |
||
59 | 59 | * @version 2.1 Beta 3 |
60 | 60 | */ |
61 | 61 | |
62 | -if (!defined('SMF')) |
|
62 | +if (!defined('SMF')) { |
|
63 | 63 | die('No direct access...'); |
64 | +} |
|
64 | 65 | |
65 | 66 | /** |
66 | 67 | * This is the main dispatcher. Sets up all the available sub-actions, all the tabs and selects |
@@ -111,10 +112,11 @@ discard block |
||
111 | 112 | $settings_not_writable = !is_writable($boarddir . '/Settings.php'); |
112 | 113 | $settings_backup_fail = !@is_writable($boarddir . '/Settings_bak.php') || !@copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php'); |
113 | 114 | |
114 | - if ($settings_not_writable) |
|
115 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
116 | - elseif ($settings_backup_fail) |
|
117 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
115 | + if ($settings_not_writable) { |
|
116 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
117 | + } elseif ($settings_backup_fail) { |
|
118 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
119 | + } |
|
118 | 120 | |
119 | 121 | $context['settings_not_writable'] = $settings_not_writable; |
120 | 122 | |
@@ -166,8 +168,9 @@ discard block |
||
166 | 168 | |
167 | 169 | call_integration_hook('integrate_general_settings', array(&$config_vars)); |
168 | 170 | |
169 | - if ($return_config) |
|
170 | - return $config_vars; |
|
171 | + if ($return_config) { |
|
172 | + return $config_vars; |
|
173 | + } |
|
171 | 174 | |
172 | 175 | // Setup the template stuff. |
173 | 176 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=general;save'; |
@@ -232,8 +235,9 @@ discard block |
||
232 | 235 | |
233 | 236 | call_integration_hook('integrate_database_settings', array(&$config_vars)); |
234 | 237 | |
235 | - if ($return_config) |
|
236 | - return $config_vars; |
|
238 | + if ($return_config) { |
|
239 | + return $config_vars; |
|
240 | + } |
|
237 | 241 | |
238 | 242 | // Setup the template stuff. |
239 | 243 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=database;save'; |
@@ -308,13 +312,15 @@ discard block |
||
308 | 312 | hideGlobalCookies(); |
309 | 313 | });', true); |
310 | 314 | |
311 | - if (empty($user_settings['tfa_secret'])) |
|
312 | - addInlineJavaScript(''); |
|
315 | + if (empty($user_settings['tfa_secret'])) { |
|
316 | + addInlineJavaScript(''); |
|
317 | + } |
|
313 | 318 | |
314 | 319 | call_integration_hook('integrate_cookie_settings', array(&$config_vars)); |
315 | 320 | |
316 | - if ($return_config) |
|
317 | - return $config_vars; |
|
321 | + if ($return_config) { |
|
322 | + return $config_vars; |
|
323 | + } |
|
318 | 324 | |
319 | 325 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=cookie;save'; |
320 | 326 | $context['settings_title'] = $txt['cookies_sessions_settings']; |
@@ -325,11 +331,13 @@ discard block |
||
325 | 331 | call_integration_hook('integrate_save_cookie_settings'); |
326 | 332 | |
327 | 333 | // Local and global do not play nicely together. |
328 | - if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) |
|
329 | - unset ($_POST['globalCookies']); |
|
334 | + if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) { |
|
335 | + unset ($_POST['globalCookies']); |
|
336 | + } |
|
330 | 337 | |
331 | - if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) |
|
332 | - fatal_lang_error('invalid_cookie_domain', false); |
|
338 | + if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) { |
|
339 | + fatal_lang_error('invalid_cookie_domain', false); |
|
340 | + } |
|
333 | 341 | |
334 | 342 | saveSettings($config_vars); |
335 | 343 | |
@@ -412,8 +420,9 @@ discard block |
||
412 | 420 | |
413 | 421 | call_integration_hook('integrate_general_security_settings', array(&$config_vars)); |
414 | 422 | |
415 | - if ($return_config) |
|
416 | - return $config_vars; |
|
423 | + if ($return_config) { |
|
424 | + return $config_vars; |
|
425 | + } |
|
417 | 426 | |
418 | 427 | // Saving? |
419 | 428 | if (isset($_GET['save'])) |
@@ -445,18 +454,24 @@ discard block |
||
445 | 454 | |
446 | 455 | // Detect all available optimizers |
447 | 456 | $detected = array(); |
448 | - if (function_exists('apc_store')) |
|
449 | - $detected['apc'] = $txt['apc_cache']; |
|
450 | - if (function_exists('apcu_store')) |
|
451 | - $detected['apcu'] = $txt['apcu_cache']; |
|
452 | - if (function_exists('output_cache_put') || function_exists('zend_shm_cache_store')) |
|
453 | - $detected['zend'] = $txt['zend_cache']; |
|
454 | - if (function_exists('memcache_set') || function_exists('memcached_set')) |
|
455 | - $detected['memcached'] = $txt['memcached_cache']; |
|
456 | - if (function_exists('xcache_set')) |
|
457 | - $detected['xcache'] = $txt['xcache_cache']; |
|
458 | - if (function_exists('file_put_contents')) |
|
459 | - $detected['smf'] = $txt['default_cache']; |
|
457 | + if (function_exists('apc_store')) { |
|
458 | + $detected['apc'] = $txt['apc_cache']; |
|
459 | + } |
|
460 | + if (function_exists('apcu_store')) { |
|
461 | + $detected['apcu'] = $txt['apcu_cache']; |
|
462 | + } |
|
463 | + if (function_exists('output_cache_put') || function_exists('zend_shm_cache_store')) { |
|
464 | + $detected['zend'] = $txt['zend_cache']; |
|
465 | + } |
|
466 | + if (function_exists('memcache_set') || function_exists('memcached_set')) { |
|
467 | + $detected['memcached'] = $txt['memcached_cache']; |
|
468 | + } |
|
469 | + if (function_exists('xcache_set')) { |
|
470 | + $detected['xcache'] = $txt['xcache_cache']; |
|
471 | + } |
|
472 | + if (function_exists('file_put_contents')) { |
|
473 | + $detected['smf'] = $txt['default_cache']; |
|
474 | + } |
|
460 | 475 | |
461 | 476 | // set our values to show what, if anything, we found |
462 | 477 | if (empty($detected)) |
@@ -464,8 +479,7 @@ discard block |
||
464 | 479 | $txt['cache_settings_message'] = $txt['detected_no_caching']; |
465 | 480 | $cache_level = array($txt['cache_off']); |
466 | 481 | $detected['none'] = $txt['cache_off']; |
467 | - } |
|
468 | - else |
|
482 | + } else |
|
469 | 483 | { |
470 | 484 | $txt['cache_settings_message'] = sprintf($txt['detected_accelerators'], implode(', ', $detected)); |
471 | 485 | $cache_level = array($txt['cache_off'], $txt['cache_level1'], $txt['cache_level2'], $txt['cache_level3']); |
@@ -490,8 +504,9 @@ discard block |
||
490 | 504 | |
491 | 505 | call_integration_hook('integrate_modify_cache_settings', array(&$config_vars)); |
492 | 506 | |
493 | - if ($return_config) |
|
494 | - return $config_vars; |
|
507 | + if ($return_config) { |
|
508 | + return $config_vars; |
|
509 | + } |
|
495 | 510 | |
496 | 511 | // Saving again? |
497 | 512 | if (isset($_GET['save'])) |
@@ -519,8 +534,9 @@ discard block |
||
519 | 534 | $context['save_disabled'] = $context['settings_not_writable']; |
520 | 535 | |
521 | 536 | // Decide what message to show. |
522 | - if (!$context['save_disabled']) |
|
523 | - $context['settings_message'] = $txt['caching_information']; |
|
537 | + if (!$context['save_disabled']) { |
|
538 | + $context['settings_message'] = $txt['caching_information']; |
|
539 | + } |
|
524 | 540 | |
525 | 541 | // Prepare the template. |
526 | 542 | prepareServerSettingsContext($config_vars); |
@@ -543,24 +559,25 @@ discard block |
||
543 | 559 | if (stripos(PHP_OS, 'win') === 0) |
544 | 560 | { |
545 | 561 | $context['settings_message'] = $txt['loadavg_disabled_windows']; |
546 | - if (isset($_GET['save'])) |
|
547 | - $_SESSION['adm-save'] = $txt['loadavg_disabled_windows']; |
|
548 | - } |
|
549 | - elseif (stripos(PHP_OS, 'darwin') === 0) |
|
562 | + if (isset($_GET['save'])) { |
|
563 | + $_SESSION['adm-save'] = $txt['loadavg_disabled_windows']; |
|
564 | + } |
|
565 | + } elseif (stripos(PHP_OS, 'darwin') === 0) |
|
550 | 566 | { |
551 | 567 | $context['settings_message'] = $txt['loadavg_disabled_osx']; |
552 | - if (isset($_GET['save'])) |
|
553 | - $_SESSION['adm-save'] = $txt['loadavg_disabled_osx']; |
|
554 | - } |
|
555 | - else |
|
568 | + if (isset($_GET['save'])) { |
|
569 | + $_SESSION['adm-save'] = $txt['loadavg_disabled_osx']; |
|
570 | + } |
|
571 | + } else |
|
556 | 572 | { |
557 | 573 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
558 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0) |
|
559 | - $modSettings['load_average'] = (float) $matches[1]; |
|
560 | - elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0) |
|
561 | - $modSettings['load_average'] = (float) $matches[1]; |
|
562 | - else |
|
563 | - unset($modSettings['load_average']); |
|
574 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0) { |
|
575 | + $modSettings['load_average'] = (float) $matches[1]; |
|
576 | + } elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0) { |
|
577 | + $modSettings['load_average'] = (float) $matches[1]; |
|
578 | + } else { |
|
579 | + unset($modSettings['load_average']); |
|
580 | + } |
|
564 | 581 | |
565 | 582 | if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
566 | 583 | { |
@@ -596,8 +613,9 @@ discard block |
||
596 | 613 | |
597 | 614 | call_integration_hook('integrate_loadavg_settings', array(&$config_vars)); |
598 | 615 | |
599 | - if ($return_config) |
|
600 | - return $config_vars; |
|
616 | + if ($return_config) { |
|
617 | + return $config_vars; |
|
618 | + } |
|
601 | 619 | |
602 | 620 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=loads;save'; |
603 | 621 | $context['settings_title'] = $txt['load_balancing_settings']; |
@@ -608,24 +626,27 @@ discard block |
||
608 | 626 | // Stupidity is not allowed. |
609 | 627 | foreach ($_POST as $key => $value) |
610 | 628 | { |
611 | - if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values))) |
|
612 | - continue; |
|
613 | - else |
|
614 | - $_POST[$key] = (float) $value; |
|
615 | - |
|
616 | - if ($key == 'loadavg_auto_opt' && $value <= 1) |
|
617 | - $_POST['loadavg_auto_opt'] = 1.0; |
|
618 | - elseif ($key == 'loadavg_forum' && $value < 10) |
|
619 | - $_POST['loadavg_forum'] = 10.0; |
|
620 | - elseif ($value < 2) |
|
621 | - $_POST[$key] = 2.0; |
|
629 | + if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values))) { |
|
630 | + continue; |
|
631 | + } else { |
|
632 | + $_POST[$key] = (float) $value; |
|
633 | + } |
|
634 | + |
|
635 | + if ($key == 'loadavg_auto_opt' && $value <= 1) { |
|
636 | + $_POST['loadavg_auto_opt'] = 1.0; |
|
637 | + } elseif ($key == 'loadavg_forum' && $value < 10) { |
|
638 | + $_POST['loadavg_forum'] = 10.0; |
|
639 | + } elseif ($value < 2) { |
|
640 | + $_POST[$key] = 2.0; |
|
641 | + } |
|
622 | 642 | } |
623 | 643 | |
624 | 644 | call_integration_hook('integrate_save_loadavg_settings'); |
625 | 645 | |
626 | 646 | saveDBSettings($config_vars); |
627 | - if (!isset($_SESSION['adm-save'])) |
|
628 | - $_SESSION['adm-save'] = true; |
|
647 | + if (!isset($_SESSION['adm-save'])) { |
|
648 | + $_SESSION['adm-save'] = true; |
|
649 | + } |
|
629 | 650 | redirectexit('action=admin;area=serversettings;sa=loads;' . $context['session_var'] . '=' . $context['session_id']); |
630 | 651 | } |
631 | 652 | |
@@ -662,10 +683,11 @@ discard block |
||
662 | 683 | |
663 | 684 | if (isset($_SESSION['adm-save'])) |
664 | 685 | { |
665 | - if ($_SESSION['adm-save'] === true) |
|
666 | - $context['saved_successful'] = true; |
|
667 | - else |
|
668 | - $context['saved_failed'] = $_SESSION['adm-save']; |
|
686 | + if ($_SESSION['adm-save'] === true) { |
|
687 | + $context['saved_successful'] = true; |
|
688 | + } else { |
|
689 | + $context['saved_failed'] = $_SESSION['adm-save']; |
|
690 | + } |
|
669 | 691 | |
670 | 692 | unset($_SESSION['adm-save']); |
671 | 693 | } |
@@ -673,9 +695,9 @@ discard block |
||
673 | 695 | $context['config_vars'] = array(); |
674 | 696 | foreach ($config_vars as $identifier => $config_var) |
675 | 697 | { |
676 | - if (!is_array($config_var) || !isset($config_var[1])) |
|
677 | - $context['config_vars'][] = $config_var; |
|
678 | - else |
|
698 | + if (!is_array($config_var) || !isset($config_var[1])) { |
|
699 | + $context['config_vars'][] = $config_var; |
|
700 | + } else |
|
679 | 701 | { |
680 | 702 | $varname = $config_var[0]; |
681 | 703 | global $$varname; |
@@ -710,16 +732,19 @@ discard block |
||
710 | 732 | if ($config_var[3] == 'int' || $config_var[3] == 'float') |
711 | 733 | { |
712 | 734 | // Default to a min of 0 if one isn't set |
713 | - if (isset($config_var['min'])) |
|
714 | - $context['config_vars'][$config_var[0]]['min'] = $config_var['min']; |
|
715 | - else |
|
716 | - $context['config_vars'][$config_var[0]]['min'] = 0; |
|
735 | + if (isset($config_var['min'])) { |
|
736 | + $context['config_vars'][$config_var[0]]['min'] = $config_var['min']; |
|
737 | + } else { |
|
738 | + $context['config_vars'][$config_var[0]]['min'] = 0; |
|
739 | + } |
|
717 | 740 | |
718 | - if (isset($config_var['max'])) |
|
719 | - $context['config_vars'][$config_var[0]]['max'] = $config_var['max']; |
|
741 | + if (isset($config_var['max'])) { |
|
742 | + $context['config_vars'][$config_var[0]]['max'] = $config_var['max']; |
|
743 | + } |
|
720 | 744 | |
721 | - if (isset($config_var['step'])) |
|
722 | - $context['config_vars'][$config_var[0]]['step'] = $config_var['step']; |
|
745 | + if (isset($config_var['step'])) { |
|
746 | + $context['config_vars'][$config_var[0]]['step'] = $config_var['step']; |
|
747 | + } |
|
723 | 748 | } |
724 | 749 | |
725 | 750 | // If this is a select box handle any data. |
@@ -727,12 +752,13 @@ discard block |
||
727 | 752 | { |
728 | 753 | // If it's associative |
729 | 754 | $config_values = array_values($config_var[4]); |
730 | - if (isset($config_values[0]) && is_array($config_values[0])) |
|
731 | - $context['config_vars'][$config_var[0]]['data'] = $config_var[4]; |
|
732 | - else |
|
755 | + if (isset($config_values[0]) && is_array($config_values[0])) { |
|
756 | + $context['config_vars'][$config_var[0]]['data'] = $config_var[4]; |
|
757 | + } else |
|
733 | 758 | { |
734 | - foreach ($config_var[4] as $key => $item) |
|
735 | - $context['config_vars'][$config_var[0]]['data'][] = array($key, $item); |
|
759 | + foreach ($config_var[4] as $key => $item) { |
|
760 | + $context['config_vars'][$config_var[0]]['data'][] = array($key, $item); |
|
761 | + } |
|
736 | 762 | } |
737 | 763 | } |
738 | 764 | } |
@@ -757,10 +783,11 @@ discard block |
||
757 | 783 | |
758 | 784 | if (isset($_SESSION['adm-save'])) |
759 | 785 | { |
760 | - if ($_SESSION['adm-save'] === true) |
|
761 | - $context['saved_successful'] = true; |
|
762 | - else |
|
763 | - $context['saved_failed'] = $_SESSION['adm-save']; |
|
786 | + if ($_SESSION['adm-save'] === true) { |
|
787 | + $context['saved_successful'] = true; |
|
788 | + } else { |
|
789 | + $context['saved_failed'] = $_SESSION['adm-save']; |
|
790 | + } |
|
764 | 791 | |
765 | 792 | unset($_SESSION['adm-save']); |
766 | 793 | } |
@@ -772,26 +799,30 @@ discard block |
||
772 | 799 | foreach ($config_vars as $config_var) |
773 | 800 | { |
774 | 801 | // HR? |
775 | - if (!is_array($config_var)) |
|
776 | - $context['config_vars'][] = $config_var; |
|
777 | - else |
|
802 | + if (!is_array($config_var)) { |
|
803 | + $context['config_vars'][] = $config_var; |
|
804 | + } else |
|
778 | 805 | { |
779 | 806 | // If it has no name it doesn't have any purpose! |
780 | - if (empty($config_var[1])) |
|
781 | - continue; |
|
807 | + if (empty($config_var[1])) { |
|
808 | + continue; |
|
809 | + } |
|
782 | 810 | |
783 | 811 | // Special case for inline permissions |
784 | - if ($config_var[0] == 'permissions' && allowedTo('manage_permissions')) |
|
785 | - $inlinePermissions[] = $config_var[1]; |
|
786 | - elseif ($config_var[0] == 'permissions') |
|
787 | - continue; |
|
812 | + if ($config_var[0] == 'permissions' && allowedTo('manage_permissions')) { |
|
813 | + $inlinePermissions[] = $config_var[1]; |
|
814 | + } elseif ($config_var[0] == 'permissions') { |
|
815 | + continue; |
|
816 | + } |
|
788 | 817 | |
789 | - if ($config_var[0] == 'boards') |
|
790 | - $board_list = true; |
|
818 | + if ($config_var[0] == 'boards') { |
|
819 | + $board_list = true; |
|
820 | + } |
|
791 | 821 | |
792 | 822 | // Are we showing the BBC selection box? |
793 | - if ($config_var[0] == 'bbc') |
|
794 | - $bbcChoice[] = $config_var[1]; |
|
823 | + if ($config_var[0] == 'bbc') { |
|
824 | + $bbcChoice[] = $config_var[1]; |
|
825 | + } |
|
795 | 826 | |
796 | 827 | // We need to do some parsing of the value before we pass it in. |
797 | 828 | if (isset($modSettings[$config_var[1]])) |
@@ -810,8 +841,7 @@ discard block |
||
810 | 841 | default: |
811 | 842 | $value = $smcFunc['htmlspecialchars']($modSettings[$config_var[1]]); |
812 | 843 | } |
813 | - } |
|
814 | - else |
|
844 | + } else |
|
815 | 845 | { |
816 | 846 | // Darn, it's empty. What type is expected? |
817 | 847 | switch ($config_var[0]) |
@@ -851,16 +881,19 @@ discard block |
||
851 | 881 | if ($config_var[0] == 'int' || $config_var[0] == 'float') |
852 | 882 | { |
853 | 883 | // Default to a min of 0 if one isn't set |
854 | - if (isset($config_var['min'])) |
|
855 | - $context['config_vars'][$config_var[1]]['min'] = $config_var['min']; |
|
856 | - else |
|
857 | - $context['config_vars'][$config_var[1]]['min'] = 0; |
|
884 | + if (isset($config_var['min'])) { |
|
885 | + $context['config_vars'][$config_var[1]]['min'] = $config_var['min']; |
|
886 | + } else { |
|
887 | + $context['config_vars'][$config_var[1]]['min'] = 0; |
|
888 | + } |
|
858 | 889 | |
859 | - if (isset($config_var['max'])) |
|
860 | - $context['config_vars'][$config_var[1]]['max'] = $config_var['max']; |
|
890 | + if (isset($config_var['max'])) { |
|
891 | + $context['config_vars'][$config_var[1]]['max'] = $config_var['max']; |
|
892 | + } |
|
861 | 893 | |
862 | - if (isset($config_var['step'])) |
|
863 | - $context['config_vars'][$config_var[1]]['step'] = $config_var['step']; |
|
894 | + if (isset($config_var['step'])) { |
|
895 | + $context['config_vars'][$config_var[1]]['step'] = $config_var['step']; |
|
896 | + } |
|
864 | 897 | } |
865 | 898 | |
866 | 899 | // If this is a select box handle any data. |
@@ -874,12 +907,13 @@ discard block |
||
874 | 907 | } |
875 | 908 | |
876 | 909 | // If it's associative |
877 | - if (isset($config_var[2][0]) && is_array($config_var[2][0])) |
|
878 | - $context['config_vars'][$config_var[1]]['data'] = $config_var[2]; |
|
879 | - else |
|
910 | + if (isset($config_var[2][0]) && is_array($config_var[2][0])) { |
|
911 | + $context['config_vars'][$config_var[1]]['data'] = $config_var[2]; |
|
912 | + } else |
|
880 | 913 | { |
881 | - foreach ($config_var[2] as $key => $item) |
|
882 | - $context['config_vars'][$config_var[1]]['data'][] = array($key, $item); |
|
914 | + foreach ($config_var[2] as $key => $item) { |
|
915 | + $context['config_vars'][$config_var[1]]['data'][] = array($key, $item); |
|
916 | + } |
|
883 | 917 | } |
884 | 918 | } |
885 | 919 | |
@@ -888,17 +922,19 @@ discard block |
||
888 | 922 | { |
889 | 923 | if (!is_numeric($k)) |
890 | 924 | { |
891 | - if (substr($k, 0, 2) == 'on') |
|
892 | - $context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"'; |
|
893 | - else |
|
894 | - $context['config_vars'][$config_var[1]][$k] = $v; |
|
925 | + if (substr($k, 0, 2) == 'on') { |
|
926 | + $context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"'; |
|
927 | + } else { |
|
928 | + $context['config_vars'][$config_var[1]][$k] = $v; |
|
929 | + } |
|
895 | 930 | } |
896 | 931 | |
897 | 932 | // See if there are any other labels that might fit? |
898 | - if (isset($txt['setting_' . $config_var[1]])) |
|
899 | - $context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]]; |
|
900 | - elseif (isset($txt['groups_' . $config_var[1]])) |
|
901 | - $context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]]; |
|
933 | + if (isset($txt['setting_' . $config_var[1]])) { |
|
934 | + $context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]]; |
|
935 | + } elseif (isset($txt['groups_' . $config_var[1]])) { |
|
936 | + $context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]]; |
|
937 | + } |
|
902 | 938 | } |
903 | 939 | |
904 | 940 | // Set the subtext in case it's part of the label. |
@@ -931,8 +967,9 @@ discard block |
||
931 | 967 | // What are the options, eh? |
932 | 968 | $temp = parse_bbc(false); |
933 | 969 | $bbcTags = array(); |
934 | - foreach ($temp as $tag) |
|
935 | - $bbcTags[] = $tag['tag']; |
|
970 | + foreach ($temp as $tag) { |
|
971 | + $bbcTags[] = $tag['tag']; |
|
972 | + } |
|
936 | 973 | |
937 | 974 | $bbcTags = array_unique($bbcTags); |
938 | 975 | $totalTags = count($bbcTags); |
@@ -947,8 +984,9 @@ discard block |
||
947 | 984 | $col = 0; $i = 0; |
948 | 985 | foreach ($bbcTags as $tag) |
949 | 986 | { |
950 | - if ($i % $tagsPerColumn == 0 && $i != 0) |
|
951 | - $col++; |
|
987 | + if ($i % $tagsPerColumn == 0 && $i != 0) { |
|
988 | + $col++; |
|
989 | + } |
|
952 | 990 | |
953 | 991 | $context['bbc_columns'][$col][] = array( |
954 | 992 | 'tag' => $tag, |
@@ -991,18 +1029,21 @@ discard block |
||
991 | 1029 | validateToken('admin-ssc'); |
992 | 1030 | |
993 | 1031 | // Fix the darn stupid cookiename! (more may not be allowed, but these for sure!) |
994 | - if (isset($_POST['cookiename'])) |
|
995 | - $_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']); |
|
1032 | + if (isset($_POST['cookiename'])) { |
|
1033 | + $_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']); |
|
1034 | + } |
|
996 | 1035 | |
997 | 1036 | // Fix the forum's URL if necessary. |
998 | 1037 | if (isset($_POST['boardurl'])) |
999 | 1038 | { |
1000 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
1001 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
1002 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
1003 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
1004 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
1005 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
1039 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
1040 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
1041 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
1042 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
1043 | + } |
|
1044 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
1045 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
1046 | + } |
|
1006 | 1047 | } |
1007 | 1048 | |
1008 | 1049 | // Any passwords? |
@@ -1037,21 +1078,21 @@ discard block |
||
1037 | 1078 | // Figure out which config vars we're saving here... |
1038 | 1079 | foreach ($config_vars as $var) |
1039 | 1080 | { |
1040 | - if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]]))) |
|
1041 | - continue; |
|
1081 | + if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]]))) { |
|
1082 | + continue; |
|
1083 | + } |
|
1042 | 1084 | |
1043 | 1085 | $config_var = $var[0]; |
1044 | 1086 | |
1045 | 1087 | if (in_array($config_var, $config_passwords)) |
1046 | 1088 | { |
1047 | - if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) |
|
1048 | - $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\''; |
|
1049 | - } |
|
1050 | - elseif (in_array($config_var, $config_strs)) |
|
1089 | + if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) { |
|
1090 | + $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\''; |
|
1091 | + } |
|
1092 | + } elseif (in_array($config_var, $config_strs)) |
|
1051 | 1093 | { |
1052 | 1094 | $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var], '\'\\') . '\''; |
1053 | - } |
|
1054 | - elseif (in_array($config_var, $config_ints)) |
|
1095 | + } elseif (in_array($config_var, $config_ints)) |
|
1055 | 1096 | { |
1056 | 1097 | $new_settings[$config_var] = (int) $_POST[$config_var]; |
1057 | 1098 | |
@@ -1060,17 +1101,17 @@ discard block |
||
1060 | 1101 | $new_settings[$config_var] = max($min, $new_settings[$config_var]); |
1061 | 1102 | |
1062 | 1103 | // Is there a max value for this as well? |
1063 | - if (isset($var['max'])) |
|
1064 | - $new_settings[$config_var] = min($var['max'], $new_settings[$config_var]); |
|
1065 | - } |
|
1066 | - elseif (in_array($config_var, $config_bools)) |
|
1104 | + if (isset($var['max'])) { |
|
1105 | + $new_settings[$config_var] = min($var['max'], $new_settings[$config_var]); |
|
1106 | + } |
|
1107 | + } elseif (in_array($config_var, $config_bools)) |
|
1067 | 1108 | { |
1068 | - if (!empty($_POST[$config_var])) |
|
1069 | - $new_settings[$config_var] = '1'; |
|
1070 | - else |
|
1071 | - $new_settings[$config_var] = '0'; |
|
1072 | - } |
|
1073 | - else |
|
1109 | + if (!empty($_POST[$config_var])) { |
|
1110 | + $new_settings[$config_var] = '1'; |
|
1111 | + } else { |
|
1112 | + $new_settings[$config_var] = '0'; |
|
1113 | + } |
|
1114 | + } else |
|
1074 | 1115 | { |
1075 | 1116 | // This shouldn't happen, but it might... |
1076 | 1117 | fatal_error('Unknown config_var \'' . $config_var . '\''); |
@@ -1086,30 +1127,35 @@ discard block |
||
1086 | 1127 | foreach ($config_vars as $config_var) |
1087 | 1128 | { |
1088 | 1129 | // We just saved the file-based settings, so skip their definitions. |
1089 | - if (!is_array($config_var) || $config_var[2] == 'file') |
|
1090 | - continue; |
|
1130 | + if (!is_array($config_var) || $config_var[2] == 'file') { |
|
1131 | + continue; |
|
1132 | + } |
|
1091 | 1133 | |
1092 | 1134 | $new_setting = array($config_var[3], $config_var[0]); |
1093 | 1135 | |
1094 | 1136 | // Select options need carried over, too. |
1095 | - if (isset($config_var[4])) |
|
1096 | - $new_setting[] = $config_var[4]; |
|
1137 | + if (isset($config_var[4])) { |
|
1138 | + $new_setting[] = $config_var[4]; |
|
1139 | + } |
|
1097 | 1140 | |
1098 | 1141 | // Include min and max if necessary |
1099 | - if (isset($config_var['min'])) |
|
1100 | - $new_setting['min'] = $config_var['min']; |
|
1142 | + if (isset($config_var['min'])) { |
|
1143 | + $new_setting['min'] = $config_var['min']; |
|
1144 | + } |
|
1101 | 1145 | |
1102 | - if (isset($config_var['max'])) |
|
1103 | - $new_setting['max'] = $config_var['max']; |
|
1146 | + if (isset($config_var['max'])) { |
|
1147 | + $new_setting['max'] = $config_var['max']; |
|
1148 | + } |
|
1104 | 1149 | |
1105 | 1150 | // Rewrite the definition a bit. |
1106 | 1151 | $new_settings[] = $new_setting; |
1107 | 1152 | } |
1108 | 1153 | |
1109 | 1154 | // Save the new database-based settings, if any. |
1110 | - if (!empty($new_settings)) |
|
1111 | - saveDBSettings($new_settings); |
|
1112 | -} |
|
1155 | + if (!empty($new_settings)) { |
|
1156 | + saveDBSettings($new_settings); |
|
1157 | + } |
|
1158 | + } |
|
1113 | 1159 | |
1114 | 1160 | /** |
1115 | 1161 | * Helper function for saving database settings. |
@@ -1127,22 +1173,25 @@ discard block |
||
1127 | 1173 | $inlinePermissions = array(); |
1128 | 1174 | foreach ($config_vars as $var) |
1129 | 1175 | { |
1130 | - if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags'])))) |
|
1131 | - continue; |
|
1176 | + if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags'])))) { |
|
1177 | + continue; |
|
1178 | + } |
|
1132 | 1179 | |
1133 | 1180 | // Checkboxes! |
1134 | - elseif ($var[0] == 'check') |
|
1135 | - $setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0'; |
|
1181 | + elseif ($var[0] == 'check') { |
|
1182 | + $setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0'; |
|
1183 | + } |
|
1136 | 1184 | // Select boxes! |
1137 | - elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) |
|
1138 | - $setArray[$var[1]] = $_POST[$var[1]]; |
|
1139 | - elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array()) |
|
1185 | + elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) { |
|
1186 | + $setArray[$var[1]] = $_POST[$var[1]]; |
|
1187 | + } elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array()) |
|
1140 | 1188 | { |
1141 | 1189 | // For security purposes we validate this line by line. |
1142 | 1190 | $lOptions = array(); |
1143 | - foreach ($_POST[$var[1]] as $invar) |
|
1144 | - if (in_array($invar, array_keys($var[2]))) |
|
1191 | + foreach ($_POST[$var[1]] as $invar) { |
|
1192 | + if (in_array($invar, array_keys($var[2]))) |
|
1145 | 1193 | $lOptions[] = $invar; |
1194 | + } |
|
1146 | 1195 | |
1147 | 1196 | $setArray[$var[1]] = json_encode($lOptions); |
1148 | 1197 | } |
@@ -1156,18 +1205,20 @@ discard block |
||
1156 | 1205 | $request = $smcFunc['db_query']('', ' |
1157 | 1206 | SELECT id_board |
1158 | 1207 | FROM {db_prefix}boards'); |
1159 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1160 | - $board_list[$row[0]] = true; |
|
1208 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1209 | + $board_list[$row[0]] = true; |
|
1210 | + } |
|
1161 | 1211 | |
1162 | 1212 | $smcFunc['db_free_result']($request); |
1163 | 1213 | } |
1164 | 1214 | |
1165 | 1215 | $lOptions = array(); |
1166 | 1216 | |
1167 | - if (!empty($_POST[$var[1]])) |
|
1168 | - foreach ($_POST[$var[1]] as $invar => $dummy) |
|
1217 | + if (!empty($_POST[$var[1]])) { |
|
1218 | + foreach ($_POST[$var[1]] as $invar => $dummy) |
|
1169 | 1219 | if (isset($board_list[$invar])) |
1170 | 1220 | $lOptions[] = $invar; |
1221 | + } |
|
1171 | 1222 | |
1172 | 1223 | $setArray[$var[1]] = !empty($lOptions) ? implode(',', $lOptions) : ''; |
1173 | 1224 | } |
@@ -1181,8 +1232,9 @@ discard block |
||
1181 | 1232 | $setArray[$var[1]] = max($min, $setArray[$var[1]]); |
1182 | 1233 | |
1183 | 1234 | // Do we have a max value for this as well? |
1184 | - if (isset($var['max'])) |
|
1185 | - $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
1235 | + if (isset($var['max'])) { |
|
1236 | + $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
1237 | + } |
|
1186 | 1238 | } |
1187 | 1239 | // Floating point! |
1188 | 1240 | elseif ($var[0] == 'float') |
@@ -1194,40 +1246,47 @@ discard block |
||
1194 | 1246 | $setArray[$var[1]] = max($min, $setArray[$var[1]]); |
1195 | 1247 | |
1196 | 1248 | // Do we have a max value for this as well? |
1197 | - if (isset($var['max'])) |
|
1198 | - $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
1249 | + if (isset($var['max'])) { |
|
1250 | + $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
1251 | + } |
|
1199 | 1252 | } |
1200 | 1253 | // Text! |
1201 | - elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'))) |
|
1202 | - $setArray[$var[1]] = $_POST[$var[1]]; |
|
1254 | + elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'))) { |
|
1255 | + $setArray[$var[1]] = $_POST[$var[1]]; |
|
1256 | + } |
|
1203 | 1257 | // Passwords! |
1204 | 1258 | elseif ($var[0] == 'password') |
1205 | 1259 | { |
1206 | - if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1]) |
|
1207 | - $setArray[$var[1]] = $_POST[$var[1]][0]; |
|
1260 | + if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1]) { |
|
1261 | + $setArray[$var[1]] = $_POST[$var[1]][0]; |
|
1262 | + } |
|
1208 | 1263 | } |
1209 | 1264 | // BBC. |
1210 | 1265 | elseif ($var[0] == 'bbc') |
1211 | 1266 | { |
1212 | 1267 | |
1213 | 1268 | $bbcTags = array(); |
1214 | - foreach (parse_bbc(false) as $tag) |
|
1215 | - $bbcTags[] = $tag['tag']; |
|
1269 | + foreach (parse_bbc(false) as $tag) { |
|
1270 | + $bbcTags[] = $tag['tag']; |
|
1271 | + } |
|
1216 | 1272 | |
1217 | - if (!isset($_POST[$var[1] . '_enabledTags'])) |
|
1218 | - $_POST[$var[1] . '_enabledTags'] = array(); |
|
1219 | - elseif (!is_array($_POST[$var[1] . '_enabledTags'])) |
|
1220 | - $_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']); |
|
1273 | + if (!isset($_POST[$var[1] . '_enabledTags'])) { |
|
1274 | + $_POST[$var[1] . '_enabledTags'] = array(); |
|
1275 | + } elseif (!is_array($_POST[$var[1] . '_enabledTags'])) { |
|
1276 | + $_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']); |
|
1277 | + } |
|
1221 | 1278 | |
1222 | 1279 | $setArray[$var[1]] = implode(',', array_diff($bbcTags, $_POST[$var[1] . '_enabledTags'])); |
1223 | 1280 | } |
1224 | 1281 | // Permissions? |
1225 | - elseif ($var[0] == 'permissions') |
|
1226 | - $inlinePermissions[] = $var[1]; |
|
1282 | + elseif ($var[0] == 'permissions') { |
|
1283 | + $inlinePermissions[] = $var[1]; |
|
1284 | + } |
|
1227 | 1285 | } |
1228 | 1286 | |
1229 | - if (!empty($setArray)) |
|
1230 | - updateSettings($setArray); |
|
1287 | + if (!empty($setArray)) { |
|
1288 | + updateSettings($setArray); |
|
1289 | + } |
|
1231 | 1290 | |
1232 | 1291 | // If we have inline permissions we need to save them. |
1233 | 1292 | if (!empty($inlinePermissions) && allowedTo('manage_permissions')) |
@@ -1265,18 +1324,21 @@ discard block |
||
1265 | 1324 | // put all of it into an array |
1266 | 1325 | foreach ($info_lines as $line) |
1267 | 1326 | { |
1268 | - if (preg_match('~(' . $remove . ')~', $line)) |
|
1269 | - continue; |
|
1327 | + if (preg_match('~(' . $remove . ')~', $line)) { |
|
1328 | + continue; |
|
1329 | + } |
|
1270 | 1330 | |
1271 | 1331 | // new category? |
1272 | - if (strpos($line, '<h2>') !== false) |
|
1273 | - $category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category; |
|
1332 | + if (strpos($line, '<h2>') !== false) { |
|
1333 | + $category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category; |
|
1334 | + } |
|
1274 | 1335 | |
1275 | 1336 | // load it as setting => value or the old setting local master |
1276 | - if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) |
|
1277 | - $pinfo[$category][$val[1]] = $val[2]; |
|
1278 | - elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) |
|
1279 | - $pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]); |
|
1337 | + if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) { |
|
1338 | + $pinfo[$category][$val[1]] = $val[2]; |
|
1339 | + } elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) { |
|
1340 | + $pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]); |
|
1341 | + } |
|
1280 | 1342 | } |
1281 | 1343 | |
1282 | 1344 | // load it in to context and display it |
@@ -16,8 +16,9 @@ discard block |
||
16 | 16 | * @version 2.1 Beta 3 |
17 | 17 | */ |
18 | 18 | |
19 | -if (!defined('SMF')) |
|
19 | +if (!defined('SMF')) { |
|
20 | 20 | die('No direct access...'); |
21 | +} |
|
21 | 22 | |
22 | 23 | |
23 | 24 | /** |
@@ -28,14 +29,16 @@ discard block |
||
28 | 29 | function sha1_smf($str) |
29 | 30 | { |
30 | 31 | // If we have mhash loaded in, use it instead! |
31 | - if (function_exists('mhash') && defined('MHASH_SHA1')) |
|
32 | - return bin2hex(mhash(MHASH_SHA1, $str)); |
|
32 | + if (function_exists('mhash') && defined('MHASH_SHA1')) { |
|
33 | + return bin2hex(mhash(MHASH_SHA1, $str)); |
|
34 | + } |
|
33 | 35 | |
34 | 36 | $nblk = (strlen($str) + 8 >> 6) + 1; |
35 | 37 | $blks = array_pad(array(), $nblk * 16, 0); |
36 | 38 | |
37 | - for ($i = 0; $i < strlen($str); $i++) |
|
38 | - $blks[$i >> 2] |= ord($str{$i}) << (24 - ($i % 4) * 8); |
|
39 | + for ($i = 0; $i < strlen($str); $i++) { |
|
40 | + $blks[$i >> 2] |= ord($str{$i}) << (24 - ($i % 4) * 8); |
|
41 | + } |
|
39 | 42 | |
40 | 43 | $blks[$i >> 2] |= 0x80 << (24 - ($i % 4) * 8); |
41 | 44 | |
@@ -70,10 +73,11 @@ discard block |
||
70 | 73 | |
71 | 74 | for ($j = 0; $j < 80; $j++) |
72 | 75 | { |
73 | - if ($j < 16) |
|
74 | - $w[$j] = isset($x[$i + $j]) ? $x[$i + $j] : 0; |
|
75 | - else |
|
76 | - $w[$j] = sha1_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1); |
|
76 | + if ($j < 16) { |
|
77 | + $w[$j] = isset($x[$i + $j]) ? $x[$i + $j] : 0; |
|
78 | + } else { |
|
79 | + $w[$j] = sha1_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1); |
|
80 | + } |
|
77 | 81 | |
78 | 82 | $t = sha1_rol($a, 5) + sha1_ft($j, $b, $c, $d) + $e + $w[$j] + sha1_kt($j); |
79 | 83 | $e = $d; |
@@ -103,12 +107,15 @@ discard block |
||
103 | 107 | */ |
104 | 108 | function sha1_ft($t, $b, $c, $d) |
105 | 109 | { |
106 | - if ($t < 20) |
|
107 | - return ($b & $c) | ((~$b) & $d); |
|
108 | - if ($t < 40) |
|
109 | - return $b ^ $c ^ $d; |
|
110 | - if ($t < 60) |
|
111 | - return ($b & $c) | ($b & $d) | ($c & $d); |
|
110 | + if ($t < 20) { |
|
111 | + return ($b & $c) | ((~$b) & $d); |
|
112 | + } |
|
113 | + if ($t < 40) { |
|
114 | + return $b ^ $c ^ $d; |
|
115 | + } |
|
116 | + if ($t < 60) { |
|
117 | + return ($b & $c) | ($b & $d) | ($c & $d); |
|
118 | + } |
|
112 | 119 | |
113 | 120 | return $b ^ $c ^ $d; |
114 | 121 | } |
@@ -132,10 +139,11 @@ discard block |
||
132 | 139 | function sha1_rol($num, $cnt) |
133 | 140 | { |
134 | 141 | // Unfortunately, PHP uses unsigned 32-bit longs only. So we have to kludge it a bit. |
135 | - if ($num & 0x80000000) |
|
136 | - $a = ($num >> 1 & 0x7fffffff) >> (31 - $cnt); |
|
137 | - else |
|
138 | - $a = $num >> (32 - $cnt); |
|
142 | + if ($num & 0x80000000) { |
|
143 | + $a = ($num >> 1 & 0x7fffffff) >> (31 - $cnt); |
|
144 | + } else { |
|
145 | + $a = $num >> (32 - $cnt); |
|
146 | + } |
|
139 | 147 | |
140 | 148 | return ($num << $cnt) | $a; |
141 | 149 | } |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | } |
72 | 72 | |
73 | 73 | // Use cache when possible. |
74 | - if (($cache = cache_get_data('attachment_lookup_id-'. $attachId)) != null) |
|
74 | + if (($cache = cache_get_data('attachment_lookup_id-' . $attachId)) != null) |
|
75 | 75 | list($file, $thumbFile) = $cache; |
76 | 76 | |
77 | 77 | // Get the info from the DB. |
78 | - if(empty($file) || empty($thumbFile) && !empty($file['id_thumb'])) |
|
78 | + if (empty($file) || empty($thumbFile) && !empty($file['id_thumb'])) |
|
79 | 79 | { |
80 | 80 | // Do we have a hook wanting to use our attachment system? We use $attachRequest to prevent accidental usage of $request. |
81 | 81 | $attachRequest = null; |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | $file['filePath'] = getAttachmentFilename($file['filename'], $attachId, $file['id_folder'], false, $file['file_hash']); |
145 | 145 | // ensure variant attachment compatibility |
146 | 146 | $filePath = pathinfo($file['filePath']); |
147 | - $file['filePath'] = !file_exists($file['filePath']) ? substr($file['filePath'], 0, -(strlen($filePath['extension'])+1)) : $file['filePath']; |
|
148 | - $file['etag'] = '"'. md5_file($file['filePath']) .'"'; |
|
147 | + $file['filePath'] = !file_exists($file['filePath']) ? substr($file['filePath'], 0, -(strlen($filePath['extension']) + 1)) : $file['filePath']; |
|
148 | + $file['etag'] = '"' . md5_file($file['filePath']) . '"'; |
|
149 | 149 | |
150 | 150 | // now get the thumbfile! |
151 | 151 | $thumbFile = array(); |
@@ -171,13 +171,13 @@ discard block |
||
171 | 171 | |
172 | 172 | // set filePath and ETag time |
173 | 173 | $thumbFile['filePath'] = getAttachmentFilename($thumbFile['filename'], $attachId, $thumbFile['id_folder'], false, $thumbFile['file_hash']); |
174 | - $thumbFile['etag'] = '"'. md5_file($thumbFile['filePath']) .'"'; |
|
174 | + $thumbFile['etag'] = '"' . md5_file($thumbFile['filePath']) . '"'; |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
178 | 178 | // Cache it. |
179 | - if(!empty($file) || !empty($thumbFile)) |
|
180 | - cache_put_data('attachment_lookup_id-'. $file['id_attach'], array($file, $thumbFile), mt_rand(850, 900)); |
|
179 | + if (!empty($file) || !empty($thumbFile)) |
|
180 | + cache_put_data('attachment_lookup_id-' . $file['id_attach'], array($file, $thumbFile), mt_rand(850, 900)); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | // Update the download counter (unless it's a thumbnail). |
@@ -289,17 +289,17 @@ discard block |
||
289 | 289 | if (!empty($modSettings['attachmentRecodeLineEndings']) && !isset($_REQUEST['image']) && in_array($file['fileext'], array('txt', 'css', 'htm', 'html', 'php', 'xml'))) |
290 | 290 | { |
291 | 291 | if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) |
292 | - $callback = function ($buffer) |
|
292 | + $callback = function($buffer) |
|
293 | 293 | { |
294 | 294 | return preg_replace('~[\r]?\n~', "\r\n", $buffer); |
295 | 295 | }; |
296 | 296 | elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) |
297 | - $callback = function ($buffer) |
|
297 | + $callback = function($buffer) |
|
298 | 298 | { |
299 | 299 | return preg_replace('~[\r]?\n~', "\r", $buffer); |
300 | 300 | }; |
301 | 301 | else |
302 | - $callback = function ($buffer) |
|
302 | + $callback = function($buffer) |
|
303 | 303 | { |
304 | 304 | return preg_replace('~[\r]?\n~', "\n", $buffer); |
305 | 305 | }; |
@@ -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 | * Shows an avatar based on $_GET['attach'] |
@@ -35,11 +36,11 @@ discard block |
||
35 | 36 | |
36 | 37 | if (!empty($modSettings['enableCompressedOutput']) && !headers_sent() && ob_get_length() == 0) |
37 | 38 | { |
38 | - if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler') |
|
39 | - $modSettings['enableCompressedOutput'] = 0; |
|
40 | - |
|
41 | - else |
|
42 | - ob_start('ob_gzhandler'); |
|
39 | + if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler') { |
|
40 | + $modSettings['enableCompressedOutput'] = 0; |
|
41 | + } else { |
|
42 | + ob_start('ob_gzhandler'); |
|
43 | + } |
|
43 | 44 | } |
44 | 45 | |
45 | 46 | if (empty($modSettings['enableCompressedOutput'])) |
@@ -71,8 +72,9 @@ discard block |
||
71 | 72 | } |
72 | 73 | |
73 | 74 | // Use cache when possible. |
74 | - if (($cache = cache_get_data('attachment_lookup_id-'. $attachId)) != null) |
|
75 | - list($file, $thumbFile) = $cache; |
|
75 | + if (($cache = cache_get_data('attachment_lookup_id-'. $attachId)) != null) { |
|
76 | + list($file, $thumbFile) = $cache; |
|
77 | + } |
|
76 | 78 | |
77 | 79 | // Get the info from the DB. |
78 | 80 | if(empty($file) || empty($thumbFile) && !empty($file['id_thumb'])) |
@@ -80,10 +82,9 @@ discard block |
||
80 | 82 | // Do we have a hook wanting to use our attachment system? We use $attachRequest to prevent accidental usage of $request. |
81 | 83 | $attachRequest = null; |
82 | 84 | call_integration_hook('integrate_download_request', array(&$attachRequest)); |
83 | - if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) |
|
84 | - $request = $attachRequest; |
|
85 | - |
|
86 | - else |
|
85 | + if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) { |
|
86 | + $request = $attachRequest; |
|
87 | + } else |
|
87 | 88 | { |
88 | 89 | // Make sure this attachment is on this board and load its info while we are at it. |
89 | 90 | $request = $smcFunc['db_query']('', ' |
@@ -176,13 +177,14 @@ discard block |
||
176 | 177 | } |
177 | 178 | |
178 | 179 | // Cache it. |
179 | - if(!empty($file) || !empty($thumbFile)) |
|
180 | - cache_put_data('attachment_lookup_id-'. $file['id_attach'], array($file, $thumbFile), mt_rand(850, 900)); |
|
180 | + if(!empty($file) || !empty($thumbFile)) { |
|
181 | + cache_put_data('attachment_lookup_id-'. $file['id_attach'], array($file, $thumbFile), mt_rand(850, 900)); |
|
182 | + } |
|
181 | 183 | } |
182 | 184 | |
183 | 185 | // Update the download counter (unless it's a thumbnail). |
184 | - if ($file['attachment_type'] != 3 && empty($showThumb)) |
|
185 | - $smcFunc['db_query']('attach_download_increase', ' |
|
186 | + if ($file['attachment_type'] != 3 && empty($showThumb)) { |
|
187 | + $smcFunc['db_query']('attach_download_increase', ' |
|
186 | 188 | UPDATE LOW_PRIORITY {db_prefix}attachments |
187 | 189 | SET downloads = downloads + 1 |
188 | 190 | WHERE id_attach = {int:id_attach}', |
@@ -190,10 +192,12 @@ discard block |
||
190 | 192 | 'id_attach' => $attachId, |
191 | 193 | ) |
192 | 194 | ); |
195 | + } |
|
193 | 196 | |
194 | 197 | // Replace the normal file with its thumbnail if it has one! |
195 | - if (!empty($showThumb) && !empty($thumbFile)) |
|
196 | - $file = $thumbFile; |
|
198 | + if (!empty($showThumb) && !empty($thumbFile)) { |
|
199 | + $file = $thumbFile; |
|
200 | + } |
|
197 | 201 | |
198 | 202 | // No point in a nicer message, because this is supposed to be an attachment anyway... |
199 | 203 | if (!file_exists($file['filePath'])) |
@@ -232,8 +236,9 @@ discard block |
||
232 | 236 | // Send the attachment headers. |
233 | 237 | header('Pragma: '); |
234 | 238 | |
235 | - if (!isBrowser('gecko')) |
|
236 | - header('Content-Transfer-Encoding: binary'); |
|
239 | + if (!isBrowser('gecko')) { |
|
240 | + header('Content-Transfer-Encoding: binary'); |
|
241 | + } |
|
237 | 242 | |
238 | 243 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
239 | 244 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($file['filePath'])) . ' GMT'); |
@@ -242,18 +247,19 @@ discard block |
||
242 | 247 | header('ETag: ' . $eTag); |
243 | 248 | |
244 | 249 | // Make sure the mime type warrants an inline display. |
245 | - if (isset($_REQUEST['image']) && !empty($file['mime_type']) && strpos($file['mime_type'], 'image/') !== 0) |
|
246 | - unset($_REQUEST['image']); |
|
250 | + if (isset($_REQUEST['image']) && !empty($file['mime_type']) && strpos($file['mime_type'], 'image/') !== 0) { |
|
251 | + unset($_REQUEST['image']); |
|
252 | + } |
|
247 | 253 | |
248 | 254 | // Does this have a mime type? |
249 | - elseif (!empty($file['mime_type']) && (isset($_REQUEST['image']) || !in_array($file['fileext'], array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) |
|
250 | - header('Content-Type: ' . strtr($file['mime_type'], array('image/bmp' => 'image/x-ms-bmp'))); |
|
251 | - |
|
252 | - else |
|
255 | + elseif (!empty($file['mime_type']) && (isset($_REQUEST['image']) || !in_array($file['fileext'], array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) { |
|
256 | + header('Content-Type: ' . strtr($file['mime_type'], array('image/bmp' => 'image/x-ms-bmp'))); |
|
257 | + } else |
|
253 | 258 | { |
254 | 259 | header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream')); |
255 | - if (isset($_REQUEST['image'])) |
|
256 | - unset($_REQUEST['image']); |
|
260 | + if (isset($_REQUEST['image'])) { |
|
261 | + unset($_REQUEST['image']); |
|
262 | + } |
|
257 | 263 | } |
258 | 264 | |
259 | 265 | // Convert the file to UTF-8, cuz most browsers dig that. |
@@ -261,24 +267,22 @@ discard block |
||
261 | 267 | $disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline'; |
262 | 268 | |
263 | 269 | // Different browsers like different standards... |
264 | - if (isBrowser('firefox')) |
|
265 | - header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
266 | - |
|
267 | - elseif (isBrowser('opera')) |
|
268 | - header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
269 | - |
|
270 | - elseif (isBrowser('ie')) |
|
271 | - header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
272 | - |
|
273 | - else |
|
274 | - header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
270 | + if (isBrowser('firefox')) { |
|
271 | + header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
272 | + } elseif (isBrowser('opera')) { |
|
273 | + header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
274 | + } elseif (isBrowser('ie')) { |
|
275 | + header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
276 | + } else { |
|
277 | + header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
278 | + } |
|
275 | 279 | |
276 | 280 | // If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE. |
277 | - if (!isset($_REQUEST['image']) && in_array($file['fileext'], array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) |
|
278 | - header('Cache-Control: no-cache'); |
|
279 | - |
|
280 | - else |
|
281 | - header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
281 | + if (!isset($_REQUEST['image']) && in_array($file['fileext'], array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) { |
|
282 | + header('Cache-Control: no-cache'); |
|
283 | + } else { |
|
284 | + header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
285 | + } |
|
282 | 286 | |
283 | 287 | header('Content-Length: ' . filesize($file['filePath'])); |
284 | 288 | |
@@ -288,20 +292,23 @@ discard block |
||
288 | 292 | // Recode line endings for text files, if enabled. |
289 | 293 | if (!empty($modSettings['attachmentRecodeLineEndings']) && !isset($_REQUEST['image']) && in_array($file['fileext'], array('txt', 'css', 'htm', 'html', 'php', 'xml'))) |
290 | 294 | { |
291 | - if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) |
|
292 | - $callback = function ($buffer) |
|
295 | + if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) { |
|
296 | + $callback = function ($buffer) |
|
293 | 297 | { |
294 | 298 | return preg_replace('~[\r]?\n~', "\r\n", $buffer); |
299 | + } |
|
295 | 300 | }; |
296 | - elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) |
|
297 | - $callback = function ($buffer) |
|
301 | + elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) { |
|
302 | + $callback = function ($buffer) |
|
298 | 303 | { |
299 | 304 | return preg_replace('~[\r]?\n~', "\r", $buffer); |
305 | + } |
|
300 | 306 | }; |
301 | - else |
|
302 | - $callback = function ($buffer) |
|
307 | + else { |
|
308 | + $callback = function ($buffer) |
|
303 | 309 | { |
304 | 310 | return preg_replace('~[\r]?\n~', "\n", $buffer); |
311 | + } |
|
305 | 312 | }; |
306 | 313 | } |
307 | 314 | |
@@ -309,8 +316,9 @@ discard block |
||
309 | 316 | if (filesize($file['filePath']) > 4194304) |
310 | 317 | { |
311 | 318 | // Forcibly end any output buffering going on. |
312 | - while (@ob_get_level() > 0) |
|
313 | - @ob_end_clean(); |
|
319 | + while (@ob_get_level() > 0) { |
|
320 | + @ob_end_clean(); |
|
321 | + } |
|
314 | 322 | |
315 | 323 | $fp = fopen($file['filePath'], 'rb'); |
316 | 324 | while (!feof($fp)) |
@@ -322,8 +330,9 @@ discard block |
||
322 | 330 | } |
323 | 331 | |
324 | 332 | // On some of the less-bright hosts, readfile() is disabled. It's just a faster, more byte safe, version of what's in the if. |
325 | - elseif (@readfile($file['filePath']) === null) |
|
326 | - echo file_get_contents($file['filePath']); |
|
333 | + elseif (@readfile($file['filePath']) === null) { |
|
334 | + echo file_get_contents($file['filePath']); |
|
335 | + } |
|
327 | 336 | |
328 | 337 | die(); |
329 | 338 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | { |
151 | 151 | if (!@is_dir($directory)) |
152 | 152 | { |
153 | - if (!@mkdir($directory,0755)) |
|
153 | + if (!@mkdir($directory, 0755)) |
|
154 | 154 | { |
155 | 155 | $context['dir_creation_error'] = 'attachments_no_create'; |
156 | 156 | return false; |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @return array|bool An array of all the directories and subdirectories or false on failure |
250 | 250 | */ |
251 | -function get_directory_tree_elements ($directory) |
|
251 | +function get_directory_tree_elements($directory) |
|
252 | 252 | { |
253 | 253 | /* |
254 | 254 | In Windows server both \ and / can be used as directory separators in paths |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | if (substr($directory, 0, 1) != DIRECTORY_SEPARATOR) |
265 | 265 | return false; |
266 | 266 | |
267 | - $tree = explode(DIRECTORY_SEPARATOR, trim($directory,DIRECTORY_SEPARATOR)); |
|
267 | + $tree = explode(DIRECTORY_SEPARATOR, trim($directory, DIRECTORY_SEPARATOR)); |
|
268 | 268 | } |
269 | 269 | return $tree; |
270 | 270 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * |
278 | 278 | * @return string|bool The first part of the path or false on error |
279 | 279 | */ |
280 | -function attachments_init_dir (&$tree, &$count) |
|
280 | +function attachments_init_dir(&$tree, &$count) |
|
281 | 281 | { |
282 | 282 | $directory = ''; |
283 | 283 | // If on Windows servers the first part of the path is the drive (e.g. "C:") |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | //Better be sure that the first part of the path is actually a drive letter... |
287 | 287 | //...even if, I should check this in the admin page...isn't it? |
288 | 288 | //...NHAAA Let's leave space for users' complains! :P |
289 | - if (preg_match('/^[a-z]:$/i',$tree[0])) |
|
289 | + if (preg_match('/^[a-z]:$/i', $tree[0])) |
|
290 | 290 | $directory = array_shift($tree); |
291 | 291 | else |
292 | 292 | return false; |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | global $modSettings, $context, $sourcedir, $smcFunc; |
485 | 485 | |
486 | 486 | // No data or missing data .... Not necessarily needed, but in case a mod author missed something. |
487 | - if ( empty($_SESSION['temp_attachments'][$attachID])) |
|
487 | + if (empty($_SESSION['temp_attachments'][$attachID])) |
|
488 | 488 | $error = '$_SESSION[\'temp_attachments\'][$attachID]'; |
489 | 489 | |
490 | 490 | elseif (empty($attachID)) |
@@ -911,9 +911,9 @@ discard block |
||
911 | 911 | $attachContext = $attachLoaded[$attachID]; |
912 | 912 | |
913 | 913 | // Fix the url to point out to showAvatar(). |
914 | - $attachContext['href'] = $scripturl . '?action=dlattach;attach=' . $attachID .';type=preview'; |
|
914 | + $attachContext['href'] = $scripturl . '?action=dlattach;attach=' . $attachID . ';type=preview'; |
|
915 | 915 | |
916 | - $attachContext['link'] = '<a href="' . $scripturl . '?action=dlattach;attach=' . $attachID .';type=preview'. (empty($attachContext['is_image']) ? ';file' : '') .'">' . $smcFunc['htmlspecialchars']($attachContext['name']) . '</a>'; |
|
916 | + $attachContext['link'] = '<a href="' . $scripturl . '?action=dlattach;attach=' . $attachID . ';type=preview' . (empty($attachContext['is_image']) ? ';file' : '') . '">' . $smcFunc['htmlspecialchars']($attachContext['name']) . '</a>'; |
|
917 | 917 | |
918 | 918 | // Fix the thumbnail too, if the image has one. |
919 | 919 | if (!empty($attachContext['thumbnail']) && !empty($attachContext['thumbnail']['has_thumb'])) |
@@ -1078,7 +1078,7 @@ discard block |
||
1078 | 1078 | LEFT JOIN {db_prefix}attachments AS thumb ON (thumb.id_attach = a.id_thumb)') . ' |
1079 | 1079 | LEFT JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_msg) |
1080 | 1080 | WHERE a.attachment_type = {int:attachment_type} |
1081 | - '. (!empty($msgID) ? 'AND a.id_msg = {int:message_id}' : '') .'', |
|
1081 | + '. (!empty($msgID) ? 'AND a.id_msg = {int:message_id}' : '') . '', |
|
1082 | 1082 | array( |
1083 | 1083 | 'message_id' => $msgID, |
1084 | 1084 | 'attachment_type' => 0, |
@@ -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 | * Check if the current directory is still valid or not. |
@@ -28,22 +29,24 @@ discard block |
||
28 | 29 | global $boarddir, $modSettings, $context; |
29 | 30 | |
30 | 31 | // Not pretty, but since we don't want folders created for every post. It'll do unless a better solution can be found. |
31 | - if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'admin') |
|
32 | - $doit = true; |
|
33 | - elseif (empty($modSettings['automanage_attachments'])) |
|
34 | - return; |
|
35 | - elseif (!isset($_FILES)) |
|
36 | - return; |
|
37 | - elseif (isset($_FILES['attachment'])) |
|
38 | - foreach ($_FILES['attachment']['tmp_name'] as $dummy) |
|
32 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'admin') { |
|
33 | + $doit = true; |
|
34 | + } elseif (empty($modSettings['automanage_attachments'])) { |
|
35 | + return; |
|
36 | + } elseif (!isset($_FILES)) { |
|
37 | + return; |
|
38 | + } elseif (isset($_FILES['attachment'])) { |
|
39 | + foreach ($_FILES['attachment']['tmp_name'] as $dummy) |
|
39 | 40 | if (!empty($dummy)) |
40 | 41 | { |
41 | 42 | $doit = true; |
43 | + } |
|
42 | 44 | break; |
43 | 45 | } |
44 | 46 | |
45 | - if (!isset($doit)) |
|
46 | - return; |
|
47 | + if (!isset($doit)) { |
|
48 | + return; |
|
49 | + } |
|
47 | 50 | |
48 | 51 | $year = date('Y'); |
49 | 52 | $month = date('m'); |
@@ -55,21 +58,25 @@ discard block |
||
55 | 58 | |
56 | 59 | if (!empty($modSettings['attachment_basedirectories']) && !empty($modSettings['use_subdirectories_for_attachments'])) |
57 | 60 | { |
58 | - if (!is_array($modSettings['attachment_basedirectories'])) |
|
59 | - $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
61 | + if (!is_array($modSettings['attachment_basedirectories'])) { |
|
62 | + $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
63 | + } |
|
60 | 64 | $base_dir = array_search($modSettings['basedirectory_for_attachments'], $modSettings['attachment_basedirectories']); |
65 | + } else { |
|
66 | + $base_dir = 0; |
|
61 | 67 | } |
62 | - else |
|
63 | - $base_dir = 0; |
|
64 | 68 | |
65 | 69 | if ($modSettings['automanage_attachments'] == 1) |
66 | 70 | { |
67 | - if (!isset($modSettings['last_attachments_directory'])) |
|
68 | - $modSettings['last_attachments_directory'] = array(); |
|
69 | - if (!is_array($modSettings['last_attachments_directory'])) |
|
70 | - $modSettings['last_attachments_directory'] = smf_json_decode($modSettings['last_attachments_directory'], true); |
|
71 | - if (!isset($modSettings['last_attachments_directory'][$base_dir])) |
|
72 | - $modSettings['last_attachments_directory'][$base_dir] = 0; |
|
71 | + if (!isset($modSettings['last_attachments_directory'])) { |
|
72 | + $modSettings['last_attachments_directory'] = array(); |
|
73 | + } |
|
74 | + if (!is_array($modSettings['last_attachments_directory'])) { |
|
75 | + $modSettings['last_attachments_directory'] = smf_json_decode($modSettings['last_attachments_directory'], true); |
|
76 | + } |
|
77 | + if (!isset($modSettings['last_attachments_directory'][$base_dir])) { |
|
78 | + $modSettings['last_attachments_directory'][$base_dir] = 0; |
|
79 | + } |
|
73 | 80 | } |
74 | 81 | |
75 | 82 | $basedirectory = (!empty($modSettings['use_subdirectories_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : $boarddir); |
@@ -98,12 +105,14 @@ discard block |
||
98 | 105 | $updir = ''; |
99 | 106 | } |
100 | 107 | |
101 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
102 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
103 | - if (!in_array($updir, $modSettings['attachmentUploadDir']) && !empty($updir)) |
|
104 | - $outputCreation = automanage_attachments_create_directory($updir); |
|
105 | - elseif (in_array($updir, $modSettings['attachmentUploadDir'])) |
|
106 | - $outputCreation = true; |
|
108 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
109 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
110 | + } |
|
111 | + if (!in_array($updir, $modSettings['attachmentUploadDir']) && !empty($updir)) { |
|
112 | + $outputCreation = automanage_attachments_create_directory($updir); |
|
113 | + } elseif (in_array($updir, $modSettings['attachmentUploadDir'])) { |
|
114 | + $outputCreation = true; |
|
115 | + } |
|
107 | 116 | |
108 | 117 | if ($outputCreation) |
109 | 118 | { |
@@ -140,8 +149,9 @@ discard block |
||
140 | 149 | $count = count($tree); |
141 | 150 | |
142 | 151 | $directory = attachments_init_dir($tree, $count); |
143 | - if ($directory === false) |
|
144 | - return false; |
|
152 | + if ($directory === false) { |
|
153 | + return false; |
|
154 | + } |
|
145 | 155 | } |
146 | 156 | |
147 | 157 | $directory .= DIRECTORY_SEPARATOR . array_shift($tree); |
@@ -169,8 +179,9 @@ discard block |
||
169 | 179 | } |
170 | 180 | |
171 | 181 | // Everything seems fine...let's create the .htaccess |
172 | - if (!file_exists($directory . DIRECTORY_SEPARATOR . '.htaccess')) |
|
173 | - secureDirectory($updir, true); |
|
182 | + if (!file_exists($directory . DIRECTORY_SEPARATOR . '.htaccess')) { |
|
183 | + secureDirectory($updir, true); |
|
184 | + } |
|
174 | 185 | |
175 | 186 | $sep = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? '\/' : DIRECTORY_SEPARATOR; |
176 | 187 | $updir = rtrim($updir, $sep); |
@@ -202,8 +213,9 @@ discard block |
||
202 | 213 | { |
203 | 214 | global $modSettings, $boarddir; |
204 | 215 | |
205 | - if (!isset($modSettings['automanage_attachments']) || (!empty($modSettings['automanage_attachments']) && $modSettings['automanage_attachments'] != 1)) |
|
206 | - return; |
|
216 | + if (!isset($modSettings['automanage_attachments']) || (!empty($modSettings['automanage_attachments']) && $modSettings['automanage_attachments'] != 1)) { |
|
217 | + return; |
|
218 | + } |
|
207 | 219 | |
208 | 220 | $basedirectory = !empty($modSettings['use_subdirectories_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : $boarddir; |
209 | 221 | // Just to be sure: I don't want directory separators at the end |
@@ -215,13 +227,14 @@ discard block |
||
215 | 227 | { |
216 | 228 | $base_dir = array_search($modSettings['basedirectory_for_attachments'], $modSettings['attachment_basedirectories']); |
217 | 229 | $base_dir = !empty($modSettings['automanage_attachments']) ? $base_dir : 0; |
230 | + } else { |
|
231 | + $base_dir = 0; |
|
218 | 232 | } |
219 | - else |
|
220 | - $base_dir = 0; |
|
221 | 233 | |
222 | 234 | // Get the last attachment directory for that base directory |
223 | - if (empty($modSettings['last_attachments_directory'][$base_dir])) |
|
224 | - $modSettings['last_attachments_directory'][$base_dir] = 0; |
|
235 | + if (empty($modSettings['last_attachments_directory'][$base_dir])) { |
|
236 | + $modSettings['last_attachments_directory'][$base_dir] = 0; |
|
237 | + } |
|
225 | 238 | // And increment it. |
226 | 239 | $modSettings['last_attachments_directory'][$base_dir]++; |
227 | 240 | |
@@ -236,10 +249,10 @@ discard block |
||
236 | 249 | $modSettings['last_attachments_directory'] = smf_json_decode($modSettings['last_attachments_directory'], true); |
237 | 250 | |
238 | 251 | return true; |
252 | + } else { |
|
253 | + return false; |
|
254 | + } |
|
239 | 255 | } |
240 | - else |
|
241 | - return false; |
|
242 | -} |
|
243 | 256 | |
244 | 257 | /** |
245 | 258 | * Split a path into a list of all directories and subdirectories |
@@ -257,12 +270,13 @@ discard block |
||
257 | 270 | * in Windows we need to explode for both \ and / |
258 | 271 | * while in linux should be safe to explode only for / (aka DIRECTORY_SEPARATOR) |
259 | 272 | */ |
260 | - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') |
|
261 | - $tree = preg_split('#[\\\/]#', $directory); |
|
262 | - else |
|
273 | + if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
|
274 | + $tree = preg_split('#[\\\/]#', $directory); |
|
275 | + } else |
|
263 | 276 | { |
264 | - if (substr($directory, 0, 1) != DIRECTORY_SEPARATOR) |
|
265 | - return false; |
|
277 | + if (substr($directory, 0, 1) != DIRECTORY_SEPARATOR) { |
|
278 | + return false; |
|
279 | + } |
|
266 | 280 | |
267 | 281 | $tree = explode(DIRECTORY_SEPARATOR, trim($directory,DIRECTORY_SEPARATOR)); |
268 | 282 | } |
@@ -286,10 +300,11 @@ discard block |
||
286 | 300 | //Better be sure that the first part of the path is actually a drive letter... |
287 | 301 | //...even if, I should check this in the admin page...isn't it? |
288 | 302 | //...NHAAA Let's leave space for users' complains! :P |
289 | - if (preg_match('/^[a-z]:$/i',$tree[0])) |
|
290 | - $directory = array_shift($tree); |
|
291 | - else |
|
292 | - return false; |
|
303 | + if (preg_match('/^[a-z]:$/i',$tree[0])) { |
|
304 | + $directory = array_shift($tree); |
|
305 | + } else { |
|
306 | + return false; |
|
307 | + } |
|
293 | 308 | |
294 | 309 | $count--; |
295 | 310 | } |
@@ -304,18 +319,20 @@ discard block |
||
304 | 319 | global $context, $modSettings, $smcFunc, $txt, $user_info; |
305 | 320 | |
306 | 321 | // Make sure we're uploading to the right place. |
307 | - if (!empty($modSettings['automanage_attachments'])) |
|
308 | - automanage_attachments_check_directory(); |
|
322 | + if (!empty($modSettings['automanage_attachments'])) { |
|
323 | + automanage_attachments_check_directory(); |
|
324 | + } |
|
309 | 325 | |
310 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
311 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
326 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
327 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
328 | + } |
|
312 | 329 | |
313 | 330 | $context['attach_dir'] = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
314 | 331 | |
315 | 332 | // Is the attachments folder actualy there? |
316 | - if (!empty($context['dir_creation_error'])) |
|
317 | - $initial_error = $context['dir_creation_error']; |
|
318 | - elseif (!is_dir($context['attach_dir'])) |
|
333 | + if (!empty($context['dir_creation_error'])) { |
|
334 | + $initial_error = $context['dir_creation_error']; |
|
335 | + } elseif (!is_dir($context['attach_dir'])) |
|
319 | 336 | { |
320 | 337 | $initial_error = 'attach_folder_warning'; |
321 | 338 | log_error(sprintf($txt['attach_folder_admin_warning'], $context['attach_dir']), 'critical'); |
@@ -338,12 +355,12 @@ discard block |
||
338 | 355 | ); |
339 | 356 | list ($context['attachments']['quantity'], $context['attachments']['total_size']) = $smcFunc['db_fetch_row']($request); |
340 | 357 | $smcFunc['db_free_result']($request); |
341 | - } |
|
342 | - else |
|
343 | - $context['attachments'] = array( |
|
358 | + } else { |
|
359 | + $context['attachments'] = array( |
|
344 | 360 | 'quantity' => 0, |
345 | 361 | 'total_size' => 0, |
346 | 362 | ); |
363 | + } |
|
347 | 364 | } |
348 | 365 | |
349 | 366 | // Hmm. There are still files in session. |
@@ -353,39 +370,44 @@ discard block |
||
353 | 370 | // Let's try to keep them. But... |
354 | 371 | $ignore_temp = true; |
355 | 372 | // If new files are being added. We can't ignore those |
356 | - foreach ($_FILES['attachment']['tmp_name'] as $dummy) |
|
357 | - if (!empty($dummy)) |
|
373 | + foreach ($_FILES['attachment']['tmp_name'] as $dummy) { |
|
374 | + if (!empty($dummy)) |
|
358 | 375 | { |
359 | 376 | $ignore_temp = false; |
377 | + } |
|
360 | 378 | break; |
361 | 379 | } |
362 | 380 | |
363 | 381 | // Need to make space for the new files. So, bye bye. |
364 | 382 | if (!$ignore_temp) |
365 | 383 | { |
366 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
367 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
384 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) { |
|
385 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
368 | 386 | unlink($attachment['tmp_name']); |
387 | + } |
|
369 | 388 | |
370 | 389 | $context['we_are_history'] = $txt['error_temp_attachments_flushed']; |
371 | 390 | $_SESSION['temp_attachments'] = array(); |
372 | 391 | } |
373 | 392 | } |
374 | 393 | |
375 | - if (!isset($_FILES['attachment']['name'])) |
|
376 | - $_FILES['attachment']['tmp_name'] = array(); |
|
394 | + if (!isset($_FILES['attachment']['name'])) { |
|
395 | + $_FILES['attachment']['tmp_name'] = array(); |
|
396 | + } |
|
377 | 397 | |
378 | - if (!isset($_SESSION['temp_attachments'])) |
|
379 | - $_SESSION['temp_attachments'] = array(); |
|
398 | + if (!isset($_SESSION['temp_attachments'])) { |
|
399 | + $_SESSION['temp_attachments'] = array(); |
|
400 | + } |
|
380 | 401 | |
381 | 402 | // Remember where we are at. If it's anywhere at all. |
382 | - if (!$ignore_temp) |
|
383 | - $_SESSION['temp_attachments']['post'] = array( |
|
403 | + if (!$ignore_temp) { |
|
404 | + $_SESSION['temp_attachments']['post'] = array( |
|
384 | 405 | 'msg' => !empty($_REQUEST['msg']) ? $_REQUEST['msg'] : 0, |
385 | 406 | 'last_msg' => !empty($_REQUEST['last_msg']) ? $_REQUEST['last_msg'] : 0, |
386 | 407 | 'topic' => !empty($topic) ? $topic : 0, |
387 | 408 | 'board' => !empty($board) ? $board : 0, |
388 | 409 | ); |
410 | + } |
|
389 | 411 | |
390 | 412 | // If we have an initial error, lets just display it. |
391 | 413 | if (!empty($initial_error)) |
@@ -393,9 +415,10 @@ discard block |
||
393 | 415 | $_SESSION['temp_attachments']['initial_error'] = $initial_error; |
394 | 416 | |
395 | 417 | // And delete the files 'cos they ain't going nowhere. |
396 | - foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
|
397 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
418 | + foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) { |
|
419 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
398 | 420 | unlink($_FILES['attachment']['tmp_name'][$n]); |
421 | + } |
|
399 | 422 | |
400 | 423 | $_FILES['attachment']['tmp_name'] = array(); |
401 | 424 | } |
@@ -403,21 +426,24 @@ discard block |
||
403 | 426 | // Loop through $_FILES['attachment'] array and move each file to the current attachments folder. |
404 | 427 | foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
405 | 428 | { |
406 | - if ($_FILES['attachment']['name'][$n] == '') |
|
407 | - continue; |
|
429 | + if ($_FILES['attachment']['name'][$n] == '') { |
|
430 | + continue; |
|
431 | + } |
|
408 | 432 | |
409 | 433 | // First, let's first check for PHP upload errors. |
410 | 434 | $errors = array(); |
411 | 435 | if (!empty($_FILES['attachment']['error'][$n])) |
412 | 436 | { |
413 | - if ($_FILES['attachment']['error'][$n] == 2) |
|
414 | - $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
415 | - elseif ($_FILES['attachment']['error'][$n] == 6) |
|
416 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
417 | - else |
|
418 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
419 | - if (empty($errors)) |
|
420 | - $errors[] = 'attach_php_error'; |
|
437 | + if ($_FILES['attachment']['error'][$n] == 2) { |
|
438 | + $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
439 | + } elseif ($_FILES['attachment']['error'][$n] == 6) { |
|
440 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
441 | + } else { |
|
442 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
443 | + } |
|
444 | + if (empty($errors)) { |
|
445 | + $errors[] = 'attach_php_error'; |
|
446 | + } |
|
421 | 447 | } |
422 | 448 | |
423 | 449 | // Try to move and rename the file before doing any more checks on it. |
@@ -435,16 +461,16 @@ discard block |
||
435 | 461 | ); |
436 | 462 | |
437 | 463 | // Move the file to the attachments folder with a temp name for now. |
438 | - if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) |
|
439 | - smf_chmod($destName, 0644); |
|
440 | - else |
|
464 | + if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) { |
|
465 | + smf_chmod($destName, 0644); |
|
466 | + } else |
|
441 | 467 | { |
442 | 468 | $_SESSION['temp_attachments'][$attachID]['errors'][] = 'attach_timeout'; |
443 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
444 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
469 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
470 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
471 | + } |
|
445 | 472 | } |
446 | - } |
|
447 | - else |
|
473 | + } else |
|
448 | 474 | { |
449 | 475 | $_SESSION['temp_attachments'][$attachID] = array( |
450 | 476 | 'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])), |
@@ -452,12 +478,14 @@ discard block |
||
452 | 478 | 'errors' => $errors, |
453 | 479 | ); |
454 | 480 | |
455 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
456 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
481 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
482 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
483 | + } |
|
457 | 484 | } |
458 | 485 | // If there's no errors to this point. We still do need to apply some additional checks before we are finished. |
459 | - if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) |
|
460 | - attachmentChecks($attachID); |
|
486 | + if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) { |
|
487 | + attachmentChecks($attachID); |
|
488 | + } |
|
461 | 489 | } |
462 | 490 | // Mod authors, finally a hook to hang an alternate attachment upload system upon |
463 | 491 | // Upload to the current attachment folder with the file name $attachID or 'post_tmp_' . $user_info['id'] . '_' . md5(mt_rand()) |
@@ -484,21 +512,20 @@ discard block |
||
484 | 512 | global $modSettings, $context, $sourcedir, $smcFunc; |
485 | 513 | |
486 | 514 | // No data or missing data .... Not necessarily needed, but in case a mod author missed something. |
487 | - if ( empty($_SESSION['temp_attachments'][$attachID])) |
|
488 | - $error = '$_SESSION[\'temp_attachments\'][$attachID]'; |
|
489 | - |
|
490 | - elseif (empty($attachID)) |
|
491 | - $error = '$attachID'; |
|
492 | - |
|
493 | - elseif (empty($context['attachments'])) |
|
494 | - $error = '$context[\'attachments\']'; |
|
495 | - |
|
496 | - elseif (empty($context['attach_dir'])) |
|
497 | - $error = '$context[\'attach_dir\']'; |
|
515 | + if ( empty($_SESSION['temp_attachments'][$attachID])) { |
|
516 | + $error = '$_SESSION[\'temp_attachments\'][$attachID]'; |
|
517 | + } elseif (empty($attachID)) { |
|
518 | + $error = '$attachID'; |
|
519 | + } elseif (empty($context['attachments'])) { |
|
520 | + $error = '$context[\'attachments\']'; |
|
521 | + } elseif (empty($context['attach_dir'])) { |
|
522 | + $error = '$context[\'attach_dir\']'; |
|
523 | + } |
|
498 | 524 | |
499 | 525 | // Let's get their attention. |
500 | - if (!empty($error)) |
|
501 | - fatal_lang_error('attach_check_nag', 'debug', array($error)); |
|
526 | + if (!empty($error)) { |
|
527 | + fatal_lang_error('attach_check_nag', 'debug', array($error)); |
|
528 | + } |
|
502 | 529 | |
503 | 530 | // Just in case this slipped by the first checks, we stop it here and now |
504 | 531 | if ($_SESSION['temp_attachments'][$attachID]['size'] == 0) |
@@ -527,8 +554,9 @@ discard block |
||
527 | 554 | $size = @getimagesize($_SESSION['temp_attachments'][$attachID]['tmp_name']); |
528 | 555 | if (!(empty($size)) && ($size[2] != $old_format)) |
529 | 556 | { |
530 | - if (isset($context['validImageTypes'][$size[2]])) |
|
531 | - $_SESSION['temp_attachments'][$attachID]['type'] = 'image/' . $context['validImageTypes'][$size[2]]; |
|
557 | + if (isset($context['validImageTypes'][$size[2]])) { |
|
558 | + $_SESSION['temp_attachments'][$attachID]['type'] = 'image/' . $context['validImageTypes'][$size[2]]; |
|
559 | + } |
|
532 | 560 | } |
533 | 561 | } |
534 | 562 | } |
@@ -582,42 +610,48 @@ discard block |
||
582 | 610 | // Or, let the user know that it ain't gonna happen. |
583 | 611 | else |
584 | 612 | { |
585 | - if (isset($context['dir_creation_error'])) |
|
586 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = $context['dir_creation_error']; |
|
587 | - else |
|
588 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space'; |
|
613 | + if (isset($context['dir_creation_error'])) { |
|
614 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = $context['dir_creation_error']; |
|
615 | + } else { |
|
616 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space'; |
|
617 | + } |
|
589 | 618 | } |
619 | + } else { |
|
620 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space'; |
|
590 | 621 | } |
591 | - else |
|
592 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space'; |
|
593 | 622 | } |
594 | 623 | } |
595 | 624 | |
596 | 625 | // Is the file too big? |
597 | 626 | $context['attachments']['total_size'] += $_SESSION['temp_attachments'][$attachID]['size']; |
598 | - if (!empty($modSettings['attachmentSizeLimit']) && $_SESSION['temp_attachments'][$attachID]['size'] > $modSettings['attachmentSizeLimit'] * 1024) |
|
599 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = array('file_too_big', array(comma_format($modSettings['attachmentSizeLimit'], 0))); |
|
627 | + if (!empty($modSettings['attachmentSizeLimit']) && $_SESSION['temp_attachments'][$attachID]['size'] > $modSettings['attachmentSizeLimit'] * 1024) { |
|
628 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = array('file_too_big', array(comma_format($modSettings['attachmentSizeLimit'], 0))); |
|
629 | + } |
|
600 | 630 | |
601 | 631 | // Check the total upload size for this post... |
602 | - if (!empty($modSettings['attachmentPostLimit']) && $context['attachments']['total_size'] > $modSettings['attachmentPostLimit'] * 1024) |
|
603 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = array('attach_max_total_file_size', array(comma_format($modSettings['attachmentPostLimit'], 0), comma_format($modSettings['attachmentPostLimit'] - (($context['attachments']['total_size'] - $_SESSION['temp_attachments'][$attachID]['size']) / 1024), 0))); |
|
632 | + if (!empty($modSettings['attachmentPostLimit']) && $context['attachments']['total_size'] > $modSettings['attachmentPostLimit'] * 1024) { |
|
633 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = array('attach_max_total_file_size', array(comma_format($modSettings['attachmentPostLimit'], 0), comma_format($modSettings['attachmentPostLimit'] - (($context['attachments']['total_size'] - $_SESSION['temp_attachments'][$attachID]['size']) / 1024), 0))); |
|
634 | + } |
|
604 | 635 | |
605 | 636 | // Have we reached the maximum number of files we are allowed? |
606 | 637 | $context['attachments']['quantity']++; |
607 | 638 | |
608 | 639 | // Set a max limit if none exists |
609 | - if (empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] >= 50) |
|
610 | - $modSettings['attachmentNumPerPostLimit'] = 50; |
|
640 | + if (empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] >= 50) { |
|
641 | + $modSettings['attachmentNumPerPostLimit'] = 50; |
|
642 | + } |
|
611 | 643 | |
612 | - if (!empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] > $modSettings['attachmentNumPerPostLimit']) |
|
613 | - $_SESSION['temp_attachments'][$attachID]['errors'][] = array('attachments_limit_per_post', array($modSettings['attachmentNumPerPostLimit'])); |
|
644 | + if (!empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] > $modSettings['attachmentNumPerPostLimit']) { |
|
645 | + $_SESSION['temp_attachments'][$attachID]['errors'][] = array('attachments_limit_per_post', array($modSettings['attachmentNumPerPostLimit'])); |
|
646 | + } |
|
614 | 647 | |
615 | 648 | // File extension check |
616 | 649 | if (!empty($modSettings['attachmentCheckExtensions'])) |
617 | 650 | { |
618 | 651 | $allowed = explode(',', strtolower($modSettings['attachmentExtensions'])); |
619 | - foreach ($allowed as $k => $dummy) |
|
620 | - $allowed[$k] = trim($dummy); |
|
652 | + foreach ($allowed as $k => $dummy) { |
|
653 | + $allowed[$k] = trim($dummy); |
|
654 | + } |
|
621 | 655 | |
622 | 656 | if (!in_array(strtolower(substr(strrchr($_SESSION['temp_attachments'][$attachID]['name'], '.'), 1)), $allowed)) |
623 | 657 | { |
@@ -629,10 +663,12 @@ discard block |
||
629 | 663 | // Undo the math if there's an error |
630 | 664 | if (!empty($_SESSION['temp_attachments'][$attachID]['errors'])) |
631 | 665 | { |
632 | - if (isset($context['dir_size'])) |
|
633 | - $context['dir_size'] -= $_SESSION['temp_attachments'][$attachID]['size']; |
|
634 | - if (isset($context['dir_files'])) |
|
635 | - $context['dir_files']--; |
|
666 | + if (isset($context['dir_size'])) { |
|
667 | + $context['dir_size'] -= $_SESSION['temp_attachments'][$attachID]['size']; |
|
668 | + } |
|
669 | + if (isset($context['dir_files'])) { |
|
670 | + $context['dir_files']--; |
|
671 | + } |
|
636 | 672 | $context['attachments']['total_size'] -= $_SESSION['temp_attachments'][$attachID]['size']; |
637 | 673 | $context['attachments']['quantity']--; |
638 | 674 | return false; |
@@ -664,12 +700,14 @@ discard block |
||
664 | 700 | if (empty($attachmentOptions['mime_type']) && $attachmentOptions['width']) |
665 | 701 | { |
666 | 702 | // Got a proper mime type? |
667 | - if (!empty($size['mime'])) |
|
668 | - $attachmentOptions['mime_type'] = $size['mime']; |
|
703 | + if (!empty($size['mime'])) { |
|
704 | + $attachmentOptions['mime_type'] = $size['mime']; |
|
705 | + } |
|
669 | 706 | |
670 | 707 | // Otherwise a valid one? |
671 | - elseif (isset($context['validImageTypes'][$size[2]])) |
|
672 | - $attachmentOptions['mime_type'] = 'image/' . $context['validImageTypes'][$size[2]]; |
|
708 | + elseif (isset($context['validImageTypes'][$size[2]])) { |
|
709 | + $attachmentOptions['mime_type'] = 'image/' . $context['validImageTypes'][$size[2]]; |
|
710 | + } |
|
673 | 711 | } |
674 | 712 | |
675 | 713 | // It is possible we might have a MIME type that isn't actually an image but still have a size. |
@@ -681,15 +719,17 @@ discard block |
||
681 | 719 | } |
682 | 720 | |
683 | 721 | // Get the hash if no hash has been given yet. |
684 | - if (empty($attachmentOptions['file_hash'])) |
|
685 | - $attachmentOptions['file_hash'] = getAttachmentFilename($attachmentOptions['name'], false, null, true); |
|
722 | + if (empty($attachmentOptions['file_hash'])) { |
|
723 | + $attachmentOptions['file_hash'] = getAttachmentFilename($attachmentOptions['name'], false, null, true); |
|
724 | + } |
|
686 | 725 | |
687 | 726 | // Assuming no-one set the extension let's take a look at it. |
688 | 727 | if (empty($attachmentOptions['fileext'])) |
689 | 728 | { |
690 | 729 | $attachmentOptions['fileext'] = strtolower(strrpos($attachmentOptions['name'], '.') !== false ? substr($attachmentOptions['name'], strrpos($attachmentOptions['name'], '.') + 1) : ''); |
691 | - if (strlen($attachmentOptions['fileext']) > 8 || '.' . $attachmentOptions['fileext'] == $attachmentOptions['name']) |
|
692 | - $attachmentOptions['fileext'] = ''; |
|
730 | + if (strlen($attachmentOptions['fileext']) > 8 || '.' . $attachmentOptions['fileext'] == $attachmentOptions['name']) { |
|
731 | + $attachmentOptions['fileext'] = ''; |
|
732 | + } |
|
693 | 733 | } |
694 | 734 | |
695 | 735 | // Last chance to change stuff! |
@@ -698,8 +738,9 @@ discard block |
||
698 | 738 | // Make sure the folder is valid... |
699 | 739 | $tmp = is_array($modSettings['attachmentUploadDir']) ? $modSettings['attachmentUploadDir'] : smf_json_decode($modSettings['attachmentUploadDir'], true); |
700 | 740 | $folders = array_keys($tmp); |
701 | - if (empty($attachmentOptions['id_folder']) || !in_array($attachmentOptions['id_folder'], $folders)) |
|
702 | - $attachmentOptions['id_folder'] = $modSettings['currentAttachmentUploadDir']; |
|
741 | + if (empty($attachmentOptions['id_folder']) || !in_array($attachmentOptions['id_folder'], $folders)) { |
|
742 | + $attachmentOptions['id_folder'] = $modSettings['currentAttachmentUploadDir']; |
|
743 | + } |
|
703 | 744 | |
704 | 745 | $smcFunc['db_insert']('', |
705 | 746 | '{db_prefix}attachments', |
@@ -730,8 +771,8 @@ discard block |
||
730 | 771 | rename($attachmentOptions['tmp_name'], $attachmentOptions['destination']); |
731 | 772 | |
732 | 773 | // If it's not approved then add to the approval queue. |
733 | - if (!$attachmentOptions['approved']) |
|
734 | - $smcFunc['db_insert']('', |
|
774 | + if (!$attachmentOptions['approved']) { |
|
775 | + $smcFunc['db_insert']('', |
|
735 | 776 | '{db_prefix}approval_queue', |
736 | 777 | array( |
737 | 778 | 'id_attach' => 'int', 'id_msg' => 'int', |
@@ -741,9 +782,11 @@ discard block |
||
741 | 782 | ), |
742 | 783 | array() |
743 | 784 | ); |
785 | + } |
|
744 | 786 | |
745 | - if (empty($modSettings['attachmentThumbnails']) || (empty($attachmentOptions['width']) && empty($attachmentOptions['height']))) |
|
746 | - return true; |
|
787 | + if (empty($modSettings['attachmentThumbnails']) || (empty($attachmentOptions['width']) && empty($attachmentOptions['height']))) { |
|
788 | + return true; |
|
789 | + } |
|
747 | 790 | |
748 | 791 | // Like thumbnails, do we? |
749 | 792 | if (!empty($modSettings['attachmentThumbWidth']) && !empty($modSettings['attachmentThumbHeight']) && ($attachmentOptions['width'] > $modSettings['attachmentThumbWidth'] || $attachmentOptions['height'] > $modSettings['attachmentThumbHeight'])) |
@@ -754,13 +797,15 @@ discard block |
||
754 | 797 | $size = @getimagesize($attachmentOptions['destination'] . '_thumb'); |
755 | 798 | list ($thumb_width, $thumb_height) = $size; |
756 | 799 | |
757 | - if (!empty($size['mime'])) |
|
758 | - $thumb_mime = $size['mime']; |
|
759 | - elseif (isset($context['validImageTypes'][$size[2]])) |
|
760 | - $thumb_mime = 'image/' . $context['validImageTypes'][$size[2]]; |
|
800 | + if (!empty($size['mime'])) { |
|
801 | + $thumb_mime = $size['mime']; |
|
802 | + } elseif (isset($context['validImageTypes'][$size[2]])) { |
|
803 | + $thumb_mime = 'image/' . $context['validImageTypes'][$size[2]]; |
|
804 | + } |
|
761 | 805 | // Lord only knows how this happened... |
762 | - else |
|
763 | - $thumb_mime = ''; |
|
806 | + else { |
|
807 | + $thumb_mime = ''; |
|
808 | + } |
|
764 | 809 | |
765 | 810 | $thumb_filename = $attachmentOptions['name'] . '_thumb'; |
766 | 811 | $thumb_size = filesize($attachmentOptions['destination'] . '_thumb'); |
@@ -840,15 +885,17 @@ discard block |
||
840 | 885 | global $smcFunc; |
841 | 886 | |
842 | 887 | // Oh, come on! |
843 | - if (empty($attachIDs) || empty($msgID)) |
|
844 | - return false; |
|
888 | + if (empty($attachIDs) || empty($msgID)) { |
|
889 | + return false; |
|
890 | + } |
|
845 | 891 | |
846 | 892 | // "I see what is right and approve, but I do what is wrong." |
847 | 893 | call_integration_hook('integrate_assign_attachments', array(&$attachIDs, &$msgID)); |
848 | 894 | |
849 | 895 | // One last check |
850 | - if (empty($attachIDs)) |
|
851 | - return false; |
|
896 | + if (empty($attachIDs)) { |
|
897 | + return false; |
|
898 | + } |
|
852 | 899 | |
853 | 900 | // Perform. |
854 | 901 | $smcFunc['db_query']('', ' |
@@ -880,8 +927,9 @@ discard block |
||
880 | 927 | $externalParse = false; |
881 | 928 | |
882 | 929 | // Meh... |
883 | - if (empty($attachID)) |
|
884 | - return 'attachments_no_data_loaded'; |
|
930 | + if (empty($attachID)) { |
|
931 | + return 'attachments_no_data_loaded'; |
|
932 | + } |
|
885 | 933 | |
886 | 934 | // Make it easy. |
887 | 935 | $msgID = !empty($_REQUEST['msg']) ? (int) $_REQUEST['msg'] : 0; |
@@ -890,20 +938,23 @@ discard block |
||
890 | 938 | $externalParse = call_integration_hook('integrate_pre_parseAttachBBC', array($attachID, $msgID)); |
891 | 939 | |
892 | 940 | // "I am innocent of the blood of this just person: see ye to it." |
893 | - if (!empty($externalParse) && (is_string($externalParse) || is_array($externalParse))) |
|
894 | - return $externalParse; |
|
941 | + if (!empty($externalParse) && (is_string($externalParse) || is_array($externalParse))) { |
|
942 | + return $externalParse; |
|
943 | + } |
|
895 | 944 | |
896 | 945 | //Are attachments enable? |
897 | - if (empty($modSettings['attachmentEnable'])) |
|
898 | - return 'attachments_not_enable'; |
|
946 | + if (empty($modSettings['attachmentEnable'])) { |
|
947 | + return 'attachments_not_enable'; |
|
948 | + } |
|
899 | 949 | |
900 | 950 | // Previewing much? no msg ID has been set yet. |
901 | 951 | if (!empty($context['preview_message'])) |
902 | 952 | { |
903 | 953 | $allAttachments = getAttachsByMsg(0); |
904 | 954 | |
905 | - if (empty($allAttachments[0][$attachID])) |
|
906 | - return 'attachments_no_data_loaded'; |
|
955 | + if (empty($allAttachments[0][$attachID])) { |
|
956 | + return 'attachments_no_data_loaded'; |
|
957 | + } |
|
907 | 958 | |
908 | 959 | $attachContext = $allAttachments[0][$attachID]; |
909 | 960 | $attachLoaded = loadAttachmentContext(0, $allAttachments); |
@@ -916,57 +967,66 @@ discard block |
||
916 | 967 | $attachContext['link'] = '<a href="' . $scripturl . '?action=dlattach;attach=' . $attachID .';type=preview'. (empty($attachContext['is_image']) ? ';file' : '') .'">' . $smcFunc['htmlspecialchars']($attachContext['name']) . '</a>'; |
917 | 968 | |
918 | 969 | // Fix the thumbnail too, if the image has one. |
919 | - if (!empty($attachContext['thumbnail']) && !empty($attachContext['thumbnail']['has_thumb'])) |
|
920 | - $attachContext['thumbnail']['href'] = $scripturl . '?action=dlattach;attach=' . $attachContext['thumbnail']['id'] . ';image;type=preview'; |
|
970 | + if (!empty($attachContext['thumbnail']) && !empty($attachContext['thumbnail']['has_thumb'])) { |
|
971 | + $attachContext['thumbnail']['href'] = $scripturl . '?action=dlattach;attach=' . $attachContext['thumbnail']['id'] . ';image;type=preview'; |
|
972 | + } |
|
921 | 973 | |
922 | 974 | return $attachContext; |
923 | 975 | } |
924 | 976 | |
925 | 977 | // There is always the chance someone else has already done our dirty work... |
926 | 978 | // If so, all pertinent checks were already done. Hopefully... |
927 | - if (!empty($context['current_attachments']) && !empty($context['current_attachments'][$attachID])) |
|
928 | - return $context['current_attachments'][$attachID]; |
|
979 | + if (!empty($context['current_attachments']) && !empty($context['current_attachments'][$attachID])) { |
|
980 | + return $context['current_attachments'][$attachID]; |
|
981 | + } |
|
929 | 982 | |
930 | 983 | // If we are lucky enough to be in $board's scope then check it! |
931 | - if (!empty($board) && !allowedTo('view_attachments', $board)) |
|
932 | - return 'attachments_not_allowed_to_see'; |
|
984 | + if (!empty($board) && !allowedTo('view_attachments', $board)) { |
|
985 | + return 'attachments_not_allowed_to_see'; |
|
986 | + } |
|
933 | 987 | |
934 | 988 | // Get the message info associated with this particular attach ID. |
935 | 989 | $attachInfo = getAttachMsgInfo($attachID); |
936 | 990 | |
937 | 991 | // There is always the chance this attachment no longer exists or isn't associated to a message anymore... |
938 | - if (empty($attachInfo) || empty($attachInfo['msg'])) |
|
939 | - return 'attachments_no_msg_associated'; |
|
992 | + if (empty($attachInfo) || empty($attachInfo['msg'])) { |
|
993 | + return 'attachments_no_msg_associated'; |
|
994 | + } |
|
940 | 995 | |
941 | 996 | // Hold it! got the info now check if you can see this attachment. |
942 | - if (!allowedTo('view_attachments', $attachInfo['board'])) |
|
943 | - return 'attachments_not_allowed_to_see'; |
|
997 | + if (!allowedTo('view_attachments', $attachInfo['board'])) { |
|
998 | + return 'attachments_not_allowed_to_see'; |
|
999 | + } |
|
944 | 1000 | |
945 | 1001 | $allAttachments = getAttachsByMsg($attachInfo['msg']); |
946 | 1002 | $attachContext = $allAttachments[$attachInfo['msg']][$attachID]; |
947 | 1003 | |
948 | 1004 | // No point in keep going further. |
949 | - if (!allowedTo('view_attachments', $attachContext['board'])) |
|
950 | - return 'attachments_not_allowed_to_see'; |
|
1005 | + if (!allowedTo('view_attachments', $attachContext['board'])) { |
|
1006 | + return 'attachments_not_allowed_to_see'; |
|
1007 | + } |
|
951 | 1008 | |
952 | 1009 | // Load this particular attach's context. |
953 | - if (!empty($attachContext)) |
|
954 | - $attachLoaded = loadAttachmentContext($attachContext['id_msg'], $allAttachments); |
|
1010 | + if (!empty($attachContext)) { |
|
1011 | + $attachLoaded = loadAttachmentContext($attachContext['id_msg'], $allAttachments); |
|
1012 | + } |
|
955 | 1013 | |
956 | 1014 | // One last check, you know, gotta be paranoid... |
957 | - else |
|
958 | - return 'attachments_no_data_loaded'; |
|
1015 | + else { |
|
1016 | + return 'attachments_no_data_loaded'; |
|
1017 | + } |
|
959 | 1018 | |
960 | 1019 | // This is the last "if" I promise! |
961 | - if (empty($attachLoaded)) |
|
962 | - return 'attachments_no_data_loaded'; |
|
963 | - |
|
964 | - else |
|
965 | - $attachContext = $attachLoaded[$attachID]; |
|
1020 | + if (empty($attachLoaded)) { |
|
1021 | + return 'attachments_no_data_loaded'; |
|
1022 | + } else { |
|
1023 | + $attachContext = $attachLoaded[$attachID]; |
|
1024 | + } |
|
966 | 1025 | |
967 | 1026 | // You may or may not want to show this under the post. |
968 | - if (!empty($modSettings['dont_show_attach_under_post']) && !isset($context['show_attach_under_post'][$attachID])) |
|
969 | - $context['show_attach_under_post'][$attachID] = $attachID; |
|
1027 | + if (!empty($modSettings['dont_show_attach_under_post']) && !isset($context['show_attach_under_post'][$attachID])) { |
|
1028 | + $context['show_attach_under_post'][$attachID] = $attachID; |
|
1029 | + } |
|
970 | 1030 | |
971 | 1031 | // Last minute changes? |
972 | 1032 | call_integration_hook('integrate_post_parseAttachBBC', array(&$attachContext)); |
@@ -986,8 +1046,9 @@ discard block |
||
986 | 1046 | { |
987 | 1047 | global $smcFunc, $modSettings; |
988 | 1048 | |
989 | - if (empty($attachIDs)) |
|
990 | - return array(); |
|
1049 | + if (empty($attachIDs)) { |
|
1050 | + return array(); |
|
1051 | + } |
|
991 | 1052 | |
992 | 1053 | $return = array(); |
993 | 1054 | |
@@ -1003,11 +1064,12 @@ discard block |
||
1003 | 1064 | ) |
1004 | 1065 | ); |
1005 | 1066 | |
1006 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
1007 | - return array(); |
|
1067 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
1068 | + return array(); |
|
1069 | + } |
|
1008 | 1070 | |
1009 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1010 | - $return[$row['id_attach']] = array( |
|
1071 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1072 | + $return[$row['id_attach']] = array( |
|
1011 | 1073 | 'name' => $smcFunc['htmlspecialchars']($row['filename']), |
1012 | 1074 | 'size' => $row['size'], |
1013 | 1075 | 'attachID' => $row['id_attach'], |
@@ -1016,6 +1078,7 @@ discard block |
||
1016 | 1078 | 'mime_type' => $row['mime_type'], |
1017 | 1079 | 'thumb' => $row['id_thumb'], |
1018 | 1080 | ); |
1081 | + } |
|
1019 | 1082 | $smcFunc['db_free_result']($request); |
1020 | 1083 | |
1021 | 1084 | return $return; |
@@ -1032,8 +1095,9 @@ discard block |
||
1032 | 1095 | { |
1033 | 1096 | global $smcFunc; |
1034 | 1097 | |
1035 | - if (empty($attachID)) |
|
1036 | - return array(); |
|
1098 | + if (empty($attachID)) { |
|
1099 | + return array(); |
|
1100 | + } |
|
1037 | 1101 | |
1038 | 1102 | $request = $smcFunc['db_query']('', ' |
1039 | 1103 | SELECT a.id_msg AS msg, m.id_topic AS topic, m.id_board AS board |
@@ -1046,8 +1110,9 @@ discard block |
||
1046 | 1110 | ) |
1047 | 1111 | ); |
1048 | 1112 | |
1049 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
1050 | - return array(); |
|
1113 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
1114 | + return array(); |
|
1115 | + } |
|
1051 | 1116 | |
1052 | 1117 | $row = $smcFunc['db_fetch_assoc']($request); |
1053 | 1118 | $smcFunc['db_free_result']($request); |
@@ -1088,8 +1153,9 @@ discard block |
||
1088 | 1153 | $temp = array(); |
1089 | 1154 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1090 | 1155 | { |
1091 | - if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) |
|
1092 | - continue; |
|
1156 | + if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) { |
|
1157 | + continue; |
|
1158 | + } |
|
1093 | 1159 | |
1094 | 1160 | $temp[$row['id_attach']] = $row; |
1095 | 1161 | } |
@@ -1118,8 +1184,9 @@ discard block |
||
1118 | 1184 | { |
1119 | 1185 | global $modSettings, $txt, $scripturl, $sourcedir, $smcFunc; |
1120 | 1186 | |
1121 | - if (empty($attachments) || empty($attachments[$id_msg])) |
|
1122 | - return array(); |
|
1187 | + if (empty($attachments) || empty($attachments[$id_msg])) { |
|
1188 | + return array(); |
|
1189 | + } |
|
1123 | 1190 | |
1124 | 1191 | // Set up the attachment info - based on code by Meriadoc. |
1125 | 1192 | $attachmentData = array(); |
@@ -1143,11 +1210,13 @@ discard block |
||
1143 | 1210 | ); |
1144 | 1211 | |
1145 | 1212 | // If something is unapproved we'll note it so we can sort them. |
1146 | - if (!$attachment['approved']) |
|
1147 | - $have_unapproved = true; |
|
1213 | + if (!$attachment['approved']) { |
|
1214 | + $have_unapproved = true; |
|
1215 | + } |
|
1148 | 1216 | |
1149 | - if (!$attachmentData[$i]['is_image']) |
|
1150 | - continue; |
|
1217 | + if (!$attachmentData[$i]['is_image']) { |
|
1218 | + continue; |
|
1219 | + } |
|
1151 | 1220 | |
1152 | 1221 | $attachmentData[$i]['real_width'] = $attachment['width']; |
1153 | 1222 | $attachmentData[$i]['width'] = $attachment['width']; |
@@ -1168,12 +1237,12 @@ discard block |
||
1168 | 1237 | // So what folder are we putting this image in? |
1169 | 1238 | if (!empty($modSettings['currentAttachmentUploadDir'])) |
1170 | 1239 | { |
1171 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
1172 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
1240 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
1241 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
1242 | + } |
|
1173 | 1243 | $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
1174 | 1244 | $id_folder_thumb = $modSettings['currentAttachmentUploadDir']; |
1175 | - } |
|
1176 | - else |
|
1245 | + } else |
|
1177 | 1246 | { |
1178 | 1247 | $path = $modSettings['attachmentUploadDir']; |
1179 | 1248 | $id_folder_thumb = 1; |
@@ -1188,10 +1257,11 @@ discard block |
||
1188 | 1257 | $thumb_ext = isset($context['validImageTypes'][$size[2]]) ? $context['validImageTypes'][$size[2]] : ''; |
1189 | 1258 | |
1190 | 1259 | // Figure out the mime type. |
1191 | - if (!empty($size['mime'])) |
|
1192 | - $thumb_mime = $size['mime']; |
|
1193 | - else |
|
1194 | - $thumb_mime = 'image/' . $thumb_ext; |
|
1260 | + if (!empty($size['mime'])) { |
|
1261 | + $thumb_mime = $size['mime']; |
|
1262 | + } else { |
|
1263 | + $thumb_mime = 'image/' . $thumb_ext; |
|
1264 | + } |
|
1195 | 1265 | |
1196 | 1266 | $thumb_filename = $attachment['filename'] . '_thumb'; |
1197 | 1267 | $thumb_hash = getAttachmentFilename($thumb_filename, false, null, true); |
@@ -1238,11 +1308,12 @@ discard block |
||
1238 | 1308 | } |
1239 | 1309 | } |
1240 | 1310 | |
1241 | - if (!empty($attachment['id_thumb'])) |
|
1242 | - $attachmentData[$i]['thumbnail'] = array( |
|
1311 | + if (!empty($attachment['id_thumb'])) { |
|
1312 | + $attachmentData[$i]['thumbnail'] = array( |
|
1243 | 1313 | 'id' => $attachment['id_thumb'], |
1244 | 1314 | 'href' => $scripturl . '?action=dlattach;topic=' . $attachment['topic'] . '.0;attach=' . $attachment['id_thumb'] . ';image', |
1245 | 1315 | ); |
1316 | + } |
|
1246 | 1317 | $attachmentData[$i]['thumbnail']['has_thumb'] = !empty($attachment['id_thumb']); |
1247 | 1318 | |
1248 | 1319 | // If thumbnails are disabled, check the maximum size of the image. |
@@ -1252,30 +1323,31 @@ discard block |
||
1252 | 1323 | { |
1253 | 1324 | $attachmentData[$i]['width'] = $modSettings['max_image_width']; |
1254 | 1325 | $attachmentData[$i]['height'] = floor($attachment['height'] * $modSettings['max_image_width'] / $attachment['width']); |
1255 | - } |
|
1256 | - elseif (!empty($modSettings['max_image_width'])) |
|
1326 | + } elseif (!empty($modSettings['max_image_width'])) |
|
1257 | 1327 | { |
1258 | 1328 | $attachmentData[$i]['width'] = floor($attachment['width'] * $modSettings['max_image_height'] / $attachment['height']); |
1259 | 1329 | $attachmentData[$i]['height'] = $modSettings['max_image_height']; |
1260 | 1330 | } |
1261 | - } |
|
1262 | - elseif ($attachmentData[$i]['thumbnail']['has_thumb']) |
|
1331 | + } elseif ($attachmentData[$i]['thumbnail']['has_thumb']) |
|
1263 | 1332 | { |
1264 | 1333 | // If the image is too large to show inline, make it a popup. |
1265 | - if (((!empty($modSettings['max_image_width']) && $attachmentData[$i]['real_width'] > $modSettings['max_image_width']) || (!empty($modSettings['max_image_height']) && $attachmentData[$i]['real_height'] > $modSettings['max_image_height']))) |
|
1266 | - $attachmentData[$i]['thumbnail']['javascript'] = 'return reqWin(\'' . $attachmentData[$i]['href'] . ';image\', ' . ($attachment['width'] + 20) . ', ' . ($attachment['height'] + 20) . ', true);'; |
|
1267 | - else |
|
1268 | - $attachmentData[$i]['thumbnail']['javascript'] = 'return expandThumb(' . $attachment['id_attach'] . ');'; |
|
1334 | + if (((!empty($modSettings['max_image_width']) && $attachmentData[$i]['real_width'] > $modSettings['max_image_width']) || (!empty($modSettings['max_image_height']) && $attachmentData[$i]['real_height'] > $modSettings['max_image_height']))) { |
|
1335 | + $attachmentData[$i]['thumbnail']['javascript'] = 'return reqWin(\'' . $attachmentData[$i]['href'] . ';image\', ' . ($attachment['width'] + 20) . ', ' . ($attachment['height'] + 20) . ', true);'; |
|
1336 | + } else { |
|
1337 | + $attachmentData[$i]['thumbnail']['javascript'] = 'return expandThumb(' . $attachment['id_attach'] . ');'; |
|
1338 | + } |
|
1269 | 1339 | } |
1270 | 1340 | |
1271 | - if (!$attachmentData[$i]['thumbnail']['has_thumb']) |
|
1272 | - $attachmentData[$i]['downloads']++; |
|
1341 | + if (!$attachmentData[$i]['thumbnail']['has_thumb']) { |
|
1342 | + $attachmentData[$i]['downloads']++; |
|
1343 | + } |
|
1273 | 1344 | } |
1274 | 1345 | } |
1275 | 1346 | |
1276 | 1347 | // Do we need to instigate a sort? |
1277 | - if ($have_unapproved) |
|
1278 | - usort($attachmentData, 'approved_attach_sort'); |
|
1348 | + if ($have_unapproved) { |
|
1349 | + usort($attachmentData, 'approved_attach_sort'); |
|
1350 | + } |
|
1279 | 1351 | |
1280 | 1352 | return $attachmentData; |
1281 | 1353 | } |