@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * @version 2.1 Beta 3 |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -if (!defined('SMF')) |
|
| 18 | +if (!defined('SMF')) { |
|
| 19 | 19 | die('No direct access...'); |
| 20 | +} |
|
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * This helps organize things... |
@@ -37,13 +38,14 @@ discard block |
||
| 37 | 38 | |
| 38 | 39 | loadLanguage('PersonalMessage+Drafts'); |
| 39 | 40 | |
| 40 | - if (!isset($_REQUEST['xml'])) |
|
| 41 | - loadTemplate('PersonalMessage'); |
|
| 41 | + if (!isset($_REQUEST['xml'])) { |
|
| 42 | + loadTemplate('PersonalMessage'); |
|
| 43 | + } |
|
| 42 | 44 | |
| 43 | 45 | // Load up the members maximum message capacity. |
| 44 | - if ($user_info['is_admin']) |
|
| 45 | - $context['message_limit'] = 0; |
|
| 46 | - elseif (($context['message_limit'] = cache_get_data('msgLimit:' . $user_info['id'], 360)) === null) |
|
| 46 | + if ($user_info['is_admin']) { |
|
| 47 | + $context['message_limit'] = 0; |
|
| 48 | + } elseif (($context['message_limit'] = cache_get_data('msgLimit:' . $user_info['id'], 360)) === null) |
|
| 47 | 49 | { |
| 48 | 50 | // @todo Why do we do this? It seems like if they have any limit we should use it. |
| 49 | 51 | $request = $smcFunc['db_query']('', ' |
@@ -78,8 +80,9 @@ discard block |
||
| 78 | 80 | } |
| 79 | 81 | |
| 80 | 82 | // a previous message was sent successfully? show a small indication. |
| 81 | - if (isset($_GET['done']) && ($_GET['done'] == 'sent')) |
|
| 82 | - $context['pm_sent'] = true; |
|
| 83 | + if (isset($_GET['done']) && ($_GET['done'] == 'sent')) { |
|
| 84 | + $context['pm_sent'] = true; |
|
| 85 | + } |
|
| 83 | 86 | |
| 84 | 87 | $context['labels'] = array(); |
| 85 | 88 | |
@@ -210,11 +213,11 @@ discard block |
||
| 210 | 213 | { |
| 211 | 214 | $_REQUEST['sa'] = ''; |
| 212 | 215 | MessageFolder(); |
| 213 | - } |
|
| 214 | - else |
|
| 216 | + } else |
|
| 215 | 217 | { |
| 216 | - if (!isset($_REQUEST['xml']) && $_REQUEST['sa'] != 'popup') |
|
| 217 | - messageIndexBar($_REQUEST['sa']); |
|
| 218 | + if (!isset($_REQUEST['xml']) && $_REQUEST['sa'] != 'popup') { |
|
| 219 | + messageIndexBar($_REQUEST['sa']); |
|
| 220 | + } |
|
| 218 | 221 | |
| 219 | 222 | call_helper($subActions[$_REQUEST['sa']]); |
| 220 | 223 | } |
@@ -291,16 +294,17 @@ discard block |
||
| 291 | 294 | ); |
| 292 | 295 | |
| 293 | 296 | // Handle labels. |
| 294 | - if (empty($context['currently_using_labels'])) |
|
| 295 | - unset($pm_areas['labels']); |
|
| 296 | - else |
|
| 297 | + if (empty($context['currently_using_labels'])) { |
|
| 298 | + unset($pm_areas['labels']); |
|
| 299 | + } else |
|
| 297 | 300 | { |
| 298 | 301 | // Note we send labels by id as it will have less problems in the querystring. |
| 299 | 302 | $unread_in_labels = 0; |
| 300 | 303 | foreach ($context['labels'] as $label) |
| 301 | 304 | { |
| 302 | - if ($label['id'] == -1) |
|
| 303 | - continue; |
|
| 305 | + if ($label['id'] == -1) { |
|
| 306 | + continue; |
|
| 307 | + } |
|
| 304 | 308 | |
| 305 | 309 | // Count the amount of unread items in labels. |
| 306 | 310 | $unread_in_labels += $label['unread_messages']; |
@@ -314,8 +318,9 @@ discard block |
||
| 314 | 318 | ); |
| 315 | 319 | } |
| 316 | 320 | |
| 317 | - if (!empty($unread_in_labels)) |
|
| 318 | - $pm_areas['labels']['title'] .= ' <span class="amt">' . $unread_in_labels . '</span>'; |
|
| 321 | + if (!empty($unread_in_labels)) { |
|
| 322 | + $pm_areas['labels']['title'] .= ' <span class="amt">' . $unread_in_labels . '</span>'; |
|
| 323 | + } |
|
| 319 | 324 | } |
| 320 | 325 | |
| 321 | 326 | $pm_areas['folders']['areas']['inbox']['unread_messages'] = &$context['labels'][-1]['unread_messages']; |
@@ -353,8 +358,9 @@ discard block |
||
| 353 | 358 | unset($pm_areas); |
| 354 | 359 | |
| 355 | 360 | // No menu means no access. |
| 356 | - if (!$pm_include_data && (!$user_info['is_guest'] || validateSession())) |
|
| 357 | - fatal_lang_error('no_access', false); |
|
| 361 | + if (!$pm_include_data && (!$user_info['is_guest'] || validateSession())) { |
|
| 362 | + fatal_lang_error('no_access', false); |
|
| 363 | + } |
|
| 358 | 364 | |
| 359 | 365 | // Make a note of the Unique ID for this menu. |
| 360 | 366 | $context['pm_menu_id'] = $context['max_menu_id']; |
@@ -365,9 +371,10 @@ discard block |
||
| 365 | 371 | $context['menu_item_selected'] = $current_area; |
| 366 | 372 | |
| 367 | 373 | // Set the template for this area and add the profile layer. |
| 368 | - if (!isset($_REQUEST['xml'])) |
|
| 369 | - $context['template_layers'][] = 'pm'; |
|
| 370 | -} |
|
| 374 | + if (!isset($_REQUEST['xml'])) { |
|
| 375 | + $context['template_layers'][] = 'pm'; |
|
| 376 | + } |
|
| 377 | + } |
|
| 371 | 378 | |
| 372 | 379 | /** |
| 373 | 380 | * The popup for when we ask for the popup from the user. |
@@ -399,8 +406,9 @@ discard block |
||
| 399 | 406 | ) |
| 400 | 407 | ); |
| 401 | 408 | $pms = array(); |
| 402 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 403 | - $pms[] = $row[0]; |
|
| 409 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 410 | + $pms[] = $row[0]; |
|
| 411 | + } |
|
| 404 | 412 | $smcFunc['db_free_result']($request); |
| 405 | 413 | |
| 406 | 414 | if (!empty($pms)) |
@@ -428,8 +436,9 @@ discard block |
||
| 428 | 436 | ); |
| 429 | 437 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 430 | 438 | { |
| 431 | - if (!empty($row['id_member_from'])) |
|
| 432 | - $senders[] = $row['id_member_from']; |
|
| 439 | + if (!empty($row['id_member_from'])) { |
|
| 440 | + $senders[] = $row['id_member_from']; |
|
| 441 | + } |
|
| 433 | 442 | |
| 434 | 443 | $row['replied_to_you'] = $row['id_pm'] != $row['id_pm_head']; |
| 435 | 444 | $row['time'] = timeformat($row['timestamp']); |
@@ -439,13 +448,15 @@ discard block |
||
| 439 | 448 | $smcFunc['db_free_result']($request); |
| 440 | 449 | |
| 441 | 450 | $senders = loadMemberData($senders); |
| 442 | - foreach ($senders as $member) |
|
| 443 | - loadMemberContext($member); |
|
| 451 | + foreach ($senders as $member) { |
|
| 452 | + loadMemberContext($member); |
|
| 453 | + } |
|
| 444 | 454 | |
| 445 | 455 | // Having loaded everyone, attach them to the PMs. |
| 446 | - foreach ($context['unread_pms'] as $id_pm => $details) |
|
| 447 | - if (!empty($memberContext[$details['id_member_from']])) |
|
| 456 | + foreach ($context['unread_pms'] as $id_pm => $details) { |
|
| 457 | + if (!empty($memberContext[$details['id_member_from']])) |
|
| 448 | 458 | $context['unread_pms'][$id_pm]['member'] = &$memberContext[$details['id_member_from']]; |
| 459 | + } |
|
| 449 | 460 | } |
| 450 | 461 | } |
| 451 | 462 | |
@@ -465,12 +476,13 @@ discard block |
||
| 465 | 476 | } |
| 466 | 477 | |
| 467 | 478 | // Make sure the starting location is valid. |
| 468 | - if (isset($_GET['start']) && $_GET['start'] != 'new') |
|
| 469 | - $_GET['start'] = (int) $_GET['start']; |
|
| 470 | - elseif (!isset($_GET['start']) && !empty($options['view_newest_pm_first'])) |
|
| 471 | - $_GET['start'] = 0; |
|
| 472 | - else |
|
| 473 | - $_GET['start'] = 'new'; |
|
| 479 | + if (isset($_GET['start']) && $_GET['start'] != 'new') { |
|
| 480 | + $_GET['start'] = (int) $_GET['start']; |
|
| 481 | + } elseif (!isset($_GET['start']) && !empty($options['view_newest_pm_first'])) { |
|
| 482 | + $_GET['start'] = 0; |
|
| 483 | + } else { |
|
| 484 | + $_GET['start'] = 'new'; |
|
| 485 | + } |
|
| 474 | 486 | |
| 475 | 487 | // Set up some basic theme stuff. |
| 476 | 488 | $context['from_or_to'] = $context['folder'] != 'sent' ? 'from' : 'to'; |
@@ -487,8 +499,7 @@ discard block |
||
| 487 | 499 | { |
| 488 | 500 | $labelQuery = ' |
| 489 | 501 | AND pmr.in_inbox = 1'; |
| 490 | - } |
|
| 491 | - elseif ($context['folder'] != 'sent') |
|
| 502 | + } elseif ($context['folder'] != 'sent') |
|
| 492 | 503 | { |
| 493 | 504 | $labelJoin = ' |
| 494 | 505 | INNER JOIN {db_prefix}pm_labeled_messages AS pl ON (pl.id_pm = pmr.id_pm)'; |
@@ -530,22 +541,24 @@ discard block |
||
| 530 | 541 | $txt['delete_all'] = str_replace('PMBOX', $pmbox, $txt['delete_all']); |
| 531 | 542 | |
| 532 | 543 | // Now, build the link tree! |
| 533 | - if ($context['current_label_id'] == -1) |
|
| 534 | - $context['linktree'][] = array( |
|
| 544 | + if ($context['current_label_id'] == -1) { |
|
| 545 | + $context['linktree'][] = array( |
|
| 535 | 546 | 'url' => $scripturl . '?action=pm;f=' . $context['folder'], |
| 536 | 547 | 'name' => $pmbox |
| 537 | 548 | ); |
| 549 | + } |
|
| 538 | 550 | |
| 539 | 551 | // Build it further for a label. |
| 540 | - if ($context['current_label_id'] != -1) |
|
| 541 | - $context['linktree'][] = array( |
|
| 552 | + if ($context['current_label_id'] != -1) { |
|
| 553 | + $context['linktree'][] = array( |
|
| 542 | 554 | 'url' => $scripturl . '?action=pm;f=' . $context['folder'] . ';l=' . $context['current_label_id'], |
| 543 | 555 | 'name' => $txt['pm_current_label'] . ': ' . $context['current_label'] |
| 544 | 556 | ); |
| 557 | + } |
|
| 545 | 558 | |
| 546 | 559 | // Figure out how many messages there are. |
| 547 | - if ($context['folder'] == 'sent') |
|
| 548 | - $request = $smcFunc['db_query']('', ' |
|
| 560 | + if ($context['folder'] == 'sent') { |
|
| 561 | + $request = $smcFunc['db_query']('', ' |
|
| 549 | 562 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
| 550 | 563 | FROM {db_prefix}personal_messages AS pm |
| 551 | 564 | WHERE pm.id_member_from = {int:current_member} |
@@ -555,8 +568,8 @@ discard block |
||
| 555 | 568 | 'not_deleted' => 0, |
| 556 | 569 | ) |
| 557 | 570 | ); |
| 558 | - else |
|
| 559 | - $request = $smcFunc['db_query']('', ' |
|
| 571 | + } else { |
|
| 572 | + $request = $smcFunc['db_query']('', ' |
|
| 560 | 573 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
| 561 | 574 | FROM {db_prefix}pm_recipients AS pmr' . ($context['display_mode'] == 2 ? ' |
| 562 | 575 | INNER JOIN {db_prefix}personal_messages AS pm ON (pm.id_pm = pmr.id_pm)' : '') . $labelJoin . ' |
@@ -567,6 +580,7 @@ discard block |
||
| 567 | 580 | 'not_deleted' => 0, |
| 568 | 581 | ) |
| 569 | 582 | ); |
| 583 | + } |
|
| 570 | 584 | list ($max_messages) = $smcFunc['db_fetch_row']($request); |
| 571 | 585 | $smcFunc['db_free_result']($request); |
| 572 | 586 | |
@@ -575,10 +589,11 @@ discard block |
||
| 575 | 589 | $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
| 576 | 590 | |
| 577 | 591 | // Start on the last page. |
| 578 | - if (!is_numeric($_GET['start']) || $_GET['start'] >= $max_messages) |
|
| 579 | - $_GET['start'] = ($max_messages - 1) - (($max_messages - 1) % $maxPerPage); |
|
| 580 | - elseif ($_GET['start'] < 0) |
|
| 581 | - $_GET['start'] = 0; |
|
| 592 | + if (!is_numeric($_GET['start']) || $_GET['start'] >= $max_messages) { |
|
| 593 | + $_GET['start'] = ($max_messages - 1) - (($max_messages - 1) % $maxPerPage); |
|
| 594 | + } elseif ($_GET['start'] < 0) { |
|
| 595 | + $_GET['start'] = 0; |
|
| 596 | + } |
|
| 582 | 597 | |
| 583 | 598 | // ... but wait - what if we want to start from a specific message? |
| 584 | 599 | if (isset($_GET['pmid'])) |
@@ -586,19 +601,21 @@ discard block |
||
| 586 | 601 | $pmID = (int) $_GET['pmid']; |
| 587 | 602 | |
| 588 | 603 | // Make sure you have access to this PM. |
| 589 | - if (!isAccessiblePM($pmID, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) |
|
| 590 | - fatal_lang_error('no_access', false); |
|
| 604 | + if (!isAccessiblePM($pmID, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) { |
|
| 605 | + fatal_lang_error('no_access', false); |
|
| 606 | + } |
|
| 591 | 607 | |
| 592 | 608 | $context['current_pm'] = $pmID; |
| 593 | 609 | |
| 594 | 610 | // With only one page of PM's we're gonna want page 1. |
| 595 | - if ($max_messages <= $maxPerPage) |
|
| 596 | - $_GET['start'] = 0; |
|
| 611 | + if ($max_messages <= $maxPerPage) { |
|
| 612 | + $_GET['start'] = 0; |
|
| 613 | + } |
|
| 597 | 614 | // If we pass kstart we assume we're in the right place. |
| 598 | 615 | elseif (!isset($_GET['kstart'])) |
| 599 | 616 | { |
| 600 | - if ($context['folder'] == 'sent') |
|
| 601 | - $request = $smcFunc['db_query']('', ' |
|
| 617 | + if ($context['folder'] == 'sent') { |
|
| 618 | + $request = $smcFunc['db_query']('', ' |
|
| 602 | 619 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
| 603 | 620 | FROM {db_prefix}personal_messages |
| 604 | 621 | WHERE id_member_from = {int:current_member} |
@@ -610,8 +627,8 @@ discard block |
||
| 610 | 627 | 'id_pm' => $pmID, |
| 611 | 628 | ) |
| 612 | 629 | ); |
| 613 | - else |
|
| 614 | - $request = $smcFunc['db_query']('', ' |
|
| 630 | + } else { |
|
| 631 | + $request = $smcFunc['db_query']('', ' |
|
| 615 | 632 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
| 616 | 633 | FROM {db_prefix}pm_recipients AS pmr' . ($context['display_mode'] == 2 ? ' |
| 617 | 634 | INNER JOIN {db_prefix}personal_messages AS pm ON (pm.id_pm = pmr.id_pm)' : '') . $labelJoin . ' |
@@ -624,6 +641,7 @@ discard block |
||
| 624 | 641 | 'id_pm' => $pmID, |
| 625 | 642 | ) |
| 626 | 643 | ); |
| 644 | + } |
|
| 627 | 645 | |
| 628 | 646 | list ($_GET['start']) = $smcFunc['db_fetch_row']($request); |
| 629 | 647 | $smcFunc['db_free_result']($request); |
@@ -638,8 +656,9 @@ discard block |
||
| 638 | 656 | { |
| 639 | 657 | $pmsg = (int) $_GET['pmsg']; |
| 640 | 658 | |
| 641 | - if (!isAccessiblePM($pmsg, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) |
|
| 642 | - fatal_lang_error('no_access', false); |
|
| 659 | + if (!isAccessiblePM($pmsg, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) { |
|
| 660 | + fatal_lang_error('no_access', false); |
|
| 661 | + } |
|
| 643 | 662 | } |
| 644 | 663 | |
| 645 | 664 | // Set up the page index. |
@@ -734,8 +753,9 @@ discard block |
||
| 734 | 753 | { |
| 735 | 754 | if (!isset($recipients[$row['id_pm']])) |
| 736 | 755 | { |
| 737 | - if (isset($row['id_member_from'])) |
|
| 738 | - $posters[$row['id_pm']] = $row['id_member_from']; |
|
| 756 | + if (isset($row['id_member_from'])) { |
|
| 757 | + $posters[$row['id_pm']] = $row['id_member_from']; |
|
| 758 | + } |
|
| 739 | 759 | $pms[$row['id_pm']] = $row['id_pm']; |
| 740 | 760 | $recipients[$row['id_pm']] = array( |
| 741 | 761 | 'to' => array(), |
@@ -744,29 +764,33 @@ discard block |
||
| 744 | 764 | } |
| 745 | 765 | |
| 746 | 766 | // Keep track of the last message so we know what the head is without another query! |
| 747 | - if ((empty($pmID) && (empty($options['view_newest_pm_first']) || !isset($lastData))) || empty($lastData) || (!empty($pmID) && $pmID == $row['id_pm'])) |
|
| 748 | - $lastData = array( |
|
| 767 | + if ((empty($pmID) && (empty($options['view_newest_pm_first']) || !isset($lastData))) || empty($lastData) || (!empty($pmID) && $pmID == $row['id_pm'])) { |
|
| 768 | + $lastData = array( |
|
| 749 | 769 | 'id' => $row['id_pm'], |
| 750 | 770 | 'head' => $row['id_pm_head'], |
| 751 | 771 | ); |
| 772 | + } |
|
| 752 | 773 | } |
| 753 | 774 | $smcFunc['db_free_result']($request); |
| 754 | 775 | |
| 755 | 776 | // Make sure that we have been given a correct head pm id! |
| 756 | - if ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id']) |
|
| 757 | - fatal_lang_error('no_access', false); |
|
| 777 | + if ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id']) { |
|
| 778 | + fatal_lang_error('no_access', false); |
|
| 779 | + } |
|
| 758 | 780 | |
| 759 | 781 | if (!empty($pms)) |
| 760 | 782 | { |
| 761 | 783 | // Select the correct current message. |
| 762 | - if (empty($pmID)) |
|
| 763 | - $context['current_pm'] = $lastData['id']; |
|
| 784 | + if (empty($pmID)) { |
|
| 785 | + $context['current_pm'] = $lastData['id']; |
|
| 786 | + } |
|
| 764 | 787 | |
| 765 | 788 | // This is a list of the pm's that are used for "full" display. |
| 766 | - if ($context['display_mode'] == 0) |
|
| 767 | - $display_pms = $pms; |
|
| 768 | - else |
|
| 769 | - $display_pms = array($context['current_pm']); |
|
| 789 | + if ($context['display_mode'] == 0) { |
|
| 790 | + $display_pms = $pms; |
|
| 791 | + } else { |
|
| 792 | + $display_pms = array($context['current_pm']); |
|
| 793 | + } |
|
| 770 | 794 | |
| 771 | 795 | // At this point we know the main id_pm's. But - if we are looking at conversations we need the others! |
| 772 | 796 | if ($context['display_mode'] == 2) |
@@ -788,16 +812,18 @@ discard block |
||
| 788 | 812 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 789 | 813 | { |
| 790 | 814 | // This is, frankly, a joke. We will put in a workaround for people sending to themselves - yawn! |
| 791 | - if ($context['folder'] == 'sent' && $row['id_member_from'] == $user_info['id'] && $row['deleted_by_sender'] == 1) |
|
| 792 | - continue; |
|
| 793 | - elseif ($row['id_member'] == $user_info['id'] & $row['deleted'] == 1) |
|
| 794 | - continue; |
|
| 815 | + if ($context['folder'] == 'sent' && $row['id_member_from'] == $user_info['id'] && $row['deleted_by_sender'] == 1) { |
|
| 816 | + continue; |
|
| 817 | + } elseif ($row['id_member'] == $user_info['id'] & $row['deleted'] == 1) { |
|
| 818 | + continue; |
|
| 819 | + } |
|
| 795 | 820 | |
| 796 | - if (!isset($recipients[$row['id_pm']])) |
|
| 797 | - $recipients[$row['id_pm']] = array( |
|
| 821 | + if (!isset($recipients[$row['id_pm']])) { |
|
| 822 | + $recipients[$row['id_pm']] = array( |
|
| 798 | 823 | 'to' => array(), |
| 799 | 824 | 'bcc' => array() |
| 800 | 825 | ); |
| 826 | + } |
|
| 801 | 827 | $display_pms[] = $row['id_pm']; |
| 802 | 828 | $posters[$row['id_pm']] = $row['id_member_from']; |
| 803 | 829 | } |
@@ -848,8 +874,9 @@ discard block |
||
| 848 | 874 | while ($row2 = $smcFunc['db_fetch_assoc']($request2)) |
| 849 | 875 | { |
| 850 | 876 | $l_id = $row2['id_label']; |
| 851 | - if (isset($context['labels'][$l_id])) |
|
| 852 | - $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
| 877 | + if (isset($context['labels'][$l_id])) { |
|
| 878 | + $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
| 879 | + } |
|
| 853 | 880 | } |
| 854 | 881 | |
| 855 | 882 | $smcFunc['db_free_result']($request2); |
@@ -866,9 +893,10 @@ discard block |
||
| 866 | 893 | // Make sure we don't load unnecessary data. |
| 867 | 894 | if ($context['display_mode'] == 1) |
| 868 | 895 | { |
| 869 | - foreach ($posters as $k => $v) |
|
| 870 | - if (!in_array($k, $display_pms)) |
|
| 896 | + foreach ($posters as $k => $v) { |
|
| 897 | + if (!in_array($k, $display_pms)) |
|
| 871 | 898 | unset($posters[$k]); |
| 899 | + } |
|
| 872 | 900 | } |
| 873 | 901 | |
| 874 | 902 | // Load any users.... |
@@ -879,8 +907,9 @@ discard block |
||
| 879 | 907 | { |
| 880 | 908 | // Get the order right. |
| 881 | 909 | $orderBy = array(); |
| 882 | - foreach (array_reverse($pms) as $pm) |
|
| 883 | - $orderBy[] = 'pm.id_pm = ' . $pm; |
|
| 910 | + foreach (array_reverse($pms) as $pm) { |
|
| 911 | + $orderBy[] = 'pm.id_pm = ' . $pm; |
|
| 912 | + } |
|
| 884 | 913 | |
| 885 | 914 | // Seperate query for these bits! |
| 886 | 915 | $subjects_request = $smcFunc['db_query']('', ' |
@@ -926,9 +955,9 @@ discard block |
||
| 926 | 955 | // Allow mods to add additional buttons here |
| 927 | 956 | call_integration_hook('integrate_conversation_buttons'); |
| 928 | 957 | } |
| 958 | + } else { |
|
| 959 | + $messages_request = false; |
|
| 929 | 960 | } |
| 930 | - else |
|
| 931 | - $messages_request = false; |
|
| 932 | 961 | |
| 933 | 962 | $context['can_send_pm'] = allowedTo('pm_send'); |
| 934 | 963 | $context['can_send_email'] = allowedTo('moderate_forum'); |
@@ -939,11 +968,13 @@ discard block |
||
| 939 | 968 | if ($context['folder'] != 'sent' && !empty($context['labels'][(int) $context['current_label_id']]['unread_messages'])) |
| 940 | 969 | { |
| 941 | 970 | // If the display mode is "old sk00l" do them all... |
| 942 | - if ($context['display_mode'] == 0) |
|
| 943 | - markMessages(null, $context['current_label_id']); |
|
| 971 | + if ($context['display_mode'] == 0) { |
|
| 972 | + markMessages(null, $context['current_label_id']); |
|
| 973 | + } |
|
| 944 | 974 | // Otherwise do just the current one! |
| 945 | - elseif (!empty($context['current_pm'])) |
|
| 946 | - markMessages($display_pms, $context['current_label_id']); |
|
| 975 | + elseif (!empty($context['current_pm'])) { |
|
| 976 | + markMessages($display_pms, $context['current_label_id']); |
|
| 977 | + } |
|
| 947 | 978 | } |
| 948 | 979 | } |
| 949 | 980 | |
@@ -961,8 +992,9 @@ discard block |
||
| 961 | 992 | |
| 962 | 993 | // Count the current message number.... |
| 963 | 994 | static $counter = null; |
| 964 | - if ($counter === null || $reset) |
|
| 965 | - $counter = $context['start']; |
|
| 995 | + if ($counter === null || $reset) { |
|
| 996 | + $counter = $context['start']; |
|
| 997 | + } |
|
| 966 | 998 | |
| 967 | 999 | static $temp_pm_selected = null; |
| 968 | 1000 | if ($temp_pm_selected === null) |
@@ -1007,19 +1039,22 @@ discard block |
||
| 1007 | 1039 | } |
| 1008 | 1040 | |
| 1009 | 1041 | // Bail if it's false, ie. no messages. |
| 1010 | - if ($messages_request == false) |
|
| 1011 | - return false; |
|
| 1042 | + if ($messages_request == false) { |
|
| 1043 | + return false; |
|
| 1044 | + } |
|
| 1012 | 1045 | |
| 1013 | 1046 | // Reset the data? |
| 1014 | - if ($reset == true) |
|
| 1015 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1047 | + if ($reset == true) { |
|
| 1048 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1049 | + } |
|
| 1016 | 1050 | |
| 1017 | 1051 | // Get the next one... bail if anything goes wrong. |
| 1018 | 1052 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
| 1019 | 1053 | if (!$message) |
| 1020 | 1054 | { |
| 1021 | - if ($type != 'subject') |
|
| 1022 | - $smcFunc['db_free_result']($messages_request); |
|
| 1055 | + if ($type != 'subject') { |
|
| 1056 | + $smcFunc['db_free_result']($messages_request); |
|
| 1057 | + } |
|
| 1023 | 1058 | |
| 1024 | 1059 | return false; |
| 1025 | 1060 | } |
@@ -1039,8 +1074,7 @@ discard block |
||
| 1039 | 1074 | $memberContext[$message['id_member_from']]['email'] = ''; |
| 1040 | 1075 | $memberContext[$message['id_member_from']]['show_email'] = false; |
| 1041 | 1076 | $memberContext[$message['id_member_from']]['is_guest'] = true; |
| 1042 | - } |
|
| 1043 | - else |
|
| 1077 | + } else |
|
| 1044 | 1078 | { |
| 1045 | 1079 | $memberContext[$message['id_member_from']]['can_view_profile'] = allowedTo('profile_view') || ($message['id_member_from'] == $user_info['id'] && !$user_info['is_guest']); |
| 1046 | 1080 | $memberContext[$message['id_member_from']]['can_see_warning'] = !isset($context['disabled_fields']['warning_status']) && $memberContext[$message['id_member_from']]['warning_status'] && ($context['user']['can_mod'] || (!empty($modSettings['warning_show']) && ($modSettings['warning_show'] > 1 || $message['id_member_from'] == $user_info['id']))); |
@@ -1081,12 +1115,13 @@ discard block |
||
| 1081 | 1115 | $counter++; |
| 1082 | 1116 | |
| 1083 | 1117 | // Any custom profile fields? |
| 1084 | - if (!empty($memberContext[$message['id_member_from']]['custom_fields'])) |
|
| 1085 | - foreach ($memberContext[$message['id_member_from']]['custom_fields'] as $custom) |
|
| 1118 | + if (!empty($memberContext[$message['id_member_from']]['custom_fields'])) { |
|
| 1119 | + foreach ($memberContext[$message['id_member_from']]['custom_fields'] as $custom) |
|
| 1086 | 1120 | switch ($custom['placement']) |
| 1087 | 1121 | { |
| 1088 | 1122 | case 1: |
| 1089 | 1123 | $output['custom_fields']['icons'][] = $custom; |
| 1124 | + } |
|
| 1090 | 1125 | break; |
| 1091 | 1126 | case 2: |
| 1092 | 1127 | $output['custom_fields']['above_signature'][] = $custom; |
@@ -1129,22 +1164,28 @@ discard block |
||
| 1129 | 1164 | $context['search_params'][$k] = $v; |
| 1130 | 1165 | } |
| 1131 | 1166 | } |
| 1132 | - if (isset($_REQUEST['search'])) |
|
| 1133 | - $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
| 1167 | + if (isset($_REQUEST['search'])) { |
|
| 1168 | + $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
| 1169 | + } |
|
| 1134 | 1170 | |
| 1135 | - if (isset($context['search_params']['search'])) |
|
| 1136 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 1137 | - if (isset($context['search_params']['userspec'])) |
|
| 1138 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 1171 | + if (isset($context['search_params']['search'])) { |
|
| 1172 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 1173 | + } |
|
| 1174 | + if (isset($context['search_params']['userspec'])) { |
|
| 1175 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 1176 | + } |
|
| 1139 | 1177 | |
| 1140 | - if (!empty($context['search_params']['searchtype'])) |
|
| 1141 | - $context['search_params']['searchtype'] = 2; |
|
| 1178 | + if (!empty($context['search_params']['searchtype'])) { |
|
| 1179 | + $context['search_params']['searchtype'] = 2; |
|
| 1180 | + } |
|
| 1142 | 1181 | |
| 1143 | - if (!empty($context['search_params']['minage'])) |
|
| 1144 | - $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
| 1182 | + if (!empty($context['search_params']['minage'])) { |
|
| 1183 | + $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
| 1184 | + } |
|
| 1145 | 1185 | |
| 1146 | - if (!empty($context['search_params']['maxage'])) |
|
| 1147 | - $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
| 1186 | + if (!empty($context['search_params']['maxage'])) { |
|
| 1187 | + $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
| 1188 | + } |
|
| 1148 | 1189 | |
| 1149 | 1190 | $context['search_params']['subject_only'] = !empty($context['search_params']['subject_only']); |
| 1150 | 1191 | $context['search_params']['show_complete'] = !empty($context['search_params']['show_complete']); |
@@ -1171,8 +1212,9 @@ discard block |
||
| 1171 | 1212 | $context['search_errors']['messages'] = array(); |
| 1172 | 1213 | foreach ($context['search_errors'] as $search_error => $dummy) |
| 1173 | 1214 | { |
| 1174 | - if ($search_error == 'messages') |
|
| 1175 | - continue; |
|
| 1215 | + if ($search_error == 'messages') { |
|
| 1216 | + continue; |
|
| 1217 | + } |
|
| 1176 | 1218 | |
| 1177 | 1219 | $context['search_errors']['messages'][] = $txt['error_' . $search_error]; |
| 1178 | 1220 | } |
@@ -1194,8 +1236,9 @@ discard block |
||
| 1194 | 1236 | global $scripturl, $modSettings, $user_info, $context, $txt; |
| 1195 | 1237 | global $memberContext, $smcFunc; |
| 1196 | 1238 | |
| 1197 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) |
|
| 1198 | - fatal_lang_error('loadavg_search_disabled', false); |
|
| 1239 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) { |
|
| 1240 | + fatal_lang_error('loadavg_search_disabled', false); |
|
| 1241 | + } |
|
| 1199 | 1242 | |
| 1200 | 1243 | /** |
| 1201 | 1244 | * @todo For the moment force the folder to the inbox. |
@@ -1224,35 +1267,40 @@ discard block |
||
| 1224 | 1267 | $context['start'] = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
| 1225 | 1268 | |
| 1226 | 1269 | // Store whether simple search was used (needed if the user wants to do another query). |
| 1227 | - if (!isset($search_params['advanced'])) |
|
| 1228 | - $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
| 1270 | + if (!isset($search_params['advanced'])) { |
|
| 1271 | + $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
| 1272 | + } |
|
| 1229 | 1273 | |
| 1230 | 1274 | // 1 => 'allwords' (default, don't set as param) / 2 => 'anywords'. |
| 1231 | - if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) |
|
| 1232 | - $search_params['searchtype'] = 2; |
|
| 1275 | + if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) { |
|
| 1276 | + $search_params['searchtype'] = 2; |
|
| 1277 | + } |
|
| 1233 | 1278 | |
| 1234 | 1279 | // Minimum age of messages. Default to zero (don't set param in that case). |
| 1235 | - if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) |
|
| 1236 | - $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
| 1280 | + if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) { |
|
| 1281 | + $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
| 1282 | + } |
|
| 1237 | 1283 | |
| 1238 | 1284 | // Maximum age of messages. Default to infinite (9999 days: param not set). |
| 1239 | - if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] != 9999)) |
|
| 1240 | - $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
| 1285 | + if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] != 9999)) { |
|
| 1286 | + $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
| 1287 | + } |
|
| 1241 | 1288 | |
| 1242 | 1289 | $search_params['subject_only'] = !empty($search_params['subject_only']) || !empty($_REQUEST['subject_only']); |
| 1243 | 1290 | $search_params['show_complete'] = !empty($search_params['show_complete']) || !empty($_REQUEST['show_complete']); |
| 1244 | 1291 | |
| 1245 | 1292 | // Default the user name to a wildcard matching every user (*). |
| 1246 | - if (!empty($search_params['user_spec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) |
|
| 1247 | - $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
| 1293 | + if (!empty($search_params['user_spec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) { |
|
| 1294 | + $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
| 1295 | + } |
|
| 1248 | 1296 | |
| 1249 | 1297 | // This will be full of all kinds of parameters! |
| 1250 | 1298 | $searchq_parameters = array(); |
| 1251 | 1299 | |
| 1252 | 1300 | // If there's no specific user, then don't mention it in the main query. |
| 1253 | - if (empty($search_params['userspec'])) |
|
| 1254 | - $userQuery = ''; |
|
| 1255 | - else |
|
| 1301 | + if (empty($search_params['userspec'])) { |
|
| 1302 | + $userQuery = ''; |
|
| 1303 | + } else |
|
| 1256 | 1304 | { |
| 1257 | 1305 | $userString = strtr($smcFunc['htmlspecialchars']($search_params['userspec'], ENT_QUOTES), array('"' => '"')); |
| 1258 | 1306 | $userString = strtr($userString, array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_')); |
@@ -1264,8 +1312,9 @@ discard block |
||
| 1264 | 1312 | { |
| 1265 | 1313 | $possible_users[$k] = trim($possible_users[$k]); |
| 1266 | 1314 | |
| 1267 | - if (strlen($possible_users[$k]) == 0) |
|
| 1268 | - unset($possible_users[$k]); |
|
| 1315 | + if (strlen($possible_users[$k]) == 0) { |
|
| 1316 | + unset($possible_users[$k]); |
|
| 1317 | + } |
|
| 1269 | 1318 | } |
| 1270 | 1319 | |
| 1271 | 1320 | if (!empty($possible_users)) |
@@ -1277,8 +1326,9 @@ discard block |
||
| 1277 | 1326 | { |
| 1278 | 1327 | $where_params['name_' . $k] = $v; |
| 1279 | 1328 | $where_clause[] = '{raw:real_name} LIKE {string:name_' . $k . '}'; |
| 1280 | - if (!isset($where_params['real_name'])) |
|
| 1281 | - $where_params['real_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(real_name)' : 'real_name'; |
|
| 1329 | + if (!isset($where_params['real_name'])) { |
|
| 1330 | + $where_params['real_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(real_name)' : 'real_name'; |
|
| 1331 | + } |
|
| 1282 | 1332 | } |
| 1283 | 1333 | |
| 1284 | 1334 | // Who matches those criteria? |
@@ -1291,28 +1341,28 @@ discard block |
||
| 1291 | 1341 | ); |
| 1292 | 1342 | |
| 1293 | 1343 | // Simply do nothing if there're too many members matching the criteria. |
| 1294 | - if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) |
|
| 1295 | - $userQuery = ''; |
|
| 1296 | - elseif ($smcFunc['db_num_rows']($request) == 0) |
|
| 1344 | + if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) { |
|
| 1345 | + $userQuery = ''; |
|
| 1346 | + } elseif ($smcFunc['db_num_rows']($request) == 0) |
|
| 1297 | 1347 | { |
| 1298 | 1348 | $userQuery = 'AND 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['pm_from_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name'; |
| 1301 | - } |
|
| 1302 | - else |
|
| 1351 | + } else |
|
| 1303 | 1352 | { |
| 1304 | 1353 | $memberlist = array(); |
| 1305 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1306 | - $memberlist[] = $row['id_member']; |
|
| 1354 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1355 | + $memberlist[] = $row['id_member']; |
|
| 1356 | + } |
|
| 1307 | 1357 | $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})))'; |
| 1308 | 1358 | $searchq_parameters['guest_user_name_implode'] = '\'' . implode('\' OR ' . ($smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name') . ' LIKE \'', $possible_users) . '\''; |
| 1309 | 1359 | $searchq_parameters['member_list'] = $memberlist; |
| 1310 | 1360 | $searchq_parameters['pm_from_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name'; |
| 1311 | 1361 | } |
| 1312 | 1362 | $smcFunc['db_free_result']($request); |
| 1363 | + } else { |
|
| 1364 | + $userQuery = ''; |
|
| 1313 | 1365 | } |
| 1314 | - else |
|
| 1315 | - $userQuery = ''; |
|
| 1316 | 1366 | } |
| 1317 | 1367 | |
| 1318 | 1368 | // Setup the sorting variables... |
@@ -1320,8 +1370,9 @@ discard block |
||
| 1320 | 1370 | $sort_columns = array( |
| 1321 | 1371 | 'pm.id_pm', |
| 1322 | 1372 | ); |
| 1323 | - if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) |
|
| 1324 | - list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
| 1373 | + if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) { |
|
| 1374 | + list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
| 1375 | + } |
|
| 1325 | 1376 | $search_params['sort'] = !empty($search_params['sort']) && in_array($search_params['sort'], $sort_columns) ? $search_params['sort'] : 'pm.id_pm'; |
| 1326 | 1377 | $search_params['sort_dir'] = !empty($search_params['sort_dir']) && $search_params['sort_dir'] == 'asc' ? 'asc' : 'desc'; |
| 1327 | 1378 | |
@@ -1331,24 +1382,27 @@ discard block |
||
| 1331 | 1382 | if ($context['folder'] == 'inbox' && !empty($search_params['advanced']) && $context['currently_using_labels']) |
| 1332 | 1383 | { |
| 1333 | 1384 | // Came here from pagination? Put them back into $_REQUEST for sanitization. |
| 1334 | - if (isset($search_params['labels'])) |
|
| 1335 | - $_REQUEST['searchlabel'] = explode(',', $search_params['labels']); |
|
| 1385 | + if (isset($search_params['labels'])) { |
|
| 1386 | + $_REQUEST['searchlabel'] = explode(',', $search_params['labels']); |
|
| 1387 | + } |
|
| 1336 | 1388 | |
| 1337 | 1389 | // Assuming we have some labels - make them all integers. |
| 1338 | 1390 | if (!empty($_REQUEST['searchlabel']) && is_array($_REQUEST['searchlabel'])) |
| 1339 | 1391 | { |
| 1340 | - foreach ($_REQUEST['searchlabel'] as $key => $id) |
|
| 1341 | - $_REQUEST['searchlabel'][$key] = (int) $id; |
|
| 1392 | + foreach ($_REQUEST['searchlabel'] as $key => $id) { |
|
| 1393 | + $_REQUEST['searchlabel'][$key] = (int) $id; |
|
| 1394 | + } |
|
| 1395 | + } else { |
|
| 1396 | + $_REQUEST['searchlabel'] = array(); |
|
| 1342 | 1397 | } |
| 1343 | - else |
|
| 1344 | - $_REQUEST['searchlabel'] = array(); |
|
| 1345 | 1398 | |
| 1346 | 1399 | // Now that everything is cleaned up a bit, make the labels a param. |
| 1347 | 1400 | $search_params['labels'] = implode(',', $_REQUEST['searchlabel']); |
| 1348 | 1401 | |
| 1349 | 1402 | // No labels selected? That must be an error! |
| 1350 | - if (empty($_REQUEST['searchlabel'])) |
|
| 1351 | - $context['search_errors']['no_labels_selected'] = true; |
|
| 1403 | + if (empty($_REQUEST['searchlabel'])) { |
|
| 1404 | + $context['search_errors']['no_labels_selected'] = true; |
|
| 1405 | + } |
|
| 1352 | 1406 | // Otherwise prepare the query! |
| 1353 | 1407 | elseif (count($_REQUEST['searchlabel']) != count($context['labels'])) |
| 1354 | 1408 | { |
@@ -1371,8 +1425,7 @@ discard block |
||
| 1371 | 1425 | // Not searching the inbox - PM must be labeled |
| 1372 | 1426 | $labelQuery = ' AND pml.id_label IN ({array_int:labels})'; |
| 1373 | 1427 | $labelJoin = ' INNER JOIN {db_prefix}pm_labeled_messages AS pml ON (pml.id_pm = pmr.id_pm)'; |
| 1374 | - } |
|
| 1375 | - else |
|
| 1428 | + } else |
|
| 1376 | 1429 | { |
| 1377 | 1430 | // Searching the inbox - PM doesn't have to be labeled |
| 1378 | 1431 | $labelQuery = ' AND (' . substr($labelQuery, 5) . ' OR pml.id_label IN ({array_int:labels}))'; |
@@ -1387,8 +1440,9 @@ discard block |
||
| 1387 | 1440 | // What are we actually searching for? |
| 1388 | 1441 | $search_params['search'] = !empty($search_params['search']) ? $search_params['search'] : (isset($_REQUEST['search']) ? $_REQUEST['search'] : ''); |
| 1389 | 1442 | // If we ain't got nothing - we should error! |
| 1390 | - if (!isset($search_params['search']) || $search_params['search'] == '') |
|
| 1391 | - $context['search_errors']['invalid_search_string'] = true; |
|
| 1443 | + if (!isset($search_params['search']) || $search_params['search'] == '') { |
|
| 1444 | + $context['search_errors']['invalid_search_string'] = true; |
|
| 1445 | + } |
|
| 1392 | 1446 | |
| 1393 | 1447 | // Extract phrase parts first (e.g. some words "this is a phrase" some more words.) |
| 1394 | 1448 | preg_match_all('~(?:^|\s)([-]?)"([^"]+)"(?:$|\s)~' . ($context['utf8'] ? 'u' : ''), $search_params['search'], $matches, PREG_PATTERN_ORDER); |
@@ -1401,12 +1455,14 @@ discard block |
||
| 1401 | 1455 | $excludedWords = array(); |
| 1402 | 1456 | |
| 1403 | 1457 | // .. first, we check for things like -"some words", but not "-some words". |
| 1404 | - foreach ($matches[1] as $index => $word) |
|
| 1405 | - if ($word == '-') |
|
| 1458 | + foreach ($matches[1] as $index => $word) { |
|
| 1459 | + if ($word == '-') |
|
| 1406 | 1460 | { |
| 1407 | 1461 | $word = $smcFunc['strtolower'](trim($searchArray[$index])); |
| 1408 | - if (strlen($word) > 0) |
|
| 1409 | - $excludedWords[] = $word; |
|
| 1462 | + } |
|
| 1463 | + if (strlen($word) > 0) { |
|
| 1464 | + $excludedWords[] = $word; |
|
| 1465 | + } |
|
| 1410 | 1466 | unset($searchArray[$index]); |
| 1411 | 1467 | } |
| 1412 | 1468 | |
@@ -1416,8 +1472,9 @@ discard block |
||
| 1416 | 1472 | if (strpos(trim($word), '-') === 0) |
| 1417 | 1473 | { |
| 1418 | 1474 | $word = substr($smcFunc['strtolower']($word), 1); |
| 1419 | - if (strlen($word) > 0) |
|
| 1420 | - $excludedWords[] = $word; |
|
| 1475 | + if (strlen($word) > 0) { |
|
| 1476 | + $excludedWords[] = $word; |
|
| 1477 | + } |
|
| 1421 | 1478 | unset($tempSearch[$index]); |
| 1422 | 1479 | } |
| 1423 | 1480 | } |
@@ -1428,9 +1485,9 @@ discard block |
||
| 1428 | 1485 | foreach ($searchArray as $index => $value) |
| 1429 | 1486 | { |
| 1430 | 1487 | $searchArray[$index] = $smcFunc['strtolower'](trim($value)); |
| 1431 | - if ($searchArray[$index] == '') |
|
| 1432 | - unset($searchArray[$index]); |
|
| 1433 | - else |
|
| 1488 | + if ($searchArray[$index] == '') { |
|
| 1489 | + unset($searchArray[$index]); |
|
| 1490 | + } else |
|
| 1434 | 1491 | { |
| 1435 | 1492 | // Sort out entities first. |
| 1436 | 1493 | $searchArray[$index] = $smcFunc['htmlspecialchars']($searchArray[$index]); |
@@ -1440,27 +1497,32 @@ discard block |
||
| 1440 | 1497 | |
| 1441 | 1498 | // Create an array of replacements for highlighting. |
| 1442 | 1499 | $context['mark'] = array(); |
| 1443 | - foreach ($searchArray as $word) |
|
| 1444 | - $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
| 1500 | + foreach ($searchArray as $word) { |
|
| 1501 | + $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
| 1502 | + } |
|
| 1445 | 1503 | |
| 1446 | 1504 | // This contains *everything* |
| 1447 | 1505 | $searchWords = array_merge($searchArray, $excludedWords); |
| 1448 | 1506 | |
| 1449 | 1507 | // Make sure at least one word is being searched for. |
| 1450 | - if (empty($searchArray)) |
|
| 1451 | - $context['search_errors']['invalid_search_string'] = true; |
|
| 1508 | + if (empty($searchArray)) { |
|
| 1509 | + $context['search_errors']['invalid_search_string'] = true; |
|
| 1510 | + } |
|
| 1452 | 1511 | |
| 1453 | 1512 | // Sort out the search query so the user can edit it - if they want. |
| 1454 | 1513 | $context['search_params'] = $search_params; |
| 1455 | - if (isset($context['search_params']['search'])) |
|
| 1456 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 1457 | - if (isset($context['search_params']['userspec'])) |
|
| 1458 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 1514 | + if (isset($context['search_params']['search'])) { |
|
| 1515 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 1516 | + } |
|
| 1517 | + if (isset($context['search_params']['userspec'])) { |
|
| 1518 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 1519 | + } |
|
| 1459 | 1520 | |
| 1460 | 1521 | // Now we have all the parameters, combine them together for pagination and the like... |
| 1461 | 1522 | $context['params'] = array(); |
| 1462 | - foreach ($search_params as $k => $v) |
|
| 1463 | - $context['params'][] = $k . '|\'|' . $v; |
|
| 1523 | + foreach ($search_params as $k => $v) { |
|
| 1524 | + $context['params'][] = $k . '|\'|' . $v; |
|
| 1525 | + } |
|
| 1464 | 1526 | $context['params'] = base64_encode(implode('|"|', $context['params'])); |
| 1465 | 1527 | |
| 1466 | 1528 | // Compile the subject query part. |
@@ -1468,26 +1530,31 @@ discard block |
||
| 1468 | 1530 | |
| 1469 | 1531 | foreach ($searchWords as $index => $word) |
| 1470 | 1532 | { |
| 1471 | - if ($word == '') |
|
| 1472 | - continue; |
|
| 1533 | + if ($word == '') { |
|
| 1534 | + continue; |
|
| 1535 | + } |
|
| 1473 | 1536 | |
| 1474 | - if ($search_params['subject_only']) |
|
| 1475 | - $andQueryParts[] = 'pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '}'; |
|
| 1476 | - else |
|
| 1477 | - $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 . '})'; |
|
| 1537 | + if ($search_params['subject_only']) { |
|
| 1538 | + $andQueryParts[] = 'pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '}'; |
|
| 1539 | + } else { |
|
| 1540 | + $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 . '})'; |
|
| 1541 | + } |
|
| 1478 | 1542 | $searchq_parameters['search_' . $index] = '%' . strtr($word, array('_' => '\\_', '%' => '\\%')) . '%'; |
| 1479 | 1543 | } |
| 1480 | 1544 | |
| 1481 | 1545 | $searchQuery = ' 1=1'; |
| 1482 | - if (!empty($andQueryParts)) |
|
| 1483 | - $searchQuery = implode(!empty($search_params['searchtype']) && $search_params['searchtype'] == 2 ? ' OR ' : ' AND ', $andQueryParts); |
|
| 1546 | + if (!empty($andQueryParts)) { |
|
| 1547 | + $searchQuery = implode(!empty($search_params['searchtype']) && $search_params['searchtype'] == 2 ? ' OR ' : ' AND ', $andQueryParts); |
|
| 1548 | + } |
|
| 1484 | 1549 | |
| 1485 | 1550 | // Age limits? |
| 1486 | 1551 | $timeQuery = ''; |
| 1487 | - if (!empty($search_params['minage'])) |
|
| 1488 | - $timeQuery .= ' AND pm.msgtime < ' . (time() - $search_params['minage'] * 86400); |
|
| 1489 | - if (!empty($search_params['maxage'])) |
|
| 1490 | - $timeQuery .= ' AND pm.msgtime > ' . (time() - $search_params['maxage'] * 86400); |
|
| 1552 | + if (!empty($search_params['minage'])) { |
|
| 1553 | + $timeQuery .= ' AND pm.msgtime < ' . (time() - $search_params['minage'] * 86400); |
|
| 1554 | + } |
|
| 1555 | + if (!empty($search_params['maxage'])) { |
|
| 1556 | + $timeQuery .= ' AND pm.msgtime > ' . (time() - $search_params['maxage'] * 86400); |
|
| 1557 | + } |
|
| 1491 | 1558 | |
| 1492 | 1559 | // If we have errors - return back to the first screen... |
| 1493 | 1560 | if (!empty($context['search_errors'])) |
@@ -1573,8 +1640,9 @@ discard block |
||
| 1573 | 1640 | ) |
| 1574 | 1641 | ); |
| 1575 | 1642 | $real_pm_ids = array(); |
| 1576 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1577 | - $real_pm_ids[$row['id_pm_head']] = $row['id_pm']; |
|
| 1643 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1644 | + $real_pm_ids[$row['id_pm_head']] = $row['id_pm']; |
|
| 1645 | + } |
|
| 1578 | 1646 | $smcFunc['db_free_result']($request); |
| 1579 | 1647 | } |
| 1580 | 1648 | |
@@ -1604,8 +1672,9 @@ discard block |
||
| 1604 | 1672 | ); |
| 1605 | 1673 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1606 | 1674 | { |
| 1607 | - if ($context['folder'] == 'sent' || empty($row['bcc'])) |
|
| 1608 | - $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>'; |
|
| 1675 | + if ($context['folder'] == 'sent' || empty($row['bcc'])) { |
|
| 1676 | + $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>'; |
|
| 1677 | + } |
|
| 1609 | 1678 | |
| 1610 | 1679 | if ($row['id_member_to'] == $user_info['id'] && $context['folder'] != 'sent') |
| 1611 | 1680 | { |
@@ -1626,12 +1695,14 @@ discard block |
||
| 1626 | 1695 | while ($row2 = $smcFunc['db_fetch_assoc']($request2)) |
| 1627 | 1696 | { |
| 1628 | 1697 | $l_id = $row2['id_label']; |
| 1629 | - if (isset($context['labels'][$l_id])) |
|
| 1630 | - $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
| 1698 | + if (isset($context['labels'][$l_id])) { |
|
| 1699 | + $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
| 1700 | + } |
|
| 1631 | 1701 | |
| 1632 | 1702 | // Here we find the first label on a message - for linking to posts in results |
| 1633 | - if (!isset($context['first_label'][$row['id_pm']]) && $row['in_inbox'] != 1) |
|
| 1634 | - $context['first_label'][$row['id_pm']] = $l_id; |
|
| 1703 | + if (!isset($context['first_label'][$row['id_pm']]) && $row['in_inbox'] != 1) { |
|
| 1704 | + $context['first_label'][$row['id_pm']] = $l_id; |
|
| 1705 | + } |
|
| 1635 | 1706 | } |
| 1636 | 1707 | |
| 1637 | 1708 | $smcFunc['db_free_result']($request2); |
@@ -1758,8 +1829,9 @@ discard block |
||
| 1758 | 1829 | list ($postCount) = $smcFunc['db_fetch_row']($request); |
| 1759 | 1830 | $smcFunc['db_free_result']($request); |
| 1760 | 1831 | |
| 1761 | - if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) |
|
| 1762 | - fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
| 1832 | + if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) { |
|
| 1833 | + fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
| 1834 | + } |
|
| 1763 | 1835 | } |
| 1764 | 1836 | |
| 1765 | 1837 | // Quoting/Replying to a message? |
@@ -1768,8 +1840,9 @@ discard block |
||
| 1768 | 1840 | $pmsg = (int) $_REQUEST['pmsg']; |
| 1769 | 1841 | |
| 1770 | 1842 | // Make sure this is yours. |
| 1771 | - if (!isAccessiblePM($pmsg)) |
|
| 1772 | - fatal_lang_error('no_access', false); |
|
| 1843 | + if (!isAccessiblePM($pmsg)) { |
|
| 1844 | + fatal_lang_error('no_access', false); |
|
| 1845 | + } |
|
| 1773 | 1846 | |
| 1774 | 1847 | // Work out whether this is one you've received? |
| 1775 | 1848 | $request = $smcFunc['db_query']('', ' |
@@ -1806,8 +1879,9 @@ discard block |
||
| 1806 | 1879 | 'id_pm' => $pmsg, |
| 1807 | 1880 | ) |
| 1808 | 1881 | ); |
| 1809 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1810 | - fatal_lang_error('pm_not_yours', false); |
|
| 1882 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1883 | + fatal_lang_error('pm_not_yours', false); |
|
| 1884 | + } |
|
| 1811 | 1885 | $row_quoted = $smcFunc['db_fetch_assoc']($request); |
| 1812 | 1886 | $smcFunc['db_free_result']($request); |
| 1813 | 1887 | |
@@ -1818,9 +1892,9 @@ discard block |
||
| 1818 | 1892 | // Add 'Re: ' to it.... |
| 1819 | 1893 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 1820 | 1894 | { |
| 1821 | - if ($language === $user_info['language']) |
|
| 1822 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 1823 | - else |
|
| 1895 | + if ($language === $user_info['language']) { |
|
| 1896 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 1897 | + } else |
|
| 1824 | 1898 | { |
| 1825 | 1899 | loadLanguage('index', $language, false); |
| 1826 | 1900 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -1829,22 +1903,25 @@ discard block |
||
| 1829 | 1903 | cache_put_data('response_prefix', $context['response_prefix'], 600); |
| 1830 | 1904 | } |
| 1831 | 1905 | $form_subject = $row_quoted['subject']; |
| 1832 | - if ($context['reply'] && trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
| 1833 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
| 1906 | + if ($context['reply'] && trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
| 1907 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
| 1908 | + } |
|
| 1834 | 1909 | |
| 1835 | 1910 | if (isset($_REQUEST['quote'])) |
| 1836 | 1911 | { |
| 1837 | 1912 | // Remove any nested quotes and <br>... |
| 1838 | 1913 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $row_quoted['body']); |
| 1839 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
| 1840 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 1841 | - if (empty($row_quoted['id_member'])) |
|
| 1842 | - $form_message = '[quote author="' . $row_quoted['real_name'] . '"]' . "\n" . $form_message . "\n" . '[/quote]'; |
|
| 1843 | - else |
|
| 1844 | - $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]'; |
|
| 1914 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
| 1915 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 1916 | + } |
|
| 1917 | + if (empty($row_quoted['id_member'])) { |
|
| 1918 | + $form_message = '[quote author="' . $row_quoted['real_name'] . '"]' . "\n" . $form_message . "\n" . '[/quote]'; |
|
| 1919 | + } else { |
|
| 1920 | + $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]'; |
|
| 1921 | + } |
|
| 1922 | + } else { |
|
| 1923 | + $form_message = ''; |
|
| 1845 | 1924 | } |
| 1846 | - else |
|
| 1847 | - $form_message = ''; |
|
| 1848 | 1925 | |
| 1849 | 1926 | // Do the BBC thang on the message. |
| 1850 | 1927 | $row_quoted['body'] = parse_bbc($row_quoted['body'], true, 'pm' . $row_quoted['id_pm']); |
@@ -1865,8 +1942,7 @@ discard block |
||
| 1865 | 1942 | 'timestamp' => forum_time(true, $row_quoted['msgtime']), |
| 1866 | 1943 | 'body' => $row_quoted['body'] |
| 1867 | 1944 | ); |
| 1868 | - } |
|
| 1869 | - else |
|
| 1945 | + } else |
|
| 1870 | 1946 | { |
| 1871 | 1947 | $context['quoted_message'] = false; |
| 1872 | 1948 | $form_subject = ''; |
@@ -1885,11 +1961,12 @@ discard block |
||
| 1885 | 1961 | if ($_REQUEST['u'] == 'all' && isset($row_quoted)) |
| 1886 | 1962 | { |
| 1887 | 1963 | // Firstly, to reply to all we clearly already have $row_quoted - so have the original member from. |
| 1888 | - if ($row_quoted['id_member'] != $user_info['id']) |
|
| 1889 | - $context['recipients']['to'][] = array( |
|
| 1964 | + if ($row_quoted['id_member'] != $user_info['id']) { |
|
| 1965 | + $context['recipients']['to'][] = array( |
|
| 1890 | 1966 | 'id' => $row_quoted['id_member'], |
| 1891 | 1967 | 'name' => $smcFunc['htmlspecialchars']($row_quoted['real_name']), |
| 1892 | 1968 | ); |
| 1969 | + } |
|
| 1893 | 1970 | |
| 1894 | 1971 | // Now to get the others. |
| 1895 | 1972 | $request = $smcFunc['db_query']('', ' |
@@ -1905,18 +1982,19 @@ discard block |
||
| 1905 | 1982 | 'not_bcc' => 0, |
| 1906 | 1983 | ) |
| 1907 | 1984 | ); |
| 1908 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1909 | - $context['recipients']['to'][] = array( |
|
| 1985 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1986 | + $context['recipients']['to'][] = array( |
|
| 1910 | 1987 | 'id' => $row['id_member'], |
| 1911 | 1988 | 'name' => $row['real_name'], |
| 1912 | 1989 | ); |
| 1990 | + } |
|
| 1913 | 1991 | $smcFunc['db_free_result']($request); |
| 1914 | - } |
|
| 1915 | - else |
|
| 1992 | + } else |
|
| 1916 | 1993 | { |
| 1917 | 1994 | $_REQUEST['u'] = explode(',', $_REQUEST['u']); |
| 1918 | - foreach ($_REQUEST['u'] as $key => $uID) |
|
| 1919 | - $_REQUEST['u'][$key] = (int) $uID; |
|
| 1995 | + foreach ($_REQUEST['u'] as $key => $uID) { |
|
| 1996 | + $_REQUEST['u'][$key] = (int) $uID; |
|
| 1997 | + } |
|
| 1920 | 1998 | |
| 1921 | 1999 | $_REQUEST['u'] = array_unique($_REQUEST['u']); |
| 1922 | 2000 | |
@@ -1930,22 +2008,24 @@ discard block |
||
| 1930 | 2008 | 'limit' => count($_REQUEST['u']), |
| 1931 | 2009 | ) |
| 1932 | 2010 | ); |
| 1933 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1934 | - $context['recipients']['to'][] = array( |
|
| 2011 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2012 | + $context['recipients']['to'][] = array( |
|
| 1935 | 2013 | 'id' => $row['id_member'], |
| 1936 | 2014 | 'name' => $row['real_name'], |
| 1937 | 2015 | ); |
| 2016 | + } |
|
| 1938 | 2017 | $smcFunc['db_free_result']($request); |
| 1939 | 2018 | } |
| 1940 | 2019 | |
| 1941 | 2020 | // Get a literal name list in case the user has JavaScript disabled. |
| 1942 | 2021 | $names = array(); |
| 1943 | - foreach ($context['recipients']['to'] as $to) |
|
| 1944 | - $names[] = $to['name']; |
|
| 2022 | + foreach ($context['recipients']['to'] as $to) { |
|
| 2023 | + $names[] = $to['name']; |
|
| 2024 | + } |
|
| 1945 | 2025 | $context['to_value'] = empty($names) ? '' : '"' . implode('", "', $names) . '"'; |
| 2026 | + } else { |
|
| 2027 | + $context['to_value'] = ''; |
|
| 1946 | 2028 | } |
| 1947 | - else |
|
| 1948 | - $context['to_value'] = ''; |
|
| 1949 | 2029 | |
| 1950 | 2030 | // Set the defaults... |
| 1951 | 2031 | $context['subject'] = $form_subject; |
@@ -2015,8 +2095,9 @@ discard block |
||
| 2015 | 2095 | |
| 2016 | 2096 | // validate with loadMemberData() |
| 2017 | 2097 | $memberResult = loadMemberData($user_info['id'], false); |
| 2018 | - if (!$memberResult) |
|
| 2019 | - fatal_lang_error('not_a_user', false); |
|
| 2098 | + if (!$memberResult) { |
|
| 2099 | + fatal_lang_error('not_a_user', false); |
|
| 2100 | + } |
|
| 2020 | 2101 | list ($memID) = $memberResult; |
| 2021 | 2102 | |
| 2022 | 2103 | // drafts is where the functions reside |
@@ -2042,9 +2123,9 @@ discard block |
||
| 2042 | 2123 | $context['sub_template'] = 'send'; |
| 2043 | 2124 | loadJavaScriptFile('PersonalMessage.js', array('defer' => false), 'smf_pms'); |
| 2044 | 2125 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
| 2126 | + } else { |
|
| 2127 | + $context['sub_template'] = 'pm'; |
|
| 2045 | 2128 | } |
| 2046 | - else |
|
| 2047 | - $context['sub_template'] = 'pm'; |
|
| 2048 | 2129 | |
| 2049 | 2130 | $context['page_title'] = $txt['send_message']; |
| 2050 | 2131 | |
@@ -2105,10 +2186,11 @@ discard block |
||
| 2105 | 2186 | ); |
| 2106 | 2187 | if ($smcFunc['db_num_rows']($request) == 0) |
| 2107 | 2188 | { |
| 2108 | - if (!isset($_REQUEST['xml'])) |
|
| 2109 | - fatal_lang_error('pm_not_yours', false); |
|
| 2110 | - else |
|
| 2111 | - $error_types[] = 'pm_not_yours'; |
|
| 2189 | + if (!isset($_REQUEST['xml'])) { |
|
| 2190 | + fatal_lang_error('pm_not_yours', false); |
|
| 2191 | + } else { |
|
| 2192 | + $error_types[] = 'pm_not_yours'; |
|
| 2193 | + } |
|
| 2112 | 2194 | } |
| 2113 | 2195 | $row_quoted = $smcFunc['db_fetch_assoc']($request); |
| 2114 | 2196 | $smcFunc['db_free_result']($request); |
@@ -2155,14 +2237,16 @@ discard block |
||
| 2155 | 2237 | $context['post_error'][$error_type] = true; |
| 2156 | 2238 | if (isset($txt['error_' . $error_type])) |
| 2157 | 2239 | { |
| 2158 | - if ($error_type == 'long_message') |
|
| 2159 | - $txt['error_' . $error_type] = sprintf($txt['error_' . $error_type], $modSettings['max_messageLength']); |
|
| 2240 | + if ($error_type == 'long_message') { |
|
| 2241 | + $txt['error_' . $error_type] = sprintf($txt['error_' . $error_type], $modSettings['max_messageLength']); |
|
| 2242 | + } |
|
| 2160 | 2243 | $context['post_error']['messages'][] = $txt['error_' . $error_type]; |
| 2161 | 2244 | } |
| 2162 | 2245 | |
| 2163 | 2246 | // If it's not a minor error flag it as such. |
| 2164 | - if (!in_array($error_type, array('new_reply', 'not_approved', 'new_replies', 'old_topic', 'need_qr_verification', 'no_subject'))) |
|
| 2165 | - $context['error_type'] = 'serious'; |
|
| 2247 | + if (!in_array($error_type, array('new_reply', 'not_approved', 'new_replies', 'old_topic', 'need_qr_verification', 'no_subject'))) { |
|
| 2248 | + $context['error_type'] = 'serious'; |
|
| 2249 | + } |
|
| 2166 | 2250 | } |
| 2167 | 2251 | |
| 2168 | 2252 | // We need to load the editor once more. |
@@ -2220,8 +2304,9 @@ discard block |
||
| 2220 | 2304 | require_once($sourcedir . '/Subs-Auth.php'); |
| 2221 | 2305 | |
| 2222 | 2306 | // PM Drafts enabled and needed? |
| 2223 | - if ($context['drafts_pm_save'] && (isset($_POST['save_draft']) || isset($_POST['id_pm_draft']))) |
|
| 2224 | - require_once($sourcedir . '/Drafts.php'); |
|
| 2307 | + if ($context['drafts_pm_save'] && (isset($_POST['save_draft']) || isset($_POST['id_pm_draft']))) { |
|
| 2308 | + require_once($sourcedir . '/Drafts.php'); |
|
| 2309 | + } |
|
| 2225 | 2310 | |
| 2226 | 2311 | loadLanguage('PersonalMessage', '', false); |
| 2227 | 2312 | |
@@ -2251,24 +2336,27 @@ discard block |
||
| 2251 | 2336 | |
| 2252 | 2337 | if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) |
| 2253 | 2338 | { |
| 2254 | - if (!isset($_REQUEST['xml'])) |
|
| 2255 | - fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
| 2256 | - else |
|
| 2257 | - $post_errors[] = 'pm_too_many_per_hour'; |
|
| 2339 | + if (!isset($_REQUEST['xml'])) { |
|
| 2340 | + fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
| 2341 | + } else { |
|
| 2342 | + $post_errors[] = 'pm_too_many_per_hour'; |
|
| 2343 | + } |
|
| 2258 | 2344 | } |
| 2259 | 2345 | } |
| 2260 | 2346 | |
| 2261 | 2347 | // If your session timed out, show an error, but do allow to re-submit. |
| 2262 | - if (!isset($_REQUEST['xml']) && checkSession('post', '', false) != '') |
|
| 2263 | - $post_errors[] = 'session_timeout'; |
|
| 2348 | + if (!isset($_REQUEST['xml']) && checkSession('post', '', false) != '') { |
|
| 2349 | + $post_errors[] = 'session_timeout'; |
|
| 2350 | + } |
|
| 2264 | 2351 | |
| 2265 | 2352 | $_REQUEST['subject'] = isset($_REQUEST['subject']) ? trim($_REQUEST['subject']) : ''; |
| 2266 | 2353 | $_REQUEST['to'] = empty($_POST['to']) ? (empty($_GET['to']) ? '' : $_GET['to']) : $_POST['to']; |
| 2267 | 2354 | $_REQUEST['bcc'] = empty($_POST['bcc']) ? (empty($_GET['bcc']) ? '' : $_GET['bcc']) : $_POST['bcc']; |
| 2268 | 2355 | |
| 2269 | 2356 | // Route the input from the 'u' parameter to the 'to'-list. |
| 2270 | - if (!empty($_POST['u'])) |
|
| 2271 | - $_POST['recipient_to'] = explode(',', $_POST['u']); |
|
| 2357 | + if (!empty($_POST['u'])) { |
|
| 2358 | + $_POST['recipient_to'] = explode(',', $_POST['u']); |
|
| 2359 | + } |
|
| 2272 | 2360 | |
| 2273 | 2361 | // Construct the list of recipients. |
| 2274 | 2362 | $recipientList = array(); |
@@ -2280,8 +2368,9 @@ discard block |
||
| 2280 | 2368 | $recipientList[$recipientType] = array(); |
| 2281 | 2369 | if (!empty($_POST['recipient_' . $recipientType]) && is_array($_POST['recipient_' . $recipientType])) |
| 2282 | 2370 | { |
| 2283 | - foreach ($_POST['recipient_' . $recipientType] as $recipient) |
|
| 2284 | - $recipientList[$recipientType][] = (int) $recipient; |
|
| 2371 | + foreach ($_POST['recipient_' . $recipientType] as $recipient) { |
|
| 2372 | + $recipientList[$recipientType][] = (int) $recipient; |
|
| 2373 | + } |
|
| 2285 | 2374 | } |
| 2286 | 2375 | |
| 2287 | 2376 | // Are there also literal names set? |
@@ -2295,10 +2384,11 @@ discard block |
||
| 2295 | 2384 | |
| 2296 | 2385 | foreach ($namedRecipientList[$recipientType] as $index => $recipient) |
| 2297 | 2386 | { |
| 2298 | - if (strlen(trim($recipient)) > 0) |
|
| 2299 | - $namedRecipientList[$recipientType][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($recipient))); |
|
| 2300 | - else |
|
| 2301 | - unset($namedRecipientList[$recipientType][$index]); |
|
| 2387 | + if (strlen(trim($recipient)) > 0) { |
|
| 2388 | + $namedRecipientList[$recipientType][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($recipient))); |
|
| 2389 | + } else { |
|
| 2390 | + unset($namedRecipientList[$recipientType][$index]); |
|
| 2391 | + } |
|
| 2302 | 2392 | } |
| 2303 | 2393 | |
| 2304 | 2394 | if (!empty($namedRecipientList[$recipientType])) |
@@ -2328,8 +2418,9 @@ discard block |
||
| 2328 | 2418 | } |
| 2329 | 2419 | |
| 2330 | 2420 | // Selected a recipient to be deleted? Remove them now. |
| 2331 | - if (!empty($_POST['delete_recipient'])) |
|
| 2332 | - $recipientList[$recipientType] = array_diff($recipientList[$recipientType], array((int) $_POST['delete_recipient'])); |
|
| 2421 | + if (!empty($_POST['delete_recipient'])) { |
|
| 2422 | + $recipientList[$recipientType] = array_diff($recipientList[$recipientType], array((int) $_POST['delete_recipient'])); |
|
| 2423 | + } |
|
| 2333 | 2424 | |
| 2334 | 2425 | // Make sure we don't include the same name twice |
| 2335 | 2426 | $recipientList[$recipientType] = array_unique($recipientList[$recipientType]); |
@@ -2339,8 +2430,9 @@ discard block |
||
| 2339 | 2430 | $is_recipient_change = !empty($_POST['delete_recipient']) || !empty($_POST['to_submit']) || !empty($_POST['bcc_submit']); |
| 2340 | 2431 | |
| 2341 | 2432 | // Check if there's at least one recipient. |
| 2342 | - if (empty($recipientList['to']) && empty($recipientList['bcc'])) |
|
| 2343 | - $post_errors[] = 'no_to'; |
|
| 2433 | + if (empty($recipientList['to']) && empty($recipientList['bcc'])) { |
|
| 2434 | + $post_errors[] = 'no_to'; |
|
| 2435 | + } |
|
| 2344 | 2436 | |
| 2345 | 2437 | // Make sure that we remove the members who did get it from the screen. |
| 2346 | 2438 | if (!$is_recipient_change) |
@@ -2354,28 +2446,31 @@ discard block |
||
| 2354 | 2446 | // Since we already have a post error, remove the previous one. |
| 2355 | 2447 | $post_errors = array_diff($post_errors, array('no_to')); |
| 2356 | 2448 | |
| 2357 | - foreach ($namesNotFound[$recipientType] as $name) |
|
| 2358 | - $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
| 2449 | + foreach ($namesNotFound[$recipientType] as $name) { |
|
| 2450 | + $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
| 2451 | + } |
|
| 2359 | 2452 | } |
| 2360 | 2453 | } |
| 2361 | 2454 | } |
| 2362 | 2455 | |
| 2363 | 2456 | // Did they make any mistakes? |
| 2364 | - if ($_REQUEST['subject'] == '') |
|
| 2365 | - $post_errors[] = 'no_subject'; |
|
| 2366 | - if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') |
|
| 2367 | - $post_errors[] = 'no_message'; |
|
| 2368 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_REQUEST['message']) > $modSettings['max_messageLength']) |
|
| 2369 | - $post_errors[] = 'long_message'; |
|
| 2370 | - else |
|
| 2457 | + if ($_REQUEST['subject'] == '') { |
|
| 2458 | + $post_errors[] = 'no_subject'; |
|
| 2459 | + } |
|
| 2460 | + if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') { |
|
| 2461 | + $post_errors[] = 'no_message'; |
|
| 2462 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_REQUEST['message']) > $modSettings['max_messageLength']) { |
|
| 2463 | + $post_errors[] = 'long_message'; |
|
| 2464 | + } else |
|
| 2371 | 2465 | { |
| 2372 | 2466 | // Preparse the message. |
| 2373 | 2467 | $message = $_REQUEST['message']; |
| 2374 | 2468 | preparsecode($message); |
| 2375 | 2469 | |
| 2376 | 2470 | // Make sure there's still some content left without the tags. |
| 2377 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($smcFunc['htmlspecialchars']($message, ENT_QUOTES), false), '<img>')) === '' && (!allowedTo('admin_forum') || strpos($message, '[html]') === false)) |
|
| 2378 | - $post_errors[] = 'no_message'; |
|
| 2471 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($smcFunc['htmlspecialchars']($message, ENT_QUOTES), false), '<img>')) === '' && (!allowedTo('admin_forum') || strpos($message, '[html]') === false)) { |
|
| 2472 | + $post_errors[] = 'no_message'; |
|
| 2473 | + } |
|
| 2379 | 2474 | } |
| 2380 | 2475 | |
| 2381 | 2476 | // Wrong verification code? |
@@ -2387,13 +2482,15 @@ discard block |
||
| 2387 | 2482 | ); |
| 2388 | 2483 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
| 2389 | 2484 | |
| 2390 | - if (is_array($context['require_verification'])) |
|
| 2391 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 2485 | + if (is_array($context['require_verification'])) { |
|
| 2486 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 2487 | + } |
|
| 2392 | 2488 | } |
| 2393 | 2489 | |
| 2394 | 2490 | // If they did, give a chance to make ammends. |
| 2395 | - if (!empty($post_errors) && !$is_recipient_change && !isset($_REQUEST['preview']) && !isset($_REQUEST['xml'])) |
|
| 2396 | - return messagePostError($post_errors, $namedRecipientList, $recipientList); |
|
| 2491 | + if (!empty($post_errors) && !$is_recipient_change && !isset($_REQUEST['preview']) && !isset($_REQUEST['xml'])) { |
|
| 2492 | + return messagePostError($post_errors, $namedRecipientList, $recipientList); |
|
| 2493 | + } |
|
| 2397 | 2494 | |
| 2398 | 2495 | // Want to take a second glance before you send? |
| 2399 | 2496 | if (isset($_REQUEST['preview'])) |
@@ -2424,8 +2521,9 @@ discard block |
||
| 2424 | 2521 | foreach ($namesNotFound as $recipientType => $names) |
| 2425 | 2522 | { |
| 2426 | 2523 | $post_errors[] = 'bad_' . $recipientType; |
| 2427 | - foreach ($names as $name) |
|
| 2428 | - $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
| 2524 | + foreach ($names as $name) { |
|
| 2525 | + $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
| 2526 | + } |
|
| 2429 | 2527 | } |
| 2430 | 2528 | |
| 2431 | 2529 | return messagePostError(array(), $namedRecipientList, $recipientList); |
@@ -2455,13 +2553,14 @@ discard block |
||
| 2455 | 2553 | checkSubmitOnce('check'); |
| 2456 | 2554 | |
| 2457 | 2555 | // Do the actual sending of the PM. |
| 2458 | - if (!empty($recipientList['to']) || !empty($recipientList['bcc'])) |
|
| 2459 | - $context['send_log'] = sendpm($recipientList, $_REQUEST['subject'], $_REQUEST['message'], true, null, !empty($_REQUEST['pm_head']) ? (int) $_REQUEST['pm_head'] : 0); |
|
| 2460 | - else |
|
| 2461 | - $context['send_log'] = array( |
|
| 2556 | + if (!empty($recipientList['to']) || !empty($recipientList['bcc'])) { |
|
| 2557 | + $context['send_log'] = sendpm($recipientList, $_REQUEST['subject'], $_REQUEST['message'], true, null, !empty($_REQUEST['pm_head']) ? (int) $_REQUEST['pm_head'] : 0); |
|
| 2558 | + } else { |
|
| 2559 | + $context['send_log'] = array( |
|
| 2462 | 2560 | 'sent' => array(), |
| 2463 | 2561 | 'failed' => array() |
| 2464 | 2562 | ); |
| 2563 | + } |
|
| 2465 | 2564 | |
| 2466 | 2565 | // Mark the message as "replied to". |
| 2467 | 2566 | if (!empty($context['send_log']['sent']) && !empty($_REQUEST['replied_to']) && isset($_REQUEST['f']) && $_REQUEST['f'] == 'inbox') |
@@ -2479,11 +2578,12 @@ discard block |
||
| 2479 | 2578 | } |
| 2480 | 2579 | |
| 2481 | 2580 | // If one or more of the recipient were invalid, go back to the post screen with the failed usernames. |
| 2482 | - if (!empty($context['send_log']['failed'])) |
|
| 2483 | - return messagePostError($post_errors, $namesNotFound, array( |
|
| 2581 | + if (!empty($context['send_log']['failed'])) { |
|
| 2582 | + return messagePostError($post_errors, $namesNotFound, array( |
|
| 2484 | 2583 | 'to' => array_intersect($recipientList['to'], $context['send_log']['failed']), |
| 2485 | 2584 | 'bcc' => array_intersect($recipientList['bcc'], $context['send_log']['failed']) |
| 2486 | 2585 | )); |
| 2586 | + } |
|
| 2487 | 2587 | |
| 2488 | 2588 | // Message sent successfully? |
| 2489 | 2589 | if (!empty($context['send_log']) && empty($context['send_log']['failed'])) |
@@ -2491,8 +2591,9 @@ discard block |
||
| 2491 | 2591 | $context['current_label_redirect'] = $context['current_label_redirect'] . ';done=sent'; |
| 2492 | 2592 | |
| 2493 | 2593 | // If we had a PM draft for this one, then its time to remove it since it was just sent |
| 2494 | - if ($context['drafts_pm_save'] && !empty($_POST['id_pm_draft'])) |
|
| 2495 | - DeleteDraft($_POST['id_pm_draft']); |
|
| 2594 | + if ($context['drafts_pm_save'] && !empty($_POST['id_pm_draft'])) { |
|
| 2595 | + DeleteDraft($_POST['id_pm_draft']); |
|
| 2596 | + } |
|
| 2496 | 2597 | } |
| 2497 | 2598 | |
| 2498 | 2599 | // Go back to the where they sent from, if possible... |
@@ -2507,24 +2608,28 @@ discard block |
||
| 2507 | 2608 | |
| 2508 | 2609 | checkSession('request'); |
| 2509 | 2610 | |
| 2510 | - if (isset($_REQUEST['del_selected'])) |
|
| 2511 | - $_REQUEST['pm_action'] = 'delete'; |
|
| 2611 | + if (isset($_REQUEST['del_selected'])) { |
|
| 2612 | + $_REQUEST['pm_action'] = 'delete'; |
|
| 2613 | + } |
|
| 2512 | 2614 | |
| 2513 | 2615 | if (isset($_REQUEST['pm_action']) && $_REQUEST['pm_action'] != '' && !empty($_REQUEST['pms']) && is_array($_REQUEST['pms'])) |
| 2514 | 2616 | { |
| 2515 | - foreach ($_REQUEST['pms'] as $pm) |
|
| 2516 | - $_REQUEST['pm_actions'][(int) $pm] = $_REQUEST['pm_action']; |
|
| 2617 | + foreach ($_REQUEST['pms'] as $pm) { |
|
| 2618 | + $_REQUEST['pm_actions'][(int) $pm] = $_REQUEST['pm_action']; |
|
| 2619 | + } |
|
| 2517 | 2620 | } |
| 2518 | 2621 | |
| 2519 | - if (empty($_REQUEST['pm_actions'])) |
|
| 2520 | - redirectexit($context['current_label_redirect']); |
|
| 2622 | + if (empty($_REQUEST['pm_actions'])) { |
|
| 2623 | + redirectexit($context['current_label_redirect']); |
|
| 2624 | + } |
|
| 2521 | 2625 | |
| 2522 | 2626 | // If we are in conversation, we may need to apply this to every message in the conversation. |
| 2523 | 2627 | if ($context['display_mode'] == 2 && isset($_REQUEST['conversation'])) |
| 2524 | 2628 | { |
| 2525 | 2629 | $id_pms = array(); |
| 2526 | - foreach ($_REQUEST['pm_actions'] as $pm => $dummy) |
|
| 2527 | - $id_pms[] = (int) $pm; |
|
| 2630 | + foreach ($_REQUEST['pm_actions'] as $pm => $dummy) { |
|
| 2631 | + $id_pms[] = (int) $pm; |
|
| 2632 | + } |
|
| 2528 | 2633 | |
| 2529 | 2634 | $request = $smcFunc['db_query']('', ' |
| 2530 | 2635 | SELECT id_pm_head, id_pm |
@@ -2535,8 +2640,9 @@ discard block |
||
| 2535 | 2640 | ) |
| 2536 | 2641 | ); |
| 2537 | 2642 | $pm_heads = array(); |
| 2538 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2539 | - $pm_heads[$row['id_pm_head']] = $row['id_pm']; |
|
| 2643 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2644 | + $pm_heads[$row['id_pm_head']] = $row['id_pm']; |
|
| 2645 | + } |
|
| 2540 | 2646 | $smcFunc['db_free_result']($request); |
| 2541 | 2647 | |
| 2542 | 2648 | $request = $smcFunc['db_query']('', ' |
@@ -2550,8 +2656,9 @@ discard block |
||
| 2550 | 2656 | // Copy the action from the single to PM to the others. |
| 2551 | 2657 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2552 | 2658 | { |
| 2553 | - if (isset($pm_heads[$row['id_pm_head']]) && isset($_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]])) |
|
| 2554 | - $_REQUEST['pm_actions'][$row['id_pm']] = $_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]]; |
|
| 2659 | + if (isset($pm_heads[$row['id_pm_head']]) && isset($_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]])) { |
|
| 2660 | + $_REQUEST['pm_actions'][$row['id_pm']] = $_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]]; |
|
| 2661 | + } |
|
| 2555 | 2662 | } |
| 2556 | 2663 | $smcFunc['db_free_result']($request); |
| 2557 | 2664 | } |
@@ -2562,22 +2669,21 @@ discard block |
||
| 2562 | 2669 | $labels = array(); |
| 2563 | 2670 | foreach ($_REQUEST['pm_actions'] as $pm => $action) |
| 2564 | 2671 | { |
| 2565 | - if ($action === 'delete') |
|
| 2566 | - $to_delete[] = (int) $pm; |
|
| 2567 | - else |
|
| 2672 | + if ($action === 'delete') { |
|
| 2673 | + $to_delete[] = (int) $pm; |
|
| 2674 | + } else |
|
| 2568 | 2675 | { |
| 2569 | 2676 | if (substr($action, 0, 4) == 'add_') |
| 2570 | 2677 | { |
| 2571 | 2678 | $type = 'add'; |
| 2572 | 2679 | $action = substr($action, 4); |
| 2573 | - } |
|
| 2574 | - elseif (substr($action, 0, 4) == 'rem_') |
|
| 2680 | + } elseif (substr($action, 0, 4) == 'rem_') |
|
| 2575 | 2681 | { |
| 2576 | 2682 | $type = 'rem'; |
| 2577 | 2683 | $action = substr($action, 4); |
| 2684 | + } else { |
|
| 2685 | + $type = 'unk'; |
|
| 2578 | 2686 | } |
| 2579 | - else |
|
| 2580 | - $type = 'unk'; |
|
| 2581 | 2687 | |
| 2582 | 2688 | if ($action == '-1' || (int) $action > 0) |
| 2583 | 2689 | { |
@@ -2588,8 +2694,9 @@ discard block |
||
| 2588 | 2694 | } |
| 2589 | 2695 | |
| 2590 | 2696 | // Deleting, it looks like? |
| 2591 | - if (!empty($to_delete)) |
|
| 2592 | - deleteMessages($to_delete, $context['display_mode'] == 2 ? null : $context['folder']); |
|
| 2697 | + if (!empty($to_delete)) { |
|
| 2698 | + deleteMessages($to_delete, $context['display_mode'] == 2 ? null : $context['folder']); |
|
| 2699 | + } |
|
| 2593 | 2700 | |
| 2594 | 2701 | // Are we labeling anything? |
| 2595 | 2702 | if (!empty($to_label) && $context['folder'] == 'inbox') |
@@ -2655,8 +2762,7 @@ discard block |
||
| 2655 | 2762 | } |
| 2656 | 2763 | |
| 2657 | 2764 | $smcFunc['db_free_result']($request2); |
| 2658 | - } |
|
| 2659 | - elseif ($type == 'rem') |
|
| 2765 | + } elseif ($type == 'rem') |
|
| 2660 | 2766 | { |
| 2661 | 2767 | // If we're removing from the inbox, see if we have at least one other label. |
| 2662 | 2768 | // This query is faster than the one above |
@@ -2688,21 +2794,25 @@ discard block |
||
| 2688 | 2794 | if ($to_label[$row['id_pm']] != '-1') |
| 2689 | 2795 | { |
| 2690 | 2796 | // If this label is in the list and we're not adding it, remove it |
| 2691 | - if (array_key_exists($to_label[$row['id_pm']], $labels) && $type !== 'add') |
|
| 2692 | - unset($labels[$to_label[$row['id_pm']]]); |
|
| 2693 | - else if ($type !== 'rem') |
|
| 2694 | - $labels[$to_label[$row['id_pm']]] = $to_label[$row['id_pm']]; |
|
| 2797 | + if (array_key_exists($to_label[$row['id_pm']], $labels) && $type !== 'add') { |
|
| 2798 | + unset($labels[$to_label[$row['id_pm']]]); |
|
| 2799 | + } else if ($type !== 'rem') { |
|
| 2800 | + $labels[$to_label[$row['id_pm']]] = $to_label[$row['id_pm']]; |
|
| 2801 | + } |
|
| 2695 | 2802 | } |
| 2696 | 2803 | |
| 2697 | 2804 | // Removing all labels or just removing the inbox label |
| 2698 | - if ($type == 'rem' && empty($labels)) |
|
| 2699 | - $in_inbox = (empty($context['can_remove_inbox']) ? 1 : 0); |
|
| 2805 | + if ($type == 'rem' && empty($labels)) { |
|
| 2806 | + $in_inbox = (empty($context['can_remove_inbox']) ? 1 : 0); |
|
| 2807 | + } |
|
| 2700 | 2808 | // Adding new labels, but removing inbox and applying new ones |
| 2701 | - elseif ($type == 'add' && !empty($options['pm_remove_inbox_label']) && !empty($labels)) |
|
| 2702 | - $in_inbox = 0; |
|
| 2809 | + elseif ($type == 'add' && !empty($options['pm_remove_inbox_label']) && !empty($labels)) { |
|
| 2810 | + $in_inbox = 0; |
|
| 2811 | + } |
|
| 2703 | 2812 | // Just adding it to the inbox |
| 2704 | - else |
|
| 2705 | - $in_inbox = 1; |
|
| 2813 | + else { |
|
| 2814 | + $in_inbox = 1; |
|
| 2815 | + } |
|
| 2706 | 2816 | |
| 2707 | 2817 | // Are we adding it to or removing it from the inbox? |
| 2708 | 2818 | if ($in_inbox != $row['in_inbox']) |
@@ -2744,8 +2854,9 @@ discard block |
||
| 2744 | 2854 | if (!empty($labels_to_apply)) |
| 2745 | 2855 | { |
| 2746 | 2856 | $inserts = array(); |
| 2747 | - foreach ($labels_to_apply as $label) |
|
| 2748 | - $inserts[] = array($row['id_pm'], $label); |
|
| 2857 | + foreach ($labels_to_apply as $label) { |
|
| 2858 | + $inserts[] = array($row['id_pm'], $label); |
|
| 2859 | + } |
|
| 2749 | 2860 | |
| 2750 | 2861 | $smcFunc['db_insert']('', |
| 2751 | 2862 | '{db_prefix}pm_labeled_messages', |
@@ -2789,11 +2900,13 @@ discard block |
||
| 2789 | 2900 | checkSession('get'); |
| 2790 | 2901 | |
| 2791 | 2902 | // If all then delete all messages the user has. |
| 2792 | - if ($_REQUEST['f'] == 'all') |
|
| 2793 | - deleteMessages(null, null); |
|
| 2903 | + if ($_REQUEST['f'] == 'all') { |
|
| 2904 | + deleteMessages(null, null); |
|
| 2905 | + } |
|
| 2794 | 2906 | // Otherwise just the selected folder. |
| 2795 | - else |
|
| 2796 | - deleteMessages(null, $_REQUEST['f'] != 'sent' ? 'inbox' : 'sent'); |
|
| 2907 | + else { |
|
| 2908 | + deleteMessages(null, $_REQUEST['f'] != 'sent' ? 'inbox' : 'sent'); |
|
| 2909 | + } |
|
| 2797 | 2910 | |
| 2798 | 2911 | // Done... all gone. |
| 2799 | 2912 | redirectexit($context['current_label_redirect']); |
@@ -2830,8 +2943,9 @@ discard block |
||
| 2830 | 2943 | 'msgtime' => $deleteTime, |
| 2831 | 2944 | ) |
| 2832 | 2945 | ); |
| 2833 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 2834 | - $toDelete[] = $row[0]; |
|
| 2946 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 2947 | + $toDelete[] = $row[0]; |
|
| 2948 | + } |
|
| 2835 | 2949 | $smcFunc['db_free_result']($request); |
| 2836 | 2950 | |
| 2837 | 2951 | // Select all messages in their inbox older than $deleteTime. |
@@ -2848,8 +2962,9 @@ discard block |
||
| 2848 | 2962 | 'msgtime' => $deleteTime, |
| 2849 | 2963 | ) |
| 2850 | 2964 | ); |
| 2851 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2852 | - $toDelete[] = $row['id_pm']; |
|
| 2965 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2966 | + $toDelete[] = $row['id_pm']; |
|
| 2967 | + } |
|
| 2853 | 2968 | $smcFunc['db_free_result']($request); |
| 2854 | 2969 | |
| 2855 | 2970 | // Delete the actual messages. |
@@ -2880,26 +2995,29 @@ discard block |
||
| 2880 | 2995 | { |
| 2881 | 2996 | global $user_info, $smcFunc; |
| 2882 | 2997 | |
| 2883 | - if ($owner === null) |
|
| 2884 | - $owner = array($user_info['id']); |
|
| 2885 | - elseif (empty($owner)) |
|
| 2886 | - return; |
|
| 2887 | - elseif (!is_array($owner)) |
|
| 2888 | - $owner = array($owner); |
|
| 2998 | + if ($owner === null) { |
|
| 2999 | + $owner = array($user_info['id']); |
|
| 3000 | + } elseif (empty($owner)) { |
|
| 3001 | + return; |
|
| 3002 | + } elseif (!is_array($owner)) { |
|
| 3003 | + $owner = array($owner); |
|
| 3004 | + } |
|
| 2889 | 3005 | |
| 2890 | 3006 | if ($personal_messages !== null) |
| 2891 | 3007 | { |
| 2892 | - if (empty($personal_messages) || !is_array($personal_messages)) |
|
| 2893 | - return; |
|
| 3008 | + if (empty($personal_messages) || !is_array($personal_messages)) { |
|
| 3009 | + return; |
|
| 3010 | + } |
|
| 2894 | 3011 | |
| 2895 | - foreach ($personal_messages as $index => $delete_id) |
|
| 2896 | - $personal_messages[$index] = (int) $delete_id; |
|
| 3012 | + foreach ($personal_messages as $index => $delete_id) { |
|
| 3013 | + $personal_messages[$index] = (int) $delete_id; |
|
| 3014 | + } |
|
| 2897 | 3015 | |
| 2898 | 3016 | $where = ' |
| 2899 | 3017 | AND id_pm IN ({array_int:pm_list})'; |
| 3018 | + } else { |
|
| 3019 | + $where = ''; |
|
| 2900 | 3020 | } |
| 2901 | - else |
|
| 2902 | - $where = ''; |
|
| 2903 | 3021 | |
| 2904 | 3022 | if ($folder == 'sent' || $folder === null) |
| 2905 | 3023 | { |
@@ -2934,17 +3052,19 @@ discard block |
||
| 2934 | 3052 | // ...And update the statistics accordingly - now including unread messages!. |
| 2935 | 3053 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2936 | 3054 | { |
| 2937 | - if ($row['is_read']) |
|
| 2938 | - updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'])); |
|
| 2939 | - else |
|
| 2940 | - 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'])); |
|
| 3055 | + if ($row['is_read']) { |
|
| 3056 | + updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'])); |
|
| 3057 | + } else { |
|
| 3058 | + 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'])); |
|
| 3059 | + } |
|
| 2941 | 3060 | |
| 2942 | 3061 | // If this is the current member we need to make their message count correct. |
| 2943 | 3062 | if ($user_info['id'] == $row['id_member']) |
| 2944 | 3063 | { |
| 2945 | 3064 | $user_info['messages'] -= $row['num_deleted_messages']; |
| 2946 | - if (!($row['is_read'])) |
|
| 2947 | - $user_info['unread_messages'] -= $row['num_deleted_messages']; |
|
| 3065 | + if (!($row['is_read'])) { |
|
| 3066 | + $user_info['unread_messages'] -= $row['num_deleted_messages']; |
|
| 3067 | + } |
|
| 2948 | 3068 | } |
| 2949 | 3069 | } |
| 2950 | 3070 | $smcFunc['db_free_result']($request); |
@@ -3012,8 +3132,9 @@ discard block |
||
| 3012 | 3132 | ) |
| 3013 | 3133 | ); |
| 3014 | 3134 | $remove_pms = array(); |
| 3015 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3016 | - $remove_pms[] = $row['sender']; |
|
| 3135 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3136 | + $remove_pms[] = $row['sender']; |
|
| 3137 | + } |
|
| 3017 | 3138 | $smcFunc['db_free_result']($request); |
| 3018 | 3139 | |
| 3019 | 3140 | if (!empty($remove_pms)) |
@@ -3058,8 +3179,9 @@ discard block |
||
| 3058 | 3179 | { |
| 3059 | 3180 | global $user_info, $context, $smcFunc; |
| 3060 | 3181 | |
| 3061 | - if ($owner === null) |
|
| 3062 | - $owner = $user_info['id']; |
|
| 3182 | + if ($owner === null) { |
|
| 3183 | + $owner = $user_info['id']; |
|
| 3184 | + } |
|
| 3063 | 3185 | |
| 3064 | 3186 | $in_inbox = ''; |
| 3065 | 3187 | |
@@ -3083,8 +3205,7 @@ discard block |
||
| 3083 | 3205 | } |
| 3084 | 3206 | |
| 3085 | 3207 | $smcFunc['db_free_result']($get_messages); |
| 3086 | - } |
|
| 3087 | - elseif ($label = '-1') |
|
| 3208 | + } elseif ($label = '-1') |
|
| 3088 | 3209 | { |
| 3089 | 3210 | // Marking all PMs in your inbox read |
| 3090 | 3211 | $in_inbox = ' |
@@ -3109,8 +3230,9 @@ discard block |
||
| 3109 | 3230 | { |
| 3110 | 3231 | if ($owner == $user_info['id']) |
| 3111 | 3232 | { |
| 3112 | - foreach ($context['labels'] as $label) |
|
| 3113 | - $context['labels'][(int) $label['id']]['unread_messages'] = 0; |
|
| 3233 | + foreach ($context['labels'] as $label) { |
|
| 3234 | + $context['labels'][(int) $label['id']]['unread_messages'] = 0; |
|
| 3235 | + } |
|
| 3114 | 3236 | } |
| 3115 | 3237 | |
| 3116 | 3238 | $result = $smcFunc['db_query']('', ' |
@@ -3130,8 +3252,9 @@ discard block |
||
| 3130 | 3252 | { |
| 3131 | 3253 | $total_unread += $row['num']; |
| 3132 | 3254 | |
| 3133 | - if ($owner != $user_info['id'] || empty($row['id_pm'])) |
|
| 3134 | - continue; |
|
| 3255 | + if ($owner != $user_info['id'] || empty($row['id_pm'])) { |
|
| 3256 | + continue; |
|
| 3257 | + } |
|
| 3135 | 3258 | |
| 3136 | 3259 | $this_labels = array(); |
| 3137 | 3260 | |
@@ -3155,11 +3278,13 @@ discard block |
||
| 3155 | 3278 | |
| 3156 | 3279 | $smcFunc['db_free_result']($result2); |
| 3157 | 3280 | |
| 3158 | - foreach ($this_labels as $this_label) |
|
| 3159 | - $context['labels'][$this_label]['unread_messages'] += $row['num']; |
|
| 3281 | + foreach ($this_labels as $this_label) { |
|
| 3282 | + $context['labels'][$this_label]['unread_messages'] += $row['num']; |
|
| 3283 | + } |
|
| 3160 | 3284 | |
| 3161 | - if ($row['in_inbox'] == 1) |
|
| 3162 | - $context['labels'][-1]['unread_messages'] += $row['num']; |
|
| 3285 | + if ($row['in_inbox'] == 1) { |
|
| 3286 | + $context['labels'][-1]['unread_messages'] += $row['num']; |
|
| 3287 | + } |
|
| 3163 | 3288 | } |
| 3164 | 3289 | $smcFunc['db_free_result']($result); |
| 3165 | 3290 | |
@@ -3168,8 +3293,9 @@ discard block |
||
| 3168 | 3293 | updateMemberData($owner, array('unread_messages' => $total_unread)); |
| 3169 | 3294 | |
| 3170 | 3295 | // If it was for the current member, reflect this in the $user_info array too. |
| 3171 | - if ($owner == $user_info['id']) |
|
| 3172 | - $user_info['unread_messages'] = $total_unread; |
|
| 3296 | + if ($owner == $user_info['id']) { |
|
| 3297 | + $user_info['unread_messages'] = $total_unread; |
|
| 3298 | + } |
|
| 3173 | 3299 | } |
| 3174 | 3300 | } |
| 3175 | 3301 | |
@@ -3197,8 +3323,9 @@ discard block |
||
| 3197 | 3323 | // Add all existing labels to the array to save, slashing them as necessary... |
| 3198 | 3324 | foreach ($context['labels'] as $label) |
| 3199 | 3325 | { |
| 3200 | - if ($label['id'] != -1) |
|
| 3201 | - $the_labels[$label['id']] = $label['name']; |
|
| 3326 | + if ($label['id'] != -1) { |
|
| 3327 | + $the_labels[$label['id']] = $label['name']; |
|
| 3328 | + } |
|
| 3202 | 3329 | } |
| 3203 | 3330 | |
| 3204 | 3331 | if (isset($_POST[$context['session_var']])) |
@@ -3217,8 +3344,9 @@ discard block |
||
| 3217 | 3344 | { |
| 3218 | 3345 | $_POST['label'] = strtr($smcFunc['htmlspecialchars'](trim($_POST['label'])), array(',' => ',')); |
| 3219 | 3346 | |
| 3220 | - if ($smcFunc['strlen']($_POST['label']) > 30) |
|
| 3221 | - $_POST['label'] = $smcFunc['substr']($_POST['label'], 0, 30); |
|
| 3347 | + if ($smcFunc['strlen']($_POST['label']) > 30) { |
|
| 3348 | + $_POST['label'] = $smcFunc['substr']($_POST['label'], 0, 30); |
|
| 3349 | + } |
|
| 3222 | 3350 | if ($_POST['label'] != '') |
| 3223 | 3351 | { |
| 3224 | 3352 | $the_labels[] = $_POST['label']; |
@@ -3239,24 +3367,25 @@ discard block |
||
| 3239 | 3367 | { |
| 3240 | 3368 | foreach ($the_labels as $id => $name) |
| 3241 | 3369 | { |
| 3242 | - if ($id == -1) |
|
| 3243 | - continue; |
|
| 3244 | - elseif (isset($_POST['label_name'][$id])) |
|
| 3370 | + if ($id == -1) { |
|
| 3371 | + continue; |
|
| 3372 | + } elseif (isset($_POST['label_name'][$id])) |
|
| 3245 | 3373 | { |
| 3246 | 3374 | $_POST['label_name'][$id] = trim(strtr($smcFunc['htmlspecialchars']($_POST['label_name'][$id]), array(',' => ','))); |
| 3247 | 3375 | |
| 3248 | - if ($smcFunc['strlen']($_POST['label_name'][$id]) > 30) |
|
| 3249 | - $_POST['label_name'][$id] = $smcFunc['substr']($_POST['label_name'][$id], 0, 30); |
|
| 3376 | + if ($smcFunc['strlen']($_POST['label_name'][$id]) > 30) { |
|
| 3377 | + $_POST['label_name'][$id] = $smcFunc['substr']($_POST['label_name'][$id], 0, 30); |
|
| 3378 | + } |
|
| 3250 | 3379 | if ($_POST['label_name'][$id] != '') |
| 3251 | 3380 | { |
| 3252 | 3381 | // Changing the name of this label? |
| 3253 | - if ($the_labels[$id] != $_POST['label_name'][$id]) |
|
| 3254 | - $label_updates[$id] = $_POST['label_name'][$id]; |
|
| 3382 | + if ($the_labels[$id] != $_POST['label_name'][$id]) { |
|
| 3383 | + $label_updates[$id] = $_POST['label_name'][$id]; |
|
| 3384 | + } |
|
| 3255 | 3385 | |
| 3256 | 3386 | $the_labels[(int) $id] = $_POST['label_name'][$id]; |
| 3257 | 3387 | |
| 3258 | - } |
|
| 3259 | - else |
|
| 3388 | + } else |
|
| 3260 | 3389 | { |
| 3261 | 3390 | unset($the_labels[(int) $id]); |
| 3262 | 3391 | $labels_to_remove[] = $id; |
@@ -3270,8 +3399,9 @@ discard block |
||
| 3270 | 3399 | if (!empty($labels_to_add)) |
| 3271 | 3400 | { |
| 3272 | 3401 | $inserts = array(); |
| 3273 | - foreach ($labels_to_add AS $label) |
|
| 3274 | - $inserts[] = array($user_info['id'], $label); |
|
| 3402 | + foreach ($labels_to_add AS $label) { |
|
| 3403 | + $inserts[] = array($user_info['id'], $label); |
|
| 3404 | + } |
|
| 3275 | 3405 | |
| 3276 | 3406 | $smcFunc['db_insert']('', '{db_prefix}pm_labels', array('id_member' => 'int', 'name' => 'string-30'), $inserts, array()); |
| 3277 | 3407 | } |
@@ -3361,8 +3491,9 @@ discard block |
||
| 3361 | 3491 | // Each action... |
| 3362 | 3492 | foreach ($rule['actions'] as $k2 => $action) |
| 3363 | 3493 | { |
| 3364 | - if ($action['t'] != 'lab' || !in_array($action['v'], $labels_to_remove)) |
|
| 3365 | - continue; |
|
| 3494 | + if ($action['t'] != 'lab' || !in_array($action['v'], $labels_to_remove)) { |
|
| 3495 | + continue; |
|
| 3496 | + } |
|
| 3366 | 3497 | |
| 3367 | 3498 | $rule_changes[] = $rule['id']; |
| 3368 | 3499 | |
@@ -3377,8 +3508,8 @@ discard block |
||
| 3377 | 3508 | { |
| 3378 | 3509 | $rule_changes = array_unique($rule_changes); |
| 3379 | 3510 | // Update/delete as appropriate. |
| 3380 | - foreach ($rule_changes as $k => $id) |
|
| 3381 | - if (!empty($context['rules'][$id]['actions'])) |
|
| 3511 | + foreach ($rule_changes as $k => $id) { |
|
| 3512 | + if (!empty($context['rules'][$id]['actions'])) |
|
| 3382 | 3513 | { |
| 3383 | 3514 | $smcFunc['db_query']('', ' |
| 3384 | 3515 | UPDATE {db_prefix}pm_rules |
@@ -3391,12 +3522,13 @@ discard block |
||
| 3391 | 3522 | 'actions' => json_encode($context['rules'][$id]['actions']), |
| 3392 | 3523 | ) |
| 3393 | 3524 | ); |
| 3525 | + } |
|
| 3394 | 3526 | unset($rule_changes[$k]); |
| 3395 | 3527 | } |
| 3396 | 3528 | |
| 3397 | 3529 | // Anything left here means it's lost all actions... |
| 3398 | - if (!empty($rule_changes)) |
|
| 3399 | - $smcFunc['db_query']('', ' |
|
| 3530 | + if (!empty($rule_changes)) { |
|
| 3531 | + $smcFunc['db_query']('', ' |
|
| 3400 | 3532 | DELETE FROM {db_prefix}pm_rules |
| 3401 | 3533 | WHERE id_rule IN ({array_int:rule_list}) |
| 3402 | 3534 | AND id_member = {int:current_member}', |
@@ -3405,6 +3537,7 @@ discard block |
||
| 3405 | 3537 | 'rule_list' => $rule_changes, |
| 3406 | 3538 | ) |
| 3407 | 3539 | ); |
| 3540 | + } |
|
| 3408 | 3541 | } |
| 3409 | 3542 | |
| 3410 | 3543 | // Make sure we're not caching this! |
@@ -3474,8 +3607,9 @@ discard block |
||
| 3474 | 3607 | // Save the fields. |
| 3475 | 3608 | saveProfileFields(); |
| 3476 | 3609 | |
| 3477 | - if (!empty($profile_vars)) |
|
| 3478 | - updateMemberData($user_info['id'], $profile_vars); |
|
| 3610 | + if (!empty($profile_vars)) { |
|
| 3611 | + updateMemberData($user_info['id'], $profile_vars); |
|
| 3612 | + } |
|
| 3479 | 3613 | } |
| 3480 | 3614 | |
| 3481 | 3615 | setupProfileContext( |
@@ -3500,13 +3634,15 @@ discard block |
||
| 3500 | 3634 | global $user_info, $language, $modSettings, $smcFunc; |
| 3501 | 3635 | |
| 3502 | 3636 | // Check that this feature is even enabled! |
| 3503 | - if (empty($modSettings['enableReportPM']) || empty($_REQUEST['pmsg'])) |
|
| 3504 | - fatal_lang_error('no_access', false); |
|
| 3637 | + if (empty($modSettings['enableReportPM']) || empty($_REQUEST['pmsg'])) { |
|
| 3638 | + fatal_lang_error('no_access', false); |
|
| 3639 | + } |
|
| 3505 | 3640 | |
| 3506 | 3641 | $pmsg = (int) $_REQUEST['pmsg']; |
| 3507 | 3642 | |
| 3508 | - if (!isAccessiblePM($pmsg, 'inbox')) |
|
| 3509 | - fatal_lang_error('no_access', false); |
|
| 3643 | + if (!isAccessiblePM($pmsg, 'inbox')) { |
|
| 3644 | + fatal_lang_error('no_access', false); |
|
| 3645 | + } |
|
| 3510 | 3646 | |
| 3511 | 3647 | $context['pm_id'] = $pmsg; |
| 3512 | 3648 | $context['page_title'] = $txt['pm_report_title']; |
@@ -3528,8 +3664,9 @@ discard block |
||
| 3528 | 3664 | ) |
| 3529 | 3665 | ); |
| 3530 | 3666 | $context['admins'] = array(); |
| 3531 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3532 | - $context['admins'][$row['id_member']] = $row['real_name']; |
|
| 3667 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3668 | + $context['admins'][$row['id_member']] = $row['real_name']; |
|
| 3669 | + } |
|
| 3533 | 3670 | $smcFunc['db_free_result']($request); |
| 3534 | 3671 | |
| 3535 | 3672 | // How many admins in total? |
@@ -3558,8 +3695,9 @@ discard block |
||
| 3558 | 3695 | ) |
| 3559 | 3696 | ); |
| 3560 | 3697 | // Can only be a hacker here! |
| 3561 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 3562 | - fatal_lang_error('no_access', false); |
|
| 3698 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 3699 | + fatal_lang_error('no_access', false); |
|
| 3700 | + } |
|
| 3563 | 3701 | list ($subject, $body, $time, $memberFromID, $memberFromName) = $smcFunc['db_fetch_row']($request); |
| 3564 | 3702 | $smcFunc['db_free_result']($request); |
| 3565 | 3703 | |
@@ -3583,15 +3721,17 @@ discard block |
||
| 3583 | 3721 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3584 | 3722 | { |
| 3585 | 3723 | // If it's hidden still don't reveal their names - privacy after all ;) |
| 3586 | - if ($row['bcc']) |
|
| 3587 | - $hidden_recipients++; |
|
| 3588 | - else |
|
| 3589 | - $recipients[] = '[url=' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . ']' . $row['to_name'] . '[/url]'; |
|
| 3724 | + if ($row['bcc']) { |
|
| 3725 | + $hidden_recipients++; |
|
| 3726 | + } else { |
|
| 3727 | + $recipients[] = '[url=' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . ']' . $row['to_name'] . '[/url]'; |
|
| 3728 | + } |
|
| 3590 | 3729 | } |
| 3591 | 3730 | $smcFunc['db_free_result']($request); |
| 3592 | 3731 | |
| 3593 | - if ($hidden_recipients) |
|
| 3594 | - $recipients[] = sprintf($txt['pm_report_pm_hidden'], $hidden_recipients); |
|
| 3732 | + if ($hidden_recipients) { |
|
| 3733 | + $recipients[] = sprintf($txt['pm_report_pm_hidden'], $hidden_recipients); |
|
| 3734 | + } |
|
| 3595 | 3735 | |
| 3596 | 3736 | // Now let's get out and loop through the admins. |
| 3597 | 3737 | $request = $smcFunc['db_query']('', ' |
@@ -3607,8 +3747,9 @@ discard block |
||
| 3607 | 3747 | ); |
| 3608 | 3748 | |
| 3609 | 3749 | // Maybe we shouldn't advertise this? |
| 3610 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 3611 | - fatal_lang_error('no_access', false); |
|
| 3750 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 3751 | + fatal_lang_error('no_access', false); |
|
| 3752 | + } |
|
| 3612 | 3753 | |
| 3613 | 3754 | $memberFromName = un_htmlspecialchars($memberFromName); |
| 3614 | 3755 | |
@@ -3627,8 +3768,9 @@ discard block |
||
| 3627 | 3768 | // Make the body. |
| 3628 | 3769 | $report_body = str_replace(array('{REPORTER}', '{SENDER}'), array(un_htmlspecialchars($user_info['name']), $memberFromName), $txt['pm_report_pm_user_sent']); |
| 3629 | 3770 | $report_body .= "\n" . '[b]' . $_POST['reason'] . '[/b]' . "\n\n"; |
| 3630 | - if (!empty($recipients)) |
|
| 3631 | - $report_body .= $txt['pm_report_pm_other_recipients'] . ' ' . implode(', ', $recipients) . "\n\n"; |
|
| 3771 | + if (!empty($recipients)) { |
|
| 3772 | + $report_body .= $txt['pm_report_pm_other_recipients'] . ' ' . implode(', ', $recipients) . "\n\n"; |
|
| 3773 | + } |
|
| 3632 | 3774 | $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]'; |
| 3633 | 3775 | |
| 3634 | 3776 | // Plonk it in the array ;) |
@@ -3648,12 +3790,14 @@ discard block |
||
| 3648 | 3790 | $smcFunc['db_free_result']($request); |
| 3649 | 3791 | |
| 3650 | 3792 | // Send a different email for each language. |
| 3651 | - foreach ($messagesToSend as $lang => $message) |
|
| 3652 | - sendpm($message['recipients'], $message['subject'], $message['body']); |
|
| 3793 | + foreach ($messagesToSend as $lang => $message) { |
|
| 3794 | + sendpm($message['recipients'], $message['subject'], $message['body']); |
|
| 3795 | + } |
|
| 3653 | 3796 | |
| 3654 | 3797 | // Give the user their own language back! |
| 3655 | - if (!empty($modSettings['userLanguage'])) |
|
| 3656 | - loadLanguage('PersonalMessage', '', false); |
|
| 3798 | + if (!empty($modSettings['userLanguage'])) { |
|
| 3799 | + loadLanguage('PersonalMessage', '', false); |
|
| 3800 | + } |
|
| 3657 | 3801 | |
| 3658 | 3802 | // Leave them with a template. |
| 3659 | 3803 | $context['sub_template'] = 'report_message_complete'; |
@@ -3699,8 +3843,9 @@ discard block |
||
| 3699 | 3843 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3700 | 3844 | { |
| 3701 | 3845 | // Hide hidden groups! |
| 3702 | - if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) |
|
| 3703 | - continue; |
|
| 3846 | + if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) { |
|
| 3847 | + continue; |
|
| 3848 | + } |
|
| 3704 | 3849 | |
| 3705 | 3850 | $context['groups'][$row['id_group']] = $row['group_name']; |
| 3706 | 3851 | } |
@@ -3726,9 +3871,10 @@ discard block |
||
| 3726 | 3871 | $context['rule'] = $context['rules'][$context['rid']]; |
| 3727 | 3872 | $members = array(); |
| 3728 | 3873 | // Need to get member names! |
| 3729 | - foreach ($context['rule']['criteria'] as $k => $criteria) |
|
| 3730 | - if ($criteria['t'] == 'mid' && !empty($criteria['v'])) |
|
| 3874 | + foreach ($context['rule']['criteria'] as $k => $criteria) { |
|
| 3875 | + if ($criteria['t'] == 'mid' && !empty($criteria['v'])) |
|
| 3731 | 3876 | $members[(int) $criteria['v']] = $k; |
| 3877 | + } |
|
| 3732 | 3878 | |
| 3733 | 3879 | if (!empty($members)) |
| 3734 | 3880 | { |
@@ -3740,19 +3886,20 @@ discard block |
||
| 3740 | 3886 | 'member_list' => array_keys($members), |
| 3741 | 3887 | ) |
| 3742 | 3888 | ); |
| 3743 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3744 | - $context['rule']['criteria'][$members[$row['id_member']]]['v'] = $row['member_name']; |
|
| 3889 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3890 | + $context['rule']['criteria'][$members[$row['id_member']]]['v'] = $row['member_name']; |
|
| 3891 | + } |
|
| 3745 | 3892 | $smcFunc['db_free_result']($request); |
| 3746 | 3893 | } |
| 3747 | - } |
|
| 3748 | - else |
|
| 3749 | - $context['rule'] = array( |
|
| 3894 | + } else { |
|
| 3895 | + $context['rule'] = array( |
|
| 3750 | 3896 | 'id' => '', |
| 3751 | 3897 | 'name' => '', |
| 3752 | 3898 | 'criteria' => array(), |
| 3753 | 3899 | 'actions' => array(), |
| 3754 | 3900 | 'logic' => 'and', |
| 3755 | 3901 | ); |
| 3902 | + } |
|
| 3756 | 3903 | } |
| 3757 | 3904 | // Saving? |
| 3758 | 3905 | elseif (isset($_GET['save'])) |
@@ -3762,22 +3909,25 @@ discard block |
||
| 3762 | 3909 | |
| 3763 | 3910 | // Name is easy! |
| 3764 | 3911 | $ruleName = $smcFunc['htmlspecialchars'](trim($_POST['rule_name'])); |
| 3765 | - if (empty($ruleName)) |
|
| 3766 | - fatal_lang_error('pm_rule_no_name', false); |
|
| 3912 | + if (empty($ruleName)) { |
|
| 3913 | + fatal_lang_error('pm_rule_no_name', false); |
|
| 3914 | + } |
|
| 3767 | 3915 | |
| 3768 | 3916 | // Sanity check... |
| 3769 | - if (empty($_POST['ruletype']) || empty($_POST['acttype'])) |
|
| 3770 | - fatal_lang_error('pm_rule_no_criteria', false); |
|
| 3917 | + if (empty($_POST['ruletype']) || empty($_POST['acttype'])) { |
|
| 3918 | + fatal_lang_error('pm_rule_no_criteria', false); |
|
| 3919 | + } |
|
| 3771 | 3920 | |
| 3772 | 3921 | // Let's do the criteria first - it's also hardest! |
| 3773 | 3922 | $criteria = array(); |
| 3774 | 3923 | foreach ($_POST['ruletype'] as $ind => $type) |
| 3775 | 3924 | { |
| 3776 | 3925 | // Check everything is here... |
| 3777 | - if ($type == 'gid' && (!isset($_POST['ruledefgroup'][$ind]) || !isset($context['groups'][$_POST['ruledefgroup'][$ind]]))) |
|
| 3778 | - continue; |
|
| 3779 | - elseif ($type != 'bud' && !isset($_POST['ruledef'][$ind])) |
|
| 3780 | - continue; |
|
| 3926 | + if ($type == 'gid' && (!isset($_POST['ruledefgroup'][$ind]) || !isset($context['groups'][$_POST['ruledefgroup'][$ind]]))) { |
|
| 3927 | + continue; |
|
| 3928 | + } elseif ($type != 'bud' && !isset($_POST['ruledef'][$ind])) { |
|
| 3929 | + continue; |
|
| 3930 | + } |
|
| 3781 | 3931 | |
| 3782 | 3932 | // Members need to be found. |
| 3783 | 3933 | if ($type == 'mid') |
@@ -3801,13 +3951,13 @@ discard block |
||
| 3801 | 3951 | $smcFunc['db_free_result']($request); |
| 3802 | 3952 | |
| 3803 | 3953 | $criteria[] = array('t' => 'mid', 'v' => $memID); |
| 3954 | + } elseif ($type == 'bud') { |
|
| 3955 | + $criteria[] = array('t' => 'bud', 'v' => 1); |
|
| 3956 | + } elseif ($type == 'gid') { |
|
| 3957 | + $criteria[] = array('t' => 'gid', 'v' => (int) $_POST['ruledefgroup'][$ind]); |
|
| 3958 | + } elseif (in_array($type, array('sub', 'msg')) && trim($_POST['ruledef'][$ind]) != '') { |
|
| 3959 | + $criteria[] = array('t' => $type, 'v' => $smcFunc['htmlspecialchars'](trim($_POST['ruledef'][$ind]))); |
|
| 3804 | 3960 | } |
| 3805 | - elseif ($type == 'bud') |
|
| 3806 | - $criteria[] = array('t' => 'bud', 'v' => 1); |
|
| 3807 | - elseif ($type == 'gid') |
|
| 3808 | - $criteria[] = array('t' => 'gid', 'v' => (int) $_POST['ruledefgroup'][$ind]); |
|
| 3809 | - elseif (in_array($type, array('sub', 'msg')) && trim($_POST['ruledef'][$ind]) != '') |
|
| 3810 | - $criteria[] = array('t' => $type, 'v' => $smcFunc['htmlspecialchars'](trim($_POST['ruledef'][$ind]))); |
|
| 3811 | 3961 | } |
| 3812 | 3962 | |
| 3813 | 3963 | // Also do the actions! |
@@ -3817,26 +3967,29 @@ discard block |
||
| 3817 | 3967 | foreach ($_POST['acttype'] as $ind => $type) |
| 3818 | 3968 | { |
| 3819 | 3969 | // Picking a valid label? |
| 3820 | - if ($type == 'lab' && (!isset($_POST['labdef'][$ind]) || !isset($context['labels'][$_POST['labdef'][$ind]]))) |
|
| 3821 | - continue; |
|
| 3970 | + if ($type == 'lab' && (!isset($_POST['labdef'][$ind]) || !isset($context['labels'][$_POST['labdef'][$ind]]))) { |
|
| 3971 | + continue; |
|
| 3972 | + } |
|
| 3822 | 3973 | |
| 3823 | 3974 | // Record what we're doing. |
| 3824 | - if ($type == 'del') |
|
| 3825 | - $doDelete = 1; |
|
| 3826 | - elseif ($type == 'lab') |
|
| 3827 | - $actions[] = array('t' => 'lab', 'v' => (int) $_POST['labdef'][$ind]); |
|
| 3975 | + if ($type == 'del') { |
|
| 3976 | + $doDelete = 1; |
|
| 3977 | + } elseif ($type == 'lab') { |
|
| 3978 | + $actions[] = array('t' => 'lab', 'v' => (int) $_POST['labdef'][$ind]); |
|
| 3979 | + } |
|
| 3828 | 3980 | } |
| 3829 | 3981 | |
| 3830 | - if (empty($criteria) || (empty($actions) && !$doDelete)) |
|
| 3831 | - fatal_lang_error('pm_rule_no_criteria', false); |
|
| 3982 | + if (empty($criteria) || (empty($actions) && !$doDelete)) { |
|
| 3983 | + fatal_lang_error('pm_rule_no_criteria', false); |
|
| 3984 | + } |
|
| 3832 | 3985 | |
| 3833 | 3986 | // What are we storing? |
| 3834 | 3987 | $criteria = json_encode($criteria); |
| 3835 | 3988 | $actions = json_encode($actions); |
| 3836 | 3989 | |
| 3837 | 3990 | // Create the rule? |
| 3838 | - if (empty($context['rid'])) |
|
| 3839 | - $smcFunc['db_insert']('', |
|
| 3991 | + if (empty($context['rid'])) { |
|
| 3992 | + $smcFunc['db_insert']('', |
|
| 3840 | 3993 | '{db_prefix}pm_rules', |
| 3841 | 3994 | array( |
| 3842 | 3995 | 'id_member' => 'int', 'rule_name' => 'string', 'criteria' => 'string', 'actions' => 'string', |
@@ -3847,8 +4000,8 @@ discard block |
||
| 3847 | 4000 | ), |
| 3848 | 4001 | array('id_rule') |
| 3849 | 4002 | ); |
| 3850 | - else |
|
| 3851 | - $smcFunc['db_query']('', ' |
|
| 4003 | + } else { |
|
| 4004 | + $smcFunc['db_query']('', ' |
|
| 3852 | 4005 | UPDATE {db_prefix}pm_rules |
| 3853 | 4006 | SET rule_name = {string:rule_name}, criteria = {string:criteria}, actions = {string:actions}, |
| 3854 | 4007 | delete_pm = {int:delete_pm}, is_or = {int:is_or} |
@@ -3864,6 +4017,7 @@ discard block |
||
| 3864 | 4017 | 'actions' => $actions, |
| 3865 | 4018 | ) |
| 3866 | 4019 | ); |
| 4020 | + } |
|
| 3867 | 4021 | |
| 3868 | 4022 | redirectexit('action=pm;sa=manrules'); |
| 3869 | 4023 | } |
@@ -3872,11 +4026,12 @@ discard block |
||
| 3872 | 4026 | { |
| 3873 | 4027 | checkSession(); |
| 3874 | 4028 | $toDelete = array(); |
| 3875 | - foreach ($_POST['delrule'] as $k => $v) |
|
| 3876 | - $toDelete[] = (int) $k; |
|
| 4029 | + foreach ($_POST['delrule'] as $k => $v) { |
|
| 4030 | + $toDelete[] = (int) $k; |
|
| 4031 | + } |
|
| 3877 | 4032 | |
| 3878 | - if (!empty($toDelete)) |
|
| 3879 | - $smcFunc['db_query']('', ' |
|
| 4033 | + if (!empty($toDelete)) { |
|
| 4034 | + $smcFunc['db_query']('', ' |
|
| 3880 | 4035 | DELETE FROM {db_prefix}pm_rules |
| 3881 | 4036 | WHERE id_rule IN ({array_int:delete_list}) |
| 3882 | 4037 | AND id_member = {int:current_member}', |
@@ -3885,6 +4040,7 @@ discard block |
||
| 3885 | 4040 | 'delete_list' => $toDelete, |
| 3886 | 4041 | ) |
| 3887 | 4042 | ); |
| 4043 | + } |
|
| 3888 | 4044 | |
| 3889 | 4045 | redirectexit('action=pm;sa=manrules'); |
| 3890 | 4046 | } |
@@ -3903,8 +4059,9 @@ discard block |
||
| 3903 | 4059 | loadRules(); |
| 3904 | 4060 | |
| 3905 | 4061 | // No rules? |
| 3906 | - if (empty($context['rules'])) |
|
| 3907 | - return; |
|
| 4062 | + if (empty($context['rules'])) { |
|
| 4063 | + return; |
|
| 4064 | + } |
|
| 3908 | 4065 | |
| 3909 | 4066 | // Just unread ones? |
| 3910 | 4067 | $ruleQuery = $all_messages ? '' : ' AND pmr.is_new = 1'; |
@@ -3934,8 +4091,9 @@ discard block |
||
| 3934 | 4091 | // Loop through all the criteria hoping to make a match. |
| 3935 | 4092 | foreach ($rule['criteria'] as $criterium) |
| 3936 | 4093 | { |
| 3937 | - 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)) |
|
| 3938 | - $match = true; |
|
| 4094 | + 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)) { |
|
| 4095 | + $match = true; |
|
| 4096 | + } |
|
| 3939 | 4097 | // If we're adding and one criteria don't match then we stop! |
| 3940 | 4098 | elseif ($rule['logic'] == 'and') |
| 3941 | 4099 | { |
@@ -3947,17 +4105,18 @@ discard block |
||
| 3947 | 4105 | // If we have a match the rule must be true - act! |
| 3948 | 4106 | if ($match) |
| 3949 | 4107 | { |
| 3950 | - if ($rule['delete']) |
|
| 3951 | - $actions['deletes'][] = $row['id_pm']; |
|
| 3952 | - else |
|
| 4108 | + if ($rule['delete']) { |
|
| 4109 | + $actions['deletes'][] = $row['id_pm']; |
|
| 4110 | + } else |
|
| 3953 | 4111 | { |
| 3954 | 4112 | foreach ($rule['actions'] as $ruleAction) |
| 3955 | 4113 | { |
| 3956 | 4114 | if ($ruleAction['t'] == 'lab') |
| 3957 | 4115 | { |
| 3958 | 4116 | // Get a basic pot started! |
| 3959 | - if (!isset($actions['labels'][$row['id_pm']])) |
|
| 3960 | - $actions['labels'][$row['id_pm']] = array(); |
|
| 4117 | + if (!isset($actions['labels'][$row['id_pm']])) { |
|
| 4118 | + $actions['labels'][$row['id_pm']] = array(); |
|
| 4119 | + } |
|
| 3961 | 4120 | $actions['labels'][$row['id_pm']][] = $ruleAction['v']; |
| 3962 | 4121 | } |
| 3963 | 4122 | } |
@@ -3968,8 +4127,9 @@ discard block |
||
| 3968 | 4127 | $smcFunc['db_free_result']($request); |
| 3969 | 4128 | |
| 3970 | 4129 | // Deletes are easy! |
| 3971 | - if (!empty($actions['deletes'])) |
|
| 3972 | - deleteMessages($actions['deletes']); |
|
| 4130 | + if (!empty($actions['deletes'])) { |
|
| 4131 | + deleteMessages($actions['deletes']); |
|
| 4132 | + } |
|
| 3973 | 4133 | |
| 3974 | 4134 | // Relabel? |
| 3975 | 4135 | if (!empty($actions['labels'])) |
@@ -3996,8 +4156,7 @@ discard block |
||
| 3996 | 4156 | 'current_member' => $user_info['id'], |
| 3997 | 4157 | ) |
| 3998 | 4158 | ); |
| 3999 | - } |
|
| 4000 | - else |
|
| 4159 | + } else |
|
| 4001 | 4160 | { |
| 4002 | 4161 | $realLabels[] = $label['id']; |
| 4003 | 4162 | } |
@@ -4006,8 +4165,9 @@ discard block |
||
| 4006 | 4165 | |
| 4007 | 4166 | $inserts = array(); |
| 4008 | 4167 | // Now we insert the label info |
| 4009 | - foreach ($realLabels as $a_label) |
|
| 4010 | - $inserts[] = array($pm, $a_label); |
|
| 4168 | + foreach ($realLabels as $a_label) { |
|
| 4169 | + $inserts[] = array($pm, $a_label); |
|
| 4170 | + } |
|
| 4011 | 4171 | |
| 4012 | 4172 | $smcFunc['db_insert']('ignore', |
| 4013 | 4173 | '{db_prefix}pm_labeled_messages', |
@@ -4028,8 +4188,9 @@ discard block |
||
| 4028 | 4188 | { |
| 4029 | 4189 | global $user_info, $context, $smcFunc; |
| 4030 | 4190 | |
| 4031 | - if (isset($context['rules']) && !$reload) |
|
| 4032 | - return; |
|
| 4191 | + if (isset($context['rules']) && !$reload) { |
|
| 4192 | + return; |
|
| 4193 | + } |
|
| 4033 | 4194 | |
| 4034 | 4195 | $request = $smcFunc['db_query']('', ' |
| 4035 | 4196 | SELECT |
@@ -4053,8 +4214,9 @@ discard block |
||
| 4053 | 4214 | 'logic' => $row['is_or'] ? 'or' : 'and', |
| 4054 | 4215 | ); |
| 4055 | 4216 | |
| 4056 | - if ($row['delete_pm']) |
|
| 4057 | - $context['rules'][$row['id_rule']]['actions'][] = array('t' => 'del', 'v' => 1); |
|
| 4217 | + if ($row['delete_pm']) { |
|
| 4218 | + $context['rules'][$row['id_rule']]['actions'][] = array('t' => 'del', 'v' => 1); |
|
| 4219 | + } |
|
| 4058 | 4220 | } |
| 4059 | 4221 | $smcFunc['db_free_result']($request); |
| 4060 | 4222 | } |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * The news dispatcher; doesn't do anything, just delegates. |
@@ -67,8 +68,9 @@ discard block |
||
| 67 | 68 | ); |
| 68 | 69 | |
| 69 | 70 | // Force the right area... |
| 70 | - if (substr($_REQUEST['sa'], 0, 7) == 'mailing') |
|
| 71 | - $context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers'; |
|
| 71 | + if (substr($_REQUEST['sa'], 0, 7) == 'mailing') { |
|
| 72 | + $context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers'; |
|
| 73 | + } |
|
| 72 | 74 | |
| 73 | 75 | call_helper($subActions[$_REQUEST['sa']][0]); |
| 74 | 76 | } |
@@ -99,9 +101,10 @@ discard block |
||
| 99 | 101 | $temp_news = explode("\n", $modSettings['news']); |
| 100 | 102 | |
| 101 | 103 | // Remove the items that were selected. |
| 102 | - foreach ($temp_news as $i => $news) |
|
| 103 | - if (in_array($i, $_POST['remove'])) |
|
| 104 | + foreach ($temp_news as $i => $news) { |
|
| 105 | + if (in_array($i, $_POST['remove'])) |
|
| 104 | 106 | unset($temp_news[$i]); |
| 107 | + } |
|
| 105 | 108 | |
| 106 | 109 | // Update the database. |
| 107 | 110 | updateSettings(array('news' => implode("\n", $temp_news))); |
@@ -117,9 +120,9 @@ discard block |
||
| 117 | 120 | |
| 118 | 121 | foreach ($_POST['news'] as $i => $news) |
| 119 | 122 | { |
| 120 | - if (trim($news) == '') |
|
| 121 | - unset($_POST['news'][$i]); |
|
| 122 | - else |
|
| 123 | + if (trim($news) == '') { |
|
| 124 | + unset($_POST['news'][$i]); |
|
| 125 | + } else |
|
| 123 | 126 | { |
| 124 | 127 | $_POST['news'][$i] = $smcFunc['htmlspecialchars']($_POST['news'][$i], ENT_QUOTES); |
| 125 | 128 | preparsecode($_POST['news'][$i]); |
@@ -154,11 +157,12 @@ discard block |
||
| 154 | 157 | 'data' => array( |
| 155 | 158 | 'function' => function($news) |
| 156 | 159 | { |
| 157 | - if (is_numeric($news['id'])) |
|
| 158 | - return '<textarea id="data_' . $news['id'] . '" rows="3" cols="50" name="news[]" class="padding block">' . $news['unparsed'] . '</textarea> |
|
| 160 | + if (is_numeric($news['id'])) { |
|
| 161 | + return '<textarea id="data_' . $news['id'] . '" rows="3" cols="50" name="news[]" class="padding block">' . $news['unparsed'] . '</textarea> |
|
| 159 | 162 | <div class="floatleft" id="preview_' . $news['id'] . '"></div>'; |
| 160 | - else |
|
| 161 | - return $news['unparsed']; |
|
| 163 | + } else { |
|
| 164 | + return $news['unparsed']; |
|
| 165 | + } |
|
| 162 | 166 | }, |
| 163 | 167 | 'style' => 'width: 50%;', |
| 164 | 168 | ), |
@@ -183,10 +187,11 @@ discard block |
||
| 183 | 187 | 'data' => array( |
| 184 | 188 | 'function' => function($news) |
| 185 | 189 | { |
| 186 | - if (is_numeric($news['id'])) |
|
| 187 | - return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '" class="input_check">'; |
|
| 188 | - else |
|
| 189 | - return ''; |
|
| 190 | + if (is_numeric($news['id'])) { |
|
| 191 | + return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '" class="input_check">'; |
|
| 192 | + } else { |
|
| 193 | + return ''; |
|
| 194 | + } |
|
| 190 | 195 | }, |
| 191 | 196 | 'class' => 'centercol', |
| 192 | 197 | ), |
@@ -280,12 +285,13 @@ discard block |
||
| 280 | 285 | |
| 281 | 286 | $admin_current_news = array(); |
| 282 | 287 | // Ready the current news. |
| 283 | - foreach (explode("\n", $modSettings['news']) as $id => $line) |
|
| 284 | - $admin_current_news[$id] = array( |
|
| 288 | + foreach (explode("\n", $modSettings['news']) as $id => $line) { |
|
| 289 | + $admin_current_news[$id] = array( |
|
| 285 | 290 | 'id' => $id, |
| 286 | 291 | 'unparsed' => un_preparsecode($line), |
| 287 | 292 | 'parsed' => preg_replace('~<([/]?)form[^>]*?[>]*>~i', '<em class="smalltext"><$1form></em>', parse_bbc($line)), |
| 288 | 293 | ); |
| 294 | + } |
|
| 289 | 295 | |
| 290 | 296 | $admin_current_news['last'] = array( |
| 291 | 297 | 'id' => 'last', |
@@ -352,10 +358,11 @@ discard block |
||
| 352 | 358 | 'member_count' => 0, |
| 353 | 359 | ); |
| 354 | 360 | |
| 355 | - if ($row['min_posts'] == -1) |
|
| 356 | - $normalGroups[$row['id_group']] = $row['id_group']; |
|
| 357 | - else |
|
| 358 | - $postGroups[$row['id_group']] = $row['id_group']; |
|
| 361 | + if ($row['min_posts'] == -1) { |
|
| 362 | + $normalGroups[$row['id_group']] = $row['id_group']; |
|
| 363 | + } else { |
|
| 364 | + $postGroups[$row['id_group']] = $row['id_group']; |
|
| 365 | + } |
|
| 359 | 366 | } |
| 360 | 367 | $smcFunc['db_free_result']($request); |
| 361 | 368 | |
@@ -371,8 +378,9 @@ discard block |
||
| 371 | 378 | 'post_group_list' => $postGroups, |
| 372 | 379 | ) |
| 373 | 380 | ); |
| 374 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
| 375 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
| 381 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
| 382 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
| 383 | + } |
|
| 376 | 384 | $smcFunc['db_free_result']($query); |
| 377 | 385 | } |
| 378 | 386 | |
@@ -388,8 +396,9 @@ discard block |
||
| 388 | 396 | 'normal_group_list' => $normalGroups, |
| 389 | 397 | ) |
| 390 | 398 | ); |
| 391 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
| 392 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
| 399 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
| 400 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
| 401 | + } |
|
| 393 | 402 | $smcFunc['db_free_result']($query); |
| 394 | 403 | |
| 395 | 404 | // Also do those who have it as an additional membergroup - this ones more yucky... |
@@ -406,8 +415,9 @@ discard block |
||
| 406 | 415 | 'blank_string' => '', |
| 407 | 416 | ) |
| 408 | 417 | ); |
| 409 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
| 410 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
| 418 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
| 419 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
| 420 | + } |
|
| 411 | 421 | $smcFunc['db_free_result']($query); |
| 412 | 422 | } |
| 413 | 423 | |
@@ -458,10 +468,11 @@ discard block |
||
| 458 | 468 | { |
| 459 | 469 | $context[$key] = !empty($_REQUEST[$post]) ? $_REQUEST[$post] : ''; |
| 460 | 470 | |
| 461 | - if (empty($context[$key]) && empty($_REQUEST['xml'])) |
|
| 462 | - $context['post_error']['messages'][] = $txt['error_no_' . $post]; |
|
| 463 | - elseif (!empty($_REQUEST['xml'])) |
|
| 464 | - continue; |
|
| 471 | + if (empty($context[$key]) && empty($_REQUEST['xml'])) { |
|
| 472 | + $context['post_error']['messages'][] = $txt['error_no_' . $post]; |
|
| 473 | + } elseif (!empty($_REQUEST['xml'])) { |
|
| 474 | + continue; |
|
| 475 | + } |
|
| 465 | 476 | |
| 466 | 477 | preparsecode($context[$key]); |
| 467 | 478 | if ($html) |
@@ -540,10 +551,12 @@ discard block |
||
| 540 | 551 | |
| 541 | 552 | // Start by finding any members! |
| 542 | 553 | $toClean = array(); |
| 543 | - if (!empty($_POST['members'])) |
|
| 544 | - $toClean[] = 'members'; |
|
| 545 | - if (!empty($_POST['exclude_members'])) |
|
| 546 | - $toClean[] = 'exclude_members'; |
|
| 554 | + if (!empty($_POST['members'])) { |
|
| 555 | + $toClean[] = 'members'; |
|
| 556 | + } |
|
| 557 | + if (!empty($_POST['exclude_members'])) { |
|
| 558 | + $toClean[] = 'exclude_members'; |
|
| 559 | + } |
|
| 547 | 560 | if (!empty($toClean)) |
| 548 | 561 | { |
| 549 | 562 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -555,11 +568,13 @@ discard block |
||
| 555 | 568 | preg_match_all('~"([^"]+)"~', $_POST[$type], $matches); |
| 556 | 569 | $_POST[$type] = array_unique(array_merge($matches[1], explode(',', preg_replace('~"[^"]+"~', '', $_POST[$type])))); |
| 557 | 570 | |
| 558 | - foreach ($_POST[$type] as $index => $member) |
|
| 559 | - if (strlen(trim($member)) > 0) |
|
| 571 | + foreach ($_POST[$type] as $index => $member) { |
|
| 572 | + if (strlen(trim($member)) > 0) |
|
| 560 | 573 | $_POST[$type][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($member))); |
| 561 | - else |
|
| 562 | - unset($_POST[$type][$index]); |
|
| 574 | + } |
|
| 575 | + else { |
|
| 576 | + unset($_POST[$type][$index]); |
|
| 577 | + } |
|
| 563 | 578 | |
| 564 | 579 | // Find the members |
| 565 | 580 | $_POST[$type] = implode(',', array_keys(findMembers($_POST[$type]))); |
@@ -569,16 +584,18 @@ discard block |
||
| 569 | 584 | if (isset($_POST['member_list']) && is_array($_POST['member_list'])) |
| 570 | 585 | { |
| 571 | 586 | $members = array(); |
| 572 | - foreach ($_POST['member_list'] as $member_id) |
|
| 573 | - $members[] = (int) $member_id; |
|
| 587 | + foreach ($_POST['member_list'] as $member_id) { |
|
| 588 | + $members[] = (int) $member_id; |
|
| 589 | + } |
|
| 574 | 590 | $_POST['members'] = implode(',', $members); |
| 575 | 591 | } |
| 576 | 592 | |
| 577 | 593 | if (isset($_POST['exclude_member_list']) && is_array($_POST['exclude_member_list'])) |
| 578 | 594 | { |
| 579 | 595 | $members = array(); |
| 580 | - foreach ($_POST['exclude_member_list'] as $member_id) |
|
| 581 | - $members[] = (int) $member_id; |
|
| 596 | + foreach ($_POST['exclude_member_list'] as $member_id) { |
|
| 597 | + $members[] = (int) $member_id; |
|
| 598 | + } |
|
| 582 | 599 | $_POST['exclude_members'] = implode(',', $members); |
| 583 | 600 | } |
| 584 | 601 | |
@@ -602,8 +619,9 @@ discard block |
||
| 602 | 619 | 'current_time' => time(), |
| 603 | 620 | ) |
| 604 | 621 | ); |
| 605 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 606 | - $context['recipients']['exclude_members'][] = $row['id_member']; |
|
| 622 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 623 | + $context['recipients']['exclude_members'][] = $row['id_member']; |
|
| 624 | + } |
|
| 607 | 625 | $smcFunc['db_free_result']($request); |
| 608 | 626 | |
| 609 | 627 | $request = $smcFunc['db_query']('', ' |
@@ -638,8 +656,9 @@ discard block |
||
| 638 | 656 | WHERE email_address IN(' . implode(', ', $condition_array) . ')', |
| 639 | 657 | $condition_array_params |
| 640 | 658 | ); |
| 641 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 642 | - $context['recipients']['exclude_members'][] = $row['id_member']; |
|
| 659 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 660 | + $context['recipients']['exclude_members'][] = $row['id_member']; |
|
| 661 | + } |
|
| 643 | 662 | $smcFunc['db_free_result']($request); |
| 644 | 663 | } |
| 645 | 664 | |
@@ -657,10 +676,11 @@ discard block |
||
| 657 | 676 | ); |
| 658 | 677 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 659 | 678 | { |
| 660 | - if (in_array(3, $context['recipients'])) |
|
| 661 | - $context['recipients']['exclude_members'][] = $row['identifier']; |
|
| 662 | - else |
|
| 663 | - $context['recipients']['members'][] = $row['identifier']; |
|
| 679 | + if (in_array(3, $context['recipients'])) { |
|
| 680 | + $context['recipients']['exclude_members'][] = $row['identifier']; |
|
| 681 | + } else { |
|
| 682 | + $context['recipients']['members'][] = $row['identifier']; |
|
| 683 | + } |
|
| 664 | 684 | } |
| 665 | 685 | $smcFunc['db_free_result']($request); |
| 666 | 686 | } |
@@ -707,8 +727,9 @@ discard block |
||
| 707 | 727 | $num_at_once = 1000; |
| 708 | 728 | |
| 709 | 729 | // If by PM's I suggest we half the above number. |
| 710 | - if (!empty($_POST['send_pm'])) |
|
| 711 | - $num_at_once /= 2; |
|
| 730 | + if (!empty($_POST['send_pm'])) { |
|
| 731 | + $num_at_once /= 2; |
|
| 732 | + } |
|
| 712 | 733 | |
| 713 | 734 | checkSession(); |
| 714 | 735 | |
@@ -731,8 +752,7 @@ discard block |
||
| 731 | 752 | ); |
| 732 | 753 | list ($context['total_members']) = $smcFunc['db_fetch_row']($request); |
| 733 | 754 | $smcFunc['db_free_result']($request); |
| 734 | - } |
|
| 735 | - else |
|
| 755 | + } else |
|
| 736 | 756 | { |
| 737 | 757 | $context['total_members'] = (int) $_REQUEST['total_members']; |
| 738 | 758 | } |
@@ -750,32 +770,35 @@ discard block |
||
| 750 | 770 | if (!empty($_POST['exclude_members'])) |
| 751 | 771 | { |
| 752 | 772 | $members = explode(',', $_POST['exclude_members']); |
| 753 | - foreach ($members as $member) |
|
| 754 | - if ($member >= $context['start']) |
|
| 773 | + foreach ($members as $member) { |
|
| 774 | + if ($member >= $context['start']) |
|
| 755 | 775 | $context['recipients']['exclude_members'][] = (int) $member; |
| 776 | + } |
|
| 756 | 777 | } |
| 757 | 778 | |
| 758 | 779 | // What about members we *must* do? |
| 759 | 780 | if (!empty($_POST['members'])) |
| 760 | 781 | { |
| 761 | 782 | $members = explode(',', $_POST['members']); |
| 762 | - foreach ($members as $member) |
|
| 763 | - if ($member >= $context['start']) |
|
| 783 | + foreach ($members as $member) { |
|
| 784 | + if ($member >= $context['start']) |
|
| 764 | 785 | $context['recipients']['members'][] = (int) $member; |
| 786 | + } |
|
| 765 | 787 | } |
| 766 | 788 | // Cleaning groups is simple - although deal with both checkbox and commas. |
| 767 | 789 | if (isset($_POST['groups'])) |
| 768 | 790 | { |
| 769 | 791 | if (is_array($_POST['groups'])) |
| 770 | 792 | { |
| 771 | - foreach ($_POST['groups'] as $group => $dummy) |
|
| 772 | - $context['recipients']['groups'][] = (int) $group; |
|
| 773 | - } |
|
| 774 | - else |
|
| 793 | + foreach ($_POST['groups'] as $group => $dummy) { |
|
| 794 | + $context['recipients']['groups'][] = (int) $group; |
|
| 795 | + } |
|
| 796 | + } else |
|
| 775 | 797 | { |
| 776 | 798 | $groups = explode(',', $_POST['groups']); |
| 777 | - foreach ($groups as $group) |
|
| 778 | - $context['recipients']['groups'][] = (int) $group; |
|
| 799 | + foreach ($groups as $group) { |
|
| 800 | + $context['recipients']['groups'][] = (int) $group; |
|
| 801 | + } |
|
| 779 | 802 | } |
| 780 | 803 | } |
| 781 | 804 | // Same for excluded groups |
@@ -783,14 +806,15 @@ discard block |
||
| 783 | 806 | { |
| 784 | 807 | if (is_array($_POST['exclude_groups'])) |
| 785 | 808 | { |
| 786 | - foreach ($_POST['exclude_groups'] as $group => $dummy) |
|
| 787 | - $context['recipients']['exclude_groups'][] = (int) $group; |
|
| 788 | - } |
|
| 789 | - else |
|
| 809 | + foreach ($_POST['exclude_groups'] as $group => $dummy) { |
|
| 810 | + $context['recipients']['exclude_groups'][] = (int) $group; |
|
| 811 | + } |
|
| 812 | + } else |
|
| 790 | 813 | { |
| 791 | 814 | $groups = explode(',', $_POST['exclude_groups']); |
| 792 | - foreach ($groups as $group) |
|
| 793 | - $context['recipients']['exclude_groups'][] = (int) $group; |
|
| 815 | + foreach ($groups as $group) { |
|
| 816 | + $context['recipients']['exclude_groups'][] = (int) $group; |
|
| 817 | + } |
|
| 794 | 818 | } |
| 795 | 819 | } |
| 796 | 820 | // Finally - emails! |
@@ -800,14 +824,16 @@ discard block |
||
| 800 | 824 | foreach ($addressed as $curmem) |
| 801 | 825 | { |
| 802 | 826 | $curmem = trim($curmem); |
| 803 | - if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) |
|
| 804 | - $context['recipients']['emails'][$curmem] = $curmem; |
|
| 827 | + if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) { |
|
| 828 | + $context['recipients']['emails'][$curmem] = $curmem; |
|
| 829 | + } |
|
| 805 | 830 | } |
| 806 | 831 | } |
| 807 | 832 | |
| 808 | 833 | // If we're only cleaning drop out here. |
| 809 | - if ($clean_only) |
|
| 810 | - return; |
|
| 834 | + if ($clean_only) { |
|
| 835 | + return; |
|
| 836 | + } |
|
| 811 | 837 | |
| 812 | 838 | require_once($sourcedir . '/Subs-Post.php'); |
| 813 | 839 | |
@@ -823,16 +849,18 @@ discard block |
||
| 823 | 849 | if (!$context['send_pm'] && !empty($_POST['send_html'])) |
| 824 | 850 | { |
| 825 | 851 | // Prepare the message for HTML. |
| 826 | - if (!empty($_POST['parse_html'])) |
|
| 827 | - $_POST['message'] = str_replace(array("\n", ' '), array('<br>' . "\n", ' '), $_POST['message']); |
|
| 852 | + if (!empty($_POST['parse_html'])) { |
|
| 853 | + $_POST['message'] = str_replace(array("\n", ' '), array('<br>' . "\n", ' '), $_POST['message']); |
|
| 854 | + } |
|
| 828 | 855 | |
| 829 | 856 | // This is here to prevent spam filters from tagging this as spam. |
| 830 | 857 | if (preg_match('~\<html~i', $_POST['message']) == 0) |
| 831 | 858 | { |
| 832 | - if (preg_match('~\<body~i', $_POST['message']) == 0) |
|
| 833 | - $_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>'; |
|
| 834 | - else |
|
| 835 | - $_POST['message'] = '<html>' . $_POST['message'] . '</html>'; |
|
| 859 | + if (preg_match('~\<body~i', $_POST['message']) == 0) { |
|
| 860 | + $_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>'; |
|
| 861 | + } else { |
|
| 862 | + $_POST['message'] = '<html>' . $_POST['message'] . '</html>'; |
|
| 863 | + } |
|
| 836 | 864 | } |
| 837 | 865 | } |
| 838 | 866 | |
@@ -886,15 +914,17 @@ discard block |
||
| 886 | 914 | foreach ($context['recipients']['emails'] as $k => $email) |
| 887 | 915 | { |
| 888 | 916 | // Done as many as we can? |
| 889 | - if ($i >= $num_at_once) |
|
| 890 | - break; |
|
| 917 | + if ($i >= $num_at_once) { |
|
| 918 | + break; |
|
| 919 | + } |
|
| 891 | 920 | |
| 892 | 921 | // Don't sent it twice! |
| 893 | 922 | unset($context['recipients']['emails'][$k]); |
| 894 | 923 | |
| 895 | 924 | // Dammit - can't PM emails! |
| 896 | - if ($context['send_pm']) |
|
| 897 | - continue; |
|
| 925 | + if ($context['send_pm']) { |
|
| 926 | + continue; |
|
| 927 | + } |
|
| 898 | 928 | |
| 899 | 929 | $to_member = array( |
| 900 | 930 | $email, |
@@ -928,8 +958,9 @@ discard block |
||
| 928 | 958 | $queryBuild[] = 'mem.id_post_group = {int:group_' . $group . '}'; |
| 929 | 959 | } |
| 930 | 960 | } |
| 931 | - if (!empty($queryBuild)) |
|
| 932 | - $sendQuery .= implode(' OR ', $queryBuild); |
|
| 961 | + if (!empty($queryBuild)) { |
|
| 962 | + $sendQuery .= implode(' OR ', $queryBuild); |
|
| 963 | + } |
|
| 933 | 964 | } |
| 934 | 965 | if (!empty($context['recipients']['members'])) |
| 935 | 966 | { |
@@ -948,8 +979,9 @@ discard block |
||
| 948 | 979 | } |
| 949 | 980 | |
| 950 | 981 | // Anything to exclude? |
| 951 | - if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) |
|
| 952 | - $sendQuery .= ' AND mem.id_group != {int:regular_group}'; |
|
| 982 | + if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) { |
|
| 983 | + $sendQuery .= ' AND mem.id_group != {int:regular_group}'; |
|
| 984 | + } |
|
| 953 | 985 | if (!empty($context['recipients']['exclude_members'])) |
| 954 | 986 | { |
| 955 | 987 | $sendQuery .= ' AND mem.id_member NOT IN ({array_int:exclude_members})'; |
@@ -985,21 +1017,24 @@ discard block |
||
| 985 | 1017 | foreach ($rows as $row) |
| 986 | 1018 | { |
| 987 | 1019 | // Force them to have it? |
| 988 | - if (empty($context['email_force']) || empty($prefs[$row['id_member']]['announcements'])) |
|
| 989 | - continue; |
|
| 1020 | + if (empty($context['email_force']) || empty($prefs[$row['id_member']]['announcements'])) { |
|
| 1021 | + continue; |
|
| 1022 | + } |
|
| 990 | 1023 | |
| 991 | 1024 | // What groups are we looking at here? |
| 992 | - if (empty($row['additional_groups'])) |
|
| 993 | - $groups = array($row['id_group'], $row['id_post_group']); |
|
| 994 | - else |
|
| 995 | - $groups = array_merge( |
|
| 1025 | + if (empty($row['additional_groups'])) { |
|
| 1026 | + $groups = array($row['id_group'], $row['id_post_group']); |
|
| 1027 | + } else { |
|
| 1028 | + $groups = array_merge( |
|
| 996 | 1029 | array($row['id_group'], $row['id_post_group']), |
| 997 | 1030 | explode(',', $row['additional_groups']) |
| 998 | 1031 | ); |
| 1032 | + } |
|
| 999 | 1033 | |
| 1000 | 1034 | // Excluded groups? |
| 1001 | - if (array_intersect($groups, $context['recipients']['exclude_groups'])) |
|
| 1002 | - continue; |
|
| 1035 | + if (array_intersect($groups, $context['recipients']['exclude_groups'])) { |
|
| 1036 | + continue; |
|
| 1037 | + } |
|
| 1003 | 1038 | |
| 1004 | 1039 | // We might need this |
| 1005 | 1040 | $cleanMemberName = empty($_POST['send_html']) || $context['send_pm'] ? un_htmlspecialchars($row['real_name']) : $row['real_name']; |
@@ -1022,10 +1057,11 @@ discard block |
||
| 1022 | 1057 | ), $_POST['subject']); |
| 1023 | 1058 | |
| 1024 | 1059 | // Send the actual email - or a PM! |
| 1025 | - if (!$context['send_pm']) |
|
| 1026 | - sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5); |
|
| 1027 | - else |
|
| 1028 | - sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message); |
|
| 1060 | + if (!$context['send_pm']) { |
|
| 1061 | + sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5); |
|
| 1062 | + } else { |
|
| 1063 | + sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message); |
|
| 1064 | + } |
|
| 1029 | 1065 | } |
| 1030 | 1066 | } |
| 1031 | 1067 | |
@@ -1075,8 +1111,9 @@ discard block |
||
| 1075 | 1111 | |
| 1076 | 1112 | call_integration_hook('integrate_modify_news_settings', array(&$config_vars)); |
| 1077 | 1113 | |
| 1078 | - if ($return_config) |
|
| 1079 | - return $config_vars; |
|
| 1114 | + if ($return_config) { |
|
| 1115 | + return $config_vars; |
|
| 1116 | + } |
|
| 1080 | 1117 | |
| 1081 | 1118 | $context['page_title'] = $txt['admin_edit_news'] . ' - ' . $txt['settings']; |
| 1082 | 1119 | $context['sub_template'] = 'show_settings'; |
@@ -19,8 +19,9 @@ discard block |
||
| 19 | 19 | * @version 2.1 Beta 3 |
| 20 | 20 | */ |
| 21 | 21 | |
| 22 | -if (!defined('SMF')) |
|
| 22 | +if (!defined('SMF')) { |
|
| 23 | 23 | die('No direct access...'); |
| 24 | +} |
|
| 24 | 25 | |
| 25 | 26 | /** |
| 26 | 27 | * Class gif_lzw_compression |
@@ -52,13 +53,15 @@ discard block |
||
| 52 | 53 | |
| 53 | 54 | $this->LZWCommand($data, true); |
| 54 | 55 | |
| 55 | - while (($iIndex = $this->LZWCommand($data, false)) >= 0) |
|
| 56 | - $ret .= chr($iIndex); |
|
| 56 | + while (($iIndex = $this->LZWCommand($data, false)) >= 0) { |
|
| 57 | + $ret .= chr($iIndex); |
|
| 58 | + } |
|
| 57 | 59 | |
| 58 | 60 | $datLen = $stLen - strlen($data); |
| 59 | 61 | |
| 60 | - if ($iIndex != -2) |
|
| 61 | - return false; |
|
| 62 | + if ($iIndex != -2) { |
|
| 63 | + return false; |
|
| 64 | + } |
|
| 62 | 65 | |
| 63 | 66 | return $ret; |
| 64 | 67 | } |
@@ -140,8 +143,9 @@ discard block |
||
| 140 | 143 | return $this->FirstCode; |
| 141 | 144 | } |
| 142 | 145 | |
| 143 | - if ($Code == $this->EndCode) |
|
| 144 | - return -2; |
|
| 146 | + if ($Code == $this->EndCode) { |
|
| 147 | + return -2; |
|
| 148 | + } |
|
| 145 | 149 | |
| 146 | 150 | $InCode = $Code; |
| 147 | 151 | if ($Code >= $this->MaxCode) |
@@ -156,8 +160,10 @@ discard block |
||
| 156 | 160 | $this->Stack[$this->sp] = $this->Vals[$Code]; |
| 157 | 161 | $this->sp++; |
| 158 | 162 | |
| 159 | - if ($Code == $this->Next[$Code]) // Circular table entry, big GIF Error! |
|
| 163 | + if ($Code == $this->Next[$Code]) { |
|
| 164 | + // Circular table entry, big GIF Error! |
|
| 160 | 165 | return -1; |
| 166 | + } |
|
| 161 | 167 | |
| 162 | 168 | $Code = $this->Next[$Code]; |
| 163 | 169 | } |
@@ -207,8 +213,9 @@ discard block |
||
| 207 | 213 | if ($this->Done) |
| 208 | 214 | { |
| 209 | 215 | // Ran off the end of my bits... |
| 210 | - if ($this->CurBit >= $this->LastBit) |
|
| 211 | - return 0; |
|
| 216 | + if ($this->CurBit >= $this->LastBit) { |
|
| 217 | + return 0; |
|
| 218 | + } |
|
| 212 | 219 | |
| 213 | 220 | return -1; |
| 214 | 221 | } |
@@ -221,13 +228,14 @@ discard block |
||
| 221 | 228 | |
| 222 | 229 | if ($count) |
| 223 | 230 | { |
| 224 | - for ($i = 0; $i < $count; $i++) |
|
| 225 | - $this->Buf[2 + $i] = ord($data{$i}); |
|
| 231 | + for ($i = 0; $i < $count; $i++) { |
|
| 232 | + $this->Buf[2 + $i] = ord($data{$i}); |
|
| 233 | + } |
|
| 226 | 234 | |
| 227 | 235 | $data = substr($data, $count); |
| 236 | + } else { |
|
| 237 | + $this->Done = 1; |
|
| 228 | 238 | } |
| 229 | - else |
|
| 230 | - $this->Done = 1; |
|
| 231 | 239 | |
| 232 | 240 | $this->LastByte = 2 + $count; |
| 233 | 241 | $this->CurBit = ($this->CurBit - $this->LastBit) + 16; |
@@ -235,8 +243,9 @@ discard block |
||
| 235 | 243 | } |
| 236 | 244 | |
| 237 | 245 | $iRet = 0; |
| 238 | - for ($i = $this->CurBit, $j = 0; $j < $this->CodeSize; $i++, $j++) |
|
| 239 | - $iRet |= (($this->Buf[intval($i / 8)] & (1 << ($i % 8))) != 0) << $j; |
|
| 246 | + for ($i = $this->CurBit, $j = 0; $j < $this->CodeSize; $i++, $j++) { |
|
| 247 | + $iRet |= (($this->Buf[intval($i / 8)] & (1 << ($i % 8))) != 0) << $j; |
|
| 248 | + } |
|
| 240 | 249 | |
| 241 | 250 | $this->CurBit += $this->CodeSize; |
| 242 | 251 | return $iRet; |
@@ -261,8 +270,9 @@ discard block |
||
| 261 | 270 | for ($i = 0; $i < $num; $i++) |
| 262 | 271 | { |
| 263 | 272 | $rgb = substr($lpData, $i * 3, 3); |
| 264 | - if (strlen($rgb) < 3) |
|
| 265 | - return false; |
|
| 273 | + if (strlen($rgb) < 3) { |
|
| 274 | + return false; |
|
| 275 | + } |
|
| 266 | 276 | |
| 267 | 277 | $this->m_arColors[] = (ord($rgb[2]) << 16) + (ord($rgb[1]) << 8) + ord($rgb[0]); |
| 268 | 278 | $this->m_nColors++; |
@@ -329,13 +339,15 @@ discard block |
||
| 329 | 339 | $hdrLen = 0; |
| 330 | 340 | |
| 331 | 341 | $this->m_lpVer = substr($lpData, 0, 6); |
| 332 | - if (($this->m_lpVer != 'GIF87a') && ($this->m_lpVer != 'GIF89a')) |
|
| 333 | - return false; |
|
| 342 | + if (($this->m_lpVer != 'GIF87a') && ($this->m_lpVer != 'GIF89a')) { |
|
| 343 | + return false; |
|
| 344 | + } |
|
| 334 | 345 | |
| 335 | 346 | list ($this->m_nWidth, $this->m_nHeight) = array_values(unpack('v2', substr($lpData, 6, 4))); |
| 336 | 347 | |
| 337 | - if (!$this->m_nWidth || !$this->m_nHeight) |
|
| 338 | - return false; |
|
| 348 | + if (!$this->m_nWidth || !$this->m_nHeight) { |
|
| 349 | + return false; |
|
| 350 | + } |
|
| 339 | 351 | |
| 340 | 352 | $b = ord(substr($lpData, 10, 1)); |
| 341 | 353 | $this->m_bGlobalClr = ($b & 0x80) ? true : false; |
@@ -349,8 +361,9 @@ discard block |
||
| 349 | 361 | if ($this->m_bGlobalClr) |
| 350 | 362 | { |
| 351 | 363 | $this->m_colorTable = new gif_color_table(); |
| 352 | - if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) |
|
| 353 | - return false; |
|
| 364 | + if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) { |
|
| 365 | + return false; |
|
| 366 | + } |
|
| 354 | 367 | |
| 355 | 368 | $hdrLen += 3 * $this->m_nTableSize; |
| 356 | 369 | } |
@@ -377,8 +390,9 @@ discard block |
||
| 377 | 390 | // Get the width/height/etc. from the header. |
| 378 | 391 | list ($this->m_nLeft, $this->m_nTop, $this->m_nWidth, $this->m_nHeight) = array_values(unpack('v4', substr($lpData, 0, 8))); |
| 379 | 392 | |
| 380 | - if (!$this->m_nWidth || !$this->m_nHeight) |
|
| 381 | - return false; |
|
| 393 | + if (!$this->m_nWidth || !$this->m_nHeight) { |
|
| 394 | + return false; |
|
| 395 | + } |
|
| 382 | 396 | |
| 383 | 397 | $b = ord($lpData[8]); |
| 384 | 398 | $this->m_bLocalClr = ($b & 0x80) ? true : false; |
@@ -390,8 +404,9 @@ discard block |
||
| 390 | 404 | if ($this->m_bLocalClr) |
| 391 | 405 | { |
| 392 | 406 | $this->m_colorTable = new gif_color_table(); |
| 393 | - if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) |
|
| 394 | - return false; |
|
| 407 | + if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) { |
|
| 408 | + return false; |
|
| 409 | + } |
|
| 395 | 410 | |
| 396 | 411 | $hdrLen += 3 * $this->m_nTableSize; |
| 397 | 412 | } |
@@ -427,8 +442,9 @@ discard block |
||
| 427 | 442 | // Extension... |
| 428 | 443 | case 0x21: |
| 429 | 444 | $len = 0; |
| 430 | - if (!$this->skipExt($data, $len)) |
|
| 431 | - return false; |
|
| 445 | + if (!$this->skipExt($data, $len)) { |
|
| 446 | + return false; |
|
| 447 | + } |
|
| 432 | 448 | |
| 433 | 449 | $datLen += $len; |
| 434 | 450 | break; |
@@ -437,21 +453,24 @@ discard block |
||
| 437 | 453 | case 0x2C: |
| 438 | 454 | // Load the header and color table. |
| 439 | 455 | $len = 0; |
| 440 | - if (!$this->m_gih->load($data, $len)) |
|
| 441 | - return false; |
|
| 456 | + if (!$this->m_gih->load($data, $len)) { |
|
| 457 | + return false; |
|
| 458 | + } |
|
| 442 | 459 | |
| 443 | 460 | $data = substr($data, $len); |
| 444 | 461 | $datLen += $len; |
| 445 | 462 | |
| 446 | 463 | // Decompress the data, and ride on home ;). |
| 447 | 464 | $len = 0; |
| 448 | - if (!($this->m_data = $this->m_lzw->decompress($data, $len))) |
|
| 449 | - return false; |
|
| 465 | + if (!($this->m_data = $this->m_lzw->decompress($data, $len))) { |
|
| 466 | + return false; |
|
| 467 | + } |
|
| 450 | 468 | |
| 451 | 469 | $datLen += $len; |
| 452 | 470 | |
| 453 | - if ($this->m_gih->m_bInterlace) |
|
| 454 | - $this->deInterlace(); |
|
| 471 | + if ($this->m_gih->m_bInterlace) { |
|
| 472 | + $this->deInterlace(); |
|
| 473 | + } |
|
| 455 | 474 | |
| 456 | 475 | return true; |
| 457 | 476 | |
@@ -571,17 +590,20 @@ discard block |
||
| 571 | 590 | |
| 572 | 591 | public function loadFile($filename, $iIndex) |
| 573 | 592 | { |
| 574 | - if ($iIndex < 0) |
|
| 575 | - return false; |
|
| 593 | + if ($iIndex < 0) { |
|
| 594 | + return false; |
|
| 595 | + } |
|
| 576 | 596 | |
| 577 | 597 | $this->data = @file_get_contents($filename); |
| 578 | - if ($this->data === false) |
|
| 579 | - return false; |
|
| 598 | + if ($this->data === false) { |
|
| 599 | + return false; |
|
| 600 | + } |
|
| 580 | 601 | |
| 581 | 602 | // Tell the header to load up.... |
| 582 | 603 | $len = 0; |
| 583 | - if (!$this->header->load($this->data, $len)) |
|
| 584 | - return false; |
|
| 604 | + if (!$this->header->load($this->data, $len)) { |
|
| 605 | + return false; |
|
| 606 | + } |
|
| 585 | 607 | |
| 586 | 608 | $this->data = substr($this->data, $len); |
| 587 | 609 | |
@@ -589,8 +611,9 @@ discard block |
||
| 589 | 611 | for ($j = 0; $j <= $iIndex; $j++) |
| 590 | 612 | { |
| 591 | 613 | $imgLen = 0; |
| 592 | - if (!$this->image->load($this->data, $imgLen)) |
|
| 593 | - return false; |
|
| 614 | + if (!$this->image->load($this->data, $imgLen)) { |
|
| 615 | + return false; |
|
| 616 | + } |
|
| 594 | 617 | |
| 595 | 618 | $this->data = substr($this->data, $imgLen); |
| 596 | 619 | } |
@@ -601,8 +624,9 @@ discard block |
||
| 601 | 624 | |
| 602 | 625 | public function get_png_data($background_color) |
| 603 | 626 | { |
| 604 | - if (!$this->loaded) |
|
| 605 | - return false; |
|
| 627 | + if (!$this->loaded) { |
|
| 628 | + return false; |
|
| 629 | + } |
|
| 606 | 630 | |
| 607 | 631 | // Prepare the color table. |
| 608 | 632 | if ($this->image->m_gih->m_bLocalClr) |
@@ -610,25 +634,26 @@ discard block |
||
| 610 | 634 | $colors = $this->image->m_gih->m_nTableSize; |
| 611 | 635 | $pal = $this->image->m_gih->m_colorTable->toString(); |
| 612 | 636 | |
| 613 | - if ($background_color != -1) |
|
| 614 | - $background_color = $this->image->m_gih->m_colorTable->colorIndex($background_color); |
|
| 615 | - } |
|
| 616 | - elseif ($this->header->m_bGlobalClr) |
|
| 637 | + if ($background_color != -1) { |
|
| 638 | + $background_color = $this->image->m_gih->m_colorTable->colorIndex($background_color); |
|
| 639 | + } |
|
| 640 | + } elseif ($this->header->m_bGlobalClr) |
|
| 617 | 641 | { |
| 618 | 642 | $colors = $this->header->m_nTableSize; |
| 619 | 643 | $pal = $this->header->m_colorTable->toString(); |
| 620 | 644 | |
| 621 | - if ($background_color != -1) |
|
| 622 | - $background_color = $this->header->m_colorTable->colorIndex($background_color); |
|
| 623 | - } |
|
| 624 | - else |
|
| 645 | + if ($background_color != -1) { |
|
| 646 | + $background_color = $this->header->m_colorTable->colorIndex($background_color); |
|
| 647 | + } |
|
| 648 | + } else |
|
| 625 | 649 | { |
| 626 | 650 | $colors = 0; |
| 627 | 651 | $background_color = -1; |
| 628 | 652 | } |
| 629 | 653 | |
| 630 | - if ($background_color == -1) |
|
| 631 | - $background_color = $this->header->m_nBgColor; |
|
| 654 | + if ($background_color == -1) { |
|
| 655 | + $background_color = $this->header->m_nBgColor; |
|
| 656 | + } |
|
| 632 | 657 | |
| 633 | 658 | $data = &$this->image->m_data; |
| 634 | 659 | $header = &$this->image->m_gih; |
@@ -644,11 +669,13 @@ discard block |
||
| 644 | 669 | for ($x = 0; $x < $this->header->m_nWidth; $x++, $i++) |
| 645 | 670 | { |
| 646 | 671 | // Is this in the proper range? If so, get the specific pixel data... |
| 647 | - if ($x >= $header->m_nLeft && $y >= $header->m_nTop && $x < ($header->m_nLeft + $header->m_nWidth) && $y < ($header->m_nTop + $header->m_nHeight)) |
|
| 648 | - $bmp .= $data{$i}; |
|
| 672 | + if ($x >= $header->m_nLeft && $y >= $header->m_nTop && $x < ($header->m_nLeft + $header->m_nWidth) && $y < ($header->m_nTop + $header->m_nHeight)) { |
|
| 673 | + $bmp .= $data{$i}; |
|
| 674 | + } |
|
| 649 | 675 | // Otherwise, this is background... |
| 650 | - else |
|
| 651 | - $bmp .= chr($background_color); |
|
| 676 | + else { |
|
| 677 | + $bmp .= chr($background_color); |
|
| 678 | + } |
|
| 652 | 679 | } |
| 653 | 680 | } |
| 654 | 681 | |
@@ -677,8 +704,9 @@ discard block |
||
| 677 | 704 | $tmp = 'tRNS'; |
| 678 | 705 | |
| 679 | 706 | // Stick each color on - full transparency or none. |
| 680 | - for ($i = 0; $i < $colors; $i++) |
|
| 681 | - $tmp .= $i == $this->image->m_nTrans ? "\x00" : "\xFF"; |
|
| 707 | + for ($i = 0; $i < $colors; $i++) { |
|
| 708 | + $tmp .= $i == $this->image->m_nTrans ? "\x00" : "\xFF"; |
|
| 709 | + } |
|
| 682 | 710 | |
| 683 | 711 | $out .= $tmp . pack('N', smf_crc32($tmp)); |
| 684 | 712 | } |
@@ -1,9 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
| 4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
| 4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
| 5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
| 6 | -else |
|
| 6 | +} else { |
|
| 7 | 7 | exit; |
| 8 | +} |
|
| 8 | 9 | |
| 9 | 10 | ?> |
| 10 | 11 | \ No newline at end of file |
@@ -1,9 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
| 4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
| 4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
| 5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
| 6 | -else |
|
| 6 | +} else { |
|
| 7 | 7 | exit; |
| 8 | +} |
|
| 8 | 9 | |
| 9 | 10 | ?> |
| 10 | 11 | \ No newline at end of file |
@@ -12,7 +12,8 @@ |
||
| 12 | 12 | header('Location: ' . $boardurl); |
| 13 | 13 | } |
| 14 | 14 | // Can't find it... just forget it. |
| 15 | -else |
|
| 15 | +else { |
|
| 16 | 16 | exit; |
| 17 | +} |
|
| 17 | 18 | |
| 18 | 19 | ?> |
| 19 | 20 | \ No newline at end of file |
@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * @version 2.1 Beta 3 |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -if (!defined('SMF')) |
|
| 18 | +if (!defined('SMF')) { |
|
| 19 | 19 | die('No direct access...'); |
| 20 | +} |
|
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * Creates a wave file that spells the letters of $word. |
@@ -32,8 +33,9 @@ discard block |
||
| 32 | 33 | global $settings, $user_info; |
| 33 | 34 | |
| 34 | 35 | // Allow max 2 requests per 20 seconds. |
| 35 | - if (($ip = cache_get_data('wave_file/' . $user_info['ip'], 20)) > 2 || ($ip2 = cache_get_data('wave_file/' . $user_info['ip2'], 20)) > 2) |
|
| 36 | - die(header('HTTP/1.1 400 Bad Request')); |
|
| 36 | + if (($ip = cache_get_data('wave_file/' . $user_info['ip'], 20)) > 2 || ($ip2 = cache_get_data('wave_file/' . $user_info['ip2'], 20)) > 2) { |
|
| 37 | + die(header('HTTP/1.1 400 Bad Request')); |
|
| 38 | + } |
|
| 37 | 39 | cache_put_data('wave_file/' . $user_info['ip'], $ip ? $ip + 1 : 1, 20); |
| 38 | 40 | cache_put_data('wave_file/' . $user_info['ip2'], $ip2 ? $ip2 + 1 : 1, 20); |
| 39 | 41 | |
@@ -42,16 +44,19 @@ discard block |
||
| 42 | 44 | mt_srand(end($tmp)); |
| 43 | 45 | |
| 44 | 46 | // Try to see if there's a sound font in the user's language. |
| 45 | - if (file_exists($settings['default_theme_dir'] . '/fonts/sound/a.' . $user_info['language'] . '.wav')) |
|
| 46 | - $sound_language = $user_info['language']; |
|
| 47 | + if (file_exists($settings['default_theme_dir'] . '/fonts/sound/a.' . $user_info['language'] . '.wav')) { |
|
| 48 | + $sound_language = $user_info['language']; |
|
| 49 | + } |
|
| 47 | 50 | |
| 48 | 51 | // English should be there. |
| 49 | - elseif (file_exists($settings['default_theme_dir'] . '/fonts/sound/a.english.wav')) |
|
| 50 | - $sound_language = 'english'; |
|
| 52 | + elseif (file_exists($settings['default_theme_dir'] . '/fonts/sound/a.english.wav')) { |
|
| 53 | + $sound_language = 'english'; |
|
| 54 | + } |
|
| 51 | 55 | |
| 52 | 56 | // Guess not... |
| 53 | - else |
|
| 54 | - return false; |
|
| 57 | + else { |
|
| 58 | + return false; |
|
| 59 | + } |
|
| 55 | 60 | |
| 56 | 61 | // File names are in lower case so lets make sure that we are only using a lower case string |
| 57 | 62 | $word = strtolower($word); |
@@ -61,20 +66,25 @@ discard block |
||
| 61 | 66 | for ($i = 0; $i < strlen($word); $i++) |
| 62 | 67 | { |
| 63 | 68 | $sound_letter = implode('', file($settings['default_theme_dir'] . '/fonts/sound/' . $word{$i} . '.' . $sound_language . '.wav')); |
| 64 | - if (strpos($sound_letter, 'data') === false) |
|
| 65 | - return false; |
|
| 69 | + if (strpos($sound_letter, 'data') === false) { |
|
| 70 | + return false; |
|
| 71 | + } |
|
| 66 | 72 | |
| 67 | 73 | $sound_letter = substr($sound_letter, strpos($sound_letter, 'data') + 8); |
| 68 | 74 | switch ($word{$i} === 's' ? 0 : mt_rand(0, 2)) |
| 69 | 75 | { |
| 70 | - case 0 : for ($j = 0, $n = strlen($sound_letter); $j < $n; $j++) |
|
| 71 | - for ($k = 0, $m = round(mt_rand(15, 25) / 10); $k < $m; $k++) |
|
| 72 | - $sound_word .= $word{$i} === 's' ? $sound_letter{$j} : chr(mt_rand(max(ord($sound_letter{$j}) - 1, 0x00), min(ord($sound_letter{$j}) + 1, 0xFF))); |
|
| 76 | + case 0 : for ($j = 0, $n = strlen($sound_letter); $j < $n; $j++) { |
|
| 77 | + for ($k = 0, $m = round(mt_rand(15, 25) / 10); |
|
| 78 | + } |
|
| 79 | + $k < $m; $k++) { |
|
| 80 | + $sound_word .= $word{$i} === 's' ? $sound_letter{$j} : chr(mt_rand(max(ord($sound_letter{$j}) - 1, 0x00), min(ord($sound_letter{$j}) + 1, 0xFF))); |
|
| 81 | + } |
|
| 73 | 82 | break; |
| 74 | 83 | |
| 75 | 84 | case 1: |
| 76 | - for ($j = 0, $n = strlen($sound_letter) - 1; $j < $n; $j += 2) |
|
| 77 | - $sound_word .= (mt_rand(0, 3) == 0 ? '' : $sound_letter{$j}) . (mt_rand(0, 3) === 0 ? $sound_letter{$j + 1} : $sound_letter{$j}) . (mt_rand(0, 3) === 0 ? $sound_letter{$j} : $sound_letter{$j + 1}) . $sound_letter{$j + 1} . (mt_rand(0, 3) == 0 ? $sound_letter{$j + 1} : ''); |
|
| 85 | + for ($j = 0, $n = strlen($sound_letter) - 1; $j < $n; $j += 2) { |
|
| 86 | + $sound_word .= (mt_rand(0, 3) == 0 ? '' : $sound_letter{$j}) . (mt_rand(0, 3) === 0 ? $sound_letter{$j + 1} : $sound_letter{$j}) . (mt_rand(0, 3) === 0 ? $sound_letter{$j} : $sound_letter{$j + 1}) . $sound_letter{$j + 1} . (mt_rand(0, 3) == 0 ? $sound_letter{$j + 1} : ''); |
|
| 87 | + } |
|
| 78 | 88 | $sound_word .= str_repeat($sound_letter{$n}, 2); |
| 79 | 89 | break; |
| 80 | 90 | |
@@ -82,10 +92,12 @@ discard block |
||
| 82 | 92 | $shift = 0; |
| 83 | 93 | for ($j = 0, $n = strlen($sound_letter); $j < $n; $j++) |
| 84 | 94 | { |
| 85 | - if (mt_rand(0, 10) === 0) |
|
| 86 | - $shift += mt_rand(-3, 3); |
|
| 87 | - for ($k = 0, $m = round(mt_rand(15, 25) / 10); $k < $m; $k++) |
|
| 88 | - $sound_word .= chr(min(max(ord($sound_letter{$j}) + $shift, 0x00), 0xFF)); |
|
| 95 | + if (mt_rand(0, 10) === 0) { |
|
| 96 | + $shift += mt_rand(-3, 3); |
|
| 97 | + } |
|
| 98 | + for ($k = 0, $m = round(mt_rand(15, 25) / 10); $k < $m; $k++) { |
|
| 99 | + $sound_word .= chr(min(max(ord($sound_letter{$j}) + $shift, 0x00), 0xFF)); |
|
| 100 | + } |
|
| 89 | 101 | } |
| 90 | 102 | break; |
| 91 | 103 | |
@@ -30,8 +30,9 @@ discard block |
||
| 30 | 30 | * @version 2.1 Beta 3 |
| 31 | 31 | */ |
| 32 | 32 | |
| 33 | -if (!defined('SMF')) |
|
| 33 | +if (!defined('SMF')) { |
|
| 34 | 34 | die('No direct access...'); |
| 35 | +} |
|
| 35 | 36 | |
| 36 | 37 | /** |
| 37 | 38 | * Subaction handler - manages the action and delegates control to the proper |
@@ -103,12 +104,12 @@ discard block |
||
| 103 | 104 | cache_put_data('minimized_css', null); |
| 104 | 105 | |
| 105 | 106 | // Follow the sa or just go to administration. |
| 106 | - if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) |
|
| 107 | - call_helper($subActions[$_GET['sa']]); |
|
| 108 | - |
|
| 109 | - else |
|
| 110 | - call_helper($subActions['admin']); |
|
| 111 | -} |
|
| 107 | + if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) { |
|
| 108 | + call_helper($subActions[$_GET['sa']]); |
|
| 109 | + } else { |
|
| 110 | + call_helper($subActions['admin']); |
|
| 111 | + } |
|
| 112 | + } |
|
| 112 | 113 | |
| 113 | 114 | /** |
| 114 | 115 | * This function allows administration of themes and their settings, |
@@ -130,15 +131,16 @@ discard block |
||
| 130 | 131 | checkSession(); |
| 131 | 132 | validateToken('admin-tm'); |
| 132 | 133 | |
| 133 | - if (isset($_POST['options']['known_themes'])) |
|
| 134 | - foreach ($_POST['options']['known_themes'] as $key => $id) |
|
| 134 | + if (isset($_POST['options']['known_themes'])) { |
|
| 135 | + foreach ($_POST['options']['known_themes'] as $key => $id) |
|
| 135 | 136 | $_POST['options']['known_themes'][$key] = (int) $id; |
| 137 | + } else { |
|
| 138 | + fatal_lang_error('themes_none_selectable', false); |
|
| 139 | + } |
|
| 136 | 140 | |
| 137 | - else |
|
| 138 | - fatal_lang_error('themes_none_selectable', false); |
|
| 139 | - |
|
| 140 | - if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) |
|
| 141 | - fatal_lang_error('themes_default_selectable', false); |
|
| 141 | + if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) { |
|
| 142 | + fatal_lang_error('themes_default_selectable', false); |
|
| 143 | + } |
|
| 142 | 144 | |
| 143 | 145 | // Commit the new settings. |
| 144 | 146 | updateSettings(array( |
@@ -146,8 +148,9 @@ discard block |
||
| 146 | 148 | 'theme_guests' => $_POST['options']['theme_guests'], |
| 147 | 149 | 'knownThemes' => implode(',', $_POST['options']['known_themes']), |
| 148 | 150 | )); |
| 149 | - if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) |
|
| 150 | - updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset'])); |
|
| 151 | + if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) { |
|
| 152 | + updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset'])); |
|
| 153 | + } |
|
| 151 | 154 | |
| 152 | 155 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=admin'); |
| 153 | 156 | } |
@@ -166,8 +169,9 @@ discard block |
||
| 166 | 169 | // Look for a non existent theme directory. (ie theme87.) |
| 167 | 170 | $theme_dir = $boarddir . '/Themes/theme'; |
| 168 | 171 | $i = 1; |
| 169 | - while (file_exists($theme_dir . $i)) |
|
| 170 | - $i++; |
|
| 172 | + while (file_exists($theme_dir . $i)) { |
|
| 173 | + $i++; |
|
| 174 | + } |
|
| 171 | 175 | |
| 172 | 176 | $context['new_theme_name'] = 'theme' . $i; |
| 173 | 177 | |
@@ -189,8 +193,9 @@ discard block |
||
| 189 | 193 | loadLanguage('Admin'); |
| 190 | 194 | isAllowedTo('admin_forum'); |
| 191 | 195 | |
| 192 | - if (isset($_REQUEST['th'])) |
|
| 193 | - return SetThemeSettings(); |
|
| 196 | + if (isset($_REQUEST['th'])) { |
|
| 197 | + return SetThemeSettings(); |
|
| 198 | + } |
|
| 194 | 199 | |
| 195 | 200 | if (isset($_POST['save'])) |
| 196 | 201 | { |
@@ -274,12 +279,13 @@ discard block |
||
| 274 | 279 | $context['themes'] = array(); |
| 275 | 280 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 276 | 281 | { |
| 277 | - if (!isset($context['themes'][$row['id_theme']])) |
|
| 278 | - $context['themes'][$row['id_theme']] = array( |
|
| 282 | + if (!isset($context['themes'][$row['id_theme']])) { |
|
| 283 | + $context['themes'][$row['id_theme']] = array( |
|
| 279 | 284 | 'id' => $row['id_theme'], |
| 280 | 285 | 'num_default_options' => 0, |
| 281 | 286 | 'num_members' => 0, |
| 282 | 287 | ); |
| 288 | + } |
|
| 283 | 289 | $context['themes'][$row['id_theme']][$row['variable']] = $row['value']; |
| 284 | 290 | } |
| 285 | 291 | $smcFunc['db_free_result']($request); |
@@ -293,8 +299,9 @@ discard block |
||
| 293 | 299 | 'guest_member' => -1, |
| 294 | 300 | ) |
| 295 | 301 | ); |
| 296 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 297 | - $context['themes'][$row['id_theme']]['num_default_options'] = $row['value']; |
|
| 302 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 303 | + $context['themes'][$row['id_theme']]['num_default_options'] = $row['value']; |
|
| 304 | + } |
|
| 298 | 305 | $smcFunc['db_free_result']($request); |
| 299 | 306 | |
| 300 | 307 | // Need to make sure we don't do custom fields. |
@@ -305,8 +312,9 @@ discard block |
||
| 305 | 312 | ) |
| 306 | 313 | ); |
| 307 | 314 | $customFields = array(); |
| 308 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 309 | - $customFields[] = $row['col_name']; |
|
| 315 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 316 | + $customFields[] = $row['col_name']; |
|
| 317 | + } |
|
| 310 | 318 | $smcFunc['db_free_result']($request); |
| 311 | 319 | $customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})'); |
| 312 | 320 | |
@@ -321,14 +329,16 @@ discard block |
||
| 321 | 329 | 'custom_fields' => empty($customFields) ? array() : $customFields, |
| 322 | 330 | ) |
| 323 | 331 | ); |
| 324 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 325 | - $context['themes'][$row['id_theme']]['num_members'] = $row['value']; |
|
| 332 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 333 | + $context['themes'][$row['id_theme']]['num_members'] = $row['value']; |
|
| 334 | + } |
|
| 326 | 335 | $smcFunc['db_free_result']($request); |
| 327 | 336 | |
| 328 | 337 | // There has to be a Settings template! |
| 329 | - foreach ($context['themes'] as $k => $v) |
|
| 330 | - if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members']))) |
|
| 338 | + foreach ($context['themes'] as $k => $v) { |
|
| 339 | + if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members']))) |
|
| 331 | 340 | unset($context['themes'][$k]); |
| 341 | + } |
|
| 332 | 342 | |
| 333 | 343 | loadTemplate('Themes'); |
| 334 | 344 | $context['sub_template'] = 'reset_list'; |
@@ -343,16 +353,19 @@ discard block |
||
| 343 | 353 | checkSession(); |
| 344 | 354 | validateToken('admin-sto'); |
| 345 | 355 | |
| 346 | - if (empty($_POST['options'])) |
|
| 347 | - $_POST['options'] = array(); |
|
| 348 | - if (empty($_POST['default_options'])) |
|
| 349 | - $_POST['default_options'] = array(); |
|
| 356 | + if (empty($_POST['options'])) { |
|
| 357 | + $_POST['options'] = array(); |
|
| 358 | + } |
|
| 359 | + if (empty($_POST['default_options'])) { |
|
| 360 | + $_POST['default_options'] = array(); |
|
| 361 | + } |
|
| 350 | 362 | |
| 351 | 363 | // Set up the sql query. |
| 352 | 364 | $setValues = array(); |
| 353 | 365 | |
| 354 | - foreach ($_POST['options'] as $opt => $val) |
|
| 355 | - $setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
| 366 | + foreach ($_POST['options'] as $opt => $val) { |
|
| 367 | + $setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
| 368 | + } |
|
| 356 | 369 | |
| 357 | 370 | $old_settings = array(); |
| 358 | 371 | foreach ($_POST['default_options'] as $opt => $val) |
@@ -366,8 +379,8 @@ discard block |
||
| 366 | 379 | if (!empty($setValues)) |
| 367 | 380 | { |
| 368 | 381 | // Are there options in non-default themes set that should be cleared? |
| 369 | - if (!empty($old_settings)) |
|
| 370 | - $smcFunc['db_query']('', ' |
|
| 382 | + if (!empty($old_settings)) { |
|
| 383 | + $smcFunc['db_query']('', ' |
|
| 371 | 384 | DELETE FROM {db_prefix}themes |
| 372 | 385 | WHERE id_theme != {int:default_theme} |
| 373 | 386 | AND id_member = {int:guest_member} |
@@ -378,6 +391,7 @@ discard block |
||
| 378 | 391 | 'old_settings' => $old_settings, |
| 379 | 392 | ) |
| 380 | 393 | ); |
| 394 | + } |
|
| 381 | 395 | |
| 382 | 396 | $smcFunc['db_insert']('replace', |
| 383 | 397 | '{db_prefix}themes', |
@@ -391,8 +405,7 @@ discard block |
||
| 391 | 405 | cache_put_data('theme_settings-1', null, 90); |
| 392 | 406 | |
| 393 | 407 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset'); |
| 394 | - } |
|
| 395 | - elseif (isset($_POST['submit']) && $_POST['who'] == 1) |
|
| 408 | + } elseif (isset($_POST['submit']) && $_POST['who'] == 1) |
|
| 396 | 409 | { |
| 397 | 410 | checkSession(); |
| 398 | 411 | validateToken('admin-sto'); |
@@ -405,9 +418,9 @@ discard block |
||
| 405 | 418 | $old_settings = array(); |
| 406 | 419 | foreach ($_POST['default_options'] as $opt => $val) |
| 407 | 420 | { |
| 408 | - if ($_POST['default_options_master'][$opt] == 0) |
|
| 409 | - continue; |
|
| 410 | - elseif ($_POST['default_options_master'][$opt] == 1) |
|
| 421 | + if ($_POST['default_options_master'][$opt] == 0) { |
|
| 422 | + continue; |
|
| 423 | + } elseif ($_POST['default_options_master'][$opt] == 1) |
|
| 411 | 424 | { |
| 412 | 425 | // Delete then insert for ease of database compatibility! |
| 413 | 426 | $smcFunc['db_query']('substring', ' |
@@ -433,8 +446,7 @@ discard block |
||
| 433 | 446 | ); |
| 434 | 447 | |
| 435 | 448 | $old_settings[] = $opt; |
| 436 | - } |
|
| 437 | - elseif ($_POST['default_options_master'][$opt] == 2) |
|
| 449 | + } elseif ($_POST['default_options_master'][$opt] == 2) |
|
| 438 | 450 | { |
| 439 | 451 | $smcFunc['db_query']('', ' |
| 440 | 452 | DELETE FROM {db_prefix}themes |
@@ -449,8 +461,8 @@ discard block |
||
| 449 | 461 | } |
| 450 | 462 | |
| 451 | 463 | // Delete options from other themes. |
| 452 | - if (!empty($old_settings)) |
|
| 453 | - $smcFunc['db_query']('', ' |
|
| 464 | + if (!empty($old_settings)) { |
|
| 465 | + $smcFunc['db_query']('', ' |
|
| 454 | 466 | DELETE FROM {db_prefix}themes |
| 455 | 467 | WHERE id_theme != {int:default_theme} |
| 456 | 468 | AND id_member > {int:no_member} |
@@ -461,12 +473,13 @@ discard block |
||
| 461 | 473 | 'old_settings' => $old_settings, |
| 462 | 474 | ) |
| 463 | 475 | ); |
| 476 | + } |
|
| 464 | 477 | |
| 465 | 478 | foreach ($_POST['options'] as $opt => $val) |
| 466 | 479 | { |
| 467 | - if ($_POST['options_master'][$opt] == 0) |
|
| 468 | - continue; |
|
| 469 | - elseif ($_POST['options_master'][$opt] == 1) |
|
| 480 | + if ($_POST['options_master'][$opt] == 0) { |
|
| 481 | + continue; |
|
| 482 | + } elseif ($_POST['options_master'][$opt] == 1) |
|
| 470 | 483 | { |
| 471 | 484 | // Delete then insert for ease of database compatibility - again! |
| 472 | 485 | $smcFunc['db_query']('substring', ' |
@@ -491,8 +504,7 @@ discard block |
||
| 491 | 504 | 'value' => (is_array($val) ? implode(',', $val) : $val), |
| 492 | 505 | ) |
| 493 | 506 | ); |
| 494 | - } |
|
| 495 | - elseif ($_POST['options_master'][$opt] == 2) |
|
| 507 | + } elseif ($_POST['options_master'][$opt] == 2) |
|
| 496 | 508 | { |
| 497 | 509 | $smcFunc['db_query']('', ' |
| 498 | 510 | DELETE FROM {db_prefix}themes |
@@ -509,8 +521,7 @@ discard block |
||
| 509 | 521 | } |
| 510 | 522 | |
| 511 | 523 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset'); |
| 512 | - } |
|
| 513 | - elseif (!empty($_GET['who']) && $_GET['who'] == 2) |
|
| 524 | + } elseif (!empty($_GET['who']) && $_GET['who'] == 2) |
|
| 514 | 525 | { |
| 515 | 526 | checkSession('get'); |
| 516 | 527 | validateToken('admin-stor', 'request'); |
@@ -525,8 +536,9 @@ discard block |
||
| 525 | 536 | ) |
| 526 | 537 | ); |
| 527 | 538 | $customFields = array(); |
| 528 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 529 | - $customFields[] = $row['col_name']; |
|
| 539 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 540 | + $customFields[] = $row['col_name']; |
|
| 541 | + } |
|
| 530 | 542 | $smcFunc['db_free_result']($request); |
| 531 | 543 | } |
| 532 | 544 | $customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})'); |
@@ -578,13 +590,13 @@ discard block |
||
| 578 | 590 | ) |
| 579 | 591 | ); |
| 580 | 592 | $context['theme_options'] = array(); |
| 581 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 582 | - $context['theme_options'][$row['variable']] = $row['value']; |
|
| 593 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 594 | + $context['theme_options'][$row['variable']] = $row['value']; |
|
| 595 | + } |
|
| 583 | 596 | $smcFunc['db_free_result']($request); |
| 584 | 597 | |
| 585 | 598 | $context['theme_options_reset'] = false; |
| 586 | - } |
|
| 587 | - else |
|
| 599 | + } else |
|
| 588 | 600 | { |
| 589 | 601 | $context['theme_options'] = array(); |
| 590 | 602 | $context['theme_options_reset'] = true; |
@@ -593,30 +605,32 @@ discard block |
||
| 593 | 605 | foreach ($context['options'] as $i => $setting) |
| 594 | 606 | { |
| 595 | 607 | // Just skip separators |
| 596 | - if (!is_array($setting)) |
|
| 597 | - continue; |
|
| 608 | + if (!is_array($setting)) { |
|
| 609 | + continue; |
|
| 610 | + } |
|
| 598 | 611 | |
| 599 | 612 | // Is this disabled? |
| 600 | 613 | if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) |
| 601 | 614 | { |
| 602 | 615 | unset($context['options'][$i]); |
| 603 | 616 | continue; |
| 604 | - } |
|
| 605 | - elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
| 617 | + } elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
| 606 | 618 | { |
| 607 | 619 | unset($context['options'][$i]); |
| 608 | 620 | continue; |
| 609 | 621 | } |
| 610 | 622 | |
| 611 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
| 612 | - $context['options'][$i]['type'] = 'checkbox'; |
|
| 613 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
| 614 | - $context['options'][$i]['type'] = 'number'; |
|
| 615 | - elseif ($setting['type'] == 'string') |
|
| 616 | - $context['options'][$i]['type'] = 'text'; |
|
| 623 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
| 624 | + $context['options'][$i]['type'] = 'checkbox'; |
|
| 625 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
| 626 | + $context['options'][$i]['type'] = 'number'; |
|
| 627 | + } elseif ($setting['type'] == 'string') { |
|
| 628 | + $context['options'][$i]['type'] = 'text'; |
|
| 629 | + } |
|
| 617 | 630 | |
| 618 | - if (isset($setting['options'])) |
|
| 619 | - $context['options'][$i]['type'] = 'list'; |
|
| 631 | + if (isset($setting['options'])) { |
|
| 632 | + $context['options'][$i]['type'] = 'list'; |
|
| 633 | + } |
|
| 620 | 634 | |
| 621 | 635 | $context['options'][$i]['value'] = !isset($context['theme_options'][$setting['id']]) ? '' : $context['theme_options'][$setting['id']]; |
| 622 | 636 | } |
@@ -641,8 +655,9 @@ discard block |
||
| 641 | 655 | { |
| 642 | 656 | global $txt, $context, $settings, $modSettings, $smcFunc; |
| 643 | 657 | |
| 644 | - if (empty($_GET['th']) && empty($_GET['id'])) |
|
| 645 | - return ThemeAdmin(); |
|
| 658 | + if (empty($_GET['th']) && empty($_GET['id'])) { |
|
| 659 | + return ThemeAdmin(); |
|
| 660 | + } |
|
| 646 | 661 | |
| 647 | 662 | $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
| 648 | 663 | |
@@ -653,8 +668,9 @@ discard block |
||
| 653 | 668 | isAllowedTo('admin_forum'); |
| 654 | 669 | |
| 655 | 670 | // Validate inputs/user. |
| 656 | - if (empty($_GET['th'])) |
|
| 657 | - fatal_lang_error('no_theme', false); |
|
| 671 | + if (empty($_GET['th'])) { |
|
| 672 | + fatal_lang_error('no_theme', false); |
|
| 673 | + } |
|
| 658 | 674 | |
| 659 | 675 | // Fetch the smiley sets... |
| 660 | 676 | $sets = explode(',', 'none,' . $modSettings['smiley_sets_known']); |
@@ -662,8 +678,9 @@ discard block |
||
| 662 | 678 | $context['smiley_sets'] = array( |
| 663 | 679 | '' => $txt['smileys_no_default'] |
| 664 | 680 | ); |
| 665 | - foreach ($sets as $i => $set) |
|
| 666 | - $context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]); |
|
| 681 | + foreach ($sets as $i => $set) { |
|
| 682 | + $context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]); |
|
| 683 | + } |
|
| 667 | 684 | |
| 668 | 685 | $old_id = $settings['theme_id']; |
| 669 | 686 | $old_settings = $settings; |
@@ -688,8 +705,9 @@ discard block |
||
| 688 | 705 | if (file_exists($settings['theme_dir'] . '/index.template.php')) |
| 689 | 706 | { |
| 690 | 707 | $file_contents = implode('', file($settings['theme_dir'] . '/index.template.php')); |
| 691 | - if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) |
|
| 692 | - eval('global $settings;' . $matches[0]); |
|
| 708 | + if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) { |
|
| 709 | + eval('global $settings;' . $matches[0]); |
|
| 710 | + } |
|
| 693 | 711 | } |
| 694 | 712 | |
| 695 | 713 | // Submitting! |
@@ -698,37 +716,45 @@ discard block |
||
| 698 | 716 | checkSession(); |
| 699 | 717 | validateToken('admin-sts'); |
| 700 | 718 | |
| 701 | - if (empty($_POST['options'])) |
|
| 702 | - $_POST['options'] = array(); |
|
| 703 | - if (empty($_POST['default_options'])) |
|
| 704 | - $_POST['default_options'] = array(); |
|
| 719 | + if (empty($_POST['options'])) { |
|
| 720 | + $_POST['options'] = array(); |
|
| 721 | + } |
|
| 722 | + if (empty($_POST['default_options'])) { |
|
| 723 | + $_POST['default_options'] = array(); |
|
| 724 | + } |
|
| 705 | 725 | |
| 706 | 726 | // Make sure items are cast correctly. |
| 707 | 727 | foreach ($context['theme_settings'] as $item) |
| 708 | 728 | { |
| 709 | 729 | // Disregard this item if this is just a separator. |
| 710 | - if (!is_array($item)) |
|
| 711 | - continue; |
|
| 730 | + if (!is_array($item)) { |
|
| 731 | + continue; |
|
| 732 | + } |
|
| 712 | 733 | |
| 713 | 734 | foreach (array('options', 'default_options') as $option) |
| 714 | 735 | { |
| 715 | - if (!isset($_POST[$option][$item['id']])) |
|
| 716 | - continue; |
|
| 736 | + if (!isset($_POST[$option][$item['id']])) { |
|
| 737 | + continue; |
|
| 738 | + } |
|
| 717 | 739 | // Checkbox. |
| 718 | - elseif (empty($item['type'])) |
|
| 719 | - $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0; |
|
| 740 | + elseif (empty($item['type'])) { |
|
| 741 | + $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0; |
|
| 742 | + } |
|
| 720 | 743 | // Number |
| 721 | - elseif ($item['type'] == 'number') |
|
| 722 | - $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']]; |
|
| 744 | + elseif ($item['type'] == 'number') { |
|
| 745 | + $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']]; |
|
| 746 | + } |
|
| 723 | 747 | } |
| 724 | 748 | } |
| 725 | 749 | |
| 726 | 750 | // Set up the sql query. |
| 727 | 751 | $inserts = array(); |
| 728 | - foreach ($_POST['options'] as $opt => $val) |
|
| 729 | - $inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
| 730 | - foreach ($_POST['default_options'] as $opt => $val) |
|
| 731 | - $inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
| 752 | + foreach ($_POST['options'] as $opt => $val) { |
|
| 753 | + $inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
| 754 | + } |
|
| 755 | + foreach ($_POST['default_options'] as $opt => $val) { |
|
| 756 | + $inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
| 757 | + } |
|
| 732 | 758 | // If we're actually inserting something.. |
| 733 | 759 | if (!empty($inserts)) |
| 734 | 760 | { |
@@ -754,8 +780,9 @@ discard block |
||
| 754 | 780 | |
| 755 | 781 | foreach ($settings as $setting => $dummy) |
| 756 | 782 | { |
| 757 | - if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) |
|
| 758 | - $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
| 783 | + if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) { |
|
| 784 | + $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
| 785 | + } |
|
| 759 | 786 | } |
| 760 | 787 | |
| 761 | 788 | $context['settings'] = $context['theme_settings']; |
@@ -764,18 +791,21 @@ discard block |
||
| 764 | 791 | foreach ($context['settings'] as $i => $setting) |
| 765 | 792 | { |
| 766 | 793 | // Separators are dummies, so leave them alone. |
| 767 | - if (!is_array($setting)) |
|
| 768 | - continue; |
|
| 794 | + if (!is_array($setting)) { |
|
| 795 | + continue; |
|
| 796 | + } |
|
| 769 | 797 | |
| 770 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
| 771 | - $context['settings'][$i]['type'] = 'checkbox'; |
|
| 772 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
| 773 | - $context['settings'][$i]['type'] = 'number'; |
|
| 774 | - elseif ($setting['type'] == 'string') |
|
| 775 | - $context['settings'][$i]['type'] = 'text'; |
|
| 798 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
| 799 | + $context['settings'][$i]['type'] = 'checkbox'; |
|
| 800 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
| 801 | + $context['settings'][$i]['type'] = 'number'; |
|
| 802 | + } elseif ($setting['type'] == 'string') { |
|
| 803 | + $context['settings'][$i]['type'] = 'text'; |
|
| 804 | + } |
|
| 776 | 805 | |
| 777 | - if (isset($setting['options'])) |
|
| 778 | - $context['settings'][$i]['type'] = 'list'; |
|
| 806 | + if (isset($setting['options'])) { |
|
| 807 | + $context['settings'][$i]['type'] = 'list'; |
|
| 808 | + } |
|
| 779 | 809 | |
| 780 | 810 | $context['settings'][$i]['value'] = !isset($settings[$setting['id']]) ? '' : $settings[$setting['id']]; |
| 781 | 811 | } |
@@ -828,8 +858,9 @@ discard block |
||
| 828 | 858 | $themeID = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
| 829 | 859 | |
| 830 | 860 | // You can't delete the default theme! |
| 831 | - if ($themeID == 1) |
|
| 832 | - fatal_lang_error('no_access', false); |
|
| 861 | + if ($themeID == 1) { |
|
| 862 | + fatal_lang_error('no_access', false); |
|
| 863 | + } |
|
| 833 | 864 | |
| 834 | 865 | $theme_info = get_single_theme($themeID); |
| 835 | 866 | |
@@ -837,8 +868,9 @@ discard block |
||
| 837 | 868 | remove_theme($themeID); |
| 838 | 869 | |
| 839 | 870 | // And remove all its files and folders too. |
| 840 | - if (!empty($theme_info) && !empty($theme_info['theme_dir'])) |
|
| 841 | - remove_dir($theme_info['theme_dir']); |
|
| 871 | + if (!empty($theme_info) && !empty($theme_info['theme_dir'])) { |
|
| 872 | + remove_dir($theme_info['theme_dir']); |
|
| 873 | + } |
|
| 842 | 874 | |
| 843 | 875 | // Go back to the list page. |
| 844 | 876 | redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id'] . ';done=removing'); |
@@ -863,12 +895,14 @@ discard block |
||
| 863 | 895 | $enableThemes = explode(',', $modSettings['enableThemes']); |
| 864 | 896 | |
| 865 | 897 | // Are we disabling it? |
| 866 | - if (isset($_GET['disabled'])) |
|
| 867 | - $enableThemes = array_diff($enableThemes, array($themeID)); |
|
| 898 | + if (isset($_GET['disabled'])) { |
|
| 899 | + $enableThemes = array_diff($enableThemes, array($themeID)); |
|
| 900 | + } |
|
| 868 | 901 | |
| 869 | 902 | // Nope? then enable it! |
| 870 | - else |
|
| 871 | - $enableThemes[] = (string) $themeID; |
|
| 903 | + else { |
|
| 904 | + $enableThemes[] = (string) $themeID; |
|
| 905 | + } |
|
| 872 | 906 | |
| 873 | 907 | // Update the setting. |
| 874 | 908 | $enableThemes = strtr(implode(',', $enableThemes), array(',,' => ',')); |
@@ -903,18 +937,21 @@ discard block |
||
| 903 | 937 | |
| 904 | 938 | $_SESSION['id_theme'] = 0; |
| 905 | 939 | |
| 906 | - if (isset($_GET['id'])) |
|
| 907 | - $_GET['th'] = $_GET['id']; |
|
| 940 | + if (isset($_GET['id'])) { |
|
| 941 | + $_GET['th'] = $_GET['id']; |
|
| 942 | + } |
|
| 908 | 943 | |
| 909 | 944 | // Saving a variant cause JS doesn't work - pretend it did ;) |
| 910 | 945 | if (isset($_POST['save'])) |
| 911 | 946 | { |
| 912 | 947 | // Which theme? |
| 913 | - foreach ($_POST['save'] as $k => $v) |
|
| 914 | - $_GET['th'] = (int) $k; |
|
| 948 | + foreach ($_POST['save'] as $k => $v) { |
|
| 949 | + $_GET['th'] = (int) $k; |
|
| 950 | + } |
|
| 915 | 951 | |
| 916 | - if (isset($_POST['vrt'][$k])) |
|
| 917 | - $_GET['vrt'] = $_POST['vrt'][$k]; |
|
| 952 | + if (isset($_POST['vrt'][$k])) { |
|
| 953 | + $_GET['vrt'] = $_POST['vrt'][$k]; |
|
| 954 | + } |
|
| 918 | 955 | } |
| 919 | 956 | |
| 920 | 957 | // Have we made a decision, or are we just browsing? |
@@ -992,8 +1029,9 @@ discard block |
||
| 992 | 1029 | else |
| 993 | 1030 | { |
| 994 | 1031 | // The forum's default theme is always 0 and we |
| 995 | - if (isset($_GET['th']) && $_GET['th'] == 0) |
|
| 996 | - $_GET['th'] = $modSettings['theme_guests']; |
|
| 1032 | + if (isset($_GET['th']) && $_GET['th'] == 0) { |
|
| 1033 | + $_GET['th'] = $modSettings['theme_guests']; |
|
| 1034 | + } |
|
| 997 | 1035 | |
| 998 | 1036 | updateMemberData((int) $_REQUEST['u'], array('id_theme' => (int) $_GET['th'])); |
| 999 | 1037 | |
@@ -1007,8 +1045,9 @@ discard block |
||
| 1007 | 1045 | ); |
| 1008 | 1046 | cache_put_data('theme_settings-' . $_GET['th'] . ':' . (int) $_REQUEST['u'], null, 90); |
| 1009 | 1047 | |
| 1010 | - if ($user_info['id'] == $_REQUEST['u']) |
|
| 1011 | - $_SESSION['id_variant'] = 0; |
|
| 1048 | + if ($user_info['id'] == $_REQUEST['u']) { |
|
| 1049 | + $_SESSION['id_variant'] = 0; |
|
| 1050 | + } |
|
| 1012 | 1051 | } |
| 1013 | 1052 | |
| 1014 | 1053 | redirectexit('action=profile;u=' . (int) $_REQUEST['u'] . ';area=theme'); |
@@ -1077,12 +1116,13 @@ discard block |
||
| 1077 | 1116 | ); |
| 1078 | 1117 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1079 | 1118 | { |
| 1080 | - if (!isset($context['available_themes'][$row['id_theme']])) |
|
| 1081 | - $context['available_themes'][$row['id_theme']] = array( |
|
| 1119 | + if (!isset($context['available_themes'][$row['id_theme']])) { |
|
| 1120 | + $context['available_themes'][$row['id_theme']] = array( |
|
| 1082 | 1121 | 'id' => $row['id_theme'], |
| 1083 | 1122 | 'selected' => $context['current_theme'] == $row['id_theme'], |
| 1084 | 1123 | 'num_users' => 0 |
| 1085 | 1124 | ); |
| 1125 | + } |
|
| 1086 | 1126 | $context['available_themes'][$row['id_theme']][$row['variable']] = $row['value']; |
| 1087 | 1127 | } |
| 1088 | 1128 | $smcFunc['db_free_result']($request); |
@@ -1095,9 +1135,9 @@ discard block |
||
| 1095 | 1135 | 'num_users' => 0 |
| 1096 | 1136 | ); |
| 1097 | 1137 | $guest_theme = 0; |
| 1138 | + } else { |
|
| 1139 | + $guest_theme = $modSettings['theme_guests']; |
|
| 1098 | 1140 | } |
| 1099 | - else |
|
| 1100 | - $guest_theme = $modSettings['theme_guests']; |
|
| 1101 | 1141 | |
| 1102 | 1142 | $request = $smcFunc['db_query']('', ' |
| 1103 | 1143 | SELECT id_theme, COUNT(*) AS the_count |
@@ -1110,15 +1150,17 @@ discard block |
||
| 1110 | 1150 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1111 | 1151 | { |
| 1112 | 1152 | // Figure out which theme it is they are REALLY using. |
| 1113 | - if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) |
|
| 1114 | - $row['id_theme'] = $guest_theme; |
|
| 1115 | - elseif (empty($modSettings['theme_allow'])) |
|
| 1116 | - $row['id_theme'] = $guest_theme; |
|
| 1153 | + if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) { |
|
| 1154 | + $row['id_theme'] = $guest_theme; |
|
| 1155 | + } elseif (empty($modSettings['theme_allow'])) { |
|
| 1156 | + $row['id_theme'] = $guest_theme; |
|
| 1157 | + } |
|
| 1117 | 1158 | |
| 1118 | - if (isset($context['available_themes'][$row['id_theme']])) |
|
| 1119 | - $context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count']; |
|
| 1120 | - else |
|
| 1121 | - $context['available_themes'][$guest_theme]['num_users'] += $row['the_count']; |
|
| 1159 | + if (isset($context['available_themes'][$row['id_theme']])) { |
|
| 1160 | + $context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count']; |
|
| 1161 | + } else { |
|
| 1162 | + $context['available_themes'][$guest_theme]['num_users'] += $row['the_count']; |
|
| 1163 | + } |
|
| 1122 | 1164 | } |
| 1123 | 1165 | $smcFunc['db_free_result']($request); |
| 1124 | 1166 | |
@@ -1137,8 +1179,9 @@ discard block |
||
| 1137 | 1179 | 'id_member' => isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? array(-1, $context['current_member']) : array(-1), |
| 1138 | 1180 | ) |
| 1139 | 1181 | ); |
| 1140 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1141 | - $variant_preferences[$row['id_theme']] = $row['value']; |
|
| 1182 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1183 | + $variant_preferences[$row['id_theme']] = $row['value']; |
|
| 1184 | + } |
|
| 1142 | 1185 | $smcFunc['db_free_result']($request); |
| 1143 | 1186 | } |
| 1144 | 1187 | |
@@ -1149,17 +1192,18 @@ discard block |
||
| 1149 | 1192 | foreach ($context['available_themes'] as $id_theme => $theme_data) |
| 1150 | 1193 | { |
| 1151 | 1194 | // Don't try to load the forum or board default theme's data... it doesn't have any! |
| 1152 | - if ($id_theme == 0) |
|
| 1153 | - continue; |
|
| 1195 | + if ($id_theme == 0) { |
|
| 1196 | + continue; |
|
| 1197 | + } |
|
| 1154 | 1198 | |
| 1155 | 1199 | // The thumbnail needs the correct path. |
| 1156 | 1200 | $settings['images_url'] = &$theme_data['images_url']; |
| 1157 | 1201 | |
| 1158 | - if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) |
|
| 1159 | - include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'); |
|
| 1160 | - elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) |
|
| 1161 | - include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'); |
|
| 1162 | - else |
|
| 1202 | + if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) { |
|
| 1203 | + include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'); |
|
| 1204 | + } elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) { |
|
| 1205 | + include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'); |
|
| 1206 | + } else |
|
| 1163 | 1207 | { |
| 1164 | 1208 | $txt['theme_thumbnail_href'] = $theme_data['images_url'] . '/thumbnail.png'; |
| 1165 | 1209 | $txt['theme_description'] = ''; |
@@ -1184,15 +1228,17 @@ discard block |
||
| 1184 | 1228 | loadLanguage('Settings'); |
| 1185 | 1229 | |
| 1186 | 1230 | $context['available_themes'][$id_theme]['variants'] = array(); |
| 1187 | - foreach ($settings['theme_variants'] as $variant) |
|
| 1188 | - $context['available_themes'][$id_theme]['variants'][$variant] = array( |
|
| 1231 | + foreach ($settings['theme_variants'] as $variant) { |
|
| 1232 | + $context['available_themes'][$id_theme]['variants'][$variant] = array( |
|
| 1189 | 1233 | 'label' => isset($txt['variant_' . $variant]) ? $txt['variant_' . $variant] : $variant, |
| 1190 | 1234 | 'thumbnail' => !file_exists($theme_data['theme_dir'] . '/images/thumbnail.png') || file_exists($theme_data['theme_dir'] . '/images/thumbnail_' . $variant . '.png') ? $theme_data['images_url'] . '/thumbnail_' . $variant . '.png' : ($theme_data['images_url'] . '/thumbnail.png'), |
| 1191 | 1235 | ); |
| 1236 | + } |
|
| 1192 | 1237 | |
| 1193 | 1238 | $context['available_themes'][$id_theme]['selected_variant'] = isset($_GET['vrt']) ? $_GET['vrt'] : (!empty($variant_preferences[$id_theme]) ? $variant_preferences[$id_theme] : (!empty($settings['default_variant']) ? $settings['default_variant'] : $settings['theme_variants'][0])); |
| 1194 | - if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) |
|
| 1195 | - $context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0]; |
|
| 1239 | + if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) { |
|
| 1240 | + $context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0]; |
|
| 1241 | + } |
|
| 1196 | 1242 | |
| 1197 | 1243 | $context['available_themes'][$id_theme]['thumbnail_href'] = $context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail']; |
| 1198 | 1244 | // Allow themes to override the text. |
@@ -1208,8 +1254,9 @@ discard block |
||
| 1208 | 1254 | // As long as we're not doing the default theme... |
| 1209 | 1255 | if (!isset($_REQUEST['u']) || $_REQUEST['u'] >= 0) |
| 1210 | 1256 | { |
| 1211 | - if ($guest_theme != 0) |
|
| 1212 | - $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
| 1257 | + if ($guest_theme != 0) { |
|
| 1258 | + $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
| 1259 | + } |
|
| 1213 | 1260 | |
| 1214 | 1261 | $context['available_themes'][0]['id'] = 0; |
| 1215 | 1262 | $context['available_themes'][0]['name'] = $txt['theme_forum_default']; |
@@ -1258,14 +1305,16 @@ discard block |
||
| 1258 | 1305 | $action = $smcFunc['htmlspecialchars'](trim($_GET['do'])); |
| 1259 | 1306 | |
| 1260 | 1307 | // Got any info from the specific form? |
| 1261 | - if (!isset($_POST['save_' . $action])) |
|
| 1262 | - fatal_lang_error('theme_install_no_action', false); |
|
| 1308 | + if (!isset($_POST['save_' . $action])) { |
|
| 1309 | + fatal_lang_error('theme_install_no_action', false); |
|
| 1310 | + } |
|
| 1263 | 1311 | |
| 1264 | 1312 | validateToken('admin-t-' . $action); |
| 1265 | 1313 | |
| 1266 | 1314 | // Hopefully the themes directory is writable, or we might have a problem. |
| 1267 | - if (!is_writable($themedir)) |
|
| 1268 | - fatal_lang_error('theme_install_write_error', 'critical'); |
|
| 1315 | + if (!is_writable($themedir)) { |
|
| 1316 | + fatal_lang_error('theme_install_write_error', 'critical'); |
|
| 1317 | + } |
|
| 1269 | 1318 | |
| 1270 | 1319 | // Call the function and handle the result. |
| 1271 | 1320 | $result = $subActions[$action](); |
@@ -1280,9 +1329,10 @@ discard block |
||
| 1280 | 1329 | } |
| 1281 | 1330 | |
| 1282 | 1331 | // Nope, show a nice error. |
| 1283 | - else |
|
| 1284 | - fatal_lang_error('theme_install_no_action', false); |
|
| 1285 | -} |
|
| 1332 | + else { |
|
| 1333 | + fatal_lang_error('theme_install_no_action', false); |
|
| 1334 | + } |
|
| 1335 | + } |
|
| 1286 | 1336 | |
| 1287 | 1337 | /** |
| 1288 | 1338 | * Installs a theme from a theme package. |
@@ -1298,8 +1348,9 @@ discard block |
||
| 1298 | 1348 | $dirtemp = $themedir . '/temp'; |
| 1299 | 1349 | |
| 1300 | 1350 | // Make sure the temp dir doesn't already exist |
| 1301 | - if (file_exists($dirtemp)) |
|
| 1302 | - remove_dir($dirtemp); |
|
| 1351 | + if (file_exists($dirtemp)) { |
|
| 1352 | + remove_dir($dirtemp); |
|
| 1353 | + } |
|
| 1303 | 1354 | |
| 1304 | 1355 | // Create the temp dir. |
| 1305 | 1356 | mkdir($dirtemp, 0777); |
@@ -1311,17 +1362,20 @@ discard block |
||
| 1311 | 1362 | smf_chmod($dirtemp, '0755'); |
| 1312 | 1363 | |
| 1313 | 1364 | // How about now? |
| 1314 | - if (!is_writable($dirtemp)) |
|
| 1315 | - fatal_lang_error('theme_install_write_error', 'critical'); |
|
| 1365 | + if (!is_writable($dirtemp)) { |
|
| 1366 | + fatal_lang_error('theme_install_write_error', 'critical'); |
|
| 1367 | + } |
|
| 1316 | 1368 | } |
| 1317 | 1369 | |
| 1318 | 1370 | // This happens when the admin session is gone and the user has to login again. |
| 1319 | - if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) |
|
| 1320 | - redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1371 | + if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) { |
|
| 1372 | + redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1373 | + } |
|
| 1321 | 1374 | |
| 1322 | 1375 | // Another error check layer, something went wrong with the upload. |
| 1323 | - if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) |
|
| 1324 | - fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false); |
|
| 1376 | + if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) { |
|
| 1377 | + fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false); |
|
| 1378 | + } |
|
| 1325 | 1379 | |
| 1326 | 1380 | // Get the theme's name. |
| 1327 | 1381 | $name = pathinfo($_FILES['theme_gz']['name'], PATHINFO_FILENAME); |
@@ -1352,11 +1406,10 @@ discard block |
||
| 1352 | 1406 | |
| 1353 | 1407 | // return all the info. |
| 1354 | 1408 | return $context['to_install']; |
| 1409 | + } else { |
|
| 1410 | + fatal_lang_error('theme_install_error_title', false); |
|
| 1411 | + } |
|
| 1355 | 1412 | } |
| 1356 | - |
|
| 1357 | - else |
|
| 1358 | - fatal_lang_error('theme_install_error_title', false); |
|
| 1359 | -} |
|
| 1360 | 1413 | |
| 1361 | 1414 | /** |
| 1362 | 1415 | * Makes a copy from the default theme, assigns a name for it and installs it. |
@@ -1370,15 +1423,17 @@ discard block |
||
| 1370 | 1423 | global $forum_version; |
| 1371 | 1424 | |
| 1372 | 1425 | // There's gotta be something to work with. |
| 1373 | - if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) |
|
| 1374 | - fatal_lang_error('theme_install_error_title', false); |
|
| 1426 | + if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) { |
|
| 1427 | + fatal_lang_error('theme_install_error_title', false); |
|
| 1428 | + } |
|
| 1375 | 1429 | |
| 1376 | 1430 | // Get a cleaner version. |
| 1377 | 1431 | $name = preg_replace('~[^A-Za-z0-9_\- ]~', '', $_REQUEST['copy']); |
| 1378 | 1432 | |
| 1379 | 1433 | // Is there a theme already named like this? |
| 1380 | - if (file_exists($themedir . '/' . $name)) |
|
| 1381 | - fatal_lang_error('theme_install_already_dir', false); |
|
| 1434 | + if (file_exists($themedir . '/' . $name)) { |
|
| 1435 | + fatal_lang_error('theme_install_already_dir', false); |
|
| 1436 | + } |
|
| 1382 | 1437 | |
| 1383 | 1438 | // This is a brand new theme so set all possible values. |
| 1384 | 1439 | $context['to_install'] = array( |
@@ -1398,8 +1453,9 @@ discard block |
||
| 1398 | 1453 | |
| 1399 | 1454 | // Buy some time. |
| 1400 | 1455 | @set_time_limit(600); |
| 1401 | - if (function_exists('apache_reset_timeout')) |
|
| 1402 | - @apache_reset_timeout(); |
|
| 1456 | + if (function_exists('apache_reset_timeout')) { |
|
| 1457 | + @apache_reset_timeout(); |
|
| 1458 | + } |
|
| 1403 | 1459 | |
| 1404 | 1460 | // Create subdirectories for css and javascript files. |
| 1405 | 1461 | mkdir($context['to_install']['theme_dir'] . '/css', 0777); |
@@ -1435,12 +1491,13 @@ discard block |
||
| 1435 | 1491 | |
| 1436 | 1492 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1437 | 1493 | { |
| 1438 | - if ($row['variable'] == 'theme_templates') |
|
| 1439 | - $theme_templates = $row['value']; |
|
| 1440 | - elseif ($row['variable'] == 'theme_layers') |
|
| 1441 | - $theme_layers = $row['value']; |
|
| 1442 | - else |
|
| 1443 | - continue; |
|
| 1494 | + if ($row['variable'] == 'theme_templates') { |
|
| 1495 | + $theme_templates = $row['value']; |
|
| 1496 | + } elseif ($row['variable'] == 'theme_layers') { |
|
| 1497 | + $theme_layers = $row['value']; |
|
| 1498 | + } else { |
|
| 1499 | + continue; |
|
| 1500 | + } |
|
| 1444 | 1501 | } |
| 1445 | 1502 | |
| 1446 | 1503 | $smcFunc['db_free_result']($request); |
@@ -1499,12 +1556,14 @@ discard block |
||
| 1499 | 1556 | global $themedir, $themeurl, $context; |
| 1500 | 1557 | |
| 1501 | 1558 | // Cannot use the theme dir as a theme dir. |
| 1502 | - if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) |
|
| 1503 | - fatal_lang_error('theme_install_invalid_dir', false); |
|
| 1559 | + if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) { |
|
| 1560 | + fatal_lang_error('theme_install_invalid_dir', false); |
|
| 1561 | + } |
|
| 1504 | 1562 | |
| 1505 | 1563 | // Check is there is "something" on the dir. |
| 1506 | - elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) |
|
| 1507 | - fatal_lang_error('theme_install_error', false); |
|
| 1564 | + elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) { |
|
| 1565 | + fatal_lang_error('theme_install_error', false); |
|
| 1566 | + } |
|
| 1508 | 1567 | |
| 1509 | 1568 | $name = basename($_REQUEST['theme_dir']); |
| 1510 | 1569 | $name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $name); |
@@ -1548,24 +1607,27 @@ discard block |
||
| 1548 | 1607 | } |
| 1549 | 1608 | |
| 1550 | 1609 | // Any special layers? |
| 1551 | - if (isset($settings['catch_action']['layers'])) |
|
| 1552 | - $context['template_layers'] = $settings['catch_action']['layers']; |
|
| 1610 | + if (isset($settings['catch_action']['layers'])) { |
|
| 1611 | + $context['template_layers'] = $settings['catch_action']['layers']; |
|
| 1612 | + } |
|
| 1553 | 1613 | |
| 1554 | 1614 | // Any function to call? |
| 1555 | 1615 | if (isset($settings['catch_action']['function'])) |
| 1556 | 1616 | { |
| 1557 | 1617 | $hook = $settings['catch_action']['function']; |
| 1558 | 1618 | |
| 1559 | - if (!isset($settings['catch_action']['filename'])) |
|
| 1560 | - $settings['catch_action']['filename'] = ''; |
|
| 1619 | + if (!isset($settings['catch_action']['filename'])) { |
|
| 1620 | + $settings['catch_action']['filename'] = ''; |
|
| 1621 | + } |
|
| 1561 | 1622 | |
| 1562 | 1623 | add_integration_function('integrate_wrap_action', $hook, false, $settings['catch_action']['filename'], false); |
| 1563 | 1624 | call_integration_hook('integrate_wrap_action'); |
| 1564 | 1625 | } |
| 1565 | 1626 | // And finally, the main sub template ;). |
| 1566 | - if (isset($settings['catch_action']['sub_template'])) |
|
| 1567 | - $context['sub_template'] = $settings['catch_action']['sub_template']; |
|
| 1568 | -} |
|
| 1627 | + if (isset($settings['catch_action']['sub_template'])) { |
|
| 1628 | + $context['sub_template'] = $settings['catch_action']['sub_template']; |
|
| 1629 | + } |
|
| 1630 | + } |
|
| 1569 | 1631 | |
| 1570 | 1632 | /** |
| 1571 | 1633 | * Set an option via javascript. |
@@ -1584,12 +1646,14 @@ discard block |
||
| 1584 | 1646 | checkSession('get'); |
| 1585 | 1647 | |
| 1586 | 1648 | // This good-for-nothing pixel is being used to keep the session alive. |
| 1587 | - if (empty($_GET['var']) || !isset($_GET['val'])) |
|
| 1588 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
| 1649 | + if (empty($_GET['var']) || !isset($_GET['val'])) { |
|
| 1650 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
| 1651 | + } |
|
| 1589 | 1652 | |
| 1590 | 1653 | // Sorry, guests can't go any further than this. |
| 1591 | - if ($user_info['is_guest'] || $user_info['id'] == 0) |
|
| 1592 | - obExit(false); |
|
| 1654 | + if ($user_info['is_guest'] || $user_info['id'] == 0) { |
|
| 1655 | + obExit(false); |
|
| 1656 | + } |
|
| 1593 | 1657 | |
| 1594 | 1658 | $reservedVars = array( |
| 1595 | 1659 | 'actual_theme_url', |
@@ -1612,8 +1676,9 @@ discard block |
||
| 1612 | 1676 | ); |
| 1613 | 1677 | |
| 1614 | 1678 | // Can't change reserved vars. |
| 1615 | - if (in_array(strtolower($_GET['var']), $reservedVars)) |
|
| 1616 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
| 1679 | + if (in_array(strtolower($_GET['var']), $reservedVars)) { |
|
| 1680 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
| 1681 | + } |
|
| 1617 | 1682 | |
| 1618 | 1683 | // Use a specific theme? |
| 1619 | 1684 | if (isset($_GET['th']) || isset($_GET['id'])) |
@@ -1629,8 +1694,9 @@ discard block |
||
| 1629 | 1694 | { |
| 1630 | 1695 | $options['admin_preferences'] = !empty($options['admin_preferences']) ? smf_json_decode($options['admin_preferences'], true) : array(); |
| 1631 | 1696 | // New thingy... |
| 1632 | - if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) |
|
| 1633 | - $options['admin_preferences'][$_GET['admin_key']] = $_GET['val']; |
|
| 1697 | + if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) { |
|
| 1698 | + $options['admin_preferences'][$_GET['admin_key']] = $_GET['val']; |
|
| 1699 | + } |
|
| 1634 | 1700 | |
| 1635 | 1701 | // Change the value to be something nice, |
| 1636 | 1702 | $_GET['val'] = json_encode($options['admin_preferences']); |
@@ -1660,8 +1726,9 @@ discard block |
||
| 1660 | 1726 | global $context, $scripturl, $boarddir, $smcFunc, $txt; |
| 1661 | 1727 | |
| 1662 | 1728 | // @todo Should this be removed? |
| 1663 | - if (isset($_REQUEST['preview'])) |
|
| 1664 | - die('die() with fire'); |
|
| 1729 | + if (isset($_REQUEST['preview'])) { |
|
| 1730 | + die('die() with fire'); |
|
| 1731 | + } |
|
| 1665 | 1732 | |
| 1666 | 1733 | isAllowedTo('admin_forum'); |
| 1667 | 1734 | loadTemplate('Themes'); |
@@ -1675,11 +1742,11 @@ discard block |
||
| 1675 | 1742 | foreach ($context['themes'] as $key => $theme) |
| 1676 | 1743 | { |
| 1677 | 1744 | // There has to be a Settings template! |
| 1678 | - if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) |
|
| 1679 | - unset($context['themes'][$key]); |
|
| 1680 | - |
|
| 1681 | - else |
|
| 1682 | - $context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css'); |
|
| 1745 | + if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) { |
|
| 1746 | + unset($context['themes'][$key]); |
|
| 1747 | + } else { |
|
| 1748 | + $context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css'); |
|
| 1749 | + } |
|
| 1683 | 1750 | } |
| 1684 | 1751 | |
| 1685 | 1752 | $context['sub_template'] = 'edit_list'; |
@@ -1694,22 +1761,24 @@ discard block |
||
| 1694 | 1761 | $context['theme_id'] = $currentTheme['id']; |
| 1695 | 1762 | $context['browse_title'] = sprintf($txt['themeadmin_browsing_theme'], $currentTheme['name']); |
| 1696 | 1763 | |
| 1697 | - if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) |
|
| 1698 | - fatal_lang_error('theme_edit_missing', false); |
|
| 1764 | + if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) { |
|
| 1765 | + fatal_lang_error('theme_edit_missing', false); |
|
| 1766 | + } |
|
| 1699 | 1767 | |
| 1700 | 1768 | if (!isset($_REQUEST['filename'])) |
| 1701 | 1769 | { |
| 1702 | 1770 | if (isset($_GET['directory'])) |
| 1703 | 1771 | { |
| 1704 | - if (substr($_GET['directory'], 0, 1) == '.') |
|
| 1705 | - $_GET['directory'] = ''; |
|
| 1706 | - else |
|
| 1772 | + if (substr($_GET['directory'], 0, 1) == '.') { |
|
| 1773 | + $_GET['directory'] = ''; |
|
| 1774 | + } else |
|
| 1707 | 1775 | { |
| 1708 | 1776 | $_GET['directory'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_GET['directory']); |
| 1709 | 1777 | |
| 1710 | 1778 | $temp = realpath($currentTheme['theme_dir'] . '/' . $_GET['directory']); |
| 1711 | - if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) |
|
| 1712 | - $_GET['directory'] = ''; |
|
| 1779 | + if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) { |
|
| 1780 | + $_GET['directory'] = ''; |
|
| 1781 | + } |
|
| 1713 | 1782 | } |
| 1714 | 1783 | } |
| 1715 | 1784 | |
@@ -1728,37 +1797,39 @@ discard block |
||
| 1728 | 1797 | 'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $temp, |
| 1729 | 1798 | 'size' => '', |
| 1730 | 1799 | )); |
| 1800 | + } else { |
|
| 1801 | + $context['theme_files'] = get_file_listing($currentTheme['theme_dir'], ''); |
|
| 1731 | 1802 | } |
| 1732 | - else |
|
| 1733 | - $context['theme_files'] = get_file_listing($currentTheme['theme_dir'], ''); |
|
| 1734 | 1803 | |
| 1735 | 1804 | $context['sub_template'] = 'edit_browse'; |
| 1736 | 1805 | |
| 1737 | 1806 | return; |
| 1738 | - } |
|
| 1739 | - else |
|
| 1807 | + } else |
|
| 1740 | 1808 | { |
| 1741 | - if (substr($_REQUEST['filename'], 0, 1) == '.') |
|
| 1742 | - $_REQUEST['filename'] = ''; |
|
| 1743 | - else |
|
| 1809 | + if (substr($_REQUEST['filename'], 0, 1) == '.') { |
|
| 1810 | + $_REQUEST['filename'] = ''; |
|
| 1811 | + } else |
|
| 1744 | 1812 | { |
| 1745 | 1813 | $_REQUEST['filename'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_REQUEST['filename']); |
| 1746 | 1814 | |
| 1747 | 1815 | $temp = realpath($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
| 1748 | - if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) |
|
| 1749 | - $_REQUEST['filename'] = ''; |
|
| 1816 | + if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) { |
|
| 1817 | + $_REQUEST['filename'] = ''; |
|
| 1818 | + } |
|
| 1750 | 1819 | } |
| 1751 | 1820 | |
| 1752 | - if (empty($_REQUEST['filename'])) |
|
| 1753 | - fatal_lang_error('theme_edit_missing', false); |
|
| 1821 | + if (empty($_REQUEST['filename'])) { |
|
| 1822 | + fatal_lang_error('theme_edit_missing', false); |
|
| 1823 | + } |
|
| 1754 | 1824 | } |
| 1755 | 1825 | |
| 1756 | 1826 | if (isset($_POST['save'])) |
| 1757 | 1827 | { |
| 1758 | 1828 | if (checkSession('post', '', false) == '' && validateToken('admin-te-' . md5($_GET['th'] . '-' . $_REQUEST['filename']), 'post', false) == true) |
| 1759 | 1829 | { |
| 1760 | - if (is_array($_POST['entire_file'])) |
|
| 1761 | - $_POST['entire_file'] = implode("\n", $_POST['entire_file']); |
|
| 1830 | + if (is_array($_POST['entire_file'])) { |
|
| 1831 | + $_POST['entire_file'] = implode("\n", $_POST['entire_file']); |
|
| 1832 | + } |
|
| 1762 | 1833 | |
| 1763 | 1834 | $_POST['entire_file'] = rtrim(strtr($_POST['entire_file'], array("\r" => '', ' ' => "\t"))); |
| 1764 | 1835 | |
@@ -1770,10 +1841,11 @@ discard block |
||
| 1770 | 1841 | fclose($fp); |
| 1771 | 1842 | |
| 1772 | 1843 | $error = @file_get_contents($currentTheme['theme_url'] . '/tmp_' . session_id() . '.php'); |
| 1773 | - if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) |
|
| 1774 | - $error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'; |
|
| 1775 | - else |
|
| 1776 | - unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'); |
|
| 1844 | + if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) { |
|
| 1845 | + $error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'; |
|
| 1846 | + } else { |
|
| 1847 | + unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'); |
|
| 1848 | + } |
|
| 1777 | 1849 | } |
| 1778 | 1850 | |
| 1779 | 1851 | if (!isset($error_file)) |
@@ -1794,10 +1866,11 @@ discard block |
||
| 1794 | 1866 | $context['sub_template'] = 'edit_file'; |
| 1795 | 1867 | |
| 1796 | 1868 | // Recycle the submitted data. |
| 1797 | - if (is_array($_POST['entire_file'])) |
|
| 1798 | - $context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file'])); |
|
| 1799 | - else |
|
| 1800 | - $context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']); |
|
| 1869 | + if (is_array($_POST['entire_file'])) { |
|
| 1870 | + $context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file'])); |
|
| 1871 | + } else { |
|
| 1872 | + $context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']); |
|
| 1873 | + } |
|
| 1801 | 1874 | |
| 1802 | 1875 | $context['edit_filename'] = $smcFunc['htmlspecialchars']($_POST['filename']); |
| 1803 | 1876 | |
@@ -1820,17 +1893,17 @@ discard block |
||
| 1820 | 1893 | $context['sub_template'] = 'edit_style'; |
| 1821 | 1894 | |
| 1822 | 1895 | $context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(file_get_contents($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']), array("\t" => ' '))); |
| 1823 | - } |
|
| 1824 | - elseif (substr($_REQUEST['filename'], -13) == '.template.php') |
|
| 1896 | + } elseif (substr($_REQUEST['filename'], -13) == '.template.php') |
|
| 1825 | 1897 | { |
| 1826 | 1898 | $context['sub_template'] = 'edit_template'; |
| 1827 | 1899 | |
| 1828 | - if (!isset($error_file)) |
|
| 1829 | - $file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
|
| 1830 | - else |
|
| 1900 | + if (!isset($error_file)) { |
|
| 1901 | + $file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
|
| 1902 | + } else |
|
| 1831 | 1903 | { |
| 1832 | - if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) |
|
| 1833 | - $context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2]; |
|
| 1904 | + if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) { |
|
| 1905 | + $context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2]; |
|
| 1906 | + } |
|
| 1834 | 1907 | $file_data = file($error_file); |
| 1835 | 1908 | unlink($error_file); |
| 1836 | 1909 | } |
@@ -1844,8 +1917,9 @@ discard block |
||
| 1844 | 1917 | // Try to format the functions a little nicer... |
| 1845 | 1918 | $context['file_parts'][$j]['data'] = trim($context['file_parts'][$j]['data']) . "\n"; |
| 1846 | 1919 | |
| 1847 | - if (empty($context['file_parts'][$j]['lines'])) |
|
| 1848 | - unset($context['file_parts'][$j]); |
|
| 1920 | + if (empty($context['file_parts'][$j]['lines'])) { |
|
| 1921 | + unset($context['file_parts'][$j]); |
|
| 1922 | + } |
|
| 1849 | 1923 | $context['file_parts'][++$j] = array('lines' => 0, 'line' => $i + 1, 'data' => ''); |
| 1850 | 1924 | } |
| 1851 | 1925 | |
@@ -1854,8 +1928,7 @@ discard block |
||
| 1854 | 1928 | } |
| 1855 | 1929 | |
| 1856 | 1930 | $context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(implode('', $file_data), array("\t" => ' '))); |
| 1857 | - } |
|
| 1858 | - else |
|
| 1931 | + } else |
|
| 1859 | 1932 | { |
| 1860 | 1933 | $context['sub_template'] = 'edit_file'; |
| 1861 | 1934 | |
@@ -1881,8 +1954,9 @@ discard block |
||
| 1881 | 1954 | |
| 1882 | 1955 | $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
| 1883 | 1956 | |
| 1884 | - if (empty($_GET['th'])) |
|
| 1885 | - fatal_lang_error('theme_install_invalid_id'); |
|
| 1957 | + if (empty($_GET['th'])) { |
|
| 1958 | + fatal_lang_error('theme_install_invalid_id'); |
|
| 1959 | + } |
|
| 1886 | 1960 | |
| 1887 | 1961 | // Get the theme info. |
| 1888 | 1962 | $theme = get_single_theme($_GET['th']); |
@@ -1890,25 +1964,24 @@ discard block |
||
| 1890 | 1964 | |
| 1891 | 1965 | if (isset($_REQUEST['template']) && preg_match('~[\./\\\\:\0]~', $_REQUEST['template']) == 0) |
| 1892 | 1966 | { |
| 1893 | - if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) |
|
| 1894 | - $filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'; |
|
| 1895 | - |
|
| 1896 | - else |
|
| 1897 | - fatal_lang_error('no_access', false); |
|
| 1967 | + if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) { |
|
| 1968 | + $filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'; |
|
| 1969 | + } else { |
|
| 1970 | + fatal_lang_error('no_access', false); |
|
| 1971 | + } |
|
| 1898 | 1972 | |
| 1899 | 1973 | $fp = fopen($theme['theme_dir'] . '/' . $_REQUEST['template'] . '.template.php', 'w'); |
| 1900 | 1974 | fwrite($fp, file_get_contents($filename)); |
| 1901 | 1975 | fclose($fp); |
| 1902 | 1976 | |
| 1903 | 1977 | redirectexit('action=admin;area=theme;th=' . $context['theme_id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=copy'); |
| 1904 | - } |
|
| 1905 | - elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0) |
|
| 1978 | + } elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0) |
|
| 1906 | 1979 | { |
| 1907 | - if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) |
|
| 1908 | - $filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'; |
|
| 1909 | - |
|
| 1910 | - else |
|
| 1911 | - fatal_lang_error('no_access', false); |
|
| 1980 | + if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) { |
|
| 1981 | + $filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'; |
|
| 1982 | + } else { |
|
| 1983 | + fatal_lang_error('no_access', false); |
|
| 1984 | + } |
|
| 1912 | 1985 | |
| 1913 | 1986 | $fp = fopen($theme['theme_dir'] . '/languages/' . $_REQUEST['lang_file'] . '.php', 'w'); |
| 1914 | 1987 | fwrite($fp, file_get_contents($filename)); |
@@ -1923,16 +1996,18 @@ discard block |
||
| 1923 | 1996 | $dir = dir($settings['default_theme_dir']); |
| 1924 | 1997 | while ($entry = $dir->read()) |
| 1925 | 1998 | { |
| 1926 | - if (substr($entry, -13) == '.template.php') |
|
| 1927 | - $templates[] = substr($entry, 0, -13); |
|
| 1999 | + if (substr($entry, -13) == '.template.php') { |
|
| 2000 | + $templates[] = substr($entry, 0, -13); |
|
| 2001 | + } |
|
| 1928 | 2002 | } |
| 1929 | 2003 | $dir->close(); |
| 1930 | 2004 | |
| 1931 | 2005 | $dir = dir($settings['default_theme_dir'] . '/languages'); |
| 1932 | 2006 | while ($entry = $dir->read()) |
| 1933 | 2007 | { |
| 1934 | - if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) |
|
| 1935 | - $lang_files[] = $matches[1]; |
|
| 2008 | + if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) { |
|
| 2009 | + $lang_files[] = $matches[1]; |
|
| 2010 | + } |
|
| 1936 | 2011 | } |
| 1937 | 2012 | $dir->close(); |
| 1938 | 2013 | |
@@ -1940,21 +2015,23 @@ discard block |
||
| 1940 | 2015 | natcasesort($lang_files); |
| 1941 | 2016 | |
| 1942 | 2017 | $context['available_templates'] = array(); |
| 1943 | - foreach ($templates as $template) |
|
| 1944 | - $context['available_templates'][$template] = array( |
|
| 2018 | + foreach ($templates as $template) { |
|
| 2019 | + $context['available_templates'][$template] = array( |
|
| 1945 | 2020 | 'filename' => $template . '.template.php', |
| 1946 | 2021 | 'value' => $template, |
| 1947 | 2022 | 'already_exists' => false, |
| 1948 | 2023 | 'can_copy' => is_writable($theme['theme_dir']), |
| 1949 | 2024 | ); |
| 2025 | + } |
|
| 1950 | 2026 | $context['available_language_files'] = array(); |
| 1951 | - foreach ($lang_files as $file) |
|
| 1952 | - $context['available_language_files'][$file] = array( |
|
| 2027 | + foreach ($lang_files as $file) { |
|
| 2028 | + $context['available_language_files'][$file] = array( |
|
| 1953 | 2029 | 'filename' => $file . '.php', |
| 1954 | 2030 | 'value' => $file, |
| 1955 | 2031 | 'already_exists' => false, |
| 1956 | 2032 | 'can_copy' => file_exists($theme['theme_dir'] . '/languages') ? is_writable($theme['theme_dir'] . '/languages') : is_writable($theme['theme_dir']), |
| 1957 | 2033 | ); |
| 2034 | + } |
|
| 1958 | 2035 | |
| 1959 | 2036 | $dir = dir($theme['theme_dir']); |
| 1960 | 2037 | while ($entry = $dir->read()) |
@@ -18,23 +18,25 @@ discard block |
||
| 18 | 18 | global $context; |
| 19 | 19 | |
| 20 | 20 | // Prevent Chrome from auto completing fields when viewing/editing other members profiles |
| 21 | - if (isBrowser('is_chrome') && !$context['user']['is_owner']) |
|
| 22 | - echo ' |
|
| 21 | + if (isBrowser('is_chrome') && !$context['user']['is_owner']) { |
|
| 22 | + echo ' |
|
| 23 | 23 | <script> |
| 24 | 24 | disableAutoComplete(); |
| 25 | 25 | </script>'; |
| 26 | + } |
|
| 26 | 27 | |
| 27 | 28 | // If an error occurred while trying to save previously, give the user a clue! |
| 28 | 29 | echo ' |
| 29 | 30 | ', template_error_message(); |
| 30 | 31 | |
| 31 | 32 | // If the profile was update successfully, let the user know this. |
| 32 | - if (!empty($context['profile_updated'])) |
|
| 33 | - echo ' |
|
| 33 | + if (!empty($context['profile_updated'])) { |
|
| 34 | + echo ' |
|
| 34 | 35 | <div class="infobox"> |
| 35 | 36 | ', $context['profile_updated'], ' |
| 36 | 37 | </div>'; |
| 37 | -} |
|
| 38 | + } |
|
| 39 | + } |
|
| 38 | 40 | |
| 39 | 41 | /** |
| 40 | 42 | * Template for any HTML needed below the profile (closing off divs/tables, etc.) |
@@ -102,8 +104,7 @@ discard block |
||
| 102 | 104 | if (empty($context['unread_alerts'])) |
| 103 | 105 | { |
| 104 | 106 | template_alerts_all_read(); |
| 105 | - } |
|
| 106 | - else |
|
| 107 | + } else |
|
| 107 | 108 | { |
| 108 | 109 | foreach ($context['unread_alerts'] as $id_alert => $details) |
| 109 | 110 | { |
@@ -164,10 +165,11 @@ discard block |
||
| 164 | 165 | <div class="custom_fields_above_name"> |
| 165 | 166 | <ul >'; |
| 166 | 167 | |
| 167 | - foreach ($context['print_custom_fields']['above_member'] as $field) |
|
| 168 | - if (!empty($field['output_html'])) |
|
| 168 | + foreach ($context['print_custom_fields']['above_member'] as $field) { |
|
| 169 | + if (!empty($field['output_html'])) |
|
| 169 | 170 | echo ' |
| 170 | 171 | <li>', $field['output_html'], '</li>'; |
| 172 | + } |
|
| 171 | 173 | |
| 172 | 174 | echo ' |
| 173 | 175 | </ul> |
@@ -188,10 +190,11 @@ discard block |
||
| 188 | 190 | <div class="custom_fields_below_avatar"> |
| 189 | 191 | <ul >'; |
| 190 | 192 | |
| 191 | - foreach ($context['print_custom_fields']['below_avatar'] as $field) |
|
| 192 | - if (!empty($field['output_html'])) |
|
| 193 | + foreach ($context['print_custom_fields']['below_avatar'] as $field) { |
|
| 194 | + if (!empty($field['output_html'])) |
|
| 193 | 195 | echo ' |
| 194 | 196 | <li>', $field['output_html'], '</li>'; |
| 197 | + } |
|
| 195 | 198 | |
| 196 | 199 | echo ' |
| 197 | 200 | </ul> |
@@ -202,22 +205,25 @@ discard block |
||
| 202 | 205 | echo ' |
| 203 | 206 | <ul class="clear">'; |
| 204 | 207 | // Email is only visible if it's your profile or you have the moderate_forum permission |
| 205 | - if ($context['member']['show_email']) |
|
| 206 | - echo ' |
|
| 208 | + if ($context['member']['show_email']) { |
|
| 209 | + echo ' |
|
| 207 | 210 | <li><a href="mailto:', $context['member']['email'], '" title="', $context['member']['email'], '" rel="nofollow"><span class="generic_icons mail" title="' . $txt['email'] . '"></span></a></li>'; |
| 211 | + } |
|
| 208 | 212 | |
| 209 | 213 | // Don't show an icon if they haven't specified a website. |
| 210 | - if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) |
|
| 211 | - echo ' |
|
| 214 | + if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) { |
|
| 215 | + echo ' |
|
| 212 | 216 | <li><a href="', $context['member']['website']['url'], '" title="' . $context['member']['website']['title'] . '" target="_blank" class="new_win">', ($settings['use_image_buttons'] ? '<span class="generic_icons www" title="' . $context['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
| 217 | + } |
|
| 213 | 218 | |
| 214 | 219 | // Are there any custom profile fields as icons? |
| 215 | 220 | if (!empty($context['print_custom_fields']['icons'])) |
| 216 | 221 | { |
| 217 | - foreach ($context['print_custom_fields']['icons'] as $field) |
|
| 218 | - if (!empty($field['output_html'])) |
|
| 222 | + foreach ($context['print_custom_fields']['icons'] as $field) { |
|
| 223 | + if (!empty($field['output_html'])) |
|
| 219 | 224 | echo ' |
| 220 | 225 | <li class="custom_field">', $field['output_html'], '</li>'; |
| 226 | + } |
|
| 221 | 227 | } |
| 222 | 228 | |
| 223 | 229 | echo ' |
@@ -225,23 +231,26 @@ discard block |
||
| 225 | 231 | <span id="userstatus">', $context['can_send_pm'] ? '<a href="' . $context['member']['online']['href'] . '" title="' . $context['member']['online']['text'] . '" rel="nofollow">' : '', $settings['use_image_buttons'] ? '<span class="' . ($context['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $context['member']['online']['text'] . '"></span>' : $context['member']['online']['label'], $context['can_send_pm'] ? '</a>' : '', $settings['use_image_buttons'] ? '<span class="smalltext"> ' . $context['member']['online']['label'] . '</span>' : ''; |
| 226 | 232 | |
| 227 | 233 | // Can they add this member as a buddy? |
| 228 | - if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) |
|
| 229 | - echo ' |
|
| 234 | + if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) { |
|
| 235 | + echo ' |
|
| 230 | 236 | <br><a href="', $scripturl, '?action=buddy;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a>'; |
| 237 | + } |
|
| 231 | 238 | |
| 232 | 239 | echo ' |
| 233 | 240 | </span>'; |
| 234 | 241 | |
| 235 | - if (!$context['user']['is_owner'] && $context['can_send_pm']) |
|
| 236 | - echo ' |
|
| 242 | + if (!$context['user']['is_owner'] && $context['can_send_pm']) { |
|
| 243 | + echo ' |
|
| 237 | 244 | <a href="', $scripturl, '?action=pm;sa=send;u=', $context['id_member'], '" class="infolinks">', $txt['profile_sendpm_short'], '</a>'; |
| 245 | + } |
|
| 238 | 246 | |
| 239 | 247 | echo ' |
| 240 | 248 | <a href="', $scripturl, '?action=profile;area=showposts;u=', $context['id_member'], '" class="infolinks">', $txt['showPosts'], '</a>'; |
| 241 | 249 | |
| 242 | - if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) |
|
| 243 | - echo ' |
|
| 250 | + if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) { |
|
| 251 | + echo ' |
|
| 244 | 252 | <a href="', $scripturl, '?action=profile;area=showdrafts;u=', $context['id_member'], '" class="infolinks">', $txt['drafts_show'], '</a>'; |
| 253 | + } |
|
| 245 | 254 | |
| 246 | 255 | echo ' |
| 247 | 256 | <a href="', $scripturl, '?action=profile;area=statistics;u=', $context['id_member'], '" class="infolinks">', $txt['statPanel'], '</a>'; |
@@ -253,10 +262,11 @@ discard block |
||
| 253 | 262 | <div class="custom_fields_bottom"> |
| 254 | 263 | <ul class="nolist">'; |
| 255 | 264 | |
| 256 | - foreach ($context['print_custom_fields']['bottom_poster'] as $field) |
|
| 257 | - if (!empty($field['output_html'])) |
|
| 265 | + foreach ($context['print_custom_fields']['bottom_poster'] as $field) { |
|
| 266 | + if (!empty($field['output_html'])) |
|
| 258 | 267 | echo ' |
| 259 | 268 | <li>', $field['output_html'], '</li>'; |
| 269 | + } |
|
| 260 | 270 | |
| 261 | 271 | echo ' |
| 262 | 272 | </ul> |
@@ -270,15 +280,17 @@ discard block |
||
| 270 | 280 | <div id="detailedinfo"> |
| 271 | 281 | <dl class="settings">'; |
| 272 | 282 | |
| 273 | - if ($context['user']['is_owner'] || $context['user']['is_admin']) |
|
| 274 | - echo ' |
|
| 283 | + if ($context['user']['is_owner'] || $context['user']['is_admin']) { |
|
| 284 | + echo ' |
|
| 275 | 285 | <dt>', $txt['username'], ': </dt> |
| 276 | 286 | <dd>', $context['member']['username'], '</dd>'; |
| 287 | + } |
|
| 277 | 288 | |
| 278 | - if (!isset($context['disabled_fields']['posts'])) |
|
| 279 | - echo ' |
|
| 289 | + if (!isset($context['disabled_fields']['posts'])) { |
|
| 290 | + echo ' |
|
| 280 | 291 | <dt>', $txt['profile_posts'], ': </dt> |
| 281 | 292 | <dd>', $context['member']['posts'], ' (', $context['member']['posts_per_day'], ' ', $txt['posts_per_day'], ')</dd>'; |
| 293 | + } |
|
| 282 | 294 | |
| 283 | 295 | if ($context['member']['show_email']) |
| 284 | 296 | { |
@@ -287,15 +299,17 @@ discard block |
||
| 287 | 299 | <dd><a href="mailto:', $context['member']['email'], '">', $context['member']['email'], '</a></dd>'; |
| 288 | 300 | } |
| 289 | 301 | |
| 290 | - if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) |
|
| 291 | - echo ' |
|
| 302 | + if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) { |
|
| 303 | + echo ' |
|
| 292 | 304 | <dt>', $txt['custom_title'], ': </dt> |
| 293 | 305 | <dd>', $context['member']['title'], '</dd>'; |
| 306 | + } |
|
| 294 | 307 | |
| 295 | - if (!empty($context['member']['blurb'])) |
|
| 296 | - echo ' |
|
| 308 | + if (!empty($context['member']['blurb'])) { |
|
| 309 | + echo ' |
|
| 297 | 310 | <dt>', $txt['personal_text'], ': </dt> |
| 298 | 311 | <dd>', $context['member']['blurb'], '</dd>'; |
| 312 | + } |
|
| 299 | 313 | |
| 300 | 314 | echo ' |
| 301 | 315 | <dt>', $txt['age'], ':</dt> |
@@ -310,11 +324,12 @@ discard block |
||
| 310 | 324 | echo ' |
| 311 | 325 | <dl class="settings">'; |
| 312 | 326 | |
| 313 | - foreach ($context['print_custom_fields']['standard'] as $field) |
|
| 314 | - if (!empty($field['output_html'])) |
|
| 327 | + foreach ($context['print_custom_fields']['standard'] as $field) { |
|
| 328 | + if (!empty($field['output_html'])) |
|
| 315 | 329 | echo ' |
| 316 | 330 | <dt>', $field['name'], ':</dt> |
| 317 | 331 | <dd>', $field['output_html'], '</dd>'; |
| 332 | + } |
|
| 318 | 333 | |
| 319 | 334 | echo ' |
| 320 | 335 | </dl>'; |
@@ -332,9 +347,10 @@ discard block |
||
| 332 | 347 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=', ($context['can_issue_warning'] && !$context['user']['is_owner'] ? 'issuewarning' : 'viewwarning'), '">', $context['member']['warning'], '%</a>'; |
| 333 | 348 | |
| 334 | 349 | // Can we provide information on what this means? |
| 335 | - if (!empty($context['warning_status'])) |
|
| 336 | - echo ' |
|
| 350 | + if (!empty($context['warning_status'])) { |
|
| 351 | + echo ' |
|
| 337 | 352 | <span class="smalltext">(', $context['warning_status'], ')</span>'; |
| 353 | + } |
|
| 338 | 354 | |
| 339 | 355 | echo ' |
| 340 | 356 | </dd>'; |
@@ -345,9 +361,10 @@ discard block |
||
| 345 | 361 | { |
| 346 | 362 | |
| 347 | 363 | // If the person looking at the summary has permission, and the account isn't activated, give the viewer the ability to do it themselves. |
| 348 | - if (!empty($context['activate_message'])) |
|
| 349 | - echo ' |
|
| 364 | + if (!empty($context['activate_message'])) { |
|
| 365 | + echo ' |
|
| 350 | 366 | <dt class="clear"><span class="alert">', $context['activate_message'], '</span> (<a href="', $context['activate_link'], '"', ($context['activate_type'] == 4 ? ' class="you_sure" data-confirm="' . $txt['profileConfirm'] . '"' : ''), '>', $context['activate_link_text'], '</a>)</dt>'; |
| 367 | + } |
|
| 351 | 368 | |
| 352 | 369 | // If the current member is banned, show a message and possibly a link to the ban. |
| 353 | 370 | if (!empty($context['member']['bans'])) |
@@ -357,9 +374,10 @@ discard block |
||
| 357 | 374 | <dt class="clear" id="ban_info" style="display: none;"> |
| 358 | 375 | <strong>', $txt['user_banned_by_following'], ':</strong>'; |
| 359 | 376 | |
| 360 | - foreach ($context['member']['bans'] as $ban) |
|
| 361 | - echo ' |
|
| 377 | + foreach ($context['member']['bans'] as $ban) { |
|
| 378 | + echo ' |
|
| 362 | 379 | <br><span class="smalltext">', $ban['explanation'], '</span>'; |
| 380 | + } |
|
| 363 | 381 | |
| 364 | 382 | echo ' |
| 365 | 383 | </dt>'; |
@@ -373,30 +391,34 @@ discard block |
||
| 373 | 391 | // If the person looking is allowed, they can check the members IP address and hostname. |
| 374 | 392 | if ($context['can_see_ip']) |
| 375 | 393 | { |
| 376 | - if (!empty($context['member']['ip'])) |
|
| 377 | - echo ' |
|
| 394 | + if (!empty($context['member']['ip'])) { |
|
| 395 | + echo ' |
|
| 378 | 396 | <dt>', $txt['ip'], ': </dt> |
| 379 | 397 | <dd><a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['member']['ip'], ';u=', $context['member']['id'], '">', $context['member']['ip'], '</a></dd>'; |
| 398 | + } |
|
| 380 | 399 | |
| 381 | - if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) |
|
| 382 | - echo ' |
|
| 400 | + if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) { |
|
| 401 | + echo ' |
|
| 383 | 402 | <dt>', $txt['hostname'], ': </dt> |
| 384 | 403 | <dd>', $context['member']['hostname'], '</dd>'; |
| 404 | + } |
|
| 385 | 405 | } |
| 386 | 406 | |
| 387 | 407 | echo ' |
| 388 | 408 | <dt>', $txt['local_time'], ':</dt> |
| 389 | 409 | <dd>', $context['member']['local_time'], '</dd>'; |
| 390 | 410 | |
| 391 | - if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) |
|
| 392 | - echo ' |
|
| 411 | + if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) { |
|
| 412 | + echo ' |
|
| 393 | 413 | <dt>', $txt['language'], ':</dt> |
| 394 | 414 | <dd>', $context['member']['language'], '</dd>'; |
| 415 | + } |
|
| 395 | 416 | |
| 396 | - if ($context['member']['show_last_login']) |
|
| 397 | - echo ' |
|
| 417 | + if ($context['member']['show_last_login']) { |
|
| 418 | + echo ' |
|
| 398 | 419 | <dt>', $txt['lastLoggedIn'], ': </dt> |
| 399 | 420 | <dd>', $context['member']['last_login'], (!empty($context['member']['is_hidden']) ? ' (' . $txt['hidden'] . ')' : ''), '</dd>'; |
| 421 | + } |
|
| 400 | 422 | |
| 401 | 423 | echo ' |
| 402 | 424 | </dl>'; |
@@ -408,10 +430,11 @@ discard block |
||
| 408 | 430 | <div class="custom_fields_above_signature"> |
| 409 | 431 | <ul class="nolist">'; |
| 410 | 432 | |
| 411 | - foreach ($context['print_custom_fields']['above_signature'] as $field) |
|
| 412 | - if (!empty($field['output_html'])) |
|
| 433 | + foreach ($context['print_custom_fields']['above_signature'] as $field) { |
|
| 434 | + if (!empty($field['output_html'])) |
|
| 413 | 435 | echo ' |
| 414 | 436 | <li>', $field['output_html'], '</li>'; |
| 437 | + } |
|
| 415 | 438 | |
| 416 | 439 | echo ' |
| 417 | 440 | </ul> |
@@ -419,12 +442,13 @@ discard block |
||
| 419 | 442 | } |
| 420 | 443 | |
| 421 | 444 | // Show the users signature. |
| 422 | - if ($context['signature_enabled'] && !empty($context['member']['signature'])) |
|
| 423 | - echo ' |
|
| 445 | + if ($context['signature_enabled'] && !empty($context['member']['signature'])) { |
|
| 446 | + echo ' |
|
| 424 | 447 | <div class="signature"> |
| 425 | 448 | <h5>', $txt['signature'], ':</h5> |
| 426 | 449 | ', $context['member']['signature'], ' |
| 427 | 450 | </div>'; |
| 451 | + } |
|
| 428 | 452 | |
| 429 | 453 | // Are there any custom profile fields for below the signature? |
| 430 | 454 | if (!empty($context['print_custom_fields']['below_signature'])) |
@@ -433,10 +457,11 @@ discard block |
||
| 433 | 457 | <div class="custom_fields_below_signature"> |
| 434 | 458 | <ul class="nolist">'; |
| 435 | 459 | |
| 436 | - foreach ($context['print_custom_fields']['below_signature'] as $field) |
|
| 437 | - if (!empty($field['output_html'])) |
|
| 460 | + foreach ($context['print_custom_fields']['below_signature'] as $field) { |
|
| 461 | + if (!empty($field['output_html'])) |
|
| 438 | 462 | echo ' |
| 439 | 463 | <li>', $field['output_html'], '</li>'; |
| 464 | + } |
|
| 440 | 465 | |
| 441 | 466 | echo ' |
| 442 | 467 | </ul> |
@@ -481,62 +506,70 @@ discard block |
||
| 481 | 506 | </div> |
| 482 | 507 | <div class="list_posts">'; |
| 483 | 508 | |
| 484 | - if (!$post['approved']) |
|
| 485 | - echo ' |
|
| 509 | + if (!$post['approved']) { |
|
| 510 | + echo ' |
|
| 486 | 511 | <div class="approve_post"> |
| 487 | 512 | <em>', $txt['post_awaiting_approval'], '</em> |
| 488 | 513 | </div>'; |
| 514 | + } |
|
| 489 | 515 | |
| 490 | 516 | echo ' |
| 491 | 517 | ', $post['body'], ' |
| 492 | 518 | </div>'; |
| 493 | 519 | |
| 494 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
| 495 | - echo ' |
|
| 520 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
| 521 | + echo ' |
|
| 496 | 522 | <div class="floatright"> |
| 497 | 523 | <ul class="quickbuttons">'; |
| 524 | + } |
|
| 498 | 525 | |
| 499 | 526 | // If they *can* reply? |
| 500 | - if ($post['can_reply']) |
|
| 501 | - echo ' |
|
| 527 | + if ($post['can_reply']) { |
|
| 528 | + echo ' |
|
| 502 | 529 | <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>'; |
| 530 | + } |
|
| 503 | 531 | |
| 504 | 532 | // If they *can* quote? |
| 505 | - if ($post['can_quote']) |
|
| 506 | - echo ' |
|
| 533 | + if ($post['can_quote']) { |
|
| 534 | + echo ' |
|
| 507 | 535 | <li><a href="', $scripturl . '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
| 536 | + } |
|
| 508 | 537 | |
| 509 | 538 | // How about... even... remove it entirely?! |
| 510 | - if ($post['can_delete']) |
|
| 511 | - echo ' |
|
| 539 | + if ($post['can_delete']) { |
|
| 540 | + echo ' |
|
| 512 | 541 | <li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';profile;u=', $context['member']['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
| 542 | + } |
|
| 513 | 543 | |
| 514 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
| 515 | - echo ' |
|
| 544 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
| 545 | + echo ' |
|
| 516 | 546 | </ul> |
| 517 | 547 | </div>'; |
| 548 | + } |
|
| 518 | 549 | |
| 519 | 550 | echo ' |
| 520 | 551 | </div>'; |
| 521 | 552 | } |
| 553 | + } else { |
|
| 554 | + template_show_list('attachments'); |
|
| 522 | 555 | } |
| 523 | - else |
|
| 524 | - template_show_list('attachments'); |
|
| 525 | 556 | |
| 526 | 557 | // No posts? Just end with a informative message. |
| 527 | - if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) |
|
| 528 | - echo ' |
|
| 558 | + if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) { |
|
| 559 | + echo ' |
|
| 529 | 560 | <div class="windowbg2"> |
| 530 | 561 | ', isset($context['attachments']) ? $txt['show_attachments_none'] : ($context['is_topics'] ? $txt['show_topics_none'] : $txt['show_posts_none']), ' |
| 531 | 562 | </div>'; |
| 563 | + } |
|
| 532 | 564 | |
| 533 | 565 | // Show more page numbers. |
| 534 | - if (!empty($context['page_index'])) |
|
| 535 | - echo ' |
|
| 566 | + if (!empty($context['page_index'])) { |
|
| 567 | + echo ' |
|
| 536 | 568 | <div class="pagesection"> |
| 537 | 569 | <div class="pagelinks">', $context['page_index'], '</div> |
| 538 | 570 | </div>'; |
| 539 | -} |
|
| 571 | + } |
|
| 572 | + } |
|
| 540 | 573 | |
| 541 | 574 | /** |
| 542 | 575 | * Template for showing alerts within the alerts popup |
@@ -546,11 +579,12 @@ discard block |
||
| 546 | 579 | global $context, $txt, $scripturl; |
| 547 | 580 | |
| 548 | 581 | // Do we have an update message? |
| 549 | - if (!empty($context['update_message'])) |
|
| 550 | - echo ' |
|
| 582 | + if (!empty($context['update_message'])) { |
|
| 583 | + echo ' |
|
| 551 | 584 | <div class="infobox"> |
| 552 | 585 | ', $context['update_message'], '. |
| 553 | 586 | </div>'; |
| 587 | + } |
|
| 554 | 588 | |
| 555 | 589 | echo ' |
| 556 | 590 | <div class="cat_bar"> |
@@ -559,13 +593,12 @@ discard block |
||
| 559 | 593 | </h3> |
| 560 | 594 | </div>'; |
| 561 | 595 | |
| 562 | - if (empty($context['alerts'])) |
|
| 563 | - echo ' |
|
| 596 | + if (empty($context['alerts'])) { |
|
| 597 | + echo ' |
|
| 564 | 598 | <div class="information"> |
| 565 | 599 | ', $txt['alerts_none'], ' |
| 566 | 600 | </div>'; |
| 567 | - |
|
| 568 | - else |
|
| 601 | + } else |
|
| 569 | 602 | { |
| 570 | 603 | // Start the form. |
| 571 | 604 | echo ' |
@@ -627,12 +660,12 @@ discard block |
||
| 627 | 660 | </div>' : ''; |
| 628 | 661 | |
| 629 | 662 | // No drafts? Just show an informative message. |
| 630 | - if (empty($context['drafts'])) |
|
| 631 | - echo ' |
|
| 663 | + if (empty($context['drafts'])) { |
|
| 664 | + echo ' |
|
| 632 | 665 | <div class="windowbg2 centertext"> |
| 633 | 666 | ', $txt['draft_none'], ' |
| 634 | 667 | </div>'; |
| 635 | - else |
|
| 668 | + } else |
|
| 636 | 669 | { |
| 637 | 670 | // For every draft to be displayed, give it its own div, and show the important details of the draft. |
| 638 | 671 | foreach ($context['drafts'] as $draft) |
@@ -643,11 +676,13 @@ discard block |
||
| 643 | 676 | <div class="topic_details"> |
| 644 | 677 | <h5><strong><a href="', $scripturl, '?board=', $draft['board']['id'], '.0">', $draft['board']['name'], '</a> / ', $draft['topic']['link'], '</strong> '; |
| 645 | 678 | |
| 646 | - if (!empty($draft['sticky'])) |
|
| 647 | - echo '<span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>'; |
|
| 679 | + if (!empty($draft['sticky'])) { |
|
| 680 | + echo '<span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>'; |
|
| 681 | + } |
|
| 648 | 682 | |
| 649 | - if (!empty($draft['locked'])) |
|
| 650 | - echo '<span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>'; |
|
| 683 | + if (!empty($draft['locked'])) { |
|
| 684 | + echo '<span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>'; |
|
| 685 | + } |
|
| 651 | 686 | |
| 652 | 687 | echo ' |
| 653 | 688 | </h5> |
@@ -680,12 +715,13 @@ discard block |
||
| 680 | 715 | { |
| 681 | 716 | global $context, $scripturl, $txt; |
| 682 | 717 | |
| 683 | - if (!empty($context['saved_successful'])) |
|
| 684 | - echo ' |
|
| 718 | + if (!empty($context['saved_successful'])) { |
|
| 719 | + echo ' |
|
| 685 | 720 | <div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>'; |
| 686 | - elseif (!empty($context['saved_failed'])) |
|
| 687 | - echo ' |
|
| 721 | + } elseif (!empty($context['saved_failed'])) { |
|
| 722 | + echo ' |
|
| 688 | 723 | <div class="errorbox">', $context['saved_failed'], '</div>'; |
| 724 | + } |
|
| 689 | 725 | |
| 690 | 726 | echo ' |
| 691 | 727 | <div id="edit_buddies"> |
@@ -699,24 +735,27 @@ discard block |
||
| 699 | 735 | <th scope="col" class="quarter_table">', $txt['name'], '</th> |
| 700 | 736 | <th scope="col">', $txt['status'], '</th>'; |
| 701 | 737 | |
| 702 | - if (allowedTo('moderate_forum')) |
|
| 703 | - echo ' |
|
| 738 | + if (allowedTo('moderate_forum')) { |
|
| 739 | + echo ' |
|
| 704 | 740 | <th scope="col">', $txt['email'], '</th>'; |
| 741 | + } |
|
| 705 | 742 | |
| 706 | - if (!empty($context['custom_pf'])) |
|
| 707 | - foreach ($context['custom_pf'] as $column) |
|
| 743 | + if (!empty($context['custom_pf'])) { |
|
| 744 | + foreach ($context['custom_pf'] as $column) |
|
| 708 | 745 | echo '<th scope="col">', $column['label'], '</th>'; |
| 746 | + } |
|
| 709 | 747 | |
| 710 | 748 | echo ' |
| 711 | 749 | <th scope="col">', $txt['remove'], '</th> |
| 712 | 750 | </tr>'; |
| 713 | 751 | |
| 714 | 752 | // If they don't have any buddies don't list them! |
| 715 | - if (empty($context['buddies'])) |
|
| 716 | - echo ' |
|
| 753 | + if (empty($context['buddies'])) { |
|
| 754 | + echo ' |
|
| 717 | 755 | <tr class="windowbg"> |
| 718 | 756 | <td colspan="', allowedTo('moderate_forum') ? '10' : '9', '"><strong>', $txt['no_buddies'], '</strong></td> |
| 719 | 757 | </tr>'; |
| 758 | + } |
|
| 720 | 759 | |
| 721 | 760 | // Now loop through each buddy showing info on each. |
| 722 | 761 | else |
@@ -728,15 +767,17 @@ discard block |
||
| 728 | 767 | <td>', $buddy['link'], '</td> |
| 729 | 768 | <td><a href="', $buddy['online']['href'], '"><span class="' . ($buddy['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $buddy['online']['text'] . '"></span></a></td>'; |
| 730 | 769 | |
| 731 | - if ($buddy['show_email']) |
|
| 732 | - echo ' |
|
| 770 | + if ($buddy['show_email']) { |
|
| 771 | + echo ' |
|
| 733 | 772 | <td><a href="mailto:' . $buddy['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $buddy['name'] . '"></span></a></td>'; |
| 773 | + } |
|
| 734 | 774 | |
| 735 | 775 | // Show the custom profile fields for this user. |
| 736 | - if (!empty($context['custom_pf'])) |
|
| 737 | - foreach ($context['custom_pf'] as $key => $column) |
|
| 776 | + if (!empty($context['custom_pf'])) { |
|
| 777 | + foreach ($context['custom_pf'] as $key => $column) |
|
| 738 | 778 | echo ' |
| 739 | 779 | <td class="lefttext">', $buddy['options'][$key], '</td>'; |
| 780 | + } |
|
| 740 | 781 | |
| 741 | 782 | echo ' |
| 742 | 783 | <td><a href="', $scripturl, '?action=profile;area=lists;sa=buddies;u=', $context['id_member'], ';remove=', $buddy['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['buddy_remove'], '"></span></a></td> |
@@ -766,9 +807,10 @@ discard block |
||
| 766 | 807 | </dl> |
| 767 | 808 | </div>'; |
| 768 | 809 | |
| 769 | - if (!empty($context['token_check'])) |
|
| 770 | - echo ' |
|
| 810 | + if (!empty($context['token_check'])) { |
|
| 811 | + echo ' |
|
| 771 | 812 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 813 | + } |
|
| 772 | 814 | |
| 773 | 815 | echo ' |
| 774 | 816 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -794,12 +836,13 @@ discard block |
||
| 794 | 836 | { |
| 795 | 837 | global $context, $scripturl, $txt; |
| 796 | 838 | |
| 797 | - if (!empty($context['saved_successful'])) |
|
| 798 | - echo ' |
|
| 839 | + if (!empty($context['saved_successful'])) { |
|
| 840 | + echo ' |
|
| 799 | 841 | <div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>'; |
| 800 | - elseif (!empty($context['saved_failed'])) |
|
| 801 | - echo ' |
|
| 842 | + } elseif (!empty($context['saved_failed'])) { |
|
| 843 | + echo ' |
|
| 802 | 844 | <div class="errorbox">', $context['saved_failed'], '</div>'; |
| 845 | + } |
|
| 803 | 846 | |
| 804 | 847 | echo ' |
| 805 | 848 | <div id="edit_buddies"> |
@@ -813,20 +856,22 @@ discard block |
||
| 813 | 856 | <th scope="col" class="quarter_table">', $txt['name'], '</th> |
| 814 | 857 | <th scope="col">', $txt['status'], '</th>'; |
| 815 | 858 | |
| 816 | - if (allowedTo('moderate_forum')) |
|
| 817 | - echo ' |
|
| 859 | + if (allowedTo('moderate_forum')) { |
|
| 860 | + echo ' |
|
| 818 | 861 | <th scope="col">', $txt['email'], '</th>'; |
| 862 | + } |
|
| 819 | 863 | |
| 820 | 864 | echo ' |
| 821 | 865 | <th scope="col">', $txt['ignore_remove'], '</th> |
| 822 | 866 | </tr>'; |
| 823 | 867 | |
| 824 | 868 | // If they don't have anyone on their ignore list, don't list it! |
| 825 | - if (empty($context['ignore_list'])) |
|
| 826 | - echo ' |
|
| 869 | + if (empty($context['ignore_list'])) { |
|
| 870 | + echo ' |
|
| 827 | 871 | <tr class="windowbg"> |
| 828 | 872 | <td colspan="', allowedTo('moderate_forum') ? '4' : '3', '"><strong>', $txt['no_ignore'], '</strong></td> |
| 829 | 873 | </tr>'; |
| 874 | + } |
|
| 830 | 875 | |
| 831 | 876 | // Now loop through each buddy showing info on each. |
| 832 | 877 | foreach ($context['ignore_list'] as $member) |
@@ -836,9 +881,10 @@ discard block |
||
| 836 | 881 | <td>', $member['link'], '</td> |
| 837 | 882 | <td><a href="', $member['online']['href'], '"><span class="' . ($member['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $member['online']['text'] . '"></span></a></td>'; |
| 838 | 883 | |
| 839 | - if ($member['show_email']) |
|
| 840 | - echo ' |
|
| 884 | + if ($member['show_email']) { |
|
| 885 | + echo ' |
|
| 841 | 886 | <td><a href="mailto:' . $member['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $member['name'] . '"></span></a></td>'; |
| 887 | + } |
|
| 842 | 888 | echo ' |
| 843 | 889 | <td><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=ignore;remove=', $member['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['ignore_remove'], '"></span></a></td> |
| 844 | 890 | </tr>'; |
@@ -865,9 +911,10 @@ discard block |
||
| 865 | 911 | </dl> |
| 866 | 912 | </div>'; |
| 867 | 913 | |
| 868 | - if (!empty($context['token_check'])) |
|
| 869 | - echo ' |
|
| 914 | + if (!empty($context['token_check'])) { |
|
| 915 | + echo ' |
|
| 870 | 916 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 917 | + } |
|
| 871 | 918 | |
| 872 | 919 | echo ' |
| 873 | 920 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -912,9 +959,10 @@ discard block |
||
| 912 | 959 | <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip'], ';u=', $context['member']['id'], '">', $context['last_ip'], '</a>'; |
| 913 | 960 | |
| 914 | 961 | // Second address detected? |
| 915 | - if (!empty($context['last_ip2'])) |
|
| 916 | - echo ' |
|
| 962 | + if (!empty($context['last_ip2'])) { |
|
| 963 | + echo ' |
|
| 917 | 964 | , <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip2'], ';u=', $context['member']['id'], '">', $context['last_ip2'], '</a>'; |
| 965 | + } |
|
| 918 | 966 | |
| 919 | 967 | echo ' |
| 920 | 968 | </dd>'; |
@@ -979,9 +1027,10 @@ discard block |
||
| 979 | 1027 | <h3 class="catbg">', $txt['whois_title'], ' ', $context['ip'], '</h3> |
| 980 | 1028 | </div> |
| 981 | 1029 | <div class="windowbg2 noup">'; |
| 982 | - foreach ($context['whois_servers'] as $server) |
|
| 983 | - echo ' |
|
| 1030 | + foreach ($context['whois_servers'] as $server) { |
|
| 1031 | + echo ' |
|
| 984 | 1032 | <a href="', $server['url'], '" target="_blank" class="new_win"', isset($context['auto_whois_server']) && $context['auto_whois_server']['name'] == $server['name'] ? ' style="font-weight: bold;"' : '', '>', $server['name'], '</a><br>'; |
| 1033 | + } |
|
| 985 | 1034 | echo ' |
| 986 | 1035 | </div> |
| 987 | 1036 | <br>'; |
@@ -992,10 +1041,10 @@ discard block |
||
| 992 | 1041 | <div class="cat_bar"> |
| 993 | 1042 | <h3 class="catbg">', $txt['members_from_ip'], ' ', $context['ip'], '</h3> |
| 994 | 1043 | </div>'; |
| 995 | - if (empty($context['ips'])) |
|
| 996 | - echo ' |
|
| 1044 | + if (empty($context['ips'])) { |
|
| 1045 | + echo ' |
|
| 997 | 1046 | <p class="windowbg2 description"><em>', $txt['no_members_from_ip'], '</em></p>'; |
| 998 | - else |
|
| 1047 | + } else |
|
| 999 | 1048 | { |
| 1000 | 1049 | echo ' |
| 1001 | 1050 | <table class="table_grid"> |
@@ -1008,12 +1057,13 @@ discard block |
||
| 1008 | 1057 | <tbody>'; |
| 1009 | 1058 | |
| 1010 | 1059 | // Loop through each of the members and display them. |
| 1011 | - foreach ($context['ips'] as $ip => $memberlist) |
|
| 1012 | - echo ' |
|
| 1060 | + foreach ($context['ips'] as $ip => $memberlist) { |
|
| 1061 | + echo ' |
|
| 1013 | 1062 | <tr class="windowbg"> |
| 1014 | 1063 | <td><a href="', $context['base_url'], ';searchip=', $ip, '">', $ip, '</a></td> |
| 1015 | 1064 | <td>', implode(', ', $memberlist), '</td> |
| 1016 | 1065 | </tr>'; |
| 1066 | + } |
|
| 1017 | 1067 | |
| 1018 | 1068 | echo ' |
| 1019 | 1069 | </tbody> |
@@ -1059,8 +1109,7 @@ discard block |
||
| 1059 | 1109 | { |
| 1060 | 1110 | echo ' |
| 1061 | 1111 | <div class="information">', $txt['showPermissions_all'], '</div>'; |
| 1062 | - } |
|
| 1063 | - else |
|
| 1112 | + } else |
|
| 1064 | 1113 | { |
| 1065 | 1114 | echo ' |
| 1066 | 1115 | <div class="information">',$txt['showPermissions_help'], '</div> |
@@ -1074,9 +1123,10 @@ discard block |
||
| 1074 | 1123 | </div> |
| 1075 | 1124 | <div class="windowbg smalltext"> |
| 1076 | 1125 | ', $txt['showPermissions_restricted_boards_desc'], ':<br>'; |
| 1077 | - foreach ($context['no_access_boards'] as $no_access_board) |
|
| 1078 | - echo ' |
|
| 1126 | + foreach ($context['no_access_boards'] as $no_access_board) { |
|
| 1127 | + echo ' |
|
| 1079 | 1128 | <a href="', $scripturl, '?board=', $no_access_board['id'], '.0">', $no_access_board['name'], '</a>', $no_access_board['is_last'] ? '' : ', '; |
| 1129 | + } |
|
| 1080 | 1130 | echo ' |
| 1081 | 1131 | </div>'; |
| 1082 | 1132 | } |
@@ -1108,12 +1158,13 @@ discard block |
||
| 1108 | 1158 | </td> |
| 1109 | 1159 | <td class="smalltext">'; |
| 1110 | 1160 | |
| 1111 | - if ($permission['is_denied']) |
|
| 1112 | - echo ' |
|
| 1161 | + if ($permission['is_denied']) { |
|
| 1162 | + echo ' |
|
| 1113 | 1163 | <span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>'; |
| 1114 | - else |
|
| 1115 | - echo ' |
|
| 1164 | + } else { |
|
| 1165 | + echo ' |
|
| 1116 | 1166 | ', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']); |
| 1167 | + } |
|
| 1117 | 1168 | |
| 1118 | 1169 | echo ' |
| 1119 | 1170 | </td> |
@@ -1123,10 +1174,10 @@ discard block |
||
| 1123 | 1174 | </tbody> |
| 1124 | 1175 | </table> |
| 1125 | 1176 | </div><br>'; |
| 1126 | - } |
|
| 1127 | - else |
|
| 1128 | - echo ' |
|
| 1177 | + } else { |
|
| 1178 | + echo ' |
|
| 1129 | 1179 | <p class="windowbg2">', $txt['showPermissions_none_general'], '</p>'; |
| 1180 | + } |
|
| 1130 | 1181 | |
| 1131 | 1182 | // Board permission section. |
| 1132 | 1183 | echo ' |
@@ -1136,14 +1187,16 @@ discard block |
||
| 1136 | 1187 | <a id="board_permissions"></a>', $txt['showPermissions_select'], ': |
| 1137 | 1188 | <select name="board" onchange="if (this.options[this.selectedIndex].value) this.form.submit();"> |
| 1138 | 1189 | <option value="0"', $context['board'] == 0 ? ' selected' : '', '>', $txt['showPermissions_global'], ' </option>'; |
| 1139 | - if (!empty($context['boards'])) |
|
| 1140 | - echo ' |
|
| 1190 | + if (!empty($context['boards'])) { |
|
| 1191 | + echo ' |
|
| 1141 | 1192 | <option value="" disabled>---------------------------</option>'; |
| 1193 | + } |
|
| 1142 | 1194 | |
| 1143 | 1195 | // Fill the box with any local permission boards. |
| 1144 | - foreach ($context['boards'] as $board) |
|
| 1145 | - echo ' |
|
| 1196 | + foreach ($context['boards'] as $board) { |
|
| 1197 | + echo ' |
|
| 1146 | 1198 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['name'], ' (', $board['profile_name'], ')</option>'; |
| 1199 | + } |
|
| 1147 | 1200 | |
| 1148 | 1201 | echo ' |
| 1149 | 1202 | </select> |
@@ -1174,8 +1227,7 @@ discard block |
||
| 1174 | 1227 | { |
| 1175 | 1228 | echo ' |
| 1176 | 1229 | <span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>'; |
| 1177 | - } |
|
| 1178 | - else |
|
| 1230 | + } else |
|
| 1179 | 1231 | { |
| 1180 | 1232 | echo ' |
| 1181 | 1233 | ', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']); |
@@ -1187,10 +1239,10 @@ discard block |
||
| 1187 | 1239 | echo ' |
| 1188 | 1240 | </tbody> |
| 1189 | 1241 | </table>'; |
| 1190 | - } |
|
| 1191 | - else |
|
| 1192 | - echo ' |
|
| 1242 | + } else { |
|
| 1243 | + echo ' |
|
| 1193 | 1244 | <p class="windowbg2">', $txt['showPermissions_none_board'], '</p>'; |
| 1245 | + } |
|
| 1194 | 1246 | echo ' |
| 1195 | 1247 | </div> |
| 1196 | 1248 | </div>'; |
@@ -1232,9 +1284,10 @@ discard block |
||
| 1232 | 1284 | </div>'; |
| 1233 | 1285 | |
| 1234 | 1286 | // If they haven't post at all, don't draw the graph. |
| 1235 | - if (empty($context['posts_by_time'])) |
|
| 1236 | - echo ' |
|
| 1287 | + if (empty($context['posts_by_time'])) { |
|
| 1288 | + echo ' |
|
| 1237 | 1289 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
| 1290 | + } |
|
| 1238 | 1291 | // Otherwise do! |
| 1239 | 1292 | else |
| 1240 | 1293 | { |
@@ -1273,11 +1326,10 @@ discard block |
||
| 1273 | 1326 | </h3> |
| 1274 | 1327 | </div>'; |
| 1275 | 1328 | |
| 1276 | - if (empty($context['popular_boards'])) |
|
| 1277 | - echo ' |
|
| 1329 | + if (empty($context['popular_boards'])) { |
|
| 1330 | + echo ' |
|
| 1278 | 1331 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
| 1279 | - |
|
| 1280 | - else |
|
| 1332 | + } else |
|
| 1281 | 1333 | { |
| 1282 | 1334 | echo ' |
| 1283 | 1335 | <dl class="stats">'; |
@@ -1308,10 +1360,10 @@ discard block |
||
| 1308 | 1360 | </h3> |
| 1309 | 1361 | </div>'; |
| 1310 | 1362 | |
| 1311 | - if (empty($context['board_activity'])) |
|
| 1312 | - echo ' |
|
| 1363 | + if (empty($context['board_activity'])) { |
|
| 1364 | + echo ' |
|
| 1313 | 1365 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
| 1314 | - else |
|
| 1366 | + } else |
|
| 1315 | 1367 | { |
| 1316 | 1368 | echo ' |
| 1317 | 1369 | <dl class="stats">'; |
@@ -1359,41 +1411,46 @@ discard block |
||
| 1359 | 1411 | <h3 class="catbg profile_hd">'; |
| 1360 | 1412 | |
| 1361 | 1413 | // Don't say "Profile" if this isn't the profile... |
| 1362 | - if (!empty($context['profile_header_text'])) |
|
| 1363 | - echo ' |
|
| 1414 | + if (!empty($context['profile_header_text'])) { |
|
| 1415 | + echo ' |
|
| 1364 | 1416 | ', $context['profile_header_text']; |
| 1365 | - else |
|
| 1366 | - echo ' |
|
| 1417 | + } else { |
|
| 1418 | + echo ' |
|
| 1367 | 1419 | ', $txt['profile']; |
| 1420 | + } |
|
| 1368 | 1421 | |
| 1369 | 1422 | echo ' |
| 1370 | 1423 | </h3> |
| 1371 | 1424 | </div>'; |
| 1372 | 1425 | |
| 1373 | 1426 | // Have we some description? |
| 1374 | - if ($context['page_desc']) |
|
| 1375 | - echo ' |
|
| 1427 | + if ($context['page_desc']) { |
|
| 1428 | + echo ' |
|
| 1376 | 1429 | <p class="information">', $context['page_desc'], '</p>'; |
| 1430 | + } |
|
| 1377 | 1431 | |
| 1378 | 1432 | echo ' |
| 1379 | 1433 | <div class="roundframe">'; |
| 1380 | 1434 | |
| 1381 | 1435 | // Any bits at the start? |
| 1382 | - if (!empty($context['profile_prehtml'])) |
|
| 1383 | - echo ' |
|
| 1436 | + if (!empty($context['profile_prehtml'])) { |
|
| 1437 | + echo ' |
|
| 1384 | 1438 | <div>', $context['profile_prehtml'], '</div>'; |
| 1439 | + } |
|
| 1385 | 1440 | |
| 1386 | - if (!empty($context['profile_fields'])) |
|
| 1387 | - echo ' |
|
| 1441 | + if (!empty($context['profile_fields'])) { |
|
| 1442 | + echo ' |
|
| 1388 | 1443 | <dl class="settings">'; |
| 1444 | + } |
|
| 1389 | 1445 | |
| 1390 | 1446 | // Start the big old loop 'of love. |
| 1391 | 1447 | $lastItem = 'hr'; |
| 1392 | 1448 | foreach ($context['profile_fields'] as $key => $field) |
| 1393 | 1449 | { |
| 1394 | 1450 | // We add a little hack to be sure we never get more than one hr in a row! |
| 1395 | - if ($lastItem == 'hr' && $field['type'] == 'hr') |
|
| 1396 | - continue; |
|
| 1451 | + if ($lastItem == 'hr' && $field['type'] == 'hr') { |
|
| 1452 | + continue; |
|
| 1453 | + } |
|
| 1397 | 1454 | |
| 1398 | 1455 | $lastItem = $field['type']; |
| 1399 | 1456 | if ($field['type'] == 'hr') |
@@ -1402,48 +1459,50 @@ discard block |
||
| 1402 | 1459 | </dl> |
| 1403 | 1460 | <hr> |
| 1404 | 1461 | <dl class="settings">'; |
| 1405 | - } |
|
| 1406 | - elseif ($field['type'] == 'callback') |
|
| 1462 | + } elseif ($field['type'] == 'callback') |
|
| 1407 | 1463 | { |
| 1408 | 1464 | if (isset($field['callback_func']) && function_exists('template_profile_' . $field['callback_func'])) |
| 1409 | 1465 | { |
| 1410 | 1466 | $callback_func = 'template_profile_' . $field['callback_func']; |
| 1411 | 1467 | $callback_func(); |
| 1412 | 1468 | } |
| 1413 | - } |
|
| 1414 | - else |
|
| 1469 | + } else |
|
| 1415 | 1470 | { |
| 1416 | 1471 | echo ' |
| 1417 | 1472 | <dt> |
| 1418 | 1473 | <strong', !empty($field['is_error']) ? ' class="error"' : '', '>', $field['type'] !== 'label' ? '<label for="' . $key . '">' : '', $field['label'], $field['type'] !== 'label' ? '</label>' : '', '</strong>'; |
| 1419 | 1474 | |
| 1420 | 1475 | // Does it have any subtext to show? |
| 1421 | - if (!empty($field['subtext'])) |
|
| 1422 | - echo ' |
|
| 1476 | + if (!empty($field['subtext'])) { |
|
| 1477 | + echo ' |
|
| 1423 | 1478 | <br> |
| 1424 | 1479 | <span class="smalltext">', $field['subtext'], '</span>'; |
| 1480 | + } |
|
| 1425 | 1481 | |
| 1426 | 1482 | echo ' |
| 1427 | 1483 | </dt> |
| 1428 | 1484 | <dd>'; |
| 1429 | 1485 | |
| 1430 | 1486 | // Want to put something infront of the box? |
| 1431 | - if (!empty($field['preinput'])) |
|
| 1432 | - echo ' |
|
| 1487 | + if (!empty($field['preinput'])) { |
|
| 1488 | + echo ' |
|
| 1433 | 1489 | ', $field['preinput']; |
| 1490 | + } |
|
| 1434 | 1491 | |
| 1435 | 1492 | // What type of data are we showing? |
| 1436 | - if ($field['type'] == 'label') |
|
| 1437 | - echo ' |
|
| 1493 | + if ($field['type'] == 'label') { |
|
| 1494 | + echo ' |
|
| 1438 | 1495 | ', $field['value']; |
| 1496 | + } |
|
| 1439 | 1497 | |
| 1440 | 1498 | // Maybe it's a text box - very likely! |
| 1441 | 1499 | elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'number', 'time', 'url'))) |
| 1442 | 1500 | { |
| 1443 | - if ($field['type'] == 'int' || $field['type'] == 'float') |
|
| 1444 | - $type = 'number'; |
|
| 1445 | - else |
|
| 1446 | - $type = $field['type']; |
|
| 1501 | + if ($field['type'] == 'int' || $field['type'] == 'float') { |
|
| 1502 | + $type = 'number'; |
|
| 1503 | + } else { |
|
| 1504 | + $type = $field['type']; |
|
| 1505 | + } |
|
| 1447 | 1506 | $step = $field['type'] == 'float' ? ' step="0.1"' : ''; |
| 1448 | 1507 | |
| 1449 | 1508 | |
@@ -1451,9 +1510,10 @@ discard block |
||
| 1451 | 1510 | <input type="', $type, '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" ', $field['input_attr'], ' class="input_', $field['type'] == 'password' ? 'password' : 'text', '"', $step, '>'; |
| 1452 | 1511 | } |
| 1453 | 1512 | // You "checking" me out? ;) |
| 1454 | - elseif ($field['type'] == 'check') |
|
| 1455 | - echo ' |
|
| 1513 | + elseif ($field['type'] == 'check') { |
|
| 1514 | + echo ' |
|
| 1456 | 1515 | <input type="hidden" name="', $key, '" value="0"><input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" class="input_check" ', $field['input_attr'], '>'; |
| 1516 | + } |
|
| 1457 | 1517 | |
| 1458 | 1518 | // Always fun - select boxes! |
| 1459 | 1519 | elseif ($field['type'] == 'select') |
@@ -1464,13 +1524,15 @@ discard block |
||
| 1464 | 1524 | if (isset($field['options'])) |
| 1465 | 1525 | { |
| 1466 | 1526 | // Is this some code to generate the options? |
| 1467 | - if (!is_array($field['options'])) |
|
| 1468 | - $field['options'] = $field['options'](); |
|
| 1527 | + if (!is_array($field['options'])) { |
|
| 1528 | + $field['options'] = $field['options'](); |
|
| 1529 | + } |
|
| 1469 | 1530 | // Assuming we now have some! |
| 1470 | - if (is_array($field['options'])) |
|
| 1471 | - foreach ($field['options'] as $value => $name) |
|
| 1531 | + if (is_array($field['options'])) { |
|
| 1532 | + foreach ($field['options'] as $value => $name) |
|
| 1472 | 1533 | echo ' |
| 1473 | 1534 | <option value="', $value, '"', $value == $field['value'] ? ' selected' : '', '>', $name, '</option>'; |
| 1535 | + } |
|
| 1474 | 1536 | } |
| 1475 | 1537 | |
| 1476 | 1538 | echo ' |
@@ -1478,25 +1540,28 @@ discard block |
||
| 1478 | 1540 | } |
| 1479 | 1541 | |
| 1480 | 1542 | // Something to end with? |
| 1481 | - if (!empty($field['postinput'])) |
|
| 1482 | - echo ' |
|
| 1543 | + if (!empty($field['postinput'])) { |
|
| 1544 | + echo ' |
|
| 1483 | 1545 | ', $field['postinput']; |
| 1546 | + } |
|
| 1484 | 1547 | |
| 1485 | 1548 | echo ' |
| 1486 | 1549 | </dd>'; |
| 1487 | 1550 | } |
| 1488 | 1551 | } |
| 1489 | 1552 | |
| 1490 | - if (!empty($context['profile_fields'])) |
|
| 1491 | - echo ' |
|
| 1553 | + if (!empty($context['profile_fields'])) { |
|
| 1554 | + echo ' |
|
| 1492 | 1555 | </dl>'; |
| 1556 | + } |
|
| 1493 | 1557 | |
| 1494 | 1558 | // Are there any custom profile fields - if so print them! |
| 1495 | 1559 | if (!empty($context['custom_fields'])) |
| 1496 | 1560 | { |
| 1497 | - if ($lastItem != 'hr') |
|
| 1498 | - echo ' |
|
| 1561 | + if ($lastItem != 'hr') { |
|
| 1562 | + echo ' |
|
| 1499 | 1563 | <hr>'; |
| 1564 | + } |
|
| 1500 | 1565 | |
| 1501 | 1566 | echo ' |
| 1502 | 1567 | <dl class="settings">'; |
@@ -1519,13 +1584,14 @@ discard block |
||
| 1519 | 1584 | } |
| 1520 | 1585 | |
| 1521 | 1586 | // Any closing HTML? |
| 1522 | - if (!empty($context['profile_posthtml'])) |
|
| 1523 | - echo ' |
|
| 1587 | + if (!empty($context['profile_posthtml'])) { |
|
| 1588 | + echo ' |
|
| 1524 | 1589 | <div>', $context['profile_posthtml'], '</div>'; |
| 1590 | + } |
|
| 1525 | 1591 | |
| 1526 | 1592 | // Only show the password box if it's actually needed. |
| 1527 | - if ($context['require_password']) |
|
| 1528 | - echo ' |
|
| 1593 | + if ($context['require_password']) { |
|
| 1594 | + echo ' |
|
| 1529 | 1595 | <dl class="settings"> |
| 1530 | 1596 | <dt> |
| 1531 | 1597 | <strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '><label for="oldpasswrd">', $txt['current_password'], ': </label></strong><br> |
@@ -1535,18 +1601,21 @@ discard block |
||
| 1535 | 1601 | <input type="password" name="oldpasswrd" id="oldpasswrd" size="20" style="margin-right: 4ex;" class="input_password"> |
| 1536 | 1602 | </dd> |
| 1537 | 1603 | </dl>'; |
| 1604 | + } |
|
| 1538 | 1605 | |
| 1539 | 1606 | // The button shouldn't say "Change profile" unless we're changing the profile... |
| 1540 | - if (!empty($context['submit_button_text'])) |
|
| 1541 | - echo ' |
|
| 1607 | + if (!empty($context['submit_button_text'])) { |
|
| 1608 | + echo ' |
|
| 1542 | 1609 | <input type="submit" name="save" value="', $context['submit_button_text'], '" class="button_submit">'; |
| 1543 | - else |
|
| 1544 | - echo ' |
|
| 1610 | + } else { |
|
| 1611 | + echo ' |
|
| 1545 | 1612 | <input type="submit" name="save" value="', $txt['change_profile'], '" class="button_submit">'; |
| 1613 | + } |
|
| 1546 | 1614 | |
| 1547 | - if (!empty($context['token_check'])) |
|
| 1548 | - echo ' |
|
| 1615 | + if (!empty($context['token_check'])) { |
|
| 1616 | + echo ' |
|
| 1549 | 1617 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 1618 | + } |
|
| 1550 | 1619 | |
| 1551 | 1620 | echo ' |
| 1552 | 1621 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -1556,10 +1625,11 @@ discard block |
||
| 1556 | 1625 | </form>'; |
| 1557 | 1626 | |
| 1558 | 1627 | // Any final spellchecking stuff? |
| 1559 | - if (!empty($context['show_spellchecking'])) |
|
| 1560 | - echo ' |
|
| 1628 | + if (!empty($context['show_spellchecking'])) { |
|
| 1629 | + echo ' |
|
| 1561 | 1630 | <form name="spell_form" id="spell_form" method="post" accept-charset="', $context['character_set'], '" target="spellWindow" action="', $scripturl, '?action=spellcheck"><input type="hidden" name="spellstring" value=""></form>'; |
| 1562 | -} |
|
| 1631 | + } |
|
| 1632 | + } |
|
| 1563 | 1633 | |
| 1564 | 1634 | /** |
| 1565 | 1635 | * Personal Message settings. |
@@ -1596,10 +1666,11 @@ discard block |
||
| 1596 | 1666 | <select name="pm_receive_from" id="pm_receive_from"> |
| 1597 | 1667 | <option value="0"', empty($context['receive_from']) || (empty($modSettings['enable_buddylist']) && $context['receive_from'] < 3) ? ' selected' : '', '>', $txt['pm_receive_from_everyone'], '</option>'; |
| 1598 | 1668 | |
| 1599 | - if (!empty($modSettings['enable_buddylist'])) |
|
| 1600 | - echo ' |
|
| 1669 | + if (!empty($modSettings['enable_buddylist'])) { |
|
| 1670 | + echo ' |
|
| 1601 | 1671 | <option value="1"', !empty($context['receive_from']) && $context['receive_from'] == 1 ? ' selected' : '', '>', $txt['pm_receive_from_ignore'], '</option> |
| 1602 | 1672 | <option value="2"', !empty($context['receive_from']) && $context['receive_from'] == 2 ? ' selected' : '', '>', $txt['pm_receive_from_buddies'], '</option>'; |
| 1673 | + } |
|
| 1603 | 1674 | |
| 1604 | 1675 | echo ' |
| 1605 | 1676 | <option value="3"', !empty($context['receive_from']) && $context['receive_from'] > 2 ? ' selected' : '', '>', $txt['pm_receive_from_admins'], '</option> |
@@ -1641,11 +1712,12 @@ discard block |
||
| 1641 | 1712 | if (empty($setting) || !is_array($setting)) |
| 1642 | 1713 | { |
| 1643 | 1714 | // Insert a separator (unless this is the first item in the list) |
| 1644 | - if ($i !== $first_option_key) |
|
| 1645 | - echo ' |
|
| 1715 | + if ($i !== $first_option_key) { |
|
| 1716 | + echo ' |
|
| 1646 | 1717 | </dl> |
| 1647 | 1718 | <hr> |
| 1648 | 1719 | <dl class="settings">'; |
| 1720 | + } |
|
| 1649 | 1721 | |
| 1650 | 1722 | // Should we give a name to this section? |
| 1651 | 1723 | if (is_string($setting) && !empty($setting)) |
@@ -1653,48 +1725,52 @@ discard block |
||
| 1653 | 1725 | $titled_section = true; |
| 1654 | 1726 | echo ' |
| 1655 | 1727 | <dt><b>' . $setting . '</b></dt><dd></dd>'; |
| 1728 | + } else { |
|
| 1729 | + $titled_section = false; |
|
| 1656 | 1730 | } |
| 1657 | - else |
|
| 1658 | - $titled_section = false; |
|
| 1659 | 1731 | |
| 1660 | 1732 | continue; |
| 1661 | 1733 | } |
| 1662 | 1734 | |
| 1663 | 1735 | // Is this disabled? |
| 1664 | - if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) |
|
| 1665 | - continue; |
|
| 1666 | - elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
| 1667 | - continue; |
|
| 1668 | - elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored'])) |
|
| 1669 | - continue; |
|
| 1670 | - elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist'])) |
|
| 1671 | - continue; |
|
| 1672 | - elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg'])) |
|
| 1673 | - continue; |
|
| 1674 | - elseif ($setting['id'] == 'topics_per_page' && !empty($modSettings['disableCustomPerPage'])) |
|
| 1675 | - continue; |
|
| 1676 | - elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) |
|
| 1677 | - continue; |
|
| 1678 | - elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) |
|
| 1679 | - continue; |
|
| 1736 | + if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) { |
|
| 1737 | + continue; |
|
| 1738 | + } elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) { |
|
| 1739 | + continue; |
|
| 1740 | + } elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored'])) { |
|
| 1741 | + continue; |
|
| 1742 | + } elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist'])) { |
|
| 1743 | + continue; |
|
| 1744 | + } elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg'])) { |
|
| 1745 | + continue; |
|
| 1746 | + } elseif ($setting['id'] == 'topics_per_page' && !empty($modSettings['disableCustomPerPage'])) { |
|
| 1747 | + continue; |
|
| 1748 | + } elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) { |
|
| 1749 | + continue; |
|
| 1750 | + } elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) { |
|
| 1751 | + continue; |
|
| 1752 | + } |
|
| 1680 | 1753 | |
| 1681 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
| 1682 | - $setting['type'] = 'checkbox'; |
|
| 1683 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
| 1684 | - $setting['type'] = 'number'; |
|
| 1685 | - elseif ($setting['type'] == 'string') |
|
| 1686 | - $setting['type'] = 'text'; |
|
| 1754 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
| 1755 | + $setting['type'] = 'checkbox'; |
|
| 1756 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
| 1757 | + $setting['type'] = 'number'; |
|
| 1758 | + } elseif ($setting['type'] == 'string') { |
|
| 1759 | + $setting['type'] = 'text'; |
|
| 1760 | + } |
|
| 1687 | 1761 | |
| 1688 | - if (isset($setting['options'])) |
|
| 1689 | - $setting['type'] = 'list'; |
|
| 1762 | + if (isset($setting['options'])) { |
|
| 1763 | + $setting['type'] = 'list'; |
|
| 1764 | + } |
|
| 1690 | 1765 | |
| 1691 | 1766 | echo ' |
| 1692 | 1767 | <dt> |
| 1693 | 1768 | <label for="', $setting['id'], '">', !$titled_section ? '<b>' : '', $setting['label'], !$titled_section ? '</b>' : '', '</label>'; |
| 1694 | 1769 | |
| 1695 | - if (isset($setting['description'])) |
|
| 1696 | - echo ' |
|
| 1770 | + if (isset($setting['description'])) { |
|
| 1771 | + echo ' |
|
| 1697 | 1772 | <br><span class="smalltext">', $setting['description'], '</span>'; |
| 1773 | + } |
|
| 1698 | 1774 | echo ' |
| 1699 | 1775 | </dt> |
| 1700 | 1776 | <dd>'; |
@@ -1732,13 +1808,11 @@ discard block |
||
| 1732 | 1808 | |
| 1733 | 1809 | echo ' |
| 1734 | 1810 | <input type="number"', $min . $max . $step; |
| 1735 | - } |
|
| 1736 | - else if (isset($setting['type']) && $setting['type'] == 'url') |
|
| 1811 | + } else if (isset($setting['type']) && $setting['type'] == 'url') |
|
| 1737 | 1812 | { |
| 1738 | 1813 | echo' |
| 1739 | 1814 | <input type="url"'; |
| 1740 | - } |
|
| 1741 | - else |
|
| 1815 | + } else |
|
| 1742 | 1816 | { |
| 1743 | 1817 | echo ' |
| 1744 | 1818 | <input type="text"'; |
@@ -1777,8 +1851,8 @@ discard block |
||
| 1777 | 1851 | <dl class="settings">'; |
| 1778 | 1852 | |
| 1779 | 1853 | // Allow notification on announcements to be disabled? |
| 1780 | - if (!empty($modSettings['allow_disableAnnounce'])) |
|
| 1781 | - echo ' |
|
| 1854 | + if (!empty($modSettings['allow_disableAnnounce'])) { |
|
| 1855 | + echo ' |
|
| 1782 | 1856 | <dt> |
| 1783 | 1857 | <label for="notify_announcements">', $txt['notify_important_email'], '</label> |
| 1784 | 1858 | </dt> |
@@ -1786,9 +1860,10 @@ discard block |
||
| 1786 | 1860 | <input type="hidden" name="notify_announcements" value="0"> |
| 1787 | 1861 | <input type="checkbox" id="notify_announcements" name="notify_announcements" value="1"', !empty($context['member']['notify_announcements']) ? ' checked' : '', ' class="input_check"> |
| 1788 | 1862 | </dd>'; |
| 1863 | + } |
|
| 1789 | 1864 | |
| 1790 | - if (!empty($modSettings['enable_ajax_alerts'])) |
|
| 1791 | - echo ' |
|
| 1865 | + if (!empty($modSettings['enable_ajax_alerts'])) { |
|
| 1866 | + echo ' |
|
| 1792 | 1867 | <dt> |
| 1793 | 1868 | <label for="notify_send_body">', $txt['notify_alert_timeout'], '</label> |
| 1794 | 1869 | </dt> |
@@ -1796,6 +1871,7 @@ discard block |
||
| 1796 | 1871 | <input type="number" size="4" id="notify_alert_timeout" name="opt_alert_timeout" min="0" value="', $context['member']['alert_timeout'], '" class="input_text"> |
| 1797 | 1872 | </dd> |
| 1798 | 1873 | '; |
| 1874 | + } |
|
| 1799 | 1875 | |
| 1800 | 1876 | echo ' |
| 1801 | 1877 | </dl> |
@@ -1825,9 +1901,10 @@ discard block |
||
| 1825 | 1901 | <td colspan="3">'; |
| 1826 | 1902 | $label = $txt['alert_opt_' . $opts[1]]; |
| 1827 | 1903 | $label_pos = isset($opts['label']) ? $opts['label'] : ''; |
| 1828 | - if ($label_pos == 'before') |
|
| 1829 | - echo ' |
|
| 1904 | + if ($label_pos == 'before') { |
|
| 1905 | + echo ' |
|
| 1830 | 1906 | <label for="opt_', $opts[1], '">', $label, '</label>'; |
| 1907 | + } |
|
| 1831 | 1908 | |
| 1832 | 1909 | $this_value = isset($context['alert_prefs'][$opts[1]]) ? $context['alert_prefs'][$opts[1]] : 0; |
| 1833 | 1910 | switch ($opts[0]) |
@@ -1839,17 +1916,19 @@ discard block |
||
| 1839 | 1916 | case 'select': |
| 1840 | 1917 | echo ' |
| 1841 | 1918 | <select name="opt_', $opts[1], '" id="opt_', $opts[1], '">'; |
| 1842 | - foreach ($opts['opts'] as $k => $v) |
|
| 1843 | - echo ' |
|
| 1919 | + foreach ($opts['opts'] as $k => $v) { |
|
| 1920 | + echo ' |
|
| 1844 | 1921 | <option value="', $k, '"', $this_value == $k ? ' selected' : '', '>', $v, '</option>'; |
| 1922 | + } |
|
| 1845 | 1923 | echo ' |
| 1846 | 1924 | </select>'; |
| 1847 | 1925 | break; |
| 1848 | 1926 | } |
| 1849 | 1927 | |
| 1850 | - if ($label_pos == 'after') |
|
| 1851 | - echo ' |
|
| 1928 | + if ($label_pos == 'after') { |
|
| 1929 | + echo ' |
|
| 1852 | 1930 | <label for="opt_', $opts[1], '">', $label, '</label>'; |
| 1931 | + } |
|
| 1853 | 1932 | |
| 1854 | 1933 | echo ' |
| 1855 | 1934 | </td> |
@@ -1963,11 +2042,12 @@ discard block |
||
| 1963 | 2042 | <p class="information">', $txt['groupMembership_info'], '</p>'; |
| 1964 | 2043 | |
| 1965 | 2044 | // Do we have an update message? |
| 1966 | - if (!empty($context['update_message'])) |
|
| 1967 | - echo ' |
|
| 2045 | + if (!empty($context['update_message'])) { |
|
| 2046 | + echo ' |
|
| 1968 | 2047 | <div class="infobox"> |
| 1969 | 2048 | ', $context['update_message'], '. |
| 1970 | 2049 | </div>'; |
| 2050 | + } |
|
| 1971 | 2051 | |
| 1972 | 2052 | echo ' |
| 1973 | 2053 | <div id="groups">'; |
@@ -1989,8 +2069,7 @@ discard block |
||
| 1989 | 2069 | </div> |
| 1990 | 2070 | </div> |
| 1991 | 2071 | </div>'; |
| 1992 | - } |
|
| 1993 | - else |
|
| 2072 | + } else |
|
| 1994 | 2073 | { |
| 1995 | 2074 | echo ' |
| 1996 | 2075 | <div class="title_bar"> |
@@ -2002,27 +2081,30 @@ discard block |
||
| 2002 | 2081 | echo ' |
| 2003 | 2082 | <div class="windowbg" id="primdiv_', $group['id'], '">'; |
| 2004 | 2083 | |
| 2005 | - if ($context['can_edit_primary']) |
|
| 2006 | - echo ' |
|
| 2084 | + if ($context['can_edit_primary']) { |
|
| 2085 | + echo ' |
|
| 2007 | 2086 | <input type="radio" name="primary" id="primary_', $group['id'], '" value="', $group['id'], '"', $group['is_primary'] ? ' checked' : '', ' onclick="highlightSelected(\'primdiv_' . $group['id'] . '\');"', $group['can_be_primary'] ? '' : ' disabled', ' class="input_radio">'; |
| 2087 | + } |
|
| 2008 | 2088 | |
| 2009 | 2089 | echo ' |
| 2010 | 2090 | <label for="primary_', $group['id'], '"><strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), '</label>'; |
| 2011 | 2091 | |
| 2012 | 2092 | // Can they leave their group? |
| 2013 | - if ($group['can_leave']) |
|
| 2014 | - echo ' |
|
| 2093 | + if ($group['can_leave']) { |
|
| 2094 | + echo ' |
|
| 2015 | 2095 | <a href="' . $scripturl . '?action=profile;save;u=' . $context['id_member'] . ';area=groupmembership;' . $context['session_var'] . '=' . $context['session_id'] . ';gid=' . $group['id'] . ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '">' . $txt['leave_group'] . '</a>'; |
| 2096 | + } |
|
| 2016 | 2097 | |
| 2017 | 2098 | echo ' |
| 2018 | 2099 | </div>'; |
| 2019 | 2100 | } |
| 2020 | 2101 | |
| 2021 | - if ($context['can_edit_primary']) |
|
| 2022 | - echo ' |
|
| 2102 | + if ($context['can_edit_primary']) { |
|
| 2103 | + echo ' |
|
| 2023 | 2104 | <div class="padding righttext"> |
| 2024 | 2105 | <input type="submit" value="', $txt['make_primary'], '" class="button_submit"> |
| 2025 | 2106 | </div>'; |
| 2107 | + } |
|
| 2026 | 2108 | |
| 2027 | 2109 | // Any groups they can join? |
| 2028 | 2110 | if (!empty($context['groups']['available'])) |
@@ -2038,15 +2120,16 @@ discard block |
||
| 2038 | 2120 | <div class="windowbg"> |
| 2039 | 2121 | <strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), ''; |
| 2040 | 2122 | |
| 2041 | - if ($group['type'] == 3) |
|
| 2042 | - echo ' |
|
| 2123 | + if ($group['type'] == 3) { |
|
| 2124 | + echo ' |
|
| 2043 | 2125 | <a href="', $scripturl, '?action=profile;save;u=', $context['id_member'], ';area=groupmembership;', $context['session_var'], '=', $context['session_id'], ';gid=', $group['id'], ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '" class="button floatright">', $txt['join_group'], '</a>'; |
| 2044 | - elseif ($group['type'] == 2 && $group['pending']) |
|
| 2045 | - echo ' |
|
| 2126 | + } elseif ($group['type'] == 2 && $group['pending']) { |
|
| 2127 | + echo ' |
|
| 2046 | 2128 | <span class="floatright">', $txt['approval_pending'], '</span>'; |
| 2047 | - elseif ($group['type'] == 2) |
|
| 2048 | - echo ' |
|
| 2129 | + } elseif ($group['type'] == 2) { |
|
| 2130 | + echo ' |
|
| 2049 | 2131 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=groupmembership;request=', $group['id'], '" class="button floatright">', $txt['request_group'], '</a>'; |
| 2132 | + } |
|
| 2050 | 2133 | |
| 2051 | 2134 | echo ' |
| 2052 | 2135 | </div>'; |
@@ -2069,9 +2152,10 @@ discard block |
||
| 2069 | 2152 | |
| 2070 | 2153 | prevDiv.className = "windowbg"; |
| 2071 | 2154 | }'; |
| 2072 | - if (isset($context['groups']['member'][$context['primary_group']])) |
|
| 2073 | - echo ' |
|
| 2155 | + if (isset($context['groups']['member'][$context['primary_group']])) { |
|
| 2156 | + echo ' |
|
| 2074 | 2157 | highlightSelected("primdiv_' . $context['primary_group'] . '");'; |
| 2158 | + } |
|
| 2075 | 2159 | echo ' |
| 2076 | 2160 | </script>'; |
| 2077 | 2161 | } |
@@ -2079,9 +2163,10 @@ discard block |
||
| 2079 | 2163 | echo ' |
| 2080 | 2164 | </div>'; |
| 2081 | 2165 | |
| 2082 | - if (!empty($context['token_check'])) |
|
| 2083 | - echo ' |
|
| 2166 | + if (!empty($context['token_check'])) { |
|
| 2167 | + echo ' |
|
| 2084 | 2168 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2169 | + } |
|
| 2085 | 2170 | |
| 2086 | 2171 | echo ' |
| 2087 | 2172 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2128,14 +2213,15 @@ discard block |
||
| 2128 | 2213 | |
| 2129 | 2214 | foreach ($category['boards'] as $board) |
| 2130 | 2215 | { |
| 2131 | - if ($i == $limit) |
|
| 2132 | - echo ' |
|
| 2216 | + if ($i == $limit) { |
|
| 2217 | + echo ' |
|
| 2133 | 2218 | </ul> |
| 2134 | 2219 | </li> |
| 2135 | 2220 | </ul> |
| 2136 | 2221 | <ul class="ignoreboards floatright"> |
| 2137 | 2222 | <li class="category"> |
| 2138 | 2223 | <ul>'; |
| 2224 | + } |
|
| 2139 | 2225 | |
| 2140 | 2226 | echo ' |
| 2141 | 2227 | <li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;"> |
@@ -2181,10 +2267,11 @@ discard block |
||
| 2181 | 2267 | |
| 2182 | 2268 | // Work out the starting color. |
| 2183 | 2269 | $context['current_color'] = $context['colors'][0]; |
| 2184 | - foreach ($context['colors'] as $limit => $color) |
|
| 2185 | - if ($context['member']['warning'] >= $limit) |
|
| 2270 | + foreach ($context['colors'] as $limit => $color) { |
|
| 2271 | + if ($context['member']['warning'] >= $limit) |
|
| 2186 | 2272 | $context['current_color'] = $color; |
| 2187 | -} |
|
| 2273 | + } |
|
| 2274 | + } |
|
| 2188 | 2275 | |
| 2189 | 2276 | // Show all warnings of a user? |
| 2190 | 2277 | function template_viewWarning() |
@@ -2223,14 +2310,15 @@ discard block |
||
| 2223 | 2310 | </dd>'; |
| 2224 | 2311 | |
| 2225 | 2312 | // There's some impact of this? |
| 2226 | - if (!empty($context['level_effects'][$context['current_level']])) |
|
| 2227 | - echo ' |
|
| 2313 | + if (!empty($context['level_effects'][$context['current_level']])) { |
|
| 2314 | + echo ' |
|
| 2228 | 2315 | <dt> |
| 2229 | 2316 | <strong>', $txt['profile_viewwarning_impact'], ':</strong> |
| 2230 | 2317 | </dt> |
| 2231 | 2318 | <dd> |
| 2232 | 2319 | ', $context['level_effects'][$context['current_level']], ' |
| 2233 | 2320 | </dd>'; |
| 2321 | + } |
|
| 2234 | 2322 | |
| 2235 | 2323 | echo ' |
| 2236 | 2324 | </dl> |
@@ -2268,10 +2356,11 @@ discard block |
||
| 2268 | 2356 | |
| 2269 | 2357 | // Otherwise see what we can do...'; |
| 2270 | 2358 | |
| 2271 | - foreach ($context['notification_templates'] as $k => $type) |
|
| 2272 | - echo ' |
|
| 2359 | + foreach ($context['notification_templates'] as $k => $type) { |
|
| 2360 | + echo ' |
|
| 2273 | 2361 | if (index == ', $k, ') |
| 2274 | 2362 | document.getElementById(\'warn_body\').value = "', strtr($type['body'], array('"' => "'", "\n" => '\\n', "\r" => '')), '";'; |
| 2363 | + } |
|
| 2275 | 2364 | |
| 2276 | 2365 | echo ' |
| 2277 | 2366 | } |
@@ -2281,10 +2370,11 @@ discard block |
||
| 2281 | 2370 | // Also set the right effect. |
| 2282 | 2371 | effectText = "";'; |
| 2283 | 2372 | |
| 2284 | - foreach ($context['level_effects'] as $limit => $text) |
|
| 2285 | - echo ' |
|
| 2373 | + foreach ($context['level_effects'] as $limit => $text) { |
|
| 2374 | + echo ' |
|
| 2286 | 2375 | if (slideAmount >= ', $limit, ') |
| 2287 | 2376 | effectText = "', $text, '";'; |
| 2377 | + } |
|
| 2288 | 2378 | |
| 2289 | 2379 | echo ' |
| 2290 | 2380 | setInnerHTML(document.getElementById(\'cur_level_div\'), slideAmount + \'% (\' + effectText + \')\'); |
@@ -2299,31 +2389,34 @@ discard block |
||
| 2299 | 2389 | </h3> |
| 2300 | 2390 | </div>'; |
| 2301 | 2391 | |
| 2302 | - if (!$context['user']['is_owner']) |
|
| 2303 | - echo ' |
|
| 2392 | + if (!$context['user']['is_owner']) { |
|
| 2393 | + echo ' |
|
| 2304 | 2394 | <p class="information">', $txt['profile_warning_desc'], '</p>'; |
| 2395 | + } |
|
| 2305 | 2396 | |
| 2306 | 2397 | echo ' |
| 2307 | 2398 | <div class="windowbg"> |
| 2308 | 2399 | <dl class="settings">'; |
| 2309 | 2400 | |
| 2310 | - if (!$context['user']['is_owner']) |
|
| 2311 | - echo ' |
|
| 2401 | + if (!$context['user']['is_owner']) { |
|
| 2402 | + echo ' |
|
| 2312 | 2403 | <dt> |
| 2313 | 2404 | <strong>', $txt['profile_warning_name'], ':</strong> |
| 2314 | 2405 | </dt> |
| 2315 | 2406 | <dd> |
| 2316 | 2407 | <strong>', $context['member']['name'], '</strong> |
| 2317 | 2408 | </dd>'; |
| 2409 | + } |
|
| 2318 | 2410 | |
| 2319 | 2411 | echo ' |
| 2320 | 2412 | <dt> |
| 2321 | 2413 | <strong>', $txt['profile_warning_level'], ':</strong>'; |
| 2322 | 2414 | |
| 2323 | 2415 | // Is there only so much they can apply? |
| 2324 | - if ($context['warning_limit']) |
|
| 2325 | - echo ' |
|
| 2416 | + if ($context['warning_limit']) { |
|
| 2417 | + echo ' |
|
| 2326 | 2418 | <br><span class="smalltext">', sprintf($txt['profile_warning_limit_attribute'], $context['warning_limit']), '</span>'; |
| 2419 | + } |
|
| 2327 | 2420 | |
| 2328 | 2421 | echo ' |
| 2329 | 2422 | </dt> |
@@ -2376,9 +2469,10 @@ discard block |
||
| 2376 | 2469 | <option value="-1">', $txt['profile_warning_notify_template'], '</option> |
| 2377 | 2470 | <option value="-1" disabled>------------------------------</option>'; |
| 2378 | 2471 | |
| 2379 | - foreach ($context['notification_templates'] as $id_template => $template) |
|
| 2380 | - echo ' |
|
| 2472 | + foreach ($context['notification_templates'] as $id_template => $template) { |
|
| 2473 | + echo ' |
|
| 2381 | 2474 | <option value="', $id_template, '">', $template['title'], '</option>'; |
| 2475 | + } |
|
| 2382 | 2476 | |
| 2383 | 2477 | echo ' |
| 2384 | 2478 | </select> |
@@ -2390,9 +2484,10 @@ discard block |
||
| 2390 | 2484 | </dl> |
| 2391 | 2485 | <div class="righttext">'; |
| 2392 | 2486 | |
| 2393 | - if (!empty($context['token_check'])) |
|
| 2394 | - echo ' |
|
| 2487 | + if (!empty($context['token_check'])) { |
|
| 2488 | + echo ' |
|
| 2395 | 2489 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2490 | + } |
|
| 2396 | 2491 | |
| 2397 | 2492 | echo ' |
| 2398 | 2493 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2408,8 +2503,8 @@ discard block |
||
| 2408 | 2503 | echo ' |
| 2409 | 2504 | <script>'; |
| 2410 | 2505 | |
| 2411 | - if (!$context['user']['is_owner']) |
|
| 2412 | - echo ' |
|
| 2506 | + if (!$context['user']['is_owner']) { |
|
| 2507 | + echo ' |
|
| 2413 | 2508 | modifyWarnNotify(); |
| 2414 | 2509 | $(document).ready(function() { |
| 2415 | 2510 | $("#preview_button").click(function() { |
@@ -2448,6 +2543,7 @@ discard block |
||
| 2448 | 2543 | }); |
| 2449 | 2544 | return false; |
| 2450 | 2545 | }'; |
| 2546 | + } |
|
| 2451 | 2547 | |
| 2452 | 2548 | echo ' |
| 2453 | 2549 | </script>'; |
@@ -2470,16 +2566,18 @@ discard block |
||
| 2470 | 2566 | </div>'; |
| 2471 | 2567 | |
| 2472 | 2568 | // If deleting another account give them a lovely info box. |
| 2473 | - if (!$context['user']['is_owner']) |
|
| 2474 | - echo ' |
|
| 2569 | + if (!$context['user']['is_owner']) { |
|
| 2570 | + echo ' |
|
| 2475 | 2571 | <p class="information">', $txt['deleteAccount_desc'], '</p>'; |
| 2572 | + } |
|
| 2476 | 2573 | echo ' |
| 2477 | 2574 | <div class="windowbg2">'; |
| 2478 | 2575 | |
| 2479 | 2576 | // If they are deleting their account AND the admin needs to approve it - give them another piece of info ;) |
| 2480 | - if ($context['needs_approval']) |
|
| 2481 | - echo ' |
|
| 2577 | + if ($context['needs_approval']) { |
|
| 2578 | + echo ' |
|
| 2482 | 2579 | <div class="errorbox">', $txt['deleteAccount_approval'], '</div>'; |
| 2580 | + } |
|
| 2483 | 2581 | |
| 2484 | 2582 | // If the user is deleting their own account warn them first - and require a password! |
| 2485 | 2583 | if ($context['user']['is_owner']) |
@@ -2491,9 +2589,10 @@ discard block |
||
| 2491 | 2589 | <input type="password" name="oldpasswrd" size="20" class="input_password"> |
| 2492 | 2590 | <input type="submit" value="', $txt['yes'], '" class="button_submit">'; |
| 2493 | 2591 | |
| 2494 | - if (!empty($context['token_check'])) |
|
| 2495 | - echo ' |
|
| 2592 | + if (!empty($context['token_check'])) { |
|
| 2593 | + echo ' |
|
| 2496 | 2594 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2595 | + } |
|
| 2497 | 2596 | |
| 2498 | 2597 | echo ' |
| 2499 | 2598 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2519,9 +2618,10 @@ discard block |
||
| 2519 | 2618 | <option value="topics">', $txt['deleteAccount_topics'], '</option> |
| 2520 | 2619 | </select>'; |
| 2521 | 2620 | |
| 2522 | - if ($context['show_perma_delete']) |
|
| 2523 | - echo ' |
|
| 2621 | + if ($context['show_perma_delete']) { |
|
| 2622 | + echo ' |
|
| 2524 | 2623 | <br><label for="perma_delete"><input type="checkbox" name="perma_delete" id="perma_delete" value="1" class="input_check">', $txt['deleteAccount_permanent'], ':</label>'; |
| 2624 | + } |
|
| 2525 | 2625 | |
| 2526 | 2626 | echo ' |
| 2527 | 2627 | </div>'; |
@@ -2534,9 +2634,10 @@ discard block |
||
| 2534 | 2634 | <div> |
| 2535 | 2635 | <input type="submit" value="', $txt['delete'], '" class="button_submit">'; |
| 2536 | 2636 | |
| 2537 | - if (!empty($context['token_check'])) |
|
| 2538 | - echo ' |
|
| 2637 | + if (!empty($context['token_check'])) { |
|
| 2638 | + echo ' |
|
| 2539 | 2639 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2640 | + } |
|
| 2540 | 2641 | |
| 2541 | 2642 | echo ' |
| 2542 | 2643 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2562,8 +2663,8 @@ discard block |
||
| 2562 | 2663 | <hr>'; |
| 2563 | 2664 | |
| 2564 | 2665 | // Only show the password box if it's actually needed. |
| 2565 | - if ($context['require_password']) |
|
| 2566 | - echo ' |
|
| 2666 | + if ($context['require_password']) { |
|
| 2667 | + echo ' |
|
| 2567 | 2668 | <dl class="settings"> |
| 2568 | 2669 | <dt> |
| 2569 | 2670 | <strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '>', $txt['current_password'], ': </strong><br> |
@@ -2573,13 +2674,15 @@ discard block |
||
| 2573 | 2674 | <input type="password" name="oldpasswrd" size="20" style="margin-right: 4ex;" class="input_password"> |
| 2574 | 2675 | </dd> |
| 2575 | 2676 | </dl>'; |
| 2677 | + } |
|
| 2576 | 2678 | |
| 2577 | 2679 | echo ' |
| 2578 | 2680 | <div class="righttext">'; |
| 2579 | 2681 | |
| 2580 | - if (!empty($context['token_check'])) |
|
| 2581 | - echo ' |
|
| 2682 | + if (!empty($context['token_check'])) { |
|
| 2683 | + echo ' |
|
| 2582 | 2684 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2685 | + } |
|
| 2583 | 2686 | |
| 2584 | 2687 | echo ' |
| 2585 | 2688 | <input type="submit" value="', $txt['change_profile'], '" class="button_submit"> |
@@ -2606,9 +2709,10 @@ discard block |
||
| 2606 | 2709 | <ul id="list_errors">'; |
| 2607 | 2710 | |
| 2608 | 2711 | // Cycle through each error and display an error message. |
| 2609 | - foreach ($context['post_errors'] as $error) |
|
| 2610 | - echo ' |
|
| 2712 | + foreach ($context['post_errors'] as $error) { |
|
| 2713 | + echo ' |
|
| 2611 | 2714 | <li>', isset($txt['profile_error_' . $error]) ? $txt['profile_error_' . $error] : $error, '</li>'; |
| 2715 | + } |
|
| 2612 | 2716 | |
| 2613 | 2717 | echo ' |
| 2614 | 2718 | </ul>'; |
@@ -2634,12 +2738,13 @@ discard block |
||
| 2634 | 2738 | <select name="id_group" ', ($context['user']['is_owner'] && $context['member']['group_id'] == 1 ? 'onchange="if (this.value != 1 && !confirm(\'' . $txt['deadmin_confirm'] . '\')) this.value = 1;"' : ''), '>'; |
| 2635 | 2739 | |
| 2636 | 2740 | // Fill the select box with all primary member groups that can be assigned to a member. |
| 2637 | - foreach ($context['member_groups'] as $member_group) |
|
| 2638 | - if (!empty($member_group['can_be_primary'])) |
|
| 2741 | + foreach ($context['member_groups'] as $member_group) { |
|
| 2742 | + if (!empty($member_group['can_be_primary'])) |
|
| 2639 | 2743 | echo ' |
| 2640 | 2744 | <option value="', $member_group['id'], '"', $member_group['is_primary'] ? ' selected' : '', '> |
| 2641 | 2745 | ', $member_group['name'], ' |
| 2642 | 2746 | </option>'; |
| 2747 | + } |
|
| 2643 | 2748 | echo ' |
| 2644 | 2749 | </select> |
| 2645 | 2750 | </dd> |
@@ -2651,10 +2756,11 @@ discard block |
||
| 2651 | 2756 | <input type="hidden" name="additional_groups[]" value="0">'; |
| 2652 | 2757 | |
| 2653 | 2758 | // For each membergroup show a checkbox so members can be assigned to more than one group. |
| 2654 | - foreach ($context['member_groups'] as $member_group) |
|
| 2655 | - if ($member_group['can_be_additional']) |
|
| 2759 | + foreach ($context['member_groups'] as $member_group) { |
|
| 2760 | + if ($member_group['can_be_additional']) |
|
| 2656 | 2761 | echo ' |
| 2657 | 2762 | <label for="additional_groups-', $member_group['id'], '"><input type="checkbox" name="additional_groups[]" value="', $member_group['id'], '" id="additional_groups-', $member_group['id'], '"', $member_group['is_additional'] ? ' checked' : '', ' class="input_check"> ', $member_group['name'], '</label><br>'; |
| 2763 | + } |
|
| 2658 | 2764 | echo ' |
| 2659 | 2765 | </span> |
| 2660 | 2766 | <a href="javascript:void(0);" onclick="document.getElementById(\'additional_groupsList\').style.display = \'block\'; document.getElementById(\'additional_groupsLink\').style.display = \'none\'; return false;" id="additional_groupsLink" style="display: none;" class="toggle_down">', $txt['additional_membergroups_show'], '</a> |
@@ -2714,9 +2820,10 @@ discard block |
||
| 2714 | 2820 | <span class="smalltext">', $txt['sig_info'], '</span><br> |
| 2715 | 2821 | <br>'; |
| 2716 | 2822 | |
| 2717 | - if ($context['show_spellchecking']) |
|
| 2718 | - echo ' |
|
| 2823 | + if ($context['show_spellchecking']) { |
|
| 2824 | + echo ' |
|
| 2719 | 2825 | <input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'creator\', \'signature\');" class="button_submit">'; |
| 2826 | + } |
|
| 2720 | 2827 | |
| 2721 | 2828 | echo ' |
| 2722 | 2829 | </dt> |
@@ -2724,17 +2831,20 @@ discard block |
||
| 2724 | 2831 | <textarea class="editor" onkeyup="calcCharLeft();" id="signature" name="signature" rows="5" cols="50" style="min-width: 50%; max-width: 99%;">', $context['member']['signature'], '</textarea><br>'; |
| 2725 | 2832 | |
| 2726 | 2833 | // If there is a limit at all! |
| 2727 | - if (!empty($context['signature_limits']['max_length'])) |
|
| 2728 | - echo ' |
|
| 2834 | + if (!empty($context['signature_limits']['max_length'])) { |
|
| 2835 | + echo ' |
|
| 2729 | 2836 | <span class="smalltext">', sprintf($txt['max_sig_characters'], $context['signature_limits']['max_length']), ' <span id="signatureLeft">', $context['signature_limits']['max_length'], '</span></span><br>'; |
| 2837 | + } |
|
| 2730 | 2838 | |
| 2731 | - if (!empty($context['show_preview_button'])) |
|
| 2732 | - echo ' |
|
| 2839 | + if (!empty($context['show_preview_button'])) { |
|
| 2840 | + echo ' |
|
| 2733 | 2841 | <input type="button" name="preview_signature" id="preview_button" value="', $txt['preview_signature'], '" class="button_submit">'; |
| 2842 | + } |
|
| 2734 | 2843 | |
| 2735 | - if ($context['signature_warning']) |
|
| 2736 | - echo ' |
|
| 2844 | + if ($context['signature_warning']) { |
|
| 2845 | + echo ' |
|
| 2737 | 2846 | <span class="smalltext">', $context['signature_warning'], '</span>'; |
| 2847 | + } |
|
| 2738 | 2848 | |
| 2739 | 2849 | // Some javascript used to count how many characters have been used so far in the signature. |
| 2740 | 2850 | echo ' |
@@ -2778,9 +2888,10 @@ discard block |
||
| 2778 | 2888 | <div> |
| 2779 | 2889 | <select name="cat" id="cat" size="10" onchange="changeSel(\'\');" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'server_stored\');">'; |
| 2780 | 2890 | // This lists all the file categories. |
| 2781 | - foreach ($context['avatars'] as $avatar) |
|
| 2782 | - echo ' |
|
| 2891 | + foreach ($context['avatars'] as $avatar) { |
|
| 2892 | + echo ' |
|
| 2783 | 2893 | <option value="', $avatar['filename'] . ($avatar['is_dir'] ? '/' : ''), '"', ($avatar['checked'] ? ' selected' : ''), '>', $avatar['name'], '</option>'; |
| 2894 | + } |
|
| 2784 | 2895 | echo ' |
| 2785 | 2896 | </select> |
| 2786 | 2897 | </div> |
@@ -2835,16 +2946,17 @@ discard block |
||
| 2835 | 2946 | <div id="avatar_gravatar"> |
| 2836 | 2947 | <img src="' . $context['member']['avatar']['href'] . '" alt="" />'; |
| 2837 | 2948 | |
| 2838 | - if (empty($modSettings['gravatarAllowExtraEmail'])) |
|
| 2839 | - echo ' |
|
| 2949 | + if (empty($modSettings['gravatarAllowExtraEmail'])) { |
|
| 2950 | + echo ' |
|
| 2840 | 2951 | <div class="smalltext">', $txt['gravatar_noAlternateEmail'], '</div>'; |
| 2841 | - else |
|
| 2952 | + } else |
|
| 2842 | 2953 | { |
| 2843 | 2954 | // Depending on other stuff, the stored value here might have some odd things in it from other areas. |
| 2844 | - if ($context['member']['avatar']['external'] == $context['member']['email']) |
|
| 2845 | - $textbox_value = ''; |
|
| 2846 | - else |
|
| 2847 | - $textbox_value = $context['member']['avatar']['external']; |
|
| 2955 | + if ($context['member']['avatar']['external'] == $context['member']['email']) { |
|
| 2956 | + $textbox_value = ''; |
|
| 2957 | + } else { |
|
| 2958 | + $textbox_value = $context['member']['avatar']['external']; |
|
| 2959 | + } |
|
| 2848 | 2960 | |
| 2849 | 2961 | echo ' |
| 2850 | 2962 | <div class="smalltext">', $txt['gravatar_alternateEmail'], '</div> |
@@ -2916,8 +3028,9 @@ discard block |
||
| 2916 | 3028 | $h = !empty($modSettings['avatar_max_height_' . $type]) ? comma_format($modSettings['avatar_max_height_' . $type]) : 0; |
| 2917 | 3029 | |
| 2918 | 3030 | $suffix = (!empty($w) ? 'w' : '') . (!empty($h) ? 'h' : ''); |
| 2919 | - if (empty($suffix)) |
|
| 2920 | - return; |
|
| 3031 | + if (empty($suffix)) { |
|
| 3032 | + return; |
|
| 3033 | + } |
|
| 2921 | 3034 | |
| 2922 | 3035 | echo ' |
| 2923 | 3036 | <div class="smalltext">', sprintf($txt['avatar_max_size_' . $suffix], $w, $h), '</div>'; |
@@ -2939,9 +3052,10 @@ discard block |
||
| 2939 | 3052 | <dd> |
| 2940 | 3053 | <select name="easyformat" id="easyformat" onchange="document.forms.creator.time_format.value = this.options[this.selectedIndex].value;" style="margin-bottom: 4px;">'; |
| 2941 | 3054 | // Help the user by showing a list of common time formats. |
| 2942 | - foreach ($context['easy_timeformats'] as $time_format) |
|
| 2943 | - echo ' |
|
| 3055 | + foreach ($context['easy_timeformats'] as $time_format) { |
|
| 3056 | + echo ' |
|
| 2944 | 3057 | <option value="', $time_format['format'], '"', $time_format['format'] == $context['member']['time_format'] ? ' selected' : '', '>', $time_format['title'], '</option>'; |
| 3058 | + } |
|
| 2945 | 3059 | echo ' |
| 2946 | 3060 | </select><br> |
| 2947 | 3061 | <input type="text" name="time_format" id="time_format" value="', $context['member']['time_format'], '" size="30" class="input_text"> |
@@ -2977,9 +3091,10 @@ discard block |
||
| 2977 | 3091 | </dt> |
| 2978 | 3092 | <dd> |
| 2979 | 3093 | <select name="smiley_set" id="smiley_set" onchange="document.getElementById(\'smileypr\').src = this.selectedIndex == 0 ? \'', $settings['images_url'], '/blank.png\' : \'', $modSettings['smileys_url'], '/\' + (this.selectedIndex != 1 ? this.options[this.selectedIndex].value : \'', !empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'], '\') + \'/smiley.gif\';">'; |
| 2980 | - foreach ($context['smiley_sets'] as $set) |
|
| 2981 | - echo ' |
|
| 3094 | + foreach ($context['smiley_sets'] as $set) { |
|
| 3095 | + echo ' |
|
| 2982 | 3096 | <option value="', $set['id'], '"', $set['selected'] ? ' selected' : '', '>', $set['name'], '</option>'; |
| 3097 | + } |
|
| 2983 | 3098 | echo ' |
| 2984 | 3099 | </select> <img id="smileypr" class="centericon" src="', $context['member']['smiley_set']['id'] != 'none' ? $modSettings['smileys_url'] . '/' . ($context['member']['smiley_set']['id'] != '' ? $context['member']['smiley_set']['id'] : (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'])) . '/smiley.gif' : $settings['images_url'] . '/blank.png', '" alt=":)" style="padding-left: 20px;"> |
| 2985 | 3100 | </dd>'; |
@@ -3030,10 +3145,11 @@ discard block |
||
| 3030 | 3145 | </div> |
| 3031 | 3146 | <div class="clear"></div>'; |
| 3032 | 3147 | |
| 3033 | - if (!empty($context['from_ajax'])) |
|
| 3034 | - echo ' |
|
| 3148 | + if (!empty($context['from_ajax'])) { |
|
| 3149 | + echo ' |
|
| 3035 | 3150 | <br> |
| 3036 | 3151 | <a href="javascript:self.close();"></a>'; |
| 3152 | + } |
|
| 3037 | 3153 | |
| 3038 | 3154 | echo ' |
| 3039 | 3155 | </div> |
@@ -3072,15 +3188,16 @@ discard block |
||
| 3072 | 3188 | <br /><div class="smalltext">', $txt['tfa_profile_desc'], '</div> |
| 3073 | 3189 | </dt> |
| 3074 | 3190 | <dd>'; |
| 3075 | - if (!$context['tfa_enabled'] && $context['user']['is_owner']) |
|
| 3076 | - echo ' |
|
| 3191 | + if (!$context['tfa_enabled'] && $context['user']['is_owner']) { |
|
| 3192 | + echo ' |
|
| 3077 | 3193 | <a href="', !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl, '?action=profile;area=tfasetup" id="enable_tfa">', $txt['tfa_profile_enable'], '</a>'; |
| 3078 | - elseif (!$context['tfa_enabled']) |
|
| 3079 | - echo ' |
|
| 3194 | + } elseif (!$context['tfa_enabled']) { |
|
| 3195 | + echo ' |
|
| 3080 | 3196 | ', $txt['tfa_profile_disabled']; |
| 3081 | - else |
|
| 3082 | - echo ' |
|
| 3197 | + } else { |
|
| 3198 | + echo ' |
|
| 3083 | 3199 | ', sprintf($txt['tfa_profile_enabled'], $scripturl . '?action=profile;u=' . $context['id_member'] . ';area=tfasetup;disable'); |
| 3200 | + } |
|
| 3084 | 3201 | echo ' |
| 3085 | 3202 | </dd>'; |
| 3086 | 3203 | } |