@@ -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 | } |
@@ -297,15 +300,16 @@ discard block |
||
| 297 | 300 | ); |
| 298 | 301 | |
| 299 | 302 | // Handle labels. |
| 300 | - if (empty($context['currently_using_labels'])) |
|
| 301 | - unset($pm_areas['labels']); |
|
| 302 | - else |
|
| 303 | + if (empty($context['currently_using_labels'])) { |
|
| 304 | + unset($pm_areas['labels']); |
|
| 305 | + } else |
|
| 303 | 306 | { |
| 304 | 307 | // Note we send labels by id as it will have less problems in the querystring. |
| 305 | 308 | foreach ($context['labels'] as $label) |
| 306 | 309 | { |
| 307 | - if ($label['id'] == -1) |
|
| 308 | - continue; |
|
| 310 | + if ($label['id'] == -1) { |
|
| 311 | + continue; |
|
| 312 | + } |
|
| 309 | 313 | |
| 310 | 314 | // Count the amount of unread items in labels. |
| 311 | 315 | $pm_areas['labels']['amt'] += $label['unread_messages']; |
@@ -356,8 +360,9 @@ discard block |
||
| 356 | 360 | unset($pm_areas); |
| 357 | 361 | |
| 358 | 362 | // No menu means no access. |
| 359 | - if (!$pm_include_data && (!$user_info['is_guest'] || validateSession())) |
|
| 360 | - fatal_lang_error('no_access', false); |
|
| 363 | + if (!$pm_include_data && (!$user_info['is_guest'] || validateSession())) { |
|
| 364 | + fatal_lang_error('no_access', false); |
|
| 365 | + } |
|
| 361 | 366 | |
| 362 | 367 | // Make a note of the Unique ID for this menu. |
| 363 | 368 | $context['pm_menu_id'] = $context['max_menu_id']; |
@@ -368,9 +373,10 @@ discard block |
||
| 368 | 373 | $context['menu_item_selected'] = $current_area; |
| 369 | 374 | |
| 370 | 375 | // Set the template for this area and add the profile layer. |
| 371 | - if (!isset($_REQUEST['xml'])) |
|
| 372 | - $context['template_layers'][] = 'pm'; |
|
| 373 | -} |
|
| 376 | + if (!isset($_REQUEST['xml'])) { |
|
| 377 | + $context['template_layers'][] = 'pm'; |
|
| 378 | + } |
|
| 379 | + } |
|
| 374 | 380 | |
| 375 | 381 | /** |
| 376 | 382 | * The popup for when we ask for the popup from the user. |
@@ -402,8 +408,9 @@ discard block |
||
| 402 | 408 | ) |
| 403 | 409 | ); |
| 404 | 410 | $pms = array(); |
| 405 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 406 | - $pms[] = $row[0]; |
|
| 411 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 412 | + $pms[] = $row[0]; |
|
| 413 | + } |
|
| 407 | 414 | $smcFunc['db_free_result']($request); |
| 408 | 415 | |
| 409 | 416 | if (!empty($pms)) |
@@ -431,8 +438,9 @@ discard block |
||
| 431 | 438 | ); |
| 432 | 439 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 433 | 440 | { |
| 434 | - if (!empty($row['id_member_from'])) |
|
| 435 | - $senders[] = $row['id_member_from']; |
|
| 441 | + if (!empty($row['id_member_from'])) { |
|
| 442 | + $senders[] = $row['id_member_from']; |
|
| 443 | + } |
|
| 436 | 444 | |
| 437 | 445 | $row['replied_to_you'] = $row['id_pm'] != $row['id_pm_head']; |
| 438 | 446 | $row['time'] = timeformat($row['timestamp']); |
@@ -442,13 +450,15 @@ discard block |
||
| 442 | 450 | $smcFunc['db_free_result']($request); |
| 443 | 451 | |
| 444 | 452 | $senders = loadMemberData($senders); |
| 445 | - foreach ($senders as $member) |
|
| 446 | - loadMemberContext($member); |
|
| 453 | + foreach ($senders as $member) { |
|
| 454 | + loadMemberContext($member); |
|
| 455 | + } |
|
| 447 | 456 | |
| 448 | 457 | // Having loaded everyone, attach them to the PMs. |
| 449 | - foreach ($context['unread_pms'] as $id_pm => $details) |
|
| 450 | - if (!empty($memberContext[$details['id_member_from']])) |
|
| 458 | + foreach ($context['unread_pms'] as $id_pm => $details) { |
|
| 459 | + if (!empty($memberContext[$details['id_member_from']])) |
|
| 451 | 460 | $context['unread_pms'][$id_pm]['member'] = &$memberContext[$details['id_member_from']]; |
| 461 | + } |
|
| 452 | 462 | } |
| 453 | 463 | } |
| 454 | 464 | |
@@ -468,12 +478,13 @@ discard block |
||
| 468 | 478 | } |
| 469 | 479 | |
| 470 | 480 | // Make sure the starting location is valid. |
| 471 | - if (isset($_GET['start']) && $_GET['start'] != 'new') |
|
| 472 | - $_GET['start'] = (int) $_GET['start']; |
|
| 473 | - elseif (!isset($_GET['start']) && !empty($options['view_newest_pm_first'])) |
|
| 474 | - $_GET['start'] = 0; |
|
| 475 | - else |
|
| 476 | - $_GET['start'] = 'new'; |
|
| 481 | + if (isset($_GET['start']) && $_GET['start'] != 'new') { |
|
| 482 | + $_GET['start'] = (int) $_GET['start']; |
|
| 483 | + } elseif (!isset($_GET['start']) && !empty($options['view_newest_pm_first'])) { |
|
| 484 | + $_GET['start'] = 0; |
|
| 485 | + } else { |
|
| 486 | + $_GET['start'] = 'new'; |
|
| 487 | + } |
|
| 477 | 488 | |
| 478 | 489 | // Set up some basic theme stuff. |
| 479 | 490 | $context['from_or_to'] = $context['folder'] != 'sent' ? 'from' : 'to'; |
@@ -487,9 +498,10 @@ discard block |
||
| 487 | 498 | list ($sig_limits, $sig_bbc) = explode(':', $modSettings['signature_settings']); |
| 488 | 499 | $sig_limits = explode(',', $sig_limits); |
| 489 | 500 | |
| 490 | - if (!empty($sig_limits[5]) || !empty($sig_limits[6])) |
|
| 491 | - addInlineCss(' |
|
| 501 | + if (!empty($sig_limits[5]) || !empty($sig_limits[6])) { |
|
| 502 | + addInlineCss(' |
|
| 492 | 503 | .signature img { ' . (!empty($sig_limits[5]) ? 'max-width: ' . (int) $sig_limits[5] . 'px; ' : '') . (!empty($sig_limits[6]) ? 'max-height: ' . (int) $sig_limits[6] . 'px; ' : '') . '}'); |
| 504 | + } |
|
| 493 | 505 | } |
| 494 | 506 | |
| 495 | 507 | $labelJoin = ''; |
@@ -501,8 +513,7 @@ discard block |
||
| 501 | 513 | { |
| 502 | 514 | $labelQuery = ' |
| 503 | 515 | AND pmr.in_inbox = 1'; |
| 504 | - } |
|
| 505 | - elseif ($context['folder'] != 'sent') |
|
| 516 | + } elseif ($context['folder'] != 'sent') |
|
| 506 | 517 | { |
| 507 | 518 | $labelJoin = ' |
| 508 | 519 | INNER JOIN {db_prefix}pm_labeled_messages AS pl ON (pl.id_pm = pmr.id_pm)'; |
@@ -544,22 +555,24 @@ discard block |
||
| 544 | 555 | $txt['delete_all'] = str_replace('PMBOX', $pmbox, $txt['delete_all']); |
| 545 | 556 | |
| 546 | 557 | // Now, build the link tree! |
| 547 | - if ($context['current_label_id'] == -1) |
|
| 548 | - $context['linktree'][] = array( |
|
| 558 | + if ($context['current_label_id'] == -1) { |
|
| 559 | + $context['linktree'][] = array( |
|
| 549 | 560 | 'url' => $scripturl . '?action=pm;f=' . $context['folder'], |
| 550 | 561 | 'name' => $pmbox |
| 551 | 562 | ); |
| 563 | + } |
|
| 552 | 564 | |
| 553 | 565 | // Build it further for a label. |
| 554 | - if ($context['current_label_id'] != -1) |
|
| 555 | - $context['linktree'][] = array( |
|
| 566 | + if ($context['current_label_id'] != -1) { |
|
| 567 | + $context['linktree'][] = array( |
|
| 556 | 568 | 'url' => $scripturl . '?action=pm;f=' . $context['folder'] . ';l=' . $context['current_label_id'], |
| 557 | 569 | 'name' => $txt['pm_current_label'] . ': ' . $context['current_label'] |
| 558 | 570 | ); |
| 571 | + } |
|
| 559 | 572 | |
| 560 | 573 | // Figure out how many messages there are. |
| 561 | - if ($context['folder'] == 'sent') |
|
| 562 | - $request = $smcFunc['db_query']('', ' |
|
| 574 | + if ($context['folder'] == 'sent') { |
|
| 575 | + $request = $smcFunc['db_query']('', ' |
|
| 563 | 576 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
| 564 | 577 | FROM {db_prefix}personal_messages AS pm |
| 565 | 578 | WHERE pm.id_member_from = {int:current_member} |
@@ -569,8 +582,8 @@ discard block |
||
| 569 | 582 | 'not_deleted' => 0, |
| 570 | 583 | ) |
| 571 | 584 | ); |
| 572 | - else |
|
| 573 | - $request = $smcFunc['db_query']('', ' |
|
| 585 | + } else { |
|
| 586 | + $request = $smcFunc['db_query']('', ' |
|
| 574 | 587 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
| 575 | 588 | FROM {db_prefix}pm_recipients AS pmr' . ($context['display_mode'] == 2 ? ' |
| 576 | 589 | INNER JOIN {db_prefix}personal_messages AS pm ON (pm.id_pm = pmr.id_pm)' : '') . $labelJoin . ' |
@@ -581,6 +594,7 @@ discard block |
||
| 581 | 594 | 'not_deleted' => 0, |
| 582 | 595 | ) |
| 583 | 596 | ); |
| 597 | + } |
|
| 584 | 598 | list ($max_messages) = $smcFunc['db_fetch_row']($request); |
| 585 | 599 | $smcFunc['db_free_result']($request); |
| 586 | 600 | |
@@ -589,10 +603,11 @@ discard block |
||
| 589 | 603 | $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
| 590 | 604 | |
| 591 | 605 | // Start on the last page. |
| 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; |
|
| 606 | + if (!is_numeric($_GET['start']) || $_GET['start'] >= $max_messages) { |
|
| 607 | + $_GET['start'] = ($max_messages - 1) - (($max_messages - 1) % $maxPerPage); |
|
| 608 | + } elseif ($_GET['start'] < 0) { |
|
| 609 | + $_GET['start'] = 0; |
|
| 610 | + } |
|
| 596 | 611 | |
| 597 | 612 | // ... but wait - what if we want to start from a specific message? |
| 598 | 613 | if (isset($_GET['pmid'])) |
@@ -600,19 +615,21 @@ discard block |
||
| 600 | 615 | $pmID = (int) $_GET['pmid']; |
| 601 | 616 | |
| 602 | 617 | // Make sure you have access to this PM. |
| 603 | - if (!isAccessiblePM($pmID, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) |
|
| 604 | - fatal_lang_error('no_access', false); |
|
| 618 | + if (!isAccessiblePM($pmID, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) { |
|
| 619 | + fatal_lang_error('no_access', false); |
|
| 620 | + } |
|
| 605 | 621 | |
| 606 | 622 | $context['current_pm'] = $pmID; |
| 607 | 623 | |
| 608 | 624 | // With only one page of PM's we're gonna want page 1. |
| 609 | - if ($max_messages <= $maxPerPage) |
|
| 610 | - $_GET['start'] = 0; |
|
| 625 | + if ($max_messages <= $maxPerPage) { |
|
| 626 | + $_GET['start'] = 0; |
|
| 627 | + } |
|
| 611 | 628 | // If we pass kstart we assume we're in the right place. |
| 612 | 629 | elseif (!isset($_GET['kstart'])) |
| 613 | 630 | { |
| 614 | - if ($context['folder'] == 'sent') |
|
| 615 | - $request = $smcFunc['db_query']('', ' |
|
| 631 | + if ($context['folder'] == 'sent') { |
|
| 632 | + $request = $smcFunc['db_query']('', ' |
|
| 616 | 633 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
| 617 | 634 | FROM {db_prefix}personal_messages |
| 618 | 635 | WHERE id_member_from = {int:current_member} |
@@ -624,8 +641,8 @@ discard block |
||
| 624 | 641 | 'id_pm' => $pmID, |
| 625 | 642 | ) |
| 626 | 643 | ); |
| 627 | - else |
|
| 628 | - $request = $smcFunc['db_query']('', ' |
|
| 644 | + } else { |
|
| 645 | + $request = $smcFunc['db_query']('', ' |
|
| 629 | 646 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
| 630 | 647 | FROM {db_prefix}pm_recipients AS pmr' . ($context['display_mode'] == 2 ? ' |
| 631 | 648 | INNER JOIN {db_prefix}personal_messages AS pm ON (pm.id_pm = pmr.id_pm)' : '') . $labelJoin . ' |
@@ -638,6 +655,7 @@ discard block |
||
| 638 | 655 | 'id_pm' => $pmID, |
| 639 | 656 | ) |
| 640 | 657 | ); |
| 658 | + } |
|
| 641 | 659 | |
| 642 | 660 | list ($_GET['start']) = $smcFunc['db_fetch_row']($request); |
| 643 | 661 | $smcFunc['db_free_result']($request); |
@@ -652,8 +670,9 @@ discard block |
||
| 652 | 670 | { |
| 653 | 671 | $pmsg = (int) $_GET['pmsg']; |
| 654 | 672 | |
| 655 | - if (!isAccessiblePM($pmsg, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) |
|
| 656 | - fatal_lang_error('no_access', false); |
|
| 673 | + if (!isAccessiblePM($pmsg, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) { |
|
| 674 | + fatal_lang_error('no_access', false); |
|
| 675 | + } |
|
| 657 | 676 | } |
| 658 | 677 | |
| 659 | 678 | // Set up the page index. |
@@ -747,8 +766,9 @@ discard block |
||
| 747 | 766 | { |
| 748 | 767 | if (!isset($recipients[$row['id_pm']])) |
| 749 | 768 | { |
| 750 | - if (isset($row['id_member_from'])) |
|
| 751 | - $posters[$row['id_pm']] = $row['id_member_from']; |
|
| 769 | + if (isset($row['id_member_from'])) { |
|
| 770 | + $posters[$row['id_pm']] = $row['id_member_from']; |
|
| 771 | + } |
|
| 752 | 772 | $pms[$row['id_pm']] = $row['id_pm']; |
| 753 | 773 | $recipients[$row['id_pm']] = array( |
| 754 | 774 | 'to' => array(), |
@@ -757,29 +777,33 @@ discard block |
||
| 757 | 777 | } |
| 758 | 778 | |
| 759 | 779 | // Keep track of the last message so we know what the head is without another query! |
| 760 | - if ((empty($pmID) && (empty($options['view_newest_pm_first']) || !isset($lastData))) || empty($lastData) || (!empty($pmID) && $pmID == $row['id_pm'])) |
|
| 761 | - $lastData = array( |
|
| 780 | + if ((empty($pmID) && (empty($options['view_newest_pm_first']) || !isset($lastData))) || empty($lastData) || (!empty($pmID) && $pmID == $row['id_pm'])) { |
|
| 781 | + $lastData = array( |
|
| 762 | 782 | 'id' => $row['id_pm'], |
| 763 | 783 | 'head' => $row['id_pm_head'], |
| 764 | 784 | ); |
| 785 | + } |
|
| 765 | 786 | } |
| 766 | 787 | $smcFunc['db_free_result']($request); |
| 767 | 788 | |
| 768 | 789 | // Make sure that we have been given a correct head pm id! |
| 769 | - if ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id']) |
|
| 770 | - fatal_lang_error('no_access', false); |
|
| 790 | + if ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id']) { |
|
| 791 | + fatal_lang_error('no_access', false); |
|
| 792 | + } |
|
| 771 | 793 | |
| 772 | 794 | if (!empty($pms)) |
| 773 | 795 | { |
| 774 | 796 | // Select the correct current message. |
| 775 | - if (empty($pmID)) |
|
| 776 | - $context['current_pm'] = $lastData['id']; |
|
| 797 | + if (empty($pmID)) { |
|
| 798 | + $context['current_pm'] = $lastData['id']; |
|
| 799 | + } |
|
| 777 | 800 | |
| 778 | 801 | // This is a list of the pm's that are used for "full" display. |
| 779 | - if ($context['display_mode'] == 0) |
|
| 780 | - $display_pms = $pms; |
|
| 781 | - else |
|
| 782 | - $display_pms = array($context['current_pm']); |
|
| 802 | + if ($context['display_mode'] == 0) { |
|
| 803 | + $display_pms = $pms; |
|
| 804 | + } else { |
|
| 805 | + $display_pms = array($context['current_pm']); |
|
| 806 | + } |
|
| 783 | 807 | |
| 784 | 808 | // At this point we know the main id_pm's. But - if we are looking at conversations we need the others! |
| 785 | 809 | if ($context['display_mode'] == 2) |
@@ -801,16 +825,18 @@ discard block |
||
| 801 | 825 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 802 | 826 | { |
| 803 | 827 | // This is, frankly, a joke. We will put in a workaround for people sending to themselves - yawn! |
| 804 | - if ($context['folder'] == 'sent' && $row['id_member_from'] == $user_info['id'] && $row['deleted_by_sender'] == 1) |
|
| 805 | - continue; |
|
| 806 | - elseif ($row['id_member'] == $user_info['id'] & $row['deleted'] == 1) |
|
| 807 | - continue; |
|
| 828 | + if ($context['folder'] == 'sent' && $row['id_member_from'] == $user_info['id'] && $row['deleted_by_sender'] == 1) { |
|
| 829 | + continue; |
|
| 830 | + } elseif ($row['id_member'] == $user_info['id'] & $row['deleted'] == 1) { |
|
| 831 | + continue; |
|
| 832 | + } |
|
| 808 | 833 | |
| 809 | - if (!isset($recipients[$row['id_pm']])) |
|
| 810 | - $recipients[$row['id_pm']] = array( |
|
| 834 | + if (!isset($recipients[$row['id_pm']])) { |
|
| 835 | + $recipients[$row['id_pm']] = array( |
|
| 811 | 836 | 'to' => array(), |
| 812 | 837 | 'bcc' => array() |
| 813 | 838 | ); |
| 839 | + } |
|
| 814 | 840 | $display_pms[] = $row['id_pm']; |
| 815 | 841 | $posters[$row['id_pm']] = $row['id_member_from']; |
| 816 | 842 | } |
@@ -861,8 +887,9 @@ discard block |
||
| 861 | 887 | while ($row2 = $smcFunc['db_fetch_assoc']($request2)) |
| 862 | 888 | { |
| 863 | 889 | $l_id = $row2['id_label']; |
| 864 | - if (isset($context['labels'][$l_id])) |
|
| 865 | - $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
| 890 | + if (isset($context['labels'][$l_id])) { |
|
| 891 | + $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
| 892 | + } |
|
| 866 | 893 | } |
| 867 | 894 | |
| 868 | 895 | $smcFunc['db_free_result']($request2); |
@@ -879,9 +906,10 @@ discard block |
||
| 879 | 906 | // Make sure we don't load unnecessary data. |
| 880 | 907 | if ($context['display_mode'] == 1) |
| 881 | 908 | { |
| 882 | - foreach ($posters as $k => $v) |
|
| 883 | - if (!in_array($k, $display_pms)) |
|
| 909 | + foreach ($posters as $k => $v) { |
|
| 910 | + if (!in_array($k, $display_pms)) |
|
| 884 | 911 | unset($posters[$k]); |
| 912 | + } |
|
| 885 | 913 | } |
| 886 | 914 | |
| 887 | 915 | // Load any users.... |
@@ -892,8 +920,9 @@ discard block |
||
| 892 | 920 | { |
| 893 | 921 | // Get the order right. |
| 894 | 922 | $orderBy = array(); |
| 895 | - foreach (array_reverse($pms) as $pm) |
|
| 896 | - $orderBy[] = 'pm.id_pm = ' . $pm; |
|
| 923 | + foreach (array_reverse($pms) as $pm) { |
|
| 924 | + $orderBy[] = 'pm.id_pm = ' . $pm; |
|
| 925 | + } |
|
| 897 | 926 | |
| 898 | 927 | // Seperate query for these bits! |
| 899 | 928 | $subjects_request = $smcFunc['db_query']('', ' |
@@ -939,9 +968,9 @@ discard block |
||
| 939 | 968 | // Allow mods to add additional buttons here |
| 940 | 969 | call_integration_hook('integrate_conversation_buttons'); |
| 941 | 970 | } |
| 971 | + } else { |
|
| 972 | + $messages_request = false; |
|
| 942 | 973 | } |
| 943 | - else |
|
| 944 | - $messages_request = false; |
|
| 945 | 974 | |
| 946 | 975 | $context['can_send_pm'] = allowedTo('pm_send'); |
| 947 | 976 | $context['can_send_email'] = allowedTo('moderate_forum'); |
@@ -952,11 +981,13 @@ discard block |
||
| 952 | 981 | if ($context['folder'] != 'sent' && !empty($context['labels'][(int) $context['current_label_id']]['unread_messages'])) |
| 953 | 982 | { |
| 954 | 983 | // If the display mode is "old sk00l" do them all... |
| 955 | - if ($context['display_mode'] == 0) |
|
| 956 | - markMessages(null, $context['current_label_id']); |
|
| 984 | + if ($context['display_mode'] == 0) { |
|
| 985 | + markMessages(null, $context['current_label_id']); |
|
| 986 | + } |
|
| 957 | 987 | // Otherwise do just the current one! |
| 958 | - elseif (!empty($context['current_pm'])) |
|
| 959 | - markMessages($display_pms, $context['current_label_id']); |
|
| 988 | + elseif (!empty($context['current_pm'])) { |
|
| 989 | + markMessages($display_pms, $context['current_label_id']); |
|
| 990 | + } |
|
| 960 | 991 | } |
| 961 | 992 | } |
| 962 | 993 | |
@@ -974,8 +1005,9 @@ discard block |
||
| 974 | 1005 | |
| 975 | 1006 | // Count the current message number.... |
| 976 | 1007 | static $counter = null; |
| 977 | - if ($counter === null || $reset) |
|
| 978 | - $counter = $context['start']; |
|
| 1008 | + if ($counter === null || $reset) { |
|
| 1009 | + $counter = $context['start']; |
|
| 1010 | + } |
|
| 979 | 1011 | |
| 980 | 1012 | static $temp_pm_selected = null; |
| 981 | 1013 | if ($temp_pm_selected === null) |
@@ -1020,19 +1052,22 @@ discard block |
||
| 1020 | 1052 | } |
| 1021 | 1053 | |
| 1022 | 1054 | // Bail if it's false, ie. no messages. |
| 1023 | - if ($messages_request == false) |
|
| 1024 | - return false; |
|
| 1055 | + if ($messages_request == false) { |
|
| 1056 | + return false; |
|
| 1057 | + } |
|
| 1025 | 1058 | |
| 1026 | 1059 | // Reset the data? |
| 1027 | - if ($reset == true) |
|
| 1028 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1060 | + if ($reset == true) { |
|
| 1061 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1062 | + } |
|
| 1029 | 1063 | |
| 1030 | 1064 | // Get the next one... bail if anything goes wrong. |
| 1031 | 1065 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
| 1032 | 1066 | if (!$message) |
| 1033 | 1067 | { |
| 1034 | - if ($type != 'subject') |
|
| 1035 | - $smcFunc['db_free_result']($messages_request); |
|
| 1068 | + if ($type != 'subject') { |
|
| 1069 | + $smcFunc['db_free_result']($messages_request); |
|
| 1070 | + } |
|
| 1036 | 1071 | |
| 1037 | 1072 | return false; |
| 1038 | 1073 | } |
@@ -1052,8 +1087,7 @@ discard block |
||
| 1052 | 1087 | $memberContext[$message['id_member_from']]['email'] = ''; |
| 1053 | 1088 | $memberContext[$message['id_member_from']]['show_email'] = false; |
| 1054 | 1089 | $memberContext[$message['id_member_from']]['is_guest'] = true; |
| 1055 | - } |
|
| 1056 | - else |
|
| 1090 | + } else |
|
| 1057 | 1091 | { |
| 1058 | 1092 | $memberContext[$message['id_member_from']]['can_view_profile'] = allowedTo('profile_view') || ($message['id_member_from'] == $user_info['id'] && !$user_info['is_guest']); |
| 1059 | 1093 | $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']))); |
@@ -1094,9 +1128,10 @@ discard block |
||
| 1094 | 1128 | $counter++; |
| 1095 | 1129 | |
| 1096 | 1130 | // Any custom profile fields? |
| 1097 | - if (!empty($memberContext[$message['id_member_from']]['custom_fields'])) |
|
| 1098 | - foreach ($memberContext[$message['id_member_from']]['custom_fields'] as $custom) |
|
| 1131 | + if (!empty($memberContext[$message['id_member_from']]['custom_fields'])) { |
|
| 1132 | + foreach ($memberContext[$message['id_member_from']]['custom_fields'] as $custom) |
|
| 1099 | 1133 | $output['custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
| 1134 | + } |
|
| 1100 | 1135 | |
| 1101 | 1136 | call_integration_hook('integrate_prepare_pm_context', array(&$output, &$message, $counter)); |
| 1102 | 1137 | |
@@ -1120,22 +1155,28 @@ discard block |
||
| 1120 | 1155 | $context['search_params'][$k] = $v; |
| 1121 | 1156 | } |
| 1122 | 1157 | } |
| 1123 | - if (isset($_REQUEST['search'])) |
|
| 1124 | - $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
| 1158 | + if (isset($_REQUEST['search'])) { |
|
| 1159 | + $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
| 1160 | + } |
|
| 1125 | 1161 | |
| 1126 | - if (isset($context['search_params']['search'])) |
|
| 1127 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 1128 | - if (isset($context['search_params']['userspec'])) |
|
| 1129 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 1162 | + if (isset($context['search_params']['search'])) { |
|
| 1163 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 1164 | + } |
|
| 1165 | + if (isset($context['search_params']['userspec'])) { |
|
| 1166 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 1167 | + } |
|
| 1130 | 1168 | |
| 1131 | - if (!empty($context['search_params']['searchtype'])) |
|
| 1132 | - $context['search_params']['searchtype'] = 2; |
|
| 1169 | + if (!empty($context['search_params']['searchtype'])) { |
|
| 1170 | + $context['search_params']['searchtype'] = 2; |
|
| 1171 | + } |
|
| 1133 | 1172 | |
| 1134 | - if (!empty($context['search_params']['minage'])) |
|
| 1135 | - $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
| 1173 | + if (!empty($context['search_params']['minage'])) { |
|
| 1174 | + $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
| 1175 | + } |
|
| 1136 | 1176 | |
| 1137 | - if (!empty($context['search_params']['maxage'])) |
|
| 1138 | - $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
| 1177 | + if (!empty($context['search_params']['maxage'])) { |
|
| 1178 | + $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
| 1179 | + } |
|
| 1139 | 1180 | |
| 1140 | 1181 | $context['search_params']['subject_only'] = !empty($context['search_params']['subject_only']); |
| 1141 | 1182 | $context['search_params']['show_complete'] = !empty($context['search_params']['show_complete']); |
@@ -1162,8 +1203,9 @@ discard block |
||
| 1162 | 1203 | $context['search_errors']['messages'] = array(); |
| 1163 | 1204 | foreach ($context['search_errors'] as $search_error => $dummy) |
| 1164 | 1205 | { |
| 1165 | - if ($search_error == 'messages') |
|
| 1166 | - continue; |
|
| 1206 | + if ($search_error == 'messages') { |
|
| 1207 | + continue; |
|
| 1208 | + } |
|
| 1167 | 1209 | |
| 1168 | 1210 | $context['search_errors']['messages'][] = $txt['error_' . $search_error]; |
| 1169 | 1211 | } |
@@ -1185,8 +1227,9 @@ discard block |
||
| 1185 | 1227 | global $scripturl, $modSettings, $user_info, $context, $txt; |
| 1186 | 1228 | global $memberContext, $smcFunc; |
| 1187 | 1229 | |
| 1188 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) |
|
| 1189 | - fatal_lang_error('loadavg_search_disabled', false); |
|
| 1230 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) { |
|
| 1231 | + fatal_lang_error('loadavg_search_disabled', false); |
|
| 1232 | + } |
|
| 1190 | 1233 | |
| 1191 | 1234 | /** |
| 1192 | 1235 | * @todo For the moment force the folder to the inbox. |
@@ -1215,35 +1258,40 @@ discard block |
||
| 1215 | 1258 | $context['start'] = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
| 1216 | 1259 | |
| 1217 | 1260 | // Store whether simple search was used (needed if the user wants to do another query). |
| 1218 | - if (!isset($search_params['advanced'])) |
|
| 1219 | - $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
| 1261 | + if (!isset($search_params['advanced'])) { |
|
| 1262 | + $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
| 1263 | + } |
|
| 1220 | 1264 | |
| 1221 | 1265 | // 1 => 'allwords' (default, don't set as param) / 2 => 'anywords'. |
| 1222 | - if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) |
|
| 1223 | - $search_params['searchtype'] = 2; |
|
| 1266 | + if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) { |
|
| 1267 | + $search_params['searchtype'] = 2; |
|
| 1268 | + } |
|
| 1224 | 1269 | |
| 1225 | 1270 | // Minimum age of messages. Default to zero (don't set param in that case). |
| 1226 | - if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) |
|
| 1227 | - $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
| 1271 | + if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) { |
|
| 1272 | + $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
| 1273 | + } |
|
| 1228 | 1274 | |
| 1229 | 1275 | // Maximum age of messages. Default to infinite (9999 days: param not set). |
| 1230 | - if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] != 9999)) |
|
| 1231 | - $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
| 1276 | + if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] != 9999)) { |
|
| 1277 | + $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
| 1278 | + } |
|
| 1232 | 1279 | |
| 1233 | 1280 | $search_params['subject_only'] = !empty($search_params['subject_only']) || !empty($_REQUEST['subject_only']); |
| 1234 | 1281 | $search_params['show_complete'] = !empty($search_params['show_complete']) || !empty($_REQUEST['show_complete']); |
| 1235 | 1282 | |
| 1236 | 1283 | // Default the user name to a wildcard matching every user (*). |
| 1237 | - if (!empty($search_params['user_spec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) |
|
| 1238 | - $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
| 1284 | + if (!empty($search_params['user_spec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) { |
|
| 1285 | + $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
| 1286 | + } |
|
| 1239 | 1287 | |
| 1240 | 1288 | // This will be full of all kinds of parameters! |
| 1241 | 1289 | $searchq_parameters = array(); |
| 1242 | 1290 | |
| 1243 | 1291 | // If there's no specific user, then don't mention it in the main query. |
| 1244 | - if (empty($search_params['userspec'])) |
|
| 1245 | - $userQuery = ''; |
|
| 1246 | - else |
|
| 1292 | + if (empty($search_params['userspec'])) { |
|
| 1293 | + $userQuery = ''; |
|
| 1294 | + } else |
|
| 1247 | 1295 | { |
| 1248 | 1296 | $userString = strtr($smcFunc['htmlspecialchars']($search_params['userspec'], ENT_QUOTES), array('"' => '"')); |
| 1249 | 1297 | $userString = strtr($userString, array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_')); |
@@ -1255,8 +1303,9 @@ discard block |
||
| 1255 | 1303 | { |
| 1256 | 1304 | $possible_users[$k] = trim($possible_users[$k]); |
| 1257 | 1305 | |
| 1258 | - if (strlen($possible_users[$k]) == 0) |
|
| 1259 | - unset($possible_users[$k]); |
|
| 1306 | + if (strlen($possible_users[$k]) == 0) { |
|
| 1307 | + unset($possible_users[$k]); |
|
| 1308 | + } |
|
| 1260 | 1309 | } |
| 1261 | 1310 | |
| 1262 | 1311 | if (!empty($possible_users)) |
@@ -1268,8 +1317,9 @@ discard block |
||
| 1268 | 1317 | { |
| 1269 | 1318 | $where_params['name_' . $k] = $v; |
| 1270 | 1319 | $where_clause[] = '{raw:real_name} LIKE {string:name_' . $k . '}'; |
| 1271 | - if (!isset($where_params['real_name'])) |
|
| 1272 | - $where_params['real_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(real_name)' : 'real_name'; |
|
| 1320 | + if (!isset($where_params['real_name'])) { |
|
| 1321 | + $where_params['real_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(real_name)' : 'real_name'; |
|
| 1322 | + } |
|
| 1273 | 1323 | } |
| 1274 | 1324 | |
| 1275 | 1325 | // Who matches those criteria? |
@@ -1282,28 +1332,28 @@ discard block |
||
| 1282 | 1332 | ); |
| 1283 | 1333 | |
| 1284 | 1334 | // Simply do nothing if there're too many members matching the criteria. |
| 1285 | - if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) |
|
| 1286 | - $userQuery = ''; |
|
| 1287 | - elseif ($smcFunc['db_num_rows']($request) == 0) |
|
| 1335 | + if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) { |
|
| 1336 | + $userQuery = ''; |
|
| 1337 | + } elseif ($smcFunc['db_num_rows']($request) == 0) |
|
| 1288 | 1338 | { |
| 1289 | 1339 | $userQuery = 'AND pm.id_member_from = 0 AND ({raw:pm_from_name} LIKE {raw:guest_user_name_implode})'; |
| 1290 | 1340 | $searchq_parameters['guest_user_name_implode'] = '\'' . implode('\' OR ' . ($smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name') . ' LIKE \'', $possible_users) . '\''; |
| 1291 | 1341 | $searchq_parameters['pm_from_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name'; |
| 1292 | - } |
|
| 1293 | - else |
|
| 1342 | + } else |
|
| 1294 | 1343 | { |
| 1295 | 1344 | $memberlist = array(); |
| 1296 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1297 | - $memberlist[] = $row['id_member']; |
|
| 1345 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1346 | + $memberlist[] = $row['id_member']; |
|
| 1347 | + } |
|
| 1298 | 1348 | $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})))'; |
| 1299 | 1349 | $searchq_parameters['guest_user_name_implode'] = '\'' . implode('\' OR ' . ($smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name') . ' LIKE \'', $possible_users) . '\''; |
| 1300 | 1350 | $searchq_parameters['member_list'] = $memberlist; |
| 1301 | 1351 | $searchq_parameters['pm_from_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name'; |
| 1302 | 1352 | } |
| 1303 | 1353 | $smcFunc['db_free_result']($request); |
| 1354 | + } else { |
|
| 1355 | + $userQuery = ''; |
|
| 1304 | 1356 | } |
| 1305 | - else |
|
| 1306 | - $userQuery = ''; |
|
| 1307 | 1357 | } |
| 1308 | 1358 | |
| 1309 | 1359 | // Setup the sorting variables... |
@@ -1311,8 +1361,9 @@ discard block |
||
| 1311 | 1361 | $sort_columns = array( |
| 1312 | 1362 | 'pm.id_pm', |
| 1313 | 1363 | ); |
| 1314 | - if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) |
|
| 1315 | - list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
| 1364 | + if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) { |
|
| 1365 | + list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
| 1366 | + } |
|
| 1316 | 1367 | $search_params['sort'] = !empty($search_params['sort']) && in_array($search_params['sort'], $sort_columns) ? $search_params['sort'] : 'pm.id_pm'; |
| 1317 | 1368 | $search_params['sort_dir'] = !empty($search_params['sort_dir']) && $search_params['sort_dir'] == 'asc' ? 'asc' : 'desc'; |
| 1318 | 1369 | |
@@ -1322,24 +1373,27 @@ discard block |
||
| 1322 | 1373 | if ($context['folder'] == 'inbox' && !empty($search_params['advanced']) && $context['currently_using_labels']) |
| 1323 | 1374 | { |
| 1324 | 1375 | // Came here from pagination? Put them back into $_REQUEST for sanitization. |
| 1325 | - if (isset($search_params['labels'])) |
|
| 1326 | - $_REQUEST['searchlabel'] = explode(',', $search_params['labels']); |
|
| 1376 | + if (isset($search_params['labels'])) { |
|
| 1377 | + $_REQUEST['searchlabel'] = explode(',', $search_params['labels']); |
|
| 1378 | + } |
|
| 1327 | 1379 | |
| 1328 | 1380 | // Assuming we have some labels - make them all integers. |
| 1329 | 1381 | if (!empty($_REQUEST['searchlabel']) && is_array($_REQUEST['searchlabel'])) |
| 1330 | 1382 | { |
| 1331 | - foreach ($_REQUEST['searchlabel'] as $key => $id) |
|
| 1332 | - $_REQUEST['searchlabel'][$key] = (int) $id; |
|
| 1383 | + foreach ($_REQUEST['searchlabel'] as $key => $id) { |
|
| 1384 | + $_REQUEST['searchlabel'][$key] = (int) $id; |
|
| 1385 | + } |
|
| 1386 | + } else { |
|
| 1387 | + $_REQUEST['searchlabel'] = array(); |
|
| 1333 | 1388 | } |
| 1334 | - else |
|
| 1335 | - $_REQUEST['searchlabel'] = array(); |
|
| 1336 | 1389 | |
| 1337 | 1390 | // Now that everything is cleaned up a bit, make the labels a param. |
| 1338 | 1391 | $search_params['labels'] = implode(',', $_REQUEST['searchlabel']); |
| 1339 | 1392 | |
| 1340 | 1393 | // No labels selected? That must be an error! |
| 1341 | - if (empty($_REQUEST['searchlabel'])) |
|
| 1342 | - $context['search_errors']['no_labels_selected'] = true; |
|
| 1394 | + if (empty($_REQUEST['searchlabel'])) { |
|
| 1395 | + $context['search_errors']['no_labels_selected'] = true; |
|
| 1396 | + } |
|
| 1343 | 1397 | // Otherwise prepare the query! |
| 1344 | 1398 | elseif (count($_REQUEST['searchlabel']) != count($context['labels'])) |
| 1345 | 1399 | { |
@@ -1362,8 +1416,7 @@ discard block |
||
| 1362 | 1416 | // Not searching the inbox - PM must be labeled |
| 1363 | 1417 | $labelQuery = ' AND pml.id_label IN ({array_int:labels})'; |
| 1364 | 1418 | $labelJoin = ' INNER JOIN {db_prefix}pm_labeled_messages AS pml ON (pml.id_pm = pmr.id_pm)'; |
| 1365 | - } |
|
| 1366 | - else |
|
| 1419 | + } else |
|
| 1367 | 1420 | { |
| 1368 | 1421 | // Searching the inbox - PM doesn't have to be labeled |
| 1369 | 1422 | $labelQuery = ' AND (' . substr($labelQuery, 5) . ' OR pml.id_label IN ({array_int:labels}))'; |
@@ -1378,8 +1431,9 @@ discard block |
||
| 1378 | 1431 | // What are we actually searching for? |
| 1379 | 1432 | $search_params['search'] = !empty($search_params['search']) ? $search_params['search'] : (isset($_REQUEST['search']) ? $_REQUEST['search'] : ''); |
| 1380 | 1433 | // If we ain't got nothing - we should error! |
| 1381 | - if (!isset($search_params['search']) || $search_params['search'] == '') |
|
| 1382 | - $context['search_errors']['invalid_search_string'] = true; |
|
| 1434 | + if (!isset($search_params['search']) || $search_params['search'] == '') { |
|
| 1435 | + $context['search_errors']['invalid_search_string'] = true; |
|
| 1436 | + } |
|
| 1383 | 1437 | |
| 1384 | 1438 | // Extract phrase parts first (e.g. some words "this is a phrase" some more words.) |
| 1385 | 1439 | preg_match_all('~(?:^|\s)([-]?)"([^"]+)"(?:$|\s)~' . ($context['utf8'] ? 'u' : ''), $search_params['search'], $matches, PREG_PATTERN_ORDER); |
@@ -1392,12 +1446,14 @@ discard block |
||
| 1392 | 1446 | $excludedWords = array(); |
| 1393 | 1447 | |
| 1394 | 1448 | // .. first, we check for things like -"some words", but not "-some words". |
| 1395 | - foreach ($matches[1] as $index => $word) |
|
| 1396 | - if ($word == '-') |
|
| 1449 | + foreach ($matches[1] as $index => $word) { |
|
| 1450 | + if ($word == '-') |
|
| 1397 | 1451 | { |
| 1398 | 1452 | $word = $smcFunc['strtolower'](trim($searchArray[$index])); |
| 1399 | - if (strlen($word) > 0) |
|
| 1400 | - $excludedWords[] = $word; |
|
| 1453 | + } |
|
| 1454 | + if (strlen($word) > 0) { |
|
| 1455 | + $excludedWords[] = $word; |
|
| 1456 | + } |
|
| 1401 | 1457 | unset($searchArray[$index]); |
| 1402 | 1458 | } |
| 1403 | 1459 | |
@@ -1407,8 +1463,9 @@ discard block |
||
| 1407 | 1463 | if (strpos(trim($word), '-') === 0) |
| 1408 | 1464 | { |
| 1409 | 1465 | $word = substr($smcFunc['strtolower']($word), 1); |
| 1410 | - if (strlen($word) > 0) |
|
| 1411 | - $excludedWords[] = $word; |
|
| 1466 | + if (strlen($word) > 0) { |
|
| 1467 | + $excludedWords[] = $word; |
|
| 1468 | + } |
|
| 1412 | 1469 | unset($tempSearch[$index]); |
| 1413 | 1470 | } |
| 1414 | 1471 | } |
@@ -1419,9 +1476,9 @@ discard block |
||
| 1419 | 1476 | foreach ($searchArray as $index => $value) |
| 1420 | 1477 | { |
| 1421 | 1478 | $searchArray[$index] = $smcFunc['strtolower'](trim($value)); |
| 1422 | - if ($searchArray[$index] == '') |
|
| 1423 | - unset($searchArray[$index]); |
|
| 1424 | - else |
|
| 1479 | + if ($searchArray[$index] == '') { |
|
| 1480 | + unset($searchArray[$index]); |
|
| 1481 | + } else |
|
| 1425 | 1482 | { |
| 1426 | 1483 | // Sort out entities first. |
| 1427 | 1484 | $searchArray[$index] = $smcFunc['htmlspecialchars']($searchArray[$index]); |
@@ -1431,27 +1488,32 @@ discard block |
||
| 1431 | 1488 | |
| 1432 | 1489 | // Create an array of replacements for highlighting. |
| 1433 | 1490 | $context['mark'] = array(); |
| 1434 | - foreach ($searchArray as $word) |
|
| 1435 | - $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
| 1491 | + foreach ($searchArray as $word) { |
|
| 1492 | + $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
| 1493 | + } |
|
| 1436 | 1494 | |
| 1437 | 1495 | // This contains *everything* |
| 1438 | 1496 | $searchWords = array_merge($searchArray, $excludedWords); |
| 1439 | 1497 | |
| 1440 | 1498 | // Make sure at least one word is being searched for. |
| 1441 | - if (empty($searchArray)) |
|
| 1442 | - $context['search_errors']['invalid_search_string'] = true; |
|
| 1499 | + if (empty($searchArray)) { |
|
| 1500 | + $context['search_errors']['invalid_search_string'] = true; |
|
| 1501 | + } |
|
| 1443 | 1502 | |
| 1444 | 1503 | // Sort out the search query so the user can edit it - if they want. |
| 1445 | 1504 | $context['search_params'] = $search_params; |
| 1446 | - if (isset($context['search_params']['search'])) |
|
| 1447 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 1448 | - if (isset($context['search_params']['userspec'])) |
|
| 1449 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 1505 | + if (isset($context['search_params']['search'])) { |
|
| 1506 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 1507 | + } |
|
| 1508 | + if (isset($context['search_params']['userspec'])) { |
|
| 1509 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 1510 | + } |
|
| 1450 | 1511 | |
| 1451 | 1512 | // Now we have all the parameters, combine them together for pagination and the like... |
| 1452 | 1513 | $context['params'] = array(); |
| 1453 | - foreach ($search_params as $k => $v) |
|
| 1454 | - $context['params'][] = $k . '|\'|' . $v; |
|
| 1514 | + foreach ($search_params as $k => $v) { |
|
| 1515 | + $context['params'][] = $k . '|\'|' . $v; |
|
| 1516 | + } |
|
| 1455 | 1517 | $context['params'] = base64_encode(implode('|"|', $context['params'])); |
| 1456 | 1518 | |
| 1457 | 1519 | // Compile the subject query part. |
@@ -1459,26 +1521,31 @@ discard block |
||
| 1459 | 1521 | |
| 1460 | 1522 | foreach ($searchWords as $index => $word) |
| 1461 | 1523 | { |
| 1462 | - if ($word == '') |
|
| 1463 | - continue; |
|
| 1524 | + if ($word == '') { |
|
| 1525 | + continue; |
|
| 1526 | + } |
|
| 1464 | 1527 | |
| 1465 | - if ($search_params['subject_only']) |
|
| 1466 | - $andQueryParts[] = 'pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '}'; |
|
| 1467 | - else |
|
| 1468 | - $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 . '})'; |
|
| 1528 | + if ($search_params['subject_only']) { |
|
| 1529 | + $andQueryParts[] = 'pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '}'; |
|
| 1530 | + } else { |
|
| 1531 | + $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 . '})'; |
|
| 1532 | + } |
|
| 1469 | 1533 | $searchq_parameters['search_' . $index] = '%' . strtr($word, array('_' => '\\_', '%' => '\\%')) . '%'; |
| 1470 | 1534 | } |
| 1471 | 1535 | |
| 1472 | 1536 | $searchQuery = ' 1=1'; |
| 1473 | - if (!empty($andQueryParts)) |
|
| 1474 | - $searchQuery = implode(!empty($search_params['searchtype']) && $search_params['searchtype'] == 2 ? ' OR ' : ' AND ', $andQueryParts); |
|
| 1537 | + if (!empty($andQueryParts)) { |
|
| 1538 | + $searchQuery = implode(!empty($search_params['searchtype']) && $search_params['searchtype'] == 2 ? ' OR ' : ' AND ', $andQueryParts); |
|
| 1539 | + } |
|
| 1475 | 1540 | |
| 1476 | 1541 | // Age limits? |
| 1477 | 1542 | $timeQuery = ''; |
| 1478 | - if (!empty($search_params['minage'])) |
|
| 1479 | - $timeQuery .= ' AND pm.msgtime < ' . (time() - $search_params['minage'] * 86400); |
|
| 1480 | - if (!empty($search_params['maxage'])) |
|
| 1481 | - $timeQuery .= ' AND pm.msgtime > ' . (time() - $search_params['maxage'] * 86400); |
|
| 1543 | + if (!empty($search_params['minage'])) { |
|
| 1544 | + $timeQuery .= ' AND pm.msgtime < ' . (time() - $search_params['minage'] * 86400); |
|
| 1545 | + } |
|
| 1546 | + if (!empty($search_params['maxage'])) { |
|
| 1547 | + $timeQuery .= ' AND pm.msgtime > ' . (time() - $search_params['maxage'] * 86400); |
|
| 1548 | + } |
|
| 1482 | 1549 | |
| 1483 | 1550 | // If we have errors - return back to the first screen... |
| 1484 | 1551 | if (!empty($context['search_errors'])) |
@@ -1564,8 +1631,9 @@ discard block |
||
| 1564 | 1631 | ) |
| 1565 | 1632 | ); |
| 1566 | 1633 | $real_pm_ids = array(); |
| 1567 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1568 | - $real_pm_ids[$row['id_pm_head']] = $row['id_pm']; |
|
| 1634 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1635 | + $real_pm_ids[$row['id_pm_head']] = $row['id_pm']; |
|
| 1636 | + } |
|
| 1569 | 1637 | $smcFunc['db_free_result']($request); |
| 1570 | 1638 | } |
| 1571 | 1639 | |
@@ -1595,8 +1663,9 @@ discard block |
||
| 1595 | 1663 | ); |
| 1596 | 1664 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1597 | 1665 | { |
| 1598 | - if ($context['folder'] == 'sent' || empty($row['bcc'])) |
|
| 1599 | - $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>'; |
|
| 1666 | + if ($context['folder'] == 'sent' || empty($row['bcc'])) { |
|
| 1667 | + $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>'; |
|
| 1668 | + } |
|
| 1600 | 1669 | |
| 1601 | 1670 | if ($row['id_member_to'] == $user_info['id'] && $context['folder'] != 'sent') |
| 1602 | 1671 | { |
@@ -1617,12 +1686,14 @@ discard block |
||
| 1617 | 1686 | while ($row2 = $smcFunc['db_fetch_assoc']($request2)) |
| 1618 | 1687 | { |
| 1619 | 1688 | $l_id = $row2['id_label']; |
| 1620 | - if (isset($context['labels'][$l_id])) |
|
| 1621 | - $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
| 1689 | + if (isset($context['labels'][$l_id])) { |
|
| 1690 | + $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
| 1691 | + } |
|
| 1622 | 1692 | |
| 1623 | 1693 | // Here we find the first label on a message - for linking to posts in results |
| 1624 | - if (!isset($context['first_label'][$row['id_pm']]) && $row['in_inbox'] != 1) |
|
| 1625 | - $context['first_label'][$row['id_pm']] = $l_id; |
|
| 1694 | + if (!isset($context['first_label'][$row['id_pm']]) && $row['in_inbox'] != 1) { |
|
| 1695 | + $context['first_label'][$row['id_pm']] = $l_id; |
|
| 1696 | + } |
|
| 1626 | 1697 | } |
| 1627 | 1698 | |
| 1628 | 1699 | $smcFunc['db_free_result']($request2); |
@@ -1749,8 +1820,9 @@ discard block |
||
| 1749 | 1820 | list ($postCount) = $smcFunc['db_fetch_row']($request); |
| 1750 | 1821 | $smcFunc['db_free_result']($request); |
| 1751 | 1822 | |
| 1752 | - if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) |
|
| 1753 | - fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
| 1823 | + if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) { |
|
| 1824 | + fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
| 1825 | + } |
|
| 1754 | 1826 | } |
| 1755 | 1827 | |
| 1756 | 1828 | // Quoting/Replying to a message? |
@@ -1759,8 +1831,9 @@ discard block |
||
| 1759 | 1831 | $pmsg = (int) $_REQUEST['pmsg']; |
| 1760 | 1832 | |
| 1761 | 1833 | // Make sure this is yours. |
| 1762 | - if (!isAccessiblePM($pmsg)) |
|
| 1763 | - fatal_lang_error('no_access', false); |
|
| 1834 | + if (!isAccessiblePM($pmsg)) { |
|
| 1835 | + fatal_lang_error('no_access', false); |
|
| 1836 | + } |
|
| 1764 | 1837 | |
| 1765 | 1838 | // Work out whether this is one you've received? |
| 1766 | 1839 | $request = $smcFunc['db_query']('', ' |
@@ -1797,8 +1870,9 @@ discard block |
||
| 1797 | 1870 | 'id_pm' => $pmsg, |
| 1798 | 1871 | ) |
| 1799 | 1872 | ); |
| 1800 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1801 | - fatal_lang_error('pm_not_yours', false); |
|
| 1873 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1874 | + fatal_lang_error('pm_not_yours', false); |
|
| 1875 | + } |
|
| 1802 | 1876 | $row_quoted = $smcFunc['db_fetch_assoc']($request); |
| 1803 | 1877 | $smcFunc['db_free_result']($request); |
| 1804 | 1878 | |
@@ -1809,9 +1883,9 @@ discard block |
||
| 1809 | 1883 | // Add 'Re: ' to it.... |
| 1810 | 1884 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 1811 | 1885 | { |
| 1812 | - if ($language === $user_info['language']) |
|
| 1813 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 1814 | - else |
|
| 1886 | + if ($language === $user_info['language']) { |
|
| 1887 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 1888 | + } else |
|
| 1815 | 1889 | { |
| 1816 | 1890 | loadLanguage('index', $language, false); |
| 1817 | 1891 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -1820,22 +1894,25 @@ discard block |
||
| 1820 | 1894 | cache_put_data('response_prefix', $context['response_prefix'], 600); |
| 1821 | 1895 | } |
| 1822 | 1896 | $form_subject = $row_quoted['subject']; |
| 1823 | - if ($context['reply'] && trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
| 1824 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
| 1897 | + if ($context['reply'] && trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
| 1898 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
| 1899 | + } |
|
| 1825 | 1900 | |
| 1826 | 1901 | if (isset($_REQUEST['quote'])) |
| 1827 | 1902 | { |
| 1828 | 1903 | // Remove any nested quotes and <br>... |
| 1829 | 1904 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $row_quoted['body']); |
| 1830 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
| 1831 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 1832 | - if (empty($row_quoted['id_member'])) |
|
| 1833 | - $form_message = '[quote author="' . $row_quoted['real_name'] . '"]' . "\n" . $form_message . "\n" . '[/quote]'; |
|
| 1834 | - else |
|
| 1835 | - $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]'; |
|
| 1905 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
| 1906 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 1907 | + } |
|
| 1908 | + if (empty($row_quoted['id_member'])) { |
|
| 1909 | + $form_message = '[quote author="' . $row_quoted['real_name'] . '"]' . "\n" . $form_message . "\n" . '[/quote]'; |
|
| 1910 | + } else { |
|
| 1911 | + $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]'; |
|
| 1912 | + } |
|
| 1913 | + } else { |
|
| 1914 | + $form_message = ''; |
|
| 1836 | 1915 | } |
| 1837 | - else |
|
| 1838 | - $form_message = ''; |
|
| 1839 | 1916 | |
| 1840 | 1917 | // Do the BBC thang on the message. |
| 1841 | 1918 | $row_quoted['body'] = parse_bbc($row_quoted['body'], true, 'pm' . $row_quoted['id_pm']); |
@@ -1856,8 +1933,7 @@ discard block |
||
| 1856 | 1933 | 'timestamp' => forum_time(true, $row_quoted['msgtime']), |
| 1857 | 1934 | 'body' => $row_quoted['body'] |
| 1858 | 1935 | ); |
| 1859 | - } |
|
| 1860 | - else |
|
| 1936 | + } else |
|
| 1861 | 1937 | { |
| 1862 | 1938 | $context['quoted_message'] = false; |
| 1863 | 1939 | $form_subject = ''; |
@@ -1876,11 +1952,12 @@ discard block |
||
| 1876 | 1952 | if ($_REQUEST['u'] == 'all' && isset($row_quoted)) |
| 1877 | 1953 | { |
| 1878 | 1954 | // Firstly, to reply to all we clearly already have $row_quoted - so have the original member from. |
| 1879 | - if ($row_quoted['id_member'] != $user_info['id']) |
|
| 1880 | - $context['recipients']['to'][] = array( |
|
| 1955 | + if ($row_quoted['id_member'] != $user_info['id']) { |
|
| 1956 | + $context['recipients']['to'][] = array( |
|
| 1881 | 1957 | 'id' => $row_quoted['id_member'], |
| 1882 | 1958 | 'name' => $smcFunc['htmlspecialchars']($row_quoted['real_name']), |
| 1883 | 1959 | ); |
| 1960 | + } |
|
| 1884 | 1961 | |
| 1885 | 1962 | // Now to get the others. |
| 1886 | 1963 | $request = $smcFunc['db_query']('', ' |
@@ -1896,18 +1973,19 @@ discard block |
||
| 1896 | 1973 | 'not_bcc' => 0, |
| 1897 | 1974 | ) |
| 1898 | 1975 | ); |
| 1899 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1900 | - $context['recipients']['to'][] = array( |
|
| 1976 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1977 | + $context['recipients']['to'][] = array( |
|
| 1901 | 1978 | 'id' => $row['id_member'], |
| 1902 | 1979 | 'name' => $row['real_name'], |
| 1903 | 1980 | ); |
| 1981 | + } |
|
| 1904 | 1982 | $smcFunc['db_free_result']($request); |
| 1905 | - } |
|
| 1906 | - else |
|
| 1983 | + } else |
|
| 1907 | 1984 | { |
| 1908 | 1985 | $_REQUEST['u'] = explode(',', $_REQUEST['u']); |
| 1909 | - foreach ($_REQUEST['u'] as $key => $uID) |
|
| 1910 | - $_REQUEST['u'][$key] = (int) $uID; |
|
| 1986 | + foreach ($_REQUEST['u'] as $key => $uID) { |
|
| 1987 | + $_REQUEST['u'][$key] = (int) $uID; |
|
| 1988 | + } |
|
| 1911 | 1989 | |
| 1912 | 1990 | $_REQUEST['u'] = array_unique($_REQUEST['u']); |
| 1913 | 1991 | |
@@ -1921,22 +1999,24 @@ discard block |
||
| 1921 | 1999 | 'limit' => count($_REQUEST['u']), |
| 1922 | 2000 | ) |
| 1923 | 2001 | ); |
| 1924 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1925 | - $context['recipients']['to'][] = array( |
|
| 2002 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2003 | + $context['recipients']['to'][] = array( |
|
| 1926 | 2004 | 'id' => $row['id_member'], |
| 1927 | 2005 | 'name' => $row['real_name'], |
| 1928 | 2006 | ); |
| 2007 | + } |
|
| 1929 | 2008 | $smcFunc['db_free_result']($request); |
| 1930 | 2009 | } |
| 1931 | 2010 | |
| 1932 | 2011 | // Get a literal name list in case the user has JavaScript disabled. |
| 1933 | 2012 | $names = array(); |
| 1934 | - foreach ($context['recipients']['to'] as $to) |
|
| 1935 | - $names[] = $to['name']; |
|
| 2013 | + foreach ($context['recipients']['to'] as $to) { |
|
| 2014 | + $names[] = $to['name']; |
|
| 2015 | + } |
|
| 1936 | 2016 | $context['to_value'] = empty($names) ? '' : '"' . implode('", "', $names) . '"'; |
| 2017 | + } else { |
|
| 2018 | + $context['to_value'] = ''; |
|
| 1937 | 2019 | } |
| 1938 | - else |
|
| 1939 | - $context['to_value'] = ''; |
|
| 1940 | 2020 | |
| 1941 | 2021 | // Set the defaults... |
| 1942 | 2022 | $context['subject'] = $form_subject; |
@@ -2006,8 +2086,9 @@ discard block |
||
| 2006 | 2086 | |
| 2007 | 2087 | // validate with loadMemberData() |
| 2008 | 2088 | $memberResult = loadMemberData($user_info['id'], false); |
| 2009 | - if (!$memberResult) |
|
| 2010 | - fatal_lang_error('not_a_user', false); |
|
| 2089 | + if (!$memberResult) { |
|
| 2090 | + fatal_lang_error('not_a_user', false); |
|
| 2091 | + } |
|
| 2011 | 2092 | list ($memID) = $memberResult; |
| 2012 | 2093 | |
| 2013 | 2094 | // drafts is where the functions reside |
@@ -2033,9 +2114,9 @@ discard block |
||
| 2033 | 2114 | $context['sub_template'] = 'send'; |
| 2034 | 2115 | loadJavaScriptFile('PersonalMessage.js', array('defer' => false, 'minimize' => true), 'smf_pms'); |
| 2035 | 2116 | loadJavaScriptFile('suggest.js', array('defer' => false, 'minimize' => true), 'smf_suggest'); |
| 2117 | + } else { |
|
| 2118 | + $context['sub_template'] = 'pm'; |
|
| 2036 | 2119 | } |
| 2037 | - else |
|
| 2038 | - $context['sub_template'] = 'pm'; |
|
| 2039 | 2120 | |
| 2040 | 2121 | $context['page_title'] = $txt['send_message']; |
| 2041 | 2122 | |
@@ -2096,10 +2177,11 @@ discard block |
||
| 2096 | 2177 | ); |
| 2097 | 2178 | if ($smcFunc['db_num_rows']($request) == 0) |
| 2098 | 2179 | { |
| 2099 | - if (!isset($_REQUEST['xml'])) |
|
| 2100 | - fatal_lang_error('pm_not_yours', false); |
|
| 2101 | - else |
|
| 2102 | - $error_types[] = 'pm_not_yours'; |
|
| 2180 | + if (!isset($_REQUEST['xml'])) { |
|
| 2181 | + fatal_lang_error('pm_not_yours', false); |
|
| 2182 | + } else { |
|
| 2183 | + $error_types[] = 'pm_not_yours'; |
|
| 2184 | + } |
|
| 2103 | 2185 | } |
| 2104 | 2186 | $row_quoted = $smcFunc['db_fetch_assoc']($request); |
| 2105 | 2187 | $smcFunc['db_free_result']($request); |
@@ -2146,14 +2228,16 @@ discard block |
||
| 2146 | 2228 | $context['post_error'][$error_type] = true; |
| 2147 | 2229 | if (isset($txt['error_' . $error_type])) |
| 2148 | 2230 | { |
| 2149 | - if ($error_type == 'long_message') |
|
| 2150 | - $txt['error_' . $error_type] = sprintf($txt['error_' . $error_type], $modSettings['max_messageLength']); |
|
| 2231 | + if ($error_type == 'long_message') { |
|
| 2232 | + $txt['error_' . $error_type] = sprintf($txt['error_' . $error_type], $modSettings['max_messageLength']); |
|
| 2233 | + } |
|
| 2151 | 2234 | $context['post_error']['messages'][] = $txt['error_' . $error_type]; |
| 2152 | 2235 | } |
| 2153 | 2236 | |
| 2154 | 2237 | // If it's not a minor error flag it as such. |
| 2155 | - if (!in_array($error_type, array('new_reply', 'not_approved', 'new_replies', 'old_topic', 'need_qr_verification', 'no_subject'))) |
|
| 2156 | - $context['error_type'] = 'serious'; |
|
| 2238 | + if (!in_array($error_type, array('new_reply', 'not_approved', 'new_replies', 'old_topic', 'need_qr_verification', 'no_subject'))) { |
|
| 2239 | + $context['error_type'] = 'serious'; |
|
| 2240 | + } |
|
| 2157 | 2241 | } |
| 2158 | 2242 | |
| 2159 | 2243 | // We need to load the editor once more. |
@@ -2211,8 +2295,9 @@ discard block |
||
| 2211 | 2295 | require_once($sourcedir . '/Subs-Auth.php'); |
| 2212 | 2296 | |
| 2213 | 2297 | // PM Drafts enabled and needed? |
| 2214 | - if ($context['drafts_pm_save'] && (isset($_POST['save_draft']) || isset($_POST['id_pm_draft']))) |
|
| 2215 | - require_once($sourcedir . '/Drafts.php'); |
|
| 2298 | + if ($context['drafts_pm_save'] && (isset($_POST['save_draft']) || isset($_POST['id_pm_draft']))) { |
|
| 2299 | + require_once($sourcedir . '/Drafts.php'); |
|
| 2300 | + } |
|
| 2216 | 2301 | |
| 2217 | 2302 | loadLanguage('PersonalMessage', '', false); |
| 2218 | 2303 | |
@@ -2242,24 +2327,27 @@ discard block |
||
| 2242 | 2327 | |
| 2243 | 2328 | if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) |
| 2244 | 2329 | { |
| 2245 | - if (!isset($_REQUEST['xml'])) |
|
| 2246 | - fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
| 2247 | - else |
|
| 2248 | - $post_errors[] = 'pm_too_many_per_hour'; |
|
| 2330 | + if (!isset($_REQUEST['xml'])) { |
|
| 2331 | + fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
| 2332 | + } else { |
|
| 2333 | + $post_errors[] = 'pm_too_many_per_hour'; |
|
| 2334 | + } |
|
| 2249 | 2335 | } |
| 2250 | 2336 | } |
| 2251 | 2337 | |
| 2252 | 2338 | // If your session timed out, show an error, but do allow to re-submit. |
| 2253 | - if (!isset($_REQUEST['xml']) && checkSession('post', '', false) != '') |
|
| 2254 | - $post_errors[] = 'session_timeout'; |
|
| 2339 | + if (!isset($_REQUEST['xml']) && checkSession('post', '', false) != '') { |
|
| 2340 | + $post_errors[] = 'session_timeout'; |
|
| 2341 | + } |
|
| 2255 | 2342 | |
| 2256 | 2343 | $_REQUEST['subject'] = isset($_REQUEST['subject']) ? trim($_REQUEST['subject']) : ''; |
| 2257 | 2344 | $_REQUEST['to'] = empty($_POST['to']) ? (empty($_GET['to']) ? '' : $_GET['to']) : $_POST['to']; |
| 2258 | 2345 | $_REQUEST['bcc'] = empty($_POST['bcc']) ? (empty($_GET['bcc']) ? '' : $_GET['bcc']) : $_POST['bcc']; |
| 2259 | 2346 | |
| 2260 | 2347 | // Route the input from the 'u' parameter to the 'to'-list. |
| 2261 | - if (!empty($_POST['u'])) |
|
| 2262 | - $_POST['recipient_to'] = explode(',', $_POST['u']); |
|
| 2348 | + if (!empty($_POST['u'])) { |
|
| 2349 | + $_POST['recipient_to'] = explode(',', $_POST['u']); |
|
| 2350 | + } |
|
| 2263 | 2351 | |
| 2264 | 2352 | // Construct the list of recipients. |
| 2265 | 2353 | $recipientList = array(); |
@@ -2271,8 +2359,9 @@ discard block |
||
| 2271 | 2359 | $recipientList[$recipientType] = array(); |
| 2272 | 2360 | if (!empty($_POST['recipient_' . $recipientType]) && is_array($_POST['recipient_' . $recipientType])) |
| 2273 | 2361 | { |
| 2274 | - foreach ($_POST['recipient_' . $recipientType] as $recipient) |
|
| 2275 | - $recipientList[$recipientType][] = (int) $recipient; |
|
| 2362 | + foreach ($_POST['recipient_' . $recipientType] as $recipient) { |
|
| 2363 | + $recipientList[$recipientType][] = (int) $recipient; |
|
| 2364 | + } |
|
| 2276 | 2365 | } |
| 2277 | 2366 | |
| 2278 | 2367 | // Are there also literal names set? |
@@ -2286,10 +2375,11 @@ discard block |
||
| 2286 | 2375 | |
| 2287 | 2376 | foreach ($namedRecipientList[$recipientType] as $index => $recipient) |
| 2288 | 2377 | { |
| 2289 | - if (strlen(trim($recipient)) > 0) |
|
| 2290 | - $namedRecipientList[$recipientType][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($recipient))); |
|
| 2291 | - else |
|
| 2292 | - unset($namedRecipientList[$recipientType][$index]); |
|
| 2378 | + if (strlen(trim($recipient)) > 0) { |
|
| 2379 | + $namedRecipientList[$recipientType][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($recipient))); |
|
| 2380 | + } else { |
|
| 2381 | + unset($namedRecipientList[$recipientType][$index]); |
|
| 2382 | + } |
|
| 2293 | 2383 | } |
| 2294 | 2384 | |
| 2295 | 2385 | if (!empty($namedRecipientList[$recipientType])) |
@@ -2319,8 +2409,9 @@ discard block |
||
| 2319 | 2409 | } |
| 2320 | 2410 | |
| 2321 | 2411 | // Selected a recipient to be deleted? Remove them now. |
| 2322 | - if (!empty($_POST['delete_recipient'])) |
|
| 2323 | - $recipientList[$recipientType] = array_diff($recipientList[$recipientType], array((int) $_POST['delete_recipient'])); |
|
| 2412 | + if (!empty($_POST['delete_recipient'])) { |
|
| 2413 | + $recipientList[$recipientType] = array_diff($recipientList[$recipientType], array((int) $_POST['delete_recipient'])); |
|
| 2414 | + } |
|
| 2324 | 2415 | |
| 2325 | 2416 | // Make sure we don't include the same name twice |
| 2326 | 2417 | $recipientList[$recipientType] = array_unique($recipientList[$recipientType]); |
@@ -2330,8 +2421,9 @@ discard block |
||
| 2330 | 2421 | $is_recipient_change = !empty($_POST['delete_recipient']) || !empty($_POST['to_submit']) || !empty($_POST['bcc_submit']); |
| 2331 | 2422 | |
| 2332 | 2423 | // Check if there's at least one recipient. |
| 2333 | - if (empty($recipientList['to']) && empty($recipientList['bcc'])) |
|
| 2334 | - $post_errors[] = 'no_to'; |
|
| 2424 | + if (empty($recipientList['to']) && empty($recipientList['bcc'])) { |
|
| 2425 | + $post_errors[] = 'no_to'; |
|
| 2426 | + } |
|
| 2335 | 2427 | |
| 2336 | 2428 | // Make sure that we remove the members who did get it from the screen. |
| 2337 | 2429 | if (!$is_recipient_change) |
@@ -2345,28 +2437,31 @@ discard block |
||
| 2345 | 2437 | // Since we already have a post error, remove the previous one. |
| 2346 | 2438 | $post_errors = array_diff($post_errors, array('no_to')); |
| 2347 | 2439 | |
| 2348 | - foreach ($namesNotFound[$recipientType] as $name) |
|
| 2349 | - $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
| 2440 | + foreach ($namesNotFound[$recipientType] as $name) { |
|
| 2441 | + $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
| 2442 | + } |
|
| 2350 | 2443 | } |
| 2351 | 2444 | } |
| 2352 | 2445 | } |
| 2353 | 2446 | |
| 2354 | 2447 | // Did they make any mistakes? |
| 2355 | - if ($_REQUEST['subject'] == '') |
|
| 2356 | - $post_errors[] = 'no_subject'; |
|
| 2357 | - if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') |
|
| 2358 | - $post_errors[] = 'no_message'; |
|
| 2359 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_REQUEST['message']) > $modSettings['max_messageLength']) |
|
| 2360 | - $post_errors[] = 'long_message'; |
|
| 2361 | - else |
|
| 2448 | + if ($_REQUEST['subject'] == '') { |
|
| 2449 | + $post_errors[] = 'no_subject'; |
|
| 2450 | + } |
|
| 2451 | + if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') { |
|
| 2452 | + $post_errors[] = 'no_message'; |
|
| 2453 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_REQUEST['message']) > $modSettings['max_messageLength']) { |
|
| 2454 | + $post_errors[] = 'long_message'; |
|
| 2455 | + } else |
|
| 2362 | 2456 | { |
| 2363 | 2457 | // Preparse the message. |
| 2364 | 2458 | $message = $_REQUEST['message']; |
| 2365 | 2459 | preparsecode($message); |
| 2366 | 2460 | |
| 2367 | 2461 | // Make sure there's still some content left without the tags. |
| 2368 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($smcFunc['htmlspecialchars']($message, ENT_QUOTES), false), '<img>')) === '' && (!allowedTo('admin_forum') || strpos($message, '[html]') === false)) |
|
| 2369 | - $post_errors[] = 'no_message'; |
|
| 2462 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($smcFunc['htmlspecialchars']($message, ENT_QUOTES), false), '<img>')) === '' && (!allowedTo('admin_forum') || strpos($message, '[html]') === false)) { |
|
| 2463 | + $post_errors[] = 'no_message'; |
|
| 2464 | + } |
|
| 2370 | 2465 | } |
| 2371 | 2466 | |
| 2372 | 2467 | // Wrong verification code? |
@@ -2378,13 +2473,15 @@ discard block |
||
| 2378 | 2473 | ); |
| 2379 | 2474 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
| 2380 | 2475 | |
| 2381 | - if (is_array($context['require_verification'])) |
|
| 2382 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 2476 | + if (is_array($context['require_verification'])) { |
|
| 2477 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 2478 | + } |
|
| 2383 | 2479 | } |
| 2384 | 2480 | |
| 2385 | 2481 | // If they did, give a chance to make ammends. |
| 2386 | - if (!empty($post_errors) && !$is_recipient_change && !isset($_REQUEST['preview']) && !isset($_REQUEST['xml'])) |
|
| 2387 | - return messagePostError($post_errors, $namedRecipientList, $recipientList); |
|
| 2482 | + if (!empty($post_errors) && !$is_recipient_change && !isset($_REQUEST['preview']) && !isset($_REQUEST['xml'])) { |
|
| 2483 | + return messagePostError($post_errors, $namedRecipientList, $recipientList); |
|
| 2484 | + } |
|
| 2388 | 2485 | |
| 2389 | 2486 | // Want to take a second glance before you send? |
| 2390 | 2487 | if (isset($_REQUEST['preview'])) |
@@ -2415,8 +2512,9 @@ discard block |
||
| 2415 | 2512 | foreach ($namesNotFound as $recipientType => $names) |
| 2416 | 2513 | { |
| 2417 | 2514 | $post_errors[] = 'bad_' . $recipientType; |
| 2418 | - foreach ($names as $name) |
|
| 2419 | - $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
| 2515 | + foreach ($names as $name) { |
|
| 2516 | + $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
| 2517 | + } |
|
| 2420 | 2518 | } |
| 2421 | 2519 | |
| 2422 | 2520 | return messagePostError(array(), $namedRecipientList, $recipientList); |
@@ -2446,13 +2544,14 @@ discard block |
||
| 2446 | 2544 | checkSubmitOnce('check'); |
| 2447 | 2545 | |
| 2448 | 2546 | // Do the actual sending of the PM. |
| 2449 | - if (!empty($recipientList['to']) || !empty($recipientList['bcc'])) |
|
| 2450 | - $context['send_log'] = sendpm($recipientList, $_REQUEST['subject'], $_REQUEST['message'], true, null, !empty($_REQUEST['pm_head']) ? (int) $_REQUEST['pm_head'] : 0); |
|
| 2451 | - else |
|
| 2452 | - $context['send_log'] = array( |
|
| 2547 | + if (!empty($recipientList['to']) || !empty($recipientList['bcc'])) { |
|
| 2548 | + $context['send_log'] = sendpm($recipientList, $_REQUEST['subject'], $_REQUEST['message'], true, null, !empty($_REQUEST['pm_head']) ? (int) $_REQUEST['pm_head'] : 0); |
|
| 2549 | + } else { |
|
| 2550 | + $context['send_log'] = array( |
|
| 2453 | 2551 | 'sent' => array(), |
| 2454 | 2552 | 'failed' => array() |
| 2455 | 2553 | ); |
| 2554 | + } |
|
| 2456 | 2555 | |
| 2457 | 2556 | // Mark the message as "replied to". |
| 2458 | 2557 | if (!empty($context['send_log']['sent']) && !empty($_REQUEST['replied_to']) && isset($_REQUEST['f']) && $_REQUEST['f'] == 'inbox') |
@@ -2470,11 +2569,12 @@ discard block |
||
| 2470 | 2569 | } |
| 2471 | 2570 | |
| 2472 | 2571 | // If one or more of the recipient were invalid, go back to the post screen with the failed usernames. |
| 2473 | - if (!empty($context['send_log']['failed'])) |
|
| 2474 | - return messagePostError($post_errors, $namesNotFound, array( |
|
| 2572 | + if (!empty($context['send_log']['failed'])) { |
|
| 2573 | + return messagePostError($post_errors, $namesNotFound, array( |
|
| 2475 | 2574 | 'to' => array_intersect($recipientList['to'], $context['send_log']['failed']), |
| 2476 | 2575 | 'bcc' => array_intersect($recipientList['bcc'], $context['send_log']['failed']) |
| 2477 | 2576 | )); |
| 2577 | + } |
|
| 2478 | 2578 | |
| 2479 | 2579 | // Message sent successfully? |
| 2480 | 2580 | if (!empty($context['send_log']) && empty($context['send_log']['failed'])) |
@@ -2482,8 +2582,9 @@ discard block |
||
| 2482 | 2582 | $context['current_label_redirect'] = $context['current_label_redirect'] . ';done=sent'; |
| 2483 | 2583 | |
| 2484 | 2584 | // If we had a PM draft for this one, then its time to remove it since it was just sent |
| 2485 | - if ($context['drafts_pm_save'] && !empty($_POST['id_pm_draft'])) |
|
| 2486 | - DeleteDraft($_POST['id_pm_draft']); |
|
| 2585 | + if ($context['drafts_pm_save'] && !empty($_POST['id_pm_draft'])) { |
|
| 2586 | + DeleteDraft($_POST['id_pm_draft']); |
|
| 2587 | + } |
|
| 2487 | 2588 | } |
| 2488 | 2589 | |
| 2489 | 2590 | // Go back to the where they sent from, if possible... |
@@ -2498,24 +2599,28 @@ discard block |
||
| 2498 | 2599 | |
| 2499 | 2600 | checkSession('request'); |
| 2500 | 2601 | |
| 2501 | - if (isset($_REQUEST['del_selected'])) |
|
| 2502 | - $_REQUEST['pm_action'] = 'delete'; |
|
| 2602 | + if (isset($_REQUEST['del_selected'])) { |
|
| 2603 | + $_REQUEST['pm_action'] = 'delete'; |
|
| 2604 | + } |
|
| 2503 | 2605 | |
| 2504 | 2606 | if (isset($_REQUEST['pm_action']) && $_REQUEST['pm_action'] != '' && !empty($_REQUEST['pms']) && is_array($_REQUEST['pms'])) |
| 2505 | 2607 | { |
| 2506 | - foreach ($_REQUEST['pms'] as $pm) |
|
| 2507 | - $_REQUEST['pm_actions'][(int) $pm] = $_REQUEST['pm_action']; |
|
| 2608 | + foreach ($_REQUEST['pms'] as $pm) { |
|
| 2609 | + $_REQUEST['pm_actions'][(int) $pm] = $_REQUEST['pm_action']; |
|
| 2610 | + } |
|
| 2508 | 2611 | } |
| 2509 | 2612 | |
| 2510 | - if (empty($_REQUEST['pm_actions'])) |
|
| 2511 | - redirectexit($context['current_label_redirect']); |
|
| 2613 | + if (empty($_REQUEST['pm_actions'])) { |
|
| 2614 | + redirectexit($context['current_label_redirect']); |
|
| 2615 | + } |
|
| 2512 | 2616 | |
| 2513 | 2617 | // If we are in conversation, we may need to apply this to every message in the conversation. |
| 2514 | 2618 | if ($context['display_mode'] == 2 && isset($_REQUEST['conversation'])) |
| 2515 | 2619 | { |
| 2516 | 2620 | $id_pms = array(); |
| 2517 | - foreach ($_REQUEST['pm_actions'] as $pm => $dummy) |
|
| 2518 | - $id_pms[] = (int) $pm; |
|
| 2621 | + foreach ($_REQUEST['pm_actions'] as $pm => $dummy) { |
|
| 2622 | + $id_pms[] = (int) $pm; |
|
| 2623 | + } |
|
| 2519 | 2624 | |
| 2520 | 2625 | $request = $smcFunc['db_query']('', ' |
| 2521 | 2626 | SELECT id_pm_head, id_pm |
@@ -2526,8 +2631,9 @@ discard block |
||
| 2526 | 2631 | ) |
| 2527 | 2632 | ); |
| 2528 | 2633 | $pm_heads = array(); |
| 2529 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2530 | - $pm_heads[$row['id_pm_head']] = $row['id_pm']; |
|
| 2634 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2635 | + $pm_heads[$row['id_pm_head']] = $row['id_pm']; |
|
| 2636 | + } |
|
| 2531 | 2637 | $smcFunc['db_free_result']($request); |
| 2532 | 2638 | |
| 2533 | 2639 | $request = $smcFunc['db_query']('', ' |
@@ -2541,8 +2647,9 @@ discard block |
||
| 2541 | 2647 | // Copy the action from the single to PM to the others. |
| 2542 | 2648 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2543 | 2649 | { |
| 2544 | - if (isset($pm_heads[$row['id_pm_head']]) && isset($_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]])) |
|
| 2545 | - $_REQUEST['pm_actions'][$row['id_pm']] = $_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]]; |
|
| 2650 | + if (isset($pm_heads[$row['id_pm_head']]) && isset($_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]])) { |
|
| 2651 | + $_REQUEST['pm_actions'][$row['id_pm']] = $_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]]; |
|
| 2652 | + } |
|
| 2546 | 2653 | } |
| 2547 | 2654 | $smcFunc['db_free_result']($request); |
| 2548 | 2655 | } |
@@ -2553,22 +2660,21 @@ discard block |
||
| 2553 | 2660 | $labels = array(); |
| 2554 | 2661 | foreach ($_REQUEST['pm_actions'] as $pm => $action) |
| 2555 | 2662 | { |
| 2556 | - if ($action === 'delete') |
|
| 2557 | - $to_delete[] = (int) $pm; |
|
| 2558 | - else |
|
| 2663 | + if ($action === 'delete') { |
|
| 2664 | + $to_delete[] = (int) $pm; |
|
| 2665 | + } else |
|
| 2559 | 2666 | { |
| 2560 | 2667 | if (substr($action, 0, 4) == 'add_') |
| 2561 | 2668 | { |
| 2562 | 2669 | $type = 'add'; |
| 2563 | 2670 | $action = substr($action, 4); |
| 2564 | - } |
|
| 2565 | - elseif (substr($action, 0, 4) == 'rem_') |
|
| 2671 | + } elseif (substr($action, 0, 4) == 'rem_') |
|
| 2566 | 2672 | { |
| 2567 | 2673 | $type = 'rem'; |
| 2568 | 2674 | $action = substr($action, 4); |
| 2675 | + } else { |
|
| 2676 | + $type = 'unk'; |
|
| 2569 | 2677 | } |
| 2570 | - else |
|
| 2571 | - $type = 'unk'; |
|
| 2572 | 2678 | |
| 2573 | 2679 | if ($action == '-1' || (int) $action > 0) |
| 2574 | 2680 | { |
@@ -2579,8 +2685,9 @@ discard block |
||
| 2579 | 2685 | } |
| 2580 | 2686 | |
| 2581 | 2687 | // Deleting, it looks like? |
| 2582 | - if (!empty($to_delete)) |
|
| 2583 | - deleteMessages($to_delete, $context['display_mode'] == 2 ? null : $context['folder']); |
|
| 2688 | + if (!empty($to_delete)) { |
|
| 2689 | + deleteMessages($to_delete, $context['display_mode'] == 2 ? null : $context['folder']); |
|
| 2690 | + } |
|
| 2584 | 2691 | |
| 2585 | 2692 | // Are we labeling anything? |
| 2586 | 2693 | if (!empty($to_label) && $context['folder'] == 'inbox') |
@@ -2646,8 +2753,7 @@ discard block |
||
| 2646 | 2753 | } |
| 2647 | 2754 | |
| 2648 | 2755 | $smcFunc['db_free_result']($request2); |
| 2649 | - } |
|
| 2650 | - elseif ($type == 'rem') |
|
| 2756 | + } elseif ($type == 'rem') |
|
| 2651 | 2757 | { |
| 2652 | 2758 | // If we're removing from the inbox, see if we have at least one other label. |
| 2653 | 2759 | // This query is faster than the one above |
@@ -2679,21 +2785,25 @@ discard block |
||
| 2679 | 2785 | if ($to_label[$row['id_pm']] != '-1') |
| 2680 | 2786 | { |
| 2681 | 2787 | // If this label is in the list and we're not adding it, remove it |
| 2682 | - if (array_key_exists($to_label[$row['id_pm']], $labels) && $type !== 'add') |
|
| 2683 | - unset($labels[$to_label[$row['id_pm']]]); |
|
| 2684 | - else if ($type !== 'rem') |
|
| 2685 | - $labels[$to_label[$row['id_pm']]] = $to_label[$row['id_pm']]; |
|
| 2788 | + if (array_key_exists($to_label[$row['id_pm']], $labels) && $type !== 'add') { |
|
| 2789 | + unset($labels[$to_label[$row['id_pm']]]); |
|
| 2790 | + } else if ($type !== 'rem') { |
|
| 2791 | + $labels[$to_label[$row['id_pm']]] = $to_label[$row['id_pm']]; |
|
| 2792 | + } |
|
| 2686 | 2793 | } |
| 2687 | 2794 | |
| 2688 | 2795 | // Removing all labels or just removing the inbox label |
| 2689 | - if ($type == 'rem' && empty($labels)) |
|
| 2690 | - $in_inbox = (empty($context['can_remove_inbox']) ? 1 : 0); |
|
| 2796 | + if ($type == 'rem' && empty($labels)) { |
|
| 2797 | + $in_inbox = (empty($context['can_remove_inbox']) ? 1 : 0); |
|
| 2798 | + } |
|
| 2691 | 2799 | // Adding new labels, but removing inbox and applying new ones |
| 2692 | - elseif ($type == 'add' && !empty($options['pm_remove_inbox_label']) && !empty($labels)) |
|
| 2693 | - $in_inbox = 0; |
|
| 2800 | + elseif ($type == 'add' && !empty($options['pm_remove_inbox_label']) && !empty($labels)) { |
|
| 2801 | + $in_inbox = 0; |
|
| 2802 | + } |
|
| 2694 | 2803 | // Just adding it to the inbox |
| 2695 | - else |
|
| 2696 | - $in_inbox = 1; |
|
| 2804 | + else { |
|
| 2805 | + $in_inbox = 1; |
|
| 2806 | + } |
|
| 2697 | 2807 | |
| 2698 | 2808 | // Are we adding it to or removing it from the inbox? |
| 2699 | 2809 | if ($in_inbox != $row['in_inbox']) |
@@ -2735,8 +2845,9 @@ discard block |
||
| 2735 | 2845 | if (!empty($labels_to_apply)) |
| 2736 | 2846 | { |
| 2737 | 2847 | $inserts = array(); |
| 2738 | - foreach ($labels_to_apply as $label) |
|
| 2739 | - $inserts[] = array($row['id_pm'], $label); |
|
| 2848 | + foreach ($labels_to_apply as $label) { |
|
| 2849 | + $inserts[] = array($row['id_pm'], $label); |
|
| 2850 | + } |
|
| 2740 | 2851 | |
| 2741 | 2852 | $smcFunc['db_insert']('', |
| 2742 | 2853 | '{db_prefix}pm_labeled_messages', |
@@ -2780,11 +2891,13 @@ discard block |
||
| 2780 | 2891 | checkSession('get'); |
| 2781 | 2892 | |
| 2782 | 2893 | // If all then delete all messages the user has. |
| 2783 | - if ($_REQUEST['f'] == 'all') |
|
| 2784 | - deleteMessages(null, null); |
|
| 2894 | + if ($_REQUEST['f'] == 'all') { |
|
| 2895 | + deleteMessages(null, null); |
|
| 2896 | + } |
|
| 2785 | 2897 | // Otherwise just the selected folder. |
| 2786 | - else |
|
| 2787 | - deleteMessages(null, $_REQUEST['f'] != 'sent' ? 'inbox' : 'sent'); |
|
| 2898 | + else { |
|
| 2899 | + deleteMessages(null, $_REQUEST['f'] != 'sent' ? 'inbox' : 'sent'); |
|
| 2900 | + } |
|
| 2788 | 2901 | |
| 2789 | 2902 | // Done... all gone. |
| 2790 | 2903 | redirectexit($context['current_label_redirect']); |
@@ -2821,8 +2934,9 @@ discard block |
||
| 2821 | 2934 | 'msgtime' => $deleteTime, |
| 2822 | 2935 | ) |
| 2823 | 2936 | ); |
| 2824 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 2825 | - $toDelete[] = $row[0]; |
|
| 2937 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 2938 | + $toDelete[] = $row[0]; |
|
| 2939 | + } |
|
| 2826 | 2940 | $smcFunc['db_free_result']($request); |
| 2827 | 2941 | |
| 2828 | 2942 | // Select all messages in their inbox older than $deleteTime. |
@@ -2839,8 +2953,9 @@ discard block |
||
| 2839 | 2953 | 'msgtime' => $deleteTime, |
| 2840 | 2954 | ) |
| 2841 | 2955 | ); |
| 2842 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2843 | - $toDelete[] = $row['id_pm']; |
|
| 2956 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2957 | + $toDelete[] = $row['id_pm']; |
|
| 2958 | + } |
|
| 2844 | 2959 | $smcFunc['db_free_result']($request); |
| 2845 | 2960 | |
| 2846 | 2961 | // Delete the actual messages. |
@@ -2871,26 +2986,29 @@ discard block |
||
| 2871 | 2986 | { |
| 2872 | 2987 | global $user_info, $smcFunc; |
| 2873 | 2988 | |
| 2874 | - if ($owner === null) |
|
| 2875 | - $owner = array($user_info['id']); |
|
| 2876 | - elseif (empty($owner)) |
|
| 2877 | - return; |
|
| 2878 | - elseif (!is_array($owner)) |
|
| 2879 | - $owner = array($owner); |
|
| 2989 | + if ($owner === null) { |
|
| 2990 | + $owner = array($user_info['id']); |
|
| 2991 | + } elseif (empty($owner)) { |
|
| 2992 | + return; |
|
| 2993 | + } elseif (!is_array($owner)) { |
|
| 2994 | + $owner = array($owner); |
|
| 2995 | + } |
|
| 2880 | 2996 | |
| 2881 | 2997 | if ($personal_messages !== null) |
| 2882 | 2998 | { |
| 2883 | - if (empty($personal_messages) || !is_array($personal_messages)) |
|
| 2884 | - return; |
|
| 2999 | + if (empty($personal_messages) || !is_array($personal_messages)) { |
|
| 3000 | + return; |
|
| 3001 | + } |
|
| 2885 | 3002 | |
| 2886 | - foreach ($personal_messages as $index => $delete_id) |
|
| 2887 | - $personal_messages[$index] = (int) $delete_id; |
|
| 3003 | + foreach ($personal_messages as $index => $delete_id) { |
|
| 3004 | + $personal_messages[$index] = (int) $delete_id; |
|
| 3005 | + } |
|
| 2888 | 3006 | |
| 2889 | 3007 | $where = ' |
| 2890 | 3008 | AND id_pm IN ({array_int:pm_list})'; |
| 3009 | + } else { |
|
| 3010 | + $where = ''; |
|
| 2891 | 3011 | } |
| 2892 | - else |
|
| 2893 | - $where = ''; |
|
| 2894 | 3012 | |
| 2895 | 3013 | if ($folder == 'sent' || $folder === null) |
| 2896 | 3014 | { |
@@ -2925,17 +3043,19 @@ discard block |
||
| 2925 | 3043 | // ...And update the statistics accordingly - now including unread messages!. |
| 2926 | 3044 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2927 | 3045 | { |
| 2928 | - if ($row['is_read']) |
|
| 2929 | - updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'])); |
|
| 2930 | - else |
|
| 2931 | - 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'])); |
|
| 3046 | + if ($row['is_read']) { |
|
| 3047 | + updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'])); |
|
| 3048 | + } else { |
|
| 3049 | + 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'])); |
|
| 3050 | + } |
|
| 2932 | 3051 | |
| 2933 | 3052 | // If this is the current member we need to make their message count correct. |
| 2934 | 3053 | if ($user_info['id'] == $row['id_member']) |
| 2935 | 3054 | { |
| 2936 | 3055 | $user_info['messages'] -= $row['num_deleted_messages']; |
| 2937 | - if (!($row['is_read'])) |
|
| 2938 | - $user_info['unread_messages'] -= $row['num_deleted_messages']; |
|
| 3056 | + if (!($row['is_read'])) { |
|
| 3057 | + $user_info['unread_messages'] -= $row['num_deleted_messages']; |
|
| 3058 | + } |
|
| 2939 | 3059 | } |
| 2940 | 3060 | } |
| 2941 | 3061 | $smcFunc['db_free_result']($request); |
@@ -3003,8 +3123,9 @@ discard block |
||
| 3003 | 3123 | ) |
| 3004 | 3124 | ); |
| 3005 | 3125 | $remove_pms = array(); |
| 3006 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3007 | - $remove_pms[] = $row['sender']; |
|
| 3126 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3127 | + $remove_pms[] = $row['sender']; |
|
| 3128 | + } |
|
| 3008 | 3129 | $smcFunc['db_free_result']($request); |
| 3009 | 3130 | |
| 3010 | 3131 | if (!empty($remove_pms)) |
@@ -3049,8 +3170,9 @@ discard block |
||
| 3049 | 3170 | { |
| 3050 | 3171 | global $user_info, $context, $smcFunc; |
| 3051 | 3172 | |
| 3052 | - if ($owner === null) |
|
| 3053 | - $owner = $user_info['id']; |
|
| 3173 | + if ($owner === null) { |
|
| 3174 | + $owner = $user_info['id']; |
|
| 3175 | + } |
|
| 3054 | 3176 | |
| 3055 | 3177 | $in_inbox = ''; |
| 3056 | 3178 | |
@@ -3074,8 +3196,7 @@ discard block |
||
| 3074 | 3196 | } |
| 3075 | 3197 | |
| 3076 | 3198 | $smcFunc['db_free_result']($get_messages); |
| 3077 | - } |
|
| 3078 | - elseif ($label = '-1') |
|
| 3199 | + } elseif ($label = '-1') |
|
| 3079 | 3200 | { |
| 3080 | 3201 | // Marking all PMs in your inbox read |
| 3081 | 3202 | $in_inbox = ' |
@@ -3100,8 +3221,9 @@ discard block |
||
| 3100 | 3221 | { |
| 3101 | 3222 | if ($owner == $user_info['id']) |
| 3102 | 3223 | { |
| 3103 | - foreach ($context['labels'] as $label) |
|
| 3104 | - $context['labels'][(int) $label['id']]['unread_messages'] = 0; |
|
| 3224 | + foreach ($context['labels'] as $label) { |
|
| 3225 | + $context['labels'][(int) $label['id']]['unread_messages'] = 0; |
|
| 3226 | + } |
|
| 3105 | 3227 | } |
| 3106 | 3228 | |
| 3107 | 3229 | $result = $smcFunc['db_query']('', ' |
@@ -3121,8 +3243,9 @@ discard block |
||
| 3121 | 3243 | { |
| 3122 | 3244 | $total_unread += $row['num']; |
| 3123 | 3245 | |
| 3124 | - if ($owner != $user_info['id'] || empty($row['id_pm'])) |
|
| 3125 | - continue; |
|
| 3246 | + if ($owner != $user_info['id'] || empty($row['id_pm'])) { |
|
| 3247 | + continue; |
|
| 3248 | + } |
|
| 3126 | 3249 | |
| 3127 | 3250 | $this_labels = array(); |
| 3128 | 3251 | |
@@ -3146,11 +3269,13 @@ discard block |
||
| 3146 | 3269 | |
| 3147 | 3270 | $smcFunc['db_free_result']($result2); |
| 3148 | 3271 | |
| 3149 | - foreach ($this_labels as $this_label) |
|
| 3150 | - $context['labels'][$this_label]['unread_messages'] += $row['num']; |
|
| 3272 | + foreach ($this_labels as $this_label) { |
|
| 3273 | + $context['labels'][$this_label]['unread_messages'] += $row['num']; |
|
| 3274 | + } |
|
| 3151 | 3275 | |
| 3152 | - if ($row['in_inbox'] == 1) |
|
| 3153 | - $context['labels'][-1]['unread_messages'] += $row['num']; |
|
| 3276 | + if ($row['in_inbox'] == 1) { |
|
| 3277 | + $context['labels'][-1]['unread_messages'] += $row['num']; |
|
| 3278 | + } |
|
| 3154 | 3279 | } |
| 3155 | 3280 | $smcFunc['db_free_result']($result); |
| 3156 | 3281 | |
@@ -3159,8 +3284,9 @@ discard block |
||
| 3159 | 3284 | updateMemberData($owner, array('unread_messages' => $total_unread)); |
| 3160 | 3285 | |
| 3161 | 3286 | // If it was for the current member, reflect this in the $user_info array too. |
| 3162 | - if ($owner == $user_info['id']) |
|
| 3163 | - $user_info['unread_messages'] = $total_unread; |
|
| 3287 | + if ($owner == $user_info['id']) { |
|
| 3288 | + $user_info['unread_messages'] = $total_unread; |
|
| 3289 | + } |
|
| 3164 | 3290 | } |
| 3165 | 3291 | } |
| 3166 | 3292 | |
@@ -3188,8 +3314,9 @@ discard block |
||
| 3188 | 3314 | // Add all existing labels to the array to save, slashing them as necessary... |
| 3189 | 3315 | foreach ($context['labels'] as $label) |
| 3190 | 3316 | { |
| 3191 | - if ($label['id'] != -1) |
|
| 3192 | - $the_labels[$label['id']] = $label['name']; |
|
| 3317 | + if ($label['id'] != -1) { |
|
| 3318 | + $the_labels[$label['id']] = $label['name']; |
|
| 3319 | + } |
|
| 3193 | 3320 | } |
| 3194 | 3321 | |
| 3195 | 3322 | if (isset($_POST[$context['session_var']])) |
@@ -3208,8 +3335,9 @@ discard block |
||
| 3208 | 3335 | { |
| 3209 | 3336 | $_POST['label'] = strtr($smcFunc['htmlspecialchars'](trim($_POST['label'])), array(',' => ',')); |
| 3210 | 3337 | |
| 3211 | - if ($smcFunc['strlen']($_POST['label']) > 30) |
|
| 3212 | - $_POST['label'] = $smcFunc['substr']($_POST['label'], 0, 30); |
|
| 3338 | + if ($smcFunc['strlen']($_POST['label']) > 30) { |
|
| 3339 | + $_POST['label'] = $smcFunc['substr']($_POST['label'], 0, 30); |
|
| 3340 | + } |
|
| 3213 | 3341 | if ($_POST['label'] != '') |
| 3214 | 3342 | { |
| 3215 | 3343 | $the_labels[] = $_POST['label']; |
@@ -3230,23 +3358,24 @@ discard block |
||
| 3230 | 3358 | { |
| 3231 | 3359 | foreach ($the_labels as $id => $name) |
| 3232 | 3360 | { |
| 3233 | - if ($id == -1) |
|
| 3234 | - continue; |
|
| 3235 | - elseif (isset($_POST['label_name'][$id])) |
|
| 3361 | + if ($id == -1) { |
|
| 3362 | + continue; |
|
| 3363 | + } elseif (isset($_POST['label_name'][$id])) |
|
| 3236 | 3364 | { |
| 3237 | 3365 | $_POST['label_name'][$id] = trim(strtr($smcFunc['htmlspecialchars']($_POST['label_name'][$id]), array(',' => ','))); |
| 3238 | 3366 | |
| 3239 | - if ($smcFunc['strlen']($_POST['label_name'][$id]) > 30) |
|
| 3240 | - $_POST['label_name'][$id] = $smcFunc['substr']($_POST['label_name'][$id], 0, 30); |
|
| 3367 | + if ($smcFunc['strlen']($_POST['label_name'][$id]) > 30) { |
|
| 3368 | + $_POST['label_name'][$id] = $smcFunc['substr']($_POST['label_name'][$id], 0, 30); |
|
| 3369 | + } |
|
| 3241 | 3370 | if ($_POST['label_name'][$id] != '') |
| 3242 | 3371 | { |
| 3243 | 3372 | // Changing the name of this label? |
| 3244 | - if ($the_labels[$id] != $_POST['label_name'][$id]) |
|
| 3245 | - $label_updates[$id] = $_POST['label_name'][$id]; |
|
| 3373 | + if ($the_labels[$id] != $_POST['label_name'][$id]) { |
|
| 3374 | + $label_updates[$id] = $_POST['label_name'][$id]; |
|
| 3375 | + } |
|
| 3246 | 3376 | |
| 3247 | 3377 | $the_labels[(int) $id] = $_POST['label_name'][$id]; |
| 3248 | - } |
|
| 3249 | - else |
|
| 3378 | + } else |
|
| 3250 | 3379 | { |
| 3251 | 3380 | unset($the_labels[(int) $id]); |
| 3252 | 3381 | $labels_to_remove[] = $id; |
@@ -3260,8 +3389,9 @@ discard block |
||
| 3260 | 3389 | if (!empty($labels_to_add)) |
| 3261 | 3390 | { |
| 3262 | 3391 | $inserts = array(); |
| 3263 | - foreach ($labels_to_add AS $label) |
|
| 3264 | - $inserts[] = array($user_info['id'], $label); |
|
| 3392 | + foreach ($labels_to_add AS $label) { |
|
| 3393 | + $inserts[] = array($user_info['id'], $label); |
|
| 3394 | + } |
|
| 3265 | 3395 | |
| 3266 | 3396 | $smcFunc['db_insert']('', '{db_prefix}pm_labels', array('id_member' => 'int', 'name' => 'string-30'), $inserts, array()); |
| 3267 | 3397 | } |
@@ -3351,8 +3481,9 @@ discard block |
||
| 3351 | 3481 | // Each action... |
| 3352 | 3482 | foreach ($rule['actions'] as $k2 => $action) |
| 3353 | 3483 | { |
| 3354 | - if ($action['t'] != 'lab' || !in_array($action['v'], $labels_to_remove)) |
|
| 3355 | - continue; |
|
| 3484 | + if ($action['t'] != 'lab' || !in_array($action['v'], $labels_to_remove)) { |
|
| 3485 | + continue; |
|
| 3486 | + } |
|
| 3356 | 3487 | |
| 3357 | 3488 | $rule_changes[] = $rule['id']; |
| 3358 | 3489 | |
@@ -3367,8 +3498,8 @@ discard block |
||
| 3367 | 3498 | { |
| 3368 | 3499 | $rule_changes = array_unique($rule_changes); |
| 3369 | 3500 | // Update/delete as appropriate. |
| 3370 | - foreach ($rule_changes as $k => $id) |
|
| 3371 | - if (!empty($context['rules'][$id]['actions'])) |
|
| 3501 | + foreach ($rule_changes as $k => $id) { |
|
| 3502 | + if (!empty($context['rules'][$id]['actions'])) |
|
| 3372 | 3503 | { |
| 3373 | 3504 | $smcFunc['db_query']('', ' |
| 3374 | 3505 | UPDATE {db_prefix}pm_rules |
@@ -3381,12 +3512,13 @@ discard block |
||
| 3381 | 3512 | 'actions' => $smcFunc['json_encode']($context['rules'][$id]['actions']), |
| 3382 | 3513 | ) |
| 3383 | 3514 | ); |
| 3515 | + } |
|
| 3384 | 3516 | unset($rule_changes[$k]); |
| 3385 | 3517 | } |
| 3386 | 3518 | |
| 3387 | 3519 | // Anything left here means it's lost all actions... |
| 3388 | - if (!empty($rule_changes)) |
|
| 3389 | - $smcFunc['db_query']('', ' |
|
| 3520 | + if (!empty($rule_changes)) { |
|
| 3521 | + $smcFunc['db_query']('', ' |
|
| 3390 | 3522 | DELETE FROM {db_prefix}pm_rules |
| 3391 | 3523 | WHERE id_rule IN ({array_int:rule_list}) |
| 3392 | 3524 | AND id_member = {int:current_member}', |
@@ -3395,6 +3527,7 @@ discard block |
||
| 3395 | 3527 | 'rule_list' => $rule_changes, |
| 3396 | 3528 | ) |
| 3397 | 3529 | ); |
| 3530 | + } |
|
| 3398 | 3531 | } |
| 3399 | 3532 | |
| 3400 | 3533 | // Make sure we're not caching this! |
@@ -3464,8 +3597,9 @@ discard block |
||
| 3464 | 3597 | // Save the fields. |
| 3465 | 3598 | saveProfileFields(); |
| 3466 | 3599 | |
| 3467 | - if (!empty($profile_vars)) |
|
| 3468 | - updateMemberData($user_info['id'], $profile_vars); |
|
| 3600 | + if (!empty($profile_vars)) { |
|
| 3601 | + updateMemberData($user_info['id'], $profile_vars); |
|
| 3602 | + } |
|
| 3469 | 3603 | } |
| 3470 | 3604 | |
| 3471 | 3605 | setupProfileContext( |
@@ -3490,13 +3624,15 @@ discard block |
||
| 3490 | 3624 | global $user_info, $language, $modSettings, $smcFunc; |
| 3491 | 3625 | |
| 3492 | 3626 | // Check that this feature is even enabled! |
| 3493 | - if (empty($modSettings['enableReportPM']) || empty($_REQUEST['pmsg'])) |
|
| 3494 | - fatal_lang_error('no_access', false); |
|
| 3627 | + if (empty($modSettings['enableReportPM']) || empty($_REQUEST['pmsg'])) { |
|
| 3628 | + fatal_lang_error('no_access', false); |
|
| 3629 | + } |
|
| 3495 | 3630 | |
| 3496 | 3631 | $pmsg = (int) $_REQUEST['pmsg']; |
| 3497 | 3632 | |
| 3498 | - if (!isAccessiblePM($pmsg, 'inbox')) |
|
| 3499 | - fatal_lang_error('no_access', false); |
|
| 3633 | + if (!isAccessiblePM($pmsg, 'inbox')) { |
|
| 3634 | + fatal_lang_error('no_access', false); |
|
| 3635 | + } |
|
| 3500 | 3636 | |
| 3501 | 3637 | $context['pm_id'] = $pmsg; |
| 3502 | 3638 | $context['page_title'] = $txt['pm_report_title']; |
@@ -3518,8 +3654,9 @@ discard block |
||
| 3518 | 3654 | ) |
| 3519 | 3655 | ); |
| 3520 | 3656 | $context['admins'] = array(); |
| 3521 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3522 | - $context['admins'][$row['id_member']] = $row['real_name']; |
|
| 3657 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3658 | + $context['admins'][$row['id_member']] = $row['real_name']; |
|
| 3659 | + } |
|
| 3523 | 3660 | $smcFunc['db_free_result']($request); |
| 3524 | 3661 | |
| 3525 | 3662 | // How many admins in total? |
@@ -3548,8 +3685,9 @@ discard block |
||
| 3548 | 3685 | ) |
| 3549 | 3686 | ); |
| 3550 | 3687 | // Can only be a hacker here! |
| 3551 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 3552 | - fatal_lang_error('no_access', false); |
|
| 3688 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 3689 | + fatal_lang_error('no_access', false); |
|
| 3690 | + } |
|
| 3553 | 3691 | list ($subject, $body, $time, $memberFromID, $memberFromName) = $smcFunc['db_fetch_row']($request); |
| 3554 | 3692 | $smcFunc['db_free_result']($request); |
| 3555 | 3693 | |
@@ -3573,15 +3711,17 @@ discard block |
||
| 3573 | 3711 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3574 | 3712 | { |
| 3575 | 3713 | // If it's hidden still don't reveal their names - privacy after all ;) |
| 3576 | - if ($row['bcc']) |
|
| 3577 | - $hidden_recipients++; |
|
| 3578 | - else |
|
| 3579 | - $recipients[] = '[url=' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . ']' . $row['to_name'] . '[/url]'; |
|
| 3714 | + if ($row['bcc']) { |
|
| 3715 | + $hidden_recipients++; |
|
| 3716 | + } else { |
|
| 3717 | + $recipients[] = '[url=' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . ']' . $row['to_name'] . '[/url]'; |
|
| 3718 | + } |
|
| 3580 | 3719 | } |
| 3581 | 3720 | $smcFunc['db_free_result']($request); |
| 3582 | 3721 | |
| 3583 | - if ($hidden_recipients) |
|
| 3584 | - $recipients[] = sprintf($txt['pm_report_pm_hidden'], $hidden_recipients); |
|
| 3722 | + if ($hidden_recipients) { |
|
| 3723 | + $recipients[] = sprintf($txt['pm_report_pm_hidden'], $hidden_recipients); |
|
| 3724 | + } |
|
| 3585 | 3725 | |
| 3586 | 3726 | // Now let's get out and loop through the admins. |
| 3587 | 3727 | $request = $smcFunc['db_query']('', ' |
@@ -3597,8 +3737,9 @@ discard block |
||
| 3597 | 3737 | ); |
| 3598 | 3738 | |
| 3599 | 3739 | // Maybe we shouldn't advertise this? |
| 3600 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 3601 | - fatal_lang_error('no_access', false); |
|
| 3740 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 3741 | + fatal_lang_error('no_access', false); |
|
| 3742 | + } |
|
| 3602 | 3743 | |
| 3603 | 3744 | $memberFromName = un_htmlspecialchars($memberFromName); |
| 3604 | 3745 | |
@@ -3617,8 +3758,9 @@ discard block |
||
| 3617 | 3758 | // Make the body. |
| 3618 | 3759 | $report_body = str_replace(array('{REPORTER}', '{SENDER}'), array(un_htmlspecialchars($user_info['name']), $memberFromName), $txt['pm_report_pm_user_sent']); |
| 3619 | 3760 | $report_body .= "\n" . '[b]' . $_POST['reason'] . '[/b]' . "\n\n"; |
| 3620 | - if (!empty($recipients)) |
|
| 3621 | - $report_body .= $txt['pm_report_pm_other_recipients'] . ' ' . implode(', ', $recipients) . "\n\n"; |
|
| 3761 | + if (!empty($recipients)) { |
|
| 3762 | + $report_body .= $txt['pm_report_pm_other_recipients'] . ' ' . implode(', ', $recipients) . "\n\n"; |
|
| 3763 | + } |
|
| 3622 | 3764 | $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]'; |
| 3623 | 3765 | |
| 3624 | 3766 | // Plonk it in the array ;) |
@@ -3638,12 +3780,14 @@ discard block |
||
| 3638 | 3780 | $smcFunc['db_free_result']($request); |
| 3639 | 3781 | |
| 3640 | 3782 | // Send a different email for each language. |
| 3641 | - foreach ($messagesToSend as $lang => $message) |
|
| 3642 | - sendpm($message['recipients'], $message['subject'], $message['body']); |
|
| 3783 | + foreach ($messagesToSend as $lang => $message) { |
|
| 3784 | + sendpm($message['recipients'], $message['subject'], $message['body']); |
|
| 3785 | + } |
|
| 3643 | 3786 | |
| 3644 | 3787 | // Give the user their own language back! |
| 3645 | - if (!empty($modSettings['userLanguage'])) |
|
| 3646 | - loadLanguage('PersonalMessage', '', false); |
|
| 3788 | + if (!empty($modSettings['userLanguage'])) { |
|
| 3789 | + loadLanguage('PersonalMessage', '', false); |
|
| 3790 | + } |
|
| 3647 | 3791 | |
| 3648 | 3792 | // Leave them with a template. |
| 3649 | 3793 | $context['sub_template'] = 'report_message_complete'; |
@@ -3689,8 +3833,9 @@ discard block |
||
| 3689 | 3833 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3690 | 3834 | { |
| 3691 | 3835 | // Hide hidden groups! |
| 3692 | - if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) |
|
| 3693 | - continue; |
|
| 3836 | + if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) { |
|
| 3837 | + continue; |
|
| 3838 | + } |
|
| 3694 | 3839 | |
| 3695 | 3840 | $context['groups'][$row['id_group']] = $row['group_name']; |
| 3696 | 3841 | } |
@@ -3716,9 +3861,10 @@ discard block |
||
| 3716 | 3861 | $context['rule'] = $context['rules'][$context['rid']]; |
| 3717 | 3862 | $members = array(); |
| 3718 | 3863 | // Need to get member names! |
| 3719 | - foreach ($context['rule']['criteria'] as $k => $criteria) |
|
| 3720 | - if ($criteria['t'] == 'mid' && !empty($criteria['v'])) |
|
| 3864 | + foreach ($context['rule']['criteria'] as $k => $criteria) { |
|
| 3865 | + if ($criteria['t'] == 'mid' && !empty($criteria['v'])) |
|
| 3721 | 3866 | $members[(int) $criteria['v']] = $k; |
| 3867 | + } |
|
| 3722 | 3868 | |
| 3723 | 3869 | if (!empty($members)) |
| 3724 | 3870 | { |
@@ -3730,19 +3876,20 @@ discard block |
||
| 3730 | 3876 | 'member_list' => array_keys($members), |
| 3731 | 3877 | ) |
| 3732 | 3878 | ); |
| 3733 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3734 | - $context['rule']['criteria'][$members[$row['id_member']]]['v'] = $row['member_name']; |
|
| 3879 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3880 | + $context['rule']['criteria'][$members[$row['id_member']]]['v'] = $row['member_name']; |
|
| 3881 | + } |
|
| 3735 | 3882 | $smcFunc['db_free_result']($request); |
| 3736 | 3883 | } |
| 3737 | - } |
|
| 3738 | - else |
|
| 3739 | - $context['rule'] = array( |
|
| 3884 | + } else { |
|
| 3885 | + $context['rule'] = array( |
|
| 3740 | 3886 | 'id' => '', |
| 3741 | 3887 | 'name' => '', |
| 3742 | 3888 | 'criteria' => array(), |
| 3743 | 3889 | 'actions' => array(), |
| 3744 | 3890 | 'logic' => 'and', |
| 3745 | 3891 | ); |
| 3892 | + } |
|
| 3746 | 3893 | } |
| 3747 | 3894 | // Saving? |
| 3748 | 3895 | elseif (isset($_GET['save'])) |
@@ -3752,22 +3899,25 @@ discard block |
||
| 3752 | 3899 | |
| 3753 | 3900 | // Name is easy! |
| 3754 | 3901 | $ruleName = $smcFunc['htmlspecialchars'](trim($_POST['rule_name'])); |
| 3755 | - if (empty($ruleName)) |
|
| 3756 | - fatal_lang_error('pm_rule_no_name', false); |
|
| 3902 | + if (empty($ruleName)) { |
|
| 3903 | + fatal_lang_error('pm_rule_no_name', false); |
|
| 3904 | + } |
|
| 3757 | 3905 | |
| 3758 | 3906 | // Sanity check... |
| 3759 | - if (empty($_POST['ruletype']) || empty($_POST['acttype'])) |
|
| 3760 | - fatal_lang_error('pm_rule_no_criteria', false); |
|
| 3907 | + if (empty($_POST['ruletype']) || empty($_POST['acttype'])) { |
|
| 3908 | + fatal_lang_error('pm_rule_no_criteria', false); |
|
| 3909 | + } |
|
| 3761 | 3910 | |
| 3762 | 3911 | // Let's do the criteria first - it's also hardest! |
| 3763 | 3912 | $criteria = array(); |
| 3764 | 3913 | foreach ($_POST['ruletype'] as $ind => $type) |
| 3765 | 3914 | { |
| 3766 | 3915 | // Check everything is here... |
| 3767 | - if ($type == 'gid' && (!isset($_POST['ruledefgroup'][$ind]) || !isset($context['groups'][$_POST['ruledefgroup'][$ind]]))) |
|
| 3768 | - continue; |
|
| 3769 | - elseif ($type != 'bud' && !isset($_POST['ruledef'][$ind])) |
|
| 3770 | - continue; |
|
| 3916 | + if ($type == 'gid' && (!isset($_POST['ruledefgroup'][$ind]) || !isset($context['groups'][$_POST['ruledefgroup'][$ind]]))) { |
|
| 3917 | + continue; |
|
| 3918 | + } elseif ($type != 'bud' && !isset($_POST['ruledef'][$ind])) { |
|
| 3919 | + continue; |
|
| 3920 | + } |
|
| 3771 | 3921 | |
| 3772 | 3922 | // Members need to be found. |
| 3773 | 3923 | if ($type == 'mid') |
@@ -3791,13 +3941,13 @@ discard block |
||
| 3791 | 3941 | $smcFunc['db_free_result']($request); |
| 3792 | 3942 | |
| 3793 | 3943 | $criteria[] = array('t' => 'mid', 'v' => $memID); |
| 3944 | + } elseif ($type == 'bud') { |
|
| 3945 | + $criteria[] = array('t' => 'bud', 'v' => 1); |
|
| 3946 | + } elseif ($type == 'gid') { |
|
| 3947 | + $criteria[] = array('t' => 'gid', 'v' => (int) $_POST['ruledefgroup'][$ind]); |
|
| 3948 | + } elseif (in_array($type, array('sub', 'msg')) && trim($_POST['ruledef'][$ind]) != '') { |
|
| 3949 | + $criteria[] = array('t' => $type, 'v' => $smcFunc['htmlspecialchars'](trim($_POST['ruledef'][$ind]))); |
|
| 3794 | 3950 | } |
| 3795 | - elseif ($type == 'bud') |
|
| 3796 | - $criteria[] = array('t' => 'bud', 'v' => 1); |
|
| 3797 | - elseif ($type == 'gid') |
|
| 3798 | - $criteria[] = array('t' => 'gid', 'v' => (int) $_POST['ruledefgroup'][$ind]); |
|
| 3799 | - elseif (in_array($type, array('sub', 'msg')) && trim($_POST['ruledef'][$ind]) != '') |
|
| 3800 | - $criteria[] = array('t' => $type, 'v' => $smcFunc['htmlspecialchars'](trim($_POST['ruledef'][$ind]))); |
|
| 3801 | 3951 | } |
| 3802 | 3952 | |
| 3803 | 3953 | // Also do the actions! |
@@ -3807,26 +3957,29 @@ discard block |
||
| 3807 | 3957 | foreach ($_POST['acttype'] as $ind => $type) |
| 3808 | 3958 | { |
| 3809 | 3959 | // Picking a valid label? |
| 3810 | - if ($type == 'lab' && (!isset($_POST['labdef'][$ind]) || !isset($context['labels'][$_POST['labdef'][$ind]]))) |
|
| 3811 | - continue; |
|
| 3960 | + if ($type == 'lab' && (!isset($_POST['labdef'][$ind]) || !isset($context['labels'][$_POST['labdef'][$ind]]))) { |
|
| 3961 | + continue; |
|
| 3962 | + } |
|
| 3812 | 3963 | |
| 3813 | 3964 | // Record what we're doing. |
| 3814 | - if ($type == 'del') |
|
| 3815 | - $doDelete = 1; |
|
| 3816 | - elseif ($type == 'lab') |
|
| 3817 | - $actions[] = array('t' => 'lab', 'v' => (int) $_POST['labdef'][$ind]); |
|
| 3965 | + if ($type == 'del') { |
|
| 3966 | + $doDelete = 1; |
|
| 3967 | + } elseif ($type == 'lab') { |
|
| 3968 | + $actions[] = array('t' => 'lab', 'v' => (int) $_POST['labdef'][$ind]); |
|
| 3969 | + } |
|
| 3818 | 3970 | } |
| 3819 | 3971 | |
| 3820 | - if (empty($criteria) || (empty($actions) && !$doDelete)) |
|
| 3821 | - fatal_lang_error('pm_rule_no_criteria', false); |
|
| 3972 | + if (empty($criteria) || (empty($actions) && !$doDelete)) { |
|
| 3973 | + fatal_lang_error('pm_rule_no_criteria', false); |
|
| 3974 | + } |
|
| 3822 | 3975 | |
| 3823 | 3976 | // What are we storing? |
| 3824 | 3977 | $criteria = $smcFunc['json_encode']($criteria); |
| 3825 | 3978 | $actions = $smcFunc['json_encode']($actions); |
| 3826 | 3979 | |
| 3827 | 3980 | // Create the rule? |
| 3828 | - if (empty($context['rid'])) |
|
| 3829 | - $smcFunc['db_insert']('', |
|
| 3981 | + if (empty($context['rid'])) { |
|
| 3982 | + $smcFunc['db_insert']('', |
|
| 3830 | 3983 | '{db_prefix}pm_rules', |
| 3831 | 3984 | array( |
| 3832 | 3985 | 'id_member' => 'int', 'rule_name' => 'string', 'criteria' => 'string', 'actions' => 'string', |
@@ -3837,8 +3990,8 @@ discard block |
||
| 3837 | 3990 | ), |
| 3838 | 3991 | array('id_rule') |
| 3839 | 3992 | ); |
| 3840 | - else |
|
| 3841 | - $smcFunc['db_query']('', ' |
|
| 3993 | + } else { |
|
| 3994 | + $smcFunc['db_query']('', ' |
|
| 3842 | 3995 | UPDATE {db_prefix}pm_rules |
| 3843 | 3996 | SET rule_name = {string:rule_name}, criteria = {string:criteria}, actions = {string:actions}, |
| 3844 | 3997 | delete_pm = {int:delete_pm}, is_or = {int:is_or} |
@@ -3854,6 +4007,7 @@ discard block |
||
| 3854 | 4007 | 'actions' => $actions, |
| 3855 | 4008 | ) |
| 3856 | 4009 | ); |
| 4010 | + } |
|
| 3857 | 4011 | |
| 3858 | 4012 | redirectexit('action=pm;sa=manrules'); |
| 3859 | 4013 | } |
@@ -3862,11 +4016,12 @@ discard block |
||
| 3862 | 4016 | { |
| 3863 | 4017 | checkSession(); |
| 3864 | 4018 | $toDelete = array(); |
| 3865 | - foreach ($_POST['delrule'] as $k => $v) |
|
| 3866 | - $toDelete[] = (int) $k; |
|
| 4019 | + foreach ($_POST['delrule'] as $k => $v) { |
|
| 4020 | + $toDelete[] = (int) $k; |
|
| 4021 | + } |
|
| 3867 | 4022 | |
| 3868 | - if (!empty($toDelete)) |
|
| 3869 | - $smcFunc['db_query']('', ' |
|
| 4023 | + if (!empty($toDelete)) { |
|
| 4024 | + $smcFunc['db_query']('', ' |
|
| 3870 | 4025 | DELETE FROM {db_prefix}pm_rules |
| 3871 | 4026 | WHERE id_rule IN ({array_int:delete_list}) |
| 3872 | 4027 | AND id_member = {int:current_member}', |
@@ -3875,6 +4030,7 @@ discard block |
||
| 3875 | 4030 | 'delete_list' => $toDelete, |
| 3876 | 4031 | ) |
| 3877 | 4032 | ); |
| 4033 | + } |
|
| 3878 | 4034 | |
| 3879 | 4035 | redirectexit('action=pm;sa=manrules'); |
| 3880 | 4036 | } |
@@ -3893,8 +4049,9 @@ discard block |
||
| 3893 | 4049 | loadRules(); |
| 3894 | 4050 | |
| 3895 | 4051 | // No rules? |
| 3896 | - if (empty($context['rules'])) |
|
| 3897 | - return; |
|
| 4052 | + if (empty($context['rules'])) { |
|
| 4053 | + return; |
|
| 4054 | + } |
|
| 3898 | 4055 | |
| 3899 | 4056 | // Just unread ones? |
| 3900 | 4057 | $ruleQuery = $all_messages ? '' : ' AND pmr.is_new = 1'; |
@@ -3924,8 +4081,9 @@ discard block |
||
| 3924 | 4081 | // Loop through all the criteria hoping to make a match. |
| 3925 | 4082 | foreach ($rule['criteria'] as $criterium) |
| 3926 | 4083 | { |
| 3927 | - 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)) |
|
| 3928 | - $match = true; |
|
| 4084 | + 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)) { |
|
| 4085 | + $match = true; |
|
| 4086 | + } |
|
| 3929 | 4087 | // If we're adding and one criteria don't match then we stop! |
| 3930 | 4088 | elseif ($rule['logic'] == 'and') |
| 3931 | 4089 | { |
@@ -3937,17 +4095,18 @@ discard block |
||
| 3937 | 4095 | // If we have a match the rule must be true - act! |
| 3938 | 4096 | if ($match) |
| 3939 | 4097 | { |
| 3940 | - if ($rule['delete']) |
|
| 3941 | - $actions['deletes'][] = $row['id_pm']; |
|
| 3942 | - else |
|
| 4098 | + if ($rule['delete']) { |
|
| 4099 | + $actions['deletes'][] = $row['id_pm']; |
|
| 4100 | + } else |
|
| 3943 | 4101 | { |
| 3944 | 4102 | foreach ($rule['actions'] as $ruleAction) |
| 3945 | 4103 | { |
| 3946 | 4104 | if ($ruleAction['t'] == 'lab') |
| 3947 | 4105 | { |
| 3948 | 4106 | // Get a basic pot started! |
| 3949 | - if (!isset($actions['labels'][$row['id_pm']])) |
|
| 3950 | - $actions['labels'][$row['id_pm']] = array(); |
|
| 4107 | + if (!isset($actions['labels'][$row['id_pm']])) { |
|
| 4108 | + $actions['labels'][$row['id_pm']] = array(); |
|
| 4109 | + } |
|
| 3951 | 4110 | $actions['labels'][$row['id_pm']][] = $ruleAction['v']; |
| 3952 | 4111 | } |
| 3953 | 4112 | } |
@@ -3958,8 +4117,9 @@ discard block |
||
| 3958 | 4117 | $smcFunc['db_free_result']($request); |
| 3959 | 4118 | |
| 3960 | 4119 | // Deletes are easy! |
| 3961 | - if (!empty($actions['deletes'])) |
|
| 3962 | - deleteMessages($actions['deletes']); |
|
| 4120 | + if (!empty($actions['deletes'])) { |
|
| 4121 | + deleteMessages($actions['deletes']); |
|
| 4122 | + } |
|
| 3963 | 4123 | |
| 3964 | 4124 | // Relabel? |
| 3965 | 4125 | if (!empty($actions['labels'])) |
@@ -3986,8 +4146,7 @@ discard block |
||
| 3986 | 4146 | 'current_member' => $user_info['id'], |
| 3987 | 4147 | ) |
| 3988 | 4148 | ); |
| 3989 | - } |
|
| 3990 | - else |
|
| 4149 | + } else |
|
| 3991 | 4150 | { |
| 3992 | 4151 | $realLabels[] = $label['id']; |
| 3993 | 4152 | } |
@@ -3996,8 +4155,9 @@ discard block |
||
| 3996 | 4155 | |
| 3997 | 4156 | $inserts = array(); |
| 3998 | 4157 | // Now we insert the label info |
| 3999 | - foreach ($realLabels as $a_label) |
|
| 4000 | - $inserts[] = array($pm, $a_label); |
|
| 4158 | + foreach ($realLabels as $a_label) { |
|
| 4159 | + $inserts[] = array($pm, $a_label); |
|
| 4160 | + } |
|
| 4001 | 4161 | |
| 4002 | 4162 | $smcFunc['db_insert']('ignore', |
| 4003 | 4163 | '{db_prefix}pm_labeled_messages', |
@@ -4018,8 +4178,9 @@ discard block |
||
| 4018 | 4178 | { |
| 4019 | 4179 | global $user_info, $context, $smcFunc; |
| 4020 | 4180 | |
| 4021 | - if (isset($context['rules']) && !$reload) |
|
| 4022 | - return; |
|
| 4181 | + if (isset($context['rules']) && !$reload) { |
|
| 4182 | + return; |
|
| 4183 | + } |
|
| 4023 | 4184 | |
| 4024 | 4185 | $request = $smcFunc['db_query']('', ' |
| 4025 | 4186 | SELECT |
@@ -4043,8 +4204,9 @@ discard block |
||
| 4043 | 4204 | 'logic' => $row['is_or'] ? 'or' : 'and', |
| 4044 | 4205 | ); |
| 4045 | 4206 | |
| 4046 | - if ($row['delete_pm']) |
|
| 4047 | - $context['rules'][$row['id_rule']]['actions'][] = array('t' => 'del', 'v' => 1); |
|
| 4207 | + if ($row['delete_pm']) { |
|
| 4208 | + $context['rules'][$row['id_rule']]['actions'][] = array('t' => 'del', 'v' => 1); |
|
| 4209 | + } |
|
| 4048 | 4210 | } |
| 4049 | 4211 | $smcFunc['db_free_result']($request); |
| 4050 | 4212 | } |
@@ -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 | * Create a menu. |
@@ -64,22 +65,26 @@ discard block |
||
| 64 | 65 | $menu_context['current_action'] = isset($menuOptions['action']) ? $menuOptions['action'] : $context['current_action']; |
| 65 | 66 | |
| 66 | 67 | // Allow extend *any* menu with a single hook |
| 67 | - if (!empty($menu_context['current_action'])) |
|
| 68 | - call_integration_hook('integrate_' . $menu_context['current_action'] . '_areas', array(&$menuData)); |
|
| 68 | + if (!empty($menu_context['current_action'])) { |
|
| 69 | + call_integration_hook('integrate_' . $menu_context['current_action'] . '_areas', array(&$menuData)); |
|
| 70 | + } |
|
| 69 | 71 | |
| 70 | 72 | // What is the current area selected? |
| 71 | - if (isset($menuOptions['current_area']) || isset($_GET['area'])) |
|
| 72 | - $menu_context['current_area'] = isset($menuOptions['current_area']) ? $menuOptions['current_area'] : $_GET['area']; |
|
| 73 | + if (isset($menuOptions['current_area']) || isset($_GET['area'])) { |
|
| 74 | + $menu_context['current_area'] = isset($menuOptions['current_area']) ? $menuOptions['current_area'] : $_GET['area']; |
|
| 75 | + } |
|
| 73 | 76 | |
| 74 | 77 | // Build a list of additional parameters that should go in the URL. |
| 75 | 78 | $menu_context['extra_parameters'] = ''; |
| 76 | - if (!empty($menuOptions['extra_url_parameters'])) |
|
| 77 | - foreach ($menuOptions['extra_url_parameters'] as $key => $value) |
|
| 79 | + if (!empty($menuOptions['extra_url_parameters'])) { |
|
| 80 | + foreach ($menuOptions['extra_url_parameters'] as $key => $value) |
|
| 78 | 81 | $menu_context['extra_parameters'] .= ';' . $key . '=' . $value; |
| 82 | + } |
|
| 79 | 83 | |
| 80 | 84 | // Only include the session ID in the URL if it's strictly necessary. |
| 81 | - if (empty($menuOptions['disable_url_session_check'])) |
|
| 82 | - $menu_context['extra_parameters'] .= ';' . $context['session_var'] . '=' . $context['session_id']; |
|
| 85 | + if (empty($menuOptions['disable_url_session_check'])) { |
|
| 86 | + $menu_context['extra_parameters'] .= ';' . $context['session_var'] . '=' . $context['session_id']; |
|
| 87 | + } |
|
| 83 | 88 | |
| 84 | 89 | $include_data = array(); |
| 85 | 90 | |
@@ -87,8 +92,9 @@ discard block |
||
| 87 | 92 | foreach ($menuData as $section_id => $section) |
| 88 | 93 | { |
| 89 | 94 | // Is this enabled - or has as permission check - which fails? |
| 90 | - if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($section['permission']) && !allowedTo($section['permission']))) |
|
| 91 | - continue; |
|
| 95 | + if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($section['permission']) && !allowedTo($section['permission']))) { |
|
| 96 | + continue; |
|
| 97 | + } |
|
| 92 | 98 | |
| 93 | 99 | // Now we cycle through the sections to pick the right area. |
| 94 | 100 | foreach ($section['areas'] as $area_id => $area) |
@@ -110,67 +116,67 @@ discard block |
||
| 110 | 116 | if (empty($area['hidden'])) |
| 111 | 117 | { |
| 112 | 118 | // First time this section? |
| 113 | - if (!isset($menu_context['sections'][$section_id])) |
|
| 114 | - $menu_context['sections'][$section_id]['title'] = $section['title']; |
|
| 119 | + if (!isset($menu_context['sections'][$section_id])) { |
|
| 120 | + $menu_context['sections'][$section_id]['title'] = $section['title']; |
|
| 121 | + } |
|
| 115 | 122 | |
| 116 | 123 | // Is there a counter amount to show for this section? |
| 117 | - if (!empty($section['amt'])) |
|
| 118 | - $menu_context['sections'][$section_id]['amt'] = $section['amt']; |
|
| 124 | + if (!empty($section['amt'])) { |
|
| 125 | + $menu_context['sections'][$section_id]['amt'] = $section['amt']; |
|
| 126 | + } |
|
| 119 | 127 | |
| 120 | 128 | $menu_context['sections'][$section_id]['areas'][$area_id] = array('label' => isset($area['label']) ? $area['label'] : $txt[$area_id]); |
| 121 | 129 | // We'll need the ID as well... |
| 122 | 130 | $menu_context['sections'][$section_id]['id'] = $section_id; |
| 123 | 131 | // Does it have a custom URL? |
| 124 | - if (isset($area['custom_url'])) |
|
| 125 | - $menu_context['sections'][$section_id]['areas'][$area_id]['url'] = $area['custom_url']; |
|
| 132 | + if (isset($area['custom_url'])) { |
|
| 133 | + $menu_context['sections'][$section_id]['areas'][$area_id]['url'] = $area['custom_url']; |
|
| 134 | + } |
|
| 126 | 135 | |
| 127 | 136 | // Is there a counter amount to show for this area? |
| 128 | - if (!empty($area['amt'])) |
|
| 129 | - $menu_context['sections'][$section_id]['areas'][$area_id]['amt'] = $area['amt']; |
|
| 137 | + if (!empty($area['amt'])) { |
|
| 138 | + $menu_context['sections'][$section_id]['areas'][$area_id]['amt'] = $area['amt']; |
|
| 139 | + } |
|
| 130 | 140 | |
| 131 | 141 | // Does this area have its own icon? |
| 132 | 142 | if (!isset($area['force_menu_into_arms_of_another_menu']) && $user_info['name'] == 'iamanoompaloompa') |
| 133 | 143 | { |
| 134 | 144 | $menu_context['sections'][$section_id]['areas'][$area_id] = $smcFunc['json_decode'](base64_decode('eyJsYWJlbCI6Ik9vbXBhIExvb21wYSIsInVybCI6Imh0dHBzOlwvXC9lbi53aWtpcGVkaWEub3JnXC93aWtpXC9Pb21wYV9Mb29tcGFzPyIsImljb24iOiI8aW1nIHNyYz1cImh0dHBzOlwvXC93d3cuc2ltcGxlbWFjaGluZXMub3JnXC9pbWFnZXNcL29vbXBhLmdpZlwiIGFsdD1cIkknbSBhbiBPb21wYSBMb29tcGFcIiBcLz4ifQ=='), true); |
| 135 | - } |
|
| 136 | - elseif (isset($area['icon'])) |
|
| 145 | + } elseif (isset($area['icon'])) |
|
| 137 | 146 | { |
| 138 | 147 | if (file_exists($settings['theme_dir'] . '/images/admin/' . $area['icon'])) |
| 139 | 148 | { |
| 140 | 149 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['images_url'] . '/admin/' . $area['icon'] . '" alt="">'; |
| 141 | - } |
|
| 142 | - elseif (file_exists($settings['default_theme_dir'] . '/images/admin/' . $area['icon'])) |
|
| 150 | + } elseif (file_exists($settings['default_theme_dir'] . '/images/admin/' . $area['icon'])) |
|
| 143 | 151 | { |
| 144 | 152 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['default_images_url'] . '/admin/' . $area['icon'] . '" alt="">'; |
| 153 | + } else { |
|
| 154 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area['icon'] . '"></span>'; |
|
| 145 | 155 | } |
| 146 | - else |
|
| 147 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area['icon'] . '"></span>'; |
|
| 156 | + } else { |
|
| 157 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area_id . '"></span>'; |
|
| 148 | 158 | } |
| 149 | - else |
|
| 150 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area_id . '"></span>'; |
|
| 151 | 159 | |
| 152 | 160 | if (isset($area['icon_class']) && empty($menu_context['sections'][$section_id]['areas'][$area_id]['icon'])) |
| 153 | 161 | { |
| 154 | 162 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . $area['icon_class']; |
| 155 | - } |
|
| 156 | - elseif (isset($area['icon'])) |
|
| 163 | + } elseif (isset($area['icon'])) |
|
| 157 | 164 | { |
| 158 | 165 | if (substr($area['icon'], -4) === '.png' || substr($area['icon'], -4) === '.gif') |
| 159 | 166 | { |
| 160 | 167 | if (file_exists($settings['theme_dir'] . '/images/admin/big/' . $area['icon'])) |
| 161 | 168 | { |
| 162 | 169 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['theme_url'] . '/images/admin/big/' . $area['icon']; |
| 163 | - } |
|
| 164 | - elseif (file_exists($settings['default_theme_dir'] . '/images/admin/big/' . $area['icon'])) |
|
| 170 | + } elseif (file_exists($settings['default_theme_dir'] . '/images/admin/big/' . $area['icon'])) |
|
| 165 | 171 | { |
| 166 | 172 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['default_theme_url'] . '/images/admin/big/' . $area['icon']; |
| 167 | 173 | } |
| 168 | 174 | } |
| 169 | 175 | |
| 170 | 176 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area['icon']); |
| 177 | + } else { |
|
| 178 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area_id); |
|
| 171 | 179 | } |
| 172 | - else |
|
| 173 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area_id); |
|
| 174 | 180 | |
| 175 | 181 | // This is a shortcut for Font-Icon users so they don't have to re-do whole CSS. |
| 176 | 182 | $menu_context['sections'][$section_id]['areas'][$area_id]['plain_class'] = !empty($area['icon']) ? $area['icon'] : ''; |
@@ -187,39 +193,46 @@ discard block |
||
| 187 | 193 | { |
| 188 | 194 | if ((empty($sub[1]) || allowedTo($sub[1])) && (!isset($sub['enabled']) || !empty($sub['enabled']))) |
| 189 | 195 | { |
| 190 | - if ($first_sa == null) |
|
| 191 | - $first_sa = $sa; |
|
| 196 | + if ($first_sa == null) { |
|
| 197 | + $first_sa = $sa; |
|
| 198 | + } |
|
| 192 | 199 | |
| 193 | 200 | $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa] = array('label' => $sub[0]); |
| 194 | 201 | // Custom URL? |
| 195 | - if (isset($sub['url'])) |
|
| 196 | - $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['url'] = $sub['url']; |
|
| 202 | + if (isset($sub['url'])) { |
|
| 203 | + $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['url'] = $sub['url']; |
|
| 204 | + } |
|
| 197 | 205 | |
| 198 | 206 | // Is there a counter amount to show for this subsection? |
| 199 | - if (!empty($sub['amt'])) |
|
| 200 | - $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['amt'] = $sub['amt']; |
|
| 207 | + if (!empty($sub['amt'])) { |
|
| 208 | + $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['amt'] = $sub['amt']; |
|
| 209 | + } |
|
| 201 | 210 | |
| 202 | 211 | // A bit complicated - but is this set? |
| 203 | 212 | if ($menu_context['current_area'] == $area_id) |
| 204 | 213 | { |
| 205 | 214 | // Save which is the first... |
| 206 | - if (empty($first_sa)) |
|
| 207 | - $first_sa = $sa; |
|
| 215 | + if (empty($first_sa)) { |
|
| 216 | + $first_sa = $sa; |
|
| 217 | + } |
|
| 208 | 218 | |
| 209 | 219 | // Is this the current subsection? |
| 210 | - if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == $sa) |
|
| 211 | - $menu_context['current_subsection'] = $sa; |
|
| 220 | + if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == $sa) { |
|
| 221 | + $menu_context['current_subsection'] = $sa; |
|
| 222 | + } |
|
| 212 | 223 | // Otherwise is it the default? |
| 213 | - elseif (!isset($menu_context['current_subsection']) && !empty($sub[2])) |
|
| 214 | - $menu_context['current_subsection'] = $sa; |
|
| 224 | + elseif (!isset($menu_context['current_subsection']) && !empty($sub[2])) { |
|
| 225 | + $menu_context['current_subsection'] = $sa; |
|
| 226 | + } |
|
| 215 | 227 | } |
| 216 | 228 | |
| 217 | 229 | // Let's assume this is the last, for now. |
| 218 | 230 | $last_sa = $sa; |
| 219 | 231 | } |
| 220 | 232 | // Mark it as disabled... |
| 221 | - else |
|
| 222 | - $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['disabled'] = true; |
|
| 233 | + else { |
|
| 234 | + $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['disabled'] = true; |
|
| 235 | + } |
|
| 223 | 236 | } |
| 224 | 237 | |
| 225 | 238 | // Set which one is first, last and selected in the group. |
@@ -228,8 +241,9 @@ discard block |
||
| 228 | 241 | $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$context['right_to_left'] ? $last_sa : $first_sa]['is_first'] = true; |
| 229 | 242 | $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$context['right_to_left'] ? $first_sa : $last_sa]['is_last'] = true; |
| 230 | 243 | |
| 231 | - if ($menu_context['current_area'] == $area_id && !isset($menu_context['current_subsection'])) |
|
| 232 | - $menu_context['current_subsection'] = $first_sa; |
|
| 244 | + if ($menu_context['current_area'] == $area_id && !isset($menu_context['current_subsection'])) { |
|
| 245 | + $menu_context['current_subsection'] = $first_sa; |
|
| 246 | + } |
|
| 233 | 247 | } |
| 234 | 248 | } |
| 235 | 249 | } |
@@ -263,23 +277,26 @@ discard block |
||
| 263 | 277 | $menu_context['base_url'] = isset($menuOptions['base_url']) ? $menuOptions['base_url'] : $scripturl . '?action=' . $menu_context['current_action']; |
| 264 | 278 | |
| 265 | 279 | // If we didn't find the area we were looking for go to a default one. |
| 266 | - if (isset($backup_area) && empty($found_section)) |
|
| 267 | - $menu_context['current_area'] = $backup_area; |
|
| 280 | + if (isset($backup_area) && empty($found_section)) { |
|
| 281 | + $menu_context['current_area'] = $backup_area; |
|
| 282 | + } |
|
| 268 | 283 | |
| 269 | 284 | // If there are sections quickly goes through all the sections to check if the base menu has an url |
| 270 | 285 | if (!empty($menu_context['current_section'])) |
| 271 | 286 | { |
| 272 | 287 | $menu_context['sections'][$menu_context['current_section']]['selected'] = true; |
| 273 | 288 | $menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['selected'] = true; |
| 274 | - if (!empty($menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']])) |
|
| 275 | - $menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]['selected'] = true; |
|
| 289 | + if (!empty($menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']])) { |
|
| 290 | + $menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]['selected'] = true; |
|
| 291 | + } |
|
| 276 | 292 | |
| 277 | - foreach ($menu_context['sections'] as $section_id => $section) |
|
| 278 | - foreach ($section['areas'] as $area_id => $area) |
|
| 293 | + foreach ($menu_context['sections'] as $section_id => $section) { |
|
| 294 | + foreach ($section['areas'] as $area_id => $area) |
|
| 279 | 295 | { |
| 280 | 296 | if (!isset($menu_context['sections'][$section_id]['url'])) |
| 281 | 297 | { |
| 282 | 298 | $menu_context['sections'][$section_id]['url'] = isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $area_id; |
| 299 | + } |
|
| 283 | 300 | break; |
| 284 | 301 | } |
| 285 | 302 | } |
@@ -290,8 +307,9 @@ discard block |
||
| 290 | 307 | { |
| 291 | 308 | // Never happened! |
| 292 | 309 | $context['max_menu_id']--; |
| 293 | - if ($context['max_menu_id'] == 0) |
|
| 294 | - unset($context['max_menu_id']); |
|
| 310 | + if ($context['max_menu_id'] == 0) { |
|
| 311 | + unset($context['max_menu_id']); |
|
| 312 | + } |
|
| 295 | 313 | |
| 296 | 314 | return false; |
| 297 | 315 | } |
@@ -302,8 +320,9 @@ discard block |
||
| 302 | 320 | $context['template_layers'][] = $menu_context['layer_name']; |
| 303 | 321 | |
| 304 | 322 | // Check we had something - for sanity sake. |
| 305 | - if (empty($include_data)) |
|
| 306 | - return false; |
|
| 323 | + if (empty($include_data)) { |
|
| 324 | + return false; |
|
| 325 | + } |
|
| 307 | 326 | |
| 308 | 327 | // Finally - return information on the selected item. |
| 309 | 328 | $include_data += array( |
@@ -326,12 +345,14 @@ discard block |
||
| 326 | 345 | global $context; |
| 327 | 346 | |
| 328 | 347 | $menu_name = $menu_id == 'last' && isset($context['max_menu_id']) && isset($context['menu_data_' . $context['max_menu_id']]) ? 'menu_data_' . $context['max_menu_id'] : 'menu_data_' . $menu_id; |
| 329 | - if (!isset($context[$menu_name])) |
|
| 330 | - return false; |
|
| 348 | + if (!isset($context[$menu_name])) { |
|
| 349 | + return false; |
|
| 350 | + } |
|
| 331 | 351 | |
| 332 | 352 | $layer_index = array_search($context[$menu_name]['layer_name'], $context['template_layers']); |
| 333 | - if ($layer_index !== false) |
|
| 334 | - unset($context['template_layers'][$layer_index]); |
|
| 353 | + if ($layer_index !== false) { |
|
| 354 | + unset($context['template_layers'][$layer_index]); |
|
| 355 | + } |
|
| 335 | 356 | |
| 336 | 357 | unset($context[$menu_name]); |
| 337 | 358 | } |
@@ -83,16 +83,18 @@ discard block |
||
| 83 | 83 | foreach ($section['areas'] as $i => $area) |
| 84 | 84 | { |
| 85 | 85 | // Not supposed to be printed? |
| 86 | - if (empty($area['label'])) |
|
| 87 | - continue; |
|
| 86 | + if (empty($area['label'])) { |
|
| 87 | + continue; |
|
| 88 | + } |
|
| 88 | 89 | |
| 89 | 90 | echo ' |
| 90 | 91 | <li', !empty($area['subsections']) ? ' class="subsections"' : '', '> |
| 91 | 92 | <a class="', $area['icon_class'], !empty($area['selected']) ? ' chosen ' : '', '" href="', (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i), $menu_context['extra_parameters'], '">', $area['icon'], $area['label'], !empty($area['amt']) ? ' <span class="amt">' . $area['amt'] . '</span>' : '', '</a>'; |
| 92 | 93 | |
| 93 | 94 | // Is this the current area, or just some area? |
| 94 | - if (!empty($area['selected']) && empty($context['tabs'])) |
|
| 95 | - $context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array(); |
|
| 95 | + if (!empty($area['selected']) && empty($context['tabs'])) { |
|
| 96 | + $context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array(); |
|
| 97 | + } |
|
| 96 | 98 | |
| 97 | 99 | // Are there any subsections? |
| 98 | 100 | if (!empty($area['subsections'])) |
@@ -102,8 +104,9 @@ discard block |
||
| 102 | 104 | |
| 103 | 105 | foreach ($area['subsections'] as $sa => $sub) |
| 104 | 106 | { |
| 105 | - if (!empty($sub['disabled'])) |
|
| 106 | - continue; |
|
| 107 | + if (!empty($sub['disabled'])) { |
|
| 108 | + continue; |
|
| 109 | + } |
|
| 107 | 110 | |
| 108 | 111 | $url = isset($sub['url']) ? $sub['url'] : (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i) . ';sa=' . $sa; |
| 109 | 112 | |
@@ -150,8 +153,9 @@ discard block |
||
| 150 | 153 | <h3 class="catbg">'; |
| 151 | 154 | |
| 152 | 155 | // The function is in Admin.template.php, but since this template is used elsewhere too better check if the function is available |
| 153 | - if (function_exists('template_admin_quick_search')) |
|
| 154 | - template_admin_quick_search(); |
|
| 156 | + if (function_exists('template_admin_quick_search')) { |
|
| 157 | + template_admin_quick_search(); |
|
| 158 | + } |
|
| 155 | 159 | |
| 156 | 160 | // Exactly how many tabs do we have? |
| 157 | 161 | if (!empty($context['tabs'])) |
@@ -166,30 +170,36 @@ discard block |
||
| 166 | 170 | } |
| 167 | 171 | |
| 168 | 172 | // Did this not even exist - or do we not have a label? |
| 169 | - if (!isset($tab_context['tabs'][$id])) |
|
| 170 | - $tab_context['tabs'][$id] = array('label' => $tab['label']); |
|
| 171 | - elseif (!isset($tab_context['tabs'][$id]['label'])) |
|
| 172 | - $tab_context['tabs'][$id]['label'] = $tab['label']; |
|
| 173 | + if (!isset($tab_context['tabs'][$id])) { |
|
| 174 | + $tab_context['tabs'][$id] = array('label' => $tab['label']); |
|
| 175 | + } elseif (!isset($tab_context['tabs'][$id]['label'])) { |
|
| 176 | + $tab_context['tabs'][$id]['label'] = $tab['label']; |
|
| 177 | + } |
|
| 173 | 178 | |
| 174 | 179 | // Has a custom URL defined in the main admin structure? |
| 175 | - if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url'])) |
|
| 176 | - $tab_context['tabs'][$id]['url'] = $tab['url']; |
|
| 180 | + if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url'])) { |
|
| 181 | + $tab_context['tabs'][$id]['url'] = $tab['url']; |
|
| 182 | + } |
|
| 177 | 183 | |
| 178 | 184 | // Any additional paramaters for the url? |
| 179 | - if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params'])) |
|
| 180 | - $tab_context['tabs'][$id]['add_params'] = $tab['add_params']; |
|
| 185 | + if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params'])) { |
|
| 186 | + $tab_context['tabs'][$id]['add_params'] = $tab['add_params']; |
|
| 187 | + } |
|
| 181 | 188 | |
| 182 | 189 | // Has it been deemed selected? |
| 183 | - if (!empty($tab['is_selected'])) |
|
| 184 | - $tab_context['tabs'][$id]['is_selected'] = true; |
|
| 190 | + if (!empty($tab['is_selected'])) { |
|
| 191 | + $tab_context['tabs'][$id]['is_selected'] = true; |
|
| 192 | + } |
|
| 185 | 193 | |
| 186 | 194 | // Does it have its own help? |
| 187 | - if (!empty($tab['help'])) |
|
| 188 | - $tab_context['tabs'][$id]['help'] = $tab['help']; |
|
| 195 | + if (!empty($tab['help'])) { |
|
| 196 | + $tab_context['tabs'][$id]['help'] = $tab['help']; |
|
| 197 | + } |
|
| 189 | 198 | |
| 190 | 199 | // Is this the last one? |
| 191 | - if (!empty($tab['is_last']) && !isset($tab_context['override_last'])) |
|
| 192 | - $tab_context['tabs'][$id]['is_last'] = true; |
|
| 200 | + if (!empty($tab['is_last']) && !isset($tab_context['override_last'])) { |
|
| 201 | + $tab_context['tabs'][$id]['is_last'] = true; |
|
| 202 | + } |
|
| 193 | 203 | } |
| 194 | 204 | |
| 195 | 205 | // Find the selected tab |
@@ -206,22 +216,24 @@ discard block |
||
| 206 | 216 | // Show an icon and/or a help item? |
| 207 | 217 | if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']) || !empty($selected_tab['icon']) || !empty($tab_context['icon']) || !empty($selected_tab['help']) || !empty($tab_context['help'])) |
| 208 | 218 | { |
| 209 | - if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class'])) |
|
| 210 | - echo ' |
|
| 219 | + if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class'])) { |
|
| 220 | + echo ' |
|
| 211 | 221 | <span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>'; |
| 212 | - elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon'])) |
|
| 213 | - echo ' |
|
| 222 | + } elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon'])) { |
|
| 223 | + echo ' |
|
| 214 | 224 | <img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">'; |
| 225 | + } |
|
| 215 | 226 | |
| 216 | - if (!empty($selected_tab['help']) || !empty($tab_context['help'])) |
|
| 217 | - echo ' |
|
| 227 | + if (!empty($selected_tab['help']) || !empty($tab_context['help'])) { |
|
| 228 | + echo ' |
|
| 218 | 229 | <a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>'; |
| 230 | + } |
|
| 219 | 231 | |
| 220 | 232 | echo $tab_context['title']; |
| 221 | - } |
|
| 222 | - else |
|
| 223 | - echo ' |
|
| 233 | + } else { |
|
| 234 | + echo ' |
|
| 224 | 235 | ', $tab_context['title']; |
| 236 | + } |
|
| 225 | 237 | |
| 226 | 238 | echo ' |
| 227 | 239 | </h3>', (function_exists('template_admin_quick_search') ? ' |
@@ -230,11 +242,12 @@ discard block |
||
| 230 | 242 | } |
| 231 | 243 | |
| 232 | 244 | // Shall we use the tabs? Yes, it's the only known way! |
| 233 | - if (!empty($selected_tab['description']) || !empty($tab_context['description'])) |
|
| 234 | - echo ' |
|
| 245 | + if (!empty($selected_tab['description']) || !empty($tab_context['description'])) { |
|
| 246 | + echo ' |
|
| 235 | 247 | <p class="information"> |
| 236 | 248 | ', !empty($selected_tab['description']) ? $selected_tab['description'] : $tab_context['description'], ' |
| 237 | 249 | </p>'; |
| 250 | + } |
|
| 238 | 251 | |
| 239 | 252 | // Print out all the items in this tab (if any). |
| 240 | 253 | if (!empty($context['tabs'])) |
@@ -246,19 +259,21 @@ discard block |
||
| 246 | 259 | |
| 247 | 260 | foreach ($tab_context['tabs'] as $sa => $tab) |
| 248 | 261 | { |
| 249 | - if (!empty($tab['disabled'])) |
|
| 250 | - continue; |
|
| 262 | + if (!empty($tab['disabled'])) { |
|
| 263 | + continue; |
|
| 264 | + } |
|
| 251 | 265 | |
| 252 | - if (!empty($tab['is_selected'])) |
|
| 253 | - echo ' |
|
| 266 | + if (!empty($tab['is_selected'])) { |
|
| 267 | + echo ' |
|
| 254 | 268 | <li> |
| 255 | 269 | <a class="active" href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a> |
| 256 | 270 | </li>'; |
| 257 | - else |
|
| 258 | - echo ' |
|
| 271 | + } else { |
|
| 272 | + echo ' |
|
| 259 | 273 | <li> |
| 260 | 274 | <a href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a> |
| 261 | 275 | </li>'; |
| 276 | + } |
|
| 262 | 277 | } |
| 263 | 278 | |
| 264 | 279 | // The end of tabs |
@@ -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. |
@@ -121,8 +122,9 @@ discard block |
||
| 121 | 122 | echo ' |
| 122 | 123 | <meta'; |
| 123 | 124 | |
| 124 | - foreach ($meta_tag as $meta_key => $meta_value) |
|
| 125 | - echo ' ', $meta_key, '="', $meta_value, '"'; |
|
| 125 | + foreach ($meta_tag as $meta_key => $meta_value) { |
|
| 126 | + echo ' ', $meta_key, '="', $meta_value, '"'; |
|
| 127 | + } |
|
| 126 | 128 | |
| 127 | 129 | echo '>'; |
| 128 | 130 | } |
@@ -133,14 +135,16 @@ discard block |
||
| 133 | 135 | <meta name="theme-color" content="#557EA0">'; |
| 134 | 136 | |
| 135 | 137 | // Please don't index these Mr Robot. |
| 136 | - if (!empty($context['robot_no_index'])) |
|
| 137 | - echo ' |
|
| 138 | + if (!empty($context['robot_no_index'])) { |
|
| 139 | + echo ' |
|
| 138 | 140 | <meta name="robots" content="noindex">'; |
| 141 | + } |
|
| 139 | 142 | |
| 140 | 143 | // Present a canonical url for search engines to prevent duplicate content in their indices. |
| 141 | - if (!empty($context['canonical_url'])) |
|
| 142 | - echo ' |
|
| 144 | + if (!empty($context['canonical_url'])) { |
|
| 145 | + echo ' |
|
| 143 | 146 | <link rel="canonical" href="', $context['canonical_url'], '">'; |
| 147 | + } |
|
| 144 | 148 | |
| 145 | 149 | // Show all the relative links, such as help, search, contents, and the like. |
| 146 | 150 | echo ' |
@@ -149,24 +153,28 @@ discard block |
||
| 149 | 153 | <link rel="search" href="' . $scripturl . '?action=search">' : ''); |
| 150 | 154 | |
| 151 | 155 | // If RSS feeds are enabled, advertise the presence of one. |
| 152 | - if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged'])) |
|
| 153 | - echo ' |
|
| 156 | + if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged'])) { |
|
| 157 | + echo ' |
|
| 154 | 158 | <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'] : '', '"> |
| 155 | 159 | <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'] : '', '">'; |
| 160 | + } |
|
| 156 | 161 | |
| 157 | 162 | // If we're viewing a topic, these should be the previous and next topics, respectively. |
| 158 | - if (!empty($context['links']['next'])) |
|
| 159 | - echo ' |
|
| 163 | + if (!empty($context['links']['next'])) { |
|
| 164 | + echo ' |
|
| 160 | 165 | <link rel="next" href="', $context['links']['next'], '">'; |
| 166 | + } |
|
| 161 | 167 | |
| 162 | - if (!empty($context['links']['prev'])) |
|
| 163 | - echo ' |
|
| 168 | + if (!empty($context['links']['prev'])) { |
|
| 169 | + echo ' |
|
| 164 | 170 | <link rel="prev" href="', $context['links']['prev'], '">'; |
| 171 | + } |
|
| 165 | 172 | |
| 166 | 173 | // If we're in a board, or a topic for that matter, the index will be the board's index. |
| 167 | - if (!empty($context['current_board'])) |
|
| 168 | - echo ' |
|
| 174 | + if (!empty($context['current_board'])) { |
|
| 175 | + echo ' |
|
| 169 | 176 | <link rel="index" href="', $scripturl, '?board=', $context['current_board'], '.0">'; |
| 177 | + } |
|
| 170 | 178 | |
| 171 | 179 | // Output any remaining HTML headers. (from mods, maybe?) |
| 172 | 180 | echo $context['html_headers']; |
@@ -199,20 +207,22 @@ discard block |
||
| 199 | 207 | <li> |
| 200 | 208 | <a href="', $scripturl, '?action=profile"', !empty($context['self_profile']) ? ' class="active"' : '', ' id="profile_menu_top" onclick="return false;">'; |
| 201 | 209 | |
| 202 | - if (!empty($context['user']['avatar'])) |
|
| 203 | - echo $context['user']['avatar']['image']; |
|
| 210 | + if (!empty($context['user']['avatar'])) { |
|
| 211 | + echo $context['user']['avatar']['image']; |
|
| 212 | + } |
|
| 204 | 213 | |
| 205 | 214 | echo $context['user']['name'], '</a> |
| 206 | 215 | <div id="profile_menu" class="top_menu"></div> |
| 207 | 216 | </li>'; |
| 208 | 217 | |
| 209 | 218 | // Secondly, PMs if we're doing them |
| 210 | - if ($context['allow_pm']) |
|
| 211 | - echo ' |
|
| 219 | + if ($context['allow_pm']) { |
|
| 220 | + echo ' |
|
| 212 | 221 | <li> |
| 213 | 222 | <a href="', $scripturl, '?action=pm"', !empty($context['self_pm']) ? ' class="active"' : '', ' id="pm_menu_top">', $txt['pm_short'], !empty($context['user']['unread_messages']) ? ' <span class="amt">' . $context['user']['unread_messages'] . '</span>' : '', '</a> |
| 214 | 223 | <div id="pm_menu" class="top_menu scrollable"></div> |
| 215 | 224 | </li>'; |
| 225 | + } |
|
| 216 | 226 | |
| 217 | 227 | // Thirdly, alerts |
| 218 | 228 | echo ' |
@@ -227,17 +237,18 @@ discard block |
||
| 227 | 237 | } |
| 228 | 238 | // Otherwise they're a guest. Ask them to either register or login. |
| 229 | 239 | else |
| 230 | - if (empty($maintenance)) |
|
| 231 | - echo ' |
|
| 240 | + if (empty($maintenance)) { |
|
| 241 | + echo ' |
|
| 232 | 242 | <ul class="floatleft welcome"> |
| 233 | 243 | <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> |
| 234 | 244 | </ul>'; |
| 235 | - else |
|
| 236 | - // In maintenance mode, only login is allowed and don't show OverlayDiv |
|
| 245 | + } else { |
|
| 246 | + // In maintenance mode, only login is allowed and don't show OverlayDiv |
|
| 237 | 247 | echo ' |
| 238 | 248 | <ul class="floatleft welcome"> |
| 239 | 249 | <li>', sprintf($txt['welcome_guest'], $txt['guest_title'], '', $scripturl. '?action=login', 'return true;'), '</li> |
| 240 | 250 | </ul>'; |
| 251 | + } |
|
| 241 | 252 | |
| 242 | 253 | if (!empty($modSettings['userLanguage']) && !empty($context['languages']) && count($context['languages']) > 1) |
| 243 | 254 | { |
@@ -245,9 +256,10 @@ discard block |
||
| 245 | 256 | <form id="languages_form" method="get" class="floatright"> |
| 246 | 257 | <select id="language_select" name="language" onchange="this.form.submit()">'; |
| 247 | 258 | |
| 248 | - foreach ($context['languages'] as $language) |
|
| 249 | - echo ' |
|
| 259 | + foreach ($context['languages'] as $language) { |
|
| 260 | + echo ' |
|
| 250 | 261 | <option value="', $language['filename'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' selected="selected"' : '', '>', str_replace('-utf8', '', $language['name']), '</option>'; |
| 262 | + } |
|
| 251 | 263 | |
| 252 | 264 | echo ' |
| 253 | 265 | </select> |
@@ -271,32 +283,37 @@ discard block |
||
| 271 | 283 | <option value="all"', ($selected == 'all' ? ' selected' : ''), '>', $txt['search_entireforum'], ' </option>'; |
| 272 | 284 | |
| 273 | 285 | // Can't limit it to a specific topic if we are not in one |
| 274 | - if (!empty($context['current_topic'])) |
|
| 275 | - echo ' |
|
| 286 | + if (!empty($context['current_topic'])) { |
|
| 287 | + echo ' |
|
| 276 | 288 | <option value="topic"', ($selected == 'current_topic' ? ' selected' : ''), '>', $txt['search_thistopic'], '</option>'; |
| 289 | + } |
|
| 277 | 290 | |
| 278 | 291 | // Can't limit it to a specific board if we are not in one |
| 279 | - if (!empty($context['current_board'])) |
|
| 280 | - echo ' |
|
| 292 | + if (!empty($context['current_board'])) { |
|
| 293 | + echo ' |
|
| 281 | 294 | <option value="board"', ($selected == 'current_board' ? ' selected' : ''), '>', $txt['search_thisbrd'], '</option>'; |
| 295 | + } |
|
| 282 | 296 | |
| 283 | 297 | // Can't search for members if we can't see the memberlist |
| 284 | - if (!empty($context['allow_memberlist'])) |
|
| 285 | - echo ' |
|
| 298 | + if (!empty($context['allow_memberlist'])) { |
|
| 299 | + echo ' |
|
| 286 | 300 | <option value="members"', ($selected == 'members' ? ' selected' : ''), '>', $txt['search_members'], ' </option>'; |
| 301 | + } |
|
| 287 | 302 | |
| 288 | 303 | echo ' |
| 289 | 304 | </select>'; |
| 290 | 305 | |
| 291 | 306 | // Search within current topic? |
| 292 | - if (!empty($context['current_topic'])) |
|
| 293 | - echo ' |
|
| 307 | + if (!empty($context['current_topic'])) { |
|
| 308 | + echo ' |
|
| 294 | 309 | <input type="hidden" name="sd_topic" value="', $context['current_topic'], '">'; |
| 310 | + } |
|
| 295 | 311 | |
| 296 | 312 | // If we're on a certain board, limit it to this board ;). |
| 297 | - elseif (!empty($context['current_board'])) |
|
| 298 | - echo ' |
|
| 313 | + elseif (!empty($context['current_board'])) { |
|
| 314 | + echo ' |
|
| 299 | 315 | <input type="hidden" name="sd_brd" value="', $context['current_board'], '">'; |
| 316 | + } |
|
| 300 | 317 | |
| 301 | 318 | echo ' |
| 302 | 319 | <input type="submit" name="search2" value="', $txt['search'], '" class="button"> |
@@ -328,12 +345,13 @@ discard block |
||
| 328 | 345 | </div>'; |
| 329 | 346 | |
| 330 | 347 | // Show a random news item? (or you could pick one from news_lines...) |
| 331 | - if (!empty($settings['enable_news']) && !empty($context['random_news_line'])) |
|
| 332 | - echo ' |
|
| 348 | + if (!empty($settings['enable_news']) && !empty($context['random_news_line'])) { |
|
| 349 | + echo ' |
|
| 333 | 350 | <div class="news"> |
| 334 | 351 | <h2>', $txt['news'], ': </h2> |
| 335 | 352 | <p>', $context['random_news_line'], '</p> |
| 336 | 353 | </div>'; |
| 354 | + } |
|
| 337 | 355 | |
| 338 | 356 | echo ' |
| 339 | 357 | <hr class="clear"> |
@@ -392,9 +410,10 @@ discard block |
||
| 392 | 410 | </ul>'; |
| 393 | 411 | |
| 394 | 412 | // Show the load time? |
| 395 | - if ($context['show_load_time']) |
|
| 396 | - echo ' |
|
| 413 | + if ($context['show_load_time']) { |
|
| 414 | + echo ' |
|
| 397 | 415 | <p>', sprintf($txt['page_created_full'], $context['load_time'], $context['load_queries']), '</p>'; |
| 416 | + } |
|
| 398 | 417 | |
| 399 | 418 | echo ' |
| 400 | 419 | </div> |
@@ -425,18 +444,20 @@ discard block |
||
| 425 | 444 | global $context, $shown_linktree, $scripturl, $txt; |
| 426 | 445 | |
| 427 | 446 | // If linktree is empty, just return - also allow an override. |
| 428 | - if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show)) |
|
| 429 | - return; |
|
| 447 | + if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show)) { |
|
| 448 | + return; |
|
| 449 | + } |
|
| 430 | 450 | echo ' |
| 431 | 451 | <div class="navigate_section"> |
| 432 | 452 | <ul>'; |
| 433 | 453 | |
| 434 | - if ($context['user']['is_logged']) |
|
| 435 | - echo ' |
|
| 454 | + if ($context['user']['is_logged']) { |
|
| 455 | + echo ' |
|
| 436 | 456 | <li class="unread_links"> |
| 437 | 457 | <a href="', $scripturl, '?action=unread" title="', $txt['unread_since_visit'], '">', $txt['view_unread_category'], '</a> |
| 438 | 458 | <a href="', $scripturl, '?action=unreadreplies" title="', $txt['show_unread_replies'], '">', $txt['unread_replies'], '</a> |
| 439 | 459 | </li>'; |
| 460 | + } |
|
| 440 | 461 | |
| 441 | 462 | // Each tree item has a URL and name. Some may have extra_before and extra_after. |
| 442 | 463 | foreach ($context['linktree'] as $link_num => $tree) |
@@ -447,25 +468,29 @@ discard block |
||
| 447 | 468 | // Don't show a separator for the first one. |
| 448 | 469 | // Better here. Always points to the next level when the linktree breaks to a second line. |
| 449 | 470 | // Picked a better looking HTML entity, and added support for RTL plus a span for styling. |
| 450 | - if ($link_num != 0) |
|
| 451 | - echo ' |
|
| 471 | + if ($link_num != 0) { |
|
| 472 | + echo ' |
|
| 452 | 473 | <span class="dividers">', $context['right_to_left'] ? ' ◄ ' : ' ► ', '</span>'; |
| 474 | + } |
|
| 453 | 475 | |
| 454 | 476 | // Show something before the link? |
| 455 | - if (isset($tree['extra_before'])) |
|
| 456 | - echo $tree['extra_before'], ' '; |
|
| 477 | + if (isset($tree['extra_before'])) { |
|
| 478 | + echo $tree['extra_before'], ' '; |
|
| 479 | + } |
|
| 457 | 480 | |
| 458 | 481 | // Show the link, including a URL if it should have one. |
| 459 | - if (isset($tree['url'])) |
|
| 460 | - echo ' |
|
| 482 | + if (isset($tree['url'])) { |
|
| 483 | + echo ' |
|
| 461 | 484 | <a href="' . $tree['url'] . '"><span>' . $tree['name'] . '</span></a>'; |
| 462 | - else |
|
| 463 | - echo ' |
|
| 485 | + } else { |
|
| 486 | + echo ' |
|
| 464 | 487 | <span>' . $tree['name'] . '</span>'; |
| 488 | + } |
|
| 465 | 489 | |
| 466 | 490 | // Show something after the link...? |
| 467 | - if (isset($tree['extra_after'])) |
|
| 468 | - echo ' ', $tree['extra_after']; |
|
| 491 | + if (isset($tree['extra_after'])) { |
|
| 492 | + echo ' ', $tree['extra_after']; |
|
| 493 | + } |
|
| 469 | 494 | |
| 470 | 495 | echo ' |
| 471 | 496 | </li>'; |
@@ -516,13 +541,14 @@ discard block |
||
| 516 | 541 | echo ' |
| 517 | 542 | <ul>'; |
| 518 | 543 | |
| 519 | - foreach ($childbutton['sub_buttons'] as $grandchildbutton) |
|
| 520 | - echo ' |
|
| 544 | + foreach ($childbutton['sub_buttons'] as $grandchildbutton) { |
|
| 545 | + echo ' |
|
| 521 | 546 | <li> |
| 522 | 547 | <a href="', $grandchildbutton['href'], '"', isset($grandchildbutton['target']) ? ' target="' . $grandchildbutton['target'] . '"' : '', '> |
| 523 | 548 | ', $grandchildbutton['title'], !empty($grandchildbutton['amt']) ? ' <span class="amt">' . $grandchildbutton['amt'] . '</span>' : '', ' |
| 524 | 549 | </a> |
| 525 | 550 | </li>'; |
| 551 | + } |
|
| 526 | 552 | |
| 527 | 553 | echo ' |
| 528 | 554 | </ul>'; |
@@ -553,8 +579,9 @@ discard block |
||
| 553 | 579 | { |
| 554 | 580 | global $context, $txt; |
| 555 | 581 | |
| 556 | - if (!is_array($strip_options)) |
|
| 557 | - $strip_options = array(); |
|
| 582 | + if (!is_array($strip_options)) { |
|
| 583 | + $strip_options = array(); |
|
| 584 | + } |
|
| 558 | 585 | |
| 559 | 586 | // Create the buttons... |
| 560 | 587 | $buttons = array(); |
@@ -563,8 +590,9 @@ discard block |
||
| 563 | 590 | // 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!) |
| 564 | 591 | if (!isset($value['test']) || !empty($context[$value['test']])) |
| 565 | 592 | { |
| 566 | - if (!isset($value['id'])) |
|
| 567 | - $value['id'] = $key; |
|
| 593 | + if (!isset($value['id'])) { |
|
| 594 | + $value['id'] = $key; |
|
| 595 | + } |
|
| 568 | 596 | |
| 569 | 597 | $button = ' |
| 570 | 598 | <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>'; |
@@ -577,13 +605,15 @@ discard block |
||
| 577 | 605 | <div class="overview">'; |
| 578 | 606 | foreach ($value['sub_buttons'] as $element) |
| 579 | 607 | { |
| 580 | - if (isset($element['test']) && empty($context[$element['test']])) |
|
| 581 | - continue; |
|
| 608 | + if (isset($element['test']) && empty($context[$element['test']])) { |
|
| 609 | + continue; |
|
| 610 | + } |
|
| 582 | 611 | |
| 583 | 612 | $button .= ' |
| 584 | 613 | <a href="' . $element['url'] . '"><strong>' . $txt[$element['text']] . '</strong>'; |
| 585 | - if (isset($txt[$element['text'] . '_desc'])) |
|
| 586 | - $button .= '<br><span>' . $txt[$element['text'] . '_desc'] . '</span>'; |
|
| 614 | + if (isset($txt[$element['text'] . '_desc'])) { |
|
| 615 | + $button .= '<br><span>' . $txt[$element['text'] . '_desc'] . '</span>'; |
|
| 616 | + } |
|
| 587 | 617 | $button .= '</a>'; |
| 588 | 618 | } |
| 589 | 619 | $button .= ' |
@@ -597,8 +627,9 @@ discard block |
||
| 597 | 627 | } |
| 598 | 628 | |
| 599 | 629 | // No buttons? No button strip either. |
| 600 | - if (empty($buttons)) |
|
| 601 | - return; |
|
| 630 | + if (empty($buttons)) { |
|
| 631 | + return; |
|
| 632 | + } |
|
| 602 | 633 | |
| 603 | 634 | echo ' |
| 604 | 635 | <div class="buttonlist', !empty($direction) ? ' float' . $direction : '', '"', (empty($buttons) ? ' style="display: none;"' : ''), (!empty($strip_options['id']) ? ' id="' . $strip_options['id'] . '"' : ''), '> |
@@ -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 | * Takes a message and parses it, returning nothing. |
@@ -31,8 +32,9 @@ discard block |
||
| 31 | 32 | global $user_info, $modSettings, $context, $sourcedir; |
| 32 | 33 | |
| 33 | 34 | // This line makes all languages *theoretically* work even with the wrong charset ;). |
| 34 | - if (empty($context['utf8'])) |
|
| 35 | - $message = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $message); |
|
| 35 | + if (empty($context['utf8'])) { |
|
| 36 | + $message = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $message); |
|
| 37 | + } |
|
| 36 | 38 | |
| 37 | 39 | // Clean up after nobbc ;). |
| 38 | 40 | $message = preg_replace_callback('~\[nobbc\](.+?)\[/nobbc\]~is', function($a) |
@@ -47,17 +49,19 @@ discard block |
||
| 47 | 49 | $message = preg_replace('~\.{100,}~', '...', $message); |
| 48 | 50 | |
| 49 | 51 | // Trim off trailing quotes - these often happen by accident. |
| 50 | - while (substr($message, -7) == '[quote]') |
|
| 51 | - $message = substr($message, 0, -7); |
|
| 52 | - while (substr($message, 0, 8) == '[/quote]') |
|
| 53 | - $message = substr($message, 8); |
|
| 52 | + while (substr($message, -7) == '[quote]') { |
|
| 53 | + $message = substr($message, 0, -7); |
|
| 54 | + } |
|
| 55 | + while (substr($message, 0, 8) == '[/quote]') { |
|
| 56 | + $message = substr($message, 8); |
|
| 57 | + } |
|
| 54 | 58 | |
| 55 | 59 | // Find all code blocks, work out whether we'd be parsing them, then ensure they are all closed. |
| 56 | 60 | $in_tag = false; |
| 57 | 61 | $had_tag = false; |
| 58 | 62 | $codeopen = 0; |
| 59 | - if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches)) |
|
| 60 | - foreach ($matches[0] as $index => $dummy) |
|
| 63 | + if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches)) { |
|
| 64 | + foreach ($matches[0] as $index => $dummy) |
|
| 61 | 65 | { |
| 62 | 66 | // Closing? |
| 63 | 67 | if (!empty($matches[2][$index])) |
@@ -65,6 +69,7 @@ discard block |
||
| 65 | 69 | // If it's closing and we're not in a tag we need to open it... |
| 66 | 70 | if (!$in_tag) |
| 67 | 71 | $codeopen = true; |
| 72 | + } |
|
| 68 | 73 | // Either way we ain't in one any more. |
| 69 | 74 | $in_tag = false; |
| 70 | 75 | } |
@@ -73,17 +78,20 @@ discard block |
||
| 73 | 78 | { |
| 74 | 79 | $had_tag = true; |
| 75 | 80 | // If we're in a tag don't do nought! |
| 76 | - if (!$in_tag) |
|
| 77 | - $in_tag = true; |
|
| 81 | + if (!$in_tag) { |
|
| 82 | + $in_tag = true; |
|
| 83 | + } |
|
| 78 | 84 | } |
| 79 | 85 | } |
| 80 | 86 | |
| 81 | 87 | // If we have an open tag, close it. |
| 82 | - if ($in_tag) |
|
| 83 | - $message .= '[/code]'; |
|
| 88 | + if ($in_tag) { |
|
| 89 | + $message .= '[/code]'; |
|
| 90 | + } |
|
| 84 | 91 | // Open any ones that need to be open, only if we've never had a tag. |
| 85 | - if ($codeopen && !$had_tag) |
|
| 86 | - $message = '[code]' . $message; |
|
| 92 | + if ($codeopen && !$had_tag) { |
|
| 93 | + $message = '[code]' . $message; |
|
| 94 | + } |
|
| 87 | 95 | |
| 88 | 96 | // Replace code BBC with placeholders. We'll restore them at the end. |
| 89 | 97 | $parts = preg_split('~(\[/code\]|\[code(?:=[^\]]+)?\])~i', $message, -1, PREG_SPLIT_DELIM_CAPTURE); |
@@ -108,23 +116,26 @@ discard block |
||
| 108 | 116 | fixTags($message); |
| 109 | 117 | |
| 110 | 118 | // Replace /me.+?\n with [me=name]dsf[/me]\n. |
| 111 | - if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false) |
|
| 112 | - $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me="' . $user_info['name'] . '"]$2[/me]', $message); |
|
| 113 | - else |
|
| 114 | - $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message); |
|
| 119 | + if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false) { |
|
| 120 | + $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me="' . $user_info['name'] . '"]$2[/me]', $message); |
|
| 121 | + } else { |
|
| 122 | + $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message); |
|
| 123 | + } |
|
| 115 | 124 | |
| 116 | 125 | if (!$previewing && strpos($message, '[html]') !== false) |
| 117 | 126 | { |
| 118 | - if (allowedTo('admin_forum')) |
|
| 119 | - $message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) { |
|
| 127 | + if (allowedTo('admin_forum')) { |
|
| 128 | + $message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) { |
|
| 120 | 129 | return '[html]' . strtr(un_htmlspecialchars($m[1]), array("\n" => ' ', ' ' => '  ', '[' => '[', ']' => ']')) . '[/html]'; |
| 130 | + } |
|
| 121 | 131 | }, $message); |
| 122 | 132 | |
| 123 | 133 | // We should edit them out, or else if an admin edits the message they will get shown... |
| 124 | 134 | else |
| 125 | 135 | { |
| 126 | - while (strpos($message, '[html]') !== false) |
|
| 127 | - $message = preg_replace('~\[[/]?html\]~i', '', $message); |
|
| 136 | + while (strpos($message, '[html]') !== false) { |
|
| 137 | + $message = preg_replace('~\[[/]?html\]~i', '', $message); |
|
| 138 | + } |
|
| 128 | 139 | } |
| 129 | 140 | } |
| 130 | 141 | |
@@ -146,10 +157,12 @@ discard block |
||
| 146 | 157 | |
| 147 | 158 | $list_open = substr_count($message, '[list]') + substr_count($message, '[list '); |
| 148 | 159 | $list_close = substr_count($message, '[/list]'); |
| 149 | - if ($list_close - $list_open > 0) |
|
| 150 | - $message = str_repeat('[list]', $list_close - $list_open) . $message; |
|
| 151 | - if ($list_open - $list_close > 0) |
|
| 152 | - $message = $message . str_repeat('[/list]', $list_open - $list_close); |
|
| 160 | + if ($list_close - $list_open > 0) { |
|
| 161 | + $message = str_repeat('[list]', $list_close - $list_open) . $message; |
|
| 162 | + } |
|
| 163 | + if ($list_open - $list_close > 0) { |
|
| 164 | + $message = $message . str_repeat('[/list]', $list_open - $list_close); |
|
| 165 | + } |
|
| 153 | 166 | |
| 154 | 167 | $mistake_fixes = array( |
| 155 | 168 | // Find [table]s not followed by [tr]. |
@@ -198,8 +211,9 @@ discard block |
||
| 198 | 211 | ); |
| 199 | 212 | |
| 200 | 213 | // Fix up some use of tables without [tr]s, etc. (it has to be done more than once to catch it all.) |
| 201 | - for ($j = 0; $j < 3; $j++) |
|
| 202 | - $message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message); |
|
| 214 | + for ($j = 0; $j < 3; $j++) { |
|
| 215 | + $message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message); |
|
| 216 | + } |
|
| 203 | 217 | |
| 204 | 218 | // Remove empty bbc from the sections outside the code tags |
| 205 | 219 | $allowedEmpty = array( |
@@ -210,24 +224,28 @@ discard block |
||
| 210 | 224 | require_once($sourcedir . '/Subs.php'); |
| 211 | 225 | |
| 212 | 226 | $alltags = array(); |
| 213 | - foreach (($codes = parse_bbc(false)) as $code) |
|
| 214 | - if (!in_array($code['tag'], $allowedEmpty)) |
|
| 227 | + foreach (($codes = parse_bbc(false)) as $code) { |
|
| 228 | + if (!in_array($code['tag'], $allowedEmpty)) |
|
| 215 | 229 | $alltags[] = $code['tag']; |
| 230 | + } |
|
| 216 | 231 | |
| 217 | 232 | $alltags_regex = '\b' . implode("\b|\b", array_unique($alltags)) . '\b'; |
| 218 | 233 | |
| 219 | - while (preg_match('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', $message)) |
|
| 220 | - $message = preg_replace('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', '', $message); |
|
| 234 | + while (preg_match('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', $message)) { |
|
| 235 | + $message = preg_replace('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', '', $message); |
|
| 236 | + } |
|
| 221 | 237 | |
| 222 | 238 | // Restore code blocks |
| 223 | - if (!empty($code_tags)) |
|
| 224 | - $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
| 239 | + if (!empty($code_tags)) { |
|
| 240 | + $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
| 241 | + } |
|
| 225 | 242 | |
| 226 | 243 | // Restore white space entities |
| 227 | - if (!$previewing) |
|
| 228 | - $message = strtr($message, array(' ' => ' ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
| 229 | - else |
|
| 230 | - $message = strtr($message, array(' ' => ' ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
| 244 | + if (!$previewing) { |
|
| 245 | + $message = strtr($message, array(' ' => ' ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
| 246 | + } else { |
|
| 247 | + $message = strtr($message, array(' ' => ' ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
| 248 | + } |
|
| 231 | 249 | |
| 232 | 250 | // Now let's quickly clean up things that will slow our parser (which are common in posted code.) |
| 233 | 251 | $message = strtr($message, array('[]' => '[]', '['' => '['')); |
@@ -270,8 +288,9 @@ discard block |
||
| 270 | 288 | return "[time]" . timeformat("$m[1]", false) . "[/time]"; |
| 271 | 289 | }, $message); |
| 272 | 290 | |
| 273 | - if (!empty($code_tags)) |
|
| 274 | - $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
| 291 | + if (!empty($code_tags)) { |
|
| 292 | + $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
| 293 | + } |
|
| 275 | 294 | |
| 276 | 295 | // Change breaks back to \n's and &nsbp; back to spaces. |
| 277 | 296 | return preg_replace('~<br( /)?' . '>~', "\n", str_replace(' ', ' ', $message)); |
@@ -352,8 +371,9 @@ discard block |
||
| 352 | 371 | ); |
| 353 | 372 | |
| 354 | 373 | // Fix each type of tag. |
| 355 | - foreach ($fixArray as $param) |
|
| 356 | - fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra'])); |
|
| 374 | + foreach ($fixArray as $param) { |
|
| 375 | + fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra'])); |
|
| 376 | + } |
|
| 357 | 377 | |
| 358 | 378 | // Now fix possible security problems with images loading links automatically... |
| 359 | 379 | $message = preg_replace_callback('~(\[img.*?\])(.+?)\[/img\]~is', function($m) |
@@ -378,10 +398,11 @@ discard block |
||
| 378 | 398 | { |
| 379 | 399 | global $boardurl, $scripturl; |
| 380 | 400 | |
| 381 | - if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0) |
|
| 382 | - $domain_url = $match[1]; |
|
| 383 | - else |
|
| 384 | - $domain_url = $boardurl . '/'; |
|
| 401 | + if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0) { |
|
| 402 | + $domain_url = $match[1]; |
|
| 403 | + } else { |
|
| 404 | + $domain_url = $boardurl . '/'; |
|
| 405 | + } |
|
| 385 | 406 | |
| 386 | 407 | $replaces = array(); |
| 387 | 408 | |
@@ -389,11 +410,11 @@ discard block |
||
| 389 | 410 | { |
| 390 | 411 | $quoted = preg_match('~\[(' . $myTag . ')="~', $message); |
| 391 | 412 | preg_match_all('~\[(' . $myTag . ')=' . ($quoted ? '"(.*?)"' : '([^\]]*?)') . '\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches); |
| 413 | + } elseif ($hasEqualSign) { |
|
| 414 | + preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches); |
|
| 415 | + } else { |
|
| 416 | + preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches); |
|
| 392 | 417 | } |
| 393 | - elseif ($hasEqualSign) |
|
| 394 | - preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches); |
|
| 395 | - else |
|
| 396 | - preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches); |
|
| 397 | 418 | |
| 398 | 419 | foreach ($matches[0] as $k => $dummy) |
| 399 | 420 | { |
@@ -406,49 +427,53 @@ discard block |
||
| 406 | 427 | foreach ($protocols as $protocol) |
| 407 | 428 | { |
| 408 | 429 | $found = strncasecmp($replace, $protocol . '://', strlen($protocol) + 3) === 0; |
| 409 | - if ($found) |
|
| 410 | - break; |
|
| 430 | + if ($found) { |
|
| 431 | + break; |
|
| 432 | + } |
|
| 411 | 433 | } |
| 412 | 434 | |
| 413 | 435 | if (!$found && $protocols[0] == 'http') |
| 414 | 436 | { |
| 415 | - if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//') |
|
| 416 | - $replace = $domain_url . $replace; |
|
| 417 | - elseif (substr($replace, 0, 1) == '?') |
|
| 418 | - $replace = $scripturl . $replace; |
|
| 419 | - elseif (substr($replace, 0, 1) == '#' && $embeddedUrl) |
|
| 437 | + if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//') { |
|
| 438 | + $replace = $domain_url . $replace; |
|
| 439 | + } elseif (substr($replace, 0, 1) == '?') { |
|
| 440 | + $replace = $scripturl . $replace; |
|
| 441 | + } elseif (substr($replace, 0, 1) == '#' && $embeddedUrl) |
|
| 420 | 442 | { |
| 421 | 443 | $replace = '#' . preg_replace('~[^A-Za-z0-9_\-#]~', '', substr($replace, 1)); |
| 422 | 444 | $this_tag = 'iurl'; |
| 423 | 445 | $this_close = 'iurl'; |
| 446 | + } elseif (substr($replace, 0, 2) != '//') { |
|
| 447 | + $replace = $protocols[0] . '://' . $replace; |
|
| 424 | 448 | } |
| 425 | - elseif (substr($replace, 0, 2) != '//') |
|
| 426 | - $replace = $protocols[0] . '://' . $replace; |
|
| 427 | - } |
|
| 428 | - elseif (!$found && $protocols[0] == 'ftp') |
|
| 429 | - $replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace); |
|
| 430 | - elseif (!$found) |
|
| 431 | - $replace = $protocols[0] . '://' . $replace; |
|
| 432 | - |
|
| 433 | - if ($hasEqualSign && $embeddedUrl) |
|
| 434 | - $replaces[$matches[0][$k]] = '[' . $this_tag . '="' . $replace . '"]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']'); |
|
| 435 | - elseif ($hasEqualSign) |
|
| 436 | - $replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']'; |
|
| 437 | - elseif ($embeddedUrl) |
|
| 438 | - $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']'; |
|
| 439 | - else |
|
| 440 | - $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']'; |
|
| 449 | + } elseif (!$found && $protocols[0] == 'ftp') { |
|
| 450 | + $replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace); |
|
| 451 | + } elseif (!$found) { |
|
| 452 | + $replace = $protocols[0] . '://' . $replace; |
|
| 453 | + } |
|
| 454 | + |
|
| 455 | + if ($hasEqualSign && $embeddedUrl) { |
|
| 456 | + $replaces[$matches[0][$k]] = '[' . $this_tag . '="' . $replace . '"]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']'); |
|
| 457 | + } elseif ($hasEqualSign) { |
|
| 458 | + $replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']'; |
|
| 459 | + } elseif ($embeddedUrl) { |
|
| 460 | + $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']'; |
|
| 461 | + } else { |
|
| 462 | + $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']'; |
|
| 463 | + } |
|
| 441 | 464 | } |
| 442 | 465 | |
| 443 | 466 | foreach ($replaces as $k => $v) |
| 444 | 467 | { |
| 445 | - if ($k == $v) |
|
| 446 | - unset($replaces[$k]); |
|
| 468 | + if ($k == $v) { |
|
| 469 | + unset($replaces[$k]); |
|
| 470 | + } |
|
| 447 | 471 | } |
| 448 | 472 | |
| 449 | - if (!empty($replaces)) |
|
| 450 | - $message = strtr($message, $replaces); |
|
| 451 | -} |
|
| 473 | + if (!empty($replaces)) { |
|
| 474 | + $message = strtr($message, $replaces); |
|
| 475 | + } |
|
| 476 | + } |
|
| 452 | 477 | |
| 453 | 478 | /** |
| 454 | 479 | * This function sends an email to the specified recipient(s). |
@@ -492,8 +517,9 @@ discard block |
||
| 492 | 517 | } |
| 493 | 518 | |
| 494 | 519 | // Nothing left? Nothing else to do |
| 495 | - if (empty($to_array)) |
|
| 496 | - return true; |
|
| 520 | + if (empty($to_array)) { |
|
| 521 | + return true; |
|
| 522 | + } |
|
| 497 | 523 | |
| 498 | 524 | // Once upon a time, Hotmail could not interpret non-ASCII mails. |
| 499 | 525 | // In honour of those days, it's still called the 'hotmail fix'. |
@@ -510,15 +536,17 @@ discard block |
||
| 510 | 536 | } |
| 511 | 537 | |
| 512 | 538 | // Call this function recursively for the hotmail addresses. |
| 513 | - if (!empty($hotmail_to)) |
|
| 514 | - $mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private); |
|
| 539 | + if (!empty($hotmail_to)) { |
|
| 540 | + $mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private); |
|
| 541 | + } |
|
| 515 | 542 | |
| 516 | 543 | // The remaining addresses no longer need the fix. |
| 517 | 544 | $hotmail_fix = false; |
| 518 | 545 | |
| 519 | 546 | // No other addresses left? Return instantly. |
| 520 | - if (empty($to_array)) |
|
| 521 | - return $mail_result; |
|
| 547 | + if (empty($to_array)) { |
|
| 548 | + return $mail_result; |
|
| 549 | + } |
|
| 522 | 550 | } |
| 523 | 551 | |
| 524 | 552 | // Get rid of entities. |
@@ -543,13 +571,15 @@ discard block |
||
| 543 | 571 | $headers .= 'Return-Path: ' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . $line_break; |
| 544 | 572 | $headers .= 'Date: ' . gmdate('D, d M Y H:i:s') . ' -0000' . $line_break; |
| 545 | 573 | |
| 546 | - if ($message_id !== null && empty($modSettings['mail_no_message_id'])) |
|
| 547 | - $headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break; |
|
| 574 | + if ($message_id !== null && empty($modSettings['mail_no_message_id'])) { |
|
| 575 | + $headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break; |
|
| 576 | + } |
|
| 548 | 577 | $headers .= 'X-Mailer: SMF' . $line_break; |
| 549 | 578 | |
| 550 | 579 | // Pass this to the integration before we start modifying the output -- it'll make it easier later. |
| 551 | - if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true)) |
|
| 552 | - return false; |
|
| 580 | + if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true)) { |
|
| 581 | + return false; |
|
| 582 | + } |
|
| 553 | 583 | |
| 554 | 584 | // Save the original message... |
| 555 | 585 | $orig_message = $message; |
@@ -598,17 +628,19 @@ discard block |
||
| 598 | 628 | } |
| 599 | 629 | |
| 600 | 630 | // Are we using the mail queue, if so this is where we butt in... |
| 601 | - if ($priority != 0) |
|
| 602 | - return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private); |
|
| 631 | + if ($priority != 0) { |
|
| 632 | + return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private); |
|
| 633 | + } |
|
| 603 | 634 | |
| 604 | 635 | // If it's a priority mail, send it now - note though that this should NOT be used for sending many at once. |
| 605 | 636 | elseif (!empty($modSettings['mail_limit'])) |
| 606 | 637 | { |
| 607 | 638 | list ($last_mail_time, $mails_this_minute) = @explode('|', $modSettings['mail_recent']); |
| 608 | - if (empty($mails_this_minute) || time() > $last_mail_time + 60) |
|
| 609 | - $new_queue_stat = time() . '|' . 1; |
|
| 610 | - else |
|
| 611 | - $new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1); |
|
| 639 | + if (empty($mails_this_minute) || time() > $last_mail_time + 60) { |
|
| 640 | + $new_queue_stat = time() . '|' . 1; |
|
| 641 | + } else { |
|
| 642 | + $new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1); |
|
| 643 | + } |
|
| 612 | 644 | |
| 613 | 645 | updateSettings(array('mail_recent' => $new_queue_stat)); |
| 614 | 646 | } |
@@ -642,8 +674,7 @@ discard block |
||
| 642 | 674 | log_error(sprintf($txt['mail_send_unable'], $to)); |
| 643 | 675 | $mail_result = false; |
| 644 | 676 | } |
| 645 | - } |
|
| 646 | - catch(ErrorException $e) |
|
| 677 | + } catch(ErrorException $e) |
|
| 647 | 678 | { |
| 648 | 679 | log_error($e->getMessage(), 'general', $e->getFile(), $e->getLine()); |
| 649 | 680 | log_error(sprintf($txt['mail_send_unable'], $to)); |
@@ -653,12 +684,13 @@ discard block |
||
| 653 | 684 | |
| 654 | 685 | // Wait, wait, I'm still sending here! |
| 655 | 686 | @set_time_limit(300); |
| 656 | - if (function_exists('apache_reset_timeout')) |
|
| 657 | - @apache_reset_timeout(); |
|
| 687 | + if (function_exists('apache_reset_timeout')) { |
|
| 688 | + @apache_reset_timeout(); |
|
| 689 | + } |
|
| 658 | 690 | } |
| 691 | + } else { |
|
| 692 | + $mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers); |
|
| 659 | 693 | } |
| 660 | - else |
|
| 661 | - $mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers); |
|
| 662 | 694 | |
| 663 | 695 | // Everything go smoothly? |
| 664 | 696 | return $mail_result; |
@@ -684,8 +716,9 @@ discard block |
||
| 684 | 716 | static $cur_insert = array(); |
| 685 | 717 | static $cur_insert_len = 0; |
| 686 | 718 | |
| 687 | - if ($cur_insert_len == 0) |
|
| 688 | - $cur_insert = array(); |
|
| 719 | + if ($cur_insert_len == 0) { |
|
| 720 | + $cur_insert = array(); |
|
| 721 | + } |
|
| 689 | 722 | |
| 690 | 723 | // If we're flushing, make the final inserts - also if we're near the MySQL length limit! |
| 691 | 724 | if (($flush || $cur_insert_len > 800000) && !empty($cur_insert)) |
@@ -760,8 +793,9 @@ discard block |
||
| 760 | 793 | } |
| 761 | 794 | |
| 762 | 795 | // If they are using SSI there is a good chance obExit will never be called. So lets be nice and flush it for them. |
| 763 | - if (SMF === 'SSI' || SMF === 'BACKGROUND') |
|
| 764 | - return AddMailQueue(true); |
|
| 796 | + if (SMF === 'SSI' || SMF === 'BACKGROUND') { |
|
| 797 | + return AddMailQueue(true); |
|
| 798 | + } |
|
| 765 | 799 | |
| 766 | 800 | return true; |
| 767 | 801 | } |
@@ -792,23 +826,26 @@ discard block |
||
| 792 | 826 | 'sent' => array() |
| 793 | 827 | ); |
| 794 | 828 | |
| 795 | - if ($from === null) |
|
| 796 | - $from = array( |
|
| 829 | + if ($from === null) { |
|
| 830 | + $from = array( |
|
| 797 | 831 | 'id' => $user_info['id'], |
| 798 | 832 | 'name' => $user_info['name'], |
| 799 | 833 | 'username' => $user_info['username'] |
| 800 | 834 | ); |
| 835 | + } |
|
| 801 | 836 | |
| 802 | 837 | // This is the one that will go in their inbox. |
| 803 | 838 | $htmlmessage = $smcFunc['htmlspecialchars']($message, ENT_QUOTES); |
| 804 | 839 | preparsecode($htmlmessage); |
| 805 | 840 | $htmlsubject = strtr($smcFunc['htmlspecialchars']($subject), array("\r" => '', "\n" => '', "\t" => '')); |
| 806 | - if ($smcFunc['strlen']($htmlsubject) > 100) |
|
| 807 | - $htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100); |
|
| 841 | + if ($smcFunc['strlen']($htmlsubject) > 100) { |
|
| 842 | + $htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100); |
|
| 843 | + } |
|
| 808 | 844 | |
| 809 | 845 | // Make sure is an array |
| 810 | - if (!is_array($recipients)) |
|
| 811 | - $recipients = array($recipients); |
|
| 846 | + if (!is_array($recipients)) { |
|
| 847 | + $recipients = array($recipients); |
|
| 848 | + } |
|
| 812 | 849 | |
| 813 | 850 | // Integrated PMs |
| 814 | 851 | call_integration_hook('integrate_personal_message', array(&$recipients, &$from, &$subject, &$message)); |
@@ -836,21 +873,23 @@ discard block |
||
| 836 | 873 | 'usernames' => array_keys($usernames), |
| 837 | 874 | ) |
| 838 | 875 | ); |
| 839 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 840 | - if (isset($usernames[$smcFunc['strtolower']($row['member_name'])])) |
|
| 876 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 877 | + if (isset($usernames[$smcFunc['strtolower']($row['member_name'])])) |
|
| 841 | 878 | $usernames[$smcFunc['strtolower']($row['member_name'])] = $row['id_member']; |
| 879 | + } |
|
| 842 | 880 | $smcFunc['db_free_result']($request); |
| 843 | 881 | |
| 844 | 882 | // Replace the usernames with IDs. Drop usernames that couldn't be found. |
| 845 | - foreach ($recipients as $rec_type => $rec) |
|
| 846 | - foreach ($rec as $id => $member) |
|
| 883 | + foreach ($recipients as $rec_type => $rec) { |
|
| 884 | + foreach ($rec as $id => $member) |
|
| 847 | 885 | { |
| 848 | 886 | if (is_numeric($recipients[$rec_type][$id])) |
| 849 | 887 | continue; |
| 888 | + } |
|
| 850 | 889 | |
| 851 | - if (!empty($usernames[$member])) |
|
| 852 | - $recipients[$rec_type][$id] = $usernames[$member]; |
|
| 853 | - else |
|
| 890 | + if (!empty($usernames[$member])) { |
|
| 891 | + $recipients[$rec_type][$id] = $usernames[$member]; |
|
| 892 | + } else |
|
| 854 | 893 | { |
| 855 | 894 | $log['failed'][$id] = sprintf($txt['pm_error_user_not_found'], $recipients[$rec_type][$id]); |
| 856 | 895 | unset($recipients[$rec_type][$id]); |
@@ -888,8 +927,9 @@ discard block |
||
| 888 | 927 | $delete = false; |
| 889 | 928 | foreach ($criteria as $criterium) |
| 890 | 929 | { |
| 891 | - if (($criterium['t'] == 'mid' && $criterium['v'] == $from['id']) || ($criterium['t'] == 'gid' && in_array($criterium['v'], $user_info['groups'])) || ($criterium['t'] == 'sub' && strpos($subject, $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($message, $criterium['v']) !== false)) |
|
| 892 | - $delete = true; |
|
| 930 | + if (($criterium['t'] == 'mid' && $criterium['v'] == $from['id']) || ($criterium['t'] == 'gid' && in_array($criterium['v'], $user_info['groups'])) || ($criterium['t'] == 'sub' && strpos($subject, $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($message, $criterium['v']) !== false)) { |
|
| 931 | + $delete = true; |
|
| 932 | + } |
|
| 893 | 933 | // If we're adding and one criteria don't match then we stop! |
| 894 | 934 | elseif (!$row['is_or']) |
| 895 | 935 | { |
@@ -897,8 +937,9 @@ discard block |
||
| 897 | 937 | break; |
| 898 | 938 | } |
| 899 | 939 | } |
| 900 | - if ($delete) |
|
| 901 | - $deletes[$row['id_member']] = 1; |
|
| 940 | + if ($delete) { |
|
| 941 | + $deletes[$row['id_member']] = 1; |
|
| 942 | + } |
|
| 902 | 943 | } |
| 903 | 944 | $smcFunc['db_free_result']($request); |
| 904 | 945 | |
@@ -913,8 +954,9 @@ discard block |
||
| 913 | 954 | array( |
| 914 | 955 | ) |
| 915 | 956 | ); |
| 916 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 917 | - $message_limit_cache[$row['id_group']] = $row['max_messages']; |
|
| 957 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 958 | + $message_limit_cache[$row['id_group']] = $row['max_messages']; |
|
| 959 | + } |
|
| 918 | 960 | $smcFunc['db_free_result']($request); |
| 919 | 961 | } |
| 920 | 962 | |
@@ -922,8 +964,9 @@ discard block |
||
| 922 | 964 | require_once($sourcedir . '/Subs-Members.php'); |
| 923 | 965 | $pmReadGroups = groupsAllowedTo('pm_read'); |
| 924 | 966 | |
| 925 | - if (empty($modSettings['permission_enable_deny'])) |
|
| 926 | - $pmReadGroups['denied'] = array(); |
|
| 967 | + if (empty($modSettings['permission_enable_deny'])) { |
|
| 968 | + $pmReadGroups['denied'] = array(); |
|
| 969 | + } |
|
| 927 | 970 | |
| 928 | 971 | // Load their alert preferences |
| 929 | 972 | require_once($sourcedir . '/Subs-Notify.php'); |
@@ -955,8 +998,9 @@ discard block |
||
| 955 | 998 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 956 | 999 | { |
| 957 | 1000 | // Don't do anything for members to be deleted! |
| 958 | - if (isset($deletes[$row['id_member']])) |
|
| 959 | - continue; |
|
| 1001 | + if (isset($deletes[$row['id_member']])) { |
|
| 1002 | + continue; |
|
| 1003 | + } |
|
| 960 | 1004 | |
| 961 | 1005 | // Load the preferences for this member (if any) |
| 962 | 1006 | $prefs = !empty($notifyPrefs[$row['id_member']]) ? $notifyPrefs[$row['id_member']] : array(); |
@@ -977,8 +1021,9 @@ discard block |
||
| 977 | 1021 | { |
| 978 | 1022 | foreach ($groups as $id) |
| 979 | 1023 | { |
| 980 | - if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id]) |
|
| 981 | - $message_limit = $message_limit_cache[$id]; |
|
| 1024 | + if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id]) { |
|
| 1025 | + $message_limit = $message_limit_cache[$id]; |
|
| 1026 | + } |
|
| 982 | 1027 | } |
| 983 | 1028 | |
| 984 | 1029 | if ($message_limit > 0 && $message_limit <= $row['instant_messages']) |
@@ -1026,8 +1071,9 @@ discard block |
||
| 1026 | 1071 | $smcFunc['db_free_result']($request); |
| 1027 | 1072 | |
| 1028 | 1073 | // Only 'send' the message if there are any recipients left. |
| 1029 | - if (empty($all_to)) |
|
| 1030 | - return $log; |
|
| 1074 | + if (empty($all_to)) { |
|
| 1075 | + return $log; |
|
| 1076 | + } |
|
| 1031 | 1077 | |
| 1032 | 1078 | // Insert the message itself and then grab the last insert id. |
| 1033 | 1079 | $id_pm = $smcFunc['db_insert']('', |
@@ -1048,8 +1094,8 @@ discard block |
||
| 1048 | 1094 | if (!empty($id_pm)) |
| 1049 | 1095 | { |
| 1050 | 1096 | // If this is new we need to set it part of it's own conversation. |
| 1051 | - if (empty($pm_head)) |
|
| 1052 | - $smcFunc['db_query']('', ' |
|
| 1097 | + if (empty($pm_head)) { |
|
| 1098 | + $smcFunc['db_query']('', ' |
|
| 1053 | 1099 | UPDATE {db_prefix}personal_messages |
| 1054 | 1100 | SET id_pm_head = {int:id_pm_head} |
| 1055 | 1101 | WHERE id_pm = {int:id_pm_head}', |
@@ -1057,6 +1103,7 @@ discard block |
||
| 1057 | 1103 | 'id_pm_head' => $id_pm, |
| 1058 | 1104 | ) |
| 1059 | 1105 | ); |
| 1106 | + } |
|
| 1060 | 1107 | |
| 1061 | 1108 | // Some people think manually deleting personal_messages is fun... it's not. We protect against it though :) |
| 1062 | 1109 | $smcFunc['db_query']('', ' |
@@ -1072,8 +1119,9 @@ discard block |
||
| 1072 | 1119 | foreach ($all_to as $to) |
| 1073 | 1120 | { |
| 1074 | 1121 | $insertRows[] = array($id_pm, $to, in_array($to, $recipients['bcc']) ? 1 : 0, isset($deletes[$to]) ? 1 : 0, 1); |
| 1075 | - if (!in_array($to, $recipients['bcc'])) |
|
| 1076 | - $to_list[] = $to; |
|
| 1122 | + if (!in_array($to, $recipients['bcc'])) { |
|
| 1123 | + $to_list[] = $to; |
|
| 1124 | + } |
|
| 1077 | 1125 | } |
| 1078 | 1126 | |
| 1079 | 1127 | $smcFunc['db_insert']('insert', |
@@ -1091,9 +1139,9 @@ discard block |
||
| 1091 | 1139 | { |
| 1092 | 1140 | censorText($message); |
| 1093 | 1141 | $message = trim(un_htmlspecialchars(strip_tags(strtr(parse_bbc($smcFunc['htmlspecialchars']($message), false), array('<br>' => "\n", '</div>' => "\n", '</li>' => "\n", '[' => '[', ']' => ']'))))); |
| 1142 | + } else { |
|
| 1143 | + $message = ''; |
|
| 1094 | 1144 | } |
| 1095 | - else |
|
| 1096 | - $message = ''; |
|
| 1097 | 1145 | |
| 1098 | 1146 | $to_names = array(); |
| 1099 | 1147 | if (count($to_list) > 1) |
@@ -1106,8 +1154,9 @@ discard block |
||
| 1106 | 1154 | 'to_members' => $to_list, |
| 1107 | 1155 | ) |
| 1108 | 1156 | ); |
| 1109 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1110 | - $to_names[] = un_htmlspecialchars($row['real_name']); |
|
| 1157 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1158 | + $to_names[] = un_htmlspecialchars($row['real_name']); |
|
| 1159 | + } |
|
| 1111 | 1160 | $smcFunc['db_free_result']($request); |
| 1112 | 1161 | } |
| 1113 | 1162 | $replacements = array( |
@@ -1135,11 +1184,13 @@ discard block |
||
| 1135 | 1184 | loadLanguage('index+PersonalMessage'); |
| 1136 | 1185 | |
| 1137 | 1186 | // Add one to their unread and read message counts. |
| 1138 | - foreach ($all_to as $k => $id) |
|
| 1139 | - if (isset($deletes[$id])) |
|
| 1187 | + foreach ($all_to as $k => $id) { |
|
| 1188 | + if (isset($deletes[$id])) |
|
| 1140 | 1189 | unset($all_to[$k]); |
| 1141 | - if (!empty($all_to)) |
|
| 1142 | - updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1)); |
|
| 1190 | + } |
|
| 1191 | + if (!empty($all_to)) { |
|
| 1192 | + updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1)); |
|
| 1193 | + } |
|
| 1143 | 1194 | |
| 1144 | 1195 | return $log; |
| 1145 | 1196 | } |
@@ -1169,15 +1220,17 @@ discard block |
||
| 1169 | 1220 | // Let's, for now, assume there are only 'ish characters. |
| 1170 | 1221 | $simple = true; |
| 1171 | 1222 | |
| 1172 | - foreach ($matches[1] as $entity) |
|
| 1173 | - if ($entity > 128) |
|
| 1223 | + foreach ($matches[1] as $entity) { |
|
| 1224 | + if ($entity > 128) |
|
| 1174 | 1225 | $simple = false; |
| 1226 | + } |
|
| 1175 | 1227 | unset($matches); |
| 1176 | 1228 | |
| 1177 | - if ($simple) |
|
| 1178 | - $string = preg_replace_callback('~&#(\d{3,8});~', function($m) |
|
| 1229 | + if ($simple) { |
|
| 1230 | + $string = preg_replace_callback('~&#(\d{3,8});~', function($m) |
|
| 1179 | 1231 | { |
| 1180 | 1232 | return chr("$m[1]"); |
| 1233 | + } |
|
| 1181 | 1234 | }, $string); |
| 1182 | 1235 | else |
| 1183 | 1236 | { |
@@ -1185,8 +1238,9 @@ discard block |
||
| 1185 | 1238 | if (!$context['utf8'] && function_exists('iconv')) |
| 1186 | 1239 | { |
| 1187 | 1240 | $newstring = @iconv($context['character_set'], 'UTF-8', $string); |
| 1188 | - if ($newstring) |
|
| 1189 | - $string = $newstring; |
|
| 1241 | + if ($newstring) { |
|
| 1242 | + $string = $newstring; |
|
| 1243 | + } |
|
| 1190 | 1244 | } |
| 1191 | 1245 | |
| 1192 | 1246 | $string = preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $string); |
@@ -1202,23 +1256,25 @@ discard block |
||
| 1202 | 1256 | if (!$context['utf8'] && function_exists('iconv')) |
| 1203 | 1257 | { |
| 1204 | 1258 | $newstring = @iconv($context['character_set'], 'UTF-8', $string); |
| 1205 | - if ($newstring) |
|
| 1206 | - $string = $newstring; |
|
| 1259 | + if ($newstring) { |
|
| 1260 | + $string = $newstring; |
|
| 1261 | + } |
|
| 1207 | 1262 | } |
| 1208 | 1263 | |
| 1209 | 1264 | $entityConvert = function($m) |
| 1210 | 1265 | { |
| 1211 | 1266 | $c = $m[1]; |
| 1212 | - if (strlen($c) === 1 && ord($c[0]) <= 0x7F) |
|
| 1213 | - return $c; |
|
| 1214 | - elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF) |
|
| 1215 | - return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";"; |
|
| 1216 | - elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF) |
|
| 1217 | - return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";"; |
|
| 1218 | - elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7) |
|
| 1219 | - return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";"; |
|
| 1220 | - else |
|
| 1221 | - return ""; |
|
| 1267 | + if (strlen($c) === 1 && ord($c[0]) <= 0x7F) { |
|
| 1268 | + return $c; |
|
| 1269 | + } elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF) { |
|
| 1270 | + return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";"; |
|
| 1271 | + } elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF) { |
|
| 1272 | + return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";"; |
|
| 1273 | + } elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7) { |
|
| 1274 | + return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";"; |
|
| 1275 | + } else { |
|
| 1276 | + return ""; |
|
| 1277 | + } |
|
| 1222 | 1278 | }; |
| 1223 | 1279 | |
| 1224 | 1280 | // Convert all 'special' characters to HTML entities. |
@@ -1232,19 +1288,20 @@ discard block |
||
| 1232 | 1288 | $string = base64_encode($string); |
| 1233 | 1289 | |
| 1234 | 1290 | // Show the characterset and the transfer-encoding for header strings. |
| 1235 | - if ($with_charset) |
|
| 1236 | - $string = '=?' . $charset . '?B?' . $string . '?='; |
|
| 1291 | + if ($with_charset) { |
|
| 1292 | + $string = '=?' . $charset . '?B?' . $string . '?='; |
|
| 1293 | + } |
|
| 1237 | 1294 | |
| 1238 | 1295 | // Break it up in lines (mail body). |
| 1239 | - else |
|
| 1240 | - $string = chunk_split($string, 76, $line_break); |
|
| 1296 | + else { |
|
| 1297 | + $string = chunk_split($string, 76, $line_break); |
|
| 1298 | + } |
|
| 1241 | 1299 | |
| 1242 | 1300 | return array($charset, $string, 'base64'); |
| 1301 | + } else { |
|
| 1302 | + return array($charset, $string, '7bit'); |
|
| 1303 | + } |
|
| 1243 | 1304 | } |
| 1244 | - |
|
| 1245 | - else |
|
| 1246 | - return array($charset, $string, '7bit'); |
|
| 1247 | -} |
|
| 1248 | 1305 | |
| 1249 | 1306 | /** |
| 1250 | 1307 | * Sends mail, like mail() but over SMTP. |
@@ -1270,8 +1327,9 @@ discard block |
||
| 1270 | 1327 | if ($modSettings['mail_type'] == 3 && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '') |
| 1271 | 1328 | { |
| 1272 | 1329 | $socket = fsockopen($modSettings['smtp_host'], 110, $errno, $errstr, 2); |
| 1273 | - if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.')) |
|
| 1274 | - $socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2); |
|
| 1330 | + if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.')) { |
|
| 1331 | + $socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2); |
|
| 1332 | + } |
|
| 1275 | 1333 | |
| 1276 | 1334 | if ($socket) |
| 1277 | 1335 | { |
@@ -1293,11 +1351,13 @@ discard block |
||
| 1293 | 1351 | if (substr($modSettings['smtp_host'], 0, 4) == 'ssl:' && (empty($modSettings['smtp_port']) || $modSettings['smtp_port'] == 25)) |
| 1294 | 1352 | { |
| 1295 | 1353 | // ssl:hostname can cause fsocketopen to fail with a lookup failure, ensure it exists for this test. |
| 1296 | - if (substr($modSettings['smtp_host'], 0, 6) != 'ssl://') |
|
| 1297 | - $modSettings['smtp_host'] = str_replace('ssl:', 'ss://', $modSettings['smtp_host']); |
|
| 1354 | + if (substr($modSettings['smtp_host'], 0, 6) != 'ssl://') { |
|
| 1355 | + $modSettings['smtp_host'] = str_replace('ssl:', 'ss://', $modSettings['smtp_host']); |
|
| 1356 | + } |
|
| 1298 | 1357 | |
| 1299 | - if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3)) |
|
| 1300 | - log_error($txt['smtp_port_ssl']); |
|
| 1358 | + if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3)) { |
|
| 1359 | + log_error($txt['smtp_port_ssl']); |
|
| 1360 | + } |
|
| 1301 | 1361 | } |
| 1302 | 1362 | |
| 1303 | 1363 | // Unable to connect! Don't show any error message, but just log one and try to continue anyway. |
@@ -1309,26 +1369,30 @@ discard block |
||
| 1309 | 1369 | } |
| 1310 | 1370 | |
| 1311 | 1371 | // Wait for a response of 220, without "-" continuer. |
| 1312 | - if (!server_parse(null, $socket, '220')) |
|
| 1313 | - return false; |
|
| 1372 | + if (!server_parse(null, $socket, '220')) { |
|
| 1373 | + return false; |
|
| 1374 | + } |
|
| 1314 | 1375 | |
| 1315 | 1376 | // Try to determine the server's fully qualified domain name |
| 1316 | 1377 | // Can't rely on $_SERVER['SERVER_NAME'] because it can be spoofed on Apache |
| 1317 | 1378 | if (empty($helo)) |
| 1318 | 1379 | { |
| 1319 | 1380 | // See if we can get the domain name from the host itself |
| 1320 | - if (function_exists('gethostname')) |
|
| 1321 | - $helo = gethostname(); |
|
| 1322 | - elseif (function_exists('php_uname')) |
|
| 1323 | - $helo = php_uname('n'); |
|
| 1381 | + if (function_exists('gethostname')) { |
|
| 1382 | + $helo = gethostname(); |
|
| 1383 | + } elseif (function_exists('php_uname')) { |
|
| 1384 | + $helo = php_uname('n'); |
|
| 1385 | + } |
|
| 1324 | 1386 | |
| 1325 | 1387 | // If the hostname isn't a fully qualified domain name, we can use the host name from $boardurl instead |
| 1326 | - if (empty($helo) || strpos($helo, '.') === false || substr_compare($helo, '.local', -6) === 0 || (!empty($modSettings['tld_regex']) && !preg_match('/\.' . $modSettings['tld_regex'] . '$/u', $helo))) |
|
| 1327 | - $helo = parse_url($boardurl, PHP_URL_HOST); |
|
| 1388 | + if (empty($helo) || strpos($helo, '.') === false || substr_compare($helo, '.local', -6) === 0 || (!empty($modSettings['tld_regex']) && !preg_match('/\.' . $modSettings['tld_regex'] . '$/u', $helo))) { |
|
| 1389 | + $helo = parse_url($boardurl, PHP_URL_HOST); |
|
| 1390 | + } |
|
| 1328 | 1391 | |
| 1329 | 1392 | // This is one of those situations where 'www.' is undesirable |
| 1330 | - if (strpos($helo, 'www.') === 0) |
|
| 1331 | - $helo = substr($helo, 4); |
|
| 1393 | + if (strpos($helo, 'www.') === 0) { |
|
| 1394 | + $helo = substr($helo, 4); |
|
| 1395 | + } |
|
| 1332 | 1396 | } |
| 1333 | 1397 | |
| 1334 | 1398 | // SMTP = 1, SMTP - STARTTLS = 2 |
@@ -1341,8 +1405,9 @@ discard block |
||
| 1341 | 1405 | if ($modSettings['mail_type'] == 2 && preg_match("~250( |-)STARTTLS~mi", $response)) |
| 1342 | 1406 | { |
| 1343 | 1407 | // Send STARTTLS to enable encryption |
| 1344 | - if (!server_parse('STARTTLS', $socket, '220')) |
|
| 1345 | - return false; |
|
| 1408 | + if (!server_parse('STARTTLS', $socket, '220')) { |
|
| 1409 | + return false; |
|
| 1410 | + } |
|
| 1346 | 1411 | // Enable the encryption |
| 1347 | 1412 | // php 5.6+ fix |
| 1348 | 1413 | $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT; |
@@ -1353,30 +1418,35 @@ discard block |
||
| 1353 | 1418 | $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT; |
| 1354 | 1419 | } |
| 1355 | 1420 | |
| 1356 | - if (!@stream_socket_enable_crypto($socket, true, $crypto_method)) |
|
| 1357 | - return false; |
|
| 1421 | + if (!@stream_socket_enable_crypto($socket, true, $crypto_method)) { |
|
| 1422 | + return false; |
|
| 1423 | + } |
|
| 1358 | 1424 | // Send the EHLO command again |
| 1359 | - if (!server_parse('EHLO ' . $helo, $socket, null) == '250') |
|
| 1360 | - return false; |
|
| 1425 | + if (!server_parse('EHLO ' . $helo, $socket, null) == '250') { |
|
| 1426 | + return false; |
|
| 1427 | + } |
|
| 1361 | 1428 | } |
| 1362 | 1429 | |
| 1363 | - if (!server_parse('AUTH LOGIN', $socket, '334')) |
|
| 1364 | - return false; |
|
| 1430 | + if (!server_parse('AUTH LOGIN', $socket, '334')) { |
|
| 1431 | + return false; |
|
| 1432 | + } |
|
| 1365 | 1433 | // Send the username and password, encoded. |
| 1366 | - if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334')) |
|
| 1367 | - return false; |
|
| 1434 | + if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334')) { |
|
| 1435 | + return false; |
|
| 1436 | + } |
|
| 1368 | 1437 | // The password is already encoded ;) |
| 1369 | - if (!server_parse($modSettings['smtp_password'], $socket, '235')) |
|
| 1370 | - return false; |
|
| 1438 | + if (!server_parse($modSettings['smtp_password'], $socket, '235')) { |
|
| 1439 | + return false; |
|
| 1440 | + } |
|
| 1441 | + } elseif (!server_parse('HELO ' . $helo, $socket, '250')) { |
|
| 1442 | + return false; |
|
| 1371 | 1443 | } |
| 1372 | - elseif (!server_parse('HELO ' . $helo, $socket, '250')) |
|
| 1373 | - return false; |
|
| 1374 | - } |
|
| 1375 | - else |
|
| 1444 | + } else |
|
| 1376 | 1445 | { |
| 1377 | 1446 | // Just say "helo". |
| 1378 | - if (!server_parse('HELO ' . $helo, $socket, '250')) |
|
| 1379 | - return false; |
|
| 1447 | + if (!server_parse('HELO ' . $helo, $socket, '250')) { |
|
| 1448 | + return false; |
|
| 1449 | + } |
|
| 1380 | 1450 | } |
| 1381 | 1451 | |
| 1382 | 1452 | // Fix the message for any lines beginning with a period! (the first is ignored, you see.) |
@@ -1389,31 +1459,38 @@ discard block |
||
| 1389 | 1459 | // Reset the connection to send another email. |
| 1390 | 1460 | if ($i != 0) |
| 1391 | 1461 | { |
| 1392 | - if (!server_parse('RSET', $socket, '250')) |
|
| 1393 | - return false; |
|
| 1462 | + if (!server_parse('RSET', $socket, '250')) { |
|
| 1463 | + return false; |
|
| 1464 | + } |
|
| 1394 | 1465 | } |
| 1395 | 1466 | |
| 1396 | 1467 | // From, to, and then start the data... |
| 1397 | - if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250')) |
|
| 1398 | - return false; |
|
| 1399 | - if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250')) |
|
| 1400 | - return false; |
|
| 1401 | - if (!server_parse('DATA', $socket, '354')) |
|
| 1402 | - return false; |
|
| 1468 | + if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250')) { |
|
| 1469 | + return false; |
|
| 1470 | + } |
|
| 1471 | + if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250')) { |
|
| 1472 | + return false; |
|
| 1473 | + } |
|
| 1474 | + if (!server_parse('DATA', $socket, '354')) { |
|
| 1475 | + return false; |
|
| 1476 | + } |
|
| 1403 | 1477 | fputs($socket, 'Subject: ' . $subject . "\r\n"); |
| 1404 | - if (strlen($mail_to) > 0) |
|
| 1405 | - fputs($socket, 'To: <' . $mail_to . '>' . "\r\n"); |
|
| 1478 | + if (strlen($mail_to) > 0) { |
|
| 1479 | + fputs($socket, 'To: <' . $mail_to . '>' . "\r\n"); |
|
| 1480 | + } |
|
| 1406 | 1481 | fputs($socket, $headers . "\r\n\r\n"); |
| 1407 | 1482 | fputs($socket, $message . "\r\n"); |
| 1408 | 1483 | |
| 1409 | 1484 | // Send a ., or in other words "end of data". |
| 1410 | - if (!server_parse('.', $socket, '250')) |
|
| 1411 | - return false; |
|
| 1485 | + if (!server_parse('.', $socket, '250')) { |
|
| 1486 | + return false; |
|
| 1487 | + } |
|
| 1412 | 1488 | |
| 1413 | 1489 | // Almost done, almost done... don't stop me just yet! |
| 1414 | 1490 | @set_time_limit(300); |
| 1415 | - if (function_exists('apache_reset_timeout')) |
|
| 1416 | - @apache_reset_timeout(); |
|
| 1491 | + if (function_exists('apache_reset_timeout')) { |
|
| 1492 | + @apache_reset_timeout(); |
|
| 1493 | + } |
|
| 1417 | 1494 | } |
| 1418 | 1495 | fputs($socket, 'QUIT' . "\r\n"); |
| 1419 | 1496 | fclose($socket); |
@@ -1437,8 +1514,9 @@ discard block |
||
| 1437 | 1514 | { |
| 1438 | 1515 | global $txt; |
| 1439 | 1516 | |
| 1440 | - if ($message !== null) |
|
| 1441 | - fputs($socket, $message . "\r\n"); |
|
| 1517 | + if ($message !== null) { |
|
| 1518 | + fputs($socket, $message . "\r\n"); |
|
| 1519 | + } |
|
| 1442 | 1520 | |
| 1443 | 1521 | // No response yet. |
| 1444 | 1522 | $server_response = ''; |
@@ -1454,8 +1532,9 @@ discard block |
||
| 1454 | 1532 | $response .= $server_response; |
| 1455 | 1533 | } |
| 1456 | 1534 | |
| 1457 | - if ($code === null) |
|
| 1458 | - return substr($server_response, 0, 3); |
|
| 1535 | + if ($code === null) { |
|
| 1536 | + return substr($server_response, 0, 3); |
|
| 1537 | + } |
|
| 1459 | 1538 | |
| 1460 | 1539 | if (substr($server_response, 0, 3) != $code) |
| 1461 | 1540 | { |
@@ -1485,8 +1564,9 @@ discard block |
||
| 1485 | 1564 | // Create a pspell or enchant dictionary resource |
| 1486 | 1565 | $dict = spell_init(); |
| 1487 | 1566 | |
| 1488 | - if (!isset($_POST['spellstring']) || !$dict) |
|
| 1489 | - die; |
|
| 1567 | + if (!isset($_POST['spellstring']) || !$dict) { |
|
| 1568 | + die; |
|
| 1569 | + } |
|
| 1490 | 1570 | |
| 1491 | 1571 | // Construct a bit of Javascript code. |
| 1492 | 1572 | $context['spell_js'] = ' |
@@ -1504,8 +1584,9 @@ discard block |
||
| 1504 | 1584 | $check_word = explode('|', $alphas[$i]); |
| 1505 | 1585 | |
| 1506 | 1586 | // If the word is a known word, or spelled right... |
| 1507 | - if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2])) |
|
| 1508 | - continue; |
|
| 1587 | + if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2])) { |
|
| 1588 | + continue; |
|
| 1589 | + } |
|
| 1509 | 1590 | |
| 1510 | 1591 | // Find the word, and move up the "last occurrence" to here. |
| 1511 | 1592 | $found_words = true; |
@@ -1519,20 +1600,23 @@ discard block |
||
| 1519 | 1600 | if (!empty($suggestions)) |
| 1520 | 1601 | { |
| 1521 | 1602 | // But first check they aren't going to be censored - no naughty words! |
| 1522 | - foreach ($suggestions as $k => $word) |
|
| 1523 | - if ($suggestions[$k] != censorText($word)) |
|
| 1603 | + foreach ($suggestions as $k => $word) { |
|
| 1604 | + if ($suggestions[$k] != censorText($word)) |
|
| 1524 | 1605 | unset($suggestions[$k]); |
| 1606 | + } |
|
| 1525 | 1607 | |
| 1526 | - if (!empty($suggestions)) |
|
| 1527 | - $context['spell_js'] .= '"' . implode('", "', $suggestions) . '"'; |
|
| 1608 | + if (!empty($suggestions)) { |
|
| 1609 | + $context['spell_js'] .= '"' . implode('", "', $suggestions) . '"'; |
|
| 1610 | + } |
|
| 1528 | 1611 | } |
| 1529 | 1612 | |
| 1530 | 1613 | $context['spell_js'] .= ']),'; |
| 1531 | 1614 | } |
| 1532 | 1615 | |
| 1533 | 1616 | // If words were found, take off the last comma. |
| 1534 | - if ($found_words) |
|
| 1535 | - $context['spell_js'] = substr($context['spell_js'], 0, -1); |
|
| 1617 | + if ($found_words) { |
|
| 1618 | + $context['spell_js'] = substr($context['spell_js'], 0, -1); |
|
| 1619 | + } |
|
| 1536 | 1620 | |
| 1537 | 1621 | $context['spell_js'] .= ' |
| 1538 | 1622 | );'; |
@@ -1567,11 +1651,13 @@ discard block |
||
| 1567 | 1651 | global $user_info, $smcFunc; |
| 1568 | 1652 | |
| 1569 | 1653 | // Can't do it if there's no topics. |
| 1570 | - if (empty($topics)) |
|
| 1571 | - return; |
|
| 1654 | + if (empty($topics)) { |
|
| 1655 | + return; |
|
| 1656 | + } |
|
| 1572 | 1657 | // It must be an array - it must! |
| 1573 | - if (!is_array($topics)) |
|
| 1574 | - $topics = array($topics); |
|
| 1658 | + if (!is_array($topics)) { |
|
| 1659 | + $topics = array($topics); |
|
| 1660 | + } |
|
| 1575 | 1661 | |
| 1576 | 1662 | // Get the subject and body... |
| 1577 | 1663 | $result = $smcFunc['db_query']('', ' |
@@ -1619,14 +1705,15 @@ discard block |
||
| 1619 | 1705 | } |
| 1620 | 1706 | $smcFunc['db_free_result']($result); |
| 1621 | 1707 | |
| 1622 | - if (!empty($task_rows)) |
|
| 1623 | - $smcFunc['db_insert']('', |
|
| 1708 | + if (!empty($task_rows)) { |
|
| 1709 | + $smcFunc['db_insert']('', |
|
| 1624 | 1710 | '{db_prefix}background_tasks', |
| 1625 | 1711 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
| 1626 | 1712 | $task_rows, |
| 1627 | 1713 | array('id_task') |
| 1628 | 1714 | ); |
| 1629 | -} |
|
| 1715 | + } |
|
| 1716 | + } |
|
| 1630 | 1717 | |
| 1631 | 1718 | /** |
| 1632 | 1719 | * Create a post, either as new topic (id_topic = 0) or in an existing one. |
@@ -1664,9 +1751,9 @@ discard block |
||
| 1664 | 1751 | $msgOptions['send_notifications'] = isset($msgOptions['send_notifications']) ? (bool) $msgOptions['send_notifications'] : true; |
| 1665 | 1752 | |
| 1666 | 1753 | // We need to know if the topic is approved. If we're told that's great - if not find out. |
| 1667 | - if (!$modSettings['postmod_active']) |
|
| 1668 | - $topicOptions['is_approved'] = true; |
|
| 1669 | - elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved'])) |
|
| 1754 | + if (!$modSettings['postmod_active']) { |
|
| 1755 | + $topicOptions['is_approved'] = true; |
|
| 1756 | + } elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved'])) |
|
| 1670 | 1757 | { |
| 1671 | 1758 | $request = $smcFunc['db_query']('', ' |
| 1672 | 1759 | SELECT approved |
@@ -1689,8 +1776,7 @@ discard block |
||
| 1689 | 1776 | $posterOptions['id'] = 0; |
| 1690 | 1777 | $posterOptions['name'] = $txt['guest_title']; |
| 1691 | 1778 | $posterOptions['email'] = ''; |
| 1692 | - } |
|
| 1693 | - elseif ($posterOptions['id'] != $user_info['id']) |
|
| 1779 | + } elseif ($posterOptions['id'] != $user_info['id']) |
|
| 1694 | 1780 | { |
| 1695 | 1781 | $request = $smcFunc['db_query']('', ' |
| 1696 | 1782 | SELECT member_name, email_address |
@@ -1708,12 +1794,11 @@ discard block |
||
| 1708 | 1794 | $posterOptions['id'] = 0; |
| 1709 | 1795 | $posterOptions['name'] = $txt['guest_title']; |
| 1710 | 1796 | $posterOptions['email'] = ''; |
| 1797 | + } else { |
|
| 1798 | + list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request); |
|
| 1711 | 1799 | } |
| 1712 | - else |
|
| 1713 | - list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request); |
|
| 1714 | 1800 | $smcFunc['db_free_result']($request); |
| 1715 | - } |
|
| 1716 | - else |
|
| 1801 | + } else |
|
| 1717 | 1802 | { |
| 1718 | 1803 | $posterOptions['name'] = $user_info['name']; |
| 1719 | 1804 | $posterOptions['email'] = $user_info['email']; |
@@ -1723,8 +1808,9 @@ discard block |
||
| 1723 | 1808 | if (!empty($modSettings['enable_mentions'])) |
| 1724 | 1809 | { |
| 1725 | 1810 | $msgOptions['mentioned_members'] = Mentions::getMentionedMembers($msgOptions['body']); |
| 1726 | - if (!empty($msgOptions['mentioned_members'])) |
|
| 1727 | - $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']); |
|
| 1811 | + if (!empty($msgOptions['mentioned_members'])) { |
|
| 1812 | + $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']); |
|
| 1813 | + } |
|
| 1728 | 1814 | } |
| 1729 | 1815 | |
| 1730 | 1816 | // It's do or die time: forget any user aborts! |
@@ -1757,12 +1843,13 @@ discard block |
||
| 1757 | 1843 | ); |
| 1758 | 1844 | |
| 1759 | 1845 | // Something went wrong creating the message... |
| 1760 | - if (empty($msgOptions['id'])) |
|
| 1761 | - return false; |
|
| 1846 | + if (empty($msgOptions['id'])) { |
|
| 1847 | + return false; |
|
| 1848 | + } |
|
| 1762 | 1849 | |
| 1763 | 1850 | // Fix the attachments. |
| 1764 | - if (!empty($msgOptions['attachments'])) |
|
| 1765 | - $smcFunc['db_query']('', ' |
|
| 1851 | + if (!empty($msgOptions['attachments'])) { |
|
| 1852 | + $smcFunc['db_query']('', ' |
|
| 1766 | 1853 | UPDATE {db_prefix}attachments |
| 1767 | 1854 | SET id_msg = {int:id_msg} |
| 1768 | 1855 | WHERE id_attach IN ({array_int:attachment_list})', |
@@ -1771,6 +1858,7 @@ discard block |
||
| 1771 | 1858 | 'id_msg' => $msgOptions['id'], |
| 1772 | 1859 | ) |
| 1773 | 1860 | ); |
| 1861 | + } |
|
| 1774 | 1862 | |
| 1775 | 1863 | // What if we want to export new posts out to a CMS? |
| 1776 | 1864 | call_integration_hook('integrate_after_create_post', array($msgOptions, $topicOptions, $posterOptions, $message_columns, $message_parameters)); |
@@ -1847,20 +1935,23 @@ discard block |
||
| 1847 | 1935 | 'id_topic' => $topicOptions['id'], |
| 1848 | 1936 | 'counter_increment' => 1, |
| 1849 | 1937 | ); |
| 1850 | - if ($msgOptions['approved']) |
|
| 1851 | - $topics_columns = array( |
|
| 1938 | + if ($msgOptions['approved']) { |
|
| 1939 | + $topics_columns = array( |
|
| 1852 | 1940 | 'id_member_updated = {int:poster_id}', |
| 1853 | 1941 | 'id_last_msg = {int:id_msg}', |
| 1854 | 1942 | 'num_replies = num_replies + {int:counter_increment}', |
| 1855 | 1943 | ); |
| 1856 | - else |
|
| 1857 | - $topics_columns = array( |
|
| 1944 | + } else { |
|
| 1945 | + $topics_columns = array( |
|
| 1858 | 1946 | 'unapproved_posts = unapproved_posts + {int:counter_increment}', |
| 1859 | 1947 | ); |
| 1860 | - if ($topicOptions['lock_mode'] !== null) |
|
| 1861 | - $topics_columns[] = 'locked = {int:locked}'; |
|
| 1862 | - if ($topicOptions['sticky_mode'] !== null) |
|
| 1863 | - $topics_columns[] = 'is_sticky = {int:is_sticky}'; |
|
| 1948 | + } |
|
| 1949 | + if ($topicOptions['lock_mode'] !== null) { |
|
| 1950 | + $topics_columns[] = 'locked = {int:locked}'; |
|
| 1951 | + } |
|
| 1952 | + if ($topicOptions['sticky_mode'] !== null) { |
|
| 1953 | + $topics_columns[] = 'is_sticky = {int:is_sticky}'; |
|
| 1954 | + } |
|
| 1864 | 1955 | |
| 1865 | 1956 | call_integration_hook('integrate_modify_topic', array(&$topics_columns, &$update_parameters, &$msgOptions, &$topicOptions, &$posterOptions)); |
| 1866 | 1957 | |
@@ -1889,8 +1980,8 @@ discard block |
||
| 1889 | 1980 | ); |
| 1890 | 1981 | |
| 1891 | 1982 | // Increase the number of posts and topics on the board. |
| 1892 | - if ($msgOptions['approved']) |
|
| 1893 | - $smcFunc['db_query']('', ' |
|
| 1983 | + if ($msgOptions['approved']) { |
|
| 1984 | + $smcFunc['db_query']('', ' |
|
| 1894 | 1985 | UPDATE {db_prefix}boards |
| 1895 | 1986 | SET num_posts = num_posts + 1' . ($new_topic ? ', num_topics = num_topics + 1' : '') . ' |
| 1896 | 1987 | WHERE id_board = {int:id_board}', |
@@ -1898,7 +1989,7 @@ discard block |
||
| 1898 | 1989 | 'id_board' => $topicOptions['board'], |
| 1899 | 1990 | ) |
| 1900 | 1991 | ); |
| 1901 | - else |
|
| 1992 | + } else |
|
| 1902 | 1993 | { |
| 1903 | 1994 | $smcFunc['db_query']('', ' |
| 1904 | 1995 | UPDATE {db_prefix}boards |
@@ -1968,8 +2059,8 @@ discard block |
||
| 1968 | 2059 | } |
| 1969 | 2060 | } |
| 1970 | 2061 | |
| 1971 | - if ($msgOptions['approved'] && empty($topicOptions['is_approved'])) |
|
| 1972 | - $smcFunc['db_insert']('', |
|
| 2062 | + if ($msgOptions['approved'] && empty($topicOptions['is_approved'])) { |
|
| 2063 | + $smcFunc['db_insert']('', |
|
| 1973 | 2064 | '{db_prefix}background_tasks', |
| 1974 | 2065 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
| 1975 | 2066 | array( |
@@ -1981,19 +2072,22 @@ discard block |
||
| 1981 | 2072 | ), |
| 1982 | 2073 | array('id_task') |
| 1983 | 2074 | ); |
| 2075 | + } |
|
| 1984 | 2076 | |
| 1985 | 2077 | // If there's a custom search index, it may need updating... |
| 1986 | 2078 | require_once($sourcedir . '/Search.php'); |
| 1987 | 2079 | $searchAPI = findSearchAPI(); |
| 1988 | - if (is_callable(array($searchAPI, 'postCreated'))) |
|
| 1989 | - $searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions); |
|
| 2080 | + if (is_callable(array($searchAPI, 'postCreated'))) { |
|
| 2081 | + $searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions); |
|
| 2082 | + } |
|
| 1990 | 2083 | |
| 1991 | 2084 | // Increase the post counter for the user that created the post. |
| 1992 | 2085 | if (!empty($posterOptions['update_post_count']) && !empty($posterOptions['id']) && $msgOptions['approved']) |
| 1993 | 2086 | { |
| 1994 | 2087 | // Are you the one that happened to create this post? |
| 1995 | - if ($user_info['id'] == $posterOptions['id']) |
|
| 1996 | - $user_info['posts']++; |
|
| 2088 | + if ($user_info['id'] == $posterOptions['id']) { |
|
| 2089 | + $user_info['posts']++; |
|
| 2090 | + } |
|
| 1997 | 2091 | updateMemberData($posterOptions['id'], array('posts' => '+')); |
| 1998 | 2092 | } |
| 1999 | 2093 | |
@@ -2001,19 +2095,21 @@ discard block |
||
| 2001 | 2095 | $_SESSION['last_read_topic'] = 0; |
| 2002 | 2096 | |
| 2003 | 2097 | // Better safe than sorry. |
| 2004 | - if (isset($_SESSION['topicseen_cache'][$topicOptions['board']])) |
|
| 2005 | - $_SESSION['topicseen_cache'][$topicOptions['board']]--; |
|
| 2098 | + if (isset($_SESSION['topicseen_cache'][$topicOptions['board']])) { |
|
| 2099 | + $_SESSION['topicseen_cache'][$topicOptions['board']]--; |
|
| 2100 | + } |
|
| 2006 | 2101 | |
| 2007 | 2102 | // Update all the stats so everyone knows about this new topic and message. |
| 2008 | 2103 | updateStats('message', true, $msgOptions['id']); |
| 2009 | 2104 | |
| 2010 | 2105 | // Update the last message on the board assuming it's approved AND the topic is. |
| 2011 | - if ($msgOptions['approved']) |
|
| 2012 | - updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0); |
|
| 2106 | + if ($msgOptions['approved']) { |
|
| 2107 | + updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0); |
|
| 2108 | + } |
|
| 2013 | 2109 | |
| 2014 | 2110 | // Queue createPost background notification |
| 2015 | - if ($msgOptions['send_notifications'] && $msgOptions['approved']) |
|
| 2016 | - $smcFunc['db_insert']('', |
|
| 2111 | + if ($msgOptions['send_notifications'] && $msgOptions['approved']) { |
|
| 2112 | + $smcFunc['db_insert']('', |
|
| 2017 | 2113 | '{db_prefix}background_tasks', |
| 2018 | 2114 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
| 2019 | 2115 | array('$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', $smcFunc['json_encode'](array( |
@@ -2024,6 +2120,7 @@ discard block |
||
| 2024 | 2120 | )), 0), |
| 2025 | 2121 | array('id_task') |
| 2026 | 2122 | ); |
| 2123 | + } |
|
| 2027 | 2124 | |
| 2028 | 2125 | // Alright, done now... we can abort now, I guess... at least this much is done. |
| 2029 | 2126 | ignore_user_abort($previous_ignore_user_abort); |
@@ -2050,14 +2147,18 @@ discard block |
||
| 2050 | 2147 | |
| 2051 | 2148 | // This is longer than it has to be, but makes it so we only set/change what we have to. |
| 2052 | 2149 | $messages_columns = array(); |
| 2053 | - if (isset($posterOptions['name'])) |
|
| 2054 | - $messages_columns['poster_name'] = $posterOptions['name']; |
|
| 2055 | - if (isset($posterOptions['email'])) |
|
| 2056 | - $messages_columns['poster_email'] = $posterOptions['email']; |
|
| 2057 | - if (isset($msgOptions['icon'])) |
|
| 2058 | - $messages_columns['icon'] = $msgOptions['icon']; |
|
| 2059 | - if (isset($msgOptions['subject'])) |
|
| 2060 | - $messages_columns['subject'] = $msgOptions['subject']; |
|
| 2150 | + if (isset($posterOptions['name'])) { |
|
| 2151 | + $messages_columns['poster_name'] = $posterOptions['name']; |
|
| 2152 | + } |
|
| 2153 | + if (isset($posterOptions['email'])) { |
|
| 2154 | + $messages_columns['poster_email'] = $posterOptions['email']; |
|
| 2155 | + } |
|
| 2156 | + if (isset($msgOptions['icon'])) { |
|
| 2157 | + $messages_columns['icon'] = $msgOptions['icon']; |
|
| 2158 | + } |
|
| 2159 | + if (isset($msgOptions['subject'])) { |
|
| 2160 | + $messages_columns['subject'] = $msgOptions['subject']; |
|
| 2161 | + } |
|
| 2061 | 2162 | if (isset($msgOptions['body'])) |
| 2062 | 2163 | { |
| 2063 | 2164 | $messages_columns['body'] = $msgOptions['body']; |
@@ -2084,8 +2185,9 @@ discard block |
||
| 2084 | 2185 | $messages_columns['modified_reason'] = $msgOptions['modify_reason']; |
| 2085 | 2186 | $messages_columns['id_msg_modified'] = $modSettings['maxMsgID']; |
| 2086 | 2187 | } |
| 2087 | - if (isset($msgOptions['smileys_enabled'])) |
|
| 2088 | - $messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1; |
|
| 2188 | + if (isset($msgOptions['smileys_enabled'])) { |
|
| 2189 | + $messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1; |
|
| 2190 | + } |
|
| 2089 | 2191 | |
| 2090 | 2192 | // Which columns need to be ints? |
| 2091 | 2193 | $messageInts = array('modified_time', 'id_msg_modified', 'smileys_enabled'); |
@@ -2096,8 +2198,9 @@ discard block |
||
| 2096 | 2198 | // Update search api |
| 2097 | 2199 | require_once($sourcedir . '/Search.php'); |
| 2098 | 2200 | $searchAPI = findSearchAPI(); |
| 2099 | - if ($searchAPI->supportsMethod('postRemoved')) |
|
| 2100 | - $searchAPI->postRemoved($msgOptions['id']); |
|
| 2201 | + if ($searchAPI->supportsMethod('postRemoved')) { |
|
| 2202 | + $searchAPI->postRemoved($msgOptions['id']); |
|
| 2203 | + } |
|
| 2101 | 2204 | |
| 2102 | 2205 | if (!empty($modSettings['enable_mentions']) && isset($msgOptions['body'])) |
| 2103 | 2206 | { |
@@ -2109,23 +2212,27 @@ discard block |
||
| 2109 | 2212 | { |
| 2110 | 2213 | preg_match_all('/\[member\=([0-9]+)\]([^\[]*)\[\/member\]/U', $msgOptions['old_body'], $match); |
| 2111 | 2214 | |
| 2112 | - if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2])) |
|
| 2113 | - foreach ($match[1] as $i => $oldID) |
|
| 2215 | + if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2])) { |
|
| 2216 | + foreach ($match[1] as $i => $oldID) |
|
| 2114 | 2217 | $oldmentions[$oldID] = array('id' => $oldID, 'real_name' => $match[2][$i]); |
| 2218 | + } |
|
| 2115 | 2219 | |
| 2116 | - if (empty($modSettings['search_custom_index_config'])) |
|
| 2117 | - unset($msgOptions['old_body']); |
|
| 2220 | + if (empty($modSettings['search_custom_index_config'])) { |
|
| 2221 | + unset($msgOptions['old_body']); |
|
| 2222 | + } |
|
| 2118 | 2223 | } |
| 2119 | 2224 | |
| 2120 | 2225 | $mentions = Mentions::getMentionedMembers($msgOptions['body']); |
| 2121 | 2226 | $messages_columns['body'] = $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $mentions); |
| 2122 | 2227 | |
| 2123 | 2228 | // Remove the poster. |
| 2124 | - if (isset($mentions[$user_info['id']])) |
|
| 2125 | - unset($mentions[$user_info['id']]); |
|
| 2229 | + if (isset($mentions[$user_info['id']])) { |
|
| 2230 | + unset($mentions[$user_info['id']]); |
|
| 2231 | + } |
|
| 2126 | 2232 | |
| 2127 | - if (isset($oldmentions[$user_info['id']])) |
|
| 2128 | - unset($oldmentions[$user_info['id']]); |
|
| 2233 | + if (isset($oldmentions[$user_info['id']])) { |
|
| 2234 | + unset($oldmentions[$user_info['id']]); |
|
| 2235 | + } |
|
| 2129 | 2236 | |
| 2130 | 2237 | if (is_array($mentions) && is_array($oldmentions) && count(array_diff_key($mentions, $oldmentions)) > 0 && count($mentions) > count($oldmentions)) |
| 2131 | 2238 | { |
@@ -2155,8 +2262,9 @@ discard block |
||
| 2155 | 2262 | } |
| 2156 | 2263 | |
| 2157 | 2264 | // Nothing to do? |
| 2158 | - if (empty($messages_columns)) |
|
| 2159 | - return true; |
|
| 2265 | + if (empty($messages_columns)) { |
|
| 2266 | + return true; |
|
| 2267 | + } |
|
| 2160 | 2268 | |
| 2161 | 2269 | // Change the post. |
| 2162 | 2270 | $smcFunc['db_query']('', ' |
@@ -2217,8 +2325,9 @@ discard block |
||
| 2217 | 2325 | // If there's a custom search index, it needs to be modified... |
| 2218 | 2326 | require_once($sourcedir . '/Search.php'); |
| 2219 | 2327 | $searchAPI = findSearchAPI(); |
| 2220 | - if (is_callable(array($searchAPI, 'postModified'))) |
|
| 2221 | - $searchAPI->postModified($msgOptions, $topicOptions, $posterOptions); |
|
| 2328 | + if (is_callable(array($searchAPI, 'postModified'))) { |
|
| 2329 | + $searchAPI->postModified($msgOptions, $topicOptions, $posterOptions); |
|
| 2330 | + } |
|
| 2222 | 2331 | |
| 2223 | 2332 | if (isset($msgOptions['subject'])) |
| 2224 | 2333 | { |
@@ -2232,14 +2341,16 @@ discard block |
||
| 2232 | 2341 | 'id_first_msg' => $msgOptions['id'], |
| 2233 | 2342 | ) |
| 2234 | 2343 | ); |
| 2235 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
| 2236 | - updateStats('subject', $topicOptions['id'], $msgOptions['subject']); |
|
| 2344 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
| 2345 | + updateStats('subject', $topicOptions['id'], $msgOptions['subject']); |
|
| 2346 | + } |
|
| 2237 | 2347 | $smcFunc['db_free_result']($request); |
| 2238 | 2348 | } |
| 2239 | 2349 | |
| 2240 | 2350 | // Finally, if we are setting the approved state we need to do much more work :( |
| 2241 | - if ($modSettings['postmod_active'] && isset($msgOptions['approved'])) |
|
| 2242 | - approvePosts($msgOptions['id'], $msgOptions['approved']); |
|
| 2351 | + if ($modSettings['postmod_active'] && isset($msgOptions['approved'])) { |
|
| 2352 | + approvePosts($msgOptions['id'], $msgOptions['approved']); |
|
| 2353 | + } |
|
| 2243 | 2354 | |
| 2244 | 2355 | return true; |
| 2245 | 2356 | } |
@@ -2256,11 +2367,13 @@ discard block |
||
| 2256 | 2367 | { |
| 2257 | 2368 | global $smcFunc; |
| 2258 | 2369 | |
| 2259 | - if (!is_array($msgs)) |
|
| 2260 | - $msgs = array($msgs); |
|
| 2370 | + if (!is_array($msgs)) { |
|
| 2371 | + $msgs = array($msgs); |
|
| 2372 | + } |
|
| 2261 | 2373 | |
| 2262 | - if (empty($msgs)) |
|
| 2263 | - return false; |
|
| 2374 | + if (empty($msgs)) { |
|
| 2375 | + return false; |
|
| 2376 | + } |
|
| 2264 | 2377 | |
| 2265 | 2378 | // May as well start at the beginning, working out *what* we need to change. |
| 2266 | 2379 | $request = $smcFunc['db_query']('', ' |
@@ -2292,20 +2405,22 @@ discard block |
||
| 2292 | 2405 | $topics[] = $row['id_topic']; |
| 2293 | 2406 | |
| 2294 | 2407 | // Ensure our change array exists already. |
| 2295 | - if (!isset($topic_changes[$row['id_topic']])) |
|
| 2296 | - $topic_changes[$row['id_topic']] = array( |
|
| 2408 | + if (!isset($topic_changes[$row['id_topic']])) { |
|
| 2409 | + $topic_changes[$row['id_topic']] = array( |
|
| 2297 | 2410 | 'id_last_msg' => $row['id_last_msg'], |
| 2298 | 2411 | 'approved' => $row['topic_approved'], |
| 2299 | 2412 | 'replies' => 0, |
| 2300 | 2413 | 'unapproved_posts' => 0, |
| 2301 | 2414 | ); |
| 2302 | - if (!isset($board_changes[$row['id_board']])) |
|
| 2303 | - $board_changes[$row['id_board']] = array( |
|
| 2415 | + } |
|
| 2416 | + if (!isset($board_changes[$row['id_board']])) { |
|
| 2417 | + $board_changes[$row['id_board']] = array( |
|
| 2304 | 2418 | 'posts' => 0, |
| 2305 | 2419 | 'topics' => 0, |
| 2306 | 2420 | 'unapproved_posts' => 0, |
| 2307 | 2421 | 'unapproved_topics' => 0, |
| 2308 | 2422 | ); |
| 2423 | + } |
|
| 2309 | 2424 | |
| 2310 | 2425 | // If it's the first message then the topic state changes! |
| 2311 | 2426 | if ($row['id_msg'] == $row['id_first_msg']) |
@@ -2326,14 +2441,13 @@ discard block |
||
| 2326 | 2441 | 'poster' => $row['id_member'], |
| 2327 | 2442 | 'new_topic' => true, |
| 2328 | 2443 | ); |
| 2329 | - } |
|
| 2330 | - else |
|
| 2444 | + } else |
|
| 2331 | 2445 | { |
| 2332 | 2446 | $topic_changes[$row['id_topic']]['replies'] += $approve ? 1 : -1; |
| 2333 | 2447 | |
| 2334 | 2448 | // This will be a post... but don't notify unless it's not followed by approved ones. |
| 2335 | - if ($row['id_msg'] > $row['id_last_msg']) |
|
| 2336 | - $notification_posts[$row['id_topic']] = array( |
|
| 2449 | + if ($row['id_msg'] > $row['id_last_msg']) { |
|
| 2450 | + $notification_posts[$row['id_topic']] = array( |
|
| 2337 | 2451 | 'id' => $row['id_msg'], |
| 2338 | 2452 | 'body' => $row['body'], |
| 2339 | 2453 | 'subject' => $row['subject'], |
@@ -2344,28 +2458,33 @@ discard block |
||
| 2344 | 2458 | 'new_topic' => false, |
| 2345 | 2459 | 'msg' => $row['id_msg'], |
| 2346 | 2460 | ); |
| 2461 | + } |
|
| 2347 | 2462 | } |
| 2348 | 2463 | |
| 2349 | 2464 | // If this is being approved and id_msg is higher than the current id_last_msg then it changes. |
| 2350 | - if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg']) |
|
| 2351 | - $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg']; |
|
| 2465 | + if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg']) { |
|
| 2466 | + $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg']; |
|
| 2467 | + } |
|
| 2352 | 2468 | // If this is being unapproved, and it's equal to the id_last_msg we need to find a new one! |
| 2353 | - elseif (!$approve) |
|
| 2354 | - // Default to the first message and then we'll override in a bit ;) |
|
| 2469 | + elseif (!$approve) { |
|
| 2470 | + // Default to the first message and then we'll override in a bit ;) |
|
| 2355 | 2471 | $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_first_msg']; |
| 2472 | + } |
|
| 2356 | 2473 | |
| 2357 | 2474 | $topic_changes[$row['id_topic']]['unapproved_posts'] += $approve ? -1 : 1; |
| 2358 | 2475 | $board_changes[$row['id_board']]['unapproved_posts'] += $approve ? -1 : 1; |
| 2359 | 2476 | $board_changes[$row['id_board']]['posts'] += $approve ? 1 : -1; |
| 2360 | 2477 | |
| 2361 | 2478 | // Post count for the user? |
| 2362 | - if ($row['id_member'] && empty($row['count_posts'])) |
|
| 2363 | - $member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1; |
|
| 2479 | + if ($row['id_member'] && empty($row['count_posts'])) { |
|
| 2480 | + $member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1; |
|
| 2481 | + } |
|
| 2364 | 2482 | } |
| 2365 | 2483 | $smcFunc['db_free_result']($request); |
| 2366 | 2484 | |
| 2367 | - if (empty($msgs)) |
|
| 2368 | - return; |
|
| 2485 | + if (empty($msgs)) { |
|
| 2486 | + return; |
|
| 2487 | + } |
|
| 2369 | 2488 | |
| 2370 | 2489 | // Now we have the differences make the changes, first the easy one. |
| 2371 | 2490 | $smcFunc['db_query']('', ' |
@@ -2392,14 +2511,15 @@ discard block |
||
| 2392 | 2511 | 'approved' => 1, |
| 2393 | 2512 | ) |
| 2394 | 2513 | ); |
| 2395 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2396 | - $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg']; |
|
| 2514 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2515 | + $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg']; |
|
| 2516 | + } |
|
| 2397 | 2517 | $smcFunc['db_free_result']($request); |
| 2398 | 2518 | } |
| 2399 | 2519 | |
| 2400 | 2520 | // ... next the topics... |
| 2401 | - foreach ($topic_changes as $id => $changes) |
|
| 2402 | - $smcFunc['db_query']('', ' |
|
| 2521 | + foreach ($topic_changes as $id => $changes) { |
|
| 2522 | + $smcFunc['db_query']('', ' |
|
| 2403 | 2523 | UPDATE {db_prefix}topics |
| 2404 | 2524 | SET approved = {int:approved}, unapproved_posts = unapproved_posts + {int:unapproved_posts}, |
| 2405 | 2525 | num_replies = num_replies + {int:num_replies}, id_last_msg = {int:id_last_msg} |
@@ -2412,10 +2532,11 @@ discard block |
||
| 2412 | 2532 | 'id_topic' => $id, |
| 2413 | 2533 | ) |
| 2414 | 2534 | ); |
| 2535 | + } |
|
| 2415 | 2536 | |
| 2416 | 2537 | // ... finally the boards... |
| 2417 | - foreach ($board_changes as $id => $changes) |
|
| 2418 | - $smcFunc['db_query']('', ' |
|
| 2538 | + foreach ($board_changes as $id => $changes) { |
|
| 2539 | + $smcFunc['db_query']('', ' |
|
| 2419 | 2540 | UPDATE {db_prefix}boards |
| 2420 | 2541 | SET num_posts = num_posts + {int:num_posts}, unapproved_posts = unapproved_posts + {int:unapproved_posts}, |
| 2421 | 2542 | num_topics = num_topics + {int:num_topics}, unapproved_topics = unapproved_topics + {int:unapproved_topics} |
@@ -2428,13 +2549,14 @@ discard block |
||
| 2428 | 2549 | 'id_board' => $id, |
| 2429 | 2550 | ) |
| 2430 | 2551 | ); |
| 2552 | + } |
|
| 2431 | 2553 | |
| 2432 | 2554 | // Finally, least importantly, notifications! |
| 2433 | 2555 | if ($approve) |
| 2434 | 2556 | { |
| 2435 | 2557 | $task_rows = array(); |
| 2436 | - foreach (array_merge($notification_topics, $notification_posts) as $topic) |
|
| 2437 | - $task_rows[] = array( |
|
| 2558 | + foreach (array_merge($notification_topics, $notification_posts) as $topic) { |
|
| 2559 | + $task_rows[] = array( |
|
| 2438 | 2560 | '$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', $smcFunc['json_encode'](array( |
| 2439 | 2561 | 'msgOptions' => array( |
| 2440 | 2562 | 'id' => $topic['msg'], |
@@ -2452,14 +2574,16 @@ discard block |
||
| 2452 | 2574 | 'type' => $topic['new_topic'] ? 'topic' : 'reply', |
| 2453 | 2575 | )), 0 |
| 2454 | 2576 | ); |
| 2577 | + } |
|
| 2455 | 2578 | |
| 2456 | - if ($notify) |
|
| 2457 | - $smcFunc['db_insert']('', |
|
| 2579 | + if ($notify) { |
|
| 2580 | + $smcFunc['db_insert']('', |
|
| 2458 | 2581 | '{db_prefix}background_tasks', |
| 2459 | 2582 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
| 2460 | 2583 | $task_rows, |
| 2461 | 2584 | array('id_task') |
| 2462 | 2585 | ); |
| 2586 | + } |
|
| 2463 | 2587 | |
| 2464 | 2588 | $smcFunc['db_query']('', ' |
| 2465 | 2589 | DELETE FROM {db_prefix}approval_queue |
@@ -2475,8 +2599,9 @@ discard block |
||
| 2475 | 2599 | else |
| 2476 | 2600 | { |
| 2477 | 2601 | $msgInserts = array(); |
| 2478 | - foreach ($msgs as $msg) |
|
| 2479 | - $msgInserts[] = array($msg); |
|
| 2602 | + foreach ($msgs as $msg) { |
|
| 2603 | + $msgInserts[] = array($msg); |
|
| 2604 | + } |
|
| 2480 | 2605 | |
| 2481 | 2606 | $smcFunc['db_insert']('ignore', |
| 2482 | 2607 | '{db_prefix}approval_queue', |
@@ -2490,9 +2615,10 @@ discard block |
||
| 2490 | 2615 | updateLastMessages(array_keys($board_changes)); |
| 2491 | 2616 | |
| 2492 | 2617 | // Post count for the members? |
| 2493 | - if (!empty($member_post_changes)) |
|
| 2494 | - foreach ($member_post_changes as $id_member => $count_change) |
|
| 2618 | + if (!empty($member_post_changes)) { |
|
| 2619 | + foreach ($member_post_changes as $id_member => $count_change) |
|
| 2495 | 2620 | updateMemberData($id_member, array('posts' => 'posts ' . ($approve ? '+' : '-') . ' ' . $count_change)); |
| 2621 | + } |
|
| 2496 | 2622 | |
| 2497 | 2623 | return true; |
| 2498 | 2624 | } |
@@ -2509,11 +2635,13 @@ discard block |
||
| 2509 | 2635 | { |
| 2510 | 2636 | global $smcFunc; |
| 2511 | 2637 | |
| 2512 | - if (!is_array($topics)) |
|
| 2513 | - $topics = array($topics); |
|
| 2638 | + if (!is_array($topics)) { |
|
| 2639 | + $topics = array($topics); |
|
| 2640 | + } |
|
| 2514 | 2641 | |
| 2515 | - if (empty($topics)) |
|
| 2516 | - return false; |
|
| 2642 | + if (empty($topics)) { |
|
| 2643 | + return false; |
|
| 2644 | + } |
|
| 2517 | 2645 | |
| 2518 | 2646 | $approve_type = $approve ? 0 : 1; |
| 2519 | 2647 | |
@@ -2529,8 +2657,9 @@ discard block |
||
| 2529 | 2657 | ) |
| 2530 | 2658 | ); |
| 2531 | 2659 | $msgs = array(); |
| 2532 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2533 | - $msgs[] = $row['id_msg']; |
|
| 2660 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2661 | + $msgs[] = $row['id_msg']; |
|
| 2662 | + } |
|
| 2534 | 2663 | $smcFunc['db_free_result']($request); |
| 2535 | 2664 | |
| 2536 | 2665 | return approvePosts($msgs, $approve); |
@@ -2553,11 +2682,13 @@ discard block |
||
| 2553 | 2682 | global $board_info, $board, $smcFunc; |
| 2554 | 2683 | |
| 2555 | 2684 | // Please - let's be sane. |
| 2556 | - if (empty($setboards)) |
|
| 2557 | - return false; |
|
| 2685 | + if (empty($setboards)) { |
|
| 2686 | + return false; |
|
| 2687 | + } |
|
| 2558 | 2688 | |
| 2559 | - if (!is_array($setboards)) |
|
| 2560 | - $setboards = array($setboards); |
|
| 2689 | + if (!is_array($setboards)) { |
|
| 2690 | + $setboards = array($setboards); |
|
| 2691 | + } |
|
| 2561 | 2692 | |
| 2562 | 2693 | // If we don't know the id_msg we need to find it. |
| 2563 | 2694 | if (!$id_msg) |
@@ -2575,15 +2706,16 @@ discard block |
||
| 2575 | 2706 | ) |
| 2576 | 2707 | ); |
| 2577 | 2708 | $lastMsg = array(); |
| 2578 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2579 | - $lastMsg[$row['id_board']] = $row['id_msg']; |
|
| 2709 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2710 | + $lastMsg[$row['id_board']] = $row['id_msg']; |
|
| 2711 | + } |
|
| 2580 | 2712 | $smcFunc['db_free_result']($request); |
| 2581 | - } |
|
| 2582 | - else |
|
| 2713 | + } else |
|
| 2583 | 2714 | { |
| 2584 | 2715 | // Just to note - there should only be one board passed if we are doing this. |
| 2585 | - foreach ($setboards as $id_board) |
|
| 2586 | - $lastMsg[$id_board] = $id_msg; |
|
| 2716 | + foreach ($setboards as $id_board) { |
|
| 2717 | + $lastMsg[$id_board] = $id_msg; |
|
| 2718 | + } |
|
| 2587 | 2719 | } |
| 2588 | 2720 | |
| 2589 | 2721 | $parent_boards = array(); |
@@ -2598,10 +2730,11 @@ discard block |
||
| 2598 | 2730 | $lastModified[$id_board] = 0; |
| 2599 | 2731 | } |
| 2600 | 2732 | |
| 2601 | - if (!empty($board) && $id_board == $board) |
|
| 2602 | - $parents = $board_info['parent_boards']; |
|
| 2603 | - else |
|
| 2604 | - $parents = getBoardParents($id_board); |
|
| 2733 | + if (!empty($board) && $id_board == $board) { |
|
| 2734 | + $parents = $board_info['parent_boards']; |
|
| 2735 | + } else { |
|
| 2736 | + $parents = getBoardParents($id_board); |
|
| 2737 | + } |
|
| 2605 | 2738 | |
| 2606 | 2739 | // Ignore any parents on the top child level. |
| 2607 | 2740 | // @todo Why? |
@@ -2610,10 +2743,11 @@ discard block |
||
| 2610 | 2743 | if ($parent['level'] != 0) |
| 2611 | 2744 | { |
| 2612 | 2745 | // If we're already doing this one as a board, is this a higher last modified? |
| 2613 | - if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id]) |
|
| 2614 | - $lastModified[$id] = $lastModified[$id_board]; |
|
| 2615 | - elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board])) |
|
| 2616 | - $parent_boards[$id] = $lastModified[$id_board]; |
|
| 2746 | + if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id]) { |
|
| 2747 | + $lastModified[$id] = $lastModified[$id_board]; |
|
| 2748 | + } elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board])) { |
|
| 2749 | + $parent_boards[$id] = $lastModified[$id_board]; |
|
| 2750 | + } |
|
| 2617 | 2751 | } |
| 2618 | 2752 | } |
| 2619 | 2753 | } |
@@ -2626,23 +2760,24 @@ discard block |
||
| 2626 | 2760 | // Finally, to save on queries make the changes... |
| 2627 | 2761 | foreach ($parent_boards as $id => $msg) |
| 2628 | 2762 | { |
| 2629 | - if (!isset($parent_updates[$msg])) |
|
| 2630 | - $parent_updates[$msg] = array($id); |
|
| 2631 | - else |
|
| 2632 | - $parent_updates[$msg][] = $id; |
|
| 2763 | + if (!isset($parent_updates[$msg])) { |
|
| 2764 | + $parent_updates[$msg] = array($id); |
|
| 2765 | + } else { |
|
| 2766 | + $parent_updates[$msg][] = $id; |
|
| 2767 | + } |
|
| 2633 | 2768 | } |
| 2634 | 2769 | |
| 2635 | 2770 | foreach ($lastMsg as $id => $msg) |
| 2636 | 2771 | { |
| 2637 | - if (!isset($board_updates[$msg . '-' . $lastModified[$id]])) |
|
| 2638 | - $board_updates[$msg . '-' . $lastModified[$id]] = array( |
|
| 2772 | + if (!isset($board_updates[$msg . '-' . $lastModified[$id]])) { |
|
| 2773 | + $board_updates[$msg . '-' . $lastModified[$id]] = array( |
|
| 2639 | 2774 | 'id' => $msg, |
| 2640 | 2775 | 'updated' => $lastModified[$id], |
| 2641 | 2776 | 'boards' => array($id) |
| 2642 | 2777 | ); |
| 2643 | - |
|
| 2644 | - else |
|
| 2645 | - $board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id; |
|
| 2778 | + } else { |
|
| 2779 | + $board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id; |
|
| 2780 | + } |
|
| 2646 | 2781 | } |
| 2647 | 2782 | |
| 2648 | 2783 | // Now commit the changes! |
@@ -2734,11 +2869,13 @@ discard block |
||
| 2734 | 2869 | global $txt, $mbname, $scripturl, $settings; |
| 2735 | 2870 | |
| 2736 | 2871 | // First things first, load up the email templates language file, if we need to. |
| 2737 | - if ($loadLang) |
|
| 2738 | - loadLanguage('EmailTemplates', $lang); |
|
| 2872 | + if ($loadLang) { |
|
| 2873 | + loadLanguage('EmailTemplates', $lang); |
|
| 2874 | + } |
|
| 2739 | 2875 | |
| 2740 | - if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body'])) |
|
| 2741 | - fatal_lang_error('email_no_template', 'template', array($template)); |
|
| 2876 | + if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body'])) { |
|
| 2877 | + fatal_lang_error('email_no_template', 'template', array($template)); |
|
| 2878 | + } |
|
| 2742 | 2879 | |
| 2743 | 2880 | $ret = array( |
| 2744 | 2881 | 'subject' => $txt[$template . '_subject'], |
@@ -2788,17 +2925,18 @@ discard block |
||
| 2788 | 2925 | function user_info_callback($matches) |
| 2789 | 2926 | { |
| 2790 | 2927 | global $user_info; |
| 2791 | - if (empty($matches[1])) |
|
| 2792 | - return ''; |
|
| 2928 | + if (empty($matches[1])) { |
|
| 2929 | + return ''; |
|
| 2930 | + } |
|
| 2793 | 2931 | |
| 2794 | 2932 | $use_ref = true; |
| 2795 | 2933 | $ref = &$user_info; |
| 2796 | 2934 | |
| 2797 | 2935 | foreach (explode('.', $matches[1]) as $index) |
| 2798 | 2936 | { |
| 2799 | - if ($use_ref && isset($ref[$index])) |
|
| 2800 | - $ref = &$ref[$index]; |
|
| 2801 | - else |
|
| 2937 | + if ($use_ref && isset($ref[$index])) { |
|
| 2938 | + $ref = &$ref[$index]; |
|
| 2939 | + } else |
|
| 2802 | 2940 | { |
| 2803 | 2941 | $use_ref = false; |
| 2804 | 2942 | break; |
@@ -2835,8 +2973,7 @@ discard block |
||
| 2835 | 2973 | if (!empty($lang_locale) && enchant_broker_dict_exists($context['enchant_broker'], $lang_locale)) |
| 2836 | 2974 | { |
| 2837 | 2975 | $enchant_link = enchant_broker_request_dict($context['enchant_broker'], $lang_locale); |
| 2838 | - } |
|
| 2839 | - elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary'])) |
|
| 2976 | + } elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary'])) |
|
| 2840 | 2977 | { |
| 2841 | 2978 | $enchant_link = enchant_broker_request_dict($context['enchant_broker'], $txt['lang_dictionary']); |
| 2842 | 2979 | } |
@@ -2846,8 +2983,7 @@ discard block |
||
| 2846 | 2983 | { |
| 2847 | 2984 | $context['provider'] = 'enchant'; |
| 2848 | 2985 | return $enchant_link; |
| 2849 | - } |
|
| 2850 | - else |
|
| 2986 | + } else |
|
| 2851 | 2987 | { |
| 2852 | 2988 | // Free up any resources used... |
| 2853 | 2989 | @enchant_broker_free($context['enchant_broker']); |
@@ -2868,8 +3004,9 @@ discard block |
||
| 2868 | 3004 | $pspell_link = pspell_new($txt['lang_dictionary'], $txt['lang_spelling'], '', strtr($context['character_set'], array('iso-' => 'iso', 'ISO-' => 'iso')), PSPELL_FAST | PSPELL_RUN_TOGETHER); |
| 2869 | 3005 | |
| 2870 | 3006 | // Most people don't have anything but English installed... So we use English as a last resort. |
| 2871 | - if (!$pspell_link) |
|
| 2872 | - $pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER); |
|
| 3007 | + if (!$pspell_link) { |
|
| 3008 | + $pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER); |
|
| 3009 | + } |
|
| 2873 | 3010 | |
| 2874 | 3011 | error_reporting($old); |
| 2875 | 3012 | ob_end_clean(); |
@@ -2909,8 +3046,7 @@ discard block |
||
| 2909 | 3046 | $word = iconv($txt['lang_character_set'], 'UTF-8', $word); |
| 2910 | 3047 | } |
| 2911 | 3048 | return enchant_dict_check($dict, $word); |
| 2912 | - } |
|
| 2913 | - elseif ($context['provider'] == 'pspell') |
|
| 3049 | + } elseif ($context['provider'] == 'pspell') |
|
| 2914 | 3050 | { |
| 2915 | 3051 | return pspell_check($dict, $word); |
| 2916 | 3052 | } |
@@ -2946,13 +3082,11 @@ discard block |
||
| 2946 | 3082 | } |
| 2947 | 3083 | |
| 2948 | 3084 | return $suggestions; |
| 2949 | - } |
|
| 2950 | - else |
|
| 3085 | + } else |
|
| 2951 | 3086 | { |
| 2952 | 3087 | return enchant_dict_suggest($dict, $word); |
| 2953 | 3088 | } |
| 2954 | - } |
|
| 2955 | - elseif ($context['provider'] == 'pspell') |
|
| 3089 | + } elseif ($context['provider'] == 'pspell') |
|
| 2956 | 3090 | { |
| 2957 | 3091 | return pspell_suggest($dict, $word); |
| 2958 | 3092 | } |
@@ -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 | * Get the latest post made on the system |
@@ -44,8 +45,9 @@ discard block |
||
| 44 | 45 | 'is_approved' => 1, |
| 45 | 46 | ) |
| 46 | 47 | ); |
| 47 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 48 | - return array(); |
|
| 48 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 49 | + return array(); |
|
| 50 | + } |
|
| 49 | 51 | $row = $smcFunc['db_fetch_assoc']($request); |
| 50 | 52 | $smcFunc['db_free_result']($request); |
| 51 | 53 | |
@@ -54,8 +56,9 @@ discard block |
||
| 54 | 56 | censorText($row['body']); |
| 55 | 57 | |
| 56 | 58 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled']), array('<br>' => ' '))); |
| 57 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
| 58 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 59 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
| 60 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 61 | + } |
|
| 59 | 62 | |
| 60 | 63 | // Send the data. |
| 61 | 64 | return array( |
@@ -83,8 +86,9 @@ discard block |
||
| 83 | 86 | |
| 84 | 87 | $context['is_redirect'] = false; |
| 85 | 88 | |
| 86 | - if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) |
|
| 87 | - $_REQUEST['start'] = 95; |
|
| 89 | + if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) { |
|
| 90 | + $_REQUEST['start'] = 95; |
|
| 91 | + } |
|
| 88 | 92 | |
| 89 | 93 | $_REQUEST['start'] = (int) $_REQUEST['start']; |
| 90 | 94 | |
@@ -92,8 +96,9 @@ discard block |
||
| 92 | 96 | if (!empty($_REQUEST['c']) && empty($board)) |
| 93 | 97 | { |
| 94 | 98 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
| 95 | - foreach ($_REQUEST['c'] as $i => $c) |
|
| 96 | - $_REQUEST['c'][$i] = (int) $c; |
|
| 99 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
| 100 | + $_REQUEST['c'][$i] = (int) $c; |
|
| 101 | + } |
|
| 97 | 102 | |
| 98 | 103 | if (count($_REQUEST['c']) == 1) |
| 99 | 104 | { |
@@ -109,8 +114,9 @@ discard block |
||
| 109 | 114 | list ($name) = $smcFunc['db_fetch_row']($request); |
| 110 | 115 | $smcFunc['db_free_result']($request); |
| 111 | 116 | |
| 112 | - if (empty($name)) |
|
| 113 | - fatal_lang_error('no_access', false); |
|
| 117 | + if (empty($name)) { |
|
| 118 | + fatal_lang_error('no_access', false); |
|
| 119 | + } |
|
| 114 | 120 | |
| 115 | 121 | $context['linktree'][] = array( |
| 116 | 122 | 'url' => $scripturl . '#c' . (int) $_REQUEST['c'], |
@@ -142,8 +148,9 @@ discard block |
||
| 142 | 148 | } |
| 143 | 149 | $smcFunc['db_free_result']($request); |
| 144 | 150 | |
| 145 | - if (empty($boards)) |
|
| 146 | - fatal_lang_error('error_no_boards_selected'); |
|
| 151 | + if (empty($boards)) { |
|
| 152 | + fatal_lang_error('error_no_boards_selected'); |
|
| 153 | + } |
|
| 147 | 154 | |
| 148 | 155 | $query_this_board = 'b.id_board IN ({array_int:boards})'; |
| 149 | 156 | $query_parameters['boards'] = $boards; |
@@ -157,12 +164,12 @@ discard block |
||
| 157 | 164 | } |
| 158 | 165 | |
| 159 | 166 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;c=' . implode(',', $_REQUEST['c']), $_REQUEST['start'], min(100, $total_cat_posts), 10, false); |
| 160 | - } |
|
| 161 | - elseif (!empty($_REQUEST['boards'])) |
|
| 167 | + } elseif (!empty($_REQUEST['boards'])) |
|
| 162 | 168 | { |
| 163 | 169 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
| 164 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
| 165 | - $_REQUEST['boards'][$i] = (int) $b; |
|
| 170 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
| 171 | + $_REQUEST['boards'][$i] = (int) $b; |
|
| 172 | + } |
|
| 166 | 173 | |
| 167 | 174 | $request = $smcFunc['db_query']('', ' |
| 168 | 175 | SELECT b.id_board, b.num_posts |
@@ -186,8 +193,9 @@ discard block |
||
| 186 | 193 | } |
| 187 | 194 | $smcFunc['db_free_result']($request); |
| 188 | 195 | |
| 189 | - if (empty($boards)) |
|
| 190 | - fatal_lang_error('error_no_boards_selected'); |
|
| 196 | + if (empty($boards)) { |
|
| 197 | + fatal_lang_error('error_no_boards_selected'); |
|
| 198 | + } |
|
| 191 | 199 | |
| 192 | 200 | $query_this_board = 'b.id_board IN ({array_int:boards})'; |
| 193 | 201 | $query_parameters['boards'] = $boards; |
@@ -201,8 +209,7 @@ discard block |
||
| 201 | 209 | } |
| 202 | 210 | |
| 203 | 211 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;boards=' . implode(',', $_REQUEST['boards']), $_REQUEST['start'], min(100, $total_posts), 10, false); |
| 204 | - } |
|
| 205 | - elseif (!empty($board)) |
|
| 212 | + } elseif (!empty($board)) |
|
| 206 | 213 | { |
| 207 | 214 | $request = $smcFunc['db_query']('', ' |
| 208 | 215 | SELECT num_posts, redirect |
@@ -235,8 +242,7 @@ discard block |
||
| 235 | 242 | } |
| 236 | 243 | |
| 237 | 244 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;board=' . $board . '.%1$d', $_REQUEST['start'], min(100, $total_posts), 10, true); |
| 238 | - } |
|
| 239 | - else |
|
| 245 | + } else |
|
| 240 | 246 | { |
| 241 | 247 | $query_this_board = '{query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' |
| 242 | 248 | AND b.id_board != {int:recycle_board}' : ''). ' |
@@ -271,8 +277,9 @@ discard block |
||
| 271 | 277 | ); |
| 272 | 278 | |
| 273 | 279 | // If you selected a redirection board, don't try getting posts for it... |
| 274 | - if ($context['is_redirect']) |
|
| 275 | - $messages = 0; |
|
| 280 | + if ($context['is_redirect']) { |
|
| 281 | + $messages = 0; |
|
| 282 | + } |
|
| 276 | 283 | |
| 277 | 284 | $key = 'recent-' . $user_info['id'] . '-' . md5($smcFunc['json_encode'](array_diff_key($query_parameters, array('max_id_msg' => 0)))) . '-' . (int) $_REQUEST['start']; |
| 278 | 285 | if (!$context['is_redirect'] && (empty($modSettings['cache_enable']) || ($messages = cache_get_data($key, 120)) == null)) |
@@ -303,16 +310,18 @@ discard block |
||
| 303 | 310 | $query_this_board = str_replace('AND m.id_msg >= {int:max_id_msg}', '', $query_this_board); |
| 304 | 311 | $cache_results = true; |
| 305 | 312 | unset($query_parameters['max_id_msg']); |
| 313 | + } else { |
|
| 314 | + $done = true; |
|
| 306 | 315 | } |
| 307 | - else |
|
| 308 | - $done = true; |
|
| 309 | 316 | } |
| 310 | 317 | $messages = array(); |
| 311 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 312 | - $messages[] = $row['id_msg']; |
|
| 318 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 319 | + $messages[] = $row['id_msg']; |
|
| 320 | + } |
|
| 313 | 321 | $smcFunc['db_free_result']($request); |
| 314 | - if (!empty($cache_results)) |
|
| 315 | - cache_put_data($key, $messages, 120); |
|
| 322 | + if (!empty($cache_results)) { |
|
| 323 | + cache_put_data($key, $messages, 120); |
|
| 324 | + } |
|
| 316 | 325 | } |
| 317 | 326 | |
| 318 | 327 | // Nothing here... Or at least, nothing you can see... |
@@ -399,8 +408,9 @@ discard block |
||
| 399 | 408 | 'css_class' => 'windowbg', |
| 400 | 409 | ); |
| 401 | 410 | |
| 402 | - if ($user_info['id'] == $row['id_first_member']) |
|
| 403 | - $board_ids['own'][$row['id_board']][] = $row['id_msg']; |
|
| 411 | + if ($user_info['id'] == $row['id_first_member']) { |
|
| 412 | + $board_ids['own'][$row['id_board']][] = $row['id_msg']; |
|
| 413 | + } |
|
| 404 | 414 | $board_ids['any'][$row['id_board']][] = $row['id_msg']; |
| 405 | 415 | } |
| 406 | 416 | $smcFunc['db_free_result']($request); |
@@ -426,20 +436,23 @@ discard block |
||
| 426 | 436 | $boards = boardsAllowedTo($permission); |
| 427 | 437 | |
| 428 | 438 | // If 0 is the only thing in the array, they can do it everywhere! |
| 429 | - if (!empty($boards) && $boards[0] == 0) |
|
| 430 | - $boards = array_keys($board_ids[$type]); |
|
| 439 | + if (!empty($boards) && $boards[0] == 0) { |
|
| 440 | + $boards = array_keys($board_ids[$type]); |
|
| 441 | + } |
|
| 431 | 442 | |
| 432 | 443 | // Go through the boards, and look for posts they can do this on. |
| 433 | 444 | foreach ($boards as $board_id) |
| 434 | 445 | { |
| 435 | 446 | // Hmm, they have permission, but there are no topics from that board on this page. |
| 436 | - if (!isset($board_ids[$type][$board_id])) |
|
| 437 | - continue; |
|
| 447 | + if (!isset($board_ids[$type][$board_id])) { |
|
| 448 | + continue; |
|
| 449 | + } |
|
| 438 | 450 | |
| 439 | 451 | // Okay, looks like they can do it for these posts. |
| 440 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
| 441 | - if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id']) |
|
| 452 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
| 453 | + if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id']) |
|
| 442 | 454 | $context['posts'][$counter][$allowed] = true; |
| 455 | + } |
|
| 443 | 456 | } |
| 444 | 457 | } |
| 445 | 458 | } |
@@ -482,17 +495,19 @@ discard block |
||
| 482 | 495 | $context['showing_all_topics'] = isset($_GET['all']); |
| 483 | 496 | $context['start'] = (int) $_REQUEST['start']; |
| 484 | 497 | $context['topics_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
| 485 | - if ($_REQUEST['action'] == 'unread') |
|
| 486 | - $context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit']; |
|
| 487 | - else |
|
| 488 | - $context['page_title'] = $txt['unread_replies']; |
|
| 498 | + if ($_REQUEST['action'] == 'unread') { |
|
| 499 | + $context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit']; |
|
| 500 | + } else { |
|
| 501 | + $context['page_title'] = $txt['unread_replies']; |
|
| 502 | + } |
|
| 489 | 503 | |
| 490 | - if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) |
|
| 491 | - fatal_lang_error('loadavg_allunread_disabled', false); |
|
| 492 | - elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) |
|
| 493 | - fatal_lang_error('loadavg_unreadreplies_disabled', false); |
|
| 494 | - elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) |
|
| 495 | - fatal_lang_error('loadavg_unread_disabled', false); |
|
| 504 | + if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) { |
|
| 505 | + fatal_lang_error('loadavg_allunread_disabled', false); |
|
| 506 | + } elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) { |
|
| 507 | + fatal_lang_error('loadavg_unreadreplies_disabled', false); |
|
| 508 | + } elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) { |
|
| 509 | + fatal_lang_error('loadavg_unread_disabled', false); |
|
| 510 | + } |
|
| 496 | 511 | |
| 497 | 512 | // Parameters for the main query. |
| 498 | 513 | $query_parameters = array(); |
@@ -505,12 +520,14 @@ discard block |
||
| 505 | 520 | if (!empty($_REQUEST['boards'])) |
| 506 | 521 | { |
| 507 | 522 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
| 508 | - foreach ($_REQUEST['boards'] as $b) |
|
| 509 | - $boards[] = (int) $b; |
|
| 523 | + foreach ($_REQUEST['boards'] as $b) { |
|
| 524 | + $boards[] = (int) $b; |
|
| 525 | + } |
|
| 510 | 526 | } |
| 511 | 527 | |
| 512 | - if (!empty($board)) |
|
| 513 | - $boards[] = (int) $board; |
|
| 528 | + if (!empty($board)) { |
|
| 529 | + $boards[] = (int) $board; |
|
| 530 | + } |
|
| 514 | 531 | |
| 515 | 532 | // The easiest thing is to just get all the boards they can see, but since we've specified the top of tree we ignore some of them |
| 516 | 533 | $request = $smcFunc['db_query']('', ' |
@@ -527,30 +544,31 @@ discard block |
||
| 527 | 544 | ) |
| 528 | 545 | ); |
| 529 | 546 | |
| 530 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 531 | - if (in_array($row['id_parent'], $boards)) |
|
| 547 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 548 | + if (in_array($row['id_parent'], $boards)) |
|
| 532 | 549 | $boards[] = $row['id_board']; |
| 550 | + } |
|
| 533 | 551 | |
| 534 | 552 | $smcFunc['db_free_result']($request); |
| 535 | 553 | |
| 536 | - if (empty($boards)) |
|
| 537 | - fatal_lang_error('error_no_boards_selected'); |
|
| 554 | + if (empty($boards)) { |
|
| 555 | + fatal_lang_error('error_no_boards_selected'); |
|
| 556 | + } |
|
| 538 | 557 | |
| 539 | 558 | $query_this_board = 'id_board IN ({array_int:boards})'; |
| 540 | 559 | $query_parameters['boards'] = $boards; |
| 541 | 560 | $context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%d'; |
| 542 | - } |
|
| 543 | - elseif (!empty($board)) |
|
| 561 | + } elseif (!empty($board)) |
|
| 544 | 562 | { |
| 545 | 563 | $query_this_board = 'id_board = {int:board}'; |
| 546 | 564 | $query_parameters['board'] = $board; |
| 547 | 565 | $context['querystring_board_limits'] = ';board=' . $board . '.%1$d'; |
| 548 | - } |
|
| 549 | - elseif (!empty($_REQUEST['boards'])) |
|
| 566 | + } elseif (!empty($_REQUEST['boards'])) |
|
| 550 | 567 | { |
| 551 | 568 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
| 552 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
| 553 | - $_REQUEST['boards'][$i] = (int) $b; |
|
| 569 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
| 570 | + $_REQUEST['boards'][$i] = (int) $b; |
|
| 571 | + } |
|
| 554 | 572 | |
| 555 | 573 | $request = $smcFunc['db_query']('', ' |
| 556 | 574 | SELECT b.id_board |
@@ -562,22 +580,24 @@ discard block |
||
| 562 | 580 | ) |
| 563 | 581 | ); |
| 564 | 582 | $boards = array(); |
| 565 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 566 | - $boards[] = $row['id_board']; |
|
| 583 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 584 | + $boards[] = $row['id_board']; |
|
| 585 | + } |
|
| 567 | 586 | $smcFunc['db_free_result']($request); |
| 568 | 587 | |
| 569 | - if (empty($boards)) |
|
| 570 | - fatal_lang_error('error_no_boards_selected'); |
|
| 588 | + if (empty($boards)) { |
|
| 589 | + fatal_lang_error('error_no_boards_selected'); |
|
| 590 | + } |
|
| 571 | 591 | |
| 572 | 592 | $query_this_board = 'id_board IN ({array_int:boards})'; |
| 573 | 593 | $query_parameters['boards'] = $boards; |
| 574 | 594 | $context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%1$d'; |
| 575 | - } |
|
| 576 | - elseif (!empty($_REQUEST['c'])) |
|
| 595 | + } elseif (!empty($_REQUEST['c'])) |
|
| 577 | 596 | { |
| 578 | 597 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
| 579 | - foreach ($_REQUEST['c'] as $i => $c) |
|
| 580 | - $_REQUEST['c'][$i] = (int) $c; |
|
| 598 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
| 599 | + $_REQUEST['c'][$i] = (int) $c; |
|
| 600 | + } |
|
| 581 | 601 | |
| 582 | 602 | $see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board'; |
| 583 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -590,18 +610,19 @@ discard block |
||
| 590 | 610 | ) |
| 591 | 611 | ); |
| 592 | 612 | $boards = array(); |
| 593 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 594 | - $boards[] = $row['id_board']; |
|
| 613 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 614 | + $boards[] = $row['id_board']; |
|
| 615 | + } |
|
| 595 | 616 | $smcFunc['db_free_result']($request); |
| 596 | 617 | |
| 597 | - if (empty($boards)) |
|
| 598 | - fatal_lang_error('error_no_boards_selected'); |
|
| 618 | + if (empty($boards)) { |
|
| 619 | + fatal_lang_error('error_no_boards_selected'); |
|
| 620 | + } |
|
| 599 | 621 | |
| 600 | 622 | $query_this_board = 'id_board IN ({array_int:boards})'; |
| 601 | 623 | $query_parameters['boards'] = $boards; |
| 602 | 624 | $context['querystring_board_limits'] = ';c=' . implode(',', $_REQUEST['c']) . ';start=%1$d'; |
| 603 | - } |
|
| 604 | - else |
|
| 625 | + } else |
|
| 605 | 626 | { |
| 606 | 627 | $see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board'; |
| 607 | 628 | // Don't bother to show deleted posts! |
@@ -615,12 +636,14 @@ discard block |
||
| 615 | 636 | ) |
| 616 | 637 | ); |
| 617 | 638 | $boards = array(); |
| 618 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 619 | - $boards[] = $row['id_board']; |
|
| 639 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 640 | + $boards[] = $row['id_board']; |
|
| 641 | + } |
|
| 620 | 642 | $smcFunc['db_free_result']($request); |
| 621 | 643 | |
| 622 | - if (empty($boards)) |
|
| 623 | - fatal_lang_error('error_no_boards_available', false); |
|
| 644 | + if (empty($boards)) { |
|
| 645 | + fatal_lang_error('error_no_boards_available', false); |
|
| 646 | + } |
|
| 624 | 647 | |
| 625 | 648 | $query_this_board = 'id_board IN ({array_int:boards})'; |
| 626 | 649 | $query_parameters['boards'] = $boards; |
@@ -682,13 +705,14 @@ discard block |
||
| 682 | 705 | 'name' => $_REQUEST['action'] == 'unread' ? $txt['unread_topics_visit'] : $txt['unread_replies'] |
| 683 | 706 | ); |
| 684 | 707 | |
| 685 | - if ($context['showing_all_topics']) |
|
| 686 | - $context['linktree'][] = array( |
|
| 708 | + if ($context['showing_all_topics']) { |
|
| 709 | + $context['linktree'][] = array( |
|
| 687 | 710 | 'url' => $scripturl . '?action=' . $_REQUEST['action'] . ';all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'], |
| 688 | 711 | 'name' => $txt['unread_topics_all'] |
| 689 | 712 | ); |
| 690 | - else |
|
| 691 | - $txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'])); |
|
| 713 | + } else { |
|
| 714 | + $txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'])); |
|
| 715 | + } |
|
| 692 | 716 | |
| 693 | 717 | loadTemplate('Recent'); |
| 694 | 718 | loadTemplate('MessageIndex'); |
@@ -696,8 +720,9 @@ discard block |
||
| 696 | 720 | |
| 697 | 721 | // Setup the default topic icons... for checking they exist and the like ;) |
| 698 | 722 | $context['icon_sources'] = array(); |
| 699 | - foreach ($context['stable_icons'] as $icon) |
|
| 700 | - $context['icon_sources'][$icon] = 'images_url'; |
|
| 723 | + foreach ($context['stable_icons'] as $icon) { |
|
| 724 | + $context['icon_sources'][$icon] = 'images_url'; |
|
| 725 | + } |
|
| 701 | 726 | |
| 702 | 727 | $is_topics = $_REQUEST['action'] == 'unread'; |
| 703 | 728 | |
@@ -727,8 +752,7 @@ discard block |
||
| 727 | 752 | ); |
| 728 | 753 | list ($earliest_msg) = $smcFunc['db_fetch_row']($request); |
| 729 | 754 | $smcFunc['db_free_result']($request); |
| 730 | - } |
|
| 731 | - else |
|
| 755 | + } else |
|
| 732 | 756 | { |
| 733 | 757 | $request = $smcFunc['db_query']('', ' |
| 734 | 758 | SELECT MIN(lmr.id_msg) |
@@ -744,14 +768,14 @@ discard block |
||
| 744 | 768 | } |
| 745 | 769 | |
| 746 | 770 | // This is needed in case of topics marked unread. |
| 747 | - if (empty($earliest_msg)) |
|
| 748 | - $earliest_msg = 0; |
|
| 749 | - else |
|
| 771 | + if (empty($earliest_msg)) { |
|
| 772 | + $earliest_msg = 0; |
|
| 773 | + } else |
|
| 750 | 774 | { |
| 751 | 775 | // Using caching, when possible, to ignore the below slow query. |
| 752 | - if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) |
|
| 753 | - $earliest_msg2 = $_SESSION['cached_log_time'][1]; |
|
| 754 | - else |
|
| 776 | + if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) { |
|
| 777 | + $earliest_msg2 = $_SESSION['cached_log_time'][1]; |
|
| 778 | + } else |
|
| 755 | 779 | { |
| 756 | 780 | // This query is pretty slow, but it's needed to ensure nothing crucial is ignored. |
| 757 | 781 | $request = $smcFunc['db_query']('', ' |
@@ -766,8 +790,9 @@ discard block |
||
| 766 | 790 | $smcFunc['db_free_result']($request); |
| 767 | 791 | |
| 768 | 792 | // In theory this could be zero, if the first ever post is unread, so fudge it ;) |
| 769 | - if ($earliest_msg2 == 0) |
|
| 770 | - $earliest_msg2 = -1; |
|
| 793 | + if ($earliest_msg2 == 0) { |
|
| 794 | + $earliest_msg2 = -1; |
|
| 795 | + } |
|
| 771 | 796 | |
| 772 | 797 | $_SESSION['cached_log_time'] = array(time(), $earliest_msg2); |
| 773 | 798 | } |
@@ -805,9 +830,9 @@ discard block |
||
| 805 | 830 | 'db_error_skip' => true, |
| 806 | 831 | )) |
| 807 | 832 | ) !== false; |
| 833 | + } else { |
|
| 834 | + $have_temp_table = false; |
|
| 808 | 835 | } |
| 809 | - else |
|
| 810 | - $have_temp_table = false; |
|
| 811 | 836 | |
| 812 | 837 | if ($context['showing_all_topics'] && $have_temp_table) |
| 813 | 838 | { |
@@ -853,14 +878,15 @@ discard block |
||
| 853 | 878 | |
| 854 | 879 | $context['topics'] = array(); |
| 855 | 880 | $context['no_topic_listing'] = true; |
| 856 | - if ($context['querystring_board_limits'] == ';start=%1$d') |
|
| 857 | - $context['querystring_board_limits'] = ''; |
|
| 858 | - else |
|
| 859 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 881 | + if ($context['querystring_board_limits'] == ';start=%1$d') { |
|
| 882 | + $context['querystring_board_limits'] = ''; |
|
| 883 | + } else { |
|
| 884 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 885 | + } |
|
| 860 | 886 | return; |
| 887 | + } else { |
|
| 888 | + $min_message = (int) $min_message; |
|
| 861 | 889 | } |
| 862 | - else |
|
| 863 | - $min_message = (int) $min_message; |
|
| 864 | 890 | |
| 865 | 891 | $request = $smcFunc['db_query']('substring', ' |
| 866 | 892 | SELECT ' . $select_clause . ' |
@@ -889,8 +915,7 @@ discard block |
||
| 889 | 915 | 'limit' => $context['topics_per_page'], |
| 890 | 916 | )) |
| 891 | 917 | ); |
| 892 | - } |
|
| 893 | - elseif ($is_topics) |
|
| 918 | + } elseif ($is_topics) |
|
| 894 | 919 | { |
| 895 | 920 | $request = $smcFunc['db_query']('', ' |
| 896 | 921 | SELECT COUNT(*), MIN(t.id_last_msg) |
@@ -941,14 +966,15 @@ discard block |
||
| 941 | 966 | |
| 942 | 967 | $context['topics'] = array(); |
| 943 | 968 | $context['no_topic_listing'] = true; |
| 944 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
| 945 | - $context['querystring_board_limits'] = ''; |
|
| 946 | - else |
|
| 947 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 969 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
| 970 | + $context['querystring_board_limits'] = ''; |
|
| 971 | + } else { |
|
| 972 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 973 | + } |
|
| 948 | 974 | return; |
| 975 | + } else { |
|
| 976 | + $min_message = (int) $min_message; |
|
| 949 | 977 | } |
| 950 | - else |
|
| 951 | - $min_message = (int) $min_message; |
|
| 952 | 978 | |
| 953 | 979 | $request = $smcFunc['db_query']('substring', ' |
| 954 | 980 | SELECT ' . $select_clause . ' |
@@ -978,8 +1004,7 @@ discard block |
||
| 978 | 1004 | 'limit' => $context['topics_per_page'], |
| 979 | 1005 | )) |
| 980 | 1006 | ); |
| 981 | - } |
|
| 982 | - else |
|
| 1007 | + } else |
|
| 983 | 1008 | { |
| 984 | 1009 | if ($modSettings['totalMessages'] > 100000) |
| 985 | 1010 | { |
@@ -1031,8 +1056,8 @@ discard block |
||
| 1031 | 1056 | ) !== false; |
| 1032 | 1057 | |
| 1033 | 1058 | // If that worked, create a sample of the log_topics table too. |
| 1034 | - if ($have_temp_table) |
|
| 1035 | - $have_temp_table = $smcFunc['db_query']('', ' |
|
| 1059 | + if ($have_temp_table) { |
|
| 1060 | + $have_temp_table = $smcFunc['db_query']('', ' |
|
| 1036 | 1061 | CREATE TEMPORARY TABLE {db_prefix}log_topics_posted_in ( |
| 1037 | 1062 | PRIMARY KEY (id_topic) |
| 1038 | 1063 | ) |
@@ -1045,6 +1070,7 @@ discard block |
||
| 1045 | 1070 | 'db_error_skip' => true, |
| 1046 | 1071 | ) |
| 1047 | 1072 | ) !== false; |
| 1073 | + } |
|
| 1048 | 1074 | } |
| 1049 | 1075 | |
| 1050 | 1076 | if (!empty($have_temp_table)) |
@@ -1060,8 +1086,7 @@ discard block |
||
| 1060 | 1086 | ); |
| 1061 | 1087 | list ($num_topics) = $smcFunc['db_fetch_row']($request); |
| 1062 | 1088 | $smcFunc['db_free_result']($request); |
| 1063 | - } |
|
| 1064 | - else |
|
| 1089 | + } else |
|
| 1065 | 1090 | { |
| 1066 | 1091 | $request = $smcFunc['db_query']('unread_fetch_topic_count', ' |
| 1067 | 1092 | SELECT COUNT(DISTINCT t.id_topic), MIN(t.id_last_msg) |
@@ -1102,15 +1127,16 @@ discard block |
||
| 1102 | 1127 | { |
| 1103 | 1128 | $context['topics'] = array(); |
| 1104 | 1129 | $context['no_topic_listing'] = true; |
| 1105 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
| 1106 | - $context['querystring_board_limits'] = ''; |
|
| 1107 | - else |
|
| 1108 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 1130 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
| 1131 | + $context['querystring_board_limits'] = ''; |
|
| 1132 | + } else { |
|
| 1133 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 1134 | + } |
|
| 1109 | 1135 | return; |
| 1110 | 1136 | } |
| 1111 | 1137 | |
| 1112 | - if (!empty($have_temp_table)) |
|
| 1113 | - $request = $smcFunc['db_query']('', ' |
|
| 1138 | + if (!empty($have_temp_table)) { |
|
| 1139 | + $request = $smcFunc['db_query']('', ' |
|
| 1114 | 1140 | SELECT t.id_topic |
| 1115 | 1141 | FROM {db_prefix}topics_posted_in AS t |
| 1116 | 1142 | LEFT JOIN {db_prefix}log_topics_posted_in AS lt ON (lt.id_topic = t.id_topic) |
@@ -1124,8 +1150,8 @@ discard block |
||
| 1124 | 1150 | 'limit' => $context['topics_per_page'], |
| 1125 | 1151 | )) |
| 1126 | 1152 | ); |
| 1127 | - else |
|
| 1128 | - $request = $smcFunc['db_query']('', ' |
|
| 1153 | + } else { |
|
| 1154 | + $request = $smcFunc['db_query']('', ' |
|
| 1129 | 1155 | SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'].' |
| 1130 | 1156 | FROM {db_prefix}topics AS t |
| 1131 | 1157 | INNER JOIN {db_prefix}messages AS m ON (m.id_topic = t.id_topic AND m.id_member = {int:current_member})' . (strpos($_REQUEST['sort'], 'ms.') === false ? '' : ' |
@@ -1149,10 +1175,12 @@ discard block |
||
| 1149 | 1175 | 'sort' => $_REQUEST['sort'], |
| 1150 | 1176 | )) |
| 1151 | 1177 | ); |
| 1178 | + } |
|
| 1152 | 1179 | |
| 1153 | 1180 | $topics = array(); |
| 1154 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1155 | - $topics[] = $row['id_topic']; |
|
| 1181 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1182 | + $topics[] = $row['id_topic']; |
|
| 1183 | + } |
|
| 1156 | 1184 | $smcFunc['db_free_result']($request); |
| 1157 | 1185 | |
| 1158 | 1186 | // Sanity... where have you gone? |
@@ -1160,10 +1188,11 @@ discard block |
||
| 1160 | 1188 | { |
| 1161 | 1189 | $context['topics'] = array(); |
| 1162 | 1190 | $context['no_topic_listing'] = true; |
| 1163 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
| 1164 | - $context['querystring_board_limits'] = ''; |
|
| 1165 | - else |
|
| 1166 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 1191 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
| 1192 | + $context['querystring_board_limits'] = ''; |
|
| 1193 | + } else { |
|
| 1194 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
| 1195 | + } |
|
| 1167 | 1196 | return; |
| 1168 | 1197 | } |
| 1169 | 1198 | |
@@ -1197,8 +1226,9 @@ discard block |
||
| 1197 | 1226 | |
| 1198 | 1227 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1199 | 1228 | { |
| 1200 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
| 1201 | - continue; |
|
| 1229 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
| 1230 | + continue; |
|
| 1231 | + } |
|
| 1202 | 1232 | |
| 1203 | 1233 | $topic_ids[] = $row['id_topic']; |
| 1204 | 1234 | |
@@ -1206,11 +1236,13 @@ discard block |
||
| 1206 | 1236 | { |
| 1207 | 1237 | // Limit them to 128 characters - do this FIRST because it's a lot of wasted censoring otherwise. |
| 1208 | 1238 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
| 1209 | - if ($smcFunc['strlen']($row['first_body']) > 128) |
|
| 1210 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...'; |
|
| 1239 | + if ($smcFunc['strlen']($row['first_body']) > 128) { |
|
| 1240 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...'; |
|
| 1241 | + } |
|
| 1211 | 1242 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
| 1212 | - if ($smcFunc['strlen']($row['last_body']) > 128) |
|
| 1213 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...'; |
|
| 1243 | + if ($smcFunc['strlen']($row['last_body']) > 128) { |
|
| 1244 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...'; |
|
| 1245 | + } |
|
| 1214 | 1246 | |
| 1215 | 1247 | // Censor the subject and message preview. |
| 1216 | 1248 | censorText($row['first_subject']); |
@@ -1221,23 +1253,22 @@ discard block |
||
| 1221 | 1253 | { |
| 1222 | 1254 | $row['last_subject'] = $row['first_subject']; |
| 1223 | 1255 | $row['last_body'] = $row['first_body']; |
| 1224 | - } |
|
| 1225 | - else |
|
| 1256 | + } else |
|
| 1226 | 1257 | { |
| 1227 | 1258 | censorText($row['last_subject']); |
| 1228 | 1259 | censorText($row['last_body']); |
| 1229 | 1260 | } |
| 1230 | - } |
|
| 1231 | - else |
|
| 1261 | + } else |
|
| 1232 | 1262 | { |
| 1233 | 1263 | $row['first_body'] = ''; |
| 1234 | 1264 | $row['last_body'] = ''; |
| 1235 | 1265 | censorText($row['first_subject']); |
| 1236 | 1266 | |
| 1237 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
| 1238 | - $row['last_subject'] = $row['first_subject']; |
|
| 1239 | - else |
|
| 1240 | - censorText($row['last_subject']); |
|
| 1267 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
| 1268 | + $row['last_subject'] = $row['first_subject']; |
|
| 1269 | + } else { |
|
| 1270 | + censorText($row['last_subject']); |
|
| 1271 | + } |
|
| 1241 | 1272 | } |
| 1242 | 1273 | |
| 1243 | 1274 | // Decide how many pages the topic should have. |
@@ -1249,29 +1280,32 @@ discard block |
||
| 1249 | 1280 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $topic_length, $messages_per_page, true, false); |
| 1250 | 1281 | |
| 1251 | 1282 | // If we can use all, show all. |
| 1252 | - if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) |
|
| 1253 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 1283 | + if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) { |
|
| 1284 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 1285 | + } |
|
| 1286 | + } else { |
|
| 1287 | + $pages = ''; |
|
| 1254 | 1288 | } |
| 1255 | 1289 | |
| 1256 | - else |
|
| 1257 | - $pages = ''; |
|
| 1258 | - |
|
| 1259 | 1290 | // We need to check the topic icons exist... you can never be too sure! |
| 1260 | 1291 | if (!empty($modSettings['messageIconChecks_enable'])) |
| 1261 | 1292 | { |
| 1262 | 1293 | // First icon first... as you'd expect. |
| 1263 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
| 1264 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1294 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
| 1295 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1296 | + } |
|
| 1265 | 1297 | // Last icon... last... duh. |
| 1266 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
| 1267 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1268 | - } |
|
| 1269 | - else |
|
| 1298 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
| 1299 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1300 | + } |
|
| 1301 | + } else |
|
| 1270 | 1302 | { |
| 1271 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
| 1272 | - $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
| 1273 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
| 1274 | - $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
| 1303 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
| 1304 | + $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
| 1305 | + } |
|
| 1306 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
| 1307 | + $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
| 1308 | + } |
|
| 1275 | 1309 | } |
| 1276 | 1310 | |
| 1277 | 1311 | // Force the recycling icon if appropriate |
@@ -1285,12 +1319,14 @@ discard block |
||
| 1285 | 1319 | $colorClass = 'windowbg'; |
| 1286 | 1320 | |
| 1287 | 1321 | // Sticky topics should get a different color, too. |
| 1288 | - if ($row['is_sticky']) |
|
| 1289 | - $colorClass .= ' sticky'; |
|
| 1322 | + if ($row['is_sticky']) { |
|
| 1323 | + $colorClass .= ' sticky'; |
|
| 1324 | + } |
|
| 1290 | 1325 | |
| 1291 | 1326 | // Locked topics get special treatment as well. |
| 1292 | - if ($row['locked']) |
|
| 1293 | - $colorClass .= ' locked'; |
|
| 1327 | + if ($row['locked']) { |
|
| 1328 | + $colorClass .= ' locked'; |
|
| 1329 | + } |
|
| 1294 | 1330 | |
| 1295 | 1331 | // And build the array. |
| 1296 | 1332 | $context['topics'][$row['id_topic']] = array( |
@@ -1387,8 +1423,9 @@ discard block |
||
| 1387 | 1423 | ); |
| 1388 | 1424 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 1389 | 1425 | { |
| 1390 | - if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) |
|
| 1391 | - $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
| 1426 | + if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) { |
|
| 1427 | + $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
| 1428 | + } |
|
| 1392 | 1429 | } |
| 1393 | 1430 | $smcFunc['db_free_result']($result); |
| 1394 | 1431 | } |
@@ -1403,28 +1440,30 @@ discard block |
||
| 1403 | 1440 | 'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']), |
| 1404 | 1441 | ); |
| 1405 | 1442 | |
| 1406 | - if ($context['showCheckboxes']) |
|
| 1407 | - $context['recent_buttons']['markselectread'] = array( |
|
| 1443 | + if ($context['showCheckboxes']) { |
|
| 1444 | + $context['recent_buttons']['markselectread'] = array( |
|
| 1408 | 1445 | 'text' => 'quick_mod_markread', |
| 1409 | 1446 | 'image' => 'markselectedread.png', |
| 1410 | 1447 | 'url' => 'javascript:document.quickModForm.submit();', |
| 1411 | 1448 | ); |
| 1449 | + } |
|
| 1412 | 1450 | |
| 1413 | - if (!empty($context['topics']) && !$context['showing_all_topics']) |
|
| 1414 | - $context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true); |
|
| 1415 | - } |
|
| 1416 | - elseif (!$is_topics && isset($context['topics_to_mark'])) |
|
| 1451 | + if (!empty($context['topics']) && !$context['showing_all_topics']) { |
|
| 1452 | + $context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true); |
|
| 1453 | + } |
|
| 1454 | + } elseif (!$is_topics && isset($context['topics_to_mark'])) |
|
| 1417 | 1455 | { |
| 1418 | 1456 | $context['recent_buttons'] = array( |
| 1419 | 1457 | 'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']), |
| 1420 | 1458 | ); |
| 1421 | 1459 | |
| 1422 | - if ($context['showCheckboxes']) |
|
| 1423 | - $context['recent_buttons']['markselectread'] = array( |
|
| 1460 | + if ($context['showCheckboxes']) { |
|
| 1461 | + $context['recent_buttons']['markselectread'] = array( |
|
| 1424 | 1462 | 'text' => 'quick_mod_markread', |
| 1425 | 1463 | 'image' => 'markselectedread.png', |
| 1426 | 1464 | 'url' => 'javascript:document.quickModForm.submit();', |
| 1427 | 1465 | ); |
| 1466 | + } |
|
| 1428 | 1467 | } |
| 1429 | 1468 | |
| 1430 | 1469 | // Allow mods to add additional buttons here |
@@ -12,8 +12,9 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Don't do anything if SMF is already loaded. |
| 15 | -if (defined('SMF')) |
|
| 15 | +if (defined('SMF')) { |
|
| 16 | 16 | return true; |
| 17 | +} |
|
| 17 | 18 | |
| 18 | 19 | define('SMF', 'SSI'); |
| 19 | 20 | |
@@ -28,16 +29,18 @@ discard block |
||
| 28 | 29 | $time_start = microtime(true); |
| 29 | 30 | |
| 30 | 31 | // Just being safe... |
| 31 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
| 32 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
| 32 | 33 | if (isset($GLOBALS[$variable])) |
| 33 | 34 | unset($GLOBALS[$variable]); |
| 35 | +} |
|
| 34 | 36 | |
| 35 | 37 | // Get the forum's settings for database and file paths. |
| 36 | 38 | require_once(dirname(__FILE__) . '/Settings.php'); |
| 37 | 39 | |
| 38 | 40 | // Make absolutely sure the cache directory is defined. |
| 39 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 41 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 40 | 42 | $cachedir = $boarddir . '/cache'; |
| 43 | +} |
|
| 41 | 44 | |
| 42 | 45 | $ssi_error_reporting = error_reporting(E_ALL); |
| 43 | 46 | /* Set this to one of three values depending on what you want to happen in the case of a fatal error. |
@@ -48,12 +51,14 @@ discard block |
||
| 48 | 51 | $ssi_on_error_method = false; |
| 49 | 52 | |
| 50 | 53 | // Don't do john didley if the forum's been shut down completely. |
| 51 | -if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) |
|
| 54 | +if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) { |
|
| 52 | 55 | die($mmessage); |
| 56 | +} |
|
| 53 | 57 | |
| 54 | 58 | // Fix for using the current directory as a path. |
| 55 | -if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') |
|
| 59 | +if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') { |
|
| 56 | 60 | $sourcedir = dirname(__FILE__) . substr($sourcedir, 1); |
| 61 | +} |
|
| 57 | 62 | |
| 58 | 63 | // Load the important includes. |
| 59 | 64 | require_once($sourcedir . '/QueryString.php'); |
@@ -78,26 +83,30 @@ discard block |
||
| 78 | 83 | cleanRequest(); |
| 79 | 84 | |
| 80 | 85 | // Seed the random generator? |
| 81 | -if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) |
|
| 86 | +if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) { |
|
| 82 | 87 | smf_seed_generator(); |
| 88 | +} |
|
| 83 | 89 | |
| 84 | 90 | // Check on any hacking attempts. |
| 85 | -if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) |
|
| 91 | +if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) { |
|
| 86 | 92 | die('No direct access...'); |
| 87 | -elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) |
|
| 93 | +} elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) { |
|
| 88 | 94 | die('No direct access...'); |
| 89 | -elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) |
|
| 95 | +} elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) { |
|
| 90 | 96 | die('No direct access...'); |
| 91 | -elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) |
|
| 97 | +} elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) { |
|
| 92 | 98 | die('No direct access...'); |
| 93 | -if (isset($_REQUEST['context'])) |
|
| 99 | +} |
|
| 100 | +if (isset($_REQUEST['context'])) { |
|
| 94 | 101 | die('No direct access...'); |
| 102 | +} |
|
| 95 | 103 | |
| 96 | 104 | // Gzip output? (because it must be boolean and true, this can't be hacked.) |
| 97 | -if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) |
|
| 105 | +if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) { |
|
| 98 | 106 | ob_start('ob_gzhandler'); |
| 99 | -else |
|
| 107 | +} else { |
|
| 100 | 108 | $modSettings['enableCompressedOutput'] = '0'; |
| 109 | +} |
|
| 101 | 110 | |
| 102 | 111 | /** |
| 103 | 112 | * An autoloader for certain classes. |
@@ -146,9 +155,9 @@ discard block |
||
| 146 | 155 | ob_start('ob_sessrewrite'); |
| 147 | 156 | |
| 148 | 157 | // Start the session... known to scramble SSI includes in cases... |
| 149 | -if (!headers_sent()) |
|
| 158 | +if (!headers_sent()) { |
|
| 150 | 159 | loadSession(); |
| 151 | -else |
|
| 160 | +} else |
|
| 152 | 161 | { |
| 153 | 162 | if (isset($_COOKIE[session_name()]) || isset($_REQUEST[session_name()])) |
| 154 | 163 | { |
@@ -182,12 +191,14 @@ discard block |
||
| 182 | 191 | loadTheme(isset($ssi_theme) ? (int) $ssi_theme : 0); |
| 183 | 192 | |
| 184 | 193 | // @todo: probably not the best place, but somewhere it should be set... |
| 185 | -if (!headers_sent()) |
|
| 194 | +if (!headers_sent()) { |
|
| 186 | 195 | header('content-type: text/html; charset=' . (empty($modSettings['global_character_set']) ? (empty($txt['lang_character_set']) ? 'ISO-8859-1' : $txt['lang_character_set']) : $modSettings['global_character_set'])); |
| 196 | +} |
|
| 187 | 197 | |
| 188 | 198 | // Take care of any banning that needs to be done. |
| 189 | -if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) |
|
| 199 | +if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) { |
|
| 190 | 200 | is_not_banned(); |
| 201 | +} |
|
| 191 | 202 | |
| 192 | 203 | // Do we allow guests in here? |
| 193 | 204 | if (empty($ssi_guest_access) && empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && basename($_SERVER['PHP_SELF']) != 'SSI.php') |
@@ -202,17 +213,19 @@ discard block |
||
| 202 | 213 | { |
| 203 | 214 | $context['template_layers'] = $ssi_layers; |
| 204 | 215 | template_header(); |
| 205 | -} |
|
| 206 | -else |
|
| 216 | +} else { |
|
| 207 | 217 | setupThemeContext(); |
| 218 | +} |
|
| 208 | 219 | |
| 209 | 220 | // Make sure they didn't muss around with the settings... but only if it's not cli. |
| 210 | -if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') |
|
| 221 | +if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') { |
|
| 211 | 222 | trigger_error($txt['ssi_session_broken'], E_USER_NOTICE); |
| 223 | +} |
|
| 212 | 224 | |
| 213 | 225 | // Without visiting the forum this session variable might not be set on submit. |
| 214 | -if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) |
|
| 226 | +if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) { |
|
| 215 | 227 | $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; |
| 228 | +} |
|
| 216 | 229 | |
| 217 | 230 | // Have the ability to easily add functions to SSI. |
| 218 | 231 | call_integration_hook('integrate_SSI'); |
@@ -221,11 +234,13 @@ discard block |
||
| 221 | 234 | if (basename($_SERVER['PHP_SELF']) == 'SSI.php') |
| 222 | 235 | { |
| 223 | 236 | // You shouldn't just access SSI.php directly by URL!! |
| 224 | - if (!isset($_GET['ssi_function'])) |
|
| 225 | - die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\'')); |
|
| 237 | + if (!isset($_GET['ssi_function'])) { |
|
| 238 | + die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\'')); |
|
| 239 | + } |
|
| 226 | 240 | // Call a function passed by GET. |
| 227 | - if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) |
|
| 228 | - call_user_func('ssi_' . $_GET['ssi_function']); |
|
| 241 | + if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) { |
|
| 242 | + call_user_func('ssi_' . $_GET['ssi_function']); |
|
| 243 | + } |
|
| 229 | 244 | exit; |
| 230 | 245 | } |
| 231 | 246 | |
@@ -242,9 +257,10 @@ discard block |
||
| 242 | 257 | */ |
| 243 | 258 | function ssi_shutdown() |
| 244 | 259 | { |
| 245 | - if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') |
|
| 246 | - template_footer(); |
|
| 247 | -} |
|
| 260 | + if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') { |
|
| 261 | + template_footer(); |
|
| 262 | + } |
|
| 263 | + } |
|
| 248 | 264 | |
| 249 | 265 | /** |
| 250 | 266 | * Display a welcome message, like: Hey, User, you have 0 messages, 0 are new. |
@@ -257,15 +273,17 @@ discard block |
||
| 257 | 273 | |
| 258 | 274 | if ($output_method == 'echo') |
| 259 | 275 | { |
| 260 | - if ($context['user']['is_guest']) |
|
| 261 | - echo 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'); |
|
| 262 | - else |
|
| 263 | - echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : ''; |
|
| 276 | + if ($context['user']['is_guest']) { |
|
| 277 | + echo 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'); |
|
| 278 | + } else { |
|
| 279 | + echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : ''; |
|
| 280 | + } |
|
| 264 | 281 | } |
| 265 | 282 | // Don't echo... then do what?! |
| 266 | - else |
|
| 267 | - return $context['user']; |
|
| 268 | -} |
|
| 283 | + else { |
|
| 284 | + return $context['user']; |
|
| 285 | + } |
|
| 286 | + } |
|
| 269 | 287 | |
| 270 | 288 | /** |
| 271 | 289 | * Display a menu bar, like is displayed at the top of the forum. |
@@ -276,12 +294,14 @@ discard block |
||
| 276 | 294 | { |
| 277 | 295 | global $context; |
| 278 | 296 | |
| 279 | - if ($output_method == 'echo') |
|
| 280 | - template_menu(); |
|
| 297 | + if ($output_method == 'echo') { |
|
| 298 | + template_menu(); |
|
| 299 | + } |
|
| 281 | 300 | // What else could this do? |
| 282 | - else |
|
| 283 | - return $context['menu_buttons']; |
|
| 284 | -} |
|
| 301 | + else { |
|
| 302 | + return $context['menu_buttons']; |
|
| 303 | + } |
|
| 304 | + } |
|
| 285 | 305 | |
| 286 | 306 | /** |
| 287 | 307 | * Show a logout link. |
@@ -293,20 +313,23 @@ discard block |
||
| 293 | 313 | { |
| 294 | 314 | global $context, $txt, $scripturl; |
| 295 | 315 | |
| 296 | - if ($redirect_to != '') |
|
| 297 | - $_SESSION['logout_url'] = $redirect_to; |
|
| 316 | + if ($redirect_to != '') { |
|
| 317 | + $_SESSION['logout_url'] = $redirect_to; |
|
| 318 | + } |
|
| 298 | 319 | |
| 299 | 320 | // Guests can't log out. |
| 300 | - if ($context['user']['is_guest']) |
|
| 301 | - return false; |
|
| 321 | + if ($context['user']['is_guest']) { |
|
| 322 | + return false; |
|
| 323 | + } |
|
| 302 | 324 | |
| 303 | 325 | $link = '<a href="' . $scripturl . '?action=logout;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['logout'] . '</a>'; |
| 304 | 326 | |
| 305 | - if ($output_method == 'echo') |
|
| 306 | - echo $link; |
|
| 307 | - else |
|
| 308 | - return $link; |
|
| 309 | -} |
|
| 327 | + if ($output_method == 'echo') { |
|
| 328 | + echo $link; |
|
| 329 | + } else { |
|
| 330 | + return $link; |
|
| 331 | + } |
|
| 332 | + } |
|
| 310 | 333 | |
| 311 | 334 | /** |
| 312 | 335 | * Recent post list: [board] Subject by Poster Date |
@@ -322,17 +345,17 @@ discard block |
||
| 322 | 345 | global $modSettings, $context; |
| 323 | 346 | |
| 324 | 347 | // Excluding certain boards... |
| 325 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
| 326 | - $exclude_boards = array($modSettings['recycle_board']); |
|
| 327 | - else |
|
| 328 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
| 348 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
| 349 | + $exclude_boards = array($modSettings['recycle_board']); |
|
| 350 | + } else { |
|
| 351 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
| 352 | + } |
|
| 329 | 353 | |
| 330 | 354 | // What about including certain boards - note we do some protection here as pre-2.0 didn't have this parameter. |
| 331 | 355 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
| 332 | 356 | { |
| 333 | 357 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
| 334 | - } |
|
| 335 | - elseif ($include_boards != null) |
|
| 358 | + } elseif ($include_boards != null) |
|
| 336 | 359 | { |
| 337 | 360 | $include_boards = array(); |
| 338 | 361 | } |
@@ -369,8 +392,9 @@ discard block |
||
| 369 | 392 | { |
| 370 | 393 | global $modSettings; |
| 371 | 394 | |
| 372 | - if (empty($post_ids)) |
|
| 373 | - return; |
|
| 395 | + if (empty($post_ids)) { |
|
| 396 | + return; |
|
| 397 | + } |
|
| 374 | 398 | |
| 375 | 399 | // Allow the user to request more than one - why not? |
| 376 | 400 | $post_ids = is_array($post_ids) ? $post_ids : array($post_ids); |
@@ -405,8 +429,9 @@ discard block |
||
| 405 | 429 | global $scripturl, $txt, $user_info; |
| 406 | 430 | global $modSettings, $smcFunc, $context; |
| 407 | 431 | |
| 408 | - if (!empty($modSettings['enable_likes'])) |
|
| 409 | - $context['can_like'] = allowedTo('likes_like'); |
|
| 432 | + if (!empty($modSettings['enable_likes'])) { |
|
| 433 | + $context['can_like'] = allowedTo('likes_like'); |
|
| 434 | + } |
|
| 410 | 435 | |
| 411 | 436 | // Find all the posts. Newer ones will have higher IDs. |
| 412 | 437 | $request = $smcFunc['db_query']('substring', ' |
@@ -472,12 +497,13 @@ discard block |
||
| 472 | 497 | ); |
| 473 | 498 | |
| 474 | 499 | // Get the likes for each message. |
| 475 | - if (!empty($modSettings['enable_likes'])) |
|
| 476 | - $posts[$row['id_msg']]['likes'] = array( |
|
| 500 | + if (!empty($modSettings['enable_likes'])) { |
|
| 501 | + $posts[$row['id_msg']]['likes'] = array( |
|
| 477 | 502 | 'count' => $row['likes'], |
| 478 | 503 | 'you' => in_array($row['id_msg'], prepareLikesContext($row['id_topic'])), |
| 479 | 504 | 'can_like' => !$context['user']['is_guest'] && $row['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
| 480 | 505 | ); |
| 506 | + } |
|
| 481 | 507 | } |
| 482 | 508 | $smcFunc['db_free_result']($request); |
| 483 | 509 | |
@@ -485,13 +511,14 @@ discard block |
||
| 485 | 511 | call_integration_hook('integrate_ssi_queryPosts', array(&$posts)); |
| 486 | 512 | |
| 487 | 513 | // Just return it. |
| 488 | - if ($output_method != 'echo' || empty($posts)) |
|
| 489 | - return $posts; |
|
| 514 | + if ($output_method != 'echo' || empty($posts)) { |
|
| 515 | + return $posts; |
|
| 516 | + } |
|
| 490 | 517 | |
| 491 | 518 | echo ' |
| 492 | 519 | <table style="border: none" class="ssi_table">'; |
| 493 | - foreach ($posts as $post) |
|
| 494 | - echo ' |
|
| 520 | + foreach ($posts as $post) { |
|
| 521 | + echo ' |
|
| 495 | 522 | <tr> |
| 496 | 523 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
| 497 | 524 | [', $post['board']['link'], '] |
@@ -505,6 +532,7 @@ discard block |
||
| 505 | 532 | ', $post['time'], ' |
| 506 | 533 | </td> |
| 507 | 534 | </tr>'; |
| 535 | + } |
|
| 508 | 536 | echo ' |
| 509 | 537 | </table>'; |
| 510 | 538 | } |
@@ -522,25 +550,26 @@ discard block |
||
| 522 | 550 | global $settings, $scripturl, $txt, $user_info; |
| 523 | 551 | global $modSettings, $smcFunc, $context; |
| 524 | 552 | |
| 525 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
| 526 | - $exclude_boards = array($modSettings['recycle_board']); |
|
| 527 | - else |
|
| 528 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
| 553 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
| 554 | + $exclude_boards = array($modSettings['recycle_board']); |
|
| 555 | + } else { |
|
| 556 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
| 557 | + } |
|
| 529 | 558 | |
| 530 | 559 | // Only some boards?. |
| 531 | 560 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
| 532 | 561 | { |
| 533 | 562 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
| 534 | - } |
|
| 535 | - elseif ($include_boards != null) |
|
| 563 | + } elseif ($include_boards != null) |
|
| 536 | 564 | { |
| 537 | 565 | $output_method = $include_boards; |
| 538 | 566 | $include_boards = array(); |
| 539 | 567 | } |
| 540 | 568 | |
| 541 | 569 | $icon_sources = array(); |
| 542 | - foreach ($context['stable_icons'] as $icon) |
|
| 543 | - $icon_sources[$icon] = 'images_url'; |
|
| 570 | + foreach ($context['stable_icons'] as $icon) { |
|
| 571 | + $icon_sources[$icon] = 'images_url'; |
|
| 572 | + } |
|
| 544 | 573 | |
| 545 | 574 | // Find all the posts in distinct topics. Newer ones will have higher IDs. |
| 546 | 575 | $request = $smcFunc['db_query']('substring', ' |
@@ -565,13 +594,15 @@ discard block |
||
| 565 | 594 | ) |
| 566 | 595 | ); |
| 567 | 596 | $topics = array(); |
| 568 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 569 | - $topics[$row['id_topic']] = $row; |
|
| 597 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 598 | + $topics[$row['id_topic']] = $row; |
|
| 599 | + } |
|
| 570 | 600 | $smcFunc['db_free_result']($request); |
| 571 | 601 | |
| 572 | 602 | // Did we find anything? If not, bail. |
| 573 | - if (empty($topics)) |
|
| 574 | - return array(); |
|
| 603 | + if (empty($topics)) { |
|
| 604 | + return array(); |
|
| 605 | + } |
|
| 575 | 606 | |
| 576 | 607 | $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
| 577 | 608 | |
@@ -599,21 +630,24 @@ discard block |
||
| 599 | 630 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 600 | 631 | { |
| 601 | 632 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => ' '))); |
| 602 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
| 603 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 633 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
| 634 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 635 | + } |
|
| 604 | 636 | |
| 605 | 637 | // Censor the subject. |
| 606 | 638 | censorText($row['subject']); |
| 607 | 639 | censorText($row['body']); |
| 608 | 640 | |
| 609 | 641 | // Recycled icon |
| 610 | - if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) |
|
| 611 | - $row['icon'] = 'recycled'; |
|
| 642 | + if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) { |
|
| 643 | + $row['icon'] = 'recycled'; |
|
| 644 | + } |
|
| 612 | 645 | |
| 613 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
| 614 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 615 | - elseif (!isset($icon_sources[$row['icon']])) |
|
| 616 | - $icon_sources[$row['icon']] = 'images_url'; |
|
| 646 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
| 647 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 648 | + } elseif (!isset($icon_sources[$row['icon']])) { |
|
| 649 | + $icon_sources[$row['icon']] = 'images_url'; |
|
| 650 | + } |
|
| 617 | 651 | |
| 618 | 652 | // Build the array. |
| 619 | 653 | $posts[] = array( |
@@ -652,13 +686,14 @@ discard block |
||
| 652 | 686 | call_integration_hook('integrate_ssi_recentTopics', array(&$posts)); |
| 653 | 687 | |
| 654 | 688 | // Just return it. |
| 655 | - if ($output_method != 'echo' || empty($posts)) |
|
| 656 | - return $posts; |
|
| 689 | + if ($output_method != 'echo' || empty($posts)) { |
|
| 690 | + return $posts; |
|
| 691 | + } |
|
| 657 | 692 | |
| 658 | 693 | echo ' |
| 659 | 694 | <table style="border: none" class="ssi_table">'; |
| 660 | - foreach ($posts as $post) |
|
| 661 | - echo ' |
|
| 695 | + foreach ($posts as $post) { |
|
| 696 | + echo ' |
|
| 662 | 697 | <tr> |
| 663 | 698 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
| 664 | 699 | [', $post['board']['link'], '] |
@@ -672,6 +707,7 @@ discard block |
||
| 672 | 707 | ', $post['time'], ' |
| 673 | 708 | </td> |
| 674 | 709 | </tr>'; |
| 710 | + } |
|
| 675 | 711 | echo ' |
| 676 | 712 | </table>'; |
| 677 | 713 | } |
@@ -696,27 +732,30 @@ discard block |
||
| 696 | 732 | ) |
| 697 | 733 | ); |
| 698 | 734 | $return = array(); |
| 699 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 700 | - $return[] = array( |
|
| 735 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 736 | + $return[] = array( |
|
| 701 | 737 | 'id' => $row['id_member'], |
| 702 | 738 | 'name' => $row['real_name'], |
| 703 | 739 | 'href' => $scripturl . '?action=profile;u=' . $row['id_member'], |
| 704 | 740 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>', |
| 705 | 741 | 'posts' => $row['posts'] |
| 706 | 742 | ); |
| 743 | + } |
|
| 707 | 744 | $smcFunc['db_free_result']($request); |
| 708 | 745 | |
| 709 | 746 | // If mods want to do somthing with this list of members, let them do that now. |
| 710 | 747 | call_integration_hook('integrate_ssi_topPoster', array(&$return)); |
| 711 | 748 | |
| 712 | 749 | // Just return all the top posters. |
| 713 | - if ($output_method != 'echo') |
|
| 714 | - return $return; |
|
| 750 | + if ($output_method != 'echo') { |
|
| 751 | + return $return; |
|
| 752 | + } |
|
| 715 | 753 | |
| 716 | 754 | // Make a quick array to list the links in. |
| 717 | 755 | $temp_array = array(); |
| 718 | - foreach ($return as $member) |
|
| 719 | - $temp_array[] = $member['link']; |
|
| 756 | + foreach ($return as $member) { |
|
| 757 | + $temp_array[] = $member['link']; |
|
| 758 | + } |
|
| 720 | 759 | |
| 721 | 760 | echo implode(', ', $temp_array); |
| 722 | 761 | } |
@@ -748,8 +787,8 @@ discard block |
||
| 748 | 787 | ) |
| 749 | 788 | ); |
| 750 | 789 | $boards = array(); |
| 751 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 752 | - $boards[] = array( |
|
| 790 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 791 | + $boards[] = array( |
|
| 753 | 792 | 'id' => $row['id_board'], |
| 754 | 793 | 'num_posts' => $row['num_posts'], |
| 755 | 794 | 'num_topics' => $row['num_topics'], |
@@ -758,14 +797,16 @@ discard block |
||
| 758 | 797 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
| 759 | 798 | 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>' |
| 760 | 799 | ); |
| 800 | + } |
|
| 761 | 801 | $smcFunc['db_free_result']($request); |
| 762 | 802 | |
| 763 | 803 | // If mods want to do somthing with this list of boards, let them do that now. |
| 764 | 804 | call_integration_hook('integrate_ssi_topBoards', array(&$boards)); |
| 765 | 805 | |
| 766 | 806 | // If we shouldn't output or have nothing to output, just jump out. |
| 767 | - if ($output_method != 'echo' || empty($boards)) |
|
| 768 | - return $boards; |
|
| 807 | + if ($output_method != 'echo' || empty($boards)) { |
|
| 808 | + return $boards; |
|
| 809 | + } |
|
| 769 | 810 | |
| 770 | 811 | echo ' |
| 771 | 812 | <table class="ssi_table"> |
@@ -774,13 +815,14 @@ discard block |
||
| 774 | 815 | <th style="text-align: left">', $txt['board_topics'], '</th> |
| 775 | 816 | <th style="text-align: left">', $txt['posts'], '</th> |
| 776 | 817 | </tr>'; |
| 777 | - foreach ($boards as $sBoard) |
|
| 778 | - echo ' |
|
| 818 | + foreach ($boards as $sBoard) { |
|
| 819 | + echo ' |
|
| 779 | 820 | <tr> |
| 780 | 821 | <td>', $sBoard['link'], $sBoard['new'] ? ' <a href="' . $sBoard['href'] . '" class="new_posts">' . $txt['new'] . '</a>' : '', '</td> |
| 781 | 822 | <td style="text-align: right">', comma_format($sBoard['num_topics']), '</td> |
| 782 | 823 | <td style="text-align: right">', comma_format($sBoard['num_posts']), '</td> |
| 783 | 824 | </tr>'; |
| 825 | + } |
|
| 784 | 826 | echo ' |
| 785 | 827 | </table>'; |
| 786 | 828 | } |
@@ -813,12 +855,13 @@ discard block |
||
| 813 | 855 | ) |
| 814 | 856 | ); |
| 815 | 857 | $topic_ids = array(); |
| 816 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 817 | - $topic_ids[] = $row['id_topic']; |
|
| 858 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 859 | + $topic_ids[] = $row['id_topic']; |
|
| 860 | + } |
|
| 818 | 861 | $smcFunc['db_free_result']($request); |
| 862 | + } else { |
|
| 863 | + $topic_ids = array(); |
|
| 819 | 864 | } |
| 820 | - else |
|
| 821 | - $topic_ids = array(); |
|
| 822 | 865 | |
| 823 | 866 | $request = $smcFunc['db_query']('', ' |
| 824 | 867 | SELECT m.subject, m.id_topic, t.num_views, t.num_replies |
@@ -857,8 +900,9 @@ discard block |
||
| 857 | 900 | // If mods want to do somthing with this list of topics, let them do that now. |
| 858 | 901 | call_integration_hook('integrate_ssi_topTopics', array(&$topics, $type)); |
| 859 | 902 | |
| 860 | - if ($output_method != 'echo' || empty($topics)) |
|
| 861 | - return $topics; |
|
| 903 | + if ($output_method != 'echo' || empty($topics)) { |
|
| 904 | + return $topics; |
|
| 905 | + } |
|
| 862 | 906 | |
| 863 | 907 | echo ' |
| 864 | 908 | <table class="ssi_table"> |
@@ -867,8 +911,8 @@ discard block |
||
| 867 | 911 | <th style="text-align: left">', $txt['views'], '</th> |
| 868 | 912 | <th style="text-align: left">', $txt['replies'], '</th> |
| 869 | 913 | </tr>'; |
| 870 | - foreach ($topics as $sTopic) |
|
| 871 | - echo ' |
|
| 914 | + foreach ($topics as $sTopic) { |
|
| 915 | + echo ' |
|
| 872 | 916 | <tr> |
| 873 | 917 | <td style="text-align: left"> |
| 874 | 918 | ', $sTopic['link'], ' |
@@ -876,6 +920,7 @@ discard block |
||
| 876 | 920 | <td style="text-align: right">', comma_format($sTopic['num_views']), '</td> |
| 877 | 921 | <td style="text-align: right">', comma_format($sTopic['num_replies']), '</td> |
| 878 | 922 | </tr>'; |
| 923 | + } |
|
| 879 | 924 | echo ' |
| 880 | 925 | </table>'; |
| 881 | 926 | } |
@@ -911,12 +956,13 @@ discard block |
||
| 911 | 956 | { |
| 912 | 957 | global $txt, $context; |
| 913 | 958 | |
| 914 | - if ($output_method == 'echo') |
|
| 915 | - echo ' |
|
| 959 | + if ($output_method == 'echo') { |
|
| 960 | + echo ' |
|
| 916 | 961 | ', sprintf($txt['welcome_newest_member'], $context['common_stats']['latest_member']['link']), '<br>'; |
| 917 | - else |
|
| 918 | - return $context['common_stats']['latest_member']; |
|
| 919 | -} |
|
| 962 | + } else { |
|
| 963 | + return $context['common_stats']['latest_member']; |
|
| 964 | + } |
|
| 965 | + } |
|
| 920 | 966 | |
| 921 | 967 | /** |
| 922 | 968 | * Fetches a random member. |
@@ -965,8 +1011,9 @@ discard block |
||
| 965 | 1011 | } |
| 966 | 1012 | |
| 967 | 1013 | // Just to be sure put the random generator back to something... random. |
| 968 | - if ($random_type != '') |
|
| 969 | - mt_srand(time()); |
|
| 1014 | + if ($random_type != '') { |
|
| 1015 | + mt_srand(time()); |
|
| 1016 | + } |
|
| 970 | 1017 | |
| 971 | 1018 | return $result; |
| 972 | 1019 | } |
@@ -979,8 +1026,9 @@ discard block |
||
| 979 | 1026 | */ |
| 980 | 1027 | function ssi_fetchMember($member_ids = array(), $output_method = 'echo') |
| 981 | 1028 | { |
| 982 | - if (empty($member_ids)) |
|
| 983 | - return; |
|
| 1029 | + if (empty($member_ids)) { |
|
| 1030 | + return; |
|
| 1031 | + } |
|
| 984 | 1032 | |
| 985 | 1033 | // Can have more than one member if you really want... |
| 986 | 1034 | $member_ids = is_array($member_ids) ? $member_ids : array($member_ids); |
@@ -1005,8 +1053,9 @@ discard block |
||
| 1005 | 1053 | */ |
| 1006 | 1054 | function ssi_fetchGroupMembers($group_id = null, $output_method = 'echo') |
| 1007 | 1055 | { |
| 1008 | - if ($group_id === null) |
|
| 1009 | - return; |
|
| 1056 | + if ($group_id === null) { |
|
| 1057 | + return; |
|
| 1058 | + } |
|
| 1010 | 1059 | |
| 1011 | 1060 | $query_where = ' |
| 1012 | 1061 | id_group = {int:id_group} |
@@ -1033,8 +1082,9 @@ discard block |
||
| 1033 | 1082 | { |
| 1034 | 1083 | global $smcFunc, $memberContext; |
| 1035 | 1084 | |
| 1036 | - if ($query_where === null) |
|
| 1037 | - return; |
|
| 1085 | + if ($query_where === null) { |
|
| 1086 | + return; |
|
| 1087 | + } |
|
| 1038 | 1088 | |
| 1039 | 1089 | // Fetch the members in question. |
| 1040 | 1090 | $request = $smcFunc['db_query']('', ' |
@@ -1047,12 +1097,14 @@ discard block |
||
| 1047 | 1097 | )) |
| 1048 | 1098 | ); |
| 1049 | 1099 | $members = array(); |
| 1050 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1051 | - $members[] = $row['id_member']; |
|
| 1100 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1101 | + $members[] = $row['id_member']; |
|
| 1102 | + } |
|
| 1052 | 1103 | $smcFunc['db_free_result']($request); |
| 1053 | 1104 | |
| 1054 | - if (empty($members)) |
|
| 1055 | - return array(); |
|
| 1105 | + if (empty($members)) { |
|
| 1106 | + return array(); |
|
| 1107 | + } |
|
| 1056 | 1108 | |
| 1057 | 1109 | // If mods want to do somthing with this list of members, let them do that now. |
| 1058 | 1110 | call_integration_hook('integrate_ssi_queryMembers', array(&$members)); |
@@ -1061,23 +1113,25 @@ discard block |
||
| 1061 | 1113 | loadMemberData($members); |
| 1062 | 1114 | |
| 1063 | 1115 | // Draw the table! |
| 1064 | - if ($output_method == 'echo') |
|
| 1065 | - echo ' |
|
| 1116 | + if ($output_method == 'echo') { |
|
| 1117 | + echo ' |
|
| 1066 | 1118 | <table style="border: none" class="ssi_table">'; |
| 1119 | + } |
|
| 1067 | 1120 | |
| 1068 | 1121 | $query_members = array(); |
| 1069 | 1122 | foreach ($members as $member) |
| 1070 | 1123 | { |
| 1071 | 1124 | // Load their context data. |
| 1072 | - if (!loadMemberContext($member)) |
|
| 1073 | - continue; |
|
| 1125 | + if (!loadMemberContext($member)) { |
|
| 1126 | + continue; |
|
| 1127 | + } |
|
| 1074 | 1128 | |
| 1075 | 1129 | // Store this member's information. |
| 1076 | 1130 | $query_members[$member] = $memberContext[$member]; |
| 1077 | 1131 | |
| 1078 | 1132 | // Only do something if we're echo'ing. |
| 1079 | - if ($output_method == 'echo') |
|
| 1080 | - echo ' |
|
| 1133 | + if ($output_method == 'echo') { |
|
| 1134 | + echo ' |
|
| 1081 | 1135 | <tr> |
| 1082 | 1136 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
| 1083 | 1137 | ', $query_members[$member]['link'], ' |
@@ -1085,12 +1139,14 @@ discard block |
||
| 1085 | 1139 | <br>', $query_members[$member]['avatar']['image'], ' |
| 1086 | 1140 | </td> |
| 1087 | 1141 | </tr>'; |
| 1142 | + } |
|
| 1088 | 1143 | } |
| 1089 | 1144 | |
| 1090 | 1145 | // End the table if appropriate. |
| 1091 | - if ($output_method == 'echo') |
|
| 1092 | - echo ' |
|
| 1146 | + if ($output_method == 'echo') { |
|
| 1147 | + echo ' |
|
| 1093 | 1148 | </table>'; |
| 1149 | + } |
|
| 1094 | 1150 | |
| 1095 | 1151 | // Send back the data. |
| 1096 | 1152 | return $query_members; |
@@ -1105,8 +1161,9 @@ discard block |
||
| 1105 | 1161 | { |
| 1106 | 1162 | global $txt, $scripturl, $modSettings, $smcFunc; |
| 1107 | 1163 | |
| 1108 | - if (!allowedTo('view_stats')) |
|
| 1109 | - return; |
|
| 1164 | + if (!allowedTo('view_stats')) { |
|
| 1165 | + return; |
|
| 1166 | + } |
|
| 1110 | 1167 | |
| 1111 | 1168 | $totals = array( |
| 1112 | 1169 | 'members' => $modSettings['totalMembers'], |
@@ -1135,8 +1192,9 @@ discard block |
||
| 1135 | 1192 | // If mods want to do somthing with the board stats, let them do that now. |
| 1136 | 1193 | call_integration_hook('integrate_ssi_boardStats', array(&$totals)); |
| 1137 | 1194 | |
| 1138 | - if ($output_method != 'echo') |
|
| 1139 | - return $totals; |
|
| 1195 | + if ($output_method != 'echo') { |
|
| 1196 | + return $totals; |
|
| 1197 | + } |
|
| 1140 | 1198 | |
| 1141 | 1199 | echo ' |
| 1142 | 1200 | ', $txt['total_members'], ': <a href="', $scripturl . '?action=mlist">', comma_format($totals['members']), '</a><br> |
@@ -1165,8 +1223,8 @@ discard block |
||
| 1165 | 1223 | call_integration_hook('integrate_ssi_whosOnline', array(&$return)); |
| 1166 | 1224 | |
| 1167 | 1225 | // Add some redundancy for backwards compatibility reasons. |
| 1168 | - if ($output_method != 'echo') |
|
| 1169 | - return $return + array( |
|
| 1226 | + if ($output_method != 'echo') { |
|
| 1227 | + return $return + array( |
|
| 1170 | 1228 | 'users' => $return['users_online'], |
| 1171 | 1229 | 'guests' => $return['num_guests'], |
| 1172 | 1230 | 'hidden' => $return['num_users_hidden'], |
@@ -1174,29 +1232,35 @@ discard block |
||
| 1174 | 1232 | 'num_users' => $return['num_users_online'], |
| 1175 | 1233 | 'total_users' => $return['num_users_online'] + $return['num_guests'], |
| 1176 | 1234 | ); |
| 1235 | + } |
|
| 1177 | 1236 | |
| 1178 | 1237 | echo ' |
| 1179 | 1238 | ', comma_format($return['num_guests']), ' ', $return['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', comma_format($return['num_users_online']), ' ', $return['num_users_online'] == 1 ? $txt['user'] : $txt['users']; |
| 1180 | 1239 | |
| 1181 | 1240 | $bracketList = array(); |
| 1182 | - if (!empty($user_info['buddies'])) |
|
| 1183 | - $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
| 1184 | - if (!empty($return['num_spiders'])) |
|
| 1185 | - $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
| 1186 | - if (!empty($return['num_users_hidden'])) |
|
| 1187 | - $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
| 1241 | + if (!empty($user_info['buddies'])) { |
|
| 1242 | + $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
| 1243 | + } |
|
| 1244 | + if (!empty($return['num_spiders'])) { |
|
| 1245 | + $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
| 1246 | + } |
|
| 1247 | + if (!empty($return['num_users_hidden'])) { |
|
| 1248 | + $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
| 1249 | + } |
|
| 1188 | 1250 | |
| 1189 | - if (!empty($bracketList)) |
|
| 1190 | - echo ' (' . implode(', ', $bracketList) . ')'; |
|
| 1251 | + if (!empty($bracketList)) { |
|
| 1252 | + echo ' (' . implode(', ', $bracketList) . ')'; |
|
| 1253 | + } |
|
| 1191 | 1254 | |
| 1192 | 1255 | echo '<br> |
| 1193 | 1256 | ', implode(', ', $return['list_users_online']); |
| 1194 | 1257 | |
| 1195 | 1258 | // Showing membergroups? |
| 1196 | - if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) |
|
| 1197 | - echo '<br> |
|
| 1259 | + if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) { |
|
| 1260 | + echo '<br> |
|
| 1198 | 1261 | [' . implode('] [', $return['membergroups']) . ']'; |
| 1199 | -} |
|
| 1262 | + } |
|
| 1263 | + } |
|
| 1200 | 1264 | |
| 1201 | 1265 | /** |
| 1202 | 1266 | * Just like whosOnline except it also logs the online presence. |
@@ -1207,11 +1271,12 @@ discard block |
||
| 1207 | 1271 | { |
| 1208 | 1272 | writeLog(); |
| 1209 | 1273 | |
| 1210 | - if ($output_method != 'echo') |
|
| 1211 | - return ssi_whosOnline($output_method); |
|
| 1212 | - else |
|
| 1213 | - ssi_whosOnline($output_method); |
|
| 1214 | -} |
|
| 1274 | + if ($output_method != 'echo') { |
|
| 1275 | + return ssi_whosOnline($output_method); |
|
| 1276 | + } else { |
|
| 1277 | + ssi_whosOnline($output_method); |
|
| 1278 | + } |
|
| 1279 | + } |
|
| 1215 | 1280 | |
| 1216 | 1281 | // Shows a login box. |
| 1217 | 1282 | /** |
@@ -1224,11 +1289,13 @@ discard block |
||
| 1224 | 1289 | { |
| 1225 | 1290 | global $scripturl, $txt, $user_info, $context; |
| 1226 | 1291 | |
| 1227 | - if ($redirect_to != '') |
|
| 1228 | - $_SESSION['login_url'] = $redirect_to; |
|
| 1292 | + if ($redirect_to != '') { |
|
| 1293 | + $_SESSION['login_url'] = $redirect_to; |
|
| 1294 | + } |
|
| 1229 | 1295 | |
| 1230 | - if ($output_method != 'echo' || !$user_info['is_guest']) |
|
| 1231 | - return $user_info['is_guest']; |
|
| 1296 | + if ($output_method != 'echo' || !$user_info['is_guest']) { |
|
| 1297 | + return $user_info['is_guest']; |
|
| 1298 | + } |
|
| 1232 | 1299 | |
| 1233 | 1300 | // Create a login token |
| 1234 | 1301 | createToken('login'); |
@@ -1280,8 +1347,9 @@ discard block |
||
| 1280 | 1347 | |
| 1281 | 1348 | $boardsAllowed = array_intersect(boardsAllowedTo('poll_view'), boardsAllowedTo('poll_vote')); |
| 1282 | 1349 | |
| 1283 | - if (empty($boardsAllowed)) |
|
| 1284 | - return array(); |
|
| 1350 | + if (empty($boardsAllowed)) { |
|
| 1351 | + return array(); |
|
| 1352 | + } |
|
| 1285 | 1353 | |
| 1286 | 1354 | $request = $smcFunc['db_query']('', ' |
| 1287 | 1355 | SELECT p.id_poll, p.question, t.id_topic, p.max_votes, p.guest_vote, p.hide_results, p.expire_time |
@@ -1314,12 +1382,14 @@ discard block |
||
| 1314 | 1382 | $smcFunc['db_free_result']($request); |
| 1315 | 1383 | |
| 1316 | 1384 | // This user has voted on all the polls. |
| 1317 | - if (empty($row) || !is_array($row)) |
|
| 1318 | - return array(); |
|
| 1385 | + if (empty($row) || !is_array($row)) { |
|
| 1386 | + return array(); |
|
| 1387 | + } |
|
| 1319 | 1388 | |
| 1320 | 1389 | // If this is a guest who's voted we'll through ourselves to show poll to show the results. |
| 1321 | - if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) |
|
| 1322 | - return ssi_showPoll($row['id_topic'], $output_method); |
|
| 1390 | + if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) { |
|
| 1391 | + return ssi_showPoll($row['id_topic'], $output_method); |
|
| 1392 | + } |
|
| 1323 | 1393 | |
| 1324 | 1394 | $request = $smcFunc['db_query']('', ' |
| 1325 | 1395 | SELECT COUNT(DISTINCT id_member) |
@@ -1383,8 +1453,9 @@ discard block |
||
| 1383 | 1453 | // If mods want to do somthing with this list of polls, let them do that now. |
| 1384 | 1454 | call_integration_hook('integrate_ssi_recentPoll', array(&$return, $topPollInstead)); |
| 1385 | 1455 | |
| 1386 | - if ($output_method != 'echo') |
|
| 1387 | - return $return; |
|
| 1456 | + if ($output_method != 'echo') { |
|
| 1457 | + return $return; |
|
| 1458 | + } |
|
| 1388 | 1459 | |
| 1389 | 1460 | if ($allow_view_results) |
| 1390 | 1461 | { |
@@ -1393,19 +1464,20 @@ discard block |
||
| 1393 | 1464 | <strong>', $return['question'], '</strong><br> |
| 1394 | 1465 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
| 1395 | 1466 | |
| 1396 | - foreach ($return['options'] as $option) |
|
| 1397 | - echo ' |
|
| 1467 | + foreach ($return['options'] as $option) { |
|
| 1468 | + echo ' |
|
| 1398 | 1469 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
| 1470 | + } |
|
| 1399 | 1471 | |
| 1400 | 1472 | echo ' |
| 1401 | 1473 | <input type="submit" value="', $txt['poll_vote'], '" class="button"> |
| 1402 | 1474 | <input type="hidden" name="poll" value="', $return['id'], '"> |
| 1403 | 1475 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 1404 | 1476 | </form>'; |
| 1477 | + } else { |
|
| 1478 | + echo $txt['poll_cannot_see']; |
|
| 1479 | + } |
|
| 1405 | 1480 | } |
| 1406 | - else |
|
| 1407 | - echo $txt['poll_cannot_see']; |
|
| 1408 | -} |
|
| 1409 | 1481 | |
| 1410 | 1482 | /** |
| 1411 | 1483 | * Shows the poll from the specified topic |
@@ -1419,13 +1491,15 @@ discard block |
||
| 1419 | 1491 | |
| 1420 | 1492 | $boardsAllowed = boardsAllowedTo('poll_view'); |
| 1421 | 1493 | |
| 1422 | - if (empty($boardsAllowed)) |
|
| 1423 | - return array(); |
|
| 1494 | + if (empty($boardsAllowed)) { |
|
| 1495 | + return array(); |
|
| 1496 | + } |
|
| 1424 | 1497 | |
| 1425 | - if ($topic === null && isset($_REQUEST['ssi_topic'])) |
|
| 1426 | - $topic = (int) $_REQUEST['ssi_topic']; |
|
| 1427 | - else |
|
| 1428 | - $topic = (int) $topic; |
|
| 1498 | + if ($topic === null && isset($_REQUEST['ssi_topic'])) { |
|
| 1499 | + $topic = (int) $_REQUEST['ssi_topic']; |
|
| 1500 | + } else { |
|
| 1501 | + $topic = (int) $topic; |
|
| 1502 | + } |
|
| 1429 | 1503 | |
| 1430 | 1504 | $request = $smcFunc['db_query']('', ' |
| 1431 | 1505 | SELECT |
@@ -1446,17 +1520,18 @@ discard block |
||
| 1446 | 1520 | ); |
| 1447 | 1521 | |
| 1448 | 1522 | // Either this topic has no poll, or the user cannot view it. |
| 1449 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1450 | - return array(); |
|
| 1523 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1524 | + return array(); |
|
| 1525 | + } |
|
| 1451 | 1526 | |
| 1452 | 1527 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1453 | 1528 | $smcFunc['db_free_result']($request); |
| 1454 | 1529 | |
| 1455 | 1530 | // Check if they can vote. |
| 1456 | 1531 | $already_voted = false; |
| 1457 | - if (!empty($row['expire_time']) && $row['expire_time'] < time()) |
|
| 1458 | - $allow_vote = false; |
|
| 1459 | - elseif ($user_info['is_guest']) |
|
| 1532 | + if (!empty($row['expire_time']) && $row['expire_time'] < time()) { |
|
| 1533 | + $allow_vote = false; |
|
| 1534 | + } elseif ($user_info['is_guest']) |
|
| 1460 | 1535 | { |
| 1461 | 1536 | // There's a difference between "allowed to vote" and "already voted"... |
| 1462 | 1537 | $allow_vote = $row['guest_vote']; |
@@ -1466,10 +1541,9 @@ discard block |
||
| 1466 | 1541 | { |
| 1467 | 1542 | $already_voted = true; |
| 1468 | 1543 | } |
| 1469 | - } |
|
| 1470 | - elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) |
|
| 1471 | - $allow_vote = false; |
|
| 1472 | - else |
|
| 1544 | + } elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) { |
|
| 1545 | + $allow_vote = false; |
|
| 1546 | + } else |
|
| 1473 | 1547 | { |
| 1474 | 1548 | $request = $smcFunc['db_query']('', ' |
| 1475 | 1549 | SELECT id_member |
@@ -1551,8 +1625,9 @@ discard block |
||
| 1551 | 1625 | // If mods want to do somthing with this poll, let them do that now. |
| 1552 | 1626 | call_integration_hook('integrate_ssi_showPoll', array(&$return)); |
| 1553 | 1627 | |
| 1554 | - if ($output_method != 'echo') |
|
| 1555 | - return $return; |
|
| 1628 | + if ($output_method != 'echo') { |
|
| 1629 | + return $return; |
|
| 1630 | + } |
|
| 1556 | 1631 | |
| 1557 | 1632 | if ($return['allow_vote']) |
| 1558 | 1633 | { |
@@ -1561,17 +1636,17 @@ discard block |
||
| 1561 | 1636 | <strong>', $return['question'], '</strong><br> |
| 1562 | 1637 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
| 1563 | 1638 | |
| 1564 | - foreach ($return['options'] as $option) |
|
| 1565 | - echo ' |
|
| 1639 | + foreach ($return['options'] as $option) { |
|
| 1640 | + echo ' |
|
| 1566 | 1641 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
| 1642 | + } |
|
| 1567 | 1643 | |
| 1568 | 1644 | echo ' |
| 1569 | 1645 | <input type="submit" value="', $txt['poll_vote'], '" class="button"> |
| 1570 | 1646 | <input type="hidden" name="poll" value="', $return['id'], '"> |
| 1571 | 1647 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 1572 | 1648 | </form>'; |
| 1573 | - } |
|
| 1574 | - else |
|
| 1649 | + } else |
|
| 1575 | 1650 | { |
| 1576 | 1651 | echo ' |
| 1577 | 1652 | <div class="ssi_poll"> |
@@ -1651,27 +1726,32 @@ discard block |
||
| 1651 | 1726 | 'is_approved' => 1, |
| 1652 | 1727 | ) |
| 1653 | 1728 | ); |
| 1654 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1655 | - die; |
|
| 1729 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1730 | + die; |
|
| 1731 | + } |
|
| 1656 | 1732 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1657 | 1733 | $smcFunc['db_free_result']($request); |
| 1658 | 1734 | |
| 1659 | - if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) |
|
| 1660 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1735 | + if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) { |
|
| 1736 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1737 | + } |
|
| 1661 | 1738 | |
| 1662 | 1739 | // Too many options checked? |
| 1663 | - if (count($_REQUEST['options']) > $row['max_votes']) |
|
| 1664 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1740 | + if (count($_REQUEST['options']) > $row['max_votes']) { |
|
| 1741 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1742 | + } |
|
| 1665 | 1743 | |
| 1666 | 1744 | // It's a guest who has already voted? |
| 1667 | 1745 | if ($user_info['is_guest']) |
| 1668 | 1746 | { |
| 1669 | 1747 | // Guest voting disabled? |
| 1670 | - if (!$row['guest_vote']) |
|
| 1671 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1748 | + if (!$row['guest_vote']) { |
|
| 1749 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1750 | + } |
|
| 1672 | 1751 | // Already voted? |
| 1673 | - elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) |
|
| 1674 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1752 | + elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) { |
|
| 1753 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1754 | + } |
|
| 1675 | 1755 | } |
| 1676 | 1756 | |
| 1677 | 1757 | $sOptions = array(); |
@@ -1725,11 +1805,13 @@ discard block |
||
| 1725 | 1805 | { |
| 1726 | 1806 | global $scripturl, $txt, $context; |
| 1727 | 1807 | |
| 1728 | - if (!allowedTo('search_posts')) |
|
| 1729 | - return; |
|
| 1808 | + if (!allowedTo('search_posts')) { |
|
| 1809 | + return; |
|
| 1810 | + } |
|
| 1730 | 1811 | |
| 1731 | - if ($output_method != 'echo') |
|
| 1732 | - return $scripturl . '?action=search'; |
|
| 1812 | + if ($output_method != 'echo') { |
|
| 1813 | + return $scripturl . '?action=search'; |
|
| 1814 | + } |
|
| 1733 | 1815 | |
| 1734 | 1816 | echo ' |
| 1735 | 1817 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '"> |
@@ -1751,8 +1833,9 @@ discard block |
||
| 1751 | 1833 | // If mods want to do somthing with the news, let them do that now. Don't need to pass the news line itself, since it is already in $context. |
| 1752 | 1834 | call_integration_hook('integrate_ssi_news'); |
| 1753 | 1835 | |
| 1754 | - if ($output_method != 'echo') |
|
| 1755 | - return $context['random_news_line']; |
|
| 1836 | + if ($output_method != 'echo') { |
|
| 1837 | + return $context['random_news_line']; |
|
| 1838 | + } |
|
| 1756 | 1839 | |
| 1757 | 1840 | echo $context['random_news_line']; |
| 1758 | 1841 | } |
@@ -1766,8 +1849,9 @@ discard block |
||
| 1766 | 1849 | { |
| 1767 | 1850 | global $scripturl, $modSettings, $user_info; |
| 1768 | 1851 | |
| 1769 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) |
|
| 1770 | - return; |
|
| 1852 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) { |
|
| 1853 | + return; |
|
| 1854 | + } |
|
| 1771 | 1855 | |
| 1772 | 1856 | $eventOptions = array( |
| 1773 | 1857 | 'include_birthdays' => true, |
@@ -1778,13 +1862,15 @@ discard block |
||
| 1778 | 1862 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
| 1779 | 1863 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
| 1780 | 1864 | |
| 1781 | - if ($output_method != 'echo') |
|
| 1782 | - return $return['calendar_birthdays']; |
|
| 1865 | + if ($output_method != 'echo') { |
|
| 1866 | + return $return['calendar_birthdays']; |
|
| 1867 | + } |
|
| 1783 | 1868 | |
| 1784 | - foreach ($return['calendar_birthdays'] as $member) |
|
| 1785 | - echo ' |
|
| 1869 | + foreach ($return['calendar_birthdays'] as $member) { |
|
| 1870 | + echo ' |
|
| 1786 | 1871 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">' . $member['name'] . '</span>' . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>' . (!$member['is_last'] ? ', ' : ''); |
| 1787 | -} |
|
| 1872 | + } |
|
| 1873 | + } |
|
| 1788 | 1874 | |
| 1789 | 1875 | /** |
| 1790 | 1876 | * Shows today's holidays. |
@@ -1795,8 +1881,9 @@ discard block |
||
| 1795 | 1881 | { |
| 1796 | 1882 | global $modSettings, $user_info; |
| 1797 | 1883 | |
| 1798 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
| 1799 | - return; |
|
| 1884 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
| 1885 | + return; |
|
| 1886 | + } |
|
| 1800 | 1887 | |
| 1801 | 1888 | $eventOptions = array( |
| 1802 | 1889 | 'include_holidays' => true, |
@@ -1807,8 +1894,9 @@ discard block |
||
| 1807 | 1894 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
| 1808 | 1895 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
| 1809 | 1896 | |
| 1810 | - if ($output_method != 'echo') |
|
| 1811 | - return $return['calendar_holidays']; |
|
| 1897 | + if ($output_method != 'echo') { |
|
| 1898 | + return $return['calendar_holidays']; |
|
| 1899 | + } |
|
| 1812 | 1900 | |
| 1813 | 1901 | echo ' |
| 1814 | 1902 | ', implode(', ', $return['calendar_holidays']); |
@@ -1822,8 +1910,9 @@ discard block |
||
| 1822 | 1910 | { |
| 1823 | 1911 | global $modSettings, $user_info; |
| 1824 | 1912 | |
| 1825 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
| 1826 | - return; |
|
| 1913 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
| 1914 | + return; |
|
| 1915 | + } |
|
| 1827 | 1916 | |
| 1828 | 1917 | $eventOptions = array( |
| 1829 | 1918 | 'include_events' => true, |
@@ -1834,14 +1923,16 @@ discard block |
||
| 1834 | 1923 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
| 1835 | 1924 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
| 1836 | 1925 | |
| 1837 | - if ($output_method != 'echo') |
|
| 1838 | - return $return['calendar_events']; |
|
| 1926 | + if ($output_method != 'echo') { |
|
| 1927 | + return $return['calendar_events']; |
|
| 1928 | + } |
|
| 1839 | 1929 | |
| 1840 | 1930 | foreach ($return['calendar_events'] as $event) |
| 1841 | 1931 | { |
| 1842 | - if ($event['can_edit']) |
|
| 1843 | - echo ' |
|
| 1932 | + if ($event['can_edit']) { |
|
| 1933 | + echo ' |
|
| 1844 | 1934 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
| 1935 | + } |
|
| 1845 | 1936 | echo ' |
| 1846 | 1937 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
| 1847 | 1938 | } |
@@ -1856,8 +1947,9 @@ discard block |
||
| 1856 | 1947 | { |
| 1857 | 1948 | global $modSettings, $txt, $scripturl, $user_info; |
| 1858 | 1949 | |
| 1859 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
| 1860 | - return; |
|
| 1950 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
| 1951 | + return; |
|
| 1952 | + } |
|
| 1861 | 1953 | |
| 1862 | 1954 | $eventOptions = array( |
| 1863 | 1955 | 'include_birthdays' => allowedTo('profile_view'), |
@@ -1870,19 +1962,22 @@ discard block |
||
| 1870 | 1962 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
| 1871 | 1963 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
| 1872 | 1964 | |
| 1873 | - if ($output_method != 'echo') |
|
| 1874 | - return $return; |
|
| 1965 | + if ($output_method != 'echo') { |
|
| 1966 | + return $return; |
|
| 1967 | + } |
|
| 1875 | 1968 | |
| 1876 | - if (!empty($return['calendar_holidays'])) |
|
| 1877 | - echo ' |
|
| 1969 | + if (!empty($return['calendar_holidays'])) { |
|
| 1970 | + echo ' |
|
| 1878 | 1971 | <span class="holiday">' . $txt['calendar_prompt'] . ' ' . implode(', ', $return['calendar_holidays']) . '<br></span>'; |
| 1972 | + } |
|
| 1879 | 1973 | if (!empty($return['calendar_birthdays'])) |
| 1880 | 1974 | { |
| 1881 | 1975 | echo ' |
| 1882 | 1976 | <span class="birthday">' . $txt['birthdays_upcoming'] . '</span> '; |
| 1883 | - foreach ($return['calendar_birthdays'] as $member) |
|
| 1884 | - echo ' |
|
| 1977 | + foreach ($return['calendar_birthdays'] as $member) { |
|
| 1978 | + echo ' |
|
| 1885 | 1979 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', !$member['is_last'] ? ', ' : ''; |
| 1980 | + } |
|
| 1886 | 1981 | echo ' |
| 1887 | 1982 | <br>'; |
| 1888 | 1983 | } |
@@ -1892,9 +1987,10 @@ discard block |
||
| 1892 | 1987 | <span class="event">' . $txt['events_upcoming'] . '</span> '; |
| 1893 | 1988 | foreach ($return['calendar_events'] as $event) |
| 1894 | 1989 | { |
| 1895 | - if ($event['can_edit']) |
|
| 1896 | - echo ' |
|
| 1990 | + if ($event['can_edit']) { |
|
| 1991 | + echo ' |
|
| 1897 | 1992 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
| 1993 | + } |
|
| 1898 | 1994 | echo ' |
| 1899 | 1995 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
| 1900 | 1996 | } |
@@ -1918,25 +2014,29 @@ discard block |
||
| 1918 | 2014 | loadLanguage('Stats'); |
| 1919 | 2015 | |
| 1920 | 2016 | // Must be integers.... |
| 1921 | - if ($limit === null) |
|
| 1922 | - $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
| 1923 | - else |
|
| 1924 | - $limit = (int) $limit; |
|
| 1925 | - |
|
| 1926 | - if ($start === null) |
|
| 1927 | - $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
| 1928 | - else |
|
| 1929 | - $start = (int) $start; |
|
| 1930 | - |
|
| 1931 | - if ($board !== null) |
|
| 1932 | - $board = (int) $board; |
|
| 1933 | - elseif (isset($_GET['board'])) |
|
| 1934 | - $board = (int) $_GET['board']; |
|
| 1935 | - |
|
| 1936 | - if ($length === null) |
|
| 1937 | - $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
| 1938 | - else |
|
| 1939 | - $length = (int) $length; |
|
| 2017 | + if ($limit === null) { |
|
| 2018 | + $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
| 2019 | + } else { |
|
| 2020 | + $limit = (int) $limit; |
|
| 2021 | + } |
|
| 2022 | + |
|
| 2023 | + if ($start === null) { |
|
| 2024 | + $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
| 2025 | + } else { |
|
| 2026 | + $start = (int) $start; |
|
| 2027 | + } |
|
| 2028 | + |
|
| 2029 | + if ($board !== null) { |
|
| 2030 | + $board = (int) $board; |
|
| 2031 | + } elseif (isset($_GET['board'])) { |
|
| 2032 | + $board = (int) $_GET['board']; |
|
| 2033 | + } |
|
| 2034 | + |
|
| 2035 | + if ($length === null) { |
|
| 2036 | + $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
| 2037 | + } else { |
|
| 2038 | + $length = (int) $length; |
|
| 2039 | + } |
|
| 1940 | 2040 | |
| 1941 | 2041 | $limit = max(0, $limit); |
| 1942 | 2042 | $start = max(0, $start); |
@@ -1954,17 +2054,19 @@ discard block |
||
| 1954 | 2054 | ); |
| 1955 | 2055 | if ($smcFunc['db_num_rows']($request) == 0) |
| 1956 | 2056 | { |
| 1957 | - if ($output_method == 'echo') |
|
| 1958 | - die($txt['ssi_no_guests']); |
|
| 1959 | - else |
|
| 1960 | - return array(); |
|
| 2057 | + if ($output_method == 'echo') { |
|
| 2058 | + die($txt['ssi_no_guests']); |
|
| 2059 | + } else { |
|
| 2060 | + return array(); |
|
| 2061 | + } |
|
| 1961 | 2062 | } |
| 1962 | 2063 | list ($board) = $smcFunc['db_fetch_row']($request); |
| 1963 | 2064 | $smcFunc['db_free_result']($request); |
| 1964 | 2065 | |
| 1965 | 2066 | $icon_sources = array(); |
| 1966 | - foreach ($context['stable_icons'] as $icon) |
|
| 1967 | - $icon_sources[$icon] = 'images_url'; |
|
| 2067 | + foreach ($context['stable_icons'] as $icon) { |
|
| 2068 | + $icon_sources[$icon] = 'images_url'; |
|
| 2069 | + } |
|
| 1968 | 2070 | |
| 1969 | 2071 | if (!empty($modSettings['enable_likes'])) |
| 1970 | 2072 | { |
@@ -1987,12 +2089,14 @@ discard block |
||
| 1987 | 2089 | ) |
| 1988 | 2090 | ); |
| 1989 | 2091 | $posts = array(); |
| 1990 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1991 | - $posts[] = $row['id_first_msg']; |
|
| 2092 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2093 | + $posts[] = $row['id_first_msg']; |
|
| 2094 | + } |
|
| 1992 | 2095 | $smcFunc['db_free_result']($request); |
| 1993 | 2096 | |
| 1994 | - if (empty($posts)) |
|
| 1995 | - return array(); |
|
| 2097 | + if (empty($posts)) { |
|
| 2098 | + return array(); |
|
| 2099 | + } |
|
| 1996 | 2100 | |
| 1997 | 2101 | // Find the posts. |
| 1998 | 2102 | $request = $smcFunc['db_query']('', ' |
@@ -2022,26 +2126,30 @@ discard block |
||
| 2022 | 2126 | $last_space = strrpos($row['body'], ' '); |
| 2023 | 2127 | $last_open = strrpos($row['body'], '<'); |
| 2024 | 2128 | $last_close = strrpos($row['body'], '>'); |
| 2025 | - if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) |
|
| 2026 | - $cutoff = $last_open; |
|
| 2027 | - elseif (empty($last_close) || $last_close < $last_open) |
|
| 2028 | - $cutoff = $last_space; |
|
| 2129 | + if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) { |
|
| 2130 | + $cutoff = $last_open; |
|
| 2131 | + } elseif (empty($last_close) || $last_close < $last_open) { |
|
| 2132 | + $cutoff = $last_space; |
|
| 2133 | + } |
|
| 2029 | 2134 | |
| 2030 | - if ($cutoff !== false) |
|
| 2031 | - $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
| 2135 | + if ($cutoff !== false) { |
|
| 2136 | + $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
| 2137 | + } |
|
| 2032 | 2138 | $row['body'] .= '...'; |
| 2033 | 2139 | } |
| 2034 | 2140 | |
| 2035 | 2141 | $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); |
| 2036 | 2142 | |
| 2037 | - if (!empty($recycle_board) && $row['id_board'] == $recycle_board) |
|
| 2038 | - $row['icon'] = 'recycled'; |
|
| 2143 | + if (!empty($recycle_board) && $row['id_board'] == $recycle_board) { |
|
| 2144 | + $row['icon'] = 'recycled'; |
|
| 2145 | + } |
|
| 2039 | 2146 | |
| 2040 | 2147 | // Check that this message icon is there... |
| 2041 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
| 2042 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 2043 | - elseif (!isset($icon_sources[$row['icon']])) |
|
| 2044 | - $icon_sources[$row['icon']] = 'images_url'; |
|
| 2148 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
| 2149 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 2150 | + } elseif (!isset($icon_sources[$row['icon']])) { |
|
| 2151 | + $icon_sources[$row['icon']] = 'images_url'; |
|
| 2152 | + } |
|
| 2045 | 2153 | |
| 2046 | 2154 | censorText($row['subject']); |
| 2047 | 2155 | censorText($row['body']); |
@@ -2078,16 +2186,18 @@ discard block |
||
| 2078 | 2186 | } |
| 2079 | 2187 | $smcFunc['db_free_result']($request); |
| 2080 | 2188 | |
| 2081 | - if (empty($return)) |
|
| 2082 | - return $return; |
|
| 2189 | + if (empty($return)) { |
|
| 2190 | + return $return; |
|
| 2191 | + } |
|
| 2083 | 2192 | |
| 2084 | 2193 | $return[count($return) - 1]['is_last'] = true; |
| 2085 | 2194 | |
| 2086 | 2195 | // If mods want to do somthing with this list of posts, let them do that now. |
| 2087 | 2196 | call_integration_hook('integrate_ssi_boardNews', array(&$return)); |
| 2088 | 2197 | |
| 2089 | - if ($output_method != 'echo') |
|
| 2090 | - return $return; |
|
| 2198 | + if ($output_method != 'echo') { |
|
| 2199 | + return $return; |
|
| 2200 | + } |
|
| 2091 | 2201 | |
| 2092 | 2202 | foreach ($return as $news) |
| 2093 | 2203 | { |
@@ -2139,9 +2249,10 @@ discard block |
||
| 2139 | 2249 | echo ' |
| 2140 | 2250 | </div>'; |
| 2141 | 2251 | |
| 2142 | - if (!$news['is_last']) |
|
| 2143 | - echo ' |
|
| 2252 | + if (!$news['is_last']) { |
|
| 2253 | + echo ' |
|
| 2144 | 2254 | <hr>'; |
| 2255 | + } |
|
| 2145 | 2256 | } |
| 2146 | 2257 | } |
| 2147 | 2258 | |
@@ -2155,8 +2266,9 @@ discard block |
||
| 2155 | 2266 | { |
| 2156 | 2267 | global $user_info, $scripturl, $modSettings, $txt, $context, $smcFunc; |
| 2157 | 2268 | |
| 2158 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
| 2159 | - return; |
|
| 2269 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
| 2270 | + return; |
|
| 2271 | + } |
|
| 2160 | 2272 | |
| 2161 | 2273 | // Find all events which are happening in the near future that the member can see. |
| 2162 | 2274 | $request = $smcFunc['db_query']('', ' |
@@ -2182,20 +2294,23 @@ discard block |
||
| 2182 | 2294 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2183 | 2295 | { |
| 2184 | 2296 | // Check if we've already come by an event linked to this same topic with the same title... and don't display it if we have. |
| 2185 | - if (!empty($duplicates[$row['title'] . $row['id_topic']])) |
|
| 2186 | - continue; |
|
| 2297 | + if (!empty($duplicates[$row['title'] . $row['id_topic']])) { |
|
| 2298 | + continue; |
|
| 2299 | + } |
|
| 2187 | 2300 | |
| 2188 | 2301 | // Censor the title. |
| 2189 | 2302 | censorText($row['title']); |
| 2190 | 2303 | |
| 2191 | - if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) |
|
| 2192 | - $date = strftime('%Y-%m-%d', forum_time(false)); |
|
| 2193 | - else |
|
| 2194 | - $date = $row['start_date']; |
|
| 2304 | + if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) { |
|
| 2305 | + $date = strftime('%Y-%m-%d', forum_time(false)); |
|
| 2306 | + } else { |
|
| 2307 | + $date = $row['start_date']; |
|
| 2308 | + } |
|
| 2195 | 2309 | |
| 2196 | 2310 | // If the topic it is attached to is not approved then don't link it. |
| 2197 | - if (!empty($row['id_first_msg']) && !$row['approved']) |
|
| 2198 | - $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
| 2311 | + if (!empty($row['id_first_msg']) && !$row['approved']) { |
|
| 2312 | + $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
| 2313 | + } |
|
| 2199 | 2314 | |
| 2200 | 2315 | $allday = (empty($row['start_time']) || empty($row['end_time']) || empty($row['timezone']) || !in_array($row['timezone'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) ? true : false; |
| 2201 | 2316 | |
@@ -2221,24 +2336,27 @@ discard block |
||
| 2221 | 2336 | } |
| 2222 | 2337 | $smcFunc['db_free_result']($request); |
| 2223 | 2338 | |
| 2224 | - foreach ($return as $mday => $array) |
|
| 2225 | - $return[$mday][count($array) - 1]['is_last'] = true; |
|
| 2339 | + foreach ($return as $mday => $array) { |
|
| 2340 | + $return[$mday][count($array) - 1]['is_last'] = true; |
|
| 2341 | + } |
|
| 2226 | 2342 | |
| 2227 | 2343 | // If mods want to do somthing with this list of events, let them do that now. |
| 2228 | 2344 | call_integration_hook('integrate_ssi_recentEvents', array(&$return)); |
| 2229 | 2345 | |
| 2230 | - if ($output_method != 'echo' || empty($return)) |
|
| 2231 | - return $return; |
|
| 2346 | + if ($output_method != 'echo' || empty($return)) { |
|
| 2347 | + return $return; |
|
| 2348 | + } |
|
| 2232 | 2349 | |
| 2233 | 2350 | // Well the output method is echo. |
| 2234 | 2351 | echo ' |
| 2235 | 2352 | <span class="event">' . $txt['events'] . '</span> '; |
| 2236 | - foreach ($return as $mday => $array) |
|
| 2237 | - foreach ($array as $event) |
|
| 2353 | + foreach ($return as $mday => $array) { |
|
| 2354 | + foreach ($array as $event) |
|
| 2238 | 2355 | { |
| 2239 | 2356 | if ($event['can_edit']) |
| 2240 | 2357 | echo ' |
| 2241 | 2358 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
| 2359 | + } |
|
| 2242 | 2360 | |
| 2243 | 2361 | echo ' |
| 2244 | 2362 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
@@ -2257,8 +2375,9 @@ discard block |
||
| 2257 | 2375 | global $smcFunc; |
| 2258 | 2376 | |
| 2259 | 2377 | // If $id is null, this was most likely called from a query string and should do nothing. |
| 2260 | - if ($id === null) |
|
| 2261 | - return; |
|
| 2378 | + if ($id === null) { |
|
| 2379 | + return; |
|
| 2380 | + } |
|
| 2262 | 2381 | |
| 2263 | 2382 | $request = $smcFunc['db_query']('', ' |
| 2264 | 2383 | SELECT passwd, member_name, is_activated |
@@ -2290,8 +2409,9 @@ discard block |
||
| 2290 | 2409 | $attachments_boards = boardsAllowedTo('view_attachments'); |
| 2291 | 2410 | |
| 2292 | 2411 | // No boards? Adios amigo. |
| 2293 | - if (empty($attachments_boards)) |
|
| 2294 | - return array(); |
|
| 2412 | + if (empty($attachments_boards)) { |
|
| 2413 | + return array(); |
|
| 2414 | + } |
|
| 2295 | 2415 | |
| 2296 | 2416 | // Is it an array? |
| 2297 | 2417 | $attachment_ext = (array) $attachment_ext; |
@@ -2375,8 +2495,9 @@ discard block |
||
| 2375 | 2495 | call_integration_hook('integrate_ssi_recentAttachments', array(&$attachments)); |
| 2376 | 2496 | |
| 2377 | 2497 | // So you just want an array? Here you can have it. |
| 2378 | - if ($output_method == 'array' || empty($attachments)) |
|
| 2379 | - return $attachments; |
|
| 2498 | + if ($output_method == 'array' || empty($attachments)) { |
|
| 2499 | + return $attachments; |
|
| 2500 | + } |
|
| 2380 | 2501 | |
| 2381 | 2502 | // Give them the default. |
| 2382 | 2503 | echo ' |
@@ -2387,14 +2508,15 @@ discard block |
||
| 2387 | 2508 | <th style="text-align: left; padding: 2">', $txt['downloads'], '</th> |
| 2388 | 2509 | <th style="text-align: left; padding: 2">', $txt['filesize'], '</th> |
| 2389 | 2510 | </tr>'; |
| 2390 | - foreach ($attachments as $attach) |
|
| 2391 | - echo ' |
|
| 2511 | + foreach ($attachments as $attach) { |
|
| 2512 | + echo ' |
|
| 2392 | 2513 | <tr> |
| 2393 | 2514 | <td>', $attach['file']['link'], '</td> |
| 2394 | 2515 | <td>', $attach['member']['link'], '</td> |
| 2395 | 2516 | <td style="text-align: center">', $attach['file']['downloads'], '</td> |
| 2396 | 2517 | <td>', $attach['file']['filesize'], '</td> |
| 2397 | 2518 | </tr>'; |
| 2519 | + } |
|
| 2398 | 2520 | echo ' |
| 2399 | 2521 | </table>'; |
| 2400 | 2522 | } |
@@ -62,16 +62,17 @@ |
||
| 62 | 62 | <div id="error_box" class="errorbox"> |
| 63 | 63 | <ul id="error_list">'; |
| 64 | 64 | |
| 65 | - foreach ($context['post_errors'] as $key => $error) |
|
| 66 | - echo ' |
|
| 65 | + foreach ($context['post_errors'] as $key => $error) { |
|
| 66 | + echo ' |
|
| 67 | 67 | <li id="error_', $key, '" class="error">', $error, '</li>'; |
| 68 | + } |
|
| 68 | 69 | |
| 69 | 70 | echo ' |
| 70 | 71 | </ul>'; |
| 71 | - } |
|
| 72 | - else |
|
| 73 | - echo ' |
|
| 72 | + } else { |
|
| 73 | + echo ' |
|
| 74 | 74 | <div id="error_box" class="errorbox hidden">'; |
| 75 | + } |
|
| 75 | 76 | |
| 76 | 77 | echo ' |
| 77 | 78 | </div>'; |
@@ -30,25 +30,27 @@ discard block |
||
| 30 | 30 | </div> |
| 31 | 31 | <div class="information">'; |
| 32 | 32 | |
| 33 | - if ($context['is_installed']) |
|
| 34 | - echo ' |
|
| 33 | + if ($context['is_installed']) { |
|
| 34 | + echo ' |
|
| 35 | 35 | <strong>', $txt['package_installed_warning1'], '</strong><br> |
| 36 | 36 | <br> |
| 37 | 37 | ', $txt['package_installed_warning2'], '<br> |
| 38 | 38 | <br>'; |
| 39 | + } |
|
| 39 | 40 | |
| 40 | 41 | echo $txt['package_installed_warning3'], ' |
| 41 | 42 | </div> |
| 42 | 43 | <br>'; |
| 43 | 44 | |
| 44 | 45 | // Do errors exist in the install? If so light them up like a christmas tree. |
| 45 | - if ($context['has_failure']) |
|
| 46 | - echo ' |
|
| 46 | + if ($context['has_failure']) { |
|
| 47 | + echo ' |
|
| 47 | 48 | <div class="errorbox"> |
| 48 | 49 | ', sprintf($txt['package_will_fail_title'], $txt['package_' . ($context['uninstalling'] ? 'uninstall' : 'install')]), '<br> |
| 49 | 50 | ', sprintf($txt['package_will_fail_warning'], $txt['package_' . ($context['uninstalling'] ? 'uninstall' : 'install')]), |
| 50 | 51 | !empty($context['failure_details']) ? '<br><br><strong>' . $context['failure_details'] . '</strong>' : '', ' |
| 51 | 52 | </div>'; |
| 53 | + } |
|
| 52 | 54 | |
| 53 | 55 | // Display the package readme if one exists |
| 54 | 56 | if (isset($context['package_readme'])) |
@@ -62,9 +64,10 @@ discard block |
||
| 62 | 64 | <span class="floatright">', $txt['package_available_readme_language'], ' |
| 63 | 65 | <select name="readme_language" id="readme_language" onchange="if (this.options[this.selectedIndex].value) window.location.href = smf_prepareScriptUrl(smf_scripturl + \'', '?action=admin;area=packages;sa=', $context['uninstalling'] ? 'uninstall' : 'install', ';package=', $context['filename'], ';readme=\' + this.options[this.selectedIndex].value + \';license=\' + get_selected(\'license_language\'));">'; |
| 64 | 66 | |
| 65 | - foreach ($context['readmes'] as $a => $b) |
|
| 66 | - echo ' |
|
| 67 | + foreach ($context['readmes'] as $a => $b) { |
|
| 68 | + echo ' |
|
| 67 | 69 | <option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_readme_default'] : ucfirst($b), '</option>'; |
| 70 | + } |
|
| 68 | 71 | |
| 69 | 72 | echo ' |
| 70 | 73 | </select> |
@@ -85,9 +88,10 @@ discard block |
||
| 85 | 88 | <span class="floatright">', $txt['package_available_license_language'], ' |
| 86 | 89 | <select name="license_language" id="license_language" onchange="if (this.options[this.selectedIndex].value) window.location.href = smf_prepareScriptUrl(smf_scripturl + \'', '?action=admin;area=packages;sa=install', ';package=', $context['filename'], ';license=\' + this.options[this.selectedIndex].value + \';readme=\' + get_selected(\'readme_language\'));">'; |
| 87 | 90 | |
| 88 | - foreach ($context['licenses'] as $a => $b) |
|
| 89 | - echo ' |
|
| 91 | + foreach ($context['licenses'] as $a => $b) { |
|
| 92 | + echo ' |
|
| 90 | 93 | <option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_license_default'] : ucfirst($b), '</option>'; |
| 94 | + } |
|
| 91 | 95 | echo ' |
| 92 | 96 | </select> |
| 93 | 97 | </span> |
@@ -114,9 +118,10 @@ discard block |
||
| 114 | 118 | ', $txt['package_db_uninstall_actions'], ': |
| 115 | 119 | <ul>'; |
| 116 | 120 | |
| 117 | - foreach ($context['database_changes'] as $change) |
|
| 118 | - echo ' |
|
| 121 | + foreach ($context['database_changes'] as $change) { |
|
| 122 | + echo ' |
|
| 119 | 123 | <li>', $change, '</li>'; |
| 124 | + } |
|
| 120 | 125 | |
| 121 | 126 | echo ' |
| 122 | 127 | </ul> |
@@ -127,14 +132,14 @@ discard block |
||
| 127 | 132 | echo ' |
| 128 | 133 | <div class="information">'; |
| 129 | 134 | |
| 130 | - if (empty($context['actions']) && empty($context['database_changes'])) |
|
| 131 | - echo ' |
|
| 135 | + if (empty($context['actions']) && empty($context['database_changes'])) { |
|
| 136 | + echo ' |
|
| 132 | 137 | <br> |
| 133 | 138 | <div class="errorbox"> |
| 134 | 139 | ', $txt['corrupt_compatible'], ' |
| 135 | 140 | </div> |
| 136 | 141 | </div><!-- .information -->'; |
| 137 | - else |
|
| 142 | + } else |
|
| 138 | 143 | { |
| 139 | 144 | echo ' |
| 140 | 145 | ', $txt['perform_actions'], ' |
@@ -238,9 +243,10 @@ discard block |
||
| 238 | 243 | <td></td> |
| 239 | 244 | <td>'; |
| 240 | 245 | |
| 241 | - if (!empty($context['themes_locked'])) |
|
| 242 | - echo ' |
|
| 246 | + if (!empty($context['themes_locked'])) { |
|
| 247 | + echo ' |
|
| 243 | 248 | <input type="hidden" name="custom_theme[]" value="', $id, '">'; |
| 249 | + } |
|
| 244 | 250 | echo ' |
| 245 | 251 | <input type="checkbox" name="custom_theme[]" id="custom_theme_', $id, '" value="', $id, '" onclick="', (!empty($theme['has_failure']) ? 'if (this.form.custom_theme_' . $id . '.checked && !confirm(\'' . $txt['package_theme_failure_warning'] . '\')) return false;' : ''), 'invertAll(this, this.form, \'dummy_theme_', $id, '\', true);"', !empty($context['themes_locked']) ? ' disabled checked' : '', '> |
| 246 | 252 | </td> |
@@ -306,21 +312,23 @@ discard block |
||
| 306 | 312 | } |
| 307 | 313 | |
| 308 | 314 | // Are we effectively ready to install? |
| 309 | - if (!$context['ftp_needed'] && (!empty($context['actions']) || !empty($context['database_changes']))) |
|
| 310 | - echo ' |
|
| 315 | + if (!$context['ftp_needed'] && (!empty($context['actions']) || !empty($context['database_changes']))) { |
|
| 316 | + echo ' |
|
| 311 | 317 | <div class="righttext padding"> |
| 312 | 318 | <input type="submit" value="', $context['uninstalling'] ? $txt['package_uninstall_now'] : $txt['package_install_now'], '" onclick="return ', !empty($context['has_failure']) ? '(submitThisOnce(this) && confirm(\'' . ($context['uninstalling'] ? $txt['package_will_fail_popup_uninstall'] : $txt['package_will_fail_popup']) . '\'))' : 'submitThisOnce(this)', ';" class="button"> |
| 313 | 319 | </div>'; |
| 320 | + } |
|
| 314 | 321 | |
| 315 | 322 | // If we need ftp information then demand it! |
| 316 | - elseif ($context['ftp_needed']) |
|
| 317 | - echo ' |
|
| 323 | + elseif ($context['ftp_needed']) { |
|
| 324 | + echo ' |
|
| 318 | 325 | <div class="cat_bar"> |
| 319 | 326 | <h3 class="catbg">', $txt['package_ftp_necessary'], '</h3> |
| 320 | 327 | </div> |
| 321 | 328 | <div> |
| 322 | 329 | ', template_control_chmod(), ' |
| 323 | 330 | </div>'; |
| 331 | + } |
|
| 324 | 332 | |
| 325 | 333 | echo ' |
| 326 | 334 | |
@@ -336,8 +344,8 @@ discard block |
||
| 336 | 344 | // Operations. |
| 337 | 345 | if (!empty($js_operations)) |
| 338 | 346 | { |
| 339 | - foreach ($js_operations as $key => $operation) |
|
| 340 | - echo ' |
|
| 347 | + foreach ($js_operations as $key => $operation) { |
|
| 348 | + echo ' |
|
| 341 | 349 | aOperationElements[', $key, '] = new smc_Toggle({ |
| 342 | 350 | bToggleEnabled: true, |
| 343 | 351 | bNoAnimate: true, |
@@ -355,6 +363,7 @@ discard block |
||
| 355 | 363 | } |
| 356 | 364 | ] |
| 357 | 365 | });'; |
| 366 | + } |
|
| 358 | 367 | } |
| 359 | 368 | |
| 360 | 369 | echo ' |
@@ -376,14 +385,15 @@ discard block |
||
| 376 | 385 | </script>'; |
| 377 | 386 | |
| 378 | 387 | // And a bit more for database changes. |
| 379 | - if (!empty($context['database_changes'])) |
|
| 380 | - echo ' |
|
| 388 | + if (!empty($context['database_changes'])) { |
|
| 389 | + echo ' |
|
| 381 | 390 | <script> |
| 382 | 391 | var database_changes_area = document.getElementById(\'db_changes_div\'); |
| 383 | 392 | var db_vis = false; |
| 384 | 393 | database_changes_area.classList.add(\'hidden\'); |
| 385 | 394 | </script>'; |
| 386 | -} |
|
| 395 | + } |
|
| 396 | + } |
|
| 387 | 397 | |
| 388 | 398 | /** |
| 389 | 399 | * Extract package contents |
@@ -392,8 +402,8 @@ discard block |
||
| 392 | 402 | { |
| 393 | 403 | global $context, $txt, $scripturl; |
| 394 | 404 | |
| 395 | - if (!empty($context['redirect_url'])) |
|
| 396 | - echo ' |
|
| 405 | + if (!empty($context['redirect_url'])) { |
|
| 406 | + echo ' |
|
| 397 | 407 | <script> |
| 398 | 408 | setTimeout("doRedirect();", ', empty($context['redirect_timeout']) ? '5000' : $context['redirect_timeout'], '); |
| 399 | 409 | |
@@ -402,49 +412,48 @@ discard block |
||
| 402 | 412 | window.location = "', $context['redirect_url'], '"; |
| 403 | 413 | } |
| 404 | 414 | </script>'; |
| 415 | + } |
|
| 405 | 416 | |
| 406 | - if (empty($context['redirect_url'])) |
|
| 407 | - echo ' |
|
| 417 | + if (empty($context['redirect_url'])) { |
|
| 418 | + echo ' |
|
| 408 | 419 | <div class="cat_bar"> |
| 409 | 420 | <h3 class="catbg">', $context['uninstalling'] ? $txt['uninstall'] : $txt['extracting'], '</h3> |
| 410 | 421 | </div> |
| 411 | 422 | <div class="information">', $txt['package_installed_extract'], '</div>'; |
| 412 | - else |
|
| 413 | - echo ' |
|
| 423 | + } else { |
|
| 424 | + echo ' |
|
| 414 | 425 | <div class="cat_bar"> |
| 415 | 426 | <h3 class="catbg">', $txt['package_installed_redirecting'], '</h3> |
| 416 | 427 | </div>'; |
| 428 | + } |
|
| 417 | 429 | |
| 418 | 430 | echo ' |
| 419 | 431 | <div class="windowbg">'; |
| 420 | 432 | |
| 421 | 433 | // If we are going to redirect we have a slightly different agenda. |
| 422 | - if (!empty($context['redirect_url'])) |
|
| 423 | - echo ' |
|
| 434 | + if (!empty($context['redirect_url'])) { |
|
| 435 | + echo ' |
|
| 424 | 436 | ', $context['redirect_text'], '<br><br> |
| 425 | 437 | <a href="', $context['redirect_url'], '">', $txt['package_installed_redirect_go_now'], '</a> | <a href="', $scripturl, '?action=admin;area=packages;sa=browse">', $txt['package_installed_redirect_cancel'], '</a>'; |
| 426 | - |
|
| 427 | - elseif ($context['uninstalling']) |
|
| 428 | - echo ' |
|
| 438 | + } elseif ($context['uninstalling']) { |
|
| 439 | + echo ' |
|
| 429 | 440 | ', $txt['package_uninstall_done']; |
| 430 | - |
|
| 431 | - elseif ($context['install_finished']) |
|
| 441 | + } elseif ($context['install_finished']) |
|
| 432 | 442 | { |
| 433 | - if ($context['extract_type'] == 'avatar') |
|
| 434 | - echo ' |
|
| 443 | + if ($context['extract_type'] == 'avatar') { |
|
| 444 | + echo ' |
|
| 435 | 445 | ', $txt['avatars_extracted']; |
| 436 | - |
|
| 437 | - elseif ($context['extract_type'] == 'language') |
|
| 438 | - echo ' |
|
| 446 | + } elseif ($context['extract_type'] == 'language') { |
|
| 447 | + echo ' |
|
| 439 | 448 | ', $txt['language_extracted']; |
| 440 | - |
|
| 441 | - else |
|
| 442 | - echo ' |
|
| 449 | + } else { |
|
| 450 | + echo ' |
|
| 443 | 451 | ', $txt['package_installed_done']; |
| 444 | - } |
|
| 445 | - else |
|
| 446 | - echo ' |
|
| 452 | + } |
|
| 453 | + } else { |
|
| 454 | + echo ' |
|
| 447 | 455 | ', $txt['corrupt_compatible']; |
| 456 | + } |
|
| 448 | 457 | |
| 449 | 458 | echo ' |
| 450 | 459 | </div><!-- .windowbg -->'; |
@@ -474,9 +483,10 @@ discard block |
||
| 474 | 483 | <div class="windowbg"> |
| 475 | 484 | <ol>'; |
| 476 | 485 | |
| 477 | - foreach ($context['files'] as $fileinfo) |
|
| 478 | - echo ' |
|
| 486 | + foreach ($context['files'] as $fileinfo) { |
|
| 487 | + echo ' |
|
| 479 | 488 | <li><a href="', $scripturl, '?action=admin;area=packages;sa=examine;package=', $context['filename'], ';file=', $fileinfo['filename'], '" title="', $txt['view'], '">', $fileinfo['filename'], '</a> (', $fileinfo['size'], ' ', $txt['package_bytes'], ')</li>'; |
| 489 | + } |
|
| 480 | 490 | |
| 481 | 491 | echo ' |
| 482 | 492 | </ol> |
@@ -536,9 +546,10 @@ discard block |
||
| 536 | 546 | </script> |
| 537 | 547 | <div id="yourVersion" style="display:none">', $context['forum_version'], '</div>'; |
| 538 | 548 | |
| 539 | - if (empty($modSettings['disable_smf_js'])) |
|
| 540 | - echo ' |
|
| 549 | + if (empty($modSettings['disable_smf_js'])) { |
|
| 550 | + echo ' |
|
| 541 | 551 | <script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>'; |
| 552 | + } |
|
| 542 | 553 | |
| 543 | 554 | // This sets the announcements and current versions themselves ;). |
| 544 | 555 | echo ' |
@@ -576,12 +587,13 @@ discard block |
||
| 576 | 587 | } |
| 577 | 588 | } |
| 578 | 589 | |
| 579 | - if (!$mods_available) |
|
| 580 | - echo ' |
|
| 590 | + if (!$mods_available) { |
|
| 591 | + echo ' |
|
| 581 | 592 | <div class="noticebox">', $txt['no_packages'], '</div>'; |
| 582 | - else |
|
| 583 | - echo ' |
|
| 593 | + } else { |
|
| 594 | + echo ' |
|
| 584 | 595 | <br>'; |
| 596 | + } |
|
| 585 | 597 | |
| 586 | 598 | // The advanced (emulation) box, collapsed by default |
| 587 | 599 | echo ' |
@@ -608,9 +620,10 @@ discard block |
||
| 608 | 620 | <a id="revert" name="revert"></a> |
| 609 | 621 | <select name="version_emulate" id="ve">'; |
| 610 | 622 | |
| 611 | - foreach ($context['emulation_versions'] as $version) |
|
| 612 | - echo ' |
|
| 623 | + foreach ($context['emulation_versions'] as $version) { |
|
| 624 | + echo ' |
|
| 613 | 625 | <option value="', $version, '"', ($version == $context['selected_version'] ? ' selected="selected"' : ''), '>', $version, '</option>'; |
| 626 | + } |
|
| 614 | 627 | |
| 615 | 628 | echo ' |
| 616 | 629 | </select> |
@@ -665,11 +678,12 @@ discard block |
||
| 665 | 678 | { |
| 666 | 679 | global $context, $txt, $scripturl; |
| 667 | 680 | |
| 668 | - if (!empty($context['package_ftp']['error'])) |
|
| 669 | - echo ' |
|
| 681 | + if (!empty($context['package_ftp']['error'])) { |
|
| 682 | + echo ' |
|
| 670 | 683 | <div class="errorbox"> |
| 671 | 684 | <pre>', $context['package_ftp']['error'], '</pre> |
| 672 | 685 | </div>'; |
| 686 | + } |
|
| 673 | 687 | |
| 674 | 688 | echo ' |
| 675 | 689 | <div id="admin_form_wrapper"> |
@@ -752,13 +766,14 @@ discard block |
||
| 752 | 766 | <legend>' . $txt['package_servers'] . '</legend> |
| 753 | 767 | <ul class="package_servers">'; |
| 754 | 768 | |
| 755 | - foreach ($context['servers'] as $server) |
|
| 756 | - echo ' |
|
| 769 | + foreach ($context['servers'] as $server) { |
|
| 770 | + echo ' |
|
| 757 | 771 | <li class="flow_auto"> |
| 758 | 772 | <span class="floatleft">' . $server['name'] . '</span> |
| 759 | 773 | <span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=remove;server=' . $server['id'] . ';', $context['session_var'], '=', $context['session_id'], '">[ ' . $txt['delete'] . ' ]</a></span> |
| 760 | 774 | <span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=browse;server=' . $server['id'] . '">[ ' . $txt['package_browse'] . ' ]</a></span> |
| 761 | 775 | </li>'; |
| 776 | + } |
|
| 762 | 777 | echo ' |
| 763 | 778 | </ul> |
| 764 | 779 | </fieldset> |
@@ -842,11 +857,12 @@ discard block |
||
| 842 | 857 | <div class="windowbg">'; |
| 843 | 858 | |
| 844 | 859 | // No packages, as yet. |
| 845 | - if (empty($context['package_list'])) |
|
| 846 | - echo ' |
|
| 860 | + if (empty($context['package_list'])) { |
|
| 861 | + echo ' |
|
| 847 | 862 | <ul> |
| 848 | 863 | <li>', $txt['no_packages'], '</li> |
| 849 | 864 | </ul>'; |
| 865 | + } |
|
| 850 | 866 | |
| 851 | 867 | // List out the packages... |
| 852 | 868 | else |
@@ -860,11 +876,12 @@ discard block |
||
| 860 | 876 | <li> |
| 861 | 877 | <strong><span id="ps_img_', $i, '" class="toggle_up" alt="*" style="display: none;"></span> ', $packageSection['title'], '</strong>'; |
| 862 | 878 | |
| 863 | - if (!empty($packageSection['text'])) |
|
| 864 | - echo ' |
|
| 879 | + if (!empty($packageSection['text'])) { |
|
| 880 | + echo ' |
|
| 865 | 881 | <div class="sub_bar"> |
| 866 | 882 | <h3 class="subbg">', $packageSection['text'], '</h3> |
| 867 | 883 | </div>'; |
| 884 | + } |
|
| 868 | 885 | |
| 869 | 886 | echo ' |
| 870 | 887 | <', $context['list_type'], ' id="package_section_', $i, '" class="packages">'; |
@@ -875,24 +892,28 @@ discard block |
||
| 875 | 892 | <li>'; |
| 876 | 893 | |
| 877 | 894 | // Textual message. Could be empty just for a blank line... |
| 878 | - if ($package['is_text']) |
|
| 879 | - echo ' |
|
| 895 | + if ($package['is_text']) { |
|
| 896 | + echo ' |
|
| 880 | 897 | ', empty($package['name']) ? ' ' : $package['name']; |
| 898 | + } |
|
| 881 | 899 | |
| 882 | 900 | // This is supposed to be a rule.. |
| 883 | - elseif ($package['is_line']) |
|
| 884 | - echo ' |
|
| 901 | + elseif ($package['is_line']) { |
|
| 902 | + echo ' |
|
| 885 | 903 | <hr>'; |
| 904 | + } |
|
| 886 | 905 | |
| 887 | 906 | // A remote link. |
| 888 | - elseif ($package['is_remote']) |
|
| 889 | - echo ' |
|
| 907 | + elseif ($package['is_remote']) { |
|
| 908 | + echo ' |
|
| 890 | 909 | <strong>', $package['link'], '</strong>'; |
| 910 | + } |
|
| 891 | 911 | |
| 892 | 912 | // A title? |
| 893 | - elseif ($package['is_heading'] || $package['is_title']) |
|
| 894 | - echo ' |
|
| 913 | + elseif ($package['is_heading'] || $package['is_title']) { |
|
| 914 | + echo ' |
|
| 895 | 915 | <strong>', $package['name'], '</strong>'; |
| 916 | + } |
|
| 896 | 917 | |
| 897 | 918 | // Otherwise, it's a package. |
| 898 | 919 | else |
@@ -903,32 +924,36 @@ discard block |
||
| 903 | 924 | <ul id="package_section_', $i, '_pkg_', $id, '" class="package_section">'; |
| 904 | 925 | |
| 905 | 926 | // Show the mod type? |
| 906 | - if ($package['type'] != '') |
|
| 907 | - echo ' |
|
| 927 | + if ($package['type'] != '') { |
|
| 928 | + echo ' |
|
| 908 | 929 | <li class="package_section"> |
| 909 | 930 | ', $txt['package_type'], ': ', $smcFunc['ucwords']($smcFunc['strtolower']($package['type'])), ' |
| 910 | 931 | </li>'; |
| 932 | + } |
|
| 911 | 933 | |
| 912 | 934 | // Show the version number? |
| 913 | - if ($package['version'] != '') |
|
| 914 | - echo ' |
|
| 935 | + if ($package['version'] != '') { |
|
| 936 | + echo ' |
|
| 915 | 937 | <li class="package_section"> |
| 916 | 938 | ', $txt['mod_version'], ': ', $package['version'], ' |
| 917 | 939 | </li>'; |
| 940 | + } |
|
| 918 | 941 | |
| 919 | 942 | // How 'bout the author? |
| 920 | - if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link'])) |
|
| 921 | - echo ' |
|
| 943 | + if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link'])) { |
|
| 944 | + echo ' |
|
| 922 | 945 | <li class="package_section"> |
| 923 | 946 | ', $txt['mod_author'], ': ', $package['author']['link'], ' |
| 924 | 947 | </li>'; |
| 948 | + } |
|
| 925 | 949 | |
| 926 | 950 | // The homepage... |
| 927 | - if ($package['author']['website']['link'] != '') |
|
| 928 | - echo ' |
|
| 951 | + if ($package['author']['website']['link'] != '') { |
|
| 952 | + echo ' |
|
| 929 | 953 | <li class="package_section"> |
| 930 | 954 | ', $txt['author_website'], ': ', $package['author']['website']['link'], ' |
| 931 | 955 | </li>'; |
| 956 | + } |
|
| 932 | 957 | |
| 933 | 958 | // Description: bleh bleh! |
| 934 | 959 | // Location of file: http://someplace/. |
@@ -986,8 +1011,8 @@ discard block |
||
| 986 | 1011 | |
| 987 | 1012 | foreach ($ps['items'] as $id => $package) |
| 988 | 1013 | { |
| 989 | - if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote']) |
|
| 990 | - echo ' |
|
| 1014 | + if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote']) { |
|
| 1015 | + echo ' |
|
| 991 | 1016 | var oPackageToggle_', $section, '_pkg_', $id, ' = new smc_Toggle({ |
| 992 | 1017 | bToggleEnabled: true, |
| 993 | 1018 | bCurrentlyCollapsed: true, |
@@ -1002,6 +1027,7 @@ discard block |
||
| 1002 | 1027 | } |
| 1003 | 1028 | ] |
| 1004 | 1029 | });'; |
| 1030 | + } |
|
| 1005 | 1031 | } |
| 1006 | 1032 | } |
| 1007 | 1033 | |
@@ -1044,9 +1070,10 @@ discard block |
||
| 1044 | 1070 | { |
| 1045 | 1071 | global $context, $txt, $scripturl; |
| 1046 | 1072 | |
| 1047 | - if (!empty($context['saved_successful'])) |
|
| 1048 | - echo ' |
|
| 1073 | + if (!empty($context['saved_successful'])) { |
|
| 1074 | + echo ' |
|
| 1049 | 1075 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
| 1076 | + } |
|
| 1050 | 1077 | |
| 1051 | 1078 | echo ' |
| 1052 | 1079 | <div class="cat_bar"> |
@@ -1106,8 +1133,9 @@ discard block |
||
| 1106 | 1133 | global $context, $txt; |
| 1107 | 1134 | |
| 1108 | 1135 | // Nothing to do? Brilliant! |
| 1109 | - if (empty($context['package_ftp'])) |
|
| 1110 | - return false; |
|
| 1136 | + if (empty($context['package_ftp'])) { |
|
| 1137 | + return false; |
|
| 1138 | + } |
|
| 1111 | 1139 | |
| 1112 | 1140 | if (empty($context['package_ftp']['form_elements_only'])) |
| 1113 | 1141 | { |
@@ -1117,19 +1145,21 @@ discard block |
||
| 1117 | 1145 | ', $txt['package_ftp_why_file_list'], ' |
| 1118 | 1146 | <ul style="display: inline;">'; |
| 1119 | 1147 | |
| 1120 | - if (!empty($context['notwritable_files'])) |
|
| 1121 | - foreach ($context['notwritable_files'] as $file) |
|
| 1148 | + if (!empty($context['notwritable_files'])) { |
|
| 1149 | + foreach ($context['notwritable_files'] as $file) |
|
| 1122 | 1150 | echo ' |
| 1123 | 1151 | <li>', $file, '</li>'; |
| 1152 | + } |
|
| 1124 | 1153 | |
| 1125 | 1154 | echo ' |
| 1126 | 1155 | </ul>'; |
| 1127 | 1156 | |
| 1128 | - if (!$context['server']['is_windows']) |
|
| 1129 | - echo ' |
|
| 1157 | + if (!$context['server']['is_windows']) { |
|
| 1158 | + echo ' |
|
| 1130 | 1159 | <hr> |
| 1131 | 1160 | ', $txt['package_chmod_linux'], '<br> |
| 1132 | 1161 | <samp># chmod a+w ', implode(' ', $context['notwritable_files']), '</samp>'; |
| 1162 | + } |
|
| 1133 | 1163 | |
| 1134 | 1164 | echo ' |
| 1135 | 1165 | </div><!-- #need_writable_list -->'; |
@@ -1142,9 +1172,10 @@ discard block |
||
| 1142 | 1172 | </div> |
| 1143 | 1173 | </div>'; |
| 1144 | 1174 | |
| 1145 | - if (!empty($context['package_ftp']['destination'])) |
|
| 1146 | - echo ' |
|
| 1175 | + if (!empty($context['package_ftp']['destination'])) { |
|
| 1176 | + echo ' |
|
| 1147 | 1177 | <form action="', $context['package_ftp']['destination'], '" method="post" accept-charset="', $context['character_set'], '">'; |
| 1178 | + } |
|
| 1148 | 1179 | |
| 1149 | 1180 | echo ' |
| 1150 | 1181 | <fieldset> |
@@ -1178,24 +1209,27 @@ discard block |
||
| 1178 | 1209 | </dl> |
| 1179 | 1210 | </fieldset>'; |
| 1180 | 1211 | |
| 1181 | - if (empty($context['package_ftp']['form_elements_only'])) |
|
| 1182 | - echo ' |
|
| 1212 | + if (empty($context['package_ftp']['form_elements_only'])) { |
|
| 1213 | + echo ' |
|
| 1183 | 1214 | <div class="righttext" style="margin: 1ex;"> |
| 1184 | 1215 | <span id="test_ftp_placeholder_full"></span> |
| 1185 | 1216 | <input type="submit" value="', $txt['package_proceed'], '" class="button"> |
| 1186 | 1217 | </div>'; |
| 1218 | + } |
|
| 1187 | 1219 | |
| 1188 | - if (!empty($context['package_ftp']['destination'])) |
|
| 1189 | - echo ' |
|
| 1220 | + if (!empty($context['package_ftp']['destination'])) { |
|
| 1221 | + echo ' |
|
| 1190 | 1222 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 1191 | 1223 | </form>'; |
| 1224 | + } |
|
| 1192 | 1225 | |
| 1193 | 1226 | // Hide the details of the list. |
| 1194 | - if (empty($context['package_ftp']['form_elements_only'])) |
|
| 1195 | - echo ' |
|
| 1227 | + if (empty($context['package_ftp']['form_elements_only'])) { |
|
| 1228 | + echo ' |
|
| 1196 | 1229 | <script> |
| 1197 | 1230 | document.getElementById(\'need_writable_list\').style.display = \'none\'; |
| 1198 | 1231 | </script>'; |
| 1232 | + } |
|
| 1199 | 1233 | |
| 1200 | 1234 | // Quick generate the test button. |
| 1201 | 1235 | echo ' |
@@ -1552,9 +1586,10 @@ discard block |
||
| 1552 | 1586 | <td width="30%"> |
| 1553 | 1587 | <strong>'; |
| 1554 | 1588 | |
| 1555 | - if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) |
|
| 1556 | - echo ' |
|
| 1589 | + if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) { |
|
| 1590 | + echo ' |
|
| 1557 | 1591 | <span class="generic_icons folder"></span>'; |
| 1592 | + } |
|
| 1558 | 1593 | |
| 1559 | 1594 | echo ' |
| 1560 | 1595 | ', $name, ' |
@@ -1581,8 +1616,9 @@ discard block |
||
| 1581 | 1616 | </td> |
| 1582 | 1617 | </tr>'; |
| 1583 | 1618 | |
| 1584 | - if (!empty($dir['contents'])) |
|
| 1585 | - template_permission_show_contents($name, $dir['contents'], 1); |
|
| 1619 | + if (!empty($dir['contents'])) { |
|
| 1620 | + template_permission_show_contents($name, $dir['contents'], 1); |
|
| 1621 | + } |
|
| 1586 | 1622 | } |
| 1587 | 1623 | |
| 1588 | 1624 | echo ' |
@@ -1618,13 +1654,14 @@ discard block |
||
| 1618 | 1654 | </fieldset>'; |
| 1619 | 1655 | |
| 1620 | 1656 | // Likely to need FTP? |
| 1621 | - if (empty($context['ftp_connected'])) |
|
| 1622 | - echo ' |
|
| 1657 | + if (empty($context['ftp_connected'])) { |
|
| 1658 | + echo ' |
|
| 1623 | 1659 | <p> |
| 1624 | 1660 | ', $txt['package_file_perms_ftp_details'], ': |
| 1625 | 1661 | </p> |
| 1626 | 1662 | ', template_control_chmod(), ' |
| 1627 | 1663 | <div class="noticebox">', $txt['package_file_perms_ftp_retain'], '</div>'; |
| 1664 | + } |
|
| 1628 | 1665 | |
| 1629 | 1666 | echo ' |
| 1630 | 1667 | <span id="test_ftp_placeholder_full"></span> |
@@ -1633,9 +1670,10 @@ discard block |
||
| 1633 | 1670 | </div><!-- .windowbg -->'; |
| 1634 | 1671 | |
| 1635 | 1672 | // Any looks fors we've already done? |
| 1636 | - foreach ($context['look_for'] as $path) |
|
| 1637 | - echo ' |
|
| 1673 | + foreach ($context['look_for'] as $path) { |
|
| 1674 | + echo ' |
|
| 1638 | 1675 | <input type="hidden" name="back_look[]" value="', $path, '">'; |
| 1676 | + } |
|
| 1639 | 1677 | |
| 1640 | 1678 | echo ' |
| 1641 | 1679 | </form> |
@@ -1677,9 +1715,10 @@ discard block |
||
| 1677 | 1715 | <td class="smalltext" width="30%">' . str_repeat(' ', $level * 5), ' |
| 1678 | 1716 | ', (!empty($dir['type']) && $dir['type'] == 'dir_recursive') || !empty($dir['list_contents']) ? '<a id="link_' . $cur_ident . '" href="' . $scripturl . '?action=admin;area=packages;sa=perms;find=' . base64_encode($ident . '/' . $name) . ';back_look=' . $context['back_look_data'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '#fol_' . $cur_ident . '" onclick="return expandFolder(\'' . $cur_ident . '\', \'' . addcslashes($ident . '/' . $name, "'\\") . '\');">' : ''; |
| 1679 | 1717 | |
| 1680 | - if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) |
|
| 1681 | - echo ' |
|
| 1718 | + if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) { |
|
| 1719 | + echo ' |
|
| 1682 | 1720 | <span class="generic_icons folder"></span>'; |
| 1721 | + } |
|
| 1683 | 1722 | |
| 1684 | 1723 | echo ' |
| 1685 | 1724 | ', $name, ' |
@@ -1697,34 +1736,38 @@ discard block |
||
| 1697 | 1736 | </tr> |
| 1698 | 1737 | <tr id="insert_div_loc_' . $cur_ident . '" style="display: none;"><td></td></tr>'; |
| 1699 | 1738 | |
| 1700 | - if (!empty($dir['contents'])) |
|
| 1701 | - template_permission_show_contents($ident . '/' . $name, $dir['contents'], $level + 1, !empty($dir['more_files'])); |
|
| 1739 | + if (!empty($dir['contents'])) { |
|
| 1740 | + template_permission_show_contents($ident . '/' . $name, $dir['contents'], $level + 1, !empty($dir['more_files'])); |
|
| 1741 | + } |
|
| 1702 | 1742 | } |
| 1703 | 1743 | } |
| 1704 | 1744 | |
| 1705 | 1745 | // We have more files to show? |
| 1706 | - if ($has_more) |
|
| 1707 | - echo ' |
|
| 1746 | + if ($has_more) { |
|
| 1747 | + echo ' |
|
| 1708 | 1748 | <tr class="windowbg" id="content_', $js_ident, '_more"> |
| 1709 | 1749 | <td class="smalltext" width="40%">' . str_repeat(' ', $level * 5), ' |
| 1710 | 1750 | « <a href="' . $scripturl . '?action=admin;area=packages;sa=perms;find=' . base64_encode($ident) . ';fileoffset=', ($context['file_offset'] + $context['file_limit']), ';' . $context['session_var'] . '=' . $context['session_id'] . '#fol_' . preg_replace('~[^A-Za-z0-9_\-=:]~', ':-:', $ident) . '">', $txt['package_file_perms_more_files'], '</a> » |
| 1711 | 1751 | </td> |
| 1712 | 1752 | <td colspan="6"></td> |
| 1713 | 1753 | </tr>'; |
| 1754 | + } |
|
| 1714 | 1755 | |
| 1715 | 1756 | if ($drawn_div) |
| 1716 | 1757 | { |
| 1717 | 1758 | // Hide anything too far down the tree. |
| 1718 | 1759 | $isFound = false; |
| 1719 | - foreach ($context['look_for'] as $tree) |
|
| 1720 | - if (substr($tree, 0, strlen($ident)) == $ident) |
|
| 1760 | + foreach ($context['look_for'] as $tree) { |
|
| 1761 | + if (substr($tree, 0, strlen($ident)) == $ident) |
|
| 1721 | 1762 | $isFound = true; |
| 1763 | + } |
|
| 1722 | 1764 | |
| 1723 | - if ($level > 1 && !$isFound) |
|
| 1724 | - echo ' |
|
| 1765 | + if ($level > 1 && !$isFound) { |
|
| 1766 | + echo ' |
|
| 1725 | 1767 | <script> |
| 1726 | 1768 | expandFolder(\'', $js_ident, '\', \'\'); |
| 1727 | 1769 | </script>'; |
| 1770 | + } |
|
| 1728 | 1771 | } |
| 1729 | 1772 | } |
| 1730 | 1773 | |
@@ -1743,11 +1786,12 @@ discard block |
||
| 1743 | 1786 | <h3 class="catbg">', $txt['package_file_perms_applying'], '</h3> |
| 1744 | 1787 | </div>'; |
| 1745 | 1788 | |
| 1746 | - if (!empty($context['skip_ftp'])) |
|
| 1747 | - echo ' |
|
| 1789 | + if (!empty($context['skip_ftp'])) { |
|
| 1790 | + echo ' |
|
| 1748 | 1791 | <div class="errorbox"> |
| 1749 | 1792 | ', $txt['package_file_perms_skipping_ftp'], ' |
| 1750 | 1793 | </div>'; |
| 1794 | + } |
|
| 1751 | 1795 | |
| 1752 | 1796 | // How many have we done? |
| 1753 | 1797 | $remaining_items = count($context['method'] == 'individual' ? $context['to_process'] : $context['directory_list']); |
@@ -1785,28 +1829,31 @@ discard block |
||
| 1785 | 1829 | <br>'; |
| 1786 | 1830 | |
| 1787 | 1831 | // Put out the right hidden data. |
| 1788 | - if ($context['method'] == 'individual') |
|
| 1789 | - echo ' |
|
| 1832 | + if ($context['method'] == 'individual') { |
|
| 1833 | + echo ' |
|
| 1790 | 1834 | <input type="hidden" name="custom_value" value="', $context['custom_value'], '"> |
| 1791 | 1835 | <input type="hidden" name="totalItems" value="', $context['total_items'], '"> |
| 1792 | 1836 | <input type="hidden" name="toProcess" value="', $context['to_process_encode'], '">'; |
| 1793 | - else |
|
| 1794 | - echo ' |
|
| 1837 | + } else { |
|
| 1838 | + echo ' |
|
| 1795 | 1839 | <input type="hidden" name="predefined" value="', $context['predefined_type'], '"> |
| 1796 | 1840 | <input type="hidden" name="fileOffset" value="', $context['file_offset'], '"> |
| 1797 | 1841 | <input type="hidden" name="totalItems" value="', $context['total_items'], '"> |
| 1798 | 1842 | <input type="hidden" name="dirList" value="', $context['directory_list_encode'], '"> |
| 1799 | 1843 | <input type="hidden" name="specialFiles" value="', $context['special_files_encode'], '">'; |
| 1844 | + } |
|
| 1800 | 1845 | |
| 1801 | 1846 | // Are we not using FTP for whatever reason. |
| 1802 | - if (!empty($context['skip_ftp'])) |
|
| 1803 | - echo ' |
|
| 1847 | + if (!empty($context['skip_ftp'])) { |
|
| 1848 | + echo ' |
|
| 1804 | 1849 | <input type="hidden" name="skip_ftp" value="1">'; |
| 1850 | + } |
|
| 1805 | 1851 | |
| 1806 | 1852 | // Retain state. |
| 1807 | - foreach ($context['back_look_data'] as $path) |
|
| 1808 | - echo ' |
|
| 1853 | + foreach ($context['back_look_data'] as $path) { |
|
| 1854 | + echo ' |
|
| 1809 | 1855 | <input type="hidden" name="back_look[]" value="', $path, '">'; |
| 1856 | + } |
|
| 1810 | 1857 | |
| 1811 | 1858 | echo ' |
| 1812 | 1859 | <input type="hidden" name="method" value="', $context['method'], '"> |