@@ -4070,7 +4070,7 @@ |
||
| 4070 | 4070 | * |
| 4071 | 4071 | * @param int $pmID The ID of the PM |
| 4072 | 4072 | * @param string $validFor Which folders this is valud for - can be 'inbox', 'outbox' or 'in_or_outbox' |
| 4073 | - * @return boolean Whether the PM is accessible in that folder for the current user |
|
| 4073 | + * @return boolean|null Whether the PM is accessible in that folder for the current user |
|
| 4074 | 4074 | */ |
| 4075 | 4075 | function isAccessiblePM($pmID, $validFor = 'in_or_outbox') |
| 4076 | 4076 | { |
@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * @version 2.1 Beta 4 |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -if (!defined('SMF')) |
|
| 18 | +if (!defined('SMF')) { |
|
| 19 | 19 | die('No direct access...'); |
| 20 | +} |
|
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * This helps organize things... |
@@ -37,13 +38,14 @@ discard block |
||
| 37 | 38 | |
| 38 | 39 | loadLanguage('PersonalMessage+Drafts'); |
| 39 | 40 | |
| 40 | - if (!isset($_REQUEST['xml'])) |
|
| 41 | - loadTemplate('PersonalMessage'); |
|
| 41 | + if (!isset($_REQUEST['xml'])) { |
|
| 42 | + loadTemplate('PersonalMessage'); |
|
| 43 | + } |
|
| 42 | 44 | |
| 43 | 45 | // Load up the members maximum message capacity. |
| 44 | - if ($user_info['is_admin']) |
|
| 45 | - $context['message_limit'] = 0; |
|
| 46 | - elseif (($context['message_limit'] = cache_get_data('msgLimit:' . $user_info['id'], 360)) === null) |
|
| 46 | + if ($user_info['is_admin']) { |
|
| 47 | + $context['message_limit'] = 0; |
|
| 48 | + } elseif (($context['message_limit'] = cache_get_data('msgLimit:' . $user_info['id'], 360)) === null) |
|
| 47 | 49 | { |
| 48 | 50 | // @todo Why do we do this? It seems like if they have any limit we should use it. |
| 49 | 51 | $request = $smcFunc['db_query']('', ' |
@@ -78,8 +80,9 @@ discard block |
||
| 78 | 80 | } |
| 79 | 81 | |
| 80 | 82 | // a previous message was sent successfully? show a small indication. |
| 81 | - if (isset($_GET['done']) && ($_GET['done'] == 'sent')) |
|
| 82 | - $context['pm_sent'] = true; |
|
| 83 | + if (isset($_GET['done']) && ($_GET['done'] == 'sent')) { |
|
| 84 | + $context['pm_sent'] = true; |
|
| 85 | + } |
|
| 83 | 86 | |
| 84 | 87 | $context['labels'] = array(); |
| 85 | 88 | |
@@ -210,11 +213,11 @@ discard block |
||
| 210 | 213 | { |
| 211 | 214 | $_REQUEST['sa'] = ''; |
| 212 | 215 | MessageFolder(); |
| 213 | - } |
|
| 214 | - else |
|
| 216 | + } else |
|
| 215 | 217 | { |
| 216 | - if (!isset($_REQUEST['xml']) && $_REQUEST['sa'] != 'popup') |
|
| 217 | - messageIndexBar($_REQUEST['sa']); |
|
| 218 | + if (!isset($_REQUEST['xml']) && $_REQUEST['sa'] != 'popup') { |
|
| 219 | + messageIndexBar($_REQUEST['sa']); |
|
| 220 | + } |
|
| 218 | 221 | |
| 219 | 222 | call_helper($subActions[$_REQUEST['sa']]); |
| 220 | 223 | } |
@@ -291,16 +294,17 @@ discard block |
||
| 291 | 294 | ); |
| 292 | 295 | |
| 293 | 296 | // Handle labels. |
| 294 | - if (empty($context['currently_using_labels'])) |
|
| 295 | - unset($pm_areas['labels']); |
|
| 296 | - else |
|
| 297 | + if (empty($context['currently_using_labels'])) { |
|
| 298 | + unset($pm_areas['labels']); |
|
| 299 | + } else |
|
| 297 | 300 | { |
| 298 | 301 | // Note we send labels by id as it will have less problems in the querystring. |
| 299 | 302 | $unread_in_labels = 0; |
| 300 | 303 | foreach ($context['labels'] as $label) |
| 301 | 304 | { |
| 302 | - if ($label['id'] == -1) |
|
| 303 | - continue; |
|
| 305 | + if ($label['id'] == -1) { |
|
| 306 | + continue; |
|
| 307 | + } |
|
| 304 | 308 | |
| 305 | 309 | // Count the amount of unread items in labels. |
| 306 | 310 | $unread_in_labels += $label['unread_messages']; |
@@ -314,8 +318,9 @@ discard block |
||
| 314 | 318 | ); |
| 315 | 319 | } |
| 316 | 320 | |
| 317 | - if (!empty($unread_in_labels)) |
|
| 318 | - $pm_areas['labels']['title'] .= ' <span class="amt">' . $unread_in_labels . '</span>'; |
|
| 321 | + if (!empty($unread_in_labels)) { |
|
| 322 | + $pm_areas['labels']['title'] .= ' <span class="amt">' . $unread_in_labels . '</span>'; |
|
| 323 | + } |
|
| 319 | 324 | } |
| 320 | 325 | |
| 321 | 326 | $pm_areas['folders']['areas']['inbox']['unread_messages'] = &$context['labels'][-1]['unread_messages']; |
@@ -353,8 +358,9 @@ discard block |
||
| 353 | 358 | unset($pm_areas); |
| 354 | 359 | |
| 355 | 360 | // No menu means no access. |
| 356 | - if (!$pm_include_data && (!$user_info['is_guest'] || validateSession())) |
|
| 357 | - fatal_lang_error('no_access', false); |
|
| 361 | + if (!$pm_include_data && (!$user_info['is_guest'] || validateSession())) { |
|
| 362 | + fatal_lang_error('no_access', false); |
|
| 363 | + } |
|
| 358 | 364 | |
| 359 | 365 | // Make a note of the Unique ID for this menu. |
| 360 | 366 | $context['pm_menu_id'] = $context['max_menu_id']; |
@@ -365,9 +371,10 @@ discard block |
||
| 365 | 371 | $context['menu_item_selected'] = $current_area; |
| 366 | 372 | |
| 367 | 373 | // Set the template for this area and add the profile layer. |
| 368 | - if (!isset($_REQUEST['xml'])) |
|
| 369 | - $context['template_layers'][] = 'pm'; |
|
| 370 | -} |
|
| 374 | + if (!isset($_REQUEST['xml'])) { |
|
| 375 | + $context['template_layers'][] = 'pm'; |
|
| 376 | + } |
|
| 377 | + } |
|
| 371 | 378 | |
| 372 | 379 | /** |
| 373 | 380 | * The popup for when we ask for the popup from the user. |
@@ -399,8 +406,9 @@ discard block |
||
| 399 | 406 | ) |
| 400 | 407 | ); |
| 401 | 408 | $pms = array(); |
| 402 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 403 | - $pms[] = $row[0]; |
|
| 409 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 410 | + $pms[] = $row[0]; |
|
| 411 | + } |
|
| 404 | 412 | $smcFunc['db_free_result']($request); |
| 405 | 413 | |
| 406 | 414 | if (!empty($pms)) |
@@ -428,8 +436,9 @@ discard block |
||
| 428 | 436 | ); |
| 429 | 437 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 430 | 438 | { |
| 431 | - if (!empty($row['id_member_from'])) |
|
| 432 | - $senders[] = $row['id_member_from']; |
|
| 439 | + if (!empty($row['id_member_from'])) { |
|
| 440 | + $senders[] = $row['id_member_from']; |
|
| 441 | + } |
|
| 433 | 442 | |
| 434 | 443 | $row['replied_to_you'] = $row['id_pm'] != $row['id_pm_head']; |
| 435 | 444 | $row['time'] = timeformat($row['timestamp']); |
@@ -439,13 +448,15 @@ discard block |
||
| 439 | 448 | $smcFunc['db_free_result']($request); |
| 440 | 449 | |
| 441 | 450 | $senders = loadMemberData($senders); |
| 442 | - foreach ($senders as $member) |
|
| 443 | - loadMemberContext($member); |
|
| 451 | + foreach ($senders as $member) { |
|
| 452 | + loadMemberContext($member); |
|
| 453 | + } |
|
| 444 | 454 | |
| 445 | 455 | // Having loaded everyone, attach them to the PMs. |
| 446 | - foreach ($context['unread_pms'] as $id_pm => $details) |
|
| 447 | - if (!empty($memberContext[$details['id_member_from']])) |
|
| 456 | + foreach ($context['unread_pms'] as $id_pm => $details) { |
|
| 457 | + if (!empty($memberContext[$details['id_member_from']])) |
|
| 448 | 458 | $context['unread_pms'][$id_pm]['member'] = &$memberContext[$details['id_member_from']]; |
| 459 | + } |
|
| 449 | 460 | } |
| 450 | 461 | } |
| 451 | 462 | |
@@ -465,12 +476,13 @@ discard block |
||
| 465 | 476 | } |
| 466 | 477 | |
| 467 | 478 | // Make sure the starting location is valid. |
| 468 | - if (isset($_GET['start']) && $_GET['start'] != 'new') |
|
| 469 | - $_GET['start'] = (int) $_GET['start']; |
|
| 470 | - elseif (!isset($_GET['start']) && !empty($options['view_newest_pm_first'])) |
|
| 471 | - $_GET['start'] = 0; |
|
| 472 | - else |
|
| 473 | - $_GET['start'] = 'new'; |
|
| 479 | + if (isset($_GET['start']) && $_GET['start'] != 'new') { |
|
| 480 | + $_GET['start'] = (int) $_GET['start']; |
|
| 481 | + } elseif (!isset($_GET['start']) && !empty($options['view_newest_pm_first'])) { |
|
| 482 | + $_GET['start'] = 0; |
|
| 483 | + } else { |
|
| 484 | + $_GET['start'] = 'new'; |
|
| 485 | + } |
|
| 474 | 486 | |
| 475 | 487 | // Set up some basic theme stuff. |
| 476 | 488 | $context['from_or_to'] = $context['folder'] != 'sent' ? 'from' : 'to'; |
@@ -487,8 +499,7 @@ discard block |
||
| 487 | 499 | { |
| 488 | 500 | $labelQuery = ' |
| 489 | 501 | AND pmr.in_inbox = 1'; |
| 490 | - } |
|
| 491 | - elseif ($context['folder'] != 'sent') |
|
| 502 | + } elseif ($context['folder'] != 'sent') |
|
| 492 | 503 | { |
| 493 | 504 | $labelJoin = ' |
| 494 | 505 | INNER JOIN {db_prefix}pm_labeled_messages AS pl ON (pl.id_pm = pmr.id_pm)'; |
@@ -530,22 +541,24 @@ discard block |
||
| 530 | 541 | $txt['delete_all'] = str_replace('PMBOX', $pmbox, $txt['delete_all']); |
| 531 | 542 | |
| 532 | 543 | // Now, build the link tree! |
| 533 | - if ($context['current_label_id'] == -1) |
|
| 534 | - $context['linktree'][] = array( |
|
| 544 | + if ($context['current_label_id'] == -1) { |
|
| 545 | + $context['linktree'][] = array( |
|
| 535 | 546 | 'url' => $scripturl . '?action=pm;f=' . $context['folder'], |
| 536 | 547 | 'name' => $pmbox |
| 537 | 548 | ); |
| 549 | + } |
|
| 538 | 550 | |
| 539 | 551 | // Build it further for a label. |
| 540 | - if ($context['current_label_id'] != -1) |
|
| 541 | - $context['linktree'][] = array( |
|
| 552 | + if ($context['current_label_id'] != -1) { |
|
| 553 | + $context['linktree'][] = array( |
|
| 542 | 554 | 'url' => $scripturl . '?action=pm;f=' . $context['folder'] . ';l=' . $context['current_label_id'], |
| 543 | 555 | 'name' => $txt['pm_current_label'] . ': ' . $context['current_label'] |
| 544 | 556 | ); |
| 557 | + } |
|
| 545 | 558 | |
| 546 | 559 | // Figure out how many messages there are. |
| 547 | - if ($context['folder'] == 'sent') |
|
| 548 | - $request = $smcFunc['db_query']('', ' |
|
| 560 | + if ($context['folder'] == 'sent') { |
|
| 561 | + $request = $smcFunc['db_query']('', ' |
|
| 549 | 562 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
| 550 | 563 | FROM {db_prefix}personal_messages AS pm |
| 551 | 564 | WHERE pm.id_member_from = {int:current_member} |
@@ -555,8 +568,8 @@ discard block |
||
| 555 | 568 | 'not_deleted' => 0, |
| 556 | 569 | ) |
| 557 | 570 | ); |
| 558 | - else |
|
| 559 | - $request = $smcFunc['db_query']('', ' |
|
| 571 | + } else { |
|
| 572 | + $request = $smcFunc['db_query']('', ' |
|
| 560 | 573 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
| 561 | 574 | FROM {db_prefix}pm_recipients AS pmr' . ($context['display_mode'] == 2 ? ' |
| 562 | 575 | INNER JOIN {db_prefix}personal_messages AS pm ON (pm.id_pm = pmr.id_pm)' : '') . $labelJoin . ' |
@@ -567,6 +580,7 @@ discard block |
||
| 567 | 580 | 'not_deleted' => 0, |
| 568 | 581 | ) |
| 569 | 582 | ); |
| 583 | + } |
|
| 570 | 584 | list ($max_messages) = $smcFunc['db_fetch_row']($request); |
| 571 | 585 | $smcFunc['db_free_result']($request); |
| 572 | 586 | |
@@ -575,10 +589,11 @@ discard block |
||
| 575 | 589 | $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
| 576 | 590 | |
| 577 | 591 | // Start on the last page. |
| 578 | - if (!is_numeric($_GET['start']) || $_GET['start'] >= $max_messages) |
|
| 579 | - $_GET['start'] = ($max_messages - 1) - (($max_messages - 1) % $maxPerPage); |
|
| 580 | - elseif ($_GET['start'] < 0) |
|
| 581 | - $_GET['start'] = 0; |
|
| 592 | + if (!is_numeric($_GET['start']) || $_GET['start'] >= $max_messages) { |
|
| 593 | + $_GET['start'] = ($max_messages - 1) - (($max_messages - 1) % $maxPerPage); |
|
| 594 | + } elseif ($_GET['start'] < 0) { |
|
| 595 | + $_GET['start'] = 0; |
|
| 596 | + } |
|
| 582 | 597 | |
| 583 | 598 | // ... but wait - what if we want to start from a specific message? |
| 584 | 599 | if (isset($_GET['pmid'])) |
@@ -586,19 +601,21 @@ discard block |
||
| 586 | 601 | $pmID = (int) $_GET['pmid']; |
| 587 | 602 | |
| 588 | 603 | // Make sure you have access to this PM. |
| 589 | - if (!isAccessiblePM($pmID, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) |
|
| 590 | - fatal_lang_error('no_access', false); |
|
| 604 | + if (!isAccessiblePM($pmID, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) { |
|
| 605 | + fatal_lang_error('no_access', false); |
|
| 606 | + } |
|
| 591 | 607 | |
| 592 | 608 | $context['current_pm'] = $pmID; |
| 593 | 609 | |
| 594 | 610 | // With only one page of PM's we're gonna want page 1. |
| 595 | - if ($max_messages <= $maxPerPage) |
|
| 596 | - $_GET['start'] = 0; |
|
| 611 | + if ($max_messages <= $maxPerPage) { |
|
| 612 | + $_GET['start'] = 0; |
|
| 613 | + } |
|
| 597 | 614 | // If we pass kstart we assume we're in the right place. |
| 598 | 615 | elseif (!isset($_GET['kstart'])) |
| 599 | 616 | { |
| 600 | - if ($context['folder'] == 'sent') |
|
| 601 | - $request = $smcFunc['db_query']('', ' |
|
| 617 | + if ($context['folder'] == 'sent') { |
|
| 618 | + $request = $smcFunc['db_query']('', ' |
|
| 602 | 619 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
| 603 | 620 | FROM {db_prefix}personal_messages |
| 604 | 621 | WHERE id_member_from = {int:current_member} |
@@ -610,8 +627,8 @@ discard block |
||
| 610 | 627 | 'id_pm' => $pmID, |
| 611 | 628 | ) |
| 612 | 629 | ); |
| 613 | - else |
|
| 614 | - $request = $smcFunc['db_query']('', ' |
|
| 630 | + } else { |
|
| 631 | + $request = $smcFunc['db_query']('', ' |
|
| 615 | 632 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
| 616 | 633 | FROM {db_prefix}pm_recipients AS pmr' . ($context['display_mode'] == 2 ? ' |
| 617 | 634 | INNER JOIN {db_prefix}personal_messages AS pm ON (pm.id_pm = pmr.id_pm)' : '') . $labelJoin . ' |
@@ -624,6 +641,7 @@ discard block |
||
| 624 | 641 | 'id_pm' => $pmID, |
| 625 | 642 | ) |
| 626 | 643 | ); |
| 644 | + } |
|
| 627 | 645 | |
| 628 | 646 | list ($_GET['start']) = $smcFunc['db_fetch_row']($request); |
| 629 | 647 | $smcFunc['db_free_result']($request); |
@@ -638,8 +656,9 @@ discard block |
||
| 638 | 656 | { |
| 639 | 657 | $pmsg = (int) $_GET['pmsg']; |
| 640 | 658 | |
| 641 | - if (!isAccessiblePM($pmsg, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) |
|
| 642 | - fatal_lang_error('no_access', false); |
|
| 659 | + if (!isAccessiblePM($pmsg, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) { |
|
| 660 | + fatal_lang_error('no_access', false); |
|
| 661 | + } |
|
| 643 | 662 | } |
| 644 | 663 | |
| 645 | 664 | // Set up the page index. |
@@ -734,8 +753,9 @@ discard block |
||
| 734 | 753 | { |
| 735 | 754 | if (!isset($recipients[$row['id_pm']])) |
| 736 | 755 | { |
| 737 | - if (isset($row['id_member_from'])) |
|
| 738 | - $posters[$row['id_pm']] = $row['id_member_from']; |
|
| 756 | + if (isset($row['id_member_from'])) { |
|
| 757 | + $posters[$row['id_pm']] = $row['id_member_from']; |
|
| 758 | + } |
|
| 739 | 759 | $pms[$row['id_pm']] = $row['id_pm']; |
| 740 | 760 | $recipients[$row['id_pm']] = array( |
| 741 | 761 | 'to' => array(), |
@@ -744,29 +764,33 @@ discard block |
||
| 744 | 764 | } |
| 745 | 765 | |
| 746 | 766 | // Keep track of the last message so we know what the head is without another query! |
| 747 | - if ((empty($pmID) && (empty($options['view_newest_pm_first']) || !isset($lastData))) || empty($lastData) || (!empty($pmID) && $pmID == $row['id_pm'])) |
|
| 748 | - $lastData = array( |
|
| 767 | + if ((empty($pmID) && (empty($options['view_newest_pm_first']) || !isset($lastData))) || empty($lastData) || (!empty($pmID) && $pmID == $row['id_pm'])) { |
|
| 768 | + $lastData = array( |
|
| 749 | 769 | 'id' => $row['id_pm'], |
| 750 | 770 | 'head' => $row['id_pm_head'], |
| 751 | 771 | ); |
| 772 | + } |
|
| 752 | 773 | } |
| 753 | 774 | $smcFunc['db_free_result']($request); |
| 754 | 775 | |
| 755 | 776 | // Make sure that we have been given a correct head pm id! |
| 756 | - if ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id']) |
|
| 757 | - fatal_lang_error('no_access', false); |
|
| 777 | + if ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id']) { |
|
| 778 | + fatal_lang_error('no_access', false); |
|
| 779 | + } |
|
| 758 | 780 | |
| 759 | 781 | if (!empty($pms)) |
| 760 | 782 | { |
| 761 | 783 | // Select the correct current message. |
| 762 | - if (empty($pmID)) |
|
| 763 | - $context['current_pm'] = $lastData['id']; |
|
| 784 | + if (empty($pmID)) { |
|
| 785 | + $context['current_pm'] = $lastData['id']; |
|
| 786 | + } |
|
| 764 | 787 | |
| 765 | 788 | // This is a list of the pm's that are used for "full" display. |
| 766 | - if ($context['display_mode'] == 0) |
|
| 767 | - $display_pms = $pms; |
|
| 768 | - else |
|
| 769 | - $display_pms = array($context['current_pm']); |
|
| 789 | + if ($context['display_mode'] == 0) { |
|
| 790 | + $display_pms = $pms; |
|
| 791 | + } else { |
|
| 792 | + $display_pms = array($context['current_pm']); |
|
| 793 | + } |
|
| 770 | 794 | |
| 771 | 795 | // At this point we know the main id_pm's. But - if we are looking at conversations we need the others! |
| 772 | 796 | if ($context['display_mode'] == 2) |
@@ -788,16 +812,18 @@ discard block |
||
| 788 | 812 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 789 | 813 | { |
| 790 | 814 | // This is, frankly, a joke. We will put in a workaround for people sending to themselves - yawn! |
| 791 | - if ($context['folder'] == 'sent' && $row['id_member_from'] == $user_info['id'] && $row['deleted_by_sender'] == 1) |
|
| 792 | - continue; |
|
| 793 | - elseif ($row['id_member'] == $user_info['id'] & $row['deleted'] == 1) |
|
| 794 | - continue; |
|
| 815 | + if ($context['folder'] == 'sent' && $row['id_member_from'] == $user_info['id'] && $row['deleted_by_sender'] == 1) { |
|
| 816 | + continue; |
|
| 817 | + } elseif ($row['id_member'] == $user_info['id'] & $row['deleted'] == 1) { |
|
| 818 | + continue; |
|
| 819 | + } |
|
| 795 | 820 | |
| 796 | - if (!isset($recipients[$row['id_pm']])) |
|
| 797 | - $recipients[$row['id_pm']] = array( |
|
| 821 | + if (!isset($recipients[$row['id_pm']])) { |
|
| 822 | + $recipients[$row['id_pm']] = array( |
|
| 798 | 823 | 'to' => array(), |
| 799 | 824 | 'bcc' => array() |
| 800 | 825 | ); |
| 826 | + } |
|
| 801 | 827 | $display_pms[] = $row['id_pm']; |
| 802 | 828 | $posters[$row['id_pm']] = $row['id_member_from']; |
| 803 | 829 | } |
@@ -848,8 +874,9 @@ discard block |
||
| 848 | 874 | while ($row2 = $smcFunc['db_fetch_assoc']($request2)) |
| 849 | 875 | { |
| 850 | 876 | $l_id = $row2['id_label']; |
| 851 | - if (isset($context['labels'][$l_id])) |
|
| 852 | - $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
| 877 | + if (isset($context['labels'][$l_id])) { |
|
| 878 | + $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
| 879 | + } |
|
| 853 | 880 | } |
| 854 | 881 | |
| 855 | 882 | $smcFunc['db_free_result']($request2); |
@@ -866,9 +893,10 @@ discard block |
||
| 866 | 893 | // Make sure we don't load unnecessary data. |
| 867 | 894 | if ($context['display_mode'] == 1) |
| 868 | 895 | { |
| 869 | - foreach ($posters as $k => $v) |
|
| 870 | - if (!in_array($k, $display_pms)) |
|
| 896 | + foreach ($posters as $k => $v) { |
|
| 897 | + if (!in_array($k, $display_pms)) |
|
| 871 | 898 | unset($posters[$k]); |
| 899 | + } |
|
| 872 | 900 | } |
| 873 | 901 | |
| 874 | 902 | // Load any users.... |
@@ -879,8 +907,9 @@ discard block |
||
| 879 | 907 | { |
| 880 | 908 | // Get the order right. |
| 881 | 909 | $orderBy = array(); |
| 882 | - foreach (array_reverse($pms) as $pm) |
|
| 883 | - $orderBy[] = 'pm.id_pm = ' . $pm; |
|
| 910 | + foreach (array_reverse($pms) as $pm) { |
|
| 911 | + $orderBy[] = 'pm.id_pm = ' . $pm; |
|
| 912 | + } |
|
| 884 | 913 | |
| 885 | 914 | // Seperate query for these bits! |
| 886 | 915 | $subjects_request = $smcFunc['db_query']('', ' |
@@ -926,9 +955,9 @@ discard block |
||
| 926 | 955 | // Allow mods to add additional buttons here |
| 927 | 956 | call_integration_hook('integrate_conversation_buttons'); |
| 928 | 957 | } |
| 958 | + } else { |
|
| 959 | + $messages_request = false; |
|
| 929 | 960 | } |
| 930 | - else |
|
| 931 | - $messages_request = false; |
|
| 932 | 961 | |
| 933 | 962 | $context['can_send_pm'] = allowedTo('pm_send'); |
| 934 | 963 | $context['can_send_email'] = allowedTo('moderate_forum'); |
@@ -939,11 +968,13 @@ discard block |
||
| 939 | 968 | if ($context['folder'] != 'sent' && !empty($context['labels'][(int) $context['current_label_id']]['unread_messages'])) |
| 940 | 969 | { |
| 941 | 970 | // If the display mode is "old sk00l" do them all... |
| 942 | - if ($context['display_mode'] == 0) |
|
| 943 | - markMessages(null, $context['current_label_id']); |
|
| 971 | + if ($context['display_mode'] == 0) { |
|
| 972 | + markMessages(null, $context['current_label_id']); |
|
| 973 | + } |
|
| 944 | 974 | // Otherwise do just the current one! |
| 945 | - elseif (!empty($context['current_pm'])) |
|
| 946 | - markMessages($display_pms, $context['current_label_id']); |
|
| 975 | + elseif (!empty($context['current_pm'])) { |
|
| 976 | + markMessages($display_pms, $context['current_label_id']); |
|
| 977 | + } |
|
| 947 | 978 | } |
| 948 | 979 | } |
| 949 | 980 | |
@@ -961,8 +992,9 @@ discard block |
||
| 961 | 992 | |
| 962 | 993 | // Count the current message number.... |
| 963 | 994 | static $counter = null; |
| 964 | - if ($counter === null || $reset) |
|
| 965 | - $counter = $context['start']; |
|
| 995 | + if ($counter === null || $reset) { |
|
| 996 | + $counter = $context['start']; |
|
| 997 | + } |
|
| 966 | 998 | |
| 967 | 999 | static $temp_pm_selected = null; |
| 968 | 1000 | if ($temp_pm_selected === null) |
@@ -1007,19 +1039,22 @@ discard block |
||
| 1007 | 1039 | } |
| 1008 | 1040 | |
| 1009 | 1041 | // Bail if it's false, ie. no messages. |
| 1010 | - if ($messages_request == false) |
|
| 1011 | - return false; |
|
| 1042 | + if ($messages_request == false) { |
|
| 1043 | + return false; |
|
| 1044 | + } |
|
| 1012 | 1045 | |
| 1013 | 1046 | // Reset the data? |
| 1014 | - if ($reset == true) |
|
| 1015 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1047 | + if ($reset == true) { |
|
| 1048 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1049 | + } |
|
| 1016 | 1050 | |
| 1017 | 1051 | // Get the next one... bail if anything goes wrong. |
| 1018 | 1052 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
| 1019 | 1053 | if (!$message) |
| 1020 | 1054 | { |
| 1021 | - if ($type != 'subject') |
|
| 1022 | - $smcFunc['db_free_result']($messages_request); |
|
| 1055 | + if ($type != 'subject') { |
|
| 1056 | + $smcFunc['db_free_result']($messages_request); |
|
| 1057 | + } |
|
| 1023 | 1058 | |
| 1024 | 1059 | return false; |
| 1025 | 1060 | } |
@@ -1039,8 +1074,7 @@ discard block |
||
| 1039 | 1074 | $memberContext[$message['id_member_from']]['email'] = ''; |
| 1040 | 1075 | $memberContext[$message['id_member_from']]['show_email'] = false; |
| 1041 | 1076 | $memberContext[$message['id_member_from']]['is_guest'] = true; |
| 1042 | - } |
|
| 1043 | - else |
|
| 1077 | + } else |
|
| 1044 | 1078 | { |
| 1045 | 1079 | $memberContext[$message['id_member_from']]['can_view_profile'] = allowedTo('profile_view') || ($message['id_member_from'] == $user_info['id'] && !$user_info['is_guest']); |
| 1046 | 1080 | $memberContext[$message['id_member_from']]['can_see_warning'] = !isset($context['disabled_fields']['warning_status']) && $memberContext[$message['id_member_from']]['warning_status'] && ($context['user']['can_mod'] || (!empty($modSettings['warning_show']) && ($modSettings['warning_show'] > 1 || $message['id_member_from'] == $user_info['id']))); |
@@ -1081,9 +1115,10 @@ discard block |
||
| 1081 | 1115 | $counter++; |
| 1082 | 1116 | |
| 1083 | 1117 | // Any custom profile fields? |
| 1084 | - if (!empty($memberContext[$message['id_member_from']]['custom_fields'])) |
|
| 1085 | - foreach ($memberContext[$message['id_member_from']]['custom_fields'] as $custom) |
|
| 1118 | + if (!empty($memberContext[$message['id_member_from']]['custom_fields'])) { |
|
| 1119 | + foreach ($memberContext[$message['id_member_from']]['custom_fields'] as $custom) |
|
| 1086 | 1120 | $output['custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
| 1121 | + } |
|
| 1087 | 1122 | |
| 1088 | 1123 | call_integration_hook('integrate_prepare_pm_context', array(&$output, &$message, $counter)); |
| 1089 | 1124 | |
@@ -1107,22 +1142,28 @@ discard block |
||
| 1107 | 1142 | $context['search_params'][$k] = $v; |
| 1108 | 1143 | } |
| 1109 | 1144 | } |
| 1110 | - if (isset($_REQUEST['search'])) |
|
| 1111 | - $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
| 1145 | + if (isset($_REQUEST['search'])) { |
|
| 1146 | + $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
| 1147 | + } |
|
| 1112 | 1148 | |
| 1113 | - if (isset($context['search_params']['search'])) |
|
| 1114 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 1115 | - if (isset($context['search_params']['userspec'])) |
|
| 1116 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 1149 | + if (isset($context['search_params']['search'])) { |
|
| 1150 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 1151 | + } |
|
| 1152 | + if (isset($context['search_params']['userspec'])) { |
|
| 1153 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 1154 | + } |
|
| 1117 | 1155 | |
| 1118 | - if (!empty($context['search_params']['searchtype'])) |
|
| 1119 | - $context['search_params']['searchtype'] = 2; |
|
| 1156 | + if (!empty($context['search_params']['searchtype'])) { |
|
| 1157 | + $context['search_params']['searchtype'] = 2; |
|
| 1158 | + } |
|
| 1120 | 1159 | |
| 1121 | - if (!empty($context['search_params']['minage'])) |
|
| 1122 | - $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
| 1160 | + if (!empty($context['search_params']['minage'])) { |
|
| 1161 | + $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
| 1162 | + } |
|
| 1123 | 1163 | |
| 1124 | - if (!empty($context['search_params']['maxage'])) |
|
| 1125 | - $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
| 1164 | + if (!empty($context['search_params']['maxage'])) { |
|
| 1165 | + $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
| 1166 | + } |
|
| 1126 | 1167 | |
| 1127 | 1168 | $context['search_params']['subject_only'] = !empty($context['search_params']['subject_only']); |
| 1128 | 1169 | $context['search_params']['show_complete'] = !empty($context['search_params']['show_complete']); |
@@ -1149,8 +1190,9 @@ discard block |
||
| 1149 | 1190 | $context['search_errors']['messages'] = array(); |
| 1150 | 1191 | foreach ($context['search_errors'] as $search_error => $dummy) |
| 1151 | 1192 | { |
| 1152 | - if ($search_error == 'messages') |
|
| 1153 | - continue; |
|
| 1193 | + if ($search_error == 'messages') { |
|
| 1194 | + continue; |
|
| 1195 | + } |
|
| 1154 | 1196 | |
| 1155 | 1197 | $context['search_errors']['messages'][] = $txt['error_' . $search_error]; |
| 1156 | 1198 | } |
@@ -1172,8 +1214,9 @@ discard block |
||
| 1172 | 1214 | global $scripturl, $modSettings, $user_info, $context, $txt; |
| 1173 | 1215 | global $memberContext, $smcFunc; |
| 1174 | 1216 | |
| 1175 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) |
|
| 1176 | - fatal_lang_error('loadavg_search_disabled', false); |
|
| 1217 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) { |
|
| 1218 | + fatal_lang_error('loadavg_search_disabled', false); |
|
| 1219 | + } |
|
| 1177 | 1220 | |
| 1178 | 1221 | /** |
| 1179 | 1222 | * @todo For the moment force the folder to the inbox. |
@@ -1202,35 +1245,40 @@ discard block |
||
| 1202 | 1245 | $context['start'] = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
| 1203 | 1246 | |
| 1204 | 1247 | // Store whether simple search was used (needed if the user wants to do another query). |
| 1205 | - if (!isset($search_params['advanced'])) |
|
| 1206 | - $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
| 1248 | + if (!isset($search_params['advanced'])) { |
|
| 1249 | + $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
| 1250 | + } |
|
| 1207 | 1251 | |
| 1208 | 1252 | // 1 => 'allwords' (default, don't set as param) / 2 => 'anywords'. |
| 1209 | - if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) |
|
| 1210 | - $search_params['searchtype'] = 2; |
|
| 1253 | + if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) { |
|
| 1254 | + $search_params['searchtype'] = 2; |
|
| 1255 | + } |
|
| 1211 | 1256 | |
| 1212 | 1257 | // Minimum age of messages. Default to zero (don't set param in that case). |
| 1213 | - if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) |
|
| 1214 | - $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
| 1258 | + if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) { |
|
| 1259 | + $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
| 1260 | + } |
|
| 1215 | 1261 | |
| 1216 | 1262 | // Maximum age of messages. Default to infinite (9999 days: param not set). |
| 1217 | - if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] != 9999)) |
|
| 1218 | - $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
| 1263 | + if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] != 9999)) { |
|
| 1264 | + $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
| 1265 | + } |
|
| 1219 | 1266 | |
| 1220 | 1267 | $search_params['subject_only'] = !empty($search_params['subject_only']) || !empty($_REQUEST['subject_only']); |
| 1221 | 1268 | $search_params['show_complete'] = !empty($search_params['show_complete']) || !empty($_REQUEST['show_complete']); |
| 1222 | 1269 | |
| 1223 | 1270 | // Default the user name to a wildcard matching every user (*). |
| 1224 | - if (!empty($search_params['user_spec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) |
|
| 1225 | - $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
| 1271 | + if (!empty($search_params['user_spec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) { |
|
| 1272 | + $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
| 1273 | + } |
|
| 1226 | 1274 | |
| 1227 | 1275 | // This will be full of all kinds of parameters! |
| 1228 | 1276 | $searchq_parameters = array(); |
| 1229 | 1277 | |
| 1230 | 1278 | // If there's no specific user, then don't mention it in the main query. |
| 1231 | - if (empty($search_params['userspec'])) |
|
| 1232 | - $userQuery = ''; |
|
| 1233 | - else |
|
| 1279 | + if (empty($search_params['userspec'])) { |
|
| 1280 | + $userQuery = ''; |
|
| 1281 | + } else |
|
| 1234 | 1282 | { |
| 1235 | 1283 | $userString = strtr($smcFunc['htmlspecialchars']($search_params['userspec'], ENT_QUOTES), array('"' => '"')); |
| 1236 | 1284 | $userString = strtr($userString, array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_')); |
@@ -1242,8 +1290,9 @@ discard block |
||
| 1242 | 1290 | { |
| 1243 | 1291 | $possible_users[$k] = trim($possible_users[$k]); |
| 1244 | 1292 | |
| 1245 | - if (strlen($possible_users[$k]) == 0) |
|
| 1246 | - unset($possible_users[$k]); |
|
| 1293 | + if (strlen($possible_users[$k]) == 0) { |
|
| 1294 | + unset($possible_users[$k]); |
|
| 1295 | + } |
|
| 1247 | 1296 | } |
| 1248 | 1297 | |
| 1249 | 1298 | if (!empty($possible_users)) |
@@ -1255,8 +1304,9 @@ discard block |
||
| 1255 | 1304 | { |
| 1256 | 1305 | $where_params['name_' . $k] = $v; |
| 1257 | 1306 | $where_clause[] = '{raw:real_name} LIKE {string:name_' . $k . '}'; |
| 1258 | - if (!isset($where_params['real_name'])) |
|
| 1259 | - $where_params['real_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(real_name)' : 'real_name'; |
|
| 1307 | + if (!isset($where_params['real_name'])) { |
|
| 1308 | + $where_params['real_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(real_name)' : 'real_name'; |
|
| 1309 | + } |
|
| 1260 | 1310 | } |
| 1261 | 1311 | |
| 1262 | 1312 | // Who matches those criteria? |
@@ -1269,28 +1319,28 @@ discard block |
||
| 1269 | 1319 | ); |
| 1270 | 1320 | |
| 1271 | 1321 | // Simply do nothing if there're too many members matching the criteria. |
| 1272 | - if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) |
|
| 1273 | - $userQuery = ''; |
|
| 1274 | - elseif ($smcFunc['db_num_rows']($request) == 0) |
|
| 1322 | + if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) { |
|
| 1323 | + $userQuery = ''; |
|
| 1324 | + } elseif ($smcFunc['db_num_rows']($request) == 0) |
|
| 1275 | 1325 | { |
| 1276 | 1326 | $userQuery = 'AND pm.id_member_from = 0 AND ({raw:pm_from_name} LIKE {raw:guest_user_name_implode})'; |
| 1277 | 1327 | $searchq_parameters['guest_user_name_implode'] = '\'' . implode('\' OR ' . ($smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name') . ' LIKE \'', $possible_users) . '\''; |
| 1278 | 1328 | $searchq_parameters['pm_from_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name'; |
| 1279 | - } |
|
| 1280 | - else |
|
| 1329 | + } else |
|
| 1281 | 1330 | { |
| 1282 | 1331 | $memberlist = array(); |
| 1283 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1284 | - $memberlist[] = $row['id_member']; |
|
| 1332 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1333 | + $memberlist[] = $row['id_member']; |
|
| 1334 | + } |
|
| 1285 | 1335 | $userQuery = 'AND (pm.id_member_from IN ({array_int:member_list}) OR (pm.id_member_from = 0 AND ({raw:pm_from_name} LIKE {raw:guest_user_name_implode})))'; |
| 1286 | 1336 | $searchq_parameters['guest_user_name_implode'] = '\'' . implode('\' OR ' . ($smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name') . ' LIKE \'', $possible_users) . '\''; |
| 1287 | 1337 | $searchq_parameters['member_list'] = $memberlist; |
| 1288 | 1338 | $searchq_parameters['pm_from_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name'; |
| 1289 | 1339 | } |
| 1290 | 1340 | $smcFunc['db_free_result']($request); |
| 1341 | + } else { |
|
| 1342 | + $userQuery = ''; |
|
| 1291 | 1343 | } |
| 1292 | - else |
|
| 1293 | - $userQuery = ''; |
|
| 1294 | 1344 | } |
| 1295 | 1345 | |
| 1296 | 1346 | // Setup the sorting variables... |
@@ -1298,8 +1348,9 @@ discard block |
||
| 1298 | 1348 | $sort_columns = array( |
| 1299 | 1349 | 'pm.id_pm', |
| 1300 | 1350 | ); |
| 1301 | - if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) |
|
| 1302 | - list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
| 1351 | + if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) { |
|
| 1352 | + list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
| 1353 | + } |
|
| 1303 | 1354 | $search_params['sort'] = !empty($search_params['sort']) && in_array($search_params['sort'], $sort_columns) ? $search_params['sort'] : 'pm.id_pm'; |
| 1304 | 1355 | $search_params['sort_dir'] = !empty($search_params['sort_dir']) && $search_params['sort_dir'] == 'asc' ? 'asc' : 'desc'; |
| 1305 | 1356 | |
@@ -1309,24 +1360,27 @@ discard block |
||
| 1309 | 1360 | if ($context['folder'] == 'inbox' && !empty($search_params['advanced']) && $context['currently_using_labels']) |
| 1310 | 1361 | { |
| 1311 | 1362 | // Came here from pagination? Put them back into $_REQUEST for sanitization. |
| 1312 | - if (isset($search_params['labels'])) |
|
| 1313 | - $_REQUEST['searchlabel'] = explode(',', $search_params['labels']); |
|
| 1363 | + if (isset($search_params['labels'])) { |
|
| 1364 | + $_REQUEST['searchlabel'] = explode(',', $search_params['labels']); |
|
| 1365 | + } |
|
| 1314 | 1366 | |
| 1315 | 1367 | // Assuming we have some labels - make them all integers. |
| 1316 | 1368 | if (!empty($_REQUEST['searchlabel']) && is_array($_REQUEST['searchlabel'])) |
| 1317 | 1369 | { |
| 1318 | - foreach ($_REQUEST['searchlabel'] as $key => $id) |
|
| 1319 | - $_REQUEST['searchlabel'][$key] = (int) $id; |
|
| 1370 | + foreach ($_REQUEST['searchlabel'] as $key => $id) { |
|
| 1371 | + $_REQUEST['searchlabel'][$key] = (int) $id; |
|
| 1372 | + } |
|
| 1373 | + } else { |
|
| 1374 | + $_REQUEST['searchlabel'] = array(); |
|
| 1320 | 1375 | } |
| 1321 | - else |
|
| 1322 | - $_REQUEST['searchlabel'] = array(); |
|
| 1323 | 1376 | |
| 1324 | 1377 | // Now that everything is cleaned up a bit, make the labels a param. |
| 1325 | 1378 | $search_params['labels'] = implode(',', $_REQUEST['searchlabel']); |
| 1326 | 1379 | |
| 1327 | 1380 | // No labels selected? That must be an error! |
| 1328 | - if (empty($_REQUEST['searchlabel'])) |
|
| 1329 | - $context['search_errors']['no_labels_selected'] = true; |
|
| 1381 | + if (empty($_REQUEST['searchlabel'])) { |
|
| 1382 | + $context['search_errors']['no_labels_selected'] = true; |
|
| 1383 | + } |
|
| 1330 | 1384 | // Otherwise prepare the query! |
| 1331 | 1385 | elseif (count($_REQUEST['searchlabel']) != count($context['labels'])) |
| 1332 | 1386 | { |
@@ -1349,8 +1403,7 @@ discard block |
||
| 1349 | 1403 | // Not searching the inbox - PM must be labeled |
| 1350 | 1404 | $labelQuery = ' AND pml.id_label IN ({array_int:labels})'; |
| 1351 | 1405 | $labelJoin = ' INNER JOIN {db_prefix}pm_labeled_messages AS pml ON (pml.id_pm = pmr.id_pm)'; |
| 1352 | - } |
|
| 1353 | - else |
|
| 1406 | + } else |
|
| 1354 | 1407 | { |
| 1355 | 1408 | // Searching the inbox - PM doesn't have to be labeled |
| 1356 | 1409 | $labelQuery = ' AND (' . substr($labelQuery, 5) . ' OR pml.id_label IN ({array_int:labels}))'; |
@@ -1365,8 +1418,9 @@ discard block |
||
| 1365 | 1418 | // What are we actually searching for? |
| 1366 | 1419 | $search_params['search'] = !empty($search_params['search']) ? $search_params['search'] : (isset($_REQUEST['search']) ? $_REQUEST['search'] : ''); |
| 1367 | 1420 | // If we ain't got nothing - we should error! |
| 1368 | - if (!isset($search_params['search']) || $search_params['search'] == '') |
|
| 1369 | - $context['search_errors']['invalid_search_string'] = true; |
|
| 1421 | + if (!isset($search_params['search']) || $search_params['search'] == '') { |
|
| 1422 | + $context['search_errors']['invalid_search_string'] = true; |
|
| 1423 | + } |
|
| 1370 | 1424 | |
| 1371 | 1425 | // Extract phrase parts first (e.g. some words "this is a phrase" some more words.) |
| 1372 | 1426 | preg_match_all('~(?:^|\s)([-]?)"([^"]+)"(?:$|\s)~' . ($context['utf8'] ? 'u' : ''), $search_params['search'], $matches, PREG_PATTERN_ORDER); |
@@ -1379,12 +1433,14 @@ discard block |
||
| 1379 | 1433 | $excludedWords = array(); |
| 1380 | 1434 | |
| 1381 | 1435 | // .. first, we check for things like -"some words", but not "-some words". |
| 1382 | - foreach ($matches[1] as $index => $word) |
|
| 1383 | - if ($word == '-') |
|
| 1436 | + foreach ($matches[1] as $index => $word) { |
|
| 1437 | + if ($word == '-') |
|
| 1384 | 1438 | { |
| 1385 | 1439 | $word = $smcFunc['strtolower'](trim($searchArray[$index])); |
| 1386 | - if (strlen($word) > 0) |
|
| 1387 | - $excludedWords[] = $word; |
|
| 1440 | + } |
|
| 1441 | + if (strlen($word) > 0) { |
|
| 1442 | + $excludedWords[] = $word; |
|
| 1443 | + } |
|
| 1388 | 1444 | unset($searchArray[$index]); |
| 1389 | 1445 | } |
| 1390 | 1446 | |
@@ -1394,8 +1450,9 @@ discard block |
||
| 1394 | 1450 | if (strpos(trim($word), '-') === 0) |
| 1395 | 1451 | { |
| 1396 | 1452 | $word = substr($smcFunc['strtolower']($word), 1); |
| 1397 | - if (strlen($word) > 0) |
|
| 1398 | - $excludedWords[] = $word; |
|
| 1453 | + if (strlen($word) > 0) { |
|
| 1454 | + $excludedWords[] = $word; |
|
| 1455 | + } |
|
| 1399 | 1456 | unset($tempSearch[$index]); |
| 1400 | 1457 | } |
| 1401 | 1458 | } |
@@ -1406,9 +1463,9 @@ discard block |
||
| 1406 | 1463 | foreach ($searchArray as $index => $value) |
| 1407 | 1464 | { |
| 1408 | 1465 | $searchArray[$index] = $smcFunc['strtolower'](trim($value)); |
| 1409 | - if ($searchArray[$index] == '') |
|
| 1410 | - unset($searchArray[$index]); |
|
| 1411 | - else |
|
| 1466 | + if ($searchArray[$index] == '') { |
|
| 1467 | + unset($searchArray[$index]); |
|
| 1468 | + } else |
|
| 1412 | 1469 | { |
| 1413 | 1470 | // Sort out entities first. |
| 1414 | 1471 | $searchArray[$index] = $smcFunc['htmlspecialchars']($searchArray[$index]); |
@@ -1418,27 +1475,32 @@ discard block |
||
| 1418 | 1475 | |
| 1419 | 1476 | // Create an array of replacements for highlighting. |
| 1420 | 1477 | $context['mark'] = array(); |
| 1421 | - foreach ($searchArray as $word) |
|
| 1422 | - $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
| 1478 | + foreach ($searchArray as $word) { |
|
| 1479 | + $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
| 1480 | + } |
|
| 1423 | 1481 | |
| 1424 | 1482 | // This contains *everything* |
| 1425 | 1483 | $searchWords = array_merge($searchArray, $excludedWords); |
| 1426 | 1484 | |
| 1427 | 1485 | // Make sure at least one word is being searched for. |
| 1428 | - if (empty($searchArray)) |
|
| 1429 | - $context['search_errors']['invalid_search_string'] = true; |
|
| 1486 | + if (empty($searchArray)) { |
|
| 1487 | + $context['search_errors']['invalid_search_string'] = true; |
|
| 1488 | + } |
|
| 1430 | 1489 | |
| 1431 | 1490 | // Sort out the search query so the user can edit it - if they want. |
| 1432 | 1491 | $context['search_params'] = $search_params; |
| 1433 | - if (isset($context['search_params']['search'])) |
|
| 1434 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 1435 | - if (isset($context['search_params']['userspec'])) |
|
| 1436 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 1492 | + if (isset($context['search_params']['search'])) { |
|
| 1493 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 1494 | + } |
|
| 1495 | + if (isset($context['search_params']['userspec'])) { |
|
| 1496 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 1497 | + } |
|
| 1437 | 1498 | |
| 1438 | 1499 | // Now we have all the parameters, combine them together for pagination and the like... |
| 1439 | 1500 | $context['params'] = array(); |
| 1440 | - foreach ($search_params as $k => $v) |
|
| 1441 | - $context['params'][] = $k . '|\'|' . $v; |
|
| 1501 | + foreach ($search_params as $k => $v) { |
|
| 1502 | + $context['params'][] = $k . '|\'|' . $v; |
|
| 1503 | + } |
|
| 1442 | 1504 | $context['params'] = base64_encode(implode('|"|', $context['params'])); |
| 1443 | 1505 | |
| 1444 | 1506 | // Compile the subject query part. |
@@ -1446,26 +1508,31 @@ discard block |
||
| 1446 | 1508 | |
| 1447 | 1509 | foreach ($searchWords as $index => $word) |
| 1448 | 1510 | { |
| 1449 | - if ($word == '') |
|
| 1450 | - continue; |
|
| 1511 | + if ($word == '') { |
|
| 1512 | + continue; |
|
| 1513 | + } |
|
| 1451 | 1514 | |
| 1452 | - if ($search_params['subject_only']) |
|
| 1453 | - $andQueryParts[] = 'pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '}'; |
|
| 1454 | - else |
|
| 1455 | - $andQueryParts[] = '(pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '} ' . (in_array($word, $excludedWords) ? 'AND pm.body NOT' : 'OR pm.body') . ' LIKE {string:search_' . $index . '})'; |
|
| 1515 | + if ($search_params['subject_only']) { |
|
| 1516 | + $andQueryParts[] = 'pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '}'; |
|
| 1517 | + } else { |
|
| 1518 | + $andQueryParts[] = '(pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '} ' . (in_array($word, $excludedWords) ? 'AND pm.body NOT' : 'OR pm.body') . ' LIKE {string:search_' . $index . '})'; |
|
| 1519 | + } |
|
| 1456 | 1520 | $searchq_parameters['search_' . $index] = '%' . strtr($word, array('_' => '\\_', '%' => '\\%')) . '%'; |
| 1457 | 1521 | } |
| 1458 | 1522 | |
| 1459 | 1523 | $searchQuery = ' 1=1'; |
| 1460 | - if (!empty($andQueryParts)) |
|
| 1461 | - $searchQuery = implode(!empty($search_params['searchtype']) && $search_params['searchtype'] == 2 ? ' OR ' : ' AND ', $andQueryParts); |
|
| 1524 | + if (!empty($andQueryParts)) { |
|
| 1525 | + $searchQuery = implode(!empty($search_params['searchtype']) && $search_params['searchtype'] == 2 ? ' OR ' : ' AND ', $andQueryParts); |
|
| 1526 | + } |
|
| 1462 | 1527 | |
| 1463 | 1528 | // Age limits? |
| 1464 | 1529 | $timeQuery = ''; |
| 1465 | - if (!empty($search_params['minage'])) |
|
| 1466 | - $timeQuery .= ' AND pm.msgtime < ' . (time() - $search_params['minage'] * 86400); |
|
| 1467 | - if (!empty($search_params['maxage'])) |
|
| 1468 | - $timeQuery .= ' AND pm.msgtime > ' . (time() - $search_params['maxage'] * 86400); |
|
| 1530 | + if (!empty($search_params['minage'])) { |
|
| 1531 | + $timeQuery .= ' AND pm.msgtime < ' . (time() - $search_params['minage'] * 86400); |
|
| 1532 | + } |
|
| 1533 | + if (!empty($search_params['maxage'])) { |
|
| 1534 | + $timeQuery .= ' AND pm.msgtime > ' . (time() - $search_params['maxage'] * 86400); |
|
| 1535 | + } |
|
| 1469 | 1536 | |
| 1470 | 1537 | // If we have errors - return back to the first screen... |
| 1471 | 1538 | if (!empty($context['search_errors'])) |
@@ -1551,8 +1618,9 @@ discard block |
||
| 1551 | 1618 | ) |
| 1552 | 1619 | ); |
| 1553 | 1620 | $real_pm_ids = array(); |
| 1554 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1555 | - $real_pm_ids[$row['id_pm_head']] = $row['id_pm']; |
|
| 1621 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1622 | + $real_pm_ids[$row['id_pm_head']] = $row['id_pm']; |
|
| 1623 | + } |
|
| 1556 | 1624 | $smcFunc['db_free_result']($request); |
| 1557 | 1625 | } |
| 1558 | 1626 | |
@@ -1582,8 +1650,9 @@ discard block |
||
| 1582 | 1650 | ); |
| 1583 | 1651 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1584 | 1652 | { |
| 1585 | - if ($context['folder'] == 'sent' || empty($row['bcc'])) |
|
| 1586 | - $recipients[$row['id_pm']][empty($row['bcc']) ? 'to' : 'bcc'][] = empty($row['id_member_to']) ? $txt['guest_title'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . '">' . $row['to_name'] . '</a>'; |
|
| 1653 | + if ($context['folder'] == 'sent' || empty($row['bcc'])) { |
|
| 1654 | + $recipients[$row['id_pm']][empty($row['bcc']) ? 'to' : 'bcc'][] = empty($row['id_member_to']) ? $txt['guest_title'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . '">' . $row['to_name'] . '</a>'; |
|
| 1655 | + } |
|
| 1587 | 1656 | |
| 1588 | 1657 | if ($row['id_member_to'] == $user_info['id'] && $context['folder'] != 'sent') |
| 1589 | 1658 | { |
@@ -1604,12 +1673,14 @@ discard block |
||
| 1604 | 1673 | while ($row2 = $smcFunc['db_fetch_assoc']($request2)) |
| 1605 | 1674 | { |
| 1606 | 1675 | $l_id = $row2['id_label']; |
| 1607 | - if (isset($context['labels'][$l_id])) |
|
| 1608 | - $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
| 1676 | + if (isset($context['labels'][$l_id])) { |
|
| 1677 | + $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
| 1678 | + } |
|
| 1609 | 1679 | |
| 1610 | 1680 | // Here we find the first label on a message - for linking to posts in results |
| 1611 | - if (!isset($context['first_label'][$row['id_pm']]) && $row['in_inbox'] != 1) |
|
| 1612 | - $context['first_label'][$row['id_pm']] = $l_id; |
|
| 1681 | + if (!isset($context['first_label'][$row['id_pm']]) && $row['in_inbox'] != 1) { |
|
| 1682 | + $context['first_label'][$row['id_pm']] = $l_id; |
|
| 1683 | + } |
|
| 1613 | 1684 | } |
| 1614 | 1685 | |
| 1615 | 1686 | $smcFunc['db_free_result']($request2); |
@@ -1736,8 +1807,9 @@ discard block |
||
| 1736 | 1807 | list ($postCount) = $smcFunc['db_fetch_row']($request); |
| 1737 | 1808 | $smcFunc['db_free_result']($request); |
| 1738 | 1809 | |
| 1739 | - if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) |
|
| 1740 | - fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
| 1810 | + if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) { |
|
| 1811 | + fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
| 1812 | + } |
|
| 1741 | 1813 | } |
| 1742 | 1814 | |
| 1743 | 1815 | // Quoting/Replying to a message? |
@@ -1746,8 +1818,9 @@ discard block |
||
| 1746 | 1818 | $pmsg = (int) $_REQUEST['pmsg']; |
| 1747 | 1819 | |
| 1748 | 1820 | // Make sure this is yours. |
| 1749 | - if (!isAccessiblePM($pmsg)) |
|
| 1750 | - fatal_lang_error('no_access', false); |
|
| 1821 | + if (!isAccessiblePM($pmsg)) { |
|
| 1822 | + fatal_lang_error('no_access', false); |
|
| 1823 | + } |
|
| 1751 | 1824 | |
| 1752 | 1825 | // Work out whether this is one you've received? |
| 1753 | 1826 | $request = $smcFunc['db_query']('', ' |
@@ -1784,8 +1857,9 @@ discard block |
||
| 1784 | 1857 | 'id_pm' => $pmsg, |
| 1785 | 1858 | ) |
| 1786 | 1859 | ); |
| 1787 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1788 | - fatal_lang_error('pm_not_yours', false); |
|
| 1860 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1861 | + fatal_lang_error('pm_not_yours', false); |
|
| 1862 | + } |
|
| 1789 | 1863 | $row_quoted = $smcFunc['db_fetch_assoc']($request); |
| 1790 | 1864 | $smcFunc['db_free_result']($request); |
| 1791 | 1865 | |
@@ -1796,9 +1870,9 @@ discard block |
||
| 1796 | 1870 | // Add 'Re: ' to it.... |
| 1797 | 1871 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 1798 | 1872 | { |
| 1799 | - if ($language === $user_info['language']) |
|
| 1800 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 1801 | - else |
|
| 1873 | + if ($language === $user_info['language']) { |
|
| 1874 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 1875 | + } else |
|
| 1802 | 1876 | { |
| 1803 | 1877 | loadLanguage('index', $language, false); |
| 1804 | 1878 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -1807,22 +1881,25 @@ discard block |
||
| 1807 | 1881 | cache_put_data('response_prefix', $context['response_prefix'], 600); |
| 1808 | 1882 | } |
| 1809 | 1883 | $form_subject = $row_quoted['subject']; |
| 1810 | - if ($context['reply'] && trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
| 1811 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
| 1884 | + if ($context['reply'] && trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
| 1885 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
| 1886 | + } |
|
| 1812 | 1887 | |
| 1813 | 1888 | if (isset($_REQUEST['quote'])) |
| 1814 | 1889 | { |
| 1815 | 1890 | // Remove any nested quotes and <br>... |
| 1816 | 1891 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $row_quoted['body']); |
| 1817 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
| 1818 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 1819 | - if (empty($row_quoted['id_member'])) |
|
| 1820 | - $form_message = '[quote author="' . $row_quoted['real_name'] . '"]' . "\n" . $form_message . "\n" . '[/quote]'; |
|
| 1821 | - else |
|
| 1822 | - $form_message = '[quote author=' . $row_quoted['real_name'] . ' link=action=profile;u=' . $row_quoted['id_member'] . ' date=' . $row_quoted['msgtime'] . ']' . "\n" . $form_message . "\n" . '[/quote]'; |
|
| 1892 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
| 1893 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 1894 | + } |
|
| 1895 | + if (empty($row_quoted['id_member'])) { |
|
| 1896 | + $form_message = '[quote author="' . $row_quoted['real_name'] . '"]' . "\n" . $form_message . "\n" . '[/quote]'; |
|
| 1897 | + } else { |
|
| 1898 | + $form_message = '[quote author=' . $row_quoted['real_name'] . ' link=action=profile;u=' . $row_quoted['id_member'] . ' date=' . $row_quoted['msgtime'] . ']' . "\n" . $form_message . "\n" . '[/quote]'; |
|
| 1899 | + } |
|
| 1900 | + } else { |
|
| 1901 | + $form_message = ''; |
|
| 1823 | 1902 | } |
| 1824 | - else |
|
| 1825 | - $form_message = ''; |
|
| 1826 | 1903 | |
| 1827 | 1904 | // Do the BBC thang on the message. |
| 1828 | 1905 | $row_quoted['body'] = parse_bbc($row_quoted['body'], true, 'pm' . $row_quoted['id_pm']); |
@@ -1843,8 +1920,7 @@ discard block |
||
| 1843 | 1920 | 'timestamp' => forum_time(true, $row_quoted['msgtime']), |
| 1844 | 1921 | 'body' => $row_quoted['body'] |
| 1845 | 1922 | ); |
| 1846 | - } |
|
| 1847 | - else |
|
| 1923 | + } else |
|
| 1848 | 1924 | { |
| 1849 | 1925 | $context['quoted_message'] = false; |
| 1850 | 1926 | $form_subject = ''; |
@@ -1863,11 +1939,12 @@ discard block |
||
| 1863 | 1939 | if ($_REQUEST['u'] == 'all' && isset($row_quoted)) |
| 1864 | 1940 | { |
| 1865 | 1941 | // Firstly, to reply to all we clearly already have $row_quoted - so have the original member from. |
| 1866 | - if ($row_quoted['id_member'] != $user_info['id']) |
|
| 1867 | - $context['recipients']['to'][] = array( |
|
| 1942 | + if ($row_quoted['id_member'] != $user_info['id']) { |
|
| 1943 | + $context['recipients']['to'][] = array( |
|
| 1868 | 1944 | 'id' => $row_quoted['id_member'], |
| 1869 | 1945 | 'name' => $smcFunc['htmlspecialchars']($row_quoted['real_name']), |
| 1870 | 1946 | ); |
| 1947 | + } |
|
| 1871 | 1948 | |
| 1872 | 1949 | // Now to get the others. |
| 1873 | 1950 | $request = $smcFunc['db_query']('', ' |
@@ -1883,18 +1960,19 @@ discard block |
||
| 1883 | 1960 | 'not_bcc' => 0, |
| 1884 | 1961 | ) |
| 1885 | 1962 | ); |
| 1886 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1887 | - $context['recipients']['to'][] = array( |
|
| 1963 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1964 | + $context['recipients']['to'][] = array( |
|
| 1888 | 1965 | 'id' => $row['id_member'], |
| 1889 | 1966 | 'name' => $row['real_name'], |
| 1890 | 1967 | ); |
| 1968 | + } |
|
| 1891 | 1969 | $smcFunc['db_free_result']($request); |
| 1892 | - } |
|
| 1893 | - else |
|
| 1970 | + } else |
|
| 1894 | 1971 | { |
| 1895 | 1972 | $_REQUEST['u'] = explode(',', $_REQUEST['u']); |
| 1896 | - foreach ($_REQUEST['u'] as $key => $uID) |
|
| 1897 | - $_REQUEST['u'][$key] = (int) $uID; |
|
| 1973 | + foreach ($_REQUEST['u'] as $key => $uID) { |
|
| 1974 | + $_REQUEST['u'][$key] = (int) $uID; |
|
| 1975 | + } |
|
| 1898 | 1976 | |
| 1899 | 1977 | $_REQUEST['u'] = array_unique($_REQUEST['u']); |
| 1900 | 1978 | |
@@ -1908,22 +1986,24 @@ discard block |
||
| 1908 | 1986 | 'limit' => count($_REQUEST['u']), |
| 1909 | 1987 | ) |
| 1910 | 1988 | ); |
| 1911 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1912 | - $context['recipients']['to'][] = array( |
|
| 1989 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1990 | + $context['recipients']['to'][] = array( |
|
| 1913 | 1991 | 'id' => $row['id_member'], |
| 1914 | 1992 | 'name' => $row['real_name'], |
| 1915 | 1993 | ); |
| 1994 | + } |
|
| 1916 | 1995 | $smcFunc['db_free_result']($request); |
| 1917 | 1996 | } |
| 1918 | 1997 | |
| 1919 | 1998 | // Get a literal name list in case the user has JavaScript disabled. |
| 1920 | 1999 | $names = array(); |
| 1921 | - foreach ($context['recipients']['to'] as $to) |
|
| 1922 | - $names[] = $to['name']; |
|
| 2000 | + foreach ($context['recipients']['to'] as $to) { |
|
| 2001 | + $names[] = $to['name']; |
|
| 2002 | + } |
|
| 1923 | 2003 | $context['to_value'] = empty($names) ? '' : '"' . implode('", "', $names) . '"'; |
| 2004 | + } else { |
|
| 2005 | + $context['to_value'] = ''; |
|
| 1924 | 2006 | } |
| 1925 | - else |
|
| 1926 | - $context['to_value'] = ''; |
|
| 1927 | 2007 | |
| 1928 | 2008 | // Set the defaults... |
| 1929 | 2009 | $context['subject'] = $form_subject; |
@@ -1993,8 +2073,9 @@ discard block |
||
| 1993 | 2073 | |
| 1994 | 2074 | // validate with loadMemberData() |
| 1995 | 2075 | $memberResult = loadMemberData($user_info['id'], false); |
| 1996 | - if (!$memberResult) |
|
| 1997 | - fatal_lang_error('not_a_user', false); |
|
| 2076 | + if (!$memberResult) { |
|
| 2077 | + fatal_lang_error('not_a_user', false); |
|
| 2078 | + } |
|
| 1998 | 2079 | list ($memID) = $memberResult; |
| 1999 | 2080 | |
| 2000 | 2081 | // drafts is where the functions reside |
@@ -2020,9 +2101,9 @@ discard block |
||
| 2020 | 2101 | $context['sub_template'] = 'send'; |
| 2021 | 2102 | loadJavaScriptFile('PersonalMessage.js', array('defer' => false), 'smf_pms'); |
| 2022 | 2103 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
| 2104 | + } else { |
|
| 2105 | + $context['sub_template'] = 'pm'; |
|
| 2023 | 2106 | } |
| 2024 | - else |
|
| 2025 | - $context['sub_template'] = 'pm'; |
|
| 2026 | 2107 | |
| 2027 | 2108 | $context['page_title'] = $txt['send_message']; |
| 2028 | 2109 | |
@@ -2083,10 +2164,11 @@ discard block |
||
| 2083 | 2164 | ); |
| 2084 | 2165 | if ($smcFunc['db_num_rows']($request) == 0) |
| 2085 | 2166 | { |
| 2086 | - if (!isset($_REQUEST['xml'])) |
|
| 2087 | - fatal_lang_error('pm_not_yours', false); |
|
| 2088 | - else |
|
| 2089 | - $error_types[] = 'pm_not_yours'; |
|
| 2167 | + if (!isset($_REQUEST['xml'])) { |
|
| 2168 | + fatal_lang_error('pm_not_yours', false); |
|
| 2169 | + } else { |
|
| 2170 | + $error_types[] = 'pm_not_yours'; |
|
| 2171 | + } |
|
| 2090 | 2172 | } |
| 2091 | 2173 | $row_quoted = $smcFunc['db_fetch_assoc']($request); |
| 2092 | 2174 | $smcFunc['db_free_result']($request); |
@@ -2133,14 +2215,16 @@ discard block |
||
| 2133 | 2215 | $context['post_error'][$error_type] = true; |
| 2134 | 2216 | if (isset($txt['error_' . $error_type])) |
| 2135 | 2217 | { |
| 2136 | - if ($error_type == 'long_message') |
|
| 2137 | - $txt['error_' . $error_type] = sprintf($txt['error_' . $error_type], $modSettings['max_messageLength']); |
|
| 2218 | + if ($error_type == 'long_message') { |
|
| 2219 | + $txt['error_' . $error_type] = sprintf($txt['error_' . $error_type], $modSettings['max_messageLength']); |
|
| 2220 | + } |
|
| 2138 | 2221 | $context['post_error']['messages'][] = $txt['error_' . $error_type]; |
| 2139 | 2222 | } |
| 2140 | 2223 | |
| 2141 | 2224 | // If it's not a minor error flag it as such. |
| 2142 | - if (!in_array($error_type, array('new_reply', 'not_approved', 'new_replies', 'old_topic', 'need_qr_verification', 'no_subject'))) |
|
| 2143 | - $context['error_type'] = 'serious'; |
|
| 2225 | + if (!in_array($error_type, array('new_reply', 'not_approved', 'new_replies', 'old_topic', 'need_qr_verification', 'no_subject'))) { |
|
| 2226 | + $context['error_type'] = 'serious'; |
|
| 2227 | + } |
|
| 2144 | 2228 | } |
| 2145 | 2229 | |
| 2146 | 2230 | // We need to load the editor once more. |
@@ -2198,8 +2282,9 @@ discard block |
||
| 2198 | 2282 | require_once($sourcedir . '/Subs-Auth.php'); |
| 2199 | 2283 | |
| 2200 | 2284 | // PM Drafts enabled and needed? |
| 2201 | - if ($context['drafts_pm_save'] && (isset($_POST['save_draft']) || isset($_POST['id_pm_draft']))) |
|
| 2202 | - require_once($sourcedir . '/Drafts.php'); |
|
| 2285 | + if ($context['drafts_pm_save'] && (isset($_POST['save_draft']) || isset($_POST['id_pm_draft']))) { |
|
| 2286 | + require_once($sourcedir . '/Drafts.php'); |
|
| 2287 | + } |
|
| 2203 | 2288 | |
| 2204 | 2289 | loadLanguage('PersonalMessage', '', false); |
| 2205 | 2290 | |
@@ -2229,24 +2314,27 @@ discard block |
||
| 2229 | 2314 | |
| 2230 | 2315 | if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) |
| 2231 | 2316 | { |
| 2232 | - if (!isset($_REQUEST['xml'])) |
|
| 2233 | - fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
| 2234 | - else |
|
| 2235 | - $post_errors[] = 'pm_too_many_per_hour'; |
|
| 2317 | + if (!isset($_REQUEST['xml'])) { |
|
| 2318 | + fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
| 2319 | + } else { |
|
| 2320 | + $post_errors[] = 'pm_too_many_per_hour'; |
|
| 2321 | + } |
|
| 2236 | 2322 | } |
| 2237 | 2323 | } |
| 2238 | 2324 | |
| 2239 | 2325 | // If your session timed out, show an error, but do allow to re-submit. |
| 2240 | - if (!isset($_REQUEST['xml']) && checkSession('post', '', false) != '') |
|
| 2241 | - $post_errors[] = 'session_timeout'; |
|
| 2326 | + if (!isset($_REQUEST['xml']) && checkSession('post', '', false) != '') { |
|
| 2327 | + $post_errors[] = 'session_timeout'; |
|
| 2328 | + } |
|
| 2242 | 2329 | |
| 2243 | 2330 | $_REQUEST['subject'] = isset($_REQUEST['subject']) ? trim($_REQUEST['subject']) : ''; |
| 2244 | 2331 | $_REQUEST['to'] = empty($_POST['to']) ? (empty($_GET['to']) ? '' : $_GET['to']) : $_POST['to']; |
| 2245 | 2332 | $_REQUEST['bcc'] = empty($_POST['bcc']) ? (empty($_GET['bcc']) ? '' : $_GET['bcc']) : $_POST['bcc']; |
| 2246 | 2333 | |
| 2247 | 2334 | // Route the input from the 'u' parameter to the 'to'-list. |
| 2248 | - if (!empty($_POST['u'])) |
|
| 2249 | - $_POST['recipient_to'] = explode(',', $_POST['u']); |
|
| 2335 | + if (!empty($_POST['u'])) { |
|
| 2336 | + $_POST['recipient_to'] = explode(',', $_POST['u']); |
|
| 2337 | + } |
|
| 2250 | 2338 | |
| 2251 | 2339 | // Construct the list of recipients. |
| 2252 | 2340 | $recipientList = array(); |
@@ -2258,8 +2346,9 @@ discard block |
||
| 2258 | 2346 | $recipientList[$recipientType] = array(); |
| 2259 | 2347 | if (!empty($_POST['recipient_' . $recipientType]) && is_array($_POST['recipient_' . $recipientType])) |
| 2260 | 2348 | { |
| 2261 | - foreach ($_POST['recipient_' . $recipientType] as $recipient) |
|
| 2262 | - $recipientList[$recipientType][] = (int) $recipient; |
|
| 2349 | + foreach ($_POST['recipient_' . $recipientType] as $recipient) { |
|
| 2350 | + $recipientList[$recipientType][] = (int) $recipient; |
|
| 2351 | + } |
|
| 2263 | 2352 | } |
| 2264 | 2353 | |
| 2265 | 2354 | // Are there also literal names set? |
@@ -2273,10 +2362,11 @@ discard block |
||
| 2273 | 2362 | |
| 2274 | 2363 | foreach ($namedRecipientList[$recipientType] as $index => $recipient) |
| 2275 | 2364 | { |
| 2276 | - if (strlen(trim($recipient)) > 0) |
|
| 2277 | - $namedRecipientList[$recipientType][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($recipient))); |
|
| 2278 | - else |
|
| 2279 | - unset($namedRecipientList[$recipientType][$index]); |
|
| 2365 | + if (strlen(trim($recipient)) > 0) { |
|
| 2366 | + $namedRecipientList[$recipientType][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($recipient))); |
|
| 2367 | + } else { |
|
| 2368 | + unset($namedRecipientList[$recipientType][$index]); |
|
| 2369 | + } |
|
| 2280 | 2370 | } |
| 2281 | 2371 | |
| 2282 | 2372 | if (!empty($namedRecipientList[$recipientType])) |
@@ -2306,8 +2396,9 @@ discard block |
||
| 2306 | 2396 | } |
| 2307 | 2397 | |
| 2308 | 2398 | // Selected a recipient to be deleted? Remove them now. |
| 2309 | - if (!empty($_POST['delete_recipient'])) |
|
| 2310 | - $recipientList[$recipientType] = array_diff($recipientList[$recipientType], array((int) $_POST['delete_recipient'])); |
|
| 2399 | + if (!empty($_POST['delete_recipient'])) { |
|
| 2400 | + $recipientList[$recipientType] = array_diff($recipientList[$recipientType], array((int) $_POST['delete_recipient'])); |
|
| 2401 | + } |
|
| 2311 | 2402 | |
| 2312 | 2403 | // Make sure we don't include the same name twice |
| 2313 | 2404 | $recipientList[$recipientType] = array_unique($recipientList[$recipientType]); |
@@ -2317,8 +2408,9 @@ discard block |
||
| 2317 | 2408 | $is_recipient_change = !empty($_POST['delete_recipient']) || !empty($_POST['to_submit']) || !empty($_POST['bcc_submit']); |
| 2318 | 2409 | |
| 2319 | 2410 | // Check if there's at least one recipient. |
| 2320 | - if (empty($recipientList['to']) && empty($recipientList['bcc'])) |
|
| 2321 | - $post_errors[] = 'no_to'; |
|
| 2411 | + if (empty($recipientList['to']) && empty($recipientList['bcc'])) { |
|
| 2412 | + $post_errors[] = 'no_to'; |
|
| 2413 | + } |
|
| 2322 | 2414 | |
| 2323 | 2415 | // Make sure that we remove the members who did get it from the screen. |
| 2324 | 2416 | if (!$is_recipient_change) |
@@ -2332,28 +2424,31 @@ discard block |
||
| 2332 | 2424 | // Since we already have a post error, remove the previous one. |
| 2333 | 2425 | $post_errors = array_diff($post_errors, array('no_to')); |
| 2334 | 2426 | |
| 2335 | - foreach ($namesNotFound[$recipientType] as $name) |
|
| 2336 | - $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
| 2427 | + foreach ($namesNotFound[$recipientType] as $name) { |
|
| 2428 | + $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
| 2429 | + } |
|
| 2337 | 2430 | } |
| 2338 | 2431 | } |
| 2339 | 2432 | } |
| 2340 | 2433 | |
| 2341 | 2434 | // Did they make any mistakes? |
| 2342 | - if ($_REQUEST['subject'] == '') |
|
| 2343 | - $post_errors[] = 'no_subject'; |
|
| 2344 | - if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') |
|
| 2345 | - $post_errors[] = 'no_message'; |
|
| 2346 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_REQUEST['message']) > $modSettings['max_messageLength']) |
|
| 2347 | - $post_errors[] = 'long_message'; |
|
| 2348 | - else |
|
| 2435 | + if ($_REQUEST['subject'] == '') { |
|
| 2436 | + $post_errors[] = 'no_subject'; |
|
| 2437 | + } |
|
| 2438 | + if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') { |
|
| 2439 | + $post_errors[] = 'no_message'; |
|
| 2440 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_REQUEST['message']) > $modSettings['max_messageLength']) { |
|
| 2441 | + $post_errors[] = 'long_message'; |
|
| 2442 | + } else |
|
| 2349 | 2443 | { |
| 2350 | 2444 | // Preparse the message. |
| 2351 | 2445 | $message = $_REQUEST['message']; |
| 2352 | 2446 | preparsecode($message); |
| 2353 | 2447 | |
| 2354 | 2448 | // Make sure there's still some content left without the tags. |
| 2355 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($smcFunc['htmlspecialchars']($message, ENT_QUOTES), false), '<img>')) === '' && (!allowedTo('admin_forum') || strpos($message, '[html]') === false)) |
|
| 2356 | - $post_errors[] = 'no_message'; |
|
| 2449 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($smcFunc['htmlspecialchars']($message, ENT_QUOTES), false), '<img>')) === '' && (!allowedTo('admin_forum') || strpos($message, '[html]') === false)) { |
|
| 2450 | + $post_errors[] = 'no_message'; |
|
| 2451 | + } |
|
| 2357 | 2452 | } |
| 2358 | 2453 | |
| 2359 | 2454 | // Wrong verification code? |
@@ -2365,13 +2460,15 @@ discard block |
||
| 2365 | 2460 | ); |
| 2366 | 2461 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
| 2367 | 2462 | |
| 2368 | - if (is_array($context['require_verification'])) |
|
| 2369 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 2463 | + if (is_array($context['require_verification'])) { |
|
| 2464 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 2465 | + } |
|
| 2370 | 2466 | } |
| 2371 | 2467 | |
| 2372 | 2468 | // If they did, give a chance to make ammends. |
| 2373 | - if (!empty($post_errors) && !$is_recipient_change && !isset($_REQUEST['preview']) && !isset($_REQUEST['xml'])) |
|
| 2374 | - return messagePostError($post_errors, $namedRecipientList, $recipientList); |
|
| 2469 | + if (!empty($post_errors) && !$is_recipient_change && !isset($_REQUEST['preview']) && !isset($_REQUEST['xml'])) { |
|
| 2470 | + return messagePostError($post_errors, $namedRecipientList, $recipientList); |
|
| 2471 | + } |
|
| 2375 | 2472 | |
| 2376 | 2473 | // Want to take a second glance before you send? |
| 2377 | 2474 | if (isset($_REQUEST['preview'])) |
@@ -2402,8 +2499,9 @@ discard block |
||
| 2402 | 2499 | foreach ($namesNotFound as $recipientType => $names) |
| 2403 | 2500 | { |
| 2404 | 2501 | $post_errors[] = 'bad_' . $recipientType; |
| 2405 | - foreach ($names as $name) |
|
| 2406 | - $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
| 2502 | + foreach ($names as $name) { |
|
| 2503 | + $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
| 2504 | + } |
|
| 2407 | 2505 | } |
| 2408 | 2506 | |
| 2409 | 2507 | return messagePostError(array(), $namedRecipientList, $recipientList); |
@@ -2433,13 +2531,14 @@ discard block |
||
| 2433 | 2531 | checkSubmitOnce('check'); |
| 2434 | 2532 | |
| 2435 | 2533 | // Do the actual sending of the PM. |
| 2436 | - if (!empty($recipientList['to']) || !empty($recipientList['bcc'])) |
|
| 2437 | - $context['send_log'] = sendpm($recipientList, $_REQUEST['subject'], $_REQUEST['message'], true, null, !empty($_REQUEST['pm_head']) ? (int) $_REQUEST['pm_head'] : 0); |
|
| 2438 | - else |
|
| 2439 | - $context['send_log'] = array( |
|
| 2534 | + if (!empty($recipientList['to']) || !empty($recipientList['bcc'])) { |
|
| 2535 | + $context['send_log'] = sendpm($recipientList, $_REQUEST['subject'], $_REQUEST['message'], true, null, !empty($_REQUEST['pm_head']) ? (int) $_REQUEST['pm_head'] : 0); |
|
| 2536 | + } else { |
|
| 2537 | + $context['send_log'] = array( |
|
| 2440 | 2538 | 'sent' => array(), |
| 2441 | 2539 | 'failed' => array() |
| 2442 | 2540 | ); |
| 2541 | + } |
|
| 2443 | 2542 | |
| 2444 | 2543 | // Mark the message as "replied to". |
| 2445 | 2544 | if (!empty($context['send_log']['sent']) && !empty($_REQUEST['replied_to']) && isset($_REQUEST['f']) && $_REQUEST['f'] == 'inbox') |
@@ -2457,11 +2556,12 @@ discard block |
||
| 2457 | 2556 | } |
| 2458 | 2557 | |
| 2459 | 2558 | // If one or more of the recipient were invalid, go back to the post screen with the failed usernames. |
| 2460 | - if (!empty($context['send_log']['failed'])) |
|
| 2461 | - return messagePostError($post_errors, $namesNotFound, array( |
|
| 2559 | + if (!empty($context['send_log']['failed'])) { |
|
| 2560 | + return messagePostError($post_errors, $namesNotFound, array( |
|
| 2462 | 2561 | 'to' => array_intersect($recipientList['to'], $context['send_log']['failed']), |
| 2463 | 2562 | 'bcc' => array_intersect($recipientList['bcc'], $context['send_log']['failed']) |
| 2464 | 2563 | )); |
| 2564 | + } |
|
| 2465 | 2565 | |
| 2466 | 2566 | // Message sent successfully? |
| 2467 | 2567 | if (!empty($context['send_log']) && empty($context['send_log']['failed'])) |
@@ -2469,8 +2569,9 @@ discard block |
||
| 2469 | 2569 | $context['current_label_redirect'] = $context['current_label_redirect'] . ';done=sent'; |
| 2470 | 2570 | |
| 2471 | 2571 | // If we had a PM draft for this one, then its time to remove it since it was just sent |
| 2472 | - if ($context['drafts_pm_save'] && !empty($_POST['id_pm_draft'])) |
|
| 2473 | - DeleteDraft($_POST['id_pm_draft']); |
|
| 2572 | + if ($context['drafts_pm_save'] && !empty($_POST['id_pm_draft'])) { |
|
| 2573 | + DeleteDraft($_POST['id_pm_draft']); |
|
| 2574 | + } |
|
| 2474 | 2575 | } |
| 2475 | 2576 | |
| 2476 | 2577 | // Go back to the where they sent from, if possible... |
@@ -2485,24 +2586,28 @@ discard block |
||
| 2485 | 2586 | |
| 2486 | 2587 | checkSession('request'); |
| 2487 | 2588 | |
| 2488 | - if (isset($_REQUEST['del_selected'])) |
|
| 2489 | - $_REQUEST['pm_action'] = 'delete'; |
|
| 2589 | + if (isset($_REQUEST['del_selected'])) { |
|
| 2590 | + $_REQUEST['pm_action'] = 'delete'; |
|
| 2591 | + } |
|
| 2490 | 2592 | |
| 2491 | 2593 | if (isset($_REQUEST['pm_action']) && $_REQUEST['pm_action'] != '' && !empty($_REQUEST['pms']) && is_array($_REQUEST['pms'])) |
| 2492 | 2594 | { |
| 2493 | - foreach ($_REQUEST['pms'] as $pm) |
|
| 2494 | - $_REQUEST['pm_actions'][(int) $pm] = $_REQUEST['pm_action']; |
|
| 2595 | + foreach ($_REQUEST['pms'] as $pm) { |
|
| 2596 | + $_REQUEST['pm_actions'][(int) $pm] = $_REQUEST['pm_action']; |
|
| 2597 | + } |
|
| 2495 | 2598 | } |
| 2496 | 2599 | |
| 2497 | - if (empty($_REQUEST['pm_actions'])) |
|
| 2498 | - redirectexit($context['current_label_redirect']); |
|
| 2600 | + if (empty($_REQUEST['pm_actions'])) { |
|
| 2601 | + redirectexit($context['current_label_redirect']); |
|
| 2602 | + } |
|
| 2499 | 2603 | |
| 2500 | 2604 | // If we are in conversation, we may need to apply this to every message in the conversation. |
| 2501 | 2605 | if ($context['display_mode'] == 2 && isset($_REQUEST['conversation'])) |
| 2502 | 2606 | { |
| 2503 | 2607 | $id_pms = array(); |
| 2504 | - foreach ($_REQUEST['pm_actions'] as $pm => $dummy) |
|
| 2505 | - $id_pms[] = (int) $pm; |
|
| 2608 | + foreach ($_REQUEST['pm_actions'] as $pm => $dummy) { |
|
| 2609 | + $id_pms[] = (int) $pm; |
|
| 2610 | + } |
|
| 2506 | 2611 | |
| 2507 | 2612 | $request = $smcFunc['db_query']('', ' |
| 2508 | 2613 | SELECT id_pm_head, id_pm |
@@ -2513,8 +2618,9 @@ discard block |
||
| 2513 | 2618 | ) |
| 2514 | 2619 | ); |
| 2515 | 2620 | $pm_heads = array(); |
| 2516 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2517 | - $pm_heads[$row['id_pm_head']] = $row['id_pm']; |
|
| 2621 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2622 | + $pm_heads[$row['id_pm_head']] = $row['id_pm']; |
|
| 2623 | + } |
|
| 2518 | 2624 | $smcFunc['db_free_result']($request); |
| 2519 | 2625 | |
| 2520 | 2626 | $request = $smcFunc['db_query']('', ' |
@@ -2528,8 +2634,9 @@ discard block |
||
| 2528 | 2634 | // Copy the action from the single to PM to the others. |
| 2529 | 2635 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2530 | 2636 | { |
| 2531 | - if (isset($pm_heads[$row['id_pm_head']]) && isset($_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]])) |
|
| 2532 | - $_REQUEST['pm_actions'][$row['id_pm']] = $_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]]; |
|
| 2637 | + if (isset($pm_heads[$row['id_pm_head']]) && isset($_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]])) { |
|
| 2638 | + $_REQUEST['pm_actions'][$row['id_pm']] = $_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]]; |
|
| 2639 | + } |
|
| 2533 | 2640 | } |
| 2534 | 2641 | $smcFunc['db_free_result']($request); |
| 2535 | 2642 | } |
@@ -2540,22 +2647,21 @@ discard block |
||
| 2540 | 2647 | $labels = array(); |
| 2541 | 2648 | foreach ($_REQUEST['pm_actions'] as $pm => $action) |
| 2542 | 2649 | { |
| 2543 | - if ($action === 'delete') |
|
| 2544 | - $to_delete[] = (int) $pm; |
|
| 2545 | - else |
|
| 2650 | + if ($action === 'delete') { |
|
| 2651 | + $to_delete[] = (int) $pm; |
|
| 2652 | + } else |
|
| 2546 | 2653 | { |
| 2547 | 2654 | if (substr($action, 0, 4) == 'add_') |
| 2548 | 2655 | { |
| 2549 | 2656 | $type = 'add'; |
| 2550 | 2657 | $action = substr($action, 4); |
| 2551 | - } |
|
| 2552 | - elseif (substr($action, 0, 4) == 'rem_') |
|
| 2658 | + } elseif (substr($action, 0, 4) == 'rem_') |
|
| 2553 | 2659 | { |
| 2554 | 2660 | $type = 'rem'; |
| 2555 | 2661 | $action = substr($action, 4); |
| 2662 | + } else { |
|
| 2663 | + $type = 'unk'; |
|
| 2556 | 2664 | } |
| 2557 | - else |
|
| 2558 | - $type = 'unk'; |
|
| 2559 | 2665 | |
| 2560 | 2666 | if ($action == '-1' || (int) $action > 0) |
| 2561 | 2667 | { |
@@ -2566,8 +2672,9 @@ discard block |
||
| 2566 | 2672 | } |
| 2567 | 2673 | |
| 2568 | 2674 | // Deleting, it looks like? |
| 2569 | - if (!empty($to_delete)) |
|
| 2570 | - deleteMessages($to_delete, $context['display_mode'] == 2 ? null : $context['folder']); |
|
| 2675 | + if (!empty($to_delete)) { |
|
| 2676 | + deleteMessages($to_delete, $context['display_mode'] == 2 ? null : $context['folder']); |
|
| 2677 | + } |
|
| 2571 | 2678 | |
| 2572 | 2679 | // Are we labeling anything? |
| 2573 | 2680 | if (!empty($to_label) && $context['folder'] == 'inbox') |
@@ -2633,8 +2740,7 @@ discard block |
||
| 2633 | 2740 | } |
| 2634 | 2741 | |
| 2635 | 2742 | $smcFunc['db_free_result']($request2); |
| 2636 | - } |
|
| 2637 | - elseif ($type == 'rem') |
|
| 2743 | + } elseif ($type == 'rem') |
|
| 2638 | 2744 | { |
| 2639 | 2745 | // If we're removing from the inbox, see if we have at least one other label. |
| 2640 | 2746 | // This query is faster than the one above |
@@ -2666,21 +2772,25 @@ discard block |
||
| 2666 | 2772 | if ($to_label[$row['id_pm']] != '-1') |
| 2667 | 2773 | { |
| 2668 | 2774 | // If this label is in the list and we're not adding it, remove it |
| 2669 | - if (array_key_exists($to_label[$row['id_pm']], $labels) && $type !== 'add') |
|
| 2670 | - unset($labels[$to_label[$row['id_pm']]]); |
|
| 2671 | - else if ($type !== 'rem') |
|
| 2672 | - $labels[$to_label[$row['id_pm']]] = $to_label[$row['id_pm']]; |
|
| 2775 | + if (array_key_exists($to_label[$row['id_pm']], $labels) && $type !== 'add') { |
|
| 2776 | + unset($labels[$to_label[$row['id_pm']]]); |
|
| 2777 | + } else if ($type !== 'rem') { |
|
| 2778 | + $labels[$to_label[$row['id_pm']]] = $to_label[$row['id_pm']]; |
|
| 2779 | + } |
|
| 2673 | 2780 | } |
| 2674 | 2781 | |
| 2675 | 2782 | // Removing all labels or just removing the inbox label |
| 2676 | - if ($type == 'rem' && empty($labels)) |
|
| 2677 | - $in_inbox = (empty($context['can_remove_inbox']) ? 1 : 0); |
|
| 2783 | + if ($type == 'rem' && empty($labels)) { |
|
| 2784 | + $in_inbox = (empty($context['can_remove_inbox']) ? 1 : 0); |
|
| 2785 | + } |
|
| 2678 | 2786 | // Adding new labels, but removing inbox and applying new ones |
| 2679 | - elseif ($type == 'add' && !empty($options['pm_remove_inbox_label']) && !empty($labels)) |
|
| 2680 | - $in_inbox = 0; |
|
| 2787 | + elseif ($type == 'add' && !empty($options['pm_remove_inbox_label']) && !empty($labels)) { |
|
| 2788 | + $in_inbox = 0; |
|
| 2789 | + } |
|
| 2681 | 2790 | // Just adding it to the inbox |
| 2682 | - else |
|
| 2683 | - $in_inbox = 1; |
|
| 2791 | + else { |
|
| 2792 | + $in_inbox = 1; |
|
| 2793 | + } |
|
| 2684 | 2794 | |
| 2685 | 2795 | // Are we adding it to or removing it from the inbox? |
| 2686 | 2796 | if ($in_inbox != $row['in_inbox']) |
@@ -2722,8 +2832,9 @@ discard block |
||
| 2722 | 2832 | if (!empty($labels_to_apply)) |
| 2723 | 2833 | { |
| 2724 | 2834 | $inserts = array(); |
| 2725 | - foreach ($labels_to_apply as $label) |
|
| 2726 | - $inserts[] = array($row['id_pm'], $label); |
|
| 2835 | + foreach ($labels_to_apply as $label) { |
|
| 2836 | + $inserts[] = array($row['id_pm'], $label); |
|
| 2837 | + } |
|
| 2727 | 2838 | |
| 2728 | 2839 | $smcFunc['db_insert']('', |
| 2729 | 2840 | '{db_prefix}pm_labeled_messages', |
@@ -2767,11 +2878,13 @@ discard block |
||
| 2767 | 2878 | checkSession('get'); |
| 2768 | 2879 | |
| 2769 | 2880 | // If all then delete all messages the user has. |
| 2770 | - if ($_REQUEST['f'] == 'all') |
|
| 2771 | - deleteMessages(null, null); |
|
| 2881 | + if ($_REQUEST['f'] == 'all') { |
|
| 2882 | + deleteMessages(null, null); |
|
| 2883 | + } |
|
| 2772 | 2884 | // Otherwise just the selected folder. |
| 2773 | - else |
|
| 2774 | - deleteMessages(null, $_REQUEST['f'] != 'sent' ? 'inbox' : 'sent'); |
|
| 2885 | + else { |
|
| 2886 | + deleteMessages(null, $_REQUEST['f'] != 'sent' ? 'inbox' : 'sent'); |
|
| 2887 | + } |
|
| 2775 | 2888 | |
| 2776 | 2889 | // Done... all gone. |
| 2777 | 2890 | redirectexit($context['current_label_redirect']); |
@@ -2808,8 +2921,9 @@ discard block |
||
| 2808 | 2921 | 'msgtime' => $deleteTime, |
| 2809 | 2922 | ) |
| 2810 | 2923 | ); |
| 2811 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 2812 | - $toDelete[] = $row[0]; |
|
| 2924 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 2925 | + $toDelete[] = $row[0]; |
|
| 2926 | + } |
|
| 2813 | 2927 | $smcFunc['db_free_result']($request); |
| 2814 | 2928 | |
| 2815 | 2929 | // Select all messages in their inbox older than $deleteTime. |
@@ -2826,8 +2940,9 @@ discard block |
||
| 2826 | 2940 | 'msgtime' => $deleteTime, |
| 2827 | 2941 | ) |
| 2828 | 2942 | ); |
| 2829 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2830 | - $toDelete[] = $row['id_pm']; |
|
| 2943 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2944 | + $toDelete[] = $row['id_pm']; |
|
| 2945 | + } |
|
| 2831 | 2946 | $smcFunc['db_free_result']($request); |
| 2832 | 2947 | |
| 2833 | 2948 | // Delete the actual messages. |
@@ -2858,26 +2973,29 @@ discard block |
||
| 2858 | 2973 | { |
| 2859 | 2974 | global $user_info, $smcFunc; |
| 2860 | 2975 | |
| 2861 | - if ($owner === null) |
|
| 2862 | - $owner = array($user_info['id']); |
|
| 2863 | - elseif (empty($owner)) |
|
| 2864 | - return; |
|
| 2865 | - elseif (!is_array($owner)) |
|
| 2866 | - $owner = array($owner); |
|
| 2976 | + if ($owner === null) { |
|
| 2977 | + $owner = array($user_info['id']); |
|
| 2978 | + } elseif (empty($owner)) { |
|
| 2979 | + return; |
|
| 2980 | + } elseif (!is_array($owner)) { |
|
| 2981 | + $owner = array($owner); |
|
| 2982 | + } |
|
| 2867 | 2983 | |
| 2868 | 2984 | if ($personal_messages !== null) |
| 2869 | 2985 | { |
| 2870 | - if (empty($personal_messages) || !is_array($personal_messages)) |
|
| 2871 | - return; |
|
| 2986 | + if (empty($personal_messages) || !is_array($personal_messages)) { |
|
| 2987 | + return; |
|
| 2988 | + } |
|
| 2872 | 2989 | |
| 2873 | - foreach ($personal_messages as $index => $delete_id) |
|
| 2874 | - $personal_messages[$index] = (int) $delete_id; |
|
| 2990 | + foreach ($personal_messages as $index => $delete_id) { |
|
| 2991 | + $personal_messages[$index] = (int) $delete_id; |
|
| 2992 | + } |
|
| 2875 | 2993 | |
| 2876 | 2994 | $where = ' |
| 2877 | 2995 | AND id_pm IN ({array_int:pm_list})'; |
| 2996 | + } else { |
|
| 2997 | + $where = ''; |
|
| 2878 | 2998 | } |
| 2879 | - else |
|
| 2880 | - $where = ''; |
|
| 2881 | 2999 | |
| 2882 | 3000 | if ($folder == 'sent' || $folder === null) |
| 2883 | 3001 | { |
@@ -2912,17 +3030,19 @@ discard block |
||
| 2912 | 3030 | // ...And update the statistics accordingly - now including unread messages!. |
| 2913 | 3031 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2914 | 3032 | { |
| 2915 | - if ($row['is_read']) |
|
| 2916 | - updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'])); |
|
| 2917 | - else |
|
| 2918 | - updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'], 'unread_messages' => $where == '' ? 0 : 'unread_messages - ' . $row['num_deleted_messages'])); |
|
| 3033 | + if ($row['is_read']) { |
|
| 3034 | + updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'])); |
|
| 3035 | + } else { |
|
| 3036 | + updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'], 'unread_messages' => $where == '' ? 0 : 'unread_messages - ' . $row['num_deleted_messages'])); |
|
| 3037 | + } |
|
| 2919 | 3038 | |
| 2920 | 3039 | // If this is the current member we need to make their message count correct. |
| 2921 | 3040 | if ($user_info['id'] == $row['id_member']) |
| 2922 | 3041 | { |
| 2923 | 3042 | $user_info['messages'] -= $row['num_deleted_messages']; |
| 2924 | - if (!($row['is_read'])) |
|
| 2925 | - $user_info['unread_messages'] -= $row['num_deleted_messages']; |
|
| 3043 | + if (!($row['is_read'])) { |
|
| 3044 | + $user_info['unread_messages'] -= $row['num_deleted_messages']; |
|
| 3045 | + } |
|
| 2926 | 3046 | } |
| 2927 | 3047 | } |
| 2928 | 3048 | $smcFunc['db_free_result']($request); |
@@ -2990,8 +3110,9 @@ discard block |
||
| 2990 | 3110 | ) |
| 2991 | 3111 | ); |
| 2992 | 3112 | $remove_pms = array(); |
| 2993 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2994 | - $remove_pms[] = $row['sender']; |
|
| 3113 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3114 | + $remove_pms[] = $row['sender']; |
|
| 3115 | + } |
|
| 2995 | 3116 | $smcFunc['db_free_result']($request); |
| 2996 | 3117 | |
| 2997 | 3118 | if (!empty($remove_pms)) |
@@ -3036,8 +3157,9 @@ discard block |
||
| 3036 | 3157 | { |
| 3037 | 3158 | global $user_info, $context, $smcFunc; |
| 3038 | 3159 | |
| 3039 | - if ($owner === null) |
|
| 3040 | - $owner = $user_info['id']; |
|
| 3160 | + if ($owner === null) { |
|
| 3161 | + $owner = $user_info['id']; |
|
| 3162 | + } |
|
| 3041 | 3163 | |
| 3042 | 3164 | $in_inbox = ''; |
| 3043 | 3165 | |
@@ -3061,8 +3183,7 @@ discard block |
||
| 3061 | 3183 | } |
| 3062 | 3184 | |
| 3063 | 3185 | $smcFunc['db_free_result']($get_messages); |
| 3064 | - } |
|
| 3065 | - elseif ($label = '-1') |
|
| 3186 | + } elseif ($label = '-1') |
|
| 3066 | 3187 | { |
| 3067 | 3188 | // Marking all PMs in your inbox read |
| 3068 | 3189 | $in_inbox = ' |
@@ -3087,8 +3208,9 @@ discard block |
||
| 3087 | 3208 | { |
| 3088 | 3209 | if ($owner == $user_info['id']) |
| 3089 | 3210 | { |
| 3090 | - foreach ($context['labels'] as $label) |
|
| 3091 | - $context['labels'][(int) $label['id']]['unread_messages'] = 0; |
|
| 3211 | + foreach ($context['labels'] as $label) { |
|
| 3212 | + $context['labels'][(int) $label['id']]['unread_messages'] = 0; |
|
| 3213 | + } |
|
| 3092 | 3214 | } |
| 3093 | 3215 | |
| 3094 | 3216 | $result = $smcFunc['db_query']('', ' |
@@ -3108,8 +3230,9 @@ discard block |
||
| 3108 | 3230 | { |
| 3109 | 3231 | $total_unread += $row['num']; |
| 3110 | 3232 | |
| 3111 | - if ($owner != $user_info['id'] || empty($row['id_pm'])) |
|
| 3112 | - continue; |
|
| 3233 | + if ($owner != $user_info['id'] || empty($row['id_pm'])) { |
|
| 3234 | + continue; |
|
| 3235 | + } |
|
| 3113 | 3236 | |
| 3114 | 3237 | $this_labels = array(); |
| 3115 | 3238 | |
@@ -3133,11 +3256,13 @@ discard block |
||
| 3133 | 3256 | |
| 3134 | 3257 | $smcFunc['db_free_result']($result2); |
| 3135 | 3258 | |
| 3136 | - foreach ($this_labels as $this_label) |
|
| 3137 | - $context['labels'][$this_label]['unread_messages'] += $row['num']; |
|
| 3259 | + foreach ($this_labels as $this_label) { |
|
| 3260 | + $context['labels'][$this_label]['unread_messages'] += $row['num']; |
|
| 3261 | + } |
|
| 3138 | 3262 | |
| 3139 | - if ($row['in_inbox'] == 1) |
|
| 3140 | - $context['labels'][-1]['unread_messages'] += $row['num']; |
|
| 3263 | + if ($row['in_inbox'] == 1) { |
|
| 3264 | + $context['labels'][-1]['unread_messages'] += $row['num']; |
|
| 3265 | + } |
|
| 3141 | 3266 | } |
| 3142 | 3267 | $smcFunc['db_free_result']($result); |
| 3143 | 3268 | |
@@ -3146,8 +3271,9 @@ discard block |
||
| 3146 | 3271 | updateMemberData($owner, array('unread_messages' => $total_unread)); |
| 3147 | 3272 | |
| 3148 | 3273 | // If it was for the current member, reflect this in the $user_info array too. |
| 3149 | - if ($owner == $user_info['id']) |
|
| 3150 | - $user_info['unread_messages'] = $total_unread; |
|
| 3274 | + if ($owner == $user_info['id']) { |
|
| 3275 | + $user_info['unread_messages'] = $total_unread; |
|
| 3276 | + } |
|
| 3151 | 3277 | } |
| 3152 | 3278 | } |
| 3153 | 3279 | |
@@ -3175,8 +3301,9 @@ discard block |
||
| 3175 | 3301 | // Add all existing labels to the array to save, slashing them as necessary... |
| 3176 | 3302 | foreach ($context['labels'] as $label) |
| 3177 | 3303 | { |
| 3178 | - if ($label['id'] != -1) |
|
| 3179 | - $the_labels[$label['id']] = $label['name']; |
|
| 3304 | + if ($label['id'] != -1) { |
|
| 3305 | + $the_labels[$label['id']] = $label['name']; |
|
| 3306 | + } |
|
| 3180 | 3307 | } |
| 3181 | 3308 | |
| 3182 | 3309 | if (isset($_POST[$context['session_var']])) |
@@ -3195,8 +3322,9 @@ discard block |
||
| 3195 | 3322 | { |
| 3196 | 3323 | $_POST['label'] = strtr($smcFunc['htmlspecialchars'](trim($_POST['label'])), array(',' => ',')); |
| 3197 | 3324 | |
| 3198 | - if ($smcFunc['strlen']($_POST['label']) > 30) |
|
| 3199 | - $_POST['label'] = $smcFunc['substr']($_POST['label'], 0, 30); |
|
| 3325 | + if ($smcFunc['strlen']($_POST['label']) > 30) { |
|
| 3326 | + $_POST['label'] = $smcFunc['substr']($_POST['label'], 0, 30); |
|
| 3327 | + } |
|
| 3200 | 3328 | if ($_POST['label'] != '') |
| 3201 | 3329 | { |
| 3202 | 3330 | $the_labels[] = $_POST['label']; |
@@ -3217,24 +3345,25 @@ discard block |
||
| 3217 | 3345 | { |
| 3218 | 3346 | foreach ($the_labels as $id => $name) |
| 3219 | 3347 | { |
| 3220 | - if ($id == -1) |
|
| 3221 | - continue; |
|
| 3222 | - elseif (isset($_POST['label_name'][$id])) |
|
| 3348 | + if ($id == -1) { |
|
| 3349 | + continue; |
|
| 3350 | + } elseif (isset($_POST['label_name'][$id])) |
|
| 3223 | 3351 | { |
| 3224 | 3352 | $_POST['label_name'][$id] = trim(strtr($smcFunc['htmlspecialchars']($_POST['label_name'][$id]), array(',' => ','))); |
| 3225 | 3353 | |
| 3226 | - if ($smcFunc['strlen']($_POST['label_name'][$id]) > 30) |
|
| 3227 | - $_POST['label_name'][$id] = $smcFunc['substr']($_POST['label_name'][$id], 0, 30); |
|
| 3354 | + if ($smcFunc['strlen']($_POST['label_name'][$id]) > 30) { |
|
| 3355 | + $_POST['label_name'][$id] = $smcFunc['substr']($_POST['label_name'][$id], 0, 30); |
|
| 3356 | + } |
|
| 3228 | 3357 | if ($_POST['label_name'][$id] != '') |
| 3229 | 3358 | { |
| 3230 | 3359 | // Changing the name of this label? |
| 3231 | - if ($the_labels[$id] != $_POST['label_name'][$id]) |
|
| 3232 | - $label_updates[$id] = $_POST['label_name'][$id]; |
|
| 3360 | + if ($the_labels[$id] != $_POST['label_name'][$id]) { |
|
| 3361 | + $label_updates[$id] = $_POST['label_name'][$id]; |
|
| 3362 | + } |
|
| 3233 | 3363 | |
| 3234 | 3364 | $the_labels[(int) $id] = $_POST['label_name'][$id]; |
| 3235 | 3365 | |
| 3236 | - } |
|
| 3237 | - else |
|
| 3366 | + } else |
|
| 3238 | 3367 | { |
| 3239 | 3368 | unset($the_labels[(int) $id]); |
| 3240 | 3369 | $labels_to_remove[] = $id; |
@@ -3248,8 +3377,9 @@ discard block |
||
| 3248 | 3377 | if (!empty($labels_to_add)) |
| 3249 | 3378 | { |
| 3250 | 3379 | $inserts = array(); |
| 3251 | - foreach ($labels_to_add AS $label) |
|
| 3252 | - $inserts[] = array($user_info['id'], $label); |
|
| 3380 | + foreach ($labels_to_add AS $label) { |
|
| 3381 | + $inserts[] = array($user_info['id'], $label); |
|
| 3382 | + } |
|
| 3253 | 3383 | |
| 3254 | 3384 | $smcFunc['db_insert']('', '{db_prefix}pm_labels', array('id_member' => 'int', 'name' => 'string-30'), $inserts, array()); |
| 3255 | 3385 | } |
@@ -3339,8 +3469,9 @@ discard block |
||
| 3339 | 3469 | // Each action... |
| 3340 | 3470 | foreach ($rule['actions'] as $k2 => $action) |
| 3341 | 3471 | { |
| 3342 | - if ($action['t'] != 'lab' || !in_array($action['v'], $labels_to_remove)) |
|
| 3343 | - continue; |
|
| 3472 | + if ($action['t'] != 'lab' || !in_array($action['v'], $labels_to_remove)) { |
|
| 3473 | + continue; |
|
| 3474 | + } |
|
| 3344 | 3475 | |
| 3345 | 3476 | $rule_changes[] = $rule['id']; |
| 3346 | 3477 | |
@@ -3355,8 +3486,8 @@ discard block |
||
| 3355 | 3486 | { |
| 3356 | 3487 | $rule_changes = array_unique($rule_changes); |
| 3357 | 3488 | // Update/delete as appropriate. |
| 3358 | - foreach ($rule_changes as $k => $id) |
|
| 3359 | - if (!empty($context['rules'][$id]['actions'])) |
|
| 3489 | + foreach ($rule_changes as $k => $id) { |
|
| 3490 | + if (!empty($context['rules'][$id]['actions'])) |
|
| 3360 | 3491 | { |
| 3361 | 3492 | $smcFunc['db_query']('', ' |
| 3362 | 3493 | UPDATE {db_prefix}pm_rules |
@@ -3369,12 +3500,13 @@ discard block |
||
| 3369 | 3500 | 'actions' => $smcFunc['json_encode']($context['rules'][$id]['actions']), |
| 3370 | 3501 | ) |
| 3371 | 3502 | ); |
| 3503 | + } |
|
| 3372 | 3504 | unset($rule_changes[$k]); |
| 3373 | 3505 | } |
| 3374 | 3506 | |
| 3375 | 3507 | // Anything left here means it's lost all actions... |
| 3376 | - if (!empty($rule_changes)) |
|
| 3377 | - $smcFunc['db_query']('', ' |
|
| 3508 | + if (!empty($rule_changes)) { |
|
| 3509 | + $smcFunc['db_query']('', ' |
|
| 3378 | 3510 | DELETE FROM {db_prefix}pm_rules |
| 3379 | 3511 | WHERE id_rule IN ({array_int:rule_list}) |
| 3380 | 3512 | AND id_member = {int:current_member}', |
@@ -3383,6 +3515,7 @@ discard block |
||
| 3383 | 3515 | 'rule_list' => $rule_changes, |
| 3384 | 3516 | ) |
| 3385 | 3517 | ); |
| 3518 | + } |
|
| 3386 | 3519 | } |
| 3387 | 3520 | |
| 3388 | 3521 | // Make sure we're not caching this! |
@@ -3452,8 +3585,9 @@ discard block |
||
| 3452 | 3585 | // Save the fields. |
| 3453 | 3586 | saveProfileFields(); |
| 3454 | 3587 | |
| 3455 | - if (!empty($profile_vars)) |
|
| 3456 | - updateMemberData($user_info['id'], $profile_vars); |
|
| 3588 | + if (!empty($profile_vars)) { |
|
| 3589 | + updateMemberData($user_info['id'], $profile_vars); |
|
| 3590 | + } |
|
| 3457 | 3591 | } |
| 3458 | 3592 | |
| 3459 | 3593 | setupProfileContext( |
@@ -3478,13 +3612,15 @@ discard block |
||
| 3478 | 3612 | global $user_info, $language, $modSettings, $smcFunc; |
| 3479 | 3613 | |
| 3480 | 3614 | // Check that this feature is even enabled! |
| 3481 | - if (empty($modSettings['enableReportPM']) || empty($_REQUEST['pmsg'])) |
|
| 3482 | - fatal_lang_error('no_access', false); |
|
| 3615 | + if (empty($modSettings['enableReportPM']) || empty($_REQUEST['pmsg'])) { |
|
| 3616 | + fatal_lang_error('no_access', false); |
|
| 3617 | + } |
|
| 3483 | 3618 | |
| 3484 | 3619 | $pmsg = (int) $_REQUEST['pmsg']; |
| 3485 | 3620 | |
| 3486 | - if (!isAccessiblePM($pmsg, 'inbox')) |
|
| 3487 | - fatal_lang_error('no_access', false); |
|
| 3621 | + if (!isAccessiblePM($pmsg, 'inbox')) { |
|
| 3622 | + fatal_lang_error('no_access', false); |
|
| 3623 | + } |
|
| 3488 | 3624 | |
| 3489 | 3625 | $context['pm_id'] = $pmsg; |
| 3490 | 3626 | $context['page_title'] = $txt['pm_report_title']; |
@@ -3506,8 +3642,9 @@ discard block |
||
| 3506 | 3642 | ) |
| 3507 | 3643 | ); |
| 3508 | 3644 | $context['admins'] = array(); |
| 3509 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3510 | - $context['admins'][$row['id_member']] = $row['real_name']; |
|
| 3645 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3646 | + $context['admins'][$row['id_member']] = $row['real_name']; |
|
| 3647 | + } |
|
| 3511 | 3648 | $smcFunc['db_free_result']($request); |
| 3512 | 3649 | |
| 3513 | 3650 | // How many admins in total? |
@@ -3536,8 +3673,9 @@ discard block |
||
| 3536 | 3673 | ) |
| 3537 | 3674 | ); |
| 3538 | 3675 | // Can only be a hacker here! |
| 3539 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 3540 | - fatal_lang_error('no_access', false); |
|
| 3676 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 3677 | + fatal_lang_error('no_access', false); |
|
| 3678 | + } |
|
| 3541 | 3679 | list ($subject, $body, $time, $memberFromID, $memberFromName) = $smcFunc['db_fetch_row']($request); |
| 3542 | 3680 | $smcFunc['db_free_result']($request); |
| 3543 | 3681 | |
@@ -3561,15 +3699,17 @@ discard block |
||
| 3561 | 3699 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3562 | 3700 | { |
| 3563 | 3701 | // If it's hidden still don't reveal their names - privacy after all ;) |
| 3564 | - if ($row['bcc']) |
|
| 3565 | - $hidden_recipients++; |
|
| 3566 | - else |
|
| 3567 | - $recipients[] = '[url=' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . ']' . $row['to_name'] . '[/url]'; |
|
| 3702 | + if ($row['bcc']) { |
|
| 3703 | + $hidden_recipients++; |
|
| 3704 | + } else { |
|
| 3705 | + $recipients[] = '[url=' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . ']' . $row['to_name'] . '[/url]'; |
|
| 3706 | + } |
|
| 3568 | 3707 | } |
| 3569 | 3708 | $smcFunc['db_free_result']($request); |
| 3570 | 3709 | |
| 3571 | - if ($hidden_recipients) |
|
| 3572 | - $recipients[] = sprintf($txt['pm_report_pm_hidden'], $hidden_recipients); |
|
| 3710 | + if ($hidden_recipients) { |
|
| 3711 | + $recipients[] = sprintf($txt['pm_report_pm_hidden'], $hidden_recipients); |
|
| 3712 | + } |
|
| 3573 | 3713 | |
| 3574 | 3714 | // Now let's get out and loop through the admins. |
| 3575 | 3715 | $request = $smcFunc['db_query']('', ' |
@@ -3585,8 +3725,9 @@ discard block |
||
| 3585 | 3725 | ); |
| 3586 | 3726 | |
| 3587 | 3727 | // Maybe we shouldn't advertise this? |
| 3588 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 3589 | - fatal_lang_error('no_access', false); |
|
| 3728 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 3729 | + fatal_lang_error('no_access', false); |
|
| 3730 | + } |
|
| 3590 | 3731 | |
| 3591 | 3732 | $memberFromName = un_htmlspecialchars($memberFromName); |
| 3592 | 3733 | |
@@ -3605,8 +3746,9 @@ discard block |
||
| 3605 | 3746 | // Make the body. |
| 3606 | 3747 | $report_body = str_replace(array('{REPORTER}', '{SENDER}'), array(un_htmlspecialchars($user_info['name']), $memberFromName), $txt['pm_report_pm_user_sent']); |
| 3607 | 3748 | $report_body .= "\n" . '[b]' . $_POST['reason'] . '[/b]' . "\n\n"; |
| 3608 | - if (!empty($recipients)) |
|
| 3609 | - $report_body .= $txt['pm_report_pm_other_recipients'] . ' ' . implode(', ', $recipients) . "\n\n"; |
|
| 3749 | + if (!empty($recipients)) { |
|
| 3750 | + $report_body .= $txt['pm_report_pm_other_recipients'] . ' ' . implode(', ', $recipients) . "\n\n"; |
|
| 3751 | + } |
|
| 3610 | 3752 | $report_body .= $txt['pm_report_pm_unedited_below'] . "\n" . '[quote author=' . (empty($memberFromID) ? '"' . $memberFromName . '"' : $memberFromName . ' link=action=profile;u=' . $memberFromID . ' date=' . $time) . ']' . "\n" . un_htmlspecialchars($body) . '[/quote]'; |
| 3611 | 3753 | |
| 3612 | 3754 | // Plonk it in the array ;) |
@@ -3626,12 +3768,14 @@ discard block |
||
| 3626 | 3768 | $smcFunc['db_free_result']($request); |
| 3627 | 3769 | |
| 3628 | 3770 | // Send a different email for each language. |
| 3629 | - foreach ($messagesToSend as $lang => $message) |
|
| 3630 | - sendpm($message['recipients'], $message['subject'], $message['body']); |
|
| 3771 | + foreach ($messagesToSend as $lang => $message) { |
|
| 3772 | + sendpm($message['recipients'], $message['subject'], $message['body']); |
|
| 3773 | + } |
|
| 3631 | 3774 | |
| 3632 | 3775 | // Give the user their own language back! |
| 3633 | - if (!empty($modSettings['userLanguage'])) |
|
| 3634 | - loadLanguage('PersonalMessage', '', false); |
|
| 3776 | + if (!empty($modSettings['userLanguage'])) { |
|
| 3777 | + loadLanguage('PersonalMessage', '', false); |
|
| 3778 | + } |
|
| 3635 | 3779 | |
| 3636 | 3780 | // Leave them with a template. |
| 3637 | 3781 | $context['sub_template'] = 'report_message_complete'; |
@@ -3677,8 +3821,9 @@ discard block |
||
| 3677 | 3821 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3678 | 3822 | { |
| 3679 | 3823 | // Hide hidden groups! |
| 3680 | - if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) |
|
| 3681 | - continue; |
|
| 3824 | + if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) { |
|
| 3825 | + continue; |
|
| 3826 | + } |
|
| 3682 | 3827 | |
| 3683 | 3828 | $context['groups'][$row['id_group']] = $row['group_name']; |
| 3684 | 3829 | } |
@@ -3704,9 +3849,10 @@ discard block |
||
| 3704 | 3849 | $context['rule'] = $context['rules'][$context['rid']]; |
| 3705 | 3850 | $members = array(); |
| 3706 | 3851 | // Need to get member names! |
| 3707 | - foreach ($context['rule']['criteria'] as $k => $criteria) |
|
| 3708 | - if ($criteria['t'] == 'mid' && !empty($criteria['v'])) |
|
| 3852 | + foreach ($context['rule']['criteria'] as $k => $criteria) { |
|
| 3853 | + if ($criteria['t'] == 'mid' && !empty($criteria['v'])) |
|
| 3709 | 3854 | $members[(int) $criteria['v']] = $k; |
| 3855 | + } |
|
| 3710 | 3856 | |
| 3711 | 3857 | if (!empty($members)) |
| 3712 | 3858 | { |
@@ -3718,19 +3864,20 @@ discard block |
||
| 3718 | 3864 | 'member_list' => array_keys($members), |
| 3719 | 3865 | ) |
| 3720 | 3866 | ); |
| 3721 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3722 | - $context['rule']['criteria'][$members[$row['id_member']]]['v'] = $row['member_name']; |
|
| 3867 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3868 | + $context['rule']['criteria'][$members[$row['id_member']]]['v'] = $row['member_name']; |
|
| 3869 | + } |
|
| 3723 | 3870 | $smcFunc['db_free_result']($request); |
| 3724 | 3871 | } |
| 3725 | - } |
|
| 3726 | - else |
|
| 3727 | - $context['rule'] = array( |
|
| 3872 | + } else { |
|
| 3873 | + $context['rule'] = array( |
|
| 3728 | 3874 | 'id' => '', |
| 3729 | 3875 | 'name' => '', |
| 3730 | 3876 | 'criteria' => array(), |
| 3731 | 3877 | 'actions' => array(), |
| 3732 | 3878 | 'logic' => 'and', |
| 3733 | 3879 | ); |
| 3880 | + } |
|
| 3734 | 3881 | } |
| 3735 | 3882 | // Saving? |
| 3736 | 3883 | elseif (isset($_GET['save'])) |
@@ -3740,22 +3887,25 @@ discard block |
||
| 3740 | 3887 | |
| 3741 | 3888 | // Name is easy! |
| 3742 | 3889 | $ruleName = $smcFunc['htmlspecialchars'](trim($_POST['rule_name'])); |
| 3743 | - if (empty($ruleName)) |
|
| 3744 | - fatal_lang_error('pm_rule_no_name', false); |
|
| 3890 | + if (empty($ruleName)) { |
|
| 3891 | + fatal_lang_error('pm_rule_no_name', false); |
|
| 3892 | + } |
|
| 3745 | 3893 | |
| 3746 | 3894 | // Sanity check... |
| 3747 | - if (empty($_POST['ruletype']) || empty($_POST['acttype'])) |
|
| 3748 | - fatal_lang_error('pm_rule_no_criteria', false); |
|
| 3895 | + if (empty($_POST['ruletype']) || empty($_POST['acttype'])) { |
|
| 3896 | + fatal_lang_error('pm_rule_no_criteria', false); |
|
| 3897 | + } |
|
| 3749 | 3898 | |
| 3750 | 3899 | // Let's do the criteria first - it's also hardest! |
| 3751 | 3900 | $criteria = array(); |
| 3752 | 3901 | foreach ($_POST['ruletype'] as $ind => $type) |
| 3753 | 3902 | { |
| 3754 | 3903 | // Check everything is here... |
| 3755 | - if ($type == 'gid' && (!isset($_POST['ruledefgroup'][$ind]) || !isset($context['groups'][$_POST['ruledefgroup'][$ind]]))) |
|
| 3756 | - continue; |
|
| 3757 | - elseif ($type != 'bud' && !isset($_POST['ruledef'][$ind])) |
|
| 3758 | - continue; |
|
| 3904 | + if ($type == 'gid' && (!isset($_POST['ruledefgroup'][$ind]) || !isset($context['groups'][$_POST['ruledefgroup'][$ind]]))) { |
|
| 3905 | + continue; |
|
| 3906 | + } elseif ($type != 'bud' && !isset($_POST['ruledef'][$ind])) { |
|
| 3907 | + continue; |
|
| 3908 | + } |
|
| 3759 | 3909 | |
| 3760 | 3910 | // Members need to be found. |
| 3761 | 3911 | if ($type == 'mid') |
@@ -3779,13 +3929,13 @@ discard block |
||
| 3779 | 3929 | $smcFunc['db_free_result']($request); |
| 3780 | 3930 | |
| 3781 | 3931 | $criteria[] = array('t' => 'mid', 'v' => $memID); |
| 3932 | + } elseif ($type == 'bud') { |
|
| 3933 | + $criteria[] = array('t' => 'bud', 'v' => 1); |
|
| 3934 | + } elseif ($type == 'gid') { |
|
| 3935 | + $criteria[] = array('t' => 'gid', 'v' => (int) $_POST['ruledefgroup'][$ind]); |
|
| 3936 | + } elseif (in_array($type, array('sub', 'msg')) && trim($_POST['ruledef'][$ind]) != '') { |
|
| 3937 | + $criteria[] = array('t' => $type, 'v' => $smcFunc['htmlspecialchars'](trim($_POST['ruledef'][$ind]))); |
|
| 3782 | 3938 | } |
| 3783 | - elseif ($type == 'bud') |
|
| 3784 | - $criteria[] = array('t' => 'bud', 'v' => 1); |
|
| 3785 | - elseif ($type == 'gid') |
|
| 3786 | - $criteria[] = array('t' => 'gid', 'v' => (int) $_POST['ruledefgroup'][$ind]); |
|
| 3787 | - elseif (in_array($type, array('sub', 'msg')) && trim($_POST['ruledef'][$ind]) != '') |
|
| 3788 | - $criteria[] = array('t' => $type, 'v' => $smcFunc['htmlspecialchars'](trim($_POST['ruledef'][$ind]))); |
|
| 3789 | 3939 | } |
| 3790 | 3940 | |
| 3791 | 3941 | // Also do the actions! |
@@ -3795,26 +3945,29 @@ discard block |
||
| 3795 | 3945 | foreach ($_POST['acttype'] as $ind => $type) |
| 3796 | 3946 | { |
| 3797 | 3947 | // Picking a valid label? |
| 3798 | - if ($type == 'lab' && (!isset($_POST['labdef'][$ind]) || !isset($context['labels'][$_POST['labdef'][$ind]]))) |
|
| 3799 | - continue; |
|
| 3948 | + if ($type == 'lab' && (!isset($_POST['labdef'][$ind]) || !isset($context['labels'][$_POST['labdef'][$ind]]))) { |
|
| 3949 | + continue; |
|
| 3950 | + } |
|
| 3800 | 3951 | |
| 3801 | 3952 | // Record what we're doing. |
| 3802 | - if ($type == 'del') |
|
| 3803 | - $doDelete = 1; |
|
| 3804 | - elseif ($type == 'lab') |
|
| 3805 | - $actions[] = array('t' => 'lab', 'v' => (int) $_POST['labdef'][$ind]); |
|
| 3953 | + if ($type == 'del') { |
|
| 3954 | + $doDelete = 1; |
|
| 3955 | + } elseif ($type == 'lab') { |
|
| 3956 | + $actions[] = array('t' => 'lab', 'v' => (int) $_POST['labdef'][$ind]); |
|
| 3957 | + } |
|
| 3806 | 3958 | } |
| 3807 | 3959 | |
| 3808 | - if (empty($criteria) || (empty($actions) && !$doDelete)) |
|
| 3809 | - fatal_lang_error('pm_rule_no_criteria', false); |
|
| 3960 | + if (empty($criteria) || (empty($actions) && !$doDelete)) { |
|
| 3961 | + fatal_lang_error('pm_rule_no_criteria', false); |
|
| 3962 | + } |
|
| 3810 | 3963 | |
| 3811 | 3964 | // What are we storing? |
| 3812 | 3965 | $criteria = $smcFunc['json_encode']($criteria); |
| 3813 | 3966 | $actions = $smcFunc['json_encode']($actions); |
| 3814 | 3967 | |
| 3815 | 3968 | // Create the rule? |
| 3816 | - if (empty($context['rid'])) |
|
| 3817 | - $smcFunc['db_insert']('', |
|
| 3969 | + if (empty($context['rid'])) { |
|
| 3970 | + $smcFunc['db_insert']('', |
|
| 3818 | 3971 | '{db_prefix}pm_rules', |
| 3819 | 3972 | array( |
| 3820 | 3973 | 'id_member' => 'int', 'rule_name' => 'string', 'criteria' => 'string', 'actions' => 'string', |
@@ -3825,8 +3978,8 @@ discard block |
||
| 3825 | 3978 | ), |
| 3826 | 3979 | array('id_rule') |
| 3827 | 3980 | ); |
| 3828 | - else |
|
| 3829 | - $smcFunc['db_query']('', ' |
|
| 3981 | + } else { |
|
| 3982 | + $smcFunc['db_query']('', ' |
|
| 3830 | 3983 | UPDATE {db_prefix}pm_rules |
| 3831 | 3984 | SET rule_name = {string:rule_name}, criteria = {string:criteria}, actions = {string:actions}, |
| 3832 | 3985 | delete_pm = {int:delete_pm}, is_or = {int:is_or} |
@@ -3842,6 +3995,7 @@ discard block |
||
| 3842 | 3995 | 'actions' => $actions, |
| 3843 | 3996 | ) |
| 3844 | 3997 | ); |
| 3998 | + } |
|
| 3845 | 3999 | |
| 3846 | 4000 | redirectexit('action=pm;sa=manrules'); |
| 3847 | 4001 | } |
@@ -3850,11 +4004,12 @@ discard block |
||
| 3850 | 4004 | { |
| 3851 | 4005 | checkSession(); |
| 3852 | 4006 | $toDelete = array(); |
| 3853 | - foreach ($_POST['delrule'] as $k => $v) |
|
| 3854 | - $toDelete[] = (int) $k; |
|
| 4007 | + foreach ($_POST['delrule'] as $k => $v) { |
|
| 4008 | + $toDelete[] = (int) $k; |
|
| 4009 | + } |
|
| 3855 | 4010 | |
| 3856 | - if (!empty($toDelete)) |
|
| 3857 | - $smcFunc['db_query']('', ' |
|
| 4011 | + if (!empty($toDelete)) { |
|
| 4012 | + $smcFunc['db_query']('', ' |
|
| 3858 | 4013 | DELETE FROM {db_prefix}pm_rules |
| 3859 | 4014 | WHERE id_rule IN ({array_int:delete_list}) |
| 3860 | 4015 | AND id_member = {int:current_member}', |
@@ -3863,6 +4018,7 @@ discard block |
||
| 3863 | 4018 | 'delete_list' => $toDelete, |
| 3864 | 4019 | ) |
| 3865 | 4020 | ); |
| 4021 | + } |
|
| 3866 | 4022 | |
| 3867 | 4023 | redirectexit('action=pm;sa=manrules'); |
| 3868 | 4024 | } |
@@ -3881,8 +4037,9 @@ discard block |
||
| 3881 | 4037 | loadRules(); |
| 3882 | 4038 | |
| 3883 | 4039 | // No rules? |
| 3884 | - if (empty($context['rules'])) |
|
| 3885 | - return; |
|
| 4040 | + if (empty($context['rules'])) { |
|
| 4041 | + return; |
|
| 4042 | + } |
|
| 3886 | 4043 | |
| 3887 | 4044 | // Just unread ones? |
| 3888 | 4045 | $ruleQuery = $all_messages ? '' : ' AND pmr.is_new = 1'; |
@@ -3912,8 +4069,9 @@ discard block |
||
| 3912 | 4069 | // Loop through all the criteria hoping to make a match. |
| 3913 | 4070 | foreach ($rule['criteria'] as $criterium) |
| 3914 | 4071 | { |
| 3915 | - if (($criterium['t'] == 'mid' && $criterium['v'] == $row['id_member_from']) || ($criterium['t'] == 'gid' && $criterium['v'] == $row['id_group']) || ($criterium['t'] == 'sub' && strpos($row['subject'], $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($row['body'], $criterium['v']) !== false)) |
|
| 3916 | - $match = true; |
|
| 4072 | + if (($criterium['t'] == 'mid' && $criterium['v'] == $row['id_member_from']) || ($criterium['t'] == 'gid' && $criterium['v'] == $row['id_group']) || ($criterium['t'] == 'sub' && strpos($row['subject'], $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($row['body'], $criterium['v']) !== false)) { |
|
| 4073 | + $match = true; |
|
| 4074 | + } |
|
| 3917 | 4075 | // If we're adding and one criteria don't match then we stop! |
| 3918 | 4076 | elseif ($rule['logic'] == 'and') |
| 3919 | 4077 | { |
@@ -3925,17 +4083,18 @@ discard block |
||
| 3925 | 4083 | // If we have a match the rule must be true - act! |
| 3926 | 4084 | if ($match) |
| 3927 | 4085 | { |
| 3928 | - if ($rule['delete']) |
|
| 3929 | - $actions['deletes'][] = $row['id_pm']; |
|
| 3930 | - else |
|
| 4086 | + if ($rule['delete']) { |
|
| 4087 | + $actions['deletes'][] = $row['id_pm']; |
|
| 4088 | + } else |
|
| 3931 | 4089 | { |
| 3932 | 4090 | foreach ($rule['actions'] as $ruleAction) |
| 3933 | 4091 | { |
| 3934 | 4092 | if ($ruleAction['t'] == 'lab') |
| 3935 | 4093 | { |
| 3936 | 4094 | // Get a basic pot started! |
| 3937 | - if (!isset($actions['labels'][$row['id_pm']])) |
|
| 3938 | - $actions['labels'][$row['id_pm']] = array(); |
|
| 4095 | + if (!isset($actions['labels'][$row['id_pm']])) { |
|
| 4096 | + $actions['labels'][$row['id_pm']] = array(); |
|
| 4097 | + } |
|
| 3939 | 4098 | $actions['labels'][$row['id_pm']][] = $ruleAction['v']; |
| 3940 | 4099 | } |
| 3941 | 4100 | } |
@@ -3946,8 +4105,9 @@ discard block |
||
| 3946 | 4105 | $smcFunc['db_free_result']($request); |
| 3947 | 4106 | |
| 3948 | 4107 | // Deletes are easy! |
| 3949 | - if (!empty($actions['deletes'])) |
|
| 3950 | - deleteMessages($actions['deletes']); |
|
| 4108 | + if (!empty($actions['deletes'])) { |
|
| 4109 | + deleteMessages($actions['deletes']); |
|
| 4110 | + } |
|
| 3951 | 4111 | |
| 3952 | 4112 | // Relabel? |
| 3953 | 4113 | if (!empty($actions['labels'])) |
@@ -3974,8 +4134,7 @@ discard block |
||
| 3974 | 4134 | 'current_member' => $user_info['id'], |
| 3975 | 4135 | ) |
| 3976 | 4136 | ); |
| 3977 | - } |
|
| 3978 | - else |
|
| 4137 | + } else |
|
| 3979 | 4138 | { |
| 3980 | 4139 | $realLabels[] = $label['id']; |
| 3981 | 4140 | } |
@@ -3984,8 +4143,9 @@ discard block |
||
| 3984 | 4143 | |
| 3985 | 4144 | $inserts = array(); |
| 3986 | 4145 | // Now we insert the label info |
| 3987 | - foreach ($realLabels as $a_label) |
|
| 3988 | - $inserts[] = array($pm, $a_label); |
|
| 4146 | + foreach ($realLabels as $a_label) { |
|
| 4147 | + $inserts[] = array($pm, $a_label); |
|
| 4148 | + } |
|
| 3989 | 4149 | |
| 3990 | 4150 | $smcFunc['db_insert']('ignore', |
| 3991 | 4151 | '{db_prefix}pm_labeled_messages', |
@@ -4006,8 +4166,9 @@ discard block |
||
| 4006 | 4166 | { |
| 4007 | 4167 | global $user_info, $context, $smcFunc; |
| 4008 | 4168 | |
| 4009 | - if (isset($context['rules']) && !$reload) |
|
| 4010 | - return; |
|
| 4169 | + if (isset($context['rules']) && !$reload) { |
|
| 4170 | + return; |
|
| 4171 | + } |
|
| 4011 | 4172 | |
| 4012 | 4173 | $request = $smcFunc['db_query']('', ' |
| 4013 | 4174 | SELECT |
@@ -4031,8 +4192,9 @@ discard block |
||
| 4031 | 4192 | 'logic' => $row['is_or'] ? 'or' : 'and', |
| 4032 | 4193 | ); |
| 4033 | 4194 | |
| 4034 | - if ($row['delete_pm']) |
|
| 4035 | - $context['rules'][$row['id_rule']]['actions'][] = array('t' => 'del', 'v' => 1); |
|
| 4195 | + if ($row['delete_pm']) { |
|
| 4196 | + $context['rules'][$row['id_rule']]['actions'][] = array('t' => 'del', 'v' => 1); |
|
| 4197 | + } |
|
| 4036 | 4198 | } |
| 4037 | 4199 | $smcFunc['db_free_result']($request); |
| 4038 | 4200 | } |
@@ -2183,7 +2183,7 @@ discard block |
||
| 2183 | 2183 | * Deletes a single or a group of alerts by ID |
| 2184 | 2184 | * |
| 2185 | 2185 | * @param int|array The ID of a single alert to delete or an array containing the IDs of multiple alerts. The function will convert integers into an array for better handling. |
| 2186 | - * @param bool|int $memID The user ID. Used to update the user unread alerts count. |
|
| 2186 | + * @param integer $memID The user ID. Used to update the user unread alerts count. |
|
| 2187 | 2187 | * @return void|int If the $memID param is set, returns the new amount of unread alerts. |
| 2188 | 2188 | */ |
| 2189 | 2189 | function alert_delete($toDelete, $memID = false) |
@@ -2839,7 +2839,7 @@ discard block |
||
| 2839 | 2839 | /** |
| 2840 | 2840 | * Handles the "manage groups" section of the profile |
| 2841 | 2841 | * |
| 2842 | - * @return true Always returns true |
|
| 2842 | + * @return boolean Always returns true |
|
| 2843 | 2843 | */ |
| 2844 | 2844 | function profileLoadGroups() |
| 2845 | 2845 | { |
@@ -2896,7 +2896,7 @@ discard block |
||
| 2896 | 2896 | /** |
| 2897 | 2897 | * Load key signature context data. |
| 2898 | 2898 | * |
| 2899 | - * @return true Always returns true |
|
| 2899 | + * @return boolean Always returns true |
|
| 2900 | 2900 | */ |
| 2901 | 2901 | function profileLoadSignatureData() |
| 2902 | 2902 | { |
@@ -2960,7 +2960,7 @@ discard block |
||
| 2960 | 2960 | /** |
| 2961 | 2961 | * Load avatar context data. |
| 2962 | 2962 | * |
| 2963 | - * @return true Always returns true |
|
| 2963 | + * @return boolean Always returns true |
|
| 2964 | 2964 | */ |
| 2965 | 2965 | function profileLoadAvatarData() |
| 2966 | 2966 | { |
@@ -3033,7 +3033,7 @@ discard block |
||
| 3033 | 3033 | * Save a members group. |
| 3034 | 3034 | * |
| 3035 | 3035 | * @param int &$value The ID of the (new) primary group |
| 3036 | - * @return true Always returns true |
|
| 3036 | + * @return boolean Always returns true |
|
| 3037 | 3037 | */ |
| 3038 | 3038 | function profileSaveGroups(&$value) |
| 3039 | 3039 | { |
@@ -3138,7 +3138,7 @@ discard block |
||
| 3138 | 3138 | * @todo argh, the avatar here. Take this out of here! |
| 3139 | 3139 | * |
| 3140 | 3140 | * @param string &$value What kind of avatar we're expecting. Can be 'none', 'server_stored', 'gravatar', 'external' or 'upload' |
| 3141 | - * @return bool|string False if success (or if memID is empty and password authentication failed), otherwise a string indicating what error occurred |
|
| 3141 | + * @return false|string False if success (or if memID is empty and password authentication failed), otherwise a string indicating what error occurred |
|
| 3142 | 3142 | */ |
| 3143 | 3143 | function profileSaveAvatarData(&$value) |
| 3144 | 3144 | { |
@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * @version 2.1 Beta 4 |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -if (!defined('SMF')) |
|
| 18 | +if (!defined('SMF')) { |
|
| 19 | 19 | die('No direct access...'); |
| 20 | +} |
|
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * This defines every profile field known to man. |
@@ -29,8 +30,9 @@ discard block |
||
| 29 | 30 | global $sourcedir, $profile_vars; |
| 30 | 31 | |
| 31 | 32 | // Don't load this twice! |
| 32 | - if (!empty($profile_fields) && !$force_reload) |
|
| 33 | - return; |
|
| 33 | + if (!empty($profile_fields) && !$force_reload) { |
|
| 34 | + return; |
|
| 35 | + } |
|
| 34 | 36 | |
| 35 | 37 | /* This horrific array defines all the profile fields in the whole world! |
| 36 | 38 | In general each "field" has one array - the key of which is the database column name associated with said field. Each item |
@@ -103,13 +105,14 @@ discard block |
||
| 103 | 105 | if (isset($_POST['bday2'], $_POST['bday3']) && $value > 0 && $_POST['bday2'] > 0) |
| 104 | 106 | { |
| 105 | 107 | // Set to blank? |
| 106 | - if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) |
|
| 107 | - $value = '1004-01-01'; |
|
| 108 | - else |
|
| 109 | - $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '1004-01-01'; |
|
| 108 | + if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) { |
|
| 109 | + $value = '1004-01-01'; |
|
| 110 | + } else { |
|
| 111 | + $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '1004-01-01'; |
|
| 112 | + } |
|
| 113 | + } else { |
|
| 114 | + $value = '1004-01-01'; |
|
| 110 | 115 | } |
| 111 | - else |
|
| 112 | - $value = '1004-01-01'; |
|
| 113 | 116 | |
| 114 | 117 | $profile_vars['birthdate'] = $value; |
| 115 | 118 | $cur_profile['birthdate'] = $value; |
@@ -127,8 +130,7 @@ discard block |
||
| 127 | 130 | { |
| 128 | 131 | $value = checkdate($dates[2], $dates[3], $dates[1] < 4 ? 4 : $dates[1]) ? sprintf('%04d-%02d-%02d', $dates[1] < 4 ? 4 : $dates[1], $dates[2], $dates[3]) : '1004-01-01'; |
| 129 | 132 | return true; |
| 130 | - } |
|
| 131 | - else |
|
| 133 | + } else |
|
| 132 | 134 | { |
| 133 | 135 | $value = empty($cur_profile['birthdate']) ? '1004-01-01' : $cur_profile['birthdate']; |
| 134 | 136 | return false; |
@@ -150,10 +152,11 @@ discard block |
||
| 150 | 152 | return $txt['invalid_registration'] . ' ' . strftime('%d %b %Y ' . (strpos($user_info['time_format'], '%H') !== false ? '%I:%M:%S %p' : '%H:%M:%S'), forum_time(false)); |
| 151 | 153 | } |
| 152 | 154 | // As long as it doesn't equal "N/A"... |
| 153 | - elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) |
|
| 154 | - $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 155 | - else |
|
| 156 | - $value = $cur_profile['date_registered']; |
|
| 155 | + elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) { |
|
| 156 | + $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 157 | + } else { |
|
| 158 | + $value = $cur_profile['date_registered']; |
|
| 159 | + } |
|
| 157 | 160 | |
| 158 | 161 | return true; |
| 159 | 162 | }, |
@@ -177,8 +180,9 @@ discard block |
||
| 177 | 180 | { |
| 178 | 181 | global $context, $old_profile, $profile_vars, $sourcedir, $modSettings; |
| 179 | 182 | |
| 180 | - if (strtolower($value) == strtolower($old_profile['email_address'])) |
|
| 181 | - return false; |
|
| 183 | + if (strtolower($value) == strtolower($old_profile['email_address'])) { |
|
| 184 | + return false; |
|
| 185 | + } |
|
| 182 | 186 | |
| 183 | 187 | $isValid = profileValidateEmail($value, $context['id_member']); |
| 184 | 188 | |
@@ -254,11 +258,11 @@ discard block |
||
| 254 | 258 | |
| 255 | 259 | if (isset($context['profile_languages'][$value])) |
| 256 | 260 | { |
| 257 | - if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) |
|
| 258 | - $_SESSION['language'] = $value; |
|
| 261 | + if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) { |
|
| 262 | + $_SESSION['language'] = $value; |
|
| 263 | + } |
|
| 259 | 264 | return true; |
| 260 | - } |
|
| 261 | - else |
|
| 265 | + } else |
|
| 262 | 266 | { |
| 263 | 267 | $value = $cur_profile['lngfile']; |
| 264 | 268 | return false; |
@@ -282,13 +286,14 @@ discard block |
||
| 282 | 286 | |
| 283 | 287 | // Maybe they are trying to change their password as well? |
| 284 | 288 | $resetPassword = true; |
| 285 | - if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) |
|
| 286 | - $resetPassword = false; |
|
| 289 | + if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) { |
|
| 290 | + $resetPassword = false; |
|
| 291 | + } |
|
| 287 | 292 | |
| 288 | 293 | // Do the reset... this will send them an email too. |
| 289 | - if ($resetPassword) |
|
| 290 | - resetPassword($context['id_member'], $value); |
|
| 291 | - elseif ($value !== null) |
|
| 294 | + if ($resetPassword) { |
|
| 295 | + resetPassword($context['id_member'], $value); |
|
| 296 | + } elseif ($value !== null) |
|
| 292 | 297 | { |
| 293 | 298 | validateUsername($context['id_member'], trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value))); |
| 294 | 299 | updateMemberData($context['id_member'], array('member_name' => $value)); |
@@ -312,20 +317,23 @@ discard block |
||
| 312 | 317 | 'input_validate' => function(&$value) use ($sourcedir, $user_info, $smcFunc, $cur_profile) |
| 313 | 318 | { |
| 314 | 319 | // If we didn't try it then ignore it! |
| 315 | - if ($value == '') |
|
| 316 | - return false; |
|
| 320 | + if ($value == '') { |
|
| 321 | + return false; |
|
| 322 | + } |
|
| 317 | 323 | |
| 318 | 324 | // Do the two entries for the password even match? |
| 319 | - if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) |
|
| 320 | - return 'bad_new_password'; |
|
| 325 | + if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) { |
|
| 326 | + return 'bad_new_password'; |
|
| 327 | + } |
|
| 321 | 328 | |
| 322 | 329 | // Let's get the validation function into play... |
| 323 | 330 | require_once($sourcedir . '/Subs-Auth.php'); |
| 324 | 331 | $passwordErrors = validatePassword($value, $cur_profile['member_name'], array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])); |
| 325 | 332 | |
| 326 | 333 | // Were there errors? |
| 327 | - if ($passwordErrors != null) |
|
| 328 | - return 'password_' . $passwordErrors; |
|
| 334 | + if ($passwordErrors != null) { |
|
| 335 | + return 'password_' . $passwordErrors; |
|
| 336 | + } |
|
| 329 | 337 | |
| 330 | 338 | // Set up the new password variable... ready for storage. |
| 331 | 339 | $value = hash_password($cur_profile['member_name'], un_htmlspecialchars($value)); |
@@ -350,8 +358,9 @@ discard block |
||
| 350 | 358 | 'permission' => 'profile_blurb', |
| 351 | 359 | 'input_validate' => function(&$value) use ($smcFunc) |
| 352 | 360 | { |
| 353 | - if ($smcFunc['strlen']($value) > 50) |
|
| 354 | - return 'personal_text_too_long'; |
|
| 361 | + if ($smcFunc['strlen']($value) > 50) { |
|
| 362 | + return 'personal_text_too_long'; |
|
| 363 | + } |
|
| 355 | 364 | |
| 356 | 365 | return true; |
| 357 | 366 | }, |
@@ -386,10 +395,11 @@ discard block |
||
| 386 | 395 | 'permission' => 'moderate_forum', |
| 387 | 396 | 'input_validate' => function(&$value) |
| 388 | 397 | { |
| 389 | - if (!is_numeric($value)) |
|
| 390 | - return 'digits_only'; |
|
| 391 | - else |
|
| 392 | - $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
| 398 | + if (!is_numeric($value)) { |
|
| 399 | + return 'digits_only'; |
|
| 400 | + } else { |
|
| 401 | + $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
| 402 | + } |
|
| 393 | 403 | return true; |
| 394 | 404 | }, |
| 395 | 405 | ), |
@@ -405,15 +415,16 @@ discard block |
||
| 405 | 415 | { |
| 406 | 416 | $value = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value)); |
| 407 | 417 | |
| 408 | - if (trim($value) == '') |
|
| 409 | - return 'no_name'; |
|
| 410 | - elseif ($smcFunc['strlen']($value) > 60) |
|
| 411 | - return 'name_too_long'; |
|
| 412 | - elseif ($cur_profile['real_name'] != $value) |
|
| 418 | + if (trim($value) == '') { |
|
| 419 | + return 'no_name'; |
|
| 420 | + } elseif ($smcFunc['strlen']($value) > 60) { |
|
| 421 | + return 'name_too_long'; |
|
| 422 | + } elseif ($cur_profile['real_name'] != $value) |
|
| 413 | 423 | { |
| 414 | 424 | require_once($sourcedir . '/Subs-Members.php'); |
| 415 | - if (isReservedName($value, $context['id_member'])) |
|
| 416 | - return 'name_taken'; |
|
| 425 | + if (isReservedName($value, $context['id_member'])) { |
|
| 426 | + return 'name_taken'; |
|
| 427 | + } |
|
| 417 | 428 | } |
| 418 | 429 | return true; |
| 419 | 430 | }, |
@@ -471,8 +482,9 @@ discard block |
||
| 471 | 482 | 'selected' => $set == $context['member']['smiley_set']['id'] |
| 472 | 483 | ); |
| 473 | 484 | |
| 474 | - if ($context['smiley_sets'][$i]['selected']) |
|
| 475 | - $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
| 485 | + if ($context['smiley_sets'][$i]['selected']) { |
|
| 486 | + $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
| 487 | + } |
|
| 476 | 488 | } |
| 477 | 489 | return true; |
| 478 | 490 | }, |
@@ -481,8 +493,9 @@ discard block |
||
| 481 | 493 | global $modSettings; |
| 482 | 494 | |
| 483 | 495 | $smiley_sets = explode(',', $modSettings['smiley_sets_known']); |
| 484 | - if (!in_array($value, $smiley_sets) && $value != 'none') |
|
| 485 | - $value = ''; |
|
| 496 | + if (!in_array($value, $smiley_sets) && $value != 'none') { |
|
| 497 | + $value = ''; |
|
| 498 | + } |
|
| 486 | 499 | return true; |
| 487 | 500 | }, |
| 488 | 501 | ), |
@@ -497,8 +510,9 @@ discard block |
||
| 497 | 510 | loadLanguage('Settings'); |
| 498 | 511 | |
| 499 | 512 | $context['allow_no_censored'] = false; |
| 500 | - if ($user_info['is_admin'] || $context['user']['is_owner']) |
|
| 501 | - $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
| 513 | + if ($user_info['is_admin'] || $context['user']['is_owner']) { |
|
| 514 | + $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
| 515 | + } |
|
| 502 | 516 | |
| 503 | 517 | return true; |
| 504 | 518 | }, |
@@ -545,8 +559,9 @@ discard block |
||
| 545 | 559 | 'input_validate' => function($value) |
| 546 | 560 | { |
| 547 | 561 | $tz = smf_list_timezones(); |
| 548 | - if (!isset($tz[$value])) |
|
| 549 | - return 'bad_timezone'; |
|
| 562 | + if (!isset($tz[$value])) { |
|
| 563 | + return 'bad_timezone'; |
|
| 564 | + } |
|
| 550 | 565 | |
| 551 | 566 | return true; |
| 552 | 567 | }, |
@@ -561,8 +576,9 @@ discard block |
||
| 561 | 576 | 'enabled' => !empty($modSettings['titlesEnable']), |
| 562 | 577 | 'input_validate' => function(&$value) use ($smcFunc) |
| 563 | 578 | { |
| 564 | - if ($smcFunc['strlen']($value) > 50) |
|
| 565 | - return 'user_title_too_long'; |
|
| 579 | + if ($smcFunc['strlen']($value) > 50) { |
|
| 580 | + return 'user_title_too_long'; |
|
| 581 | + } |
|
| 566 | 582 | |
| 567 | 583 | return true; |
| 568 | 584 | }, |
@@ -584,10 +600,12 @@ discard block |
||
| 584 | 600 | // Fix the URL... |
| 585 | 601 | 'input_validate' => function(&$value) |
| 586 | 602 | { |
| 587 | - if (strlen(trim($value)) > 0 && strpos($value, '://') === false) |
|
| 588 | - $value = 'http://' . $value; |
|
| 589 | - if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) |
|
| 590 | - $value = ''; |
|
| 603 | + if (strlen(trim($value)) > 0 && strpos($value, '://') === false) { |
|
| 604 | + $value = 'http://' . $value; |
|
| 605 | + } |
|
| 606 | + if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) { |
|
| 607 | + $value = ''; |
|
| 608 | + } |
|
| 591 | 609 | return true; |
| 592 | 610 | }, |
| 593 | 611 | 'link_with' => 'website', |
@@ -601,16 +619,19 @@ discard block |
||
| 601 | 619 | foreach ($profile_fields as $key => $field) |
| 602 | 620 | { |
| 603 | 621 | // Do we have permission to do this? |
| 604 | - if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) |
|
| 605 | - unset($profile_fields[$key]); |
|
| 622 | + if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) { |
|
| 623 | + unset($profile_fields[$key]); |
|
| 624 | + } |
|
| 606 | 625 | |
| 607 | 626 | // Is it enabled? |
| 608 | - if (isset($field['enabled']) && !$field['enabled']) |
|
| 609 | - unset($profile_fields[$key]); |
|
| 627 | + if (isset($field['enabled']) && !$field['enabled']) { |
|
| 628 | + unset($profile_fields[$key]); |
|
| 629 | + } |
|
| 610 | 630 | |
| 611 | 631 | // Is it specifically disabled? |
| 612 | - if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) |
|
| 613 | - unset($profile_fields[$key]); |
|
| 632 | + if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) { |
|
| 633 | + unset($profile_fields[$key]); |
|
| 634 | + } |
|
| 614 | 635 | } |
| 615 | 636 | } |
| 616 | 637 | |
@@ -635,9 +656,10 @@ discard block |
||
| 635 | 656 | loadProfileFields(true); |
| 636 | 657 | |
| 637 | 658 | // First check for any linked sets. |
| 638 | - foreach ($profile_fields as $key => $field) |
|
| 639 | - if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
| 659 | + foreach ($profile_fields as $key => $field) { |
|
| 660 | + if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
| 640 | 661 | $fields[] = $key; |
| 662 | + } |
|
| 641 | 663 | |
| 642 | 664 | $i = 0; |
| 643 | 665 | $last_type = ''; |
@@ -649,38 +671,46 @@ discard block |
||
| 649 | 671 | $cur_field = &$profile_fields[$field]; |
| 650 | 672 | |
| 651 | 673 | // Does it have a preload and does that preload succeed? |
| 652 | - if (isset($cur_field['preload']) && !$cur_field['preload']()) |
|
| 653 | - continue; |
|
| 674 | + if (isset($cur_field['preload']) && !$cur_field['preload']()) { |
|
| 675 | + continue; |
|
| 676 | + } |
|
| 654 | 677 | |
| 655 | 678 | // If this is anything but complex we need to do more cleaning! |
| 656 | 679 | if ($cur_field['type'] != 'callback' && $cur_field['type'] != 'hidden') |
| 657 | 680 | { |
| 658 | - if (!isset($cur_field['label'])) |
|
| 659 | - $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
| 681 | + if (!isset($cur_field['label'])) { |
|
| 682 | + $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
| 683 | + } |
|
| 660 | 684 | |
| 661 | 685 | // Everything has a value! |
| 662 | - if (!isset($cur_field['value'])) |
|
| 663 | - $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
| 686 | + if (!isset($cur_field['value'])) { |
|
| 687 | + $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
| 688 | + } |
|
| 664 | 689 | |
| 665 | 690 | // Any input attributes? |
| 666 | 691 | $cur_field['input_attr'] = !empty($cur_field['input_attr']) ? implode(',', $cur_field['input_attr']) : ''; |
| 667 | 692 | } |
| 668 | 693 | |
| 669 | 694 | // Was there an error with this field on posting? |
| 670 | - if (isset($context['profile_errors'][$field])) |
|
| 671 | - $cur_field['is_error'] = true; |
|
| 695 | + if (isset($context['profile_errors'][$field])) { |
|
| 696 | + $cur_field['is_error'] = true; |
|
| 697 | + } |
|
| 672 | 698 | |
| 673 | 699 | // Any javascript stuff? |
| 674 | - if (!empty($cur_field['js_submit'])) |
|
| 675 | - $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
| 676 | - if (!empty($cur_field['js'])) |
|
| 677 | - $context['profile_javascript'] .= $cur_field['js']; |
|
| 700 | + if (!empty($cur_field['js_submit'])) { |
|
| 701 | + $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
| 702 | + } |
|
| 703 | + if (!empty($cur_field['js'])) { |
|
| 704 | + $context['profile_javascript'] .= $cur_field['js']; |
|
| 705 | + } |
|
| 678 | 706 | |
| 679 | 707 | // Any template stuff? |
| 680 | - if (!empty($cur_field['prehtml'])) |
|
| 681 | - $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
| 682 | - if (!empty($cur_field['posthtml'])) |
|
| 683 | - $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
| 708 | + if (!empty($cur_field['prehtml'])) { |
|
| 709 | + $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
| 710 | + } |
|
| 711 | + if (!empty($cur_field['posthtml'])) { |
|
| 712 | + $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
| 713 | + } |
|
| 684 | 714 | |
| 685 | 715 | // Finally put it into context? |
| 686 | 716 | if ($cur_field['type'] != 'hidden') |
@@ -713,12 +743,14 @@ discard block |
||
| 713 | 743 | }, false);' : ''), true); |
| 714 | 744 | |
| 715 | 745 | // Any onsubmit javascript? |
| 716 | - if (!empty($context['profile_onsubmit_javascript'])) |
|
| 717 | - addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
| 746 | + if (!empty($context['profile_onsubmit_javascript'])) { |
|
| 747 | + addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
| 748 | + } |
|
| 718 | 749 | |
| 719 | 750 | // Any totally custom stuff? |
| 720 | - if (!empty($context['profile_javascript'])) |
|
| 721 | - addInlineJavaScript($context['profile_javascript'], true); |
|
| 751 | + if (!empty($context['profile_javascript'])) { |
|
| 752 | + addInlineJavaScript($context['profile_javascript'], true); |
|
| 753 | + } |
|
| 722 | 754 | |
| 723 | 755 | // Free up some memory. |
| 724 | 756 | unset($profile_fields); |
@@ -739,8 +771,9 @@ discard block |
||
| 739 | 771 | |
| 740 | 772 | // This allows variables to call activities when they save - by default just to reload their settings |
| 741 | 773 | $context['profile_execute_on_save'] = array(); |
| 742 | - if ($context['user']['is_owner']) |
|
| 743 | - $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
| 774 | + if ($context['user']['is_owner']) { |
|
| 775 | + $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
| 776 | + } |
|
| 744 | 777 | |
| 745 | 778 | // Assume we log nothing. |
| 746 | 779 | $context['log_changes'] = array(); |
@@ -748,8 +781,9 @@ discard block |
||
| 748 | 781 | // Cycle through the profile fields working out what to do! |
| 749 | 782 | foreach ($profile_fields as $key => $field) |
| 750 | 783 | { |
| 751 | - if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) |
|
| 752 | - continue; |
|
| 784 | + if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) { |
|
| 785 | + continue; |
|
| 786 | + } |
|
| 753 | 787 | |
| 754 | 788 | // What gets updated? |
| 755 | 789 | $db_key = isset($field['save_key']) ? $field['save_key'] : $key; |
@@ -777,12 +811,13 @@ discard block |
||
| 777 | 811 | $field['cast_type'] = empty($field['cast_type']) ? $field['type'] : $field['cast_type']; |
| 778 | 812 | |
| 779 | 813 | // Finally, clean up certain types. |
| 780 | - if ($field['cast_type'] == 'int') |
|
| 781 | - $_POST[$key] = (int) $_POST[$key]; |
|
| 782 | - elseif ($field['cast_type'] == 'float') |
|
| 783 | - $_POST[$key] = (float) $_POST[$key]; |
|
| 784 | - elseif ($field['cast_type'] == 'check') |
|
| 785 | - $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
| 814 | + if ($field['cast_type'] == 'int') { |
|
| 815 | + $_POST[$key] = (int) $_POST[$key]; |
|
| 816 | + } elseif ($field['cast_type'] == 'float') { |
|
| 817 | + $_POST[$key] = (float) $_POST[$key]; |
|
| 818 | + } elseif ($field['cast_type'] == 'check') { |
|
| 819 | + $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
| 820 | + } |
|
| 786 | 821 | |
| 787 | 822 | // If we got here we're doing OK. |
| 788 | 823 | if ($field['type'] != 'hidden' && (!isset($old_profile[$key]) || $_POST[$key] != $old_profile[$key])) |
@@ -793,11 +828,12 @@ discard block |
||
| 793 | 828 | $cur_profile[$key] = $_POST[$key]; |
| 794 | 829 | |
| 795 | 830 | // Are we logging it? |
| 796 | - if (!empty($field['log_change']) && isset($old_profile[$key])) |
|
| 797 | - $context['log_changes'][$key] = array( |
|
| 831 | + if (!empty($field['log_change']) && isset($old_profile[$key])) { |
|
| 832 | + $context['log_changes'][$key] = array( |
|
| 798 | 833 | 'previous' => $old_profile[$key], |
| 799 | 834 | 'new' => $_POST[$key], |
| 800 | 835 | ); |
| 836 | + } |
|
| 801 | 837 | } |
| 802 | 838 | |
| 803 | 839 | // Logging group changes are a bit different... |
@@ -830,10 +866,11 @@ discard block |
||
| 830 | 866 | { |
| 831 | 867 | foreach ($groups as $id => $group) |
| 832 | 868 | { |
| 833 | - if (isset($context['member_groups'][$group])) |
|
| 834 | - $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
| 835 | - else |
|
| 836 | - unset($additional_groups[$type][$id]); |
|
| 869 | + if (isset($context['member_groups'][$group])) { |
|
| 870 | + $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
| 871 | + } else { |
|
| 872 | + unset($additional_groups[$type][$id]); |
|
| 873 | + } |
|
| 837 | 874 | } |
| 838 | 875 | $additional_groups[$type] = implode(', ', $additional_groups[$type]); |
| 839 | 876 | } |
@@ -844,10 +881,11 @@ discard block |
||
| 844 | 881 | } |
| 845 | 882 | |
| 846 | 883 | // @todo Temporary |
| 847 | - if ($context['user']['is_owner']) |
|
| 848 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
| 849 | - else |
|
| 850 | - $changeOther = allowedTo('profile_extra_any'); |
|
| 884 | + if ($context['user']['is_owner']) { |
|
| 885 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
| 886 | + } else { |
|
| 887 | + $changeOther = allowedTo('profile_extra_any'); |
|
| 888 | + } |
|
| 851 | 889 | if ($changeOther && empty($post_errors)) |
| 852 | 890 | { |
| 853 | 891 | makeThemeChanges($context['id_member'], isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
@@ -855,8 +893,9 @@ discard block |
||
| 855 | 893 | { |
| 856 | 894 | $custom_fields_errors = makeCustomFieldChanges($context['id_member'], $_REQUEST['sa'], false, true); |
| 857 | 895 | |
| 858 | - if (!empty($custom_fields_errors)) |
|
| 859 | - $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
| 896 | + if (!empty($custom_fields_errors)) { |
|
| 897 | + $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
| 898 | + } |
|
| 860 | 899 | } |
| 861 | 900 | } |
| 862 | 901 | |
@@ -882,9 +921,9 @@ discard block |
||
| 882 | 921 | if ($context['user']['is_owner']) |
| 883 | 922 | { |
| 884 | 923 | $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own', 'profile_website_any', 'profile_website_own', 'profile_signature_any', 'profile_signature_own')); |
| 924 | + } else { |
|
| 925 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any')); |
|
| 885 | 926 | } |
| 886 | - else |
|
| 887 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any')); |
|
| 888 | 927 | |
| 889 | 928 | // Arrays of all the changes - makes things easier. |
| 890 | 929 | $profile_bools = array(); |
@@ -895,22 +934,25 @@ discard block |
||
| 895 | 934 | 'ignore_boards', |
| 896 | 935 | ); |
| 897 | 936 | |
| 898 | - if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) |
|
| 899 | - $_POST['ignore_brd'] = array(); |
|
| 937 | + if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) { |
|
| 938 | + $_POST['ignore_brd'] = array(); |
|
| 939 | + } |
|
| 900 | 940 | |
| 901 | 941 | unset($_POST['ignore_boards']); // Whatever it is set to is a dirty filthy thing. Kinda like our minds. |
| 902 | 942 | if (isset($_POST['ignore_brd'])) |
| 903 | 943 | { |
| 904 | - if (!is_array($_POST['ignore_brd'])) |
|
| 905 | - $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
| 944 | + if (!is_array($_POST['ignore_brd'])) { |
|
| 945 | + $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
| 946 | + } |
|
| 906 | 947 | |
| 907 | 948 | foreach ($_POST['ignore_brd'] as $k => $d) |
| 908 | 949 | { |
| 909 | 950 | $d = (int) $d; |
| 910 | - if ($d != 0) |
|
| 911 | - $_POST['ignore_brd'][$k] = $d; |
|
| 912 | - else |
|
| 913 | - unset($_POST['ignore_brd'][$k]); |
|
| 951 | + if ($d != 0) { |
|
| 952 | + $_POST['ignore_brd'][$k] = $d; |
|
| 953 | + } else { |
|
| 954 | + unset($_POST['ignore_brd'][$k]); |
|
| 955 | + } |
|
| 914 | 956 | } |
| 915 | 957 | $_POST['ignore_boards'] = implode(',', $_POST['ignore_brd']); |
| 916 | 958 | unset($_POST['ignore_brd']); |
@@ -923,21 +965,26 @@ discard block |
||
| 923 | 965 | makeThemeChanges($memID, isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
| 924 | 966 | //makeAvatarChanges($memID, $post_errors); |
| 925 | 967 | |
| 926 | - if (!empty($_REQUEST['sa'])) |
|
| 927 | - makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
| 968 | + if (!empty($_REQUEST['sa'])) { |
|
| 969 | + makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
| 970 | + } |
|
| 928 | 971 | |
| 929 | - foreach ($profile_bools as $var) |
|
| 930 | - if (isset($_POST[$var])) |
|
| 972 | + foreach ($profile_bools as $var) { |
|
| 973 | + if (isset($_POST[$var])) |
|
| 931 | 974 | $profile_vars[$var] = empty($_POST[$var]) ? '0' : '1'; |
| 932 | - foreach ($profile_ints as $var) |
|
| 933 | - if (isset($_POST[$var])) |
|
| 975 | + } |
|
| 976 | + foreach ($profile_ints as $var) { |
|
| 977 | + if (isset($_POST[$var])) |
|
| 934 | 978 | $profile_vars[$var] = $_POST[$var] != '' ? (int) $_POST[$var] : ''; |
| 935 | - foreach ($profile_floats as $var) |
|
| 936 | - if (isset($_POST[$var])) |
|
| 979 | + } |
|
| 980 | + foreach ($profile_floats as $var) { |
|
| 981 | + if (isset($_POST[$var])) |
|
| 937 | 982 | $profile_vars[$var] = (float) $_POST[$var]; |
| 938 | - foreach ($profile_strings as $var) |
|
| 939 | - if (isset($_POST[$var])) |
|
| 983 | + } |
|
| 984 | + foreach ($profile_strings as $var) { |
|
| 985 | + if (isset($_POST[$var])) |
|
| 940 | 986 | $profile_vars[$var] = $_POST[$var]; |
| 987 | + } |
|
| 941 | 988 | } |
| 942 | 989 | } |
| 943 | 990 | |
@@ -971,8 +1018,9 @@ discard block |
||
| 971 | 1018 | ); |
| 972 | 1019 | |
| 973 | 1020 | // Can't change reserved vars. |
| 974 | - if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) |
|
| 975 | - fatal_lang_error('no_access', false); |
|
| 1021 | + if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) { |
|
| 1022 | + fatal_lang_error('no_access', false); |
|
| 1023 | + } |
|
| 976 | 1024 | |
| 977 | 1025 | // Don't allow any overriding of custom fields with default or non-default options. |
| 978 | 1026 | $request = $smcFunc['db_query']('', ' |
@@ -984,8 +1032,9 @@ discard block |
||
| 984 | 1032 | ) |
| 985 | 1033 | ); |
| 986 | 1034 | $custom_fields = array(); |
| 987 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 988 | - $custom_fields[] = $row['col_name']; |
|
| 1035 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1036 | + $custom_fields[] = $row['col_name']; |
|
| 1037 | + } |
|
| 989 | 1038 | $smcFunc['db_free_result']($request); |
| 990 | 1039 | |
| 991 | 1040 | // These are the theme changes... |
@@ -994,33 +1043,39 @@ discard block |
||
| 994 | 1043 | { |
| 995 | 1044 | foreach ($_POST['options'] as $opt => $val) |
| 996 | 1045 | { |
| 997 | - if (in_array($opt, $custom_fields)) |
|
| 998 | - continue; |
|
| 1046 | + if (in_array($opt, $custom_fields)) { |
|
| 1047 | + continue; |
|
| 1048 | + } |
|
| 999 | 1049 | |
| 1000 | 1050 | // These need to be controlled. |
| 1001 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
| 1002 | - $val = max(0, min($val, 50)); |
|
| 1051 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
| 1052 | + $val = max(0, min($val, 50)); |
|
| 1053 | + } |
|
| 1003 | 1054 | // We don't set this per theme anymore. |
| 1004 | - elseif ($opt == 'allow_no_censored') |
|
| 1005 | - continue; |
|
| 1055 | + elseif ($opt == 'allow_no_censored') { |
|
| 1056 | + continue; |
|
| 1057 | + } |
|
| 1006 | 1058 | |
| 1007 | 1059 | $themeSetArray[] = array($memID, $id_theme, $opt, is_array($val) ? implode(',', $val) : $val); |
| 1008 | 1060 | } |
| 1009 | 1061 | } |
| 1010 | 1062 | |
| 1011 | 1063 | $erase_options = array(); |
| 1012 | - if (isset($_POST['default_options']) && is_array($_POST['default_options'])) |
|
| 1013 | - foreach ($_POST['default_options'] as $opt => $val) |
|
| 1064 | + if (isset($_POST['default_options']) && is_array($_POST['default_options'])) { |
|
| 1065 | + foreach ($_POST['default_options'] as $opt => $val) |
|
| 1014 | 1066 | { |
| 1015 | 1067 | if (in_array($opt, $custom_fields)) |
| 1016 | 1068 | continue; |
| 1069 | + } |
|
| 1017 | 1070 | |
| 1018 | 1071 | // These need to be controlled. |
| 1019 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
| 1020 | - $val = max(0, min($val, 50)); |
|
| 1072 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
| 1073 | + $val = max(0, min($val, 50)); |
|
| 1074 | + } |
|
| 1021 | 1075 | // Only let admins and owners change the censor. |
| 1022 | - elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) |
|
| 1023 | - continue; |
|
| 1076 | + elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) { |
|
| 1077 | + continue; |
|
| 1078 | + } |
|
| 1024 | 1079 | |
| 1025 | 1080 | $themeSetArray[] = array($memID, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
| 1026 | 1081 | $erase_options[] = $opt; |
@@ -1056,8 +1111,9 @@ discard block |
||
| 1056 | 1111 | |
| 1057 | 1112 | // Admins can choose any theme, even if it's not enabled... |
| 1058 | 1113 | $themes = allowedTo('admin_forum') ? explode(',', $modSettings['knownThemes']) : explode(',', $modSettings['enableThemes']); |
| 1059 | - foreach ($themes as $t) |
|
| 1060 | - cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
| 1114 | + foreach ($themes as $t) { |
|
| 1115 | + cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
| 1116 | + } |
|
| 1061 | 1117 | } |
| 1062 | 1118 | } |
| 1063 | 1119 | |
@@ -1076,8 +1132,9 @@ discard block |
||
| 1076 | 1132 | if (isset($_POST['edit_notify_boards']) && !empty($_POST['notify_boards'])) |
| 1077 | 1133 | { |
| 1078 | 1134 | // Make sure only integers are deleted. |
| 1079 | - foreach ($_POST['notify_boards'] as $index => $id) |
|
| 1080 | - $_POST['notify_boards'][$index] = (int) $id; |
|
| 1135 | + foreach ($_POST['notify_boards'] as $index => $id) { |
|
| 1136 | + $_POST['notify_boards'][$index] = (int) $id; |
|
| 1137 | + } |
|
| 1081 | 1138 | |
| 1082 | 1139 | // id_board = 0 is reserved for topic notifications. |
| 1083 | 1140 | $_POST['notify_boards'] = array_diff($_POST['notify_boards'], array(0)); |
@@ -1096,8 +1153,9 @@ discard block |
||
| 1096 | 1153 | // We are editing topic notifications...... |
| 1097 | 1154 | elseif (isset($_POST['edit_notify_topics']) && !empty($_POST['notify_topics'])) |
| 1098 | 1155 | { |
| 1099 | - foreach ($_POST['notify_topics'] as $index => $id) |
|
| 1100 | - $_POST['notify_topics'][$index] = (int) $id; |
|
| 1156 | + foreach ($_POST['notify_topics'] as $index => $id) { |
|
| 1157 | + $_POST['notify_topics'][$index] = (int) $id; |
|
| 1158 | + } |
|
| 1101 | 1159 | |
| 1102 | 1160 | // Make sure there are no zeros left. |
| 1103 | 1161 | $_POST['notify_topics'] = array_diff($_POST['notify_topics'], array(0)); |
@@ -1111,16 +1169,18 @@ discard block |
||
| 1111 | 1169 | 'selected_member' => $memID, |
| 1112 | 1170 | ) |
| 1113 | 1171 | ); |
| 1114 | - foreach ($_POST['notify_topics'] as $topic) |
|
| 1115 | - setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
| 1172 | + foreach ($_POST['notify_topics'] as $topic) { |
|
| 1173 | + setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
| 1174 | + } |
|
| 1116 | 1175 | } |
| 1117 | 1176 | |
| 1118 | 1177 | // We are removing topic preferences |
| 1119 | 1178 | elseif (isset($_POST['remove_notify_topics']) && !empty($_POST['notify_topics'])) |
| 1120 | 1179 | { |
| 1121 | 1180 | $prefs = array(); |
| 1122 | - foreach ($_POST['notify_topics'] as $topic) |
|
| 1123 | - $prefs[] = 'topic_notify_' . $topic; |
|
| 1181 | + foreach ($_POST['notify_topics'] as $topic) { |
|
| 1182 | + $prefs[] = 'topic_notify_' . $topic; |
|
| 1183 | + } |
|
| 1124 | 1184 | deleteNotifyPrefs($memID, $prefs); |
| 1125 | 1185 | } |
| 1126 | 1186 | |
@@ -1128,8 +1188,9 @@ discard block |
||
| 1128 | 1188 | elseif (isset($_POST['remove_notify_board']) && !empty($_POST['notify_boards'])) |
| 1129 | 1189 | { |
| 1130 | 1190 | $prefs = array(); |
| 1131 | - foreach ($_POST['notify_boards'] as $board) |
|
| 1132 | - $prefs[] = 'board_notify_' . $board; |
|
| 1191 | + foreach ($_POST['notify_boards'] as $board) { |
|
| 1192 | + $prefs[] = 'board_notify_' . $board; |
|
| 1193 | + } |
|
| 1133 | 1194 | deleteNotifyPrefs($memID, $prefs); |
| 1134 | 1195 | } |
| 1135 | 1196 | } |
@@ -1150,8 +1211,9 @@ discard block |
||
| 1150 | 1211 | |
| 1151 | 1212 | $errors = array(); |
| 1152 | 1213 | |
| 1153 | - if ($sanitize && isset($_POST['customfield'])) |
|
| 1154 | - $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
| 1214 | + if ($sanitize && isset($_POST['customfield'])) { |
|
| 1215 | + $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
| 1216 | + } |
|
| 1155 | 1217 | |
| 1156 | 1218 | $where = $area == 'register' ? 'show_reg != 0' : 'show_profile = {string:area}'; |
| 1157 | 1219 | |
@@ -1176,26 +1238,29 @@ discard block |
||
| 1176 | 1238 | - The data is not invisible to users but editable by the owner (or if it is the user is not the owner) |
| 1177 | 1239 | - The area isn't registration, and if it is that the field is not supposed to be shown there. |
| 1178 | 1240 | */ |
| 1179 | - if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) |
|
| 1180 | - continue; |
|
| 1241 | + if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) { |
|
| 1242 | + continue; |
|
| 1243 | + } |
|
| 1181 | 1244 | |
| 1182 | 1245 | // Validate the user data. |
| 1183 | - if ($row['field_type'] == 'check') |
|
| 1184 | - $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
| 1185 | - elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
| 1246 | + if ($row['field_type'] == 'check') { |
|
| 1247 | + $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
| 1248 | + } elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
| 1186 | 1249 | { |
| 1187 | 1250 | $value = $row['default_value']; |
| 1188 | - foreach (explode(',', $row['field_options']) as $k => $v) |
|
| 1189 | - if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
| 1251 | + foreach (explode(',', $row['field_options']) as $k => $v) { |
|
| 1252 | + if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
| 1190 | 1253 | $value = $v; |
| 1254 | + } |
|
| 1191 | 1255 | } |
| 1192 | 1256 | // Otherwise some form of text! |
| 1193 | 1257 | else |
| 1194 | 1258 | { |
| 1195 | 1259 | $value = isset($_POST['customfield'][$row['col_name']]) ? $_POST['customfield'][$row['col_name']] : ''; |
| 1196 | 1260 | |
| 1197 | - if ($row['field_length']) |
|
| 1198 | - $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
| 1261 | + if ($row['field_length']) { |
|
| 1262 | + $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
| 1263 | + } |
|
| 1199 | 1264 | |
| 1200 | 1265 | // Any masks? |
| 1201 | 1266 | if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none') |
@@ -1204,36 +1269,34 @@ discard block |
||
| 1204 | 1269 | $valueReference = un_htmlspecialchars($value); |
| 1205 | 1270 | |
| 1206 | 1271 | // Try and avoid some checks. '0' could be a valid non-empty value. |
| 1207 | - if (empty($value) && !is_numeric($value)) |
|
| 1208 | - $value = ''; |
|
| 1272 | + if (empty($value) && !is_numeric($value)) { |
|
| 1273 | + $value = ''; |
|
| 1274 | + } |
|
| 1209 | 1275 | |
| 1210 | 1276 | if ($row['mask'] == 'nohtml' && ($valueReference != strip_tags($valueReference) || $value != filter_var($value, FILTER_SANITIZE_STRING) || preg_match('/<(.+?)[\s]*\/?[\s]*>/si', $valueReference))) |
| 1211 | 1277 | { |
| 1212 | - if ($returnErrors) |
|
| 1213 | - $errors[] = 'custom_field_nohtml_fail'; |
|
| 1214 | - |
|
| 1215 | - else |
|
| 1216 | - $value = ''; |
|
| 1217 | - } |
|
| 1218 | - elseif ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
|
| 1278 | + if ($returnErrors) { |
|
| 1279 | + $errors[] = 'custom_field_nohtml_fail'; |
|
| 1280 | + } else { |
|
| 1281 | + $value = ''; |
|
| 1282 | + } |
|
| 1283 | + } elseif ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
|
| 1219 | 1284 | { |
| 1220 | - if ($returnErrors) |
|
| 1221 | - $errors[] = 'custom_field_mail_fail'; |
|
| 1222 | - |
|
| 1223 | - else |
|
| 1224 | - $value = ''; |
|
| 1225 | - } |
|
| 1226 | - elseif ($row['mask'] == 'number') |
|
| 1285 | + if ($returnErrors) { |
|
| 1286 | + $errors[] = 'custom_field_mail_fail'; |
|
| 1287 | + } else { |
|
| 1288 | + $value = ''; |
|
| 1289 | + } |
|
| 1290 | + } elseif ($row['mask'] == 'number') |
|
| 1227 | 1291 | { |
| 1228 | 1292 | $value = (int) $value; |
| 1229 | - } |
|
| 1230 | - elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
| 1293 | + } elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
| 1231 | 1294 | { |
| 1232 | - if ($returnErrors) |
|
| 1233 | - $errors[] = 'custom_field_regex_fail'; |
|
| 1234 | - |
|
| 1235 | - else |
|
| 1236 | - $value = ''; |
|
| 1295 | + if ($returnErrors) { |
|
| 1296 | + $errors[] = 'custom_field_regex_fail'; |
|
| 1297 | + } else { |
|
| 1298 | + $value = ''; |
|
| 1299 | + } |
|
| 1237 | 1300 | } |
| 1238 | 1301 | |
| 1239 | 1302 | unset($valueReference); |
@@ -1261,8 +1324,9 @@ discard block |
||
| 1261 | 1324 | |
| 1262 | 1325 | $hook_errors = call_integration_hook('integrate_save_custom_profile_fields', array(&$changes, &$log_changes, &$errors, $returnErrors, $memID, $area, $sanitize)); |
| 1263 | 1326 | |
| 1264 | - if (!empty($hook_errors) && is_array($hook_errors)) |
|
| 1265 | - $errors = array_merge($errors, $hook_errors); |
|
| 1327 | + if (!empty($hook_errors) && is_array($hook_errors)) { |
|
| 1328 | + $errors = array_merge($errors, $hook_errors); |
|
| 1329 | + } |
|
| 1266 | 1330 | |
| 1267 | 1331 | // Make those changes! |
| 1268 | 1332 | if (!empty($changes) && empty($context['password_auth_failed']) && empty($errors)) |
@@ -1280,9 +1344,10 @@ discard block |
||
| 1280 | 1344 | } |
| 1281 | 1345 | } |
| 1282 | 1346 | |
| 1283 | - if ($returnErrors) |
|
| 1284 | - return $errors; |
|
| 1285 | -} |
|
| 1347 | + if ($returnErrors) { |
|
| 1348 | + return $errors; |
|
| 1349 | + } |
|
| 1350 | + } |
|
| 1286 | 1351 | |
| 1287 | 1352 | /** |
| 1288 | 1353 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1294,8 +1359,9 @@ discard block |
||
| 1294 | 1359 | global $context, $txt, $modSettings; |
| 1295 | 1360 | |
| 1296 | 1361 | // Do a quick check to ensure people aren't getting here illegally! |
| 1297 | - if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) |
|
| 1298 | - fatal_lang_error('no_access', false); |
|
| 1362 | + if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) { |
|
| 1363 | + fatal_lang_error('no_access', false); |
|
| 1364 | + } |
|
| 1299 | 1365 | |
| 1300 | 1366 | // Can we email the user direct? |
| 1301 | 1367 | $context['can_moderate_forum'] = allowedTo('moderate_forum'); |
@@ -1325,9 +1391,10 @@ discard block |
||
| 1325 | 1391 | $context['sub_template'] = $subActions[$context['list_area']][0]; |
| 1326 | 1392 | $call = call_helper($subActions[$context['list_area']][0], true); |
| 1327 | 1393 | |
| 1328 | - if (!empty($call)) |
|
| 1329 | - call_user_func($call, $memID); |
|
| 1330 | -} |
|
| 1394 | + if (!empty($call)) { |
|
| 1395 | + call_user_func($call, $memID); |
|
| 1396 | + } |
|
| 1397 | + } |
|
| 1331 | 1398 | |
| 1332 | 1399 | /** |
| 1333 | 1400 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1341,9 +1408,10 @@ discard block |
||
| 1341 | 1408 | |
| 1342 | 1409 | // For making changes! |
| 1343 | 1410 | $buddiesArray = explode(',', $user_profile[$memID]['buddy_list']); |
| 1344 | - foreach ($buddiesArray as $k => $dummy) |
|
| 1345 | - if ($dummy == '') |
|
| 1411 | + foreach ($buddiesArray as $k => $dummy) { |
|
| 1412 | + if ($dummy == '') |
|
| 1346 | 1413 | unset($buddiesArray[$k]); |
| 1414 | + } |
|
| 1347 | 1415 | |
| 1348 | 1416 | // Removing a buddy? |
| 1349 | 1417 | if (isset($_GET['remove'])) |
@@ -1355,10 +1423,11 @@ discard block |
||
| 1355 | 1423 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
| 1356 | 1424 | |
| 1357 | 1425 | // Heh, I'm lazy, do it the easy way... |
| 1358 | - foreach ($buddiesArray as $key => $buddy) |
|
| 1359 | - if ($buddy == (int) $_GET['remove']) |
|
| 1426 | + foreach ($buddiesArray as $key => $buddy) { |
|
| 1427 | + if ($buddy == (int) $_GET['remove']) |
|
| 1360 | 1428 | { |
| 1361 | 1429 | unset($buddiesArray[$key]); |
| 1430 | + } |
|
| 1362 | 1431 | $_SESSION['prf-save'] = true; |
| 1363 | 1432 | } |
| 1364 | 1433 | |
@@ -1368,8 +1437,7 @@ discard block |
||
| 1368 | 1437 | |
| 1369 | 1438 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
| 1370 | 1439 | redirectexit('action=profile;area=lists;sa=buddies;u=' . $memID); |
| 1371 | - } |
|
| 1372 | - elseif (isset($_POST['new_buddy'])) |
|
| 1440 | + } elseif (isset($_POST['new_buddy'])) |
|
| 1373 | 1441 | { |
| 1374 | 1442 | checkSession(); |
| 1375 | 1443 | |
@@ -1382,8 +1450,9 @@ discard block |
||
| 1382 | 1450 | { |
| 1383 | 1451 | $new_buddies[$k] = strtr(trim($new_buddies[$k]), array('\'' => ''')); |
| 1384 | 1452 | |
| 1385 | - if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
| 1386 | - unset($new_buddies[$k]); |
|
| 1453 | + if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
| 1454 | + unset($new_buddies[$k]); |
|
| 1455 | + } |
|
| 1387 | 1456 | } |
| 1388 | 1457 | |
| 1389 | 1458 | call_integration_hook('integrate_add_buddies', array($memID, &$new_buddies)); |
@@ -1403,16 +1472,18 @@ discard block |
||
| 1403 | 1472 | ) |
| 1404 | 1473 | ); |
| 1405 | 1474 | |
| 1406 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1407 | - $_SESSION['prf-save'] = true; |
|
| 1475 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1476 | + $_SESSION['prf-save'] = true; |
|
| 1477 | + } |
|
| 1408 | 1478 | |
| 1409 | 1479 | // Add the new member to the buddies array. |
| 1410 | 1480 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1411 | 1481 | { |
| 1412 | - if (in_array($row['id_member'], $buddiesArray)) |
|
| 1413 | - continue; |
|
| 1414 | - else |
|
| 1415 | - $buddiesArray[] = (int) $row['id_member']; |
|
| 1482 | + if (in_array($row['id_member'], $buddiesArray)) { |
|
| 1483 | + continue; |
|
| 1484 | + } else { |
|
| 1485 | + $buddiesArray[] = (int) $row['id_member']; |
|
| 1486 | + } |
|
| 1416 | 1487 | } |
| 1417 | 1488 | $smcFunc['db_free_result']($request); |
| 1418 | 1489 | |
@@ -1442,18 +1513,20 @@ discard block |
||
| 1442 | 1513 | |
| 1443 | 1514 | $context['custom_pf'] = array(); |
| 1444 | 1515 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); |
| 1445 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1446 | - if (!isset($disabled_fields[$row['col_name']])) |
|
| 1516 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1517 | + if (!isset($disabled_fields[$row['col_name']])) |
|
| 1447 | 1518 | $context['custom_pf'][$row['col_name']] = array( |
| 1448 | 1519 | 'label' => $row['field_name'], |
| 1449 | 1520 | 'type' => $row['field_type'], |
| 1450 | 1521 | 'bbc' => !empty($row['bbc']), |
| 1451 | 1522 | 'enclose' => $row['enclose'], |
| 1452 | 1523 | ); |
| 1524 | + } |
|
| 1453 | 1525 | |
| 1454 | 1526 | // Gotta disable the gender option. |
| 1455 | - if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled') |
|
| 1456 | - unset($context['custom_pf']['cust_gender']); |
|
| 1527 | + if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled') { |
|
| 1528 | + unset($context['custom_pf']['cust_gender']); |
|
| 1529 | + } |
|
| 1457 | 1530 | |
| 1458 | 1531 | $smcFunc['db_free_result']($request); |
| 1459 | 1532 | |
@@ -1470,8 +1543,9 @@ discard block |
||
| 1470 | 1543 | 'buddy_list_count' => substr_count($user_profile[$memID]['buddy_list'], ',') + 1, |
| 1471 | 1544 | ) |
| 1472 | 1545 | ); |
| 1473 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1474 | - $buddies[] = $row['id_member']; |
|
| 1546 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1547 | + $buddies[] = $row['id_member']; |
|
| 1548 | + } |
|
| 1475 | 1549 | $smcFunc['db_free_result']($result); |
| 1476 | 1550 | } |
| 1477 | 1551 | |
@@ -1499,30 +1573,32 @@ discard block |
||
| 1499 | 1573 | continue; |
| 1500 | 1574 | } |
| 1501 | 1575 | |
| 1502 | - if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) |
|
| 1503 | - $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
| 1504 | - |
|
| 1505 | - elseif ($column['type'] == 'check') |
|
| 1506 | - $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 1576 | + if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
| 1577 | + $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
| 1578 | + } elseif ($column['type'] == 'check') { |
|
| 1579 | + $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 1580 | + } |
|
| 1507 | 1581 | |
| 1508 | 1582 | // Enclosing the user input within some other text? |
| 1509 | - if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) |
|
| 1510 | - $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
| 1583 | + if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
| 1584 | + $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
| 1511 | 1585 | '{SCRIPTURL}' => $scripturl, |
| 1512 | 1586 | '{IMAGES_URL}' => $settings['images_url'], |
| 1513 | 1587 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1514 | 1588 | '{INPUT}' => $context['buddies'][$buddy]['options'][$key], |
| 1515 | 1589 | )); |
| 1590 | + } |
|
| 1516 | 1591 | } |
| 1517 | 1592 | } |
| 1518 | 1593 | } |
| 1519 | 1594 | |
| 1520 | 1595 | if (isset($_SESSION['prf-save'])) |
| 1521 | 1596 | { |
| 1522 | - if ($_SESSION['prf-save'] === true) |
|
| 1523 | - $context['saved_successful'] = true; |
|
| 1524 | - else |
|
| 1525 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1597 | + if ($_SESSION['prf-save'] === true) { |
|
| 1598 | + $context['saved_successful'] = true; |
|
| 1599 | + } else { |
|
| 1600 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1601 | + } |
|
| 1526 | 1602 | |
| 1527 | 1603 | unset($_SESSION['prf-save']); |
| 1528 | 1604 | } |
@@ -1542,9 +1618,10 @@ discard block |
||
| 1542 | 1618 | |
| 1543 | 1619 | // For making changes! |
| 1544 | 1620 | $ignoreArray = explode(',', $user_profile[$memID]['pm_ignore_list']); |
| 1545 | - foreach ($ignoreArray as $k => $dummy) |
|
| 1546 | - if ($dummy == '') |
|
| 1621 | + foreach ($ignoreArray as $k => $dummy) { |
|
| 1622 | + if ($dummy == '') |
|
| 1547 | 1623 | unset($ignoreArray[$k]); |
| 1624 | + } |
|
| 1548 | 1625 | |
| 1549 | 1626 | // Removing a member from the ignore list? |
| 1550 | 1627 | if (isset($_GET['remove'])) |
@@ -1554,10 +1631,11 @@ discard block |
||
| 1554 | 1631 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
| 1555 | 1632 | |
| 1556 | 1633 | // Heh, I'm lazy, do it the easy way... |
| 1557 | - foreach ($ignoreArray as $key => $id_remove) |
|
| 1558 | - if ($id_remove == (int) $_GET['remove']) |
|
| 1634 | + foreach ($ignoreArray as $key => $id_remove) { |
|
| 1635 | + if ($id_remove == (int) $_GET['remove']) |
|
| 1559 | 1636 | { |
| 1560 | 1637 | unset($ignoreArray[$key]); |
| 1638 | + } |
|
| 1561 | 1639 | $_SESSION['prf-save'] = true; |
| 1562 | 1640 | } |
| 1563 | 1641 | |
@@ -1567,8 +1645,7 @@ discard block |
||
| 1567 | 1645 | |
| 1568 | 1646 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
| 1569 | 1647 | redirectexit('action=profile;area=lists;sa=ignore;u=' . $memID); |
| 1570 | - } |
|
| 1571 | - elseif (isset($_POST['new_ignore'])) |
|
| 1648 | + } elseif (isset($_POST['new_ignore'])) |
|
| 1572 | 1649 | { |
| 1573 | 1650 | checkSession(); |
| 1574 | 1651 | // Prepare the string for extraction... |
@@ -1580,8 +1657,9 @@ discard block |
||
| 1580 | 1657 | { |
| 1581 | 1658 | $new_entries[$k] = strtr(trim($new_entries[$k]), array('\'' => ''')); |
| 1582 | 1659 | |
| 1583 | - if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
| 1584 | - unset($new_entries[$k]); |
|
| 1660 | + if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
| 1661 | + unset($new_entries[$k]); |
|
| 1662 | + } |
|
| 1585 | 1663 | } |
| 1586 | 1664 | |
| 1587 | 1665 | $_SESSION['prf-save'] = $txt['could_not_add_person']; |
@@ -1599,16 +1677,18 @@ discard block |
||
| 1599 | 1677 | ) |
| 1600 | 1678 | ); |
| 1601 | 1679 | |
| 1602 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1603 | - $_SESSION['prf-save'] = true; |
|
| 1680 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1681 | + $_SESSION['prf-save'] = true; |
|
| 1682 | + } |
|
| 1604 | 1683 | |
| 1605 | 1684 | // Add the new member to the buddies array. |
| 1606 | 1685 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1607 | 1686 | { |
| 1608 | - if (in_array($row['id_member'], $ignoreArray)) |
|
| 1609 | - continue; |
|
| 1610 | - else |
|
| 1611 | - $ignoreArray[] = (int) $row['id_member']; |
|
| 1687 | + if (in_array($row['id_member'], $ignoreArray)) { |
|
| 1688 | + continue; |
|
| 1689 | + } else { |
|
| 1690 | + $ignoreArray[] = (int) $row['id_member']; |
|
| 1691 | + } |
|
| 1612 | 1692 | } |
| 1613 | 1693 | $smcFunc['db_free_result']($request); |
| 1614 | 1694 | |
@@ -1637,8 +1717,9 @@ discard block |
||
| 1637 | 1717 | 'ignore_list_count' => substr_count($user_profile[$memID]['pm_ignore_list'], ',') + 1, |
| 1638 | 1718 | ) |
| 1639 | 1719 | ); |
| 1640 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1641 | - $ignored[] = $row['id_member']; |
|
| 1720 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1721 | + $ignored[] = $row['id_member']; |
|
| 1722 | + } |
|
| 1642 | 1723 | $smcFunc['db_free_result']($result); |
| 1643 | 1724 | } |
| 1644 | 1725 | |
@@ -1657,10 +1738,11 @@ discard block |
||
| 1657 | 1738 | |
| 1658 | 1739 | if (isset($_SESSION['prf-save'])) |
| 1659 | 1740 | { |
| 1660 | - if ($_SESSION['prf-save'] === true) |
|
| 1661 | - $context['saved_successful'] = true; |
|
| 1662 | - else |
|
| 1663 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1741 | + if ($_SESSION['prf-save'] === true) { |
|
| 1742 | + $context['saved_successful'] = true; |
|
| 1743 | + } else { |
|
| 1744 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1745 | + } |
|
| 1664 | 1746 | |
| 1665 | 1747 | unset($_SESSION['prf-save']); |
| 1666 | 1748 | } |
@@ -1676,8 +1758,9 @@ discard block |
||
| 1676 | 1758 | global $context, $txt; |
| 1677 | 1759 | |
| 1678 | 1760 | loadThemeOptions($memID); |
| 1679 | - if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) |
|
| 1680 | - loadCustomFields($memID, 'account'); |
|
| 1761 | + if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) { |
|
| 1762 | + loadCustomFields($memID, 'account'); |
|
| 1763 | + } |
|
| 1681 | 1764 | |
| 1682 | 1765 | $context['sub_template'] = 'edit_options'; |
| 1683 | 1766 | $context['page_desc'] = $txt['account_info']; |
@@ -1704,8 +1787,9 @@ discard block |
||
| 1704 | 1787 | global $context, $txt; |
| 1705 | 1788 | |
| 1706 | 1789 | loadThemeOptions($memID); |
| 1707 | - if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) |
|
| 1708 | - loadCustomFields($memID, 'forumprofile'); |
|
| 1790 | + if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) { |
|
| 1791 | + loadCustomFields($memID, 'forumprofile'); |
|
| 1792 | + } |
|
| 1709 | 1793 | |
| 1710 | 1794 | $context['sub_template'] = 'edit_options'; |
| 1711 | 1795 | $context['page_desc'] = $txt['forumProfile_info']; |
@@ -1738,18 +1822,21 @@ discard block |
||
| 1738 | 1822 | $dirs = array(); |
| 1739 | 1823 | $files = array(); |
| 1740 | 1824 | |
| 1741 | - if (!$dir) |
|
| 1742 | - return array(); |
|
| 1825 | + if (!$dir) { |
|
| 1826 | + return array(); |
|
| 1827 | + } |
|
| 1743 | 1828 | |
| 1744 | 1829 | while ($line = $dir->read()) |
| 1745 | 1830 | { |
| 1746 | - if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) |
|
| 1747 | - continue; |
|
| 1831 | + if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) { |
|
| 1832 | + continue; |
|
| 1833 | + } |
|
| 1748 | 1834 | |
| 1749 | - if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) |
|
| 1750 | - $dirs[] = $line; |
|
| 1751 | - else |
|
| 1752 | - $files[] = $line; |
|
| 1835 | + if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) { |
|
| 1836 | + $dirs[] = $line; |
|
| 1837 | + } else { |
|
| 1838 | + $files[] = $line; |
|
| 1839 | + } |
|
| 1753 | 1840 | } |
| 1754 | 1841 | $dir->close(); |
| 1755 | 1842 | |
@@ -1770,14 +1857,15 @@ discard block |
||
| 1770 | 1857 | foreach ($dirs as $line) |
| 1771 | 1858 | { |
| 1772 | 1859 | $tmp = getAvatars($directory . (!empty($directory) ? '/' : '') . $line, $level + 1); |
| 1773 | - if (!empty($tmp)) |
|
| 1774 | - $result[] = array( |
|
| 1860 | + if (!empty($tmp)) { |
|
| 1861 | + $result[] = array( |
|
| 1775 | 1862 | 'filename' => $smcFunc['htmlspecialchars']($line), |
| 1776 | 1863 | 'checked' => strpos($context['member']['avatar']['server_pic'], $line . '/') !== false, |
| 1777 | 1864 | 'name' => '[' . $smcFunc['htmlspecialchars'](str_replace('_', ' ', $line)) . ']', |
| 1778 | 1865 | 'is_dir' => true, |
| 1779 | 1866 | 'files' => $tmp |
| 1780 | 1867 | ); |
| 1868 | + } |
|
| 1781 | 1869 | unset($tmp); |
| 1782 | 1870 | } |
| 1783 | 1871 | |
@@ -1787,8 +1875,9 @@ discard block |
||
| 1787 | 1875 | $extension = substr(strrchr($line, '.'), 1); |
| 1788 | 1876 | |
| 1789 | 1877 | // Make sure it is an image. |
| 1790 | - if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) |
|
| 1791 | - continue; |
|
| 1878 | + if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) { |
|
| 1879 | + continue; |
|
| 1880 | + } |
|
| 1792 | 1881 | |
| 1793 | 1882 | $result[] = array( |
| 1794 | 1883 | 'filename' => $smcFunc['htmlspecialchars']($line), |
@@ -1796,8 +1885,9 @@ discard block |
||
| 1796 | 1885 | 'name' => $smcFunc['htmlspecialchars'](str_replace('_', ' ', $filename)), |
| 1797 | 1886 | 'is_dir' => false |
| 1798 | 1887 | ); |
| 1799 | - if ($level == 1) |
|
| 1800 | - $context['avatar_list'][] = $directory . '/' . $line; |
|
| 1888 | + if ($level == 1) { |
|
| 1889 | + $context['avatar_list'][] = $directory . '/' . $line; |
|
| 1890 | + } |
|
| 1801 | 1891 | } |
| 1802 | 1892 | |
| 1803 | 1893 | return $result; |
@@ -1816,8 +1906,9 @@ discard block |
||
| 1816 | 1906 | loadSubTemplate('options'); |
| 1817 | 1907 | |
| 1818 | 1908 | loadThemeOptions($memID); |
| 1819 | - if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) |
|
| 1820 | - loadCustomFields($memID, 'theme'); |
|
| 1909 | + if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) { |
|
| 1910 | + loadCustomFields($memID, 'theme'); |
|
| 1911 | + } |
|
| 1821 | 1912 | |
| 1822 | 1913 | $context['sub_template'] = 'edit_options'; |
| 1823 | 1914 | $context['page_desc'] = $txt['theme_info']; |
@@ -1871,16 +1962,19 @@ discard block |
||
| 1871 | 1962 | { |
| 1872 | 1963 | global $txt, $context, $modSettings, $smcFunc, $sourcedir; |
| 1873 | 1964 | |
| 1874 | - if (!isset($context['token_check'])) |
|
| 1875 | - $context['token_check'] = 'profile-nt' . $memID; |
|
| 1965 | + if (!isset($context['token_check'])) { |
|
| 1966 | + $context['token_check'] = 'profile-nt' . $memID; |
|
| 1967 | + } |
|
| 1876 | 1968 | |
| 1877 | 1969 | is_not_guest(); |
| 1878 | - if (!$context['user']['is_owner']) |
|
| 1879 | - isAllowedTo('profile_extra_any'); |
|
| 1970 | + if (!$context['user']['is_owner']) { |
|
| 1971 | + isAllowedTo('profile_extra_any'); |
|
| 1972 | + } |
|
| 1880 | 1973 | |
| 1881 | 1974 | // Set the post action if we're coming from the profile... |
| 1882 | - if (!isset($context['action'])) |
|
| 1883 | - $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
| 1975 | + if (!isset($context['action'])) { |
|
| 1976 | + $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
| 1977 | + } |
|
| 1884 | 1978 | |
| 1885 | 1979 | // What options are set |
| 1886 | 1980 | loadThemeOptions($memID); |
@@ -1967,28 +2061,34 @@ discard block |
||
| 1967 | 2061 | ); |
| 1968 | 2062 | |
| 1969 | 2063 | // There are certain things that are disabled at the group level. |
| 1970 | - if (empty($modSettings['cal_enabled'])) |
|
| 1971 | - unset($alert_types['calendar']); |
|
| 2064 | + if (empty($modSettings['cal_enabled'])) { |
|
| 2065 | + unset($alert_types['calendar']); |
|
| 2066 | + } |
|
| 1972 | 2067 | |
| 1973 | 2068 | // Disable paid subscriptions at group level if they're disabled |
| 1974 | - if (empty($modSettings['paid_enabled'])) |
|
| 1975 | - unset($alert_types['paidsubs']); |
|
| 2069 | + if (empty($modSettings['paid_enabled'])) { |
|
| 2070 | + unset($alert_types['paidsubs']); |
|
| 2071 | + } |
|
| 1976 | 2072 | |
| 1977 | 2073 | // Disable membergroup requests at group level if they're disabled |
| 1978 | - if (empty($modSettings['show_group_membership'])) |
|
| 1979 | - unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
| 2074 | + if (empty($modSettings['show_group_membership'])) { |
|
| 2075 | + unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
| 2076 | + } |
|
| 1980 | 2077 | |
| 1981 | 2078 | // Disable mentions if they're disabled |
| 1982 | - if (empty($modSettings['enable_mentions'])) |
|
| 1983 | - unset($alert_types['msg']['msg_mention']); |
|
| 2079 | + if (empty($modSettings['enable_mentions'])) { |
|
| 2080 | + unset($alert_types['msg']['msg_mention']); |
|
| 2081 | + } |
|
| 1984 | 2082 | |
| 1985 | 2083 | // Disable likes if they're disabled |
| 1986 | - if (empty($modSettings['enable_likes'])) |
|
| 1987 | - unset($alert_types['msg']['msg_like']); |
|
| 2084 | + if (empty($modSettings['enable_likes'])) { |
|
| 2085 | + unset($alert_types['msg']['msg_like']); |
|
| 2086 | + } |
|
| 1988 | 2087 | |
| 1989 | 2088 | // Disable buddy requests if they're disabled |
| 1990 | - if (empty($modSettings['enable_buddylist'])) |
|
| 1991 | - unset($alert_types['members']['buddy_request']); |
|
| 2089 | + if (empty($modSettings['enable_buddylist'])) { |
|
| 2090 | + unset($alert_types['members']['buddy_request']); |
|
| 2091 | + } |
|
| 1992 | 2092 | |
| 1993 | 2093 | // Now, now, we could pass this through global but we should really get into the habit of |
| 1994 | 2094 | // passing content to hooks, not expecting hooks to splatter everything everywhere. |
@@ -2016,15 +2116,17 @@ discard block |
||
| 2016 | 2116 | $perms_cache['manage_membergroups'] = in_array($memID, $members); |
| 2017 | 2117 | } |
| 2018 | 2118 | |
| 2019 | - if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) |
|
| 2020 | - unset($alert_types['members']['request_group']); |
|
| 2119 | + if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) { |
|
| 2120 | + unset($alert_types['members']['request_group']); |
|
| 2121 | + } |
|
| 2021 | 2122 | |
| 2022 | 2123 | foreach ($alert_types as $group => $items) |
| 2023 | 2124 | { |
| 2024 | 2125 | foreach ($items as $alert_key => $alert_value) |
| 2025 | 2126 | { |
| 2026 | - if (!isset($alert_value['permission'])) |
|
| 2027 | - continue; |
|
| 2127 | + if (!isset($alert_value['permission'])) { |
|
| 2128 | + continue; |
|
| 2129 | + } |
|
| 2028 | 2130 | if (!isset($perms_cache[$alert_value['permission']['name']])) |
| 2029 | 2131 | { |
| 2030 | 2132 | $in_board = !empty($alert_value['permission']['is_board']) ? 0 : null; |
@@ -2032,12 +2134,14 @@ discard block |
||
| 2032 | 2134 | $perms_cache[$alert_value['permission']['name']] = in_array($memID, $members); |
| 2033 | 2135 | } |
| 2034 | 2136 | |
| 2035 | - if (!$perms_cache[$alert_value['permission']['name']]) |
|
| 2036 | - unset ($alert_types[$group][$alert_key]); |
|
| 2137 | + if (!$perms_cache[$alert_value['permission']['name']]) { |
|
| 2138 | + unset ($alert_types[$group][$alert_key]); |
|
| 2139 | + } |
|
| 2037 | 2140 | } |
| 2038 | 2141 | |
| 2039 | - if (empty($alert_types[$group])) |
|
| 2040 | - unset ($alert_types[$group]); |
|
| 2142 | + if (empty($alert_types[$group])) { |
|
| 2143 | + unset ($alert_types[$group]); |
|
| 2144 | + } |
|
| 2041 | 2145 | } |
| 2042 | 2146 | } |
| 2043 | 2147 | |
@@ -2069,9 +2173,9 @@ discard block |
||
| 2069 | 2173 | $update_prefs[$this_option[1]] = !empty($_POST['opt_' . $this_option[1]]) ? 1 : 0; |
| 2070 | 2174 | break; |
| 2071 | 2175 | case 'select': |
| 2072 | - if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) |
|
| 2073 | - $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
| 2074 | - else |
|
| 2176 | + if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) { |
|
| 2177 | + $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
| 2178 | + } else |
|
| 2075 | 2179 | { |
| 2076 | 2180 | // We didn't have a sane value. Let's grab the first item from the possibles. |
| 2077 | 2181 | $keys = array_keys($this_option['opts']); |
@@ -2091,23 +2195,28 @@ discard block |
||
| 2091 | 2195 | $this_value = 0; |
| 2092 | 2196 | foreach ($context['alert_bits'] as $type => $bitvalue) |
| 2093 | 2197 | { |
| 2094 | - if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') |
|
| 2095 | - $this_value |= $bitvalue; |
|
| 2198 | + if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') { |
|
| 2199 | + $this_value |= $bitvalue; |
|
| 2200 | + } |
|
| 2201 | + } |
|
| 2202 | + if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) { |
|
| 2203 | + $update_prefs[$item_key] = $this_value; |
|
| 2096 | 2204 | } |
| 2097 | - if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) |
|
| 2098 | - $update_prefs[$item_key] = $this_value; |
|
| 2099 | 2205 | } |
| 2100 | 2206 | } |
| 2101 | 2207 | |
| 2102 | - if (!empty($_POST['opt_alert_timeout'])) |
|
| 2103 | - $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
| 2208 | + if (!empty($_POST['opt_alert_timeout'])) { |
|
| 2209 | + $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
| 2210 | + } |
|
| 2104 | 2211 | |
| 2105 | - if (!empty($_POST['notify_announcements'])) |
|
| 2106 | - $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
| 2212 | + if (!empty($_POST['notify_announcements'])) { |
|
| 2213 | + $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
| 2214 | + } |
|
| 2107 | 2215 | |
| 2108 | 2216 | setNotifyPrefs((int) $memID, $update_prefs); |
| 2109 | - foreach ($update_prefs as $pref => $value) |
|
| 2110 | - $context['alert_prefs'][$pref] = $value; |
|
| 2217 | + foreach ($update_prefs as $pref => $value) { |
|
| 2218 | + $context['alert_prefs'][$pref] = $value; |
|
| 2219 | + } |
|
| 2111 | 2220 | |
| 2112 | 2221 | makeNotificationChanges($memID); |
| 2113 | 2222 | |
@@ -2137,8 +2246,9 @@ discard block |
||
| 2137 | 2246 | |
| 2138 | 2247 | // Now we're all set up. |
| 2139 | 2248 | is_not_guest(); |
| 2140 | - if (!$context['user']['is_owner']) |
|
| 2141 | - fatal_error('no_access'); |
|
| 2249 | + if (!$context['user']['is_owner']) { |
|
| 2250 | + fatal_error('no_access'); |
|
| 2251 | + } |
|
| 2142 | 2252 | |
| 2143 | 2253 | checkSession('get'); |
| 2144 | 2254 | |
@@ -2170,8 +2280,9 @@ discard block |
||
| 2170 | 2280 | { |
| 2171 | 2281 | global $smcFunc; |
| 2172 | 2282 | |
| 2173 | - if (empty($toMark) || empty($memID)) |
|
| 2174 | - return false; |
|
| 2283 | + if (empty($toMark) || empty($memID)) { |
|
| 2284 | + return false; |
|
| 2285 | + } |
|
| 2175 | 2286 | |
| 2176 | 2287 | $toMark = (array) $toMark; |
| 2177 | 2288 | |
@@ -2205,8 +2316,9 @@ discard block |
||
| 2205 | 2316 | { |
| 2206 | 2317 | global $smcFunc; |
| 2207 | 2318 | |
| 2208 | - if (empty($toDelete)) |
|
| 2209 | - return false; |
|
| 2319 | + if (empty($toDelete)) { |
|
| 2320 | + return false; |
|
| 2321 | + } |
|
| 2210 | 2322 | |
| 2211 | 2323 | $toDelete = (array) $toDelete; |
| 2212 | 2324 | |
@@ -2241,8 +2353,9 @@ discard block |
||
| 2241 | 2353 | { |
| 2242 | 2354 | global $smcFunc; |
| 2243 | 2355 | |
| 2244 | - if (empty($memID)) |
|
| 2245 | - return false; |
|
| 2356 | + if (empty($memID)) { |
|
| 2357 | + return false; |
|
| 2358 | + } |
|
| 2246 | 2359 | |
| 2247 | 2360 | $request = $smcFunc['db_query']('', ' |
| 2248 | 2361 | SELECT id_alert |
@@ -2319,8 +2432,9 @@ discard block |
||
| 2319 | 2432 | { |
| 2320 | 2433 | $link = $topic['link']; |
| 2321 | 2434 | |
| 2322 | - if ($topic['new']) |
|
| 2323 | - $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2435 | + if ($topic['new']) { |
|
| 2436 | + $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2437 | + } |
|
| 2324 | 2438 | |
| 2325 | 2439 | $link .= '<br><span class="smalltext"><em>' . $txt['in'] . ' ' . $topic['board_link'] . '</em></span>'; |
| 2326 | 2440 | |
@@ -2471,8 +2585,9 @@ discard block |
||
| 2471 | 2585 | { |
| 2472 | 2586 | $link = $board['link']; |
| 2473 | 2587 | |
| 2474 | - if ($board['new']) |
|
| 2475 | - $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2588 | + if ($board['new']) { |
|
| 2589 | + $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2590 | + } |
|
| 2476 | 2591 | |
| 2477 | 2592 | return $link; |
| 2478 | 2593 | }, |
@@ -2672,8 +2787,8 @@ discard block |
||
| 2672 | 2787 | ) |
| 2673 | 2788 | ); |
| 2674 | 2789 | $notification_boards = array(); |
| 2675 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2676 | - $notification_boards[] = array( |
|
| 2790 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2791 | + $notification_boards[] = array( |
|
| 2677 | 2792 | 'id' => $row['id_board'], |
| 2678 | 2793 | 'name' => $row['name'], |
| 2679 | 2794 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
@@ -2681,6 +2796,7 @@ discard block |
||
| 2681 | 2796 | 'new' => $row['board_read'] < $row['id_msg_updated'], |
| 2682 | 2797 | 'notify_pref' => isset($prefs['board_notify_' . $row['id_board']]) ? $prefs['board_notify_' . $row['id_board']] : (!empty($prefs['board_notify']) ? $prefs['board_notify'] : 0), |
| 2683 | 2798 | ); |
| 2799 | + } |
|
| 2684 | 2800 | $smcFunc['db_free_result']($request); |
| 2685 | 2801 | |
| 2686 | 2802 | return $notification_boards; |
@@ -2695,17 +2811,18 @@ discard block |
||
| 2695 | 2811 | { |
| 2696 | 2812 | global $context, $options, $cur_profile, $smcFunc; |
| 2697 | 2813 | |
| 2698 | - if (isset($_POST['default_options'])) |
|
| 2699 | - $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
| 2814 | + if (isset($_POST['default_options'])) { |
|
| 2815 | + $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
| 2816 | + } |
|
| 2700 | 2817 | |
| 2701 | 2818 | if ($context['user']['is_owner']) |
| 2702 | 2819 | { |
| 2703 | 2820 | $context['member']['options'] = $options; |
| 2704 | - if (isset($_POST['options']) && is_array($_POST['options'])) |
|
| 2705 | - foreach ($_POST['options'] as $k => $v) |
|
| 2821 | + if (isset($_POST['options']) && is_array($_POST['options'])) { |
|
| 2822 | + foreach ($_POST['options'] as $k => $v) |
|
| 2706 | 2823 | $context['member']['options'][$k] = $v; |
| 2707 | - } |
|
| 2708 | - else |
|
| 2824 | + } |
|
| 2825 | + } else |
|
| 2709 | 2826 | { |
| 2710 | 2827 | $request = $smcFunc['db_query']('', ' |
| 2711 | 2828 | SELECT id_member, variable, value |
@@ -2726,8 +2843,9 @@ discard block |
||
| 2726 | 2843 | continue; |
| 2727 | 2844 | } |
| 2728 | 2845 | |
| 2729 | - if (isset($_POST['options'][$row['variable']])) |
|
| 2730 | - $row['value'] = $_POST['options'][$row['variable']]; |
|
| 2846 | + if (isset($_POST['options'][$row['variable']])) { |
|
| 2847 | + $row['value'] = $_POST['options'][$row['variable']]; |
|
| 2848 | + } |
|
| 2731 | 2849 | $context['member']['options'][$row['variable']] = $row['value']; |
| 2732 | 2850 | } |
| 2733 | 2851 | $smcFunc['db_free_result']($request); |
@@ -2735,8 +2853,9 @@ discard block |
||
| 2735 | 2853 | // Load up the default theme options for any missing. |
| 2736 | 2854 | foreach ($temp as $k => $v) |
| 2737 | 2855 | { |
| 2738 | - if (!isset($context['member']['options'][$k])) |
|
| 2739 | - $context['member']['options'][$k] = $v; |
|
| 2856 | + if (!isset($context['member']['options'][$k])) { |
|
| 2857 | + $context['member']['options'][$k] = $v; |
|
| 2858 | + } |
|
| 2740 | 2859 | } |
| 2741 | 2860 | } |
| 2742 | 2861 | } |
@@ -2751,8 +2870,9 @@ discard block |
||
| 2751 | 2870 | global $context, $modSettings, $smcFunc, $cur_profile, $sourcedir; |
| 2752 | 2871 | |
| 2753 | 2872 | // Have the admins enabled this option? |
| 2754 | - if (empty($modSettings['allow_ignore_boards'])) |
|
| 2755 | - fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
| 2873 | + if (empty($modSettings['allow_ignore_boards'])) { |
|
| 2874 | + fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
| 2875 | + } |
|
| 2756 | 2876 | |
| 2757 | 2877 | // Find all the boards this user is allowed to see. |
| 2758 | 2878 | $request = $smcFunc['db_query']('order_by_board_order', ' |
@@ -2772,12 +2892,13 @@ discard block |
||
| 2772 | 2892 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2773 | 2893 | { |
| 2774 | 2894 | // This category hasn't been set up yet.. |
| 2775 | - if (!isset($context['categories'][$row['id_cat']])) |
|
| 2776 | - $context['categories'][$row['id_cat']] = array( |
|
| 2895 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
| 2896 | + $context['categories'][$row['id_cat']] = array( |
|
| 2777 | 2897 | 'id' => $row['id_cat'], |
| 2778 | 2898 | 'name' => $row['cat_name'], |
| 2779 | 2899 | 'boards' => array() |
| 2780 | 2900 | ); |
| 2901 | + } |
|
| 2781 | 2902 | |
| 2782 | 2903 | // Set this board up, and let the template know when it's a child. (indent them..) |
| 2783 | 2904 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -2807,18 +2928,20 @@ discard block |
||
| 2807 | 2928 | } |
| 2808 | 2929 | |
| 2809 | 2930 | $max_boards = ceil(count($temp_boards) / 2); |
| 2810 | - if ($max_boards == 1) |
|
| 2811 | - $max_boards = 2; |
|
| 2931 | + if ($max_boards == 1) { |
|
| 2932 | + $max_boards = 2; |
|
| 2933 | + } |
|
| 2812 | 2934 | |
| 2813 | 2935 | // Now, alternate them so they can be shown left and right ;). |
| 2814 | 2936 | $context['board_columns'] = array(); |
| 2815 | 2937 | for ($i = 0; $i < $max_boards; $i++) |
| 2816 | 2938 | { |
| 2817 | 2939 | $context['board_columns'][] = $temp_boards[$i]; |
| 2818 | - if (isset($temp_boards[$i + $max_boards])) |
|
| 2819 | - $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
| 2820 | - else |
|
| 2821 | - $context['board_columns'][] = array(); |
|
| 2940 | + if (isset($temp_boards[$i + $max_boards])) { |
|
| 2941 | + $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
| 2942 | + } else { |
|
| 2943 | + $context['board_columns'][] = array(); |
|
| 2944 | + } |
|
| 2822 | 2945 | } |
| 2823 | 2946 | |
| 2824 | 2947 | loadThemeOptions($memID); |
@@ -2887,8 +3010,9 @@ discard block |
||
| 2887 | 3010 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2888 | 3011 | { |
| 2889 | 3012 | // We should skip the administrator group if they don't have the admin_forum permission! |
| 2890 | - if ($row['id_group'] == 1 && !allowedTo('admin_forum')) |
|
| 2891 | - continue; |
|
| 3013 | + if ($row['id_group'] == 1 && !allowedTo('admin_forum')) { |
|
| 3014 | + continue; |
|
| 3015 | + } |
|
| 2892 | 3016 | |
| 2893 | 3017 | $context['member_groups'][$row['id_group']] = array( |
| 2894 | 3018 | 'id' => $row['id_group'], |
@@ -2934,16 +3058,17 @@ discard block |
||
| 2934 | 3058 | $context['max_signature_length'] = $context['signature_limits']['max_length']; |
| 2935 | 3059 | // Warning message for signature image limits? |
| 2936 | 3060 | $context['signature_warning'] = ''; |
| 2937 | - if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) |
|
| 2938 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
| 2939 | - elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) |
|
| 2940 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); |
|
| 3061 | + if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) { |
|
| 3062 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
| 3063 | + } elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) { |
|
| 3064 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); |
|
| 3065 | + } |
|
| 2941 | 3066 | |
| 2942 | 3067 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
| 2943 | 3068 | |
| 2944 | - if (empty($context['do_preview'])) |
|
| 2945 | - $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
| 2946 | - else |
|
| 3069 | + if (empty($context['do_preview'])) { |
|
| 3070 | + $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
| 3071 | + } else |
|
| 2947 | 3072 | { |
| 2948 | 3073 | $signature = !empty($_POST['signature']) ? $_POST['signature'] : ''; |
| 2949 | 3074 | $validation = profileValidateSignature($signature); |
@@ -2953,8 +3078,9 @@ discard block |
||
| 2953 | 3078 | $context['post_errors'] = array(); |
| 2954 | 3079 | } |
| 2955 | 3080 | $context['post_errors'][] = 'signature_not_yet_saved'; |
| 2956 | - if ($validation !== true && $validation !== false) |
|
| 2957 | - $context['post_errors'][] = $validation; |
|
| 3081 | + if ($validation !== true && $validation !== false) { |
|
| 3082 | + $context['post_errors'][] = $validation; |
|
| 3083 | + } |
|
| 2958 | 3084 | |
| 2959 | 3085 | censorText($context['member']['signature']); |
| 2960 | 3086 | $context['member']['current_signature'] = $context['member']['signature']; |
@@ -2964,8 +3090,9 @@ discard block |
||
| 2964 | 3090 | } |
| 2965 | 3091 | |
| 2966 | 3092 | // Load the spell checker? |
| 2967 | - if ($context['show_spellchecking']) |
|
| 2968 | - loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
| 3093 | + if ($context['show_spellchecking']) { |
|
| 3094 | + loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
| 3095 | + } |
|
| 2969 | 3096 | |
| 2970 | 3097 | return true; |
| 2971 | 3098 | } |
@@ -2999,8 +3126,7 @@ discard block |
||
| 2999 | 3126 | 'external' => $cur_profile['avatar'] == 'gravatar://' || empty($modSettings['gravatarAllowExtraEmail']) || !empty($modSettings['gravatarOverride']) ? $cur_profile['email_address'] : substr($cur_profile['avatar'], 11) |
| 3000 | 3127 | ); |
| 3001 | 3128 | $context['member']['avatar']['href'] = get_gravatar_url($context['member']['avatar']['external']); |
| 3002 | - } |
|
| 3003 | - elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
| 3129 | + } elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
| 3004 | 3130 | { |
| 3005 | 3131 | $context['member']['avatar'] += array( |
| 3006 | 3132 | 'choice' => 'upload', |
@@ -3010,33 +3136,34 @@ discard block |
||
| 3010 | 3136 | $context['member']['avatar']['href'] = empty($cur_profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $cur_profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $cur_profile['filename']; |
| 3011 | 3137 | } |
| 3012 | 3138 | // Use "avatar_original" here so we show what the user entered even if the image proxy is enabled |
| 3013 | - elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) |
|
| 3014 | - $context['member']['avatar'] += array( |
|
| 3139 | + elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) { |
|
| 3140 | + $context['member']['avatar'] += array( |
|
| 3015 | 3141 | 'choice' => 'external', |
| 3016 | 3142 | 'server_pic' => 'blank.png', |
| 3017 | 3143 | 'external' => $cur_profile['avatar_original'] |
| 3018 | 3144 | ); |
| 3019 | - elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) |
|
| 3020 | - $context['member']['avatar'] += array( |
|
| 3145 | + } elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) { |
|
| 3146 | + $context['member']['avatar'] += array( |
|
| 3021 | 3147 | 'choice' => 'server_stored', |
| 3022 | 3148 | 'server_pic' => $cur_profile['avatar'] == '' ? 'blank.png' : $cur_profile['avatar'], |
| 3023 | 3149 | 'external' => 'http://' |
| 3024 | 3150 | ); |
| 3025 | - else |
|
| 3026 | - $context['member']['avatar'] += array( |
|
| 3151 | + } else { |
|
| 3152 | + $context['member']['avatar'] += array( |
|
| 3027 | 3153 | 'choice' => 'none', |
| 3028 | 3154 | 'server_pic' => 'blank.png', |
| 3029 | 3155 | 'external' => 'http://' |
| 3030 | 3156 | ); |
| 3157 | + } |
|
| 3031 | 3158 | |
| 3032 | 3159 | // Get a list of all the avatars. |
| 3033 | 3160 | if ($context['member']['avatar']['allow_server_stored']) |
| 3034 | 3161 | { |
| 3035 | 3162 | $context['avatar_list'] = array(); |
| 3036 | 3163 | $context['avatars'] = is_dir($modSettings['avatar_directory']) ? getAvatars('', 0) : array(); |
| 3164 | + } else { |
|
| 3165 | + $context['avatars'] = array(); |
|
| 3037 | 3166 | } |
| 3038 | - else |
|
| 3039 | - $context['avatars'] = array(); |
|
| 3040 | 3167 | |
| 3041 | 3168 | // Second level selected avatar... |
| 3042 | 3169 | $context['avatar_selected'] = substr(strrchr($context['member']['avatar']['server_pic'], '/'), 1); |
@@ -3065,19 +3192,22 @@ discard block |
||
| 3065 | 3192 | ) |
| 3066 | 3193 | ); |
| 3067 | 3194 | $protected_groups = array(1); |
| 3068 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3069 | - $protected_groups[] = $row['id_group']; |
|
| 3195 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3196 | + $protected_groups[] = $row['id_group']; |
|
| 3197 | + } |
|
| 3070 | 3198 | $smcFunc['db_free_result']($request); |
| 3071 | 3199 | |
| 3072 | 3200 | $protected_groups = array_unique($protected_groups); |
| 3073 | 3201 | } |
| 3074 | 3202 | |
| 3075 | 3203 | // The account page allows the change of your id_group - but not to a protected group! |
| 3076 | - if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) |
|
| 3077 | - $value = (int) $value; |
|
| 3204 | + if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) { |
|
| 3205 | + $value = (int) $value; |
|
| 3206 | + } |
|
| 3078 | 3207 | // ... otherwise it's the old group sir. |
| 3079 | - else |
|
| 3080 | - $value = $old_profile['id_group']; |
|
| 3208 | + else { |
|
| 3209 | + $value = $old_profile['id_group']; |
|
| 3210 | + } |
|
| 3081 | 3211 | |
| 3082 | 3212 | // Find the additional membergroups (if any) |
| 3083 | 3213 | if (isset($_POST['additional_groups']) && is_array($_POST['additional_groups'])) |
@@ -3086,16 +3216,18 @@ discard block |
||
| 3086 | 3216 | foreach ($_POST['additional_groups'] as $group_id) |
| 3087 | 3217 | { |
| 3088 | 3218 | $group_id = (int) $group_id; |
| 3089 | - if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) |
|
| 3090 | - $additional_groups[] = $group_id; |
|
| 3219 | + if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) { |
|
| 3220 | + $additional_groups[] = $group_id; |
|
| 3221 | + } |
|
| 3091 | 3222 | } |
| 3092 | 3223 | |
| 3093 | 3224 | // Put the protected groups back in there if you don't have permission to take them away. |
| 3094 | 3225 | $old_additional_groups = explode(',', $old_profile['additional_groups']); |
| 3095 | 3226 | foreach ($old_additional_groups as $group_id) |
| 3096 | 3227 | { |
| 3097 | - if (!empty($protected_groups) && in_array($group_id, $protected_groups)) |
|
| 3098 | - $additional_groups[] = $group_id; |
|
| 3228 | + if (!empty($protected_groups) && in_array($group_id, $protected_groups)) { |
|
| 3229 | + $additional_groups[] = $group_id; |
|
| 3230 | + } |
|
| 3099 | 3231 | } |
| 3100 | 3232 | |
| 3101 | 3233 | if (implode(',', $additional_groups) !== $old_profile['additional_groups']) |
@@ -3127,18 +3259,20 @@ discard block |
||
| 3127 | 3259 | list ($another) = $smcFunc['db_fetch_row']($request); |
| 3128 | 3260 | $smcFunc['db_free_result']($request); |
| 3129 | 3261 | |
| 3130 | - if (empty($another)) |
|
| 3131 | - fatal_lang_error('at_least_one_admin', 'critical'); |
|
| 3262 | + if (empty($another)) { |
|
| 3263 | + fatal_lang_error('at_least_one_admin', 'critical'); |
|
| 3264 | + } |
|
| 3132 | 3265 | } |
| 3133 | 3266 | } |
| 3134 | 3267 | |
| 3135 | 3268 | // If we are changing group status, update permission cache as necessary. |
| 3136 | 3269 | if ($value != $old_profile['id_group'] || isset($profile_vars['additional_groups'])) |
| 3137 | 3270 | { |
| 3138 | - if ($context['user']['is_owner']) |
|
| 3139 | - $_SESSION['mc']['time'] = 0; |
|
| 3140 | - else |
|
| 3141 | - updateSettings(array('settings_updated' => time())); |
|
| 3271 | + if ($context['user']['is_owner']) { |
|
| 3272 | + $_SESSION['mc']['time'] = 0; |
|
| 3273 | + } else { |
|
| 3274 | + updateSettings(array('settings_updated' => time())); |
|
| 3275 | + } |
|
| 3142 | 3276 | } |
| 3143 | 3277 | |
| 3144 | 3278 | // Announce to any hooks that we have changed groups, but don't allow them to change it. |
@@ -3159,8 +3293,9 @@ discard block |
||
| 3159 | 3293 | global $modSettings, $sourcedir, $smcFunc, $profile_vars, $cur_profile, $context; |
| 3160 | 3294 | |
| 3161 | 3295 | $memID = $context['id_member']; |
| 3162 | - if (empty($memID) && !empty($context['password_auth_failed'])) |
|
| 3163 | - return false; |
|
| 3296 | + if (empty($memID) && !empty($context['password_auth_failed'])) { |
|
| 3297 | + return false; |
|
| 3298 | + } |
|
| 3164 | 3299 | |
| 3165 | 3300 | require_once($sourcedir . '/ManageAttachments.php'); |
| 3166 | 3301 | |
@@ -3171,8 +3306,9 @@ discard block |
||
| 3171 | 3306 | $downloadedExternalAvatar = false; |
| 3172 | 3307 | if ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && strlen($_POST['userpicpersonal']) > 7 && !empty($modSettings['avatar_download_external'])) |
| 3173 | 3308 | { |
| 3174 | - if (!is_writable($uploadDir)) |
|
| 3175 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3309 | + if (!is_writable($uploadDir)) { |
|
| 3310 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3311 | + } |
|
| 3176 | 3312 | |
| 3177 | 3313 | require_once($sourcedir . '/Subs-Package.php'); |
| 3178 | 3314 | |
@@ -3216,19 +3352,18 @@ discard block |
||
| 3216 | 3352 | |
| 3217 | 3353 | // Get rid of their old avatar. (if uploaded.) |
| 3218 | 3354 | removeAttachments(array('id_member' => $memID)); |
| 3219 | - } |
|
| 3220 | - elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
| 3355 | + } elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
| 3221 | 3356 | { |
| 3222 | 3357 | // One wasn't specified, or it's not allowed to use extra email addresses, or it's not a valid one, reset to default Gravatar. |
| 3223 | - if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) |
|
| 3224 | - $profile_vars['avatar'] = 'gravatar://'; |
|
| 3225 | - else |
|
| 3226 | - $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
| 3358 | + if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) { |
|
| 3359 | + $profile_vars['avatar'] = 'gravatar://'; |
|
| 3360 | + } else { |
|
| 3361 | + $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
| 3362 | + } |
|
| 3227 | 3363 | |
| 3228 | 3364 | // Get rid of their old avatar. (if uploaded.) |
| 3229 | 3365 | removeAttachments(array('id_member' => $memID)); |
| 3230 | - } |
|
| 3231 | - elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
| 3366 | + } elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
| 3232 | 3367 | { |
| 3233 | 3368 | // We need these clean... |
| 3234 | 3369 | $cur_profile['id_attach'] = 0; |
@@ -3240,11 +3375,13 @@ discard block |
||
| 3240 | 3375 | |
| 3241 | 3376 | $profile_vars['avatar'] = str_replace(' ', '%20', preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal'])); |
| 3242 | 3377 | |
| 3243 | - if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') |
|
| 3244 | - $profile_vars['avatar'] = ''; |
|
| 3378 | + if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') { |
|
| 3379 | + $profile_vars['avatar'] = ''; |
|
| 3380 | + } |
|
| 3245 | 3381 | // Trying to make us do something we'll regret? |
| 3246 | - elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') |
|
| 3247 | - return 'bad_avatar_invalid_url'; |
|
| 3382 | + elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') { |
|
| 3383 | + return 'bad_avatar_invalid_url'; |
|
| 3384 | + } |
|
| 3248 | 3385 | // Should we check dimensions? |
| 3249 | 3386 | elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external'])) |
| 3250 | 3387 | { |
@@ -3254,9 +3391,9 @@ discard block |
||
| 3254 | 3391 | if (is_array($sizes) && (($sizes[0] > $modSettings['avatar_max_width_external'] && !empty($modSettings['avatar_max_width_external'])) || ($sizes[1] > $modSettings['avatar_max_height_external'] && !empty($modSettings['avatar_max_height_external'])))) |
| 3255 | 3392 | { |
| 3256 | 3393 | // Houston, we have a problem. The avatar is too large!! |
| 3257 | - if ($modSettings['avatar_action_too_large'] == 'option_refuse') |
|
| 3258 | - return 'bad_avatar_too_large'; |
|
| 3259 | - elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
| 3394 | + if ($modSettings['avatar_action_too_large'] == 'option_refuse') { |
|
| 3395 | + return 'bad_avatar_too_large'; |
|
| 3396 | + } elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
| 3260 | 3397 | { |
| 3261 | 3398 | // @todo remove this if appropriate |
| 3262 | 3399 | require_once($sourcedir . '/Subs-Graphics.php'); |
@@ -3266,26 +3403,27 @@ discard block |
||
| 3266 | 3403 | $cur_profile['id_attach'] = $modSettings['new_avatar_data']['id']; |
| 3267 | 3404 | $cur_profile['filename'] = $modSettings['new_avatar_data']['filename']; |
| 3268 | 3405 | $cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type']; |
| 3406 | + } else { |
|
| 3407 | + return 'bad_avatar'; |
|
| 3269 | 3408 | } |
| 3270 | - else |
|
| 3271 | - return 'bad_avatar'; |
|
| 3272 | 3409 | } |
| 3273 | 3410 | } |
| 3274 | 3411 | } |
| 3275 | - } |
|
| 3276 | - elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
| 3412 | + } elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
| 3277 | 3413 | { |
| 3278 | 3414 | if ((isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '') || $downloadedExternalAvatar) |
| 3279 | 3415 | { |
| 3280 | 3416 | // Get the dimensions of the image. |
| 3281 | 3417 | if (!$downloadedExternalAvatar) |
| 3282 | 3418 | { |
| 3283 | - if (!is_writable($uploadDir)) |
|
| 3284 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3419 | + if (!is_writable($uploadDir)) { |
|
| 3420 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3421 | + } |
|
| 3285 | 3422 | |
| 3286 | 3423 | $new_filename = $uploadDir . '/' . getAttachmentFilename('avatar_tmp_' . $memID, false, null, true); |
| 3287 | - if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) |
|
| 3288 | - fatal_lang_error('attach_timeout', 'critical'); |
|
| 3424 | + if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) { |
|
| 3425 | + fatal_lang_error('attach_timeout', 'critical'); |
|
| 3426 | + } |
|
| 3289 | 3427 | |
| 3290 | 3428 | $_FILES['attachment']['tmp_name'] = $new_filename; |
| 3291 | 3429 | } |
@@ -3398,17 +3536,19 @@ discard block |
||
| 3398 | 3536 | $profile_vars['avatar'] = ''; |
| 3399 | 3537 | |
| 3400 | 3538 | // Delete any temporary file. |
| 3401 | - if (file_exists($_FILES['attachment']['tmp_name'])) |
|
| 3402 | - @unlink($_FILES['attachment']['tmp_name']); |
|
| 3539 | + if (file_exists($_FILES['attachment']['tmp_name'])) { |
|
| 3540 | + @unlink($_FILES['attachment']['tmp_name']); |
|
| 3541 | + } |
|
| 3403 | 3542 | } |
| 3404 | 3543 | // Selected the upload avatar option and had one already uploaded before or didn't upload one. |
| 3405 | - else |
|
| 3544 | + else { |
|
| 3545 | + $profile_vars['avatar'] = ''; |
|
| 3546 | + } |
|
| 3547 | + } elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) { |
|
| 3548 | + $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
| 3549 | + } else { |
|
| 3406 | 3550 | $profile_vars['avatar'] = ''; |
| 3407 | 3551 | } |
| 3408 | - elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) |
|
| 3409 | - $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
| 3410 | - else |
|
| 3411 | - $profile_vars['avatar'] = ''; |
|
| 3412 | 3552 | |
| 3413 | 3553 | // Setup the profile variables so it shows things right on display! |
| 3414 | 3554 | $cur_profile['avatar'] = $profile_vars['avatar']; |
@@ -3456,9 +3596,9 @@ discard block |
||
| 3456 | 3596 | $smiley_parsed = $unparsed_signature; |
| 3457 | 3597 | parsesmileys($smiley_parsed); |
| 3458 | 3598 | $smiley_count = substr_count(strtolower($smiley_parsed), '<img') - substr_count(strtolower($unparsed_signature), '<img'); |
| 3459 | - if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) |
|
| 3460 | - return 'signature_allow_smileys'; |
|
| 3461 | - elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
| 3599 | + if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) { |
|
| 3600 | + return 'signature_allow_smileys'; |
|
| 3601 | + } elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
| 3462 | 3602 | { |
| 3463 | 3603 | $txt['profile_error_signature_max_smileys'] = sprintf($txt['profile_error_signature_max_smileys'], $sig_limits[4]); |
| 3464 | 3604 | return 'signature_max_smileys'; |
@@ -3471,14 +3611,15 @@ discard block |
||
| 3471 | 3611 | { |
| 3472 | 3612 | $limit_broke = 0; |
| 3473 | 3613 | // Attempt to allow all sizes of abuse, so to speak. |
| 3474 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
| 3475 | - $limit_broke = $sig_limits[7] . 'px'; |
|
| 3476 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
| 3477 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 3478 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
| 3479 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 3480 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
| 3481 | - $limit_broke = 'large'; |
|
| 3614 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
| 3615 | + $limit_broke = $sig_limits[7] . 'px'; |
|
| 3616 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
| 3617 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 3618 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
| 3619 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 3620 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
| 3621 | + $limit_broke = 'large'; |
|
| 3622 | + } |
|
| 3482 | 3623 | |
| 3483 | 3624 | if ($limit_broke) |
| 3484 | 3625 | { |
@@ -3520,24 +3661,26 @@ discard block |
||
| 3520 | 3661 | $width = -1; $height = -1; |
| 3521 | 3662 | |
| 3522 | 3663 | // Does it have predefined restraints? Width first. |
| 3523 | - if ($matches[6][$key]) |
|
| 3524 | - $matches[2][$key] = $matches[6][$key]; |
|
| 3664 | + if ($matches[6][$key]) { |
|
| 3665 | + $matches[2][$key] = $matches[6][$key]; |
|
| 3666 | + } |
|
| 3525 | 3667 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
| 3526 | 3668 | { |
| 3527 | 3669 | $width = $sig_limits[5]; |
| 3528 | 3670 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
| 3671 | + } elseif ($matches[2][$key]) { |
|
| 3672 | + $width = $matches[2][$key]; |
|
| 3529 | 3673 | } |
| 3530 | - elseif ($matches[2][$key]) |
|
| 3531 | - $width = $matches[2][$key]; |
|
| 3532 | 3674 | // ... and height. |
| 3533 | 3675 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
| 3534 | 3676 | { |
| 3535 | 3677 | $height = $sig_limits[6]; |
| 3536 | - if ($width != -1) |
|
| 3537 | - $width = $width * ($height / $matches[4][$key]); |
|
| 3678 | + if ($width != -1) { |
|
| 3679 | + $width = $width * ($height / $matches[4][$key]); |
|
| 3680 | + } |
|
| 3681 | + } elseif ($matches[4][$key]) { |
|
| 3682 | + $height = $matches[4][$key]; |
|
| 3538 | 3683 | } |
| 3539 | - elseif ($matches[4][$key]) |
|
| 3540 | - $height = $matches[4][$key]; |
|
| 3541 | 3684 | |
| 3542 | 3685 | // If the dimensions are still not fixed - we need to check the actual image. |
| 3543 | 3686 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -3555,21 +3698,24 @@ discard block |
||
| 3555 | 3698 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
| 3556 | 3699 | { |
| 3557 | 3700 | $height = $sig_limits[6]; |
| 3558 | - if ($width == -1) |
|
| 3559 | - $width = $sizes[0]; |
|
| 3701 | + if ($width == -1) { |
|
| 3702 | + $width = $sizes[0]; |
|
| 3703 | + } |
|
| 3560 | 3704 | $width = $width * ($height / $sizes[1]); |
| 3705 | + } elseif ($width != -1) { |
|
| 3706 | + $height = $sizes[1]; |
|
| 3561 | 3707 | } |
| 3562 | - elseif ($width != -1) |
|
| 3563 | - $height = $sizes[1]; |
|
| 3564 | 3708 | } |
| 3565 | 3709 | } |
| 3566 | 3710 | |
| 3567 | 3711 | // Did we come up with some changes? If so remake the string. |
| 3568 | - if ($width != -1 || $height != -1) |
|
| 3569 | - $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
| 3712 | + if ($width != -1 || $height != -1) { |
|
| 3713 | + $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
| 3714 | + } |
|
| 3715 | + } |
|
| 3716 | + if (!empty($replaces)) { |
|
| 3717 | + $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
| 3570 | 3718 | } |
| 3571 | - if (!empty($replaces)) |
|
| 3572 | - $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
| 3573 | 3719 | } |
| 3574 | 3720 | } |
| 3575 | 3721 | |
@@ -3613,10 +3759,12 @@ discard block |
||
| 3613 | 3759 | $email = strtr($email, array(''' => '\'')); |
| 3614 | 3760 | |
| 3615 | 3761 | // Check the name and email for validity. |
| 3616 | - if (trim($email) == '') |
|
| 3617 | - return 'no_email'; |
|
| 3618 | - if (!filter_var($email, FILTER_VALIDATE_EMAIL)) |
|
| 3619 | - return 'bad_email'; |
|
| 3762 | + if (trim($email) == '') { |
|
| 3763 | + return 'no_email'; |
|
| 3764 | + } |
|
| 3765 | + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
| 3766 | + return 'bad_email'; |
|
| 3767 | + } |
|
| 3620 | 3768 | |
| 3621 | 3769 | // Email addresses should be and stay unique. |
| 3622 | 3770 | $request = $smcFunc['db_query']('', ' |
@@ -3631,8 +3779,9 @@ discard block |
||
| 3631 | 3779 | ) |
| 3632 | 3780 | ); |
| 3633 | 3781 | |
| 3634 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 3635 | - return 'email_taken'; |
|
| 3782 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 3783 | + return 'email_taken'; |
|
| 3784 | + } |
|
| 3636 | 3785 | $smcFunc['db_free_result']($request); |
| 3637 | 3786 | |
| 3638 | 3787 | return true; |
@@ -3645,8 +3794,9 @@ discard block |
||
| 3645 | 3794 | { |
| 3646 | 3795 | global $modSettings, $context, $cur_profile; |
| 3647 | 3796 | |
| 3648 | - if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') |
|
| 3649 | - setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
| 3797 | + if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') { |
|
| 3798 | + setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
| 3799 | + } |
|
| 3650 | 3800 | |
| 3651 | 3801 | loadUserSettings(); |
| 3652 | 3802 | writeLog(); |
@@ -3662,8 +3812,9 @@ discard block |
||
| 3662 | 3812 | require_once($sourcedir . '/Subs-Post.php'); |
| 3663 | 3813 | |
| 3664 | 3814 | // Shouldn't happen but just in case. |
| 3665 | - if (empty($profile_vars['email_address'])) |
|
| 3666 | - return; |
|
| 3815 | + if (empty($profile_vars['email_address'])) { |
|
| 3816 | + return; |
|
| 3817 | + } |
|
| 3667 | 3818 | |
| 3668 | 3819 | $replacements = array( |
| 3669 | 3820 | 'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $context['id_member'] . ';code=' . $profile_vars['validation_code'], |
@@ -3686,8 +3837,9 @@ discard block |
||
| 3686 | 3837 | $_SESSION['log_time'] = 0; |
| 3687 | 3838 | $_SESSION['login_' . $cookiename] = $smcFunc['json_encode'](array(0, '', 0)); |
| 3688 | 3839 | |
| 3689 | - if (isset($_COOKIE[$cookiename])) |
|
| 3690 | - $_COOKIE[$cookiename] = ''; |
|
| 3840 | + if (isset($_COOKIE[$cookiename])) { |
|
| 3841 | + $_COOKIE[$cookiename] = ''; |
|
| 3842 | + } |
|
| 3691 | 3843 | |
| 3692 | 3844 | loadUserSettings(); |
| 3693 | 3845 | |
@@ -3720,11 +3872,13 @@ discard block |
||
| 3720 | 3872 | $groups[] = $curMember['id_group']; |
| 3721 | 3873 | |
| 3722 | 3874 | // Ensure the query doesn't croak! |
| 3723 | - if (empty($groups)) |
|
| 3724 | - $groups = array(0); |
|
| 3875 | + if (empty($groups)) { |
|
| 3876 | + $groups = array(0); |
|
| 3877 | + } |
|
| 3725 | 3878 | // Just to be sure... |
| 3726 | - foreach ($groups as $k => $v) |
|
| 3727 | - $groups[$k] = (int) $v; |
|
| 3879 | + foreach ($groups as $k => $v) { |
|
| 3880 | + $groups[$k] = (int) $v; |
|
| 3881 | + } |
|
| 3728 | 3882 | |
| 3729 | 3883 | // Get all the membergroups they can join. |
| 3730 | 3884 | $request = $smcFunc['db_query']('', ' |
@@ -3754,12 +3908,14 @@ discard block |
||
| 3754 | 3908 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3755 | 3909 | { |
| 3756 | 3910 | // Can they edit their primary group? |
| 3757 | - if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) |
|
| 3758 | - $context['can_edit_primary'] = true; |
|
| 3911 | + if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) { |
|
| 3912 | + $context['can_edit_primary'] = true; |
|
| 3913 | + } |
|
| 3759 | 3914 | |
| 3760 | 3915 | // If they can't manage (protected) groups, and it's not publically joinable or already assigned, they can't see it. |
| 3761 | - if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) |
|
| 3762 | - continue; |
|
| 3916 | + if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) { |
|
| 3917 | + continue; |
|
| 3918 | + } |
|
| 3763 | 3919 | |
| 3764 | 3920 | $context['groups'][in_array($row['id_group'], $groups) ? 'member' : 'available'][$row['id_group']] = array( |
| 3765 | 3921 | 'id' => $row['id_group'], |
@@ -3788,13 +3944,15 @@ discard block |
||
| 3788 | 3944 | ); |
| 3789 | 3945 | |
| 3790 | 3946 | // No changing primary one unless you have enough groups! |
| 3791 | - if (count($context['groups']['member']) < 2) |
|
| 3792 | - $context['can_edit_primary'] = false; |
|
| 3947 | + if (count($context['groups']['member']) < 2) { |
|
| 3948 | + $context['can_edit_primary'] = false; |
|
| 3949 | + } |
|
| 3793 | 3950 | |
| 3794 | 3951 | // In the special case that someone is requesting membership of a group, setup some special context vars. |
| 3795 | - if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) |
|
| 3796 | - $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
| 3797 | -} |
|
| 3952 | + if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) { |
|
| 3953 | + $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
| 3954 | + } |
|
| 3955 | + } |
|
| 3798 | 3956 | |
| 3799 | 3957 | /** |
| 3800 | 3958 | * This function actually makes all the group changes |
@@ -3809,10 +3967,12 @@ discard block |
||
| 3809 | 3967 | global $user_info, $context, $user_profile, $modSettings, $smcFunc; |
| 3810 | 3968 | |
| 3811 | 3969 | // Let's be extra cautious... |
| 3812 | - if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) |
|
| 3813 | - isAllowedTo('manage_membergroups'); |
|
| 3814 | - if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) |
|
| 3815 | - fatal_lang_error('no_access', false); |
|
| 3970 | + if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) { |
|
| 3971 | + isAllowedTo('manage_membergroups'); |
|
| 3972 | + } |
|
| 3973 | + if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) { |
|
| 3974 | + fatal_lang_error('no_access', false); |
|
| 3975 | + } |
|
| 3816 | 3976 | |
| 3817 | 3977 | checkSession(isset($_GET['gid']) ? 'get' : 'post'); |
| 3818 | 3978 | |
@@ -3831,8 +3991,9 @@ discard block |
||
| 3831 | 3991 | $foundTarget = $changeType == 'primary' && $group_id == 0 ? true : false; |
| 3832 | 3992 | |
| 3833 | 3993 | // Sanity check!! |
| 3834 | - if ($group_id == 1) |
|
| 3835 | - isAllowedTo('admin_forum'); |
|
| 3994 | + if ($group_id == 1) { |
|
| 3995 | + isAllowedTo('admin_forum'); |
|
| 3996 | + } |
|
| 3836 | 3997 | // Protected groups too! |
| 3837 | 3998 | else |
| 3838 | 3999 | { |
@@ -3849,8 +4010,9 @@ discard block |
||
| 3849 | 4010 | list ($is_protected) = $smcFunc['db_fetch_row']($request); |
| 3850 | 4011 | $smcFunc['db_free_result']($request); |
| 3851 | 4012 | |
| 3852 | - if ($is_protected == 1) |
|
| 3853 | - isAllowedTo('admin_forum'); |
|
| 4013 | + if ($is_protected == 1) { |
|
| 4014 | + isAllowedTo('admin_forum'); |
|
| 4015 | + } |
|
| 3854 | 4016 | } |
| 3855 | 4017 | |
| 3856 | 4018 | // What ever we are doing, we need to determine if changing primary is possible! |
@@ -3872,36 +4034,43 @@ discard block |
||
| 3872 | 4034 | $group_name = $row['group_name']; |
| 3873 | 4035 | |
| 3874 | 4036 | // Does the group type match what we're doing - are we trying to request a non-requestable group? |
| 3875 | - if ($changeType == 'request' && $row['group_type'] != 2) |
|
| 3876 | - fatal_lang_error('no_access', false); |
|
| 4037 | + if ($changeType == 'request' && $row['group_type'] != 2) { |
|
| 4038 | + fatal_lang_error('no_access', false); |
|
| 4039 | + } |
|
| 3877 | 4040 | // What about leaving a requestable group we are not a member of? |
| 3878 | - elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) |
|
| 3879 | - fatal_lang_error('no_access', false); |
|
| 3880 | - elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) |
|
| 3881 | - fatal_lang_error('no_access', false); |
|
| 4041 | + elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) { |
|
| 4042 | + fatal_lang_error('no_access', false); |
|
| 4043 | + } elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) { |
|
| 4044 | + fatal_lang_error('no_access', false); |
|
| 4045 | + } |
|
| 3882 | 4046 | |
| 3883 | 4047 | // We can't change the primary group if this is hidden! |
| 3884 | - if ($row['hidden'] == 2) |
|
| 3885 | - $canChangePrimary = false; |
|
| 4048 | + if ($row['hidden'] == 2) { |
|
| 4049 | + $canChangePrimary = false; |
|
| 4050 | + } |
|
| 3886 | 4051 | } |
| 3887 | 4052 | |
| 3888 | 4053 | // If this is their old primary, can we change it? |
| 3889 | - if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) |
|
| 3890 | - $canChangePrimary = 1; |
|
| 4054 | + if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) { |
|
| 4055 | + $canChangePrimary = 1; |
|
| 4056 | + } |
|
| 3891 | 4057 | |
| 3892 | 4058 | // If we are not doing a force primary move, don't do it automatically if current primary is not 0. |
| 3893 | - if ($changeType != 'primary' && $old_profile['id_group'] != 0) |
|
| 3894 | - $canChangePrimary = false; |
|
| 4059 | + if ($changeType != 'primary' && $old_profile['id_group'] != 0) { |
|
| 4060 | + $canChangePrimary = false; |
|
| 4061 | + } |
|
| 3895 | 4062 | |
| 3896 | 4063 | // If this is the one we are acting on, can we even act? |
| 3897 | - if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) |
|
| 3898 | - $canChangePrimary = false; |
|
| 4064 | + if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) { |
|
| 4065 | + $canChangePrimary = false; |
|
| 4066 | + } |
|
| 3899 | 4067 | } |
| 3900 | 4068 | $smcFunc['db_free_result']($request); |
| 3901 | 4069 | |
| 3902 | 4070 | // Didn't find the target? |
| 3903 | - if (!$foundTarget) |
|
| 3904 | - fatal_lang_error('no_access', false); |
|
| 4071 | + if (!$foundTarget) { |
|
| 4072 | + fatal_lang_error('no_access', false); |
|
| 4073 | + } |
|
| 3905 | 4074 | |
| 3906 | 4075 | // Final security check, don't allow users to promote themselves to admin. |
| 3907 | 4076 | if ($context['can_manage_membergroups'] && !allowedTo('admin_forum')) |
@@ -3921,8 +4090,9 @@ discard block |
||
| 3921 | 4090 | list ($disallow) = $smcFunc['db_fetch_row']($request); |
| 3922 | 4091 | $smcFunc['db_free_result']($request); |
| 3923 | 4092 | |
| 3924 | - if ($disallow) |
|
| 3925 | - isAllowedTo('admin_forum'); |
|
| 4093 | + if ($disallow) { |
|
| 4094 | + isAllowedTo('admin_forum'); |
|
| 4095 | + } |
|
| 3926 | 4096 | } |
| 3927 | 4097 | |
| 3928 | 4098 | // If we're requesting, add the note then return. |
@@ -3940,8 +4110,9 @@ discard block |
||
| 3940 | 4110 | 'status_open' => 0, |
| 3941 | 4111 | ) |
| 3942 | 4112 | ); |
| 3943 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 3944 | - fatal_lang_error('profile_error_already_requested_group'); |
|
| 4113 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 4114 | + fatal_lang_error('profile_error_already_requested_group'); |
|
| 4115 | + } |
|
| 3945 | 4116 | $smcFunc['db_free_result']($request); |
| 3946 | 4117 | |
| 3947 | 4118 | // Log the request. |
@@ -3975,10 +4146,11 @@ discard block |
||
| 3975 | 4146 | // Are we leaving? |
| 3976 | 4147 | if ($old_profile['id_group'] == $group_id || isset($addGroups[$group_id])) |
| 3977 | 4148 | { |
| 3978 | - if ($old_profile['id_group'] == $group_id) |
|
| 3979 | - $newPrimary = 0; |
|
| 3980 | - else |
|
| 3981 | - unset($addGroups[$group_id]); |
|
| 4149 | + if ($old_profile['id_group'] == $group_id) { |
|
| 4150 | + $newPrimary = 0; |
|
| 4151 | + } else { |
|
| 4152 | + unset($addGroups[$group_id]); |
|
| 4153 | + } |
|
| 3982 | 4154 | } |
| 3983 | 4155 | // ... if not, must be joining. |
| 3984 | 4156 | else |
@@ -3986,36 +4158,42 @@ discard block |
||
| 3986 | 4158 | // Can we change the primary, and do we want to? |
| 3987 | 4159 | if ($canChangePrimary) |
| 3988 | 4160 | { |
| 3989 | - if ($old_profile['id_group'] != 0) |
|
| 3990 | - $addGroups[$old_profile['id_group']] = -1; |
|
| 4161 | + if ($old_profile['id_group'] != 0) { |
|
| 4162 | + $addGroups[$old_profile['id_group']] = -1; |
|
| 4163 | + } |
|
| 3991 | 4164 | $newPrimary = $group_id; |
| 3992 | 4165 | } |
| 3993 | 4166 | // Otherwise it's an additional group... |
| 3994 | - else |
|
| 3995 | - $addGroups[$group_id] = -1; |
|
| 4167 | + else { |
|
| 4168 | + $addGroups[$group_id] = -1; |
|
| 4169 | + } |
|
| 3996 | 4170 | } |
| 3997 | 4171 | } |
| 3998 | 4172 | // Finally, we must be setting the primary. |
| 3999 | 4173 | elseif ($canChangePrimary) |
| 4000 | 4174 | { |
| 4001 | - if ($old_profile['id_group'] != 0) |
|
| 4002 | - $addGroups[$old_profile['id_group']] = -1; |
|
| 4003 | - if (isset($addGroups[$group_id])) |
|
| 4004 | - unset($addGroups[$group_id]); |
|
| 4175 | + if ($old_profile['id_group'] != 0) { |
|
| 4176 | + $addGroups[$old_profile['id_group']] = -1; |
|
| 4177 | + } |
|
| 4178 | + if (isset($addGroups[$group_id])) { |
|
| 4179 | + unset($addGroups[$group_id]); |
|
| 4180 | + } |
|
| 4005 | 4181 | $newPrimary = $group_id; |
| 4006 | 4182 | } |
| 4007 | 4183 | |
| 4008 | 4184 | // Finally, we can make the changes! |
| 4009 | - foreach ($addGroups as $id => $dummy) |
|
| 4010 | - if (empty($id)) |
|
| 4185 | + foreach ($addGroups as $id => $dummy) { |
|
| 4186 | + if (empty($id)) |
|
| 4011 | 4187 | unset($addGroups[$id]); |
| 4188 | + } |
|
| 4012 | 4189 | $addGroups = implode(',', array_flip($addGroups)); |
| 4013 | 4190 | |
| 4014 | 4191 | // Ensure that we don't cache permissions if the group is changing. |
| 4015 | - if ($context['user']['is_owner']) |
|
| 4016 | - $_SESSION['mc']['time'] = 0; |
|
| 4017 | - else |
|
| 4018 | - updateSettings(array('settings_updated' => time())); |
|
| 4192 | + if ($context['user']['is_owner']) { |
|
| 4193 | + $_SESSION['mc']['time'] = 0; |
|
| 4194 | + } else { |
|
| 4195 | + updateSettings(array('settings_updated' => time())); |
|
| 4196 | + } |
|
| 4019 | 4197 | |
| 4020 | 4198 | updateMemberData($memID, array('id_group' => $newPrimary, 'additional_groups' => $addGroups)); |
| 4021 | 4199 | |
@@ -4038,8 +4216,9 @@ discard block |
||
| 4038 | 4216 | if (empty($user_settings['tfa_secret']) && $context['user']['is_owner']) |
| 4039 | 4217 | { |
| 4040 | 4218 | // Check to ensure we're forcing SSL for authentication |
| 4041 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
| 4042 | - fatal_lang_error('login_ssl_required'); |
|
| 4219 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
| 4220 | + fatal_lang_error('login_ssl_required'); |
|
| 4221 | + } |
|
| 4043 | 4222 | |
| 4044 | 4223 | // In some cases (forced 2FA or backup code) they would be forced to be redirected here, |
| 4045 | 4224 | // we do not want too much AJAX to confuse them. |
@@ -4076,8 +4255,7 @@ discard block |
||
| 4076 | 4255 | $context['sub_template'] = 'tfasetup_backup'; |
| 4077 | 4256 | |
| 4078 | 4257 | return; |
| 4079 | - } |
|
| 4080 | - else |
|
| 4258 | + } else |
|
| 4081 | 4259 | { |
| 4082 | 4260 | $context['tfa_secret'] = $_SESSION['tfa_secret']; |
| 4083 | 4261 | $context['tfa_error'] = !$valid_code; |
@@ -4085,8 +4263,7 @@ discard block |
||
| 4085 | 4263 | $context['tfa_pass_value'] = $_POST['passwd']; |
| 4086 | 4264 | $context['tfa_value'] = $_POST['tfa_code']; |
| 4087 | 4265 | } |
| 4088 | - } |
|
| 4089 | - else |
|
| 4266 | + } else |
|
| 4090 | 4267 | { |
| 4091 | 4268 | $totp = new \TOTP\Auth(); |
| 4092 | 4269 | $secret = $totp->generateCode(); |
@@ -4096,17 +4273,16 @@ discard block |
||
| 4096 | 4273 | } |
| 4097 | 4274 | |
| 4098 | 4275 | $context['tfa_qr_url'] = $totp->getQrCodeUrl($context['forum_name'] . ':' . $user_info['name'], $context['tfa_secret']); |
| 4099 | - } |
|
| 4100 | - elseif (isset($_REQUEST['disable'])) |
|
| 4276 | + } elseif (isset($_REQUEST['disable'])) |
|
| 4101 | 4277 | { |
| 4102 | 4278 | updateMemberData($memID, array( |
| 4103 | 4279 | 'tfa_secret' => '', |
| 4104 | 4280 | 'tfa_backup' => '', |
| 4105 | 4281 | )); |
| 4106 | 4282 | redirectexit('action=profile;area=account;u=' . $memID); |
| 4283 | + } else { |
|
| 4284 | + redirectexit('action=profile;area=account;u=' . $memID); |
|
| 4285 | + } |
|
| 4107 | 4286 | } |
| 4108 | - else |
|
| 4109 | - redirectexit('action=profile;area=account;u=' . $memID); |
|
| 4110 | -} |
|
| 4111 | 4287 | |
| 4112 | 4288 | ?> |
| 4113 | 4289 | \ No newline at end of file |
@@ -670,7 +670,7 @@ |
||
| 670 | 670 | // Show "<< Last Edit: Time by Person >>" if this post was edited. But we need the div even if it wasn't modified! |
| 671 | 671 | // Because we insert into it through AJAX and we don't want to stop themers moving it around if they so wish so they can put it where they want it. |
| 672 | 672 | echo ' |
| 673 | - <span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '','" id="modified_', $message['id'], '">'; |
|
| 673 | + <span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '', '" id="modified_', $message['id'], '">'; |
|
| 674 | 674 | |
| 675 | 675 | if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) |
| 676 | 676 | echo |
@@ -53,11 +53,13 @@ discard block |
||
| 53 | 53 | <p>'; |
| 54 | 54 | |
| 55 | 55 | // Show just numbers...? |
| 56 | - if ($settings['display_who_viewing'] == 1) |
|
| 57 | - echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members']; |
|
| 56 | + if ($settings['display_who_viewing'] == 1) { |
|
| 57 | + echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members']; |
|
| 58 | + } |
|
| 58 | 59 | // Or show the actual people viewing the topic? |
| 59 | - else |
|
| 60 | - echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
| 60 | + else { |
|
| 61 | + echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
| 62 | + } |
|
| 61 | 63 | |
| 62 | 64 | // Now show how many guests are here too. |
| 63 | 65 | echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_topic'], ' |
@@ -95,10 +97,11 @@ discard block |
||
| 95 | 97 | <dt class="', $option['voted_this'] ? ' voted' : '', '">', $option['option'], '</dt> |
| 96 | 98 | <dd class="statsbar', $option['voted_this'] ? ' voted' : '', '">'; |
| 97 | 99 | |
| 98 | - if ($context['allow_results_view']) |
|
| 99 | - echo ' |
|
| 100 | + if ($context['allow_results_view']) { |
|
| 101 | + echo ' |
|
| 100 | 102 | ', $option['bar_ndt'], ' |
| 101 | 103 | <span class="percentage">', $option['votes'], ' (', $option['percent'], '%)</span>'; |
| 104 | + } |
|
| 102 | 105 | |
| 103 | 106 | echo ' |
| 104 | 107 | </dd>'; |
@@ -107,9 +110,10 @@ discard block |
||
| 107 | 110 | echo ' |
| 108 | 111 | </dl>'; |
| 109 | 112 | |
| 110 | - if ($context['allow_results_view']) |
|
| 111 | - echo ' |
|
| 113 | + if ($context['allow_results_view']) { |
|
| 114 | + echo ' |
|
| 112 | 115 | <p><strong>', $txt['poll_total_voters'], ':</strong> ', $context['poll']['total_votes'], '</p>'; |
| 116 | + } |
|
| 113 | 117 | } |
| 114 | 118 | // They are allowed to vote! Go to it! |
| 115 | 119 | else |
@@ -118,17 +122,19 @@ discard block |
||
| 118 | 122 | <form action="', $scripturl, '?action=vote;topic=', $context['current_topic'], '.', $context['start'], ';poll=', $context['poll']['id'], '" method="post" accept-charset="', $context['character_set'], '">'; |
| 119 | 123 | |
| 120 | 124 | // Show a warning if they are allowed more than one option. |
| 121 | - if ($context['poll']['allowed_warning']) |
|
| 122 | - echo ' |
|
| 125 | + if ($context['poll']['allowed_warning']) { |
|
| 126 | + echo ' |
|
| 123 | 127 | <p class="smallpadding">', $context['poll']['allowed_warning'], '</p>'; |
| 128 | + } |
|
| 124 | 129 | |
| 125 | 130 | echo ' |
| 126 | 131 | <ul class="options">'; |
| 127 | 132 | |
| 128 | 133 | // Show each option with its button - a radio likely. |
| 129 | - foreach ($context['poll']['options'] as $option) |
|
| 130 | - echo ' |
|
| 134 | + foreach ($context['poll']['options'] as $option) { |
|
| 135 | + echo ' |
|
| 131 | 136 | <li>', $option['vote_button'], ' <label for="', $option['id'], '">', $option['option'], '</label></li>'; |
| 137 | + } |
|
| 132 | 138 | |
| 133 | 139 | echo ' |
| 134 | 140 | </ul> |
@@ -140,9 +146,10 @@ discard block |
||
| 140 | 146 | } |
| 141 | 147 | |
| 142 | 148 | // Is the clock ticking? |
| 143 | - if (!empty($context['poll']['expire_time'])) |
|
| 144 | - echo ' |
|
| 149 | + if (!empty($context['poll']['expire_time'])) { |
|
| 150 | + echo ' |
|
| 145 | 151 | <p><strong>', ($context['poll']['is_expired'] ? $txt['poll_expired_on'] : $txt['poll_expires_on']), ':</strong> ', $context['poll']['expire_time'], '</p>'; |
| 152 | + } |
|
| 146 | 153 | |
| 147 | 154 | echo ' |
| 148 | 155 | </div><!-- #poll_options --> |
@@ -172,11 +179,13 @@ discard block |
||
| 172 | 179 | <li> |
| 173 | 180 | <strong class="event_title"><a href="', $scripturl, '?action=calendar;event=', $event['id'], '">', $event['title'], '</a></strong>'; |
| 174 | 181 | |
| 175 | - if ($event['can_edit']) |
|
| 176 | - echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
| 182 | + if ($event['can_edit']) { |
|
| 183 | + echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
| 184 | + } |
|
| 177 | 185 | |
| 178 | - if ($event['can_export']) |
|
| 179 | - echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
| 186 | + if ($event['can_export']) { |
|
| 187 | + echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
| 188 | + } |
|
| 180 | 189 | |
| 181 | 190 | echo ' |
| 182 | 191 | <br>'; |
@@ -184,14 +193,14 @@ discard block |
||
| 184 | 193 | if (!empty($event['allday'])) |
| 185 | 194 | { |
| 186 | 195 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' – <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : ''; |
| 187 | - } |
|
| 188 | - else |
|
| 196 | + } else |
|
| 189 | 197 | { |
| 190 | 198 | // Display event info relative to user's local timezone |
| 191 | 199 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
| 192 | 200 | |
| 193 | - if ($event['start_date_local'] != $event['end_date_local']) |
|
| 194 | - echo trim($event['end_date_local']) . ', '; |
|
| 201 | + if ($event['start_date_local'] != $event['end_date_local']) { |
|
| 202 | + echo trim($event['end_date_local']) . ', '; |
|
| 203 | + } |
|
| 195 | 204 | |
| 196 | 205 | echo trim($event['end_time_local']); |
| 197 | 206 | |
@@ -200,24 +209,28 @@ discard block |
||
| 200 | 209 | { |
| 201 | 210 | echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">'; |
| 202 | 211 | |
| 203 | - if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) |
|
| 204 | - echo trim($event['start_date_orig']), ', '; |
|
| 212 | + if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) { |
|
| 213 | + echo trim($event['start_date_orig']), ', '; |
|
| 214 | + } |
|
| 205 | 215 | |
| 206 | 216 | echo trim($event['start_time_orig']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
| 207 | 217 | |
| 208 | - if ($event['start_date_orig'] != $event['end_date_orig']) |
|
| 209 | - echo trim($event['end_date_orig']) . ', '; |
|
| 218 | + if ($event['start_date_orig'] != $event['end_date_orig']) { |
|
| 219 | + echo trim($event['end_date_orig']) . ', '; |
|
| 220 | + } |
|
| 210 | 221 | |
| 211 | 222 | echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)'; |
| 212 | 223 | } |
| 213 | 224 | // Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion |
| 214 | - else |
|
| 215 | - echo ' ', $event['tz_abbrev'], '</time>'; |
|
| 225 | + else { |
|
| 226 | + echo ' ', $event['tz_abbrev'], '</time>'; |
|
| 227 | + } |
|
| 216 | 228 | } |
| 217 | 229 | |
| 218 | - if (!empty($event['location'])) |
|
| 219 | - echo ' |
|
| 230 | + if (!empty($event['location'])) { |
|
| 231 | + echo ' |
|
| 220 | 232 | <br>', $event['location']; |
| 233 | + } |
|
| 221 | 234 | |
| 222 | 235 | echo ' |
| 223 | 236 | </li>'; |
@@ -256,8 +269,9 @@ discard block |
||
| 256 | 269 | $context['removableMessageIDs'] = array(); |
| 257 | 270 | |
| 258 | 271 | // Get all the messages... |
| 259 | - while ($message = $context['get_message']()) |
|
| 260 | - template_single_post($message); |
|
| 272 | + while ($message = $context['get_message']()) { |
|
| 273 | + template_single_post($message); |
|
| 274 | + } |
|
| 261 | 275 | |
| 262 | 276 | echo ' |
| 263 | 277 | </form> |
@@ -295,8 +309,9 @@ discard block |
||
| 295 | 309 | <div id="display_jump_to"> </div>'; |
| 296 | 310 | |
| 297 | 311 | // Show quickreply |
| 298 | - if ($context['can_reply']) |
|
| 299 | - template_quickreply(); |
|
| 312 | + if ($context['can_reply']) { |
|
| 313 | + template_quickreply(); |
|
| 314 | + } |
|
| 300 | 315 | |
| 301 | 316 | // User action pop on mobile screen (or actually small screen), this uses responsive css does not check mobile device. |
| 302 | 317 | echo ' |
@@ -311,8 +326,8 @@ discard block |
||
| 311 | 326 | </div>'; |
| 312 | 327 | |
| 313 | 328 | // Show the moderation button & pop only if user can moderate |
| 314 | - if ($context['can_moderate_forum'] || $context['user']['is_mod']) |
|
| 315 | - echo ' |
|
| 329 | + if ($context['can_moderate_forum'] || $context['user']['is_mod']) { |
|
| 330 | + echo ' |
|
| 316 | 331 | <div id="mobile_moderation" class="popup_container"> |
| 317 | 332 | <div class="popup_window description"> |
| 318 | 333 | <div class="popup_heading"> |
@@ -324,6 +339,7 @@ discard block |
||
| 324 | 339 | </div> |
| 325 | 340 | </div> |
| 326 | 341 | </div>'; |
| 342 | + } |
|
| 327 | 343 | |
| 328 | 344 | echo ' |
| 329 | 345 | <script>'; |
@@ -447,9 +463,10 @@ discard block |
||
| 447 | 463 | }); |
| 448 | 464 | }'; |
| 449 | 465 | |
| 450 | - if (!empty($context['ignoredMsgs'])) |
|
| 451 | - echo ' |
|
| 466 | + if (!empty($context['ignoredMsgs'])) { |
|
| 467 | + echo ' |
|
| 452 | 468 | ignore_toggles([', implode(', ', $context['ignoredMsgs']), '], ', JavaScriptEscape($txt['show_ignore_user_post']), ');'; |
| 469 | + } |
|
| 453 | 470 | |
| 454 | 471 | echo ' |
| 455 | 472 | </script>'; |
@@ -466,8 +483,9 @@ discard block |
||
| 466 | 483 | |
| 467 | 484 | $ignoring = false; |
| 468 | 485 | |
| 469 | - if ($message['can_remove']) |
|
| 470 | - $context['removableMessageIDs'][] = $message['id']; |
|
| 486 | + if ($message['can_remove']) { |
|
| 487 | + $context['removableMessageIDs'][] = $message['id']; |
|
| 488 | + } |
|
| 471 | 489 | |
| 472 | 490 | // Are we ignoring this message? |
| 473 | 491 | if (!empty($message['is_ignored'])) |
@@ -494,9 +512,10 @@ discard block |
||
| 494 | 512 | <div class="custom_fields_above_member"> |
| 495 | 513 | <ul class="nolist">'; |
| 496 | 514 | |
| 497 | - foreach ($message['custom_fields']['above_member'] as $custom) |
|
| 498 | - echo ' |
|
| 515 | + foreach ($message['custom_fields']['above_member'] as $custom) { |
|
| 516 | + echo ' |
|
| 499 | 517 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 518 | + } |
|
| 500 | 519 | |
| 501 | 520 | echo ' |
| 502 | 521 | </ul> |
@@ -507,76 +526,87 @@ discard block |
||
| 507 | 526 | <h4>'; |
| 508 | 527 | |
| 509 | 528 | // Show online and offline buttons? |
| 510 | - if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) |
|
| 511 | - echo ' |
|
| 529 | + if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) { |
|
| 530 | + echo ' |
|
| 512 | 531 | ', $context['can_send_pm'] ? '<a href="' . $message['member']['online']['href'] . '" title="' . $message['member']['online']['label'] . '">' : '', '<span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>', $context['can_send_pm'] ? '</a>' : ''; |
| 532 | + } |
|
| 513 | 533 | |
| 514 | 534 | // Custom fields BEFORE the username? |
| 515 | - if (!empty($message['custom_fields']['before_member'])) |
|
| 516 | - foreach ($message['custom_fields']['before_member'] as $custom) |
|
| 535 | + if (!empty($message['custom_fields']['before_member'])) { |
|
| 536 | + foreach ($message['custom_fields']['before_member'] as $custom) |
|
| 517 | 537 | echo ' |
| 518 | 538 | <span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>'; |
| 539 | + } |
|
| 519 | 540 | |
| 520 | 541 | // Show a link to the member's profile. |
| 521 | 542 | echo ' |
| 522 | 543 | ', $message['member']['link']; |
| 523 | 544 | |
| 524 | 545 | // Custom fields AFTER the username? |
| 525 | - if (!empty($message['custom_fields']['after_member'])) |
|
| 526 | - foreach ($message['custom_fields']['after_member'] as $custom) |
|
| 546 | + if (!empty($message['custom_fields']['after_member'])) { |
|
| 547 | + foreach ($message['custom_fields']['after_member'] as $custom) |
|
| 527 | 548 | echo ' |
| 528 | 549 | <span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>'; |
| 550 | + } |
|
| 529 | 551 | |
| 530 | 552 | echo ' |
| 531 | 553 | </h4> |
| 532 | 554 | <ul class="user_info">'; |
| 533 | 555 | |
| 534 | 556 | // Show the user's avatar. |
| 535 | - if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) |
|
| 536 | - echo ' |
|
| 557 | + if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) { |
|
| 558 | + echo ' |
|
| 537 | 559 | <li class="avatar"> |
| 538 | 560 | <a href="', $message['member']['href'], '">', $message['member']['avatar']['image'], '</a> |
| 539 | 561 | </li>'; |
| 562 | + } |
|
| 540 | 563 | |
| 541 | 564 | // Are there any custom fields below the avatar? |
| 542 | - if (!empty($message['custom_fields']['below_avatar'])) |
|
| 543 | - foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
| 565 | + if (!empty($message['custom_fields']['below_avatar'])) { |
|
| 566 | + foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
| 544 | 567 | echo ' |
| 545 | 568 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 569 | + } |
|
| 546 | 570 | |
| 547 | 571 | // Show the post group icons, but not for guests. |
| 548 | - if (!$message['member']['is_guest']) |
|
| 549 | - echo ' |
|
| 572 | + if (!$message['member']['is_guest']) { |
|
| 573 | + echo ' |
|
| 550 | 574 | <li class="icons">', $message['member']['group_icons'], '</li>'; |
| 575 | + } |
|
| 551 | 576 | |
| 552 | 577 | // Show the member's primary group (like 'Administrator') if they have one. |
| 553 | - if (!empty($message['member']['group'])) |
|
| 554 | - echo ' |
|
| 578 | + if (!empty($message['member']['group'])) { |
|
| 579 | + echo ' |
|
| 555 | 580 | <li class="membergroup">', $message['member']['group'], '</li>'; |
| 581 | + } |
|
| 556 | 582 | |
| 557 | 583 | // Show the member's custom title, if they have one. |
| 558 | - if (!empty($message['member']['title'])) |
|
| 559 | - echo ' |
|
| 584 | + if (!empty($message['member']['title'])) { |
|
| 585 | + echo ' |
|
| 560 | 586 | <li class="title">', $message['member']['title'], '</li>'; |
| 587 | + } |
|
| 561 | 588 | |
| 562 | 589 | // Don't show these things for guests. |
| 563 | 590 | if (!$message['member']['is_guest']) |
| 564 | 591 | { |
| 565 | 592 | |
| 566 | 593 | // Show the post group if and only if they have no other group or the option is on, and they are in a post group. |
| 567 | - if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) |
|
| 568 | - echo ' |
|
| 594 | + if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) { |
|
| 595 | + echo ' |
|
| 569 | 596 | <li class="postgroup">', $message['member']['post_group'], '</li>'; |
| 597 | + } |
|
| 570 | 598 | |
| 571 | 599 | // Show how many posts they have made. |
| 572 | - if (!isset($context['disabled_fields']['posts'])) |
|
| 573 | - echo ' |
|
| 600 | + if (!isset($context['disabled_fields']['posts'])) { |
|
| 601 | + echo ' |
|
| 574 | 602 | <li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>'; |
| 603 | + } |
|
| 575 | 604 | |
| 576 | 605 | // Show their personal text? |
| 577 | - if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) |
|
| 578 | - echo ' |
|
| 606 | + if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) { |
|
| 607 | + echo ' |
|
| 579 | 608 | <li class="blurb">', $message['member']['blurb'], '</li>'; |
| 609 | + } |
|
| 580 | 610 | |
| 581 | 611 | // Any custom fields to show as icons? |
| 582 | 612 | if (!empty($message['custom_fields']['icons'])) |
@@ -585,9 +615,10 @@ discard block |
||
| 585 | 615 | <li class="im_icons"> |
| 586 | 616 | <ol>'; |
| 587 | 617 | |
| 588 | - foreach ($message['custom_fields']['icons'] as $custom) |
|
| 589 | - echo ' |
|
| 618 | + foreach ($message['custom_fields']['icons'] as $custom) { |
|
| 619 | + echo ' |
|
| 590 | 620 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 621 | + } |
|
| 591 | 622 | |
| 592 | 623 | echo ' |
| 593 | 624 | </ol> |
@@ -602,19 +633,22 @@ discard block |
||
| 602 | 633 | <ol class="profile_icons">'; |
| 603 | 634 | |
| 604 | 635 | // Don't show an icon if they haven't specified a website. |
| 605 | - if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) |
|
| 606 | - echo ' |
|
| 636 | + if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) { |
|
| 637 | + echo ' |
|
| 607 | 638 | <li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
| 639 | + } |
|
| 608 | 640 | |
| 609 | 641 | // Since we know this person isn't a guest, you *can* message them. |
| 610 | - if ($context['can_send_pm']) |
|
| 611 | - echo ' |
|
| 642 | + if ($context['can_send_pm']) { |
|
| 643 | + echo ' |
|
| 612 | 644 | <li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="generic_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>'; |
| 645 | + } |
|
| 613 | 646 | |
| 614 | 647 | // Show the email if necessary |
| 615 | - if (!empty($message['member']['email']) && $message['member']['show_email']) |
|
| 616 | - echo ' |
|
| 648 | + if (!empty($message['member']['email']) && $message['member']['show_email']) { |
|
| 649 | + echo ' |
|
| 617 | 650 | <li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>'; |
| 651 | + } |
|
| 618 | 652 | |
| 619 | 653 | echo ' |
| 620 | 654 | </ol> |
@@ -622,48 +656,56 @@ discard block |
||
| 622 | 656 | } |
| 623 | 657 | |
| 624 | 658 | // Any custom fields for standard placement? |
| 625 | - if (!empty($message['custom_fields']['standard'])) |
|
| 626 | - foreach ($message['custom_fields']['standard'] as $custom) |
|
| 659 | + if (!empty($message['custom_fields']['standard'])) { |
|
| 660 | + foreach ($message['custom_fields']['standard'] as $custom) |
|
| 627 | 661 | echo ' |
| 628 | 662 | <li class="custom ', $custom['col_name'], '">', $custom['title'], ': ', $custom['value'], '</li>'; |
| 663 | + } |
|
| 629 | 664 | |
| 630 | 665 | } |
| 631 | 666 | // Otherwise, show the guest's email. |
| 632 | - elseif (!empty($message['member']['email']) && $message['member']['show_email']) |
|
| 633 | - echo ' |
|
| 667 | + elseif (!empty($message['member']['email']) && $message['member']['show_email']) { |
|
| 668 | + echo ' |
|
| 634 | 669 | <li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>'; |
| 670 | + } |
|
| 635 | 671 | |
| 636 | 672 | // Show the IP to this user for this post - because you can moderate? |
| 637 | - if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) |
|
| 638 | - echo ' |
|
| 673 | + if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) { |
|
| 674 | + echo ' |
|
| 639 | 675 | <li class="poster_ip"><a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a></li>'; |
| 676 | + } |
|
| 640 | 677 | |
| 641 | 678 | // Or, should we show it because this is you? |
| 642 | - elseif ($message['can_see_ip']) |
|
| 643 | - echo ' |
|
| 679 | + elseif ($message['can_see_ip']) { |
|
| 680 | + echo ' |
|
| 644 | 681 | <li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a></li>'; |
| 682 | + } |
|
| 645 | 683 | |
| 646 | 684 | // Okay, are you at least logged in? Then we can show something about why IPs are logged... |
| 647 | - elseif (!$context['user']['is_guest']) |
|
| 648 | - echo ' |
|
| 685 | + elseif (!$context['user']['is_guest']) { |
|
| 686 | + echo ' |
|
| 649 | 687 | <li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a></li>'; |
| 688 | + } |
|
| 650 | 689 | |
| 651 | 690 | // Otherwise, you see NOTHING! |
| 652 | - else |
|
| 653 | - echo ' |
|
| 691 | + else { |
|
| 692 | + echo ' |
|
| 654 | 693 | <li class="poster_ip">', $txt['logged'], '</li>'; |
| 694 | + } |
|
| 655 | 695 | |
| 656 | 696 | // Are we showing the warning status? |
| 657 | 697 | // Don't show these things for guests. |
| 658 | - if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) |
|
| 659 | - echo ' |
|
| 698 | + if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) { |
|
| 699 | + echo ' |
|
| 660 | 700 | <li class="warning">', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="generic_icons warning_', $message['member']['warning_status'], '"></span> ', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>'; |
| 701 | + } |
|
| 661 | 702 | |
| 662 | 703 | // Are there any custom fields to show at the bottom of the poster info? |
| 663 | - if (!empty($message['custom_fields']['bottom_poster'])) |
|
| 664 | - foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
| 704 | + if (!empty($message['custom_fields']['bottom_poster'])) { |
|
| 705 | + foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
| 665 | 706 | echo ' |
| 666 | 707 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 708 | + } |
|
| 667 | 709 | |
| 668 | 710 | // Poster info ends. |
| 669 | 711 | echo ' |
@@ -692,9 +734,10 @@ discard block |
||
| 692 | 734 | echo ' |
| 693 | 735 | <span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '','" id="modified_', $message['id'], '">'; |
| 694 | 736 | |
| 695 | - if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) |
|
| 696 | - echo |
|
| 737 | + if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) { |
|
| 738 | + echo |
|
| 697 | 739 | $message['modified']['last_edit_text']; |
| 740 | + } |
|
| 698 | 741 | |
| 699 | 742 | echo ' |
| 700 | 743 | </span> |
@@ -703,22 +746,24 @@ discard block |
||
| 703 | 746 | </div><!-- .keyinfo -->'; |
| 704 | 747 | |
| 705 | 748 | // Ignoring this user? Hide the post. |
| 706 | - if ($ignoring) |
|
| 707 | - echo ' |
|
| 749 | + if ($ignoring) { |
|
| 750 | + echo ' |
|
| 708 | 751 | <div id="msg_', $message['id'], '_ignored_prompt"> |
| 709 | 752 | ', $txt['ignoring_user'], ' |
| 710 | 753 | <a href="#" id="msg_', $message['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a> |
| 711 | 754 | </div>'; |
| 755 | + } |
|
| 712 | 756 | |
| 713 | 757 | // Show the post itself, finally! |
| 714 | 758 | echo ' |
| 715 | 759 | <div class="post">'; |
| 716 | 760 | |
| 717 | - if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) |
|
| 718 | - echo ' |
|
| 761 | + if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) { |
|
| 762 | + echo ' |
|
| 719 | 763 | <div class="approve_post"> |
| 720 | 764 | ', $txt['post_awaiting_approval'], ' |
| 721 | 765 | </div>'; |
| 766 | + } |
|
| 722 | 767 | echo ' |
| 723 | 768 | <div class="inner" data-msgid="', $message['id'], '" id="msg_', $message['id'], '"', $ignoring ? ' style="display:none;"' : '', '> |
| 724 | 769 | ', $message['body'], ' |
@@ -737,9 +782,9 @@ discard block |
||
| 737 | 782 | foreach ($message['attachment'] as $attachment) |
| 738 | 783 | { |
| 739 | 784 | // Do we want this attachment to not be showed here? |
| 740 | - if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) |
|
| 741 | - continue; |
|
| 742 | - elseif (!$div_output) |
|
| 785 | + if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) { |
|
| 786 | + continue; |
|
| 787 | + } elseif (!$div_output) |
|
| 743 | 788 | { |
| 744 | 789 | $div_output = true; |
| 745 | 790 | |
@@ -755,9 +800,10 @@ discard block |
||
| 755 | 800 | <fieldset> |
| 756 | 801 | <legend>', $txt['attach_awaiting_approve']; |
| 757 | 802 | |
| 758 | - if ($context['can_approve']) |
|
| 759 | - echo ' |
|
| 803 | + if ($context['can_approve']) { |
|
| 804 | + echo ' |
|
| 760 | 805 | [<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]'; |
| 806 | + } |
|
| 761 | 807 | |
| 762 | 808 | echo ' |
| 763 | 809 | </legend>'; |
@@ -771,12 +817,13 @@ discard block |
||
| 771 | 817 | echo ' |
| 772 | 818 | <div class="attachments_top">'; |
| 773 | 819 | |
| 774 | - if ($attachment['thumbnail']['has_thumb']) |
|
| 775 | - echo ' |
|
| 820 | + if ($attachment['thumbnail']['has_thumb']) { |
|
| 821 | + echo ' |
|
| 776 | 822 | <a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" class="atc_img"></a>'; |
| 777 | - else |
|
| 778 | - echo ' |
|
| 823 | + } else { |
|
| 824 | + echo ' |
|
| 779 | 825 | <img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" class="atc_img">'; |
| 826 | + } |
|
| 780 | 827 | |
| 781 | 828 | echo ' |
| 782 | 829 | </div><!-- .attachments_top -->'; |
@@ -786,9 +833,10 @@ discard block |
||
| 786 | 833 | <div class="attachments_bot"> |
| 787 | 834 | <a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.png" class="centericon" alt="*"> ' . $attachment['name'] . '</a> '; |
| 788 | 835 | |
| 789 | - if (!$attachment['is_approved'] && $context['can_approve']) |
|
| 790 | - echo ' |
|
| 836 | + if (!$attachment['is_approved'] && $context['can_approve']) { |
|
| 837 | + echo ' |
|
| 791 | 838 | [<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>] | [<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] '; |
| 839 | + } |
|
| 792 | 840 | echo ' |
| 793 | 841 | <br>', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . '<br>' . sprintf($txt['attach_viewed'], $attachment['downloads']) : '<br>' . sprintf($txt['attach_downloaded'], $attachment['downloads'])), ' |
| 794 | 842 | </div><!-- .attachments_bot -->'; |
@@ -797,35 +845,40 @@ discard block |
||
| 797 | 845 | </div><!-- .attached -->'; |
| 798 | 846 | |
| 799 | 847 | // Next attachment line ? |
| 800 | - if (++$i % $attachments_per_line === 0) |
|
| 801 | - echo ' |
|
| 848 | + if (++$i % $attachments_per_line === 0) { |
|
| 849 | + echo ' |
|
| 802 | 850 | <br>'; |
| 851 | + } |
|
| 803 | 852 | } |
| 804 | 853 | |
| 805 | 854 | // If we had unapproved attachments clean up. |
| 806 | - if ($last_approved_state == 0) |
|
| 807 | - echo ' |
|
| 855 | + if ($last_approved_state == 0) { |
|
| 856 | + echo ' |
|
| 808 | 857 | </fieldset>'; |
| 858 | + } |
|
| 809 | 859 | |
| 810 | 860 | // Only do this if we output a div above - otherwise it'll break things |
| 811 | - if ($div_output) |
|
| 812 | - echo ' |
|
| 861 | + if ($div_output) { |
|
| 862 | + echo ' |
|
| 813 | 863 | </div><!-- #msg_[id]_footer -->'; |
| 864 | + } |
|
| 814 | 865 | } |
| 815 | 866 | |
| 816 | 867 | // And stuff below the attachments. |
| 817 | - if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) |
|
| 818 | - echo ' |
|
| 868 | + if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) { |
|
| 869 | + echo ' |
|
| 819 | 870 | <div class="under_message">'; |
| 871 | + } |
|
| 820 | 872 | |
| 821 | 873 | // Maybe they want to report this post to the moderator(s)? |
| 822 | - if ($context['can_report_moderator']) |
|
| 823 | - echo ' |
|
| 874 | + if ($context['can_report_moderator']) { |
|
| 875 | + echo ' |
|
| 824 | 876 | <ul class="floatright smalltext"> |
| 825 | 877 | <li class="report_link"> |
| 826 | 878 | <a href="', $scripturl, '?action=reporttm;topic=', $context['current_topic'], '.', $message['counter'], ';msg=', $message['id'], '">', $txt['report_to_mod'], '</a> |
| 827 | 879 | </li> |
| 828 | 880 | </ul>'; |
| 881 | + } |
|
| 829 | 882 | |
| 830 | 883 | // What about likes? |
| 831 | 884 | if (!empty($modSettings['enable_likes'])) |
@@ -872,78 +925,91 @@ discard block |
||
| 872 | 925 | <ul class="quickbuttons">'; |
| 873 | 926 | |
| 874 | 927 | // Can they quote? if so they can select and quote as well! |
| 875 | - if ($context['can_quote']) |
|
| 876 | - echo ' |
|
| 928 | + if ($context['can_quote']) { |
|
| 929 | + echo ' |
|
| 877 | 930 | <li><a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';last_msg=', $context['topic_last_message'], '" onclick="return oQuickReply.quote(', $message['id'], ');"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li> |
| 878 | 931 | <li style="display:none;" id="quoteSelected_', $message['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'], '</a></li>'; |
| 932 | + } |
|
| 879 | 933 | |
| 880 | 934 | // Can the user modify the contents of this post? Show the modify inline image. |
| 881 | - if ($message['can_modify']) |
|
| 882 | - echo ' |
|
| 935 | + if ($message['can_modify']) { |
|
| 936 | + echo ' |
|
| 883 | 937 | <li class="quick_edit"><a title="', $txt['modify_msg'], '" class="modifybutton" id="modify_button_', $message['id'], '" onclick="oQuickModify.modifyMsg(\'', $message['id'], '\', \'', !empty($modSettings['toggle_subject']), '\')"><span class="generic_icons quick_edit_button"></span>', $txt['quick_edit'], '</a></li>'; |
| 938 | + } |
|
| 884 | 939 | |
| 885 | - if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) |
|
| 886 | - echo ' |
|
| 940 | + if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) { |
|
| 941 | + echo ' |
|
| 887 | 942 | <li class="post_options">', $txt['post_options']; |
| 943 | + } |
|
| 888 | 944 | |
| 889 | 945 | echo ' |
| 890 | 946 | <ul>'; |
| 891 | 947 | |
| 892 | 948 | // Can the user modify the contents of this post? |
| 893 | - if ($message['can_modify']) |
|
| 894 | - echo ' |
|
| 949 | + if ($message['can_modify']) { |
|
| 950 | + echo ' |
|
| 895 | 951 | <li><a href="', $scripturl, '?action=post;msg=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], '"><span class="generic_icons modify_button"></span>', $txt['modify'], '</a></li>'; |
| 952 | + } |
|
| 896 | 953 | |
| 897 | 954 | // How about... even... remove it entirely?! |
| 898 | - if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) |
|
| 899 | - echo ' |
|
| 955 | + if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) { |
|
| 956 | + echo ' |
|
| 900 | 957 | <li><a href="', $scripturl, '?action=removetopic2;topic=', $context['current_topic'], '.', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['are_sure_remove_topic'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove_topic'], '</a></li>'; |
| 901 | - elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) |
|
| 902 | - echo ' |
|
| 958 | + } elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) { |
|
| 959 | + echo ' |
|
| 903 | 960 | <li><a href="', $scripturl, '?action=deletemsg;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message_question'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
| 961 | + } |
|
| 904 | 962 | |
| 905 | 963 | // What about splitting it off the rest of the topic? |
| 906 | - if ($context['can_split'] && !empty($context['real_num_replies'])) |
|
| 907 | - echo ' |
|
| 964 | + if ($context['can_split'] && !empty($context['real_num_replies'])) { |
|
| 965 | + echo ' |
|
| 908 | 966 | <li><a href="', $scripturl, '?action=splittopics;topic=', $context['current_topic'], '.0;at=', $message['id'], '"><span class="generic_icons split_button"></span>', $txt['split'], '</a></li>'; |
| 967 | + } |
|
| 909 | 968 | |
| 910 | 969 | // Can we issue a warning because of this post? Remember, we can't give guests warnings. |
| 911 | - if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) |
|
| 912 | - echo ' |
|
| 970 | + if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) { |
|
| 971 | + echo ' |
|
| 913 | 972 | <li><a href="', $scripturl, '?action=profile;area=issuewarning;u=', $message['member']['id'], ';msg=', $message['id'], '"><span class="generic_icons warn_button"></span>', $txt['issue_warning'], '</a></li>'; |
| 973 | + } |
|
| 914 | 974 | |
| 915 | 975 | // Can we restore topics? |
| 916 | - if ($context['can_restore_msg']) |
|
| 917 | - echo ' |
|
| 976 | + if ($context['can_restore_msg']) { |
|
| 977 | + echo ' |
|
| 918 | 978 | <li><a href="', $scripturl, '?action=restoretopic;msgs=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons restore_button"></span>', $txt['restore_message'], '</a></li>'; |
| 979 | + } |
|
| 919 | 980 | |
| 920 | 981 | // Maybe we can approve it, maybe we should? |
| 921 | - if ($message['can_approve']) |
|
| 922 | - echo ' |
|
| 982 | + if ($message['can_approve']) { |
|
| 983 | + echo ' |
|
| 923 | 984 | <li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons approve_button"></span>', $txt['approve'], '</a></li>'; |
| 985 | + } |
|
| 924 | 986 | |
| 925 | 987 | // Maybe we can unapprove it? |
| 926 | - if ($message['can_unapprove']) |
|
| 927 | - echo ' |
|
| 988 | + if ($message['can_unapprove']) { |
|
| 989 | + echo ' |
|
| 928 | 990 | <li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons unapprove_button"></span>', $txt['unapprove'], '</a></li>'; |
| 991 | + } |
|
| 929 | 992 | |
| 930 | 993 | echo ' |
| 931 | 994 | </ul> |
| 932 | 995 | </li>'; |
| 933 | 996 | |
| 934 | 997 | // Show a checkbox for quick moderation? |
| 935 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) |
|
| 936 | - echo ' |
|
| 998 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) { |
|
| 999 | + echo ' |
|
| 937 | 1000 | <li style="display: none;" id="in_topic_mod_check_', $message['id'], '"></li>'; |
| 1001 | + } |
|
| 938 | 1002 | |
| 939 | - if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) |
|
| 940 | - echo ' |
|
| 1003 | + if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) { |
|
| 1004 | + echo ' |
|
| 941 | 1005 | </ul><!-- .quickbuttons -->'; |
| 1006 | + } |
|
| 942 | 1007 | } |
| 943 | 1008 | |
| 944 | - if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) |
|
| 945 | - echo ' |
|
| 1009 | + if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) { |
|
| 1010 | + echo ' |
|
| 946 | 1011 | </div><!-- .under_message -->'; |
| 1012 | + } |
|
| 947 | 1013 | |
| 948 | 1014 | echo ' |
| 949 | 1015 | </div><!-- .postarea --> |
@@ -956,9 +1022,10 @@ discard block |
||
| 956 | 1022 | <div class="custom_fields_above_signature"> |
| 957 | 1023 | <ul class="nolist">'; |
| 958 | 1024 | |
| 959 | - foreach ($message['custom_fields']['above_signature'] as $custom) |
|
| 960 | - echo ' |
|
| 1025 | + foreach ($message['custom_fields']['above_signature'] as $custom) { |
|
| 1026 | + echo ' |
|
| 961 | 1027 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 1028 | + } |
|
| 962 | 1029 | |
| 963 | 1030 | echo ' |
| 964 | 1031 | </ul> |
@@ -966,11 +1033,12 @@ discard block |
||
| 966 | 1033 | } |
| 967 | 1034 | |
| 968 | 1035 | // Show the member's signature? |
| 969 | - if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) |
|
| 970 | - echo ' |
|
| 1036 | + if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) { |
|
| 1037 | + echo ' |
|
| 971 | 1038 | <div class="signature" id="msg_', $message['id'], '_signature"', $ignoring ? ' style="display:none;"' : '', '> |
| 972 | 1039 | ', $message['member']['signature'], ' |
| 973 | 1040 | </div>'; |
| 1041 | + } |
|
| 974 | 1042 | |
| 975 | 1043 | |
| 976 | 1044 | // Are there any custom profile fields for below the signature? |
@@ -980,9 +1048,10 @@ discard block |
||
| 980 | 1048 | <div class="custom_fields_below_signature"> |
| 981 | 1049 | <ul class="nolist">'; |
| 982 | 1050 | |
| 983 | - foreach ($message['custom_fields']['below_signature'] as $custom) |
|
| 984 | - echo ' |
|
| 1051 | + foreach ($message['custom_fields']['below_signature'] as $custom) { |
|
| 1052 | + echo ' |
|
| 985 | 1053 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 1054 | + } |
|
| 986 | 1055 | |
| 987 | 1056 | echo ' |
| 988 | 1057 | </ul> |
@@ -1032,8 +1101,8 @@ discard block |
||
| 1032 | 1101 | <input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '">'; |
| 1033 | 1102 | |
| 1034 | 1103 | // Guests just need more. |
| 1035 | - if ($context['user']['is_guest']) |
|
| 1036 | - echo ' |
|
| 1104 | + if ($context['user']['is_guest']) { |
|
| 1105 | + echo ' |
|
| 1037 | 1106 | <dl id="post_header"> |
| 1038 | 1107 | <dt> |
| 1039 | 1108 | ', $txt['name'], ': |
@@ -1048,6 +1117,7 @@ discard block |
||
| 1048 | 1117 | <input type="email" name="email" size="25" value="', $context['email'], '" tabindex="', $context['tabindex']++, '" required> |
| 1049 | 1118 | </dd> |
| 1050 | 1119 | </dl>'; |
| 1120 | + } |
|
| 1051 | 1121 | |
| 1052 | 1122 | echo ' |
| 1053 | 1123 | ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'), ' |
@@ -1095,8 +1165,8 @@ discard block |
||
| 1095 | 1165 | <br class="clear">'; |
| 1096 | 1166 | |
| 1097 | 1167 | // draft autosave available and the user has it enabled? |
| 1098 | - if (!empty($context['drafts_autosave'])) |
|
| 1099 | - echo ' |
|
| 1168 | + if (!empty($context['drafts_autosave'])) { |
|
| 1169 | + echo ' |
|
| 1100 | 1170 | <script> |
| 1101 | 1171 | var oDraftAutoSave = new smf_DraftAutoSave({ |
| 1102 | 1172 | sSelf: \'oDraftAutoSave\', |
@@ -1108,12 +1178,14 @@ discard block |
||
| 1108 | 1178 | iFreq: ', (empty($modSettings['masterAutoSaveDraftsDelay']) ? 60000 : $modSettings['masterAutoSaveDraftsDelay'] * 1000), ' |
| 1109 | 1179 | }); |
| 1110 | 1180 | </script>'; |
| 1181 | + } |
|
| 1111 | 1182 | |
| 1112 | - if ($context['show_spellchecking']) |
|
| 1113 | - echo ' |
|
| 1183 | + if ($context['show_spellchecking']) { |
|
| 1184 | + echo ' |
|
| 1114 | 1185 | <form action="', $scripturl, '?action=spellcheck" method="post" accept-charset="', $context['character_set'], '" name="spell_form" id="spell_form" target="spellWindow"> |
| 1115 | 1186 | <input type="hidden" name="spellstring" value=""> |
| 1116 | 1187 | </form>'; |
| 1188 | + } |
|
| 1117 | 1189 | |
| 1118 | 1190 | echo ' |
| 1119 | 1191 | <script> |
@@ -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) |
@@ -5527,7 +5527,7 @@ discard block |
||
| 5527 | 5527 | * It assumes the data is already a string. |
| 5528 | 5528 | * @param string $data The data to print |
| 5529 | 5529 | * @param string $type The content type. Defaults to Json. |
| 5530 | - * @return void |
|
| 5530 | + * @return false|null |
|
| 5531 | 5531 | */ |
| 5532 | 5532 | function smf_serverResponse($data = '', $type = 'Content-Type: application/json') |
| 5533 | 5533 | { |
@@ -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 ($var == 'alerts' && ($val === '+' || $val === '-')) |
@@ -385,18 +394,17 @@ discard block |
||
| 385 | 394 | if (is_array($members)) |
| 386 | 395 | { |
| 387 | 396 | $val = 'CASE '; |
| 388 | - foreach ($members as $k => $v) |
|
| 389 | - $val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
| 397 | + foreach ($members as $k => $v) { |
|
| 398 | + $val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
| 399 | + } |
|
| 390 | 400 | $val = $val . ' END'; |
| 391 | 401 | $type = 'raw'; |
| 392 | - } |
|
| 393 | - else |
|
| 402 | + } else |
|
| 394 | 403 | { |
| 395 | 404 | $blub = fetch_alerts($members, false, 0, array(), false); |
| 396 | 405 | $val = count($blub); |
| 397 | 406 | } |
| 398 | - } |
|
| 399 | - else if ($type == 'int' && ($val === '+' || $val === '-')) |
|
| 407 | + } else if ($type == 'int' && ($val === '+' || $val === '-')) |
|
| 400 | 408 | { |
| 401 | 409 | $val = $var . ' ' . $val . ' 1'; |
| 402 | 410 | $type = 'raw'; |
@@ -407,8 +415,9 @@ discard block |
||
| 407 | 415 | { |
| 408 | 416 | if (preg_match('~^' . $var . ' (\+ |- |\+ -)([\d]+)~', $val, $match)) |
| 409 | 417 | { |
| 410 | - if ($match[1] != '+ ') |
|
| 411 | - $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
| 418 | + if ($match[1] != '+ ') { |
|
| 419 | + $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
| 420 | + } |
|
| 412 | 421 | $type = 'raw'; |
| 413 | 422 | } |
| 414 | 423 | } |
@@ -429,8 +438,9 @@ discard block |
||
| 429 | 438 | // Clear any caching? |
| 430 | 439 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && !empty($members)) |
| 431 | 440 | { |
| 432 | - if (!is_array($members)) |
|
| 433 | - $members = array($members); |
|
| 441 | + if (!is_array($members)) { |
|
| 442 | + $members = array($members); |
|
| 443 | + } |
|
| 434 | 444 | |
| 435 | 445 | foreach ($members as $member) |
| 436 | 446 | { |
@@ -463,29 +473,32 @@ discard block |
||
| 463 | 473 | { |
| 464 | 474 | global $modSettings, $smcFunc; |
| 465 | 475 | |
| 466 | - if (empty($changeArray) || !is_array($changeArray)) |
|
| 467 | - return; |
|
| 476 | + if (empty($changeArray) || !is_array($changeArray)) { |
|
| 477 | + return; |
|
| 478 | + } |
|
| 468 | 479 | |
| 469 | 480 | $toRemove = array(); |
| 470 | 481 | |
| 471 | 482 | // Go check if there is any setting to be removed. |
| 472 | - foreach ($changeArray as $k => $v) |
|
| 473 | - if ($v === null) |
|
| 483 | + foreach ($changeArray as $k => $v) { |
|
| 484 | + if ($v === null) |
|
| 474 | 485 | { |
| 475 | 486 | // Found some, remove them from the original array and add them to ours. |
| 476 | 487 | unset($changeArray[$k]); |
| 488 | + } |
|
| 477 | 489 | $toRemove[] = $k; |
| 478 | 490 | } |
| 479 | 491 | |
| 480 | 492 | // Proceed with the deletion. |
| 481 | - if (!empty($toRemove)) |
|
| 482 | - $smcFunc['db_query']('', ' |
|
| 493 | + if (!empty($toRemove)) { |
|
| 494 | + $smcFunc['db_query']('', ' |
|
| 483 | 495 | DELETE FROM {db_prefix}settings |
| 484 | 496 | WHERE variable IN ({array_string:remove})', |
| 485 | 497 | array( |
| 486 | 498 | 'remove' => $toRemove, |
| 487 | 499 | ) |
| 488 | 500 | ); |
| 501 | + } |
|
| 489 | 502 | |
| 490 | 503 | // In some cases, this may be better and faster, but for large sets we don't want so many UPDATEs. |
| 491 | 504 | if ($update) |
@@ -514,19 +527,22 @@ discard block |
||
| 514 | 527 | foreach ($changeArray as $variable => $value) |
| 515 | 528 | { |
| 516 | 529 | // Don't bother if it's already like that ;). |
| 517 | - if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) |
|
| 518 | - continue; |
|
| 530 | + if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) { |
|
| 531 | + continue; |
|
| 532 | + } |
|
| 519 | 533 | // If the variable isn't set, but would only be set to nothing'ness, then don't bother setting it. |
| 520 | - elseif (!isset($modSettings[$variable]) && empty($value)) |
|
| 521 | - continue; |
|
| 534 | + elseif (!isset($modSettings[$variable]) && empty($value)) { |
|
| 535 | + continue; |
|
| 536 | + } |
|
| 522 | 537 | |
| 523 | 538 | $replaceArray[] = array($variable, $value); |
| 524 | 539 | |
| 525 | 540 | $modSettings[$variable] = $value; |
| 526 | 541 | } |
| 527 | 542 | |
| 528 | - if (empty($replaceArray)) |
|
| 529 | - return; |
|
| 543 | + if (empty($replaceArray)) { |
|
| 544 | + return; |
|
| 545 | + } |
|
| 530 | 546 | |
| 531 | 547 | $smcFunc['db_insert']('replace', |
| 532 | 548 | '{db_prefix}settings', |
@@ -572,14 +588,17 @@ discard block |
||
| 572 | 588 | $start_invalid = $start < 0; |
| 573 | 589 | |
| 574 | 590 | // Make sure $start is a proper variable - not less than 0. |
| 575 | - if ($start_invalid) |
|
| 576 | - $start = 0; |
|
| 591 | + if ($start_invalid) { |
|
| 592 | + $start = 0; |
|
| 593 | + } |
|
| 577 | 594 | // Not greater than the upper bound. |
| 578 | - elseif ($start >= $max_value) |
|
| 579 | - $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
| 595 | + elseif ($start >= $max_value) { |
|
| 596 | + $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
| 597 | + } |
|
| 580 | 598 | // And it has to be a multiple of $num_per_page! |
| 581 | - else |
|
| 582 | - $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
| 599 | + else { |
|
| 600 | + $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
| 601 | + } |
|
| 583 | 602 | |
| 584 | 603 | $context['current_page'] = $start / $num_per_page; |
| 585 | 604 | |
@@ -609,77 +628,87 @@ discard block |
||
| 609 | 628 | |
| 610 | 629 | // Show all the pages. |
| 611 | 630 | $display_page = 1; |
| 612 | - for ($counter = 0; $counter < $max_value; $counter += $num_per_page) |
|
| 613 | - $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
| 631 | + for ($counter = 0; $counter < $max_value; $counter += $num_per_page) { |
|
| 632 | + $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
| 633 | + } |
|
| 614 | 634 | |
| 615 | 635 | // Show the right arrow. |
| 616 | 636 | $display_page = ($start + $num_per_page) > $max_value ? $max_value : ($start + $num_per_page); |
| 617 | - if ($start != $counter - $max_value && !$start_invalid) |
|
| 618 | - $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
| 619 | - } |
|
| 620 | - else |
|
| 637 | + if ($start != $counter - $max_value && !$start_invalid) { |
|
| 638 | + $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
| 639 | + } |
|
| 640 | + } else |
|
| 621 | 641 | { |
| 622 | 642 | // If they didn't enter an odd value, pretend they did. |
| 623 | 643 | $PageContiguous = (int) ($modSettings['compactTopicPagesContiguous'] - ($modSettings['compactTopicPagesContiguous'] % 2)) / 2; |
| 624 | 644 | |
| 625 | 645 | // Show the "prev page" link. (>prev page< 1 ... 6 7 [8] 9 10 ... 15 next page) |
| 626 | - if (!empty($start) && $show_prevnext) |
|
| 627 | - $pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
| 628 | - else |
|
| 629 | - $pageindex .= ''; |
|
| 646 | + if (!empty($start) && $show_prevnext) { |
|
| 647 | + $pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
| 648 | + } else { |
|
| 649 | + $pageindex .= ''; |
|
| 650 | + } |
|
| 630 | 651 | |
| 631 | 652 | // Show the first page. (prev page >1< ... 6 7 [8] 9 10 ... 15) |
| 632 | - if ($start > $num_per_page * $PageContiguous) |
|
| 633 | - $pageindex .= sprintf($base_link, 0, '1'); |
|
| 653 | + if ($start > $num_per_page * $PageContiguous) { |
|
| 654 | + $pageindex .= sprintf($base_link, 0, '1'); |
|
| 655 | + } |
|
| 634 | 656 | |
| 635 | 657 | // Show the ... after the first page. (prev page 1 >...< 6 7 [8] 9 10 ... 15 next page) |
| 636 | - if ($start > $num_per_page * ($PageContiguous + 1)) |
|
| 637 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 658 | + if ($start > $num_per_page * ($PageContiguous + 1)) { |
|
| 659 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 638 | 660 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
| 639 | 661 | '{FIRST_PAGE}' => $num_per_page, |
| 640 | 662 | '{LAST_PAGE}' => $start - $num_per_page * $PageContiguous, |
| 641 | 663 | '{PER_PAGE}' => $num_per_page, |
| 642 | 664 | )); |
| 665 | + } |
|
| 643 | 666 | |
| 644 | 667 | // Show the pages before the current one. (prev page 1 ... >6 7< [8] 9 10 ... 15 next page) |
| 645 | - for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) |
|
| 646 | - if ($start >= $num_per_page * $nCont) |
|
| 668 | + for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) { |
|
| 669 | + if ($start >= $num_per_page * $nCont) |
|
| 647 | 670 | { |
| 648 | 671 | $tmpStart = $start - $num_per_page * $nCont; |
| 672 | + } |
|
| 649 | 673 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
| 650 | 674 | } |
| 651 | 675 | |
| 652 | 676 | // Show the current page. (prev page 1 ... 6 7 >[8]< 9 10 ... 15 next page) |
| 653 | - if (!$start_invalid) |
|
| 654 | - $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
| 655 | - else |
|
| 656 | - $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
| 677 | + if (!$start_invalid) { |
|
| 678 | + $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
| 679 | + } else { |
|
| 680 | + $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
| 681 | + } |
|
| 657 | 682 | |
| 658 | 683 | // Show the pages after the current one... (prev page 1 ... 6 7 [8] >9 10< ... 15 next page) |
| 659 | 684 | $tmpMaxPages = (int) (($max_value - 1) / $num_per_page) * $num_per_page; |
| 660 | - for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) |
|
| 661 | - if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
| 685 | + for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) { |
|
| 686 | + if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
| 662 | 687 | { |
| 663 | 688 | $tmpStart = $start + $num_per_page * $nCont; |
| 689 | + } |
|
| 664 | 690 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
| 665 | 691 | } |
| 666 | 692 | |
| 667 | 693 | // Show the '...' part near the end. (prev page 1 ... 6 7 [8] 9 10 >...< 15 next page) |
| 668 | - if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) |
|
| 669 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 694 | + if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) { |
|
| 695 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 670 | 696 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
| 671 | 697 | '{FIRST_PAGE}' => $start + $num_per_page * ($PageContiguous + 1), |
| 672 | 698 | '{LAST_PAGE}' => $tmpMaxPages, |
| 673 | 699 | '{PER_PAGE}' => $num_per_page, |
| 674 | 700 | )); |
| 701 | + } |
|
| 675 | 702 | |
| 676 | 703 | // Show the last number in the list. (prev page 1 ... 6 7 [8] 9 10 ... >15< next page) |
| 677 | - if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) |
|
| 678 | - $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
| 704 | + if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) { |
|
| 705 | + $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
| 706 | + } |
|
| 679 | 707 | |
| 680 | 708 | // Show the "next page" link. (prev page 1 ... 6 7 [8] 9 10 ... 15 >next page<) |
| 681 | - if ($start != $tmpMaxPages && $show_prevnext) |
|
| 682 | - $pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']); |
|
| 709 | + if ($start != $tmpMaxPages && $show_prevnext) { |
|
| 710 | + $pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']); |
|
| 711 | + } |
|
| 683 | 712 | } |
| 684 | 713 | $pageindex .= $settings['page_index']['extra_after']; |
| 685 | 714 | |
@@ -705,8 +734,9 @@ discard block |
||
| 705 | 734 | if ($decimal_separator === null) |
| 706 | 735 | { |
| 707 | 736 | // Not set for whatever reason? |
| 708 | - if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) |
|
| 709 | - return $number; |
|
| 737 | + if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) { |
|
| 738 | + return $number; |
|
| 739 | + } |
|
| 710 | 740 | |
| 711 | 741 | // Cache these each load... |
| 712 | 742 | $thousands_separator = $matches[1]; |
@@ -740,17 +770,20 @@ discard block |
||
| 740 | 770 | static $unsupportedFormats, $finalizedFormats; |
| 741 | 771 | |
| 742 | 772 | // Offset the time. |
| 743 | - if (!$offset_type) |
|
| 744 | - $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 773 | + if (!$offset_type) { |
|
| 774 | + $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 775 | + } |
|
| 745 | 776 | // Just the forum offset? |
| 746 | - elseif ($offset_type == 'forum') |
|
| 747 | - $time = $log_time + $modSettings['time_offset'] * 3600; |
|
| 748 | - else |
|
| 749 | - $time = $log_time; |
|
| 777 | + elseif ($offset_type == 'forum') { |
|
| 778 | + $time = $log_time + $modSettings['time_offset'] * 3600; |
|
| 779 | + } else { |
|
| 780 | + $time = $log_time; |
|
| 781 | + } |
|
| 750 | 782 | |
| 751 | 783 | // We can't have a negative date (on Windows, at least.) |
| 752 | - if ($log_time < 0) |
|
| 753 | - $log_time = 0; |
|
| 784 | + if ($log_time < 0) { |
|
| 785 | + $log_time = 0; |
|
| 786 | + } |
|
| 754 | 787 | |
| 755 | 788 | // Today and Yesterday? |
| 756 | 789 | if ($modSettings['todayMod'] >= 1 && $show_today === true) |
@@ -767,24 +800,27 @@ discard block |
||
| 767 | 800 | { |
| 768 | 801 | $h = strpos($user_info['time_format'], '%l') === false ? '%I' : '%l'; |
| 769 | 802 | $today_fmt = $h . ':%M' . $s . ' %p'; |
| 803 | + } else { |
|
| 804 | + $today_fmt = '%H:%M' . $s; |
|
| 770 | 805 | } |
| 771 | - else |
|
| 772 | - $today_fmt = '%H:%M' . $s; |
|
| 773 | 806 | |
| 774 | 807 | // Same day of the year, same year.... Today! |
| 775 | - if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) |
|
| 776 | - return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 808 | + if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) { |
|
| 809 | + return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 810 | + } |
|
| 777 | 811 | |
| 778 | 812 | // 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... |
| 779 | - 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)) |
|
| 780 | - return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 813 | + 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)) { |
|
| 814 | + return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 815 | + } |
|
| 781 | 816 | } |
| 782 | 817 | |
| 783 | 818 | $str = !is_bool($show_today) ? $show_today : $user_info['time_format']; |
| 784 | 819 | |
| 785 | 820 | // Use the cached formats if available |
| 786 | - if (is_null($finalizedFormats)) |
|
| 787 | - $finalizedFormats = (array) cache_get_data('timeformatstrings', 86400); |
|
| 821 | + if (is_null($finalizedFormats)) { |
|
| 822 | + $finalizedFormats = (array) cache_get_data('timeformatstrings', 86400); |
|
| 823 | + } |
|
| 788 | 824 | |
| 789 | 825 | // Make a supported version for this format if we don't already have one |
| 790 | 826 | if (empty($finalizedFormats[$str])) |
@@ -813,8 +849,9 @@ discard block |
||
| 813 | 849 | ); |
| 814 | 850 | |
| 815 | 851 | // No need to do this part again if we already did it once |
| 816 | - if (is_null($unsupportedFormats)) |
|
| 817 | - $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
|
| 852 | + if (is_null($unsupportedFormats)) { |
|
| 853 | + $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
|
| 854 | + } |
|
| 818 | 855 | if (empty($unsupportedFormats)) |
| 819 | 856 | { |
| 820 | 857 | foreach($strftimeFormatSubstitutions as $format => $substitution) |
@@ -823,20 +860,23 @@ discard block |
||
| 823 | 860 | |
| 824 | 861 | // Windows will return false for unsupported formats |
| 825 | 862 | // Other operating systems return the format string as a literal |
| 826 | - if ($value === false || $value === $format) |
|
| 827 | - $unsupportedFormats[] = $format; |
|
| 863 | + if ($value === false || $value === $format) { |
|
| 864 | + $unsupportedFormats[] = $format; |
|
| 865 | + } |
|
| 828 | 866 | } |
| 829 | 867 | cache_put_data('unsupportedtimeformats', $unsupportedFormats, 86400); |
| 830 | 868 | } |
| 831 | 869 | |
| 832 | 870 | // Windows needs extra help if $timeformat contains something completely invalid, e.g. '%Q' |
| 833 | - if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') |
|
| 834 | - $timeformat = preg_replace('~%(?!' . implode('|', array_keys($strftimeFormatSubstitutions)) . ')~', '%', $timeformat); |
|
| 871 | + if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { |
|
| 872 | + $timeformat = preg_replace('~%(?!' . implode('|', array_keys($strftimeFormatSubstitutions)) . ')~', '%', $timeformat); |
|
| 873 | + } |
|
| 835 | 874 | |
| 836 | 875 | // Substitute unsupported formats with supported ones |
| 837 | - if (!empty($unsupportedFormats)) |
|
| 838 | - while (preg_match('~%(' . implode('|', $unsupportedFormats) . ')~', $timeformat, $matches)) |
|
| 876 | + if (!empty($unsupportedFormats)) { |
|
| 877 | + while (preg_match('~%(' . implode('|', $unsupportedFormats) . ')~', $timeformat, $matches)) |
|
| 839 | 878 | $timeformat = str_replace($matches[0], $strftimeFormatSubstitutions[$matches[1]], $timeformat); |
| 879 | + } |
|
| 840 | 880 | |
| 841 | 881 | // Remember this so we don't need to do it again |
| 842 | 882 | $finalizedFormats[$str] = $timeformat; |
@@ -845,33 +885,39 @@ discard block |
||
| 845 | 885 | |
| 846 | 886 | $str = $finalizedFormats[$str]; |
| 847 | 887 | |
| 848 | - if (!isset($locale_cache)) |
|
| 849 | - $locale_cache = setlocale(LC_TIME, $txt['lang_locale']); |
|
| 888 | + if (!isset($locale_cache)) { |
|
| 889 | + $locale_cache = setlocale(LC_TIME, $txt['lang_locale']); |
|
| 890 | + } |
|
| 850 | 891 | |
| 851 | 892 | if ($locale_cache !== false) |
| 852 | 893 | { |
| 853 | 894 | // Check if another process changed the locale |
| 854 | - if ($process_safe === true && setlocale(LC_TIME, '0') != $locale_cache) |
|
| 855 | - setlocale(LC_TIME, $txt['lang_locale']); |
|
| 895 | + if ($process_safe === true && setlocale(LC_TIME, '0') != $locale_cache) { |
|
| 896 | + setlocale(LC_TIME, $txt['lang_locale']); |
|
| 897 | + } |
|
| 856 | 898 | |
| 857 | - if (!isset($non_twelve_hour)) |
|
| 858 | - $non_twelve_hour = trim(strftime('%p')) === ''; |
|
| 859 | - if ($non_twelve_hour && strpos($str, '%p') !== false) |
|
| 860 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 899 | + if (!isset($non_twelve_hour)) { |
|
| 900 | + $non_twelve_hour = trim(strftime('%p')) === ''; |
|
| 901 | + } |
|
| 902 | + if ($non_twelve_hour && strpos($str, '%p') !== false) { |
|
| 903 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 904 | + } |
|
| 861 | 905 | |
| 862 | - foreach (array('%a', '%A', '%b', '%B') as $token) |
|
| 863 | - if (strpos($str, $token) !== false) |
|
| 906 | + foreach (array('%a', '%A', '%b', '%B') as $token) { |
|
| 907 | + if (strpos($str, $token) !== false) |
|
| 864 | 908 | $str = str_replace($token, strftime($token, $time), $str); |
| 865 | - } |
|
| 866 | - else |
|
| 909 | + } |
|
| 910 | + } else |
|
| 867 | 911 | { |
| 868 | 912 | // Do-it-yourself time localization. Fun. |
| 869 | - foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) |
|
| 870 | - if (strpos($str, $token) !== false) |
|
| 913 | + foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) { |
|
| 914 | + if (strpos($str, $token) !== false) |
|
| 871 | 915 | $str = str_replace($token, $txt[$text_label][(int) strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str); |
| 916 | + } |
|
| 872 | 917 | |
| 873 | - if (strpos($str, '%p') !== false) |
|
| 874 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 918 | + if (strpos($str, '%p') !== false) { |
|
| 919 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 920 | + } |
|
| 875 | 921 | } |
| 876 | 922 | |
| 877 | 923 | // Format the time and then restore any literal percent characters |
@@ -894,16 +940,19 @@ discard block |
||
| 894 | 940 | static $translation = array(); |
| 895 | 941 | |
| 896 | 942 | // Determine the character set... Default to UTF-8 |
| 897 | - if (empty($context['character_set'])) |
|
| 898 | - $charset = 'UTF-8'; |
|
| 943 | + if (empty($context['character_set'])) { |
|
| 944 | + $charset = 'UTF-8'; |
|
| 945 | + } |
|
| 899 | 946 | // Use ISO-8859-1 in place of non-supported ISO-8859 charsets... |
| 900 | - elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) |
|
| 901 | - $charset = 'ISO-8859-1'; |
|
| 902 | - else |
|
| 903 | - $charset = $context['character_set']; |
|
| 947 | + elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) { |
|
| 948 | + $charset = 'ISO-8859-1'; |
|
| 949 | + } else { |
|
| 950 | + $charset = $context['character_set']; |
|
| 951 | + } |
|
| 904 | 952 | |
| 905 | - if (empty($translation)) |
|
| 906 | - $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
| 953 | + if (empty($translation)) { |
|
| 954 | + $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
| 955 | + } |
|
| 907 | 956 | |
| 908 | 957 | return strtr($string, $translation); |
| 909 | 958 | } |
@@ -925,8 +974,9 @@ discard block |
||
| 925 | 974 | global $smcFunc; |
| 926 | 975 | |
| 927 | 976 | // It was already short enough! |
| 928 | - if ($smcFunc['strlen']($subject) <= $len) |
|
| 929 | - return $subject; |
|
| 977 | + if ($smcFunc['strlen']($subject) <= $len) { |
|
| 978 | + return $subject; |
|
| 979 | + } |
|
| 930 | 980 | |
| 931 | 981 | // Shorten it by the length it was too long, and strip off junk from the end. |
| 932 | 982 | return $smcFunc['substr']($subject, 0, $len) . '...'; |
@@ -945,10 +995,11 @@ discard block |
||
| 945 | 995 | { |
| 946 | 996 | global $user_info, $modSettings; |
| 947 | 997 | |
| 948 | - if ($timestamp === null) |
|
| 949 | - $timestamp = time(); |
|
| 950 | - elseif ($timestamp == 0) |
|
| 951 | - return 0; |
|
| 998 | + if ($timestamp === null) { |
|
| 999 | + $timestamp = time(); |
|
| 1000 | + } elseif ($timestamp == 0) { |
|
| 1001 | + return 0; |
|
| 1002 | + } |
|
| 952 | 1003 | |
| 953 | 1004 | return $timestamp + ($modSettings['time_offset'] + ($use_user_offset ? $user_info['time_offset'] : 0)) * 3600; |
| 954 | 1005 | } |
@@ -977,8 +1028,9 @@ discard block |
||
| 977 | 1028 | $array[$i] = $array[$j]; |
| 978 | 1029 | $array[$j] = $temp; |
| 979 | 1030 | |
| 980 | - for ($i = 1; $p[$i] == 0; $i++) |
|
| 981 | - $p[$i] = 1; |
|
| 1031 | + for ($i = 1; $p[$i] == 0; $i++) { |
|
| 1032 | + $p[$i] = 1; |
|
| 1033 | + } |
|
| 982 | 1034 | |
| 983 | 1035 | $orders[] = $array; |
| 984 | 1036 | } |
@@ -1010,12 +1062,14 @@ discard block |
||
| 1010 | 1062 | static $disabled; |
| 1011 | 1063 | |
| 1012 | 1064 | // Don't waste cycles |
| 1013 | - if ($message === '') |
|
| 1014 | - return ''; |
|
| 1065 | + if ($message === '') { |
|
| 1066 | + return ''; |
|
| 1067 | + } |
|
| 1015 | 1068 | |
| 1016 | 1069 | // Just in case it wasn't determined yet whether UTF-8 is enabled. |
| 1017 | - if (!isset($context['utf8'])) |
|
| 1018 | - $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
| 1070 | + if (!isset($context['utf8'])) { |
|
| 1071 | + $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
| 1072 | + } |
|
| 1019 | 1073 | |
| 1020 | 1074 | // Clean up any cut/paste issues we may have |
| 1021 | 1075 | $message = sanitizeMSCutPaste($message); |
@@ -1027,13 +1081,15 @@ discard block |
||
| 1027 | 1081 | return $message; |
| 1028 | 1082 | } |
| 1029 | 1083 | |
| 1030 | - if ($smileys !== null && ($smileys == '1' || $smileys == '0')) |
|
| 1031 | - $smileys = (bool) $smileys; |
|
| 1084 | + if ($smileys !== null && ($smileys == '1' || $smileys == '0')) { |
|
| 1085 | + $smileys = (bool) $smileys; |
|
| 1086 | + } |
|
| 1032 | 1087 | |
| 1033 | 1088 | if (empty($modSettings['enableBBC']) && $message !== false) |
| 1034 | 1089 | { |
| 1035 | - if ($smileys === true) |
|
| 1036 | - parsesmileys($message); |
|
| 1090 | + if ($smileys === true) { |
|
| 1091 | + parsesmileys($message); |
|
| 1092 | + } |
|
| 1037 | 1093 | |
| 1038 | 1094 | return $message; |
| 1039 | 1095 | } |
@@ -1046,8 +1102,9 @@ discard block |
||
| 1046 | 1102 | } |
| 1047 | 1103 | |
| 1048 | 1104 | // Ensure $modSettings['tld_regex'] contains a valid regex for the autolinker |
| 1049 | - if (!empty($modSettings['autoLinkUrls'])) |
|
| 1050 | - set_tld_regex(); |
|
| 1105 | + if (!empty($modSettings['autoLinkUrls'])) { |
|
| 1106 | + set_tld_regex(); |
|
| 1107 | + } |
|
| 1051 | 1108 | |
| 1052 | 1109 | // Allow mods access before entering the main parse_bbc loop |
| 1053 | 1110 | call_integration_hook('integrate_pre_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
@@ -1061,12 +1118,14 @@ discard block |
||
| 1061 | 1118 | |
| 1062 | 1119 | $temp = explode(',', strtolower($modSettings['disabledBBC'])); |
| 1063 | 1120 | |
| 1064 | - foreach ($temp as $tag) |
|
| 1065 | - $disabled[trim($tag)] = true; |
|
| 1121 | + foreach ($temp as $tag) { |
|
| 1122 | + $disabled[trim($tag)] = true; |
|
| 1123 | + } |
|
| 1066 | 1124 | } |
| 1067 | 1125 | |
| 1068 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
| 1069 | - $disabled['flash'] = true; |
|
| 1126 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
| 1127 | + $disabled['flash'] = true; |
|
| 1128 | + } |
|
| 1070 | 1129 | |
| 1071 | 1130 | /* The following bbc are formatted as an array, with keys as follows: |
| 1072 | 1131 | |
@@ -1187,8 +1246,9 @@ discard block |
||
| 1187 | 1246 | $returnContext = ''; |
| 1188 | 1247 | |
| 1189 | 1248 | // BBC or the entire attachments feature is disabled |
| 1190 | - if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) |
|
| 1191 | - return $data; |
|
| 1249 | + if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) { |
|
| 1250 | + return $data; |
|
| 1251 | + } |
|
| 1192 | 1252 | |
| 1193 | 1253 | // Save the attach ID. |
| 1194 | 1254 | $attachID = $data; |
@@ -1199,8 +1259,9 @@ discard block |
||
| 1199 | 1259 | $currentAttachment = parseAttachBBC($attachID); |
| 1200 | 1260 | |
| 1201 | 1261 | // parseAttachBBC will return a string ($txt key) rather than diying with a fatal_error. Up to you to decide what to do. |
| 1202 | - if (is_string($currentAttachment)) |
|
| 1203 | - return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
| 1262 | + if (is_string($currentAttachment)) { |
|
| 1263 | + return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
| 1264 | + } |
|
| 1204 | 1265 | |
| 1205 | 1266 | if (!empty($currentAttachment['is_image'])) |
| 1206 | 1267 | { |
@@ -1216,15 +1277,17 @@ discard block |
||
| 1216 | 1277 | $height = ' height="' . $currentAttachment['height'] . '"'; |
| 1217 | 1278 | } |
| 1218 | 1279 | |
| 1219 | - if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) |
|
| 1220 | - $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>'; |
|
| 1221 | - else |
|
| 1222 | - $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
|
| 1280 | + if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) { |
|
| 1281 | + $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>'; |
|
| 1282 | + } else { |
|
| 1283 | + $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
|
| 1284 | + } |
|
| 1223 | 1285 | } |
| 1224 | 1286 | |
| 1225 | 1287 | // No image. Show a link. |
| 1226 | - else |
|
| 1227 | - $returnContext .= $currentAttachment['link']; |
|
| 1288 | + else { |
|
| 1289 | + $returnContext .= $currentAttachment['link']; |
|
| 1290 | + } |
|
| 1228 | 1291 | |
| 1229 | 1292 | // Gotta append what we just did. |
| 1230 | 1293 | $data = $returnContext; |
@@ -1255,8 +1318,9 @@ discard block |
||
| 1255 | 1318 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
| 1256 | 1319 | { |
| 1257 | 1320 | // Do PHP code coloring? |
| 1258 | - if ($php_parts[$php_i] != '<?php') |
|
| 1259 | - continue; |
|
| 1321 | + if ($php_parts[$php_i] != '<?php') { |
|
| 1322 | + continue; |
|
| 1323 | + } |
|
| 1260 | 1324 | |
| 1261 | 1325 | $php_string = ''; |
| 1262 | 1326 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1272,8 +1336,9 @@ discard block |
||
| 1272 | 1336 | $data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data); |
| 1273 | 1337 | |
| 1274 | 1338 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
| 1275 | - if ($context['browser']['is_opera']) |
|
| 1276 | - $data .= ' '; |
|
| 1339 | + if ($context['browser']['is_opera']) { |
|
| 1340 | + $data .= ' '; |
|
| 1341 | + } |
|
| 1277 | 1342 | } |
| 1278 | 1343 | }, |
| 1279 | 1344 | 'block_level' => true, |
@@ -1292,8 +1357,9 @@ discard block |
||
| 1292 | 1357 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
| 1293 | 1358 | { |
| 1294 | 1359 | // Do PHP code coloring? |
| 1295 | - if ($php_parts[$php_i] != '<?php') |
|
| 1296 | - continue; |
|
| 1360 | + if ($php_parts[$php_i] != '<?php') { |
|
| 1361 | + continue; |
|
| 1362 | + } |
|
| 1297 | 1363 | |
| 1298 | 1364 | $php_string = ''; |
| 1299 | 1365 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1309,8 +1375,9 @@ discard block |
||
| 1309 | 1375 | $data[0] = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data[0]); |
| 1310 | 1376 | |
| 1311 | 1377 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
| 1312 | - if ($context['browser']['is_opera']) |
|
| 1313 | - $data[0] .= ' '; |
|
| 1378 | + if ($context['browser']['is_opera']) { |
|
| 1379 | + $data[0] .= ' '; |
|
| 1380 | + } |
|
| 1314 | 1381 | } |
| 1315 | 1382 | }, |
| 1316 | 1383 | 'block_level' => true, |
@@ -1348,11 +1415,13 @@ discard block |
||
| 1348 | 1415 | 'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">', |
| 1349 | 1416 | 'validate' => function (&$tag, &$data, $disabled) |
| 1350 | 1417 | { |
| 1351 | - if (isset($disabled['url'])) |
|
| 1352 | - $tag['content'] = '$1'; |
|
| 1418 | + if (isset($disabled['url'])) { |
|
| 1419 | + $tag['content'] = '$1'; |
|
| 1420 | + } |
|
| 1353 | 1421 | $scheme = parse_url($data[0], PHP_URL_SCHEME); |
| 1354 | - if (empty($scheme)) |
|
| 1355 | - $data[0] = '//' . ltrim($data[0], ':/'); |
|
| 1422 | + if (empty($scheme)) { |
|
| 1423 | + $data[0] = '//' . ltrim($data[0], ':/'); |
|
| 1424 | + } |
|
| 1356 | 1425 | }, |
| 1357 | 1426 | 'disabled_content' => '<a href="$1" target="_blank">$1</a>', |
| 1358 | 1427 | ), |
@@ -1366,10 +1435,11 @@ discard block |
||
| 1366 | 1435 | { |
| 1367 | 1436 | $class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"'; |
| 1368 | 1437 | |
| 1369 | - if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) |
|
| 1370 | - $css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"'; |
|
| 1371 | - else |
|
| 1372 | - $css = ''; |
|
| 1438 | + if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) { |
|
| 1439 | + $css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"'; |
|
| 1440 | + } else { |
|
| 1441 | + $css = ''; |
|
| 1442 | + } |
|
| 1373 | 1443 | |
| 1374 | 1444 | $data = $class . $css; |
| 1375 | 1445 | }, |
@@ -1419,14 +1489,16 @@ discard block |
||
| 1419 | 1489 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1420 | 1490 | if ($image_proxy_enabled) |
| 1421 | 1491 | { |
| 1422 | - if (empty($scheme)) |
|
| 1423 | - $data = 'http://' . ltrim($data, ':/'); |
|
| 1492 | + if (empty($scheme)) { |
|
| 1493 | + $data = 'http://' . ltrim($data, ':/'); |
|
| 1494 | + } |
|
| 1424 | 1495 | |
| 1425 | - if ($scheme != 'https') |
|
| 1426 | - $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
| 1496 | + if ($scheme != 'https') { |
|
| 1497 | + $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
| 1498 | + } |
|
| 1499 | + } elseif (empty($scheme)) { |
|
| 1500 | + $data = '//' . ltrim($data, ':/'); |
|
| 1427 | 1501 | } |
| 1428 | - elseif (empty($scheme)) |
|
| 1429 | - $data = '//' . ltrim($data, ':/'); |
|
| 1430 | 1502 | }, |
| 1431 | 1503 | 'disabled_content' => '($1)', |
| 1432 | 1504 | ), |
@@ -1442,14 +1514,16 @@ discard block |
||
| 1442 | 1514 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1443 | 1515 | if ($image_proxy_enabled) |
| 1444 | 1516 | { |
| 1445 | - if (empty($scheme)) |
|
| 1446 | - $data = 'http://' . ltrim($data, ':/'); |
|
| 1517 | + if (empty($scheme)) { |
|
| 1518 | + $data = 'http://' . ltrim($data, ':/'); |
|
| 1519 | + } |
|
| 1447 | 1520 | |
| 1448 | - if ($scheme != 'https') |
|
| 1449 | - $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
| 1521 | + if ($scheme != 'https') { |
|
| 1522 | + $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
| 1523 | + } |
|
| 1524 | + } elseif (empty($scheme)) { |
|
| 1525 | + $data = '//' . ltrim($data, ':/'); |
|
| 1450 | 1526 | } |
| 1451 | - elseif (empty($scheme)) |
|
| 1452 | - $data = '//' . ltrim($data, ':/'); |
|
| 1453 | 1527 | }, |
| 1454 | 1528 | 'disabled_content' => '($1)', |
| 1455 | 1529 | ), |
@@ -1461,8 +1535,9 @@ discard block |
||
| 1461 | 1535 | { |
| 1462 | 1536 | $data = strtr($data, array('<br>' => '')); |
| 1463 | 1537 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1464 | - if (empty($scheme)) |
|
| 1465 | - $data = '//' . ltrim($data, ':/'); |
|
| 1538 | + if (empty($scheme)) { |
|
| 1539 | + $data = '//' . ltrim($data, ':/'); |
|
| 1540 | + } |
|
| 1466 | 1541 | }, |
| 1467 | 1542 | ), |
| 1468 | 1543 | array( |
@@ -1473,13 +1548,14 @@ discard block |
||
| 1473 | 1548 | 'after' => '</a>', |
| 1474 | 1549 | 'validate' => function (&$tag, &$data, $disabled) |
| 1475 | 1550 | { |
| 1476 | - if (substr($data, 0, 1) == '#') |
|
| 1477 | - $data = '#post_' . substr($data, 1); |
|
| 1478 | - else |
|
| 1551 | + if (substr($data, 0, 1) == '#') { |
|
| 1552 | + $data = '#post_' . substr($data, 1); |
|
| 1553 | + } else |
|
| 1479 | 1554 | { |
| 1480 | 1555 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1481 | - if (empty($scheme)) |
|
| 1482 | - $data = '//' . ltrim($data, ':/'); |
|
| 1556 | + if (empty($scheme)) { |
|
| 1557 | + $data = '//' . ltrim($data, ':/'); |
|
| 1558 | + } |
|
| 1483 | 1559 | } |
| 1484 | 1560 | }, |
| 1485 | 1561 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
@@ -1557,8 +1633,9 @@ discard block |
||
| 1557 | 1633 | { |
| 1558 | 1634 | $add_begin = substr(trim($data), 0, 5) != '<?'; |
| 1559 | 1635 | $data = highlight_php_code($add_begin ? '<?php ' . $data . '?>' : $data); |
| 1560 | - if ($add_begin) |
|
| 1561 | - $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
| 1636 | + if ($add_begin) { |
|
| 1637 | + $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
| 1638 | + } |
|
| 1562 | 1639 | } |
| 1563 | 1640 | }, |
| 1564 | 1641 | 'block_level' => false, |
@@ -1689,10 +1766,11 @@ discard block |
||
| 1689 | 1766 | 'content' => '$1', |
| 1690 | 1767 | 'validate' => function (&$tag, &$data, $disabled) |
| 1691 | 1768 | { |
| 1692 | - if (is_numeric($data)) |
|
| 1693 | - $data = timeformat($data); |
|
| 1694 | - else |
|
| 1695 | - $tag['content'] = '[time]$1[/time]'; |
|
| 1769 | + if (is_numeric($data)) { |
|
| 1770 | + $data = timeformat($data); |
|
| 1771 | + } else { |
|
| 1772 | + $tag['content'] = '[time]$1[/time]'; |
|
| 1773 | + } |
|
| 1696 | 1774 | }, |
| 1697 | 1775 | ), |
| 1698 | 1776 | array( |
@@ -1719,8 +1797,9 @@ discard block |
||
| 1719 | 1797 | { |
| 1720 | 1798 | $data = strtr($data, array('<br>' => '')); |
| 1721 | 1799 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1722 | - if (empty($scheme)) |
|
| 1723 | - $data = '//' . ltrim($data, ':/'); |
|
| 1800 | + if (empty($scheme)) { |
|
| 1801 | + $data = '//' . ltrim($data, ':/'); |
|
| 1802 | + } |
|
| 1724 | 1803 | }, |
| 1725 | 1804 | ), |
| 1726 | 1805 | array( |
@@ -1732,8 +1811,9 @@ discard block |
||
| 1732 | 1811 | 'validate' => function (&$tag, &$data, $disabled) |
| 1733 | 1812 | { |
| 1734 | 1813 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1735 | - if (empty($scheme)) |
|
| 1736 | - $data = '//' . ltrim($data, ':/'); |
|
| 1814 | + if (empty($scheme)) { |
|
| 1815 | + $data = '//' . ltrim($data, ':/'); |
|
| 1816 | + } |
|
| 1737 | 1817 | }, |
| 1738 | 1818 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
| 1739 | 1819 | 'disabled_after' => ' ($1)', |
@@ -1753,8 +1833,9 @@ discard block |
||
| 1753 | 1833 | // This is mainly for the bbc manager, so it's easy to add tags above. Custom BBC should be added above this line. |
| 1754 | 1834 | if ($message === false) |
| 1755 | 1835 | { |
| 1756 | - if (isset($temp_bbc)) |
|
| 1757 | - $bbc_codes = $temp_bbc; |
|
| 1836 | + if (isset($temp_bbc)) { |
|
| 1837 | + $bbc_codes = $temp_bbc; |
|
| 1838 | + } |
|
| 1758 | 1839 | usort($codes, function ($a, $b) { |
| 1759 | 1840 | return strcmp($a['tag'], $b['tag']); |
| 1760 | 1841 | }); |
@@ -1774,8 +1855,9 @@ discard block |
||
| 1774 | 1855 | ); |
| 1775 | 1856 | if (!isset($disabled['li']) && !isset($disabled['list'])) |
| 1776 | 1857 | { |
| 1777 | - foreach ($itemcodes as $c => $dummy) |
|
| 1778 | - $bbc_codes[$c] = array(); |
|
| 1858 | + foreach ($itemcodes as $c => $dummy) { |
|
| 1859 | + $bbc_codes[$c] = array(); |
|
| 1860 | + } |
|
| 1779 | 1861 | } |
| 1780 | 1862 | |
| 1781 | 1863 | // Shhhh! |
@@ -1796,12 +1878,14 @@ discard block |
||
| 1796 | 1878 | foreach ($codes as $code) |
| 1797 | 1879 | { |
| 1798 | 1880 | // Make it easier to process parameters later |
| 1799 | - if (!empty($code['parameters'])) |
|
| 1800 | - ksort($code['parameters'], SORT_STRING); |
|
| 1881 | + if (!empty($code['parameters'])) { |
|
| 1882 | + ksort($code['parameters'], SORT_STRING); |
|
| 1883 | + } |
|
| 1801 | 1884 | |
| 1802 | 1885 | // If we are not doing every tag only do ones we are interested in. |
| 1803 | - if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) |
|
| 1804 | - $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
| 1886 | + if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) { |
|
| 1887 | + $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
| 1888 | + } |
|
| 1805 | 1889 | } |
| 1806 | 1890 | $codes = null; |
| 1807 | 1891 | } |
@@ -1812,8 +1896,9 @@ discard block |
||
| 1812 | 1896 | // It's likely this will change if the message is modified. |
| 1813 | 1897 | $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']); |
| 1814 | 1898 | |
| 1815 | - if (($temp = cache_get_data($cache_key, 240)) != null) |
|
| 1816 | - return $temp; |
|
| 1899 | + if (($temp = cache_get_data($cache_key, 240)) != null) { |
|
| 1900 | + return $temp; |
|
| 1901 | + } |
|
| 1817 | 1902 | |
| 1818 | 1903 | $cache_t = microtime(); |
| 1819 | 1904 | } |
@@ -1845,8 +1930,9 @@ discard block |
||
| 1845 | 1930 | $disabled['flash'] = true; |
| 1846 | 1931 | |
| 1847 | 1932 | // @todo Change maybe? |
| 1848 | - if (!isset($_GET['images'])) |
|
| 1849 | - $disabled['img'] = true; |
|
| 1933 | + if (!isset($_GET['images'])) { |
|
| 1934 | + $disabled['img'] = true; |
|
| 1935 | + } |
|
| 1850 | 1936 | |
| 1851 | 1937 | // @todo Interface/setting to add more? |
| 1852 | 1938 | } |
@@ -1870,8 +1956,9 @@ discard block |
||
| 1870 | 1956 | $pos = isset($matches[0][1]) ? $matches[0][1] : false; |
| 1871 | 1957 | |
| 1872 | 1958 | // Failsafe. |
| 1873 | - if ($pos === false || $last_pos > $pos) |
|
| 1874 | - $pos = strlen($message) + 1; |
|
| 1959 | + if ($pos === false || $last_pos > $pos) { |
|
| 1960 | + $pos = strlen($message) + 1; |
|
| 1961 | + } |
|
| 1875 | 1962 | |
| 1876 | 1963 | // Can't have a one letter smiley, URL, or email! (sorry.) |
| 1877 | 1964 | if ($last_pos < $pos - 1) |
@@ -1889,8 +1976,9 @@ discard block |
||
| 1889 | 1976 | |
| 1890 | 1977 | // <br> should be empty. |
| 1891 | 1978 | $empty_tags = array('br', 'hr'); |
| 1892 | - foreach ($empty_tags as $tag) |
|
| 1893 | - $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '<' . $tag . '>', $data); |
|
| 1979 | + foreach ($empty_tags as $tag) { |
|
| 1980 | + $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '<' . $tag . '>', $data); |
|
| 1981 | + } |
|
| 1894 | 1982 | |
| 1895 | 1983 | // b, u, i, s, pre... basic tags. |
| 1896 | 1984 | $closable_tags = array('b', 'u', 'i', 's', 'em', 'ins', 'del', 'pre', 'blockquote', 'strong'); |
@@ -1899,8 +1987,9 @@ discard block |
||
| 1899 | 1987 | $diff = substr_count($data, '<' . $tag . '>') - substr_count($data, '</' . $tag . '>'); |
| 1900 | 1988 | $data = strtr($data, array('<' . $tag . '>' => '<' . $tag . '>', '</' . $tag . '>' => '</' . $tag . '>')); |
| 1901 | 1989 | |
| 1902 | - if ($diff > 0) |
|
| 1903 | - $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
| 1990 | + if ($diff > 0) { |
|
| 1991 | + $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
| 1992 | + } |
|
| 1904 | 1993 | } |
| 1905 | 1994 | |
| 1906 | 1995 | // Do <img ...> - with security... action= -> action-. |
@@ -1913,8 +2002,9 @@ discard block |
||
| 1913 | 2002 | $alt = empty($matches[3][$match]) ? '' : ' alt=' . preg_replace('~^"|"$~', '', $matches[3][$match]); |
| 1914 | 2003 | |
| 1915 | 2004 | // Remove action= from the URL - no funny business, now. |
| 1916 | - if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) |
|
| 1917 | - $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
| 2005 | + if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) { |
|
| 2006 | + $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
| 2007 | + } |
|
| 1918 | 2008 | |
| 1919 | 2009 | // Check if the image is larger than allowed. |
| 1920 | 2010 | if (!empty($modSettings['max_image_width']) && !empty($modSettings['max_image_height'])) |
@@ -1935,9 +2025,9 @@ discard block |
||
| 1935 | 2025 | |
| 1936 | 2026 | // Set the new image tag. |
| 1937 | 2027 | $replaces[$matches[0][$match]] = '[img width=' . $width . ' height=' . $height . $alt . ']' . $imgtag . '[/img]'; |
| 2028 | + } else { |
|
| 2029 | + $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
|
| 1938 | 2030 | } |
| 1939 | - else |
|
| 1940 | - $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
|
| 1941 | 2031 | } |
| 1942 | 2032 | |
| 1943 | 2033 | $data = strtr($data, $replaces); |
@@ -1950,16 +2040,18 @@ discard block |
||
| 1950 | 2040 | $no_autolink_area = false; |
| 1951 | 2041 | if (!empty($open_tags)) |
| 1952 | 2042 | { |
| 1953 | - foreach ($open_tags as $open_tag) |
|
| 1954 | - if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
| 2043 | + foreach ($open_tags as $open_tag) { |
|
| 2044 | + if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
| 1955 | 2045 | $no_autolink_area = true; |
| 2046 | + } |
|
| 1956 | 2047 | } |
| 1957 | 2048 | |
| 1958 | 2049 | // Don't go backwards. |
| 1959 | 2050 | // @todo Don't think is the real solution.... |
| 1960 | 2051 | $lastAutoPos = isset($lastAutoPos) ? $lastAutoPos : 0; |
| 1961 | - if ($pos < $lastAutoPos) |
|
| 1962 | - $no_autolink_area = true; |
|
| 2052 | + if ($pos < $lastAutoPos) { |
|
| 2053 | + $no_autolink_area = true; |
|
| 2054 | + } |
|
| 1963 | 2055 | $lastAutoPos = $pos; |
| 1964 | 2056 | |
| 1965 | 2057 | if (!$no_autolink_area) |
@@ -2068,17 +2160,19 @@ discard block |
||
| 2068 | 2160 | if ($scheme == 'mailto') |
| 2069 | 2161 | { |
| 2070 | 2162 | $email_address = str_replace('mailto:', '', $url); |
| 2071 | - if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) |
|
| 2072 | - return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
| 2073 | - else |
|
| 2074 | - return $url; |
|
| 2163 | + if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) { |
|
| 2164 | + return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
| 2165 | + } else { |
|
| 2166 | + return $url; |
|
| 2167 | + } |
|
| 2075 | 2168 | } |
| 2076 | 2169 | |
| 2077 | 2170 | // Are we linking a schemeless URL or naked domain name (e.g. "example.com")? |
| 2078 | - if (empty($scheme)) |
|
| 2079 | - $fullUrl = '//' . ltrim($url, ':/'); |
|
| 2080 | - else |
|
| 2081 | - $fullUrl = $url; |
|
| 2171 | + if (empty($scheme)) { |
|
| 2172 | + $fullUrl = '//' . ltrim($url, ':/'); |
|
| 2173 | + } else { |
|
| 2174 | + $fullUrl = $url; |
|
| 2175 | + } |
|
| 2082 | 2176 | |
| 2083 | 2177 | return '[url="' . str_replace(array('[', ']'), array('[', ']'), $fullUrl) . '"]' . $url . '[/url]'; |
| 2084 | 2178 | }, $data); |
@@ -2127,16 +2221,18 @@ discard block |
||
| 2127 | 2221 | } |
| 2128 | 2222 | |
| 2129 | 2223 | // Are we there yet? Are we there yet? |
| 2130 | - if ($pos >= strlen($message) - 1) |
|
| 2131 | - break; |
|
| 2224 | + if ($pos >= strlen($message) - 1) { |
|
| 2225 | + break; |
|
| 2226 | + } |
|
| 2132 | 2227 | |
| 2133 | 2228 | $tags = strtolower($message[$pos + 1]); |
| 2134 | 2229 | |
| 2135 | 2230 | if ($tags == '/' && !empty($open_tags)) |
| 2136 | 2231 | { |
| 2137 | 2232 | $pos2 = strpos($message, ']', $pos + 1); |
| 2138 | - if ($pos2 == $pos + 2) |
|
| 2139 | - continue; |
|
| 2233 | + if ($pos2 == $pos + 2) { |
|
| 2234 | + continue; |
|
| 2235 | + } |
|
| 2140 | 2236 | |
| 2141 | 2237 | $look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2)); |
| 2142 | 2238 | |
@@ -2146,8 +2242,9 @@ discard block |
||
| 2146 | 2242 | do |
| 2147 | 2243 | { |
| 2148 | 2244 | $tag = array_pop($open_tags); |
| 2149 | - if (!$tag) |
|
| 2150 | - break; |
|
| 2245 | + if (!$tag) { |
|
| 2246 | + break; |
|
| 2247 | + } |
|
| 2151 | 2248 | |
| 2152 | 2249 | if (!empty($tag['block_level'])) |
| 2153 | 2250 | { |
@@ -2161,10 +2258,11 @@ discard block |
||
| 2161 | 2258 | // The idea is, if we are LOOKING for a block level tag, we can close them on the way. |
| 2162 | 2259 | if (strlen($look_for) > 0 && isset($bbc_codes[$look_for[0]])) |
| 2163 | 2260 | { |
| 2164 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
| 2165 | - if ($temp['tag'] == $look_for) |
|
| 2261 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
| 2262 | + if ($temp['tag'] == $look_for) |
|
| 2166 | 2263 | { |
| 2167 | 2264 | $block_level = !empty($temp['block_level']); |
| 2265 | + } |
|
| 2168 | 2266 | break; |
| 2169 | 2267 | } |
| 2170 | 2268 | } |
@@ -2186,15 +2284,15 @@ discard block |
||
| 2186 | 2284 | { |
| 2187 | 2285 | $open_tags = $to_close; |
| 2188 | 2286 | continue; |
| 2189 | - } |
|
| 2190 | - elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
| 2287 | + } elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
| 2191 | 2288 | { |
| 2192 | 2289 | if ($block_level === null && isset($look_for[0], $bbc_codes[$look_for[0]])) |
| 2193 | 2290 | { |
| 2194 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
| 2195 | - if ($temp['tag'] == $look_for) |
|
| 2291 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
| 2292 | + if ($temp['tag'] == $look_for) |
|
| 2196 | 2293 | { |
| 2197 | 2294 | $block_level = !empty($temp['block_level']); |
| 2295 | + } |
|
| 2198 | 2296 | break; |
| 2199 | 2297 | } |
| 2200 | 2298 | } |
@@ -2202,8 +2300,9 @@ discard block |
||
| 2202 | 2300 | // We're not looking for a block level tag (or maybe even a tag that exists...) |
| 2203 | 2301 | if (!$block_level) |
| 2204 | 2302 | { |
| 2205 | - foreach ($to_close as $tag) |
|
| 2206 | - array_push($open_tags, $tag); |
|
| 2303 | + foreach ($to_close as $tag) { |
|
| 2304 | + array_push($open_tags, $tag); |
|
| 2305 | + } |
|
| 2207 | 2306 | continue; |
| 2208 | 2307 | } |
| 2209 | 2308 | } |
@@ -2216,14 +2315,17 @@ discard block |
||
| 2216 | 2315 | |
| 2217 | 2316 | // See the comment at the end of the big loop - just eating whitespace ;). |
| 2218 | 2317 | $whitespace_regex = ''; |
| 2219 | - if (!empty($tag['block_level'])) |
|
| 2220 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
| 2318 | + if (!empty($tag['block_level'])) { |
|
| 2319 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
| 2320 | + } |
|
| 2221 | 2321 | // Trim one line of whitespace after unnested tags, but all of it after nested ones |
| 2222 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
| 2223 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2322 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
| 2323 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2324 | + } |
|
| 2224 | 2325 | |
| 2225 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
| 2226 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2326 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
| 2327 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2328 | + } |
|
| 2227 | 2329 | } |
| 2228 | 2330 | |
| 2229 | 2331 | if (!empty($to_close)) |
@@ -2236,8 +2338,9 @@ discard block |
||
| 2236 | 2338 | } |
| 2237 | 2339 | |
| 2238 | 2340 | // No tags for this character, so just keep going (fastest possible course.) |
| 2239 | - if (!isset($bbc_codes[$tags])) |
|
| 2240 | - continue; |
|
| 2341 | + if (!isset($bbc_codes[$tags])) { |
|
| 2342 | + continue; |
|
| 2343 | + } |
|
| 2241 | 2344 | |
| 2242 | 2345 | $inside = empty($open_tags) ? null : $open_tags[count($open_tags) - 1]; |
| 2243 | 2346 | $tag = null; |
@@ -2246,44 +2349,52 @@ discard block |
||
| 2246 | 2349 | $pt_strlen = strlen($possible['tag']); |
| 2247 | 2350 | |
| 2248 | 2351 | // Not a match? |
| 2249 | - if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) |
|
| 2250 | - continue; |
|
| 2352 | + if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) { |
|
| 2353 | + continue; |
|
| 2354 | + } |
|
| 2251 | 2355 | |
| 2252 | 2356 | $next_c = $message[$pos + 1 + $pt_strlen]; |
| 2253 | 2357 | |
| 2254 | 2358 | // A test validation? |
| 2255 | - if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) |
|
| 2256 | - continue; |
|
| 2359 | + if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) { |
|
| 2360 | + continue; |
|
| 2361 | + } |
|
| 2257 | 2362 | // Do we want parameters? |
| 2258 | 2363 | elseif (!empty($possible['parameters'])) |
| 2259 | 2364 | { |
| 2260 | - if ($next_c != ' ') |
|
| 2261 | - continue; |
|
| 2262 | - } |
|
| 2263 | - elseif (isset($possible['type'])) |
|
| 2365 | + if ($next_c != ' ') { |
|
| 2366 | + continue; |
|
| 2367 | + } |
|
| 2368 | + } elseif (isset($possible['type'])) |
|
| 2264 | 2369 | { |
| 2265 | 2370 | // Do we need an equal sign? |
| 2266 | - if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') |
|
| 2267 | - continue; |
|
| 2371 | + if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') { |
|
| 2372 | + continue; |
|
| 2373 | + } |
|
| 2268 | 2374 | // Maybe we just want a /... |
| 2269 | - if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') |
|
| 2270 | - continue; |
|
| 2375 | + if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') { |
|
| 2376 | + continue; |
|
| 2377 | + } |
|
| 2271 | 2378 | // An immediate ]? |
| 2272 | - if ($possible['type'] == 'unparsed_content' && $next_c != ']') |
|
| 2273 | - continue; |
|
| 2379 | + if ($possible['type'] == 'unparsed_content' && $next_c != ']') { |
|
| 2380 | + continue; |
|
| 2381 | + } |
|
| 2274 | 2382 | } |
| 2275 | 2383 | // No type means 'parsed_content', which demands an immediate ] without parameters! |
| 2276 | - elseif ($next_c != ']') |
|
| 2277 | - continue; |
|
| 2384 | + elseif ($next_c != ']') { |
|
| 2385 | + continue; |
|
| 2386 | + } |
|
| 2278 | 2387 | |
| 2279 | 2388 | // Check allowed tree? |
| 2280 | - if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) |
|
| 2281 | - continue; |
|
| 2282 | - elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) |
|
| 2283 | - continue; |
|
| 2389 | + if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) { |
|
| 2390 | + continue; |
|
| 2391 | + } elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) { |
|
| 2392 | + continue; |
|
| 2393 | + } |
|
| 2284 | 2394 | // If this is in the list of disallowed child tags, don't parse it. |
| 2285 | - elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) |
|
| 2286 | - continue; |
|
| 2395 | + elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) { |
|
| 2396 | + continue; |
|
| 2397 | + } |
|
| 2287 | 2398 | |
| 2288 | 2399 | $pos1 = $pos + 1 + $pt_strlen + 1; |
| 2289 | 2400 | |
@@ -2295,8 +2406,9 @@ discard block |
||
| 2295 | 2406 | foreach ($open_tags as $open_quote) |
| 2296 | 2407 | { |
| 2297 | 2408 | // Every parent quote this quote has flips the styling |
| 2298 | - if ($open_quote['tag'] == 'quote') |
|
| 2299 | - $quote_alt = !$quote_alt; |
|
| 2409 | + if ($open_quote['tag'] == 'quote') { |
|
| 2410 | + $quote_alt = !$quote_alt; |
|
| 2411 | + } |
|
| 2300 | 2412 | } |
| 2301 | 2413 | // Add a class to the quote to style alternating blockquotes |
| 2302 | 2414 | $possible['before'] = strtr($possible['before'], array('<blockquote>' => '<blockquote class="bbc_' . ($quote_alt ? 'alternate' : 'standard') . '_quote">')); |
@@ -2307,8 +2419,9 @@ discard block |
||
| 2307 | 2419 | { |
| 2308 | 2420 | // Build a regular expression for each parameter for the current tag. |
| 2309 | 2421 | $preg = array(); |
| 2310 | - foreach ($possible['parameters'] as $p => $info) |
|
| 2311 | - $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
| 2422 | + foreach ($possible['parameters'] as $p => $info) { |
|
| 2423 | + $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
| 2424 | + } |
|
| 2312 | 2425 | |
| 2313 | 2426 | // Extract the string that potentially holds our parameters. |
| 2314 | 2427 | $blob = preg_split('~\[/?(?:' . $alltags_regex . ')~i', substr($message, $pos)); |
@@ -2328,24 +2441,27 @@ discard block |
||
| 2328 | 2441 | |
| 2329 | 2442 | $match = preg_match('~^' . implode('', $preg) . '$~i', implode(' ', $given_params), $matches) !== 0; |
| 2330 | 2443 | |
| 2331 | - if ($match) |
|
| 2332 | - $blob_counter = count($blobs) + 1; |
|
| 2444 | + if ($match) { |
|
| 2445 | + $blob_counter = count($blobs) + 1; |
|
| 2446 | + } |
|
| 2333 | 2447 | } |
| 2334 | 2448 | |
| 2335 | 2449 | // Didn't match our parameter list, try the next possible. |
| 2336 | - if (!$match) |
|
| 2337 | - continue; |
|
| 2450 | + if (!$match) { |
|
| 2451 | + continue; |
|
| 2452 | + } |
|
| 2338 | 2453 | |
| 2339 | 2454 | $params = array(); |
| 2340 | 2455 | for ($i = 1, $n = count($matches); $i < $n; $i += 2) |
| 2341 | 2456 | { |
| 2342 | 2457 | $key = strtok(ltrim($matches[$i]), '='); |
| 2343 | - if (isset($possible['parameters'][$key]['value'])) |
|
| 2344 | - $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
| 2345 | - elseif (isset($possible['parameters'][$key]['validate'])) |
|
| 2346 | - $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
| 2347 | - else |
|
| 2348 | - $params['{' . $key . '}'] = $matches[$i + 1]; |
|
| 2458 | + if (isset($possible['parameters'][$key]['value'])) { |
|
| 2459 | + $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
| 2460 | + } elseif (isset($possible['parameters'][$key]['validate'])) { |
|
| 2461 | + $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
| 2462 | + } else { |
|
| 2463 | + $params['{' . $key . '}'] = $matches[$i + 1]; |
|
| 2464 | + } |
|
| 2349 | 2465 | |
| 2350 | 2466 | // Just to make sure: replace any $ or { so they can't interpolate wrongly. |
| 2351 | 2467 | $params['{' . $key . '}'] = strtr($params['{' . $key . '}'], array('$' => '$', '{' => '{')); |
@@ -2353,23 +2469,26 @@ discard block |
||
| 2353 | 2469 | |
| 2354 | 2470 | foreach ($possible['parameters'] as $p => $info) |
| 2355 | 2471 | { |
| 2356 | - if (!isset($params['{' . $p . '}'])) |
|
| 2357 | - $params['{' . $p . '}'] = ''; |
|
| 2472 | + if (!isset($params['{' . $p . '}'])) { |
|
| 2473 | + $params['{' . $p . '}'] = ''; |
|
| 2474 | + } |
|
| 2358 | 2475 | } |
| 2359 | 2476 | |
| 2360 | 2477 | $tag = $possible; |
| 2361 | 2478 | |
| 2362 | 2479 | // Put the parameters into the string. |
| 2363 | - if (isset($tag['before'])) |
|
| 2364 | - $tag['before'] = strtr($tag['before'], $params); |
|
| 2365 | - if (isset($tag['after'])) |
|
| 2366 | - $tag['after'] = strtr($tag['after'], $params); |
|
| 2367 | - if (isset($tag['content'])) |
|
| 2368 | - $tag['content'] = strtr($tag['content'], $params); |
|
| 2480 | + if (isset($tag['before'])) { |
|
| 2481 | + $tag['before'] = strtr($tag['before'], $params); |
|
| 2482 | + } |
|
| 2483 | + if (isset($tag['after'])) { |
|
| 2484 | + $tag['after'] = strtr($tag['after'], $params); |
|
| 2485 | + } |
|
| 2486 | + if (isset($tag['content'])) { |
|
| 2487 | + $tag['content'] = strtr($tag['content'], $params); |
|
| 2488 | + } |
|
| 2369 | 2489 | |
| 2370 | 2490 | $pos1 += strlen($given_param_string); |
| 2371 | - } |
|
| 2372 | - else |
|
| 2491 | + } else |
|
| 2373 | 2492 | { |
| 2374 | 2493 | $tag = $possible; |
| 2375 | 2494 | $params = array(); |
@@ -2380,8 +2499,9 @@ discard block |
||
| 2380 | 2499 | // Item codes are complicated buggers... they are implicit [li]s and can make [list]s! |
| 2381 | 2500 | if ($smileys !== false && $tag === null && isset($itemcodes[$message[$pos + 1]]) && $message[$pos + 2] == ']' && !isset($disabled['list']) && !isset($disabled['li'])) |
| 2382 | 2501 | { |
| 2383 | - if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) |
|
| 2384 | - continue; |
|
| 2502 | + if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) { |
|
| 2503 | + continue; |
|
| 2504 | + } |
|
| 2385 | 2505 | |
| 2386 | 2506 | $tag = $itemcodes[$message[$pos + 1]]; |
| 2387 | 2507 | |
@@ -2402,9 +2522,9 @@ discard block |
||
| 2402 | 2522 | { |
| 2403 | 2523 | array_pop($open_tags); |
| 2404 | 2524 | $code = '</li>'; |
| 2525 | + } else { |
|
| 2526 | + $code = ''; |
|
| 2405 | 2527 | } |
| 2406 | - else |
|
| 2407 | - $code = ''; |
|
| 2408 | 2528 | |
| 2409 | 2529 | // Now we open a new tag. |
| 2410 | 2530 | $open_tags[] = array( |
@@ -2451,12 +2571,14 @@ discard block |
||
| 2451 | 2571 | } |
| 2452 | 2572 | |
| 2453 | 2573 | // No tag? Keep looking, then. Silly people using brackets without actual tags. |
| 2454 | - if ($tag === null) |
|
| 2455 | - continue; |
|
| 2574 | + if ($tag === null) { |
|
| 2575 | + continue; |
|
| 2576 | + } |
|
| 2456 | 2577 | |
| 2457 | 2578 | // Propagate the list to the child (so wrapping the disallowed tag won't work either.) |
| 2458 | - if (isset($inside['disallow_children'])) |
|
| 2459 | - $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
| 2579 | + if (isset($inside['disallow_children'])) { |
|
| 2580 | + $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
| 2581 | + } |
|
| 2460 | 2582 | |
| 2461 | 2583 | // Is this tag disabled? |
| 2462 | 2584 | if (isset($disabled[$tag['tag']])) |
@@ -2466,14 +2588,13 @@ discard block |
||
| 2466 | 2588 | $tag['before'] = !empty($tag['block_level']) ? '<div>' : ''; |
| 2467 | 2589 | $tag['after'] = !empty($tag['block_level']) ? '</div>' : ''; |
| 2468 | 2590 | $tag['content'] = isset($tag['type']) && $tag['type'] == 'closed' ? '' : (!empty($tag['block_level']) ? '<div>$1</div>' : '$1'); |
| 2469 | - } |
|
| 2470 | - elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
| 2591 | + } elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
| 2471 | 2592 | { |
| 2472 | 2593 | $tag['before'] = isset($tag['disabled_before']) ? $tag['disabled_before'] : (!empty($tag['block_level']) ? '<div>' : ''); |
| 2473 | 2594 | $tag['after'] = isset($tag['disabled_after']) ? $tag['disabled_after'] : (!empty($tag['block_level']) ? '</div>' : ''); |
| 2595 | + } else { |
|
| 2596 | + $tag['content'] = $tag['disabled_content']; |
|
| 2474 | 2597 | } |
| 2475 | - else |
|
| 2476 | - $tag['content'] = $tag['disabled_content']; |
|
| 2477 | 2598 | } |
| 2478 | 2599 | |
| 2479 | 2600 | // we use this a lot |
@@ -2483,8 +2604,9 @@ discard block |
||
| 2483 | 2604 | if (!empty($tag['block_level']) && $tag['tag'] != 'html' && empty($inside['block_level'])) |
| 2484 | 2605 | { |
| 2485 | 2606 | $n = count($open_tags) - 1; |
| 2486 | - while (empty($open_tags[$n]['block_level']) && $n >= 0) |
|
| 2487 | - $n--; |
|
| 2607 | + while (empty($open_tags[$n]['block_level']) && $n >= 0) { |
|
| 2608 | + $n--; |
|
| 2609 | + } |
|
| 2488 | 2610 | |
| 2489 | 2611 | // Close all the non block level tags so this tag isn't surrounded by them. |
| 2490 | 2612 | for ($i = count($open_tags) - 1; $i > $n; $i--) |
@@ -2496,12 +2618,15 @@ discard block |
||
| 2496 | 2618 | |
| 2497 | 2619 | // Trim or eat trailing stuff... see comment at the end of the big loop. |
| 2498 | 2620 | $whitespace_regex = ''; |
| 2499 | - if (!empty($tag['block_level'])) |
|
| 2500 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
| 2501 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
| 2502 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2503 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
| 2504 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2621 | + if (!empty($tag['block_level'])) { |
|
| 2622 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
| 2623 | + } |
|
| 2624 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
| 2625 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2626 | + } |
|
| 2627 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
| 2628 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2629 | + } |
|
| 2505 | 2630 | |
| 2506 | 2631 | array_pop($open_tags); |
| 2507 | 2632 | } |
@@ -2522,16 +2647,19 @@ discard block |
||
| 2522 | 2647 | elseif ($tag['type'] == 'unparsed_content') |
| 2523 | 2648 | { |
| 2524 | 2649 | $pos2 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos1); |
| 2525 | - if ($pos2 === false) |
|
| 2526 | - continue; |
|
| 2650 | + if ($pos2 === false) { |
|
| 2651 | + continue; |
|
| 2652 | + } |
|
| 2527 | 2653 | |
| 2528 | 2654 | $data = substr($message, $pos1, $pos2 - $pos1); |
| 2529 | 2655 | |
| 2530 | - if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') |
|
| 2531 | - $data = substr($data, 4); |
|
| 2656 | + if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') { |
|
| 2657 | + $data = substr($data, 4); |
|
| 2658 | + } |
|
| 2532 | 2659 | |
| 2533 | - if (isset($tag['validate'])) |
|
| 2534 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2660 | + if (isset($tag['validate'])) { |
|
| 2661 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2662 | + } |
|
| 2535 | 2663 | |
| 2536 | 2664 | $code = strtr($tag['content'], array('$1' => $data)); |
| 2537 | 2665 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 3 + $tag_strlen); |
@@ -2547,34 +2675,40 @@ discard block |
||
| 2547 | 2675 | if (isset($tag['quoted'])) |
| 2548 | 2676 | { |
| 2549 | 2677 | $quoted = substr($message, $pos1, 6) == '"'; |
| 2550 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
| 2551 | - continue; |
|
| 2678 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
| 2679 | + continue; |
|
| 2680 | + } |
|
| 2552 | 2681 | |
| 2553 | - if ($quoted) |
|
| 2554 | - $pos1 += 6; |
|
| 2682 | + if ($quoted) { |
|
| 2683 | + $pos1 += 6; |
|
| 2684 | + } |
|
| 2685 | + } else { |
|
| 2686 | + $quoted = false; |
|
| 2555 | 2687 | } |
| 2556 | - else |
|
| 2557 | - $quoted = false; |
|
| 2558 | 2688 | |
| 2559 | 2689 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
| 2560 | - if ($pos2 === false) |
|
| 2561 | - continue; |
|
| 2690 | + if ($pos2 === false) { |
|
| 2691 | + continue; |
|
| 2692 | + } |
|
| 2562 | 2693 | |
| 2563 | 2694 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
| 2564 | - if ($pos3 === false) |
|
| 2565 | - continue; |
|
| 2695 | + if ($pos3 === false) { |
|
| 2696 | + continue; |
|
| 2697 | + } |
|
| 2566 | 2698 | |
| 2567 | 2699 | $data = array( |
| 2568 | 2700 | substr($message, $pos2 + ($quoted == false ? 1 : 7), $pos3 - ($pos2 + ($quoted == false ? 1 : 7))), |
| 2569 | 2701 | substr($message, $pos1, $pos2 - $pos1) |
| 2570 | 2702 | ); |
| 2571 | 2703 | |
| 2572 | - if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') |
|
| 2573 | - $data[0] = substr($data[0], 4); |
|
| 2704 | + if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') { |
|
| 2705 | + $data[0] = substr($data[0], 4); |
|
| 2706 | + } |
|
| 2574 | 2707 | |
| 2575 | 2708 | // Validation for my parking, please! |
| 2576 | - if (isset($tag['validate'])) |
|
| 2577 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2709 | + if (isset($tag['validate'])) { |
|
| 2710 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2711 | + } |
|
| 2578 | 2712 | |
| 2579 | 2713 | $code = strtr($tag['content'], array('$1' => $data[0], '$2' => $data[1])); |
| 2580 | 2714 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
@@ -2591,23 +2725,27 @@ discard block |
||
| 2591 | 2725 | elseif ($tag['type'] == 'unparsed_commas_content') |
| 2592 | 2726 | { |
| 2593 | 2727 | $pos2 = strpos($message, ']', $pos1); |
| 2594 | - if ($pos2 === false) |
|
| 2595 | - continue; |
|
| 2728 | + if ($pos2 === false) { |
|
| 2729 | + continue; |
|
| 2730 | + } |
|
| 2596 | 2731 | |
| 2597 | 2732 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
| 2598 | - if ($pos3 === false) |
|
| 2599 | - continue; |
|
| 2733 | + if ($pos3 === false) { |
|
| 2734 | + continue; |
|
| 2735 | + } |
|
| 2600 | 2736 | |
| 2601 | 2737 | // We want $1 to be the content, and the rest to be csv. |
| 2602 | 2738 | $data = explode(',', ',' . substr($message, $pos1, $pos2 - $pos1)); |
| 2603 | 2739 | $data[0] = substr($message, $pos2 + 1, $pos3 - $pos2 - 1); |
| 2604 | 2740 | |
| 2605 | - if (isset($tag['validate'])) |
|
| 2606 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2741 | + if (isset($tag['validate'])) { |
|
| 2742 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2743 | + } |
|
| 2607 | 2744 | |
| 2608 | 2745 | $code = $tag['content']; |
| 2609 | - foreach ($data as $k => $d) |
|
| 2610 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2746 | + foreach ($data as $k => $d) { |
|
| 2747 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2748 | + } |
|
| 2611 | 2749 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
| 2612 | 2750 | $pos += strlen($code) - 1 + 2; |
| 2613 | 2751 | } |
@@ -2615,24 +2753,28 @@ discard block |
||
| 2615 | 2753 | elseif ($tag['type'] == 'unparsed_commas') |
| 2616 | 2754 | { |
| 2617 | 2755 | $pos2 = strpos($message, ']', $pos1); |
| 2618 | - if ($pos2 === false) |
|
| 2619 | - continue; |
|
| 2756 | + if ($pos2 === false) { |
|
| 2757 | + continue; |
|
| 2758 | + } |
|
| 2620 | 2759 | |
| 2621 | 2760 | $data = explode(',', substr($message, $pos1, $pos2 - $pos1)); |
| 2622 | 2761 | |
| 2623 | - if (isset($tag['validate'])) |
|
| 2624 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2762 | + if (isset($tag['validate'])) { |
|
| 2763 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2764 | + } |
|
| 2625 | 2765 | |
| 2626 | 2766 | // Fix after, for disabled code mainly. |
| 2627 | - foreach ($data as $k => $d) |
|
| 2628 | - $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
| 2767 | + foreach ($data as $k => $d) { |
|
| 2768 | + $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
| 2769 | + } |
|
| 2629 | 2770 | |
| 2630 | 2771 | $open_tags[] = $tag; |
| 2631 | 2772 | |
| 2632 | 2773 | // Replace them out, $1, $2, $3, $4, etc. |
| 2633 | 2774 | $code = $tag['before']; |
| 2634 | - foreach ($data as $k => $d) |
|
| 2635 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2775 | + foreach ($data as $k => $d) { |
|
| 2776 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2777 | + } |
|
| 2636 | 2778 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 1); |
| 2637 | 2779 | $pos += strlen($code) - 1 + 2; |
| 2638 | 2780 | } |
@@ -2643,28 +2785,33 @@ discard block |
||
| 2643 | 2785 | if (isset($tag['quoted'])) |
| 2644 | 2786 | { |
| 2645 | 2787 | $quoted = substr($message, $pos1, 6) == '"'; |
| 2646 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
| 2647 | - continue; |
|
| 2788 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
| 2789 | + continue; |
|
| 2790 | + } |
|
| 2648 | 2791 | |
| 2649 | - if ($quoted) |
|
| 2650 | - $pos1 += 6; |
|
| 2792 | + if ($quoted) { |
|
| 2793 | + $pos1 += 6; |
|
| 2794 | + } |
|
| 2795 | + } else { |
|
| 2796 | + $quoted = false; |
|
| 2651 | 2797 | } |
| 2652 | - else |
|
| 2653 | - $quoted = false; |
|
| 2654 | 2798 | |
| 2655 | 2799 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
| 2656 | - if ($pos2 === false) |
|
| 2657 | - continue; |
|
| 2800 | + if ($pos2 === false) { |
|
| 2801 | + continue; |
|
| 2802 | + } |
|
| 2658 | 2803 | |
| 2659 | 2804 | $data = substr($message, $pos1, $pos2 - $pos1); |
| 2660 | 2805 | |
| 2661 | 2806 | // Validation for my parking, please! |
| 2662 | - if (isset($tag['validate'])) |
|
| 2663 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2807 | + if (isset($tag['validate'])) { |
|
| 2808 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2809 | + } |
|
| 2664 | 2810 | |
| 2665 | 2811 | // For parsed content, we must recurse to avoid security problems. |
| 2666 | - if ($tag['type'] != 'unparsed_equals') |
|
| 2667 | - $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
| 2812 | + if ($tag['type'] != 'unparsed_equals') { |
|
| 2813 | + $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
| 2814 | + } |
|
| 2668 | 2815 | |
| 2669 | 2816 | $tag['after'] = strtr($tag['after'], array('$1' => $data)); |
| 2670 | 2817 | |
@@ -2676,34 +2823,40 @@ discard block |
||
| 2676 | 2823 | } |
| 2677 | 2824 | |
| 2678 | 2825 | // If this is block level, eat any breaks after it. |
| 2679 | - if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') |
|
| 2680 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
| 2826 | + if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') { |
|
| 2827 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
| 2828 | + } |
|
| 2681 | 2829 | |
| 2682 | 2830 | // Are we trimming outside this tag? |
| 2683 | - if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) |
|
| 2684 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
| 2831 | + if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) { |
|
| 2832 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
| 2833 | + } |
|
| 2685 | 2834 | } |
| 2686 | 2835 | |
| 2687 | 2836 | // Close any remaining tags. |
| 2688 | - while ($tag = array_pop($open_tags)) |
|
| 2689 | - $message .= "\n" . $tag['after'] . "\n"; |
|
| 2837 | + while ($tag = array_pop($open_tags)) { |
|
| 2838 | + $message .= "\n" . $tag['after'] . "\n"; |
|
| 2839 | + } |
|
| 2690 | 2840 | |
| 2691 | 2841 | // Parse the smileys within the parts where it can be done safely. |
| 2692 | 2842 | if ($smileys === true) |
| 2693 | 2843 | { |
| 2694 | 2844 | $message_parts = explode("\n", $message); |
| 2695 | - for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) |
|
| 2696 | - parsesmileys($message_parts[$i]); |
|
| 2845 | + for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) { |
|
| 2846 | + parsesmileys($message_parts[$i]); |
|
| 2847 | + } |
|
| 2697 | 2848 | |
| 2698 | 2849 | $message = implode('', $message_parts); |
| 2699 | 2850 | } |
| 2700 | 2851 | |
| 2701 | 2852 | // No smileys, just get rid of the markers. |
| 2702 | - else |
|
| 2703 | - $message = strtr($message, array("\n" => '')); |
|
| 2853 | + else { |
|
| 2854 | + $message = strtr($message, array("\n" => '')); |
|
| 2855 | + } |
|
| 2704 | 2856 | |
| 2705 | - if ($message !== '' && $message[0] === ' ') |
|
| 2706 | - $message = ' ' . substr($message, 1); |
|
| 2857 | + if ($message !== '' && $message[0] === ' ') { |
|
| 2858 | + $message = ' ' . substr($message, 1); |
|
| 2859 | + } |
|
| 2707 | 2860 | |
| 2708 | 2861 | // Cleanup whitespace. |
| 2709 | 2862 | $message = strtr($message, array(' ' => ' ', "\r" => '', "\n" => '<br>', '<br> ' => '<br> ', ' ' => "\n")); |
@@ -2712,15 +2865,16 @@ discard block |
||
| 2712 | 2865 | call_integration_hook('integrate_post_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
| 2713 | 2866 | |
| 2714 | 2867 | // Cache the output if it took some time... |
| 2715 | - if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) |
|
| 2716 | - cache_put_data($cache_key, $message, 240); |
|
| 2868 | + if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) { |
|
| 2869 | + cache_put_data($cache_key, $message, 240); |
|
| 2870 | + } |
|
| 2717 | 2871 | |
| 2718 | 2872 | // If this was a force parse revert if needed. |
| 2719 | 2873 | if (!empty($parse_tags)) |
| 2720 | 2874 | { |
| 2721 | - if (empty($temp_bbc)) |
|
| 2722 | - $bbc_codes = array(); |
|
| 2723 | - else |
|
| 2875 | + if (empty($temp_bbc)) { |
|
| 2876 | + $bbc_codes = array(); |
|
| 2877 | + } else |
|
| 2724 | 2878 | { |
| 2725 | 2879 | $bbc_codes = $temp_bbc; |
| 2726 | 2880 | unset($temp_bbc); |
@@ -2747,8 +2901,9 @@ discard block |
||
| 2747 | 2901 | static $smileyPregSearch = null, $smileyPregReplacements = array(); |
| 2748 | 2902 | |
| 2749 | 2903 | // No smiley set at all?! |
| 2750 | - if ($user_info['smiley_set'] == 'none' || trim($message) == '') |
|
| 2751 | - return; |
|
| 2904 | + if ($user_info['smiley_set'] == 'none' || trim($message) == '') { |
|
| 2905 | + return; |
|
| 2906 | + } |
|
| 2752 | 2907 | |
| 2753 | 2908 | // If smileyPregSearch hasn't been set, do it now. |
| 2754 | 2909 | if (empty($smileyPregSearch)) |
@@ -2759,8 +2914,7 @@ discard block |
||
| 2759 | 2914 | $smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)'); |
| 2760 | 2915 | $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'); |
| 2761 | 2916 | $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'], '', '', '', ''); |
| 2762 | - } |
|
| 2763 | - else |
|
| 2917 | + } else |
|
| 2764 | 2918 | { |
| 2765 | 2919 | // Load the smileys in reverse order by length so they don't get parsed wrong. |
| 2766 | 2920 | if (($temp = cache_get_data('parsing_smileys', 480)) == null) |
@@ -2784,9 +2938,9 @@ discard block |
||
| 2784 | 2938 | $smcFunc['db_free_result']($result); |
| 2785 | 2939 | |
| 2786 | 2940 | cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480); |
| 2941 | + } else { |
|
| 2942 | + list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
| 2787 | 2943 | } |
| 2788 | - else |
|
| 2789 | - list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
| 2790 | 2944 | } |
| 2791 | 2945 | |
| 2792 | 2946 | // The non-breaking-space is a complex thing... |
@@ -2863,35 +3017,41 @@ discard block |
||
| 2863 | 3017 | global $scripturl, $context, $modSettings, $db_show_debug, $db_cache; |
| 2864 | 3018 | |
| 2865 | 3019 | // In case we have mail to send, better do that - as obExit doesn't always quite make it... |
| 2866 | - if (!empty($context['flush_mail'])) |
|
| 2867 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 3020 | + if (!empty($context['flush_mail'])) { |
|
| 3021 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 2868 | 3022 | AddMailQueue(true); |
| 3023 | + } |
|
| 2869 | 3024 | |
| 2870 | 3025 | $add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:'; |
| 2871 | 3026 | |
| 2872 | - if ($add) |
|
| 2873 | - $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
| 3027 | + if ($add) { |
|
| 3028 | + $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
| 3029 | + } |
|
| 2874 | 3030 | |
| 2875 | 3031 | // Put the session ID in. |
| 2876 | - if (defined('SID') && SID != '') |
|
| 2877 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
| 3032 | + if (defined('SID') && SID != '') { |
|
| 3033 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
| 3034 | + } |
|
| 2878 | 3035 | // Keep that debug in their for template debugging! |
| 2879 | - elseif (isset($_GET['debug'])) |
|
| 2880 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
| 3036 | + elseif (isset($_GET['debug'])) { |
|
| 3037 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
| 3038 | + } |
|
| 2881 | 3039 | |
| 2882 | 3040 | 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']))) |
| 2883 | 3041 | { |
| 2884 | - if (defined('SID') && SID != '') |
|
| 2885 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
| 3042 | + if (defined('SID') && SID != '') { |
|
| 3043 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
| 2886 | 3044 | function ($m) use ($scripturl) |
| 2887 | 3045 | { |
| 2888 | 3046 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
| 3047 | + } |
|
| 2889 | 3048 | }, $setLocation); |
| 2890 | - else |
|
| 2891 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
| 3049 | + else { |
|
| 3050 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
| 2892 | 3051 | function ($m) use ($scripturl) |
| 2893 | 3052 | { |
| 2894 | 3053 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
| 3054 | + } |
|
| 2895 | 3055 | }, $setLocation); |
| 2896 | 3056 | } |
| 2897 | 3057 | |
@@ -2902,8 +3062,9 @@ discard block |
||
| 2902 | 3062 | header('Location: ' . str_replace(' ', '%20', $setLocation), true, $permanent ? 301 : 302); |
| 2903 | 3063 | |
| 2904 | 3064 | // Debugging. |
| 2905 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 2906 | - $_SESSION['debug_redirect'] = $db_cache; |
|
| 3065 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 3066 | + $_SESSION['debug_redirect'] = $db_cache; |
|
| 3067 | + } |
|
| 2907 | 3068 | |
| 2908 | 3069 | obExit(false); |
| 2909 | 3070 | } |
@@ -2922,51 +3083,60 @@ discard block |
||
| 2922 | 3083 | |
| 2923 | 3084 | // Attempt to prevent a recursive loop. |
| 2924 | 3085 | ++$level; |
| 2925 | - if ($level > 1 && !$from_fatal_error && !$has_fatal_error) |
|
| 2926 | - exit; |
|
| 2927 | - if ($from_fatal_error) |
|
| 2928 | - $has_fatal_error = true; |
|
| 3086 | + if ($level > 1 && !$from_fatal_error && !$has_fatal_error) { |
|
| 3087 | + exit; |
|
| 3088 | + } |
|
| 3089 | + if ($from_fatal_error) { |
|
| 3090 | + $has_fatal_error = true; |
|
| 3091 | + } |
|
| 2929 | 3092 | |
| 2930 | 3093 | // Clear out the stat cache. |
| 2931 | 3094 | trackStats(); |
| 2932 | 3095 | |
| 2933 | 3096 | // If we have mail to send, send it. |
| 2934 | - if (!empty($context['flush_mail'])) |
|
| 2935 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 3097 | + if (!empty($context['flush_mail'])) { |
|
| 3098 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 2936 | 3099 | AddMailQueue(true); |
| 3100 | + } |
|
| 2937 | 3101 | |
| 2938 | 3102 | $do_header = $header === null ? !$header_done : $header; |
| 2939 | - if ($do_footer === null) |
|
| 2940 | - $do_footer = $do_header; |
|
| 3103 | + if ($do_footer === null) { |
|
| 3104 | + $do_footer = $do_header; |
|
| 3105 | + } |
|
| 2941 | 3106 | |
| 2942 | 3107 | // Has the template/header been done yet? |
| 2943 | 3108 | if ($do_header) |
| 2944 | 3109 | { |
| 2945 | 3110 | // Was the page title set last minute? Also update the HTML safe one. |
| 2946 | - if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) |
|
| 2947 | - $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
| 3111 | + if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) { |
|
| 3112 | + $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
| 3113 | + } |
|
| 2948 | 3114 | |
| 2949 | 3115 | // Start up the session URL fixer. |
| 2950 | 3116 | ob_start('ob_sessrewrite'); |
| 2951 | 3117 | |
| 2952 | - if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) |
|
| 2953 | - $buffers = explode(',', $settings['output_buffers']); |
|
| 2954 | - elseif (!empty($settings['output_buffers'])) |
|
| 2955 | - $buffers = $settings['output_buffers']; |
|
| 2956 | - else |
|
| 2957 | - $buffers = array(); |
|
| 3118 | + if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) { |
|
| 3119 | + $buffers = explode(',', $settings['output_buffers']); |
|
| 3120 | + } elseif (!empty($settings['output_buffers'])) { |
|
| 3121 | + $buffers = $settings['output_buffers']; |
|
| 3122 | + } else { |
|
| 3123 | + $buffers = array(); |
|
| 3124 | + } |
|
| 2958 | 3125 | |
| 2959 | - if (isset($modSettings['integrate_buffer'])) |
|
| 2960 | - $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
| 3126 | + if (isset($modSettings['integrate_buffer'])) { |
|
| 3127 | + $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
| 3128 | + } |
|
| 2961 | 3129 | |
| 2962 | - if (!empty($buffers)) |
|
| 2963 | - foreach ($buffers as $function) |
|
| 3130 | + if (!empty($buffers)) { |
|
| 3131 | + foreach ($buffers as $function) |
|
| 2964 | 3132 | { |
| 2965 | 3133 | $call = call_helper($function, true); |
| 3134 | + } |
|
| 2966 | 3135 | |
| 2967 | 3136 | // Is it valid? |
| 2968 | - if (!empty($call)) |
|
| 2969 | - ob_start($call); |
|
| 3137 | + if (!empty($call)) { |
|
| 3138 | + ob_start($call); |
|
| 3139 | + } |
|
| 2970 | 3140 | } |
| 2971 | 3141 | |
| 2972 | 3142 | // Display the screen in the logical order. |
@@ -2978,8 +3148,9 @@ discard block |
||
| 2978 | 3148 | loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main'); |
| 2979 | 3149 | |
| 2980 | 3150 | // Anything special to put out? |
| 2981 | - if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) |
|
| 2982 | - echo $context['insert_after_template']; |
|
| 3151 | + if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) { |
|
| 3152 | + echo $context['insert_after_template']; |
|
| 3153 | + } |
|
| 2983 | 3154 | |
| 2984 | 3155 | // Just so we don't get caught in an endless loop of errors from the footer... |
| 2985 | 3156 | if (!$footer_done) |
@@ -2988,14 +3159,16 @@ discard block |
||
| 2988 | 3159 | template_footer(); |
| 2989 | 3160 | |
| 2990 | 3161 | // (since this is just debugging... it's okay that it's after </html>.) |
| 2991 | - if (!isset($_REQUEST['xml'])) |
|
| 2992 | - displayDebug(); |
|
| 3162 | + if (!isset($_REQUEST['xml'])) { |
|
| 3163 | + displayDebug(); |
|
| 3164 | + } |
|
| 2993 | 3165 | } |
| 2994 | 3166 | } |
| 2995 | 3167 | |
| 2996 | 3168 | // Remember this URL in case someone doesn't like sending HTTP_REFERER. |
| 2997 | - if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) |
|
| 2998 | - $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
| 3169 | + if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) { |
|
| 3170 | + $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
| 3171 | + } |
|
| 2999 | 3172 | |
| 3000 | 3173 | // For session check verification.... don't switch browsers... |
| 3001 | 3174 | $_SESSION['USER_AGENT'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT']; |
@@ -3004,9 +3177,10 @@ discard block |
||
| 3004 | 3177 | call_integration_hook('integrate_exit', array($do_footer)); |
| 3005 | 3178 | |
| 3006 | 3179 | // Don't exit if we're coming from index.php; that will pass through normally. |
| 3007 | - if (!$from_index) |
|
| 3008 | - exit; |
|
| 3009 | -} |
|
| 3180 | + if (!$from_index) { |
|
| 3181 | + exit; |
|
| 3182 | + } |
|
| 3183 | + } |
|
| 3010 | 3184 | |
| 3011 | 3185 | /** |
| 3012 | 3186 | * Get the size of a specified image with better error handling. |
@@ -3025,8 +3199,9 @@ discard block |
||
| 3025 | 3199 | $url = str_replace(' ', '%20', $url); |
| 3026 | 3200 | |
| 3027 | 3201 | // Can we pull this from the cache... please please? |
| 3028 | - if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) |
|
| 3029 | - return $temp; |
|
| 3202 | + if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) { |
|
| 3203 | + return $temp; |
|
| 3204 | + } |
|
| 3030 | 3205 | $t = microtime(); |
| 3031 | 3206 | |
| 3032 | 3207 | // Get the host to pester... |
@@ -3036,12 +3211,10 @@ discard block |
||
| 3036 | 3211 | if ($url == '' || $url == 'http://' || $url == 'https://') |
| 3037 | 3212 | { |
| 3038 | 3213 | return false; |
| 3039 | - } |
|
| 3040 | - elseif (!isset($match[1])) |
|
| 3214 | + } elseif (!isset($match[1])) |
|
| 3041 | 3215 | { |
| 3042 | 3216 | $size = @getimagesize($url); |
| 3043 | - } |
|
| 3044 | - else |
|
| 3217 | + } else |
|
| 3045 | 3218 | { |
| 3046 | 3219 | // Try to connect to the server... give it half a second. |
| 3047 | 3220 | $temp = 0; |
@@ -3080,12 +3253,14 @@ discard block |
||
| 3080 | 3253 | } |
| 3081 | 3254 | |
| 3082 | 3255 | // If we didn't get it, we failed. |
| 3083 | - if (!isset($size)) |
|
| 3084 | - $size = false; |
|
| 3256 | + if (!isset($size)) { |
|
| 3257 | + $size = false; |
|
| 3258 | + } |
|
| 3085 | 3259 | |
| 3086 | 3260 | // If this took a long time, we may never have to do it again, but then again we might... |
| 3087 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) |
|
| 3088 | - cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
| 3261 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) { |
|
| 3262 | + cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
| 3263 | + } |
|
| 3089 | 3264 | |
| 3090 | 3265 | // Didn't work. |
| 3091 | 3266 | return $size; |
@@ -3103,8 +3278,9 @@ discard block |
||
| 3103 | 3278 | |
| 3104 | 3279 | // Under SSI this function can be called more then once. That can cause some problems. |
| 3105 | 3280 | // So only run the function once unless we are forced to run it again. |
| 3106 | - if ($loaded && !$forceload) |
|
| 3107 | - return; |
|
| 3281 | + if ($loaded && !$forceload) { |
|
| 3282 | + return; |
|
| 3283 | + } |
|
| 3108 | 3284 | |
| 3109 | 3285 | $loaded = true; |
| 3110 | 3286 | |
@@ -3116,14 +3292,16 @@ discard block |
||
| 3116 | 3292 | $context['news_lines'] = array_filter(explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news']))))); |
| 3117 | 3293 | for ($i = 0, $n = count($context['news_lines']); $i < $n; $i++) |
| 3118 | 3294 | { |
| 3119 | - if (trim($context['news_lines'][$i]) == '') |
|
| 3120 | - continue; |
|
| 3295 | + if (trim($context['news_lines'][$i]) == '') { |
|
| 3296 | + continue; |
|
| 3297 | + } |
|
| 3121 | 3298 | |
| 3122 | 3299 | // Clean it up for presentation ;). |
| 3123 | 3300 | $context['news_lines'][$i] = parse_bbc(stripslashes(trim($context['news_lines'][$i])), true, 'news' . $i); |
| 3124 | 3301 | } |
| 3125 | - if (!empty($context['news_lines'])) |
|
| 3126 | - $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
| 3302 | + if (!empty($context['news_lines'])) { |
|
| 3303 | + $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
| 3304 | + } |
|
| 3127 | 3305 | |
| 3128 | 3306 | if (!$user_info['is_guest']) |
| 3129 | 3307 | { |
@@ -3132,40 +3310,48 @@ discard block |
||
| 3132 | 3310 | $context['user']['alerts'] = &$user_info['alerts']; |
| 3133 | 3311 | |
| 3134 | 3312 | // Personal message popup... |
| 3135 | - if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) |
|
| 3136 | - $context['user']['popup_messages'] = true; |
|
| 3137 | - else |
|
| 3138 | - $context['user']['popup_messages'] = false; |
|
| 3313 | + if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) { |
|
| 3314 | + $context['user']['popup_messages'] = true; |
|
| 3315 | + } else { |
|
| 3316 | + $context['user']['popup_messages'] = false; |
|
| 3317 | + } |
|
| 3139 | 3318 | $_SESSION['unread_messages'] = $user_info['unread_messages']; |
| 3140 | 3319 | |
| 3141 | - if (allowedTo('moderate_forum')) |
|
| 3142 | - $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
| 3320 | + if (allowedTo('moderate_forum')) { |
|
| 3321 | + $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
| 3322 | + } |
|
| 3143 | 3323 | |
| 3144 | 3324 | $context['user']['avatar'] = array(); |
| 3145 | 3325 | |
| 3146 | 3326 | // Check for gravatar first since we might be forcing them... |
| 3147 | 3327 | if (($modSettings['gravatarEnabled'] && substr($user_info['avatar']['url'], 0, 11) == 'gravatar://') || !empty($modSettings['gravatarOverride'])) |
| 3148 | 3328 | { |
| 3149 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) |
|
| 3150 | - $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
| 3151 | - else |
|
| 3152 | - $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
| 3329 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) { |
|
| 3330 | + $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
| 3331 | + } else { |
|
| 3332 | + $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
| 3333 | + } |
|
| 3153 | 3334 | } |
| 3154 | 3335 | // Uploaded? |
| 3155 | - elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) |
|
| 3156 | - $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'; |
|
| 3336 | + elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) { |
|
| 3337 | + $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'; |
|
| 3338 | + } |
|
| 3157 | 3339 | // Full URL? |
| 3158 | - elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) |
|
| 3159 | - $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
| 3340 | + elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) { |
|
| 3341 | + $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
| 3342 | + } |
|
| 3160 | 3343 | // Otherwise we assume it's server stored. |
| 3161 | - elseif ($user_info['avatar']['url'] != '') |
|
| 3162 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
| 3344 | + elseif ($user_info['avatar']['url'] != '') { |
|
| 3345 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
| 3346 | + } |
|
| 3163 | 3347 | // No avatar at all? Fine, we have a big fat default avatar ;) |
| 3164 | - else |
|
| 3165 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
| 3348 | + else { |
|
| 3349 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
| 3350 | + } |
|
| 3166 | 3351 | |
| 3167 | - if (!empty($context['user']['avatar'])) |
|
| 3168 | - $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
| 3352 | + if (!empty($context['user']['avatar'])) { |
|
| 3353 | + $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
| 3354 | + } |
|
| 3169 | 3355 | |
| 3170 | 3356 | // Figure out how long they've been logged in. |
| 3171 | 3357 | $context['user']['total_time_logged_in'] = array( |
@@ -3173,8 +3359,7 @@ discard block |
||
| 3173 | 3359 | 'hours' => floor(($user_info['total_time_logged_in'] % 86400) / 3600), |
| 3174 | 3360 | 'minutes' => floor(($user_info['total_time_logged_in'] % 3600) / 60) |
| 3175 | 3361 | ); |
| 3176 | - } |
|
| 3177 | - else |
|
| 3362 | + } else |
|
| 3178 | 3363 | { |
| 3179 | 3364 | $context['user']['messages'] = 0; |
| 3180 | 3365 | $context['user']['unread_messages'] = 0; |
@@ -3182,12 +3367,14 @@ discard block |
||
| 3182 | 3367 | $context['user']['total_time_logged_in'] = array('days' => 0, 'hours' => 0, 'minutes' => 0); |
| 3183 | 3368 | $context['user']['popup_messages'] = false; |
| 3184 | 3369 | |
| 3185 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) |
|
| 3186 | - $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
| 3370 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) { |
|
| 3371 | + $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
| 3372 | + } |
|
| 3187 | 3373 | |
| 3188 | 3374 | // If we've upgraded recently, go easy on the passwords. |
| 3189 | - if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) |
|
| 3190 | - $context['disable_login_hashing'] = true; |
|
| 3375 | + if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) { |
|
| 3376 | + $context['disable_login_hashing'] = true; |
|
| 3377 | + } |
|
| 3191 | 3378 | } |
| 3192 | 3379 | |
| 3193 | 3380 | // Setup the main menu items. |
@@ -3200,8 +3387,8 @@ discard block |
||
| 3200 | 3387 | $context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm'); |
| 3201 | 3388 | |
| 3202 | 3389 | // 2.1+: Add the PM popup here instead. Theme authors can still override it simply by editing/removing the 'fPmPopup' in the array. |
| 3203 | - if ($context['show_pm_popup']) |
|
| 3204 | - addInlineJavaScript(' |
|
| 3390 | + if ($context['show_pm_popup']) { |
|
| 3391 | + addInlineJavaScript(' |
|
| 3205 | 3392 | jQuery(document).ready(function($) { |
| 3206 | 3393 | new smc_Popup({ |
| 3207 | 3394 | heading: ' . JavaScriptEscape($txt['show_personal_messages_heading']) . ', |
@@ -3209,15 +3396,17 @@ discard block |
||
| 3209 | 3396 | icon_class: \'generic_icons mail_new\' |
| 3210 | 3397 | }); |
| 3211 | 3398 | });'); |
| 3399 | + } |
|
| 3212 | 3400 | |
| 3213 | 3401 | // Add a generic "Are you sure?" confirmation message. |
| 3214 | 3402 | addInlineJavaScript(' |
| 3215 | 3403 | var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
| 3216 | 3404 | |
| 3217 | 3405 | // Now add the capping code for avatars. |
| 3218 | - 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') |
|
| 3219 | - addInlineCss(' |
|
| 3406 | + 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') { |
|
| 3407 | + addInlineCss(' |
|
| 3220 | 3408 | img.avatar { max-width: ' . $modSettings['avatar_max_width_external'] . 'px; max-height: ' . $modSettings['avatar_max_height_external'] . 'px; }'); |
| 3409 | + } |
|
| 3221 | 3410 | |
| 3222 | 3411 | // This looks weird, but it's because BoardIndex.php references the variable. |
| 3223 | 3412 | $context['common_stats']['latest_member'] = array( |
@@ -3234,11 +3423,13 @@ discard block |
||
| 3234 | 3423 | ); |
| 3235 | 3424 | $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']); |
| 3236 | 3425 | |
| 3237 | - if (empty($settings['theme_version'])) |
|
| 3238 | - addJavaScriptVar('smf_scripturl', $scripturl); |
|
| 3426 | + if (empty($settings['theme_version'])) { |
|
| 3427 | + addJavaScriptVar('smf_scripturl', $scripturl); |
|
| 3428 | + } |
|
| 3239 | 3429 | |
| 3240 | - if (!isset($context['page_title'])) |
|
| 3241 | - $context['page_title'] = ''; |
|
| 3430 | + if (!isset($context['page_title'])) { |
|
| 3431 | + $context['page_title'] = ''; |
|
| 3432 | + } |
|
| 3242 | 3433 | |
| 3243 | 3434 | // Set some specific vars. |
| 3244 | 3435 | $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
@@ -3248,21 +3439,23 @@ discard block |
||
| 3248 | 3439 | $context['meta_tags'][] = array('property' => 'og:site_name', 'content' => $context['forum_name']); |
| 3249 | 3440 | $context['meta_tags'][] = array('property' => 'og:title', 'content' => $context['page_title_html_safe']); |
| 3250 | 3441 | |
| 3251 | - if (!empty($context['meta_keywords'])) |
|
| 3252 | - $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
| 3442 | + if (!empty($context['meta_keywords'])) { |
|
| 3443 | + $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
| 3444 | + } |
|
| 3253 | 3445 | |
| 3254 | - if (!empty($context['canonical_url'])) |
|
| 3255 | - $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
| 3446 | + if (!empty($context['canonical_url'])) { |
|
| 3447 | + $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
| 3448 | + } |
|
| 3256 | 3449 | |
| 3257 | - if (!empty($settings['og_image'])) |
|
| 3258 | - $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
| 3450 | + if (!empty($settings['og_image'])) { |
|
| 3451 | + $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
| 3452 | + } |
|
| 3259 | 3453 | |
| 3260 | 3454 | if (!empty($context['meta_description'])) |
| 3261 | 3455 | { |
| 3262 | 3456 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['meta_description']); |
| 3263 | 3457 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['meta_description']); |
| 3264 | - } |
|
| 3265 | - else |
|
| 3458 | + } else |
|
| 3266 | 3459 | { |
| 3267 | 3460 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['page_title_html_safe']); |
| 3268 | 3461 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['page_title_html_safe']); |
@@ -3287,8 +3480,9 @@ discard block |
||
| 3287 | 3480 | $memory_needed = memoryReturnBytes($needed); |
| 3288 | 3481 | |
| 3289 | 3482 | // should we account for how much is currently being used? |
| 3290 | - if ($in_use) |
|
| 3291 | - $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
| 3483 | + if ($in_use) { |
|
| 3484 | + $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
| 3485 | + } |
|
| 3292 | 3486 | |
| 3293 | 3487 | // if more is needed, request it |
| 3294 | 3488 | if ($memory_current < $memory_needed) |
@@ -3311,8 +3505,9 @@ discard block |
||
| 3311 | 3505 | */ |
| 3312 | 3506 | function memoryReturnBytes($val) |
| 3313 | 3507 | { |
| 3314 | - if (is_integer($val)) |
|
| 3315 | - return $val; |
|
| 3508 | + if (is_integer($val)) { |
|
| 3509 | + return $val; |
|
| 3510 | + } |
|
| 3316 | 3511 | |
| 3317 | 3512 | // Separate the number from the designator |
| 3318 | 3513 | $val = trim($val); |
@@ -3348,10 +3543,11 @@ discard block |
||
| 3348 | 3543 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
| 3349 | 3544 | |
| 3350 | 3545 | // Are we debugging the template/html content? |
| 3351 | - if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) |
|
| 3352 | - header('Content-Type: application/xhtml+xml'); |
|
| 3353 | - elseif (!isset($_REQUEST['xml'])) |
|
| 3354 | - header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3546 | + if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) { |
|
| 3547 | + header('Content-Type: application/xhtml+xml'); |
|
| 3548 | + } elseif (!isset($_REQUEST['xml'])) { |
|
| 3549 | + header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3550 | + } |
|
| 3355 | 3551 | } |
| 3356 | 3552 | |
| 3357 | 3553 | header('Content-Type: text/' . (isset($_REQUEST['xml']) ? 'xml' : 'html') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
@@ -3360,8 +3556,9 @@ discard block |
||
| 3360 | 3556 | if ($context['in_maintenance'] && $context['user']['is_admin']) |
| 3361 | 3557 | { |
| 3362 | 3558 | $position = array_search('body', $context['template_layers']); |
| 3363 | - if ($position === false) |
|
| 3364 | - $position = array_search('main', $context['template_layers']); |
|
| 3559 | + if ($position === false) { |
|
| 3560 | + $position = array_search('main', $context['template_layers']); |
|
| 3561 | + } |
|
| 3365 | 3562 | |
| 3366 | 3563 | if ($position !== false) |
| 3367 | 3564 | { |
@@ -3389,23 +3586,25 @@ discard block |
||
| 3389 | 3586 | |
| 3390 | 3587 | foreach ($securityFiles as $i => $securityFile) |
| 3391 | 3588 | { |
| 3392 | - if (!file_exists($boarddir . '/' . $securityFile)) |
|
| 3393 | - unset($securityFiles[$i]); |
|
| 3589 | + if (!file_exists($boarddir . '/' . $securityFile)) { |
|
| 3590 | + unset($securityFiles[$i]); |
|
| 3591 | + } |
|
| 3394 | 3592 | } |
| 3395 | 3593 | |
| 3396 | 3594 | // We are already checking so many files...just few more doesn't make any difference! :P |
| 3397 | - if (!empty($modSettings['currentAttachmentUploadDir'])) |
|
| 3398 | - $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
| 3399 | - |
|
| 3400 | - else |
|
| 3401 | - $path = $modSettings['attachmentUploadDir']; |
|
| 3595 | + if (!empty($modSettings['currentAttachmentUploadDir'])) { |
|
| 3596 | + $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
| 3597 | + } else { |
|
| 3598 | + $path = $modSettings['attachmentUploadDir']; |
|
| 3599 | + } |
|
| 3402 | 3600 | |
| 3403 | 3601 | secureDirectory($path, true); |
| 3404 | 3602 | secureDirectory($cachedir); |
| 3405 | 3603 | |
| 3406 | 3604 | // If agreement is enabled, at least the english version shall exists |
| 3407 | - if ($modSettings['requireAgreement']) |
|
| 3408 | - $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
| 3605 | + if ($modSettings['requireAgreement']) { |
|
| 3606 | + $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
| 3607 | + } |
|
| 3409 | 3608 | |
| 3410 | 3609 | if (!empty($securityFiles) || (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) || !empty($agreement)) |
| 3411 | 3610 | { |
@@ -3420,18 +3619,21 @@ discard block |
||
| 3420 | 3619 | echo ' |
| 3421 | 3620 | ', $txt['not_removed'], '<strong>', $securityFile, '</strong>!<br>'; |
| 3422 | 3621 | |
| 3423 | - if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') |
|
| 3424 | - echo ' |
|
| 3622 | + if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') { |
|
| 3623 | + echo ' |
|
| 3425 | 3624 | ', sprintf($txt['not_removed_extra'], $securityFile, substr($securityFile, 0, -1)), '<br>'; |
| 3625 | + } |
|
| 3426 | 3626 | } |
| 3427 | 3627 | |
| 3428 | - if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) |
|
| 3429 | - echo ' |
|
| 3628 | + if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) { |
|
| 3629 | + echo ' |
|
| 3430 | 3630 | <strong>', $txt['cache_writable'], '</strong><br>'; |
| 3631 | + } |
|
| 3431 | 3632 | |
| 3432 | - if (!empty($agreement)) |
|
| 3433 | - echo ' |
|
| 3633 | + if (!empty($agreement)) { |
|
| 3634 | + echo ' |
|
| 3434 | 3635 | <strong>', $txt['agreement_missing'], '</strong><br>'; |
| 3636 | + } |
|
| 3435 | 3637 | |
| 3436 | 3638 | echo ' |
| 3437 | 3639 | </p> |
@@ -3446,16 +3648,18 @@ discard block |
||
| 3446 | 3648 | <div class="windowbg alert" style="margin: 2ex; padding: 2ex; border: 2px dashed red;"> |
| 3447 | 3649 | ', sprintf($txt['you_are_post_banned'], $user_info['is_guest'] ? $txt['guest_title'] : $user_info['name']); |
| 3448 | 3650 | |
| 3449 | - if (!empty($_SESSION['ban']['cannot_post']['reason'])) |
|
| 3450 | - echo ' |
|
| 3651 | + if (!empty($_SESSION['ban']['cannot_post']['reason'])) { |
|
| 3652 | + echo ' |
|
| 3451 | 3653 | <div style="padding-left: 4ex; padding-top: 1ex;">', $_SESSION['ban']['cannot_post']['reason'], '</div>'; |
| 3654 | + } |
|
| 3452 | 3655 | |
| 3453 | - if (!empty($_SESSION['ban']['expire_time'])) |
|
| 3454 | - echo ' |
|
| 3656 | + if (!empty($_SESSION['ban']['expire_time'])) { |
|
| 3657 | + echo ' |
|
| 3455 | 3658 | <div>', sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)), '</div>'; |
| 3456 | - else |
|
| 3457 | - echo ' |
|
| 3659 | + } else { |
|
| 3660 | + echo ' |
|
| 3458 | 3661 | <div>', $txt['your_ban_expires_never'], '</div>'; |
| 3662 | + } |
|
| 3459 | 3663 | |
| 3460 | 3664 | echo ' |
| 3461 | 3665 | </div>'; |
@@ -3471,8 +3675,9 @@ discard block |
||
| 3471 | 3675 | global $forum_copyright, $software_year, $forum_version; |
| 3472 | 3676 | |
| 3473 | 3677 | // Don't display copyright for things like SSI. |
| 3474 | - if (!isset($forum_version) || !isset($software_year)) |
|
| 3475 | - return; |
|
| 3678 | + if (!isset($forum_version) || !isset($software_year)) { |
|
| 3679 | + return; |
|
| 3680 | + } |
|
| 3476 | 3681 | |
| 3477 | 3682 | // Put in the version... |
| 3478 | 3683 | printf($forum_copyright, $forum_version, $software_year); |
@@ -3490,9 +3695,10 @@ discard block |
||
| 3490 | 3695 | $context['load_time'] = round(microtime(true) - $time_start, 3); |
| 3491 | 3696 | $context['load_queries'] = $db_count; |
| 3492 | 3697 | |
| 3493 | - foreach (array_reverse($context['template_layers']) as $layer) |
|
| 3494 | - loadSubTemplate($layer . '_below', true); |
|
| 3495 | -} |
|
| 3698 | + foreach (array_reverse($context['template_layers']) as $layer) { |
|
| 3699 | + loadSubTemplate($layer . '_below', true); |
|
| 3700 | + } |
|
| 3701 | + } |
|
| 3496 | 3702 | |
| 3497 | 3703 | /** |
| 3498 | 3704 | * Output the Javascript files |
@@ -3523,8 +3729,7 @@ discard block |
||
| 3523 | 3729 | { |
| 3524 | 3730 | echo ' |
| 3525 | 3731 | var ', $key, ';'; |
| 3526 | - } |
|
| 3527 | - else |
|
| 3732 | + } else |
|
| 3528 | 3733 | { |
| 3529 | 3734 | echo ' |
| 3530 | 3735 | var ', $key, ' = ', $value, ';'; |
@@ -3539,26 +3744,27 @@ discard block |
||
| 3539 | 3744 | foreach ($context['javascript_files'] as $id => $js_file) |
| 3540 | 3745 | { |
| 3541 | 3746 | // Last minute call! allow theme authors to disable single files. |
| 3542 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
| 3543 | - continue; |
|
| 3747 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
| 3748 | + continue; |
|
| 3749 | + } |
|
| 3544 | 3750 | |
| 3545 | 3751 | // By default all files don't get minimized unless the file explicitly says so! |
| 3546 | 3752 | if (!empty($js_file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
| 3547 | 3753 | { |
| 3548 | - if ($do_deferred && !empty($js_file['options']['defer'])) |
|
| 3549 | - $toMinifyDefer[] = $js_file; |
|
| 3550 | - |
|
| 3551 | - elseif (!$do_deferred && empty($js_file['options']['defer'])) |
|
| 3552 | - $toMinify[] = $js_file; |
|
| 3754 | + if ($do_deferred && !empty($js_file['options']['defer'])) { |
|
| 3755 | + $toMinifyDefer[] = $js_file; |
|
| 3756 | + } elseif (!$do_deferred && empty($js_file['options']['defer'])) { |
|
| 3757 | + $toMinify[] = $js_file; |
|
| 3758 | + } |
|
| 3553 | 3759 | |
| 3554 | 3760 | // Grab a random seed. |
| 3555 | - if (!isset($minSeed)) |
|
| 3556 | - $minSeed = $js_file['options']['seed']; |
|
| 3557 | - } |
|
| 3558 | - |
|
| 3559 | - elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) |
|
| 3560 | - echo ' |
|
| 3761 | + if (!isset($minSeed)) { |
|
| 3762 | + $minSeed = $js_file['options']['seed']; |
|
| 3763 | + } |
|
| 3764 | + } elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) { |
|
| 3765 | + echo ' |
|
| 3561 | 3766 | <script src="', $js_file['fileUrl'], '"', !empty($js_file['options']['async']) ? ' async="async"' : '', '></script>'; |
| 3767 | + } |
|
| 3562 | 3768 | } |
| 3563 | 3769 | |
| 3564 | 3770 | if ((!$do_deferred && !empty($toMinify)) || ($do_deferred && !empty($toMinifyDefer))) |
@@ -3566,14 +3772,14 @@ discard block |
||
| 3566 | 3772 | $result = custMinify(($do_deferred ? $toMinifyDefer : $toMinify), 'js', $do_deferred); |
| 3567 | 3773 | |
| 3568 | 3774 | // Minify process couldn't work, print each individual files. |
| 3569 | - if (!empty($result) && is_array($result)) |
|
| 3570 | - foreach ($result as $minFailedFile) |
|
| 3775 | + if (!empty($result) && is_array($result)) { |
|
| 3776 | + foreach ($result as $minFailedFile) |
|
| 3571 | 3777 | echo ' |
| 3572 | 3778 | <script src="', $minFailedFile['fileUrl'], '"', !empty($minFailedFile['options']['async']) ? ' async="async"' : '', '></script>'; |
| 3573 | - |
|
| 3574 | - else |
|
| 3575 | - echo ' |
|
| 3779 | + } else { |
|
| 3780 | + echo ' |
|
| 3576 | 3781 | <script src="', $settings['theme_url'] ,'/scripts/minified', ($do_deferred ? '_deferred' : '') ,'.js', $minSeed ,'"></script>'; |
| 3782 | + } |
|
| 3577 | 3783 | } |
| 3578 | 3784 | |
| 3579 | 3785 | // Inline JavaScript - Actually useful some times! |
@@ -3584,8 +3790,9 @@ discard block |
||
| 3584 | 3790 | echo ' |
| 3585 | 3791 | <script>'; |
| 3586 | 3792 | |
| 3587 | - foreach ($context['javascript_inline']['defer'] as $js_code) |
|
| 3588 | - echo $js_code; |
|
| 3793 | + foreach ($context['javascript_inline']['defer'] as $js_code) { |
|
| 3794 | + echo $js_code; |
|
| 3795 | + } |
|
| 3589 | 3796 | |
| 3590 | 3797 | echo ' |
| 3591 | 3798 | </script>'; |
@@ -3596,8 +3803,9 @@ discard block |
||
| 3596 | 3803 | echo ' |
| 3597 | 3804 | <script>'; |
| 3598 | 3805 | |
| 3599 | - foreach ($context['javascript_inline']['standard'] as $js_code) |
|
| 3600 | - echo $js_code; |
|
| 3806 | + foreach ($context['javascript_inline']['standard'] as $js_code) { |
|
| 3807 | + echo $js_code; |
|
| 3808 | + } |
|
| 3601 | 3809 | |
| 3602 | 3810 | echo ' |
| 3603 | 3811 | </script>'; |
@@ -3622,8 +3830,9 @@ discard block |
||
| 3622 | 3830 | foreach ($context['css_files'] as $id => $file) |
| 3623 | 3831 | { |
| 3624 | 3832 | // Last minute call! allow theme authors to disable single files. |
| 3625 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
| 3626 | - continue; |
|
| 3833 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
| 3834 | + continue; |
|
| 3835 | + } |
|
| 3627 | 3836 | |
| 3628 | 3837 | // By default all files don't get minimized unless the file explicitly says so! |
| 3629 | 3838 | if (!empty($file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
@@ -3631,12 +3840,12 @@ discard block |
||
| 3631 | 3840 | $toMinify[] = $file; |
| 3632 | 3841 | |
| 3633 | 3842 | // Grab a random seed. |
| 3634 | - if (!isset($minSeed)) |
|
| 3635 | - $minSeed = $file['options']['seed']; |
|
| 3843 | + if (!isset($minSeed)) { |
|
| 3844 | + $minSeed = $file['options']['seed']; |
|
| 3845 | + } |
|
| 3846 | + } else { |
|
| 3847 | + $normal[] = $file['fileUrl']; |
|
| 3636 | 3848 | } |
| 3637 | - |
|
| 3638 | - else |
|
| 3639 | - $normal[] = $file['fileUrl']; |
|
| 3640 | 3849 | } |
| 3641 | 3850 | |
| 3642 | 3851 | if (!empty($toMinify)) |
@@ -3644,28 +3853,30 @@ discard block |
||
| 3644 | 3853 | $result = custMinify($toMinify, 'css'); |
| 3645 | 3854 | |
| 3646 | 3855 | // Minify process couldn't work, print each individual files. |
| 3647 | - if (!empty($result) && is_array($result)) |
|
| 3648 | - foreach ($result as $minFailedFile) |
|
| 3856 | + if (!empty($result) && is_array($result)) { |
|
| 3857 | + foreach ($result as $minFailedFile) |
|
| 3649 | 3858 | echo ' |
| 3650 | 3859 | <link rel="stylesheet" href="', $minFailedFile['fileUrl'], '">'; |
| 3651 | - |
|
| 3652 | - else |
|
| 3653 | - echo ' |
|
| 3860 | + } else { |
|
| 3861 | + echo ' |
|
| 3654 | 3862 | <link rel="stylesheet" href="', $settings['theme_url'] ,'/css/minified.css', $minSeed ,'">'; |
| 3863 | + } |
|
| 3655 | 3864 | } |
| 3656 | 3865 | |
| 3657 | 3866 | // Print the rest after the minified files. |
| 3658 | - if (!empty($normal)) |
|
| 3659 | - foreach ($normal as $nf) |
|
| 3867 | + if (!empty($normal)) { |
|
| 3868 | + foreach ($normal as $nf) |
|
| 3660 | 3869 | echo ' |
| 3661 | 3870 | <link rel="stylesheet" href="', $nf ,'">'; |
| 3871 | + } |
|
| 3662 | 3872 | |
| 3663 | 3873 | if ($db_show_debug === true) |
| 3664 | 3874 | { |
| 3665 | 3875 | // Try to keep only what's useful. |
| 3666 | 3876 | $repl = array($boardurl . '/Themes/' => '', $boardurl . '/' => ''); |
| 3667 | - foreach ($context['css_files'] as $file) |
|
| 3668 | - $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
| 3877 | + foreach ($context['css_files'] as $file) { |
|
| 3878 | + $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
| 3879 | + } |
|
| 3669 | 3880 | } |
| 3670 | 3881 | |
| 3671 | 3882 | if (!empty($context['css_header'])) |
@@ -3673,9 +3884,10 @@ discard block |
||
| 3673 | 3884 | echo ' |
| 3674 | 3885 | <style>'; |
| 3675 | 3886 | |
| 3676 | - foreach ($context['css_header'] as $css) |
|
| 3677 | - echo $css .' |
|
| 3887 | + foreach ($context['css_header'] as $css) { |
|
| 3888 | + echo $css .' |
|
| 3678 | 3889 | '; |
| 3890 | + } |
|
| 3679 | 3891 | |
| 3680 | 3892 | echo' |
| 3681 | 3893 | </style>'; |
@@ -3699,15 +3911,17 @@ discard block |
||
| 3699 | 3911 | $type = !empty($type) && in_array($type, $types) ? $type : false; |
| 3700 | 3912 | $data = !empty($data) ? $data : false; |
| 3701 | 3913 | |
| 3702 | - if (empty($type) || empty($data)) |
|
| 3703 | - return false; |
|
| 3914 | + if (empty($type) || empty($data)) { |
|
| 3915 | + return false; |
|
| 3916 | + } |
|
| 3704 | 3917 | |
| 3705 | 3918 | // Did we already did this? |
| 3706 | 3919 | $toCache = cache_get_data('minimized_'. $settings['theme_id'] .'_'. $type, 86400); |
| 3707 | 3920 | |
| 3708 | 3921 | // Already done? |
| 3709 | - if (!empty($toCache)) |
|
| 3710 | - return true; |
|
| 3922 | + if (!empty($toCache)) { |
|
| 3923 | + return true; |
|
| 3924 | + } |
|
| 3711 | 3925 | |
| 3712 | 3926 | // No namespaces, sorry! |
| 3713 | 3927 | $classType = 'MatthiasMullie\\Minify\\'. strtoupper($type); |
@@ -3789,8 +4003,9 @@ discard block |
||
| 3789 | 4003 | global $modSettings, $smcFunc; |
| 3790 | 4004 | |
| 3791 | 4005 | // Just make up a nice hash... |
| 3792 | - if ($new) |
|
| 3793 | - return sha1(md5($filename . time()) . mt_rand()); |
|
| 4006 | + if ($new) { |
|
| 4007 | + return sha1(md5($filename . time()) . mt_rand()); |
|
| 4008 | + } |
|
| 3794 | 4009 | |
| 3795 | 4010 | // Just make sure that attachment id is only a int |
| 3796 | 4011 | $attachment_id = (int) $attachment_id; |
@@ -3807,23 +4022,25 @@ discard block |
||
| 3807 | 4022 | 'id_attach' => $attachment_id, |
| 3808 | 4023 | )); |
| 3809 | 4024 | |
| 3810 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 3811 | - return false; |
|
| 4025 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 4026 | + return false; |
|
| 4027 | + } |
|
| 3812 | 4028 | |
| 3813 | 4029 | list ($file_hash) = $smcFunc['db_fetch_row']($request); |
| 3814 | 4030 | $smcFunc['db_free_result']($request); |
| 3815 | 4031 | } |
| 3816 | 4032 | |
| 3817 | 4033 | // Still no hash? mmm... |
| 3818 | - if (empty($file_hash)) |
|
| 3819 | - $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
| 4034 | + if (empty($file_hash)) { |
|
| 4035 | + $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
| 4036 | + } |
|
| 3820 | 4037 | |
| 3821 | 4038 | // Are we using multiple directories? |
| 3822 | - if (is_array($modSettings['attachmentUploadDir'])) |
|
| 3823 | - $path = $modSettings['attachmentUploadDir'][$dir]; |
|
| 3824 | - |
|
| 3825 | - else |
|
| 3826 | - $path = $modSettings['attachmentUploadDir']; |
|
| 4039 | + if (is_array($modSettings['attachmentUploadDir'])) { |
|
| 4040 | + $path = $modSettings['attachmentUploadDir'][$dir]; |
|
| 4041 | + } else { |
|
| 4042 | + $path = $modSettings['attachmentUploadDir']; |
|
| 4043 | + } |
|
| 3827 | 4044 | |
| 3828 | 4045 | return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
| 3829 | 4046 | } |
@@ -3838,8 +4055,9 @@ discard block |
||
| 3838 | 4055 | function ip2range($fullip) |
| 3839 | 4056 | { |
| 3840 | 4057 | // Pretend that 'unknown' is 255.255.255.255. (since that can't be an IP anyway.) |
| 3841 | - if ($fullip == 'unknown') |
|
| 3842 | - $fullip = '255.255.255.255'; |
|
| 4058 | + if ($fullip == 'unknown') { |
|
| 4059 | + $fullip = '255.255.255.255'; |
|
| 4060 | + } |
|
| 3843 | 4061 | |
| 3844 | 4062 | $ip_parts = explode('-', $fullip); |
| 3845 | 4063 | $ip_array = array(); |
@@ -3863,10 +4081,11 @@ discard block |
||
| 3863 | 4081 | $ip_array['low'] = $ip_parts[0]; |
| 3864 | 4082 | $ip_array['high'] = $ip_parts[1]; |
| 3865 | 4083 | return $ip_array; |
| 3866 | - } |
|
| 3867 | - elseif (count($ip_parts) == 2) // if ip 22.22.*-22.22.* |
|
| 4084 | + } elseif (count($ip_parts) == 2) { |
|
| 4085 | + // if ip 22.22.*-22.22.* |
|
| 3868 | 4086 | { |
| 3869 | 4087 | $valid_low = isValidIP($ip_parts[0]); |
| 4088 | + } |
|
| 3870 | 4089 | $valid_high = isValidIP($ip_parts[1]); |
| 3871 | 4090 | $count = 0; |
| 3872 | 4091 | $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
@@ -3881,7 +4100,9 @@ discard block |
||
| 3881 | 4100 | $ip_parts[0] .= $mode . $min; |
| 3882 | 4101 | $valid_low = isValidIP($ip_parts[0]); |
| 3883 | 4102 | $count++; |
| 3884 | - if ($count > 9) break; |
|
| 4103 | + if ($count > 9) { |
|
| 4104 | + break; |
|
| 4105 | + } |
|
| 3885 | 4106 | } |
| 3886 | 4107 | } |
| 3887 | 4108 | |
@@ -3895,7 +4116,9 @@ discard block |
||
| 3895 | 4116 | $ip_parts[1] .= $mode . $max; |
| 3896 | 4117 | $valid_high = isValidIP($ip_parts[1]); |
| 3897 | 4118 | $count++; |
| 3898 | - if ($count > 9) break; |
|
| 4119 | + if ($count > 9) { |
|
| 4120 | + break; |
|
| 4121 | + } |
|
| 3899 | 4122 | } |
| 3900 | 4123 | } |
| 3901 | 4124 | |
@@ -3920,46 +4143,54 @@ discard block |
||
| 3920 | 4143 | { |
| 3921 | 4144 | global $modSettings; |
| 3922 | 4145 | |
| 3923 | - if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) |
|
| 3924 | - return $host; |
|
| 4146 | + if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) { |
|
| 4147 | + return $host; |
|
| 4148 | + } |
|
| 3925 | 4149 | $t = microtime(); |
| 3926 | 4150 | |
| 3927 | 4151 | // Try the Linux host command, perhaps? |
| 3928 | 4152 | if (!isset($host) && (strpos(strtolower(PHP_OS), 'win') === false || strpos(strtolower(PHP_OS), 'darwin') !== false) && mt_rand(0, 1) == 1) |
| 3929 | 4153 | { |
| 3930 | - if (!isset($modSettings['host_to_dis'])) |
|
| 3931 | - $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
| 3932 | - else |
|
| 3933 | - $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
| 4154 | + if (!isset($modSettings['host_to_dis'])) { |
|
| 4155 | + $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
| 4156 | + } else { |
|
| 4157 | + $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
| 4158 | + } |
|
| 3934 | 4159 | |
| 3935 | 4160 | // Did host say it didn't find anything? |
| 3936 | - if (strpos($test, 'not found') !== false) |
|
| 3937 | - $host = ''; |
|
| 4161 | + if (strpos($test, 'not found') !== false) { |
|
| 4162 | + $host = ''; |
|
| 4163 | + } |
|
| 3938 | 4164 | // Invalid server option? |
| 3939 | - elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) |
|
| 3940 | - updateSettings(array('host_to_dis' => 1)); |
|
| 4165 | + elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) { |
|
| 4166 | + updateSettings(array('host_to_dis' => 1)); |
|
| 4167 | + } |
|
| 3941 | 4168 | // Maybe it found something, after all? |
| 3942 | - elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) |
|
| 3943 | - $host = $match[1]; |
|
| 4169 | + elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) { |
|
| 4170 | + $host = $match[1]; |
|
| 4171 | + } |
|
| 3944 | 4172 | } |
| 3945 | 4173 | |
| 3946 | 4174 | // This is nslookup; usually only Windows, but possibly some Unix? |
| 3947 | 4175 | if (!isset($host) && stripos(PHP_OS, 'win') !== false && strpos(strtolower(PHP_OS), 'darwin') === false && mt_rand(0, 1) == 1) |
| 3948 | 4176 | { |
| 3949 | 4177 | $test = @shell_exec('nslookup -timeout=1 ' . @escapeshellarg($ip)); |
| 3950 | - if (strpos($test, 'Non-existent domain') !== false) |
|
| 3951 | - $host = ''; |
|
| 3952 | - elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) |
|
| 3953 | - $host = $match[1]; |
|
| 4178 | + if (strpos($test, 'Non-existent domain') !== false) { |
|
| 4179 | + $host = ''; |
|
| 4180 | + } elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) { |
|
| 4181 | + $host = $match[1]; |
|
| 4182 | + } |
|
| 3954 | 4183 | } |
| 3955 | 4184 | |
| 3956 | 4185 | // This is the last try :/. |
| 3957 | - if (!isset($host) || $host === false) |
|
| 3958 | - $host = @gethostbyaddr($ip); |
|
| 4186 | + if (!isset($host) || $host === false) { |
|
| 4187 | + $host = @gethostbyaddr($ip); |
|
| 4188 | + } |
|
| 3959 | 4189 | |
| 3960 | 4190 | // It took a long time, so let's cache it! |
| 3961 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) |
|
| 3962 | - cache_put_data('hostlookup-' . $ip, $host, 600); |
|
| 4191 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) { |
|
| 4192 | + cache_put_data('hostlookup-' . $ip, $host, 600); |
|
| 4193 | + } |
|
| 3963 | 4194 | |
| 3964 | 4195 | return $host; |
| 3965 | 4196 | } |
@@ -3995,20 +4226,21 @@ discard block |
||
| 3995 | 4226 | { |
| 3996 | 4227 | $encrypted = substr(crypt($word, 'uk'), 2, $max_chars); |
| 3997 | 4228 | $total = 0; |
| 3998 | - for ($i = 0; $i < $max_chars; $i++) |
|
| 3999 | - $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
| 4229 | + for ($i = 0; $i < $max_chars; $i++) { |
|
| 4230 | + $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
| 4231 | + } |
|
| 4000 | 4232 | $returned_ints[] = $max_chars == 4 ? min($total, 16777215) : $total; |
| 4001 | 4233 | } |
| 4002 | 4234 | } |
| 4003 | 4235 | return array_unique($returned_ints); |
| 4004 | - } |
|
| 4005 | - else |
|
| 4236 | + } else |
|
| 4006 | 4237 | { |
| 4007 | 4238 | // Trim characters before and after and add slashes for database insertion. |
| 4008 | 4239 | $returned_words = array(); |
| 4009 | - foreach ($words as $word) |
|
| 4010 | - if (($word = trim($word, '-_\'')) !== '') |
|
| 4240 | + foreach ($words as $word) { |
|
| 4241 | + if (($word = trim($word, '-_\'')) !== '') |
|
| 4011 | 4242 | $returned_words[] = $max_chars === null ? $word : substr($word, 0, $max_chars); |
| 4243 | + } |
|
| 4012 | 4244 | |
| 4013 | 4245 | // Filter out all words that occur more than once. |
| 4014 | 4246 | return array_unique($returned_words); |
@@ -4030,16 +4262,18 @@ discard block |
||
| 4030 | 4262 | global $settings, $txt; |
| 4031 | 4263 | |
| 4032 | 4264 | // Does the current loaded theme have this and we are not forcing the usage of this function? |
| 4033 | - if (function_exists('template_create_button') && !$force_use) |
|
| 4034 | - return template_create_button($name, $alt, $label = '', $custom = ''); |
|
| 4265 | + if (function_exists('template_create_button') && !$force_use) { |
|
| 4266 | + return template_create_button($name, $alt, $label = '', $custom = ''); |
|
| 4267 | + } |
|
| 4035 | 4268 | |
| 4036 | - if (!$settings['use_image_buttons']) |
|
| 4037 | - return $txt[$alt]; |
|
| 4038 | - elseif (!empty($settings['use_buttons'])) |
|
| 4039 | - return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
| 4040 | - else |
|
| 4041 | - return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
| 4042 | -} |
|
| 4269 | + if (!$settings['use_image_buttons']) { |
|
| 4270 | + return $txt[$alt]; |
|
| 4271 | + } elseif (!empty($settings['use_buttons'])) { |
|
| 4272 | + return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
| 4273 | + } else { |
|
| 4274 | + return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
| 4275 | + } |
|
| 4276 | + } |
|
| 4043 | 4277 | |
| 4044 | 4278 | /** |
| 4045 | 4279 | * Sets up all of the top menu buttons |
@@ -4082,9 +4316,10 @@ discard block |
||
| 4082 | 4316 | var user_menus = new smc_PopupMenu(); |
| 4083 | 4317 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
| 4084 | 4318 | user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
| 4085 | - if ($context['allow_pm']) |
|
| 4086 | - addInlineJavaScript(' |
|
| 4319 | + if ($context['allow_pm']) { |
|
| 4320 | + addInlineJavaScript(' |
|
| 4087 | 4321 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
| 4322 | + } |
|
| 4088 | 4323 | |
| 4089 | 4324 | if (!empty($modSettings['enable_ajax_alerts'])) |
| 4090 | 4325 | { |
@@ -4244,88 +4479,96 @@ discard block |
||
| 4244 | 4479 | |
| 4245 | 4480 | // Now we put the buttons in the context so the theme can use them. |
| 4246 | 4481 | $menu_buttons = array(); |
| 4247 | - foreach ($buttons as $act => $button) |
|
| 4248 | - if (!empty($button['show'])) |
|
| 4482 | + foreach ($buttons as $act => $button) { |
|
| 4483 | + if (!empty($button['show'])) |
|
| 4249 | 4484 | { |
| 4250 | 4485 | $button['active_button'] = false; |
| 4486 | + } |
|
| 4251 | 4487 | |
| 4252 | 4488 | // This button needs some action. |
| 4253 | - if (isset($button['action_hook'])) |
|
| 4254 | - $needs_action_hook = true; |
|
| 4489 | + if (isset($button['action_hook'])) { |
|
| 4490 | + $needs_action_hook = true; |
|
| 4491 | + } |
|
| 4255 | 4492 | |
| 4256 | 4493 | // Make sure the last button truly is the last button. |
| 4257 | 4494 | if (!empty($button['is_last'])) |
| 4258 | 4495 | { |
| 4259 | - if (isset($last_button)) |
|
| 4260 | - unset($menu_buttons[$last_button]['is_last']); |
|
| 4496 | + if (isset($last_button)) { |
|
| 4497 | + unset($menu_buttons[$last_button]['is_last']); |
|
| 4498 | + } |
|
| 4261 | 4499 | $last_button = $act; |
| 4262 | 4500 | } |
| 4263 | 4501 | |
| 4264 | 4502 | // Go through the sub buttons if there are any. |
| 4265 | - if (!empty($button['sub_buttons'])) |
|
| 4266 | - foreach ($button['sub_buttons'] as $key => $subbutton) |
|
| 4503 | + if (!empty($button['sub_buttons'])) { |
|
| 4504 | + foreach ($button['sub_buttons'] as $key => $subbutton) |
|
| 4267 | 4505 | { |
| 4268 | 4506 | if (empty($subbutton['show'])) |
| 4269 | 4507 | unset($button['sub_buttons'][$key]); |
| 4508 | + } |
|
| 4270 | 4509 | |
| 4271 | 4510 | // 2nd level sub buttons next... |
| 4272 | 4511 | if (!empty($subbutton['sub_buttons'])) |
| 4273 | 4512 | { |
| 4274 | 4513 | foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2) |
| 4275 | 4514 | { |
| 4276 | - if (empty($sub_button2['show'])) |
|
| 4277 | - unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
| 4515 | + if (empty($sub_button2['show'])) { |
|
| 4516 | + unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
| 4517 | + } |
|
| 4278 | 4518 | } |
| 4279 | 4519 | } |
| 4280 | 4520 | } |
| 4281 | 4521 | |
| 4282 | 4522 | // Does this button have its own icon? |
| 4283 | - if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) |
|
| 4284 | - $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4285 | - elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) |
|
| 4286 | - $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4287 | - elseif (isset($button['icon'])) |
|
| 4288 | - $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
| 4289 | - else |
|
| 4290 | - $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
| 4523 | + if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) { |
|
| 4524 | + $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4525 | + } elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) { |
|
| 4526 | + $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4527 | + } elseif (isset($button['icon'])) { |
|
| 4528 | + $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
| 4529 | + } else { |
|
| 4530 | + $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
| 4531 | + } |
|
| 4291 | 4532 | |
| 4292 | 4533 | $menu_buttons[$act] = $button; |
| 4293 | 4534 | } |
| 4294 | 4535 | |
| 4295 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 4296 | - cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
| 4536 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 4537 | + cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
| 4538 | + } |
|
| 4297 | 4539 | } |
| 4298 | 4540 | |
| 4299 | 4541 | $context['menu_buttons'] = $menu_buttons; |
| 4300 | 4542 | |
| 4301 | 4543 | // Logging out requires the session id in the url. |
| 4302 | - if (isset($context['menu_buttons']['logout'])) |
|
| 4303 | - $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
| 4544 | + if (isset($context['menu_buttons']['logout'])) { |
|
| 4545 | + $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
| 4546 | + } |
|
| 4304 | 4547 | |
| 4305 | 4548 | // Figure out which action we are doing so we can set the active tab. |
| 4306 | 4549 | // Default to home. |
| 4307 | 4550 | $current_action = 'home'; |
| 4308 | 4551 | |
| 4309 | - if (isset($context['menu_buttons'][$context['current_action']])) |
|
| 4310 | - $current_action = $context['current_action']; |
|
| 4311 | - elseif ($context['current_action'] == 'search2') |
|
| 4312 | - $current_action = 'search'; |
|
| 4313 | - elseif ($context['current_action'] == 'theme') |
|
| 4314 | - $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
| 4315 | - elseif ($context['current_action'] == 'register2') |
|
| 4316 | - $current_action = 'register'; |
|
| 4317 | - elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) |
|
| 4318 | - $current_action = 'login'; |
|
| 4319 | - elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) |
|
| 4320 | - $current_action = 'moderate'; |
|
| 4552 | + if (isset($context['menu_buttons'][$context['current_action']])) { |
|
| 4553 | + $current_action = $context['current_action']; |
|
| 4554 | + } elseif ($context['current_action'] == 'search2') { |
|
| 4555 | + $current_action = 'search'; |
|
| 4556 | + } elseif ($context['current_action'] == 'theme') { |
|
| 4557 | + $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
| 4558 | + } elseif ($context['current_action'] == 'register2') { |
|
| 4559 | + $current_action = 'register'; |
|
| 4560 | + } elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) { |
|
| 4561 | + $current_action = 'login'; |
|
| 4562 | + } elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) { |
|
| 4563 | + $current_action = 'moderate'; |
|
| 4564 | + } |
|
| 4321 | 4565 | |
| 4322 | 4566 | // There are certain exceptions to the above where we don't want anything on the menu highlighted. |
| 4323 | 4567 | if ($context['current_action'] == 'profile' && !empty($context['user']['is_owner'])) |
| 4324 | 4568 | { |
| 4325 | 4569 | $current_action = !empty($_GET['area']) && $_GET['area'] == 'showalerts' ? 'self_alerts' : 'self_profile'; |
| 4326 | 4570 | $context[$current_action] = true; |
| 4327 | - } |
|
| 4328 | - elseif ($context['current_action'] == 'pm') |
|
| 4571 | + } elseif ($context['current_action'] == 'pm') |
|
| 4329 | 4572 | { |
| 4330 | 4573 | $current_action = 'self_pm'; |
| 4331 | 4574 | $context['self_pm'] = true; |
@@ -4366,12 +4609,14 @@ discard block |
||
| 4366 | 4609 | } |
| 4367 | 4610 | |
| 4368 | 4611 | // Not all actions are simple. |
| 4369 | - if (!empty($needs_action_hook)) |
|
| 4370 | - call_integration_hook('integrate_current_action', array(&$current_action)); |
|
| 4612 | + if (!empty($needs_action_hook)) { |
|
| 4613 | + call_integration_hook('integrate_current_action', array(&$current_action)); |
|
| 4614 | + } |
|
| 4371 | 4615 | |
| 4372 | - if (isset($context['menu_buttons'][$current_action])) |
|
| 4373 | - $context['menu_buttons'][$current_action]['active_button'] = true; |
|
| 4374 | -} |
|
| 4616 | + if (isset($context['menu_buttons'][$current_action])) { |
|
| 4617 | + $context['menu_buttons'][$current_action]['active_button'] = true; |
|
| 4618 | + } |
|
| 4619 | + } |
|
| 4375 | 4620 | |
| 4376 | 4621 | /** |
| 4377 | 4622 | * Generate a random seed and ensure it's stored in settings. |
@@ -4395,30 +4640,35 @@ discard block |
||
| 4395 | 4640 | global $modSettings, $settings, $boarddir, $sourcedir, $db_show_debug; |
| 4396 | 4641 | global $context, $txt; |
| 4397 | 4642 | |
| 4398 | - if ($db_show_debug === true) |
|
| 4399 | - $context['debug']['hooks'][] = $hook; |
|
| 4643 | + if ($db_show_debug === true) { |
|
| 4644 | + $context['debug']['hooks'][] = $hook; |
|
| 4645 | + } |
|
| 4400 | 4646 | |
| 4401 | 4647 | // Need to have some control. |
| 4402 | - if (!isset($context['instances'])) |
|
| 4403 | - $context['instances'] = array(); |
|
| 4648 | + if (!isset($context['instances'])) { |
|
| 4649 | + $context['instances'] = array(); |
|
| 4650 | + } |
|
| 4404 | 4651 | |
| 4405 | 4652 | $results = array(); |
| 4406 | - if (empty($modSettings[$hook])) |
|
| 4407 | - return $results; |
|
| 4653 | + if (empty($modSettings[$hook])) { |
|
| 4654 | + return $results; |
|
| 4655 | + } |
|
| 4408 | 4656 | |
| 4409 | 4657 | $functions = explode(',', $modSettings[$hook]); |
| 4410 | 4658 | // Loop through each function. |
| 4411 | 4659 | foreach ($functions as $function) |
| 4412 | 4660 | { |
| 4413 | 4661 | // Hook has been marked as "disabled". Skip it! |
| 4414 | - if (strpos($function, '!') !== false) |
|
| 4415 | - continue; |
|
| 4662 | + if (strpos($function, '!') !== false) { |
|
| 4663 | + continue; |
|
| 4664 | + } |
|
| 4416 | 4665 | |
| 4417 | 4666 | $call = call_helper($function, true); |
| 4418 | 4667 | |
| 4419 | 4668 | // Is it valid? |
| 4420 | - if (!empty($call)) |
|
| 4421 | - $results[$function] = call_user_func_array($call, $parameters); |
|
| 4669 | + if (!empty($call)) { |
|
| 4670 | + $results[$function] = call_user_func_array($call, $parameters); |
|
| 4671 | + } |
|
| 4422 | 4672 | |
| 4423 | 4673 | // Whatever it was suppose to call, it failed :( |
| 4424 | 4674 | elseif (!empty($function)) |
@@ -4434,8 +4684,9 @@ discard block |
||
| 4434 | 4684 | } |
| 4435 | 4685 | |
| 4436 | 4686 | // "Assume" the file resides on $boarddir somewhere... |
| 4437 | - else |
|
| 4438 | - log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
| 4687 | + else { |
|
| 4688 | + log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
| 4689 | + } |
|
| 4439 | 4690 | } |
| 4440 | 4691 | } |
| 4441 | 4692 | |
@@ -4457,12 +4708,14 @@ discard block |
||
| 4457 | 4708 | global $smcFunc, $modSettings; |
| 4458 | 4709 | |
| 4459 | 4710 | // Any objects? |
| 4460 | - if ($object) |
|
| 4461 | - $function = $function . '#'; |
|
| 4711 | + if ($object) { |
|
| 4712 | + $function = $function . '#'; |
|
| 4713 | + } |
|
| 4462 | 4714 | |
| 4463 | 4715 | // Any files to load? |
| 4464 | - if (!empty($file) && is_string($file)) |
|
| 4465 | - $function = $file . (!empty($function) ? '|' . $function : ''); |
|
| 4716 | + if (!empty($file) && is_string($file)) { |
|
| 4717 | + $function = $file . (!empty($function) ? '|' . $function : ''); |
|
| 4718 | + } |
|
| 4466 | 4719 | |
| 4467 | 4720 | // Get the correct string. |
| 4468 | 4721 | $integration_call = $function; |
@@ -4484,13 +4737,14 @@ discard block |
||
| 4484 | 4737 | if (!empty($current_functions)) |
| 4485 | 4738 | { |
| 4486 | 4739 | $current_functions = explode(',', $current_functions); |
| 4487 | - if (in_array($integration_call, $current_functions)) |
|
| 4488 | - return; |
|
| 4740 | + if (in_array($integration_call, $current_functions)) { |
|
| 4741 | + return; |
|
| 4742 | + } |
|
| 4489 | 4743 | |
| 4490 | 4744 | $permanent_functions = array_merge($current_functions, array($integration_call)); |
| 4745 | + } else { |
|
| 4746 | + $permanent_functions = array($integration_call); |
|
| 4491 | 4747 | } |
| 4492 | - else |
|
| 4493 | - $permanent_functions = array($integration_call); |
|
| 4494 | 4748 | |
| 4495 | 4749 | updateSettings(array($hook => implode(',', $permanent_functions))); |
| 4496 | 4750 | } |
@@ -4499,8 +4753,9 @@ discard block |
||
| 4499 | 4753 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
| 4500 | 4754 | |
| 4501 | 4755 | // Do nothing, if it's already there. |
| 4502 | - if (in_array($integration_call, $functions)) |
|
| 4503 | - return; |
|
| 4756 | + if (in_array($integration_call, $functions)) { |
|
| 4757 | + return; |
|
| 4758 | + } |
|
| 4504 | 4759 | |
| 4505 | 4760 | $functions[] = $integration_call; |
| 4506 | 4761 | $modSettings[$hook] = implode(',', $functions); |
@@ -4523,12 +4778,14 @@ discard block |
||
| 4523 | 4778 | global $smcFunc, $modSettings; |
| 4524 | 4779 | |
| 4525 | 4780 | // Any objects? |
| 4526 | - if ($object) |
|
| 4527 | - $function = $function . '#'; |
|
| 4781 | + if ($object) { |
|
| 4782 | + $function = $function . '#'; |
|
| 4783 | + } |
|
| 4528 | 4784 | |
| 4529 | 4785 | // Any files to load? |
| 4530 | - if (!empty($file) && is_string($file)) |
|
| 4531 | - $function = $file . '|' . $function; |
|
| 4786 | + if (!empty($file) && is_string($file)) { |
|
| 4787 | + $function = $file . '|' . $function; |
|
| 4788 | + } |
|
| 4532 | 4789 | |
| 4533 | 4790 | // Get the correct string. |
| 4534 | 4791 | $integration_call = $function; |
@@ -4549,16 +4806,18 @@ discard block |
||
| 4549 | 4806 | { |
| 4550 | 4807 | $current_functions = explode(',', $current_functions); |
| 4551 | 4808 | |
| 4552 | - if (in_array($integration_call, $current_functions)) |
|
| 4553 | - updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
| 4809 | + if (in_array($integration_call, $current_functions)) { |
|
| 4810 | + updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
| 4811 | + } |
|
| 4554 | 4812 | } |
| 4555 | 4813 | |
| 4556 | 4814 | // Turn the function list into something usable. |
| 4557 | 4815 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
| 4558 | 4816 | |
| 4559 | 4817 | // You can only remove it if it's available. |
| 4560 | - if (!in_array($integration_call, $functions)) |
|
| 4561 | - return; |
|
| 4818 | + if (!in_array($integration_call, $functions)) { |
|
| 4819 | + return; |
|
| 4820 | + } |
|
| 4562 | 4821 | |
| 4563 | 4822 | $functions = array_diff($functions, array($integration_call)); |
| 4564 | 4823 | $modSettings[$hook] = implode(',', $functions); |
@@ -4579,17 +4838,20 @@ discard block |
||
| 4579 | 4838 | global $context, $smcFunc, $txt, $db_show_debug; |
| 4580 | 4839 | |
| 4581 | 4840 | // Really? |
| 4582 | - if (empty($string)) |
|
| 4583 | - return false; |
|
| 4841 | + if (empty($string)) { |
|
| 4842 | + return false; |
|
| 4843 | + } |
|
| 4584 | 4844 | |
| 4585 | 4845 | // An array? should be a "callable" array IE array(object/class, valid_callable). |
| 4586 | 4846 | // A closure? should be a callable one. |
| 4587 | - if (is_array($string) || $string instanceof Closure) |
|
| 4588 | - return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
| 4847 | + if (is_array($string) || $string instanceof Closure) { |
|
| 4848 | + return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
| 4849 | + } |
|
| 4589 | 4850 | |
| 4590 | 4851 | // No full objects, sorry! pass a method or a property instead! |
| 4591 | - if (is_object($string)) |
|
| 4592 | - return false; |
|
| 4852 | + if (is_object($string)) { |
|
| 4853 | + return false; |
|
| 4854 | + } |
|
| 4593 | 4855 | |
| 4594 | 4856 | // Stay vitaminized my friends... |
| 4595 | 4857 | $string = $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($string)); |
@@ -4598,8 +4860,9 @@ discard block |
||
| 4598 | 4860 | $string = load_file($string); |
| 4599 | 4861 | |
| 4600 | 4862 | // Loaded file failed |
| 4601 | - if (empty($string)) |
|
| 4602 | - return false; |
|
| 4863 | + if (empty($string)) { |
|
| 4864 | + return false; |
|
| 4865 | + } |
|
| 4603 | 4866 | |
| 4604 | 4867 | // Found a method. |
| 4605 | 4868 | if (strpos($string, '::') !== false) |
@@ -4620,8 +4883,9 @@ discard block |
||
| 4620 | 4883 | // Add another one to the list. |
| 4621 | 4884 | if ($db_show_debug === true) |
| 4622 | 4885 | { |
| 4623 | - if (!isset($context['debug']['instances'])) |
|
| 4624 | - $context['debug']['instances'] = array(); |
|
| 4886 | + if (!isset($context['debug']['instances'])) { |
|
| 4887 | + $context['debug']['instances'] = array(); |
|
| 4888 | + } |
|
| 4625 | 4889 | |
| 4626 | 4890 | $context['debug']['instances'][$class] = $class; |
| 4627 | 4891 | } |
@@ -4631,13 +4895,15 @@ discard block |
||
| 4631 | 4895 | } |
| 4632 | 4896 | |
| 4633 | 4897 | // Right then. This is a call to a static method. |
| 4634 | - else |
|
| 4635 | - $func = array($class, $method); |
|
| 4898 | + else { |
|
| 4899 | + $func = array($class, $method); |
|
| 4900 | + } |
|
| 4636 | 4901 | } |
| 4637 | 4902 | |
| 4638 | 4903 | // Nope! just a plain regular function. |
| 4639 | - else |
|
| 4640 | - $func = $string; |
|
| 4904 | + else { |
|
| 4905 | + $func = $string; |
|
| 4906 | + } |
|
| 4641 | 4907 | |
| 4642 | 4908 | // Right, we got what we need, time to do some checks. |
| 4643 | 4909 | if (!is_callable($func, false, $callable_name)) |
@@ -4653,17 +4919,18 @@ discard block |
||
| 4653 | 4919 | else |
| 4654 | 4920 | { |
| 4655 | 4921 | // What are we gonna do about it? |
| 4656 | - if ($return) |
|
| 4657 | - return $func; |
|
| 4922 | + if ($return) { |
|
| 4923 | + return $func; |
|
| 4924 | + } |
|
| 4658 | 4925 | |
| 4659 | 4926 | // If this is a plain function, avoid the heat of calling call_user_func(). |
| 4660 | 4927 | else |
| 4661 | 4928 | { |
| 4662 | - if (is_array($func)) |
|
| 4663 | - call_user_func($func); |
|
| 4664 | - |
|
| 4665 | - else |
|
| 4666 | - $func(); |
|
| 4929 | + if (is_array($func)) { |
|
| 4930 | + call_user_func($func); |
|
| 4931 | + } else { |
|
| 4932 | + $func(); |
|
| 4933 | + } |
|
| 4667 | 4934 | } |
| 4668 | 4935 | } |
| 4669 | 4936 | } |
@@ -4680,31 +4947,34 @@ discard block |
||
| 4680 | 4947 | { |
| 4681 | 4948 | global $sourcedir, $txt, $boarddir, $settings; |
| 4682 | 4949 | |
| 4683 | - if (empty($string)) |
|
| 4684 | - return false; |
|
| 4950 | + if (empty($string)) { |
|
| 4951 | + return false; |
|
| 4952 | + } |
|
| 4685 | 4953 | |
| 4686 | 4954 | if (strpos($string, '|') !== false) |
| 4687 | 4955 | { |
| 4688 | 4956 | list ($file, $string) = explode('|', $string); |
| 4689 | 4957 | |
| 4690 | 4958 | // Match the wildcards to their regular vars. |
| 4691 | - if (empty($settings['theme_dir'])) |
|
| 4692 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 4693 | - |
|
| 4694 | - else |
|
| 4695 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 4959 | + if (empty($settings['theme_dir'])) { |
|
| 4960 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 4961 | + } else { |
|
| 4962 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 4963 | + } |
|
| 4696 | 4964 | |
| 4697 | 4965 | // Load the file if it can be loaded. |
| 4698 | - if (file_exists($absPath)) |
|
| 4699 | - require_once($absPath); |
|
| 4966 | + if (file_exists($absPath)) { |
|
| 4967 | + require_once($absPath); |
|
| 4968 | + } |
|
| 4700 | 4969 | |
| 4701 | 4970 | // No? try a fallback to $sourcedir |
| 4702 | 4971 | else |
| 4703 | 4972 | { |
| 4704 | 4973 | $absPath = $sourcedir .'/'. $file; |
| 4705 | 4974 | |
| 4706 | - if (file_exists($absPath)) |
|
| 4707 | - require_once($absPath); |
|
| 4975 | + if (file_exists($absPath)) { |
|
| 4976 | + require_once($absPath); |
|
| 4977 | + } |
|
| 4708 | 4978 | |
| 4709 | 4979 | // Sorry, can't do much for you at this point. |
| 4710 | 4980 | else |
@@ -4731,8 +5001,9 @@ discard block |
||
| 4731 | 5001 | global $user_info, $smcFunc; |
| 4732 | 5002 | |
| 4733 | 5003 | // Make sure we have something to work with. |
| 4734 | - if (empty($topic)) |
|
| 4735 | - return array(); |
|
| 5004 | + if (empty($topic)) { |
|
| 5005 | + return array(); |
|
| 5006 | + } |
|
| 4736 | 5007 | |
| 4737 | 5008 | |
| 4738 | 5009 | // We already know the number of likes per message, we just want to know whether the current user liked it or not. |
@@ -4755,8 +5026,9 @@ discard block |
||
| 4755 | 5026 | 'topic' => $topic, |
| 4756 | 5027 | ) |
| 4757 | 5028 | ); |
| 4758 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 4759 | - $temp[] = (int) $row['content_id']; |
|
| 5029 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 5030 | + $temp[] = (int) $row['content_id']; |
|
| 5031 | + } |
|
| 4760 | 5032 | |
| 4761 | 5033 | cache_put_data($cache_key, $temp, $ttl); |
| 4762 | 5034 | } |
@@ -4777,8 +5049,9 @@ discard block |
||
| 4777 | 5049 | { |
| 4778 | 5050 | global $context; |
| 4779 | 5051 | |
| 4780 | - if (empty($string)) |
|
| 4781 | - return $string; |
|
| 5052 | + if (empty($string)) { |
|
| 5053 | + return $string; |
|
| 5054 | + } |
|
| 4782 | 5055 | |
| 4783 | 5056 | // UTF-8 occurences of MS special characters |
| 4784 | 5057 | $findchars_utf8 = array( |
@@ -4819,10 +5092,11 @@ discard block |
||
| 4819 | 5092 | '--', // — |
| 4820 | 5093 | ); |
| 4821 | 5094 | |
| 4822 | - if ($context['utf8']) |
|
| 4823 | - $string = str_replace($findchars_utf8, $replacechars, $string); |
|
| 4824 | - else |
|
| 4825 | - $string = str_replace($findchars_iso, $replacechars, $string); |
|
| 5095 | + if ($context['utf8']) { |
|
| 5096 | + $string = str_replace($findchars_utf8, $replacechars, $string); |
|
| 5097 | + } else { |
|
| 5098 | + $string = str_replace($findchars_iso, $replacechars, $string); |
|
| 5099 | + } |
|
| 4826 | 5100 | |
| 4827 | 5101 | return $string; |
| 4828 | 5102 | } |
@@ -4841,49 +5115,59 @@ discard block |
||
| 4841 | 5115 | { |
| 4842 | 5116 | global $context; |
| 4843 | 5117 | |
| 4844 | - if (!isset($matches[2])) |
|
| 4845 | - return ''; |
|
| 5118 | + if (!isset($matches[2])) { |
|
| 5119 | + return ''; |
|
| 5120 | + } |
|
| 4846 | 5121 | |
| 4847 | 5122 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
| 4848 | 5123 | |
| 4849 | 5124 | // remove left to right / right to left overrides |
| 4850 | - if ($num === 0x202D || $num === 0x202E) |
|
| 4851 | - return ''; |
|
| 5125 | + if ($num === 0x202D || $num === 0x202E) { |
|
| 5126 | + return ''; |
|
| 5127 | + } |
|
| 4852 | 5128 | |
| 4853 | 5129 | // Quote, Ampersand, Apostrophe, Less/Greater Than get html replaced |
| 4854 | - if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) |
|
| 4855 | - return '&#' . $num . ';'; |
|
| 5130 | + if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) { |
|
| 5131 | + return '&#' . $num . ';'; |
|
| 5132 | + } |
|
| 4856 | 5133 | |
| 4857 | 5134 | if (empty($context['utf8'])) |
| 4858 | 5135 | { |
| 4859 | 5136 | // no control characters |
| 4860 | - if ($num < 0x20) |
|
| 4861 | - return ''; |
|
| 5137 | + if ($num < 0x20) { |
|
| 5138 | + return ''; |
|
| 5139 | + } |
|
| 4862 | 5140 | // text is text |
| 4863 | - elseif ($num < 0x80) |
|
| 4864 | - return chr($num); |
|
| 5141 | + elseif ($num < 0x80) { |
|
| 5142 | + return chr($num); |
|
| 5143 | + } |
|
| 4865 | 5144 | // all others get html-ised |
| 4866 | - else |
|
| 4867 | - return '&#' . $matches[2] . ';'; |
|
| 4868 | - } |
|
| 4869 | - else |
|
| 5145 | + else { |
|
| 5146 | + return '&#' . $matches[2] . ';'; |
|
| 5147 | + } |
|
| 5148 | + } else |
|
| 4870 | 5149 | { |
| 4871 | 5150 | // <0x20 are control characters, 0x20 is a space, > 0x10FFFF is past the end of the utf8 character set |
| 4872 | 5151 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text) |
| 4873 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) |
|
| 4874 | - return ''; |
|
| 5152 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) { |
|
| 5153 | + return ''; |
|
| 5154 | + } |
|
| 4875 | 5155 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
| 4876 | - elseif ($num < 0x80) |
|
| 4877 | - return chr($num); |
|
| 5156 | + elseif ($num < 0x80) { |
|
| 5157 | + return chr($num); |
|
| 5158 | + } |
|
| 4878 | 5159 | // <0x800 (2048) |
| 4879 | - elseif ($num < 0x800) |
|
| 4880 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5160 | + elseif ($num < 0x800) { |
|
| 5161 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5162 | + } |
|
| 4881 | 5163 | // < 0x10000 (65536) |
| 4882 | - elseif ($num < 0x10000) |
|
| 4883 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5164 | + elseif ($num < 0x10000) { |
|
| 5165 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5166 | + } |
|
| 4884 | 5167 | // <= 0x10FFFF (1114111) |
| 4885 | - else |
|
| 4886 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5168 | + else { |
|
| 5169 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5170 | + } |
|
| 4887 | 5171 | } |
| 4888 | 5172 | } |
| 4889 | 5173 | |
@@ -4899,28 +5183,34 @@ discard block |
||
| 4899 | 5183 | */ |
| 4900 | 5184 | function fixchar__callback($matches) |
| 4901 | 5185 | { |
| 4902 | - if (!isset($matches[1])) |
|
| 4903 | - return ''; |
|
| 5186 | + if (!isset($matches[1])) { |
|
| 5187 | + return ''; |
|
| 5188 | + } |
|
| 4904 | 5189 | |
| 4905 | 5190 | $num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1]; |
| 4906 | 5191 | |
| 4907 | 5192 | // <0x20 are control characters, > 0x10FFFF is past the end of the utf8 character set |
| 4908 | 5193 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text), 0x202D-E are left to right overrides |
| 4909 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) |
|
| 4910 | - return ''; |
|
| 5194 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) { |
|
| 5195 | + return ''; |
|
| 5196 | + } |
|
| 4911 | 5197 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
| 4912 | - elseif ($num < 0x80) |
|
| 4913 | - return chr($num); |
|
| 5198 | + elseif ($num < 0x80) { |
|
| 5199 | + return chr($num); |
|
| 5200 | + } |
|
| 4914 | 5201 | // <0x800 (2048) |
| 4915 | - elseif ($num < 0x800) |
|
| 4916 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5202 | + elseif ($num < 0x800) { |
|
| 5203 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5204 | + } |
|
| 4917 | 5205 | // < 0x10000 (65536) |
| 4918 | - elseif ($num < 0x10000) |
|
| 4919 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5206 | + elseif ($num < 0x10000) { |
|
| 5207 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5208 | + } |
|
| 4920 | 5209 | // <= 0x10FFFF (1114111) |
| 4921 | - else |
|
| 4922 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 4923 | -} |
|
| 5210 | + else { |
|
| 5211 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5212 | + } |
|
| 5213 | + } |
|
| 4924 | 5214 | |
| 4925 | 5215 | /** |
| 4926 | 5216 | * Strips out invalid html entities, replaces others with html style { codes |
@@ -4933,17 +5223,19 @@ discard block |
||
| 4933 | 5223 | */ |
| 4934 | 5224 | function entity_fix__callback($matches) |
| 4935 | 5225 | { |
| 4936 | - if (!isset($matches[2])) |
|
| 4937 | - return ''; |
|
| 5226 | + if (!isset($matches[2])) { |
|
| 5227 | + return ''; |
|
| 5228 | + } |
|
| 4938 | 5229 | |
| 4939 | 5230 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
| 4940 | 5231 | |
| 4941 | 5232 | // we don't allow control characters, characters out of range, byte markers, etc |
| 4942 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) |
|
| 4943 | - return ''; |
|
| 4944 | - else |
|
| 4945 | - return '&#' . $num . ';'; |
|
| 4946 | -} |
|
| 5233 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) { |
|
| 5234 | + return ''; |
|
| 5235 | + } else { |
|
| 5236 | + return '&#' . $num . ';'; |
|
| 5237 | + } |
|
| 5238 | + } |
|
| 4947 | 5239 | |
| 4948 | 5240 | /** |
| 4949 | 5241 | * Return a Gravatar URL based on |
@@ -4967,18 +5259,23 @@ discard block |
||
| 4967 | 5259 | $ratings = array('G', 'PG', 'R', 'X'); |
| 4968 | 5260 | $defaults = array('mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank'); |
| 4969 | 5261 | $url_params = array(); |
| 4970 | - if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) |
|
| 4971 | - $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
| 4972 | - if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) |
|
| 4973 | - $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
| 4974 | - if (!empty($modSettings['avatar_max_width_external'])) |
|
| 4975 | - $size_string = (int) $modSettings['avatar_max_width_external']; |
|
| 4976 | - if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) |
|
| 4977 | - if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
| 5262 | + if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) { |
|
| 5263 | + $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
| 5264 | + } |
|
| 5265 | + if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) { |
|
| 5266 | + $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
| 5267 | + } |
|
| 5268 | + if (!empty($modSettings['avatar_max_width_external'])) { |
|
| 5269 | + $size_string = (int) $modSettings['avatar_max_width_external']; |
|
| 5270 | + } |
|
| 5271 | + if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) { |
|
| 5272 | + if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
| 4978 | 5273 | $size_string = $modSettings['avatar_max_height_external']; |
| 5274 | + } |
|
| 4979 | 5275 | |
| 4980 | - if (!empty($size_string)) |
|
| 4981 | - $url_params[] = 's=' . $size_string; |
|
| 5276 | + if (!empty($size_string)) { |
|
| 5277 | + $url_params[] = 's=' . $size_string; |
|
| 5278 | + } |
|
| 4982 | 5279 | } |
| 4983 | 5280 | $http_method = !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 ? 'https://secure' : 'http://www'; |
| 4984 | 5281 | |
@@ -4997,22 +5294,26 @@ discard block |
||
| 4997 | 5294 | static $timezones = null, $lastwhen = null; |
| 4998 | 5295 | |
| 4999 | 5296 | // No point doing this over if we already did it once |
| 5000 | - if (!empty($timezones) && $when == $lastwhen) |
|
| 5001 | - return $timezones; |
|
| 5002 | - else |
|
| 5003 | - $lastwhen = $when; |
|
| 5297 | + if (!empty($timezones) && $when == $lastwhen) { |
|
| 5298 | + return $timezones; |
|
| 5299 | + } else { |
|
| 5300 | + $lastwhen = $when; |
|
| 5301 | + } |
|
| 5004 | 5302 | |
| 5005 | 5303 | // Parseable datetime string? |
| 5006 | - if (is_int($timestamp = strtotime($when))) |
|
| 5007 | - $when = $timestamp; |
|
| 5304 | + if (is_int($timestamp = strtotime($when))) { |
|
| 5305 | + $when = $timestamp; |
|
| 5306 | + } |
|
| 5008 | 5307 | |
| 5009 | 5308 | // A Unix timestamp? |
| 5010 | - elseif (is_numeric($when)) |
|
| 5011 | - $when = intval($when); |
|
| 5309 | + elseif (is_numeric($when)) { |
|
| 5310 | + $when = intval($when); |
|
| 5311 | + } |
|
| 5012 | 5312 | |
| 5013 | 5313 | // Invalid value? Just get current Unix timestamp. |
| 5014 | - else |
|
| 5015 | - $when = time(); |
|
| 5314 | + else { |
|
| 5315 | + $when = time(); |
|
| 5316 | + } |
|
| 5016 | 5317 | |
| 5017 | 5318 | // We'll need these too |
| 5018 | 5319 | $date_when = date_create('@' . $when); |
@@ -5076,8 +5377,9 @@ discard block |
||
| 5076 | 5377 | foreach ($priority_countries as $country) |
| 5077 | 5378 | { |
| 5078 | 5379 | $country_tzids = @timezone_identifiers_list(DateTimeZone::PER_COUNTRY, strtoupper(trim($country))); |
| 5079 | - if (!empty($country_tzids)) |
|
| 5080 | - $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
| 5380 | + if (!empty($country_tzids)) { |
|
| 5381 | + $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
| 5382 | + } |
|
| 5081 | 5383 | } |
| 5082 | 5384 | |
| 5083 | 5385 | // Process the preferred timezones first, then the rest. |
@@ -5087,8 +5389,9 @@ discard block |
||
| 5087 | 5389 | foreach ($tzids as $tzid) |
| 5088 | 5390 | { |
| 5089 | 5391 | // We don't want UTC right now |
| 5090 | - if ($tzid == 'UTC') |
|
| 5091 | - continue; |
|
| 5392 | + if ($tzid == 'UTC') { |
|
| 5393 | + continue; |
|
| 5394 | + } |
|
| 5092 | 5395 | |
| 5093 | 5396 | $tz = timezone_open($tzid); |
| 5094 | 5397 | |
@@ -5109,8 +5412,9 @@ discard block |
||
| 5109 | 5412 | } |
| 5110 | 5413 | |
| 5111 | 5414 | // A time zone from a prioritized country? |
| 5112 | - if (in_array($tzid, $priority_tzids)) |
|
| 5113 | - $priority_zones[$tzkey] = true; |
|
| 5415 | + if (in_array($tzid, $priority_tzids)) { |
|
| 5416 | + $priority_zones[$tzkey] = true; |
|
| 5417 | + } |
|
| 5114 | 5418 | |
| 5115 | 5419 | // Keep track of the location and offset for this tzid |
| 5116 | 5420 | $tzid_parts = explode('/', $tzid); |
@@ -5129,15 +5433,17 @@ discard block |
||
| 5129 | 5433 | { |
| 5130 | 5434 | date_timezone_set($date_when, timezone_open($tzvalue['tzid'])); |
| 5131 | 5435 | |
| 5132 | - if (!empty($timezone_descriptions[$tzvalue['tzid']])) |
|
| 5133 | - $desc = $timezone_descriptions[$tzvalue['tzid']]; |
|
| 5134 | - else |
|
| 5135 | - $desc = implode(', ', array_unique($tzvalue['locations'])); |
|
| 5436 | + if (!empty($timezone_descriptions[$tzvalue['tzid']])) { |
|
| 5437 | + $desc = $timezone_descriptions[$tzvalue['tzid']]; |
|
| 5438 | + } else { |
|
| 5439 | + $desc = implode(', ', array_unique($tzvalue['locations'])); |
|
| 5440 | + } |
|
| 5136 | 5441 | |
| 5137 | - if (isset($priority_zones[$tzkey])) |
|
| 5138 | - $priority_timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
| 5139 | - else |
|
| 5140 | - $timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
| 5442 | + if (isset($priority_zones[$tzkey])) { |
|
| 5443 | + $priority_timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
| 5444 | + } else { |
|
| 5445 | + $timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
| 5446 | + } |
|
| 5141 | 5447 | } |
| 5142 | 5448 | |
| 5143 | 5449 | $timezones = array_merge( |
@@ -5191,9 +5497,9 @@ discard block |
||
| 5191 | 5497 | 'Indian/Kerguelen' => 'TFT', |
| 5192 | 5498 | ); |
| 5193 | 5499 | |
| 5194 | - if (!empty($missing_tz_abbrs[$tzid])) |
|
| 5195 | - $tz_abbrev = $missing_tz_abbrs[$tzid]; |
|
| 5196 | - else |
|
| 5500 | + if (!empty($missing_tz_abbrs[$tzid])) { |
|
| 5501 | + $tz_abbrev = $missing_tz_abbrs[$tzid]; |
|
| 5502 | + } else |
|
| 5197 | 5503 | { |
| 5198 | 5504 | // Russia likes to experiment with time zones often, and names them as offsets from Moscow |
| 5199 | 5505 | $tz_location = timezone_location_get(timezone_open($tzid)); |
@@ -5221,8 +5527,9 @@ discard block |
||
| 5221 | 5527 | */ |
| 5222 | 5528 | function inet_ptod($ip_address) |
| 5223 | 5529 | { |
| 5224 | - if (!isValidIP($ip_address)) |
|
| 5225 | - return $ip_address; |
|
| 5530 | + if (!isValidIP($ip_address)) { |
|
| 5531 | + return $ip_address; |
|
| 5532 | + } |
|
| 5226 | 5533 | |
| 5227 | 5534 | $bin = inet_pton($ip_address); |
| 5228 | 5535 | return $bin; |
@@ -5234,13 +5541,15 @@ discard block |
||
| 5234 | 5541 | */ |
| 5235 | 5542 | function inet_dtop($bin) |
| 5236 | 5543 | { |
| 5237 | - if(empty($bin)) |
|
| 5238 | - return ''; |
|
| 5544 | + if(empty($bin)) { |
|
| 5545 | + return ''; |
|
| 5546 | + } |
|
| 5239 | 5547 | |
| 5240 | 5548 | global $db_type; |
| 5241 | 5549 | |
| 5242 | - if ($db_type == 'postgresql') |
|
| 5243 | - return $bin; |
|
| 5550 | + if ($db_type == 'postgresql') { |
|
| 5551 | + return $bin; |
|
| 5552 | + } |
|
| 5244 | 5553 | |
| 5245 | 5554 | $ip_address = inet_ntop($bin); |
| 5246 | 5555 | |
@@ -5265,26 +5574,32 @@ discard block |
||
| 5265 | 5574 | */ |
| 5266 | 5575 | function _safe_serialize($value) |
| 5267 | 5576 | { |
| 5268 | - if(is_null($value)) |
|
| 5269 | - return 'N;'; |
|
| 5577 | + if(is_null($value)) { |
|
| 5578 | + return 'N;'; |
|
| 5579 | + } |
|
| 5270 | 5580 | |
| 5271 | - if(is_bool($value)) |
|
| 5272 | - return 'b:'. (int) $value .';'; |
|
| 5581 | + if(is_bool($value)) { |
|
| 5582 | + return 'b:'. (int) $value .';'; |
|
| 5583 | + } |
|
| 5273 | 5584 | |
| 5274 | - if(is_int($value)) |
|
| 5275 | - return 'i:'. $value .';'; |
|
| 5585 | + if(is_int($value)) { |
|
| 5586 | + return 'i:'. $value .';'; |
|
| 5587 | + } |
|
| 5276 | 5588 | |
| 5277 | - if(is_float($value)) |
|
| 5278 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
| 5589 | + if(is_float($value)) { |
|
| 5590 | + return 'd:'. str_replace(',', '.', $value) .';'; |
|
| 5591 | + } |
|
| 5279 | 5592 | |
| 5280 | - if(is_string($value)) |
|
| 5281 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
| 5593 | + if(is_string($value)) { |
|
| 5594 | + return 's:'. strlen($value) .':"'. $value .'";'; |
|
| 5595 | + } |
|
| 5282 | 5596 | |
| 5283 | 5597 | if(is_array($value)) |
| 5284 | 5598 | { |
| 5285 | 5599 | $out = ''; |
| 5286 | - foreach($value as $k => $v) |
|
| 5287 | - $out .= _safe_serialize($k) . _safe_serialize($v); |
|
| 5600 | + foreach($value as $k => $v) { |
|
| 5601 | + $out .= _safe_serialize($k) . _safe_serialize($v); |
|
| 5602 | + } |
|
| 5288 | 5603 | |
| 5289 | 5604 | return 'a:'. count($value) .':{'. $out .'}'; |
| 5290 | 5605 | } |
@@ -5310,8 +5625,9 @@ discard block |
||
| 5310 | 5625 | |
| 5311 | 5626 | $out = _safe_serialize($value); |
| 5312 | 5627 | |
| 5313 | - if (isset($mbIntEnc)) |
|
| 5314 | - mb_internal_encoding($mbIntEnc); |
|
| 5628 | + if (isset($mbIntEnc)) { |
|
| 5629 | + mb_internal_encoding($mbIntEnc); |
|
| 5630 | + } |
|
| 5315 | 5631 | |
| 5316 | 5632 | return $out; |
| 5317 | 5633 | } |
@@ -5328,8 +5644,9 @@ discard block |
||
| 5328 | 5644 | function _safe_unserialize($str) |
| 5329 | 5645 | { |
| 5330 | 5646 | // Input is not a string. |
| 5331 | - if(empty($str) || !is_string($str)) |
|
| 5332 | - return false; |
|
| 5647 | + if(empty($str) || !is_string($str)) { |
|
| 5648 | + return false; |
|
| 5649 | + } |
|
| 5333 | 5650 | |
| 5334 | 5651 | $stack = array(); |
| 5335 | 5652 | $expected = array(); |
@@ -5345,43 +5662,38 @@ discard block |
||
| 5345 | 5662 | while($state != 1) |
| 5346 | 5663 | { |
| 5347 | 5664 | $type = isset($str[0]) ? $str[0] : ''; |
| 5348 | - if($type == '}') |
|
| 5349 | - $str = substr($str, 1); |
|
| 5350 | - |
|
| 5351 | - else if($type == 'N' && $str[1] == ';') |
|
| 5665 | + if($type == '}') { |
|
| 5666 | + $str = substr($str, 1); |
|
| 5667 | + } else if($type == 'N' && $str[1] == ';') |
|
| 5352 | 5668 | { |
| 5353 | 5669 | $value = null; |
| 5354 | 5670 | $str = substr($str, 2); |
| 5355 | - } |
|
| 5356 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 5671 | + } else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 5357 | 5672 | { |
| 5358 | 5673 | $value = $matches[1] == '1' ? true : false; |
| 5359 | 5674 | $str = substr($str, 4); |
| 5360 | - } |
|
| 5361 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 5675 | + } else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 5362 | 5676 | { |
| 5363 | 5677 | $value = (int)$matches[1]; |
| 5364 | 5678 | $str = $matches[2]; |
| 5365 | - } |
|
| 5366 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 5679 | + } else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 5367 | 5680 | { |
| 5368 | 5681 | $value = (float)$matches[1]; |
| 5369 | 5682 | $str = $matches[3]; |
| 5370 | - } |
|
| 5371 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
| 5683 | + } else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
| 5372 | 5684 | { |
| 5373 | 5685 | $value = substr($matches[2], 0, (int)$matches[1]); |
| 5374 | 5686 | $str = substr($matches[2], (int)$matches[1] + 2); |
| 5375 | - } |
|
| 5376 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 5687 | + } else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 5377 | 5688 | { |
| 5378 | 5689 | $expectedLength = (int)$matches[1]; |
| 5379 | 5690 | $str = $matches[2]; |
| 5380 | 5691 | } |
| 5381 | 5692 | |
| 5382 | 5693 | // Object or unknown/malformed type. |
| 5383 | - else |
|
| 5384 | - return false; |
|
| 5694 | + else { |
|
| 5695 | + return false; |
|
| 5696 | + } |
|
| 5385 | 5697 | |
| 5386 | 5698 | switch($state) |
| 5387 | 5699 | { |
@@ -5409,8 +5721,9 @@ discard block |
||
| 5409 | 5721 | if($type == '}') |
| 5410 | 5722 | { |
| 5411 | 5723 | // Array size is less than expected. |
| 5412 | - if(count($list) < end($expected)) |
|
| 5413 | - return false; |
|
| 5724 | + if(count($list) < end($expected)) { |
|
| 5725 | + return false; |
|
| 5726 | + } |
|
| 5414 | 5727 | |
| 5415 | 5728 | unset($list); |
| 5416 | 5729 | $list = &$stack[count($stack)-1]; |
@@ -5419,8 +5732,9 @@ discard block |
||
| 5419 | 5732 | // Go to terminal state if we're at the end of the root array. |
| 5420 | 5733 | array_pop($expected); |
| 5421 | 5734 | |
| 5422 | - if(count($expected) == 0) |
|
| 5423 | - $state = 1; |
|
| 5735 | + if(count($expected) == 0) { |
|
| 5736 | + $state = 1; |
|
| 5737 | + } |
|
| 5424 | 5738 | |
| 5425 | 5739 | break; |
| 5426 | 5740 | } |
@@ -5428,8 +5742,9 @@ discard block |
||
| 5428 | 5742 | if($type == 'i' || $type == 's') |
| 5429 | 5743 | { |
| 5430 | 5744 | // Array size exceeds expected length. |
| 5431 | - if(count($list) >= end($expected)) |
|
| 5432 | - return false; |
|
| 5745 | + if(count($list) >= end($expected)) { |
|
| 5746 | + return false; |
|
| 5747 | + } |
|
| 5433 | 5748 | |
| 5434 | 5749 | $key = $value; |
| 5435 | 5750 | $state = 3; |
@@ -5463,8 +5778,9 @@ discard block |
||
| 5463 | 5778 | } |
| 5464 | 5779 | |
| 5465 | 5780 | // Trailing data in input. |
| 5466 | - if(!empty($str)) |
|
| 5467 | - return false; |
|
| 5781 | + if(!empty($str)) { |
|
| 5782 | + return false; |
|
| 5783 | + } |
|
| 5468 | 5784 | |
| 5469 | 5785 | return $data; |
| 5470 | 5786 | } |
@@ -5487,8 +5803,9 @@ discard block |
||
| 5487 | 5803 | |
| 5488 | 5804 | $out = _safe_unserialize($str); |
| 5489 | 5805 | |
| 5490 | - if (isset($mbIntEnc)) |
|
| 5491 | - mb_internal_encoding($mbIntEnc); |
|
| 5806 | + if (isset($mbIntEnc)) { |
|
| 5807 | + mb_internal_encoding($mbIntEnc); |
|
| 5808 | + } |
|
| 5492 | 5809 | |
| 5493 | 5810 | return $out; |
| 5494 | 5811 | } |
@@ -5503,12 +5820,14 @@ discard block |
||
| 5503 | 5820 | function smf_chmod($file, $value = 0) |
| 5504 | 5821 | { |
| 5505 | 5822 | // No file? no checks! |
| 5506 | - if (empty($file)) |
|
| 5507 | - return false; |
|
| 5823 | + if (empty($file)) { |
|
| 5824 | + return false; |
|
| 5825 | + } |
|
| 5508 | 5826 | |
| 5509 | 5827 | // Already writable? |
| 5510 | - if (is_writable($file)) |
|
| 5511 | - return true; |
|
| 5828 | + if (is_writable($file)) { |
|
| 5829 | + return true; |
|
| 5830 | + } |
|
| 5512 | 5831 | |
| 5513 | 5832 | // Do we have a file or a dir? |
| 5514 | 5833 | $isDir = is_dir($file); |
@@ -5524,10 +5843,9 @@ discard block |
||
| 5524 | 5843 | { |
| 5525 | 5844 | $isWritable = true; |
| 5526 | 5845 | break; |
| 5846 | + } else { |
|
| 5847 | + @chmod($file, $val); |
|
| 5527 | 5848 | } |
| 5528 | - |
|
| 5529 | - else |
|
| 5530 | - @chmod($file, $val); |
|
| 5531 | 5849 | } |
| 5532 | 5850 | |
| 5533 | 5851 | return $isWritable; |
@@ -5546,8 +5864,9 @@ discard block |
||
| 5546 | 5864 | global $txt; |
| 5547 | 5865 | |
| 5548 | 5866 | // Come on... |
| 5549 | - if (empty($json) || !is_string($json)) |
|
| 5550 | - return array(); |
|
| 5867 | + if (empty($json) || !is_string($json)) { |
|
| 5868 | + return array(); |
|
| 5869 | + } |
|
| 5551 | 5870 | |
| 5552 | 5871 | $returnArray = @json_decode($json, $returnAsArray); |
| 5553 | 5872 | |
@@ -5585,11 +5904,11 @@ discard block |
||
| 5585 | 5904 | $jsonDebug = $jsonDebug[0]; |
| 5586 | 5905 | loadLanguage('Errors'); |
| 5587 | 5906 | |
| 5588 | - if (!empty($jsonDebug)) |
|
| 5589 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 5590 | - |
|
| 5591 | - else |
|
| 5592 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
| 5907 | + if (!empty($jsonDebug)) { |
|
| 5908 | + log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 5909 | + } else { |
|
| 5910 | + log_error($txt['json_'. $jsonError], 'critical'); |
|
| 5911 | + } |
|
| 5593 | 5912 | |
| 5594 | 5913 | // Everyone expects an array. |
| 5595 | 5914 | return array(); |
@@ -5623,8 +5942,9 @@ discard block |
||
| 5623 | 5942 | global $db_show_debug, $modSettings; |
| 5624 | 5943 | |
| 5625 | 5944 | // Defensive programming anyone? |
| 5626 | - if (empty($data)) |
|
| 5627 | - return false; |
|
| 5945 | + if (empty($data)) { |
|
| 5946 | + return false; |
|
| 5947 | + } |
|
| 5628 | 5948 | |
| 5629 | 5949 | // Don't need extra stuff... |
| 5630 | 5950 | $db_show_debug = false; |
@@ -5632,11 +5952,11 @@ discard block |
||
| 5632 | 5952 | // Kill anything else. |
| 5633 | 5953 | ob_end_clean(); |
| 5634 | 5954 | |
| 5635 | - if (!empty($modSettings['CompressedOutput'])) |
|
| 5636 | - @ob_start('ob_gzhandler'); |
|
| 5637 | - |
|
| 5638 | - else |
|
| 5639 | - ob_start(); |
|
| 5955 | + if (!empty($modSettings['CompressedOutput'])) { |
|
| 5956 | + @ob_start('ob_gzhandler'); |
|
| 5957 | + } else { |
|
| 5958 | + ob_start(); |
|
| 5959 | + } |
|
| 5640 | 5960 | |
| 5641 | 5961 | // Set the header. |
| 5642 | 5962 | header($type); |
@@ -5668,8 +5988,9 @@ discard block |
||
| 5668 | 5988 | static $done = false; |
| 5669 | 5989 | |
| 5670 | 5990 | // If we don't need to do anything, don't |
| 5671 | - if (!$update && $done) |
|
| 5672 | - return; |
|
| 5991 | + if (!$update && $done) { |
|
| 5992 | + return; |
|
| 5993 | + } |
|
| 5673 | 5994 | |
| 5674 | 5995 | // Should we get a new copy of the official list of TLDs? |
| 5675 | 5996 | if ($update) |
@@ -5678,8 +5999,9 @@ discard block |
||
| 5678 | 5999 | $tlds = fetch_web_data('https://data.iana.org/TLD/tlds-alpha-by-domain.txt'); |
| 5679 | 6000 | |
| 5680 | 6001 | // 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. |
| 5681 | - if ($tlds === false) |
|
| 5682 | - $postapocalypticNightmare = true; |
|
| 6002 | + if ($tlds === false) { |
|
| 6003 | + $postapocalypticNightmare = true; |
|
| 6004 | + } |
|
| 5683 | 6005 | } |
| 5684 | 6006 | // If we aren't updating and the regex is valid, we're done |
| 5685 | 6007 | elseif (!empty($modSettings['tld_regex']) && @preg_match('~' . $modSettings['tld_regex'] . '~', null) !== false) |
@@ -5694,10 +6016,11 @@ discard block |
||
| 5694 | 6016 | // Clean $tlds and convert it to an array |
| 5695 | 6017 | $tlds = array_filter(explode("\n", strtolower($tlds)), function($line) { |
| 5696 | 6018 | $line = trim($line); |
| 5697 | - if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) |
|
| 5698 | - return false; |
|
| 5699 | - else |
|
| 5700 | - return true; |
|
| 6019 | + if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) { |
|
| 6020 | + return false; |
|
| 6021 | + } else { |
|
| 6022 | + return true; |
|
| 6023 | + } |
|
| 5701 | 6024 | }); |
| 5702 | 6025 | |
| 5703 | 6026 | // Convert Punycode to Unicode |
@@ -5751,8 +6074,9 @@ discard block |
||
| 5751 | 6074 | $idx += $digit * $w; |
| 5752 | 6075 | $t = ($k <= $bias) ? $tmin : (($k >= $bias + $tmax) ? $tmax : ($k - $bias)); |
| 5753 | 6076 | |
| 5754 | - if ($digit < $t) |
|
| 5755 | - break; |
|
| 6077 | + if ($digit < $t) { |
|
| 6078 | + break; |
|
| 6079 | + } |
|
| 5756 | 6080 | |
| 5757 | 6081 | $w = (int) ($w * ($base - $t)); |
| 5758 | 6082 | } |
@@ -5761,8 +6085,9 @@ discard block |
||
| 5761 | 6085 | $delta = intval($is_first ? ($delta / $damp) : ($delta / 2)); |
| 5762 | 6086 | $delta += intval($delta / ($deco_len + 1)); |
| 5763 | 6087 | |
| 5764 | - for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) |
|
| 5765 | - $delta = intval($delta / ($base - $tmin)); |
|
| 6088 | + for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) { |
|
| 6089 | + $delta = intval($delta / ($base - $tmin)); |
|
| 6090 | + } |
|
| 5766 | 6091 | |
| 5767 | 6092 | $bias = intval($k + ($base - $tmin + 1) * $delta / ($delta + $skew)); |
| 5768 | 6093 | $is_first = false; |
@@ -5771,8 +6096,9 @@ discard block |
||
| 5771 | 6096 | |
| 5772 | 6097 | if ($deco_len > 0) |
| 5773 | 6098 | { |
| 5774 | - for ($i = $deco_len; $i > $idx; $i--) |
|
| 5775 | - $decoded[$i] = $decoded[($i - 1)]; |
|
| 6099 | + for ($i = $deco_len; $i > $idx; $i--) { |
|
| 6100 | + $decoded[$i] = $decoded[($i - 1)]; |
|
| 6101 | + } |
|
| 5776 | 6102 | } |
| 5777 | 6103 | $decoded[$idx++] = $char; |
| 5778 | 6104 | } |
@@ -5780,24 +6106,29 @@ discard block |
||
| 5780 | 6106 | foreach ($decoded as $k => $v) |
| 5781 | 6107 | { |
| 5782 | 6108 | // 7bit are transferred literally |
| 5783 | - if ($v < 128) |
|
| 5784 | - $output .= chr($v); |
|
| 6109 | + if ($v < 128) { |
|
| 6110 | + $output .= chr($v); |
|
| 6111 | + } |
|
| 5785 | 6112 | |
| 5786 | 6113 | // 2 bytes |
| 5787 | - elseif ($v < (1 << 11)) |
|
| 5788 | - $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
| 6114 | + elseif ($v < (1 << 11)) { |
|
| 6115 | + $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
| 6116 | + } |
|
| 5789 | 6117 | |
| 5790 | 6118 | // 3 bytes |
| 5791 | - elseif ($v < (1 << 16)) |
|
| 5792 | - $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 6119 | + elseif ($v < (1 << 16)) { |
|
| 6120 | + $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 6121 | + } |
|
| 5793 | 6122 | |
| 5794 | 6123 | // 4 bytes |
| 5795 | - elseif ($v < (1 << 21)) |
|
| 5796 | - $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 6124 | + elseif ($v < (1 << 21)) { |
|
| 6125 | + $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 6126 | + } |
|
| 5797 | 6127 | |
| 5798 | 6128 | // 'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k |
| 5799 | - else |
|
| 5800 | - $output .= $safe_char; |
|
| 6129 | + else { |
|
| 6130 | + $output .= $safe_char; |
|
| 6131 | + } |
|
| 5801 | 6132 | } |
| 5802 | 6133 | |
| 5803 | 6134 | $output_parts[] = $output; |
@@ -5890,8 +6221,7 @@ discard block |
||
| 5890 | 6221 | |
| 5891 | 6222 | $strlen = 'mb_strlen'; |
| 5892 | 6223 | $substr = 'mb_substr'; |
| 5893 | - } |
|
| 5894 | - else |
|
| 6224 | + } else |
|
| 5895 | 6225 | { |
| 5896 | 6226 | $strlen = $smcFunc['strlen']; |
| 5897 | 6227 | $substr = $smcFunc['substr']; |
@@ -5905,20 +6235,21 @@ discard block |
||
| 5905 | 6235 | |
| 5906 | 6236 | $first = $substr($string, 0, 1); |
| 5907 | 6237 | |
| 5908 | - if (empty($index[$first])) |
|
| 5909 | - $index[$first] = array(); |
|
| 6238 | + if (empty($index[$first])) { |
|
| 6239 | + $index[$first] = array(); |
|
| 6240 | + } |
|
| 5910 | 6241 | |
| 5911 | 6242 | if ($strlen($string) > 1) |
| 5912 | 6243 | { |
| 5913 | 6244 | // Sanity check on recursion |
| 5914 | - if ($depth > 99) |
|
| 5915 | - $index[$first][$substr($string, 1)] = ''; |
|
| 5916 | - |
|
| 5917 | - else |
|
| 5918 | - $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
| 6245 | + if ($depth > 99) { |
|
| 6246 | + $index[$first][$substr($string, 1)] = ''; |
|
| 6247 | + } else { |
|
| 6248 | + $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
| 6249 | + } |
|
| 6250 | + } else { |
|
| 6251 | + $index[$first][''] = ''; |
|
| 5919 | 6252 | } |
| 5920 | - else |
|
| 5921 | - $index[$first][''] = ''; |
|
| 5922 | 6253 | |
| 5923 | 6254 | $depth--; |
| 5924 | 6255 | return $index; |
@@ -5941,9 +6272,9 @@ discard block |
||
| 5941 | 6272 | $key_regex = preg_quote($key, $delim); |
| 5942 | 6273 | $new_key = $key; |
| 5943 | 6274 | |
| 5944 | - if (empty($value)) |
|
| 5945 | - $sub_regex = ''; |
|
| 5946 | - else |
|
| 6275 | + if (empty($value)) { |
|
| 6276 | + $sub_regex = ''; |
|
| 6277 | + } else |
|
| 5947 | 6278 | { |
| 5948 | 6279 | $sub_regex = $index_to_regex($value, $delim); |
| 5949 | 6280 | |
@@ -5951,22 +6282,22 @@ discard block |
||
| 5951 | 6282 | { |
| 5952 | 6283 | $new_key_array = explode('(?'.'>', $sub_regex); |
| 5953 | 6284 | $new_key .= $new_key_array[0]; |
| 6285 | + } else { |
|
| 6286 | + $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
| 5954 | 6287 | } |
| 5955 | - else |
|
| 5956 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
| 5957 | 6288 | } |
| 5958 | 6289 | |
| 5959 | - if ($depth > 1) |
|
| 5960 | - $regex[$new_key] = $key_regex . $sub_regex; |
|
| 5961 | - else |
|
| 6290 | + if ($depth > 1) { |
|
| 6291 | + $regex[$new_key] = $key_regex . $sub_regex; |
|
| 6292 | + } else |
|
| 5962 | 6293 | { |
| 5963 | 6294 | if (($length += strlen($key_regex) + 1) < $max_length || empty($regex)) |
| 5964 | 6295 | { |
| 5965 | 6296 | $regex[$new_key] = $key_regex . $sub_regex; |
| 5966 | 6297 | unset($index[$key]); |
| 6298 | + } else { |
|
| 6299 | + break; |
|
| 5967 | 6300 | } |
| 5968 | - else |
|
| 5969 | - break; |
|
| 5970 | 6301 | } |
| 5971 | 6302 | } |
| 5972 | 6303 | |
@@ -5975,10 +6306,11 @@ discard block |
||
| 5975 | 6306 | $l1 = $strlen($k1); |
| 5976 | 6307 | $l2 = $strlen($k2); |
| 5977 | 6308 | |
| 5978 | - if ($l1 == $l2) |
|
| 5979 | - return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
| 5980 | - else |
|
| 5981 | - return $l1 > $l2 ? -1 : 1; |
|
| 6309 | + if ($l1 == $l2) { |
|
| 6310 | + return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
| 6311 | + } else { |
|
| 6312 | + return $l1 > $l2 ? -1 : 1; |
|
| 6313 | + } |
|
| 5982 | 6314 | }); |
| 5983 | 6315 | |
| 5984 | 6316 | $depth--; |
@@ -5989,21 +6321,24 @@ discard block |
||
| 5989 | 6321 | $index = array(); |
| 5990 | 6322 | $regex = ''; |
| 5991 | 6323 | |
| 5992 | - foreach ($strings as $string) |
|
| 5993 | - $index = $add_string_to_index($string, $index); |
|
| 6324 | + foreach ($strings as $string) { |
|
| 6325 | + $index = $add_string_to_index($string, $index); |
|
| 6326 | + } |
|
| 5994 | 6327 | |
| 5995 | 6328 | if ($returnArray === true) |
| 5996 | 6329 | { |
| 5997 | 6330 | $regex = array(); |
| 5998 | - while (!empty($index)) |
|
| 5999 | - $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6331 | + while (!empty($index)) { |
|
| 6332 | + $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6333 | + } |
|
| 6334 | + } else { |
|
| 6335 | + $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6000 | 6336 | } |
| 6001 | - else |
|
| 6002 | - $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6003 | 6337 | |
| 6004 | 6338 | // Restore PHP's internal character encoding to whatever it was originally |
| 6005 | - if (!empty($current_encoding)) |
|
| 6006 | - mb_internal_encoding($current_encoding); |
|
| 6339 | + if (!empty($current_encoding)) { |
|
| 6340 | + mb_internal_encoding($current_encoding); |
|
| 6341 | + } |
|
| 6007 | 6342 | |
| 6008 | 6343 | return $regex; |
| 6009 | 6344 | } |
@@ -6043,13 +6378,15 @@ discard block |
||
| 6043 | 6378 | // Need to add the trailing slash, or it puts it there & thinks there's a redirect when there isn't... |
| 6044 | 6379 | $url = str_ireplace('https://', 'http://', $url) . '/'; |
| 6045 | 6380 | $headers = @get_headers($url); |
| 6046 | - if ($headers === false) |
|
| 6047 | - return false; |
|
| 6381 | + if ($headers === false) { |
|
| 6382 | + return false; |
|
| 6383 | + } |
|
| 6048 | 6384 | |
| 6049 | 6385 | // Now to see if it came back https... |
| 6050 | 6386 | // First check for a redirect status code in first row (301, 302, 307) |
| 6051 | - if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false) |
|
| 6052 | - return false; |
|
| 6387 | + if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false) { |
|
| 6388 | + return false; |
|
| 6389 | + } |
|
| 6053 | 6390 | |
| 6054 | 6391 | // Search for the location entry to confirm https |
| 6055 | 6392 | $result = false; |
@@ -6085,8 +6422,7 @@ discard block |
||
| 6085 | 6422 | $is_admin = $user_info['is_admin']; |
| 6086 | 6423 | $mod_cache = !empty($user_info['mod_cache']) ? $user_info['mod_cache'] : null; |
| 6087 | 6424 | $ignoreboards = !empty($user_info['ignoreboards']) ? $user_info['ignoreboards'] : null; |
| 6088 | - } |
|
| 6089 | - else |
|
| 6425 | + } else |
|
| 6090 | 6426 | { |
| 6091 | 6427 | $request = $smcFunc['db_query']('', ' |
| 6092 | 6428 | SELECT mem.ignore_boards, mem.id_group, mem.additional_groups, mem.id_post_group |
@@ -6100,17 +6436,19 @@ discard block |
||
| 6100 | 6436 | |
| 6101 | 6437 | $row = $smcFunc['db_fetch_assoc']($request); |
| 6102 | 6438 | |
| 6103 | - if (empty($row['additional_groups'])) |
|
| 6104 | - $groups = array($row['id_group'], $user_settings['id_post_group']); |
|
| 6105 | - else |
|
| 6106 | - $groups = array_merge( |
|
| 6439 | + if (empty($row['additional_groups'])) { |
|
| 6440 | + $groups = array($row['id_group'], $user_settings['id_post_group']); |
|
| 6441 | + } else { |
|
| 6442 | + $groups = array_merge( |
|
| 6107 | 6443 | array($row['id_group'], $user_settings['id_post_group']), |
| 6108 | 6444 | explode(',', $row['additional_groups']) |
| 6109 | 6445 | ); |
| 6446 | + } |
|
| 6110 | 6447 | |
| 6111 | 6448 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
| 6112 | - foreach ($groups as $k => $v) |
|
| 6113 | - $groups[$k] = (int) $v; |
|
| 6449 | + foreach ($groups as $k => $v) { |
|
| 6450 | + $groups[$k] = (int) $v; |
|
| 6451 | + } |
|
| 6114 | 6452 | |
| 6115 | 6453 | $is_admin = in_array(1, $groups); |
| 6116 | 6454 | |
@@ -6127,8 +6465,9 @@ discard block |
||
| 6127 | 6465 | 'current_member' => $userid, |
| 6128 | 6466 | ) |
| 6129 | 6467 | ); |
| 6130 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 6131 | - $boards_mod[] = $row['id_board']; |
|
| 6468 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 6469 | + $boards_mod[] = $row['id_board']; |
|
| 6470 | + } |
|
| 6132 | 6471 | $smcFunc['db_free_result']($request); |
| 6133 | 6472 | |
| 6134 | 6473 | // Can any of the groups they're in moderate any of the boards? |
@@ -6140,8 +6479,9 @@ discard block |
||
| 6140 | 6479 | 'groups' => $groups, |
| 6141 | 6480 | ) |
| 6142 | 6481 | ); |
| 6143 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 6144 | - $boards_mod[] = $row['id_board']; |
|
| 6482 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 6483 | + $boards_mod[] = $row['id_board']; |
|
| 6484 | + } |
|
| 6145 | 6485 | $smcFunc['db_free_result']($request); |
| 6146 | 6486 | |
| 6147 | 6487 | // Just in case we've got duplicates here... |
@@ -6151,21 +6491,25 @@ discard block |
||
| 6151 | 6491 | } |
| 6152 | 6492 | |
| 6153 | 6493 | // Just build this here, it makes it easier to change/use - administrators can see all boards. |
| 6154 | - if ($is_admin) |
|
| 6155 | - $query_part['query_see_board'] = '1=1'; |
|
| 6494 | + if ($is_admin) { |
|
| 6495 | + $query_part['query_see_board'] = '1=1'; |
|
| 6496 | + } |
|
| 6156 | 6497 | // Otherwise just the groups in $user_info['groups']. |
| 6157 | - else |
|
| 6158 | - $query_part['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $groups) . ', b.member_groups) != 0)' . (!empty($deny_boards_access) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $groups) . ', b.deny_member_groups) = 0)' : '') . (isset($mod_cache) ? ' OR ' . $mod_cache['mq'] : '') . ')'; |
|
| 6498 | + else { |
|
| 6499 | + $query_part['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $groups) . ', b.member_groups) != 0)' . (!empty($deny_boards_access) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $groups) . ', b.deny_member_groups) = 0)' : '') . (isset($mod_cache) ? ' OR ' . $mod_cache['mq'] : '') . ')'; |
|
| 6500 | + } |
|
| 6159 | 6501 | |
| 6160 | 6502 | // Build the list of boards they WANT to see. |
| 6161 | 6503 | // This will take the place of query_see_boards in certain spots, so it better include the boards they can see also |
| 6162 | 6504 | |
| 6163 | 6505 | // If they aren't ignoring any boards then they want to see all the boards they can see |
| 6164 | - if (empty($ignoreboards)) |
|
| 6165 | - $query_part['query_wanna_see_board'] = $query_part['query_see_board']; |
|
| 6506 | + if (empty($ignoreboards)) { |
|
| 6507 | + $query_part['query_wanna_see_board'] = $query_part['query_see_board']; |
|
| 6508 | + } |
|
| 6166 | 6509 | // Ok I guess they don't want to see all the boards |
| 6167 | - else |
|
| 6168 | - $query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))'; |
|
| 6510 | + else { |
|
| 6511 | + $query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))'; |
|
| 6512 | + } |
|
| 6169 | 6513 | |
| 6170 | 6514 | return $query_part; |
| 6171 | 6515 | } |
@@ -5495,7 +5495,6 @@ discard block |
||
| 5495 | 5495 | |
| 5496 | 5496 | /** |
| 5497 | 5497 | * Tries different modes to make file/dirs writable. Wrapper function for chmod() |
| 5498 | - |
|
| 5499 | 5498 | * @param string $file The file/dir full path. |
| 5500 | 5499 | * @param int $value Not needed, added for legacy reasons. |
| 5501 | 5500 | * @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. |
@@ -5535,7 +5534,6 @@ discard block |
||
| 5535 | 5534 | |
| 5536 | 5535 | /** |
| 5537 | 5536 | * Wrapper function for json_decode() with error handling. |
| 5538 | - |
|
| 5539 | 5537 | * @param string $json The string to decode. |
| 5540 | 5538 | * @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. |
| 5541 | 5539 | * @param bool $logIt To specify if the error will be logged if theres any. |
@@ -6028,7 +6026,7 @@ discard block |
||
| 6028 | 6026 | $cont = stream_context_get_params($read); |
| 6029 | 6027 | $result = isset($cont['options']['ssl']['peer_certificate']) ? true : false; |
| 6030 | 6028 | } |
| 6031 | - return $result; |
|
| 6029 | + return $result; |
|
| 6032 | 6030 | } |
| 6033 | 6031 | |
| 6034 | 6032 | /** |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | { |
| 387 | 387 | $val = 'CASE '; |
| 388 | 388 | foreach ($members as $k => $v) |
| 389 | - $val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
| 389 | + $val .= 'WHEN id_member = ' . $v . ' THEN ' . count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
| 390 | 390 | $val = $val . ' END'; |
| 391 | 391 | $type = 'raw'; |
| 392 | 392 | } |
@@ -817,7 +817,7 @@ discard block |
||
| 817 | 817 | $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
| 818 | 818 | if (empty($unsupportedFormats)) |
| 819 | 819 | { |
| 820 | - foreach($strftimeFormatSubstitutions as $format => $substitution) |
|
| 820 | + foreach ($strftimeFormatSubstitutions as $format => $substitution) |
|
| 821 | 821 | { |
| 822 | 822 | $value = @strftime('%' . $format); |
| 823 | 823 | |
@@ -1182,7 +1182,7 @@ discard block |
||
| 1182 | 1182 | 'height' => array('optional' => true, 'match' => '(\d+)'), |
| 1183 | 1183 | ), |
| 1184 | 1184 | 'content' => '$1', |
| 1185 | - 'validate' => function (&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt) |
|
| 1185 | + 'validate' => function(&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt) |
|
| 1186 | 1186 | { |
| 1187 | 1187 | $returnContext = ''; |
| 1188 | 1188 | |
@@ -1217,7 +1217,7 @@ discard block |
||
| 1217 | 1217 | } |
| 1218 | 1218 | |
| 1219 | 1219 | if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) |
| 1220 | - $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>'; |
|
| 1220 | + $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>'; |
|
| 1221 | 1221 | else |
| 1222 | 1222 | $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
| 1223 | 1223 | } |
@@ -1246,7 +1246,7 @@ discard block |
||
| 1246 | 1246 | 'type' => 'unparsed_content', |
| 1247 | 1247 | '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>', |
| 1248 | 1248 | // @todo Maybe this can be simplified? |
| 1249 | - 'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context) |
|
| 1249 | + 'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context) |
|
| 1250 | 1250 | { |
| 1251 | 1251 | if (!isset($disabled['code'])) |
| 1252 | 1252 | { |
@@ -1283,7 +1283,7 @@ discard block |
||
| 1283 | 1283 | 'type' => 'unparsed_equals_content', |
| 1284 | 1284 | '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>', |
| 1285 | 1285 | // @todo Maybe this can be simplified? |
| 1286 | - 'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context) |
|
| 1286 | + 'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context) |
|
| 1287 | 1287 | { |
| 1288 | 1288 | if (!isset($disabled['code'])) |
| 1289 | 1289 | { |
@@ -1327,7 +1327,7 @@ discard block |
||
| 1327 | 1327 | 'type' => 'unparsed_content', |
| 1328 | 1328 | 'content' => '<a href="mailto:$1" class="bbc_email">$1</a>', |
| 1329 | 1329 | // @todo Should this respect guest_hideContacts? |
| 1330 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1330 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1331 | 1331 | { |
| 1332 | 1332 | $data = strtr($data, array('<br>' => '')); |
| 1333 | 1333 | }, |
@@ -1346,7 +1346,7 @@ discard block |
||
| 1346 | 1346 | 'type' => 'unparsed_commas_content', |
| 1347 | 1347 | 'test' => '\d+,\d+\]', |
| 1348 | 1348 | 'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">', |
| 1349 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1349 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1350 | 1350 | { |
| 1351 | 1351 | if (isset($disabled['url'])) |
| 1352 | 1352 | $tag['content'] = '$1'; |
@@ -1362,7 +1362,7 @@ discard block |
||
| 1362 | 1362 | 'test' => '(left|right)(\s+max=\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)?\]', |
| 1363 | 1363 | 'before' => '<div $1>', |
| 1364 | 1364 | 'after' => '</div>', |
| 1365 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1365 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1366 | 1366 | { |
| 1367 | 1367 | $class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"'; |
| 1368 | 1368 | |
@@ -1411,7 +1411,7 @@ discard block |
||
| 1411 | 1411 | 'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'), |
| 1412 | 1412 | ), |
| 1413 | 1413 | 'content' => '<img src="$1" alt="{alt}" title="{title}"{width}{height} class="bbc_img resized">', |
| 1414 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1414 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1415 | 1415 | { |
| 1416 | 1416 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
| 1417 | 1417 | |
@@ -1434,7 +1434,7 @@ discard block |
||
| 1434 | 1434 | 'tag' => 'img', |
| 1435 | 1435 | 'type' => 'unparsed_content', |
| 1436 | 1436 | 'content' => '<img src="$1" alt="" class="bbc_img">', |
| 1437 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1437 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1438 | 1438 | { |
| 1439 | 1439 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
| 1440 | 1440 | |
@@ -1457,7 +1457,7 @@ discard block |
||
| 1457 | 1457 | 'tag' => 'iurl', |
| 1458 | 1458 | 'type' => 'unparsed_content', |
| 1459 | 1459 | 'content' => '<a href="$1" class="bbc_link">$1</a>', |
| 1460 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1460 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1461 | 1461 | { |
| 1462 | 1462 | $data = strtr($data, array('<br>' => '')); |
| 1463 | 1463 | $scheme = parse_url($data, PHP_URL_SCHEME); |
@@ -1471,7 +1471,7 @@ discard block |
||
| 1471 | 1471 | 'quoted' => 'optional', |
| 1472 | 1472 | 'before' => '<a href="$1" class="bbc_link">', |
| 1473 | 1473 | 'after' => '</a>', |
| 1474 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1474 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1475 | 1475 | { |
| 1476 | 1476 | if (substr($data, 0, 1) == '#') |
| 1477 | 1477 | $data = '#post_' . substr($data, 1); |
@@ -1551,7 +1551,7 @@ discard block |
||
| 1551 | 1551 | 'tag' => 'php', |
| 1552 | 1552 | 'type' => 'unparsed_content', |
| 1553 | 1553 | 'content' => '<span class="phpcode">$1</span>', |
| 1554 | - 'validate' => isset($disabled['php']) ? null : function (&$tag, &$data, $disabled) |
|
| 1554 | + 'validate' => isset($disabled['php']) ? null : function(&$tag, &$data, $disabled) |
|
| 1555 | 1555 | { |
| 1556 | 1556 | if (!isset($disabled['php'])) |
| 1557 | 1557 | { |
@@ -1649,7 +1649,7 @@ discard block |
||
| 1649 | 1649 | 'test' => '[1-7]\]', |
| 1650 | 1650 | 'before' => '<span style="font-size: $1;" class="bbc_size">', |
| 1651 | 1651 | 'after' => '</span>', |
| 1652 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1652 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1653 | 1653 | { |
| 1654 | 1654 | $sizes = array(1 => 0.7, 2 => 1.0, 3 => 1.35, 4 => 1.45, 5 => 2.0, 6 => 2.65, 7 => 3.95); |
| 1655 | 1655 | $data = $sizes[$data] . 'em'; |
@@ -1687,7 +1687,7 @@ discard block |
||
| 1687 | 1687 | 'tag' => 'time', |
| 1688 | 1688 | 'type' => 'unparsed_content', |
| 1689 | 1689 | 'content' => '$1', |
| 1690 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1690 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1691 | 1691 | { |
| 1692 | 1692 | if (is_numeric($data)) |
| 1693 | 1693 | $data = timeformat($data); |
@@ -1715,7 +1715,7 @@ discard block |
||
| 1715 | 1715 | 'tag' => 'url', |
| 1716 | 1716 | 'type' => 'unparsed_content', |
| 1717 | 1717 | 'content' => '<a href="$1" class="bbc_link" target="_blank">$1</a>', |
| 1718 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1718 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1719 | 1719 | { |
| 1720 | 1720 | $data = strtr($data, array('<br>' => '')); |
| 1721 | 1721 | $scheme = parse_url($data, PHP_URL_SCHEME); |
@@ -1729,7 +1729,7 @@ discard block |
||
| 1729 | 1729 | 'quoted' => 'optional', |
| 1730 | 1730 | 'before' => '<a href="$1" class="bbc_link" target="_blank">', |
| 1731 | 1731 | 'after' => '</a>', |
| 1732 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1732 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1733 | 1733 | { |
| 1734 | 1734 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1735 | 1735 | if (empty($scheme)) |
@@ -1755,7 +1755,7 @@ discard block |
||
| 1755 | 1755 | { |
| 1756 | 1756 | if (isset($temp_bbc)) |
| 1757 | 1757 | $bbc_codes = $temp_bbc; |
| 1758 | - usort($codes, function ($a, $b) { |
|
| 1758 | + usort($codes, function($a, $b) { |
|
| 1759 | 1759 | return strcmp($a['tag'], $b['tag']); |
| 1760 | 1760 | }); |
| 1761 | 1761 | return $codes; |
@@ -1992,7 +1992,7 @@ discard block |
||
| 1992 | 1992 | # a run of Unicode domain name characters and a dot |
| 1993 | 1993 | [\p{L}\p{M}\p{N}\-.:@]+\. |
| 1994 | 1994 | # and then a TLD valid in the DNS or the reserved "local" TLD |
| 1995 | - (?:'. $modSettings['tld_regex'] .'|local) |
|
| 1995 | + (?:'. $modSettings['tld_regex'] . '|local) |
|
| 1996 | 1996 | ) |
| 1997 | 1997 | # followed by a non-domain character or end of line |
| 1998 | 1998 | (?=[^\p{L}\p{N}\-.]|$) |
@@ -2060,7 +2060,7 @@ discard block |
||
| 2060 | 2060 | )? |
| 2061 | 2061 | '; |
| 2062 | 2062 | |
| 2063 | - $data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function ($matches) { |
|
| 2063 | + $data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function($matches) { |
|
| 2064 | 2064 | $url = array_shift($matches); |
| 2065 | 2065 | |
| 2066 | 2066 | $scheme = parse_url($url, PHP_URL_SCHEME); |
@@ -2800,7 +2800,7 @@ discard block |
||
| 2800 | 2800 | for ($i = 0, $n = count($smileysfrom); $i < $n; $i++) |
| 2801 | 2801 | { |
| 2802 | 2802 | $specialChars = $smcFunc['htmlspecialchars']($smileysfrom[$i], ENT_QUOTES); |
| 2803 | - $smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')). '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" class="smiley">'; |
|
| 2803 | + $smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" class="smiley">'; |
|
| 2804 | 2804 | |
| 2805 | 2805 | $smileyPregReplacements[$smileysfrom[$i]] = $smileyCode; |
| 2806 | 2806 | |
@@ -2817,7 +2817,7 @@ discard block |
||
| 2817 | 2817 | |
| 2818 | 2818 | // Replace away! |
| 2819 | 2819 | $message = preg_replace_callback($smileyPregSearch, |
| 2820 | - function ($matches) use ($smileyPregReplacements) |
|
| 2820 | + function($matches) use ($smileyPregReplacements) |
|
| 2821 | 2821 | { |
| 2822 | 2822 | return $smileyPregReplacements[$matches[1]]; |
| 2823 | 2823 | }, $message); |
@@ -2883,13 +2883,13 @@ discard block |
||
| 2883 | 2883 | { |
| 2884 | 2884 | if (defined('SID') && SID != '') |
| 2885 | 2885 | $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
| 2886 | - function ($m) use ($scripturl) |
|
| 2886 | + function($m) use ($scripturl) |
|
| 2887 | 2887 | { |
| 2888 | - return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
|
| 2888 | + return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID . (isset($m[2]) ? "$m[2]" : ""); |
|
| 2889 | 2889 | }, $setLocation); |
| 2890 | 2890 | else |
| 2891 | 2891 | $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
| 2892 | - function ($m) use ($scripturl) |
|
| 2892 | + function($m) use ($scripturl) |
|
| 2893 | 2893 | { |
| 2894 | 2894 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
| 2895 | 2895 | }, $setLocation); |
@@ -3212,7 +3212,7 @@ discard block |
||
| 3212 | 3212 | |
| 3213 | 3213 | // Add a generic "Are you sure?" confirmation message. |
| 3214 | 3214 | addInlineJavaScript(' |
| 3215 | - var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
|
| 3215 | + var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) . ';'); |
|
| 3216 | 3216 | |
| 3217 | 3217 | // Now add the capping code for avatars. |
| 3218 | 3218 | 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') |
@@ -3573,7 +3573,7 @@ discard block |
||
| 3573 | 3573 | |
| 3574 | 3574 | else |
| 3575 | 3575 | echo ' |
| 3576 | - <script src="', $settings['theme_url'] ,'/scripts/minified', ($do_deferred ? '_deferred' : '') ,'.js', $minSeed ,'"></script>'; |
|
| 3576 | + <script src="', $settings['theme_url'], '/scripts/minified', ($do_deferred ? '_deferred' : ''), '.js', $minSeed, '"></script>'; |
|
| 3577 | 3577 | } |
| 3578 | 3578 | |
| 3579 | 3579 | // Inline JavaScript - Actually useful some times! |
@@ -3651,14 +3651,14 @@ discard block |
||
| 3651 | 3651 | |
| 3652 | 3652 | else |
| 3653 | 3653 | echo ' |
| 3654 | - <link rel="stylesheet" href="', $settings['theme_url'] ,'/css/minified.css', $minSeed ,'">'; |
|
| 3654 | + <link rel="stylesheet" href="', $settings['theme_url'], '/css/minified.css', $minSeed, '">'; |
|
| 3655 | 3655 | } |
| 3656 | 3656 | |
| 3657 | 3657 | // Print the rest after the minified files. |
| 3658 | 3658 | if (!empty($normal)) |
| 3659 | 3659 | foreach ($normal as $nf) |
| 3660 | 3660 | echo ' |
| 3661 | - <link rel="stylesheet" href="', $nf ,'">'; |
|
| 3661 | + <link rel="stylesheet" href="', $nf, '">'; |
|
| 3662 | 3662 | |
| 3663 | 3663 | if ($db_show_debug === true) |
| 3664 | 3664 | { |
@@ -3674,7 +3674,7 @@ discard block |
||
| 3674 | 3674 | <style>'; |
| 3675 | 3675 | |
| 3676 | 3676 | foreach ($context['css_header'] as $css) |
| 3677 | - echo $css .' |
|
| 3677 | + echo $css . ' |
|
| 3678 | 3678 | '; |
| 3679 | 3679 | |
| 3680 | 3680 | echo' |
@@ -3703,27 +3703,27 @@ discard block |
||
| 3703 | 3703 | return false; |
| 3704 | 3704 | |
| 3705 | 3705 | // Did we already did this? |
| 3706 | - $toCache = cache_get_data('minimized_'. $settings['theme_id'] .'_'. $type, 86400); |
|
| 3706 | + $toCache = cache_get_data('minimized_' . $settings['theme_id'] . '_' . $type, 86400); |
|
| 3707 | 3707 | |
| 3708 | 3708 | // Already done? |
| 3709 | 3709 | if (!empty($toCache)) |
| 3710 | 3710 | return true; |
| 3711 | 3711 | |
| 3712 | 3712 | // No namespaces, sorry! |
| 3713 | - $classType = 'MatthiasMullie\\Minify\\'. strtoupper($type); |
|
| 3713 | + $classType = 'MatthiasMullie\\Minify\\' . strtoupper($type); |
|
| 3714 | 3714 | |
| 3715 | 3715 | // Temp path. |
| 3716 | - $cTempPath = $settings['theme_dir'] .'/'. ($type == 'css' ? 'css' : 'scripts') .'/'; |
|
| 3716 | + $cTempPath = $settings['theme_dir'] . '/' . ($type == 'css' ? 'css' : 'scripts') . '/'; |
|
| 3717 | 3717 | |
| 3718 | 3718 | // What kind of file are we going to create? |
| 3719 | - $toCreate = $cTempPath .'minified'. ($do_deferred ? '_deferred' : '') .'.'. $type; |
|
| 3719 | + $toCreate = $cTempPath . 'minified' . ($do_deferred ? '_deferred' : '') . '.' . $type; |
|
| 3720 | 3720 | |
| 3721 | 3721 | // File has to exists, if it isn't try to create it. |
| 3722 | 3722 | if ((!file_exists($toCreate) && @fopen($toCreate, 'w') === false) || !smf_chmod($toCreate)) |
| 3723 | 3723 | { |
| 3724 | 3724 | loadLanguage('Errors'); |
| 3725 | 3725 | log_error(sprintf($txt['file_not_created'], $toCreate), 'general'); |
| 3726 | - cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, null); |
|
| 3726 | + cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, null); |
|
| 3727 | 3727 | |
| 3728 | 3728 | // The process failed so roll back to print each individual file. |
| 3729 | 3729 | return $data; |
@@ -3758,14 +3758,14 @@ discard block |
||
| 3758 | 3758 | { |
| 3759 | 3759 | loadLanguage('Errors'); |
| 3760 | 3760 | log_error(sprintf($txt['file_not_created'], $toCreate), 'general'); |
| 3761 | - cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, null); |
|
| 3761 | + cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, null); |
|
| 3762 | 3762 | |
| 3763 | 3763 | // The process failed so roll back to print each individual file. |
| 3764 | 3764 | return $data; |
| 3765 | 3765 | } |
| 3766 | 3766 | |
| 3767 | 3767 | // And create a long lived cache entry. |
| 3768 | - cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, $toCreate, 86400); |
|
| 3768 | + cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, $toCreate, 86400); |
|
| 3769 | 3769 | |
| 3770 | 3770 | return true; |
| 3771 | 3771 | } |
@@ -3825,7 +3825,7 @@ discard block |
||
| 3825 | 3825 | else |
| 3826 | 3826 | $path = $modSettings['attachmentUploadDir']; |
| 3827 | 3827 | |
| 3828 | - return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
|
| 3828 | + return $path . '/' . $attachment_id . '_' . $file_hash . '.dat'; |
|
| 3829 | 3829 | } |
| 3830 | 3830 | |
| 3831 | 3831 | /** |
@@ -3869,10 +3869,10 @@ discard block |
||
| 3869 | 3869 | $valid_low = isValidIP($ip_parts[0]); |
| 3870 | 3870 | $valid_high = isValidIP($ip_parts[1]); |
| 3871 | 3871 | $count = 0; |
| 3872 | - $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
|
| 3872 | + $mode = (preg_match('/:/', $ip_parts[0]) > 0 ? ':' : '.'); |
|
| 3873 | 3873 | $max = ($mode == ':' ? 'ffff' : '255'); |
| 3874 | 3874 | $min = 0; |
| 3875 | - if(!$valid_low) |
|
| 3875 | + if (!$valid_low) |
|
| 3876 | 3876 | { |
| 3877 | 3877 | $ip_parts[0] = preg_replace('/\*/', '0', $ip_parts[0]); |
| 3878 | 3878 | $valid_low = isValidIP($ip_parts[0]); |
@@ -3886,7 +3886,7 @@ discard block |
||
| 3886 | 3886 | } |
| 3887 | 3887 | |
| 3888 | 3888 | $count = 0; |
| 3889 | - if(!$valid_high) |
|
| 3889 | + if (!$valid_high) |
|
| 3890 | 3890 | { |
| 3891 | 3891 | $ip_parts[1] = preg_replace('/\*/', $max, $ip_parts[1]); |
| 3892 | 3892 | $valid_high = isValidIP($ip_parts[1]); |
@@ -3899,7 +3899,7 @@ discard block |
||
| 3899 | 3899 | } |
| 3900 | 3900 | } |
| 3901 | 3901 | |
| 3902 | - if($valid_high && $valid_low) |
|
| 3902 | + if ($valid_high && $valid_low) |
|
| 3903 | 3903 | { |
| 3904 | 3904 | $ip_array['low'] = $ip_parts[0]; |
| 3905 | 3905 | $ip_array['high'] = $ip_parts[1]; |
@@ -4081,7 +4081,7 @@ discard block |
||
| 4081 | 4081 | addInlineJavaScript(' |
| 4082 | 4082 | var user_menus = new smc_PopupMenu(); |
| 4083 | 4083 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
| 4084 | - user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
|
| 4084 | + user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u=' . $context['user']['id'] . '");', true); |
|
| 4085 | 4085 | if ($context['allow_pm']) |
| 4086 | 4086 | addInlineJavaScript(' |
| 4087 | 4087 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
@@ -4701,7 +4701,7 @@ discard block |
||
| 4701 | 4701 | // No? try a fallback to $sourcedir |
| 4702 | 4702 | else |
| 4703 | 4703 | { |
| 4704 | - $absPath = $sourcedir .'/'. $file; |
|
| 4704 | + $absPath = $sourcedir . '/' . $file; |
|
| 4705 | 4705 | |
| 4706 | 4706 | if (file_exists($absPath)) |
| 4707 | 4707 | require_once($absPath); |
@@ -4782,15 +4782,15 @@ discard block |
||
| 4782 | 4782 | |
| 4783 | 4783 | // UTF-8 occurences of MS special characters |
| 4784 | 4784 | $findchars_utf8 = array( |
| 4785 | - "\xe2\x80\x9a", // single low-9 quotation mark |
|
| 4786 | - "\xe2\x80\x9e", // double low-9 quotation mark |
|
| 4787 | - "\xe2\x80\xa6", // horizontal ellipsis |
|
| 4788 | - "\xe2\x80\x98", // left single curly quote |
|
| 4789 | - "\xe2\x80\x99", // right single curly quote |
|
| 4790 | - "\xe2\x80\x9c", // left double curly quote |
|
| 4791 | - "\xe2\x80\x9d", // right double curly quote |
|
| 4792 | - "\xe2\x80\x93", // en dash |
|
| 4793 | - "\xe2\x80\x94", // em dash |
|
| 4785 | + "\xe2\x80\x9a", // single low-9 quotation mark |
|
| 4786 | + "\xe2\x80\x9e", // double low-9 quotation mark |
|
| 4787 | + "\xe2\x80\xa6", // horizontal ellipsis |
|
| 4788 | + "\xe2\x80\x98", // left single curly quote |
|
| 4789 | + "\xe2\x80\x99", // right single curly quote |
|
| 4790 | + "\xe2\x80\x9c", // left double curly quote |
|
| 4791 | + "\xe2\x80\x9d", // right double curly quote |
|
| 4792 | + "\xe2\x80\x93", // en dash |
|
| 4793 | + "\xe2\x80\x94", // em dash |
|
| 4794 | 4794 | ); |
| 4795 | 4795 | |
| 4796 | 4796 | // windows 1252 / iso equivalents |
@@ -4808,15 +4808,15 @@ discard block |
||
| 4808 | 4808 | |
| 4809 | 4809 | // safe replacements |
| 4810 | 4810 | $replacechars = array( |
| 4811 | - ',', // ‚ |
|
| 4812 | - ',,', // „ |
|
| 4813 | - '...', // … |
|
| 4814 | - "'", // ‘ |
|
| 4815 | - "'", // ’ |
|
| 4816 | - '"', // “ |
|
| 4817 | - '"', // ” |
|
| 4818 | - '-', // – |
|
| 4819 | - '--', // — |
|
| 4811 | + ',', // ‚ |
|
| 4812 | + ',,', // „ |
|
| 4813 | + '...', // … |
|
| 4814 | + "'", // ‘ |
|
| 4815 | + "'", // ’ |
|
| 4816 | + '"', // “ |
|
| 4817 | + '"', // ” |
|
| 4818 | + '-', // – |
|
| 4819 | + '--', // — |
|
| 4820 | 4820 | ); |
| 4821 | 4821 | |
| 4822 | 4822 | if ($context['utf8']) |
@@ -5234,7 +5234,7 @@ discard block |
||
| 5234 | 5234 | */ |
| 5235 | 5235 | function inet_dtop($bin) |
| 5236 | 5236 | { |
| 5237 | - if(empty($bin)) |
|
| 5237 | + if (empty($bin)) |
|
| 5238 | 5238 | return ''; |
| 5239 | 5239 | |
| 5240 | 5240 | global $db_type; |
@@ -5265,28 +5265,28 @@ discard block |
||
| 5265 | 5265 | */ |
| 5266 | 5266 | function _safe_serialize($value) |
| 5267 | 5267 | { |
| 5268 | - if(is_null($value)) |
|
| 5268 | + if (is_null($value)) |
|
| 5269 | 5269 | return 'N;'; |
| 5270 | 5270 | |
| 5271 | - if(is_bool($value)) |
|
| 5272 | - return 'b:'. (int) $value .';'; |
|
| 5271 | + if (is_bool($value)) |
|
| 5272 | + return 'b:' . (int) $value . ';'; |
|
| 5273 | 5273 | |
| 5274 | - if(is_int($value)) |
|
| 5275 | - return 'i:'. $value .';'; |
|
| 5274 | + if (is_int($value)) |
|
| 5275 | + return 'i:' . $value . ';'; |
|
| 5276 | 5276 | |
| 5277 | - if(is_float($value)) |
|
| 5278 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
| 5277 | + if (is_float($value)) |
|
| 5278 | + return 'd:' . str_replace(',', '.', $value) . ';'; |
|
| 5279 | 5279 | |
| 5280 | - if(is_string($value)) |
|
| 5281 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
| 5280 | + if (is_string($value)) |
|
| 5281 | + return 's:' . strlen($value) . ':"' . $value . '";'; |
|
| 5282 | 5282 | |
| 5283 | - if(is_array($value)) |
|
| 5283 | + if (is_array($value)) |
|
| 5284 | 5284 | { |
| 5285 | 5285 | $out = ''; |
| 5286 | - foreach($value as $k => $v) |
|
| 5286 | + foreach ($value as $k => $v) |
|
| 5287 | 5287 | $out .= _safe_serialize($k) . _safe_serialize($v); |
| 5288 | 5288 | |
| 5289 | - return 'a:'. count($value) .':{'. $out .'}'; |
|
| 5289 | + return 'a:' . count($value) . ':{' . $out . '}'; |
|
| 5290 | 5290 | } |
| 5291 | 5291 | |
| 5292 | 5292 | // safe_serialize cannot serialize resources or objects. |
@@ -5328,7 +5328,7 @@ discard block |
||
| 5328 | 5328 | function _safe_unserialize($str) |
| 5329 | 5329 | { |
| 5330 | 5330 | // Input is not a string. |
| 5331 | - if(empty($str) || !is_string($str)) |
|
| 5331 | + if (empty($str) || !is_string($str)) |
|
| 5332 | 5332 | return false; |
| 5333 | 5333 | |
| 5334 | 5334 | $stack = array(); |
@@ -5342,40 +5342,40 @@ discard block |
||
| 5342 | 5342 | * 3 - in array, expecting value or another array |
| 5343 | 5343 | */ |
| 5344 | 5344 | $state = 0; |
| 5345 | - while($state != 1) |
|
| 5345 | + while ($state != 1) |
|
| 5346 | 5346 | { |
| 5347 | 5347 | $type = isset($str[0]) ? $str[0] : ''; |
| 5348 | - if($type == '}') |
|
| 5348 | + if ($type == '}') |
|
| 5349 | 5349 | $str = substr($str, 1); |
| 5350 | 5350 | |
| 5351 | - else if($type == 'N' && $str[1] == ';') |
|
| 5351 | + else if ($type == 'N' && $str[1] == ';') |
|
| 5352 | 5352 | { |
| 5353 | 5353 | $value = null; |
| 5354 | 5354 | $str = substr($str, 2); |
| 5355 | 5355 | } |
| 5356 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 5356 | + else if ($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 5357 | 5357 | { |
| 5358 | 5358 | $value = $matches[1] == '1' ? true : false; |
| 5359 | 5359 | $str = substr($str, 4); |
| 5360 | 5360 | } |
| 5361 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 5361 | + else if ($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 5362 | 5362 | { |
| 5363 | - $value = (int)$matches[1]; |
|
| 5363 | + $value = (int) $matches[1]; |
|
| 5364 | 5364 | $str = $matches[2]; |
| 5365 | 5365 | } |
| 5366 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 5366 | + else if ($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 5367 | 5367 | { |
| 5368 | - $value = (float)$matches[1]; |
|
| 5368 | + $value = (float) $matches[1]; |
|
| 5369 | 5369 | $str = $matches[3]; |
| 5370 | 5370 | } |
| 5371 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
| 5371 | + else if ($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int) $matches[1], 2) == '";') |
|
| 5372 | 5372 | { |
| 5373 | - $value = substr($matches[2], 0, (int)$matches[1]); |
|
| 5374 | - $str = substr($matches[2], (int)$matches[1] + 2); |
|
| 5373 | + $value = substr($matches[2], 0, (int) $matches[1]); |
|
| 5374 | + $str = substr($matches[2], (int) $matches[1] + 2); |
|
| 5375 | 5375 | } |
| 5376 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 5376 | + else if ($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 5377 | 5377 | { |
| 5378 | - $expectedLength = (int)$matches[1]; |
|
| 5378 | + $expectedLength = (int) $matches[1]; |
|
| 5379 | 5379 | $str = $matches[2]; |
| 5380 | 5380 | } |
| 5381 | 5381 | |
@@ -5383,10 +5383,10 @@ discard block |
||
| 5383 | 5383 | else |
| 5384 | 5384 | return false; |
| 5385 | 5385 | |
| 5386 | - switch($state) |
|
| 5386 | + switch ($state) |
|
| 5387 | 5387 | { |
| 5388 | 5388 | case 3: // In array, expecting value or another array. |
| 5389 | - if($type == 'a') |
|
| 5389 | + if ($type == 'a') |
|
| 5390 | 5390 | { |
| 5391 | 5391 | $stack[] = &$list; |
| 5392 | 5392 | $list[$key] = array(); |
@@ -5395,7 +5395,7 @@ discard block |
||
| 5395 | 5395 | $state = 2; |
| 5396 | 5396 | break; |
| 5397 | 5397 | } |
| 5398 | - if($type != '}') |
|
| 5398 | + if ($type != '}') |
|
| 5399 | 5399 | { |
| 5400 | 5400 | $list[$key] = $value; |
| 5401 | 5401 | $state = 2; |
@@ -5406,29 +5406,29 @@ discard block |
||
| 5406 | 5406 | return false; |
| 5407 | 5407 | |
| 5408 | 5408 | case 2: // in array, expecting end of array or a key |
| 5409 | - if($type == '}') |
|
| 5409 | + if ($type == '}') |
|
| 5410 | 5410 | { |
| 5411 | 5411 | // Array size is less than expected. |
| 5412 | - if(count($list) < end($expected)) |
|
| 5412 | + if (count($list) < end($expected)) |
|
| 5413 | 5413 | return false; |
| 5414 | 5414 | |
| 5415 | 5415 | unset($list); |
| 5416 | - $list = &$stack[count($stack)-1]; |
|
| 5416 | + $list = &$stack[count($stack) - 1]; |
|
| 5417 | 5417 | array_pop($stack); |
| 5418 | 5418 | |
| 5419 | 5419 | // Go to terminal state if we're at the end of the root array. |
| 5420 | 5420 | array_pop($expected); |
| 5421 | 5421 | |
| 5422 | - if(count($expected) == 0) |
|
| 5422 | + if (count($expected) == 0) |
|
| 5423 | 5423 | $state = 1; |
| 5424 | 5424 | |
| 5425 | 5425 | break; |
| 5426 | 5426 | } |
| 5427 | 5427 | |
| 5428 | - if($type == 'i' || $type == 's') |
|
| 5428 | + if ($type == 'i' || $type == 's') |
|
| 5429 | 5429 | { |
| 5430 | 5430 | // Array size exceeds expected length. |
| 5431 | - if(count($list) >= end($expected)) |
|
| 5431 | + if (count($list) >= end($expected)) |
|
| 5432 | 5432 | return false; |
| 5433 | 5433 | |
| 5434 | 5434 | $key = $value; |
@@ -5441,7 +5441,7 @@ discard block |
||
| 5441 | 5441 | |
| 5442 | 5442 | // Expecting array or value. |
| 5443 | 5443 | case 0: |
| 5444 | - if($type == 'a') |
|
| 5444 | + if ($type == 'a') |
|
| 5445 | 5445 | { |
| 5446 | 5446 | $data = array(); |
| 5447 | 5447 | $list = &$data; |
@@ -5450,7 +5450,7 @@ discard block |
||
| 5450 | 5450 | break; |
| 5451 | 5451 | } |
| 5452 | 5452 | |
| 5453 | - if($type != '}') |
|
| 5453 | + if ($type != '}') |
|
| 5454 | 5454 | { |
| 5455 | 5455 | $data = $value; |
| 5456 | 5456 | $state = 1; |
@@ -5463,7 +5463,7 @@ discard block |
||
| 5463 | 5463 | } |
| 5464 | 5464 | |
| 5465 | 5465 | // Trailing data in input. |
| 5466 | - if(!empty($str)) |
|
| 5466 | + if (!empty($str)) |
|
| 5467 | 5467 | return false; |
| 5468 | 5468 | |
| 5469 | 5469 | return $data; |
@@ -5517,7 +5517,7 @@ discard block |
||
| 5517 | 5517 | // Set different modes. |
| 5518 | 5518 | $chmodValues = $isDir ? array(0750, 0755, 0775, 0777) : array(0644, 0664, 0666); |
| 5519 | 5519 | |
| 5520 | - foreach($chmodValues as $val) |
|
| 5520 | + foreach ($chmodValues as $val) |
|
| 5521 | 5521 | { |
| 5522 | 5522 | // If it's writable, break out of the loop. |
| 5523 | 5523 | if (is_writable($file)) |
@@ -5552,13 +5552,13 @@ discard block |
||
| 5552 | 5552 | $returnArray = @json_decode($json, $returnAsArray); |
| 5553 | 5553 | |
| 5554 | 5554 | // PHP 5.3 so no json_last_error_msg() |
| 5555 | - switch(json_last_error()) |
|
| 5555 | + switch (json_last_error()) |
|
| 5556 | 5556 | { |
| 5557 | 5557 | case JSON_ERROR_NONE: |
| 5558 | 5558 | $jsonError = false; |
| 5559 | 5559 | break; |
| 5560 | 5560 | case JSON_ERROR_DEPTH: |
| 5561 | - $jsonError = 'JSON_ERROR_DEPTH'; |
|
| 5561 | + $jsonError = 'JSON_ERROR_DEPTH'; |
|
| 5562 | 5562 | break; |
| 5563 | 5563 | case JSON_ERROR_STATE_MISMATCH: |
| 5564 | 5564 | $jsonError = 'JSON_ERROR_STATE_MISMATCH'; |
@@ -5586,10 +5586,10 @@ discard block |
||
| 5586 | 5586 | loadLanguage('Errors'); |
| 5587 | 5587 | |
| 5588 | 5588 | if (!empty($jsonDebug)) |
| 5589 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 5589 | + log_error($txt['json_' . $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 5590 | 5590 | |
| 5591 | 5591 | else |
| 5592 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
| 5592 | + log_error($txt['json_' . $jsonError], 'critical'); |
|
| 5593 | 5593 | |
| 5594 | 5594 | // Everyone expects an array. |
| 5595 | 5595 | return array(); |
@@ -5701,7 +5701,7 @@ discard block |
||
| 5701 | 5701 | }); |
| 5702 | 5702 | |
| 5703 | 5703 | // Convert Punycode to Unicode |
| 5704 | - $tlds = array_map(function ($input) { |
|
| 5704 | + $tlds = array_map(function($input) { |
|
| 5705 | 5705 | $prefix = 'xn--'; |
| 5706 | 5706 | $safe_char = 0xFFFC; |
| 5707 | 5707 | $base = 36; |
@@ -5717,7 +5717,7 @@ discard block |
||
| 5717 | 5717 | |
| 5718 | 5718 | foreach ($enco_parts as $encoded) |
| 5719 | 5719 | { |
| 5720 | - if (strpos($encoded,$prefix) !== 0 || strlen(trim(str_replace($prefix,'',$encoded))) == 0) |
|
| 5720 | + if (strpos($encoded, $prefix) !== 0 || strlen(trim(str_replace($prefix, '', $encoded))) == 0) |
|
| 5721 | 5721 | { |
| 5722 | 5722 | $output_parts[] = $encoded; |
| 5723 | 5723 | continue; |
@@ -5728,7 +5728,7 @@ discard block |
||
| 5728 | 5728 | $idx = 0; |
| 5729 | 5729 | $char = 0x80; |
| 5730 | 5730 | $decoded = array(); |
| 5731 | - $output=''; |
|
| 5731 | + $output = ''; |
|
| 5732 | 5732 | $delim_pos = strrpos($encoded, '-'); |
| 5733 | 5733 | |
| 5734 | 5734 | if ($delim_pos > strlen($prefix)) |
@@ -5744,7 +5744,7 @@ discard block |
||
| 5744 | 5744 | |
| 5745 | 5745 | for ($enco_idx = $delim_pos ? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len) |
| 5746 | 5746 | { |
| 5747 | - for ($old_idx = $idx, $w = 1, $k = $base; 1 ; $k += $base) |
|
| 5747 | + for ($old_idx = $idx, $w = 1, $k = $base; 1; $k += $base) |
|
| 5748 | 5748 | { |
| 5749 | 5749 | $cp = ord($encoded{$enco_idx++}); |
| 5750 | 5750 | $digit = ($cp - 48 < 10) ? $cp - 22 : (($cp - 65 < 26) ? $cp - 65 : (($cp - 97 < 26) ? $cp - 97 : $base)); |
@@ -5785,15 +5785,15 @@ discard block |
||
| 5785 | 5785 | |
| 5786 | 5786 | // 2 bytes |
| 5787 | 5787 | elseif ($v < (1 << 11)) |
| 5788 | - $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
| 5788 | + $output .= chr(192 + ($v >> 6)) . chr(128 + ($v & 63)); |
|
| 5789 | 5789 | |
| 5790 | 5790 | // 3 bytes |
| 5791 | 5791 | elseif ($v < (1 << 16)) |
| 5792 | - $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 5792 | + $output .= chr(224 + ($v >> 12)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63)); |
|
| 5793 | 5793 | |
| 5794 | 5794 | // 4 bytes |
| 5795 | 5795 | elseif ($v < (1 << 21)) |
| 5796 | - $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 5796 | + $output .= chr(240 + ($v >> 18)) . chr(128 + (($v >> 12) & 63)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63)); |
|
| 5797 | 5797 | |
| 5798 | 5798 | // 'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k |
| 5799 | 5799 | else |
@@ -5898,7 +5898,7 @@ discard block |
||
| 5898 | 5898 | } |
| 5899 | 5899 | |
| 5900 | 5900 | // This recursive function creates the index array from the strings |
| 5901 | - $add_string_to_index = function ($string, $index) use (&$strlen, &$substr, &$add_string_to_index) |
|
| 5901 | + $add_string_to_index = function($string, $index) use (&$strlen, &$substr, &$add_string_to_index) |
|
| 5902 | 5902 | { |
| 5903 | 5903 | static $depth = 0; |
| 5904 | 5904 | $depth++; |
@@ -5925,7 +5925,7 @@ discard block |
||
| 5925 | 5925 | }; |
| 5926 | 5926 | |
| 5927 | 5927 | // This recursive function turns the index array into a regular expression |
| 5928 | - $index_to_regex = function (&$index, $delim) use (&$strlen, &$index_to_regex) |
|
| 5928 | + $index_to_regex = function(&$index, $delim) use (&$strlen, &$index_to_regex) |
|
| 5929 | 5929 | { |
| 5930 | 5930 | static $depth = 0; |
| 5931 | 5931 | $depth++; |
@@ -5949,11 +5949,11 @@ discard block |
||
| 5949 | 5949 | |
| 5950 | 5950 | if (count(array_keys($value)) == 1) |
| 5951 | 5951 | { |
| 5952 | - $new_key_array = explode('(?'.'>', $sub_regex); |
|
| 5952 | + $new_key_array = explode('(?' . '>', $sub_regex); |
|
| 5953 | 5953 | $new_key .= $new_key_array[0]; |
| 5954 | 5954 | } |
| 5955 | 5955 | else |
| 5956 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
| 5956 | + $sub_regex = '(?' . '>' . $sub_regex . ')'; |
|
| 5957 | 5957 | } |
| 5958 | 5958 | |
| 5959 | 5959 | if ($depth > 1) |
@@ -5996,10 +5996,10 @@ discard block |
||
| 5996 | 5996 | { |
| 5997 | 5997 | $regex = array(); |
| 5998 | 5998 | while (!empty($index)) |
| 5999 | - $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 5999 | + $regex[] = '(?' . '>' . $index_to_regex($index, $delim) . ')'; |
|
| 6000 | 6000 | } |
| 6001 | 6001 | else |
| 6002 | - $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6002 | + $regex = '(?' . '>' . $index_to_regex($index, $delim) . ')'; |
|
| 6003 | 6003 | |
| 6004 | 6004 | // Restore PHP's internal character encoding to whatever it was originally |
| 6005 | 6005 | if (!empty($current_encoding)) |
@@ -6021,7 +6021,7 @@ discard block |
||
| 6021 | 6021 | |
| 6022 | 6022 | $result = false; |
| 6023 | 6023 | $params = array('ssl' => array('capture_peer_cert' => true, 'verify_peer' => true, 'allow_self_signed' => true)); |
| 6024 | - $stream = stream_context_create ($params); |
|
| 6024 | + $stream = stream_context_create($params); |
|
| 6025 | 6025 | |
| 6026 | 6026 | $read = @fopen($url, 'rb', false, $stream); |
| 6027 | 6027 | if ($read !== false) { |
@@ -2259,9 +2259,9 @@ discard block |
||
| 2259 | 2259 | * |
| 2260 | 2260 | * @uses the template_include() function to include the file. |
| 2261 | 2261 | * @param string $template_name The name of the template to load |
| 2262 | - * @param array|string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load |
|
| 2262 | + * @param string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load |
|
| 2263 | 2263 | * @param bool $fatal If true, dies with an error message if the template cannot be found |
| 2264 | - * @return boolean Whether or not the template was loaded |
|
| 2264 | + * @return boolean|null Whether or not the template was loaded |
|
| 2265 | 2265 | */ |
| 2266 | 2266 | function loadTemplate($template_name, $style_sheets = array(), $fatal = true) |
| 2267 | 2267 | { |
@@ -2444,7 +2444,7 @@ discard block |
||
| 2444 | 2444 | * - all code added with this function is added to the same <style> tag so do make sure your css is valid! |
| 2445 | 2445 | * |
| 2446 | 2446 | * @param string $css Some css code |
| 2447 | - * @return void|bool Adds the CSS to the $context['css_header'] array or returns if no CSS is specified |
|
| 2447 | + * @return false|null Adds the CSS to the $context['css_header'] array or returns if no CSS is specified |
|
| 2448 | 2448 | */ |
| 2449 | 2449 | function addInlineCss($css) |
| 2450 | 2450 | { |
@@ -2558,7 +2558,7 @@ discard block |
||
| 2558 | 2558 | * |
| 2559 | 2559 | * @param string $javascript Some JS code |
| 2560 | 2560 | * @param bool $defer Whether the script should load in <head> or before the closing <html> tag |
| 2561 | - * @return void|bool Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified |
|
| 2561 | + * @return false|null Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified |
|
| 2562 | 2562 | */ |
| 2563 | 2563 | function addInlineJavaScript($javascript, $defer = false) |
| 2564 | 2564 | { |
@@ -2791,7 +2791,7 @@ discard block |
||
| 2791 | 2791 | * It will try to choose only utf8 or non-utf8 languages. |
| 2792 | 2792 | * |
| 2793 | 2793 | * @param bool $use_cache Whether or not to use the cache |
| 2794 | - * @return array An array of information about available languages |
|
| 2794 | + * @return string An array of information about available languages |
|
| 2795 | 2795 | */ |
| 2796 | 2796 | function getLanguages($use_cache = true) |
| 2797 | 2797 | { |
@@ -1719,7 +1719,7 @@ |
||
| 1719 | 1719 | $id_theme = $modSettings['theme_guests']; |
| 1720 | 1720 | |
| 1721 | 1721 | // We already load the basic stuff? |
| 1722 | - if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme ) |
|
| 1722 | + if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme) |
|
| 1723 | 1723 | { |
| 1724 | 1724 | // Verify the id_theme... no foul play. |
| 1725 | 1725 | // Always allow the board specific theme, if they are overriding. |
@@ -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 | * Load the $modSettings array. |
@@ -25,13 +26,14 @@ discard block |
||
| 25 | 26 | global $cache_enable, $sourcedir, $context; |
| 26 | 27 | |
| 27 | 28 | // Most database systems have not set UTF-8 as their default input charset. |
| 28 | - if (!empty($db_character_set)) |
|
| 29 | - $smcFunc['db_query']('', ' |
|
| 29 | + if (!empty($db_character_set)) { |
|
| 30 | + $smcFunc['db_query']('', ' |
|
| 30 | 31 | SET NAMES {string:db_character_set}', |
| 31 | 32 | array( |
| 32 | 33 | 'db_character_set' => $db_character_set, |
| 33 | 34 | ) |
| 34 | 35 | ); |
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | // We need some caching support, maybe. |
| 37 | 39 | loadCacheAccelerator(); |
@@ -46,28 +48,36 @@ discard block |
||
| 46 | 48 | ) |
| 47 | 49 | ); |
| 48 | 50 | $modSettings = array(); |
| 49 | - if (!$request) |
|
| 50 | - display_db_error(); |
|
| 51 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 52 | - $modSettings[$row[0]] = $row[1]; |
|
| 51 | + if (!$request) { |
|
| 52 | + display_db_error(); |
|
| 53 | + } |
|
| 54 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 55 | + $modSettings[$row[0]] = $row[1]; |
|
| 56 | + } |
|
| 53 | 57 | $smcFunc['db_free_result']($request); |
| 54 | 58 | |
| 55 | 59 | // Do a few things to protect against missing settings or settings with invalid values... |
| 56 | - if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) |
|
| 57 | - $modSettings['defaultMaxTopics'] = 20; |
|
| 58 | - if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) |
|
| 59 | - $modSettings['defaultMaxMessages'] = 15; |
|
| 60 | - if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) |
|
| 61 | - $modSettings['defaultMaxMembers'] = 30; |
|
| 62 | - if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) |
|
| 63 | - $modSettings['defaultMaxListItems'] = 15; |
|
| 60 | + if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) { |
|
| 61 | + $modSettings['defaultMaxTopics'] = 20; |
|
| 62 | + } |
|
| 63 | + if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) { |
|
| 64 | + $modSettings['defaultMaxMessages'] = 15; |
|
| 65 | + } |
|
| 66 | + if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) { |
|
| 67 | + $modSettings['defaultMaxMembers'] = 30; |
|
| 68 | + } |
|
| 69 | + if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) { |
|
| 70 | + $modSettings['defaultMaxListItems'] = 15; |
|
| 71 | + } |
|
| 64 | 72 | |
| 65 | 73 | // We excpiclity do not use $smcFunc['json_decode'] here yet, as $smcFunc is not fully loaded. |
| 66 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
| 67 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
| 74 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
| 75 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
| 76 | + } |
|
| 68 | 77 | |
| 69 | - if (!empty($cache_enable)) |
|
| 70 | - cache_put_data('modSettings', $modSettings, 90); |
|
| 78 | + if (!empty($cache_enable)) { |
|
| 79 | + cache_put_data('modSettings', $modSettings, 90); |
|
| 80 | + } |
|
| 71 | 81 | } |
| 72 | 82 | |
| 73 | 83 | $modSettings['cache_enable'] = $cache_enable; |
@@ -87,8 +97,9 @@ discard block |
||
| 87 | 97 | }; |
| 88 | 98 | $fix_utf8mb4 = function($string) use ($utf8, $smcFunc) |
| 89 | 99 | { |
| 90 | - if (!$utf8 || $smcFunc['db_mb4']) |
|
| 91 | - return $string; |
|
| 100 | + if (!$utf8 || $smcFunc['db_mb4']) { |
|
| 101 | + return $string; |
|
| 102 | + } |
|
| 92 | 103 | |
| 93 | 104 | $i = 0; |
| 94 | 105 | $len = strlen($string); |
@@ -100,18 +111,15 @@ discard block |
||
| 100 | 111 | { |
| 101 | 112 | $new_string .= $string[$i]; |
| 102 | 113 | $i++; |
| 103 | - } |
|
| 104 | - elseif ($ord < 224) |
|
| 114 | + } elseif ($ord < 224) |
|
| 105 | 115 | { |
| 106 | 116 | $new_string .= $string[$i] . $string[$i + 1]; |
| 107 | 117 | $i += 2; |
| 108 | - } |
|
| 109 | - elseif ($ord < 240) |
|
| 118 | + } elseif ($ord < 240) |
|
| 110 | 119 | { |
| 111 | 120 | $new_string .= $string[$i] . $string[$i + 1] . $string[$i + 2]; |
| 112 | 121 | $i += 3; |
| 113 | - } |
|
| 114 | - elseif ($ord < 248) |
|
| 122 | + } elseif ($ord < 248) |
|
| 115 | 123 | { |
| 116 | 124 | // Magic happens. |
| 117 | 125 | $val = (ord($string[$i]) & 0x07) << 18; |
@@ -155,8 +163,7 @@ discard block |
||
| 155 | 163 | { |
| 156 | 164 | $result = array_search($needle, array_slice($haystack_arr, $offset)); |
| 157 | 165 | return is_int($result) ? $result + $offset : false; |
| 158 | - } |
|
| 159 | - else |
|
| 166 | + } else |
|
| 160 | 167 | { |
| 161 | 168 | $needle_arr = preg_split('~(&#' . (empty($modSettings['disableEntityCheck']) ? '\d{1,7}' : '021') . ';|"|&|<|>| |.)~' . ($utf8 ? 'u' : '') . '', $ent_check($needle), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
| 162 | 169 | $needle_size = count($needle_arr); |
@@ -165,8 +172,9 @@ discard block |
||
| 165 | 172 | while ((int) $result === $result) |
| 166 | 173 | { |
| 167 | 174 | $offset += $result; |
| 168 | - if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) |
|
| 169 | - return $offset; |
|
| 175 | + if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) { |
|
| 176 | + return $offset; |
|
| 177 | + } |
|
| 170 | 178 | $result = array_search($needle_arr[0], array_slice($haystack_arr, ++$offset)); |
| 171 | 179 | } |
| 172 | 180 | return false; |
@@ -204,8 +212,9 @@ discard block |
||
| 204 | 212 | $string = $ent_check($string); |
| 205 | 213 | preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~' . ($utf8 ? 'u' : ''), $string, $matches); |
| 206 | 214 | $string = $matches[0]; |
| 207 | - while (strlen($string) > $length) |
|
| 208 | - $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
| 215 | + while (strlen($string) > $length) { |
|
| 216 | + $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
| 217 | + } |
|
| 209 | 218 | return $string; |
| 210 | 219 | }, |
| 211 | 220 | 'ucfirst' => $utf8 ? function($string) use (&$smcFunc) |
@@ -215,8 +224,9 @@ discard block |
||
| 215 | 224 | 'ucwords' => $utf8 ? function($string) use (&$smcFunc) |
| 216 | 225 | { |
| 217 | 226 | $words = preg_split('~([\s\r\n\t]+)~', $string, -1, PREG_SPLIT_DELIM_CAPTURE); |
| 218 | - for ($i = 0, $n = count($words); $i < $n; $i += 2) |
|
| 219 | - $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
| 227 | + for ($i = 0, $n = count($words); $i < $n; $i += 2) { |
|
| 228 | + $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
| 229 | + } |
|
| 220 | 230 | return implode('', $words); |
| 221 | 231 | } : 'ucwords', |
| 222 | 232 | 'json_decode' => 'smf_json_decode', |
@@ -224,16 +234,17 @@ discard block |
||
| 224 | 234 | ); |
| 225 | 235 | |
| 226 | 236 | // Setting the timezone is a requirement for some functions. |
| 227 | - if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
|
| 228 | - date_default_timezone_set($modSettings['default_timezone']); |
|
| 229 | - else |
|
| 237 | + if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) { |
|
| 238 | + date_default_timezone_set($modSettings['default_timezone']); |
|
| 239 | + } else |
|
| 230 | 240 | { |
| 231 | 241 | // Get PHP's default timezone, if set |
| 232 | 242 | $ini_tz = ini_get('date.timezone'); |
| 233 | - if (!empty($ini_tz)) |
|
| 234 | - $modSettings['default_timezone'] = $ini_tz; |
|
| 235 | - else |
|
| 236 | - $modSettings['default_timezone'] = ''; |
|
| 243 | + if (!empty($ini_tz)) { |
|
| 244 | + $modSettings['default_timezone'] = $ini_tz; |
|
| 245 | + } else { |
|
| 246 | + $modSettings['default_timezone'] = ''; |
|
| 247 | + } |
|
| 237 | 248 | |
| 238 | 249 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 239 | 250 | if (!in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
@@ -251,22 +262,26 @@ discard block |
||
| 251 | 262 | if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) == null) |
| 252 | 263 | { |
| 253 | 264 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
| 254 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) |
|
| 255 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 256 | - elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) |
|
| 257 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 258 | - else |
|
| 259 | - unset($modSettings['load_average']); |
|
| 265 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) { |
|
| 266 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 267 | + } elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) { |
|
| 268 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 269 | + } else { |
|
| 270 | + unset($modSettings['load_average']); |
|
| 271 | + } |
|
| 260 | 272 | |
| 261 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
| 262 | - cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
| 273 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
| 274 | + cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
| 275 | + } |
|
| 263 | 276 | } |
| 264 | 277 | |
| 265 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
| 266 | - call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
| 278 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
| 279 | + call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
| 280 | + } |
|
| 267 | 281 | |
| 268 | - if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) |
|
| 269 | - display_loadavg_error(); |
|
| 282 | + if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) { |
|
| 283 | + display_loadavg_error(); |
|
| 284 | + } |
|
| 270 | 285 | } |
| 271 | 286 | |
| 272 | 287 | // Is post moderation alive and well? Everywhere else assumes this has been defined, so let's make sure it is. |
@@ -287,8 +302,9 @@ discard block |
||
| 287 | 302 | if (defined('SMF_INTEGRATION_SETTINGS')) |
| 288 | 303 | { |
| 289 | 304 | $integration_settings = $smcFunc['json_decode'](SMF_INTEGRATION_SETTINGS, true); |
| 290 | - foreach ($integration_settings as $hook => $function) |
|
| 291 | - add_integration_function($hook, $function, '', false); |
|
| 305 | + foreach ($integration_settings as $hook => $function) { |
|
| 306 | + add_integration_function($hook, $function, '', false); |
|
| 307 | + } |
|
| 292 | 308 | } |
| 293 | 309 | |
| 294 | 310 | // Any files to pre include? |
@@ -298,8 +314,9 @@ discard block |
||
| 298 | 314 | foreach ($pre_includes as $include) |
| 299 | 315 | { |
| 300 | 316 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
| 301 | - if (file_exists($include)) |
|
| 302 | - require_once($include); |
|
| 317 | + if (file_exists($include)) { |
|
| 318 | + require_once($include); |
|
| 319 | + } |
|
| 303 | 320 | } |
| 304 | 321 | } |
| 305 | 322 | |
@@ -403,27 +420,28 @@ discard block |
||
| 403 | 420 | break; |
| 404 | 421 | } |
| 405 | 422 | } |
| 423 | + } else { |
|
| 424 | + $id_member = 0; |
|
| 406 | 425 | } |
| 407 | - else |
|
| 408 | - $id_member = 0; |
|
| 409 | 426 | |
| 410 | 427 | if (empty($id_member) && isset($_COOKIE[$cookiename])) |
| 411 | 428 | { |
| 412 | 429 | $cookie_data = $smcFunc['json_decode']($_COOKIE[$cookiename], true, false); |
| 413 | 430 | |
| 414 | - if (empty($cookie_data)) |
|
| 415 | - $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
| 431 | + if (empty($cookie_data)) { |
|
| 432 | + $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
| 433 | + } |
|
| 416 | 434 | |
| 417 | 435 | list ($id_member, $password) = $cookie_data; |
| 418 | 436 | $id_member = !empty($id_member) && strlen($password) > 0 ? (int) $id_member : 0; |
| 419 | - } |
|
| 420 | - elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
| 437 | + } elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
| 421 | 438 | { |
| 422 | 439 | // @todo Perhaps we can do some more checking on this, such as on the first octet of the IP? |
| 423 | 440 | $cookie_data = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]); |
| 424 | 441 | |
| 425 | - if (empty($cookie_data)) |
|
| 426 | - $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 442 | + if (empty($cookie_data)) { |
|
| 443 | + $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 444 | + } |
|
| 427 | 445 | |
| 428 | 446 | list ($id_member, $password, $login_span) = $cookie_data; |
| 429 | 447 | $id_member = !empty($id_member) && strlen($password) == 128 && $login_span > time() ? (int) $id_member : 0; |
@@ -448,30 +466,34 @@ discard block |
||
| 448 | 466 | $user_settings = $smcFunc['db_fetch_assoc']($request); |
| 449 | 467 | $smcFunc['db_free_result']($request); |
| 450 | 468 | |
| 451 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) |
|
| 452 | - $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
| 469 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) { |
|
| 470 | + $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
| 471 | + } |
|
| 453 | 472 | |
| 454 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 455 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 473 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 474 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 475 | + } |
|
| 456 | 476 | } |
| 457 | 477 | |
| 458 | 478 | // Did we find 'im? If not, junk it. |
| 459 | 479 | if (!empty($user_settings)) |
| 460 | 480 | { |
| 461 | 481 | // As much as the password should be right, we can assume the integration set things up. |
| 462 | - if (!empty($already_verified) && $already_verified === true) |
|
| 463 | - $check = true; |
|
| 482 | + if (!empty($already_verified) && $already_verified === true) { |
|
| 483 | + $check = true; |
|
| 484 | + } |
|
| 464 | 485 | // SHA-512 hash should be 128 characters long. |
| 465 | - elseif (strlen($password) == 128) |
|
| 466 | - $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
| 467 | - else |
|
| 468 | - $check = false; |
|
| 486 | + elseif (strlen($password) == 128) { |
|
| 487 | + $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
| 488 | + } else { |
|
| 489 | + $check = false; |
|
| 490 | + } |
|
| 469 | 491 | |
| 470 | 492 | // Wrong password or not activated - either way, you're going nowhere. |
| 471 | 493 | $id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0; |
| 494 | + } else { |
|
| 495 | + $id_member = 0; |
|
| 472 | 496 | } |
| 473 | - else |
|
| 474 | - $id_member = 0; |
|
| 475 | 497 | |
| 476 | 498 | // If we no longer have the member maybe they're being all hackey, stop brute force! |
| 477 | 499 | if (!$id_member) |
@@ -500,8 +522,9 @@ discard block |
||
| 500 | 522 | |
| 501 | 523 | list ($tfamember, $tfasecret) = $tfa_data; |
| 502 | 524 | |
| 503 | - if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) |
|
| 504 | - $tfasecret = null; |
|
| 525 | + if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) { |
|
| 526 | + $tfasecret = null; |
|
| 527 | + } |
|
| 505 | 528 | } |
| 506 | 529 | |
| 507 | 530 | if (empty($tfasecret) || hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']) != $tfasecret) |
@@ -521,10 +544,12 @@ discard block |
||
| 521 | 544 | // Are we forcing 2FA? Need to check if the user groups actually require 2FA |
| 522 | 545 | elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret'])) |
| 523 | 546 | { |
| 524 | - if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups |
|
| 547 | + if ($modSettings['tfa_mode'] == 2) { |
|
| 548 | + //only do this if we are just forcing SOME membergroups |
|
| 525 | 549 | { |
| 526 | 550 | //Build an array of ALL user membergroups. |
| 527 | 551 | $full_groups = array($user_settings['id_group']); |
| 552 | + } |
|
| 528 | 553 | if (!empty($user_settings['additional_groups'])) |
| 529 | 554 | { |
| 530 | 555 | $full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups'])); |
@@ -544,15 +569,17 @@ discard block |
||
| 544 | 569 | ); |
| 545 | 570 | $row = $smcFunc['db_fetch_assoc']($request); |
| 546 | 571 | $smcFunc['db_free_result']($request); |
| 572 | + } else { |
|
| 573 | + $row['total'] = 1; |
|
| 547 | 574 | } |
| 548 | - else |
|
| 549 | - $row['total'] = 1; //simplifies logics in the next "if" |
|
| 575 | + //simplifies logics in the next "if" |
|
| 550 | 576 | |
| 551 | 577 | $area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : ''; |
| 552 | 578 | $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
| 553 | 579 | |
| 554 | - if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) |
|
| 555 | - redirectexit('action=profile;area=tfasetup;forced'); |
|
| 580 | + if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) { |
|
| 581 | + redirectexit('action=profile;area=tfasetup;forced'); |
|
| 582 | + } |
|
| 556 | 583 | } |
| 557 | 584 | } |
| 558 | 585 | |
@@ -589,33 +616,37 @@ discard block |
||
| 589 | 616 | updateMemberData($id_member, array('id_msg_last_visit' => (int) $modSettings['maxMsgID'], 'last_login' => time(), 'member_ip' => $_SERVER['REMOTE_ADDR'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'])); |
| 590 | 617 | $user_settings['last_login'] = time(); |
| 591 | 618 | |
| 592 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 593 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 619 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 620 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 621 | + } |
|
| 594 | 622 | |
| 595 | - if (!empty($modSettings['cache_enable'])) |
|
| 596 | - cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
| 623 | + if (!empty($modSettings['cache_enable'])) { |
|
| 624 | + cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
| 625 | + } |
|
| 597 | 626 | } |
| 627 | + } elseif (empty($_SESSION['id_msg_last_visit'])) { |
|
| 628 | + $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
| 598 | 629 | } |
| 599 | - elseif (empty($_SESSION['id_msg_last_visit'])) |
|
| 600 | - $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
| 601 | 630 | |
| 602 | 631 | $username = $user_settings['member_name']; |
| 603 | 632 | |
| 604 | - if (empty($user_settings['additional_groups'])) |
|
| 605 | - $user_info = array( |
|
| 633 | + if (empty($user_settings['additional_groups'])) { |
|
| 634 | + $user_info = array( |
|
| 606 | 635 | 'groups' => array($user_settings['id_group'], $user_settings['id_post_group']) |
| 607 | 636 | ); |
| 608 | - else |
|
| 609 | - $user_info = array( |
|
| 637 | + } else { |
|
| 638 | + $user_info = array( |
|
| 610 | 639 | 'groups' => array_merge( |
| 611 | 640 | array($user_settings['id_group'], $user_settings['id_post_group']), |
| 612 | 641 | explode(',', $user_settings['additional_groups']) |
| 613 | 642 | ) |
| 614 | 643 | ); |
| 644 | + } |
|
| 615 | 645 | |
| 616 | 646 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
| 617 | - foreach ($user_info['groups'] as $k => $v) |
|
| 618 | - $user_info['groups'][$k] = (int) $v; |
|
| 647 | + foreach ($user_info['groups'] as $k => $v) { |
|
| 648 | + $user_info['groups'][$k] = (int) $v; |
|
| 649 | + } |
|
| 619 | 650 | |
| 620 | 651 | // This is a logged in user, so definitely not a spider. |
| 621 | 652 | $user_info['possibly_robot'] = false; |
@@ -629,8 +660,7 @@ discard block |
||
| 629 | 660 | $time_system = new DateTime('now', $tz_system); |
| 630 | 661 | $time_user = new DateTime('now', $tz_user); |
| 631 | 662 | $user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600; |
| 632 | - } |
|
| 633 | - else |
|
| 663 | + } else |
|
| 634 | 664 | { |
| 635 | 665 | // !!! Compatibility. |
| 636 | 666 | $user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset']; |
@@ -644,8 +674,9 @@ discard block |
||
| 644 | 674 | $user_info = array('groups' => array(-1)); |
| 645 | 675 | $user_settings = array(); |
| 646 | 676 | |
| 647 | - if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) |
|
| 648 | - $_COOKIE[$cookiename] = ''; |
|
| 677 | + if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) { |
|
| 678 | + $_COOKIE[$cookiename] = ''; |
|
| 679 | + } |
|
| 649 | 680 | |
| 650 | 681 | // Expire the 2FA cookie |
| 651 | 682 | if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member'])) |
@@ -662,19 +693,20 @@ discard block |
||
| 662 | 693 | } |
| 663 | 694 | |
| 664 | 695 | // Create a login token if it doesn't exist yet. |
| 665 | - if (!isset($_SESSION['token']['post-login'])) |
|
| 666 | - createToken('login'); |
|
| 667 | - else |
|
| 668 | - list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
| 696 | + if (!isset($_SESSION['token']['post-login'])) { |
|
| 697 | + createToken('login'); |
|
| 698 | + } else { |
|
| 699 | + list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
| 700 | + } |
|
| 669 | 701 | |
| 670 | 702 | // Do we perhaps think this is a search robot? Check every five minutes just in case... |
| 671 | 703 | if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300)) |
| 672 | 704 | { |
| 673 | 705 | require_once($sourcedir . '/ManageSearchEngines.php'); |
| 674 | 706 | $user_info['possibly_robot'] = SpiderCheck(); |
| 707 | + } elseif (!empty($modSettings['spider_mode'])) { |
|
| 708 | + $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
| 675 | 709 | } |
| 676 | - elseif (!empty($modSettings['spider_mode'])) |
|
| 677 | - $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
| 678 | 710 | // If we haven't turned on proper spider hunts then have a guess! |
| 679 | 711 | else |
| 680 | 712 | { |
@@ -722,8 +754,9 @@ discard block |
||
| 722 | 754 | $user_info['groups'] = array_unique($user_info['groups']); |
| 723 | 755 | |
| 724 | 756 | // Make sure that the last item in the ignore boards array is valid. If the list was too long it could have an ending comma that could cause problems. |
| 725 | - if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) |
|
| 726 | - unset($user_info['ignoreboards'][$tmp]); |
|
| 757 | + if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) { |
|
| 758 | + unset($user_info['ignoreboards'][$tmp]); |
|
| 759 | + } |
|
| 727 | 760 | |
| 728 | 761 | // Allow the user to change their language. |
| 729 | 762 | if (!empty($modSettings['userLanguage'])) |
@@ -736,13 +769,14 @@ discard block |
||
| 736 | 769 | $user_info['language'] = strtr($_GET['language'], './\\:', '____'); |
| 737 | 770 | |
| 738 | 771 | // Make it permanent for members. |
| 739 | - if (!empty($user_info['id'])) |
|
| 740 | - updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
| 741 | - else |
|
| 742 | - $_SESSION['language'] = $user_info['language']; |
|
| 772 | + if (!empty($user_info['id'])) { |
|
| 773 | + updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
| 774 | + } else { |
|
| 775 | + $_SESSION['language'] = $user_info['language']; |
|
| 776 | + } |
|
| 777 | + } elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) { |
|
| 778 | + $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
| 743 | 779 | } |
| 744 | - elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) |
|
| 745 | - $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
| 746 | 780 | } |
| 747 | 781 | |
| 748 | 782 | $temp = build_query_board($user_info['id']); |
@@ -805,9 +839,9 @@ discard block |
||
| 805 | 839 | } |
| 806 | 840 | |
| 807 | 841 | // Remember redirection is the key to avoiding fallout from your bosses. |
| 808 | - if (!empty($topic)) |
|
| 809 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
| 810 | - else |
|
| 842 | + if (!empty($topic)) { |
|
| 843 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
| 844 | + } else |
|
| 811 | 845 | { |
| 812 | 846 | loadPermissions(); |
| 813 | 847 | loadTheme(); |
@@ -825,10 +859,11 @@ discard block |
||
| 825 | 859 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
| 826 | 860 | { |
| 827 | 861 | // @todo SLOW? |
| 828 | - if (!empty($topic)) |
|
| 829 | - $temp = cache_get_data('topic_board-' . $topic, 120); |
|
| 830 | - else |
|
| 831 | - $temp = cache_get_data('board-' . $board, 120); |
|
| 862 | + if (!empty($topic)) { |
|
| 863 | + $temp = cache_get_data('topic_board-' . $topic, 120); |
|
| 864 | + } else { |
|
| 865 | + $temp = cache_get_data('board-' . $board, 120); |
|
| 866 | + } |
|
| 832 | 867 | |
| 833 | 868 | if (!empty($temp)) |
| 834 | 869 | { |
@@ -866,8 +901,9 @@ discard block |
||
| 866 | 901 | $row = $smcFunc['db_fetch_assoc']($request); |
| 867 | 902 | |
| 868 | 903 | // Set the current board. |
| 869 | - if (!empty($row['id_board'])) |
|
| 870 | - $board = $row['id_board']; |
|
| 904 | + if (!empty($row['id_board'])) { |
|
| 905 | + $board = $row['id_board']; |
|
| 906 | + } |
|
| 871 | 907 | |
| 872 | 908 | // Basic operating information. (globals... :/) |
| 873 | 909 | $board_info = array( |
@@ -903,21 +939,23 @@ discard block |
||
| 903 | 939 | |
| 904 | 940 | do |
| 905 | 941 | { |
| 906 | - if (!empty($row['id_moderator'])) |
|
| 907 | - $board_info['moderators'][$row['id_moderator']] = array( |
|
| 942 | + if (!empty($row['id_moderator'])) { |
|
| 943 | + $board_info['moderators'][$row['id_moderator']] = array( |
|
| 908 | 944 | 'id' => $row['id_moderator'], |
| 909 | 945 | 'name' => $row['real_name'], |
| 910 | 946 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
| 911 | 947 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
| 912 | 948 | ); |
| 949 | + } |
|
| 913 | 950 | |
| 914 | - if (!empty($row['id_moderator_group'])) |
|
| 915 | - $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
| 951 | + if (!empty($row['id_moderator_group'])) { |
|
| 952 | + $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
| 916 | 953 | 'id' => $row['id_moderator_group'], |
| 917 | 954 | 'name' => $row['group_name'], |
| 918 | 955 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
| 919 | 956 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
| 920 | 957 | ); |
| 958 | + } |
|
| 921 | 959 | } |
| 922 | 960 | while ($row = $smcFunc['db_fetch_assoc']($request)); |
| 923 | 961 | |
@@ -949,12 +987,12 @@ discard block |
||
| 949 | 987 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
| 950 | 988 | { |
| 951 | 989 | // @todo SLOW? |
| 952 | - if (!empty($topic)) |
|
| 953 | - cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
| 990 | + if (!empty($topic)) { |
|
| 991 | + cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
| 992 | + } |
|
| 954 | 993 | cache_put_data('board-' . $board, $board_info, 120); |
| 955 | 994 | } |
| 956 | - } |
|
| 957 | - else |
|
| 995 | + } else |
|
| 958 | 996 | { |
| 959 | 997 | // Otherwise the topic is invalid, there are no moderators, etc. |
| 960 | 998 | $board_info = array( |
@@ -968,8 +1006,9 @@ discard block |
||
| 968 | 1006 | $smcFunc['db_free_result']($request); |
| 969 | 1007 | } |
| 970 | 1008 | |
| 971 | - if (!empty($topic)) |
|
| 972 | - $_GET['board'] = (int) $board; |
|
| 1009 | + if (!empty($topic)) { |
|
| 1010 | + $_GET['board'] = (int) $board; |
|
| 1011 | + } |
|
| 973 | 1012 | |
| 974 | 1013 | if (!empty($board)) |
| 975 | 1014 | { |
@@ -979,10 +1018,12 @@ discard block |
||
| 979 | 1018 | // Now check if the user is a moderator. |
| 980 | 1019 | $user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0; |
| 981 | 1020 | |
| 982 | - if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) |
|
| 983 | - $board_info['error'] = 'access'; |
|
| 984 | - if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) |
|
| 985 | - $board_info['error'] = 'access'; |
|
| 1021 | + if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) { |
|
| 1022 | + $board_info['error'] = 'access'; |
|
| 1023 | + } |
|
| 1024 | + if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) { |
|
| 1025 | + $board_info['error'] = 'access'; |
|
| 1026 | + } |
|
| 986 | 1027 | |
| 987 | 1028 | // Build up the linktree. |
| 988 | 1029 | $context['linktree'] = array_merge( |
@@ -1005,8 +1046,9 @@ discard block |
||
| 1005 | 1046 | $context['current_board'] = $board; |
| 1006 | 1047 | |
| 1007 | 1048 | // No posting in redirection boards! |
| 1008 | - if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) |
|
| 1009 | - $board_info['error'] == 'post_in_redirect'; |
|
| 1049 | + if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) { |
|
| 1050 | + $board_info['error'] == 'post_in_redirect'; |
|
| 1051 | + } |
|
| 1010 | 1052 | |
| 1011 | 1053 | // Hacker... you can't see this topic, I'll tell you that. (but moderators can!) |
| 1012 | 1054 | if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod'])) |
@@ -1032,24 +1074,23 @@ discard block |
||
| 1032 | 1074 | ob_end_clean(); |
| 1033 | 1075 | header('HTTP/1.1 403 Forbidden'); |
| 1034 | 1076 | die; |
| 1035 | - } |
|
| 1036 | - elseif ($board_info['error'] == 'post_in_redirect') |
|
| 1077 | + } elseif ($board_info['error'] == 'post_in_redirect') |
|
| 1037 | 1078 | { |
| 1038 | 1079 | // Slightly different error message here... |
| 1039 | 1080 | fatal_lang_error('cannot_post_redirect', false); |
| 1040 | - } |
|
| 1041 | - elseif ($user_info['is_guest']) |
|
| 1081 | + } elseif ($user_info['is_guest']) |
|
| 1042 | 1082 | { |
| 1043 | 1083 | loadLanguage('Errors'); |
| 1044 | 1084 | is_not_guest($txt['topic_gone']); |
| 1085 | + } else { |
|
| 1086 | + fatal_lang_error('topic_gone', false); |
|
| 1045 | 1087 | } |
| 1046 | - else |
|
| 1047 | - fatal_lang_error('topic_gone', false); |
|
| 1048 | 1088 | } |
| 1049 | 1089 | |
| 1050 | - if ($user_info['is_mod']) |
|
| 1051 | - $user_info['groups'][] = 3; |
|
| 1052 | -} |
|
| 1090 | + if ($user_info['is_mod']) { |
|
| 1091 | + $user_info['groups'][] = 3; |
|
| 1092 | + } |
|
| 1093 | + } |
|
| 1053 | 1094 | |
| 1054 | 1095 | /** |
| 1055 | 1096 | * Load this user's permissions. |
@@ -1070,8 +1111,9 @@ discard block |
||
| 1070 | 1111 | asort($cache_groups); |
| 1071 | 1112 | $cache_groups = implode(',', $cache_groups); |
| 1072 | 1113 | // If it's a spider then cache it different. |
| 1073 | - if ($user_info['possibly_robot']) |
|
| 1074 | - $cache_groups .= '-spider'; |
|
| 1114 | + if ($user_info['possibly_robot']) { |
|
| 1115 | + $cache_groups .= '-spider'; |
|
| 1116 | + } |
|
| 1075 | 1117 | |
| 1076 | 1118 | if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
| 1077 | 1119 | { |
@@ -1079,9 +1121,9 @@ discard block |
||
| 1079 | 1121 | banPermissions(); |
| 1080 | 1122 | |
| 1081 | 1123 | return; |
| 1124 | + } elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) { |
|
| 1125 | + list ($user_info['permissions'], $removals) = $temp; |
|
| 1082 | 1126 | } |
| 1083 | - elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
|
| 1084 | - list ($user_info['permissions'], $removals) = $temp; |
|
| 1085 | 1127 | } |
| 1086 | 1128 | |
| 1087 | 1129 | // If it is detected as a robot, and we are restricting permissions as a special group - then implement this. |
@@ -1103,23 +1145,26 @@ discard block |
||
| 1103 | 1145 | $removals = array(); |
| 1104 | 1146 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1105 | 1147 | { |
| 1106 | - if (empty($row['add_deny'])) |
|
| 1107 | - $removals[] = $row['permission']; |
|
| 1108 | - else |
|
| 1109 | - $user_info['permissions'][] = $row['permission']; |
|
| 1148 | + if (empty($row['add_deny'])) { |
|
| 1149 | + $removals[] = $row['permission']; |
|
| 1150 | + } else { |
|
| 1151 | + $user_info['permissions'][] = $row['permission']; |
|
| 1152 | + } |
|
| 1110 | 1153 | } |
| 1111 | 1154 | $smcFunc['db_free_result']($request); |
| 1112 | 1155 | |
| 1113 | - if (isset($cache_groups)) |
|
| 1114 | - cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
| 1156 | + if (isset($cache_groups)) { |
|
| 1157 | + cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
| 1158 | + } |
|
| 1115 | 1159 | } |
| 1116 | 1160 | |
| 1117 | 1161 | // Get the board permissions. |
| 1118 | 1162 | if (!empty($board)) |
| 1119 | 1163 | { |
| 1120 | 1164 | // Make sure the board (if any) has been loaded by loadBoard(). |
| 1121 | - if (!isset($board_info['profile'])) |
|
| 1122 | - fatal_lang_error('no_board'); |
|
| 1165 | + if (!isset($board_info['profile'])) { |
|
| 1166 | + fatal_lang_error('no_board'); |
|
| 1167 | + } |
|
| 1123 | 1168 | |
| 1124 | 1169 | $request = $smcFunc['db_query']('', ' |
| 1125 | 1170 | SELECT permission, add_deny |
@@ -1135,20 +1180,23 @@ discard block |
||
| 1135 | 1180 | ); |
| 1136 | 1181 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1137 | 1182 | { |
| 1138 | - if (empty($row['add_deny'])) |
|
| 1139 | - $removals[] = $row['permission']; |
|
| 1140 | - else |
|
| 1141 | - $user_info['permissions'][] = $row['permission']; |
|
| 1183 | + if (empty($row['add_deny'])) { |
|
| 1184 | + $removals[] = $row['permission']; |
|
| 1185 | + } else { |
|
| 1186 | + $user_info['permissions'][] = $row['permission']; |
|
| 1187 | + } |
|
| 1142 | 1188 | } |
| 1143 | 1189 | $smcFunc['db_free_result']($request); |
| 1144 | 1190 | } |
| 1145 | 1191 | |
| 1146 | 1192 | // Remove all the permissions they shouldn't have ;). |
| 1147 | - if (!empty($modSettings['permission_enable_deny'])) |
|
| 1148 | - $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
| 1193 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
| 1194 | + $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
| 1195 | + } |
|
| 1149 | 1196 | |
| 1150 | - if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) |
|
| 1151 | - cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
| 1197 | + if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) { |
|
| 1198 | + cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
| 1199 | + } |
|
| 1152 | 1200 | |
| 1153 | 1201 | // Banned? Watch, don't touch.. |
| 1154 | 1202 | banPermissions(); |
@@ -1160,17 +1208,18 @@ discard block |
||
| 1160 | 1208 | { |
| 1161 | 1209 | require_once($sourcedir . '/Subs-Auth.php'); |
| 1162 | 1210 | rebuildModCache(); |
| 1211 | + } else { |
|
| 1212 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
| 1163 | 1213 | } |
| 1164 | - else |
|
| 1165 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
| 1166 | 1214 | |
| 1167 | 1215 | // This is a useful phantom permission added to the current user, and only the current user while they are logged in. |
| 1168 | 1216 | // For example this drastically simplifies certain changes to the profile area. |
| 1169 | 1217 | $user_info['permissions'][] = 'is_not_guest'; |
| 1170 | 1218 | // And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions. |
| 1171 | 1219 | $user_info['permissions'][] = 'profile_view_own'; |
| 1172 | - if (in_array('profile_view', $user_info['permissions'])) |
|
| 1173 | - $user_info['permissions'][] = 'profile_view_any'; |
|
| 1220 | + if (in_array('profile_view', $user_info['permissions'])) { |
|
| 1221 | + $user_info['permissions'][] = 'profile_view_any'; |
|
| 1222 | + } |
|
| 1174 | 1223 | } |
| 1175 | 1224 | } |
| 1176 | 1225 | |
@@ -1188,8 +1237,9 @@ discard block |
||
| 1188 | 1237 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
| 1189 | 1238 | |
| 1190 | 1239 | // Can't just look for no users :P. |
| 1191 | - if (empty($users)) |
|
| 1192 | - return array(); |
|
| 1240 | + if (empty($users)) { |
|
| 1241 | + return array(); |
|
| 1242 | + } |
|
| 1193 | 1243 | |
| 1194 | 1244 | // Pass the set value |
| 1195 | 1245 | $context['loadMemberContext_set'] = $set; |
@@ -1204,8 +1254,9 @@ discard block |
||
| 1204 | 1254 | for ($i = 0, $n = count($users); $i < $n; $i++) |
| 1205 | 1255 | { |
| 1206 | 1256 | $data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240); |
| 1207 | - if ($data == null) |
|
| 1208 | - continue; |
|
| 1257 | + if ($data == null) { |
|
| 1258 | + continue; |
|
| 1259 | + } |
|
| 1209 | 1260 | |
| 1210 | 1261 | $loaded_ids[] = $data['id_member']; |
| 1211 | 1262 | $user_profile[$data['id_member']] = $data; |
@@ -1272,16 +1323,19 @@ discard block |
||
| 1272 | 1323 | $row['avatar_original'] = !empty($row['avatar']) ? $row['avatar'] : ''; |
| 1273 | 1324 | |
| 1274 | 1325 | // Take care of proxying avatar if required, do this here for maximum reach |
| 1275 | - if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) |
|
| 1276 | - $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
| 1326 | + if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) { |
|
| 1327 | + $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
| 1328 | + } |
|
| 1277 | 1329 | |
| 1278 | 1330 | // Keep track of the member's normal member group |
| 1279 | 1331 | $row['primary_group'] = $row['member_group']; |
| 1280 | 1332 | |
| 1281 | - if (isset($row['member_ip'])) |
|
| 1282 | - $row['member_ip'] = inet_dtop($row['member_ip']); |
|
| 1283 | - if (isset($row['member_ip2'])) |
|
| 1284 | - $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
| 1333 | + if (isset($row['member_ip'])) { |
|
| 1334 | + $row['member_ip'] = inet_dtop($row['member_ip']); |
|
| 1335 | + } |
|
| 1336 | + if (isset($row['member_ip2'])) { |
|
| 1337 | + $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
| 1338 | + } |
|
| 1285 | 1339 | $new_loaded_ids[] = $row['id_member']; |
| 1286 | 1340 | $loaded_ids[] = $row['id_member']; |
| 1287 | 1341 | $row['options'] = array(); |
@@ -1300,8 +1354,9 @@ discard block |
||
| 1300 | 1354 | 'loaded_ids' => $new_loaded_ids, |
| 1301 | 1355 | ) |
| 1302 | 1356 | ); |
| 1303 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1304 | - $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
| 1357 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1358 | + $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
| 1359 | + } |
|
| 1305 | 1360 | $smcFunc['db_free_result']($request); |
| 1306 | 1361 | } |
| 1307 | 1362 | |
@@ -1312,10 +1367,11 @@ discard block |
||
| 1312 | 1367 | { |
| 1313 | 1368 | foreach ($loaded_ids as $a_member) |
| 1314 | 1369 | { |
| 1315 | - if (!empty($user_profile[$a_member]['additional_groups'])) |
|
| 1316 | - $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
| 1317 | - else |
|
| 1318 | - $groups = array($user_profile[$a_member]['id_group']); |
|
| 1370 | + if (!empty($user_profile[$a_member]['additional_groups'])) { |
|
| 1371 | + $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
| 1372 | + } else { |
|
| 1373 | + $groups = array($user_profile[$a_member]['id_group']); |
|
| 1374 | + } |
|
| 1319 | 1375 | |
| 1320 | 1376 | $temp = array_intersect($groups, array_keys($board_info['moderator_groups'])); |
| 1321 | 1377 | |
@@ -1328,8 +1384,9 @@ discard block |
||
| 1328 | 1384 | |
| 1329 | 1385 | if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
| 1330 | 1386 | { |
| 1331 | - for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) |
|
| 1332 | - cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
| 1387 | + for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) { |
|
| 1388 | + cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
| 1389 | + } |
|
| 1333 | 1390 | } |
| 1334 | 1391 | |
| 1335 | 1392 | // Are we loading any moderators? If so, fix their group data... |
@@ -1355,14 +1412,17 @@ discard block |
||
| 1355 | 1412 | foreach ($temp_mods as $id) |
| 1356 | 1413 | { |
| 1357 | 1414 | // By popular demand, don't show admins or global moderators as moderators. |
| 1358 | - if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) |
|
| 1359 | - $user_profile[$id]['member_group'] = $row['member_group']; |
|
| 1415 | + if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) { |
|
| 1416 | + $user_profile[$id]['member_group'] = $row['member_group']; |
|
| 1417 | + } |
|
| 1360 | 1418 | |
| 1361 | 1419 | // If the Moderator group has no color or icons, but their group does... don't overwrite. |
| 1362 | - if (!empty($row['icons'])) |
|
| 1363 | - $user_profile[$id]['icons'] = $row['icons']; |
|
| 1364 | - if (!empty($row['member_group_color'])) |
|
| 1365 | - $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
| 1420 | + if (!empty($row['icons'])) { |
|
| 1421 | + $user_profile[$id]['icons'] = $row['icons']; |
|
| 1422 | + } |
|
| 1423 | + if (!empty($row['member_group_color'])) { |
|
| 1424 | + $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
| 1425 | + } |
|
| 1366 | 1426 | } |
| 1367 | 1427 | } |
| 1368 | 1428 | |
@@ -1384,12 +1444,14 @@ discard block |
||
| 1384 | 1444 | static $loadedLanguages = array(); |
| 1385 | 1445 | |
| 1386 | 1446 | // If this person's data is already loaded, skip it. |
| 1387 | - if (isset($dataLoaded[$user])) |
|
| 1388 | - return true; |
|
| 1447 | + if (isset($dataLoaded[$user])) { |
|
| 1448 | + return true; |
|
| 1449 | + } |
|
| 1389 | 1450 | |
| 1390 | 1451 | // We can't load guests or members not loaded by loadMemberData()! |
| 1391 | - if ($user == 0) |
|
| 1392 | - return false; |
|
| 1452 | + if ($user == 0) { |
|
| 1453 | + return false; |
|
| 1454 | + } |
|
| 1393 | 1455 | if (!isset($user_profile[$user])) |
| 1394 | 1456 | { |
| 1395 | 1457 | trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING); |
@@ -1415,12 +1477,16 @@ discard block |
||
| 1415 | 1477 | $buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array(); |
| 1416 | 1478 | |
| 1417 | 1479 | //We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme |
| 1418 | - if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists |
|
| 1480 | + if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) { |
|
| 1481 | + //icon is set and exists |
|
| 1419 | 1482 | $group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1]; |
| 1420 | - elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default |
|
| 1483 | + } elseif (isset($profile['icons'][1])) { |
|
| 1484 | + //icon is set and doesn't exist, fallback to default |
|
| 1421 | 1485 | $group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1]; |
| 1422 | - else //not set, bye bye |
|
| 1486 | + } else { |
|
| 1487 | + //not set, bye bye |
|
| 1423 | 1488 | $group_icon_url = ''; |
| 1489 | + } |
|
| 1424 | 1490 | |
| 1425 | 1491 | // These minimal values are always loaded |
| 1426 | 1492 | $memberContext[$user] = array( |
@@ -1439,8 +1505,9 @@ discard block |
||
| 1439 | 1505 | if ($context['loadMemberContext_set'] != 'minimal') |
| 1440 | 1506 | { |
| 1441 | 1507 | // Go the extra mile and load the user's native language name. |
| 1442 | - if (empty($loadedLanguages)) |
|
| 1443 | - $loadedLanguages = getLanguages(); |
|
| 1508 | + if (empty($loadedLanguages)) { |
|
| 1509 | + $loadedLanguages = getLanguages(); |
|
| 1510 | + } |
|
| 1444 | 1511 | |
| 1445 | 1512 | $memberContext[$user] += array( |
| 1446 | 1513 | 'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>', |
@@ -1495,31 +1562,33 @@ discard block |
||
| 1495 | 1562 | { |
| 1496 | 1563 | if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://'))) |
| 1497 | 1564 | { |
| 1498 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) |
|
| 1499 | - $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
| 1500 | - else |
|
| 1501 | - $image = get_gravatar_url($profile['email_address']); |
|
| 1502 | - } |
|
| 1503 | - else |
|
| 1565 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) { |
|
| 1566 | + $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
| 1567 | + } else { |
|
| 1568 | + $image = get_gravatar_url($profile['email_address']); |
|
| 1569 | + } |
|
| 1570 | + } else |
|
| 1504 | 1571 | { |
| 1505 | 1572 | // So it's stored in the member table? |
| 1506 | 1573 | if (!empty($profile['avatar'])) |
| 1507 | 1574 | { |
| 1508 | 1575 | $image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']; |
| 1576 | + } elseif (!empty($profile['filename'])) { |
|
| 1577 | + $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
| 1509 | 1578 | } |
| 1510 | - elseif (!empty($profile['filename'])) |
|
| 1511 | - $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
| 1512 | 1579 | // Right... no avatar...use the default one |
| 1513 | - else |
|
| 1514 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 1580 | + else { |
|
| 1581 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 1582 | + } |
|
| 1515 | 1583 | } |
| 1516 | - if (!empty($image)) |
|
| 1517 | - $memberContext[$user]['avatar'] = array( |
|
| 1584 | + if (!empty($image)) { |
|
| 1585 | + $memberContext[$user]['avatar'] = array( |
|
| 1518 | 1586 | 'name' => $profile['avatar'], |
| 1519 | 1587 | 'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">', |
| 1520 | 1588 | 'href' => $image, |
| 1521 | 1589 | 'url' => $image, |
| 1522 | 1590 | ); |
| 1591 | + } |
|
| 1523 | 1592 | } |
| 1524 | 1593 | |
| 1525 | 1594 | // Are we also loading the members custom fields into context? |
@@ -1527,35 +1596,41 @@ discard block |
||
| 1527 | 1596 | { |
| 1528 | 1597 | $memberContext[$user]['custom_fields'] = array(); |
| 1529 | 1598 | |
| 1530 | - if (!isset($context['display_fields'])) |
|
| 1531 | - $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
| 1599 | + if (!isset($context['display_fields'])) { |
|
| 1600 | + $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
| 1601 | + } |
|
| 1532 | 1602 | |
| 1533 | 1603 | foreach ($context['display_fields'] as $custom) |
| 1534 | 1604 | { |
| 1535 | - if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) |
|
| 1536 | - continue; |
|
| 1605 | + if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) { |
|
| 1606 | + continue; |
|
| 1607 | + } |
|
| 1537 | 1608 | |
| 1538 | 1609 | $value = $profile['options'][$custom['col_name']]; |
| 1539 | 1610 | |
| 1540 | 1611 | // Don't show the "disabled" option for the "gender" field. |
| 1541 | - if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') |
|
| 1542 | - continue; |
|
| 1612 | + if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') { |
|
| 1613 | + continue; |
|
| 1614 | + } |
|
| 1543 | 1615 | |
| 1544 | 1616 | // BBC? |
| 1545 | - if ($custom['bbc']) |
|
| 1546 | - $value = parse_bbc($value); |
|
| 1617 | + if ($custom['bbc']) { |
|
| 1618 | + $value = parse_bbc($value); |
|
| 1619 | + } |
|
| 1547 | 1620 | // ... or checkbox? |
| 1548 | - elseif (isset($custom['type']) && $custom['type'] == 'check') |
|
| 1549 | - $value = $value ? $txt['yes'] : $txt['no']; |
|
| 1621 | + elseif (isset($custom['type']) && $custom['type'] == 'check') { |
|
| 1622 | + $value = $value ? $txt['yes'] : $txt['no']; |
|
| 1623 | + } |
|
| 1550 | 1624 | |
| 1551 | 1625 | // Enclosing the user input within some other text? |
| 1552 | - if (!empty($custom['enclose'])) |
|
| 1553 | - $value = strtr($custom['enclose'], array( |
|
| 1626 | + if (!empty($custom['enclose'])) { |
|
| 1627 | + $value = strtr($custom['enclose'], array( |
|
| 1554 | 1628 | '{SCRIPTURL}' => $scripturl, |
| 1555 | 1629 | '{IMAGES_URL}' => $settings['images_url'], |
| 1556 | 1630 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1557 | 1631 | '{INPUT}' => $value, |
| 1558 | 1632 | )); |
| 1633 | + } |
|
| 1559 | 1634 | |
| 1560 | 1635 | $memberContext[$user]['custom_fields'][] = array( |
| 1561 | 1636 | 'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'], |
@@ -1582,8 +1657,9 @@ discard block |
||
| 1582 | 1657 | global $smcFunc, $txt, $scripturl, $settings; |
| 1583 | 1658 | |
| 1584 | 1659 | // Do not waste my time... |
| 1585 | - if (empty($users) || empty($params)) |
|
| 1586 | - return false; |
|
| 1660 | + if (empty($users) || empty($params)) { |
|
| 1661 | + return false; |
|
| 1662 | + } |
|
| 1587 | 1663 | |
| 1588 | 1664 | // Make sure it's an array. |
| 1589 | 1665 | $users = !is_array($users) ? array($users) : array_unique($users); |
@@ -1607,31 +1683,36 @@ discard block |
||
| 1607 | 1683 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1608 | 1684 | { |
| 1609 | 1685 | // BBC? |
| 1610 | - if (!empty($row['bbc'])) |
|
| 1611 | - $row['value'] = parse_bbc($row['value']); |
|
| 1686 | + if (!empty($row['bbc'])) { |
|
| 1687 | + $row['value'] = parse_bbc($row['value']); |
|
| 1688 | + } |
|
| 1612 | 1689 | |
| 1613 | 1690 | // ... or checkbox? |
| 1614 | - elseif (isset($row['type']) && $row['type'] == 'check') |
|
| 1615 | - $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
| 1691 | + elseif (isset($row['type']) && $row['type'] == 'check') { |
|
| 1692 | + $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
| 1693 | + } |
|
| 1616 | 1694 | |
| 1617 | 1695 | // Enclosing the user input within some other text? |
| 1618 | - if (!empty($row['enclose'])) |
|
| 1619 | - $row['value'] = strtr($row['enclose'], array( |
|
| 1696 | + if (!empty($row['enclose'])) { |
|
| 1697 | + $row['value'] = strtr($row['enclose'], array( |
|
| 1620 | 1698 | '{SCRIPTURL}' => $scripturl, |
| 1621 | 1699 | '{IMAGES_URL}' => $settings['images_url'], |
| 1622 | 1700 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1623 | 1701 | '{INPUT}' => un_htmlspecialchars($row['value']), |
| 1624 | 1702 | )); |
| 1703 | + } |
|
| 1625 | 1704 | |
| 1626 | 1705 | // Send a simple array if there is just 1 param |
| 1627 | - if (count($params) == 1) |
|
| 1628 | - $return[$row['id_member']] = $row; |
|
| 1706 | + if (count($params) == 1) { |
|
| 1707 | + $return[$row['id_member']] = $row; |
|
| 1708 | + } |
|
| 1629 | 1709 | |
| 1630 | 1710 | // More than 1? knock yourself out... |
| 1631 | 1711 | else |
| 1632 | 1712 | { |
| 1633 | - if (!isset($return[$row['id_member']])) |
|
| 1634 | - $return[$row['id_member']] = array(); |
|
| 1713 | + if (!isset($return[$row['id_member']])) { |
|
| 1714 | + $return[$row['id_member']] = array(); |
|
| 1715 | + } |
|
| 1635 | 1716 | |
| 1636 | 1717 | $return[$row['id_member']][$row['variable']] = $row; |
| 1637 | 1718 | } |
@@ -1665,8 +1746,9 @@ discard block |
||
| 1665 | 1746 | global $context; |
| 1666 | 1747 | |
| 1667 | 1748 | // Don't know any browser! |
| 1668 | - if (empty($context['browser'])) |
|
| 1669 | - detectBrowser(); |
|
| 1749 | + if (empty($context['browser'])) { |
|
| 1750 | + detectBrowser(); |
|
| 1751 | + } |
|
| 1670 | 1752 | |
| 1671 | 1753 | return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false; |
| 1672 | 1754 | } |
@@ -1684,8 +1766,9 @@ discard block |
||
| 1684 | 1766 | global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled; |
| 1685 | 1767 | |
| 1686 | 1768 | // The theme was specified by parameter. |
| 1687 | - if (!empty($id_theme)) |
|
| 1688 | - $id_theme = (int) $id_theme; |
|
| 1769 | + if (!empty($id_theme)) { |
|
| 1770 | + $id_theme = (int) $id_theme; |
|
| 1771 | + } |
|
| 1689 | 1772 | // The theme was specified by REQUEST. |
| 1690 | 1773 | elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
| 1691 | 1774 | { |
@@ -1693,54 +1776,61 @@ discard block |
||
| 1693 | 1776 | $_SESSION['id_theme'] = $id_theme; |
| 1694 | 1777 | } |
| 1695 | 1778 | // The theme was specified by REQUEST... previously. |
| 1696 | - elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
|
| 1697 | - $id_theme = (int) $_SESSION['id_theme']; |
|
| 1779 | + elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) { |
|
| 1780 | + $id_theme = (int) $_SESSION['id_theme']; |
|
| 1781 | + } |
|
| 1698 | 1782 | // The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.) |
| 1699 | - elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) |
|
| 1700 | - $id_theme = $user_info['theme']; |
|
| 1783 | + elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) { |
|
| 1784 | + $id_theme = $user_info['theme']; |
|
| 1785 | + } |
|
| 1701 | 1786 | // The theme was specified by the board. |
| 1702 | - elseif (!empty($board_info['theme'])) |
|
| 1703 | - $id_theme = $board_info['theme']; |
|
| 1787 | + elseif (!empty($board_info['theme'])) { |
|
| 1788 | + $id_theme = $board_info['theme']; |
|
| 1789 | + } |
|
| 1704 | 1790 | // The theme is the forum's default. |
| 1705 | - else |
|
| 1706 | - $id_theme = $modSettings['theme_guests']; |
|
| 1791 | + else { |
|
| 1792 | + $id_theme = $modSettings['theme_guests']; |
|
| 1793 | + } |
|
| 1707 | 1794 | |
| 1708 | 1795 | // We already load the basic stuff? |
| 1709 | 1796 | if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme ) |
| 1710 | 1797 | { |
| 1711 | 1798 | // Verify the id_theme... no foul play. |
| 1712 | 1799 | // Always allow the board specific theme, if they are overriding. |
| 1713 | - if (!empty($board_info['theme']) && $board_info['override_theme']) |
|
| 1714 | - $id_theme = $board_info['theme']; |
|
| 1800 | + if (!empty($board_info['theme']) && $board_info['override_theme']) { |
|
| 1801 | + $id_theme = $board_info['theme']; |
|
| 1802 | + } |
|
| 1715 | 1803 | // If they have specified a particular theme to use with SSI allow it to be used. |
| 1716 | - elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) |
|
| 1717 | - $id_theme = (int) $id_theme; |
|
| 1718 | - elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
| 1804 | + elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) { |
|
| 1805 | + $id_theme = (int) $id_theme; |
|
| 1806 | + } elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
| 1719 | 1807 | { |
| 1720 | 1808 | $themes = explode(',', $modSettings['enableThemes']); |
| 1721 | - if (!in_array($id_theme, $themes)) |
|
| 1722 | - $id_theme = $modSettings['theme_guests']; |
|
| 1723 | - else |
|
| 1724 | - $id_theme = (int) $id_theme; |
|
| 1809 | + if (!in_array($id_theme, $themes)) { |
|
| 1810 | + $id_theme = $modSettings['theme_guests']; |
|
| 1811 | + } else { |
|
| 1812 | + $id_theme = (int) $id_theme; |
|
| 1813 | + } |
|
| 1814 | + } else { |
|
| 1815 | + $id_theme = (int) $id_theme; |
|
| 1725 | 1816 | } |
| 1726 | - else |
|
| 1727 | - $id_theme = (int) $id_theme; |
|
| 1728 | 1817 | |
| 1729 | 1818 | $member = empty($user_info['id']) ? -1 : $user_info['id']; |
| 1730 | 1819 | |
| 1731 | 1820 | // Disable image proxy if we don't have SSL enabled |
| 1732 | - if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) |
|
| 1733 | - $image_proxy_enabled = false; |
|
| 1821 | + if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) { |
|
| 1822 | + $image_proxy_enabled = false; |
|
| 1823 | + } |
|
| 1734 | 1824 | |
| 1735 | 1825 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && ($temp = cache_get_data('theme_settings-' . $id_theme . ':' . $member, 60)) != null && time() - 60 > $modSettings['settings_updated']) |
| 1736 | 1826 | { |
| 1737 | 1827 | $themeData = $temp; |
| 1738 | 1828 | $flag = true; |
| 1829 | + } elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) { |
|
| 1830 | + $themeData = $temp + array($member => array()); |
|
| 1831 | + } else { |
|
| 1832 | + $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
| 1739 | 1833 | } |
| 1740 | - elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) |
|
| 1741 | - $themeData = $temp + array($member => array()); |
|
| 1742 | - else |
|
| 1743 | - $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
| 1744 | 1834 | |
| 1745 | 1835 | if (empty($flag)) |
| 1746 | 1836 | { |
@@ -1759,31 +1849,37 @@ discard block |
||
| 1759 | 1849 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 1760 | 1850 | { |
| 1761 | 1851 | // There are just things we shouldn't be able to change as members. |
| 1762 | - if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) |
|
| 1763 | - continue; |
|
| 1852 | + if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) { |
|
| 1853 | + continue; |
|
| 1854 | + } |
|
| 1764 | 1855 | |
| 1765 | 1856 | // If this is the theme_dir of the default theme, store it. |
| 1766 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) |
|
| 1767 | - $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
| 1857 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) { |
|
| 1858 | + $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
| 1859 | + } |
|
| 1768 | 1860 | |
| 1769 | 1861 | // If this isn't set yet, is a theme option, or is not the default theme.. |
| 1770 | - if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') |
|
| 1771 | - $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
| 1862 | + if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') { |
|
| 1863 | + $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
| 1864 | + } |
|
| 1772 | 1865 | } |
| 1773 | 1866 | $smcFunc['db_free_result']($result); |
| 1774 | 1867 | |
| 1775 | - if (!empty($themeData[-1])) |
|
| 1776 | - foreach ($themeData[-1] as $k => $v) |
|
| 1868 | + if (!empty($themeData[-1])) { |
|
| 1869 | + foreach ($themeData[-1] as $k => $v) |
|
| 1777 | 1870 | { |
| 1778 | 1871 | if (!isset($themeData[$member][$k])) |
| 1779 | 1872 | $themeData[$member][$k] = $v; |
| 1873 | + } |
|
| 1780 | 1874 | } |
| 1781 | 1875 | |
| 1782 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 1783 | - cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
| 1876 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 1877 | + cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
| 1878 | + } |
|
| 1784 | 1879 | // Only if we didn't already load that part of the cache... |
| 1785 | - elseif (!isset($temp)) |
|
| 1786 | - cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
| 1880 | + elseif (!isset($temp)) { |
|
| 1881 | + cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
| 1882 | + } |
|
| 1787 | 1883 | } |
| 1788 | 1884 | |
| 1789 | 1885 | $settings = $themeData[0]; |
@@ -1800,22 +1896,26 @@ discard block |
||
| 1800 | 1896 | $settings['template_dirs'][] = $settings['theme_dir']; |
| 1801 | 1897 | |
| 1802 | 1898 | // Based on theme (if there is one). |
| 1803 | - if (!empty($settings['base_theme_dir'])) |
|
| 1804 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1899 | + if (!empty($settings['base_theme_dir'])) { |
|
| 1900 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1901 | + } |
|
| 1805 | 1902 | |
| 1806 | 1903 | // Lastly the default theme. |
| 1807 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
| 1808 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1904 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
| 1905 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1906 | + } |
|
| 1809 | 1907 | } |
| 1810 | 1908 | |
| 1811 | 1909 | |
| 1812 | - if (!$initialize) |
|
| 1813 | - return; |
|
| 1910 | + if (!$initialize) { |
|
| 1911 | + return; |
|
| 1912 | + } |
|
| 1814 | 1913 | |
| 1815 | 1914 | // Check to see if we're forcing SSL |
| 1816 | 1915 | if (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 && empty($maintenance) && |
| 1817 | - (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') |
|
| 1818 | - redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://'))); |
|
| 1916 | + (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') { |
|
| 1917 | + redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://'))); |
|
| 1918 | + } |
|
| 1819 | 1919 | |
| 1820 | 1920 | // Check to see if they're accessing it from the wrong place. |
| 1821 | 1921 | if (isset($_SERVER['HTTP_HOST']) || isset($_SERVER['SERVER_NAME'])) |
@@ -1823,8 +1923,9 @@ discard block |
||
| 1823 | 1923 | $detected_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://'; |
| 1824 | 1924 | $detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']; |
| 1825 | 1925 | $temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')); |
| 1826 | - if ($temp != '/') |
|
| 1827 | - $detected_url .= $temp; |
|
| 1926 | + if ($temp != '/') { |
|
| 1927 | + $detected_url .= $temp; |
|
| 1928 | + } |
|
| 1828 | 1929 | } |
| 1829 | 1930 | if (isset($detected_url) && $detected_url != $boardurl) |
| 1830 | 1931 | { |
@@ -1836,8 +1937,9 @@ discard block |
||
| 1836 | 1937 | foreach ($aliases as $alias) |
| 1837 | 1938 | { |
| 1838 | 1939 | // Rip off all the boring parts, spaces, etc. |
| 1839 | - if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) |
|
| 1840 | - $do_fix = true; |
|
| 1940 | + if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) { |
|
| 1941 | + $do_fix = true; |
|
| 1942 | + } |
|
| 1841 | 1943 | } |
| 1842 | 1944 | } |
| 1843 | 1945 | |
@@ -1845,20 +1947,22 @@ discard block |
||
| 1845 | 1947 | if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI') |
| 1846 | 1948 | { |
| 1847 | 1949 | // Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;). |
| 1848 | - if (empty($_GET)) |
|
| 1849 | - redirectexit('wwwRedirect'); |
|
| 1850 | - else |
|
| 1950 | + if (empty($_GET)) { |
|
| 1951 | + redirectexit('wwwRedirect'); |
|
| 1952 | + } else |
|
| 1851 | 1953 | { |
| 1852 | 1954 | list ($k, $v) = each($_GET); |
| 1853 | 1955 | |
| 1854 | - if ($k != 'wwwRedirect') |
|
| 1855 | - redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
| 1956 | + if ($k != 'wwwRedirect') { |
|
| 1957 | + redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
| 1958 | + } |
|
| 1856 | 1959 | } |
| 1857 | 1960 | } |
| 1858 | 1961 | |
| 1859 | 1962 | // #3 is just a check for SSL... |
| 1860 | - if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) |
|
| 1861 | - $do_fix = true; |
|
| 1963 | + if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) { |
|
| 1964 | + $do_fix = true; |
|
| 1965 | + } |
|
| 1862 | 1966 | |
| 1863 | 1967 | // Okay, #4 - perhaps it's an IP address? We're gonna want to use that one, then. (assuming it's the IP or something...) |
| 1864 | 1968 | if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1) |
@@ -1892,8 +1996,9 @@ discard block |
||
| 1892 | 1996 | $board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl)); |
| 1893 | 1997 | } |
| 1894 | 1998 | } |
| 1895 | - foreach ($context['linktree'] as $k => $dummy) |
|
| 1896 | - $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
| 1999 | + foreach ($context['linktree'] as $k => $dummy) { |
|
| 2000 | + $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
| 2001 | + } |
|
| 1897 | 2002 | } |
| 1898 | 2003 | } |
| 1899 | 2004 | // Set up the contextual user array. |
@@ -1912,16 +2017,16 @@ discard block |
||
| 1912 | 2017 | 'email' => $user_info['email'], |
| 1913 | 2018 | 'ignoreusers' => $user_info['ignoreusers'], |
| 1914 | 2019 | ); |
| 1915 | - if (!$context['user']['is_guest']) |
|
| 1916 | - $context['user']['name'] = $user_info['name']; |
|
| 1917 | - elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) |
|
| 1918 | - $context['user']['name'] = $txt['guest_title']; |
|
| 2020 | + if (!$context['user']['is_guest']) { |
|
| 2021 | + $context['user']['name'] = $user_info['name']; |
|
| 2022 | + } elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) { |
|
| 2023 | + $context['user']['name'] = $txt['guest_title']; |
|
| 2024 | + } |
|
| 1919 | 2025 | |
| 1920 | 2026 | // Determine the current smiley set. |
| 1921 | 2027 | $user_info['smiley_set'] = (!in_array($user_info['smiley_set'], explode(',', $modSettings['smiley_sets_known'])) && $user_info['smiley_set'] != 'none') || empty($modSettings['smiley_sets_enable']) ? (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default']) : $user_info['smiley_set']; |
| 1922 | 2028 | $context['user']['smiley_set'] = $user_info['smiley_set']; |
| 1923 | - } |
|
| 1924 | - else |
|
| 2029 | + } else |
|
| 1925 | 2030 | { |
| 1926 | 2031 | // What to do when there is no $user_info (e.g., an error very early in the login process) |
| 1927 | 2032 | $context['user'] = array( |
@@ -1955,18 +2060,24 @@ discard block |
||
| 1955 | 2060 | } |
| 1956 | 2061 | |
| 1957 | 2062 | // Some basic information... |
| 1958 | - if (!isset($context['html_headers'])) |
|
| 1959 | - $context['html_headers'] = ''; |
|
| 1960 | - if (!isset($context['javascript_files'])) |
|
| 1961 | - $context['javascript_files'] = array(); |
|
| 1962 | - if (!isset($context['css_files'])) |
|
| 1963 | - $context['css_files'] = array(); |
|
| 1964 | - if (!isset($context['css_header'])) |
|
| 1965 | - $context['css_header'] = array(); |
|
| 1966 | - if (!isset($context['javascript_inline'])) |
|
| 1967 | - $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
| 1968 | - if (!isset($context['javascript_vars'])) |
|
| 1969 | - $context['javascript_vars'] = array(); |
|
| 2063 | + if (!isset($context['html_headers'])) { |
|
| 2064 | + $context['html_headers'] = ''; |
|
| 2065 | + } |
|
| 2066 | + if (!isset($context['javascript_files'])) { |
|
| 2067 | + $context['javascript_files'] = array(); |
|
| 2068 | + } |
|
| 2069 | + if (!isset($context['css_files'])) { |
|
| 2070 | + $context['css_files'] = array(); |
|
| 2071 | + } |
|
| 2072 | + if (!isset($context['css_header'])) { |
|
| 2073 | + $context['css_header'] = array(); |
|
| 2074 | + } |
|
| 2075 | + if (!isset($context['javascript_inline'])) { |
|
| 2076 | + $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
| 2077 | + } |
|
| 2078 | + if (!isset($context['javascript_vars'])) { |
|
| 2079 | + $context['javascript_vars'] = array(); |
|
| 2080 | + } |
|
| 1970 | 2081 | |
| 1971 | 2082 | $context['login_url'] = (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl) . '?action=login2'; |
| 1972 | 2083 | $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | '; |
@@ -1978,16 +2089,18 @@ discard block |
||
| 1978 | 2089 | $context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null; |
| 1979 | 2090 | $context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null; |
| 1980 | 2091 | $context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3; |
| 1981 | - if (isset($modSettings['load_average'])) |
|
| 1982 | - $context['load_average'] = $modSettings['load_average']; |
|
| 2092 | + if (isset($modSettings['load_average'])) { |
|
| 2093 | + $context['load_average'] = $modSettings['load_average']; |
|
| 2094 | + } |
|
| 1983 | 2095 | |
| 1984 | 2096 | // Detect the browser. This is separated out because it's also used in attachment downloads |
| 1985 | 2097 | detectBrowser(); |
| 1986 | 2098 | |
| 1987 | 2099 | // Set the top level linktree up. |
| 1988 | 2100 | // Note that if we're dealing with certain very early errors (e.g., login) the linktree might not be set yet... |
| 1989 | - if (empty($context['linktree'])) |
|
| 1990 | - $context['linktree'] = array(); |
|
| 2101 | + if (empty($context['linktree'])) { |
|
| 2102 | + $context['linktree'] = array(); |
|
| 2103 | + } |
|
| 1991 | 2104 | array_unshift($context['linktree'], array( |
| 1992 | 2105 | 'url' => $scripturl, |
| 1993 | 2106 | 'name' => $context['forum_name_html_safe'] |
@@ -1996,8 +2109,9 @@ discard block |
||
| 1996 | 2109 | // This allows sticking some HTML on the page output - useful for controls. |
| 1997 | 2110 | $context['insert_after_template'] = ''; |
| 1998 | 2111 | |
| 1999 | - if (!isset($txt)) |
|
| 2000 | - $txt = array(); |
|
| 2112 | + if (!isset($txt)) { |
|
| 2113 | + $txt = array(); |
|
| 2114 | + } |
|
| 2001 | 2115 | |
| 2002 | 2116 | $simpleActions = array( |
| 2003 | 2117 | 'findmember', |
@@ -2043,9 +2157,10 @@ discard block |
||
| 2043 | 2157 | |
| 2044 | 2158 | // See if theres any extra param to check. |
| 2045 | 2159 | $requiresXML = false; |
| 2046 | - foreach ($extraParams as $key => $extra) |
|
| 2047 | - if (isset($_REQUEST[$extra])) |
|
| 2160 | + foreach ($extraParams as $key => $extra) { |
|
| 2161 | + if (isset($_REQUEST[$extra])) |
|
| 2048 | 2162 | $requiresXML = true; |
| 2163 | + } |
|
| 2049 | 2164 | |
| 2050 | 2165 | // Output is fully XML, so no need for the index template. |
| 2051 | 2166 | if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML)) |
@@ -2060,37 +2175,39 @@ discard block |
||
| 2060 | 2175 | { |
| 2061 | 2176 | loadLanguage('index+Modifications'); |
| 2062 | 2177 | $context['template_layers'] = array(); |
| 2063 | - } |
|
| 2064 | - |
|
| 2065 | - else |
|
| 2178 | + } else |
|
| 2066 | 2179 | { |
| 2067 | 2180 | // Custom templates to load, or just default? |
| 2068 | - if (isset($settings['theme_templates'])) |
|
| 2069 | - $templates = explode(',', $settings['theme_templates']); |
|
| 2070 | - else |
|
| 2071 | - $templates = array('index'); |
|
| 2181 | + if (isset($settings['theme_templates'])) { |
|
| 2182 | + $templates = explode(',', $settings['theme_templates']); |
|
| 2183 | + } else { |
|
| 2184 | + $templates = array('index'); |
|
| 2185 | + } |
|
| 2072 | 2186 | |
| 2073 | 2187 | // Load each template... |
| 2074 | - foreach ($templates as $template) |
|
| 2075 | - loadTemplate($template); |
|
| 2188 | + foreach ($templates as $template) { |
|
| 2189 | + loadTemplate($template); |
|
| 2190 | + } |
|
| 2076 | 2191 | |
| 2077 | 2192 | // ...and attempt to load their associated language files. |
| 2078 | 2193 | $required_files = implode('+', array_merge($templates, array('Modifications'))); |
| 2079 | 2194 | loadLanguage($required_files, '', false); |
| 2080 | 2195 | |
| 2081 | 2196 | // Custom template layers? |
| 2082 | - if (isset($settings['theme_layers'])) |
|
| 2083 | - $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
| 2084 | - else |
|
| 2085 | - $context['template_layers'] = array('html', 'body'); |
|
| 2197 | + if (isset($settings['theme_layers'])) { |
|
| 2198 | + $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
| 2199 | + } else { |
|
| 2200 | + $context['template_layers'] = array('html', 'body'); |
|
| 2201 | + } |
|
| 2086 | 2202 | } |
| 2087 | 2203 | |
| 2088 | 2204 | // Initialize the theme. |
| 2089 | 2205 | loadSubTemplate('init', 'ignore'); |
| 2090 | 2206 | |
| 2091 | 2207 | // Allow overriding the board wide time/number formats. |
| 2092 | - if (empty($user_settings['time_format']) && !empty($txt['time_format'])) |
|
| 2093 | - $user_info['time_format'] = $txt['time_format']; |
|
| 2208 | + if (empty($user_settings['time_format']) && !empty($txt['time_format'])) { |
|
| 2209 | + $user_info['time_format'] = $txt['time_format']; |
|
| 2210 | + } |
|
| 2094 | 2211 | |
| 2095 | 2212 | // Set the character set from the template. |
| 2096 | 2213 | $context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']; |
@@ -2098,12 +2215,14 @@ discard block |
||
| 2098 | 2215 | $context['right_to_left'] = !empty($txt['lang_rtl']); |
| 2099 | 2216 | |
| 2100 | 2217 | // Guests may still need a name. |
| 2101 | - if ($context['user']['is_guest'] && empty($context['user']['name'])) |
|
| 2102 | - $context['user']['name'] = $txt['guest_title']; |
|
| 2218 | + if ($context['user']['is_guest'] && empty($context['user']['name'])) { |
|
| 2219 | + $context['user']['name'] = $txt['guest_title']; |
|
| 2220 | + } |
|
| 2103 | 2221 | |
| 2104 | 2222 | // Any theme-related strings that need to be loaded? |
| 2105 | - if (!empty($settings['require_theme_strings'])) |
|
| 2106 | - loadLanguage('ThemeStrings', '', false); |
|
| 2223 | + if (!empty($settings['require_theme_strings'])) { |
|
| 2224 | + loadLanguage('ThemeStrings', '', false); |
|
| 2225 | + } |
|
| 2107 | 2226 | |
| 2108 | 2227 | // Make a special URL for the language. |
| 2109 | 2228 | $settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']); |
@@ -2114,8 +2233,9 @@ discard block |
||
| 2114 | 2233 | // Here is my luvly Responsive CSS |
| 2115 | 2234 | loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true), 'smf_responsive'); |
| 2116 | 2235 | |
| 2117 | - if ($context['right_to_left']) |
|
| 2118 | - loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
| 2236 | + if ($context['right_to_left']) { |
|
| 2237 | + loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
| 2238 | + } |
|
| 2119 | 2239 | |
| 2120 | 2240 | // We allow theme variants, because we're cool. |
| 2121 | 2241 | $context['theme_variant'] = ''; |
@@ -2123,14 +2243,17 @@ discard block |
||
| 2123 | 2243 | if (!empty($settings['theme_variants'])) |
| 2124 | 2244 | { |
| 2125 | 2245 | // Overriding - for previews and that ilk. |
| 2126 | - if (!empty($_REQUEST['variant'])) |
|
| 2127 | - $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
| 2246 | + if (!empty($_REQUEST['variant'])) { |
|
| 2247 | + $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
| 2248 | + } |
|
| 2128 | 2249 | // User selection? |
| 2129 | - if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) |
|
| 2130 | - $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
| 2250 | + if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) { |
|
| 2251 | + $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
| 2252 | + } |
|
| 2131 | 2253 | // If not a user variant, select the default. |
| 2132 | - if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) |
|
| 2133 | - $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
| 2254 | + if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) { |
|
| 2255 | + $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
| 2256 | + } |
|
| 2134 | 2257 | |
| 2135 | 2258 | // Do this to keep things easier in the templates. |
| 2136 | 2259 | $context['theme_variant'] = '_' . $context['theme_variant']; |
@@ -2139,20 +2262,23 @@ discard block |
||
| 2139 | 2262 | if (!empty($context['theme_variant'])) |
| 2140 | 2263 | { |
| 2141 | 2264 | loadCSSFile('index' . $context['theme_variant'] . '.css', array(), 'smf_index' . $context['theme_variant']); |
| 2142 | - if ($context['right_to_left']) |
|
| 2143 | - loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
| 2265 | + if ($context['right_to_left']) { |
|
| 2266 | + loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
| 2267 | + } |
|
| 2144 | 2268 | } |
| 2145 | 2269 | } |
| 2146 | 2270 | |
| 2147 | 2271 | // Let's be compatible with old themes! |
| 2148 | - if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) |
|
| 2149 | - $context['template_layers'] = array('main'); |
|
| 2272 | + if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) { |
|
| 2273 | + $context['template_layers'] = array('main'); |
|
| 2274 | + } |
|
| 2150 | 2275 | |
| 2151 | 2276 | $context['tabindex'] = 1; |
| 2152 | 2277 | |
| 2153 | 2278 | // Compatibility. |
| 2154 | - if (!isset($settings['theme_version'])) |
|
| 2155 | - $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
| 2279 | + if (!isset($settings['theme_version'])) { |
|
| 2280 | + $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
| 2281 | + } |
|
| 2156 | 2282 | |
| 2157 | 2283 | // Default JS variables for use in every theme |
| 2158 | 2284 | $context['javascript_vars'] = array( |
@@ -2171,18 +2297,18 @@ discard block |
||
| 2171 | 2297 | ); |
| 2172 | 2298 | |
| 2173 | 2299 | // Add the JQuery library to the list of files to load. |
| 2174 | - if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') |
|
| 2175 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2176 | - |
|
| 2177 | - elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') |
|
| 2178 | - loadJavaScriptFile('jquery-3.1.1.min.js', array('seed' => false), 'smf_jquery'); |
|
| 2179 | - |
|
| 2180 | - elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') |
|
| 2181 | - loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
| 2300 | + if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') { |
|
| 2301 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2302 | + } elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') { |
|
| 2303 | + loadJavaScriptFile('jquery-3.1.1.min.js', array('seed' => false), 'smf_jquery'); |
|
| 2304 | + } elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') { |
|
| 2305 | + loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
| 2306 | + } |
|
| 2182 | 2307 | |
| 2183 | 2308 | // Auto loading? template_javascript() will take care of the local half of this. |
| 2184 | - else |
|
| 2185 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2309 | + else { |
|
| 2310 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2311 | + } |
|
| 2186 | 2312 | |
| 2187 | 2313 | // Queue our JQuery plugins! |
| 2188 | 2314 | loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins'); |
@@ -2205,12 +2331,12 @@ discard block |
||
| 2205 | 2331 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 2206 | 2332 | |
| 2207 | 2333 | // What to do, what to do?! |
| 2208 | - if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) |
|
| 2209 | - AutoTask(); |
|
| 2210 | - else |
|
| 2211 | - ReduceMailQueue(); |
|
| 2212 | - } |
|
| 2213 | - else |
|
| 2334 | + if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) { |
|
| 2335 | + AutoTask(); |
|
| 2336 | + } else { |
|
| 2337 | + ReduceMailQueue(); |
|
| 2338 | + } |
|
| 2339 | + } else |
|
| 2214 | 2340 | { |
| 2215 | 2341 | $type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq'; |
| 2216 | 2342 | $ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time']; |
@@ -2261,8 +2387,9 @@ discard block |
||
| 2261 | 2387 | foreach ($theme_includes as $include) |
| 2262 | 2388 | { |
| 2263 | 2389 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
| 2264 | - if (file_exists($include)) |
|
| 2265 | - require_once($include); |
|
| 2390 | + if (file_exists($include)) { |
|
| 2391 | + require_once($include); |
|
| 2392 | + } |
|
| 2266 | 2393 | } |
| 2267 | 2394 | } |
| 2268 | 2395 | |
@@ -2292,16 +2419,19 @@ discard block |
||
| 2292 | 2419 | // Do any style sheets first, cause we're easy with those. |
| 2293 | 2420 | if (!empty($style_sheets)) |
| 2294 | 2421 | { |
| 2295 | - if (!is_array($style_sheets)) |
|
| 2296 | - $style_sheets = array($style_sheets); |
|
| 2422 | + if (!is_array($style_sheets)) { |
|
| 2423 | + $style_sheets = array($style_sheets); |
|
| 2424 | + } |
|
| 2297 | 2425 | |
| 2298 | - foreach ($style_sheets as $sheet) |
|
| 2299 | - loadCSSFile($sheet . '.css', array(), $sheet); |
|
| 2426 | + foreach ($style_sheets as $sheet) { |
|
| 2427 | + loadCSSFile($sheet . '.css', array(), $sheet); |
|
| 2428 | + } |
|
| 2300 | 2429 | } |
| 2301 | 2430 | |
| 2302 | 2431 | // No template to load? |
| 2303 | - if ($template_name === false) |
|
| 2304 | - return true; |
|
| 2432 | + if ($template_name === false) { |
|
| 2433 | + return true; |
|
| 2434 | + } |
|
| 2305 | 2435 | |
| 2306 | 2436 | $loaded = false; |
| 2307 | 2437 | foreach ($settings['template_dirs'] as $template_dir) |
@@ -2316,12 +2446,14 @@ discard block |
||
| 2316 | 2446 | |
| 2317 | 2447 | if ($loaded) |
| 2318 | 2448 | { |
| 2319 | - if ($db_show_debug === true) |
|
| 2320 | - $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
| 2449 | + if ($db_show_debug === true) { |
|
| 2450 | + $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
| 2451 | + } |
|
| 2321 | 2452 | |
| 2322 | 2453 | // If they have specified an initialization function for this template, go ahead and call it now. |
| 2323 | - if (function_exists('template_' . $template_name . '_init')) |
|
| 2324 | - call_user_func('template_' . $template_name . '_init'); |
|
| 2454 | + if (function_exists('template_' . $template_name . '_init')) { |
|
| 2455 | + call_user_func('template_' . $template_name . '_init'); |
|
| 2456 | + } |
|
| 2325 | 2457 | } |
| 2326 | 2458 | // Hmmm... doesn't exist?! I don't suppose the directory is wrong, is it? |
| 2327 | 2459 | elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default')) |
@@ -2341,13 +2473,14 @@ discard block |
||
| 2341 | 2473 | loadTemplate($template_name); |
| 2342 | 2474 | } |
| 2343 | 2475 | // Cause an error otherwise. |
| 2344 | - elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) |
|
| 2345 | - fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
| 2346 | - elseif ($fatal) |
|
| 2347 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
| 2348 | - else |
|
| 2349 | - return false; |
|
| 2350 | -} |
|
| 2476 | + elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) { |
|
| 2477 | + fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
| 2478 | + } elseif ($fatal) { |
|
| 2479 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
| 2480 | + } else { |
|
| 2481 | + return false; |
|
| 2482 | + } |
|
| 2483 | + } |
|
| 2351 | 2484 | |
| 2352 | 2485 | /** |
| 2353 | 2486 | * Load a sub-template. |
@@ -2365,17 +2498,19 @@ discard block |
||
| 2365 | 2498 | { |
| 2366 | 2499 | global $context, $txt, $db_show_debug; |
| 2367 | 2500 | |
| 2368 | - if ($db_show_debug === true) |
|
| 2369 | - $context['debug']['sub_templates'][] = $sub_template_name; |
|
| 2501 | + if ($db_show_debug === true) { |
|
| 2502 | + $context['debug']['sub_templates'][] = $sub_template_name; |
|
| 2503 | + } |
|
| 2370 | 2504 | |
| 2371 | 2505 | // Figure out what the template function is named. |
| 2372 | 2506 | $theme_function = 'template_' . $sub_template_name; |
| 2373 | - if (function_exists($theme_function)) |
|
| 2374 | - $theme_function(); |
|
| 2375 | - elseif ($fatal === false) |
|
| 2376 | - fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
| 2377 | - elseif ($fatal !== 'ignore') |
|
| 2378 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
| 2507 | + if (function_exists($theme_function)) { |
|
| 2508 | + $theme_function(); |
|
| 2509 | + } elseif ($fatal === false) { |
|
| 2510 | + fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
| 2511 | + } elseif ($fatal !== 'ignore') { |
|
| 2512 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
| 2513 | + } |
|
| 2379 | 2514 | |
| 2380 | 2515 | // Are we showing debugging for templates? Just make sure not to do it before the doctype... |
| 2381 | 2516 | if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml'])) |
@@ -2412,8 +2547,9 @@ discard block |
||
| 2412 | 2547 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
| 2413 | 2548 | |
| 2414 | 2549 | // If this is an external file, automatically set this to false. |
| 2415 | - if (!empty($params['external'])) |
|
| 2416 | - $params['minimize'] = false; |
|
| 2550 | + if (!empty($params['external'])) { |
|
| 2551 | + $params['minimize'] = false; |
|
| 2552 | + } |
|
| 2417 | 2553 | |
| 2418 | 2554 | // Account for shorthand like admin.css?alp21 filenames |
| 2419 | 2555 | $has_seed = strpos($fileName, '.css?'); |
@@ -2430,13 +2566,10 @@ discard block |
||
| 2430 | 2566 | { |
| 2431 | 2567 | $fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2432 | 2568 | $filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2569 | + } else { |
|
| 2570 | + $fileUrl = false; |
|
| 2433 | 2571 | } |
| 2434 | - |
|
| 2435 | - else |
|
| 2436 | - $fileUrl = false; |
|
| 2437 | - } |
|
| 2438 | - |
|
| 2439 | - else |
|
| 2572 | + } else |
|
| 2440 | 2573 | { |
| 2441 | 2574 | $fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2442 | 2575 | $filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2451,12 +2584,14 @@ discard block |
||
| 2451 | 2584 | } |
| 2452 | 2585 | |
| 2453 | 2586 | // Add it to the array for use in the template |
| 2454 | - if (!empty($fileName)) |
|
| 2455 | - $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2587 | + if (!empty($fileName)) { |
|
| 2588 | + $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2589 | + } |
|
| 2456 | 2590 | |
| 2457 | - if (!empty($context['right_to_left']) && !empty($params['rtl'])) |
|
| 2458 | - loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
| 2459 | -} |
|
| 2591 | + if (!empty($context['right_to_left']) && !empty($params['rtl'])) { |
|
| 2592 | + loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
| 2593 | + } |
|
| 2594 | + } |
|
| 2460 | 2595 | |
| 2461 | 2596 | /** |
| 2462 | 2597 | * Add a block of inline css code to be executed later |
@@ -2473,8 +2608,9 @@ discard block |
||
| 2473 | 2608 | global $context; |
| 2474 | 2609 | |
| 2475 | 2610 | // Gotta add something... |
| 2476 | - if (empty($css)) |
|
| 2477 | - return false; |
|
| 2611 | + if (empty($css)) { |
|
| 2612 | + return false; |
|
| 2613 | + } |
|
| 2478 | 2614 | |
| 2479 | 2615 | $context['css_header'][] = $css; |
| 2480 | 2616 | } |
@@ -2509,8 +2645,9 @@ discard block |
||
| 2509 | 2645 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
| 2510 | 2646 | |
| 2511 | 2647 | // If this is an external file, automatically set this to false. |
| 2512 | - if (!empty($params['external'])) |
|
| 2513 | - $params['minimize'] = false; |
|
| 2648 | + if (!empty($params['external'])) { |
|
| 2649 | + $params['minimize'] = false; |
|
| 2650 | + } |
|
| 2514 | 2651 | |
| 2515 | 2652 | // Account for shorthand like admin.js?alp21 filenames |
| 2516 | 2653 | $has_seed = strpos($fileName, '.js?'); |
@@ -2527,16 +2664,12 @@ discard block |
||
| 2527 | 2664 | { |
| 2528 | 2665 | $fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2529 | 2666 | $filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2530 | - } |
|
| 2531 | - |
|
| 2532 | - else |
|
| 2667 | + } else |
|
| 2533 | 2668 | { |
| 2534 | 2669 | $fileUrl = false; |
| 2535 | 2670 | $filePath = false; |
| 2536 | 2671 | } |
| 2537 | - } |
|
| 2538 | - |
|
| 2539 | - else |
|
| 2672 | + } else |
|
| 2540 | 2673 | { |
| 2541 | 2674 | $fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2542 | 2675 | $filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2551,9 +2684,10 @@ discard block |
||
| 2551 | 2684 | } |
| 2552 | 2685 | |
| 2553 | 2686 | // Add it to the array for use in the template |
| 2554 | - if (!empty($fileName)) |
|
| 2555 | - $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2556 | -} |
|
| 2687 | + if (!empty($fileName)) { |
|
| 2688 | + $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2689 | + } |
|
| 2690 | + } |
|
| 2557 | 2691 | |
| 2558 | 2692 | /** |
| 2559 | 2693 | * Add a Javascript variable for output later (for feeding text strings and similar to JS) |
@@ -2567,9 +2701,10 @@ discard block |
||
| 2567 | 2701 | { |
| 2568 | 2702 | global $context; |
| 2569 | 2703 | |
| 2570 | - if (!empty($key) && (!empty($value) || $value === '0')) |
|
| 2571 | - $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
| 2572 | -} |
|
| 2704 | + if (!empty($key) && (!empty($value) || $value === '0')) { |
|
| 2705 | + $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
| 2706 | + } |
|
| 2707 | + } |
|
| 2573 | 2708 | |
| 2574 | 2709 | /** |
| 2575 | 2710 | * Add a block of inline Javascript code to be executed later |
@@ -2586,8 +2721,9 @@ discard block |
||
| 2586 | 2721 | { |
| 2587 | 2722 | global $context; |
| 2588 | 2723 | |
| 2589 | - if (empty($javascript)) |
|
| 2590 | - return false; |
|
| 2724 | + if (empty($javascript)) { |
|
| 2725 | + return false; |
|
| 2726 | + } |
|
| 2591 | 2727 | |
| 2592 | 2728 | $context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript; |
| 2593 | 2729 | } |
@@ -2608,15 +2744,18 @@ discard block |
||
| 2608 | 2744 | static $already_loaded = array(); |
| 2609 | 2745 | |
| 2610 | 2746 | // Default to the user's language. |
| 2611 | - if ($lang == '') |
|
| 2612 | - $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
| 2747 | + if ($lang == '') { |
|
| 2748 | + $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
| 2749 | + } |
|
| 2613 | 2750 | |
| 2614 | 2751 | // Do we want the English version of language file as fallback? |
| 2615 | - if (empty($modSettings['disable_language_fallback']) && $lang != 'english') |
|
| 2616 | - loadLanguage($template_name, 'english', false); |
|
| 2752 | + if (empty($modSettings['disable_language_fallback']) && $lang != 'english') { |
|
| 2753 | + loadLanguage($template_name, 'english', false); |
|
| 2754 | + } |
|
| 2617 | 2755 | |
| 2618 | - if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) |
|
| 2619 | - return $lang; |
|
| 2756 | + if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) { |
|
| 2757 | + return $lang; |
|
| 2758 | + } |
|
| 2620 | 2759 | |
| 2621 | 2760 | // Make sure we have $settings - if not we're in trouble and need to find it! |
| 2622 | 2761 | if (empty($settings['default_theme_dir'])) |
@@ -2627,8 +2766,9 @@ discard block |
||
| 2627 | 2766 | |
| 2628 | 2767 | // What theme are we in? |
| 2629 | 2768 | $theme_name = basename($settings['theme_url']); |
| 2630 | - if (empty($theme_name)) |
|
| 2631 | - $theme_name = 'unknown'; |
|
| 2769 | + if (empty($theme_name)) { |
|
| 2770 | + $theme_name = 'unknown'; |
|
| 2771 | + } |
|
| 2632 | 2772 | |
| 2633 | 2773 | // For each file open it up and write it out! |
| 2634 | 2774 | foreach (explode('+', $template_name) as $template) |
@@ -2670,8 +2810,9 @@ discard block |
||
| 2670 | 2810 | $found = true; |
| 2671 | 2811 | |
| 2672 | 2812 | // setlocale is required for basename() & pathinfo() to work properly on the selected language |
| 2673 | - if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) |
|
| 2674 | - setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
| 2813 | + if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) { |
|
| 2814 | + setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
| 2815 | + } |
|
| 2675 | 2816 | |
| 2676 | 2817 | break; |
| 2677 | 2818 | } |
@@ -2711,8 +2852,9 @@ discard block |
||
| 2711 | 2852 | } |
| 2712 | 2853 | |
| 2713 | 2854 | // Keep track of what we're up to soldier. |
| 2714 | - if ($db_show_debug === true) |
|
| 2715 | - $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
| 2855 | + if ($db_show_debug === true) { |
|
| 2856 | + $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
| 2857 | + } |
|
| 2716 | 2858 | |
| 2717 | 2859 | // Remember what we have loaded, and in which language. |
| 2718 | 2860 | $already_loaded[$template_name] = $lang; |
@@ -2758,8 +2900,9 @@ discard block |
||
| 2758 | 2900 | ) |
| 2759 | 2901 | ); |
| 2760 | 2902 | // In the EXTREMELY unlikely event this happens, give an error message. |
| 2761 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
| 2762 | - fatal_lang_error('parent_not_found', 'critical'); |
|
| 2903 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
| 2904 | + fatal_lang_error('parent_not_found', 'critical'); |
|
| 2905 | + } |
|
| 2763 | 2906 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 2764 | 2907 | { |
| 2765 | 2908 | if (!isset($boards[$row['id_board']])) |
@@ -2776,8 +2919,8 @@ discard block |
||
| 2776 | 2919 | ); |
| 2777 | 2920 | } |
| 2778 | 2921 | // If a moderator exists for this board, add that moderator for all children too. |
| 2779 | - if (!empty($row['id_moderator'])) |
|
| 2780 | - foreach ($boards as $id => $dummy) |
|
| 2922 | + if (!empty($row['id_moderator'])) { |
|
| 2923 | + foreach ($boards as $id => $dummy) |
|
| 2781 | 2924 | { |
| 2782 | 2925 | $boards[$id]['moderators'][$row['id_moderator']] = array( |
| 2783 | 2926 | 'id' => $row['id_moderator'], |
@@ -2785,11 +2928,12 @@ discard block |
||
| 2785 | 2928 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
| 2786 | 2929 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
| 2787 | 2930 | ); |
| 2931 | + } |
|
| 2788 | 2932 | } |
| 2789 | 2933 | |
| 2790 | 2934 | // If a moderator group exists for this board, add that moderator group for all children too |
| 2791 | - if (!empty($row['id_moderator_group'])) |
|
| 2792 | - foreach ($boards as $id => $dummy) |
|
| 2935 | + if (!empty($row['id_moderator_group'])) { |
|
| 2936 | + foreach ($boards as $id => $dummy) |
|
| 2793 | 2937 | { |
| 2794 | 2938 | $boards[$id]['moderator_groups'][$row['id_moderator_group']] = array( |
| 2795 | 2939 | 'id' => $row['id_moderator_group'], |
@@ -2797,6 +2941,7 @@ discard block |
||
| 2797 | 2941 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
| 2798 | 2942 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
| 2799 | 2943 | ); |
| 2944 | + } |
|
| 2800 | 2945 | } |
| 2801 | 2946 | } |
| 2802 | 2947 | $smcFunc['db_free_result']($result); |
@@ -2823,23 +2968,27 @@ discard block |
||
| 2823 | 2968 | if (!$use_cache || ($context['languages'] = cache_get_data('known_languages', !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null) |
| 2824 | 2969 | { |
| 2825 | 2970 | // If we don't have our ucwords function defined yet, let's load the settings data. |
| 2826 | - if (empty($smcFunc['ucwords'])) |
|
| 2827 | - reloadSettings(); |
|
| 2971 | + if (empty($smcFunc['ucwords'])) { |
|
| 2972 | + reloadSettings(); |
|
| 2973 | + } |
|
| 2828 | 2974 | |
| 2829 | 2975 | // If we don't have our theme information yet, let's get it. |
| 2830 | - if (empty($settings['default_theme_dir'])) |
|
| 2831 | - loadTheme(0, false); |
|
| 2976 | + if (empty($settings['default_theme_dir'])) { |
|
| 2977 | + loadTheme(0, false); |
|
| 2978 | + } |
|
| 2832 | 2979 | |
| 2833 | 2980 | // Default language directories to try. |
| 2834 | 2981 | $language_directories = array( |
| 2835 | 2982 | $settings['default_theme_dir'] . '/languages', |
| 2836 | 2983 | ); |
| 2837 | - if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) |
|
| 2838 | - $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
| 2984 | + if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) { |
|
| 2985 | + $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
| 2986 | + } |
|
| 2839 | 2987 | |
| 2840 | 2988 | // We possibly have a base theme directory. |
| 2841 | - if (!empty($settings['base_theme_dir'])) |
|
| 2842 | - $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
| 2989 | + if (!empty($settings['base_theme_dir'])) { |
|
| 2990 | + $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
| 2991 | + } |
|
| 2843 | 2992 | |
| 2844 | 2993 | // Remove any duplicates. |
| 2845 | 2994 | $language_directories = array_unique($language_directories); |
@@ -2853,20 +3002,21 @@ discard block |
||
| 2853 | 3002 | foreach ($language_directories as $language_dir) |
| 2854 | 3003 | { |
| 2855 | 3004 | // Can't look in here... doesn't exist! |
| 2856 | - if (!file_exists($language_dir)) |
|
| 2857 | - continue; |
|
| 3005 | + if (!file_exists($language_dir)) { |
|
| 3006 | + continue; |
|
| 3007 | + } |
|
| 2858 | 3008 | |
| 2859 | 3009 | $dir = dir($language_dir); |
| 2860 | 3010 | while ($entry = $dir->read()) |
| 2861 | 3011 | { |
| 2862 | 3012 | // Look for the index language file... For good measure skip any "index.language-utf8.php" files |
| 2863 | - if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) |
|
| 2864 | - continue; |
|
| 2865 | - |
|
| 2866 | - if (!empty($langList) && !empty($langList[$matches[1]])) |
|
| 2867 | - $langName = $langList[$matches[1]]; |
|
| 3013 | + if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) { |
|
| 3014 | + continue; |
|
| 3015 | + } |
|
| 2868 | 3016 | |
| 2869 | - else |
|
| 3017 | + if (!empty($langList) && !empty($langList[$matches[1]])) { |
|
| 3018 | + $langName = $langList[$matches[1]]; |
|
| 3019 | + } else |
|
| 2870 | 3020 | { |
| 2871 | 3021 | $langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' '))); |
| 2872 | 3022 | |
@@ -2907,12 +3057,14 @@ discard block |
||
| 2907 | 3057 | } |
| 2908 | 3058 | |
| 2909 | 3059 | // Do we need to store the lang list? |
| 2910 | - if (empty($langList)) |
|
| 2911 | - updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
| 3060 | + if (empty($langList)) { |
|
| 3061 | + updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
| 3062 | + } |
|
| 2912 | 3063 | |
| 2913 | 3064 | // Let's cash in on this deal. |
| 2914 | - if (!empty($modSettings['cache_enable'])) |
|
| 2915 | - cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
| 3065 | + if (!empty($modSettings['cache_enable'])) { |
|
| 3066 | + cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
| 3067 | + } |
|
| 2916 | 3068 | } |
| 2917 | 3069 | |
| 2918 | 3070 | return $context['languages']; |
@@ -2935,8 +3087,9 @@ discard block |
||
| 2935 | 3087 | global $modSettings, $options, $txt; |
| 2936 | 3088 | static $censor_vulgar = null, $censor_proper; |
| 2937 | 3089 | |
| 2938 | - if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') |
|
| 2939 | - return $text; |
|
| 3090 | + if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') { |
|
| 3091 | + return $text; |
|
| 3092 | + } |
|
| 2940 | 3093 | |
| 2941 | 3094 | // If they haven't yet been loaded, load them. |
| 2942 | 3095 | if ($censor_vulgar == null) |
@@ -2964,9 +3117,9 @@ discard block |
||
| 2964 | 3117 | { |
| 2965 | 3118 | $func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace'; |
| 2966 | 3119 | $text = $func($censor_vulgar, $censor_proper, $text); |
| 3120 | + } else { |
|
| 3121 | + $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
| 2967 | 3122 | } |
| 2968 | - else |
|
| 2969 | - $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
| 2970 | 3123 | |
| 2971 | 3124 | return $text; |
| 2972 | 3125 | } |
@@ -2992,38 +3145,42 @@ discard block |
||
| 2992 | 3145 | @ini_set('track_errors', '1'); |
| 2993 | 3146 | |
| 2994 | 3147 | // Don't include the file more than once, if $once is true. |
| 2995 | - if ($once && in_array($filename, $templates)) |
|
| 2996 | - return; |
|
| 3148 | + if ($once && in_array($filename, $templates)) { |
|
| 3149 | + return; |
|
| 3150 | + } |
|
| 2997 | 3151 | // Add this file to the include list, whether $once is true or not. |
| 2998 | - else |
|
| 2999 | - $templates[] = $filename; |
|
| 3152 | + else { |
|
| 3153 | + $templates[] = $filename; |
|
| 3154 | + } |
|
| 3000 | 3155 | |
| 3001 | 3156 | // Are we going to use eval? |
| 3002 | 3157 | if (empty($modSettings['disableTemplateEval'])) |
| 3003 | 3158 | { |
| 3004 | 3159 | $file_found = file_exists($filename) && eval('?' . '>' . rtrim(file_get_contents($filename))) !== false; |
| 3005 | 3160 | $settings['current_include_filename'] = $filename; |
| 3006 | - } |
|
| 3007 | - else |
|
| 3161 | + } else |
|
| 3008 | 3162 | { |
| 3009 | 3163 | $file_found = file_exists($filename); |
| 3010 | 3164 | |
| 3011 | - if ($once && $file_found) |
|
| 3012 | - require_once($filename); |
|
| 3013 | - elseif ($file_found) |
|
| 3014 | - require($filename); |
|
| 3165 | + if ($once && $file_found) { |
|
| 3166 | + require_once($filename); |
|
| 3167 | + } elseif ($file_found) { |
|
| 3168 | + require($filename); |
|
| 3169 | + } |
|
| 3015 | 3170 | } |
| 3016 | 3171 | |
| 3017 | 3172 | if ($file_found !== true) |
| 3018 | 3173 | { |
| 3019 | 3174 | ob_end_clean(); |
| 3020 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
| 3021 | - @ob_start('ob_gzhandler'); |
|
| 3022 | - else |
|
| 3023 | - ob_start(); |
|
| 3175 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
| 3176 | + @ob_start('ob_gzhandler'); |
|
| 3177 | + } else { |
|
| 3178 | + ob_start(); |
|
| 3179 | + } |
|
| 3024 | 3180 | |
| 3025 | - if (isset($_GET['debug'])) |
|
| 3026 | - header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3181 | + if (isset($_GET['debug'])) { |
|
| 3182 | + header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3183 | + } |
|
| 3027 | 3184 | |
| 3028 | 3185 | // Don't cache error pages!! |
| 3029 | 3186 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -3042,12 +3199,13 @@ discard block |
||
| 3042 | 3199 | echo '<!DOCTYPE html> |
| 3043 | 3200 | <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '> |
| 3044 | 3201 | <head>'; |
| 3045 | - if (isset($context['character_set'])) |
|
| 3046 | - echo ' |
|
| 3202 | + if (isset($context['character_set'])) { |
|
| 3203 | + echo ' |
|
| 3047 | 3204 | <meta charset="', $context['character_set'], '">'; |
| 3205 | + } |
|
| 3048 | 3206 | |
| 3049 | - if (!empty($maintenance) && !allowedTo('admin_forum')) |
|
| 3050 | - echo ' |
|
| 3207 | + if (!empty($maintenance) && !allowedTo('admin_forum')) { |
|
| 3208 | + echo ' |
|
| 3051 | 3209 | <title>', $mtitle, '</title> |
| 3052 | 3210 | </head> |
| 3053 | 3211 | <body> |
@@ -3055,8 +3213,8 @@ discard block |
||
| 3055 | 3213 | ', $mmessage, ' |
| 3056 | 3214 | </body> |
| 3057 | 3215 | </html>'; |
| 3058 | - elseif (!allowedTo('admin_forum')) |
|
| 3059 | - echo ' |
|
| 3216 | + } elseif (!allowedTo('admin_forum')) { |
|
| 3217 | + echo ' |
|
| 3060 | 3218 | <title>', $txt['template_parse_error'], '</title> |
| 3061 | 3219 | </head> |
| 3062 | 3220 | <body> |
@@ -3064,16 +3222,18 @@ discard block |
||
| 3064 | 3222 | ', $txt['template_parse_error_message'], ' |
| 3065 | 3223 | </body> |
| 3066 | 3224 | </html>'; |
| 3067 | - else |
|
| 3225 | + } else |
|
| 3068 | 3226 | { |
| 3069 | 3227 | require_once($sourcedir . '/Subs-Package.php'); |
| 3070 | 3228 | |
| 3071 | 3229 | $error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
| 3072 | 3230 | $error_array = error_get_last(); |
| 3073 | - if (empty($error) && ini_get('track_errors') && !empty($error_array)) |
|
| 3074 | - $error = $error_array['message']; |
|
| 3075 | - if (empty($error)) |
|
| 3076 | - $error = $txt['template_parse_errmsg']; |
|
| 3231 | + if (empty($error) && ini_get('track_errors') && !empty($error_array)) { |
|
| 3232 | + $error = $error_array['message']; |
|
| 3233 | + } |
|
| 3234 | + if (empty($error)) { |
|
| 3235 | + $error = $txt['template_parse_errmsg']; |
|
| 3236 | + } |
|
| 3077 | 3237 | |
| 3078 | 3238 | $error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>')); |
| 3079 | 3239 | |
@@ -3084,11 +3244,12 @@ discard block |
||
| 3084 | 3244 | <h3>', $txt['template_parse_error'], '</h3> |
| 3085 | 3245 | ', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
| 3086 | 3246 | |
| 3087 | - if (!empty($error)) |
|
| 3088 | - echo ' |
|
| 3247 | + if (!empty($error)) { |
|
| 3248 | + echo ' |
|
| 3089 | 3249 | <hr> |
| 3090 | 3250 | |
| 3091 | 3251 | <div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>'; |
| 3252 | + } |
|
| 3092 | 3253 | |
| 3093 | 3254 | // I know, I know... this is VERY COMPLICATED. Still, it's good. |
| 3094 | 3255 | if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0) |
@@ -3098,10 +3259,11 @@ discard block |
||
| 3098 | 3259 | $data2 = preg_split('~\<br( /)?\>~', $data2); |
| 3099 | 3260 | |
| 3100 | 3261 | // Fix the PHP code stuff... |
| 3101 | - if (!isBrowser('gecko')) |
|
| 3102 | - $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
| 3103 | - else |
|
| 3104 | - $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
| 3262 | + if (!isBrowser('gecko')) { |
|
| 3263 | + $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
| 3264 | + } else { |
|
| 3265 | + $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
| 3266 | + } |
|
| 3105 | 3267 | |
| 3106 | 3268 | // Now we get to work around a bug in PHP where it doesn't escape <br>s! |
| 3107 | 3269 | $j = -1; |
@@ -3109,8 +3271,9 @@ discard block |
||
| 3109 | 3271 | { |
| 3110 | 3272 | $j++; |
| 3111 | 3273 | |
| 3112 | - if (substr_count($line, '<br>') == 0) |
|
| 3113 | - continue; |
|
| 3274 | + if (substr_count($line, '<br>') == 0) { |
|
| 3275 | + continue; |
|
| 3276 | + } |
|
| 3114 | 3277 | |
| 3115 | 3278 | $n = substr_count($line, '<br>'); |
| 3116 | 3279 | for ($i = 0; $i < $n; $i++) |
@@ -3129,38 +3292,42 @@ discard block |
||
| 3129 | 3292 | // Figure out what the color coding was before... |
| 3130 | 3293 | $line = max($match[1] - 9, 1); |
| 3131 | 3294 | $last_line = ''; |
| 3132 | - for ($line2 = $line - 1; $line2 > 1; $line2--) |
|
| 3133 | - if (strpos($data2[$line2], '<') !== false) |
|
| 3295 | + for ($line2 = $line - 1; $line2 > 1; $line2--) { |
|
| 3296 | + if (strpos($data2[$line2], '<') !== false) |
|
| 3134 | 3297 | { |
| 3135 | 3298 | if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0) |
| 3136 | 3299 | $last_line = $color_match[1]; |
| 3300 | + } |
|
| 3137 | 3301 | break; |
| 3138 | 3302 | } |
| 3139 | 3303 | |
| 3140 | 3304 | // Show the relevant lines... |
| 3141 | 3305 | for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++) |
| 3142 | 3306 | { |
| 3143 | - if ($line == $match[1]) |
|
| 3144 | - echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
| 3307 | + if ($line == $match[1]) { |
|
| 3308 | + echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
| 3309 | + } |
|
| 3145 | 3310 | |
| 3146 | 3311 | echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> '; |
| 3147 | - if (isset($data2[$line]) && $data2[$line] != '') |
|
| 3148 | - echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
| 3312 | + if (isset($data2[$line]) && $data2[$line] != '') { |
|
| 3313 | + echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
| 3314 | + } |
|
| 3149 | 3315 | |
| 3150 | 3316 | if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0) |
| 3151 | 3317 | { |
| 3152 | 3318 | $last_line = $color_match[1]; |
| 3153 | 3319 | echo '</', substr($last_line, 1, 4), '>'; |
| 3320 | + } elseif ($last_line != '' && strpos($data2[$line], '<') !== false) { |
|
| 3321 | + $last_line = ''; |
|
| 3322 | + } elseif ($last_line != '' && $data2[$line] != '') { |
|
| 3323 | + echo '</', substr($last_line, 1, 4), '>'; |
|
| 3154 | 3324 | } |
| 3155 | - elseif ($last_line != '' && strpos($data2[$line], '<') !== false) |
|
| 3156 | - $last_line = ''; |
|
| 3157 | - elseif ($last_line != '' && $data2[$line] != '') |
|
| 3158 | - echo '</', substr($last_line, 1, 4), '>'; |
|
| 3159 | 3325 | |
| 3160 | - if ($line == $match[1]) |
|
| 3161 | - echo '</pre></div><pre style="margin: 0;">'; |
|
| 3162 | - else |
|
| 3163 | - echo "\n"; |
|
| 3326 | + if ($line == $match[1]) { |
|
| 3327 | + echo '</pre></div><pre style="margin: 0;">'; |
|
| 3328 | + } else { |
|
| 3329 | + echo "\n"; |
|
| 3330 | + } |
|
| 3164 | 3331 | } |
| 3165 | 3332 | |
| 3166 | 3333 | echo '</pre></div>'; |
@@ -3184,8 +3351,9 @@ discard block |
||
| 3184 | 3351 | global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port; |
| 3185 | 3352 | |
| 3186 | 3353 | // Figure out what type of database we are using. |
| 3187 | - if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
|
| 3188 | - $db_type = 'mysql'; |
|
| 3354 | + if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) { |
|
| 3355 | + $db_type = 'mysql'; |
|
| 3356 | + } |
|
| 3189 | 3357 | |
| 3190 | 3358 | // Load the file for the database. |
| 3191 | 3359 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -3193,8 +3361,9 @@ discard block |
||
| 3193 | 3361 | $db_options = array(); |
| 3194 | 3362 | |
| 3195 | 3363 | // Add in the port if needed |
| 3196 | - if (!empty($db_port)) |
|
| 3197 | - $db_options['port'] = $db_port; |
|
| 3364 | + if (!empty($db_port)) { |
|
| 3365 | + $db_options['port'] = $db_port; |
|
| 3366 | + } |
|
| 3198 | 3367 | |
| 3199 | 3368 | // If we are in SSI try them first, but don't worry if it doesn't work, we have the normal username and password we can use. |
| 3200 | 3369 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
@@ -3213,13 +3382,15 @@ discard block |
||
| 3213 | 3382 | } |
| 3214 | 3383 | |
| 3215 | 3384 | // Safe guard here, if there isn't a valid connection lets put a stop to it. |
| 3216 | - if (!$db_connection) |
|
| 3217 | - display_db_error(); |
|
| 3385 | + if (!$db_connection) { |
|
| 3386 | + display_db_error(); |
|
| 3387 | + } |
|
| 3218 | 3388 | |
| 3219 | 3389 | // If in SSI mode fix up the prefix. |
| 3220 | - if (SMF == 'SSI') |
|
| 3221 | - db_fix_prefix($db_prefix, $db_name); |
|
| 3222 | -} |
|
| 3390 | + if (SMF == 'SSI') { |
|
| 3391 | + db_fix_prefix($db_prefix, $db_name); |
|
| 3392 | + } |
|
| 3393 | + } |
|
| 3223 | 3394 | |
| 3224 | 3395 | /** |
| 3225 | 3396 | * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it. |
@@ -3233,10 +3404,11 @@ discard block |
||
| 3233 | 3404 | global $sourcedir, $cacheAPI, $cache_accelerator; |
| 3234 | 3405 | |
| 3235 | 3406 | // Not overriding this and we have a cacheAPI, send it back. |
| 3236 | - if (empty($overrideCache) && is_object($cacheAPI)) |
|
| 3237 | - return $cacheAPI; |
|
| 3238 | - elseif (is_null($cacheAPI)) |
|
| 3239 | - $cacheAPI = false; |
|
| 3407 | + if (empty($overrideCache) && is_object($cacheAPI)) { |
|
| 3408 | + return $cacheAPI; |
|
| 3409 | + } elseif (is_null($cacheAPI)) { |
|
| 3410 | + $cacheAPI = false; |
|
| 3411 | + } |
|
| 3240 | 3412 | |
| 3241 | 3413 | // Make sure our class is in session. |
| 3242 | 3414 | require_once($sourcedir . '/Class-CacheAPI.php'); |
@@ -3257,8 +3429,9 @@ discard block |
||
| 3257 | 3429 | if (!$testAPI->isSupported()) |
| 3258 | 3430 | { |
| 3259 | 3431 | // Can we save ourselves? |
| 3260 | - if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') |
|
| 3261 | - return loadCacheAccelerator(null, false); |
|
| 3432 | + if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') { |
|
| 3433 | + return loadCacheAccelerator(null, false); |
|
| 3434 | + } |
|
| 3262 | 3435 | return false; |
| 3263 | 3436 | } |
| 3264 | 3437 | |
@@ -3270,9 +3443,9 @@ discard block |
||
| 3270 | 3443 | { |
| 3271 | 3444 | $cacheAPI = $testAPI; |
| 3272 | 3445 | return $cacheAPI; |
| 3446 | + } else { |
|
| 3447 | + return $testAPI; |
|
| 3273 | 3448 | } |
| 3274 | - else |
|
| 3275 | - return $testAPI; |
|
| 3276 | 3449 | } |
| 3277 | 3450 | } |
| 3278 | 3451 | |
@@ -3292,8 +3465,9 @@ discard block |
||
| 3292 | 3465 | |
| 3293 | 3466 | // @todo Why are we doing this if caching is disabled? |
| 3294 | 3467 | |
| 3295 | - if (function_exists('call_integration_hook')) |
|
| 3296 | - call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
| 3468 | + if (function_exists('call_integration_hook')) { |
|
| 3469 | + call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
| 3470 | + } |
|
| 3297 | 3471 | |
| 3298 | 3472 | /* Refresh the cache if either: |
| 3299 | 3473 | 1. Caching is disabled. |
@@ -3307,16 +3481,19 @@ discard block |
||
| 3307 | 3481 | require_once($sourcedir . '/' . $file); |
| 3308 | 3482 | $cache_block = call_user_func_array($function, $params); |
| 3309 | 3483 | |
| 3310 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) |
|
| 3311 | - cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
| 3484 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) { |
|
| 3485 | + cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
| 3486 | + } |
|
| 3312 | 3487 | } |
| 3313 | 3488 | |
| 3314 | 3489 | // Some cached data may need a freshening up after retrieval. |
| 3315 | - if (!empty($cache_block['post_retri_eval'])) |
|
| 3316 | - eval($cache_block['post_retri_eval']); |
|
| 3490 | + if (!empty($cache_block['post_retri_eval'])) { |
|
| 3491 | + eval($cache_block['post_retri_eval']); |
|
| 3492 | + } |
|
| 3317 | 3493 | |
| 3318 | - if (function_exists('call_integration_hook')) |
|
| 3319 | - call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
| 3494 | + if (function_exists('call_integration_hook')) { |
|
| 3495 | + call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
| 3496 | + } |
|
| 3320 | 3497 | |
| 3321 | 3498 | return $cache_block['data']; |
| 3322 | 3499 | } |
@@ -3343,8 +3520,9 @@ discard block |
||
| 3343 | 3520 | global $smcFunc, $cache_enable, $cacheAPI; |
| 3344 | 3521 | global $cache_hits, $cache_count, $db_show_debug; |
| 3345 | 3522 | |
| 3346 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
| 3347 | - return; |
|
| 3523 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
| 3524 | + return; |
|
| 3525 | + } |
|
| 3348 | 3526 | |
| 3349 | 3527 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
| 3350 | 3528 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3357,12 +3535,14 @@ discard block |
||
| 3357 | 3535 | $value = $value === null ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_encode']($value) : json_encode($value)); |
| 3358 | 3536 | $cacheAPI->putData($key, $value, $ttl); |
| 3359 | 3537 | |
| 3360 | - if (function_exists('call_integration_hook')) |
|
| 3361 | - call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
| 3538 | + if (function_exists('call_integration_hook')) { |
|
| 3539 | + call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
| 3540 | + } |
|
| 3362 | 3541 | |
| 3363 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 3364 | - $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 3365 | -} |
|
| 3542 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 3543 | + $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 3544 | + } |
|
| 3545 | + } |
|
| 3366 | 3546 | |
| 3367 | 3547 | /** |
| 3368 | 3548 | * Gets the value from the cache specified by key, so long as it is not older than ttl seconds. |
@@ -3378,8 +3558,9 @@ discard block |
||
| 3378 | 3558 | global $smcFunc, $cache_enable, $cacheAPI; |
| 3379 | 3559 | global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug; |
| 3380 | 3560 | |
| 3381 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
| 3382 | - return; |
|
| 3561 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
| 3562 | + return; |
|
| 3563 | + } |
|
| 3383 | 3564 | |
| 3384 | 3565 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
| 3385 | 3566 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3399,16 +3580,18 @@ discard block |
||
| 3399 | 3580 | |
| 3400 | 3581 | if (empty($value)) |
| 3401 | 3582 | { |
| 3402 | - if (!is_array($cache_misses)) |
|
| 3403 | - $cache_misses = array(); |
|
| 3583 | + if (!is_array($cache_misses)) { |
|
| 3584 | + $cache_misses = array(); |
|
| 3585 | + } |
|
| 3404 | 3586 | |
| 3405 | 3587 | $cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1; |
| 3406 | 3588 | $cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get'); |
| 3407 | 3589 | } |
| 3408 | 3590 | } |
| 3409 | 3591 | |
| 3410 | - if (function_exists('call_integration_hook') && isset($value)) |
|
| 3411 | - call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
| 3592 | + if (function_exists('call_integration_hook') && isset($value)) { |
|
| 3593 | + call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
| 3594 | + } |
|
| 3412 | 3595 | |
| 3413 | 3596 | return empty($value) ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_decode']($value, true) : smf_json_decode($value, true)); |
| 3414 | 3597 | } |
@@ -3430,8 +3613,9 @@ discard block |
||
| 3430 | 3613 | global $cacheAPI; |
| 3431 | 3614 | |
| 3432 | 3615 | // If we can't get to the API, can't do this. |
| 3433 | - if (empty($cacheAPI)) |
|
| 3434 | - return; |
|
| 3616 | + if (empty($cacheAPI)) { |
|
| 3617 | + return; |
|
| 3618 | + } |
|
| 3435 | 3619 | |
| 3436 | 3620 | // Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure. |
| 3437 | 3621 | $cacheAPI->cleanCache($type); |
@@ -3456,8 +3640,9 @@ discard block |
||
| 3456 | 3640 | global $modSettings, $boardurl, $smcFunc, $image_proxy_enabled, $image_proxy_secret; |
| 3457 | 3641 | |
| 3458 | 3642 | // Come on! |
| 3459 | - if (empty($data)) |
|
| 3460 | - return array(); |
|
| 3643 | + if (empty($data)) { |
|
| 3644 | + return array(); |
|
| 3645 | + } |
|
| 3461 | 3646 | |
| 3462 | 3647 | // Set a nice default var. |
| 3463 | 3648 | $image = ''; |
@@ -3465,11 +3650,11 @@ discard block |
||
| 3465 | 3650 | // Gravatar has been set as mandatory! |
| 3466 | 3651 | if (!empty($modSettings['gravatarOverride'])) |
| 3467 | 3652 | { |
| 3468 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) |
|
| 3469 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3470 | - |
|
| 3471 | - else if (!empty($data['email'])) |
|
| 3472 | - $image = get_gravatar_url($data['email']); |
|
| 3653 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) { |
|
| 3654 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3655 | + } else if (!empty($data['email'])) { |
|
| 3656 | + $image = get_gravatar_url($data['email']); |
|
| 3657 | + } |
|
| 3473 | 3658 | } |
| 3474 | 3659 | |
| 3475 | 3660 | // Look if the user has a gravatar field or has set an external url as avatar. |
@@ -3481,54 +3666,60 @@ discard block |
||
| 3481 | 3666 | // Gravatar. |
| 3482 | 3667 | if (stristr($data['avatar'], 'gravatar://')) |
| 3483 | 3668 | { |
| 3484 | - if ($data['avatar'] == 'gravatar://') |
|
| 3485 | - $image = get_gravatar_url($data['email']); |
|
| 3486 | - |
|
| 3487 | - elseif (!empty($modSettings['gravatarAllowExtraEmail'])) |
|
| 3488 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3669 | + if ($data['avatar'] == 'gravatar://') { |
|
| 3670 | + $image = get_gravatar_url($data['email']); |
|
| 3671 | + } elseif (!empty($modSettings['gravatarAllowExtraEmail'])) { |
|
| 3672 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3673 | + } |
|
| 3489 | 3674 | } |
| 3490 | 3675 | |
| 3491 | 3676 | // External url. |
| 3492 | 3677 | else |
| 3493 | 3678 | { |
| 3494 | 3679 | // Using ssl? |
| 3495 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) |
|
| 3496 | - $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
| 3680 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) { |
|
| 3681 | + $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
| 3682 | + } |
|
| 3497 | 3683 | |
| 3498 | 3684 | // Just a plain external url. |
| 3499 | - else |
|
| 3500 | - $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
| 3685 | + else { |
|
| 3686 | + $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
| 3687 | + } |
|
| 3501 | 3688 | } |
| 3502 | 3689 | } |
| 3503 | 3690 | |
| 3504 | 3691 | // Perhaps this user has an attachment as avatar... |
| 3505 | - else if (!empty($data['filename'])) |
|
| 3506 | - $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
| 3692 | + else if (!empty($data['filename'])) { |
|
| 3693 | + $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
| 3694 | + } |
|
| 3507 | 3695 | |
| 3508 | 3696 | // Right... no avatar... use our default image. |
| 3509 | - else |
|
| 3510 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 3697 | + else { |
|
| 3698 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 3699 | + } |
|
| 3511 | 3700 | } |
| 3512 | 3701 | |
| 3513 | 3702 | call_integration_hook('integrate_set_avatar_data', array(&$image, &$data)); |
| 3514 | 3703 | |
| 3515 | 3704 | // At this point in time $image has to be filled unless you chose to force gravatar and the user doesn't have the needed data to retrieve it... thus a check for !empty() is still needed. |
| 3516 | - if (!empty($image)) |
|
| 3517 | - return array( |
|
| 3705 | + if (!empty($image)) { |
|
| 3706 | + return array( |
|
| 3518 | 3707 | 'name' => !empty($data['avatar']) ? $data['avatar'] : '', |
| 3519 | 3708 | 'image' => '<img class="avatar" src="' . $image . '" />', |
| 3520 | 3709 | 'href' => $image, |
| 3521 | 3710 | 'url' => $image, |
| 3522 | 3711 | ); |
| 3712 | + } |
|
| 3523 | 3713 | |
| 3524 | 3714 | // Fallback to make life easier for everyone... |
| 3525 | - else |
|
| 3526 | - return array( |
|
| 3715 | + else { |
|
| 3716 | + return array( |
|
| 3527 | 3717 | 'name' => '', |
| 3528 | 3718 | 'image' => '', |
| 3529 | 3719 | 'href' => '', |
| 3530 | 3720 | 'url' => '', |
| 3531 | 3721 | ); |
| 3532 | -} |
|
| 3722 | + } |
|
| 3723 | + } |
|
| 3533 | 3724 | |
| 3534 | 3725 | ?> |
| 3535 | 3726 | \ No newline at end of file |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | |
| 233 | 233 | foreach ($message['custom_fields']['above_member'] as $custom) |
| 234 | 234 | echo ' |
| 235 | - <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
|
| 235 | + <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
|
| 236 | 236 | |
| 237 | 237 | echo ' |
| 238 | 238 | </ul> |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | if (!empty($message['custom_fields']['below_avatar'])) |
| 282 | 282 | foreach ($message['custom_fields']['below_avatar'] as $custom) |
| 283 | 283 | echo ' |
| 284 | - <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
|
| 284 | + <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
|
| 285 | 285 | |
| 286 | 286 | if (!$message['member']['is_guest']) |
| 287 | 287 | echo ' |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | |
| 324 | 324 | foreach ($message['custom_fields']['icons'] as $custom) |
| 325 | 325 | echo ' |
| 326 | - <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
|
| 326 | + <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
|
| 327 | 327 | |
| 328 | 328 | echo ' |
| 329 | 329 | </ol> |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | if (!empty($message['custom_fields']['standard'])) |
| 382 | 382 | foreach ($message['custom_fields']['standard'] as $custom) |
| 383 | 383 | echo ' |
| 384 | - <li class="custom ', $custom['col_name'] ,'">', $custom['title'], ': ', $custom['value'], '</li>'; |
|
| 384 | + <li class="custom ', $custom['col_name'], '">', $custom['title'], ': ', $custom['value'], '</li>'; |
|
| 385 | 385 | |
| 386 | 386 | // Are we showing the warning status? |
| 387 | 387 | if ($message['member']['can_see_warning']) |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | if (!empty($message['custom_fields']['bottom_poster'])) |
| 393 | 393 | foreach ($message['custom_fields']['bottom_poster'] as $custom) |
| 394 | 394 | echo ' |
| 395 | - <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
|
| 395 | + <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | // Done with the information about the poster... on to the post itself. |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | |
| 492 | 492 | foreach ($message['custom_fields']['above_signature'] as $custom) |
| 493 | 493 | echo ' |
| 494 | - <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
|
| 494 | + <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
|
| 495 | 495 | |
| 496 | 496 | echo ' |
| 497 | 497 | </ul> |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | |
| 513 | 513 | foreach ($message['custom_fields']['below_signature'] as $custom) |
| 514 | 514 | echo ' |
| 515 | - <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
|
| 515 | + <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
|
| 516 | 516 | |
| 517 | 517 | echo ' |
| 518 | 518 | </ul> |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | while ($message = $context['get_pmessage']('subject')) |
| 651 | 651 | { |
| 652 | 652 | echo ' |
| 653 | - <tr class="windowbg', $message['is_unread'] ? ' unread_pm' : '','"> |
|
| 653 | + <tr class="windowbg', $message['is_unread'] ? ' unread_pm' : '', '"> |
|
| 654 | 654 | <td class="table_icon"> |
| 655 | 655 | <script> |
| 656 | 656 | currentLabels[', $message['id'], '] = {'; |
@@ -935,13 +935,13 @@ discard block |
||
| 935 | 935 | // You can only reply if they are not a guest... |
| 936 | 936 | if (!$message['member']['is_guest']) |
| 937 | 937 | echo ' |
| 938 | - <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=', $context['folder'] == 'sent' ? '' : $message['member']['id'], '">', $quote_button , '</a>', $context['menu_separator'], ' |
|
| 939 | - <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $reply_button , '</a> ', $context['menu_separator']; |
|
| 938 | + <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=', $context['folder'] == 'sent' ? '' : $message['member']['id'], '">', $quote_button, '</a>', $context['menu_separator'], ' |
|
| 939 | + <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $reply_button, '</a> ', $context['menu_separator']; |
|
| 940 | 940 | |
| 941 | 941 | // This is for "forwarding" - even if the member is gone. |
| 942 | 942 | else |
| 943 | 943 | echo ' |
| 944 | - <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $quote_button , '</a>', $context['menu_separator']; |
|
| 944 | + <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $quote_button, '</a>', $context['menu_separator']; |
|
| 945 | 945 | } |
| 946 | 946 | |
| 947 | 947 | echo ' |
@@ -1046,7 +1046,7 @@ discard block |
||
| 1046 | 1046 | <div class="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'noticebox' : 'errorbox', '"', empty($context['post_error']['messages']) ? ' style="display: none"' : '', ' id="errors"> |
| 1047 | 1047 | <dl> |
| 1048 | 1048 | <dt> |
| 1049 | - <strong id="error_serious">', $txt['error_while_submitting'] , '</strong> |
|
| 1049 | + <strong id="error_serious">', $txt['error_while_submitting'], '</strong> |
|
| 1050 | 1050 | </dt> |
| 1051 | 1051 | <dd class="error" id="error_list"> |
| 1052 | 1052 | ', empty($context['post_error']['messages']) ? '' : implode('<br>', $context['post_error']['messages']), ' |
@@ -1102,7 +1102,7 @@ discard block |
||
| 1102 | 1102 | <span', (isset($context['post_error']['no_subject']) ? ' class="error"' : ''), ' id="caption_subject">', $txt['subject'], ':</span> |
| 1103 | 1103 | </dt> |
| 1104 | 1104 | <dd id="pm_subject"> |
| 1105 | - <input type="text" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="80"',isset($context['post_error']['no_subject']) ? ' class="error"' : '', '/> |
|
| 1105 | + <input type="text" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="80"', isset($context['post_error']['no_subject']) ? ' class="error"' : '', '/> |
|
| 1106 | 1106 | </dd> |
| 1107 | 1107 | </dl> |
| 1108 | 1108 | <hr>'; |
@@ -1471,7 +1471,7 @@ discard block |
||
| 1471 | 1471 | echo ' |
| 1472 | 1472 | <div class="padding"> |
| 1473 | 1473 | <input type="submit" name="save" value="', $txt['save'], '" class="button"> |
| 1474 | - <input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" data-confirm="', $txt['pm_labels_delete'] ,'" class="button you_sure"> |
|
| 1474 | + <input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" data-confirm="', $txt['pm_labels_delete'], '" class="button you_sure"> |
|
| 1475 | 1475 | </div>'; |
| 1476 | 1476 | |
| 1477 | 1477 | echo ' |
@@ -1636,7 +1636,7 @@ discard block |
||
| 1636 | 1636 | if (!empty($context['rules'])) |
| 1637 | 1637 | echo ' |
| 1638 | 1638 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 1639 | - <input type="submit" name="delselected" value="', $txt['pm_delete_selected_rule'], '" data-confirm="', $txt['pm_js_delete_rule_confirm'] ,'" class="button smalltext you_sure">'; |
|
| 1639 | + <input type="submit" name="delselected" value="', $txt['pm_delete_selected_rule'], '" data-confirm="', $txt['pm_js_delete_rule_confirm'], '" class="button smalltext you_sure">'; |
|
| 1640 | 1640 | |
| 1641 | 1641 | echo ' |
| 1642 | 1642 | </div> |
@@ -1879,9 +1879,9 @@ discard block |
||
| 1879 | 1879 | |
| 1880 | 1880 | echo ' |
| 1881 | 1881 | <select name="acttype[', $k, ']" id="acttype', $k, '" onchange="updateActionDef(', $k, '); rebuildRuleDesc();"> |
| 1882 | - <option value="">', $txt['pm_rule_sel_action'] , ':</option> |
|
| 1883 | - <option value="lab"', $action['t'] == 'lab' ? ' selected' : '', '>', $txt['pm_rule_label'] , '</option> |
|
| 1884 | - <option value="del"', $action['t'] == 'del' ? ' selected' : '', '>', $txt['pm_rule_delete'] , '</option> |
|
| 1882 | + <option value="">', $txt['pm_rule_sel_action'], ':</option> |
|
| 1883 | + <option value="lab"', $action['t'] == 'lab' ? ' selected' : '', '>', $txt['pm_rule_label'], '</option> |
|
| 1884 | + <option value="del"', $action['t'] == 'del' ? ' selected' : '', '>', $txt['pm_rule_delete'], '</option> |
|
| 1885 | 1885 | </select> |
| 1886 | 1886 | <span id="labdiv', $k, '"> |
| 1887 | 1887 | <select name="labdef[', $k, ']" id="labdef', $k, '" onchange="rebuildRuleDesc();"> |
@@ -1994,7 +1994,7 @@ discard block |
||
| 1994 | 1994 | </div> |
| 1995 | 1995 | <ul class="quickbuttons"> |
| 1996 | 1996 | <li><a href="', $scripturl, '?action=pm;sa=showpmdrafts;id_draft=', $draft['id_draft'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons modifybutton"></span>', $txt['draft_edit'], '</a></li> |
| 1997 | - <li><a href="', $scripturl, '?action=pm;sa=showpmdrafts;delete=', $draft['id_draft'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['draft_remove'] ,'?" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['draft_delete'], '</a></li> |
|
| 1997 | + <li><a href="', $scripturl, '?action=pm;sa=showpmdrafts;delete=', $draft['id_draft'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['draft_remove'], '?" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['draft_delete'], '</a></li> |
|
| 1998 | 1998 | </ul> |
| 1999 | 1999 | </div><!-- .windowbg -->'; |
| 2000 | 2000 | } |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | <div id="personal_messages">'; |
| 22 | 22 | |
| 23 | 23 | // Show the capacity bar, if available. |
| 24 | - if (!empty($context['limit_bar'])) |
|
| 25 | - echo ' |
|
| 24 | + if (!empty($context['limit_bar'])) { |
|
| 25 | + echo ' |
|
| 26 | 26 | <div class="cat_bar"> |
| 27 | 27 | <h3 class="catbg"> |
| 28 | 28 | <span class="floatleft">', $txt['pm_capacity'], ':</span> |
@@ -32,14 +32,16 @@ discard block |
||
| 32 | 32 | <span class="floatright', $context['limit_bar']['percent'] > 90 ? ' alert' : '', '">', $context['limit_bar']['text'], '</span> |
| 33 | 33 | </h3> |
| 34 | 34 | </div>'; |
| 35 | + } |
|
| 35 | 36 | |
| 36 | 37 | // Message sent? Show a small indication. |
| 37 | - if (isset($context['pm_sent'])) |
|
| 38 | - echo ' |
|
| 38 | + if (isset($context['pm_sent'])) { |
|
| 39 | + echo ' |
|
| 39 | 40 | <div class="infobox"> |
| 40 | 41 | ', $txt['pm_sent'], ' |
| 41 | 42 | </div>'; |
| 42 | -} |
|
| 43 | + } |
|
| 44 | + } |
|
| 43 | 45 | |
| 44 | 46 | /** |
| 45 | 47 | * Just the end of the index bar, nothing special. |
@@ -72,8 +74,7 @@ discard block |
||
| 72 | 74 | { |
| 73 | 75 | echo ' |
| 74 | 76 | <div class="no_unread">', $txt['pm_no_unread'], '</div>'; |
| 75 | - } |
|
| 76 | - else |
|
| 77 | + } else |
|
| 77 | 78 | { |
| 78 | 79 | foreach ($context['unread_pms'] as $id_pm => $pm_details) |
| 79 | 80 | { |
@@ -194,14 +195,15 @@ discard block |
||
| 194 | 195 | if ($context['get_pmessage']('message', true)) |
| 195 | 196 | { |
| 196 | 197 | // Show the helpful titlebar - generally. |
| 197 | - if ($context['display_mode'] != 1) |
|
| 198 | - echo ' |
|
| 198 | + if ($context['display_mode'] != 1) { |
|
| 199 | + echo ' |
|
| 199 | 200 | <div class="cat_bar"> |
| 200 | 201 | <h3 class="catbg"> |
| 201 | 202 | <span id="author">', $txt['author'], '</span> |
| 202 | 203 | <span id="topic_title">', $txt[$context['display_mode'] == 0 ? 'messages' : 'conversation'], '</span> |
| 203 | 204 | </h3> |
| 204 | 205 | </div>'; |
| 206 | + } |
|
| 205 | 207 | |
| 206 | 208 | // Show a few buttons if we are in conversation mode and outputting the first message. |
| 207 | 209 | if ($context['display_mode'] == 2) |
@@ -230,9 +232,10 @@ discard block |
||
| 230 | 232 | <div class="custom_fields_above_member"> |
| 231 | 233 | <ul class="nolist">'; |
| 232 | 234 | |
| 233 | - foreach ($message['custom_fields']['above_member'] as $custom) |
|
| 234 | - echo ' |
|
| 235 | + foreach ($message['custom_fields']['above_member'] as $custom) { |
|
| 236 | + echo ' |
|
| 235 | 237 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 238 | + } |
|
| 236 | 239 | |
| 237 | 240 | echo ' |
| 238 | 241 | </ul> |
@@ -244,25 +247,28 @@ discard block |
||
| 244 | 247 | <a id="msg', $message['id'], '"></a>'; |
| 245 | 248 | |
| 246 | 249 | // Show online and offline buttons? |
| 247 | - if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) |
|
| 248 | - echo ' |
|
| 250 | + if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) { |
|
| 251 | + echo ' |
|
| 249 | 252 | <span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>'; |
| 253 | + } |
|
| 250 | 254 | |
| 251 | 255 | // Custom fields BEFORE the username? |
| 252 | - if (!empty($message['custom_fields']['before_member'])) |
|
| 253 | - foreach ($message['custom_fields']['before_member'] as $custom) |
|
| 256 | + if (!empty($message['custom_fields']['before_member'])) { |
|
| 257 | + foreach ($message['custom_fields']['before_member'] as $custom) |
|
| 254 | 258 | echo ' |
| 255 | 259 | <span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>'; |
| 260 | + } |
|
| 256 | 261 | |
| 257 | 262 | // Show a link to the member's profile. |
| 258 | 263 | echo ' |
| 259 | 264 | ', $message['member']['link']; |
| 260 | 265 | |
| 261 | 266 | // Custom fields AFTER the username? |
| 262 | - if (!empty($message['custom_fields']['after_member'])) |
|
| 263 | - foreach ($message['custom_fields']['after_member'] as $custom) |
|
| 267 | + if (!empty($message['custom_fields']['after_member'])) { |
|
| 268 | + foreach ($message['custom_fields']['after_member'] as $custom) |
|
| 264 | 269 | echo ' |
| 265 | 270 | <span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>'; |
| 271 | + } |
|
| 266 | 272 | |
| 267 | 273 | echo ' |
| 268 | 274 | </h4>'; |
@@ -271,48 +277,56 @@ discard block |
||
| 271 | 277 | <ul class="user_info">'; |
| 272 | 278 | |
| 273 | 279 | // Show the user's avatar. |
| 274 | - if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) |
|
| 275 | - echo ' |
|
| 280 | + if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) { |
|
| 281 | + echo ' |
|
| 276 | 282 | <li class="avatar"> |
| 277 | 283 | <a href="', $scripturl, '?action=profile;u=', $message['member']['id'], '">', $message['member']['avatar']['image'], '</a> |
| 278 | 284 | </li>'; |
| 285 | + } |
|
| 279 | 286 | |
| 280 | 287 | // Are there any custom fields below the avatar? |
| 281 | - if (!empty($message['custom_fields']['below_avatar'])) |
|
| 282 | - foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
| 288 | + if (!empty($message['custom_fields']['below_avatar'])) { |
|
| 289 | + foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
| 283 | 290 | echo ' |
| 284 | 291 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 292 | + } |
|
| 285 | 293 | |
| 286 | - if (!$message['member']['is_guest']) |
|
| 287 | - echo ' |
|
| 294 | + if (!$message['member']['is_guest']) { |
|
| 295 | + echo ' |
|
| 288 | 296 | <li class="icons">', $message['member']['group_icons'], '</li>'; |
| 297 | + } |
|
| 289 | 298 | // Show the member's primary group (like 'Administrator') if they have one. |
| 290 | - if (isset($message['member']['group']) && $message['member']['group'] != '') |
|
| 291 | - echo ' |
|
| 299 | + if (isset($message['member']['group']) && $message['member']['group'] != '') { |
|
| 300 | + echo ' |
|
| 292 | 301 | <li class="membergroup">', $message['member']['group'], '</li>'; |
| 302 | + } |
|
| 293 | 303 | |
| 294 | 304 | // Show the member's custom title, if they have one. |
| 295 | - if (isset($message['member']['title']) && $message['member']['title'] != '') |
|
| 296 | - echo ' |
|
| 305 | + if (isset($message['member']['title']) && $message['member']['title'] != '') { |
|
| 306 | + echo ' |
|
| 297 | 307 | <li class="title">', $message['member']['title'], '</li>'; |
| 308 | + } |
|
| 298 | 309 | |
| 299 | 310 | // Don't show these things for guests. |
| 300 | 311 | if (!$message['member']['is_guest']) |
| 301 | 312 | { |
| 302 | 313 | // Show the post group if and only if they have no other group or the option is on, and they are in a post group. |
| 303 | - if ((empty($modSettings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '') |
|
| 304 | - echo ' |
|
| 314 | + if ((empty($modSettings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '') { |
|
| 315 | + echo ' |
|
| 305 | 316 | <li class="postgroup">', $message['member']['post_group'], '</li>'; |
| 317 | + } |
|
| 306 | 318 | |
| 307 | 319 | // Show how many posts they have made. |
| 308 | - if (!isset($context['disabled_fields']['posts'])) |
|
| 309 | - echo ' |
|
| 320 | + if (!isset($context['disabled_fields']['posts'])) { |
|
| 321 | + echo ' |
|
| 310 | 322 | <li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>'; |
| 323 | + } |
|
| 311 | 324 | |
| 312 | 325 | // Show their personal text? |
| 313 | - if (!empty($modSettings['show_blurb']) && $message['member']['blurb'] != '') |
|
| 314 | - echo ' |
|
| 326 | + if (!empty($modSettings['show_blurb']) && $message['member']['blurb'] != '') { |
|
| 327 | + echo ' |
|
| 315 | 328 | <li class="blurb">', $message['member']['blurb'], '</li>'; |
| 329 | + } |
|
| 316 | 330 | |
| 317 | 331 | // Any custom fields to show as icons? |
| 318 | 332 | if (!empty($message['custom_fields']['icons'])) |
@@ -321,9 +335,10 @@ discard block |
||
| 321 | 335 | <li class="im_icons"> |
| 322 | 336 | <ol>'; |
| 323 | 337 | |
| 324 | - foreach ($message['custom_fields']['icons'] as $custom) |
|
| 325 | - echo ' |
|
| 338 | + foreach ($message['custom_fields']['icons'] as $custom) { |
|
| 339 | + echo ' |
|
| 326 | 340 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 341 | + } |
|
| 327 | 342 | |
| 328 | 343 | echo ' |
| 329 | 344 | </ol> |
@@ -331,19 +346,22 @@ discard block |
||
| 331 | 346 | } |
| 332 | 347 | |
| 333 | 348 | // Show the IP to this user for this post - because you can moderate? |
| 334 | - if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) |
|
| 335 | - echo ' |
|
| 349 | + if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) { |
|
| 350 | + echo ' |
|
| 336 | 351 | <li class="poster_ip"><a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a></li>'; |
| 352 | + } |
|
| 337 | 353 | |
| 338 | 354 | // Or, should we show it because this is you? |
| 339 | - elseif ($message['can_see_ip']) |
|
| 340 | - echo ' |
|
| 355 | + elseif ($message['can_see_ip']) { |
|
| 356 | + echo ' |
|
| 341 | 357 | <li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a></li>'; |
| 358 | + } |
|
| 342 | 359 | |
| 343 | 360 | // Okay, you are logged in, then we can show something about why IPs are logged... |
| 344 | - else |
|
| 345 | - echo ' |
|
| 361 | + else { |
|
| 362 | + echo ' |
|
| 346 | 363 | <li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a></li>'; |
| 364 | + } |
|
| 347 | 365 | |
| 348 | 366 | // Show the profile, website, email address, and personal message buttons. |
| 349 | 367 | if ($message['member']['show_profile_buttons']) |
@@ -353,24 +371,28 @@ discard block |
||
| 353 | 371 | <ol class="profile_icons">'; |
| 354 | 372 | |
| 355 | 373 | // Show the profile button |
| 356 | - if ($message['member']['can_view_profile']) |
|
| 357 | - echo ' |
|
| 374 | + if ($message['member']['can_view_profile']) { |
|
| 375 | + echo ' |
|
| 358 | 376 | <li><a href="', $message['member']['href'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="' . $txt['view_profile'] . '" title="' . $txt['view_profile'] . '">' : $txt['view_profile']), '</a></li>'; |
| 377 | + } |
|
| 359 | 378 | |
| 360 | 379 | // Don't show an icon if they haven't specified a website. |
| 361 | - if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website'])) |
|
| 362 | - echo ' |
|
| 380 | + if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website'])) { |
|
| 381 | + echo ' |
|
| 363 | 382 | <li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
| 383 | + } |
|
| 364 | 384 | |
| 365 | 385 | // Don't show the email address if they want it hidden. |
| 366 | - if ($message['member']['show_email']) |
|
| 367 | - echo ' |
|
| 386 | + if ($message['member']['show_email']) { |
|
| 387 | + echo ' |
|
| 368 | 388 | <li><a href="mailto:', $message['member']['email'], '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>'; |
| 389 | + } |
|
| 369 | 390 | |
| 370 | 391 | // Since we know this person isn't a guest, you *can* message them. |
| 371 | - if ($context['can_send_pm']) |
|
| 372 | - echo ' |
|
| 392 | + if ($context['can_send_pm']) { |
|
| 393 | + echo ' |
|
| 373 | 394 | <li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="generic_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>'; |
| 395 | + } |
|
| 374 | 396 | |
| 375 | 397 | echo ' |
| 376 | 398 | </ol> |
@@ -378,21 +400,24 @@ discard block |
||
| 378 | 400 | } |
| 379 | 401 | |
| 380 | 402 | // Any custom fields for standard placement? |
| 381 | - if (!empty($message['custom_fields']['standard'])) |
|
| 382 | - foreach ($message['custom_fields']['standard'] as $custom) |
|
| 403 | + if (!empty($message['custom_fields']['standard'])) { |
|
| 404 | + foreach ($message['custom_fields']['standard'] as $custom) |
|
| 383 | 405 | echo ' |
| 384 | 406 | <li class="custom ', $custom['col_name'] ,'">', $custom['title'], ': ', $custom['value'], '</li>'; |
| 407 | + } |
|
| 385 | 408 | |
| 386 | 409 | // Are we showing the warning status? |
| 387 | - if ($message['member']['can_see_warning']) |
|
| 388 | - echo ' |
|
| 410 | + if ($message['member']['can_see_warning']) { |
|
| 411 | + echo ' |
|
| 389 | 412 | <li class="warning">', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="generic_icons warning_', $message['member']['warning_status'], '"></span>', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>'; |
| 413 | + } |
|
| 390 | 414 | |
| 391 | 415 | // Are there any custom fields to show at the bottom of the poster info? |
| 392 | - if (!empty($message['custom_fields']['bottom_poster'])) |
|
| 393 | - foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
| 416 | + if (!empty($message['custom_fields']['bottom_poster'])) { |
|
| 417 | + foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
| 394 | 418 | echo ' |
| 395 | 419 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 420 | + } |
|
| 396 | 421 | } |
| 397 | 422 | |
| 398 | 423 | // Done with the information about the poster... on to the post itself. |
@@ -411,25 +436,29 @@ discard block |
||
| 411 | 436 | <span class="smalltext">« <strong> ', $txt['sent_to'], ':</strong> '; |
| 412 | 437 | |
| 413 | 438 | // People it was sent directly to.... |
| 414 | - if (!empty($message['recipients']['to'])) |
|
| 415 | - echo implode(', ', $message['recipients']['to']); |
|
| 439 | + if (!empty($message['recipients']['to'])) { |
|
| 440 | + echo implode(', ', $message['recipients']['to']); |
|
| 441 | + } |
|
| 416 | 442 | |
| 417 | 443 | // Otherwise, we're just going to say "some people"... |
| 418 | - elseif ($context['folder'] != 'sent') |
|
| 419 | - echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
| 444 | + elseif ($context['folder'] != 'sent') { |
|
| 445 | + echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
| 446 | + } |
|
| 420 | 447 | |
| 421 | 448 | echo ' |
| 422 | 449 | <strong> ', $txt['on'], ':</strong> ', $message['time'], ' » |
| 423 | 450 | </span>'; |
| 424 | 451 | |
| 425 | 452 | // If we're in the sent items, show who it was sent to besides the "To:" people. |
| 426 | - if (!empty($message['recipients']['bcc'])) |
|
| 427 | - echo ' |
|
| 453 | + if (!empty($message['recipients']['bcc'])) { |
|
| 454 | + echo ' |
|
| 428 | 455 | <br><span class="smalltext">« <strong> ', $txt['pm_bcc'], ':</strong> ', implode(', ', $message['recipients']['bcc']), ' »</span>'; |
| 456 | + } |
|
| 429 | 457 | |
| 430 | - if (!empty($message['is_replied_to'])) |
|
| 431 | - echo ' |
|
| 458 | + if (!empty($message['is_replied_to'])) { |
|
| 459 | + echo ' |
|
| 432 | 460 | <br><span class="smalltext">« ', $context['folder'] == 'sent' ? $txt['pm_sent_is_replied_to'] : $txt['pm_is_replied_to'], ' »</span>'; |
| 461 | + } |
|
| 433 | 462 | |
| 434 | 463 | echo ' |
| 435 | 464 | </div><!-- .keyinfo --> |
@@ -437,13 +466,15 @@ discard block |
||
| 437 | 466 | <div class="post"> |
| 438 | 467 | <div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>'; |
| 439 | 468 | |
| 440 | - if ($message['can_report'] || $context['can_send_pm']) |
|
| 441 | - echo ' |
|
| 469 | + if ($message['can_report'] || $context['can_send_pm']) { |
|
| 470 | + echo ' |
|
| 442 | 471 | <div class="under_message">'; |
| 472 | + } |
|
| 443 | 473 | |
| 444 | - if ($message['can_report']) |
|
| 445 | - echo ' |
|
| 474 | + if ($message['can_report']) { |
|
| 475 | + echo ' |
|
| 446 | 476 | <a href="' . $scripturl . '?action=pm;sa=report;l=' . $context['current_label_id'] . ';pmsg=' . $message['id'] . '" class="floatright">' . $txt['pm_report_to_admin'] . '</a>'; |
| 477 | + } |
|
| 447 | 478 | |
| 448 | 479 | echo ' |
| 449 | 480 | <ul class="quickbuttons">'; |
@@ -455,32 +486,36 @@ discard block |
||
| 455 | 486 | if (!$message['member']['is_guest']) |
| 456 | 487 | { |
| 457 | 488 | // Is there than more than one recipient you can reply to? |
| 458 | - if ($message['number_recipients'] > 1) |
|
| 459 | - echo ' |
|
| 489 | + if ($message['number_recipients'] > 1) { |
|
| 490 | + echo ' |
|
| 460 | 491 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=all"><span class="generic_icons reply_all_button"></span>', $txt['reply_to_all'], '</a></li>'; |
| 492 | + } |
|
| 461 | 493 | |
| 462 | 494 | echo ' |
| 463 | 495 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li> |
| 464 | 496 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote', $context['folder'] == 'sent' ? '' : ';u=' . $message['member']['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
| 465 | 497 | } |
| 466 | 498 | // This is for "forwarding" - even if the member is gone. |
| 467 | - else |
|
| 468 | - echo ' |
|
| 499 | + else { |
|
| 500 | + echo ' |
|
| 469 | 501 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote"><span class="generic_icons quote"></span>', $txt['reply_quote'], '</a></li>'; |
| 502 | + } |
|
| 470 | 503 | } |
| 471 | 504 | echo ' |
| 472 | 505 | <li><a href="', $scripturl, '?action=pm;sa=pmactions;pm_actions%5b', $message['id'], '%5D=delete;f=', $context['folder'], ';start=', $context['start'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', addslashes($txt['remove_message_question']), '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['delete'], '</a></li>'; |
| 473 | 506 | |
| 474 | - if (empty($context['display_mode'])) |
|
| 475 | - echo ' |
|
| 507 | + if (empty($context['display_mode'])) { |
|
| 508 | + echo ' |
|
| 476 | 509 | <li><input type="checkbox" name="pms[]" id="deletedisplay', $message['id'], '" value="', $message['id'], '" onclick="document.getElementById(\'deletelisting', $message['id'], '\').checked = this.checked;"></li>'; |
| 510 | + } |
|
| 477 | 511 | |
| 478 | 512 | echo ' |
| 479 | 513 | </ul>'; |
| 480 | 514 | |
| 481 | - if ($message['can_report'] || $context['can_send_pm']) |
|
| 482 | - echo ' |
|
| 515 | + if ($message['can_report'] || $context['can_send_pm']) { |
|
| 516 | + echo ' |
|
| 483 | 517 | </div><!-- .under_message -->'; |
| 518 | + } |
|
| 484 | 519 | |
| 485 | 520 | // Are there any custom profile fields for above the signature? |
| 486 | 521 | if (!empty($message['custom_fields']['above_signature'])) |
@@ -489,9 +524,10 @@ discard block |
||
| 489 | 524 | <div class="custom_fields_above_signature"> |
| 490 | 525 | <ul class="nolist">'; |
| 491 | 526 | |
| 492 | - foreach ($message['custom_fields']['above_signature'] as $custom) |
|
| 493 | - echo ' |
|
| 527 | + foreach ($message['custom_fields']['above_signature'] as $custom) { |
|
| 528 | + echo ' |
|
| 494 | 529 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 530 | + } |
|
| 495 | 531 | |
| 496 | 532 | echo ' |
| 497 | 533 | </ul> |
@@ -499,9 +535,10 @@ discard block |
||
| 499 | 535 | } |
| 500 | 536 | |
| 501 | 537 | // Show the member's signature? |
| 502 | - if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) |
|
| 503 | - echo ' |
|
| 538 | + if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) { |
|
| 539 | + echo ' |
|
| 504 | 540 | <div class="signature">', $message['member']['signature'], '</div>'; |
| 541 | + } |
|
| 505 | 542 | |
| 506 | 543 | // Are there any custom profile fields for below the signature? |
| 507 | 544 | if (!empty($message['custom_fields']['below_signature'])) |
@@ -510,9 +547,10 @@ discard block |
||
| 510 | 547 | <div class="custom_fields_below_signature"> |
| 511 | 548 | <ul class="nolist">'; |
| 512 | 549 | |
| 513 | - foreach ($message['custom_fields']['below_signature'] as $custom) |
|
| 514 | - echo ' |
|
| 550 | + foreach ($message['custom_fields']['below_signature'] as $custom) { |
|
| 551 | + echo ' |
|
| 515 | 552 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 553 | + } |
|
| 516 | 554 | |
| 517 | 555 | echo ' |
| 518 | 556 | </ul> |
@@ -539,10 +577,11 @@ discard block |
||
| 539 | 577 | echo ' |
| 540 | 578 | <option value="" disabled>', $txt['pm_msg_label_apply'], ':</option>'; |
| 541 | 579 | |
| 542 | - foreach ($context['labels'] as $label) |
|
| 543 | - if (!isset($message['labels'][$label['id']])) |
|
| 580 | + foreach ($context['labels'] as $label) { |
|
| 581 | + if (!isset($message['labels'][$label['id']])) |
|
| 544 | 582 | echo ' |
| 545 | 583 | <option value="', $label['id'], '"> ', $label['name'], '</option>'; |
| 584 | + } |
|
| 546 | 585 | } |
| 547 | 586 | |
| 548 | 587 | // ... and are there any that can be removed? |
@@ -551,9 +590,10 @@ discard block |
||
| 551 | 590 | echo ' |
| 552 | 591 | <option value="" disabled>', $txt['pm_msg_label_remove'], ':</option>'; |
| 553 | 592 | |
| 554 | - foreach ($message['labels'] as $label) |
|
| 555 | - echo ' |
|
| 593 | + foreach ($message['labels'] as $label) { |
|
| 594 | + echo ' |
|
| 556 | 595 | <option value="', $label['id'], '"> ', $label['name'], '</option>'; |
| 596 | + } |
|
| 557 | 597 | } |
| 558 | 598 | echo ' |
| 559 | 599 | </select> |
@@ -572,8 +612,8 @@ discard block |
||
| 572 | 612 | </div><!-- .windowbg -->'; |
| 573 | 613 | } |
| 574 | 614 | |
| 575 | - if (empty($context['display_mode'])) |
|
| 576 | - echo ' |
|
| 615 | + if (empty($context['display_mode'])) { |
|
| 616 | + echo ' |
|
| 577 | 617 | |
| 578 | 618 | <div class="pagesection"> |
| 579 | 619 | <div class="floatleft">', $context['page_index'], '</div> |
@@ -581,6 +621,7 @@ discard block |
||
| 581 | 621 | <input type="submit" name="del_selected" value="', $txt['quickmod_delete_selected'], '" style="font-weight: normal;" onclick="if (!confirm(\'', $txt['delete_selected_confirm'], '\')) return false;" class="button"> |
| 582 | 622 | </div> |
| 583 | 623 | </div>'; |
| 624 | + } |
|
| 584 | 625 | |
| 585 | 626 | // Show a few buttons if we are in conversation mode and outputting the first message. |
| 586 | 627 | elseif ($context['display_mode'] == 2 && isset($context['conversation_buttons'])) |
@@ -641,11 +682,12 @@ discard block |
||
| 641 | 682 | </thead> |
| 642 | 683 | <tbody>'; |
| 643 | 684 | |
| 644 | - if (!$context['show_delete']) |
|
| 645 | - echo ' |
|
| 685 | + if (!$context['show_delete']) { |
|
| 686 | + echo ' |
|
| 646 | 687 | <tr class="windowbg"> |
| 647 | 688 | <td colspan="5">', $txt['pm_alert_none'], '</td> |
| 648 | 689 | </tr>'; |
| 690 | + } |
|
| 649 | 691 | |
| 650 | 692 | while ($message = $context['get_pmessage']('subject')) |
| 651 | 693 | { |
@@ -705,9 +747,10 @@ discard block |
||
| 705 | 747 | |
| 706 | 748 | foreach ($context['labels'] as $label) |
| 707 | 749 | { |
| 708 | - if ($label['id'] != $context['current_label_id']) |
|
| 709 | - echo ' |
|
| 750 | + if ($label['id'] != $context['current_label_id']) { |
|
| 751 | + echo ' |
|
| 710 | 752 | <option value="add_', $label['id'], '"> ', $label['name'], '</option>'; |
| 753 | + } |
|
| 711 | 754 | } |
| 712 | 755 | |
| 713 | 756 | echo ' |
@@ -793,9 +836,10 @@ discard block |
||
| 793 | 836 | <dd>', $txt['pm_search_between'], ' <input type="number" name="minage" value="', empty($context['search_params']['minage']) ? '0' : $context['search_params']['minage'], '" size="5" maxlength="5" min="0" max="9999"> ', $txt['pm_search_between_and'], ' <input type="number" name="maxage" value="', empty($context['search_params']['maxage']) ? '9999' : $context['search_params']['maxage'], '" size="5" maxlength="5" min="0" max="9999"> ', $txt['pm_search_between_days'], '</dd> |
| 794 | 837 | </dl>'; |
| 795 | 838 | |
| 796 | - if (!$context['currently_using_labels']) |
|
| 797 | - echo ' |
|
| 839 | + if (!$context['currently_using_labels']) { |
|
| 840 | + echo ' |
|
| 798 | 841 | <input type="submit" name="pm_search" value="', $txt['pm_search_go'], '" class="button">'; |
| 842 | + } |
|
| 799 | 843 | |
| 800 | 844 | echo ' |
| 801 | 845 | <br class="clear_right"> |
@@ -816,12 +860,13 @@ discard block |
||
| 816 | 860 | <div id="advanced_panel_div"> |
| 817 | 861 | <ul id="searchLabelsExpand">'; |
| 818 | 862 | |
| 819 | - foreach ($context['search_labels'] as $label) |
|
| 820 | - echo ' |
|
| 863 | + foreach ($context['search_labels'] as $label) { |
|
| 864 | + echo ' |
|
| 821 | 865 | <li> |
| 822 | 866 | <label for="searchlabel_', $label['id'], '"><input type="checkbox" id="searchlabel_', $label['id'], '" name="searchlabel[', $label['id'], ']" value="', $label['id'], '"', $label['checked'] ? ' checked' : '', '> |
| 823 | 867 | ', $label['name'], '</label> |
| 824 | 868 | </li>'; |
| 869 | + } |
|
| 825 | 870 | |
| 826 | 871 | echo ' |
| 827 | 872 | </ul> |
@@ -883,8 +928,8 @@ discard block |
||
| 883 | 928 | </div>'; |
| 884 | 929 | |
| 885 | 930 | // complete results ? |
| 886 | - if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) |
|
| 887 | - echo ' |
|
| 931 | + if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) { |
|
| 932 | + echo ' |
|
| 888 | 933 | <table class="table_grid"> |
| 889 | 934 | <thead> |
| 890 | 935 | <tr class="title_bar"> |
@@ -894,6 +939,7 @@ discard block |
||
| 894 | 939 | </tr> |
| 895 | 940 | </thead> |
| 896 | 941 | <tbody>'; |
| 942 | + } |
|
| 897 | 943 | |
| 898 | 944 | // Print each message out... |
| 899 | 945 | foreach ($context['personal_messages'] as $message) |
@@ -913,12 +959,14 @@ discard block |
||
| 913 | 959 | |
| 914 | 960 | // Show the recipients. |
| 915 | 961 | // @todo This doesn't deal with the sent item searching quite right for bcc. |
| 916 | - if (!empty($message['recipients']['to'])) |
|
| 917 | - echo implode(', ', $message['recipients']['to']); |
|
| 962 | + if (!empty($message['recipients']['to'])) { |
|
| 963 | + echo implode(', ', $message['recipients']['to']); |
|
| 964 | + } |
|
| 918 | 965 | |
| 919 | 966 | // Otherwise, we're just going to say "some people"... |
| 920 | - elseif ($context['folder'] != 'sent') |
|
| 921 | - echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
| 967 | + elseif ($context['folder'] != 'sent') { |
|
| 968 | + echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
| 969 | + } |
|
| 922 | 970 | |
| 923 | 971 | echo ' |
| 924 | 972 | </h3> |
@@ -933,15 +981,17 @@ discard block |
||
| 933 | 981 | $reply_button = create_button('im_reply.png', 'reply', 'reply', 'class="centericon"'); |
| 934 | 982 | |
| 935 | 983 | // You can only reply if they are not a guest... |
| 936 | - if (!$message['member']['is_guest']) |
|
| 937 | - echo ' |
|
| 984 | + if (!$message['member']['is_guest']) { |
|
| 985 | + echo ' |
|
| 938 | 986 | <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=', $context['folder'] == 'sent' ? '' : $message['member']['id'], '">', $quote_button , '</a>', $context['menu_separator'], ' |
| 939 | 987 | <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $reply_button , '</a> ', $context['menu_separator']; |
| 988 | + } |
|
| 940 | 989 | |
| 941 | 990 | // This is for "forwarding" - even if the member is gone. |
| 942 | - else |
|
| 943 | - echo ' |
|
| 991 | + else { |
|
| 992 | + echo ' |
|
| 944 | 993 | <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $quote_button , '</a>', $context['menu_separator']; |
| 994 | + } |
|
| 945 | 995 | } |
| 946 | 996 | |
| 947 | 997 | echo ' |
@@ -962,17 +1012,19 @@ discard block |
||
| 962 | 1012 | } |
| 963 | 1013 | |
| 964 | 1014 | // Finish off the page... |
| 965 | - if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) |
|
| 966 | - echo ' |
|
| 1015 | + if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) { |
|
| 1016 | + echo ' |
|
| 967 | 1017 | </tbody> |
| 968 | 1018 | </table>'; |
| 1019 | + } |
|
| 969 | 1020 | |
| 970 | 1021 | // No results? |
| 971 | - if (empty($context['personal_messages'])) |
|
| 972 | - echo ' |
|
| 1022 | + if (empty($context['personal_messages'])) { |
|
| 1023 | + echo ' |
|
| 973 | 1024 | <div class="windowbg"> |
| 974 | 1025 | <p class="centertext">', $txt['pm_search_none_found'], '</p> |
| 975 | 1026 | </div>'; |
| 1027 | + } |
|
| 976 | 1028 | |
| 977 | 1029 | echo ' |
| 978 | 1030 | <div class="pagesection"> |
@@ -997,15 +1049,17 @@ discard block |
||
| 997 | 1049 | </div> |
| 998 | 1050 | <div class="windowbg">'; |
| 999 | 1051 | |
| 1000 | - if (!empty($context['send_log']['sent'])) |
|
| 1001 | - foreach ($context['send_log']['sent'] as $log_entry) |
|
| 1052 | + if (!empty($context['send_log']['sent'])) { |
|
| 1053 | + foreach ($context['send_log']['sent'] as $log_entry) |
|
| 1002 | 1054 | echo ' |
| 1003 | 1055 | <span class="error">', $log_entry, '</span><br>'; |
| 1056 | + } |
|
| 1004 | 1057 | |
| 1005 | - if (!empty($context['send_log']['failed'])) |
|
| 1006 | - foreach ($context['send_log']['failed'] as $log_entry) |
|
| 1058 | + if (!empty($context['send_log']['failed'])) { |
|
| 1059 | + foreach ($context['send_log']['failed'] as $log_entry) |
|
| 1007 | 1060 | echo ' |
| 1008 | 1061 | <span class="error">', $log_entry, '</span><br>'; |
| 1062 | + } |
|
| 1009 | 1063 | |
| 1010 | 1064 | echo ' |
| 1011 | 1065 | </div> |
@@ -1054,12 +1108,13 @@ discard block |
||
| 1054 | 1108 | </dl> |
| 1055 | 1109 | </div>'; |
| 1056 | 1110 | |
| 1057 | - if (!empty($modSettings['drafts_pm_enabled'])) |
|
| 1058 | - echo ' |
|
| 1111 | + if (!empty($modSettings['drafts_pm_enabled'])) { |
|
| 1112 | + echo ' |
|
| 1059 | 1113 | <div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>', |
| 1060 | 1114 | sprintf($txt['draft_pm_saved'], $scripturl . '?action=pm;sa=showpmdrafts'), ' |
| 1061 | 1115 | ', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), ' |
| 1062 | 1116 | </div>'; |
| 1117 | + } |
|
| 1063 | 1118 | |
| 1064 | 1119 | echo ' |
| 1065 | 1120 | <dl id="post_header">'; |
@@ -1115,9 +1170,10 @@ discard block |
||
| 1115 | 1170 | } |
| 1116 | 1171 | |
| 1117 | 1172 | // What about smileys? |
| 1118 | - if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) |
|
| 1119 | - echo ' |
|
| 1173 | + if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) { |
|
| 1174 | + echo ' |
|
| 1120 | 1175 | <div id="smileyBox_message"></div>'; |
| 1176 | + } |
|
| 1121 | 1177 | |
| 1122 | 1178 | // Show BBC buttons, smileys and textbox. |
| 1123 | 1179 | echo ' |
@@ -1164,10 +1220,11 @@ discard block |
||
| 1164 | 1220 | <dt><strong>', $txt['subject'], '</strong></dt> |
| 1165 | 1221 | <dd><strong>', $txt['draft_saved_on'], '</strong></dd>'; |
| 1166 | 1222 | |
| 1167 | - foreach ($context['drafts'] as $draft) |
|
| 1168 | - echo ' |
|
| 1223 | + foreach ($context['drafts'] as $draft) { |
|
| 1224 | + echo ' |
|
| 1169 | 1225 | <dt>', $draft['link'], '</dt> |
| 1170 | 1226 | <dd>', $draft['poster_time'], '</dd>'; |
| 1227 | + } |
|
| 1171 | 1228 | echo ' |
| 1172 | 1229 | </dl> |
| 1173 | 1230 | </div>'; |
@@ -1274,8 +1331,8 @@ discard block |
||
| 1274 | 1331 | }'; |
| 1275 | 1332 | |
| 1276 | 1333 | // Code for showing and hiding drafts |
| 1277 | - if (!empty($context['drafts'])) |
|
| 1278 | - echo ' |
|
| 1334 | + if (!empty($context['drafts'])) { |
|
| 1335 | + echo ' |
|
| 1279 | 1336 | var oSwapDraftOptions = new smc_Toggle({ |
| 1280 | 1337 | bToggleEnabled: true, |
| 1281 | 1338 | bCurrentlyCollapsed: true, |
@@ -1297,13 +1354,14 @@ discard block |
||
| 1297 | 1354 | } |
| 1298 | 1355 | ] |
| 1299 | 1356 | });'; |
| 1357 | + } |
|
| 1300 | 1358 | |
| 1301 | 1359 | echo ' |
| 1302 | 1360 | </script>'; |
| 1303 | 1361 | |
| 1304 | 1362 | // Show the message you're replying to. |
| 1305 | - if ($context['reply']) |
|
| 1306 | - echo ' |
|
| 1363 | + if ($context['reply']) { |
|
| 1364 | + echo ' |
|
| 1307 | 1365 | <br><br> |
| 1308 | 1366 | <div class="cat_bar"> |
| 1309 | 1367 | <h3 class="catbg">', $txt['subject'], ': ', $context['quoted_message']['subject'], '</h3> |
@@ -1317,6 +1375,7 @@ discard block |
||
| 1317 | 1375 | ', $context['quoted_message']['body'], ' |
| 1318 | 1376 | </div> |
| 1319 | 1377 | <br class="clear">'; |
| 1378 | + } |
|
| 1320 | 1379 | |
| 1321 | 1380 | echo ' |
| 1322 | 1381 | <script> |
@@ -1328,23 +1387,25 @@ discard block |
||
| 1328 | 1387 | sToControlId: \'to_control\', |
| 1329 | 1388 | aToRecipients: ['; |
| 1330 | 1389 | |
| 1331 | - foreach ($context['recipients']['to'] as $i => $member) |
|
| 1332 | - echo ' |
|
| 1390 | + foreach ($context['recipients']['to'] as $i => $member) { |
|
| 1391 | + echo ' |
|
| 1333 | 1392 | { |
| 1334 | 1393 | sItemId: ', JavaScriptEscape($member['id']), ', |
| 1335 | 1394 | sItemName: ', JavaScriptEscape($member['name']), ' |
| 1336 | 1395 | }', $i == count($context['recipients']['to']) - 1 ? '' : ','; |
| 1396 | + } |
|
| 1337 | 1397 | |
| 1338 | 1398 | echo ' |
| 1339 | 1399 | ], |
| 1340 | 1400 | aBccRecipients: ['; |
| 1341 | 1401 | |
| 1342 | - foreach ($context['recipients']['bcc'] as $i => $member) |
|
| 1343 | - echo ' |
|
| 1402 | + foreach ($context['recipients']['bcc'] as $i => $member) { |
|
| 1403 | + echo ' |
|
| 1344 | 1404 | { |
| 1345 | 1405 | sItemId: ', JavaScriptEscape($member['id']), ', |
| 1346 | 1406 | sItemName: ', JavaScriptEscape($member['name']), ' |
| 1347 | 1407 | }', $i == count($context['recipients']['bcc']) - 1 ? '' : ','; |
| 1408 | + } |
|
| 1348 | 1409 | |
| 1349 | 1410 | echo ' |
| 1350 | 1411 | ], |
@@ -1433,26 +1494,28 @@ discard block |
||
| 1433 | 1494 | </th> |
| 1434 | 1495 | <th class="centertext table_icon">'; |
| 1435 | 1496 | |
| 1436 | - if (count($context['labels']) > 2) |
|
| 1437 | - echo ' |
|
| 1497 | + if (count($context['labels']) > 2) { |
|
| 1498 | + echo ' |
|
| 1438 | 1499 | <input type="checkbox" onclick="invertAll(this, this.form);">'; |
| 1500 | + } |
|
| 1439 | 1501 | |
| 1440 | 1502 | echo ' |
| 1441 | 1503 | </th> |
| 1442 | 1504 | </tr> |
| 1443 | 1505 | </thead> |
| 1444 | 1506 | <tbody>'; |
| 1445 | - if (count($context['labels']) < 2) |
|
| 1446 | - echo ' |
|
| 1507 | + if (count($context['labels']) < 2) { |
|
| 1508 | + echo ' |
|
| 1447 | 1509 | <tr class="windowbg"> |
| 1448 | 1510 | <td colspan="2">', $txt['pm_labels_no_exist'], '</td> |
| 1449 | 1511 | </tr>'; |
| 1450 | - else |
|
| 1512 | + } else |
|
| 1451 | 1513 | { |
| 1452 | 1514 | foreach ($context['labels'] as $label) |
| 1453 | 1515 | { |
| 1454 | - if ($label['id'] == -1) |
|
| 1455 | - continue; |
|
| 1516 | + if ($label['id'] == -1) { |
|
| 1517 | + continue; |
|
| 1518 | + } |
|
| 1456 | 1519 | |
| 1457 | 1520 | echo ' |
| 1458 | 1521 | <tr class="windowbg"> |
@@ -1467,12 +1530,13 @@ discard block |
||
| 1467 | 1530 | </tbody> |
| 1468 | 1531 | </table>'; |
| 1469 | 1532 | |
| 1470 | - if (!count($context['labels']) < 2) |
|
| 1471 | - echo ' |
|
| 1533 | + if (!count($context['labels']) < 2) { |
|
| 1534 | + echo ' |
|
| 1472 | 1535 | <div class="padding"> |
| 1473 | 1536 | <input type="submit" name="save" value="', $txt['save'], '" class="button"> |
| 1474 | 1537 | <input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" data-confirm="', $txt['pm_labels_delete'] ,'" class="button you_sure"> |
| 1475 | 1538 | </div>'; |
| 1539 | + } |
|
| 1476 | 1540 | |
| 1477 | 1541 | echo ' |
| 1478 | 1542 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -1528,9 +1592,10 @@ discard block |
||
| 1528 | 1592 | <dd> |
| 1529 | 1593 | <select name="id_admin"> |
| 1530 | 1594 | <option value="0">', $txt['pm_report_all_admins'], '</option>'; |
| 1531 | - foreach ($context['admins'] as $id => $name) |
|
| 1532 | - echo ' |
|
| 1595 | + foreach ($context['admins'] as $id => $name) { |
|
| 1596 | + echo ' |
|
| 1533 | 1597 | <option value="', $id, '">', $name, '</option>'; |
| 1598 | + } |
|
| 1534 | 1599 | echo ' |
| 1535 | 1600 | </select> |
| 1536 | 1601 | </dd>'; |
@@ -1592,9 +1657,10 @@ discard block |
||
| 1592 | 1657 | </th> |
| 1593 | 1658 | <th class="centertext table_icon">'; |
| 1594 | 1659 | |
| 1595 | - if (!empty($context['rules'])) |
|
| 1596 | - echo ' |
|
| 1660 | + if (!empty($context['rules'])) { |
|
| 1661 | + echo ' |
|
| 1597 | 1662 | <input type="checkbox" onclick="invertAll(this, this.form);">'; |
| 1663 | + } |
|
| 1598 | 1664 | |
| 1599 | 1665 | echo ' |
| 1600 | 1666 | </th> |
@@ -1602,13 +1668,14 @@ discard block |
||
| 1602 | 1668 | </thead> |
| 1603 | 1669 | <tbody>'; |
| 1604 | 1670 | |
| 1605 | - if (empty($context['rules'])) |
|
| 1606 | - echo ' |
|
| 1671 | + if (empty($context['rules'])) { |
|
| 1672 | + echo ' |
|
| 1607 | 1673 | <tr class="windowbg"> |
| 1608 | 1674 | <td colspan="2"> |
| 1609 | 1675 | ', $txt['pm_rules_none'], ' |
| 1610 | 1676 | </td> |
| 1611 | 1677 | </tr>'; |
| 1678 | + } |
|
| 1612 | 1679 | |
| 1613 | 1680 | foreach ($context['rules'] as $rule) |
| 1614 | 1681 | { |
@@ -1629,14 +1696,16 @@ discard block |
||
| 1629 | 1696 | <div class="righttext"> |
| 1630 | 1697 | <a class="button" href="', $scripturl, '?action=pm;sa=manrules;add;rid=0">', $txt['pm_add_rule'], '</a>'; |
| 1631 | 1698 | |
| 1632 | - if (!empty($context['rules'])) |
|
| 1633 | - echo ' |
|
| 1699 | + if (!empty($context['rules'])) { |
|
| 1700 | + echo ' |
|
| 1634 | 1701 | [<a href="', $scripturl, '?action=pm;sa=manrules;apply;', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['pm_js_apply_rules_confirm'], '\');">', $txt['pm_apply_rules'], '</a>]'; |
| 1702 | + } |
|
| 1635 | 1703 | |
| 1636 | - if (!empty($context['rules'])) |
|
| 1637 | - echo ' |
|
| 1704 | + if (!empty($context['rules'])) { |
|
| 1705 | + echo ' |
|
| 1638 | 1706 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 1639 | 1707 | <input type="submit" name="delselected" value="', $txt['pm_delete_selected_rule'], '" data-confirm="', $txt['pm_js_delete_rule_confirm'] ,'" class="button smalltext you_sure">'; |
| 1708 | + } |
|
| 1640 | 1709 | |
| 1641 | 1710 | echo ' |
| 1642 | 1711 | </div> |
@@ -1658,14 +1727,16 @@ discard block |
||
| 1658 | 1727 | var groups = new Array() |
| 1659 | 1728 | var labels = new Array()'; |
| 1660 | 1729 | |
| 1661 | - foreach ($context['groups'] as $id => $title) |
|
| 1662 | - echo ' |
|
| 1730 | + foreach ($context['groups'] as $id => $title) { |
|
| 1731 | + echo ' |
|
| 1663 | 1732 | groups[', $id, '] = "', addslashes($title), '";'; |
| 1733 | + } |
|
| 1664 | 1734 | |
| 1665 | - foreach ($context['labels'] as $label) |
|
| 1666 | - if ($label['id'] != -1) |
|
| 1735 | + foreach ($context['labels'] as $label) { |
|
| 1736 | + if ($label['id'] != -1) |
|
| 1667 | 1737 | echo ' |
| 1668 | 1738 | labels[', ($label['id']), '] = "', addslashes($label['name']), '";'; |
| 1739 | + } |
|
| 1669 | 1740 | |
| 1670 | 1741 | echo ' |
| 1671 | 1742 | function addCriteriaOption() |
@@ -1680,8 +1751,9 @@ discard block |
||
| 1680 | 1751 | |
| 1681 | 1752 | setOuterHTML(document.getElementById("criteriaAddHere"), \'<br><select name="ruletype[\' + criteriaNum + \']" id="ruletype\' + criteriaNum + \'" onchange="updateRuleDef(\' + criteriaNum + \'); rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_criteria_pick']), ':<\' + \'/option><option value="mid">', addslashes($txt['pm_rule_mid']), '<\' + \'/option><option value="gid">', addslashes($txt['pm_rule_gid']), '<\' + \'/option><option value="sub">', addslashes($txt['pm_rule_sub']), '<\' + \'/option><option value="msg">', addslashes($txt['pm_rule_msg']), '<\' + \'/option><option value="bud">', addslashes($txt['pm_rule_bud']), '<\' + \'/option><\' + \'/select> <span id="defdiv\' + criteriaNum + \'" style="display: none;"><input type="text" name="ruledef[\' + criteriaNum + \']" id="ruledef\' + criteriaNum + \'" onkeyup="rebuildRuleDesc();" value=""><\' + \'/span><span id="defseldiv\' + criteriaNum + \'" style="display: none;"><select name="ruledefgroup[\' + criteriaNum + \']" id="ruledefgroup\' + criteriaNum + \'" onchange="rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_group']), '<\' + \'/option>'; |
| 1682 | 1753 | |
| 1683 | - foreach ($context['groups'] as $id => $group) |
|
| 1684 | - echo '<option value="', $id, '">', strtr($group, array("'" => "\'")), '<\' + \'/option>'; |
|
| 1754 | + foreach ($context['groups'] as $id => $group) { |
|
| 1755 | + echo '<option value="', $id, '">', strtr($group, array("'" => "\'")), '<\' + \'/option>'; |
|
| 1756 | + } |
|
| 1685 | 1757 | |
| 1686 | 1758 | echo '<\' + \'/select><\' + \'/span><span id="criteriaAddHere"><\' + \'/span>\'); |
| 1687 | 1759 | } |
@@ -1698,9 +1770,10 @@ discard block |
||
| 1698 | 1770 | |
| 1699 | 1771 | setOuterHTML(document.getElementById("actionAddHere"), \'<br><select name="acttype[\' + actionNum + \']" id="acttype\' + actionNum + \'" onchange="updateActionDef(\' + actionNum + \'); rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_action']), ':<\' + \'/option><option value="lab">', addslashes($txt['pm_rule_label']), '<\' + \'/option><option value="del">', addslashes($txt['pm_rule_delete']), '<\' + \'/option><\' + \'/select> <span id="labdiv\' + actionNum + \'" style="display: none;"><select name="labdef[\' + actionNum + \']" id="labdef\' + actionNum + \'" onchange="rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_label']), '<\' + \'/option>'; |
| 1700 | 1772 | |
| 1701 | - foreach ($context['labels'] as $label) |
|
| 1702 | - if ($label['id'] != -1) |
|
| 1773 | + foreach ($context['labels'] as $label) { |
|
| 1774 | + if ($label['id'] != -1) |
|
| 1703 | 1775 | echo '<option value="', ($label['id']), '">', addslashes($label['name']), '<\' + \'/option>'; |
| 1776 | + } |
|
| 1704 | 1777 | |
| 1705 | 1778 | echo '<\' + \'/select><\' + \'/span><span id="actionAddHere"><\' + \'/span>\'); |
| 1706 | 1779 | } |
@@ -1814,19 +1887,20 @@ discard block |
||
| 1814 | 1887 | $isFirst = true; |
| 1815 | 1888 | foreach ($context['rule']['criteria'] as $k => $criteria) |
| 1816 | 1889 | { |
| 1817 | - if (!$isFirst && $criteria['t'] == '') |
|
| 1818 | - echo '<div id="removeonjs1">'; |
|
| 1819 | - |
|
| 1820 | - elseif (!$isFirst) |
|
| 1821 | - echo '<br>'; |
|
| 1890 | + if (!$isFirst && $criteria['t'] == '') { |
|
| 1891 | + echo '<div id="removeonjs1">'; |
|
| 1892 | + } elseif (!$isFirst) { |
|
| 1893 | + echo '<br>'; |
|
| 1894 | + } |
|
| 1822 | 1895 | |
| 1823 | 1896 | echo ' |
| 1824 | 1897 | <select name="ruletype[', $k, ']" id="ruletype', $k, '" onchange="updateRuleDef(', $k, '); rebuildRuleDesc();"> |
| 1825 | 1898 | <option value="">', $txt['pm_rule_criteria_pick'], ':</option>'; |
| 1826 | 1899 | |
| 1827 | - foreach (array('mid', 'gid', 'sub', 'msg', 'bud') as $cr) |
|
| 1828 | - echo ' |
|
| 1900 | + foreach (array('mid', 'gid', 'sub', 'msg', 'bud') as $cr) { |
|
| 1901 | + echo ' |
|
| 1829 | 1902 | <option value="', $cr, '"', $criteria['t'] == $cr ? ' selected' : '', '>', $txt['pm_rule_' . $cr], '</option>'; |
| 1903 | + } |
|
| 1830 | 1904 | |
| 1831 | 1905 | echo ' |
| 1832 | 1906 | </select> |
@@ -1837,19 +1911,20 @@ discard block |
||
| 1837 | 1911 | <select name="ruledefgroup[', $k, ']" id="ruledefgroup', $k, '" onchange="rebuildRuleDesc();"> |
| 1838 | 1912 | <option value="">', $txt['pm_rule_sel_group'], '</option>'; |
| 1839 | 1913 | |
| 1840 | - foreach ($context['groups'] as $id => $group) |
|
| 1841 | - echo ' |
|
| 1914 | + foreach ($context['groups'] as $id => $group) { |
|
| 1915 | + echo ' |
|
| 1842 | 1916 | <option value="', $id, '"', $criteria['t'] == 'gid' && $criteria['v'] == $id ? ' selected' : '', '>', $group, '</option>'; |
| 1917 | + } |
|
| 1843 | 1918 | echo ' |
| 1844 | 1919 | </select> |
| 1845 | 1920 | </span>'; |
| 1846 | 1921 | |
| 1847 | 1922 | // If this is the dummy we add a means to hide for non js users. |
| 1848 | - if ($isFirst) |
|
| 1849 | - $isFirst = false; |
|
| 1850 | - |
|
| 1851 | - elseif ($criteria['t'] == '') |
|
| 1852 | - echo '</div><!-- .removeonjs1 -->'; |
|
| 1923 | + if ($isFirst) { |
|
| 1924 | + $isFirst = false; |
|
| 1925 | + } elseif ($criteria['t'] == '') { |
|
| 1926 | + echo '</div><!-- .removeonjs1 -->'; |
|
| 1927 | + } |
|
| 1853 | 1928 | } |
| 1854 | 1929 | |
| 1855 | 1930 | echo ' |
@@ -1872,10 +1947,11 @@ discard block |
||
| 1872 | 1947 | $isFirst = true; |
| 1873 | 1948 | foreach ($context['rule']['actions'] as $k => $action) |
| 1874 | 1949 | { |
| 1875 | - if (!$isFirst && $action['t'] == '') |
|
| 1876 | - echo '<div id="removeonjs2">'; |
|
| 1877 | - elseif (!$isFirst) |
|
| 1878 | - echo '<br>'; |
|
| 1950 | + if (!$isFirst && $action['t'] == '') { |
|
| 1951 | + echo '<div id="removeonjs2">'; |
|
| 1952 | + } elseif (!$isFirst) { |
|
| 1953 | + echo '<br>'; |
|
| 1954 | + } |
|
| 1879 | 1955 | |
| 1880 | 1956 | echo ' |
| 1881 | 1957 | <select name="acttype[', $k, ']" id="acttype', $k, '" onchange="updateActionDef(', $k, '); rebuildRuleDesc();"> |
@@ -1887,19 +1963,21 @@ discard block |
||
| 1887 | 1963 | <select name="labdef[', $k, ']" id="labdef', $k, '" onchange="rebuildRuleDesc();"> |
| 1888 | 1964 | <option value="">', $txt['pm_rule_sel_label'], '</option>'; |
| 1889 | 1965 | |
| 1890 | - foreach ($context['labels'] as $label) |
|
| 1891 | - if ($label['id'] != -1) |
|
| 1966 | + foreach ($context['labels'] as $label) { |
|
| 1967 | + if ($label['id'] != -1) |
|
| 1892 | 1968 | echo ' |
| 1893 | 1969 | <option value="', ($label['id']), '"', $action['t'] == 'lab' && $action['v'] == $label['id'] ? ' selected' : '', '>', $label['name'], '</option>'; |
| 1970 | + } |
|
| 1894 | 1971 | |
| 1895 | 1972 | echo ' |
| 1896 | 1973 | </select> |
| 1897 | 1974 | </span>'; |
| 1898 | 1975 | |
| 1899 | - if ($isFirst) |
|
| 1900 | - $isFirst = false; |
|
| 1901 | - elseif ($action['t'] == '') |
|
| 1902 | - echo '</div><!-- .removeonjs2 -->'; |
|
| 1976 | + if ($isFirst) { |
|
| 1977 | + $isFirst = false; |
|
| 1978 | + } elseif ($action['t'] == '') { |
|
| 1979 | + echo '</div><!-- .removeonjs2 -->'; |
|
| 1980 | + } |
|
| 1903 | 1981 | } |
| 1904 | 1982 | |
| 1905 | 1983 | echo ' |
@@ -1923,22 +2001,25 @@ discard block |
||
| 1923 | 2001 | echo ' |
| 1924 | 2002 | <script>'; |
| 1925 | 2003 | |
| 1926 | - foreach ($context['rule']['criteria'] as $k => $c) |
|
| 1927 | - echo ' |
|
| 2004 | + foreach ($context['rule']['criteria'] as $k => $c) { |
|
| 2005 | + echo ' |
|
| 1928 | 2006 | updateRuleDef(', $k, ');'; |
| 2007 | + } |
|
| 1929 | 2008 | |
| 1930 | - foreach ($context['rule']['actions'] as $k => $c) |
|
| 1931 | - echo ' |
|
| 2009 | + foreach ($context['rule']['actions'] as $k => $c) { |
|
| 2010 | + echo ' |
|
| 1932 | 2011 | updateActionDef(', $k, ');'; |
| 2012 | + } |
|
| 1933 | 2013 | |
| 1934 | 2014 | echo ' |
| 1935 | 2015 | rebuildRuleDesc();'; |
| 1936 | 2016 | |
| 1937 | 2017 | // If this isn't a new rule and we have JS enabled remove the JS compatibility stuff. |
| 1938 | - if ($context['rid']) |
|
| 1939 | - echo ' |
|
| 2018 | + if ($context['rid']) { |
|
| 2019 | + echo ' |
|
| 1940 | 2020 | document.getElementById("removeonjs1").style.display = "none"; |
| 1941 | 2021 | document.getElementById("removeonjs2").style.display = "none";'; |
| 2022 | + } |
|
| 1942 | 2023 | |
| 1943 | 2024 | echo ' |
| 1944 | 2025 | document.getElementById("addonjs1").style.display = ""; |
@@ -1966,12 +2047,12 @@ discard block |
||
| 1966 | 2047 | </div>'; |
| 1967 | 2048 | |
| 1968 | 2049 | // No drafts? Just show an informative message. |
| 1969 | - if (empty($context['drafts'])) |
|
| 1970 | - echo ' |
|
| 2050 | + if (empty($context['drafts'])) { |
|
| 2051 | + echo ' |
|
| 1971 | 2052 | <div class="windowbg2 centertext"> |
| 1972 | 2053 | ', $txt['draft_none'], ' |
| 1973 | 2054 | </div>'; |
| 1974 | - else |
|
| 2055 | + } else |
|
| 1975 | 2056 | { |
| 1976 | 2057 | // For every draft to be displayed, give it its own div, and show the important details of the draft. |
| 1977 | 2058 | foreach ($context['drafts'] as $draft) |
@@ -3096,8 +3096,7 @@ |
||
| 3096 | 3096 | <div class="roundframe"> |
| 3097 | 3097 | <div> |
| 3098 | 3098 | ', !empty($context['tfa_backup']) ? ' |
| 3099 | - <div class="smalltext error">' . $txt['tfa_backup_used_desc'] . '</div>' : |
|
| 3100 | - ($modSettings['tfa_mode'] == 2 ? ' |
|
| 3099 | + <div class="smalltext error">' . $txt['tfa_backup_used_desc'] . '</div>' : ($modSettings['tfa_mode'] == 2 ? ' |
|
| 3101 | 3100 | <div class="smalltext"><strong>' . $txt['tfa_forced_desc'] . '</strong></div>' : ''), ' |
| 3102 | 3101 | <div class="smalltext">', $txt['tfa_desc'], '</div> |
| 3103 | 3102 | <div class="floatleft"> |
@@ -18,23 +18,25 @@ discard block |
||
| 18 | 18 | global $context; |
| 19 | 19 | |
| 20 | 20 | // Prevent Chrome from auto completing fields when viewing/editing other members profiles |
| 21 | - if (isBrowser('is_chrome') && !$context['user']['is_owner']) |
|
| 22 | - echo ' |
|
| 21 | + if (isBrowser('is_chrome') && !$context['user']['is_owner']) { |
|
| 22 | + echo ' |
|
| 23 | 23 | <script> |
| 24 | 24 | disableAutoComplete(); |
| 25 | 25 | </script>'; |
| 26 | + } |
|
| 26 | 27 | |
| 27 | 28 | // If an error occurred while trying to save previously, give the user a clue! |
| 28 | 29 | echo ' |
| 29 | 30 | ', template_error_message(); |
| 30 | 31 | |
| 31 | 32 | // If the profile was update successfully, let the user know this. |
| 32 | - if (!empty($context['profile_updated'])) |
|
| 33 | - echo ' |
|
| 33 | + if (!empty($context['profile_updated'])) { |
|
| 34 | + echo ' |
|
| 34 | 35 | <div class="infobox"> |
| 35 | 36 | ', $context['profile_updated'], ' |
| 36 | 37 | </div>'; |
| 37 | -} |
|
| 38 | + } |
|
| 39 | + } |
|
| 38 | 40 | |
| 39 | 41 | /** |
| 40 | 42 | * Template for any HTML needed below the profile (closing off divs/tables, etc.) |
@@ -102,8 +104,7 @@ discard block |
||
| 102 | 104 | if (empty($context['unread_alerts'])) |
| 103 | 105 | { |
| 104 | 106 | template_alerts_all_read(); |
| 105 | - } |
|
| 106 | - else |
|
| 107 | + } else |
|
| 107 | 108 | { |
| 108 | 109 | foreach ($context['unread_alerts'] as $id_alert => $details) |
| 109 | 110 | { |
@@ -164,10 +165,11 @@ discard block |
||
| 164 | 165 | <div class="custom_fields_above_name"> |
| 165 | 166 | <ul>'; |
| 166 | 167 | |
| 167 | - foreach ($context['print_custom_fields']['above_member'] as $field) |
|
| 168 | - if (!empty($field['output_html'])) |
|
| 168 | + foreach ($context['print_custom_fields']['above_member'] as $field) { |
|
| 169 | + if (!empty($field['output_html'])) |
|
| 169 | 170 | echo ' |
| 170 | 171 | <li>', $field['output_html'], '</li>'; |
| 172 | + } |
|
| 171 | 173 | |
| 172 | 174 | echo ' |
| 173 | 175 | </ul> |
@@ -179,20 +181,22 @@ discard block |
||
| 179 | 181 | <div class="username clear"> |
| 180 | 182 | <h4>'; |
| 181 | 183 | |
| 182 | - if (!empty($context['print_custom_fields']['before_member'])) |
|
| 183 | - foreach ($context['print_custom_fields']['before_member'] as $field) |
|
| 184 | + if (!empty($context['print_custom_fields']['before_member'])) { |
|
| 185 | + foreach ($context['print_custom_fields']['before_member'] as $field) |
|
| 184 | 186 | if (!empty($field['output_html'])) |
| 185 | 187 | echo ' |
| 186 | 188 | <span>', $field['output_html'], '</span>'; |
| 189 | + } |
|
| 187 | 190 | |
| 188 | 191 | echo ' |
| 189 | 192 | ', $context['member']['name']; |
| 190 | 193 | |
| 191 | - if (!empty($context['print_custom_fields']['after_member'])) |
|
| 192 | - foreach ($context['print_custom_fields']['after_member'] as $field) |
|
| 194 | + if (!empty($context['print_custom_fields']['after_member'])) { |
|
| 195 | + foreach ($context['print_custom_fields']['after_member'] as $field) |
|
| 193 | 196 | if (!empty($field['output_html'])) |
| 194 | 197 | echo ' |
| 195 | 198 | <span>', $field['output_html'], '</span>'; |
| 199 | + } |
|
| 196 | 200 | |
| 197 | 201 | |
| 198 | 202 | echo ' |
@@ -208,10 +212,11 @@ discard block |
||
| 208 | 212 | <div class="custom_fields_below_avatar"> |
| 209 | 213 | <ul>'; |
| 210 | 214 | |
| 211 | - foreach ($context['print_custom_fields']['below_avatar'] as $field) |
|
| 212 | - if (!empty($field['output_html'])) |
|
| 215 | + foreach ($context['print_custom_fields']['below_avatar'] as $field) { |
|
| 216 | + if (!empty($field['output_html'])) |
|
| 213 | 217 | echo ' |
| 214 | 218 | <li>', $field['output_html'], '</li>'; |
| 219 | + } |
|
| 215 | 220 | |
| 216 | 221 | echo ' |
| 217 | 222 | </ul> |
@@ -223,22 +228,25 @@ discard block |
||
| 223 | 228 | <ul class="clear">'; |
| 224 | 229 | |
| 225 | 230 | // Email is only visible if it's your profile or you have the moderate_forum permission |
| 226 | - if ($context['member']['show_email']) |
|
| 227 | - echo ' |
|
| 231 | + if ($context['member']['show_email']) { |
|
| 232 | + echo ' |
|
| 228 | 233 | <li><a href="mailto:', $context['member']['email'], '" title="', $context['member']['email'], '" rel="nofollow"><span class="generic_icons mail" title="' . $txt['email'] . '"></span></a></li>'; |
| 234 | + } |
|
| 229 | 235 | |
| 230 | 236 | // Don't show an icon if they haven't specified a website. |
| 231 | - if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) |
|
| 232 | - echo ' |
|
| 237 | + if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) { |
|
| 238 | + echo ' |
|
| 233 | 239 | <li><a href="', $context['member']['website']['url'], '" title="' . $context['member']['website']['title'] . '" target="_blank">', ($settings['use_image_buttons'] ? '<span class="generic_icons www" title="' . $context['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
| 240 | + } |
|
| 234 | 241 | |
| 235 | 242 | // Are there any custom profile fields as icons? |
| 236 | 243 | if (!empty($context['print_custom_fields']['icons'])) |
| 237 | 244 | { |
| 238 | - foreach ($context['print_custom_fields']['icons'] as $field) |
|
| 239 | - if (!empty($field['output_html'])) |
|
| 245 | + foreach ($context['print_custom_fields']['icons'] as $field) { |
|
| 246 | + if (!empty($field['output_html'])) |
|
| 240 | 247 | echo ' |
| 241 | 248 | <li class="custom_field">', $field['output_html'], '</li>'; |
| 249 | + } |
|
| 242 | 250 | } |
| 243 | 251 | |
| 244 | 252 | echo ' |
@@ -247,24 +255,27 @@ discard block |
||
| 247 | 255 | ', $context['can_send_pm'] ? '<a href="' . $context['member']['online']['href'] . '" title="' . $context['member']['online']['text'] . '" rel="nofollow">' : '', $settings['use_image_buttons'] ? '<span class="' . ($context['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $context['member']['online']['text'] . '"></span>' : $context['member']['online']['label'], $context['can_send_pm'] ? '</a>' : '', $settings['use_image_buttons'] ? '<span class="smalltext"> ' . $context['member']['online']['label'] . '</span>' : ''; |
| 248 | 256 | |
| 249 | 257 | // Can they add this member as a buddy? |
| 250 | - if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) |
|
| 251 | - echo ' |
|
| 258 | + if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) { |
|
| 259 | + echo ' |
|
| 252 | 260 | <br> |
| 253 | 261 | <a href="', $scripturl, '?action=buddy;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a>'; |
| 262 | + } |
|
| 254 | 263 | |
| 255 | 264 | echo ' |
| 256 | 265 | </span>'; |
| 257 | 266 | |
| 258 | - if (!$context['user']['is_owner'] && $context['can_send_pm']) |
|
| 259 | - echo ' |
|
| 267 | + if (!$context['user']['is_owner'] && $context['can_send_pm']) { |
|
| 268 | + echo ' |
|
| 260 | 269 | <a href="', $scripturl, '?action=pm;sa=send;u=', $context['id_member'], '" class="infolinks">', $txt['profile_sendpm_short'], '</a>'; |
| 270 | + } |
|
| 261 | 271 | |
| 262 | 272 | echo ' |
| 263 | 273 | <a href="', $scripturl, '?action=profile;area=showposts;u=', $context['id_member'], '" class="infolinks">', $txt['showPosts'], '</a>'; |
| 264 | 274 | |
| 265 | - if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) |
|
| 266 | - echo ' |
|
| 275 | + if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) { |
|
| 276 | + echo ' |
|
| 267 | 277 | <a href="', $scripturl, '?action=profile;area=showdrafts;u=', $context['id_member'], '" class="infolinks">', $txt['drafts_show'], '</a>'; |
| 278 | + } |
|
| 268 | 279 | |
| 269 | 280 | echo ' |
| 270 | 281 | <a href="', $scripturl, '?action=profile;area=statistics;u=', $context['id_member'], '" class="infolinks">', $txt['statPanel'], '</a>'; |
@@ -276,10 +287,11 @@ discard block |
||
| 276 | 287 | <div class="custom_fields_bottom"> |
| 277 | 288 | <ul class="nolist">'; |
| 278 | 289 | |
| 279 | - foreach ($context['print_custom_fields']['bottom_poster'] as $field) |
|
| 280 | - if (!empty($field['output_html'])) |
|
| 290 | + foreach ($context['print_custom_fields']['bottom_poster'] as $field) { |
|
| 291 | + if (!empty($field['output_html'])) |
|
| 281 | 292 | echo ' |
| 282 | 293 | <li>', $field['output_html'], '</li>'; |
| 294 | + } |
|
| 283 | 295 | |
| 284 | 296 | echo ' |
| 285 | 297 | </ul> |
@@ -292,15 +304,17 @@ discard block |
||
| 292 | 304 | <div id="detailedinfo"> |
| 293 | 305 | <dl class="settings">'; |
| 294 | 306 | |
| 295 | - if ($context['user']['is_owner'] || $context['user']['is_admin']) |
|
| 296 | - echo ' |
|
| 307 | + if ($context['user']['is_owner'] || $context['user']['is_admin']) { |
|
| 308 | + echo ' |
|
| 297 | 309 | <dt>', $txt['username'], ': </dt> |
| 298 | 310 | <dd>', $context['member']['username'], '</dd>'; |
| 311 | + } |
|
| 299 | 312 | |
| 300 | - if (!isset($context['disabled_fields']['posts'])) |
|
| 301 | - echo ' |
|
| 313 | + if (!isset($context['disabled_fields']['posts'])) { |
|
| 314 | + echo ' |
|
| 302 | 315 | <dt>', $txt['profile_posts'], ': </dt> |
| 303 | 316 | <dd>', $context['member']['posts'], ' (', $context['member']['posts_per_day'], ' ', $txt['posts_per_day'], ')</dd>'; |
| 317 | + } |
|
| 304 | 318 | |
| 305 | 319 | if ($context['member']['show_email']) |
| 306 | 320 | { |
@@ -309,15 +323,17 @@ discard block |
||
| 309 | 323 | <dd><a href="mailto:', $context['member']['email'], '">', $context['member']['email'], '</a></dd>'; |
| 310 | 324 | } |
| 311 | 325 | |
| 312 | - if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) |
|
| 313 | - echo ' |
|
| 326 | + if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) { |
|
| 327 | + echo ' |
|
| 314 | 328 | <dt>', $txt['custom_title'], ': </dt> |
| 315 | 329 | <dd>', $context['member']['title'], '</dd>'; |
| 330 | + } |
|
| 316 | 331 | |
| 317 | - if (!empty($context['member']['blurb'])) |
|
| 318 | - echo ' |
|
| 332 | + if (!empty($context['member']['blurb'])) { |
|
| 333 | + echo ' |
|
| 319 | 334 | <dt>', $txt['personal_text'], ': </dt> |
| 320 | 335 | <dd>', $context['member']['blurb'], '</dd>'; |
| 336 | + } |
|
| 321 | 337 | |
| 322 | 338 | echo ' |
| 323 | 339 | <dt>', $txt['age'], ':</dt> |
@@ -331,19 +347,21 @@ discard block |
||
| 331 | 347 | { |
| 332 | 348 | $fields = array(); |
| 333 | 349 | |
| 334 | - foreach ($context['print_custom_fields']['standard'] as $field) |
|
| 335 | - if (!empty($field['output_html'])) |
|
| 350 | + foreach ($context['print_custom_fields']['standard'] as $field) { |
|
| 351 | + if (!empty($field['output_html'])) |
|
| 336 | 352 | $fields[] = $field; |
| 353 | + } |
|
| 337 | 354 | |
| 338 | 355 | if (count($fields) > 0) |
| 339 | 356 | { |
| 340 | 357 | echo ' |
| 341 | 358 | <dl class="settings">'; |
| 342 | 359 | |
| 343 | - foreach ($fields as $field) |
|
| 344 | - echo ' |
|
| 360 | + foreach ($fields as $field) { |
|
| 361 | + echo ' |
|
| 345 | 362 | <dt>', $field['name'], ':</dt> |
| 346 | 363 | <dd>', $field['output_html'], '</dd>'; |
| 364 | + } |
|
| 347 | 365 | |
| 348 | 366 | echo ' |
| 349 | 367 | </dl>'; |
@@ -363,9 +381,10 @@ discard block |
||
| 363 | 381 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=', ($context['can_issue_warning'] && !$context['user']['is_owner'] ? 'issuewarning' : 'viewwarning'), '">', $context['member']['warning'], '%</a>'; |
| 364 | 382 | |
| 365 | 383 | // Can we provide information on what this means? |
| 366 | - if (!empty($context['warning_status'])) |
|
| 367 | - echo ' |
|
| 384 | + if (!empty($context['warning_status'])) { |
|
| 385 | + echo ' |
|
| 368 | 386 | <span class="smalltext">(', $context['warning_status'], ')</span>'; |
| 387 | + } |
|
| 369 | 388 | |
| 370 | 389 | echo ' |
| 371 | 390 | </dd>'; |
@@ -376,9 +395,10 @@ discard block |
||
| 376 | 395 | { |
| 377 | 396 | |
| 378 | 397 | // If the person looking at the summary has permission, and the account isn't activated, give the viewer the ability to do it themselves. |
| 379 | - if (!empty($context['activate_message'])) |
|
| 380 | - echo ' |
|
| 398 | + if (!empty($context['activate_message'])) { |
|
| 399 | + echo ' |
|
| 381 | 400 | <dt class="clear"><span class="alert">', $context['activate_message'], '</span> (<a href="', $context['activate_link'], '"', ($context['activate_type'] == 4 ? ' class="you_sure" data-confirm="' . $txt['profileConfirm'] . '"' : ''), '>', $context['activate_link_text'], '</a>)</dt>'; |
| 401 | + } |
|
| 382 | 402 | |
| 383 | 403 | // If the current member is banned, show a message and possibly a link to the ban. |
| 384 | 404 | if (!empty($context['member']['bans'])) |
@@ -390,10 +410,11 @@ discard block |
||
| 390 | 410 | <dt class="clear" id="ban_info" style="display: none;"> |
| 391 | 411 | <strong>', $txt['user_banned_by_following'], ':</strong>'; |
| 392 | 412 | |
| 393 | - foreach ($context['member']['bans'] as $ban) |
|
| 394 | - echo ' |
|
| 413 | + foreach ($context['member']['bans'] as $ban) { |
|
| 414 | + echo ' |
|
| 395 | 415 | <br> |
| 396 | 416 | <span class="smalltext">', $ban['explanation'], '</span>'; |
| 417 | + } |
|
| 397 | 418 | |
| 398 | 419 | echo ' |
| 399 | 420 | </dt>'; |
@@ -407,30 +428,34 @@ discard block |
||
| 407 | 428 | // If the person looking is allowed, they can check the members IP address and hostname. |
| 408 | 429 | if ($context['can_see_ip']) |
| 409 | 430 | { |
| 410 | - if (!empty($context['member']['ip'])) |
|
| 411 | - echo ' |
|
| 431 | + if (!empty($context['member']['ip'])) { |
|
| 432 | + echo ' |
|
| 412 | 433 | <dt>', $txt['ip'], ': </dt> |
| 413 | 434 | <dd><a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['member']['ip'], ';u=', $context['member']['id'], '">', $context['member']['ip'], '</a></dd>'; |
| 435 | + } |
|
| 414 | 436 | |
| 415 | - if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) |
|
| 416 | - echo ' |
|
| 437 | + if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) { |
|
| 438 | + echo ' |
|
| 417 | 439 | <dt>', $txt['hostname'], ': </dt> |
| 418 | 440 | <dd>', $context['member']['hostname'], '</dd>'; |
| 441 | + } |
|
| 419 | 442 | } |
| 420 | 443 | |
| 421 | 444 | echo ' |
| 422 | 445 | <dt>', $txt['local_time'], ':</dt> |
| 423 | 446 | <dd>', $context['member']['local_time'], '</dd>'; |
| 424 | 447 | |
| 425 | - if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) |
|
| 426 | - echo ' |
|
| 448 | + if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) { |
|
| 449 | + echo ' |
|
| 427 | 450 | <dt>', $txt['language'], ':</dt> |
| 428 | 451 | <dd>', $context['member']['language'], '</dd>'; |
| 452 | + } |
|
| 429 | 453 | |
| 430 | - if ($context['member']['show_last_login']) |
|
| 431 | - echo ' |
|
| 454 | + if ($context['member']['show_last_login']) { |
|
| 455 | + echo ' |
|
| 432 | 456 | <dt>', $txt['lastLoggedIn'], ': </dt> |
| 433 | 457 | <dd>', $context['member']['last_login'], (!empty($context['member']['is_hidden']) ? ' (' . $txt['hidden'] . ')' : ''), '</dd>'; |
| 458 | + } |
|
| 434 | 459 | |
| 435 | 460 | echo ' |
| 436 | 461 | </dl>'; |
@@ -442,10 +467,11 @@ discard block |
||
| 442 | 467 | <div class="custom_fields_above_signature"> |
| 443 | 468 | <ul class="nolist">'; |
| 444 | 469 | |
| 445 | - foreach ($context['print_custom_fields']['above_signature'] as $field) |
|
| 446 | - if (!empty($field['output_html'])) |
|
| 470 | + foreach ($context['print_custom_fields']['above_signature'] as $field) { |
|
| 471 | + if (!empty($field['output_html'])) |
|
| 447 | 472 | echo ' |
| 448 | 473 | <li>', $field['output_html'], '</li>'; |
| 474 | + } |
|
| 449 | 475 | |
| 450 | 476 | echo ' |
| 451 | 477 | </ul> |
@@ -453,12 +479,13 @@ discard block |
||
| 453 | 479 | } |
| 454 | 480 | |
| 455 | 481 | // Show the users signature. |
| 456 | - if ($context['signature_enabled'] && !empty($context['member']['signature'])) |
|
| 457 | - echo ' |
|
| 482 | + if ($context['signature_enabled'] && !empty($context['member']['signature'])) { |
|
| 483 | + echo ' |
|
| 458 | 484 | <div class="signature"> |
| 459 | 485 | <h5>', $txt['signature'], ':</h5> |
| 460 | 486 | ', $context['member']['signature'], ' |
| 461 | 487 | </div>'; |
| 488 | + } |
|
| 462 | 489 | |
| 463 | 490 | // Are there any custom profile fields for below the signature? |
| 464 | 491 | if (!empty($context['print_custom_fields']['below_signature'])) |
@@ -467,10 +494,11 @@ discard block |
||
| 467 | 494 | <div class="custom_fields_below_signature"> |
| 468 | 495 | <ul class="nolist">'; |
| 469 | 496 | |
| 470 | - foreach ($context['print_custom_fields']['below_signature'] as $field) |
|
| 471 | - if (!empty($field['output_html'])) |
|
| 497 | + foreach ($context['print_custom_fields']['below_signature'] as $field) { |
|
| 498 | + if (!empty($field['output_html'])) |
|
| 472 | 499 | echo ' |
| 473 | 500 | <li>', $field['output_html'], '</li>'; |
| 501 | + } |
|
| 474 | 502 | |
| 475 | 503 | echo ' |
| 476 | 504 | </ul> |
@@ -516,62 +544,70 @@ discard block |
||
| 516 | 544 | </div> |
| 517 | 545 | <div class="list_posts">'; |
| 518 | 546 | |
| 519 | - if (!$post['approved']) |
|
| 520 | - echo ' |
|
| 547 | + if (!$post['approved']) { |
|
| 548 | + echo ' |
|
| 521 | 549 | <div class="approve_post"> |
| 522 | 550 | <em>', $txt['post_awaiting_approval'], '</em> |
| 523 | 551 | </div>'; |
| 552 | + } |
|
| 524 | 553 | |
| 525 | 554 | echo ' |
| 526 | 555 | ', $post['body'], ' |
| 527 | 556 | </div>'; |
| 528 | 557 | |
| 529 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
| 530 | - echo ' |
|
| 558 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
| 559 | + echo ' |
|
| 531 | 560 | <div class="floatright"> |
| 532 | 561 | <ul class="quickbuttons">'; |
| 562 | + } |
|
| 533 | 563 | |
| 534 | 564 | // If they *can* reply? |
| 535 | - if ($post['can_reply']) |
|
| 536 | - echo ' |
|
| 565 | + if ($post['can_reply']) { |
|
| 566 | + echo ' |
|
| 537 | 567 | <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>'; |
| 568 | + } |
|
| 538 | 569 | |
| 539 | 570 | // If they *can* quote? |
| 540 | - if ($post['can_quote']) |
|
| 541 | - echo ' |
|
| 571 | + if ($post['can_quote']) { |
|
| 572 | + echo ' |
|
| 542 | 573 | <li><a href="', $scripturl . '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
| 574 | + } |
|
| 543 | 575 | |
| 544 | 576 | // How about... even... remove it entirely?! |
| 545 | - if ($post['can_delete']) |
|
| 546 | - echo ' |
|
| 577 | + if ($post['can_delete']) { |
|
| 578 | + echo ' |
|
| 547 | 579 | <li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';profile;u=', $context['member']['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
| 580 | + } |
|
| 548 | 581 | |
| 549 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
| 550 | - echo ' |
|
| 582 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
| 583 | + echo ' |
|
| 551 | 584 | </ul> |
| 552 | 585 | </div><!-- .floatright -->'; |
| 586 | + } |
|
| 553 | 587 | |
| 554 | 588 | echo ' |
| 555 | 589 | </div><!-- $post[css_class] -->'; |
| 556 | 590 | } |
| 591 | + } else { |
|
| 592 | + template_show_list('attachments'); |
|
| 557 | 593 | } |
| 558 | - else |
|
| 559 | - template_show_list('attachments'); |
|
| 560 | 594 | |
| 561 | 595 | // No posts? Just end with a informative message. |
| 562 | - if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) |
|
| 563 | - echo ' |
|
| 596 | + if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) { |
|
| 597 | + echo ' |
|
| 564 | 598 | <div class="windowbg2"> |
| 565 | 599 | ', isset($context['attachments']) ? $txt['show_attachments_none'] : ($context['is_topics'] ? $txt['show_topics_none'] : $txt['show_posts_none']), ' |
| 566 | 600 | </div>'; |
| 601 | + } |
|
| 567 | 602 | |
| 568 | 603 | // Show more page numbers. |
| 569 | - if (!empty($context['page_index'])) |
|
| 570 | - echo ' |
|
| 604 | + if (!empty($context['page_index'])) { |
|
| 605 | + echo ' |
|
| 571 | 606 | <div class="pagesection"> |
| 572 | 607 | <div class="pagelinks">', $context['page_index'], '</div> |
| 573 | 608 | </div>'; |
| 574 | -} |
|
| 609 | + } |
|
| 610 | + } |
|
| 575 | 611 | |
| 576 | 612 | /** |
| 577 | 613 | * Template for showing alerts within the alerts popup |
@@ -581,11 +617,12 @@ discard block |
||
| 581 | 617 | global $context, $txt, $scripturl; |
| 582 | 618 | |
| 583 | 619 | // Do we have an update message? |
| 584 | - if (!empty($context['update_message'])) |
|
| 585 | - echo ' |
|
| 620 | + if (!empty($context['update_message'])) { |
|
| 621 | + echo ' |
|
| 586 | 622 | <div class="infobox"> |
| 587 | 623 | ', $context['update_message'], '. |
| 588 | 624 | </div>'; |
| 625 | + } |
|
| 589 | 626 | |
| 590 | 627 | echo ' |
| 591 | 628 | <div class="cat_bar"> |
@@ -594,13 +631,12 @@ discard block |
||
| 594 | 631 | </h3> |
| 595 | 632 | </div>'; |
| 596 | 633 | |
| 597 | - if (empty($context['alerts'])) |
|
| 598 | - echo ' |
|
| 634 | + if (empty($context['alerts'])) { |
|
| 635 | + echo ' |
|
| 599 | 636 | <div class="information"> |
| 600 | 637 | ', $txt['alerts_none'], ' |
| 601 | 638 | </div>'; |
| 602 | - |
|
| 603 | - else |
|
| 639 | + } else |
|
| 604 | 640 | { |
| 605 | 641 | // Start the form. |
| 606 | 642 | echo ' |
@@ -662,12 +698,12 @@ discard block |
||
| 662 | 698 | </div>' : ''; |
| 663 | 699 | |
| 664 | 700 | // No drafts? Just show an informative message. |
| 665 | - if (empty($context['drafts'])) |
|
| 666 | - echo ' |
|
| 701 | + if (empty($context['drafts'])) { |
|
| 702 | + echo ' |
|
| 667 | 703 | <div class="windowbg2 centertext"> |
| 668 | 704 | ', $txt['draft_none'], ' |
| 669 | 705 | </div>'; |
| 670 | - else |
|
| 706 | + } else |
|
| 671 | 707 | { |
| 672 | 708 | // For every draft to be displayed, give it its own div, and show the important details of the draft. |
| 673 | 709 | foreach ($context['drafts'] as $draft) |
@@ -679,13 +715,15 @@ discard block |
||
| 679 | 715 | <h5> |
| 680 | 716 | <strong><a href="', $scripturl, '?board=', $draft['board']['id'], '.0">', $draft['board']['name'], '</a> / ', $draft['topic']['link'], '</strong> '; |
| 681 | 717 | |
| 682 | - if (!empty($draft['sticky'])) |
|
| 683 | - echo ' |
|
| 718 | + if (!empty($draft['sticky'])) { |
|
| 719 | + echo ' |
|
| 684 | 720 | <span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>'; |
| 721 | + } |
|
| 685 | 722 | |
| 686 | - if (!empty($draft['locked'])) |
|
| 687 | - echo ' |
|
| 723 | + if (!empty($draft['locked'])) { |
|
| 724 | + echo ' |
|
| 688 | 725 | <span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>'; |
| 726 | + } |
|
| 689 | 727 | |
| 690 | 728 | echo ' |
| 691 | 729 | </h5> |
@@ -718,13 +756,13 @@ discard block |
||
| 718 | 756 | { |
| 719 | 757 | global $context, $scripturl, $txt; |
| 720 | 758 | |
| 721 | - if (!empty($context['saved_successful'])) |
|
| 722 | - echo ' |
|
| 759 | + if (!empty($context['saved_successful'])) { |
|
| 760 | + echo ' |
|
| 723 | 761 | <div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>'; |
| 724 | - |
|
| 725 | - elseif (!empty($context['saved_failed'])) |
|
| 726 | - echo ' |
|
| 762 | + } elseif (!empty($context['saved_failed'])) { |
|
| 763 | + echo ' |
|
| 727 | 764 | <div class="errorbox">', $context['saved_failed'], '</div>'; |
| 765 | + } |
|
| 728 | 766 | |
| 729 | 767 | echo ' |
| 730 | 768 | <div id="edit_buddies"> |
@@ -739,14 +777,16 @@ discard block |
||
| 739 | 777 | <th scope="col" class="quarter_table">', $txt['name'], '</th> |
| 740 | 778 | <th scope="col">', $txt['status'], '</th>'; |
| 741 | 779 | |
| 742 | - if (allowedTo('moderate_forum')) |
|
| 743 | - echo ' |
|
| 780 | + if (allowedTo('moderate_forum')) { |
|
| 781 | + echo ' |
|
| 744 | 782 | <th scope="col">', $txt['email'], '</th>'; |
| 783 | + } |
|
| 745 | 784 | |
| 746 | - if (!empty($context['custom_pf'])) |
|
| 747 | - foreach ($context['custom_pf'] as $column) |
|
| 785 | + if (!empty($context['custom_pf'])) { |
|
| 786 | + foreach ($context['custom_pf'] as $column) |
|
| 748 | 787 | echo ' |
| 749 | 788 | <th scope="col">', $column['label'], '</th>'; |
| 789 | + } |
|
| 750 | 790 | |
| 751 | 791 | echo ' |
| 752 | 792 | <th scope="col">', $txt['remove'], '</th> |
@@ -755,13 +795,14 @@ discard block |
||
| 755 | 795 | <tbody>'; |
| 756 | 796 | |
| 757 | 797 | // If they don't have any buddies don't list them! |
| 758 | - if (empty($context['buddies'])) |
|
| 759 | - echo ' |
|
| 798 | + if (empty($context['buddies'])) { |
|
| 799 | + echo ' |
|
| 760 | 800 | <tr class="windowbg"> |
| 761 | 801 | <td colspan="', allowedTo('moderate_forum') ? '10' : '9', '"> |
| 762 | 802 | <strong>', $txt['no_buddies'], '</strong> |
| 763 | 803 | </td> |
| 764 | 804 | </tr>'; |
| 805 | + } |
|
| 765 | 806 | |
| 766 | 807 | // Now loop through each buddy showing info on each. |
| 767 | 808 | else |
@@ -775,17 +816,19 @@ discard block |
||
| 775 | 816 | <a href="', $buddy['online']['href'], '"><span class="' . ($buddy['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $buddy['online']['text'] . '"></span></a> |
| 776 | 817 | </td>'; |
| 777 | 818 | |
| 778 | - if ($buddy['show_email']) |
|
| 779 | - echo ' |
|
| 819 | + if ($buddy['show_email']) { |
|
| 820 | + echo ' |
|
| 780 | 821 | <td> |
| 781 | 822 | <a href="mailto:' . $buddy['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $buddy['name'] . '"></span></a> |
| 782 | 823 | </td>'; |
| 824 | + } |
|
| 783 | 825 | |
| 784 | 826 | // Show the custom profile fields for this user. |
| 785 | - if (!empty($context['custom_pf'])) |
|
| 786 | - foreach ($context['custom_pf'] as $key => $column) |
|
| 827 | + if (!empty($context['custom_pf'])) { |
|
| 828 | + foreach ($context['custom_pf'] as $key => $column) |
|
| 787 | 829 | echo ' |
| 788 | 830 | <td class="lefttext">', $buddy['options'][$key], '</td>'; |
| 831 | + } |
|
| 789 | 832 | |
| 790 | 833 | echo ' |
| 791 | 834 | <td> |
@@ -818,9 +861,10 @@ discard block |
||
| 818 | 861 | </dl> |
| 819 | 862 | </div>'; |
| 820 | 863 | |
| 821 | - if (!empty($context['token_check'])) |
|
| 822 | - echo ' |
|
| 864 | + if (!empty($context['token_check'])) { |
|
| 865 | + echo ' |
|
| 823 | 866 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 867 | + } |
|
| 824 | 868 | |
| 825 | 869 | echo ' |
| 826 | 870 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -846,12 +890,13 @@ discard block |
||
| 846 | 890 | { |
| 847 | 891 | global $context, $scripturl, $txt; |
| 848 | 892 | |
| 849 | - if (!empty($context['saved_successful'])) |
|
| 850 | - echo ' |
|
| 893 | + if (!empty($context['saved_successful'])) { |
|
| 894 | + echo ' |
|
| 851 | 895 | <div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>'; |
| 852 | - elseif (!empty($context['saved_failed'])) |
|
| 853 | - echo ' |
|
| 896 | + } elseif (!empty($context['saved_failed'])) { |
|
| 897 | + echo ' |
|
| 854 | 898 | <div class="errorbox">', $context['saved_failed'], '</div>'; |
| 899 | + } |
|
| 855 | 900 | |
| 856 | 901 | echo ' |
| 857 | 902 | <div id="edit_buddies"> |
@@ -866,9 +911,10 @@ discard block |
||
| 866 | 911 | <th scope="col" class="quarter_table">', $txt['name'], '</th> |
| 867 | 912 | <th scope="col">', $txt['status'], '</th>'; |
| 868 | 913 | |
| 869 | - if (allowedTo('moderate_forum')) |
|
| 870 | - echo ' |
|
| 914 | + if (allowedTo('moderate_forum')) { |
|
| 915 | + echo ' |
|
| 871 | 916 | <th scope="col">', $txt['email'], '</th>'; |
| 917 | + } |
|
| 872 | 918 | |
| 873 | 919 | echo ' |
| 874 | 920 | <th scope="col">', $txt['ignore_remove'], '</th> |
@@ -877,13 +923,14 @@ discard block |
||
| 877 | 923 | <tbody>'; |
| 878 | 924 | |
| 879 | 925 | // If they don't have anyone on their ignore list, don't list it! |
| 880 | - if (empty($context['ignore_list'])) |
|
| 881 | - echo ' |
|
| 926 | + if (empty($context['ignore_list'])) { |
|
| 927 | + echo ' |
|
| 882 | 928 | <tr class="windowbg"> |
| 883 | 929 | <td colspan="', allowedTo('moderate_forum') ? '4' : '3', '"> |
| 884 | 930 | <strong>', $txt['no_ignore'], '</strong> |
| 885 | 931 | </td> |
| 886 | 932 | </tr>'; |
| 933 | + } |
|
| 887 | 934 | |
| 888 | 935 | // Now loop through each buddy showing info on each. |
| 889 | 936 | foreach ($context['ignore_list'] as $member) |
@@ -895,11 +942,12 @@ discard block |
||
| 895 | 942 | <a href="', $member['online']['href'], '"><span class="' . ($member['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $member['online']['text'] . '"></span></a> |
| 896 | 943 | </td>'; |
| 897 | 944 | |
| 898 | - if ($member['show_email']) |
|
| 899 | - echo ' |
|
| 945 | + if ($member['show_email']) { |
|
| 946 | + echo ' |
|
| 900 | 947 | <td> |
| 901 | 948 | <a href="mailto:' . $member['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $member['name'] . '"></span></a> |
| 902 | 949 | </td>'; |
| 950 | + } |
|
| 903 | 951 | echo ' |
| 904 | 952 | <td> |
| 905 | 953 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=ignore;remove=', $member['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['ignore_remove'], '"></span></a> |
@@ -929,9 +977,10 @@ discard block |
||
| 929 | 977 | </dl> |
| 930 | 978 | </div>'; |
| 931 | 979 | |
| 932 | - if (!empty($context['token_check'])) |
|
| 933 | - echo ' |
|
| 980 | + if (!empty($context['token_check'])) { |
|
| 981 | + echo ' |
|
| 934 | 982 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 983 | + } |
|
| 935 | 984 | |
| 936 | 985 | echo ' |
| 937 | 986 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -977,9 +1026,10 @@ discard block |
||
| 977 | 1026 | <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip'], ';u=', $context['member']['id'], '">', $context['last_ip'], '</a>'; |
| 978 | 1027 | |
| 979 | 1028 | // Second address detected? |
| 980 | - if (!empty($context['last_ip2'])) |
|
| 981 | - echo ' |
|
| 1029 | + if (!empty($context['last_ip2'])) { |
|
| 1030 | + echo ' |
|
| 982 | 1031 | , <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip2'], ';u=', $context['member']['id'], '">', $context['last_ip2'], '</a>'; |
| 1032 | + } |
|
| 983 | 1033 | |
| 984 | 1034 | echo ' |
| 985 | 1035 | </dd>'; |
@@ -1045,9 +1095,10 @@ discard block |
||
| 1045 | 1095 | </div> |
| 1046 | 1096 | <div class="windowbg2 noup">'; |
| 1047 | 1097 | |
| 1048 | - foreach ($context['whois_servers'] as $server) |
|
| 1049 | - echo ' |
|
| 1098 | + foreach ($context['whois_servers'] as $server) { |
|
| 1099 | + echo ' |
|
| 1050 | 1100 | <a href="', $server['url'], '" target="_blank"', isset($context['auto_whois_server']) && $context['auto_whois_server']['name'] == $server['name'] ? ' style="font-weight: bold;"' : '', '>', $server['name'], '</a><br>'; |
| 1101 | + } |
|
| 1051 | 1102 | echo ' |
| 1052 | 1103 | </div> |
| 1053 | 1104 | <br>'; |
@@ -1058,10 +1109,10 @@ discard block |
||
| 1058 | 1109 | <div class="cat_bar"> |
| 1059 | 1110 | <h3 class="catbg">', $txt['members_from_ip'], ' ', $context['ip'], '</h3> |
| 1060 | 1111 | </div>'; |
| 1061 | - if (empty($context['ips'])) |
|
| 1062 | - echo ' |
|
| 1112 | + if (empty($context['ips'])) { |
|
| 1113 | + echo ' |
|
| 1063 | 1114 | <p class="windowbg2 description"><em>', $txt['no_members_from_ip'], '</em></p>'; |
| 1064 | - else |
|
| 1115 | + } else |
|
| 1065 | 1116 | { |
| 1066 | 1117 | echo ' |
| 1067 | 1118 | <table class="table_grid"> |
@@ -1074,12 +1125,13 @@ discard block |
||
| 1074 | 1125 | <tbody>'; |
| 1075 | 1126 | |
| 1076 | 1127 | // Loop through each of the members and display them. |
| 1077 | - foreach ($context['ips'] as $ip => $memberlist) |
|
| 1078 | - echo ' |
|
| 1128 | + foreach ($context['ips'] as $ip => $memberlist) { |
|
| 1129 | + echo ' |
|
| 1079 | 1130 | <tr class="windowbg"> |
| 1080 | 1131 | <td><a href="', $context['base_url'], ';searchip=', $ip, '">', $ip, '</a></td> |
| 1081 | 1132 | <td>', implode(', ', $memberlist), '</td> |
| 1082 | 1133 | </tr>'; |
| 1134 | + } |
|
| 1083 | 1135 | |
| 1084 | 1136 | echo ' |
| 1085 | 1137 | </tbody> |
@@ -1125,8 +1177,7 @@ discard block |
||
| 1125 | 1177 | { |
| 1126 | 1178 | echo ' |
| 1127 | 1179 | <div class="information">', $txt['showPermissions_all'], '</div>'; |
| 1128 | - } |
|
| 1129 | - else |
|
| 1180 | + } else |
|
| 1130 | 1181 | { |
| 1131 | 1182 | echo ' |
| 1132 | 1183 | <div class="information">',$txt['showPermissions_help'], '</div> |
@@ -1141,9 +1192,10 @@ discard block |
||
| 1141 | 1192 | <div class="windowbg smalltext"> |
| 1142 | 1193 | ', $txt['showPermissions_restricted_boards_desc'], ':<br>'; |
| 1143 | 1194 | |
| 1144 | - foreach ($context['no_access_boards'] as $no_access_board) |
|
| 1145 | - echo ' |
|
| 1195 | + foreach ($context['no_access_boards'] as $no_access_board) { |
|
| 1196 | + echo ' |
|
| 1146 | 1197 | <a href="', $scripturl, '?board=', $no_access_board['id'], '.0">', $no_access_board['name'], '</a>', $no_access_board['is_last'] ? '' : ', '; |
| 1198 | + } |
|
| 1147 | 1199 | echo ' |
| 1148 | 1200 | </div>'; |
| 1149 | 1201 | } |
@@ -1175,12 +1227,13 @@ discard block |
||
| 1175 | 1227 | </td> |
| 1176 | 1228 | <td class="smalltext">'; |
| 1177 | 1229 | |
| 1178 | - if ($permission['is_denied']) |
|
| 1179 | - echo ' |
|
| 1230 | + if ($permission['is_denied']) { |
|
| 1231 | + echo ' |
|
| 1180 | 1232 | <span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>'; |
| 1181 | - else |
|
| 1182 | - echo ' |
|
| 1233 | + } else { |
|
| 1234 | + echo ' |
|
| 1183 | 1235 | ', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']); |
| 1236 | + } |
|
| 1184 | 1237 | |
| 1185 | 1238 | echo ' |
| 1186 | 1239 | </td> |
@@ -1191,10 +1244,10 @@ discard block |
||
| 1191 | 1244 | </table> |
| 1192 | 1245 | </div><!-- .tborder --> |
| 1193 | 1246 | <br>'; |
| 1194 | - } |
|
| 1195 | - else |
|
| 1196 | - echo ' |
|
| 1247 | + } else { |
|
| 1248 | + echo ' |
|
| 1197 | 1249 | <p class="windowbg2">', $txt['showPermissions_none_general'], '</p>'; |
| 1250 | + } |
|
| 1198 | 1251 | |
| 1199 | 1252 | // Board permission section. |
| 1200 | 1253 | echo ' |
@@ -1204,14 +1257,16 @@ discard block |
||
| 1204 | 1257 | <a id="board_permissions"></a>', $txt['showPermissions_select'], ': |
| 1205 | 1258 | <select name="board" onchange="if (this.options[this.selectedIndex].value) this.form.submit();"> |
| 1206 | 1259 | <option value="0"', $context['board'] == 0 ? ' selected' : '', '>', $txt['showPermissions_global'], ' </option>'; |
| 1207 | - if (!empty($context['boards'])) |
|
| 1208 | - echo ' |
|
| 1260 | + if (!empty($context['boards'])) { |
|
| 1261 | + echo ' |
|
| 1209 | 1262 | <option value="" disabled>---------------------------</option>'; |
| 1263 | + } |
|
| 1210 | 1264 | |
| 1211 | 1265 | // Fill the box with any local permission boards. |
| 1212 | - foreach ($context['boards'] as $board) |
|
| 1213 | - echo ' |
|
| 1266 | + foreach ($context['boards'] as $board) { |
|
| 1267 | + echo ' |
|
| 1214 | 1268 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['name'], ' (', $board['profile_name'], ')</option>'; |
| 1269 | + } |
|
| 1215 | 1270 | |
| 1216 | 1271 | echo ' |
| 1217 | 1272 | </select> |
@@ -1242,8 +1297,7 @@ discard block |
||
| 1242 | 1297 | { |
| 1243 | 1298 | echo ' |
| 1244 | 1299 | <span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>'; |
| 1245 | - } |
|
| 1246 | - else |
|
| 1300 | + } else |
|
| 1247 | 1301 | { |
| 1248 | 1302 | echo ' |
| 1249 | 1303 | ', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']); |
@@ -1255,10 +1309,10 @@ discard block |
||
| 1255 | 1309 | echo ' |
| 1256 | 1310 | </tbody> |
| 1257 | 1311 | </table>'; |
| 1258 | - } |
|
| 1259 | - else |
|
| 1260 | - echo ' |
|
| 1312 | + } else { |
|
| 1313 | + echo ' |
|
| 1261 | 1314 | <p class="windowbg2">', $txt['showPermissions_none_board'], '</p>'; |
| 1315 | + } |
|
| 1262 | 1316 | echo ' |
| 1263 | 1317 | </div><!-- #permissions -->'; |
| 1264 | 1318 | } |
@@ -1299,9 +1353,10 @@ discard block |
||
| 1299 | 1353 | </div>'; |
| 1300 | 1354 | |
| 1301 | 1355 | // If they haven't post at all, don't draw the graph. |
| 1302 | - if (empty($context['posts_by_time'])) |
|
| 1303 | - echo ' |
|
| 1356 | + if (empty($context['posts_by_time'])) { |
|
| 1357 | + echo ' |
|
| 1304 | 1358 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
| 1359 | + } |
|
| 1305 | 1360 | // Otherwise do! |
| 1306 | 1361 | else |
| 1307 | 1362 | { |
@@ -1339,11 +1394,10 @@ discard block |
||
| 1339 | 1394 | </h3> |
| 1340 | 1395 | </div>'; |
| 1341 | 1396 | |
| 1342 | - if (empty($context['popular_boards'])) |
|
| 1343 | - echo ' |
|
| 1397 | + if (empty($context['popular_boards'])) { |
|
| 1398 | + echo ' |
|
| 1344 | 1399 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
| 1345 | - |
|
| 1346 | - else |
|
| 1400 | + } else |
|
| 1347 | 1401 | { |
| 1348 | 1402 | echo ' |
| 1349 | 1403 | <dl class="stats">'; |
@@ -1373,10 +1427,10 @@ discard block |
||
| 1373 | 1427 | </h3> |
| 1374 | 1428 | </div>'; |
| 1375 | 1429 | |
| 1376 | - if (empty($context['board_activity'])) |
|
| 1377 | - echo ' |
|
| 1430 | + if (empty($context['board_activity'])) { |
|
| 1431 | + echo ' |
|
| 1378 | 1432 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
| 1379 | - else |
|
| 1433 | + } else |
|
| 1380 | 1434 | { |
| 1381 | 1435 | echo ' |
| 1382 | 1436 | <dl class="stats">'; |
@@ -1427,41 +1481,46 @@ discard block |
||
| 1427 | 1481 | <h3 class="catbg profile_hd">'; |
| 1428 | 1482 | |
| 1429 | 1483 | // Don't say "Profile" if this isn't the profile... |
| 1430 | - if (!empty($context['profile_header_text'])) |
|
| 1431 | - echo ' |
|
| 1484 | + if (!empty($context['profile_header_text'])) { |
|
| 1485 | + echo ' |
|
| 1432 | 1486 | ', $context['profile_header_text']; |
| 1433 | - else |
|
| 1434 | - echo ' |
|
| 1487 | + } else { |
|
| 1488 | + echo ' |
|
| 1435 | 1489 | ', $txt['profile']; |
| 1490 | + } |
|
| 1436 | 1491 | |
| 1437 | 1492 | echo ' |
| 1438 | 1493 | </h3> |
| 1439 | 1494 | </div>'; |
| 1440 | 1495 | |
| 1441 | 1496 | // Have we some description? |
| 1442 | - if ($context['page_desc']) |
|
| 1443 | - echo ' |
|
| 1497 | + if ($context['page_desc']) { |
|
| 1498 | + echo ' |
|
| 1444 | 1499 | <p class="information">', $context['page_desc'], '</p>'; |
| 1500 | + } |
|
| 1445 | 1501 | |
| 1446 | 1502 | echo ' |
| 1447 | 1503 | <div class="roundframe">'; |
| 1448 | 1504 | |
| 1449 | 1505 | // Any bits at the start? |
| 1450 | - if (!empty($context['profile_prehtml'])) |
|
| 1451 | - echo ' |
|
| 1506 | + if (!empty($context['profile_prehtml'])) { |
|
| 1507 | + echo ' |
|
| 1452 | 1508 | <div>', $context['profile_prehtml'], '</div>'; |
| 1509 | + } |
|
| 1453 | 1510 | |
| 1454 | - if (!empty($context['profile_fields'])) |
|
| 1455 | - echo ' |
|
| 1511 | + if (!empty($context['profile_fields'])) { |
|
| 1512 | + echo ' |
|
| 1456 | 1513 | <dl class="settings">'; |
| 1514 | + } |
|
| 1457 | 1515 | |
| 1458 | 1516 | // Start the big old loop 'of love. |
| 1459 | 1517 | $lastItem = 'hr'; |
| 1460 | 1518 | foreach ($context['profile_fields'] as $key => $field) |
| 1461 | 1519 | { |
| 1462 | 1520 | // We add a little hack to be sure we never get more than one hr in a row! |
| 1463 | - if ($lastItem == 'hr' && $field['type'] == 'hr') |
|
| 1464 | - continue; |
|
| 1521 | + if ($lastItem == 'hr' && $field['type'] == 'hr') { |
|
| 1522 | + continue; |
|
| 1523 | + } |
|
| 1465 | 1524 | |
| 1466 | 1525 | $lastItem = $field['type']; |
| 1467 | 1526 | if ($field['type'] == 'hr') |
@@ -1470,48 +1529,50 @@ discard block |
||
| 1470 | 1529 | </dl> |
| 1471 | 1530 | <hr> |
| 1472 | 1531 | <dl class="settings">'; |
| 1473 | - } |
|
| 1474 | - elseif ($field['type'] == 'callback') |
|
| 1532 | + } elseif ($field['type'] == 'callback') |
|
| 1475 | 1533 | { |
| 1476 | 1534 | if (isset($field['callback_func']) && function_exists('template_profile_' . $field['callback_func'])) |
| 1477 | 1535 | { |
| 1478 | 1536 | $callback_func = 'template_profile_' . $field['callback_func']; |
| 1479 | 1537 | $callback_func(); |
| 1480 | 1538 | } |
| 1481 | - } |
|
| 1482 | - else |
|
| 1539 | + } else |
|
| 1483 | 1540 | { |
| 1484 | 1541 | echo ' |
| 1485 | 1542 | <dt> |
| 1486 | 1543 | <strong', !empty($field['is_error']) ? ' class="error"' : '', '>', $field['type'] !== 'label' ? '<label for="' . $key . '">' : '', $field['label'], $field['type'] !== 'label' ? '</label>' : '', '</strong>'; |
| 1487 | 1544 | |
| 1488 | 1545 | // Does it have any subtext to show? |
| 1489 | - if (!empty($field['subtext'])) |
|
| 1490 | - echo ' |
|
| 1546 | + if (!empty($field['subtext'])) { |
|
| 1547 | + echo ' |
|
| 1491 | 1548 | <br> |
| 1492 | 1549 | <span class="smalltext">', $field['subtext'], '</span>'; |
| 1550 | + } |
|
| 1493 | 1551 | |
| 1494 | 1552 | echo ' |
| 1495 | 1553 | </dt> |
| 1496 | 1554 | <dd>'; |
| 1497 | 1555 | |
| 1498 | 1556 | // Want to put something infront of the box? |
| 1499 | - if (!empty($field['preinput'])) |
|
| 1500 | - echo ' |
|
| 1557 | + if (!empty($field['preinput'])) { |
|
| 1558 | + echo ' |
|
| 1501 | 1559 | ', $field['preinput']; |
| 1560 | + } |
|
| 1502 | 1561 | |
| 1503 | 1562 | // What type of data are we showing? |
| 1504 | - if ($field['type'] == 'label') |
|
| 1505 | - echo ' |
|
| 1563 | + if ($field['type'] == 'label') { |
|
| 1564 | + echo ' |
|
| 1506 | 1565 | ', $field['value']; |
| 1566 | + } |
|
| 1507 | 1567 | |
| 1508 | 1568 | // Maybe it's a text box - very likely! |
| 1509 | 1569 | elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'number', 'time', 'url'))) |
| 1510 | 1570 | { |
| 1511 | - if ($field['type'] == 'int' || $field['type'] == 'float') |
|
| 1512 | - $type = 'number'; |
|
| 1513 | - else |
|
| 1514 | - $type = $field['type']; |
|
| 1571 | + if ($field['type'] == 'int' || $field['type'] == 'float') { |
|
| 1572 | + $type = 'number'; |
|
| 1573 | + } else { |
|
| 1574 | + $type = $field['type']; |
|
| 1575 | + } |
|
| 1515 | 1576 | $step = $field['type'] == 'float' ? ' step="0.1"' : ''; |
| 1516 | 1577 | |
| 1517 | 1578 | |
@@ -1519,10 +1580,11 @@ discard block |
||
| 1519 | 1580 | <input type="', $type, '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" ', $field['input_attr'], ' ', $step, '>'; |
| 1520 | 1581 | } |
| 1521 | 1582 | // You "checking" me out? ;) |
| 1522 | - elseif ($field['type'] == 'check') |
|
| 1523 | - echo ' |
|
| 1583 | + elseif ($field['type'] == 'check') { |
|
| 1584 | + echo ' |
|
| 1524 | 1585 | <input type="hidden" name="', $key, '" value="0"> |
| 1525 | 1586 | <input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" ', $field['input_attr'], '>'; |
| 1587 | + } |
|
| 1526 | 1588 | |
| 1527 | 1589 | // Always fun - select boxes! |
| 1528 | 1590 | elseif ($field['type'] == 'select') |
@@ -1533,14 +1595,16 @@ discard block |
||
| 1533 | 1595 | if (isset($field['options'])) |
| 1534 | 1596 | { |
| 1535 | 1597 | // Is this some code to generate the options? |
| 1536 | - if (!is_array($field['options'])) |
|
| 1537 | - $field['options'] = $field['options'](); |
|
| 1598 | + if (!is_array($field['options'])) { |
|
| 1599 | + $field['options'] = $field['options'](); |
|
| 1600 | + } |
|
| 1538 | 1601 | |
| 1539 | 1602 | // Assuming we now have some! |
| 1540 | - if (is_array($field['options'])) |
|
| 1541 | - foreach ($field['options'] as $value => $name) |
|
| 1603 | + if (is_array($field['options'])) { |
|
| 1604 | + foreach ($field['options'] as $value => $name) |
|
| 1542 | 1605 | echo ' |
| 1543 | 1606 | <option value="', $value, '"', $value == $field['value'] ? ' selected' : '', '>', $name, '</option>'; |
| 1607 | + } |
|
| 1544 | 1608 | } |
| 1545 | 1609 | |
| 1546 | 1610 | echo ' |
@@ -1548,25 +1612,28 @@ discard block |
||
| 1548 | 1612 | } |
| 1549 | 1613 | |
| 1550 | 1614 | // Something to end with? |
| 1551 | - if (!empty($field['postinput'])) |
|
| 1552 | - echo ' |
|
| 1615 | + if (!empty($field['postinput'])) { |
|
| 1616 | + echo ' |
|
| 1553 | 1617 | ', $field['postinput']; |
| 1618 | + } |
|
| 1554 | 1619 | |
| 1555 | 1620 | echo ' |
| 1556 | 1621 | </dd>'; |
| 1557 | 1622 | } |
| 1558 | 1623 | } |
| 1559 | 1624 | |
| 1560 | - if (!empty($context['profile_fields'])) |
|
| 1561 | - echo ' |
|
| 1625 | + if (!empty($context['profile_fields'])) { |
|
| 1626 | + echo ' |
|
| 1562 | 1627 | </dl>'; |
| 1628 | + } |
|
| 1563 | 1629 | |
| 1564 | 1630 | // Are there any custom profile fields - if so print them! |
| 1565 | 1631 | if (!empty($context['custom_fields'])) |
| 1566 | 1632 | { |
| 1567 | - if ($lastItem != 'hr') |
|
| 1568 | - echo ' |
|
| 1633 | + if ($lastItem != 'hr') { |
|
| 1634 | + echo ' |
|
| 1569 | 1635 | <hr>'; |
| 1636 | + } |
|
| 1570 | 1637 | |
| 1571 | 1638 | echo ' |
| 1572 | 1639 | <dl class="settings">'; |
@@ -1589,13 +1656,14 @@ discard block |
||
| 1589 | 1656 | } |
| 1590 | 1657 | |
| 1591 | 1658 | // Any closing HTML? |
| 1592 | - if (!empty($context['profile_posthtml'])) |
|
| 1593 | - echo ' |
|
| 1659 | + if (!empty($context['profile_posthtml'])) { |
|
| 1660 | + echo ' |
|
| 1594 | 1661 | <div>', $context['profile_posthtml'], '</div>'; |
| 1662 | + } |
|
| 1595 | 1663 | |
| 1596 | 1664 | // Only show the password box if it's actually needed. |
| 1597 | - if ($context['require_password']) |
|
| 1598 | - echo ' |
|
| 1665 | + if ($context['require_password']) { |
|
| 1666 | + echo ' |
|
| 1599 | 1667 | <dl class="settings"> |
| 1600 | 1668 | <dt> |
| 1601 | 1669 | <strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '><label for="oldpasswrd">', $txt['current_password'], ': </label></strong><br> |
@@ -1605,18 +1673,21 @@ discard block |
||
| 1605 | 1673 | <input type="password" name="oldpasswrd" id="oldpasswrd" size="20"> |
| 1606 | 1674 | </dd> |
| 1607 | 1675 | </dl>'; |
| 1676 | + } |
|
| 1608 | 1677 | |
| 1609 | 1678 | // The button shouldn't say "Change profile" unless we're changing the profile... |
| 1610 | - if (!empty($context['submit_button_text'])) |
|
| 1611 | - echo ' |
|
| 1679 | + if (!empty($context['submit_button_text'])) { |
|
| 1680 | + echo ' |
|
| 1612 | 1681 | <input type="submit" name="save" value="', $context['submit_button_text'], '" class="button">'; |
| 1613 | - else |
|
| 1614 | - echo ' |
|
| 1682 | + } else { |
|
| 1683 | + echo ' |
|
| 1615 | 1684 | <input type="submit" name="save" value="', $txt['change_profile'], '" class="button">'; |
| 1685 | + } |
|
| 1616 | 1686 | |
| 1617 | - if (!empty($context['token_check'])) |
|
| 1618 | - echo ' |
|
| 1687 | + if (!empty($context['token_check'])) { |
|
| 1688 | + echo ' |
|
| 1619 | 1689 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 1690 | + } |
|
| 1620 | 1691 | |
| 1621 | 1692 | echo ' |
| 1622 | 1693 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -1626,10 +1697,11 @@ discard block |
||
| 1626 | 1697 | </form>'; |
| 1627 | 1698 | |
| 1628 | 1699 | // Any final spellchecking stuff? |
| 1629 | - if (!empty($context['show_spellchecking'])) |
|
| 1630 | - echo ' |
|
| 1700 | + if (!empty($context['show_spellchecking'])) { |
|
| 1701 | + echo ' |
|
| 1631 | 1702 | <form name="spell_form" id="spell_form" method="post" accept-charset="', $context['character_set'], '" target="spellWindow" action="', $scripturl, '?action=spellcheck"><input type="hidden" name="spellstring" value=""></form>'; |
| 1632 | -} |
|
| 1703 | + } |
|
| 1704 | + } |
|
| 1633 | 1705 | |
| 1634 | 1706 | /** |
| 1635 | 1707 | * Personal Message settings. |
@@ -1666,10 +1738,11 @@ discard block |
||
| 1666 | 1738 | <select name="pm_receive_from" id="pm_receive_from"> |
| 1667 | 1739 | <option value="0"', empty($context['receive_from']) || (empty($modSettings['enable_buddylist']) && $context['receive_from'] < 3) ? ' selected' : '', '>', $txt['pm_receive_from_everyone'], '</option>'; |
| 1668 | 1740 | |
| 1669 | - if (!empty($modSettings['enable_buddylist'])) |
|
| 1670 | - echo ' |
|
| 1741 | + if (!empty($modSettings['enable_buddylist'])) { |
|
| 1742 | + echo ' |
|
| 1671 | 1743 | <option value="1"', !empty($context['receive_from']) && $context['receive_from'] == 1 ? ' selected' : '', '>', $txt['pm_receive_from_ignore'], '</option> |
| 1672 | 1744 | <option value="2"', !empty($context['receive_from']) && $context['receive_from'] == 2 ? ' selected' : '', '>', $txt['pm_receive_from_buddies'], '</option>'; |
| 1745 | + } |
|
| 1673 | 1746 | |
| 1674 | 1747 | echo ' |
| 1675 | 1748 | <option value="3"', !empty($context['receive_from']) && $context['receive_from'] > 2 ? ' selected' : '', '>', $txt['pm_receive_from_admins'], '</option> |
@@ -1712,11 +1785,12 @@ discard block |
||
| 1712 | 1785 | if (empty($setting) || !is_array($setting)) |
| 1713 | 1786 | { |
| 1714 | 1787 | // Insert a separator (unless this is the first item in the list) |
| 1715 | - if ($i !== $first_option_key) |
|
| 1716 | - echo ' |
|
| 1788 | + if ($i !== $first_option_key) { |
|
| 1789 | + echo ' |
|
| 1717 | 1790 | </dl> |
| 1718 | 1791 | <hr> |
| 1719 | 1792 | <dl class="settings">'; |
| 1793 | + } |
|
| 1720 | 1794 | |
| 1721 | 1795 | // Should we give a name to this section? |
| 1722 | 1796 | if (is_string($setting) && !empty($setting)) |
@@ -1725,52 +1799,57 @@ discard block |
||
| 1725 | 1799 | echo ' |
| 1726 | 1800 | <dt><strong>' . $setting . '</strong></dt> |
| 1727 | 1801 | <dd></dd>'; |
| 1802 | + } else { |
|
| 1803 | + $titled_section = false; |
|
| 1728 | 1804 | } |
| 1729 | - else |
|
| 1730 | - $titled_section = false; |
|
| 1731 | 1805 | |
| 1732 | 1806 | continue; |
| 1733 | 1807 | } |
| 1734 | 1808 | |
| 1735 | 1809 | // Is this disabled? |
| 1736 | - if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) |
|
| 1737 | - continue; |
|
| 1738 | - elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
| 1739 | - continue; |
|
| 1740 | - elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored'])) |
|
| 1741 | - continue; |
|
| 1742 | - elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist'])) |
|
| 1743 | - continue; |
|
| 1744 | - elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg'])) |
|
| 1745 | - continue; |
|
| 1746 | - elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) |
|
| 1747 | - continue; |
|
| 1748 | - elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) |
|
| 1749 | - continue; |
|
| 1810 | + if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) { |
|
| 1811 | + continue; |
|
| 1812 | + } elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) { |
|
| 1813 | + continue; |
|
| 1814 | + } elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored'])) { |
|
| 1815 | + continue; |
|
| 1816 | + } elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist'])) { |
|
| 1817 | + continue; |
|
| 1818 | + } elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg'])) { |
|
| 1819 | + continue; |
|
| 1820 | + } elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) { |
|
| 1821 | + continue; |
|
| 1822 | + } elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) { |
|
| 1823 | + continue; |
|
| 1824 | + } |
|
| 1750 | 1825 | |
| 1751 | 1826 | // Some of these may not be set... Set to defaults here |
| 1752 | 1827 | $opts = array('topics_per_page', 'messages_per_page', 'display_quick_mod'); |
| 1753 | - if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']])) |
|
| 1754 | - $context['member']['options'][$setting['id']] = 0; |
|
| 1828 | + if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']])) { |
|
| 1829 | + $context['member']['options'][$setting['id']] = 0; |
|
| 1830 | + } |
|
| 1755 | 1831 | |
| 1756 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
| 1757 | - $setting['type'] = 'checkbox'; |
|
| 1758 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
| 1759 | - $setting['type'] = 'number'; |
|
| 1760 | - elseif ($setting['type'] == 'string') |
|
| 1761 | - $setting['type'] = 'text'; |
|
| 1832 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
| 1833 | + $setting['type'] = 'checkbox'; |
|
| 1834 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
| 1835 | + $setting['type'] = 'number'; |
|
| 1836 | + } elseif ($setting['type'] == 'string') { |
|
| 1837 | + $setting['type'] = 'text'; |
|
| 1838 | + } |
|
| 1762 | 1839 | |
| 1763 | - if (isset($setting['options'])) |
|
| 1764 | - $setting['type'] = 'list'; |
|
| 1840 | + if (isset($setting['options'])) { |
|
| 1841 | + $setting['type'] = 'list'; |
|
| 1842 | + } |
|
| 1765 | 1843 | |
| 1766 | 1844 | echo ' |
| 1767 | 1845 | <dt> |
| 1768 | 1846 | <label for="', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>'; |
| 1769 | 1847 | |
| 1770 | - if (isset($setting['description'])) |
|
| 1771 | - echo ' |
|
| 1848 | + if (isset($setting['description'])) { |
|
| 1849 | + echo ' |
|
| 1772 | 1850 | <br> |
| 1773 | 1851 | <span class="smalltext">', $setting['description'], '</span>'; |
| 1852 | + } |
|
| 1774 | 1853 | echo ' |
| 1775 | 1854 | </dt> |
| 1776 | 1855 | <dd>'; |
@@ -1808,13 +1887,11 @@ discard block |
||
| 1808 | 1887 | |
| 1809 | 1888 | echo ' |
| 1810 | 1889 | <input type="number"', $min . $max . $step; |
| 1811 | - } |
|
| 1812 | - else if (isset($setting['type']) && $setting['type'] == 'url') |
|
| 1890 | + } else if (isset($setting['type']) && $setting['type'] == 'url') |
|
| 1813 | 1891 | { |
| 1814 | 1892 | echo' |
| 1815 | 1893 | <input type="url"'; |
| 1816 | - } |
|
| 1817 | - else |
|
| 1894 | + } else |
|
| 1818 | 1895 | { |
| 1819 | 1896 | echo ' |
| 1820 | 1897 | <input type="text"'; |
@@ -1855,8 +1932,8 @@ discard block |
||
| 1855 | 1932 | <dl class="settings">'; |
| 1856 | 1933 | |
| 1857 | 1934 | // Allow notification on announcements to be disabled? |
| 1858 | - if (!empty($modSettings['allow_disableAnnounce'])) |
|
| 1859 | - echo ' |
|
| 1935 | + if (!empty($modSettings['allow_disableAnnounce'])) { |
|
| 1936 | + echo ' |
|
| 1860 | 1937 | <dt> |
| 1861 | 1938 | <label for="notify_announcements">', $txt['notify_important_email'], '</label> |
| 1862 | 1939 | </dt> |
@@ -1864,15 +1941,17 @@ discard block |
||
| 1864 | 1941 | <input type="hidden" name="notify_announcements" value="0"> |
| 1865 | 1942 | <input type="checkbox" id="notify_announcements" name="notify_announcements" value="1"', !empty($context['member']['notify_announcements']) ? ' checked' : '', '> |
| 1866 | 1943 | </dd>'; |
| 1944 | + } |
|
| 1867 | 1945 | |
| 1868 | - if (!empty($modSettings['enable_ajax_alerts'])) |
|
| 1869 | - echo ' |
|
| 1946 | + if (!empty($modSettings['enable_ajax_alerts'])) { |
|
| 1947 | + echo ' |
|
| 1870 | 1948 | <dt> |
| 1871 | 1949 | <label for="notify_send_body">', $txt['notify_alert_timeout'], '</label> |
| 1872 | 1950 | </dt> |
| 1873 | 1951 | <dd> |
| 1874 | 1952 | <input type="number" size="4" id="notify_alert_timeout" name="opt_alert_timeout" min="0" value="', $context['member']['alert_timeout'], '"> |
| 1875 | 1953 | </dd>'; |
| 1954 | + } |
|
| 1876 | 1955 | |
| 1877 | 1956 | echo ' |
| 1878 | 1957 | </dl> |
@@ -1902,9 +1981,10 @@ discard block |
||
| 1902 | 1981 | <td colspan="3">'; |
| 1903 | 1982 | $label = $txt['alert_opt_' . $opts[1]]; |
| 1904 | 1983 | $label_pos = isset($opts['label']) ? $opts['label'] : ''; |
| 1905 | - if ($label_pos == 'before') |
|
| 1906 | - echo ' |
|
| 1984 | + if ($label_pos == 'before') { |
|
| 1985 | + echo ' |
|
| 1907 | 1986 | <label for="opt_', $opts[1], '">', $label, '</label>'; |
| 1987 | + } |
|
| 1908 | 1988 | |
| 1909 | 1989 | $this_value = isset($context['alert_prefs'][$opts[1]]) ? $context['alert_prefs'][$opts[1]] : 0; |
| 1910 | 1990 | switch ($opts[0]) |
@@ -1916,17 +1996,19 @@ discard block |
||
| 1916 | 1996 | case 'select': |
| 1917 | 1997 | echo ' |
| 1918 | 1998 | <select name="opt_', $opts[1], '" id="opt_', $opts[1], '">'; |
| 1919 | - foreach ($opts['opts'] as $k => $v) |
|
| 1920 | - echo ' |
|
| 1999 | + foreach ($opts['opts'] as $k => $v) { |
|
| 2000 | + echo ' |
|
| 1921 | 2001 | <option value="', $k, '"', $this_value == $k ? ' selected' : '', '>', $v, '</option>'; |
| 2002 | + } |
|
| 1922 | 2003 | echo ' |
| 1923 | 2004 | </select>'; |
| 1924 | 2005 | break; |
| 1925 | 2006 | } |
| 1926 | 2007 | |
| 1927 | - if ($label_pos == 'after') |
|
| 1928 | - echo ' |
|
| 2008 | + if ($label_pos == 'after') { |
|
| 2009 | + echo ' |
|
| 1929 | 2010 | <label for="opt_', $opts[1], '">', $label, '</label>'; |
| 2011 | + } |
|
| 1930 | 2012 | |
| 1931 | 2013 | echo ' |
| 1932 | 2014 | </td> |
@@ -2042,11 +2124,12 @@ discard block |
||
| 2042 | 2124 | <p class="information">', $txt['groupMembership_info'], '</p>'; |
| 2043 | 2125 | |
| 2044 | 2126 | // Do we have an update message? |
| 2045 | - if (!empty($context['update_message'])) |
|
| 2046 | - echo ' |
|
| 2127 | + if (!empty($context['update_message'])) { |
|
| 2128 | + echo ' |
|
| 2047 | 2129 | <div class="infobox"> |
| 2048 | 2130 | ', $context['update_message'], '. |
| 2049 | 2131 | </div>'; |
| 2132 | + } |
|
| 2050 | 2133 | |
| 2051 | 2134 | echo ' |
| 2052 | 2135 | <div id="groups">'; |
@@ -2068,8 +2151,7 @@ discard block |
||
| 2068 | 2151 | </div> |
| 2069 | 2152 | </div> |
| 2070 | 2153 | </div><!-- .groupmembership -->'; |
| 2071 | - } |
|
| 2072 | - else |
|
| 2154 | + } else |
|
| 2073 | 2155 | { |
| 2074 | 2156 | echo ' |
| 2075 | 2157 | <div class="title_bar"> |
@@ -2081,27 +2163,30 @@ discard block |
||
| 2081 | 2163 | echo ' |
| 2082 | 2164 | <div class="windowbg" id="primdiv_', $group['id'], '">'; |
| 2083 | 2165 | |
| 2084 | - if ($context['can_edit_primary']) |
|
| 2085 | - echo ' |
|
| 2166 | + if ($context['can_edit_primary']) { |
|
| 2167 | + echo ' |
|
| 2086 | 2168 | <input type="radio" name="primary" id="primary_', $group['id'], '" value="', $group['id'], '"', $group['is_primary'] ? ' checked' : '', ' onclick="highlightSelected(\'primdiv_' . $group['id'] . '\');"', $group['can_be_primary'] ? '' : ' disabled', '>'; |
| 2169 | + } |
|
| 2087 | 2170 | |
| 2088 | 2171 | echo ' |
| 2089 | 2172 | <label for="primary_', $group['id'], '"><strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), '</label>'; |
| 2090 | 2173 | |
| 2091 | 2174 | // Can they leave their group? |
| 2092 | - if ($group['can_leave']) |
|
| 2093 | - echo ' |
|
| 2175 | + if ($group['can_leave']) { |
|
| 2176 | + echo ' |
|
| 2094 | 2177 | <a href="' . $scripturl . '?action=profile;save;u=' . $context['id_member'] . ';area=groupmembership;' . $context['session_var'] . '=' . $context['session_id'] . ';gid=' . $group['id'] . ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '">' . $txt['leave_group'] . '</a>'; |
| 2178 | + } |
|
| 2095 | 2179 | |
| 2096 | 2180 | echo ' |
| 2097 | 2181 | </div><!-- .windowbg -->'; |
| 2098 | 2182 | } |
| 2099 | 2183 | |
| 2100 | - if ($context['can_edit_primary']) |
|
| 2101 | - echo ' |
|
| 2184 | + if ($context['can_edit_primary']) { |
|
| 2185 | + echo ' |
|
| 2102 | 2186 | <div class="padding righttext"> |
| 2103 | 2187 | <input type="submit" value="', $txt['make_primary'], '" class="button"> |
| 2104 | 2188 | </div>'; |
| 2189 | + } |
|
| 2105 | 2190 | |
| 2106 | 2191 | // Any groups they can join? |
| 2107 | 2192 | if (!empty($context['groups']['available'])) |
@@ -2117,15 +2202,16 @@ discard block |
||
| 2117 | 2202 | <div class="windowbg"> |
| 2118 | 2203 | <strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), ''; |
| 2119 | 2204 | |
| 2120 | - if ($group['type'] == 3) |
|
| 2121 | - echo ' |
|
| 2205 | + if ($group['type'] == 3) { |
|
| 2206 | + echo ' |
|
| 2122 | 2207 | <a href="', $scripturl, '?action=profile;save;u=', $context['id_member'], ';area=groupmembership;', $context['session_var'], '=', $context['session_id'], ';gid=', $group['id'], ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '" class="button floatright">', $txt['join_group'], '</a>'; |
| 2123 | - elseif ($group['type'] == 2 && $group['pending']) |
|
| 2124 | - echo ' |
|
| 2208 | + } elseif ($group['type'] == 2 && $group['pending']) { |
|
| 2209 | + echo ' |
|
| 2125 | 2210 | <span class="floatright">', $txt['approval_pending'], '</span>'; |
| 2126 | - elseif ($group['type'] == 2) |
|
| 2127 | - echo ' |
|
| 2211 | + } elseif ($group['type'] == 2) { |
|
| 2212 | + echo ' |
|
| 2128 | 2213 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=groupmembership;request=', $group['id'], '" class="button floatright">', $txt['request_group'], '</a>'; |
| 2214 | + } |
|
| 2129 | 2215 | |
| 2130 | 2216 | echo ' |
| 2131 | 2217 | </div><!-- .windowbg -->'; |
@@ -2148,9 +2234,10 @@ discard block |
||
| 2148 | 2234 | |
| 2149 | 2235 | prevDiv.className = "windowbg"; |
| 2150 | 2236 | }'; |
| 2151 | - if (isset($context['groups']['member'][$context['primary_group']])) |
|
| 2152 | - echo ' |
|
| 2237 | + if (isset($context['groups']['member'][$context['primary_group']])) { |
|
| 2238 | + echo ' |
|
| 2153 | 2239 | highlightSelected("primdiv_' . $context['primary_group'] . '");'; |
| 2240 | + } |
|
| 2154 | 2241 | echo ' |
| 2155 | 2242 | </script>'; |
| 2156 | 2243 | } |
@@ -2158,9 +2245,10 @@ discard block |
||
| 2158 | 2245 | echo ' |
| 2159 | 2246 | </div><!-- #groups -->'; |
| 2160 | 2247 | |
| 2161 | - if (!empty($context['token_check'])) |
|
| 2162 | - echo ' |
|
| 2248 | + if (!empty($context['token_check'])) { |
|
| 2249 | + echo ' |
|
| 2163 | 2250 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2251 | + } |
|
| 2164 | 2252 | |
| 2165 | 2253 | echo ' |
| 2166 | 2254 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2208,14 +2296,15 @@ discard block |
||
| 2208 | 2296 | |
| 2209 | 2297 | foreach ($category['boards'] as $board) |
| 2210 | 2298 | { |
| 2211 | - if ($i == $limit) |
|
| 2212 | - echo ' |
|
| 2299 | + if ($i == $limit) { |
|
| 2300 | + echo ' |
|
| 2213 | 2301 | </ul> |
| 2214 | 2302 | </li> |
| 2215 | 2303 | </ul> |
| 2216 | 2304 | <ul class="ignoreboards floatright"> |
| 2217 | 2305 | <li class="category"> |
| 2218 | 2306 | <ul>'; |
| 2307 | + } |
|
| 2219 | 2308 | |
| 2220 | 2309 | echo ' |
| 2221 | 2310 | <li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;"> |
@@ -2261,10 +2350,11 @@ discard block |
||
| 2261 | 2350 | |
| 2262 | 2351 | // Work out the starting color. |
| 2263 | 2352 | $context['current_color'] = $context['colors'][0]; |
| 2264 | - foreach ($context['colors'] as $limit => $color) |
|
| 2265 | - if ($context['member']['warning'] >= $limit) |
|
| 2353 | + foreach ($context['colors'] as $limit => $color) { |
|
| 2354 | + if ($context['member']['warning'] >= $limit) |
|
| 2266 | 2355 | $context['current_color'] = $color; |
| 2267 | -} |
|
| 2356 | + } |
|
| 2357 | + } |
|
| 2268 | 2358 | |
| 2269 | 2359 | // Show all warnings of a user? |
| 2270 | 2360 | function template_viewWarning() |
@@ -2303,14 +2393,15 @@ discard block |
||
| 2303 | 2393 | </dd>'; |
| 2304 | 2394 | |
| 2305 | 2395 | // There's some impact of this? |
| 2306 | - if (!empty($context['level_effects'][$context['current_level']])) |
|
| 2307 | - echo ' |
|
| 2396 | + if (!empty($context['level_effects'][$context['current_level']])) { |
|
| 2397 | + echo ' |
|
| 2308 | 2398 | <dt> |
| 2309 | 2399 | <strong>', $txt['profile_viewwarning_impact'], ':</strong> |
| 2310 | 2400 | </dt> |
| 2311 | 2401 | <dd> |
| 2312 | 2402 | ', $context['level_effects'][$context['current_level']], ' |
| 2313 | 2403 | </dd>'; |
| 2404 | + } |
|
| 2314 | 2405 | |
| 2315 | 2406 | echo ' |
| 2316 | 2407 | </dl> |
@@ -2348,10 +2439,11 @@ discard block |
||
| 2348 | 2439 | |
| 2349 | 2440 | // Otherwise see what we can do...'; |
| 2350 | 2441 | |
| 2351 | - foreach ($context['notification_templates'] as $k => $type) |
|
| 2352 | - echo ' |
|
| 2442 | + foreach ($context['notification_templates'] as $k => $type) { |
|
| 2443 | + echo ' |
|
| 2353 | 2444 | if (index == ', $k, ') |
| 2354 | 2445 | document.getElementById(\'warn_body\').value = "', strtr($type['body'], array('"' => "'", "\n" => '\\n', "\r" => '')), '";'; |
| 2446 | + } |
|
| 2355 | 2447 | |
| 2356 | 2448 | echo ' |
| 2357 | 2449 | } |
@@ -2361,10 +2453,11 @@ discard block |
||
| 2361 | 2453 | // Also set the right effect. |
| 2362 | 2454 | effectText = "";'; |
| 2363 | 2455 | |
| 2364 | - foreach ($context['level_effects'] as $limit => $text) |
|
| 2365 | - echo ' |
|
| 2456 | + foreach ($context['level_effects'] as $limit => $text) { |
|
| 2457 | + echo ' |
|
| 2366 | 2458 | if (slideAmount >= ', $limit, ') |
| 2367 | 2459 | effectText = "', $text, '";'; |
| 2460 | + } |
|
| 2368 | 2461 | |
| 2369 | 2462 | echo ' |
| 2370 | 2463 | setInnerHTML(document.getElementById(\'cur_level_div\'), slideAmount + \'% (\' + effectText + \')\'); |
@@ -2379,32 +2472,35 @@ discard block |
||
| 2379 | 2472 | </h3> |
| 2380 | 2473 | </div>'; |
| 2381 | 2474 | |
| 2382 | - if (!$context['user']['is_owner']) |
|
| 2383 | - echo ' |
|
| 2475 | + if (!$context['user']['is_owner']) { |
|
| 2476 | + echo ' |
|
| 2384 | 2477 | <p class="information">', $txt['profile_warning_desc'], '</p>'; |
| 2478 | + } |
|
| 2385 | 2479 | |
| 2386 | 2480 | echo ' |
| 2387 | 2481 | <div class="windowbg"> |
| 2388 | 2482 | <dl class="settings">'; |
| 2389 | 2483 | |
| 2390 | - if (!$context['user']['is_owner']) |
|
| 2391 | - echo ' |
|
| 2484 | + if (!$context['user']['is_owner']) { |
|
| 2485 | + echo ' |
|
| 2392 | 2486 | <dt> |
| 2393 | 2487 | <strong>', $txt['profile_warning_name'], ':</strong> |
| 2394 | 2488 | </dt> |
| 2395 | 2489 | <dd> |
| 2396 | 2490 | <strong>', $context['member']['name'], '</strong> |
| 2397 | 2491 | </dd>'; |
| 2492 | + } |
|
| 2398 | 2493 | |
| 2399 | 2494 | echo ' |
| 2400 | 2495 | <dt> |
| 2401 | 2496 | <strong>', $txt['profile_warning_level'], ':</strong>'; |
| 2402 | 2497 | |
| 2403 | 2498 | // Is there only so much they can apply? |
| 2404 | - if ($context['warning_limit']) |
|
| 2405 | - echo ' |
|
| 2499 | + if ($context['warning_limit']) { |
|
| 2500 | + echo ' |
|
| 2406 | 2501 | <br> |
| 2407 | 2502 | <span class="smalltext">', sprintf($txt['profile_warning_limit_attribute'], $context['warning_limit']), '</span>'; |
| 2503 | + } |
|
| 2408 | 2504 | |
| 2409 | 2505 | echo ' |
| 2410 | 2506 | </dt> |
@@ -2459,9 +2555,10 @@ discard block |
||
| 2459 | 2555 | <option value="-1">', $txt['profile_warning_notify_template'], '</option> |
| 2460 | 2556 | <option value="-1" disabled>------------------------------</option>'; |
| 2461 | 2557 | |
| 2462 | - foreach ($context['notification_templates'] as $id_template => $template) |
|
| 2463 | - echo ' |
|
| 2558 | + foreach ($context['notification_templates'] as $id_template => $template) { |
|
| 2559 | + echo ' |
|
| 2464 | 2560 | <option value="', $id_template, '">', $template['title'], '</option>'; |
| 2561 | + } |
|
| 2465 | 2562 | |
| 2466 | 2563 | echo ' |
| 2467 | 2564 | </select> |
@@ -2474,9 +2571,10 @@ discard block |
||
| 2474 | 2571 | </dl> |
| 2475 | 2572 | <div class="righttext">'; |
| 2476 | 2573 | |
| 2477 | - if (!empty($context['token_check'])) |
|
| 2478 | - echo ' |
|
| 2574 | + if (!empty($context['token_check'])) { |
|
| 2575 | + echo ' |
|
| 2479 | 2576 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2577 | + } |
|
| 2480 | 2578 | |
| 2481 | 2579 | echo ' |
| 2482 | 2580 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2492,8 +2590,8 @@ discard block |
||
| 2492 | 2590 | echo ' |
| 2493 | 2591 | <script>'; |
| 2494 | 2592 | |
| 2495 | - if (!$context['user']['is_owner']) |
|
| 2496 | - echo ' |
|
| 2593 | + if (!$context['user']['is_owner']) { |
|
| 2594 | + echo ' |
|
| 2497 | 2595 | modifyWarnNotify(); |
| 2498 | 2596 | $(document).ready(function() { |
| 2499 | 2597 | $("#preview_button").click(function() { |
@@ -2532,6 +2630,7 @@ discard block |
||
| 2532 | 2630 | }); |
| 2533 | 2631 | return false; |
| 2534 | 2632 | }'; |
| 2633 | + } |
|
| 2535 | 2634 | |
| 2536 | 2635 | echo ' |
| 2537 | 2636 | </script>'; |
@@ -2554,16 +2653,18 @@ discard block |
||
| 2554 | 2653 | </div>'; |
| 2555 | 2654 | |
| 2556 | 2655 | // If deleting another account give them a lovely info box. |
| 2557 | - if (!$context['user']['is_owner']) |
|
| 2558 | - echo ' |
|
| 2656 | + if (!$context['user']['is_owner']) { |
|
| 2657 | + echo ' |
|
| 2559 | 2658 | <p class="information">', $txt['deleteAccount_desc'], '</p>'; |
| 2659 | + } |
|
| 2560 | 2660 | echo ' |
| 2561 | 2661 | <div class="windowbg2">'; |
| 2562 | 2662 | |
| 2563 | 2663 | // If they are deleting their account AND the admin needs to approve it - give them another piece of info ;) |
| 2564 | - if ($context['needs_approval']) |
|
| 2565 | - echo ' |
|
| 2664 | + if ($context['needs_approval']) { |
|
| 2665 | + echo ' |
|
| 2566 | 2666 | <div class="errorbox">', $txt['deleteAccount_approval'], '</div>'; |
| 2667 | + } |
|
| 2567 | 2668 | |
| 2568 | 2669 | // If the user is deleting their own account warn them first - and require a password! |
| 2569 | 2670 | if ($context['user']['is_owner']) |
@@ -2575,9 +2676,10 @@ discard block |
||
| 2575 | 2676 | <input type="password" name="oldpasswrd" size="20"> |
| 2576 | 2677 | <input type="submit" value="', $txt['yes'], '" class="button">'; |
| 2577 | 2678 | |
| 2578 | - if (!empty($context['token_check'])) |
|
| 2579 | - echo ' |
|
| 2679 | + if (!empty($context['token_check'])) { |
|
| 2680 | + echo ' |
|
| 2580 | 2681 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2682 | + } |
|
| 2581 | 2683 | |
| 2582 | 2684 | echo ' |
| 2583 | 2685 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2607,10 +2709,11 @@ discard block |
||
| 2607 | 2709 | <option value="topics">', $txt['deleteAccount_topics'], '</option> |
| 2608 | 2710 | </select>'; |
| 2609 | 2711 | |
| 2610 | - if ($context['show_perma_delete']) |
|
| 2611 | - echo ' |
|
| 2712 | + if ($context['show_perma_delete']) { |
|
| 2713 | + echo ' |
|
| 2612 | 2714 | <br> |
| 2613 | 2715 | <label for="perma_delete"><input type="checkbox" name="perma_delete" id="perma_delete" value="1">', $txt['deleteAccount_permanent'], ':</label>'; |
| 2716 | + } |
|
| 2614 | 2717 | |
| 2615 | 2718 | echo ' |
| 2616 | 2719 | </div>'; |
@@ -2623,9 +2726,10 @@ discard block |
||
| 2623 | 2726 | <div> |
| 2624 | 2727 | <input type="submit" value="', $txt['delete'], '" class="button">'; |
| 2625 | 2728 | |
| 2626 | - if (!empty($context['token_check'])) |
|
| 2627 | - echo ' |
|
| 2729 | + if (!empty($context['token_check'])) { |
|
| 2730 | + echo ' |
|
| 2628 | 2731 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2732 | + } |
|
| 2629 | 2733 | |
| 2630 | 2734 | echo ' |
| 2631 | 2735 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2651,8 +2755,8 @@ discard block |
||
| 2651 | 2755 | <hr>'; |
| 2652 | 2756 | |
| 2653 | 2757 | // Only show the password box if it's actually needed. |
| 2654 | - if ($context['require_password']) |
|
| 2655 | - echo ' |
|
| 2758 | + if ($context['require_password']) { |
|
| 2759 | + echo ' |
|
| 2656 | 2760 | <dl class="settings"> |
| 2657 | 2761 | <dt> |
| 2658 | 2762 | <strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '>', $txt['current_password'], ': </strong><br> |
@@ -2662,13 +2766,15 @@ discard block |
||
| 2662 | 2766 | <input type="password" name="oldpasswrd" size="20"> |
| 2663 | 2767 | </dd> |
| 2664 | 2768 | </dl>'; |
| 2769 | + } |
|
| 2665 | 2770 | |
| 2666 | 2771 | echo ' |
| 2667 | 2772 | <div class="righttext">'; |
| 2668 | 2773 | |
| 2669 | - if (!empty($context['token_check'])) |
|
| 2670 | - echo ' |
|
| 2774 | + if (!empty($context['token_check'])) { |
|
| 2775 | + echo ' |
|
| 2671 | 2776 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2777 | + } |
|
| 2672 | 2778 | |
| 2673 | 2779 | echo ' |
| 2674 | 2780 | <input type="submit" value="', $txt['change_profile'], '" class="button"> |
@@ -2695,9 +2801,10 @@ discard block |
||
| 2695 | 2801 | <ul id="list_errors">'; |
| 2696 | 2802 | |
| 2697 | 2803 | // Cycle through each error and display an error message. |
| 2698 | - foreach ($context['post_errors'] as $error) |
|
| 2699 | - echo ' |
|
| 2804 | + foreach ($context['post_errors'] as $error) { |
|
| 2805 | + echo ' |
|
| 2700 | 2806 | <li>', isset($txt['profile_error_' . $error]) ? $txt['profile_error_' . $error] : $error, '</li>'; |
| 2807 | + } |
|
| 2701 | 2808 | |
| 2702 | 2809 | echo ' |
| 2703 | 2810 | </ul>'; |
@@ -2723,12 +2830,13 @@ discard block |
||
| 2723 | 2830 | <select name="id_group" ', ($context['user']['is_owner'] && $context['member']['group_id'] == 1 ? 'onchange="if (this.value != 1 && !confirm(\'' . $txt['deadmin_confirm'] . '\')) this.value = 1;"' : ''), '>'; |
| 2724 | 2831 | |
| 2725 | 2832 | // Fill the select box with all primary member groups that can be assigned to a member. |
| 2726 | - foreach ($context['member_groups'] as $member_group) |
|
| 2727 | - if (!empty($member_group['can_be_primary'])) |
|
| 2833 | + foreach ($context['member_groups'] as $member_group) { |
|
| 2834 | + if (!empty($member_group['can_be_primary'])) |
|
| 2728 | 2835 | echo ' |
| 2729 | 2836 | <option value="', $member_group['id'], '"', $member_group['is_primary'] ? ' selected' : '', '> |
| 2730 | 2837 | ', $member_group['name'], ' |
| 2731 | 2838 | </option>'; |
| 2839 | + } |
|
| 2732 | 2840 | echo ' |
| 2733 | 2841 | </select> |
| 2734 | 2842 | </dd> |
@@ -2740,10 +2848,11 @@ discard block |
||
| 2740 | 2848 | <input type="hidden" name="additional_groups[]" value="0">'; |
| 2741 | 2849 | |
| 2742 | 2850 | // For each membergroup show a checkbox so members can be assigned to more than one group. |
| 2743 | - foreach ($context['member_groups'] as $member_group) |
|
| 2744 | - if ($member_group['can_be_additional']) |
|
| 2851 | + foreach ($context['member_groups'] as $member_group) { |
|
| 2852 | + if ($member_group['can_be_additional']) |
|
| 2745 | 2853 | echo ' |
| 2746 | 2854 | <label for="additional_groups-', $member_group['id'], '"><input type="checkbox" name="additional_groups[]" value="', $member_group['id'], '" id="additional_groups-', $member_group['id'], '"', $member_group['is_additional'] ? ' checked' : '', '> ', $member_group['name'], '</label><br>'; |
| 2855 | + } |
|
| 2747 | 2856 | echo ' |
| 2748 | 2857 | </span> |
| 2749 | 2858 | <a href="javascript:void(0);" onclick="document.getElementById(\'additional_groupsList\').style.display = \'block\'; document.getElementById(\'additional_groupsLink\').style.display = \'none\'; return false;" id="additional_groupsLink" style="display: none;" class="toggle_down">', $txt['additional_membergroups_show'], '</a> |
@@ -2803,9 +2912,10 @@ discard block |
||
| 2803 | 2912 | <span class="smalltext">', $txt['sig_info'], '</span><br> |
| 2804 | 2913 | <br>'; |
| 2805 | 2914 | |
| 2806 | - if ($context['show_spellchecking']) |
|
| 2807 | - echo ' |
|
| 2915 | + if ($context['show_spellchecking']) { |
|
| 2916 | + echo ' |
|
| 2808 | 2917 | <input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'creator\', \'signature\');" class="button">'; |
| 2918 | + } |
|
| 2809 | 2919 | |
| 2810 | 2920 | echo ' |
| 2811 | 2921 | </dt> |
@@ -2813,17 +2923,20 @@ discard block |
||
| 2813 | 2923 | <textarea class="editor" onkeyup="calcCharLeft();" id="signature" name="signature" rows="5" cols="50">', $context['member']['signature'], '</textarea><br>'; |
| 2814 | 2924 | |
| 2815 | 2925 | // If there is a limit at all! |
| 2816 | - if (!empty($context['signature_limits']['max_length'])) |
|
| 2817 | - echo ' |
|
| 2926 | + if (!empty($context['signature_limits']['max_length'])) { |
|
| 2927 | + echo ' |
|
| 2818 | 2928 | <span class="smalltext">', sprintf($txt['max_sig_characters'], $context['signature_limits']['max_length']), ' <span id="signatureLeft">', $context['signature_limits']['max_length'], '</span></span><br>'; |
| 2929 | + } |
|
| 2819 | 2930 | |
| 2820 | - if (!empty($context['show_preview_button'])) |
|
| 2821 | - echo ' |
|
| 2931 | + if (!empty($context['show_preview_button'])) { |
|
| 2932 | + echo ' |
|
| 2822 | 2933 | <input type="button" name="preview_signature" id="preview_button" value="', $txt['preview_signature'], '" class="button">'; |
| 2934 | + } |
|
| 2823 | 2935 | |
| 2824 | - if ($context['signature_warning']) |
|
| 2825 | - echo ' |
|
| 2936 | + if ($context['signature_warning']) { |
|
| 2937 | + echo ' |
|
| 2826 | 2938 | <span class="smalltext">', $context['signature_warning'], '</span>'; |
| 2939 | + } |
|
| 2827 | 2940 | |
| 2828 | 2941 | // Some javascript used to count how many characters have been used so far in the signature. |
| 2829 | 2942 | echo ' |
@@ -2868,9 +2981,10 @@ discard block |
||
| 2868 | 2981 | <select name="cat" id="cat" size="10" onchange="changeSel(\'\');" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'server_stored\');">'; |
| 2869 | 2982 | |
| 2870 | 2983 | // This lists all the file categories. |
| 2871 | - foreach ($context['avatars'] as $avatar) |
|
| 2872 | - echo ' |
|
| 2984 | + foreach ($context['avatars'] as $avatar) { |
|
| 2985 | + echo ' |
|
| 2873 | 2986 | <option value="', $avatar['filename'] . ($avatar['is_dir'] ? '/' : ''), '"', ($avatar['checked'] ? ' selected' : ''), '>', $avatar['name'], '</option>'; |
| 2987 | + } |
|
| 2874 | 2988 | echo ' |
| 2875 | 2989 | </select> |
| 2876 | 2990 | </div> |
@@ -2927,16 +3041,17 @@ discard block |
||
| 2927 | 3041 | <div id="avatar_gravatar"> |
| 2928 | 3042 | <img src="' . $context['member']['avatar']['href'] . '" alt="" />'; |
| 2929 | 3043 | |
| 2930 | - if (empty($modSettings['gravatarAllowExtraEmail'])) |
|
| 2931 | - echo ' |
|
| 3044 | + if (empty($modSettings['gravatarAllowExtraEmail'])) { |
|
| 3045 | + echo ' |
|
| 2932 | 3046 | <div class="smalltext">', $txt['gravatar_noAlternateEmail'], '</div>'; |
| 2933 | - else |
|
| 3047 | + } else |
|
| 2934 | 3048 | { |
| 2935 | 3049 | // Depending on other stuff, the stored value here might have some odd things in it from other areas. |
| 2936 | - if ($context['member']['avatar']['external'] == $context['member']['email']) |
|
| 2937 | - $textbox_value = ''; |
|
| 2938 | - else |
|
| 2939 | - $textbox_value = $context['member']['avatar']['external']; |
|
| 3050 | + if ($context['member']['avatar']['external'] == $context['member']['email']) { |
|
| 3051 | + $textbox_value = ''; |
|
| 3052 | + } else { |
|
| 3053 | + $textbox_value = $context['member']['avatar']['external']; |
|
| 3054 | + } |
|
| 2940 | 3055 | |
| 2941 | 3056 | echo ' |
| 2942 | 3057 | <div class="smalltext">', $txt['gravatar_alternateEmail'], '</div> |
@@ -3008,8 +3123,9 @@ discard block |
||
| 3008 | 3123 | $h = !empty($modSettings['avatar_max_height_' . $type]) ? comma_format($modSettings['avatar_max_height_' . $type]) : 0; |
| 3009 | 3124 | |
| 3010 | 3125 | $suffix = (!empty($w) ? 'w' : '') . (!empty($h) ? 'h' : ''); |
| 3011 | - if (empty($suffix)) |
|
| 3012 | - return; |
|
| 3126 | + if (empty($suffix)) { |
|
| 3127 | + return; |
|
| 3128 | + } |
|
| 3013 | 3129 | |
| 3014 | 3130 | echo ' |
| 3015 | 3131 | <div class="smalltext">', sprintf($txt['avatar_max_size_' . $suffix], $w, $h), '</div>'; |
@@ -3034,9 +3150,10 @@ discard block |
||
| 3034 | 3150 | <select name="easyformat" id="easyformat" onchange="document.forms.creator.time_format.value = this.options[this.selectedIndex].value;">'; |
| 3035 | 3151 | |
| 3036 | 3152 | // Help the user by showing a list of common time formats. |
| 3037 | - foreach ($context['easy_timeformats'] as $time_format) |
|
| 3038 | - echo ' |
|
| 3153 | + foreach ($context['easy_timeformats'] as $time_format) { |
|
| 3154 | + echo ' |
|
| 3039 | 3155 | <option value="', $time_format['format'], '"', $time_format['format'] == $context['member']['time_format'] ? ' selected' : '', '>', $time_format['title'], '</option>'; |
| 3156 | + } |
|
| 3040 | 3157 | echo ' |
| 3041 | 3158 | </select><br> |
| 3042 | 3159 | <input type="text" name="time_format" id="time_format" value="', $context['member']['time_format'], '" size="30"> |
@@ -3073,9 +3190,10 @@ discard block |
||
| 3073 | 3190 | <dd> |
| 3074 | 3191 | <select name="smiley_set" id="smiley_set" onchange="document.getElementById(\'smileypr\').src = this.selectedIndex == 0 ? \'', $settings['images_url'], '/blank.png\' : \'', $modSettings['smileys_url'], '/\' + (this.selectedIndex != 1 ? this.options[this.selectedIndex].value : \'', !empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'], '\') + \'/smiley.gif\';">'; |
| 3075 | 3192 | |
| 3076 | - foreach ($context['smiley_sets'] as $set) |
|
| 3077 | - echo ' |
|
| 3193 | + foreach ($context['smiley_sets'] as $set) { |
|
| 3194 | + echo ' |
|
| 3078 | 3195 | <option value="', $set['id'], '"', $set['selected'] ? ' selected' : '', '>', $set['name'], '</option>'; |
| 3196 | + } |
|
| 3079 | 3197 | echo ' |
| 3080 | 3198 | </select> |
| 3081 | 3199 | <img id="smileypr" class="centericon" src="', $context['member']['smiley_set']['id'] != 'none' ? $modSettings['smileys_url'] . '/' . ($context['member']['smiley_set']['id'] != '' ? $context['member']['smiley_set']['id'] : (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'])) . '/smiley.gif' : $settings['images_url'] . '/blank.png', '" alt=":)"> |
@@ -3126,10 +3244,11 @@ discard block |
||
| 3126 | 3244 | <img src="', $context['tfa_qr_url'], '" alt=""> |
| 3127 | 3245 | </div>'; |
| 3128 | 3246 | |
| 3129 | - if (!empty($context['from_ajax'])) |
|
| 3130 | - echo ' |
|
| 3247 | + if (!empty($context['from_ajax'])) { |
|
| 3248 | + echo ' |
|
| 3131 | 3249 | <br> |
| 3132 | 3250 | <a href="javascript:self.close();"></a>'; |
| 3251 | + } |
|
| 3133 | 3252 | |
| 3134 | 3253 | echo ' |
| 3135 | 3254 | </div> |
@@ -3168,15 +3287,16 @@ discard block |
||
| 3168 | 3287 | <div class="smalltext">', $txt['tfa_profile_desc'], '</div> |
| 3169 | 3288 | </dt> |
| 3170 | 3289 | <dd>'; |
| 3171 | - if (!$context['tfa_enabled'] && $context['user']['is_owner']) |
|
| 3172 | - echo ' |
|
| 3290 | + if (!$context['tfa_enabled'] && $context['user']['is_owner']) { |
|
| 3291 | + echo ' |
|
| 3173 | 3292 | <a href="', !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl, '?action=profile;area=tfasetup" id="enable_tfa">', $txt['tfa_profile_enable'], '</a>'; |
| 3174 | - elseif (!$context['tfa_enabled']) |
|
| 3175 | - echo ' |
|
| 3293 | + } elseif (!$context['tfa_enabled']) { |
|
| 3294 | + echo ' |
|
| 3176 | 3295 | ', $txt['tfa_profile_disabled']; |
| 3177 | - else |
|
| 3178 | - echo ' |
|
| 3296 | + } else { |
|
| 3297 | + echo ' |
|
| 3179 | 3298 | ', sprintf($txt['tfa_profile_enabled'], $scripturl . '?action=profile;u=' . $context['id_member'] . ';area=tfasetup;disable'); |
| 3299 | + } |
|
| 3180 | 3300 | echo ' |
| 3181 | 3301 | </dd>'; |
| 3182 | 3302 | } |
@@ -232,7 +232,7 @@ |
||
| 232 | 232 | // In maintenance mode, only login is allowed and don't show OverlayDiv |
| 233 | 233 | echo ' |
| 234 | 234 | <ul class="floatleft welcome"> |
| 235 | - <li>', sprintf($txt['welcome_guest'], $txt['guest_title'], '', $scripturl. '?action=login', 'return true;'), '</li> |
|
| 235 | + <li>', sprintf($txt['welcome_guest'], $txt['guest_title'], '', $scripturl . '?action=login', 'return true;'), '</li> |
|
| 236 | 236 | </ul>'; |
| 237 | 237 | |
| 238 | 238 | if (!empty($modSettings['userLanguage']) && !empty($context['languages']) && count($context['languages']) > 1) |
@@ -72,9 +72,10 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | // Allow css/js files to be disabled for this specific theme. |
| 74 | 74 | // Add the identifier as an array key. IE array('smf_script'); Some external files might not add identifiers, on those cases SMF uses its filename as reference. |
| 75 | - if (!isset($settings['disable_files'])) |
|
| 76 | - $settings['disable_files'] = array(); |
|
| 77 | -} |
|
| 75 | + if (!isset($settings['disable_files'])) { |
|
| 76 | + $settings['disable_files'] = array(); |
|
| 77 | + } |
|
| 78 | + } |
|
| 78 | 79 | |
| 79 | 80 | /** |
| 80 | 81 | * The main sub template above the content. |
@@ -112,8 +113,9 @@ discard block |
||
| 112 | 113 | echo ' |
| 113 | 114 | <meta'; |
| 114 | 115 | |
| 115 | - foreach ($meta_tag as $meta_key => $meta_value) |
|
| 116 | - echo ' ', $meta_key, '="', $meta_value, '"'; |
|
| 116 | + foreach ($meta_tag as $meta_key => $meta_value) { |
|
| 117 | + echo ' ', $meta_key, '="', $meta_value, '"'; |
|
| 118 | + } |
|
| 117 | 119 | |
| 118 | 120 | echo '>'; |
| 119 | 121 | } |
@@ -124,14 +126,16 @@ discard block |
||
| 124 | 126 | <meta name="theme-color" content="#557EA0">'; |
| 125 | 127 | |
| 126 | 128 | // Please don't index these Mr Robot. |
| 127 | - if (!empty($context['robot_no_index'])) |
|
| 128 | - echo ' |
|
| 129 | + if (!empty($context['robot_no_index'])) { |
|
| 130 | + echo ' |
|
| 129 | 131 | <meta name="robots" content="noindex">'; |
| 132 | + } |
|
| 130 | 133 | |
| 131 | 134 | // Present a canonical url for search engines to prevent duplicate content in their indices. |
| 132 | - if (!empty($context['canonical_url'])) |
|
| 133 | - echo ' |
|
| 135 | + if (!empty($context['canonical_url'])) { |
|
| 136 | + echo ' |
|
| 134 | 137 | <link rel="canonical" href="', $context['canonical_url'], '">'; |
| 138 | + } |
|
| 135 | 139 | |
| 136 | 140 | // Show all the relative links, such as help, search, contents, and the like. |
| 137 | 141 | echo ' |
@@ -140,10 +144,11 @@ discard block |
||
| 140 | 144 | <link rel="search" href="' . $scripturl . '?action=search">' : ''); |
| 141 | 145 | |
| 142 | 146 | // If RSS feeds are enabled, advertise the presence of one. |
| 143 | - if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged'])) |
|
| 144 | - echo ' |
|
| 147 | + if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged'])) { |
|
| 148 | + echo ' |
|
| 145 | 149 | <link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['rss'], '" href="', $scripturl, '?action=.xml;type=rss2', !empty($context['current_board']) ? ';board=' . $context['current_board'] : '', '"> |
| 146 | 150 | <link rel="alternate" type="application/atom+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['atom'], '" href="', $scripturl, '?action=.xml;type=atom', !empty($context['current_board']) ? ';board=' . $context['current_board'] : '', '">'; |
| 151 | + } |
|
| 147 | 152 | |
| 148 | 153 | // If we're viewing a topic, these should be the previous and next topics, respectively. |
| 149 | 154 | if (!empty($context['links']['next'])) |
@@ -159,9 +164,10 @@ discard block |
||
| 159 | 164 | } |
| 160 | 165 | |
| 161 | 166 | // If we're in a board, or a topic for that matter, the index will be the board's index. |
| 162 | - if (!empty($context['current_board'])) |
|
| 163 | - echo ' |
|
| 167 | + if (!empty($context['current_board'])) { |
|
| 168 | + echo ' |
|
| 164 | 169 | <link rel="index" href="', $scripturl, '?board=', $context['current_board'], '.0">'; |
| 170 | + } |
|
| 165 | 171 | |
| 166 | 172 | // Output any remaining HTML headers. (from mods, maybe?) |
| 167 | 173 | echo $context['html_headers']; |
@@ -193,8 +199,9 @@ discard block |
||
| 193 | 199 | <ul class="floatleft" id="top_info"> |
| 194 | 200 | <li> |
| 195 | 201 | <a href="', $scripturl, '?action=profile"', !empty($context['self_profile']) ? ' class="active"' : '', ' id="profile_menu_top" onclick="return false;">'; |
| 196 | - if (!empty($context['user']['avatar'])) |
|
| 197 | - echo $context['user']['avatar']['image']; |
|
| 202 | + if (!empty($context['user']['avatar'])) { |
|
| 203 | + echo $context['user']['avatar']['image']; |
|
| 204 | + } |
|
| 198 | 205 | |
| 199 | 206 | echo $context['user']['name'], '</a> |
| 200 | 207 | <div id="profile_menu" class="top_menu"></div> |
@@ -223,17 +230,18 @@ discard block |
||
| 223 | 230 | } |
| 224 | 231 | // Otherwise they're a guest. Ask them to either register or login. |
| 225 | 232 | else |
| 226 | - if (empty($maintenance)) |
|
| 227 | - echo ' |
|
| 233 | + if (empty($maintenance)) { |
|
| 234 | + echo ' |
|
| 228 | 235 | <ul class="floatleft welcome"> |
| 229 | 236 | <li>', sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'), '</li> |
| 230 | 237 | </ul>'; |
| 231 | - else |
|
| 232 | - // In maintenance mode, only login is allowed and don't show OverlayDiv |
|
| 238 | + } else { |
|
| 239 | + // In maintenance mode, only login is allowed and don't show OverlayDiv |
|
| 233 | 240 | echo ' |
| 234 | 241 | <ul class="floatleft welcome"> |
| 235 | 242 | <li>', sprintf($txt['welcome_guest'], $txt['guest_title'], '', $scripturl. '?action=login', 'return true;'), '</li> |
| 236 | 243 | </ul>'; |
| 244 | + } |
|
| 237 | 245 | |
| 238 | 246 | if (!empty($modSettings['userLanguage']) && !empty($context['languages']) && count($context['languages']) > 1) |
| 239 | 247 | { |
@@ -241,9 +249,10 @@ discard block |
||
| 241 | 249 | <form id="languages_form" method="get" class="floatright"> |
| 242 | 250 | <select id="language_select" name="language" onchange="this.form.submit()">'; |
| 243 | 251 | |
| 244 | - foreach ($context['languages'] as $language) |
|
| 245 | - echo ' |
|
| 252 | + foreach ($context['languages'] as $language) { |
|
| 253 | + echo ' |
|
| 246 | 254 | <option value="', $language['filename'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' selected="selected"' : '', '>', str_replace('-utf8', '', $language['name']), '</option>'; |
| 255 | + } |
|
| 247 | 256 | |
| 248 | 257 | echo ' |
| 249 | 258 | </select> |
@@ -267,31 +276,36 @@ discard block |
||
| 267 | 276 | <option value="all"', ($selected == 'all' ? ' selected' : ''), '>', $txt['search_entireforum'], ' </option>'; |
| 268 | 277 | |
| 269 | 278 | // Can't limit it to a specific topic if we are not in one |
| 270 | - if (!empty($context['current_topic'])) |
|
| 271 | - echo ' |
|
| 279 | + if (!empty($context['current_topic'])) { |
|
| 280 | + echo ' |
|
| 272 | 281 | <option value="topic"', ($selected == 'current_topic' ? ' selected' : ''), '>', $txt['search_thistopic'], '</option>'; |
| 282 | + } |
|
| 273 | 283 | |
| 274 | 284 | // Can't limit it to a specific board if we are not in one |
| 275 | - if (!empty($context['current_board'])) |
|
| 276 | - echo ' |
|
| 285 | + if (!empty($context['current_board'])) { |
|
| 286 | + echo ' |
|
| 277 | 287 | <option value="board"', ($selected == 'current_board' ? ' selected' : ''), '>', $txt['search_thisbrd'], '</option>'; |
| 288 | + } |
|
| 278 | 289 | |
| 279 | 290 | // Can't search for members if we can't see the memberlist |
| 280 | - if (!empty($context['allow_memberlist'])) |
|
| 281 | - echo ' |
|
| 291 | + if (!empty($context['allow_memberlist'])) { |
|
| 292 | + echo ' |
|
| 282 | 293 | <option value="members"', ($selected == 'members' ? ' selected' : ''), '>', $txt['search_members'], ' </option>'; |
| 294 | + } |
|
| 283 | 295 | |
| 284 | 296 | echo ' |
| 285 | 297 | </select>'; |
| 286 | 298 | |
| 287 | 299 | // Search within current topic? |
| 288 | - if (!empty($context['current_topic'])) |
|
| 289 | - echo ' |
|
| 300 | + if (!empty($context['current_topic'])) { |
|
| 301 | + echo ' |
|
| 290 | 302 | <input type="hidden" name="sd_topic" value="', $context['current_topic'], '">'; |
| 303 | + } |
|
| 291 | 304 | // If we're on a certain board, limit it to this board ;). |
| 292 | - elseif (!empty($context['current_board'])) |
|
| 293 | - echo ' |
|
| 305 | + elseif (!empty($context['current_board'])) { |
|
| 306 | + echo ' |
|
| 294 | 307 | <input type="hidden" name="sd_brd" value="', $context['current_board'], '">'; |
| 308 | + } |
|
| 295 | 309 | |
| 296 | 310 | echo ' |
| 297 | 311 | <input type="submit" name="search2" value="', $txt['search'], '" class="button"> |
@@ -323,12 +337,13 @@ discard block |
||
| 323 | 337 | </div>'; |
| 324 | 338 | |
| 325 | 339 | // Show a random news item? (or you could pick one from news_lines...) |
| 326 | - if (!empty($settings['enable_news']) && !empty($context['random_news_line'])) |
|
| 327 | - echo ' |
|
| 340 | + if (!empty($settings['enable_news']) && !empty($context['random_news_line'])) { |
|
| 341 | + echo ' |
|
| 328 | 342 | <div class="news"> |
| 329 | 343 | <h2>', $txt['news'], ': </h2> |
| 330 | 344 | <p>', $context['random_news_line'], '</p> |
| 331 | 345 | </div>'; |
| 346 | + } |
|
| 332 | 347 | |
| 333 | 348 | echo ' |
| 334 | 349 | <hr class="clear"> |
@@ -389,9 +404,10 @@ discard block |
||
| 389 | 404 | </ul>'; |
| 390 | 405 | |
| 391 | 406 | // Show the load time? |
| 392 | - if ($context['show_load_time']) |
|
| 393 | - echo ' |
|
| 407 | + if ($context['show_load_time']) { |
|
| 408 | + echo ' |
|
| 394 | 409 | <p>', sprintf($txt['page_created_full'], $context['load_time'], $context['load_queries']), '</p>'; |
| 410 | + } |
|
| 395 | 411 | |
| 396 | 412 | echo ' |
| 397 | 413 | </div> |
@@ -422,18 +438,20 @@ discard block |
||
| 422 | 438 | global $context, $shown_linktree, $scripturl, $txt; |
| 423 | 439 | |
| 424 | 440 | // If linktree is empty, just return - also allow an override. |
| 425 | - if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show)) |
|
| 426 | - return; |
|
| 441 | + if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show)) { |
|
| 442 | + return; |
|
| 443 | + } |
|
| 427 | 444 | echo ' |
| 428 | 445 | <div class="navigate_section"> |
| 429 | 446 | <ul>'; |
| 430 | 447 | |
| 431 | - if ($context['user']['is_logged']) |
|
| 432 | - echo ' |
|
| 448 | + if ($context['user']['is_logged']) { |
|
| 449 | + echo ' |
|
| 433 | 450 | <li class="unread_links"> |
| 434 | 451 | <a href="', $scripturl, '?action=unread" title="', $txt['unread_since_visit'], '">', $txt['view_unread_category'], '</a> |
| 435 | 452 | <a href="', $scripturl, '?action=unreadreplies" title="', $txt['show_unread_replies'], '">', $txt['unread_replies'], '</a> |
| 436 | 453 | </li>'; |
| 454 | + } |
|
| 437 | 455 | |
| 438 | 456 | // Each tree item has a URL and name. Some may have extra_before and extra_after. |
| 439 | 457 | foreach ($context['linktree'] as $link_num => $tree) |
@@ -444,25 +462,29 @@ discard block |
||
| 444 | 462 | // Don't show a separator for the first one. |
| 445 | 463 | // Better here. Always points to the next level when the linktree breaks to a second line. |
| 446 | 464 | // Picked a better looking HTML entity, and added support for RTL plus a span for styling. |
| 447 | - if ($link_num != 0) |
|
| 448 | - echo ' |
|
| 465 | + if ($link_num != 0) { |
|
| 466 | + echo ' |
|
| 449 | 467 | <span class="dividers">', $context['right_to_left'] ? ' ◄ ' : ' ► ', '</span>'; |
| 468 | + } |
|
| 450 | 469 | |
| 451 | 470 | // Show something before the link? |
| 452 | - if (isset($tree['extra_before'])) |
|
| 453 | - echo $tree['extra_before'], ' '; |
|
| 471 | + if (isset($tree['extra_before'])) { |
|
| 472 | + echo $tree['extra_before'], ' '; |
|
| 473 | + } |
|
| 454 | 474 | |
| 455 | 475 | // Show the link, including a URL if it should have one. |
| 456 | - if (isset($tree['url'])) |
|
| 457 | - echo ' |
|
| 476 | + if (isset($tree['url'])) { |
|
| 477 | + echo ' |
|
| 458 | 478 | <a href="' . $tree['url'] . '"><span>' . $tree['name'] . '</span></a>'; |
| 459 | - else |
|
| 460 | - echo ' |
|
| 479 | + } else { |
|
| 480 | + echo ' |
|
| 461 | 481 | <span>' . $tree['name'] . '</span>'; |
| 482 | + } |
|
| 462 | 483 | |
| 463 | 484 | // Show something after the link...? |
| 464 | - if (isset($tree['extra_after'])) |
|
| 465 | - echo ' ', $tree['extra_after']; |
|
| 485 | + if (isset($tree['extra_after'])) { |
|
| 486 | + echo ' ', $tree['extra_after']; |
|
| 487 | + } |
|
| 466 | 488 | |
| 467 | 489 | echo ' |
| 468 | 490 | </li>'; |
@@ -513,13 +535,14 @@ discard block |
||
| 513 | 535 | echo ' |
| 514 | 536 | <ul>'; |
| 515 | 537 | |
| 516 | - foreach ($childbutton['sub_buttons'] as $grandchildbutton) |
|
| 517 | - echo ' |
|
| 538 | + foreach ($childbutton['sub_buttons'] as $grandchildbutton) { |
|
| 539 | + echo ' |
|
| 518 | 540 | <li> |
| 519 | 541 | <a href="', $grandchildbutton['href'], '"', isset($grandchildbutton['target']) ? ' target="' . $grandchildbutton['target'] . '"' : '', '> |
| 520 | 542 | ', $grandchildbutton['title'], ' |
| 521 | 543 | </a> |
| 522 | 544 | </li>'; |
| 545 | + } |
|
| 523 | 546 | |
| 524 | 547 | echo ' |
| 525 | 548 | </ul>'; |
@@ -550,8 +573,9 @@ discard block |
||
| 550 | 573 | { |
| 551 | 574 | global $context, $txt; |
| 552 | 575 | |
| 553 | - if (!is_array($strip_options)) |
|
| 554 | - $strip_options = array(); |
|
| 576 | + if (!is_array($strip_options)) { |
|
| 577 | + $strip_options = array(); |
|
| 578 | + } |
|
| 555 | 579 | |
| 556 | 580 | // Create the buttons... |
| 557 | 581 | $buttons = array(); |
@@ -560,8 +584,9 @@ discard block |
||
| 560 | 584 | // As of 2.1, the 'test' for each button happens while the array is being generated. The extra 'test' check here is deprecated but kept for backward compatibility (update your mods, folks!) |
| 561 | 585 | if (!isset($value['test']) || !empty($context[$value['test']])) |
| 562 | 586 | { |
| 563 | - if (!isset($value['id'])) |
|
| 564 | - $value['id'] = $key; |
|
| 587 | + if (!isset($value['id'])) { |
|
| 588 | + $value['id'] = $key; |
|
| 589 | + } |
|
| 565 | 590 | |
| 566 | 591 | $button = ' |
| 567 | 592 | <a class="button button_strip_' . $key . (!empty($value['active']) ? ' active' : '') . (isset($value['class']) ? ' ' . $value['class'] : '') . '" ' . (!empty($value['url']) ? 'href="' . $value['url'] . '"' : '') . ' ' . (isset($value['custom']) ? ' ' . $value['custom'] : '') . '>' . $txt[$value['text']] . '</a>'; |
@@ -574,13 +599,15 @@ discard block |
||
| 574 | 599 | <div class="overview">'; |
| 575 | 600 | foreach ($value['sub_buttons'] as $element) |
| 576 | 601 | { |
| 577 | - if (isset($element['test']) && empty($context[$element['test']])) |
|
| 578 | - continue; |
|
| 602 | + if (isset($element['test']) && empty($context[$element['test']])) { |
|
| 603 | + continue; |
|
| 604 | + } |
|
| 579 | 605 | |
| 580 | 606 | $button .= ' |
| 581 | 607 | <a href="' . $element['url'] . '"><strong>' . $txt[$element['text']] . '</strong>'; |
| 582 | - if (isset($txt[$element['text'] . '_desc'])) |
|
| 583 | - $button .= '<br><span>' . $txt[$element['text'] . '_desc'] . '</span>'; |
|
| 608 | + if (isset($txt[$element['text'] . '_desc'])) { |
|
| 609 | + $button .= '<br><span>' . $txt[$element['text'] . '_desc'] . '</span>'; |
|
| 610 | + } |
|
| 584 | 611 | $button .= '</a>'; |
| 585 | 612 | } |
| 586 | 613 | $button .= ' |
@@ -594,8 +621,9 @@ discard block |
||
| 594 | 621 | } |
| 595 | 622 | |
| 596 | 623 | // No buttons? No button strip either. |
| 597 | - if (empty($buttons)) |
|
| 598 | - return; |
|
| 624 | + if (empty($buttons)) { |
|
| 625 | + return; |
|
| 626 | + } |
|
| 599 | 627 | |
| 600 | 628 | echo ' |
| 601 | 629 | <div class="buttonlist', !empty($direction) ? ' float' . $direction : '', '"', (empty($buttons) ? ' style="display: none;"' : ''), (!empty($strip_options['id']) ? ' id="' . $strip_options['id'] . '"' : ''), '> |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Fetches a list of boards and (optional) categories including |
@@ -37,11 +38,12 @@ discard block |
||
| 37 | 38 | require_once($sourcedir . '/Subs-Boards.php'); |
| 38 | 39 | |
| 39 | 40 | // For performance, track the latest post while going through the boards. |
| 40 | - if (!empty($boardIndexOptions['set_latest_post'])) |
|
| 41 | - $latest_post = array( |
|
| 41 | + if (!empty($boardIndexOptions['set_latest_post'])) { |
|
| 42 | + $latest_post = array( |
|
| 42 | 43 | 'timestamp' => 0, |
| 43 | 44 | 'ref' => 0, |
| 44 | 45 | ); |
| 46 | + } |
|
| 45 | 47 | |
| 46 | 48 | // Find all boards and categories, as well as related information. This will be sorted by the natural order of boards and categories, which we control. |
| 47 | 49 | $result_boards = $smcFunc['db_query']('', ' |
@@ -74,10 +76,11 @@ discard block |
||
| 74 | 76 | ); |
| 75 | 77 | |
| 76 | 78 | // Start with an empty array. |
| 77 | - if ($boardIndexOptions['include_categories']) |
|
| 78 | - $categories = array(); |
|
| 79 | - else |
|
| 80 | - $this_category = array(); |
|
| 79 | + if ($boardIndexOptions['include_categories']) { |
|
| 80 | + $categories = array(); |
|
| 81 | + } else { |
|
| 82 | + $this_category = array(); |
|
| 83 | + } |
|
| 81 | 84 | $boards = array(); |
| 82 | 85 | |
| 83 | 86 | // Run through the categories and boards (or only boards).... |
@@ -88,8 +91,9 @@ discard block |
||
| 88 | 91 | $row_board['is_read'] = !empty($row_board['is_read']) || $ignoreThisBoard ? '1' : '0'; |
| 89 | 92 | |
| 90 | 93 | // Add parent boards to the $boards list later used to fetch moderators |
| 91 | - if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) |
|
| 92 | - $boards[] = $row_board['id_board']; |
|
| 94 | + if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) { |
|
| 95 | + $boards[] = $row_board['id_board']; |
|
| 96 | + } |
|
| 93 | 97 | |
| 94 | 98 | if ($boardIndexOptions['include_categories']) |
| 95 | 99 | { |
@@ -111,8 +115,9 @@ discard block |
||
| 111 | 115 | } |
| 112 | 116 | |
| 113 | 117 | // If this board has new posts in it (and isn't the recycle bin!) then the category is new. |
| 114 | - if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) |
|
| 115 | - $categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']) && $row_board['poster_name'] != ''; |
|
| 118 | + if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) { |
|
| 119 | + $categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']) && $row_board['poster_name'] != ''; |
|
| 120 | + } |
|
| 116 | 121 | |
| 117 | 122 | // Avoid showing category unread link where it only has redirection boards. |
| 118 | 123 | $categories[$row_board['id_cat']]['show_unread'] = !empty($categories[$row_board['id_cat']]['show_unread']) ? 1 : !$row_board['is_redirect']; |
@@ -161,14 +166,12 @@ discard block |
||
| 161 | 166 | { |
| 162 | 167 | $this_category[$row_board['id_board']]['board_class'] = 'redirect'; |
| 163 | 168 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['redirect_board']; |
| 164 | - } |
|
| 165 | - elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest']) |
|
| 169 | + } elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest']) |
|
| 166 | 170 | { |
| 167 | 171 | // If we're showing to guests, we want to give them the idea that something interesting is going on! |
| 168 | 172 | $this_category[$row_board['id_board']]['board_class'] = 'on'; |
| 169 | 173 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['new_posts']; |
| 170 | - } |
|
| 171 | - else |
|
| 174 | + } else |
|
| 172 | 175 | { |
| 173 | 176 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['old_posts']; |
| 174 | 177 | } |
@@ -219,14 +222,16 @@ discard block |
||
| 219 | 222 | // Child of a child... just add it on... |
| 220 | 223 | elseif (!empty($boardIndexOptions['countChildPosts'])) |
| 221 | 224 | { |
| 222 | - if (!isset($parent_map)) |
|
| 223 | - $parent_map = array(); |
|
| 225 | + if (!isset($parent_map)) { |
|
| 226 | + $parent_map = array(); |
|
| 227 | + } |
|
| 224 | 228 | |
| 225 | - if (!isset($parent_map[$row_board['id_parent']])) |
|
| 226 | - foreach ($this_category as $id => $board) |
|
| 229 | + if (!isset($parent_map[$row_board['id_parent']])) { |
|
| 230 | + foreach ($this_category as $id => $board) |
|
| 227 | 231 | { |
| 228 | 232 | if (!isset($board['children'][$row_board['id_parent']])) |
| 229 | 233 | continue; |
| 234 | + } |
|
| 230 | 235 | |
| 231 | 236 | $parent_map[$row_board['id_parent']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]); |
| 232 | 237 | $parent_map[$row_board['id_board']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]); |
@@ -247,8 +252,9 @@ discard block |
||
| 247 | 252 | continue; |
| 248 | 253 | } |
| 249 | 254 | // Found a child of a child - skip. |
| 250 | - else |
|
| 251 | - continue; |
|
| 255 | + else { |
|
| 256 | + continue; |
|
| 257 | + } |
|
| 252 | 258 | |
| 253 | 259 | // Prepare the subject, and make sure it's not too long. |
| 254 | 260 | censorText($row_board['subject']); |
@@ -269,12 +275,13 @@ discard block |
||
| 269 | 275 | 'topic' => $row_board['id_topic'] |
| 270 | 276 | ); |
| 271 | 277 | |
| 272 | - if (!empty($settings['avatars_on_boardIndex'])) |
|
| 273 | - $this_last_post['member']['avatar'] = set_avatar_data(array( |
|
| 278 | + if (!empty($settings['avatars_on_boardIndex'])) { |
|
| 279 | + $this_last_post['member']['avatar'] = set_avatar_data(array( |
|
| 274 | 280 | 'avatar' => $row_board['avatar'], |
| 275 | 281 | 'email' => $row_board['email_address'], |
| 276 | 282 | 'filename' => !empty($row_board['member_filename']) ? $row_board['member_filename'] : '', |
| 277 | 283 | )); |
| 284 | + } |
|
| 278 | 285 | |
| 279 | 286 | // Provide the href and link. |
| 280 | 287 | if ($row_board['subject'] != '') |
@@ -286,8 +293,7 @@ discard block |
||
| 286 | 293 | link, href, subject, start (where they should go for the first unread post.), |
| 287 | 294 | and member. (which has id, name, link, href, username in it.) */ |
| 288 | 295 | $this_last_post['last_post_message'] = sprintf($txt['last_post_message'], $this_last_post['member']['link'], $this_last_post['link'], $this_last_post['time']); |
| 289 | - } |
|
| 290 | - else |
|
| 296 | + } else |
|
| 291 | 297 | { |
| 292 | 298 | $this_last_post['href'] = ''; |
| 293 | 299 | $this_last_post['link'] = $txt['not_applicable']; |
@@ -295,8 +301,9 @@ discard block |
||
| 295 | 301 | } |
| 296 | 302 | |
| 297 | 303 | // Set the last post in the parent board. |
| 298 | - if ($row_board['id_parent'] == $boardIndexOptions['parent_id'] || ($isChild && !empty($row_board['poster_time']) && $this_category[$row_board['id_parent']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time']))) |
|
| 299 | - $this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post; |
|
| 304 | + if ($row_board['id_parent'] == $boardIndexOptions['parent_id'] || ($isChild && !empty($row_board['poster_time']) && $this_category[$row_board['id_parent']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time']))) { |
|
| 305 | + $this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post; |
|
| 306 | + } |
|
| 300 | 307 | // Just in the child...? |
| 301 | 308 | if ($isChild) |
| 302 | 309 | { |
@@ -306,15 +313,17 @@ discard block |
||
| 306 | 313 | $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['new'] &= $row_board['poster_name'] != ''; |
| 307 | 314 | } |
| 308 | 315 | // No last post for this board? It's not new then, is it..? |
| 309 | - elseif ($row_board['poster_name'] == '') |
|
| 310 | - $this_category[$row_board['id_board']]['new'] = false; |
|
| 316 | + elseif ($row_board['poster_name'] == '') { |
|
| 317 | + $this_category[$row_board['id_board']]['new'] = false; |
|
| 318 | + } |
|
| 311 | 319 | |
| 312 | 320 | // Determine a global most recent topic. |
| 313 | - if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) |
|
| 314 | - $latest_post = array( |
|
| 321 | + if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) { |
|
| 322 | + $latest_post = array( |
|
| 315 | 323 | 'timestamp' => $row_board['poster_time'], |
| 316 | 324 | 'ref' => &$this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'], |
| 317 | 325 | ); |
| 326 | + } |
|
| 318 | 327 | } |
| 319 | 328 | $smcFunc['db_free_result']($result_boards); |
| 320 | 329 | |
@@ -331,8 +340,9 @@ discard block |
||
| 331 | 340 | if (!empty($moderators[$board['id']])) |
| 332 | 341 | { |
| 333 | 342 | $categories[$k]['boards'][$j]['moderators'] = $moderators[$board['id']]; |
| 334 | - foreach ($moderators[$board['id']] as $moderator) |
|
| 335 | - $categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link']; |
|
| 343 | + foreach ($moderators[$board['id']] as $moderator) { |
|
| 344 | + $categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link']; |
|
| 345 | + } |
|
| 336 | 346 | } |
| 337 | 347 | if (!empty($groups[$board['id']])) |
| 338 | 348 | { |
@@ -345,16 +355,16 @@ discard block |
||
| 345 | 355 | } |
| 346 | 356 | } |
| 347 | 357 | } |
| 348 | - } |
|
| 349 | - else |
|
| 358 | + } else |
|
| 350 | 359 | { |
| 351 | 360 | foreach ($this_category as $k => $board) |
| 352 | 361 | { |
| 353 | 362 | if (!empty($moderators[$board['id']])) |
| 354 | 363 | { |
| 355 | 364 | $this_category[$k]['moderators'] = $moderators[$board['id']]; |
| 356 | - foreach ($moderators[$board['id']] as $moderator) |
|
| 357 | - $this_category[$k]['link_moderators'][] = $moderator['link']; |
|
| 365 | + foreach ($moderators[$board['id']] as $moderator) { |
|
| 366 | + $this_category[$k]['link_moderators'][] = $moderator['link']; |
|
| 367 | + } |
|
| 358 | 368 | } |
| 359 | 369 | if (!empty($groups[$board['id']])) |
| 360 | 370 | { |
@@ -368,20 +378,23 @@ discard block |
||
| 368 | 378 | } |
| 369 | 379 | } |
| 370 | 380 | |
| 371 | - if ($boardIndexOptions['include_categories']) |
|
| 372 | - sortCategories($categories); |
|
| 373 | - else |
|
| 374 | - sortBoards($this_category); |
|
| 381 | + if ($boardIndexOptions['include_categories']) { |
|
| 382 | + sortCategories($categories); |
|
| 383 | + } else { |
|
| 384 | + sortBoards($this_category); |
|
| 385 | + } |
|
| 375 | 386 | |
| 376 | 387 | // By now we should know the most recent post...if we wanna know it that is. |
| 377 | - if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) |
|
| 378 | - $context['latest_post'] = $latest_post['ref']; |
|
| 388 | + if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) { |
|
| 389 | + $context['latest_post'] = $latest_post['ref']; |
|
| 390 | + } |
|
| 379 | 391 | |
| 380 | 392 | // I can't remember why but trying to make a ternary to get this all in one line is actually a Very Bad Idea. |
| 381 | - if ($boardIndexOptions['include_categories']) |
|
| 382 | - call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories)); |
|
| 383 | - else |
|
| 384 | - call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category)); |
|
| 393 | + if ($boardIndexOptions['include_categories']) { |
|
| 394 | + call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories)); |
|
| 395 | + } else { |
|
| 396 | + call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category)); |
|
| 397 | + } |
|
| 385 | 398 | |
| 386 | 399 | return $boardIndexOptions['include_categories'] ? $categories : $this_category; |
| 387 | 400 | } |