@@ -1799,9 +1799,9 @@ |
||
1799 | 1799 | } |
1800 | 1800 | |
1801 | 1801 | /** |
1802 | - * Callback for createList(). |
|
1803 | - * @return int The total number of warning templates |
|
1804 | - */ |
|
1802 | + * Callback for createList(). |
|
1803 | + * @return int The total number of warning templates |
|
1804 | + */ |
|
1805 | 1805 | function list_getWarningTemplateCount() |
1806 | 1806 | { |
1807 | 1807 | global $smcFunc, $user_info; |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
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 | * Entry point for the moderation center. |
@@ -26,8 +27,9 @@ discard block |
||
26 | 27 | global $smcFunc, $txt, $context, $scripturl, $modSettings, $user_info, $sourcedir, $options; |
27 | 28 | |
28 | 29 | // Don't run this twice... and don't conflict with the admin bar. |
29 | - if (isset($context['admin_area'])) |
|
30 | - return; |
|
30 | + if (isset($context['admin_area'])) { |
|
31 | + return; |
|
32 | + } |
|
31 | 33 | |
32 | 34 | $context['can_moderate_boards'] = $user_info['mod_cache']['bq'] != '0=1'; |
33 | 35 | $context['can_moderate_groups'] = $user_info['mod_cache']['gq'] != '0=1'; |
@@ -35,8 +37,9 @@ discard block |
||
35 | 37 | $context['can_moderate_users'] = allowedTo('moderate_forum'); |
36 | 38 | |
37 | 39 | // Everyone using this area must be allowed here! |
38 | - if (!$context['can_moderate_boards'] && !$context['can_moderate_groups'] && !$context['can_moderate_approvals'] && !$context['can_moderate_users']) |
|
39 | - isAllowedTo('access_mod_center'); |
|
40 | + if (!$context['can_moderate_boards'] && !$context['can_moderate_groups'] && !$context['can_moderate_approvals'] && !$context['can_moderate_users']) { |
|
41 | + isAllowedTo('access_mod_center'); |
|
42 | + } |
|
40 | 43 | |
41 | 44 | // We're gonna want a menu of some kind. |
42 | 45 | require_once($sourcedir . '/Subs-Menu.php'); |
@@ -195,8 +198,9 @@ discard block |
||
195 | 198 | unset($moderation_areas); |
196 | 199 | |
197 | 200 | // We got something - didn't we? DIDN'T WE! |
198 | - if ($mod_include_data == false) |
|
199 | - fatal_lang_error('no_access', false); |
|
201 | + if ($mod_include_data == false) { |
|
202 | + fatal_lang_error('no_access', false); |
|
203 | + } |
|
200 | 204 | |
201 | 205 | // Retain the ID information in case required by a subaction. |
202 | 206 | $context['moderation_menu_id'] = $context['max_menu_id']; |
@@ -219,22 +223,25 @@ discard block |
||
219 | 223 | 'url' => $scripturl . '?action=moderate', |
220 | 224 | 'name' => $txt['moderation_center'], |
221 | 225 | ); |
222 | - if (isset($mod_include_data['current_area']) && $mod_include_data['current_area'] != 'index') |
|
223 | - $context['linktree'][] = array( |
|
226 | + if (isset($mod_include_data['current_area']) && $mod_include_data['current_area'] != 'index') { |
|
227 | + $context['linktree'][] = array( |
|
224 | 228 | 'url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'], |
225 | 229 | 'name' => $mod_include_data['label'], |
226 | 230 | ); |
227 | - if (!empty($mod_include_data['current_subsection']) && $mod_include_data['subsections'][$mod_include_data['current_subsection']][0] != $mod_include_data['label']) |
|
228 | - $context['linktree'][] = array( |
|
231 | + } |
|
232 | + if (!empty($mod_include_data['current_subsection']) && $mod_include_data['subsections'][$mod_include_data['current_subsection']][0] != $mod_include_data['label']) { |
|
233 | + $context['linktree'][] = array( |
|
229 | 234 | 'url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'] . ';sa=' . $mod_include_data['current_subsection'], |
230 | 235 | 'name' => $mod_include_data['subsections'][$mod_include_data['current_subsection']][0], |
231 | 236 | ); |
237 | + } |
|
232 | 238 | |
233 | 239 | // Now - finally - the bit before the encore - the main performance of course! |
234 | 240 | if (!$dont_call) |
235 | 241 | { |
236 | - if (isset($mod_include_data['file'])) |
|
237 | - require_once($sourcedir . '/' . $mod_include_data['file']); |
|
242 | + if (isset($mod_include_data['file'])) { |
|
243 | + require_once($sourcedir . '/' . $mod_include_data['file']); |
|
244 | + } |
|
238 | 245 | |
239 | 246 | call_helper($mod_include_data['function']); |
240 | 247 | } |
@@ -259,8 +266,9 @@ discard block |
||
259 | 266 | // Load what blocks the user actually can see... |
260 | 267 | $valid_blocks = array(); |
261 | 268 | |
262 | - if ($context['can_moderate_groups']) |
|
263 | - $valid_blocks['g'] = 'GroupRequests'; |
|
269 | + if ($context['can_moderate_groups']) { |
|
270 | + $valid_blocks['g'] = 'GroupRequests'; |
|
271 | + } |
|
264 | 272 | if ($context['can_moderate_boards']) |
265 | 273 | { |
266 | 274 | $valid_blocks['r'] = 'ReportedPosts'; |
@@ -269,8 +277,9 @@ discard block |
||
269 | 277 | if ($context['can_moderate_users']) |
270 | 278 | { |
271 | 279 | // This falls under the category of moderating users as well... |
272 | - if (!$context['can_moderate_boards']) |
|
273 | - $valid_blocks['w'] = 'WatchedUsers'; |
|
280 | + if (!$context['can_moderate_boards']) { |
|
281 | + $valid_blocks['w'] = 'WatchedUsers'; |
|
282 | + } |
|
274 | 283 | |
275 | 284 | $valid_blocks['rm'] = 'ReportedMembers'; |
276 | 285 | } |
@@ -281,8 +290,9 @@ discard block |
||
281 | 290 | foreach ($valid_blocks as $k => $block) |
282 | 291 | { |
283 | 292 | $block = 'ModBlock' . $block; |
284 | - if (function_exists($block)) |
|
285 | - $context['mod_blocks'][] = $block(); |
|
293 | + if (function_exists($block)) { |
|
294 | + $context['mod_blocks'][] = $block(); |
|
295 | + } |
|
286 | 296 | } |
287 | 297 | |
288 | 298 | $context['admin_prefs'] = !empty($options['admin_preferences']) ? $smcFunc['json_decode']($options['admin_preferences'], true) : array(); |
@@ -309,8 +319,9 @@ discard block |
||
309 | 319 | ) |
310 | 320 | ); |
311 | 321 | $watched_users = array(); |
312 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
313 | - $watched_users[] = $row; |
|
322 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
323 | + $watched_users[] = $row; |
|
324 | + } |
|
314 | 325 | $smcFunc['db_free_result']($request); |
315 | 326 | |
316 | 327 | cache_put_data('recent_user_watches', $watched_users, 240); |
@@ -402,8 +413,9 @@ discard block |
||
402 | 413 | $note_owner = $smcFunc['db_num_rows']($get_owner); |
403 | 414 | $smcFunc['db_free_result']($get_owner); |
404 | 415 | |
405 | - if (empty($note_owner)) |
|
406 | - fatal_lang_error('mc_notes_delete_own', false); |
|
416 | + if (empty($note_owner)) { |
|
417 | + fatal_lang_error('mc_notes_delete_own', false); |
|
418 | + } |
|
407 | 419 | } |
408 | 420 | |
409 | 421 | // Lets delete it. |
@@ -460,12 +472,14 @@ discard block |
||
460 | 472 | ) |
461 | 473 | ); |
462 | 474 | $moderator_notes = array(); |
463 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
464 | - $moderator_notes[] = $row; |
|
475 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
476 | + $moderator_notes[] = $row; |
|
477 | + } |
|
465 | 478 | $smcFunc['db_free_result']($request); |
466 | 479 | |
467 | - if ($offset == 0) |
|
468 | - cache_put_data('moderator_notes', $moderator_notes, 240); |
|
480 | + if ($offset == 0) { |
|
481 | + cache_put_data('moderator_notes', $moderator_notes, 240); |
|
482 | + } |
|
469 | 483 | } |
470 | 484 | |
471 | 485 | // Lets construct a page index. |
@@ -504,8 +518,9 @@ discard block |
||
504 | 518 | // Got the info already? |
505 | 519 | $cachekey = md5($smcFunc['json_encode']($user_info['mod_cache']['bq'])); |
506 | 520 | $context['reported_posts'] = array(); |
507 | - if ($user_info['mod_cache']['bq'] == '0=1') |
|
508 | - return 'reported_posts_block'; |
|
521 | + if ($user_info['mod_cache']['bq'] == '0=1') { |
|
522 | + return 'reported_posts_block'; |
|
523 | + } |
|
509 | 524 | |
510 | 525 | if (($reported_posts = cache_get_data('reported_posts_' . $cachekey, 90)) === null) |
511 | 526 | { |
@@ -529,8 +544,9 @@ discard block |
||
529 | 544 | ) |
530 | 545 | ); |
531 | 546 | $reported_posts = array(); |
532 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
533 | - $reported_posts[] = $row; |
|
547 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
548 | + $reported_posts[] = $row; |
|
549 | + } |
|
534 | 550 | $smcFunc['db_free_result']($request); |
535 | 551 | |
536 | 552 | // Cache it. |
@@ -568,8 +584,9 @@ discard block |
||
568 | 584 | |
569 | 585 | $context['group_requests'] = array(); |
570 | 586 | // Make sure they can even moderate someone! |
571 | - if ($user_info['mod_cache']['gq'] == '0=1') |
|
572 | - return 'group_requests_block'; |
|
587 | + if ($user_info['mod_cache']['gq'] == '0=1') { |
|
588 | + return 'group_requests_block'; |
|
589 | + } |
|
573 | 590 | |
574 | 591 | // What requests are outstanding? |
575 | 592 | $request = $smcFunc['db_query']('', ' |
@@ -618,8 +635,9 @@ discard block |
||
618 | 635 | // Got the info already? |
619 | 636 | $cachekey = md5($smcFunc['json_encode']((int) allowedTo('moderate_forum'))); |
620 | 637 | $context['reported_users'] = array(); |
621 | - if (!allowedTo('moderate_forum')) |
|
622 | - return 'reported_users_block'; |
|
638 | + if (!allowedTo('moderate_forum')) { |
|
639 | + return 'reported_users_block'; |
|
640 | + } |
|
623 | 641 | |
624 | 642 | if (($reported_users = cache_get_data('reported_users_' . $cachekey, 90)) === null) |
625 | 643 | { |
@@ -642,8 +660,9 @@ discard block |
||
642 | 660 | ) |
643 | 661 | ); |
644 | 662 | $reported_users = array(); |
645 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
646 | - $reported_users[] = $row; |
|
663 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
664 | + $reported_users[] = $row; |
|
665 | + } |
|
647 | 666 | $smcFunc['db_free_result']($request); |
648 | 667 | |
649 | 668 | // Cache it. |
@@ -691,8 +710,9 @@ discard block |
||
691 | 710 | isAllowedTo('moderate_forum'); |
692 | 711 | |
693 | 712 | // Are they wanting to view a particular report? |
694 | - if (!empty($_REQUEST['report'])) |
|
695 | - return MemberReport(); |
|
713 | + if (!empty($_REQUEST['report'])) { |
|
714 | + return MemberReport(); |
|
715 | + } |
|
696 | 716 | |
697 | 717 | // Set up the comforting bits... |
698 | 718 | $context['page_title'] = $txt['mc_reported_members']; |
@@ -746,15 +766,15 @@ discard block |
||
746 | 766 | // Time to update. |
747 | 767 | updateSettings(array('last_mod_report_action' => time())); |
748 | 768 | recountOpenReports('members'); |
749 | - } |
|
750 | - elseif (isset($_POST['close']) && isset($_POST['close_selected'])) |
|
769 | + } elseif (isset($_POST['close']) && isset($_POST['close_selected'])) |
|
751 | 770 | { |
752 | 771 | checkSession(); |
753 | 772 | |
754 | 773 | // All the ones to update... |
755 | 774 | $toClose = array(); |
756 | - foreach ($_POST['close'] as $rid) |
|
757 | - $toClose[] = (int) $rid; |
|
775 | + foreach ($_POST['close'] as $rid) { |
|
776 | + $toClose[] = (int) $rid; |
|
777 | + } |
|
758 | 778 | |
759 | 779 | if (!empty($toClose)) |
760 | 780 | { |
@@ -907,8 +927,9 @@ discard block |
||
907 | 927 | global $context, $user_info; |
908 | 928 | |
909 | 929 | // You need to be allowed to moderate groups... |
910 | - if ($user_info['mod_cache']['gq'] == '0=1') |
|
911 | - isAllowedTo('manage_membergroups'); |
|
930 | + if ($user_info['mod_cache']['gq'] == '0=1') { |
|
931 | + isAllowedTo('manage_membergroups'); |
|
932 | + } |
|
912 | 933 | |
913 | 934 | // Load the group templates. |
914 | 935 | loadTemplate('ModerationCenter'); |
@@ -919,8 +940,9 @@ discard block |
||
919 | 940 | 'view' => 'ViewGroups', |
920 | 941 | ); |
921 | 942 | |
922 | - if (!isset($_GET['sa']) || !isset($subActions[$_GET['sa']])) |
|
923 | - $_GET['sa'] = 'view'; |
|
943 | + if (!isset($_GET['sa']) || !isset($subActions[$_GET['sa']])) { |
|
944 | + $_GET['sa'] = 'view'; |
|
945 | + } |
|
924 | 946 | $context['sub_action'] = $_GET['sa']; |
925 | 947 | |
926 | 948 | // Call the relevant function. |
@@ -950,8 +972,9 @@ discard block |
||
950 | 972 | 'id_notice' => $id_notice, |
951 | 973 | ) |
952 | 974 | ); |
953 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
954 | - fatal_lang_error('no_access', false); |
|
975 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
976 | + fatal_lang_error('no_access', false); |
|
977 | + } |
|
955 | 978 | list ($context['notice_body'], $context['notice_subject']) = $smcFunc['db_fetch_row']($request); |
956 | 979 | $smcFunc['db_free_result']($request); |
957 | 980 | |
@@ -988,18 +1011,20 @@ discard block |
||
988 | 1011 | checkSession(!is_array($_REQUEST['delete']) ? 'get' : 'post'); |
989 | 1012 | |
990 | 1013 | $toDelete = array(); |
991 | - if (!is_array($_REQUEST['delete'])) |
|
992 | - $toDelete[] = (int) $_REQUEST['delete']; |
|
993 | - else |
|
994 | - foreach ($_REQUEST['delete'] as $did) |
|
1014 | + if (!is_array($_REQUEST['delete'])) { |
|
1015 | + $toDelete[] = (int) $_REQUEST['delete']; |
|
1016 | + } else { |
|
1017 | + foreach ($_REQUEST['delete'] as $did) |
|
995 | 1018 | $toDelete[] = (int) $did; |
1019 | + } |
|
996 | 1020 | |
997 | 1021 | if (!empty($toDelete)) |
998 | 1022 | { |
999 | 1023 | require_once($sourcedir . '/RemoveTopic.php'); |
1000 | 1024 | // If they don't have permission we'll let it error - either way no chance of a security slip here! |
1001 | - foreach ($toDelete as $did) |
|
1002 | - removeMessage($did); |
|
1025 | + foreach ($toDelete as $did) { |
|
1026 | + removeMessage($did); |
|
1027 | + } |
|
1003 | 1028 | } |
1004 | 1029 | } |
1005 | 1030 | |
@@ -1008,20 +1033,21 @@ discard block |
||
1008 | 1033 | { |
1009 | 1034 | $approve_query = ''; |
1010 | 1035 | $delete_boards = array(); |
1011 | - } |
|
1012 | - else |
|
1036 | + } else |
|
1013 | 1037 | { |
1014 | 1038 | // Still obey permissions! |
1015 | 1039 | $approve_boards = boardsAllowedTo('approve_posts'); |
1016 | 1040 | $delete_boards = boardsAllowedTo('delete_any'); |
1017 | 1041 | |
1018 | - if ($approve_boards == array(0)) |
|
1019 | - $approve_query = ''; |
|
1020 | - elseif (!empty($approve_boards)) |
|
1021 | - $approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')'; |
|
1042 | + if ($approve_boards == array(0)) { |
|
1043 | + $approve_query = ''; |
|
1044 | + } elseif (!empty($approve_boards)) { |
|
1045 | + $approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')'; |
|
1046 | + } |
|
1022 | 1047 | // Nada, zip, etc... |
1023 | - else |
|
1024 | - $approve_query = ' AND 1=0'; |
|
1048 | + else { |
|
1049 | + $approve_query = ' AND 1=0'; |
|
1050 | + } |
|
1025 | 1051 | } |
1026 | 1052 | |
1027 | 1053 | require_once($sourcedir . '/Subs-List.php'); |
@@ -1120,10 +1146,11 @@ discard block |
||
1120 | 1146 | 'data' => array( |
1121 | 1147 | 'function' => function($member) use ($scripturl) |
1122 | 1148 | { |
1123 | - if ($member['last_post_id']) |
|
1124 | - return '<a href="' . $scripturl . '?msg=' . $member['last_post_id'] . '">' . $member['last_post'] . '</a>'; |
|
1125 | - else |
|
1126 | - return $member['last_post']; |
|
1149 | + if ($member['last_post_id']) { |
|
1150 | + return '<a href="' . $scripturl . '?msg=' . $member['last_post_id'] . '">' . $member['last_post'] . '</a>'; |
|
1151 | + } else { |
|
1152 | + return $member['last_post']; |
|
1153 | + } |
|
1127 | 1154 | }, |
1128 | 1155 | ), |
1129 | 1156 | ), |
@@ -1251,8 +1278,9 @@ discard block |
||
1251 | 1278 | ) |
1252 | 1279 | ); |
1253 | 1280 | $latest_posts = array(); |
1254 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1255 | - $latest_posts[$row['id_member']] = $row['last_post_id']; |
|
1281 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1282 | + $latest_posts[$row['id_member']] = $row['last_post_id']; |
|
1283 | + } |
|
1256 | 1284 | |
1257 | 1285 | if (!empty($latest_posts)) |
1258 | 1286 | { |
@@ -1443,15 +1471,17 @@ discard block |
||
1443 | 1471 | // Setup the direction stuff... |
1444 | 1472 | $context['order'] = isset($_REQUEST['sort']) && isset($sort_types[$_REQUEST['sort']]) ? $_REQUEST['sort'] : 'member'; |
1445 | 1473 | |
1446 | - if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) |
|
1447 | - $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
1448 | - else |
|
1449 | - $search_params_string = $search_params['string']; |
|
1474 | + if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) { |
|
1475 | + $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
1476 | + } else { |
|
1477 | + $search_params_string = $search_params['string']; |
|
1478 | + } |
|
1450 | 1479 | |
1451 | - if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) |
|
1452 | - $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
1453 | - else |
|
1454 | - $search_params_type = $search_params['type']; |
|
1480 | + if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { |
|
1481 | + $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
1482 | + } else { |
|
1483 | + $search_params_type = $search_params['type']; |
|
1484 | + } |
|
1455 | 1485 | |
1456 | 1486 | $search_params = array( |
1457 | 1487 | 'string' => $search_params_string, |
@@ -1534,9 +1564,10 @@ discard block |
||
1534 | 1564 | ' . $rowData['reason'] . ' |
1535 | 1565 | </div>'; |
1536 | 1566 | |
1537 | - if (!empty($rowData['id_notice'])) |
|
1538 | - $output .= ' |
|
1567 | + if (!empty($rowData['id_notice'])) { |
|
1568 | + $output .= ' |
|
1539 | 1569 | <a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $rowData['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" class="new_win" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a>'; |
1570 | + } |
|
1540 | 1571 | return $output; |
1541 | 1572 | }, |
1542 | 1573 | ), |
@@ -1654,9 +1685,9 @@ discard block |
||
1654 | 1685 | global $smcFunc, $modSettings, $context, $txt, $scripturl, $sourcedir, $user_info; |
1655 | 1686 | |
1656 | 1687 | // Submitting a new one? |
1657 | - if (isset($_POST['add'])) |
|
1658 | - return ModifyWarningTemplate(); |
|
1659 | - elseif (isset($_POST['delete']) && !empty($_POST['deltpl'])) |
|
1688 | + if (isset($_POST['add'])) { |
|
1689 | + return ModifyWarningTemplate(); |
|
1690 | + } elseif (isset($_POST['delete']) && !empty($_POST['deltpl'])) |
|
1660 | 1691 | { |
1661 | 1692 | checkSession(); |
1662 | 1693 | validateToken('mod-wt'); |
@@ -1675,8 +1706,9 @@ discard block |
||
1675 | 1706 | 'current_member' => $user_info['id'], |
1676 | 1707 | ) |
1677 | 1708 | ); |
1678 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1679 | - logAction('delete_warn_template', array('template' => $row['recipient_name'])); |
|
1709 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1710 | + logAction('delete_warn_template', array('template' => $row['recipient_name'])); |
|
1711 | + } |
|
1680 | 1712 | $smcFunc['db_free_result']($request); |
1681 | 1713 | |
1682 | 1714 | // Do the deletes. |
@@ -1967,16 +1999,18 @@ discard block |
||
1967 | 1999 | ); |
1968 | 2000 | |
1969 | 2001 | // If it wasn't visible and now is they've effectively added it. |
1970 | - if ($context['template_data']['personal'] && !$recipient_id) |
|
1971 | - logAction('add_warn_template', array('template' => $_POST['template_title'])); |
|
2002 | + if ($context['template_data']['personal'] && !$recipient_id) { |
|
2003 | + logAction('add_warn_template', array('template' => $_POST['template_title'])); |
|
2004 | + } |
|
1972 | 2005 | // Conversely if they made it personal it's a delete. |
1973 | - elseif (!$context['template_data']['personal'] && $recipient_id) |
|
1974 | - logAction('delete_warn_template', array('template' => $_POST['template_title'])); |
|
2006 | + elseif (!$context['template_data']['personal'] && $recipient_id) { |
|
2007 | + logAction('delete_warn_template', array('template' => $_POST['template_title'])); |
|
2008 | + } |
|
1975 | 2009 | // Otherwise just an edit. |
1976 | - else |
|
1977 | - logAction('modify_warn_template', array('template' => $_POST['template_title'])); |
|
1978 | - } |
|
1979 | - else |
|
2010 | + else { |
|
2011 | + logAction('modify_warn_template', array('template' => $_POST['template_title'])); |
|
2012 | + } |
|
2013 | + } else |
|
1980 | 2014 | { |
1981 | 2015 | $smcFunc['db_insert']('', |
1982 | 2016 | '{db_prefix}log_comments', |
@@ -1996,17 +2030,18 @@ discard block |
||
1996 | 2030 | |
1997 | 2031 | // Get out of town... |
1998 | 2032 | redirectexit('action=moderate;area=warnings;sa=templates'); |
1999 | - } |
|
2000 | - else |
|
2033 | + } else |
|
2001 | 2034 | { |
2002 | 2035 | $context['warning_errors'] = array(); |
2003 | 2036 | $context['template_data']['title'] = !empty($_POST['template_title']) ? $_POST['template_title'] : ''; |
2004 | 2037 | $context['template_data']['body'] = !empty($_POST['template_body']) ? $_POST['template_body'] : $txt['mc_warning_template_body_default']; |
2005 | 2038 | $context['template_data']['personal'] = !empty($_POST['make_personal']); |
2006 | - if (empty($_POST['template_title'])) |
|
2007 | - $context['warning_errors'][] = $txt['mc_warning_template_error_no_title']; |
|
2008 | - if (empty($_POST['template_body'])) |
|
2009 | - $context['warning_errors'][] = $txt['mc_warning_template_error_no_body']; |
|
2039 | + if (empty($_POST['template_title'])) { |
|
2040 | + $context['warning_errors'][] = $txt['mc_warning_template_error_no_title']; |
|
2041 | + } |
|
2042 | + if (empty($_POST['template_body'])) { |
|
2043 | + $context['warning_errors'][] = $txt['mc_warning_template_error_no_body']; |
|
2044 | + } |
|
2010 | 2045 | } |
2011 | 2046 | } |
2012 | 2047 | |
@@ -2051,8 +2086,9 @@ discard block |
||
2051 | 2086 | // Now check other options! |
2052 | 2087 | $pref_binary = 0; |
2053 | 2088 | |
2054 | - if ($context['can_moderate_approvals'] && !empty($_POST['mod_notify_approval'])) |
|
2055 | - $pref_binary |= 4; |
|
2089 | + if ($context['can_moderate_approvals'] && !empty($_POST['mod_notify_approval'])) { |
|
2090 | + $pref_binary |= 4; |
|
2091 | + } |
|
2056 | 2092 | |
2057 | 2093 | // Put it all together. |
2058 | 2094 | $mod_prefs = '0||' . $pref_binary; |
@@ -2076,9 +2112,10 @@ discard block |
||
2076 | 2112 | unset($_SESSION['moderate_time']); |
2077 | 2113 | |
2078 | 2114 | // Clean any moderator tokens as well. |
2079 | - foreach ($_SESSION['token'] as $key => $token) |
|
2080 | - if (strpos($key, '-mod') !== false) |
|
2115 | + foreach ($_SESSION['token'] as $key => $token) { |
|
2116 | + if (strpos($key, '-mod') !== false) |
|
2081 | 2117 | unset($_SESSION['token'][$key]); |
2118 | + } |
|
2082 | 2119 | |
2083 | 2120 | redirectexit(); |
2084 | 2121 | } |
@@ -273,7 +273,6 @@ |
||
273 | 273 | * Modify any setting related to topics. |
274 | 274 | * Requires the admin_forum permission. |
275 | 275 | * Accessed from ?action=admin;area=postsettings;sa=topics. |
276 | - |
|
277 | 276 | * @param bool $return_config Whether or not to return the config_vars array (used for admin search) |
278 | 277 | * @return void|array Returns nothing or returns $config_vars if $return_config is true |
279 | 278 | * @uses Admin template, edit_topic_settings sub-template. |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * The main entrance point for the 'Posts and topics' screen. |
@@ -98,23 +99,23 @@ discard block |
||
98 | 99 | { |
99 | 100 | $_POST['censortext'] = explode("\n", strtr($_POST['censortext'], array("\r" => ''))); |
100 | 101 | |
101 | - foreach ($_POST['censortext'] as $c) |
|
102 | - list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, ''); |
|
103 | - } |
|
104 | - elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) |
|
102 | + foreach ($_POST['censortext'] as $c) { |
|
103 | + list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, ''); |
|
104 | + } |
|
105 | + } elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) |
|
105 | 106 | { |
106 | 107 | if (is_array($_POST['censor_vulgar'])) |
107 | 108 | { |
108 | 109 | foreach ($_POST['censor_vulgar'] as $i => $value) |
109 | 110 | { |
110 | - if (trim(strtr($value, '*', ' ')) == '') |
|
111 | - unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]); |
|
111 | + if (trim(strtr($value, '*', ' ')) == '') { |
|
112 | + unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]); |
|
113 | + } |
|
112 | 114 | } |
113 | 115 | |
114 | 116 | $censored_vulgar = $_POST['censor_vulgar']; |
115 | 117 | $censored_proper = $_POST['censor_proper']; |
116 | - } |
|
117 | - else |
|
118 | + } else |
|
118 | 119 | { |
119 | 120 | $censored_vulgar = explode("\n", strtr($_POST['censor_vulgar'], array("\r" => ''))); |
120 | 121 | $censored_proper = explode("\n", strtr($_POST['censor_proper'], array("\r" => ''))); |
@@ -151,12 +152,14 @@ discard block |
||
151 | 152 | $context['censored_words'] = array(); |
152 | 153 | for ($i = 0, $n = count($censor_vulgar); $i < $n; $i++) |
153 | 154 | { |
154 | - if (empty($censor_vulgar[$i])) |
|
155 | - continue; |
|
155 | + if (empty($censor_vulgar[$i])) { |
|
156 | + continue; |
|
157 | + } |
|
156 | 158 | |
157 | 159 | // Skip it, it's either spaces or stars only. |
158 | - if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') |
|
159 | - continue; |
|
160 | + if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') { |
|
161 | + continue; |
|
162 | + } |
|
160 | 163 | |
161 | 164 | $context['censored_words'][$smcFunc['htmlspecialchars'](trim($censor_vulgar[$i]))] = isset($censor_proper[$i]) ? $smcFunc['htmlspecialchars']($censor_proper[$i]) : ''; |
162 | 165 | } |
@@ -187,10 +190,11 @@ discard block |
||
187 | 190 | |
188 | 191 | // Make an inline conditional a little shorter... |
189 | 192 | $can_spell_check = false; |
190 | - if (function_exists('pspell_new')) |
|
191 | - $can_spell_check = true; |
|
192 | - elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) |
|
193 | - $can_spell_check = true; |
|
193 | + if (function_exists('pspell_new')) { |
|
194 | + $can_spell_check = true; |
|
195 | + } elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) { |
|
196 | + $can_spell_check = true; |
|
197 | + } |
|
194 | 198 | |
195 | 199 | // All the settings... |
196 | 200 | $config_vars = array( |
@@ -221,8 +225,9 @@ discard block |
||
221 | 225 | |
222 | 226 | call_integration_hook('integrate_modify_post_settings', array(&$config_vars)); |
223 | 227 | |
224 | - if ($return_config) |
|
225 | - return $config_vars; |
|
228 | + if ($return_config) { |
|
229 | + return $config_vars; |
|
230 | + } |
|
226 | 231 | |
227 | 232 | // We'll want this for our easy save. |
228 | 233 | require_once($sourcedir . '/ManageServer.php'); |
@@ -242,17 +247,20 @@ discard block |
||
242 | 247 | db_extend('packages'); |
243 | 248 | |
244 | 249 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
245 | - foreach ($colData as $column) |
|
246 | - if ($column['name'] == 'body') |
|
250 | + foreach ($colData as $column) { |
|
251 | + if ($column['name'] == 'body') |
|
247 | 252 | $body_type = $column['type']; |
253 | + } |
|
248 | 254 | |
249 | - if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') |
|
250 | - fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database')); |
|
255 | + if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') { |
|
256 | + fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database')); |
|
257 | + } |
|
251 | 258 | } |
252 | 259 | |
253 | 260 | // If we're changing the post preview length let's check its valid |
254 | - if (!empty($_POST['preview_characters'])) |
|
255 | - $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512); |
|
261 | + if (!empty($_POST['preview_characters'])) { |
|
262 | + $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512); |
|
263 | + } |
|
256 | 264 | |
257 | 265 | call_integration_hook('integrate_save_post_settings'); |
258 | 266 | |
@@ -313,8 +321,9 @@ discard block |
||
313 | 321 | |
314 | 322 | call_integration_hook('integrate_modify_topic_settings', array(&$config_vars)); |
315 | 323 | |
316 | - if ($return_config) |
|
317 | - return $config_vars; |
|
324 | + if ($return_config) { |
|
325 | + return $config_vars; |
|
326 | + } |
|
318 | 327 | |
319 | 328 | // Get the settings template ready. |
320 | 329 | require_once($sourcedir . '/ManageServer.php'); |
@@ -367,8 +376,9 @@ discard block |
||
367 | 376 | array('int', 'drafts_autosave_frequency', 'postinput' => $txt['manageposts_seconds'], 'subtext' => $txt['drafts_autosave_frequency_subnote']), |
368 | 377 | ); |
369 | 378 | |
370 | - if ($return_config) |
|
371 | - return $config_vars; |
|
379 | + if ($return_config) { |
|
380 | + return $config_vars; |
|
381 | + } |
|
372 | 382 | |
373 | 383 | // Get the settings template ready. |
374 | 384 | require_once($sourcedir . '/ManageServer.php'); |
@@ -5265,7 +5265,6 @@ discard block |
||
5265 | 5265 | |
5266 | 5266 | /** |
5267 | 5267 | * Tries different modes to make file/dirs writable. Wrapper function for chmod() |
5268 | - |
|
5269 | 5268 | * @param string $file The file/dir full path. |
5270 | 5269 | * @param int $value Not needed, added for legacy reasons. |
5271 | 5270 | * @return boolean true if the file/dir is already writable or the function was able to make it writable, false if the function couldn't make the file/dir writable. |
@@ -5305,7 +5304,6 @@ discard block |
||
5305 | 5304 | |
5306 | 5305 | /** |
5307 | 5306 | * Wrapper function for json_decode() with error handling. |
5308 | - |
|
5309 | 5307 | * @param string $json The string to decode. |
5310 | 5308 | * @param bool $returnAsArray To return the decoded string as an array or an object, SMF only uses Arrays but to keep on compatibility with json_decode its set to false as default. |
5311 | 5309 | * @param bool $logIt To specify if the error will be logged if theres any. |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | * - caches the formatting data from the setting for optimization. |
677 | 677 | * |
678 | 678 | * @param float $number A number |
679 | - * @param bool|int $override_decimal_count If set, will use the specified number of decimal places. Otherwise it's automatically determined |
|
679 | + * @param integer $override_decimal_count If set, will use the specified number of decimal places. Otherwise it's automatically determined |
|
680 | 680 | * @return string A formatted number |
681 | 681 | */ |
682 | 682 | function comma_format($number, $override_decimal_count = false) |
@@ -5530,7 +5530,7 @@ discard block |
||
5530 | 5530 | * It assumes the data is already a string. |
5531 | 5531 | * @param string $data The data to print |
5532 | 5532 | * @param string $type The content type. Defaults to Json. |
5533 | - * @return void |
|
5533 | + * @return false|null |
|
5534 | 5534 | */ |
5535 | 5535 | function smf_serverResponse($data = '', $type = 'Content-Type: application/json') |
5536 | 5536 | { |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
801 | 801 | if (empty($unsupportedFormats)) |
802 | 802 | { |
803 | - foreach($strftimeFormatSubstitutions as $format => $substitution) |
|
803 | + foreach ($strftimeFormatSubstitutions as $format => $substitution) |
|
804 | 804 | { |
805 | 805 | $value = @strftime('%' . $format); |
806 | 806 | |
@@ -1165,7 +1165,7 @@ discard block |
||
1165 | 1165 | 'height' => array('optional' => true, 'match' => '(\d+)'), |
1166 | 1166 | ), |
1167 | 1167 | 'content' => '$1', |
1168 | - 'validate' => function (&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt) |
|
1168 | + 'validate' => function(&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt) |
|
1169 | 1169 | { |
1170 | 1170 | $returnContext = ''; |
1171 | 1171 | |
@@ -1200,7 +1200,7 @@ discard block |
||
1200 | 1200 | } |
1201 | 1201 | |
1202 | 1202 | if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) |
1203 | - $returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>'; |
|
1203 | + $returnContext .= '<a href="' . $currentAttachment['href'] . ';image" id="link_' . $currentAttachment['id'] . '" onclick="' . $currentAttachment['thumbnail']['javascript'] . '"><img src="' . $currentAttachment['thumbnail']['href'] . '"' . $alt . $title . ' id="thumb_' . $currentAttachment['id'] . '" class="atc_img"></a>'; |
|
1204 | 1204 | else |
1205 | 1205 | $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
1206 | 1206 | } |
@@ -1229,7 +1229,7 @@ discard block |
||
1229 | 1229 | 'type' => 'unparsed_content', |
1230 | 1230 | 'content' => '<div class="codeheader"><span class="code floatleft">' . $txt['code'] . '</span> <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>', |
1231 | 1231 | // @todo Maybe this can be simplified? |
1232 | - 'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context) |
|
1232 | + 'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context) |
|
1233 | 1233 | { |
1234 | 1234 | if (!isset($disabled['code'])) |
1235 | 1235 | { |
@@ -1266,7 +1266,7 @@ discard block |
||
1266 | 1266 | 'type' => 'unparsed_equals_content', |
1267 | 1267 | 'content' => '<div class="codeheader"><span class="code floatleft">' . $txt['code'] . '</span> ($2) <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>', |
1268 | 1268 | // @todo Maybe this can be simplified? |
1269 | - 'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context) |
|
1269 | + 'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context) |
|
1270 | 1270 | { |
1271 | 1271 | if (!isset($disabled['code'])) |
1272 | 1272 | { |
@@ -1310,7 +1310,7 @@ discard block |
||
1310 | 1310 | 'type' => 'unparsed_content', |
1311 | 1311 | 'content' => '<a href="mailto:$1" class="bbc_email">$1</a>', |
1312 | 1312 | // @todo Should this respect guest_hideContacts? |
1313 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1313 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1314 | 1314 | { |
1315 | 1315 | $data = strtr($data, array('<br>' => '')); |
1316 | 1316 | }, |
@@ -1329,7 +1329,7 @@ discard block |
||
1329 | 1329 | 'type' => 'unparsed_commas_content', |
1330 | 1330 | 'test' => '\d+,\d+\]', |
1331 | 1331 | 'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">', |
1332 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1332 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1333 | 1333 | { |
1334 | 1334 | if (isset($disabled['url'])) |
1335 | 1335 | $tag['content'] = '$1'; |
@@ -1345,7 +1345,7 @@ discard block |
||
1345 | 1345 | 'test' => '(left|right)(\s+max=\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)?\]', |
1346 | 1346 | 'before' => '<div $1>', |
1347 | 1347 | 'after' => '</div>', |
1348 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1348 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1349 | 1349 | { |
1350 | 1350 | $class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"'; |
1351 | 1351 | |
@@ -1394,7 +1394,7 @@ discard block |
||
1394 | 1394 | 'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'), |
1395 | 1395 | ), |
1396 | 1396 | 'content' => '<img src="$1" alt="{alt}" title="{title}"{width}{height} class="bbc_img resized">', |
1397 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1397 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1398 | 1398 | { |
1399 | 1399 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
1400 | 1400 | |
@@ -1417,7 +1417,7 @@ discard block |
||
1417 | 1417 | 'tag' => 'img', |
1418 | 1418 | 'type' => 'unparsed_content', |
1419 | 1419 | 'content' => '<img src="$1" alt="" class="bbc_img">', |
1420 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1420 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1421 | 1421 | { |
1422 | 1422 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
1423 | 1423 | |
@@ -1440,7 +1440,7 @@ discard block |
||
1440 | 1440 | 'tag' => 'iurl', |
1441 | 1441 | 'type' => 'unparsed_content', |
1442 | 1442 | 'content' => '<a href="$1" class="bbc_link">$1</a>', |
1443 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1443 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1444 | 1444 | { |
1445 | 1445 | $data = strtr($data, array('<br>' => '')); |
1446 | 1446 | $scheme = parse_url($data, PHP_URL_SCHEME); |
@@ -1454,7 +1454,7 @@ discard block |
||
1454 | 1454 | 'quoted' => 'optional', |
1455 | 1455 | 'before' => '<a href="$1" class="bbc_link">', |
1456 | 1456 | 'after' => '</a>', |
1457 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1457 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1458 | 1458 | { |
1459 | 1459 | if (substr($data, 0, 1) == '#') |
1460 | 1460 | $data = '#post_' . substr($data, 1); |
@@ -1534,7 +1534,7 @@ discard block |
||
1534 | 1534 | 'tag' => 'php', |
1535 | 1535 | 'type' => 'unparsed_content', |
1536 | 1536 | 'content' => '<span class="phpcode">$1</span>', |
1537 | - 'validate' => isset($disabled['php']) ? null : function (&$tag, &$data, $disabled) |
|
1537 | + 'validate' => isset($disabled['php']) ? null : function(&$tag, &$data, $disabled) |
|
1538 | 1538 | { |
1539 | 1539 | if (!isset($disabled['php'])) |
1540 | 1540 | { |
@@ -1632,7 +1632,7 @@ discard block |
||
1632 | 1632 | 'test' => '[1-7]\]', |
1633 | 1633 | 'before' => '<span style="font-size: $1;" class="bbc_size">', |
1634 | 1634 | 'after' => '</span>', |
1635 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1635 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1636 | 1636 | { |
1637 | 1637 | $sizes = array(1 => 0.7, 2 => 1.0, 3 => 1.35, 4 => 1.45, 5 => 2.0, 6 => 2.65, 7 => 3.95); |
1638 | 1638 | $data = $sizes[$data] . 'em'; |
@@ -1670,7 +1670,7 @@ discard block |
||
1670 | 1670 | 'tag' => 'time', |
1671 | 1671 | 'type' => 'unparsed_content', |
1672 | 1672 | 'content' => '$1', |
1673 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1673 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1674 | 1674 | { |
1675 | 1675 | if (is_numeric($data)) |
1676 | 1676 | $data = timeformat($data); |
@@ -1698,7 +1698,7 @@ discard block |
||
1698 | 1698 | 'tag' => 'url', |
1699 | 1699 | 'type' => 'unparsed_content', |
1700 | 1700 | 'content' => '<a href="$1" class="bbc_link" target="_blank">$1</a>', |
1701 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1701 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1702 | 1702 | { |
1703 | 1703 | $data = strtr($data, array('<br>' => '')); |
1704 | 1704 | $scheme = parse_url($data, PHP_URL_SCHEME); |
@@ -1712,7 +1712,7 @@ discard block |
||
1712 | 1712 | 'quoted' => 'optional', |
1713 | 1713 | 'before' => '<a href="$1" class="bbc_link" target="_blank">', |
1714 | 1714 | 'after' => '</a>', |
1715 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1715 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1716 | 1716 | { |
1717 | 1717 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1718 | 1718 | if (empty($scheme)) |
@@ -1738,7 +1738,7 @@ discard block |
||
1738 | 1738 | { |
1739 | 1739 | if (isset($temp_bbc)) |
1740 | 1740 | $bbc_codes = $temp_bbc; |
1741 | - usort($codes, function ($a, $b) { |
|
1741 | + usort($codes, function($a, $b) { |
|
1742 | 1742 | return strcmp($a['tag'], $b['tag']); |
1743 | 1743 | }); |
1744 | 1744 | return $codes; |
@@ -1976,7 +1976,7 @@ discard block |
||
1976 | 1976 | # a run of Unicode domain name characters and a dot |
1977 | 1977 | [\p{L}\p{M}\p{N}\-.:@]+\. |
1978 | 1978 | # and then a TLD valid in the DNS or the reserved "local" TLD |
1979 | - (?:'. $modSettings['tld_regex'] .'|local) |
|
1979 | + (?:'. $modSettings['tld_regex'] . '|local) |
|
1980 | 1980 | ) |
1981 | 1981 | # followed by a non-domain character or end of line |
1982 | 1982 | (?=[^\p{L}\p{N}\-.]|$) |
@@ -2044,7 +2044,7 @@ discard block |
||
2044 | 2044 | )? |
2045 | 2045 | '; |
2046 | 2046 | |
2047 | - $data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function ($matches) { |
|
2047 | + $data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function($matches) { |
|
2048 | 2048 | $url = array_shift($matches); |
2049 | 2049 | |
2050 | 2050 | $scheme = parse_url($url, PHP_URL_SCHEME); |
@@ -2781,7 +2781,7 @@ discard block |
||
2781 | 2781 | for ($i = 0, $n = count($smileysfrom); $i < $n; $i++) |
2782 | 2782 | { |
2783 | 2783 | $specialChars = $smcFunc['htmlspecialchars']($smileysfrom[$i], ENT_QUOTES); |
2784 | - $smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')). '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" class="smiley">'; |
|
2784 | + $smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" class="smiley">'; |
|
2785 | 2785 | |
2786 | 2786 | $smileyPregReplacements[$smileysfrom[$i]] = $smileyCode; |
2787 | 2787 | |
@@ -2798,7 +2798,7 @@ discard block |
||
2798 | 2798 | |
2799 | 2799 | // Replace away! |
2800 | 2800 | $message = preg_replace_callback($smileyPregSearch, |
2801 | - function ($matches) use ($smileyPregReplacements) |
|
2801 | + function($matches) use ($smileyPregReplacements) |
|
2802 | 2802 | { |
2803 | 2803 | return $smileyPregReplacements[$matches[1]]; |
2804 | 2804 | }, $message); |
@@ -2864,13 +2864,13 @@ discard block |
||
2864 | 2864 | { |
2865 | 2865 | if (defined('SID') && SID != '') |
2866 | 2866 | $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
2867 | - function ($m) use ($scripturl) |
|
2867 | + function($m) use ($scripturl) |
|
2868 | 2868 | { |
2869 | - return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
|
2869 | + return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID . (isset($m[2]) ? "$m[2]" : ""); |
|
2870 | 2870 | }, $setLocation); |
2871 | 2871 | else |
2872 | 2872 | $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
2873 | - function ($m) use ($scripturl) |
|
2873 | + function($m) use ($scripturl) |
|
2874 | 2874 | { |
2875 | 2875 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
2876 | 2876 | }, $setLocation); |
@@ -3193,7 +3193,7 @@ discard block |
||
3193 | 3193 | |
3194 | 3194 | // Add a generic "Are you sure?" confirmation message. |
3195 | 3195 | addInlineJavaScript(' |
3196 | - var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
|
3196 | + var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) . ';'); |
|
3197 | 3197 | |
3198 | 3198 | // Now add the capping code for avatars. |
3199 | 3199 | if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize') |
@@ -3554,7 +3554,7 @@ discard block |
||
3554 | 3554 | |
3555 | 3555 | else |
3556 | 3556 | echo ' |
3557 | - <script src="', $settings['theme_url'] ,'/scripts/minified', ($do_deferred ? '_deferred' : '') ,'.js', $minSeed ,'"></script>'; |
|
3557 | + <script src="', $settings['theme_url'], '/scripts/minified', ($do_deferred ? '_deferred' : ''), '.js', $minSeed, '"></script>'; |
|
3558 | 3558 | } |
3559 | 3559 | |
3560 | 3560 | // Inline JavaScript - Actually useful some times! |
@@ -3632,14 +3632,14 @@ discard block |
||
3632 | 3632 | |
3633 | 3633 | else |
3634 | 3634 | echo ' |
3635 | - <link rel="stylesheet" href="', $settings['theme_url'] ,'/css/minified.css', $minSeed ,'">'; |
|
3635 | + <link rel="stylesheet" href="', $settings['theme_url'], '/css/minified.css', $minSeed, '">'; |
|
3636 | 3636 | } |
3637 | 3637 | |
3638 | 3638 | // Print the rest after the minified files. |
3639 | 3639 | if (!empty($normal)) |
3640 | 3640 | foreach ($normal as $nf) |
3641 | 3641 | echo ' |
3642 | - <link rel="stylesheet" href="', $nf ,'">'; |
|
3642 | + <link rel="stylesheet" href="', $nf, '">'; |
|
3643 | 3643 | |
3644 | 3644 | if ($db_show_debug === true) |
3645 | 3645 | { |
@@ -3655,7 +3655,7 @@ discard block |
||
3655 | 3655 | <style>'; |
3656 | 3656 | |
3657 | 3657 | foreach ($context['css_header'] as $css) |
3658 | - echo $css .' |
|
3658 | + echo $css . ' |
|
3659 | 3659 | '; |
3660 | 3660 | |
3661 | 3661 | echo' |
@@ -3684,27 +3684,27 @@ discard block |
||
3684 | 3684 | return false; |
3685 | 3685 | |
3686 | 3686 | // Did we already did this? |
3687 | - $toCache = cache_get_data('minimized_'. $settings['theme_id'] .'_'. $type, 86400); |
|
3687 | + $toCache = cache_get_data('minimized_' . $settings['theme_id'] . '_' . $type, 86400); |
|
3688 | 3688 | |
3689 | 3689 | // Already done? |
3690 | 3690 | if (!empty($toCache)) |
3691 | 3691 | return true; |
3692 | 3692 | |
3693 | 3693 | // No namespaces, sorry! |
3694 | - $classType = 'MatthiasMullie\\Minify\\'. strtoupper($type); |
|
3694 | + $classType = 'MatthiasMullie\\Minify\\' . strtoupper($type); |
|
3695 | 3695 | |
3696 | 3696 | // Temp path. |
3697 | - $cTempPath = $settings['theme_dir'] .'/'. ($type == 'css' ? 'css' : 'scripts') .'/'; |
|
3697 | + $cTempPath = $settings['theme_dir'] . '/' . ($type == 'css' ? 'css' : 'scripts') . '/'; |
|
3698 | 3698 | |
3699 | 3699 | // What kind of file are we going to create? |
3700 | - $toCreate = $cTempPath .'minified'. ($do_deferred ? '_deferred' : '') .'.'. $type; |
|
3700 | + $toCreate = $cTempPath . 'minified' . ($do_deferred ? '_deferred' : '') . '.' . $type; |
|
3701 | 3701 | |
3702 | 3702 | // File has to exists, if it isn't try to create it. |
3703 | 3703 | if ((!file_exists($toCreate) && @fopen($toCreate, 'w') === false) || !smf_chmod($toCreate)) |
3704 | 3704 | { |
3705 | 3705 | loadLanguage('Errors'); |
3706 | 3706 | log_error(sprintf($txt['file_not_created'], $toCreate), 'general'); |
3707 | - cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, null); |
|
3707 | + cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, null); |
|
3708 | 3708 | |
3709 | 3709 | // The process failed so roll back to print each individual file. |
3710 | 3710 | return $data; |
@@ -3739,14 +3739,14 @@ discard block |
||
3739 | 3739 | { |
3740 | 3740 | loadLanguage('Errors'); |
3741 | 3741 | log_error(sprintf($txt['file_not_created'], $toCreate), 'general'); |
3742 | - cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, null); |
|
3742 | + cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, null); |
|
3743 | 3743 | |
3744 | 3744 | // The process failed so roll back to print each individual file. |
3745 | 3745 | return $data; |
3746 | 3746 | } |
3747 | 3747 | |
3748 | 3748 | // And create a long lived cache entry. |
3749 | - cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, $toCreate, 86400); |
|
3749 | + cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, $toCreate, 86400); |
|
3750 | 3750 | |
3751 | 3751 | return true; |
3752 | 3752 | } |
@@ -3806,7 +3806,7 @@ discard block |
||
3806 | 3806 | else |
3807 | 3807 | $path = $modSettings['attachmentUploadDir']; |
3808 | 3808 | |
3809 | - return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
|
3809 | + return $path . '/' . $attachment_id . '_' . $file_hash . '.dat'; |
|
3810 | 3810 | } |
3811 | 3811 | |
3812 | 3812 | /** |
@@ -3850,10 +3850,10 @@ discard block |
||
3850 | 3850 | $valid_low = isValidIP($ip_parts[0]); |
3851 | 3851 | $valid_high = isValidIP($ip_parts[1]); |
3852 | 3852 | $count = 0; |
3853 | - $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
|
3853 | + $mode = (preg_match('/:/', $ip_parts[0]) > 0 ? ':' : '.'); |
|
3854 | 3854 | $max = ($mode == ':' ? 'ffff' : '255'); |
3855 | 3855 | $min = 0; |
3856 | - if(!$valid_low) |
|
3856 | + if (!$valid_low) |
|
3857 | 3857 | { |
3858 | 3858 | $ip_parts[0] = preg_replace('/\*/', '0', $ip_parts[0]); |
3859 | 3859 | $valid_low = isValidIP($ip_parts[0]); |
@@ -3867,7 +3867,7 @@ discard block |
||
3867 | 3867 | } |
3868 | 3868 | |
3869 | 3869 | $count = 0; |
3870 | - if(!$valid_high) |
|
3870 | + if (!$valid_high) |
|
3871 | 3871 | { |
3872 | 3872 | $ip_parts[1] = preg_replace('/\*/', $max, $ip_parts[1]); |
3873 | 3873 | $valid_high = isValidIP($ip_parts[1]); |
@@ -3880,7 +3880,7 @@ discard block |
||
3880 | 3880 | } |
3881 | 3881 | } |
3882 | 3882 | |
3883 | - if($valid_high && $valid_low) |
|
3883 | + if ($valid_high && $valid_low) |
|
3884 | 3884 | { |
3885 | 3885 | $ip_array['low'] = $ip_parts[0]; |
3886 | 3886 | $ip_array['high'] = $ip_parts[1]; |
@@ -4062,7 +4062,7 @@ discard block |
||
4062 | 4062 | addInlineJavaScript(' |
4063 | 4063 | var user_menus = new smc_PopupMenu(); |
4064 | 4064 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
4065 | - user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
|
4065 | + user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u=' . $context['user']['id'] . '");', true); |
|
4066 | 4066 | if ($context['allow_pm']) |
4067 | 4067 | addInlineJavaScript(' |
4068 | 4068 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
@@ -4682,7 +4682,7 @@ discard block |
||
4682 | 4682 | // No? try a fallback to $sourcedir |
4683 | 4683 | else |
4684 | 4684 | { |
4685 | - $absPath = $sourcedir .'/'. $file; |
|
4685 | + $absPath = $sourcedir . '/' . $file; |
|
4686 | 4686 | |
4687 | 4687 | if (file_exists($absPath)) |
4688 | 4688 | require_once($absPath); |
@@ -4763,15 +4763,15 @@ discard block |
||
4763 | 4763 | |
4764 | 4764 | // UTF-8 occurences of MS special characters |
4765 | 4765 | $findchars_utf8 = array( |
4766 | - "\xe2\x80\x9a", // single low-9 quotation mark |
|
4767 | - "\xe2\x80\x9e", // double low-9 quotation mark |
|
4768 | - "\xe2\x80\xa6", // horizontal ellipsis |
|
4769 | - "\xe2\x80\x98", // left single curly quote |
|
4770 | - "\xe2\x80\x99", // right single curly quote |
|
4771 | - "\xe2\x80\x9c", // left double curly quote |
|
4772 | - "\xe2\x80\x9d", // right double curly quote |
|
4773 | - "\xe2\x80\x93", // en dash |
|
4774 | - "\xe2\x80\x94", // em dash |
|
4766 | + "\xe2\x80\x9a", // single low-9 quotation mark |
|
4767 | + "\xe2\x80\x9e", // double low-9 quotation mark |
|
4768 | + "\xe2\x80\xa6", // horizontal ellipsis |
|
4769 | + "\xe2\x80\x98", // left single curly quote |
|
4770 | + "\xe2\x80\x99", // right single curly quote |
|
4771 | + "\xe2\x80\x9c", // left double curly quote |
|
4772 | + "\xe2\x80\x9d", // right double curly quote |
|
4773 | + "\xe2\x80\x93", // en dash |
|
4774 | + "\xe2\x80\x94", // em dash |
|
4775 | 4775 | ); |
4776 | 4776 | |
4777 | 4777 | // windows 1252 / iso equivalents |
@@ -4789,15 +4789,15 @@ discard block |
||
4789 | 4789 | |
4790 | 4790 | // safe replacements |
4791 | 4791 | $replacechars = array( |
4792 | - ',', // ‚ |
|
4793 | - ',,', // „ |
|
4794 | - '...', // … |
|
4795 | - "'", // ‘ |
|
4796 | - "'", // ’ |
|
4797 | - '"', // “ |
|
4798 | - '"', // ” |
|
4799 | - '-', // – |
|
4800 | - '--', // — |
|
4792 | + ',', // ‚ |
|
4793 | + ',,', // „ |
|
4794 | + '...', // … |
|
4795 | + "'", // ‘ |
|
4796 | + "'", // ’ |
|
4797 | + '"', // “ |
|
4798 | + '"', // ” |
|
4799 | + '-', // – |
|
4800 | + '--', // — |
|
4801 | 4801 | ); |
4802 | 4802 | |
4803 | 4803 | if ($context['utf8']) |
@@ -5216,7 +5216,7 @@ discard block |
||
5216 | 5216 | */ |
5217 | 5217 | function inet_dtop($bin) |
5218 | 5218 | { |
5219 | - if(empty($bin)) |
|
5219 | + if (empty($bin)) |
|
5220 | 5220 | return ''; |
5221 | 5221 | |
5222 | 5222 | global $db_type; |
@@ -5247,28 +5247,28 @@ discard block |
||
5247 | 5247 | */ |
5248 | 5248 | function _safe_serialize($value) |
5249 | 5249 | { |
5250 | - if(is_null($value)) |
|
5250 | + if (is_null($value)) |
|
5251 | 5251 | return 'N;'; |
5252 | 5252 | |
5253 | - if(is_bool($value)) |
|
5254 | - return 'b:'. (int) $value .';'; |
|
5253 | + if (is_bool($value)) |
|
5254 | + return 'b:' . (int) $value . ';'; |
|
5255 | 5255 | |
5256 | - if(is_int($value)) |
|
5257 | - return 'i:'. $value .';'; |
|
5256 | + if (is_int($value)) |
|
5257 | + return 'i:' . $value . ';'; |
|
5258 | 5258 | |
5259 | - if(is_float($value)) |
|
5260 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
5259 | + if (is_float($value)) |
|
5260 | + return 'd:' . str_replace(',', '.', $value) . ';'; |
|
5261 | 5261 | |
5262 | - if(is_string($value)) |
|
5263 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
5262 | + if (is_string($value)) |
|
5263 | + return 's:' . strlen($value) . ':"' . $value . '";'; |
|
5264 | 5264 | |
5265 | - if(is_array($value)) |
|
5265 | + if (is_array($value)) |
|
5266 | 5266 | { |
5267 | 5267 | $out = ''; |
5268 | - foreach($value as $k => $v) |
|
5268 | + foreach ($value as $k => $v) |
|
5269 | 5269 | $out .= _safe_serialize($k) . _safe_serialize($v); |
5270 | 5270 | |
5271 | - return 'a:'. count($value) .':{'. $out .'}'; |
|
5271 | + return 'a:' . count($value) . ':{' . $out . '}'; |
|
5272 | 5272 | } |
5273 | 5273 | |
5274 | 5274 | // safe_serialize cannot serialize resources or objects. |
@@ -5310,7 +5310,7 @@ discard block |
||
5310 | 5310 | function _safe_unserialize($str) |
5311 | 5311 | { |
5312 | 5312 | // Input is not a string. |
5313 | - if(empty($str) || !is_string($str)) |
|
5313 | + if (empty($str) || !is_string($str)) |
|
5314 | 5314 | return false; |
5315 | 5315 | |
5316 | 5316 | $stack = array(); |
@@ -5324,40 +5324,40 @@ discard block |
||
5324 | 5324 | * 3 - in array, expecting value or another array |
5325 | 5325 | */ |
5326 | 5326 | $state = 0; |
5327 | - while($state != 1) |
|
5327 | + while ($state != 1) |
|
5328 | 5328 | { |
5329 | 5329 | $type = isset($str[0]) ? $str[0] : ''; |
5330 | - if($type == '}') |
|
5330 | + if ($type == '}') |
|
5331 | 5331 | $str = substr($str, 1); |
5332 | 5332 | |
5333 | - else if($type == 'N' && $str[1] == ';') |
|
5333 | + else if ($type == 'N' && $str[1] == ';') |
|
5334 | 5334 | { |
5335 | 5335 | $value = null; |
5336 | 5336 | $str = substr($str, 2); |
5337 | 5337 | } |
5338 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5338 | + else if ($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5339 | 5339 | { |
5340 | 5340 | $value = $matches[1] == '1' ? true : false; |
5341 | 5341 | $str = substr($str, 4); |
5342 | 5342 | } |
5343 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5343 | + else if ($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5344 | 5344 | { |
5345 | - $value = (int)$matches[1]; |
|
5345 | + $value = (int) $matches[1]; |
|
5346 | 5346 | $str = $matches[2]; |
5347 | 5347 | } |
5348 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5348 | + else if ($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5349 | 5349 | { |
5350 | - $value = (float)$matches[1]; |
|
5350 | + $value = (float) $matches[1]; |
|
5351 | 5351 | $str = $matches[3]; |
5352 | 5352 | } |
5353 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
5353 | + else if ($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int) $matches[1], 2) == '";') |
|
5354 | 5354 | { |
5355 | - $value = substr($matches[2], 0, (int)$matches[1]); |
|
5356 | - $str = substr($matches[2], (int)$matches[1] + 2); |
|
5355 | + $value = substr($matches[2], 0, (int) $matches[1]); |
|
5356 | + $str = substr($matches[2], (int) $matches[1] + 2); |
|
5357 | 5357 | } |
5358 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5358 | + else if ($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5359 | 5359 | { |
5360 | - $expectedLength = (int)$matches[1]; |
|
5360 | + $expectedLength = (int) $matches[1]; |
|
5361 | 5361 | $str = $matches[2]; |
5362 | 5362 | } |
5363 | 5363 | |
@@ -5365,10 +5365,10 @@ discard block |
||
5365 | 5365 | else |
5366 | 5366 | return false; |
5367 | 5367 | |
5368 | - switch($state) |
|
5368 | + switch ($state) |
|
5369 | 5369 | { |
5370 | 5370 | case 3: // In array, expecting value or another array. |
5371 | - if($type == 'a') |
|
5371 | + if ($type == 'a') |
|
5372 | 5372 | { |
5373 | 5373 | $stack[] = &$list; |
5374 | 5374 | $list[$key] = array(); |
@@ -5377,7 +5377,7 @@ discard block |
||
5377 | 5377 | $state = 2; |
5378 | 5378 | break; |
5379 | 5379 | } |
5380 | - if($type != '}') |
|
5380 | + if ($type != '}') |
|
5381 | 5381 | { |
5382 | 5382 | $list[$key] = $value; |
5383 | 5383 | $state = 2; |
@@ -5388,29 +5388,29 @@ discard block |
||
5388 | 5388 | return false; |
5389 | 5389 | |
5390 | 5390 | case 2: // in array, expecting end of array or a key |
5391 | - if($type == '}') |
|
5391 | + if ($type == '}') |
|
5392 | 5392 | { |
5393 | 5393 | // Array size is less than expected. |
5394 | - if(count($list) < end($expected)) |
|
5394 | + if (count($list) < end($expected)) |
|
5395 | 5395 | return false; |
5396 | 5396 | |
5397 | 5397 | unset($list); |
5398 | - $list = &$stack[count($stack)-1]; |
|
5398 | + $list = &$stack[count($stack) - 1]; |
|
5399 | 5399 | array_pop($stack); |
5400 | 5400 | |
5401 | 5401 | // Go to terminal state if we're at the end of the root array. |
5402 | 5402 | array_pop($expected); |
5403 | 5403 | |
5404 | - if(count($expected) == 0) |
|
5404 | + if (count($expected) == 0) |
|
5405 | 5405 | $state = 1; |
5406 | 5406 | |
5407 | 5407 | break; |
5408 | 5408 | } |
5409 | 5409 | |
5410 | - if($type == 'i' || $type == 's') |
|
5410 | + if ($type == 'i' || $type == 's') |
|
5411 | 5411 | { |
5412 | 5412 | // Array size exceeds expected length. |
5413 | - if(count($list) >= end($expected)) |
|
5413 | + if (count($list) >= end($expected)) |
|
5414 | 5414 | return false; |
5415 | 5415 | |
5416 | 5416 | $key = $value; |
@@ -5423,7 +5423,7 @@ discard block |
||
5423 | 5423 | |
5424 | 5424 | // Expecting array or value. |
5425 | 5425 | case 0: |
5426 | - if($type == 'a') |
|
5426 | + if ($type == 'a') |
|
5427 | 5427 | { |
5428 | 5428 | $data = array(); |
5429 | 5429 | $list = &$data; |
@@ -5432,7 +5432,7 @@ discard block |
||
5432 | 5432 | break; |
5433 | 5433 | } |
5434 | 5434 | |
5435 | - if($type != '}') |
|
5435 | + if ($type != '}') |
|
5436 | 5436 | { |
5437 | 5437 | $data = $value; |
5438 | 5438 | $state = 1; |
@@ -5445,7 +5445,7 @@ discard block |
||
5445 | 5445 | } |
5446 | 5446 | |
5447 | 5447 | // Trailing data in input. |
5448 | - if(!empty($str)) |
|
5448 | + if (!empty($str)) |
|
5449 | 5449 | return false; |
5450 | 5450 | |
5451 | 5451 | return $data; |
@@ -5499,7 +5499,7 @@ discard block |
||
5499 | 5499 | // Set different modes. |
5500 | 5500 | $chmodValues = $isDir ? array(0750, 0755, 0775, 0777) : array(0644, 0664, 0666); |
5501 | 5501 | |
5502 | - foreach($chmodValues as $val) |
|
5502 | + foreach ($chmodValues as $val) |
|
5503 | 5503 | { |
5504 | 5504 | // If it's writable, break out of the loop. |
5505 | 5505 | if (is_writable($file)) |
@@ -5534,13 +5534,13 @@ discard block |
||
5534 | 5534 | $returnArray = @json_decode($json, $returnAsArray); |
5535 | 5535 | |
5536 | 5536 | // PHP 5.3 so no json_last_error_msg() |
5537 | - switch(json_last_error()) |
|
5537 | + switch (json_last_error()) |
|
5538 | 5538 | { |
5539 | 5539 | case JSON_ERROR_NONE: |
5540 | 5540 | $jsonError = false; |
5541 | 5541 | break; |
5542 | 5542 | case JSON_ERROR_DEPTH: |
5543 | - $jsonError = 'JSON_ERROR_DEPTH'; |
|
5543 | + $jsonError = 'JSON_ERROR_DEPTH'; |
|
5544 | 5544 | break; |
5545 | 5545 | case JSON_ERROR_STATE_MISMATCH: |
5546 | 5546 | $jsonError = 'JSON_ERROR_STATE_MISMATCH'; |
@@ -5568,10 +5568,10 @@ discard block |
||
5568 | 5568 | loadLanguage('Errors'); |
5569 | 5569 | |
5570 | 5570 | if (!empty($jsonDebug)) |
5571 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
5571 | + log_error($txt['json_' . $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
5572 | 5572 | |
5573 | 5573 | else |
5574 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
5574 | + log_error($txt['json_' . $jsonError], 'critical'); |
|
5575 | 5575 | |
5576 | 5576 | // Everyone expects an array. |
5577 | 5577 | return array(); |
@@ -5675,7 +5675,7 @@ discard block |
||
5675 | 5675 | }); |
5676 | 5676 | |
5677 | 5677 | // Convert Punycode to Unicode |
5678 | - $tlds = array_map(function ($input) { |
|
5678 | + $tlds = array_map(function($input) { |
|
5679 | 5679 | $prefix = 'xn--'; |
5680 | 5680 | $safe_char = 0xFFFC; |
5681 | 5681 | $base = 36; |
@@ -5691,7 +5691,7 @@ discard block |
||
5691 | 5691 | |
5692 | 5692 | foreach ($enco_parts as $encoded) |
5693 | 5693 | { |
5694 | - if (strpos($encoded,$prefix) !== 0 || strlen(trim(str_replace($prefix,'',$encoded))) == 0) |
|
5694 | + if (strpos($encoded, $prefix) !== 0 || strlen(trim(str_replace($prefix, '', $encoded))) == 0) |
|
5695 | 5695 | { |
5696 | 5696 | $output_parts[] = $encoded; |
5697 | 5697 | continue; |
@@ -5702,7 +5702,7 @@ discard block |
||
5702 | 5702 | $idx = 0; |
5703 | 5703 | $char = 0x80; |
5704 | 5704 | $decoded = array(); |
5705 | - $output=''; |
|
5705 | + $output = ''; |
|
5706 | 5706 | $delim_pos = strrpos($encoded, '-'); |
5707 | 5707 | |
5708 | 5708 | if ($delim_pos > strlen($prefix)) |
@@ -5718,7 +5718,7 @@ discard block |
||
5718 | 5718 | |
5719 | 5719 | for ($enco_idx = $delim_pos ? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len) |
5720 | 5720 | { |
5721 | - for ($old_idx = $idx, $w = 1, $k = $base; 1 ; $k += $base) |
|
5721 | + for ($old_idx = $idx, $w = 1, $k = $base; 1; $k += $base) |
|
5722 | 5722 | { |
5723 | 5723 | $cp = ord($encoded{$enco_idx++}); |
5724 | 5724 | $digit = ($cp - 48 < 10) ? $cp - 22 : (($cp - 65 < 26) ? $cp - 65 : (($cp - 97 < 26) ? $cp - 97 : $base)); |
@@ -5759,15 +5759,15 @@ discard block |
||
5759 | 5759 | |
5760 | 5760 | // 2 bytes |
5761 | 5761 | elseif ($v < (1 << 11)) |
5762 | - $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
5762 | + $output .= chr(192 + ($v >> 6)) . chr(128 + ($v & 63)); |
|
5763 | 5763 | |
5764 | 5764 | // 3 bytes |
5765 | 5765 | elseif ($v < (1 << 16)) |
5766 | - $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
5766 | + $output .= chr(224 + ($v >> 12)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63)); |
|
5767 | 5767 | |
5768 | 5768 | // 4 bytes |
5769 | 5769 | elseif ($v < (1 << 21)) |
5770 | - $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
5770 | + $output .= chr(240 + ($v >> 18)) . chr(128 + (($v >> 12) & 63)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63)); |
|
5771 | 5771 | |
5772 | 5772 | // 'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k |
5773 | 5773 | else |
@@ -5873,7 +5873,7 @@ discard block |
||
5873 | 5873 | } |
5874 | 5874 | |
5875 | 5875 | // This recursive function creates the index array from the strings |
5876 | - $add_string_to_index = function ($string, $index) use (&$strlen, &$substr, &$add_string_to_index) |
|
5876 | + $add_string_to_index = function($string, $index) use (&$strlen, &$substr, &$add_string_to_index) |
|
5877 | 5877 | { |
5878 | 5878 | static $depth = 0; |
5879 | 5879 | $depth++; |
@@ -5900,7 +5900,7 @@ discard block |
||
5900 | 5900 | }; |
5901 | 5901 | |
5902 | 5902 | // This recursive function turns the index array into a regular expression |
5903 | - $index_to_regex = function (&$index, $delim) use (&$strlen, &$index_to_regex) |
|
5903 | + $index_to_regex = function(&$index, $delim) use (&$strlen, &$index_to_regex) |
|
5904 | 5904 | { |
5905 | 5905 | static $depth = 0; |
5906 | 5906 | $depth++; |
@@ -5924,11 +5924,11 @@ discard block |
||
5924 | 5924 | |
5925 | 5925 | if (count(array_keys($value)) == 1) |
5926 | 5926 | { |
5927 | - $new_key_array = explode('(?'.'>', $sub_regex); |
|
5927 | + $new_key_array = explode('(?' . '>', $sub_regex); |
|
5928 | 5928 | $new_key .= $new_key_array[0]; |
5929 | 5929 | } |
5930 | 5930 | else |
5931 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
5931 | + $sub_regex = '(?' . '>' . $sub_regex . ')'; |
|
5932 | 5932 | } |
5933 | 5933 | |
5934 | 5934 | if ($depth > 1) |
@@ -5971,10 +5971,10 @@ discard block |
||
5971 | 5971 | { |
5972 | 5972 | $regex = array(); |
5973 | 5973 | while (!empty($index)) |
5974 | - $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
5974 | + $regex[] = '(?' . '>' . $index_to_regex($index, $delim) . ')'; |
|
5975 | 5975 | } |
5976 | 5976 | else |
5977 | - $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
5977 | + $regex = '(?' . '>' . $index_to_regex($index, $delim) . ')'; |
|
5978 | 5978 | |
5979 | 5979 | // Restore PHP's internal character encoding to whatever it was originally |
5980 | 5980 | if (!empty($current_encoding)) |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
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 | * Update some basic statistics. |
@@ -122,10 +123,11 @@ discard block |
||
122 | 123 | $smcFunc['db_free_result']($result); |
123 | 124 | |
124 | 125 | // Add this to the number of unapproved members |
125 | - if (!empty($changes['unapprovedMembers'])) |
|
126 | - $changes['unapprovedMembers'] += $coppa_approvals; |
|
127 | - else |
|
128 | - $changes['unapprovedMembers'] = $coppa_approvals; |
|
126 | + if (!empty($changes['unapprovedMembers'])) { |
|
127 | + $changes['unapprovedMembers'] += $coppa_approvals; |
|
128 | + } else { |
|
129 | + $changes['unapprovedMembers'] = $coppa_approvals; |
|
130 | + } |
|
129 | 131 | } |
130 | 132 | } |
131 | 133 | } |
@@ -133,9 +135,9 @@ discard block |
||
133 | 135 | break; |
134 | 136 | |
135 | 137 | case 'message': |
136 | - if ($parameter1 === true && $parameter2 !== null) |
|
137 | - updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true); |
|
138 | - else |
|
138 | + if ($parameter1 === true && $parameter2 !== null) { |
|
139 | + updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true); |
|
140 | + } else |
|
139 | 141 | { |
140 | 142 | // SUM and MAX on a smaller table is better for InnoDB tables. |
141 | 143 | $result = $smcFunc['db_query']('', ' |
@@ -175,23 +177,25 @@ discard block |
||
175 | 177 | $parameter2 = text2words($parameter2); |
176 | 178 | |
177 | 179 | $inserts = array(); |
178 | - foreach ($parameter2 as $word) |
|
179 | - $inserts[] = array($word, $parameter1); |
|
180 | + foreach ($parameter2 as $word) { |
|
181 | + $inserts[] = array($word, $parameter1); |
|
182 | + } |
|
180 | 183 | |
181 | - if (!empty($inserts)) |
|
182 | - $smcFunc['db_insert']('ignore', |
|
184 | + if (!empty($inserts)) { |
|
185 | + $smcFunc['db_insert']('ignore', |
|
183 | 186 | '{db_prefix}log_search_subjects', |
184 | 187 | array('word' => 'string', 'id_topic' => 'int'), |
185 | 188 | $inserts, |
186 | 189 | array('word', 'id_topic') |
187 | 190 | ); |
191 | + } |
|
188 | 192 | } |
189 | 193 | break; |
190 | 194 | |
191 | 195 | case 'topic': |
192 | - if ($parameter1 === true) |
|
193 | - updateSettings(array('totalTopics' => true), true); |
|
194 | - else |
|
196 | + if ($parameter1 === true) { |
|
197 | + updateSettings(array('totalTopics' => true), true); |
|
198 | + } else |
|
195 | 199 | { |
196 | 200 | // Get the number of topics - a SUM is better for InnoDB tables. |
197 | 201 | // We also ignore the recycle bin here because there will probably be a bunch of one-post topics there. |
@@ -212,8 +216,9 @@ discard block |
||
212 | 216 | |
213 | 217 | case 'postgroups': |
214 | 218 | // Parameter two is the updated columns: we should check to see if we base groups off any of these. |
215 | - if ($parameter2 !== null && !in_array('posts', $parameter2)) |
|
216 | - return; |
|
219 | + if ($parameter2 !== null && !in_array('posts', $parameter2)) { |
|
220 | + return; |
|
221 | + } |
|
217 | 222 | |
218 | 223 | $postgroups = cache_get_data('updateStats:postgroups', 360); |
219 | 224 | if ($postgroups == null || $parameter1 == null) |
@@ -228,8 +233,9 @@ discard block |
||
228 | 233 | ) |
229 | 234 | ); |
230 | 235 | $postgroups = array(); |
231 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
232 | - $postgroups[$row['id_group']] = $row['min_posts']; |
|
236 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
237 | + $postgroups[$row['id_group']] = $row['min_posts']; |
|
238 | + } |
|
233 | 239 | $smcFunc['db_free_result']($request); |
234 | 240 | |
235 | 241 | // Sort them this way because if it's done with MySQL it causes a filesort :(. |
@@ -239,8 +245,9 @@ discard block |
||
239 | 245 | } |
240 | 246 | |
241 | 247 | // Oh great, they've screwed their post groups. |
242 | - if (empty($postgroups)) |
|
243 | - return; |
|
248 | + if (empty($postgroups)) { |
|
249 | + return; |
|
250 | + } |
|
244 | 251 | |
245 | 252 | // Set all membergroups from most posts to least posts. |
246 | 253 | $conditions = ''; |
@@ -298,10 +305,9 @@ discard block |
||
298 | 305 | { |
299 | 306 | $condition = 'id_member IN ({array_int:members})'; |
300 | 307 | $parameters['members'] = $members; |
301 | - } |
|
302 | - elseif ($members === null) |
|
303 | - $condition = '1=1'; |
|
304 | - else |
|
308 | + } elseif ($members === null) { |
|
309 | + $condition = '1=1'; |
|
310 | + } else |
|
305 | 311 | { |
306 | 312 | $condition = 'id_member = {int:member}'; |
307 | 313 | $parameters['member'] = $members; |
@@ -341,9 +347,9 @@ discard block |
||
341 | 347 | if (count($vars_to_integrate) != 0) |
342 | 348 | { |
343 | 349 | // Fetch a list of member_names if necessary |
344 | - if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) |
|
345 | - $member_names = array($user_info['username']); |
|
346 | - else |
|
350 | + if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) { |
|
351 | + $member_names = array($user_info['username']); |
|
352 | + } else |
|
347 | 353 | { |
348 | 354 | $member_names = array(); |
349 | 355 | $request = $smcFunc['db_query']('', ' |
@@ -352,14 +358,16 @@ discard block |
||
352 | 358 | WHERE ' . $condition, |
353 | 359 | $parameters |
354 | 360 | ); |
355 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
356 | - $member_names[] = $row['member_name']; |
|
361 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
362 | + $member_names[] = $row['member_name']; |
|
363 | + } |
|
357 | 364 | $smcFunc['db_free_result']($request); |
358 | 365 | } |
359 | 366 | |
360 | - if (!empty($member_names)) |
|
361 | - foreach ($vars_to_integrate as $var) |
|
367 | + if (!empty($member_names)) { |
|
368 | + foreach ($vars_to_integrate as $var) |
|
362 | 369 | call_integration_hook('integrate_change_member_data', array($member_names, $var, &$data[$var], &$knownInts, &$knownFloats)); |
370 | + } |
|
363 | 371 | } |
364 | 372 | } |
365 | 373 | |
@@ -367,16 +375,17 @@ discard block |
||
367 | 375 | foreach ($data as $var => $val) |
368 | 376 | { |
369 | 377 | $type = 'string'; |
370 | - if (in_array($var, $knownInts)) |
|
371 | - $type = 'int'; |
|
372 | - elseif (in_array($var, $knownFloats)) |
|
373 | - $type = 'float'; |
|
374 | - elseif ($var == 'birthdate') |
|
375 | - $type = 'date'; |
|
376 | - elseif ($var == 'member_ip') |
|
377 | - $type = 'inet'; |
|
378 | - elseif ($var == 'member_ip2') |
|
379 | - $type = 'inet'; |
|
378 | + if (in_array($var, $knownInts)) { |
|
379 | + $type = 'int'; |
|
380 | + } elseif (in_array($var, $knownFloats)) { |
|
381 | + $type = 'float'; |
|
382 | + } elseif ($var == 'birthdate') { |
|
383 | + $type = 'date'; |
|
384 | + } elseif ($var == 'member_ip') { |
|
385 | + $type = 'inet'; |
|
386 | + } elseif ($var == 'member_ip2') { |
|
387 | + $type = 'inet'; |
|
388 | + } |
|
380 | 389 | |
381 | 390 | // Doing an increment? |
382 | 391 | if ($type == 'int' && ($val === '+' || $val === '-')) |
@@ -390,8 +399,9 @@ discard block |
||
390 | 399 | { |
391 | 400 | if (preg_match('~^' . $var . ' (\+ |- |\+ -)([\d]+)~', $val, $match)) |
392 | 401 | { |
393 | - if ($match[1] != '+ ') |
|
394 | - $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
402 | + if ($match[1] != '+ ') { |
|
403 | + $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
404 | + } |
|
395 | 405 | $type = 'raw'; |
396 | 406 | } |
397 | 407 | } |
@@ -412,8 +422,9 @@ discard block |
||
412 | 422 | // Clear any caching? |
413 | 423 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && !empty($members)) |
414 | 424 | { |
415 | - if (!is_array($members)) |
|
416 | - $members = array($members); |
|
425 | + if (!is_array($members)) { |
|
426 | + $members = array($members); |
|
427 | + } |
|
417 | 428 | |
418 | 429 | foreach ($members as $member) |
419 | 430 | { |
@@ -446,29 +457,32 @@ discard block |
||
446 | 457 | { |
447 | 458 | global $modSettings, $smcFunc; |
448 | 459 | |
449 | - if (empty($changeArray) || !is_array($changeArray)) |
|
450 | - return; |
|
460 | + if (empty($changeArray) || !is_array($changeArray)) { |
|
461 | + return; |
|
462 | + } |
|
451 | 463 | |
452 | 464 | $toRemove = array(); |
453 | 465 | |
454 | 466 | // Go check if there is any setting to be removed. |
455 | - foreach ($changeArray as $k => $v) |
|
456 | - if ($v === null) |
|
467 | + foreach ($changeArray as $k => $v) { |
|
468 | + if ($v === null) |
|
457 | 469 | { |
458 | 470 | // Found some, remove them from the original array and add them to ours. |
459 | 471 | unset($changeArray[$k]); |
472 | + } |
|
460 | 473 | $toRemove[] = $k; |
461 | 474 | } |
462 | 475 | |
463 | 476 | // Proceed with the deletion. |
464 | - if (!empty($toRemove)) |
|
465 | - $smcFunc['db_query']('', ' |
|
477 | + if (!empty($toRemove)) { |
|
478 | + $smcFunc['db_query']('', ' |
|
466 | 479 | DELETE FROM {db_prefix}settings |
467 | 480 | WHERE variable IN ({array_string:remove})', |
468 | 481 | array( |
469 | 482 | 'remove' => $toRemove, |
470 | 483 | ) |
471 | 484 | ); |
485 | + } |
|
472 | 486 | |
473 | 487 | // In some cases, this may be better and faster, but for large sets we don't want so many UPDATEs. |
474 | 488 | if ($update) |
@@ -497,19 +511,22 @@ discard block |
||
497 | 511 | foreach ($changeArray as $variable => $value) |
498 | 512 | { |
499 | 513 | // Don't bother if it's already like that ;). |
500 | - if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) |
|
501 | - continue; |
|
514 | + if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) { |
|
515 | + continue; |
|
516 | + } |
|
502 | 517 | // If the variable isn't set, but would only be set to nothing'ness, then don't bother setting it. |
503 | - elseif (!isset($modSettings[$variable]) && empty($value)) |
|
504 | - continue; |
|
518 | + elseif (!isset($modSettings[$variable]) && empty($value)) { |
|
519 | + continue; |
|
520 | + } |
|
505 | 521 | |
506 | 522 | $replaceArray[] = array($variable, $value); |
507 | 523 | |
508 | 524 | $modSettings[$variable] = $value; |
509 | 525 | } |
510 | 526 | |
511 | - if (empty($replaceArray)) |
|
512 | - return; |
|
527 | + if (empty($replaceArray)) { |
|
528 | + return; |
|
529 | + } |
|
513 | 530 | |
514 | 531 | $smcFunc['db_insert']('replace', |
515 | 532 | '{db_prefix}settings', |
@@ -555,14 +572,17 @@ discard block |
||
555 | 572 | $start_invalid = $start < 0; |
556 | 573 | |
557 | 574 | // Make sure $start is a proper variable - not less than 0. |
558 | - if ($start_invalid) |
|
559 | - $start = 0; |
|
575 | + if ($start_invalid) { |
|
576 | + $start = 0; |
|
577 | + } |
|
560 | 578 | // Not greater than the upper bound. |
561 | - elseif ($start >= $max_value) |
|
562 | - $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
579 | + elseif ($start >= $max_value) { |
|
580 | + $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
581 | + } |
|
563 | 582 | // And it has to be a multiple of $num_per_page! |
564 | - else |
|
565 | - $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
583 | + else { |
|
584 | + $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
585 | + } |
|
566 | 586 | |
567 | 587 | $context['current_page'] = $start / $num_per_page; |
568 | 588 | |
@@ -592,77 +612,87 @@ discard block |
||
592 | 612 | |
593 | 613 | // Show all the pages. |
594 | 614 | $display_page = 1; |
595 | - for ($counter = 0; $counter < $max_value; $counter += $num_per_page) |
|
596 | - $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
615 | + for ($counter = 0; $counter < $max_value; $counter += $num_per_page) { |
|
616 | + $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
617 | + } |
|
597 | 618 | |
598 | 619 | // Show the right arrow. |
599 | 620 | $display_page = ($start + $num_per_page) > $max_value ? $max_value : ($start + $num_per_page); |
600 | - if ($start != $counter - $max_value && !$start_invalid) |
|
601 | - $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
602 | - } |
|
603 | - else |
|
621 | + if ($start != $counter - $max_value && !$start_invalid) { |
|
622 | + $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
623 | + } |
|
624 | + } else |
|
604 | 625 | { |
605 | 626 | // If they didn't enter an odd value, pretend they did. |
606 | 627 | $PageContiguous = (int) ($modSettings['compactTopicPagesContiguous'] - ($modSettings['compactTopicPagesContiguous'] % 2)) / 2; |
607 | 628 | |
608 | 629 | // Show the "prev page" link. (>prev page< 1 ... 6 7 [8] 9 10 ... 15 next page) |
609 | - if (!empty($start) && $show_prevnext) |
|
610 | - $pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
611 | - else |
|
612 | - $pageindex .= ''; |
|
630 | + if (!empty($start) && $show_prevnext) { |
|
631 | + $pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
632 | + } else { |
|
633 | + $pageindex .= ''; |
|
634 | + } |
|
613 | 635 | |
614 | 636 | // Show the first page. (prev page >1< ... 6 7 [8] 9 10 ... 15) |
615 | - if ($start > $num_per_page * $PageContiguous) |
|
616 | - $pageindex .= sprintf($base_link, 0, '1'); |
|
637 | + if ($start > $num_per_page * $PageContiguous) { |
|
638 | + $pageindex .= sprintf($base_link, 0, '1'); |
|
639 | + } |
|
617 | 640 | |
618 | 641 | // Show the ... after the first page. (prev page 1 >...< 6 7 [8] 9 10 ... 15 next page) |
619 | - if ($start > $num_per_page * ($PageContiguous + 1)) |
|
620 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
642 | + if ($start > $num_per_page * ($PageContiguous + 1)) { |
|
643 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
621 | 644 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
622 | 645 | '{FIRST_PAGE}' => $num_per_page, |
623 | 646 | '{LAST_PAGE}' => $start - $num_per_page * $PageContiguous, |
624 | 647 | '{PER_PAGE}' => $num_per_page, |
625 | 648 | )); |
649 | + } |
|
626 | 650 | |
627 | 651 | // Show the pages before the current one. (prev page 1 ... >6 7< [8] 9 10 ... 15 next page) |
628 | - for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) |
|
629 | - if ($start >= $num_per_page * $nCont) |
|
652 | + for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) { |
|
653 | + if ($start >= $num_per_page * $nCont) |
|
630 | 654 | { |
631 | 655 | $tmpStart = $start - $num_per_page * $nCont; |
656 | + } |
|
632 | 657 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
633 | 658 | } |
634 | 659 | |
635 | 660 | // Show the current page. (prev page 1 ... 6 7 >[8]< 9 10 ... 15 next page) |
636 | - if (!$start_invalid) |
|
637 | - $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
638 | - else |
|
639 | - $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
661 | + if (!$start_invalid) { |
|
662 | + $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
663 | + } else { |
|
664 | + $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
665 | + } |
|
640 | 666 | |
641 | 667 | // Show the pages after the current one... (prev page 1 ... 6 7 [8] >9 10< ... 15 next page) |
642 | 668 | $tmpMaxPages = (int) (($max_value - 1) / $num_per_page) * $num_per_page; |
643 | - for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) |
|
644 | - if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
669 | + for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) { |
|
670 | + if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
645 | 671 | { |
646 | 672 | $tmpStart = $start + $num_per_page * $nCont; |
673 | + } |
|
647 | 674 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
648 | 675 | } |
649 | 676 | |
650 | 677 | // Show the '...' part near the end. (prev page 1 ... 6 7 [8] 9 10 >...< 15 next page) |
651 | - if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) |
|
652 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
678 | + if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) { |
|
679 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
653 | 680 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
654 | 681 | '{FIRST_PAGE}' => $start + $num_per_page * ($PageContiguous + 1), |
655 | 682 | '{LAST_PAGE}' => $tmpMaxPages, |
656 | 683 | '{PER_PAGE}' => $num_per_page, |
657 | 684 | )); |
685 | + } |
|
658 | 686 | |
659 | 687 | // Show the last number in the list. (prev page 1 ... 6 7 [8] 9 10 ... >15< next page) |
660 | - if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) |
|
661 | - $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
688 | + if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) { |
|
689 | + $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
690 | + } |
|
662 | 691 | |
663 | 692 | // Show the "next page" link. (prev page 1 ... 6 7 [8] 9 10 ... 15 >next page<) |
664 | - if ($start != $tmpMaxPages && $show_prevnext) |
|
665 | - $pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']); |
|
693 | + if ($start != $tmpMaxPages && $show_prevnext) { |
|
694 | + $pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']); |
|
695 | + } |
|
666 | 696 | } |
667 | 697 | $pageindex .= $settings['page_index']['extra_after']; |
668 | 698 | |
@@ -688,8 +718,9 @@ discard block |
||
688 | 718 | if ($decimal_separator === null) |
689 | 719 | { |
690 | 720 | // Not set for whatever reason? |
691 | - if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) |
|
692 | - return $number; |
|
721 | + if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) { |
|
722 | + return $number; |
|
723 | + } |
|
693 | 724 | |
694 | 725 | // Cache these each load... |
695 | 726 | $thousands_separator = $matches[1]; |
@@ -723,17 +754,20 @@ discard block |
||
723 | 754 | static $unsupportedFormats, $finalizedFormats; |
724 | 755 | |
725 | 756 | // Offset the time. |
726 | - if (!$offset_type) |
|
727 | - $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
757 | + if (!$offset_type) { |
|
758 | + $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
759 | + } |
|
728 | 760 | // Just the forum offset? |
729 | - elseif ($offset_type == 'forum') |
|
730 | - $time = $log_time + $modSettings['time_offset'] * 3600; |
|
731 | - else |
|
732 | - $time = $log_time; |
|
761 | + elseif ($offset_type == 'forum') { |
|
762 | + $time = $log_time + $modSettings['time_offset'] * 3600; |
|
763 | + } else { |
|
764 | + $time = $log_time; |
|
765 | + } |
|
733 | 766 | |
734 | 767 | // We can't have a negative date (on Windows, at least.) |
735 | - if ($log_time < 0) |
|
736 | - $log_time = 0; |
|
768 | + if ($log_time < 0) { |
|
769 | + $log_time = 0; |
|
770 | + } |
|
737 | 771 | |
738 | 772 | // Today and Yesterday? |
739 | 773 | if ($modSettings['todayMod'] >= 1 && $show_today === true) |
@@ -750,24 +784,27 @@ discard block |
||
750 | 784 | { |
751 | 785 | $h = strpos($user_info['time_format'], '%l') === false ? '%I' : '%l'; |
752 | 786 | $today_fmt = $h . ':%M' . $s . ' %p'; |
787 | + } else { |
|
788 | + $today_fmt = '%H:%M' . $s; |
|
753 | 789 | } |
754 | - else |
|
755 | - $today_fmt = '%H:%M' . $s; |
|
756 | 790 | |
757 | 791 | // Same day of the year, same year.... Today! |
758 | - if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) |
|
759 | - return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
792 | + if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) { |
|
793 | + return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
794 | + } |
|
760 | 795 | |
761 | 796 | // Day-of-year is one less and same year, or it's the first of the year and that's the last of the year... |
762 | - if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31)) |
|
763 | - return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
797 | + if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31)) { |
|
798 | + return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
799 | + } |
|
764 | 800 | } |
765 | 801 | |
766 | 802 | $str = !is_bool($show_today) ? $show_today : $user_info['time_format']; |
767 | 803 | |
768 | 804 | // Use the cached formats if available |
769 | - if (is_null($finalizedFormats)) |
|
770 | - $finalizedFormats = (array) cache_get_data('timeformatstrings', 86400); |
|
805 | + if (is_null($finalizedFormats)) { |
|
806 | + $finalizedFormats = (array) cache_get_data('timeformatstrings', 86400); |
|
807 | + } |
|
771 | 808 | |
772 | 809 | // Make a supported version for this format if we don't already have one |
773 | 810 | if (empty($finalizedFormats[$str])) |
@@ -796,8 +833,9 @@ discard block |
||
796 | 833 | ); |
797 | 834 | |
798 | 835 | // No need to do this part again if we already did it once |
799 | - if (is_null($unsupportedFormats)) |
|
800 | - $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
|
836 | + if (is_null($unsupportedFormats)) { |
|
837 | + $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
|
838 | + } |
|
801 | 839 | if (empty($unsupportedFormats)) |
802 | 840 | { |
803 | 841 | foreach($strftimeFormatSubstitutions as $format => $substitution) |
@@ -806,20 +844,23 @@ discard block |
||
806 | 844 | |
807 | 845 | // Windows will return false for unsupported formats |
808 | 846 | // Other operating systems return the format string as a literal |
809 | - if ($value === false || $value === $format) |
|
810 | - $unsupportedFormats[] = $format; |
|
847 | + if ($value === false || $value === $format) { |
|
848 | + $unsupportedFormats[] = $format; |
|
849 | + } |
|
811 | 850 | } |
812 | 851 | cache_put_data('unsupportedtimeformats', $unsupportedFormats, 86400); |
813 | 852 | } |
814 | 853 | |
815 | 854 | // Windows needs extra help if $timeformat contains something completely invalid, e.g. '%Q' |
816 | - if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') |
|
817 | - $timeformat = preg_replace('~%(?!' . implode('|', array_keys($strftimeFormatSubstitutions)) . ')~', '%', $timeformat); |
|
855 | + if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { |
|
856 | + $timeformat = preg_replace('~%(?!' . implode('|', array_keys($strftimeFormatSubstitutions)) . ')~', '%', $timeformat); |
|
857 | + } |
|
818 | 858 | |
819 | 859 | // Substitute unsupported formats with supported ones |
820 | - if (!empty($unsupportedFormats)) |
|
821 | - while (preg_match('~%(' . implode('|', $unsupportedFormats) . ')~', $timeformat, $matches)) |
|
860 | + if (!empty($unsupportedFormats)) { |
|
861 | + while (preg_match('~%(' . implode('|', $unsupportedFormats) . ')~', $timeformat, $matches)) |
|
822 | 862 | $timeformat = str_replace($matches[0], $strftimeFormatSubstitutions[$matches[1]], $timeformat); |
863 | + } |
|
823 | 864 | |
824 | 865 | // Remember this so we don't need to do it again |
825 | 866 | $finalizedFormats[$str] = $timeformat; |
@@ -828,33 +869,39 @@ discard block |
||
828 | 869 | |
829 | 870 | $str = $finalizedFormats[$str]; |
830 | 871 | |
831 | - if (!isset($locale_cache)) |
|
832 | - $locale_cache = setlocale(LC_TIME, $txt['lang_locale']); |
|
872 | + if (!isset($locale_cache)) { |
|
873 | + $locale_cache = setlocale(LC_TIME, $txt['lang_locale']); |
|
874 | + } |
|
833 | 875 | |
834 | 876 | if ($locale_cache !== false) |
835 | 877 | { |
836 | 878 | // Check if another process changed the locale |
837 | - if ($process_safe === true && setlocale(LC_TIME, '0') != $locale_cache) |
|
838 | - setlocale(LC_TIME, $txt['lang_locale']); |
|
879 | + if ($process_safe === true && setlocale(LC_TIME, '0') != $locale_cache) { |
|
880 | + setlocale(LC_TIME, $txt['lang_locale']); |
|
881 | + } |
|
839 | 882 | |
840 | - if (!isset($non_twelve_hour)) |
|
841 | - $non_twelve_hour = trim(strftime('%p')) === ''; |
|
842 | - if ($non_twelve_hour && strpos($str, '%p') !== false) |
|
843 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
883 | + if (!isset($non_twelve_hour)) { |
|
884 | + $non_twelve_hour = trim(strftime('%p')) === ''; |
|
885 | + } |
|
886 | + if ($non_twelve_hour && strpos($str, '%p') !== false) { |
|
887 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
888 | + } |
|
844 | 889 | |
845 | - foreach (array('%a', '%A', '%b', '%B') as $token) |
|
846 | - if (strpos($str, $token) !== false) |
|
890 | + foreach (array('%a', '%A', '%b', '%B') as $token) { |
|
891 | + if (strpos($str, $token) !== false) |
|
847 | 892 | $str = str_replace($token, strftime($token, $time), $str); |
848 | - } |
|
849 | - else |
|
893 | + } |
|
894 | + } else |
|
850 | 895 | { |
851 | 896 | // Do-it-yourself time localization. Fun. |
852 | - foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) |
|
853 | - if (strpos($str, $token) !== false) |
|
897 | + foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) { |
|
898 | + if (strpos($str, $token) !== false) |
|
854 | 899 | $str = str_replace($token, $txt[$text_label][(int) strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str); |
900 | + } |
|
855 | 901 | |
856 | - if (strpos($str, '%p') !== false) |
|
857 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
902 | + if (strpos($str, '%p') !== false) { |
|
903 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
904 | + } |
|
858 | 905 | } |
859 | 906 | |
860 | 907 | // Format the time and then restore any literal percent characters |
@@ -877,16 +924,19 @@ discard block |
||
877 | 924 | static $translation = array(); |
878 | 925 | |
879 | 926 | // Determine the character set... Default to UTF-8 |
880 | - if (empty($context['character_set'])) |
|
881 | - $charset = 'UTF-8'; |
|
927 | + if (empty($context['character_set'])) { |
|
928 | + $charset = 'UTF-8'; |
|
929 | + } |
|
882 | 930 | // Use ISO-8859-1 in place of non-supported ISO-8859 charsets... |
883 | - elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) |
|
884 | - $charset = 'ISO-8859-1'; |
|
885 | - else |
|
886 | - $charset = $context['character_set']; |
|
931 | + elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) { |
|
932 | + $charset = 'ISO-8859-1'; |
|
933 | + } else { |
|
934 | + $charset = $context['character_set']; |
|
935 | + } |
|
887 | 936 | |
888 | - if (empty($translation)) |
|
889 | - $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
937 | + if (empty($translation)) { |
|
938 | + $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
939 | + } |
|
890 | 940 | |
891 | 941 | return strtr($string, $translation); |
892 | 942 | } |
@@ -908,8 +958,9 @@ discard block |
||
908 | 958 | global $smcFunc; |
909 | 959 | |
910 | 960 | // It was already short enough! |
911 | - if ($smcFunc['strlen']($subject) <= $len) |
|
912 | - return $subject; |
|
961 | + if ($smcFunc['strlen']($subject) <= $len) { |
|
962 | + return $subject; |
|
963 | + } |
|
913 | 964 | |
914 | 965 | // Shorten it by the length it was too long, and strip off junk from the end. |
915 | 966 | return $smcFunc['substr']($subject, 0, $len) . '...'; |
@@ -928,10 +979,11 @@ discard block |
||
928 | 979 | { |
929 | 980 | global $user_info, $modSettings; |
930 | 981 | |
931 | - if ($timestamp === null) |
|
932 | - $timestamp = time(); |
|
933 | - elseif ($timestamp == 0) |
|
934 | - return 0; |
|
982 | + if ($timestamp === null) { |
|
983 | + $timestamp = time(); |
|
984 | + } elseif ($timestamp == 0) { |
|
985 | + return 0; |
|
986 | + } |
|
935 | 987 | |
936 | 988 | return $timestamp + ($modSettings['time_offset'] + ($use_user_offset ? $user_info['time_offset'] : 0)) * 3600; |
937 | 989 | } |
@@ -960,8 +1012,9 @@ discard block |
||
960 | 1012 | $array[$i] = $array[$j]; |
961 | 1013 | $array[$j] = $temp; |
962 | 1014 | |
963 | - for ($i = 1; $p[$i] == 0; $i++) |
|
964 | - $p[$i] = 1; |
|
1015 | + for ($i = 1; $p[$i] == 0; $i++) { |
|
1016 | + $p[$i] = 1; |
|
1017 | + } |
|
965 | 1018 | |
966 | 1019 | $orders[] = $array; |
967 | 1020 | } |
@@ -993,12 +1046,14 @@ discard block |
||
993 | 1046 | static $disabled; |
994 | 1047 | |
995 | 1048 | // Don't waste cycles |
996 | - if ($message === '') |
|
997 | - return ''; |
|
1049 | + if ($message === '') { |
|
1050 | + return ''; |
|
1051 | + } |
|
998 | 1052 | |
999 | 1053 | // Just in case it wasn't determined yet whether UTF-8 is enabled. |
1000 | - if (!isset($context['utf8'])) |
|
1001 | - $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
1054 | + if (!isset($context['utf8'])) { |
|
1055 | + $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
1056 | + } |
|
1002 | 1057 | |
1003 | 1058 | // Clean up any cut/paste issues we may have |
1004 | 1059 | $message = sanitizeMSCutPaste($message); |
@@ -1010,13 +1065,15 @@ discard block |
||
1010 | 1065 | return $message; |
1011 | 1066 | } |
1012 | 1067 | |
1013 | - if ($smileys !== null && ($smileys == '1' || $smileys == '0')) |
|
1014 | - $smileys = (bool) $smileys; |
|
1068 | + if ($smileys !== null && ($smileys == '1' || $smileys == '0')) { |
|
1069 | + $smileys = (bool) $smileys; |
|
1070 | + } |
|
1015 | 1071 | |
1016 | 1072 | if (empty($modSettings['enableBBC']) && $message !== false) |
1017 | 1073 | { |
1018 | - if ($smileys === true) |
|
1019 | - parsesmileys($message); |
|
1074 | + if ($smileys === true) { |
|
1075 | + parsesmileys($message); |
|
1076 | + } |
|
1020 | 1077 | |
1021 | 1078 | return $message; |
1022 | 1079 | } |
@@ -1029,8 +1086,9 @@ discard block |
||
1029 | 1086 | } |
1030 | 1087 | |
1031 | 1088 | // Ensure $modSettings['tld_regex'] contains a valid regex for the autolinker |
1032 | - if (!empty($modSettings['autoLinkUrls'])) |
|
1033 | - set_tld_regex(); |
|
1089 | + if (!empty($modSettings['autoLinkUrls'])) { |
|
1090 | + set_tld_regex(); |
|
1091 | + } |
|
1034 | 1092 | |
1035 | 1093 | // Allow mods access before entering the main parse_bbc loop |
1036 | 1094 | call_integration_hook('integrate_pre_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
@@ -1044,12 +1102,14 @@ discard block |
||
1044 | 1102 | |
1045 | 1103 | $temp = explode(',', strtolower($modSettings['disabledBBC'])); |
1046 | 1104 | |
1047 | - foreach ($temp as $tag) |
|
1048 | - $disabled[trim($tag)] = true; |
|
1105 | + foreach ($temp as $tag) { |
|
1106 | + $disabled[trim($tag)] = true; |
|
1107 | + } |
|
1049 | 1108 | } |
1050 | 1109 | |
1051 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
1052 | - $disabled['flash'] = true; |
|
1110 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
1111 | + $disabled['flash'] = true; |
|
1112 | + } |
|
1053 | 1113 | |
1054 | 1114 | /* The following bbc are formatted as an array, with keys as follows: |
1055 | 1115 | |
@@ -1170,8 +1230,9 @@ discard block |
||
1170 | 1230 | $returnContext = ''; |
1171 | 1231 | |
1172 | 1232 | // BBC or the entire attachments feature is disabled |
1173 | - if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) |
|
1174 | - return $data; |
|
1233 | + if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) { |
|
1234 | + return $data; |
|
1235 | + } |
|
1175 | 1236 | |
1176 | 1237 | // Save the attach ID. |
1177 | 1238 | $attachID = $data; |
@@ -1182,8 +1243,9 @@ discard block |
||
1182 | 1243 | $currentAttachment = parseAttachBBC($attachID); |
1183 | 1244 | |
1184 | 1245 | // parseAttachBBC will return a string ($txt key) rather than diying with a fatal_error. Up to you to decide what to do. |
1185 | - if (is_string($currentAttachment)) |
|
1186 | - return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
1246 | + if (is_string($currentAttachment)) { |
|
1247 | + return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
1248 | + } |
|
1187 | 1249 | |
1188 | 1250 | if (!empty($currentAttachment['is_image'])) |
1189 | 1251 | { |
@@ -1199,15 +1261,17 @@ discard block |
||
1199 | 1261 | $height = ' height="' . $currentAttachment['height'] . '"'; |
1200 | 1262 | } |
1201 | 1263 | |
1202 | - if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) |
|
1203 | - $returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>'; |
|
1204 | - else |
|
1205 | - $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
|
1264 | + if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) { |
|
1265 | + $returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>'; |
|
1266 | + } else { |
|
1267 | + $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
|
1268 | + } |
|
1206 | 1269 | } |
1207 | 1270 | |
1208 | 1271 | // No image. Show a link. |
1209 | - else |
|
1210 | - $returnContext .= $currentAttachment['link']; |
|
1272 | + else { |
|
1273 | + $returnContext .= $currentAttachment['link']; |
|
1274 | + } |
|
1211 | 1275 | |
1212 | 1276 | // Gotta append what we just did. |
1213 | 1277 | $data = $returnContext; |
@@ -1238,8 +1302,9 @@ discard block |
||
1238 | 1302 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
1239 | 1303 | { |
1240 | 1304 | // Do PHP code coloring? |
1241 | - if ($php_parts[$php_i] != '<?php') |
|
1242 | - continue; |
|
1305 | + if ($php_parts[$php_i] != '<?php') { |
|
1306 | + continue; |
|
1307 | + } |
|
1243 | 1308 | |
1244 | 1309 | $php_string = ''; |
1245 | 1310 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1255,8 +1320,9 @@ discard block |
||
1255 | 1320 | $data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data); |
1256 | 1321 | |
1257 | 1322 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
1258 | - if ($context['browser']['is_opera']) |
|
1259 | - $data .= ' '; |
|
1323 | + if ($context['browser']['is_opera']) { |
|
1324 | + $data .= ' '; |
|
1325 | + } |
|
1260 | 1326 | } |
1261 | 1327 | }, |
1262 | 1328 | 'block_level' => true, |
@@ -1275,8 +1341,9 @@ discard block |
||
1275 | 1341 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
1276 | 1342 | { |
1277 | 1343 | // Do PHP code coloring? |
1278 | - if ($php_parts[$php_i] != '<?php') |
|
1279 | - continue; |
|
1344 | + if ($php_parts[$php_i] != '<?php') { |
|
1345 | + continue; |
|
1346 | + } |
|
1280 | 1347 | |
1281 | 1348 | $php_string = ''; |
1282 | 1349 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1292,8 +1359,9 @@ discard block |
||
1292 | 1359 | $data[0] = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data[0]); |
1293 | 1360 | |
1294 | 1361 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
1295 | - if ($context['browser']['is_opera']) |
|
1296 | - $data[0] .= ' '; |
|
1362 | + if ($context['browser']['is_opera']) { |
|
1363 | + $data[0] .= ' '; |
|
1364 | + } |
|
1297 | 1365 | } |
1298 | 1366 | }, |
1299 | 1367 | 'block_level' => true, |
@@ -1331,11 +1399,13 @@ discard block |
||
1331 | 1399 | 'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">', |
1332 | 1400 | 'validate' => function (&$tag, &$data, $disabled) |
1333 | 1401 | { |
1334 | - if (isset($disabled['url'])) |
|
1335 | - $tag['content'] = '$1'; |
|
1402 | + if (isset($disabled['url'])) { |
|
1403 | + $tag['content'] = '$1'; |
|
1404 | + } |
|
1336 | 1405 | $scheme = parse_url($data[0], PHP_URL_SCHEME); |
1337 | - if (empty($scheme)) |
|
1338 | - $data[0] = '//' . ltrim($data[0], ':/'); |
|
1406 | + if (empty($scheme)) { |
|
1407 | + $data[0] = '//' . ltrim($data[0], ':/'); |
|
1408 | + } |
|
1339 | 1409 | }, |
1340 | 1410 | 'disabled_content' => '<a href="$1" target="_blank" class="new_win">$1</a>', |
1341 | 1411 | ), |
@@ -1349,10 +1419,11 @@ discard block |
||
1349 | 1419 | { |
1350 | 1420 | $class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"'; |
1351 | 1421 | |
1352 | - if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) |
|
1353 | - $css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"'; |
|
1354 | - else |
|
1355 | - $css = ''; |
|
1422 | + if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) { |
|
1423 | + $css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"'; |
|
1424 | + } else { |
|
1425 | + $css = ''; |
|
1426 | + } |
|
1356 | 1427 | |
1357 | 1428 | $data = $class . $css; |
1358 | 1429 | }, |
@@ -1402,14 +1473,16 @@ discard block |
||
1402 | 1473 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1403 | 1474 | if ($image_proxy_enabled) |
1404 | 1475 | { |
1405 | - if (empty($scheme)) |
|
1406 | - $data = 'http://' . ltrim($data, ':/'); |
|
1476 | + if (empty($scheme)) { |
|
1477 | + $data = 'http://' . ltrim($data, ':/'); |
|
1478 | + } |
|
1407 | 1479 | |
1408 | - if ($scheme != 'https') |
|
1409 | - $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
1480 | + if ($scheme != 'https') { |
|
1481 | + $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
1482 | + } |
|
1483 | + } elseif (empty($scheme)) { |
|
1484 | + $data = '//' . ltrim($data, ':/'); |
|
1410 | 1485 | } |
1411 | - elseif (empty($scheme)) |
|
1412 | - $data = '//' . ltrim($data, ':/'); |
|
1413 | 1486 | }, |
1414 | 1487 | 'disabled_content' => '($1)', |
1415 | 1488 | ), |
@@ -1425,14 +1498,16 @@ discard block |
||
1425 | 1498 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1426 | 1499 | if ($image_proxy_enabled) |
1427 | 1500 | { |
1428 | - if (empty($scheme)) |
|
1429 | - $data = 'http://' . ltrim($data, ':/'); |
|
1501 | + if (empty($scheme)) { |
|
1502 | + $data = 'http://' . ltrim($data, ':/'); |
|
1503 | + } |
|
1430 | 1504 | |
1431 | - if ($scheme != 'https') |
|
1432 | - $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
1505 | + if ($scheme != 'https') { |
|
1506 | + $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
1507 | + } |
|
1508 | + } elseif (empty($scheme)) { |
|
1509 | + $data = '//' . ltrim($data, ':/'); |
|
1433 | 1510 | } |
1434 | - elseif (empty($scheme)) |
|
1435 | - $data = '//' . ltrim($data, ':/'); |
|
1436 | 1511 | }, |
1437 | 1512 | 'disabled_content' => '($1)', |
1438 | 1513 | ), |
@@ -1444,8 +1519,9 @@ discard block |
||
1444 | 1519 | { |
1445 | 1520 | $data = strtr($data, array('<br>' => '')); |
1446 | 1521 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1447 | - if (empty($scheme)) |
|
1448 | - $data = '//' . ltrim($data, ':/'); |
|
1522 | + if (empty($scheme)) { |
|
1523 | + $data = '//' . ltrim($data, ':/'); |
|
1524 | + } |
|
1449 | 1525 | }, |
1450 | 1526 | ), |
1451 | 1527 | array( |
@@ -1456,13 +1532,14 @@ discard block |
||
1456 | 1532 | 'after' => '</a>', |
1457 | 1533 | 'validate' => function (&$tag, &$data, $disabled) |
1458 | 1534 | { |
1459 | - if (substr($data, 0, 1) == '#') |
|
1460 | - $data = '#post_' . substr($data, 1); |
|
1461 | - else |
|
1535 | + if (substr($data, 0, 1) == '#') { |
|
1536 | + $data = '#post_' . substr($data, 1); |
|
1537 | + } else |
|
1462 | 1538 | { |
1463 | 1539 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1464 | - if (empty($scheme)) |
|
1465 | - $data = '//' . ltrim($data, ':/'); |
|
1540 | + if (empty($scheme)) { |
|
1541 | + $data = '//' . ltrim($data, ':/'); |
|
1542 | + } |
|
1466 | 1543 | } |
1467 | 1544 | }, |
1468 | 1545 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
@@ -1540,8 +1617,9 @@ discard block |
||
1540 | 1617 | { |
1541 | 1618 | $add_begin = substr(trim($data), 0, 5) != '<?'; |
1542 | 1619 | $data = highlight_php_code($add_begin ? '<?php ' . $data . '?>' : $data); |
1543 | - if ($add_begin) |
|
1544 | - $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
1620 | + if ($add_begin) { |
|
1621 | + $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
1622 | + } |
|
1545 | 1623 | } |
1546 | 1624 | }, |
1547 | 1625 | 'block_level' => false, |
@@ -1672,10 +1750,11 @@ discard block |
||
1672 | 1750 | 'content' => '$1', |
1673 | 1751 | 'validate' => function (&$tag, &$data, $disabled) |
1674 | 1752 | { |
1675 | - if (is_numeric($data)) |
|
1676 | - $data = timeformat($data); |
|
1677 | - else |
|
1678 | - $tag['content'] = '[time]$1[/time]'; |
|
1753 | + if (is_numeric($data)) { |
|
1754 | + $data = timeformat($data); |
|
1755 | + } else { |
|
1756 | + $tag['content'] = '[time]$1[/time]'; |
|
1757 | + } |
|
1679 | 1758 | }, |
1680 | 1759 | ), |
1681 | 1760 | array( |
@@ -1702,8 +1781,9 @@ discard block |
||
1702 | 1781 | { |
1703 | 1782 | $data = strtr($data, array('<br>' => '')); |
1704 | 1783 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1705 | - if (empty($scheme)) |
|
1706 | - $data = '//' . ltrim($data, ':/'); |
|
1784 | + if (empty($scheme)) { |
|
1785 | + $data = '//' . ltrim($data, ':/'); |
|
1786 | + } |
|
1707 | 1787 | }, |
1708 | 1788 | ), |
1709 | 1789 | array( |
@@ -1715,8 +1795,9 @@ discard block |
||
1715 | 1795 | 'validate' => function (&$tag, &$data, $disabled) |
1716 | 1796 | { |
1717 | 1797 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1718 | - if (empty($scheme)) |
|
1719 | - $data = '//' . ltrim($data, ':/'); |
|
1798 | + if (empty($scheme)) { |
|
1799 | + $data = '//' . ltrim($data, ':/'); |
|
1800 | + } |
|
1720 | 1801 | }, |
1721 | 1802 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
1722 | 1803 | 'disabled_after' => ' ($1)', |
@@ -1736,8 +1817,9 @@ discard block |
||
1736 | 1817 | // This is mainly for the bbc manager, so it's easy to add tags above. Custom BBC should be added above this line. |
1737 | 1818 | if ($message === false) |
1738 | 1819 | { |
1739 | - if (isset($temp_bbc)) |
|
1740 | - $bbc_codes = $temp_bbc; |
|
1820 | + if (isset($temp_bbc)) { |
|
1821 | + $bbc_codes = $temp_bbc; |
|
1822 | + } |
|
1741 | 1823 | usort($codes, function ($a, $b) { |
1742 | 1824 | return strcmp($a['tag'], $b['tag']); |
1743 | 1825 | }); |
@@ -1757,8 +1839,9 @@ discard block |
||
1757 | 1839 | ); |
1758 | 1840 | if (!isset($disabled['li']) && !isset($disabled['list'])) |
1759 | 1841 | { |
1760 | - foreach ($itemcodes as $c => $dummy) |
|
1761 | - $bbc_codes[$c] = array(); |
|
1842 | + foreach ($itemcodes as $c => $dummy) { |
|
1843 | + $bbc_codes[$c] = array(); |
|
1844 | + } |
|
1762 | 1845 | } |
1763 | 1846 | |
1764 | 1847 | // Shhhh! |
@@ -1779,12 +1862,14 @@ discard block |
||
1779 | 1862 | foreach ($codes as $code) |
1780 | 1863 | { |
1781 | 1864 | // Make it easier to process parameters later |
1782 | - if (!empty($code['parameters'])) |
|
1783 | - ksort($code['parameters'], SORT_STRING); |
|
1865 | + if (!empty($code['parameters'])) { |
|
1866 | + ksort($code['parameters'], SORT_STRING); |
|
1867 | + } |
|
1784 | 1868 | |
1785 | 1869 | // If we are not doing every tag only do ones we are interested in. |
1786 | - if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) |
|
1787 | - $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
1870 | + if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) { |
|
1871 | + $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
1872 | + } |
|
1788 | 1873 | } |
1789 | 1874 | $codes = null; |
1790 | 1875 | } |
@@ -1795,8 +1880,9 @@ discard block |
||
1795 | 1880 | // It's likely this will change if the message is modified. |
1796 | 1881 | $cache_key = 'parse:' . $cache_id . '-' . md5(md5($message) . '-' . $smileys . (empty($disabled) ? '' : implode(',', array_keys($disabled))) . $smcFunc['json_encode']($context['browser']) . $txt['lang_locale'] . $user_info['time_offset'] . $user_info['time_format']); |
1797 | 1882 | |
1798 | - if (($temp = cache_get_data($cache_key, 240)) != null) |
|
1799 | - return $temp; |
|
1883 | + if (($temp = cache_get_data($cache_key, 240)) != null) { |
|
1884 | + return $temp; |
|
1885 | + } |
|
1800 | 1886 | |
1801 | 1887 | $cache_t = microtime(); |
1802 | 1888 | } |
@@ -1828,8 +1914,9 @@ discard block |
||
1828 | 1914 | $disabled['flash'] = true; |
1829 | 1915 | |
1830 | 1916 | // @todo Change maybe? |
1831 | - if (!isset($_GET['images'])) |
|
1832 | - $disabled['img'] = true; |
|
1917 | + if (!isset($_GET['images'])) { |
|
1918 | + $disabled['img'] = true; |
|
1919 | + } |
|
1833 | 1920 | |
1834 | 1921 | // @todo Interface/setting to add more? |
1835 | 1922 | } |
@@ -1853,8 +1940,9 @@ discard block |
||
1853 | 1940 | $pos = isset($matches[0][1]) ? $matches[0][1] : false; |
1854 | 1941 | |
1855 | 1942 | // Failsafe. |
1856 | - if ($pos === false || $last_pos > $pos) |
|
1857 | - $pos = strlen($message) + 1; |
|
1943 | + if ($pos === false || $last_pos > $pos) { |
|
1944 | + $pos = strlen($message) + 1; |
|
1945 | + } |
|
1858 | 1946 | |
1859 | 1947 | // Can't have a one letter smiley, URL, or email! (sorry.) |
1860 | 1948 | if ($last_pos < $pos - 1) |
@@ -1873,8 +1961,9 @@ discard block |
||
1873 | 1961 | |
1874 | 1962 | // <br> should be empty. |
1875 | 1963 | $empty_tags = array('br', 'hr'); |
1876 | - foreach ($empty_tags as $tag) |
|
1877 | - $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '<' . $tag . '>', $data); |
|
1964 | + foreach ($empty_tags as $tag) { |
|
1965 | + $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '<' . $tag . '>', $data); |
|
1966 | + } |
|
1878 | 1967 | |
1879 | 1968 | // b, u, i, s, pre... basic tags. |
1880 | 1969 | $closable_tags = array('b', 'u', 'i', 's', 'em', 'ins', 'del', 'pre', 'blockquote', 'strong'); |
@@ -1883,8 +1972,9 @@ discard block |
||
1883 | 1972 | $diff = substr_count($data, '<' . $tag . '>') - substr_count($data, '</' . $tag . '>'); |
1884 | 1973 | $data = strtr($data, array('<' . $tag . '>' => '<' . $tag . '>', '</' . $tag . '>' => '</' . $tag . '>')); |
1885 | 1974 | |
1886 | - if ($diff > 0) |
|
1887 | - $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
1975 | + if ($diff > 0) { |
|
1976 | + $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
1977 | + } |
|
1888 | 1978 | } |
1889 | 1979 | |
1890 | 1980 | // Do <img ...> - with security... action= -> action-. |
@@ -1897,8 +1987,9 @@ discard block |
||
1897 | 1987 | $alt = empty($matches[3][$match]) ? '' : ' alt=' . preg_replace('~^"|"$~', '', $matches[3][$match]); |
1898 | 1988 | |
1899 | 1989 | // Remove action= from the URL - no funny business, now. |
1900 | - if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) |
|
1901 | - $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
1990 | + if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) { |
|
1991 | + $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
1992 | + } |
|
1902 | 1993 | |
1903 | 1994 | // Check if the image is larger than allowed. |
1904 | 1995 | if (!empty($modSettings['max_image_width']) && !empty($modSettings['max_image_height'])) |
@@ -1919,9 +2010,9 @@ discard block |
||
1919 | 2010 | |
1920 | 2011 | // Set the new image tag. |
1921 | 2012 | $replaces[$matches[0][$match]] = '[img width=' . $width . ' height=' . $height . $alt . ']' . $imgtag . '[/img]'; |
2013 | + } else { |
|
2014 | + $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
|
1922 | 2015 | } |
1923 | - else |
|
1924 | - $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
|
1925 | 2016 | } |
1926 | 2017 | |
1927 | 2018 | $data = strtr($data, $replaces); |
@@ -1934,16 +2025,18 @@ discard block |
||
1934 | 2025 | $no_autolink_area = false; |
1935 | 2026 | if (!empty($open_tags)) |
1936 | 2027 | { |
1937 | - foreach ($open_tags as $open_tag) |
|
1938 | - if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
2028 | + foreach ($open_tags as $open_tag) { |
|
2029 | + if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
1939 | 2030 | $no_autolink_area = true; |
2031 | + } |
|
1940 | 2032 | } |
1941 | 2033 | |
1942 | 2034 | // Don't go backwards. |
1943 | 2035 | // @todo Don't think is the real solution.... |
1944 | 2036 | $lastAutoPos = isset($lastAutoPos) ? $lastAutoPos : 0; |
1945 | - if ($pos < $lastAutoPos) |
|
1946 | - $no_autolink_area = true; |
|
2037 | + if ($pos < $lastAutoPos) { |
|
2038 | + $no_autolink_area = true; |
|
2039 | + } |
|
1947 | 2040 | $lastAutoPos = $pos; |
1948 | 2041 | |
1949 | 2042 | if (!$no_autolink_area) |
@@ -2052,17 +2145,19 @@ discard block |
||
2052 | 2145 | if ($scheme == 'mailto') |
2053 | 2146 | { |
2054 | 2147 | $email_address = str_replace('mailto:', '', $url); |
2055 | - if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) |
|
2056 | - return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
2057 | - else |
|
2058 | - return $url; |
|
2148 | + if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) { |
|
2149 | + return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
2150 | + } else { |
|
2151 | + return $url; |
|
2152 | + } |
|
2059 | 2153 | } |
2060 | 2154 | |
2061 | 2155 | // Are we linking a schemeless URL or naked domain name (e.g. "example.com")? |
2062 | - if (empty($scheme)) |
|
2063 | - $fullUrl = '//' . ltrim($url, ':/'); |
|
2064 | - else |
|
2065 | - $fullUrl = $url; |
|
2156 | + if (empty($scheme)) { |
|
2157 | + $fullUrl = '//' . ltrim($url, ':/'); |
|
2158 | + } else { |
|
2159 | + $fullUrl = $url; |
|
2160 | + } |
|
2066 | 2161 | |
2067 | 2162 | return '[url="' . str_replace(array('[', ']'), array('[', ']'), $fullUrl) . '"]' . $url . '[/url]'; |
2068 | 2163 | }, $data); |
@@ -2111,16 +2206,18 @@ discard block |
||
2111 | 2206 | } |
2112 | 2207 | |
2113 | 2208 | // Are we there yet? Are we there yet? |
2114 | - if ($pos >= strlen($message) - 1) |
|
2115 | - break; |
|
2209 | + if ($pos >= strlen($message) - 1) { |
|
2210 | + break; |
|
2211 | + } |
|
2116 | 2212 | |
2117 | 2213 | $tags = strtolower($message[$pos + 1]); |
2118 | 2214 | |
2119 | 2215 | if ($tags == '/' && !empty($open_tags)) |
2120 | 2216 | { |
2121 | 2217 | $pos2 = strpos($message, ']', $pos + 1); |
2122 | - if ($pos2 == $pos + 2) |
|
2123 | - continue; |
|
2218 | + if ($pos2 == $pos + 2) { |
|
2219 | + continue; |
|
2220 | + } |
|
2124 | 2221 | |
2125 | 2222 | $look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2)); |
2126 | 2223 | |
@@ -2130,8 +2227,9 @@ discard block |
||
2130 | 2227 | do |
2131 | 2228 | { |
2132 | 2229 | $tag = array_pop($open_tags); |
2133 | - if (!$tag) |
|
2134 | - break; |
|
2230 | + if (!$tag) { |
|
2231 | + break; |
|
2232 | + } |
|
2135 | 2233 | |
2136 | 2234 | if (!empty($tag['block_level'])) |
2137 | 2235 | { |
@@ -2145,10 +2243,11 @@ discard block |
||
2145 | 2243 | // The idea is, if we are LOOKING for a block level tag, we can close them on the way. |
2146 | 2244 | if (strlen($look_for) > 0 && isset($bbc_codes[$look_for[0]])) |
2147 | 2245 | { |
2148 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
2149 | - if ($temp['tag'] == $look_for) |
|
2246 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
2247 | + if ($temp['tag'] == $look_for) |
|
2150 | 2248 | { |
2151 | 2249 | $block_level = !empty($temp['block_level']); |
2250 | + } |
|
2152 | 2251 | break; |
2153 | 2252 | } |
2154 | 2253 | } |
@@ -2170,15 +2269,15 @@ discard block |
||
2170 | 2269 | { |
2171 | 2270 | $open_tags = $to_close; |
2172 | 2271 | continue; |
2173 | - } |
|
2174 | - elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
2272 | + } elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
2175 | 2273 | { |
2176 | 2274 | if ($block_level === null && isset($look_for[0], $bbc_codes[$look_for[0]])) |
2177 | 2275 | { |
2178 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
2179 | - if ($temp['tag'] == $look_for) |
|
2276 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
2277 | + if ($temp['tag'] == $look_for) |
|
2180 | 2278 | { |
2181 | 2279 | $block_level = !empty($temp['block_level']); |
2280 | + } |
|
2182 | 2281 | break; |
2183 | 2282 | } |
2184 | 2283 | } |
@@ -2186,8 +2285,9 @@ discard block |
||
2186 | 2285 | // We're not looking for a block level tag (or maybe even a tag that exists...) |
2187 | 2286 | if (!$block_level) |
2188 | 2287 | { |
2189 | - foreach ($to_close as $tag) |
|
2190 | - array_push($open_tags, $tag); |
|
2288 | + foreach ($to_close as $tag) { |
|
2289 | + array_push($open_tags, $tag); |
|
2290 | + } |
|
2191 | 2291 | continue; |
2192 | 2292 | } |
2193 | 2293 | } |
@@ -2200,14 +2300,17 @@ discard block |
||
2200 | 2300 | |
2201 | 2301 | // See the comment at the end of the big loop - just eating whitespace ;). |
2202 | 2302 | $whitespace_regex = ''; |
2203 | - if (!empty($tag['block_level'])) |
|
2204 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2303 | + if (!empty($tag['block_level'])) { |
|
2304 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2305 | + } |
|
2205 | 2306 | // Trim one line of whitespace after unnested tags, but all of it after nested ones |
2206 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
2207 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2307 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
2308 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2309 | + } |
|
2208 | 2310 | |
2209 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
2210 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2311 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
2312 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2313 | + } |
|
2211 | 2314 | } |
2212 | 2315 | |
2213 | 2316 | if (!empty($to_close)) |
@@ -2220,8 +2323,9 @@ discard block |
||
2220 | 2323 | } |
2221 | 2324 | |
2222 | 2325 | // No tags for this character, so just keep going (fastest possible course.) |
2223 | - if (!isset($bbc_codes[$tags])) |
|
2224 | - continue; |
|
2326 | + if (!isset($bbc_codes[$tags])) { |
|
2327 | + continue; |
|
2328 | + } |
|
2225 | 2329 | |
2226 | 2330 | $inside = empty($open_tags) ? null : $open_tags[count($open_tags) - 1]; |
2227 | 2331 | $tag = null; |
@@ -2230,44 +2334,52 @@ discard block |
||
2230 | 2334 | $pt_strlen = strlen($possible['tag']); |
2231 | 2335 | |
2232 | 2336 | // Not a match? |
2233 | - if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) |
|
2234 | - continue; |
|
2337 | + if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) { |
|
2338 | + continue; |
|
2339 | + } |
|
2235 | 2340 | |
2236 | 2341 | $next_c = $message[$pos + 1 + $pt_strlen]; |
2237 | 2342 | |
2238 | 2343 | // A test validation? |
2239 | - if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) |
|
2240 | - continue; |
|
2344 | + if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) { |
|
2345 | + continue; |
|
2346 | + } |
|
2241 | 2347 | // Do we want parameters? |
2242 | 2348 | elseif (!empty($possible['parameters'])) |
2243 | 2349 | { |
2244 | - if ($next_c != ' ') |
|
2245 | - continue; |
|
2246 | - } |
|
2247 | - elseif (isset($possible['type'])) |
|
2350 | + if ($next_c != ' ') { |
|
2351 | + continue; |
|
2352 | + } |
|
2353 | + } elseif (isset($possible['type'])) |
|
2248 | 2354 | { |
2249 | 2355 | // Do we need an equal sign? |
2250 | - if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') |
|
2251 | - continue; |
|
2356 | + if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') { |
|
2357 | + continue; |
|
2358 | + } |
|
2252 | 2359 | // Maybe we just want a /... |
2253 | - if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') |
|
2254 | - continue; |
|
2360 | + if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') { |
|
2361 | + continue; |
|
2362 | + } |
|
2255 | 2363 | // An immediate ]? |
2256 | - if ($possible['type'] == 'unparsed_content' && $next_c != ']') |
|
2257 | - continue; |
|
2364 | + if ($possible['type'] == 'unparsed_content' && $next_c != ']') { |
|
2365 | + continue; |
|
2366 | + } |
|
2258 | 2367 | } |
2259 | 2368 | // No type means 'parsed_content', which demands an immediate ] without parameters! |
2260 | - elseif ($next_c != ']') |
|
2261 | - continue; |
|
2369 | + elseif ($next_c != ']') { |
|
2370 | + continue; |
|
2371 | + } |
|
2262 | 2372 | |
2263 | 2373 | // Check allowed tree? |
2264 | - if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) |
|
2265 | - continue; |
|
2266 | - elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) |
|
2267 | - continue; |
|
2374 | + if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) { |
|
2375 | + continue; |
|
2376 | + } elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) { |
|
2377 | + continue; |
|
2378 | + } |
|
2268 | 2379 | // If this is in the list of disallowed child tags, don't parse it. |
2269 | - elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) |
|
2270 | - continue; |
|
2380 | + elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) { |
|
2381 | + continue; |
|
2382 | + } |
|
2271 | 2383 | |
2272 | 2384 | $pos1 = $pos + 1 + $pt_strlen + 1; |
2273 | 2385 | |
@@ -2279,8 +2391,9 @@ discard block |
||
2279 | 2391 | foreach ($open_tags as $open_quote) |
2280 | 2392 | { |
2281 | 2393 | // Every parent quote this quote has flips the styling |
2282 | - if ($open_quote['tag'] == 'quote') |
|
2283 | - $quote_alt = !$quote_alt; |
|
2394 | + if ($open_quote['tag'] == 'quote') { |
|
2395 | + $quote_alt = !$quote_alt; |
|
2396 | + } |
|
2284 | 2397 | } |
2285 | 2398 | // Add a class to the quote to style alternating blockquotes |
2286 | 2399 | $possible['before'] = strtr($possible['before'], array('<blockquote>' => '<blockquote class="bbc_' . ($quote_alt ? 'alternate' : 'standard') . '_quote">')); |
@@ -2291,8 +2404,9 @@ discard block |
||
2291 | 2404 | { |
2292 | 2405 | // Build a regular expression for each parameter for the current tag. |
2293 | 2406 | $preg = array(); |
2294 | - foreach ($possible['parameters'] as $p => $info) |
|
2295 | - $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
2407 | + foreach ($possible['parameters'] as $p => $info) { |
|
2408 | + $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
2409 | + } |
|
2296 | 2410 | |
2297 | 2411 | // Extract the string that potentially holds our parameters. |
2298 | 2412 | $blob = preg_split('~\[/?(?:' . $alltags_regex . ')~i', substr($message, $pos)); |
@@ -2312,24 +2426,27 @@ discard block |
||
2312 | 2426 | |
2313 | 2427 | $match = preg_match('~^' . implode('', $preg) . '$~i', implode(' ', $given_params), $matches) !== 0; |
2314 | 2428 | |
2315 | - if ($match) |
|
2316 | - $blob_counter = count($blobs) + 1; |
|
2429 | + if ($match) { |
|
2430 | + $blob_counter = count($blobs) + 1; |
|
2431 | + } |
|
2317 | 2432 | } |
2318 | 2433 | |
2319 | 2434 | // Didn't match our parameter list, try the next possible. |
2320 | - if (!$match) |
|
2321 | - continue; |
|
2435 | + if (!$match) { |
|
2436 | + continue; |
|
2437 | + } |
|
2322 | 2438 | |
2323 | 2439 | $params = array(); |
2324 | 2440 | for ($i = 1, $n = count($matches); $i < $n; $i += 2) |
2325 | 2441 | { |
2326 | 2442 | $key = strtok(ltrim($matches[$i]), '='); |
2327 | - if (isset($possible['parameters'][$key]['value'])) |
|
2328 | - $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
2329 | - elseif (isset($possible['parameters'][$key]['validate'])) |
|
2330 | - $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
2331 | - else |
|
2332 | - $params['{' . $key . '}'] = $matches[$i + 1]; |
|
2443 | + if (isset($possible['parameters'][$key]['value'])) { |
|
2444 | + $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
2445 | + } elseif (isset($possible['parameters'][$key]['validate'])) { |
|
2446 | + $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
2447 | + } else { |
|
2448 | + $params['{' . $key . '}'] = $matches[$i + 1]; |
|
2449 | + } |
|
2333 | 2450 | |
2334 | 2451 | // Just to make sure: replace any $ or { so they can't interpolate wrongly. |
2335 | 2452 | $params['{' . $key . '}'] = strtr($params['{' . $key . '}'], array('$' => '$', '{' => '{')); |
@@ -2337,23 +2454,26 @@ discard block |
||
2337 | 2454 | |
2338 | 2455 | foreach ($possible['parameters'] as $p => $info) |
2339 | 2456 | { |
2340 | - if (!isset($params['{' . $p . '}'])) |
|
2341 | - $params['{' . $p . '}'] = ''; |
|
2457 | + if (!isset($params['{' . $p . '}'])) { |
|
2458 | + $params['{' . $p . '}'] = ''; |
|
2459 | + } |
|
2342 | 2460 | } |
2343 | 2461 | |
2344 | 2462 | $tag = $possible; |
2345 | 2463 | |
2346 | 2464 | // Put the parameters into the string. |
2347 | - if (isset($tag['before'])) |
|
2348 | - $tag['before'] = strtr($tag['before'], $params); |
|
2349 | - if (isset($tag['after'])) |
|
2350 | - $tag['after'] = strtr($tag['after'], $params); |
|
2351 | - if (isset($tag['content'])) |
|
2352 | - $tag['content'] = strtr($tag['content'], $params); |
|
2465 | + if (isset($tag['before'])) { |
|
2466 | + $tag['before'] = strtr($tag['before'], $params); |
|
2467 | + } |
|
2468 | + if (isset($tag['after'])) { |
|
2469 | + $tag['after'] = strtr($tag['after'], $params); |
|
2470 | + } |
|
2471 | + if (isset($tag['content'])) { |
|
2472 | + $tag['content'] = strtr($tag['content'], $params); |
|
2473 | + } |
|
2353 | 2474 | |
2354 | 2475 | $pos1 += strlen($given_param_string); |
2355 | - } |
|
2356 | - else |
|
2476 | + } else |
|
2357 | 2477 | { |
2358 | 2478 | $tag = $possible; |
2359 | 2479 | $params = array(); |
@@ -2364,8 +2484,9 @@ discard block |
||
2364 | 2484 | // Item codes are complicated buggers... they are implicit [li]s and can make [list]s! |
2365 | 2485 | if ($smileys !== false && $tag === null && isset($itemcodes[$message[$pos + 1]]) && $message[$pos + 2] == ']' && !isset($disabled['list']) && !isset($disabled['li'])) |
2366 | 2486 | { |
2367 | - if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) |
|
2368 | - continue; |
|
2487 | + if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) { |
|
2488 | + continue; |
|
2489 | + } |
|
2369 | 2490 | |
2370 | 2491 | $tag = $itemcodes[$message[$pos + 1]]; |
2371 | 2492 | |
@@ -2386,9 +2507,9 @@ discard block |
||
2386 | 2507 | { |
2387 | 2508 | array_pop($open_tags); |
2388 | 2509 | $code = '</li>'; |
2510 | + } else { |
|
2511 | + $code = ''; |
|
2389 | 2512 | } |
2390 | - else |
|
2391 | - $code = ''; |
|
2392 | 2513 | |
2393 | 2514 | // Now we open a new tag. |
2394 | 2515 | $open_tags[] = array( |
@@ -2435,12 +2556,14 @@ discard block |
||
2435 | 2556 | } |
2436 | 2557 | |
2437 | 2558 | // No tag? Keep looking, then. Silly people using brackets without actual tags. |
2438 | - if ($tag === null) |
|
2439 | - continue; |
|
2559 | + if ($tag === null) { |
|
2560 | + continue; |
|
2561 | + } |
|
2440 | 2562 | |
2441 | 2563 | // Propagate the list to the child (so wrapping the disallowed tag won't work either.) |
2442 | - if (isset($inside['disallow_children'])) |
|
2443 | - $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
2564 | + if (isset($inside['disallow_children'])) { |
|
2565 | + $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
2566 | + } |
|
2444 | 2567 | |
2445 | 2568 | // Is this tag disabled? |
2446 | 2569 | if (isset($disabled[$tag['tag']])) |
@@ -2450,14 +2573,13 @@ discard block |
||
2450 | 2573 | $tag['before'] = !empty($tag['block_level']) ? '<div>' : ''; |
2451 | 2574 | $tag['after'] = !empty($tag['block_level']) ? '</div>' : ''; |
2452 | 2575 | $tag['content'] = isset($tag['type']) && $tag['type'] == 'closed' ? '' : (!empty($tag['block_level']) ? '<div>$1</div>' : '$1'); |
2453 | - } |
|
2454 | - elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
2576 | + } elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
2455 | 2577 | { |
2456 | 2578 | $tag['before'] = isset($tag['disabled_before']) ? $tag['disabled_before'] : (!empty($tag['block_level']) ? '<div>' : ''); |
2457 | 2579 | $tag['after'] = isset($tag['disabled_after']) ? $tag['disabled_after'] : (!empty($tag['block_level']) ? '</div>' : ''); |
2580 | + } else { |
|
2581 | + $tag['content'] = $tag['disabled_content']; |
|
2458 | 2582 | } |
2459 | - else |
|
2460 | - $tag['content'] = $tag['disabled_content']; |
|
2461 | 2583 | } |
2462 | 2584 | |
2463 | 2585 | // we use this a lot |
@@ -2467,8 +2589,9 @@ discard block |
||
2467 | 2589 | if (!empty($tag['block_level']) && $tag['tag'] != 'html' && empty($inside['block_level'])) |
2468 | 2590 | { |
2469 | 2591 | $n = count($open_tags) - 1; |
2470 | - while (empty($open_tags[$n]['block_level']) && $n >= 0) |
|
2471 | - $n--; |
|
2592 | + while (empty($open_tags[$n]['block_level']) && $n >= 0) { |
|
2593 | + $n--; |
|
2594 | + } |
|
2472 | 2595 | |
2473 | 2596 | // Close all the non block level tags so this tag isn't surrounded by them. |
2474 | 2597 | for ($i = count($open_tags) - 1; $i > $n; $i--) |
@@ -2480,12 +2603,15 @@ discard block |
||
2480 | 2603 | |
2481 | 2604 | // Trim or eat trailing stuff... see comment at the end of the big loop. |
2482 | 2605 | $whitespace_regex = ''; |
2483 | - if (!empty($tag['block_level'])) |
|
2484 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2485 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
2486 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2487 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
2488 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2606 | + if (!empty($tag['block_level'])) { |
|
2607 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2608 | + } |
|
2609 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
2610 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2611 | + } |
|
2612 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
2613 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2614 | + } |
|
2489 | 2615 | |
2490 | 2616 | array_pop($open_tags); |
2491 | 2617 | } |
@@ -2503,16 +2629,19 @@ discard block |
||
2503 | 2629 | elseif ($tag['type'] == 'unparsed_content') |
2504 | 2630 | { |
2505 | 2631 | $pos2 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos1); |
2506 | - if ($pos2 === false) |
|
2507 | - continue; |
|
2632 | + if ($pos2 === false) { |
|
2633 | + continue; |
|
2634 | + } |
|
2508 | 2635 | |
2509 | 2636 | $data = substr($message, $pos1, $pos2 - $pos1); |
2510 | 2637 | |
2511 | - if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') |
|
2512 | - $data = substr($data, 4); |
|
2638 | + if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') { |
|
2639 | + $data = substr($data, 4); |
|
2640 | + } |
|
2513 | 2641 | |
2514 | - if (isset($tag['validate'])) |
|
2515 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2642 | + if (isset($tag['validate'])) { |
|
2643 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2644 | + } |
|
2516 | 2645 | |
2517 | 2646 | $code = strtr($tag['content'], array('$1' => $data)); |
2518 | 2647 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 3 + $tag_strlen); |
@@ -2528,34 +2657,40 @@ discard block |
||
2528 | 2657 | if (isset($tag['quoted'])) |
2529 | 2658 | { |
2530 | 2659 | $quoted = substr($message, $pos1, 6) == '"'; |
2531 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
2532 | - continue; |
|
2660 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
2661 | + continue; |
|
2662 | + } |
|
2533 | 2663 | |
2534 | - if ($quoted) |
|
2535 | - $pos1 += 6; |
|
2664 | + if ($quoted) { |
|
2665 | + $pos1 += 6; |
|
2666 | + } |
|
2667 | + } else { |
|
2668 | + $quoted = false; |
|
2536 | 2669 | } |
2537 | - else |
|
2538 | - $quoted = false; |
|
2539 | 2670 | |
2540 | 2671 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
2541 | - if ($pos2 === false) |
|
2542 | - continue; |
|
2672 | + if ($pos2 === false) { |
|
2673 | + continue; |
|
2674 | + } |
|
2543 | 2675 | |
2544 | 2676 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
2545 | - if ($pos3 === false) |
|
2546 | - continue; |
|
2677 | + if ($pos3 === false) { |
|
2678 | + continue; |
|
2679 | + } |
|
2547 | 2680 | |
2548 | 2681 | $data = array( |
2549 | 2682 | substr($message, $pos2 + ($quoted == false ? 1 : 7), $pos3 - ($pos2 + ($quoted == false ? 1 : 7))), |
2550 | 2683 | substr($message, $pos1, $pos2 - $pos1) |
2551 | 2684 | ); |
2552 | 2685 | |
2553 | - if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') |
|
2554 | - $data[0] = substr($data[0], 4); |
|
2686 | + if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') { |
|
2687 | + $data[0] = substr($data[0], 4); |
|
2688 | + } |
|
2555 | 2689 | |
2556 | 2690 | // Validation for my parking, please! |
2557 | - if (isset($tag['validate'])) |
|
2558 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2691 | + if (isset($tag['validate'])) { |
|
2692 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2693 | + } |
|
2559 | 2694 | |
2560 | 2695 | $code = strtr($tag['content'], array('$1' => $data[0], '$2' => $data[1])); |
2561 | 2696 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
@@ -2572,23 +2707,27 @@ discard block |
||
2572 | 2707 | elseif ($tag['type'] == 'unparsed_commas_content') |
2573 | 2708 | { |
2574 | 2709 | $pos2 = strpos($message, ']', $pos1); |
2575 | - if ($pos2 === false) |
|
2576 | - continue; |
|
2710 | + if ($pos2 === false) { |
|
2711 | + continue; |
|
2712 | + } |
|
2577 | 2713 | |
2578 | 2714 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
2579 | - if ($pos3 === false) |
|
2580 | - continue; |
|
2715 | + if ($pos3 === false) { |
|
2716 | + continue; |
|
2717 | + } |
|
2581 | 2718 | |
2582 | 2719 | // We want $1 to be the content, and the rest to be csv. |
2583 | 2720 | $data = explode(',', ',' . substr($message, $pos1, $pos2 - $pos1)); |
2584 | 2721 | $data[0] = substr($message, $pos2 + 1, $pos3 - $pos2 - 1); |
2585 | 2722 | |
2586 | - if (isset($tag['validate'])) |
|
2587 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2723 | + if (isset($tag['validate'])) { |
|
2724 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2725 | + } |
|
2588 | 2726 | |
2589 | 2727 | $code = $tag['content']; |
2590 | - foreach ($data as $k => $d) |
|
2591 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2728 | + foreach ($data as $k => $d) { |
|
2729 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2730 | + } |
|
2592 | 2731 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
2593 | 2732 | $pos += strlen($code) - 1 + 2; |
2594 | 2733 | } |
@@ -2596,24 +2735,28 @@ discard block |
||
2596 | 2735 | elseif ($tag['type'] == 'unparsed_commas') |
2597 | 2736 | { |
2598 | 2737 | $pos2 = strpos($message, ']', $pos1); |
2599 | - if ($pos2 === false) |
|
2600 | - continue; |
|
2738 | + if ($pos2 === false) { |
|
2739 | + continue; |
|
2740 | + } |
|
2601 | 2741 | |
2602 | 2742 | $data = explode(',', substr($message, $pos1, $pos2 - $pos1)); |
2603 | 2743 | |
2604 | - if (isset($tag['validate'])) |
|
2605 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2744 | + if (isset($tag['validate'])) { |
|
2745 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2746 | + } |
|
2606 | 2747 | |
2607 | 2748 | // Fix after, for disabled code mainly. |
2608 | - foreach ($data as $k => $d) |
|
2609 | - $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
2749 | + foreach ($data as $k => $d) { |
|
2750 | + $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
2751 | + } |
|
2610 | 2752 | |
2611 | 2753 | $open_tags[] = $tag; |
2612 | 2754 | |
2613 | 2755 | // Replace them out, $1, $2, $3, $4, etc. |
2614 | 2756 | $code = $tag['before']; |
2615 | - foreach ($data as $k => $d) |
|
2616 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2757 | + foreach ($data as $k => $d) { |
|
2758 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2759 | + } |
|
2617 | 2760 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 1); |
2618 | 2761 | $pos += strlen($code) - 1 + 2; |
2619 | 2762 | } |
@@ -2624,28 +2767,33 @@ discard block |
||
2624 | 2767 | if (isset($tag['quoted'])) |
2625 | 2768 | { |
2626 | 2769 | $quoted = substr($message, $pos1, 6) == '"'; |
2627 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
2628 | - continue; |
|
2770 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
2771 | + continue; |
|
2772 | + } |
|
2629 | 2773 | |
2630 | - if ($quoted) |
|
2631 | - $pos1 += 6; |
|
2774 | + if ($quoted) { |
|
2775 | + $pos1 += 6; |
|
2776 | + } |
|
2777 | + } else { |
|
2778 | + $quoted = false; |
|
2632 | 2779 | } |
2633 | - else |
|
2634 | - $quoted = false; |
|
2635 | 2780 | |
2636 | 2781 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
2637 | - if ($pos2 === false) |
|
2638 | - continue; |
|
2782 | + if ($pos2 === false) { |
|
2783 | + continue; |
|
2784 | + } |
|
2639 | 2785 | |
2640 | 2786 | $data = substr($message, $pos1, $pos2 - $pos1); |
2641 | 2787 | |
2642 | 2788 | // Validation for my parking, please! |
2643 | - if (isset($tag['validate'])) |
|
2644 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2789 | + if (isset($tag['validate'])) { |
|
2790 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2791 | + } |
|
2645 | 2792 | |
2646 | 2793 | // For parsed content, we must recurse to avoid security problems. |
2647 | - if ($tag['type'] != 'unparsed_equals') |
|
2648 | - $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
2794 | + if ($tag['type'] != 'unparsed_equals') { |
|
2795 | + $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
2796 | + } |
|
2649 | 2797 | |
2650 | 2798 | $tag['after'] = strtr($tag['after'], array('$1' => $data)); |
2651 | 2799 | |
@@ -2657,34 +2805,40 @@ discard block |
||
2657 | 2805 | } |
2658 | 2806 | |
2659 | 2807 | // If this is block level, eat any breaks after it. |
2660 | - if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') |
|
2661 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
2808 | + if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') { |
|
2809 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
2810 | + } |
|
2662 | 2811 | |
2663 | 2812 | // Are we trimming outside this tag? |
2664 | - if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) |
|
2665 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
2813 | + if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) { |
|
2814 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
2815 | + } |
|
2666 | 2816 | } |
2667 | 2817 | |
2668 | 2818 | // Close any remaining tags. |
2669 | - while ($tag = array_pop($open_tags)) |
|
2670 | - $message .= "\n" . $tag['after'] . "\n"; |
|
2819 | + while ($tag = array_pop($open_tags)) { |
|
2820 | + $message .= "\n" . $tag['after'] . "\n"; |
|
2821 | + } |
|
2671 | 2822 | |
2672 | 2823 | // Parse the smileys within the parts where it can be done safely. |
2673 | 2824 | if ($smileys === true) |
2674 | 2825 | { |
2675 | 2826 | $message_parts = explode("\n", $message); |
2676 | - for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) |
|
2677 | - parsesmileys($message_parts[$i]); |
|
2827 | + for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) { |
|
2828 | + parsesmileys($message_parts[$i]); |
|
2829 | + } |
|
2678 | 2830 | |
2679 | 2831 | $message = implode('', $message_parts); |
2680 | 2832 | } |
2681 | 2833 | |
2682 | 2834 | // No smileys, just get rid of the markers. |
2683 | - else |
|
2684 | - $message = strtr($message, array("\n" => '')); |
|
2835 | + else { |
|
2836 | + $message = strtr($message, array("\n" => '')); |
|
2837 | + } |
|
2685 | 2838 | |
2686 | - if ($message !== '' && $message[0] === ' ') |
|
2687 | - $message = ' ' . substr($message, 1); |
|
2839 | + if ($message !== '' && $message[0] === ' ') { |
|
2840 | + $message = ' ' . substr($message, 1); |
|
2841 | + } |
|
2688 | 2842 | |
2689 | 2843 | // Cleanup whitespace. |
2690 | 2844 | $message = strtr($message, array(' ' => ' ', "\r" => '', "\n" => '<br>', '<br> ' => '<br> ', ' ' => "\n")); |
@@ -2693,15 +2847,16 @@ discard block |
||
2693 | 2847 | call_integration_hook('integrate_post_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
2694 | 2848 | |
2695 | 2849 | // Cache the output if it took some time... |
2696 | - if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) |
|
2697 | - cache_put_data($cache_key, $message, 240); |
|
2850 | + if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) { |
|
2851 | + cache_put_data($cache_key, $message, 240); |
|
2852 | + } |
|
2698 | 2853 | |
2699 | 2854 | // If this was a force parse revert if needed. |
2700 | 2855 | if (!empty($parse_tags)) |
2701 | 2856 | { |
2702 | - if (empty($temp_bbc)) |
|
2703 | - $bbc_codes = array(); |
|
2704 | - else |
|
2857 | + if (empty($temp_bbc)) { |
|
2858 | + $bbc_codes = array(); |
|
2859 | + } else |
|
2705 | 2860 | { |
2706 | 2861 | $bbc_codes = $temp_bbc; |
2707 | 2862 | unset($temp_bbc); |
@@ -2728,8 +2883,9 @@ discard block |
||
2728 | 2883 | static $smileyPregSearch = null, $smileyPregReplacements = array(); |
2729 | 2884 | |
2730 | 2885 | // No smiley set at all?! |
2731 | - if ($user_info['smiley_set'] == 'none' || trim($message) == '') |
|
2732 | - return; |
|
2886 | + if ($user_info['smiley_set'] == 'none' || trim($message) == '') { |
|
2887 | + return; |
|
2888 | + } |
|
2733 | 2889 | |
2734 | 2890 | // If smileyPregSearch hasn't been set, do it now. |
2735 | 2891 | if (empty($smileyPregSearch)) |
@@ -2740,8 +2896,7 @@ discard block |
||
2740 | 2896 | $smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)'); |
2741 | 2897 | $smileysto = array('evil.gif', 'cheesy.gif', 'rolleyes.gif', 'angry.gif', 'laugh.gif', 'smiley.gif', 'wink.gif', 'grin.gif', 'sad.gif', 'shocked.gif', 'cool.gif', 'tongue.gif', 'huh.gif', 'embarrassed.gif', 'lipsrsealed.gif', 'kiss.gif', 'cry.gif', 'undecided.gif', 'azn.gif', 'afro.gif', 'police.gif', 'angel.gif'); |
2742 | 2898 | $smileysdescs = array('', $txt['icon_cheesy'], $txt['icon_rolleyes'], $txt['icon_angry'], '', $txt['icon_smiley'], $txt['icon_wink'], $txt['icon_grin'], $txt['icon_sad'], $txt['icon_shocked'], $txt['icon_cool'], $txt['icon_tongue'], $txt['icon_huh'], $txt['icon_embarrassed'], $txt['icon_lips'], $txt['icon_kiss'], $txt['icon_cry'], $txt['icon_undecided'], '', '', '', ''); |
2743 | - } |
|
2744 | - else |
|
2899 | + } else |
|
2745 | 2900 | { |
2746 | 2901 | // Load the smileys in reverse order by length so they don't get parsed wrong. |
2747 | 2902 | if (($temp = cache_get_data('parsing_smileys', 480)) == null) |
@@ -2765,9 +2920,9 @@ discard block |
||
2765 | 2920 | $smcFunc['db_free_result']($result); |
2766 | 2921 | |
2767 | 2922 | cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480); |
2923 | + } else { |
|
2924 | + list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
2768 | 2925 | } |
2769 | - else |
|
2770 | - list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
2771 | 2926 | } |
2772 | 2927 | |
2773 | 2928 | // The non-breaking-space is a complex thing... |
@@ -2844,35 +2999,41 @@ discard block |
||
2844 | 2999 | global $scripturl, $context, $modSettings, $db_show_debug, $db_cache; |
2845 | 3000 | |
2846 | 3001 | // In case we have mail to send, better do that - as obExit doesn't always quite make it... |
2847 | - if (!empty($context['flush_mail'])) |
|
2848 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
3002 | + if (!empty($context['flush_mail'])) { |
|
3003 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
2849 | 3004 | AddMailQueue(true); |
3005 | + } |
|
2850 | 3006 | |
2851 | 3007 | $add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:'; |
2852 | 3008 | |
2853 | - if ($add) |
|
2854 | - $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
3009 | + if ($add) { |
|
3010 | + $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
3011 | + } |
|
2855 | 3012 | |
2856 | 3013 | // Put the session ID in. |
2857 | - if (defined('SID') && SID != '') |
|
2858 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
3014 | + if (defined('SID') && SID != '') { |
|
3015 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
3016 | + } |
|
2859 | 3017 | // Keep that debug in their for template debugging! |
2860 | - elseif (isset($_GET['debug'])) |
|
2861 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
3018 | + elseif (isset($_GET['debug'])) { |
|
3019 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
3020 | + } |
|
2862 | 3021 | |
2863 | 3022 | if (!empty($modSettings['queryless_urls']) && (empty($context['server']['is_cgi']) || ini_get('cgi.fix_pathinfo') == 1 || @get_cfg_var('cgi.fix_pathinfo') == 1) && (!empty($context['server']['is_apache']) || !empty($context['server']['is_lighttpd']) || !empty($context['server']['is_litespeed']))) |
2864 | 3023 | { |
2865 | - if (defined('SID') && SID != '') |
|
2866 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
3024 | + if (defined('SID') && SID != '') { |
|
3025 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
2867 | 3026 | function ($m) use ($scripturl) |
2868 | 3027 | { |
2869 | 3028 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
3029 | + } |
|
2870 | 3030 | }, $setLocation); |
2871 | - else |
|
2872 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
3031 | + else { |
|
3032 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
2873 | 3033 | function ($m) use ($scripturl) |
2874 | 3034 | { |
2875 | 3035 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
3036 | + } |
|
2876 | 3037 | }, $setLocation); |
2877 | 3038 | } |
2878 | 3039 | |
@@ -2883,8 +3044,9 @@ discard block |
||
2883 | 3044 | header('Location: ' . str_replace(' ', '%20', $setLocation), true, $permanent ? 301 : 302); |
2884 | 3045 | |
2885 | 3046 | // Debugging. |
2886 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
2887 | - $_SESSION['debug_redirect'] = $db_cache; |
|
3047 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
3048 | + $_SESSION['debug_redirect'] = $db_cache; |
|
3049 | + } |
|
2888 | 3050 | |
2889 | 3051 | obExit(false); |
2890 | 3052 | } |
@@ -2903,51 +3065,60 @@ discard block |
||
2903 | 3065 | |
2904 | 3066 | // Attempt to prevent a recursive loop. |
2905 | 3067 | ++$level; |
2906 | - if ($level > 1 && !$from_fatal_error && !$has_fatal_error) |
|
2907 | - exit; |
|
2908 | - if ($from_fatal_error) |
|
2909 | - $has_fatal_error = true; |
|
3068 | + if ($level > 1 && !$from_fatal_error && !$has_fatal_error) { |
|
3069 | + exit; |
|
3070 | + } |
|
3071 | + if ($from_fatal_error) { |
|
3072 | + $has_fatal_error = true; |
|
3073 | + } |
|
2910 | 3074 | |
2911 | 3075 | // Clear out the stat cache. |
2912 | 3076 | trackStats(); |
2913 | 3077 | |
2914 | 3078 | // If we have mail to send, send it. |
2915 | - if (!empty($context['flush_mail'])) |
|
2916 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
3079 | + if (!empty($context['flush_mail'])) { |
|
3080 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
2917 | 3081 | AddMailQueue(true); |
3082 | + } |
|
2918 | 3083 | |
2919 | 3084 | $do_header = $header === null ? !$header_done : $header; |
2920 | - if ($do_footer === null) |
|
2921 | - $do_footer = $do_header; |
|
3085 | + if ($do_footer === null) { |
|
3086 | + $do_footer = $do_header; |
|
3087 | + } |
|
2922 | 3088 | |
2923 | 3089 | // Has the template/header been done yet? |
2924 | 3090 | if ($do_header) |
2925 | 3091 | { |
2926 | 3092 | // Was the page title set last minute? Also update the HTML safe one. |
2927 | - if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) |
|
2928 | - $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
3093 | + if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) { |
|
3094 | + $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
3095 | + } |
|
2929 | 3096 | |
2930 | 3097 | // Start up the session URL fixer. |
2931 | 3098 | ob_start('ob_sessrewrite'); |
2932 | 3099 | |
2933 | - if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) |
|
2934 | - $buffers = explode(',', $settings['output_buffers']); |
|
2935 | - elseif (!empty($settings['output_buffers'])) |
|
2936 | - $buffers = $settings['output_buffers']; |
|
2937 | - else |
|
2938 | - $buffers = array(); |
|
3100 | + if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) { |
|
3101 | + $buffers = explode(',', $settings['output_buffers']); |
|
3102 | + } elseif (!empty($settings['output_buffers'])) { |
|
3103 | + $buffers = $settings['output_buffers']; |
|
3104 | + } else { |
|
3105 | + $buffers = array(); |
|
3106 | + } |
|
2939 | 3107 | |
2940 | - if (isset($modSettings['integrate_buffer'])) |
|
2941 | - $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
3108 | + if (isset($modSettings['integrate_buffer'])) { |
|
3109 | + $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
3110 | + } |
|
2942 | 3111 | |
2943 | - if (!empty($buffers)) |
|
2944 | - foreach ($buffers as $function) |
|
3112 | + if (!empty($buffers)) { |
|
3113 | + foreach ($buffers as $function) |
|
2945 | 3114 | { |
2946 | 3115 | $call = call_helper($function, true); |
3116 | + } |
|
2947 | 3117 | |
2948 | 3118 | // Is it valid? |
2949 | - if (!empty($call)) |
|
2950 | - ob_start($call); |
|
3119 | + if (!empty($call)) { |
|
3120 | + ob_start($call); |
|
3121 | + } |
|
2951 | 3122 | } |
2952 | 3123 | |
2953 | 3124 | // Display the screen in the logical order. |
@@ -2959,8 +3130,9 @@ discard block |
||
2959 | 3130 | loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main'); |
2960 | 3131 | |
2961 | 3132 | // Anything special to put out? |
2962 | - if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) |
|
2963 | - echo $context['insert_after_template']; |
|
3133 | + if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) { |
|
3134 | + echo $context['insert_after_template']; |
|
3135 | + } |
|
2964 | 3136 | |
2965 | 3137 | // Just so we don't get caught in an endless loop of errors from the footer... |
2966 | 3138 | if (!$footer_done) |
@@ -2969,14 +3141,16 @@ discard block |
||
2969 | 3141 | template_footer(); |
2970 | 3142 | |
2971 | 3143 | // (since this is just debugging... it's okay that it's after </html>.) |
2972 | - if (!isset($_REQUEST['xml'])) |
|
2973 | - displayDebug(); |
|
3144 | + if (!isset($_REQUEST['xml'])) { |
|
3145 | + displayDebug(); |
|
3146 | + } |
|
2974 | 3147 | } |
2975 | 3148 | } |
2976 | 3149 | |
2977 | 3150 | // Remember this URL in case someone doesn't like sending HTTP_REFERER. |
2978 | - if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) |
|
2979 | - $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
3151 | + if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) { |
|
3152 | + $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
3153 | + } |
|
2980 | 3154 | |
2981 | 3155 | // For session check verification.... don't switch browsers... |
2982 | 3156 | $_SESSION['USER_AGENT'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT']; |
@@ -2985,9 +3159,10 @@ discard block |
||
2985 | 3159 | call_integration_hook('integrate_exit', array($do_footer)); |
2986 | 3160 | |
2987 | 3161 | // Don't exit if we're coming from index.php; that will pass through normally. |
2988 | - if (!$from_index) |
|
2989 | - exit; |
|
2990 | -} |
|
3162 | + if (!$from_index) { |
|
3163 | + exit; |
|
3164 | + } |
|
3165 | + } |
|
2991 | 3166 | |
2992 | 3167 | /** |
2993 | 3168 | * Get the size of a specified image with better error handling. |
@@ -3006,8 +3181,9 @@ discard block |
||
3006 | 3181 | $url = str_replace(' ', '%20', $url); |
3007 | 3182 | |
3008 | 3183 | // Can we pull this from the cache... please please? |
3009 | - if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) |
|
3010 | - return $temp; |
|
3184 | + if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) { |
|
3185 | + return $temp; |
|
3186 | + } |
|
3011 | 3187 | $t = microtime(); |
3012 | 3188 | |
3013 | 3189 | // Get the host to pester... |
@@ -3017,12 +3193,10 @@ discard block |
||
3017 | 3193 | if ($url == '' || $url == 'http://' || $url == 'https://') |
3018 | 3194 | { |
3019 | 3195 | return false; |
3020 | - } |
|
3021 | - elseif (!isset($match[1])) |
|
3196 | + } elseif (!isset($match[1])) |
|
3022 | 3197 | { |
3023 | 3198 | $size = @getimagesize($url); |
3024 | - } |
|
3025 | - else |
|
3199 | + } else |
|
3026 | 3200 | { |
3027 | 3201 | // Try to connect to the server... give it half a second. |
3028 | 3202 | $temp = 0; |
@@ -3061,12 +3235,14 @@ discard block |
||
3061 | 3235 | } |
3062 | 3236 | |
3063 | 3237 | // If we didn't get it, we failed. |
3064 | - if (!isset($size)) |
|
3065 | - $size = false; |
|
3238 | + if (!isset($size)) { |
|
3239 | + $size = false; |
|
3240 | + } |
|
3066 | 3241 | |
3067 | 3242 | // If this took a long time, we may never have to do it again, but then again we might... |
3068 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) |
|
3069 | - cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
3243 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) { |
|
3244 | + cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
3245 | + } |
|
3070 | 3246 | |
3071 | 3247 | // Didn't work. |
3072 | 3248 | return $size; |
@@ -3084,8 +3260,9 @@ discard block |
||
3084 | 3260 | |
3085 | 3261 | // Under SSI this function can be called more then once. That can cause some problems. |
3086 | 3262 | // So only run the function once unless we are forced to run it again. |
3087 | - if ($loaded && !$forceload) |
|
3088 | - return; |
|
3263 | + if ($loaded && !$forceload) { |
|
3264 | + return; |
|
3265 | + } |
|
3089 | 3266 | |
3090 | 3267 | $loaded = true; |
3091 | 3268 | |
@@ -3097,14 +3274,16 @@ discard block |
||
3097 | 3274 | $context['news_lines'] = array_filter(explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news']))))); |
3098 | 3275 | for ($i = 0, $n = count($context['news_lines']); $i < $n; $i++) |
3099 | 3276 | { |
3100 | - if (trim($context['news_lines'][$i]) == '') |
|
3101 | - continue; |
|
3277 | + if (trim($context['news_lines'][$i]) == '') { |
|
3278 | + continue; |
|
3279 | + } |
|
3102 | 3280 | |
3103 | 3281 | // Clean it up for presentation ;). |
3104 | 3282 | $context['news_lines'][$i] = parse_bbc(stripslashes(trim($context['news_lines'][$i])), true, 'news' . $i); |
3105 | 3283 | } |
3106 | - if (!empty($context['news_lines'])) |
|
3107 | - $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
3284 | + if (!empty($context['news_lines'])) { |
|
3285 | + $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
3286 | + } |
|
3108 | 3287 | |
3109 | 3288 | if (!$user_info['is_guest']) |
3110 | 3289 | { |
@@ -3113,40 +3292,48 @@ discard block |
||
3113 | 3292 | $context['user']['alerts'] = &$user_info['alerts']; |
3114 | 3293 | |
3115 | 3294 | // Personal message popup... |
3116 | - if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) |
|
3117 | - $context['user']['popup_messages'] = true; |
|
3118 | - else |
|
3119 | - $context['user']['popup_messages'] = false; |
|
3295 | + if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) { |
|
3296 | + $context['user']['popup_messages'] = true; |
|
3297 | + } else { |
|
3298 | + $context['user']['popup_messages'] = false; |
|
3299 | + } |
|
3120 | 3300 | $_SESSION['unread_messages'] = $user_info['unread_messages']; |
3121 | 3301 | |
3122 | - if (allowedTo('moderate_forum')) |
|
3123 | - $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
3302 | + if (allowedTo('moderate_forum')) { |
|
3303 | + $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
3304 | + } |
|
3124 | 3305 | |
3125 | 3306 | $context['user']['avatar'] = array(); |
3126 | 3307 | |
3127 | 3308 | // Check for gravatar first since we might be forcing them... |
3128 | 3309 | if (($modSettings['gravatarEnabled'] && substr($user_info['avatar']['url'], 0, 11) == 'gravatar://') || !empty($modSettings['gravatarOverride'])) |
3129 | 3310 | { |
3130 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) |
|
3131 | - $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
3132 | - else |
|
3133 | - $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
3311 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) { |
|
3312 | + $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
3313 | + } else { |
|
3314 | + $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
3315 | + } |
|
3134 | 3316 | } |
3135 | 3317 | // Uploaded? |
3136 | - elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) |
|
3137 | - $context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar'; |
|
3318 | + elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) { |
|
3319 | + $context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar'; |
|
3320 | + } |
|
3138 | 3321 | // Full URL? |
3139 | - elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) |
|
3140 | - $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
3322 | + elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) { |
|
3323 | + $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
3324 | + } |
|
3141 | 3325 | // Otherwise we assume it's server stored. |
3142 | - elseif ($user_info['avatar']['url'] != '') |
|
3143 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
3326 | + elseif ($user_info['avatar']['url'] != '') { |
|
3327 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
3328 | + } |
|
3144 | 3329 | // No avatar at all? Fine, we have a big fat default avatar ;) |
3145 | - else |
|
3146 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
3330 | + else { |
|
3331 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
3332 | + } |
|
3147 | 3333 | |
3148 | - if (!empty($context['user']['avatar'])) |
|
3149 | - $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
3334 | + if (!empty($context['user']['avatar'])) { |
|
3335 | + $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
3336 | + } |
|
3150 | 3337 | |
3151 | 3338 | // Figure out how long they've been logged in. |
3152 | 3339 | $context['user']['total_time_logged_in'] = array( |
@@ -3154,8 +3341,7 @@ discard block |
||
3154 | 3341 | 'hours' => floor(($user_info['total_time_logged_in'] % 86400) / 3600), |
3155 | 3342 | 'minutes' => floor(($user_info['total_time_logged_in'] % 3600) / 60) |
3156 | 3343 | ); |
3157 | - } |
|
3158 | - else |
|
3344 | + } else |
|
3159 | 3345 | { |
3160 | 3346 | $context['user']['messages'] = 0; |
3161 | 3347 | $context['user']['unread_messages'] = 0; |
@@ -3163,12 +3349,14 @@ discard block |
||
3163 | 3349 | $context['user']['total_time_logged_in'] = array('days' => 0, 'hours' => 0, 'minutes' => 0); |
3164 | 3350 | $context['user']['popup_messages'] = false; |
3165 | 3351 | |
3166 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) |
|
3167 | - $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
3352 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) { |
|
3353 | + $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
3354 | + } |
|
3168 | 3355 | |
3169 | 3356 | // If we've upgraded recently, go easy on the passwords. |
3170 | - if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) |
|
3171 | - $context['disable_login_hashing'] = true; |
|
3357 | + if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) { |
|
3358 | + $context['disable_login_hashing'] = true; |
|
3359 | + } |
|
3172 | 3360 | } |
3173 | 3361 | |
3174 | 3362 | // Setup the main menu items. |
@@ -3181,8 +3369,8 @@ discard block |
||
3181 | 3369 | $context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm'); |
3182 | 3370 | |
3183 | 3371 | // 2.1+: Add the PM popup here instead. Theme authors can still override it simply by editing/removing the 'fPmPopup' in the array. |
3184 | - if ($context['show_pm_popup']) |
|
3185 | - addInlineJavaScript(' |
|
3372 | + if ($context['show_pm_popup']) { |
|
3373 | + addInlineJavaScript(' |
|
3186 | 3374 | jQuery(document).ready(function($) { |
3187 | 3375 | new smc_Popup({ |
3188 | 3376 | heading: ' . JavaScriptEscape($txt['show_personal_messages_heading']) . ', |
@@ -3190,15 +3378,17 @@ discard block |
||
3190 | 3378 | icon_class: \'generic_icons mail_new\' |
3191 | 3379 | }); |
3192 | 3380 | });'); |
3381 | + } |
|
3193 | 3382 | |
3194 | 3383 | // Add a generic "Are you sure?" confirmation message. |
3195 | 3384 | addInlineJavaScript(' |
3196 | 3385 | var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
3197 | 3386 | |
3198 | 3387 | // Now add the capping code for avatars. |
3199 | - if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize') |
|
3200 | - addInlineCss(' |
|
3388 | + if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize') { |
|
3389 | + addInlineCss(' |
|
3201 | 3390 | img.avatar { max-width: ' . $modSettings['avatar_max_width_external'] . 'px; max-height: ' . $modSettings['avatar_max_height_external'] . 'px; }'); |
3391 | + } |
|
3202 | 3392 | |
3203 | 3393 | // This looks weird, but it's because BoardIndex.php references the variable. |
3204 | 3394 | $context['common_stats']['latest_member'] = array( |
@@ -3215,11 +3405,13 @@ discard block |
||
3215 | 3405 | ); |
3216 | 3406 | $context['common_stats']['boardindex_total_posts'] = sprintf($txt['boardindex_total_posts'], $context['common_stats']['total_posts'], $context['common_stats']['total_topics'], $context['common_stats']['total_members']); |
3217 | 3407 | |
3218 | - if (empty($settings['theme_version'])) |
|
3219 | - addJavaScriptVar('smf_scripturl', $scripturl); |
|
3408 | + if (empty($settings['theme_version'])) { |
|
3409 | + addJavaScriptVar('smf_scripturl', $scripturl); |
|
3410 | + } |
|
3220 | 3411 | |
3221 | - if (!isset($context['page_title'])) |
|
3222 | - $context['page_title'] = ''; |
|
3412 | + if (!isset($context['page_title'])) { |
|
3413 | + $context['page_title'] = ''; |
|
3414 | + } |
|
3223 | 3415 | |
3224 | 3416 | // Set some specific vars. |
3225 | 3417 | $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
@@ -3229,21 +3421,23 @@ discard block |
||
3229 | 3421 | $context['meta_tags'][] = array('property' => 'og:site_name', 'content' => $context['forum_name']); |
3230 | 3422 | $context['meta_tags'][] = array('property' => 'og:title', 'content' => $context['page_title_html_safe']); |
3231 | 3423 | |
3232 | - if (!empty($context['meta_keywords'])) |
|
3233 | - $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
3424 | + if (!empty($context['meta_keywords'])) { |
|
3425 | + $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
3426 | + } |
|
3234 | 3427 | |
3235 | - if (!empty($context['canonical_url'])) |
|
3236 | - $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
3428 | + if (!empty($context['canonical_url'])) { |
|
3429 | + $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
3430 | + } |
|
3237 | 3431 | |
3238 | - if (!empty($settings['og_image'])) |
|
3239 | - $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
3432 | + if (!empty($settings['og_image'])) { |
|
3433 | + $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
3434 | + } |
|
3240 | 3435 | |
3241 | 3436 | if (!empty($context['meta_description'])) |
3242 | 3437 | { |
3243 | 3438 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['meta_description']); |
3244 | 3439 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['meta_description']); |
3245 | - } |
|
3246 | - else |
|
3440 | + } else |
|
3247 | 3441 | { |
3248 | 3442 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['page_title_html_safe']); |
3249 | 3443 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['page_title_html_safe']); |
@@ -3268,8 +3462,9 @@ discard block |
||
3268 | 3462 | $memory_needed = memoryReturnBytes($needed); |
3269 | 3463 | |
3270 | 3464 | // should we account for how much is currently being used? |
3271 | - if ($in_use) |
|
3272 | - $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
3465 | + if ($in_use) { |
|
3466 | + $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
3467 | + } |
|
3273 | 3468 | |
3274 | 3469 | // if more is needed, request it |
3275 | 3470 | if ($memory_current < $memory_needed) |
@@ -3292,8 +3487,9 @@ discard block |
||
3292 | 3487 | */ |
3293 | 3488 | function memoryReturnBytes($val) |
3294 | 3489 | { |
3295 | - if (is_integer($val)) |
|
3296 | - return $val; |
|
3490 | + if (is_integer($val)) { |
|
3491 | + return $val; |
|
3492 | + } |
|
3297 | 3493 | |
3298 | 3494 | // Separate the number from the designator |
3299 | 3495 | $val = trim($val); |
@@ -3329,10 +3525,11 @@ discard block |
||
3329 | 3525 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
3330 | 3526 | |
3331 | 3527 | // Are we debugging the template/html content? |
3332 | - if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) |
|
3333 | - header('Content-Type: application/xhtml+xml'); |
|
3334 | - elseif (!isset($_REQUEST['xml'])) |
|
3335 | - header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3528 | + if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) { |
|
3529 | + header('Content-Type: application/xhtml+xml'); |
|
3530 | + } elseif (!isset($_REQUEST['xml'])) { |
|
3531 | + header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3532 | + } |
|
3336 | 3533 | } |
3337 | 3534 | |
3338 | 3535 | header('Content-Type: text/' . (isset($_REQUEST['xml']) ? 'xml' : 'html') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
@@ -3341,8 +3538,9 @@ discard block |
||
3341 | 3538 | if ($context['in_maintenance'] && $context['user']['is_admin']) |
3342 | 3539 | { |
3343 | 3540 | $position = array_search('body', $context['template_layers']); |
3344 | - if ($position === false) |
|
3345 | - $position = array_search('main', $context['template_layers']); |
|
3541 | + if ($position === false) { |
|
3542 | + $position = array_search('main', $context['template_layers']); |
|
3543 | + } |
|
3346 | 3544 | |
3347 | 3545 | if ($position !== false) |
3348 | 3546 | { |
@@ -3370,23 +3568,25 @@ discard block |
||
3370 | 3568 | |
3371 | 3569 | foreach ($securityFiles as $i => $securityFile) |
3372 | 3570 | { |
3373 | - if (!file_exists($boarddir . '/' . $securityFile)) |
|
3374 | - unset($securityFiles[$i]); |
|
3571 | + if (!file_exists($boarddir . '/' . $securityFile)) { |
|
3572 | + unset($securityFiles[$i]); |
|
3573 | + } |
|
3375 | 3574 | } |
3376 | 3575 | |
3377 | 3576 | // We are already checking so many files...just few more doesn't make any difference! :P |
3378 | - if (!empty($modSettings['currentAttachmentUploadDir'])) |
|
3379 | - $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
3380 | - |
|
3381 | - else |
|
3382 | - $path = $modSettings['attachmentUploadDir']; |
|
3577 | + if (!empty($modSettings['currentAttachmentUploadDir'])) { |
|
3578 | + $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
3579 | + } else { |
|
3580 | + $path = $modSettings['attachmentUploadDir']; |
|
3581 | + } |
|
3383 | 3582 | |
3384 | 3583 | secureDirectory($path, true); |
3385 | 3584 | secureDirectory($cachedir); |
3386 | 3585 | |
3387 | 3586 | // If agreement is enabled, at least the english version shall exists |
3388 | - if ($modSettings['requireAgreement']) |
|
3389 | - $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
3587 | + if ($modSettings['requireAgreement']) { |
|
3588 | + $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
3589 | + } |
|
3390 | 3590 | |
3391 | 3591 | if (!empty($securityFiles) || (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) || !empty($agreement)) |
3392 | 3592 | { |
@@ -3401,18 +3601,21 @@ discard block |
||
3401 | 3601 | echo ' |
3402 | 3602 | ', $txt['not_removed'], '<strong>', $securityFile, '</strong>!<br>'; |
3403 | 3603 | |
3404 | - if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') |
|
3405 | - echo ' |
|
3604 | + if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') { |
|
3605 | + echo ' |
|
3406 | 3606 | ', sprintf($txt['not_removed_extra'], $securityFile, substr($securityFile, 0, -1)), '<br>'; |
3607 | + } |
|
3407 | 3608 | } |
3408 | 3609 | |
3409 | - if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) |
|
3410 | - echo ' |
|
3610 | + if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) { |
|
3611 | + echo ' |
|
3411 | 3612 | <strong>', $txt['cache_writable'], '</strong><br>'; |
3613 | + } |
|
3412 | 3614 | |
3413 | - if (!empty($agreement)) |
|
3414 | - echo ' |
|
3615 | + if (!empty($agreement)) { |
|
3616 | + echo ' |
|
3415 | 3617 | <strong>', $txt['agreement_missing'], '</strong><br>'; |
3618 | + } |
|
3416 | 3619 | |
3417 | 3620 | echo ' |
3418 | 3621 | </p> |
@@ -3427,16 +3630,18 @@ discard block |
||
3427 | 3630 | <div class="windowbg alert" style="margin: 2ex; padding: 2ex; border: 2px dashed red;"> |
3428 | 3631 | ', sprintf($txt['you_are_post_banned'], $user_info['is_guest'] ? $txt['guest_title'] : $user_info['name']); |
3429 | 3632 | |
3430 | - if (!empty($_SESSION['ban']['cannot_post']['reason'])) |
|
3431 | - echo ' |
|
3633 | + if (!empty($_SESSION['ban']['cannot_post']['reason'])) { |
|
3634 | + echo ' |
|
3432 | 3635 | <div style="padding-left: 4ex; padding-top: 1ex;">', $_SESSION['ban']['cannot_post']['reason'], '</div>'; |
3636 | + } |
|
3433 | 3637 | |
3434 | - if (!empty($_SESSION['ban']['expire_time'])) |
|
3435 | - echo ' |
|
3638 | + if (!empty($_SESSION['ban']['expire_time'])) { |
|
3639 | + echo ' |
|
3436 | 3640 | <div>', sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)), '</div>'; |
3437 | - else |
|
3438 | - echo ' |
|
3641 | + } else { |
|
3642 | + echo ' |
|
3439 | 3643 | <div>', $txt['your_ban_expires_never'], '</div>'; |
3644 | + } |
|
3440 | 3645 | |
3441 | 3646 | echo ' |
3442 | 3647 | </div>'; |
@@ -3452,8 +3657,9 @@ discard block |
||
3452 | 3657 | global $forum_copyright, $software_year, $forum_version; |
3453 | 3658 | |
3454 | 3659 | // Don't display copyright for things like SSI. |
3455 | - if (!isset($forum_version) || !isset($software_year)) |
|
3456 | - return; |
|
3660 | + if (!isset($forum_version) || !isset($software_year)) { |
|
3661 | + return; |
|
3662 | + } |
|
3457 | 3663 | |
3458 | 3664 | // Put in the version... |
3459 | 3665 | printf($forum_copyright, $forum_version, $software_year); |
@@ -3471,9 +3677,10 @@ discard block |
||
3471 | 3677 | $context['load_time'] = comma_format(round(array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)), 3)); |
3472 | 3678 | $context['load_queries'] = $db_count; |
3473 | 3679 | |
3474 | - foreach (array_reverse($context['template_layers']) as $layer) |
|
3475 | - loadSubTemplate($layer . '_below', true); |
|
3476 | -} |
|
3680 | + foreach (array_reverse($context['template_layers']) as $layer) { |
|
3681 | + loadSubTemplate($layer . '_below', true); |
|
3682 | + } |
|
3683 | + } |
|
3477 | 3684 | |
3478 | 3685 | /** |
3479 | 3686 | * Output the Javascript files |
@@ -3504,8 +3711,7 @@ discard block |
||
3504 | 3711 | { |
3505 | 3712 | echo ' |
3506 | 3713 | var ', $key, ';'; |
3507 | - } |
|
3508 | - else |
|
3714 | + } else |
|
3509 | 3715 | { |
3510 | 3716 | echo ' |
3511 | 3717 | var ', $key, ' = ', $value, ';'; |
@@ -3520,26 +3726,27 @@ discard block |
||
3520 | 3726 | foreach ($context['javascript_files'] as $id => $js_file) |
3521 | 3727 | { |
3522 | 3728 | // Last minute call! allow theme authors to disable single files. |
3523 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
3524 | - continue; |
|
3729 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
3730 | + continue; |
|
3731 | + } |
|
3525 | 3732 | |
3526 | 3733 | // By default all files don't get minimized unless the file explicitly says so! |
3527 | 3734 | if (!empty($js_file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
3528 | 3735 | { |
3529 | - if ($do_deferred && !empty($js_file['options']['defer'])) |
|
3530 | - $toMinifyDefer[] = $js_file; |
|
3531 | - |
|
3532 | - elseif (!$do_deferred && empty($js_file['options']['defer'])) |
|
3533 | - $toMinify[] = $js_file; |
|
3736 | + if ($do_deferred && !empty($js_file['options']['defer'])) { |
|
3737 | + $toMinifyDefer[] = $js_file; |
|
3738 | + } elseif (!$do_deferred && empty($js_file['options']['defer'])) { |
|
3739 | + $toMinify[] = $js_file; |
|
3740 | + } |
|
3534 | 3741 | |
3535 | 3742 | // Grab a random seed. |
3536 | - if (!isset($minSeed)) |
|
3537 | - $minSeed = $js_file['options']['seed']; |
|
3538 | - } |
|
3539 | - |
|
3540 | - elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) |
|
3541 | - echo ' |
|
3743 | + if (!isset($minSeed)) { |
|
3744 | + $minSeed = $js_file['options']['seed']; |
|
3745 | + } |
|
3746 | + } elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) { |
|
3747 | + echo ' |
|
3542 | 3748 | <script src="', $js_file['fileUrl'], '"', !empty($js_file['options']['async']) ? ' async="async"' : '', '></script>'; |
3749 | + } |
|
3543 | 3750 | } |
3544 | 3751 | |
3545 | 3752 | if ((!$do_deferred && !empty($toMinify)) || ($do_deferred && !empty($toMinifyDefer))) |
@@ -3547,14 +3754,14 @@ discard block |
||
3547 | 3754 | $result = custMinify(($do_deferred ? $toMinifyDefer : $toMinify), 'js', $do_deferred); |
3548 | 3755 | |
3549 | 3756 | // Minify process couldn't work, print each individual files. |
3550 | - if (!empty($result) && is_array($result)) |
|
3551 | - foreach ($result as $minFailedFile) |
|
3757 | + if (!empty($result) && is_array($result)) { |
|
3758 | + foreach ($result as $minFailedFile) |
|
3552 | 3759 | echo ' |
3553 | 3760 | <script src="', $minFailedFile['fileUrl'], '"', !empty($minFailedFile['options']['async']) ? ' async="async"' : '', '></script>'; |
3554 | - |
|
3555 | - else |
|
3556 | - echo ' |
|
3761 | + } else { |
|
3762 | + echo ' |
|
3557 | 3763 | <script src="', $settings['theme_url'] ,'/scripts/minified', ($do_deferred ? '_deferred' : '') ,'.js', $minSeed ,'"></script>'; |
3764 | + } |
|
3558 | 3765 | } |
3559 | 3766 | |
3560 | 3767 | // Inline JavaScript - Actually useful some times! |
@@ -3565,8 +3772,9 @@ discard block |
||
3565 | 3772 | echo ' |
3566 | 3773 | <script>'; |
3567 | 3774 | |
3568 | - foreach ($context['javascript_inline']['defer'] as $js_code) |
|
3569 | - echo $js_code; |
|
3775 | + foreach ($context['javascript_inline']['defer'] as $js_code) { |
|
3776 | + echo $js_code; |
|
3777 | + } |
|
3570 | 3778 | |
3571 | 3779 | echo ' |
3572 | 3780 | </script>'; |
@@ -3577,8 +3785,9 @@ discard block |
||
3577 | 3785 | echo ' |
3578 | 3786 | <script>'; |
3579 | 3787 | |
3580 | - foreach ($context['javascript_inline']['standard'] as $js_code) |
|
3581 | - echo $js_code; |
|
3788 | + foreach ($context['javascript_inline']['standard'] as $js_code) { |
|
3789 | + echo $js_code; |
|
3790 | + } |
|
3582 | 3791 | |
3583 | 3792 | echo ' |
3584 | 3793 | </script>'; |
@@ -3603,8 +3812,9 @@ discard block |
||
3603 | 3812 | foreach ($context['css_files'] as $id => $file) |
3604 | 3813 | { |
3605 | 3814 | // Last minute call! allow theme authors to disable single files. |
3606 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
3607 | - continue; |
|
3815 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
3816 | + continue; |
|
3817 | + } |
|
3608 | 3818 | |
3609 | 3819 | // By default all files don't get minimized unless the file explicitly says so! |
3610 | 3820 | if (!empty($file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
@@ -3612,12 +3822,12 @@ discard block |
||
3612 | 3822 | $toMinify[] = $file; |
3613 | 3823 | |
3614 | 3824 | // Grab a random seed. |
3615 | - if (!isset($minSeed)) |
|
3616 | - $minSeed = $file['options']['seed']; |
|
3825 | + if (!isset($minSeed)) { |
|
3826 | + $minSeed = $file['options']['seed']; |
|
3827 | + } |
|
3828 | + } else { |
|
3829 | + $normal[] = $file['fileUrl']; |
|
3617 | 3830 | } |
3618 | - |
|
3619 | - else |
|
3620 | - $normal[] = $file['fileUrl']; |
|
3621 | 3831 | } |
3622 | 3832 | |
3623 | 3833 | if (!empty($toMinify)) |
@@ -3625,28 +3835,30 @@ discard block |
||
3625 | 3835 | $result = custMinify($toMinify, 'css'); |
3626 | 3836 | |
3627 | 3837 | // Minify process couldn't work, print each individual files. |
3628 | - if (!empty($result) && is_array($result)) |
|
3629 | - foreach ($result as $minFailedFile) |
|
3838 | + if (!empty($result) && is_array($result)) { |
|
3839 | + foreach ($result as $minFailedFile) |
|
3630 | 3840 | echo ' |
3631 | 3841 | <link rel="stylesheet" href="', $minFailedFile['fileUrl'], '">'; |
3632 | - |
|
3633 | - else |
|
3634 | - echo ' |
|
3842 | + } else { |
|
3843 | + echo ' |
|
3635 | 3844 | <link rel="stylesheet" href="', $settings['theme_url'] ,'/css/minified.css', $minSeed ,'">'; |
3845 | + } |
|
3636 | 3846 | } |
3637 | 3847 | |
3638 | 3848 | // Print the rest after the minified files. |
3639 | - if (!empty($normal)) |
|
3640 | - foreach ($normal as $nf) |
|
3849 | + if (!empty($normal)) { |
|
3850 | + foreach ($normal as $nf) |
|
3641 | 3851 | echo ' |
3642 | 3852 | <link rel="stylesheet" href="', $nf ,'">'; |
3853 | + } |
|
3643 | 3854 | |
3644 | 3855 | if ($db_show_debug === true) |
3645 | 3856 | { |
3646 | 3857 | // Try to keep only what's useful. |
3647 | 3858 | $repl = array($boardurl . '/Themes/' => '', $boardurl . '/' => ''); |
3648 | - foreach ($context['css_files'] as $file) |
|
3649 | - $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
3859 | + foreach ($context['css_files'] as $file) { |
|
3860 | + $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
3861 | + } |
|
3650 | 3862 | } |
3651 | 3863 | |
3652 | 3864 | if (!empty($context['css_header'])) |
@@ -3654,9 +3866,10 @@ discard block |
||
3654 | 3866 | echo ' |
3655 | 3867 | <style>'; |
3656 | 3868 | |
3657 | - foreach ($context['css_header'] as $css) |
|
3658 | - echo $css .' |
|
3869 | + foreach ($context['css_header'] as $css) { |
|
3870 | + echo $css .' |
|
3659 | 3871 | '; |
3872 | + } |
|
3660 | 3873 | |
3661 | 3874 | echo' |
3662 | 3875 | </style>'; |
@@ -3680,15 +3893,17 @@ discard block |
||
3680 | 3893 | $type = !empty($type) && in_array($type, $types) ? $type : false; |
3681 | 3894 | $data = !empty($data) ? $data : false; |
3682 | 3895 | |
3683 | - if (empty($type) || empty($data)) |
|
3684 | - return false; |
|
3896 | + if (empty($type) || empty($data)) { |
|
3897 | + return false; |
|
3898 | + } |
|
3685 | 3899 | |
3686 | 3900 | // Did we already did this? |
3687 | 3901 | $toCache = cache_get_data('minimized_'. $settings['theme_id'] .'_'. $type, 86400); |
3688 | 3902 | |
3689 | 3903 | // Already done? |
3690 | - if (!empty($toCache)) |
|
3691 | - return true; |
|
3904 | + if (!empty($toCache)) { |
|
3905 | + return true; |
|
3906 | + } |
|
3692 | 3907 | |
3693 | 3908 | // No namespaces, sorry! |
3694 | 3909 | $classType = 'MatthiasMullie\\Minify\\'. strtoupper($type); |
@@ -3770,8 +3985,9 @@ discard block |
||
3770 | 3985 | global $modSettings, $smcFunc; |
3771 | 3986 | |
3772 | 3987 | // Just make up a nice hash... |
3773 | - if ($new) |
|
3774 | - return sha1(md5($filename . time()) . mt_rand()); |
|
3988 | + if ($new) { |
|
3989 | + return sha1(md5($filename . time()) . mt_rand()); |
|
3990 | + } |
|
3775 | 3991 | |
3776 | 3992 | // Just make sure that attachment id is only a int |
3777 | 3993 | $attachment_id = (int) $attachment_id; |
@@ -3788,23 +4004,25 @@ discard block |
||
3788 | 4004 | 'id_attach' => $attachment_id, |
3789 | 4005 | )); |
3790 | 4006 | |
3791 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
3792 | - return false; |
|
4007 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
4008 | + return false; |
|
4009 | + } |
|
3793 | 4010 | |
3794 | 4011 | list ($file_hash) = $smcFunc['db_fetch_row']($request); |
3795 | 4012 | $smcFunc['db_free_result']($request); |
3796 | 4013 | } |
3797 | 4014 | |
3798 | 4015 | // Still no hash? mmm... |
3799 | - if (empty($file_hash)) |
|
3800 | - $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
4016 | + if (empty($file_hash)) { |
|
4017 | + $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
4018 | + } |
|
3801 | 4019 | |
3802 | 4020 | // Are we using multiple directories? |
3803 | - if (is_array($modSettings['attachmentUploadDir'])) |
|
3804 | - $path = $modSettings['attachmentUploadDir'][$dir]; |
|
3805 | - |
|
3806 | - else |
|
3807 | - $path = $modSettings['attachmentUploadDir']; |
|
4021 | + if (is_array($modSettings['attachmentUploadDir'])) { |
|
4022 | + $path = $modSettings['attachmentUploadDir'][$dir]; |
|
4023 | + } else { |
|
4024 | + $path = $modSettings['attachmentUploadDir']; |
|
4025 | + } |
|
3808 | 4026 | |
3809 | 4027 | return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
3810 | 4028 | } |
@@ -3819,8 +4037,9 @@ discard block |
||
3819 | 4037 | function ip2range($fullip) |
3820 | 4038 | { |
3821 | 4039 | // Pretend that 'unknown' is 255.255.255.255. (since that can't be an IP anyway.) |
3822 | - if ($fullip == 'unknown') |
|
3823 | - $fullip = '255.255.255.255'; |
|
4040 | + if ($fullip == 'unknown') { |
|
4041 | + $fullip = '255.255.255.255'; |
|
4042 | + } |
|
3824 | 4043 | |
3825 | 4044 | $ip_parts = explode('-', $fullip); |
3826 | 4045 | $ip_array = array(); |
@@ -3844,10 +4063,11 @@ discard block |
||
3844 | 4063 | $ip_array['low'] = $ip_parts[0]; |
3845 | 4064 | $ip_array['high'] = $ip_parts[1]; |
3846 | 4065 | return $ip_array; |
3847 | - } |
|
3848 | - elseif (count($ip_parts) == 2) // if ip 22.22.*-22.22.* |
|
4066 | + } elseif (count($ip_parts) == 2) { |
|
4067 | + // if ip 22.22.*-22.22.* |
|
3849 | 4068 | { |
3850 | 4069 | $valid_low = isValidIP($ip_parts[0]); |
4070 | + } |
|
3851 | 4071 | $valid_high = isValidIP($ip_parts[1]); |
3852 | 4072 | $count = 0; |
3853 | 4073 | $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
@@ -3862,7 +4082,9 @@ discard block |
||
3862 | 4082 | $ip_parts[0] .= $mode . $min; |
3863 | 4083 | $valid_low = isValidIP($ip_parts[0]); |
3864 | 4084 | $count++; |
3865 | - if ($count > 9) break; |
|
4085 | + if ($count > 9) { |
|
4086 | + break; |
|
4087 | + } |
|
3866 | 4088 | } |
3867 | 4089 | } |
3868 | 4090 | |
@@ -3876,7 +4098,9 @@ discard block |
||
3876 | 4098 | $ip_parts[1] .= $mode . $max; |
3877 | 4099 | $valid_high = isValidIP($ip_parts[1]); |
3878 | 4100 | $count++; |
3879 | - if ($count > 9) break; |
|
4101 | + if ($count > 9) { |
|
4102 | + break; |
|
4103 | + } |
|
3880 | 4104 | } |
3881 | 4105 | } |
3882 | 4106 | |
@@ -3901,46 +4125,54 @@ discard block |
||
3901 | 4125 | { |
3902 | 4126 | global $modSettings; |
3903 | 4127 | |
3904 | - if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) |
|
3905 | - return $host; |
|
4128 | + if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) { |
|
4129 | + return $host; |
|
4130 | + } |
|
3906 | 4131 | $t = microtime(); |
3907 | 4132 | |
3908 | 4133 | // Try the Linux host command, perhaps? |
3909 | 4134 | if (!isset($host) && (strpos(strtolower(PHP_OS), 'win') === false || strpos(strtolower(PHP_OS), 'darwin') !== false) && mt_rand(0, 1) == 1) |
3910 | 4135 | { |
3911 | - if (!isset($modSettings['host_to_dis'])) |
|
3912 | - $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
3913 | - else |
|
3914 | - $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
4136 | + if (!isset($modSettings['host_to_dis'])) { |
|
4137 | + $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
4138 | + } else { |
|
4139 | + $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
4140 | + } |
|
3915 | 4141 | |
3916 | 4142 | // Did host say it didn't find anything? |
3917 | - if (strpos($test, 'not found') !== false) |
|
3918 | - $host = ''; |
|
4143 | + if (strpos($test, 'not found') !== false) { |
|
4144 | + $host = ''; |
|
4145 | + } |
|
3919 | 4146 | // Invalid server option? |
3920 | - elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) |
|
3921 | - updateSettings(array('host_to_dis' => 1)); |
|
4147 | + elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) { |
|
4148 | + updateSettings(array('host_to_dis' => 1)); |
|
4149 | + } |
|
3922 | 4150 | // Maybe it found something, after all? |
3923 | - elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) |
|
3924 | - $host = $match[1]; |
|
4151 | + elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) { |
|
4152 | + $host = $match[1]; |
|
4153 | + } |
|
3925 | 4154 | } |
3926 | 4155 | |
3927 | 4156 | // This is nslookup; usually only Windows, but possibly some Unix? |
3928 | 4157 | if (!isset($host) && stripos(PHP_OS, 'win') !== false && strpos(strtolower(PHP_OS), 'darwin') === false && mt_rand(0, 1) == 1) |
3929 | 4158 | { |
3930 | 4159 | $test = @shell_exec('nslookup -timeout=1 ' . @escapeshellarg($ip)); |
3931 | - if (strpos($test, 'Non-existent domain') !== false) |
|
3932 | - $host = ''; |
|
3933 | - elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) |
|
3934 | - $host = $match[1]; |
|
4160 | + if (strpos($test, 'Non-existent domain') !== false) { |
|
4161 | + $host = ''; |
|
4162 | + } elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) { |
|
4163 | + $host = $match[1]; |
|
4164 | + } |
|
3935 | 4165 | } |
3936 | 4166 | |
3937 | 4167 | // This is the last try :/. |
3938 | - if (!isset($host) || $host === false) |
|
3939 | - $host = @gethostbyaddr($ip); |
|
4168 | + if (!isset($host) || $host === false) { |
|
4169 | + $host = @gethostbyaddr($ip); |
|
4170 | + } |
|
3940 | 4171 | |
3941 | 4172 | // It took a long time, so let's cache it! |
3942 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) |
|
3943 | - cache_put_data('hostlookup-' . $ip, $host, 600); |
|
4173 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) { |
|
4174 | + cache_put_data('hostlookup-' . $ip, $host, 600); |
|
4175 | + } |
|
3944 | 4176 | |
3945 | 4177 | return $host; |
3946 | 4178 | } |
@@ -3976,20 +4208,21 @@ discard block |
||
3976 | 4208 | { |
3977 | 4209 | $encrypted = substr(crypt($word, 'uk'), 2, $max_chars); |
3978 | 4210 | $total = 0; |
3979 | - for ($i = 0; $i < $max_chars; $i++) |
|
3980 | - $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
4211 | + for ($i = 0; $i < $max_chars; $i++) { |
|
4212 | + $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
4213 | + } |
|
3981 | 4214 | $returned_ints[] = $max_chars == 4 ? min($total, 16777215) : $total; |
3982 | 4215 | } |
3983 | 4216 | } |
3984 | 4217 | return array_unique($returned_ints); |
3985 | - } |
|
3986 | - else |
|
4218 | + } else |
|
3987 | 4219 | { |
3988 | 4220 | // Trim characters before and after and add slashes for database insertion. |
3989 | 4221 | $returned_words = array(); |
3990 | - foreach ($words as $word) |
|
3991 | - if (($word = trim($word, '-_\'')) !== '') |
|
4222 | + foreach ($words as $word) { |
|
4223 | + if (($word = trim($word, '-_\'')) !== '') |
|
3992 | 4224 | $returned_words[] = $max_chars === null ? $word : substr($word, 0, $max_chars); |
4225 | + } |
|
3993 | 4226 | |
3994 | 4227 | // Filter out all words that occur more than once. |
3995 | 4228 | return array_unique($returned_words); |
@@ -4011,16 +4244,18 @@ discard block |
||
4011 | 4244 | global $settings, $txt; |
4012 | 4245 | |
4013 | 4246 | // Does the current loaded theme have this and we are not forcing the usage of this function? |
4014 | - if (function_exists('template_create_button') && !$force_use) |
|
4015 | - return template_create_button($name, $alt, $label = '', $custom = ''); |
|
4247 | + if (function_exists('template_create_button') && !$force_use) { |
|
4248 | + return template_create_button($name, $alt, $label = '', $custom = ''); |
|
4249 | + } |
|
4016 | 4250 | |
4017 | - if (!$settings['use_image_buttons']) |
|
4018 | - return $txt[$alt]; |
|
4019 | - elseif (!empty($settings['use_buttons'])) |
|
4020 | - return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
4021 | - else |
|
4022 | - return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
4023 | -} |
|
4251 | + if (!$settings['use_image_buttons']) { |
|
4252 | + return $txt[$alt]; |
|
4253 | + } elseif (!empty($settings['use_buttons'])) { |
|
4254 | + return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
4255 | + } else { |
|
4256 | + return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
4257 | + } |
|
4258 | + } |
|
4024 | 4259 | |
4025 | 4260 | /** |
4026 | 4261 | * Sets up all of the top menu buttons |
@@ -4063,9 +4298,10 @@ discard block |
||
4063 | 4298 | var user_menus = new smc_PopupMenu(); |
4064 | 4299 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
4065 | 4300 | user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
4066 | - if ($context['allow_pm']) |
|
4067 | - addInlineJavaScript(' |
|
4301 | + if ($context['allow_pm']) { |
|
4302 | + addInlineJavaScript(' |
|
4068 | 4303 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
4304 | + } |
|
4069 | 4305 | |
4070 | 4306 | if (!empty($modSettings['enable_ajax_alerts'])) |
4071 | 4307 | { |
@@ -4225,88 +4461,96 @@ discard block |
||
4225 | 4461 | |
4226 | 4462 | // Now we put the buttons in the context so the theme can use them. |
4227 | 4463 | $menu_buttons = array(); |
4228 | - foreach ($buttons as $act => $button) |
|
4229 | - if (!empty($button['show'])) |
|
4464 | + foreach ($buttons as $act => $button) { |
|
4465 | + if (!empty($button['show'])) |
|
4230 | 4466 | { |
4231 | 4467 | $button['active_button'] = false; |
4468 | + } |
|
4232 | 4469 | |
4233 | 4470 | // This button needs some action. |
4234 | - if (isset($button['action_hook'])) |
|
4235 | - $needs_action_hook = true; |
|
4471 | + if (isset($button['action_hook'])) { |
|
4472 | + $needs_action_hook = true; |
|
4473 | + } |
|
4236 | 4474 | |
4237 | 4475 | // Make sure the last button truly is the last button. |
4238 | 4476 | if (!empty($button['is_last'])) |
4239 | 4477 | { |
4240 | - if (isset($last_button)) |
|
4241 | - unset($menu_buttons[$last_button]['is_last']); |
|
4478 | + if (isset($last_button)) { |
|
4479 | + unset($menu_buttons[$last_button]['is_last']); |
|
4480 | + } |
|
4242 | 4481 | $last_button = $act; |
4243 | 4482 | } |
4244 | 4483 | |
4245 | 4484 | // Go through the sub buttons if there are any. |
4246 | - if (!empty($button['sub_buttons'])) |
|
4247 | - foreach ($button['sub_buttons'] as $key => $subbutton) |
|
4485 | + if (!empty($button['sub_buttons'])) { |
|
4486 | + foreach ($button['sub_buttons'] as $key => $subbutton) |
|
4248 | 4487 | { |
4249 | 4488 | if (empty($subbutton['show'])) |
4250 | 4489 | unset($button['sub_buttons'][$key]); |
4490 | + } |
|
4251 | 4491 | |
4252 | 4492 | // 2nd level sub buttons next... |
4253 | 4493 | if (!empty($subbutton['sub_buttons'])) |
4254 | 4494 | { |
4255 | 4495 | foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2) |
4256 | 4496 | { |
4257 | - if (empty($sub_button2['show'])) |
|
4258 | - unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
4497 | + if (empty($sub_button2['show'])) { |
|
4498 | + unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
4499 | + } |
|
4259 | 4500 | } |
4260 | 4501 | } |
4261 | 4502 | } |
4262 | 4503 | |
4263 | 4504 | // Does this button have its own icon? |
4264 | - if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) |
|
4265 | - $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4266 | - elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) |
|
4267 | - $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4268 | - elseif (isset($button['icon'])) |
|
4269 | - $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
4270 | - else |
|
4271 | - $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
4505 | + if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) { |
|
4506 | + $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4507 | + } elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) { |
|
4508 | + $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4509 | + } elseif (isset($button['icon'])) { |
|
4510 | + $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
4511 | + } else { |
|
4512 | + $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
4513 | + } |
|
4272 | 4514 | |
4273 | 4515 | $menu_buttons[$act] = $button; |
4274 | 4516 | } |
4275 | 4517 | |
4276 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
4277 | - cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
4518 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
4519 | + cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
4520 | + } |
|
4278 | 4521 | } |
4279 | 4522 | |
4280 | 4523 | $context['menu_buttons'] = $menu_buttons; |
4281 | 4524 | |
4282 | 4525 | // Logging out requires the session id in the url. |
4283 | - if (isset($context['menu_buttons']['logout'])) |
|
4284 | - $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
4526 | + if (isset($context['menu_buttons']['logout'])) { |
|
4527 | + $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
4528 | + } |
|
4285 | 4529 | |
4286 | 4530 | // Figure out which action we are doing so we can set the active tab. |
4287 | 4531 | // Default to home. |
4288 | 4532 | $current_action = 'home'; |
4289 | 4533 | |
4290 | - if (isset($context['menu_buttons'][$context['current_action']])) |
|
4291 | - $current_action = $context['current_action']; |
|
4292 | - elseif ($context['current_action'] == 'search2') |
|
4293 | - $current_action = 'search'; |
|
4294 | - elseif ($context['current_action'] == 'theme') |
|
4295 | - $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
4296 | - elseif ($context['current_action'] == 'register2') |
|
4297 | - $current_action = 'register'; |
|
4298 | - elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) |
|
4299 | - $current_action = 'login'; |
|
4300 | - elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) |
|
4301 | - $current_action = 'moderate'; |
|
4534 | + if (isset($context['menu_buttons'][$context['current_action']])) { |
|
4535 | + $current_action = $context['current_action']; |
|
4536 | + } elseif ($context['current_action'] == 'search2') { |
|
4537 | + $current_action = 'search'; |
|
4538 | + } elseif ($context['current_action'] == 'theme') { |
|
4539 | + $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
4540 | + } elseif ($context['current_action'] == 'register2') { |
|
4541 | + $current_action = 'register'; |
|
4542 | + } elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) { |
|
4543 | + $current_action = 'login'; |
|
4544 | + } elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) { |
|
4545 | + $current_action = 'moderate'; |
|
4546 | + } |
|
4302 | 4547 | |
4303 | 4548 | // There are certain exceptions to the above where we don't want anything on the menu highlighted. |
4304 | 4549 | if ($context['current_action'] == 'profile' && !empty($context['user']['is_owner'])) |
4305 | 4550 | { |
4306 | 4551 | $current_action = !empty($_GET['area']) && $_GET['area'] == 'showalerts' ? 'self_alerts' : 'self_profile'; |
4307 | 4552 | $context[$current_action] = true; |
4308 | - } |
|
4309 | - elseif ($context['current_action'] == 'pm') |
|
4553 | + } elseif ($context['current_action'] == 'pm') |
|
4310 | 4554 | { |
4311 | 4555 | $current_action = 'self_pm'; |
4312 | 4556 | $context['self_pm'] = true; |
@@ -4347,12 +4591,14 @@ discard block |
||
4347 | 4591 | } |
4348 | 4592 | |
4349 | 4593 | // Not all actions are simple. |
4350 | - if (!empty($needs_action_hook)) |
|
4351 | - call_integration_hook('integrate_current_action', array(&$current_action)); |
|
4594 | + if (!empty($needs_action_hook)) { |
|
4595 | + call_integration_hook('integrate_current_action', array(&$current_action)); |
|
4596 | + } |
|
4352 | 4597 | |
4353 | - if (isset($context['menu_buttons'][$current_action])) |
|
4354 | - $context['menu_buttons'][$current_action]['active_button'] = true; |
|
4355 | -} |
|
4598 | + if (isset($context['menu_buttons'][$current_action])) { |
|
4599 | + $context['menu_buttons'][$current_action]['active_button'] = true; |
|
4600 | + } |
|
4601 | + } |
|
4356 | 4602 | |
4357 | 4603 | /** |
4358 | 4604 | * Generate a random seed and ensure it's stored in settings. |
@@ -4376,30 +4622,35 @@ discard block |
||
4376 | 4622 | global $modSettings, $settings, $boarddir, $sourcedir, $db_show_debug; |
4377 | 4623 | global $context, $txt; |
4378 | 4624 | |
4379 | - if ($db_show_debug === true) |
|
4380 | - $context['debug']['hooks'][] = $hook; |
|
4625 | + if ($db_show_debug === true) { |
|
4626 | + $context['debug']['hooks'][] = $hook; |
|
4627 | + } |
|
4381 | 4628 | |
4382 | 4629 | // Need to have some control. |
4383 | - if (!isset($context['instances'])) |
|
4384 | - $context['instances'] = array(); |
|
4630 | + if (!isset($context['instances'])) { |
|
4631 | + $context['instances'] = array(); |
|
4632 | + } |
|
4385 | 4633 | |
4386 | 4634 | $results = array(); |
4387 | - if (empty($modSettings[$hook])) |
|
4388 | - return $results; |
|
4635 | + if (empty($modSettings[$hook])) { |
|
4636 | + return $results; |
|
4637 | + } |
|
4389 | 4638 | |
4390 | 4639 | $functions = explode(',', $modSettings[$hook]); |
4391 | 4640 | // Loop through each function. |
4392 | 4641 | foreach ($functions as $function) |
4393 | 4642 | { |
4394 | 4643 | // Hook has been marked as "disabled". Skip it! |
4395 | - if (strpos($function, '!') !== false) |
|
4396 | - continue; |
|
4644 | + if (strpos($function, '!') !== false) { |
|
4645 | + continue; |
|
4646 | + } |
|
4397 | 4647 | |
4398 | 4648 | $call = call_helper($function, true); |
4399 | 4649 | |
4400 | 4650 | // Is it valid? |
4401 | - if (!empty($call)) |
|
4402 | - $results[$function] = call_user_func_array($call, $parameters); |
|
4651 | + if (!empty($call)) { |
|
4652 | + $results[$function] = call_user_func_array($call, $parameters); |
|
4653 | + } |
|
4403 | 4654 | |
4404 | 4655 | // Whatever it was suppose to call, it failed :( |
4405 | 4656 | elseif (!empty($function)) |
@@ -4415,8 +4666,9 @@ discard block |
||
4415 | 4666 | } |
4416 | 4667 | |
4417 | 4668 | // "Assume" the file resides on $boarddir somewhere... |
4418 | - else |
|
4419 | - log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
4669 | + else { |
|
4670 | + log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
4671 | + } |
|
4420 | 4672 | } |
4421 | 4673 | } |
4422 | 4674 | |
@@ -4438,12 +4690,14 @@ discard block |
||
4438 | 4690 | global $smcFunc, $modSettings; |
4439 | 4691 | |
4440 | 4692 | // Any objects? |
4441 | - if ($object) |
|
4442 | - $function = $function . '#'; |
|
4693 | + if ($object) { |
|
4694 | + $function = $function . '#'; |
|
4695 | + } |
|
4443 | 4696 | |
4444 | 4697 | // Any files to load? |
4445 | - if (!empty($file) && is_string($file)) |
|
4446 | - $function = $file . (!empty($function) ? '|' . $function : ''); |
|
4698 | + if (!empty($file) && is_string($file)) { |
|
4699 | + $function = $file . (!empty($function) ? '|' . $function : ''); |
|
4700 | + } |
|
4447 | 4701 | |
4448 | 4702 | // Get the correct string. |
4449 | 4703 | $integration_call = $function; |
@@ -4465,13 +4719,14 @@ discard block |
||
4465 | 4719 | if (!empty($current_functions)) |
4466 | 4720 | { |
4467 | 4721 | $current_functions = explode(',', $current_functions); |
4468 | - if (in_array($integration_call, $current_functions)) |
|
4469 | - return; |
|
4722 | + if (in_array($integration_call, $current_functions)) { |
|
4723 | + return; |
|
4724 | + } |
|
4470 | 4725 | |
4471 | 4726 | $permanent_functions = array_merge($current_functions, array($integration_call)); |
4727 | + } else { |
|
4728 | + $permanent_functions = array($integration_call); |
|
4472 | 4729 | } |
4473 | - else |
|
4474 | - $permanent_functions = array($integration_call); |
|
4475 | 4730 | |
4476 | 4731 | updateSettings(array($hook => implode(',', $permanent_functions))); |
4477 | 4732 | } |
@@ -4480,8 +4735,9 @@ discard block |
||
4480 | 4735 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
4481 | 4736 | |
4482 | 4737 | // Do nothing, if it's already there. |
4483 | - if (in_array($integration_call, $functions)) |
|
4484 | - return; |
|
4738 | + if (in_array($integration_call, $functions)) { |
|
4739 | + return; |
|
4740 | + } |
|
4485 | 4741 | |
4486 | 4742 | $functions[] = $integration_call; |
4487 | 4743 | $modSettings[$hook] = implode(',', $functions); |
@@ -4504,12 +4760,14 @@ discard block |
||
4504 | 4760 | global $smcFunc, $modSettings; |
4505 | 4761 | |
4506 | 4762 | // Any objects? |
4507 | - if ($object) |
|
4508 | - $function = $function . '#'; |
|
4763 | + if ($object) { |
|
4764 | + $function = $function . '#'; |
|
4765 | + } |
|
4509 | 4766 | |
4510 | 4767 | // Any files to load? |
4511 | - if (!empty($file) && is_string($file)) |
|
4512 | - $function = $file . '|' . $function; |
|
4768 | + if (!empty($file) && is_string($file)) { |
|
4769 | + $function = $file . '|' . $function; |
|
4770 | + } |
|
4513 | 4771 | |
4514 | 4772 | // Get the correct string. |
4515 | 4773 | $integration_call = $function; |
@@ -4530,16 +4788,18 @@ discard block |
||
4530 | 4788 | { |
4531 | 4789 | $current_functions = explode(',', $current_functions); |
4532 | 4790 | |
4533 | - if (in_array($integration_call, $current_functions)) |
|
4534 | - updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
4791 | + if (in_array($integration_call, $current_functions)) { |
|
4792 | + updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
4793 | + } |
|
4535 | 4794 | } |
4536 | 4795 | |
4537 | 4796 | // Turn the function list into something usable. |
4538 | 4797 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
4539 | 4798 | |
4540 | 4799 | // You can only remove it if it's available. |
4541 | - if (!in_array($integration_call, $functions)) |
|
4542 | - return; |
|
4800 | + if (!in_array($integration_call, $functions)) { |
|
4801 | + return; |
|
4802 | + } |
|
4543 | 4803 | |
4544 | 4804 | $functions = array_diff($functions, array($integration_call)); |
4545 | 4805 | $modSettings[$hook] = implode(',', $functions); |
@@ -4560,17 +4820,20 @@ discard block |
||
4560 | 4820 | global $context, $smcFunc, $txt, $db_show_debug; |
4561 | 4821 | |
4562 | 4822 | // Really? |
4563 | - if (empty($string)) |
|
4564 | - return false; |
|
4823 | + if (empty($string)) { |
|
4824 | + return false; |
|
4825 | + } |
|
4565 | 4826 | |
4566 | 4827 | // An array? should be a "callable" array IE array(object/class, valid_callable). |
4567 | 4828 | // A closure? should be a callable one. |
4568 | - if (is_array($string) || $string instanceof Closure) |
|
4569 | - return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
4829 | + if (is_array($string) || $string instanceof Closure) { |
|
4830 | + return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
4831 | + } |
|
4570 | 4832 | |
4571 | 4833 | // No full objects, sorry! pass a method or a property instead! |
4572 | - if (is_object($string)) |
|
4573 | - return false; |
|
4834 | + if (is_object($string)) { |
|
4835 | + return false; |
|
4836 | + } |
|
4574 | 4837 | |
4575 | 4838 | // Stay vitaminized my friends... |
4576 | 4839 | $string = $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($string)); |
@@ -4579,8 +4842,9 @@ discard block |
||
4579 | 4842 | $string = load_file($string); |
4580 | 4843 | |
4581 | 4844 | // Loaded file failed |
4582 | - if (empty($string)) |
|
4583 | - return false; |
|
4845 | + if (empty($string)) { |
|
4846 | + return false; |
|
4847 | + } |
|
4584 | 4848 | |
4585 | 4849 | // Found a method. |
4586 | 4850 | if (strpos($string, '::') !== false) |
@@ -4601,8 +4865,9 @@ discard block |
||
4601 | 4865 | // Add another one to the list. |
4602 | 4866 | if ($db_show_debug === true) |
4603 | 4867 | { |
4604 | - if (!isset($context['debug']['instances'])) |
|
4605 | - $context['debug']['instances'] = array(); |
|
4868 | + if (!isset($context['debug']['instances'])) { |
|
4869 | + $context['debug']['instances'] = array(); |
|
4870 | + } |
|
4606 | 4871 | |
4607 | 4872 | $context['debug']['instances'][$class] = $class; |
4608 | 4873 | } |
@@ -4612,13 +4877,15 @@ discard block |
||
4612 | 4877 | } |
4613 | 4878 | |
4614 | 4879 | // Right then. This is a call to a static method. |
4615 | - else |
|
4616 | - $func = array($class, $method); |
|
4880 | + else { |
|
4881 | + $func = array($class, $method); |
|
4882 | + } |
|
4617 | 4883 | } |
4618 | 4884 | |
4619 | 4885 | // Nope! just a plain regular function. |
4620 | - else |
|
4621 | - $func = $string; |
|
4886 | + else { |
|
4887 | + $func = $string; |
|
4888 | + } |
|
4622 | 4889 | |
4623 | 4890 | // Right, we got what we need, time to do some checks. |
4624 | 4891 | if (!is_callable($func, false, $callable_name)) |
@@ -4634,17 +4901,18 @@ discard block |
||
4634 | 4901 | else |
4635 | 4902 | { |
4636 | 4903 | // What are we gonna do about it? |
4637 | - if ($return) |
|
4638 | - return $func; |
|
4904 | + if ($return) { |
|
4905 | + return $func; |
|
4906 | + } |
|
4639 | 4907 | |
4640 | 4908 | // If this is a plain function, avoid the heat of calling call_user_func(). |
4641 | 4909 | else |
4642 | 4910 | { |
4643 | - if (is_array($func)) |
|
4644 | - call_user_func($func); |
|
4645 | - |
|
4646 | - else |
|
4647 | - $func(); |
|
4911 | + if (is_array($func)) { |
|
4912 | + call_user_func($func); |
|
4913 | + } else { |
|
4914 | + $func(); |
|
4915 | + } |
|
4648 | 4916 | } |
4649 | 4917 | } |
4650 | 4918 | } |
@@ -4661,31 +4929,34 @@ discard block |
||
4661 | 4929 | { |
4662 | 4930 | global $sourcedir, $txt, $boarddir, $settings; |
4663 | 4931 | |
4664 | - if (empty($string)) |
|
4665 | - return false; |
|
4932 | + if (empty($string)) { |
|
4933 | + return false; |
|
4934 | + } |
|
4666 | 4935 | |
4667 | 4936 | if (strpos($string, '|') !== false) |
4668 | 4937 | { |
4669 | 4938 | list ($file, $string) = explode('|', $string); |
4670 | 4939 | |
4671 | 4940 | // Match the wildcards to their regular vars. |
4672 | - if (empty($settings['theme_dir'])) |
|
4673 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
4674 | - |
|
4675 | - else |
|
4676 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
4941 | + if (empty($settings['theme_dir'])) { |
|
4942 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
4943 | + } else { |
|
4944 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
4945 | + } |
|
4677 | 4946 | |
4678 | 4947 | // Load the file if it can be loaded. |
4679 | - if (file_exists($absPath)) |
|
4680 | - require_once($absPath); |
|
4948 | + if (file_exists($absPath)) { |
|
4949 | + require_once($absPath); |
|
4950 | + } |
|
4681 | 4951 | |
4682 | 4952 | // No? try a fallback to $sourcedir |
4683 | 4953 | else |
4684 | 4954 | { |
4685 | 4955 | $absPath = $sourcedir .'/'. $file; |
4686 | 4956 | |
4687 | - if (file_exists($absPath)) |
|
4688 | - require_once($absPath); |
|
4957 | + if (file_exists($absPath)) { |
|
4958 | + require_once($absPath); |
|
4959 | + } |
|
4689 | 4960 | |
4690 | 4961 | // Sorry, can't do much for you at this point. |
4691 | 4962 | else |
@@ -4712,8 +4983,9 @@ discard block |
||
4712 | 4983 | global $user_info, $smcFunc; |
4713 | 4984 | |
4714 | 4985 | // Make sure we have something to work with. |
4715 | - if (empty($topic)) |
|
4716 | - return array(); |
|
4986 | + if (empty($topic)) { |
|
4987 | + return array(); |
|
4988 | + } |
|
4717 | 4989 | |
4718 | 4990 | |
4719 | 4991 | // We already know the number of likes per message, we just want to know whether the current user liked it or not. |
@@ -4736,8 +5008,9 @@ discard block |
||
4736 | 5008 | 'topic' => $topic, |
4737 | 5009 | ) |
4738 | 5010 | ); |
4739 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
4740 | - $temp[] = (int) $row['content_id']; |
|
5011 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
5012 | + $temp[] = (int) $row['content_id']; |
|
5013 | + } |
|
4741 | 5014 | |
4742 | 5015 | cache_put_data($cache_key, $temp, $ttl); |
4743 | 5016 | } |
@@ -4758,8 +5031,9 @@ discard block |
||
4758 | 5031 | { |
4759 | 5032 | global $context; |
4760 | 5033 | |
4761 | - if (empty($string)) |
|
4762 | - return $string; |
|
5034 | + if (empty($string)) { |
|
5035 | + return $string; |
|
5036 | + } |
|
4763 | 5037 | |
4764 | 5038 | // UTF-8 occurences of MS special characters |
4765 | 5039 | $findchars_utf8 = array( |
@@ -4800,10 +5074,11 @@ discard block |
||
4800 | 5074 | '--', // — |
4801 | 5075 | ); |
4802 | 5076 | |
4803 | - if ($context['utf8']) |
|
4804 | - $string = str_replace($findchars_utf8, $replacechars, $string); |
|
4805 | - else |
|
4806 | - $string = str_replace($findchars_iso, $replacechars, $string); |
|
5077 | + if ($context['utf8']) { |
|
5078 | + $string = str_replace($findchars_utf8, $replacechars, $string); |
|
5079 | + } else { |
|
5080 | + $string = str_replace($findchars_iso, $replacechars, $string); |
|
5081 | + } |
|
4807 | 5082 | |
4808 | 5083 | return $string; |
4809 | 5084 | } |
@@ -4822,49 +5097,59 @@ discard block |
||
4822 | 5097 | { |
4823 | 5098 | global $context; |
4824 | 5099 | |
4825 | - if (!isset($matches[2])) |
|
4826 | - return ''; |
|
5100 | + if (!isset($matches[2])) { |
|
5101 | + return ''; |
|
5102 | + } |
|
4827 | 5103 | |
4828 | 5104 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
4829 | 5105 | |
4830 | 5106 | // remove left to right / right to left overrides |
4831 | - if ($num === 0x202D || $num === 0x202E) |
|
4832 | - return ''; |
|
5107 | + if ($num === 0x202D || $num === 0x202E) { |
|
5108 | + return ''; |
|
5109 | + } |
|
4833 | 5110 | |
4834 | 5111 | // Quote, Ampersand, Apostrophe, Less/Greater Than get html replaced |
4835 | - if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) |
|
4836 | - return '&#' . $num . ';'; |
|
5112 | + if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) { |
|
5113 | + return '&#' . $num . ';'; |
|
5114 | + } |
|
4837 | 5115 | |
4838 | 5116 | if (empty($context['utf8'])) |
4839 | 5117 | { |
4840 | 5118 | // no control characters |
4841 | - if ($num < 0x20) |
|
4842 | - return ''; |
|
5119 | + if ($num < 0x20) { |
|
5120 | + return ''; |
|
5121 | + } |
|
4843 | 5122 | // text is text |
4844 | - elseif ($num < 0x80) |
|
4845 | - return chr($num); |
|
5123 | + elseif ($num < 0x80) { |
|
5124 | + return chr($num); |
|
5125 | + } |
|
4846 | 5126 | // all others get html-ised |
4847 | - else |
|
4848 | - return '&#' . $matches[2] . ';'; |
|
4849 | - } |
|
4850 | - else |
|
5127 | + else { |
|
5128 | + return '&#' . $matches[2] . ';'; |
|
5129 | + } |
|
5130 | + } else |
|
4851 | 5131 | { |
4852 | 5132 | // <0x20 are control characters, 0x20 is a space, > 0x10FFFF is past the end of the utf8 character set |
4853 | 5133 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text) |
4854 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) |
|
4855 | - return ''; |
|
5134 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) { |
|
5135 | + return ''; |
|
5136 | + } |
|
4856 | 5137 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
4857 | - elseif ($num < 0x80) |
|
4858 | - return chr($num); |
|
5138 | + elseif ($num < 0x80) { |
|
5139 | + return chr($num); |
|
5140 | + } |
|
4859 | 5141 | // <0x800 (2048) |
4860 | - elseif ($num < 0x800) |
|
4861 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5142 | + elseif ($num < 0x800) { |
|
5143 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5144 | + } |
|
4862 | 5145 | // < 0x10000 (65536) |
4863 | - elseif ($num < 0x10000) |
|
4864 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5146 | + elseif ($num < 0x10000) { |
|
5147 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5148 | + } |
|
4865 | 5149 | // <= 0x10FFFF (1114111) |
4866 | - else |
|
4867 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5150 | + else { |
|
5151 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5152 | + } |
|
4868 | 5153 | } |
4869 | 5154 | } |
4870 | 5155 | |
@@ -4880,28 +5165,34 @@ discard block |
||
4880 | 5165 | */ |
4881 | 5166 | function fixchar__callback($matches) |
4882 | 5167 | { |
4883 | - if (!isset($matches[1])) |
|
4884 | - return ''; |
|
5168 | + if (!isset($matches[1])) { |
|
5169 | + return ''; |
|
5170 | + } |
|
4885 | 5171 | |
4886 | 5172 | $num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1]; |
4887 | 5173 | |
4888 | 5174 | // <0x20 are control characters, > 0x10FFFF is past the end of the utf8 character set |
4889 | 5175 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text), 0x202D-E are left to right overrides |
4890 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) |
|
4891 | - return ''; |
|
5176 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) { |
|
5177 | + return ''; |
|
5178 | + } |
|
4892 | 5179 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
4893 | - elseif ($num < 0x80) |
|
4894 | - return chr($num); |
|
5180 | + elseif ($num < 0x80) { |
|
5181 | + return chr($num); |
|
5182 | + } |
|
4895 | 5183 | // <0x800 (2048) |
4896 | - elseif ($num < 0x800) |
|
4897 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5184 | + elseif ($num < 0x800) { |
|
5185 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5186 | + } |
|
4898 | 5187 | // < 0x10000 (65536) |
4899 | - elseif ($num < 0x10000) |
|
4900 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5188 | + elseif ($num < 0x10000) { |
|
5189 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5190 | + } |
|
4901 | 5191 | // <= 0x10FFFF (1114111) |
4902 | - else |
|
4903 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
4904 | -} |
|
5192 | + else { |
|
5193 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5194 | + } |
|
5195 | + } |
|
4905 | 5196 | |
4906 | 5197 | /** |
4907 | 5198 | * Strips out invalid html entities, replaces others with html style { codes |
@@ -4914,17 +5205,19 @@ discard block |
||
4914 | 5205 | */ |
4915 | 5206 | function entity_fix__callback($matches) |
4916 | 5207 | { |
4917 | - if (!isset($matches[2])) |
|
4918 | - return ''; |
|
5208 | + if (!isset($matches[2])) { |
|
5209 | + return ''; |
|
5210 | + } |
|
4919 | 5211 | |
4920 | 5212 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
4921 | 5213 | |
4922 | 5214 | // we don't allow control characters, characters out of range, byte markers, etc |
4923 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) |
|
4924 | - return ''; |
|
4925 | - else |
|
4926 | - return '&#' . $num . ';'; |
|
4927 | -} |
|
5215 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) { |
|
5216 | + return ''; |
|
5217 | + } else { |
|
5218 | + return '&#' . $num . ';'; |
|
5219 | + } |
|
5220 | + } |
|
4928 | 5221 | |
4929 | 5222 | /** |
4930 | 5223 | * Return a Gravatar URL based on |
@@ -4948,18 +5241,23 @@ discard block |
||
4948 | 5241 | $ratings = array('G', 'PG', 'R', 'X'); |
4949 | 5242 | $defaults = array('mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank'); |
4950 | 5243 | $url_params = array(); |
4951 | - if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) |
|
4952 | - $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
4953 | - if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) |
|
4954 | - $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
4955 | - if (!empty($modSettings['avatar_max_width_external'])) |
|
4956 | - $size_string = (int) $modSettings['avatar_max_width_external']; |
|
4957 | - if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) |
|
4958 | - if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
5244 | + if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) { |
|
5245 | + $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
5246 | + } |
|
5247 | + if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) { |
|
5248 | + $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
5249 | + } |
|
5250 | + if (!empty($modSettings['avatar_max_width_external'])) { |
|
5251 | + $size_string = (int) $modSettings['avatar_max_width_external']; |
|
5252 | + } |
|
5253 | + if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) { |
|
5254 | + if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
4959 | 5255 | $size_string = $modSettings['avatar_max_height_external']; |
5256 | + } |
|
4960 | 5257 | |
4961 | - if (!empty($size_string)) |
|
4962 | - $url_params[] = 's=' . $size_string; |
|
5258 | + if (!empty($size_string)) { |
|
5259 | + $url_params[] = 's=' . $size_string; |
|
5260 | + } |
|
4963 | 5261 | } |
4964 | 5262 | $http_method = !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 ? 'https://secure' : 'http://www'; |
4965 | 5263 | |
@@ -4978,22 +5276,26 @@ discard block |
||
4978 | 5276 | static $timezones = null, $lastwhen = null; |
4979 | 5277 | |
4980 | 5278 | // No point doing this over if we already did it once |
4981 | - if (!empty($timezones) && $when == $lastwhen) |
|
4982 | - return $timezones; |
|
4983 | - else |
|
4984 | - $lastwhen = $when; |
|
5279 | + if (!empty($timezones) && $when == $lastwhen) { |
|
5280 | + return $timezones; |
|
5281 | + } else { |
|
5282 | + $lastwhen = $when; |
|
5283 | + } |
|
4985 | 5284 | |
4986 | 5285 | // Parseable datetime string? |
4987 | - if (is_int($timestamp = strtotime($when))) |
|
4988 | - $when = $timestamp; |
|
5286 | + if (is_int($timestamp = strtotime($when))) { |
|
5287 | + $when = $timestamp; |
|
5288 | + } |
|
4989 | 5289 | |
4990 | 5290 | // A Unix timestamp? |
4991 | - elseif (is_numeric($when)) |
|
4992 | - $when = intval($when); |
|
5291 | + elseif (is_numeric($when)) { |
|
5292 | + $when = intval($when); |
|
5293 | + } |
|
4993 | 5294 | |
4994 | 5295 | // Invalid value? Just get current Unix timestamp. |
4995 | - else |
|
4996 | - $when = time(); |
|
5296 | + else { |
|
5297 | + $when = time(); |
|
5298 | + } |
|
4997 | 5299 | |
4998 | 5300 | // We'll need these too |
4999 | 5301 | $date_when = date_create('@' . $when); |
@@ -5057,8 +5359,9 @@ discard block |
||
5057 | 5359 | foreach ($priority_countries as $country) |
5058 | 5360 | { |
5059 | 5361 | $country_tzids = @timezone_identifiers_list(DateTimeZone::PER_COUNTRY, strtoupper(trim($country))); |
5060 | - if (!empty($country_tzids)) |
|
5061 | - $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
5362 | + if (!empty($country_tzids)) { |
|
5363 | + $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
5364 | + } |
|
5062 | 5365 | } |
5063 | 5366 | |
5064 | 5367 | // Process the preferred timezones first, then the rest. |
@@ -5068,8 +5371,9 @@ discard block |
||
5068 | 5371 | foreach ($tzids as $tzid) |
5069 | 5372 | { |
5070 | 5373 | // We don't want UTC right now |
5071 | - if ($tzid == 'UTC') |
|
5072 | - continue; |
|
5374 | + if ($tzid == 'UTC') { |
|
5375 | + continue; |
|
5376 | + } |
|
5073 | 5377 | |
5074 | 5378 | $tz = timezone_open($tzid); |
5075 | 5379 | |
@@ -5084,12 +5388,14 @@ discard block |
||
5084 | 5388 | $tzgeo = timezone_location_get($tz); |
5085 | 5389 | |
5086 | 5390 | // Don't overwrite our preferred tzids |
5087 | - if (empty($zones[$tzkey]['tzid'])) |
|
5088 | - $zones[$tzkey]['tzid'] = $tzid; |
|
5391 | + if (empty($zones[$tzkey]['tzid'])) { |
|
5392 | + $zones[$tzkey]['tzid'] = $tzid; |
|
5393 | + } |
|
5089 | 5394 | |
5090 | 5395 | // A time zone from a prioritized country? |
5091 | - if (in_array($tzid, $priority_tzids)) |
|
5092 | - $priority_zones[$tzkey] = true; |
|
5396 | + if (in_array($tzid, $priority_tzids)) { |
|
5397 | + $priority_zones[$tzkey] = true; |
|
5398 | + } |
|
5093 | 5399 | |
5094 | 5400 | // Keep track of the location and offset for this tzid |
5095 | 5401 | $tzid_parts = explode('/', $tzid); |
@@ -5111,15 +5417,17 @@ discard block |
||
5111 | 5417 | |
5112 | 5418 | date_timezone_set($date_when, timezone_open($tzvalue['tzid'])); |
5113 | 5419 | |
5114 | - if (!empty($timezone_descriptions[$tzvalue['tzid']])) |
|
5115 | - $desc = $timezone_descriptions[$tzvalue['tzid']]; |
|
5116 | - else |
|
5117 | - $desc = implode(', ', array_unique($tzvalue['locations'])); |
|
5420 | + if (!empty($timezone_descriptions[$tzvalue['tzid']])) { |
|
5421 | + $desc = $timezone_descriptions[$tzvalue['tzid']]; |
|
5422 | + } else { |
|
5423 | + $desc = implode(', ', array_unique($tzvalue['locations'])); |
|
5424 | + } |
|
5118 | 5425 | |
5119 | - if (isset($priority_zones[$tzkey])) |
|
5120 | - $priority_timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5121 | - else |
|
5122 | - $timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5426 | + if (isset($priority_zones[$tzkey])) { |
|
5427 | + $priority_timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5428 | + } else { |
|
5429 | + $timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5430 | + } |
|
5123 | 5431 | } |
5124 | 5432 | |
5125 | 5433 | $timezones = array_merge( |
@@ -5173,9 +5481,9 @@ discard block |
||
5173 | 5481 | 'Indian/Kerguelen' => 'TFT', |
5174 | 5482 | ); |
5175 | 5483 | |
5176 | - if (!empty($missing_tz_abbrs[$tzid])) |
|
5177 | - $tz_abbrev = $missing_tz_abbrs[$tzid]; |
|
5178 | - else |
|
5484 | + if (!empty($missing_tz_abbrs[$tzid])) { |
|
5485 | + $tz_abbrev = $missing_tz_abbrs[$tzid]; |
|
5486 | + } else |
|
5179 | 5487 | { |
5180 | 5488 | // Russia likes to experiment with time zones often, and names them as offsets from Moscow |
5181 | 5489 | $tz_location = timezone_location_get(timezone_open($tzid)); |
@@ -5203,8 +5511,9 @@ discard block |
||
5203 | 5511 | */ |
5204 | 5512 | function inet_ptod($ip_address) |
5205 | 5513 | { |
5206 | - if (!isValidIP($ip_address)) |
|
5207 | - return $ip_address; |
|
5514 | + if (!isValidIP($ip_address)) { |
|
5515 | + return $ip_address; |
|
5516 | + } |
|
5208 | 5517 | |
5209 | 5518 | $bin = inet_pton($ip_address); |
5210 | 5519 | return $bin; |
@@ -5216,13 +5525,15 @@ discard block |
||
5216 | 5525 | */ |
5217 | 5526 | function inet_dtop($bin) |
5218 | 5527 | { |
5219 | - if(empty($bin)) |
|
5220 | - return ''; |
|
5528 | + if(empty($bin)) { |
|
5529 | + return ''; |
|
5530 | + } |
|
5221 | 5531 | |
5222 | 5532 | global $db_type; |
5223 | 5533 | |
5224 | - if ($db_type == 'postgresql') |
|
5225 | - return $bin; |
|
5534 | + if ($db_type == 'postgresql') { |
|
5535 | + return $bin; |
|
5536 | + } |
|
5226 | 5537 | |
5227 | 5538 | $ip_address = inet_ntop($bin); |
5228 | 5539 | |
@@ -5247,26 +5558,32 @@ discard block |
||
5247 | 5558 | */ |
5248 | 5559 | function _safe_serialize($value) |
5249 | 5560 | { |
5250 | - if(is_null($value)) |
|
5251 | - return 'N;'; |
|
5561 | + if(is_null($value)) { |
|
5562 | + return 'N;'; |
|
5563 | + } |
|
5252 | 5564 | |
5253 | - if(is_bool($value)) |
|
5254 | - return 'b:'. (int) $value .';'; |
|
5565 | + if(is_bool($value)) { |
|
5566 | + return 'b:'. (int) $value .';'; |
|
5567 | + } |
|
5255 | 5568 | |
5256 | - if(is_int($value)) |
|
5257 | - return 'i:'. $value .';'; |
|
5569 | + if(is_int($value)) { |
|
5570 | + return 'i:'. $value .';'; |
|
5571 | + } |
|
5258 | 5572 | |
5259 | - if(is_float($value)) |
|
5260 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
5573 | + if(is_float($value)) { |
|
5574 | + return 'd:'. str_replace(',', '.', $value) .';'; |
|
5575 | + } |
|
5261 | 5576 | |
5262 | - if(is_string($value)) |
|
5263 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
5577 | + if(is_string($value)) { |
|
5578 | + return 's:'. strlen($value) .':"'. $value .'";'; |
|
5579 | + } |
|
5264 | 5580 | |
5265 | 5581 | if(is_array($value)) |
5266 | 5582 | { |
5267 | 5583 | $out = ''; |
5268 | - foreach($value as $k => $v) |
|
5269 | - $out .= _safe_serialize($k) . _safe_serialize($v); |
|
5584 | + foreach($value as $k => $v) { |
|
5585 | + $out .= _safe_serialize($k) . _safe_serialize($v); |
|
5586 | + } |
|
5270 | 5587 | |
5271 | 5588 | return 'a:'. count($value) .':{'. $out .'}'; |
5272 | 5589 | } |
@@ -5292,8 +5609,9 @@ discard block |
||
5292 | 5609 | |
5293 | 5610 | $out = _safe_serialize($value); |
5294 | 5611 | |
5295 | - if (isset($mbIntEnc)) |
|
5296 | - mb_internal_encoding($mbIntEnc); |
|
5612 | + if (isset($mbIntEnc)) { |
|
5613 | + mb_internal_encoding($mbIntEnc); |
|
5614 | + } |
|
5297 | 5615 | |
5298 | 5616 | return $out; |
5299 | 5617 | } |
@@ -5310,8 +5628,9 @@ discard block |
||
5310 | 5628 | function _safe_unserialize($str) |
5311 | 5629 | { |
5312 | 5630 | // Input is not a string. |
5313 | - if(empty($str) || !is_string($str)) |
|
5314 | - return false; |
|
5631 | + if(empty($str) || !is_string($str)) { |
|
5632 | + return false; |
|
5633 | + } |
|
5315 | 5634 | |
5316 | 5635 | $stack = array(); |
5317 | 5636 | $expected = array(); |
@@ -5327,43 +5646,38 @@ discard block |
||
5327 | 5646 | while($state != 1) |
5328 | 5647 | { |
5329 | 5648 | $type = isset($str[0]) ? $str[0] : ''; |
5330 | - if($type == '}') |
|
5331 | - $str = substr($str, 1); |
|
5332 | - |
|
5333 | - else if($type == 'N' && $str[1] == ';') |
|
5649 | + if($type == '}') { |
|
5650 | + $str = substr($str, 1); |
|
5651 | + } else if($type == 'N' && $str[1] == ';') |
|
5334 | 5652 | { |
5335 | 5653 | $value = null; |
5336 | 5654 | $str = substr($str, 2); |
5337 | - } |
|
5338 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5655 | + } else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5339 | 5656 | { |
5340 | 5657 | $value = $matches[1] == '1' ? true : false; |
5341 | 5658 | $str = substr($str, 4); |
5342 | - } |
|
5343 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5659 | + } else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5344 | 5660 | { |
5345 | 5661 | $value = (int)$matches[1]; |
5346 | 5662 | $str = $matches[2]; |
5347 | - } |
|
5348 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5663 | + } else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5349 | 5664 | { |
5350 | 5665 | $value = (float)$matches[1]; |
5351 | 5666 | $str = $matches[3]; |
5352 | - } |
|
5353 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
5667 | + } else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
5354 | 5668 | { |
5355 | 5669 | $value = substr($matches[2], 0, (int)$matches[1]); |
5356 | 5670 | $str = substr($matches[2], (int)$matches[1] + 2); |
5357 | - } |
|
5358 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5671 | + } else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5359 | 5672 | { |
5360 | 5673 | $expectedLength = (int)$matches[1]; |
5361 | 5674 | $str = $matches[2]; |
5362 | 5675 | } |
5363 | 5676 | |
5364 | 5677 | // Object or unknown/malformed type. |
5365 | - else |
|
5366 | - return false; |
|
5678 | + else { |
|
5679 | + return false; |
|
5680 | + } |
|
5367 | 5681 | |
5368 | 5682 | switch($state) |
5369 | 5683 | { |
@@ -5391,8 +5705,9 @@ discard block |
||
5391 | 5705 | if($type == '}') |
5392 | 5706 | { |
5393 | 5707 | // Array size is less than expected. |
5394 | - if(count($list) < end($expected)) |
|
5395 | - return false; |
|
5708 | + if(count($list) < end($expected)) { |
|
5709 | + return false; |
|
5710 | + } |
|
5396 | 5711 | |
5397 | 5712 | unset($list); |
5398 | 5713 | $list = &$stack[count($stack)-1]; |
@@ -5401,8 +5716,9 @@ discard block |
||
5401 | 5716 | // Go to terminal state if we're at the end of the root array. |
5402 | 5717 | array_pop($expected); |
5403 | 5718 | |
5404 | - if(count($expected) == 0) |
|
5405 | - $state = 1; |
|
5719 | + if(count($expected) == 0) { |
|
5720 | + $state = 1; |
|
5721 | + } |
|
5406 | 5722 | |
5407 | 5723 | break; |
5408 | 5724 | } |
@@ -5410,8 +5726,9 @@ discard block |
||
5410 | 5726 | if($type == 'i' || $type == 's') |
5411 | 5727 | { |
5412 | 5728 | // Array size exceeds expected length. |
5413 | - if(count($list) >= end($expected)) |
|
5414 | - return false; |
|
5729 | + if(count($list) >= end($expected)) { |
|
5730 | + return false; |
|
5731 | + } |
|
5415 | 5732 | |
5416 | 5733 | $key = $value; |
5417 | 5734 | $state = 3; |
@@ -5445,8 +5762,9 @@ discard block |
||
5445 | 5762 | } |
5446 | 5763 | |
5447 | 5764 | // Trailing data in input. |
5448 | - if(!empty($str)) |
|
5449 | - return false; |
|
5765 | + if(!empty($str)) { |
|
5766 | + return false; |
|
5767 | + } |
|
5450 | 5768 | |
5451 | 5769 | return $data; |
5452 | 5770 | } |
@@ -5469,8 +5787,9 @@ discard block |
||
5469 | 5787 | |
5470 | 5788 | $out = _safe_unserialize($str); |
5471 | 5789 | |
5472 | - if (isset($mbIntEnc)) |
|
5473 | - mb_internal_encoding($mbIntEnc); |
|
5790 | + if (isset($mbIntEnc)) { |
|
5791 | + mb_internal_encoding($mbIntEnc); |
|
5792 | + } |
|
5474 | 5793 | |
5475 | 5794 | return $out; |
5476 | 5795 | } |
@@ -5485,12 +5804,14 @@ discard block |
||
5485 | 5804 | function smf_chmod($file, $value = 0) |
5486 | 5805 | { |
5487 | 5806 | // No file? no checks! |
5488 | - if (empty($file)) |
|
5489 | - return false; |
|
5807 | + if (empty($file)) { |
|
5808 | + return false; |
|
5809 | + } |
|
5490 | 5810 | |
5491 | 5811 | // Already writable? |
5492 | - if (is_writable($file)) |
|
5493 | - return true; |
|
5812 | + if (is_writable($file)) { |
|
5813 | + return true; |
|
5814 | + } |
|
5494 | 5815 | |
5495 | 5816 | // Do we have a file or a dir? |
5496 | 5817 | $isDir = is_dir($file); |
@@ -5506,10 +5827,9 @@ discard block |
||
5506 | 5827 | { |
5507 | 5828 | $isWritable = true; |
5508 | 5829 | break; |
5830 | + } else { |
|
5831 | + @chmod($file, $val); |
|
5509 | 5832 | } |
5510 | - |
|
5511 | - else |
|
5512 | - @chmod($file, $val); |
|
5513 | 5833 | } |
5514 | 5834 | |
5515 | 5835 | return $isWritable; |
@@ -5528,8 +5848,9 @@ discard block |
||
5528 | 5848 | global $txt; |
5529 | 5849 | |
5530 | 5850 | // Come on... |
5531 | - if (empty($json) || !is_string($json)) |
|
5532 | - return array(); |
|
5851 | + if (empty($json) || !is_string($json)) { |
|
5852 | + return array(); |
|
5853 | + } |
|
5533 | 5854 | |
5534 | 5855 | $returnArray = @json_decode($json, $returnAsArray); |
5535 | 5856 | |
@@ -5567,11 +5888,11 @@ discard block |
||
5567 | 5888 | $jsonDebug = $jsonDebug[0]; |
5568 | 5889 | loadLanguage('Errors'); |
5569 | 5890 | |
5570 | - if (!empty($jsonDebug)) |
|
5571 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
5572 | - |
|
5573 | - else |
|
5574 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
5891 | + if (!empty($jsonDebug)) { |
|
5892 | + log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
5893 | + } else { |
|
5894 | + log_error($txt['json_'. $jsonError], 'critical'); |
|
5895 | + } |
|
5575 | 5896 | |
5576 | 5897 | // Everyone expects an array. |
5577 | 5898 | return array(); |
@@ -5605,8 +5926,9 @@ discard block |
||
5605 | 5926 | global $db_show_debug, $modSettings; |
5606 | 5927 | |
5607 | 5928 | // Defensive programming anyone? |
5608 | - if (empty($data)) |
|
5609 | - return false; |
|
5929 | + if (empty($data)) { |
|
5930 | + return false; |
|
5931 | + } |
|
5610 | 5932 | |
5611 | 5933 | // Don't need extra stuff... |
5612 | 5934 | $db_show_debug = false; |
@@ -5614,11 +5936,11 @@ discard block |
||
5614 | 5936 | // Kill anything else. |
5615 | 5937 | ob_end_clean(); |
5616 | 5938 | |
5617 | - if (!empty($modSettings['CompressedOutput'])) |
|
5618 | - @ob_start('ob_gzhandler'); |
|
5619 | - |
|
5620 | - else |
|
5621 | - ob_start(); |
|
5939 | + if (!empty($modSettings['CompressedOutput'])) { |
|
5940 | + @ob_start('ob_gzhandler'); |
|
5941 | + } else { |
|
5942 | + ob_start(); |
|
5943 | + } |
|
5622 | 5944 | |
5623 | 5945 | // Set the header. |
5624 | 5946 | header($type); |
@@ -5650,8 +5972,9 @@ discard block |
||
5650 | 5972 | static $done = false; |
5651 | 5973 | |
5652 | 5974 | // If we don't need to do anything, don't |
5653 | - if (!$update && $done) |
|
5654 | - return; |
|
5975 | + if (!$update && $done) { |
|
5976 | + return; |
|
5977 | + } |
|
5655 | 5978 | |
5656 | 5979 | // Should we get a new copy of the official list of TLDs? |
5657 | 5980 | if ($update) |
@@ -5660,8 +5983,9 @@ discard block |
||
5660 | 5983 | $tlds = fetch_web_data('https://data.iana.org/TLD/tlds-alpha-by-domain.txt'); |
5661 | 5984 | |
5662 | 5985 | // If the Internet Assigned Numbers Authority can't be reached, the Internet is gone. We're probably running on a server hidden in a bunker deep underground to protect it from marauding bandits roaming on the surface. We don't want to waste precious electricity on pointlessly repeating background tasks, so we'll wait until the next regularly scheduled update to see if civilization has been restored. |
5663 | - if ($tlds === false) |
|
5664 | - $postapocalypticNightmare = true; |
|
5986 | + if ($tlds === false) { |
|
5987 | + $postapocalypticNightmare = true; |
|
5988 | + } |
|
5665 | 5989 | } |
5666 | 5990 | // If we aren't updating and the regex is valid, we're done |
5667 | 5991 | elseif (!empty($modSettings['tld_regex']) && @preg_match('~' . $modSettings['tld_regex'] . '~', null) !== false) |
@@ -5676,10 +6000,11 @@ discard block |
||
5676 | 6000 | // Clean $tlds and convert it to an array |
5677 | 6001 | $tlds = array_filter(explode("\n", strtolower($tlds)), function($line) { |
5678 | 6002 | $line = trim($line); |
5679 | - if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) |
|
5680 | - return false; |
|
5681 | - else |
|
5682 | - return true; |
|
6003 | + if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) { |
|
6004 | + return false; |
|
6005 | + } else { |
|
6006 | + return true; |
|
6007 | + } |
|
5683 | 6008 | }); |
5684 | 6009 | |
5685 | 6010 | // Convert Punycode to Unicode |
@@ -5733,8 +6058,9 @@ discard block |
||
5733 | 6058 | $idx += $digit * $w; |
5734 | 6059 | $t = ($k <= $bias) ? $tmin : (($k >= $bias + $tmax) ? $tmax : ($k - $bias)); |
5735 | 6060 | |
5736 | - if ($digit < $t) |
|
5737 | - break; |
|
6061 | + if ($digit < $t) { |
|
6062 | + break; |
|
6063 | + } |
|
5738 | 6064 | |
5739 | 6065 | $w = (int) ($w * ($base - $t)); |
5740 | 6066 | } |
@@ -5743,8 +6069,9 @@ discard block |
||
5743 | 6069 | $delta = intval($is_first ? ($delta / $damp) : ($delta / 2)); |
5744 | 6070 | $delta += intval($delta / ($deco_len + 1)); |
5745 | 6071 | |
5746 | - for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) |
|
5747 | - $delta = intval($delta / ($base - $tmin)); |
|
6072 | + for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) { |
|
6073 | + $delta = intval($delta / ($base - $tmin)); |
|
6074 | + } |
|
5748 | 6075 | |
5749 | 6076 | $bias = intval($k + ($base - $tmin + 1) * $delta / ($delta + $skew)); |
5750 | 6077 | $is_first = false; |
@@ -5753,8 +6080,9 @@ discard block |
||
5753 | 6080 | |
5754 | 6081 | if ($deco_len > 0) |
5755 | 6082 | { |
5756 | - for ($i = $deco_len; $i > $idx; $i--) |
|
5757 | - $decoded[$i] = $decoded[($i - 1)]; |
|
6083 | + for ($i = $deco_len; $i > $idx; $i--) { |
|
6084 | + $decoded[$i] = $decoded[($i - 1)]; |
|
6085 | + } |
|
5758 | 6086 | } |
5759 | 6087 | $decoded[$idx++] = $char; |
5760 | 6088 | } |
@@ -5762,24 +6090,29 @@ discard block |
||
5762 | 6090 | foreach ($decoded as $k => $v) |
5763 | 6091 | { |
5764 | 6092 | // 7bit are transferred literally |
5765 | - if ($v < 128) |
|
5766 | - $output .= chr($v); |
|
6093 | + if ($v < 128) { |
|
6094 | + $output .= chr($v); |
|
6095 | + } |
|
5767 | 6096 | |
5768 | 6097 | // 2 bytes |
5769 | - elseif ($v < (1 << 11)) |
|
5770 | - $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
6098 | + elseif ($v < (1 << 11)) { |
|
6099 | + $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
6100 | + } |
|
5771 | 6101 | |
5772 | 6102 | // 3 bytes |
5773 | - elseif ($v < (1 << 16)) |
|
5774 | - $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
6103 | + elseif ($v < (1 << 16)) { |
|
6104 | + $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
6105 | + } |
|
5775 | 6106 | |
5776 | 6107 | // 4 bytes |
5777 | - elseif ($v < (1 << 21)) |
|
5778 | - $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
6108 | + elseif ($v < (1 << 21)) { |
|
6109 | + $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
6110 | + } |
|
5779 | 6111 | |
5780 | 6112 | // 'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k |
5781 | - else |
|
5782 | - $output .= $safe_char; |
|
6113 | + else { |
|
6114 | + $output .= $safe_char; |
|
6115 | + } |
|
5783 | 6116 | } |
5784 | 6117 | |
5785 | 6118 | $output_parts[] = $output; |
@@ -5872,8 +6205,7 @@ discard block |
||
5872 | 6205 | |
5873 | 6206 | $strlen = 'mb_strlen'; |
5874 | 6207 | $substr = 'mb_substr'; |
5875 | - } |
|
5876 | - else |
|
6208 | + } else |
|
5877 | 6209 | { |
5878 | 6210 | $strlen = $smcFunc['strlen']; |
5879 | 6211 | $substr = $smcFunc['substr']; |
@@ -5887,20 +6219,21 @@ discard block |
||
5887 | 6219 | |
5888 | 6220 | $first = $substr($string, 0, 1); |
5889 | 6221 | |
5890 | - if (empty($index[$first])) |
|
5891 | - $index[$first] = array(); |
|
6222 | + if (empty($index[$first])) { |
|
6223 | + $index[$first] = array(); |
|
6224 | + } |
|
5892 | 6225 | |
5893 | 6226 | if ($strlen($string) > 1) |
5894 | 6227 | { |
5895 | 6228 | // Sanity check on recursion |
5896 | - if ($depth > 99) |
|
5897 | - $index[$first][$substr($string, 1)] = ''; |
|
5898 | - |
|
5899 | - else |
|
5900 | - $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
6229 | + if ($depth > 99) { |
|
6230 | + $index[$first][$substr($string, 1)] = ''; |
|
6231 | + } else { |
|
6232 | + $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
6233 | + } |
|
6234 | + } else { |
|
6235 | + $index[$first][''] = ''; |
|
5901 | 6236 | } |
5902 | - else |
|
5903 | - $index[$first][''] = ''; |
|
5904 | 6237 | |
5905 | 6238 | $depth--; |
5906 | 6239 | return $index; |
@@ -5923,9 +6256,9 @@ discard block |
||
5923 | 6256 | $key_regex = preg_quote($key, $delim); |
5924 | 6257 | $new_key = $key; |
5925 | 6258 | |
5926 | - if (empty($value)) |
|
5927 | - $sub_regex = ''; |
|
5928 | - else |
|
6259 | + if (empty($value)) { |
|
6260 | + $sub_regex = ''; |
|
6261 | + } else |
|
5929 | 6262 | { |
5930 | 6263 | $sub_regex = $index_to_regex($value, $delim); |
5931 | 6264 | |
@@ -5933,22 +6266,22 @@ discard block |
||
5933 | 6266 | { |
5934 | 6267 | $new_key_array = explode('(?'.'>', $sub_regex); |
5935 | 6268 | $new_key .= $new_key_array[0]; |
6269 | + } else { |
|
6270 | + $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
5936 | 6271 | } |
5937 | - else |
|
5938 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
5939 | 6272 | } |
5940 | 6273 | |
5941 | - if ($depth > 1) |
|
5942 | - $regex[$new_key] = $key_regex . $sub_regex; |
|
5943 | - else |
|
6274 | + if ($depth > 1) { |
|
6275 | + $regex[$new_key] = $key_regex . $sub_regex; |
|
6276 | + } else |
|
5944 | 6277 | { |
5945 | 6278 | if (($length += strlen($key_regex) + 1) < $max_length || empty($regex)) |
5946 | 6279 | { |
5947 | 6280 | $regex[$new_key] = $key_regex . $sub_regex; |
5948 | 6281 | unset($index[$key]); |
6282 | + } else { |
|
6283 | + break; |
|
5949 | 6284 | } |
5950 | - else |
|
5951 | - break; |
|
5952 | 6285 | } |
5953 | 6286 | } |
5954 | 6287 | |
@@ -5957,10 +6290,11 @@ discard block |
||
5957 | 6290 | $l1 = $strlen($k1); |
5958 | 6291 | $l2 = $strlen($k2); |
5959 | 6292 | |
5960 | - if ($l1 == $l2) |
|
5961 | - return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
5962 | - else |
|
5963 | - return $l1 > $l2 ? -1 : 1; |
|
6293 | + if ($l1 == $l2) { |
|
6294 | + return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
6295 | + } else { |
|
6296 | + return $l1 > $l2 ? -1 : 1; |
|
6297 | + } |
|
5964 | 6298 | }); |
5965 | 6299 | |
5966 | 6300 | $depth--; |
@@ -5971,21 +6305,24 @@ discard block |
||
5971 | 6305 | $index = array(); |
5972 | 6306 | $regex = ''; |
5973 | 6307 | |
5974 | - foreach ($strings as $string) |
|
5975 | - $index = $add_string_to_index($string, $index); |
|
6308 | + foreach ($strings as $string) { |
|
6309 | + $index = $add_string_to_index($string, $index); |
|
6310 | + } |
|
5976 | 6311 | |
5977 | 6312 | if ($returnArray === true) |
5978 | 6313 | { |
5979 | 6314 | $regex = array(); |
5980 | - while (!empty($index)) |
|
5981 | - $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6315 | + while (!empty($index)) { |
|
6316 | + $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6317 | + } |
|
6318 | + } else { |
|
6319 | + $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
5982 | 6320 | } |
5983 | - else |
|
5984 | - $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
5985 | 6321 | |
5986 | 6322 | // Restore PHP's internal character encoding to whatever it was originally |
5987 | - if (!empty($current_encoding)) |
|
5988 | - mb_internal_encoding($current_encoding); |
|
6323 | + if (!empty($current_encoding)) { |
|
6324 | + mb_internal_encoding($current_encoding); |
|
6325 | + } |
|
5989 | 6326 | |
5990 | 6327 | return $regex; |
5991 | 6328 | } |
@@ -61,7 +61,7 @@ |
||
61 | 61 | $server = trim($servers[array_rand($servers)]); |
62 | 62 | |
63 | 63 | // Normal host names do not contain slashes, while e.g. unix sockets do. Assume alternative transport pipe with port 0. |
64 | - if (strpos($server,'/') !== false) |
|
64 | + if (strpos($server, '/') !== false) |
|
65 | 65 | $host = $server; |
66 | 66 | else |
67 | 67 | { |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Our Cache API class |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | |
35 | 36 | $supported = class_exists('memcache'); |
36 | 37 | |
37 | - if ($test) |
|
38 | - return $supported; |
|
38 | + if ($test) { |
|
39 | + return $supported; |
|
40 | + } |
|
39 | 41 | return parent::isSupported() && $supported && !empty($cache_memcached); |
40 | 42 | } |
41 | 43 | |
@@ -61,9 +63,9 @@ discard block |
||
61 | 63 | $server = trim($servers[array_rand($servers)]); |
62 | 64 | |
63 | 65 | // Normal host names do not contain slashes, while e.g. unix sockets do. Assume alternative transport pipe with port 0. |
64 | - if (strpos($server,'/') !== false) |
|
65 | - $host = $server; |
|
66 | - else |
|
66 | + if (strpos($server,'/') !== false) { |
|
67 | + $host = $server; |
|
68 | + } else |
|
67 | 69 | { |
68 | 70 | $server = explode(':', $server); |
69 | 71 | $host = $server[0]; |
@@ -71,10 +73,11 @@ discard block |
||
71 | 73 | } |
72 | 74 | |
73 | 75 | // Don't wait too long: yes, we want the server, but we might be able to run the query faster! |
74 | - if (empty($db_persist)) |
|
75 | - $connected = $this->memcache->connect($host, $port); |
|
76 | - else |
|
77 | - $connected = $this->memcache->pconnect($host, $port); |
|
76 | + if (empty($db_persist)) { |
|
77 | + $connected = $this->memcache->connect($host, $port); |
|
78 | + } else { |
|
79 | + $connected = $this->memcache->pconnect($host, $port); |
|
80 | + } |
|
78 | 81 | } |
79 | 82 | |
80 | 83 | return $connected; |
@@ -90,8 +93,9 @@ discard block |
||
90 | 93 | $value = $this->memcache->get($key); |
91 | 94 | |
92 | 95 | // $value should return either data or false (from failure, key not found or empty array). |
93 | - if ($value === false) |
|
94 | - return null; |
|
96 | + if ($value === false) { |
|
97 | + return null; |
|
98 | + } |
|
95 | 99 | return $value; |
96 | 100 | } |
97 | 101 | |
@@ -132,8 +136,9 @@ discard block |
||
132 | 136 | $config_vars[] = $txt['cache_memcache_settings']; |
133 | 137 | $config_vars[] = array('cache_memcached', $txt['cache_memcache_servers'], 'file', 'text', 0, 'cache_memcached', 'postinput' => '<br><div class="smalltext"><em>' . $txt['cache_memcache_servers_subtext'] . '</em></div>'); |
134 | 138 | |
135 | - if (!isset($context['settings_post_javascript'])) |
|
136 | - $context['settings_post_javascript'] = ''; |
|
139 | + if (!isset($context['settings_post_javascript'])) { |
|
140 | + $context['settings_post_javascript'] = ''; |
|
141 | + } |
|
137 | 142 | |
138 | 143 | $context['settings_post_javascript'] .= ' |
139 | 144 | $("#cache_accelerator").change(function (e) { |
@@ -19,10 +19,10 @@ |
||
19 | 19 | */ |
20 | 20 | class GroupAct_Notify_Background extends SMF_BackgroundTask |
21 | 21 | { |
22 | - /** |
|
23 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
24 | - * @return bool Always returns true |
|
25 | - */ |
|
22 | + /** |
|
23 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
24 | + * @return bool Always returns true |
|
25 | + */ |
|
26 | 26 | public function execute() |
27 | 27 | { |
28 | 28 | global $sourcedir, $smcFunc, $language, $modSettings; |
@@ -132,8 +132,9 @@ discard block |
||
132 | 132 | 'GROUPNAME' => $user['group_name'], |
133 | 133 | ); |
134 | 134 | |
135 | - if (!empty($custom_reason)) |
|
136 | - $replacements['REASON'] = $custom_reason; |
|
135 | + if (!empty($custom_reason)) { |
|
136 | + $replacements['REASON'] = $custom_reason; |
|
137 | + } |
|
137 | 138 | |
138 | 139 | $emaildata = loadEmailTemplate($email_template_name, $replacements, $user['language']); |
139 | 140 | |
@@ -142,8 +143,8 @@ discard block |
||
142 | 143 | } |
143 | 144 | |
144 | 145 | // Insert the alerts if any |
145 | - if (!empty($alert_rows)) |
|
146 | - $smcFunc['db_insert']('', |
|
146 | + if (!empty($alert_rows)) { |
|
147 | + $smcFunc['db_insert']('', |
|
147 | 148 | '{db_prefix}user_alerts', |
148 | 149 | array( |
149 | 150 | 'alert_time' => 'int', 'id_member' => 'int', 'content_type' => 'string', |
@@ -152,6 +153,7 @@ discard block |
||
152 | 153 | $alert_rows, |
153 | 154 | array() |
154 | 155 | ); |
156 | + } |
|
155 | 157 | } |
156 | 158 | |
157 | 159 | return true; |
@@ -20,7 +20,7 @@ |
||
20 | 20 | class MsgReportReply_Notify_Background extends SMF_BackgroundTask |
21 | 21 | { |
22 | 22 | /** |
23 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
23 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
24 | 24 | * @return bool Always returns true. |
25 | 25 | */ |
26 | 26 | public function execute() |
@@ -40,8 +40,9 @@ discard block |
||
40 | 40 | 'last_comment' => $this->_details['comment_id'], |
41 | 41 | ) |
42 | 42 | ); |
43 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
44 | - $possible_members[] = $row[0]; |
|
43 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
44 | + $possible_members[] = $row[0]; |
|
45 | + } |
|
45 | 46 | $smcFunc['db_free_result']($request); |
46 | 47 | |
47 | 48 | // Presumably, there are some people? |
@@ -50,8 +51,9 @@ discard block |
||
50 | 51 | $possible_members = array_flip(array_flip($possible_members)); |
51 | 52 | $possible_members = array_diff($possible_members, array($this->_details['sender_id'])); |
52 | 53 | } |
53 | - if (empty($possible_members)) |
|
54 | - return true; |
|
54 | + if (empty($possible_members)) { |
|
55 | + return true; |
|
56 | + } |
|
55 | 57 | |
56 | 58 | // We need to know who can moderate this board - and therefore who can see this report. |
57 | 59 | // First up, people who have moderate_board in the board this topic was in. |
@@ -67,8 +69,9 @@ discard block |
||
67 | 69 | 'current_board' => $this->_details['board_id'], |
68 | 70 | ) |
69 | 71 | ); |
70 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
71 | - $members[] = $row['id_member']; |
|
72 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
73 | + $members[] = $row['id_member']; |
|
74 | + } |
|
72 | 75 | $smcFunc['db_free_result']($request); |
73 | 76 | |
74 | 77 | // Thirdly, anyone assigned to be a moderator of this group as a group->board moderator. |
@@ -85,8 +88,9 @@ discard block |
||
85 | 88 | ) |
86 | 89 | ); |
87 | 90 | |
88 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
89 | - $members[] = $row['id_member']; |
|
91 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
92 | + $members[] = $row['id_member']; |
|
93 | + } |
|
90 | 94 | $smcFunc['db_free_result']($request); |
91 | 95 | |
92 | 96 | // So now we have two lists: the people who replied to a report in the past, |
@@ -108,8 +112,9 @@ discard block |
||
108 | 112 | { |
109 | 113 | foreach ($alert_bits as $type => $bitvalue) |
110 | 114 | { |
111 | - if ($pref_option['msg_report_reply'] & $bitvalue) |
|
112 | - $notifies[$type][] = $member; |
|
115 | + if ($pref_option['msg_report_reply'] & $bitvalue) { |
|
116 | + $notifies[$type][] = $member; |
|
117 | + } |
|
113 | 118 | } |
114 | 119 | } |
115 | 120 | |
@@ -170,8 +175,9 @@ discard block |
||
170 | 175 | ); |
171 | 176 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
172 | 177 | { |
173 | - if (empty($row['lngfile'])) |
|
174 | - $row['lngfile'] = $language; |
|
178 | + if (empty($row['lngfile'])) { |
|
179 | + $row['lngfile'] = $language; |
|
180 | + } |
|
175 | 181 | $emails[$row['lngfile']][$row['id_member']] = $row['email_address']; |
176 | 182 | } |
177 | 183 | $smcFunc['db_free_result']($request); |
@@ -203,8 +209,9 @@ discard block |
||
203 | 209 | $emaildata = loadEmailTemplate('reply_to_moderator', $replacements, empty($modSettings['userLanguage']) ? $language : $this_lang); |
204 | 210 | |
205 | 211 | // And do the actual sending... |
206 | - foreach ($recipients as $id_member => $email_address) |
|
207 | - sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'rptrpy' . $this->_details['comment_id'], $emaildata['is_html'], 3); |
|
212 | + foreach ($recipients as $id_member => $email_address) { |
|
213 | + sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'rptrpy' . $this->_details['comment_id'], $emaildata['is_html'], 3); |
|
214 | + } |
|
208 | 215 | } |
209 | 216 | } |
210 | 217 |
@@ -19,7 +19,7 @@ |
||
19 | 19 | class Buddy_Notify_Background extends SMF_BackgroundTask |
20 | 20 | { |
21 | 21 | /** |
22 | - * This executes the task - loads up the info, sets the alerts and loads up the email queue. |
|
22 | + * This executes the task - loads up the info, sets the alerts and loads up the email queue. |
|
23 | 23 | * @return bool Always returns true |
24 | 24 | */ |
25 | 25 | public function execute() |
@@ -51,8 +51,9 @@ discard block |
||
51 | 51 | $birthdays = array(); |
52 | 52 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
53 | 53 | { |
54 | - if (!isset($birthdays[$row['lngfile']])) |
|
55 | - $birthdays[$row['lngfile']] = array(); |
|
54 | + if (!isset($birthdays[$row['lngfile']])) { |
|
55 | + $birthdays[$row['lngfile']] = array(); |
|
56 | + } |
|
56 | 57 | $birthdays[$row['lngfile']][$row['id_member']] = array( |
57 | 58 | 'name' => $row['real_name'], |
58 | 59 | 'email' => $row['email_address'] |
@@ -117,8 +118,8 @@ discard block |
||
117 | 118 | AddMailQueue(true); |
118 | 119 | |
119 | 120 | // Insert the alerts if any |
120 | - if (!empty($alert_rows)) |
|
121 | - $smcFunc['db_insert']('', |
|
121 | + if (!empty($alert_rows)) { |
|
122 | + $smcFunc['db_insert']('', |
|
122 | 123 | '{db_prefix}user_alerts', |
123 | 124 | array( |
124 | 125 | 'alert_time' => 'int', 'id_member' => 'int', 'content_type' => 'string', |
@@ -127,6 +128,7 @@ discard block |
||
127 | 128 | $alert_rows, |
128 | 129 | array() |
129 | 130 | ); |
131 | + } |
|
130 | 132 | } |
131 | 133 | |
132 | 134 | return true; |
@@ -18,10 +18,10 @@ |
||
18 | 18 | */ |
19 | 19 | class Birthday_Notify_Background extends SMF_BackgroundTask |
20 | 20 | { |
21 | - /** |
|
22 | - * This executes the task. It loads up the birthdays, figures out the greeting, etc. |
|
23 | - * @return bool Always returns true |
|
24 | - */ |
|
21 | + /** |
|
22 | + * This executes the task. It loads up the birthdays, figures out the greeting, etc. |
|
23 | + * @return bool Always returns true |
|
24 | + */ |
|
25 | 25 | public function execute() |
26 | 26 | { |
27 | 27 | global $txt, $smcFunc, $txtBirthdayEmails, $modSettings, $sourcedir; |
@@ -19,7 +19,7 @@ |
||
19 | 19 | class MemberReport_Notify_Background extends SMF_BackgroundTask |
20 | 20 | { |
21 | 21 | /** |
22 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
22 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
23 | 23 | * @return bool Always returns true. |
24 | 24 | */ |
25 | 25 | public function execute() |
@@ -46,9 +46,10 @@ discard block |
||
46 | 46 | |
47 | 47 | foreach ($prefs as $member => $pref_option) |
48 | 48 | { |
49 | - foreach ($alert_bits as $type => $bitvalue) |
|
50 | - if ($pref_option['member_report'] & $bitvalue) |
|
49 | + foreach ($alert_bits as $type => $bitvalue) { |
|
50 | + if ($pref_option['member_report'] & $bitvalue) |
|
51 | 51 | $notifies[$type][] = $member; |
52 | + } |
|
52 | 53 | } |
53 | 54 | |
54 | 55 | // Firstly, anyone who wants alerts. |
@@ -109,8 +110,9 @@ discard block |
||
109 | 110 | ); |
110 | 111 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
111 | 112 | { |
112 | - if (empty($row['lngfile'])) |
|
113 | - $row['lngfile'] = $language; |
|
113 | + if (empty($row['lngfile'])) { |
|
114 | + $row['lngfile'] = $language; |
|
115 | + } |
|
114 | 116 | $emails[$row['lngfile']][$row['id_member']] = $row['email_address']; |
115 | 117 | } |
116 | 118 | $smcFunc['db_free_result']($request); |
@@ -129,8 +131,9 @@ discard block |
||
129 | 131 | $emaildata = loadEmailTemplate('report_member_profile', $replacements, empty($modSettings['userLanguage']) ? $language : $this_lang); |
130 | 132 | |
131 | 133 | // And do the actual sending... |
132 | - foreach ($recipients as $id_member => $email_address) |
|
133 | - sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'ureport' . $this->_details['report_id'], $emaildata['is_html'], 2); |
|
134 | + foreach ($recipients as $id_member => $email_address) { |
|
135 | + sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'ureport' . $this->_details['report_id'], $emaildata['is_html'], 2); |
|
136 | + } |
|
134 | 137 | } |
135 | 138 | } |
136 | 139 |