@@ -51,11 +51,13 @@ discard block |
||
| 51 | 51 | <p>'; |
| 52 | 52 | |
| 53 | 53 | // Show just numbers...? |
| 54 | - if ($settings['display_who_viewing'] == 1) |
|
| 55 | - echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members']; |
|
| 54 | + if ($settings['display_who_viewing'] == 1) { |
|
| 55 | + echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members']; |
|
| 56 | + } |
|
| 56 | 57 | // Or show the actual people viewing the topic? |
| 57 | - else |
|
| 58 | - echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
| 58 | + else { |
|
| 59 | + echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
| 60 | + } |
|
| 59 | 61 | |
| 60 | 62 | // Now show how many guests are here too. |
| 61 | 63 | echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_topic'], ' |
@@ -93,10 +95,11 @@ discard block |
||
| 93 | 95 | <dt class="', $option['voted_this'] ? ' voted' : '', '">', $option['option'], '</dt> |
| 94 | 96 | <dd class="statsbar', $option['voted_this'] ? ' voted' : '', '">'; |
| 95 | 97 | |
| 96 | - if ($context['allow_results_view']) |
|
| 97 | - echo ' |
|
| 98 | + if ($context['allow_results_view']) { |
|
| 99 | + echo ' |
|
| 98 | 100 | ', $option['bar_ndt'], ' |
| 99 | 101 | <span class="percentage">', $option['votes'], ' (', $option['percent'], '%)</span>'; |
| 102 | + } |
|
| 100 | 103 | |
| 101 | 104 | echo ' |
| 102 | 105 | </dd>'; |
@@ -105,9 +108,10 @@ discard block |
||
| 105 | 108 | echo ' |
| 106 | 109 | </dl>'; |
| 107 | 110 | |
| 108 | - if ($context['allow_results_view']) |
|
| 109 | - echo ' |
|
| 111 | + if ($context['allow_results_view']) { |
|
| 112 | + echo ' |
|
| 110 | 113 | <p><strong>', $txt['poll_total_voters'], ':</strong> ', $context['poll']['total_votes'], '</p>'; |
| 114 | + } |
|
| 111 | 115 | } |
| 112 | 116 | // They are allowed to vote! Go to it! |
| 113 | 117 | else |
@@ -116,17 +120,19 @@ discard block |
||
| 116 | 120 | <form action="', $scripturl, '?action=vote;topic=', $context['current_topic'], '.', $context['start'], ';poll=', $context['poll']['id'], '" method="post" accept-charset="', $context['character_set'], '">'; |
| 117 | 121 | |
| 118 | 122 | // Show a warning if they are allowed more than one option. |
| 119 | - if ($context['poll']['allowed_warning']) |
|
| 120 | - echo ' |
|
| 123 | + if ($context['poll']['allowed_warning']) { |
|
| 124 | + echo ' |
|
| 121 | 125 | <p class="smallpadding">', $context['poll']['allowed_warning'], '</p>'; |
| 126 | + } |
|
| 122 | 127 | |
| 123 | 128 | echo ' |
| 124 | 129 | <ul class="options">'; |
| 125 | 130 | |
| 126 | 131 | // Show each option with its button - a radio likely. |
| 127 | - foreach ($context['poll']['options'] as $option) |
|
| 128 | - echo ' |
|
| 132 | + foreach ($context['poll']['options'] as $option) { |
|
| 133 | + echo ' |
|
| 129 | 134 | <li>', $option['vote_button'], ' <label for="', $option['id'], '">', $option['option'], '</label></li>'; |
| 135 | + } |
|
| 130 | 136 | |
| 131 | 137 | echo ' |
| 132 | 138 | </ul> |
@@ -138,9 +144,10 @@ discard block |
||
| 138 | 144 | } |
| 139 | 145 | |
| 140 | 146 | // Is the clock ticking? |
| 141 | - if (!empty($context['poll']['expire_time'])) |
|
| 142 | - echo ' |
|
| 147 | + if (!empty($context['poll']['expire_time'])) { |
|
| 148 | + echo ' |
|
| 143 | 149 | <p><strong>', ($context['poll']['is_expired'] ? $txt['poll_expired_on'] : $txt['poll_expires_on']), ':</strong> ', $context['poll']['expire_time'], '</p>'; |
| 150 | + } |
|
| 144 | 151 | |
| 145 | 152 | echo ' |
| 146 | 153 | </div> |
@@ -164,11 +171,12 @@ discard block |
||
| 164 | 171 | <div class="information"> |
| 165 | 172 | <ul>'; |
| 166 | 173 | |
| 167 | - foreach ($context['linked_calendar_events'] as $event) |
|
| 168 | - echo ' |
|
| 174 | + foreach ($context['linked_calendar_events'] as $event) { |
|
| 175 | + echo ' |
|
| 169 | 176 | <li> |
| 170 | 177 | ', ($event['can_edit'] ? '<a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify"></span></a> ' : ''), '<strong>', $event['title'], '</strong>: ', $event['start_date'], ($event['start_date'] != $event['end_date'] ? ' - ' . $event['end_date'] : ''), ' |
| 171 | 178 | </li>'; |
| 179 | + } |
|
| 172 | 180 | |
| 173 | 181 | echo ' |
| 174 | 182 | </ul> |
@@ -203,8 +211,9 @@ discard block |
||
| 203 | 211 | $context['removableMessageIDs'] = array(); |
| 204 | 212 | |
| 205 | 213 | // Get all the messages... |
| 206 | - while ($message = $context['get_message']()) |
|
| 207 | - template_single_post($message); |
|
| 214 | + while ($message = $context['get_message']()) { |
|
| 215 | + template_single_post($message); |
|
| 216 | + } |
|
| 208 | 217 | |
| 209 | 218 | echo ' |
| 210 | 219 | </form> |
@@ -241,8 +250,9 @@ discard block |
||
| 241 | 250 | <div id="display_jump_to"> </div>'; |
| 242 | 251 | |
| 243 | 252 | // Show quickreply |
| 244 | - if ($context['can_reply']) |
|
| 245 | - template_quickreply(); |
|
| 253 | + if ($context['can_reply']) { |
|
| 254 | + template_quickreply(); |
|
| 255 | + } |
|
| 246 | 256 | |
| 247 | 257 | // User action pop on mobile screen (or actually small screen), this uses responsive css does not check mobile device. |
| 248 | 258 | echo ' |
@@ -255,8 +265,8 @@ discard block |
||
| 255 | 265 | </div>'; |
| 256 | 266 | |
| 257 | 267 | // Show the moderation button & pop only if user can moderate |
| 258 | - if ($context['can_moderate_forum'] || $context['user']['is_mod']) |
|
| 259 | - echo ' |
|
| 268 | + if ($context['can_moderate_forum'] || $context['user']['is_mod']) { |
|
| 269 | + echo ' |
|
| 260 | 270 | <div id="mobile_moderation" class="popup_container"> |
| 261 | 271 | <div class="popup_window description"> |
| 262 | 272 | <div class="popup_heading">', $txt['mobile_moderation'],' |
@@ -266,6 +276,7 @@ discard block |
||
| 266 | 276 | </div> |
| 267 | 277 | </div> |
| 268 | 278 | </div>'; |
| 279 | + } |
|
| 269 | 280 | |
| 270 | 281 | echo ' |
| 271 | 282 | <script>'; |
@@ -389,9 +400,10 @@ discard block |
||
| 389 | 400 | }); |
| 390 | 401 | }'; |
| 391 | 402 | |
| 392 | - if (!empty($context['ignoredMsgs'])) |
|
| 393 | - echo ' |
|
| 403 | + if (!empty($context['ignoredMsgs'])) { |
|
| 404 | + echo ' |
|
| 394 | 405 | ignore_toggles([', implode(', ', $context['ignoredMsgs']), '], ', JavaScriptEscape($txt['show_ignore_user_post']), ');'; |
| 406 | + } |
|
| 395 | 407 | |
| 396 | 408 | echo ' |
| 397 | 409 | </script>'; |
@@ -408,8 +420,9 @@ discard block |
||
| 408 | 420 | |
| 409 | 421 | $ignoring = false; |
| 410 | 422 | |
| 411 | - if ($message['can_remove']) |
|
| 412 | - $context['removableMessageIDs'][] = $message['id']; |
|
| 423 | + if ($message['can_remove']) { |
|
| 424 | + $context['removableMessageIDs'][] = $message['id']; |
|
| 425 | + } |
|
| 413 | 426 | |
| 414 | 427 | // Are we ignoring this message? |
| 415 | 428 | if (!empty($message['is_ignored'])) |
@@ -435,9 +448,10 @@ discard block |
||
| 435 | 448 | <div class="custom_fields_above_member"> |
| 436 | 449 | <ul class="nolist">'; |
| 437 | 450 | |
| 438 | - foreach ($message['custom_fields']['above_member'] as $custom) |
|
| 439 | - echo ' |
|
| 451 | + foreach ($message['custom_fields']['above_member'] as $custom) { |
|
| 452 | + echo ' |
|
| 440 | 453 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 454 | + } |
|
| 441 | 455 | |
| 442 | 456 | echo ' |
| 443 | 457 | </ul> |
@@ -448,9 +462,10 @@ discard block |
||
| 448 | 462 | <h4>'; |
| 449 | 463 | |
| 450 | 464 | // Show online and offline buttons? |
| 451 | - if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) |
|
| 452 | - echo ' |
|
| 465 | + if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) { |
|
| 466 | + echo ' |
|
| 453 | 467 | ', $context['can_send_pm'] ? '<a href="' . $message['member']['online']['href'] . '" title="' . $message['member']['online']['label'] . '">' : '', '<span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>', $context['can_send_pm'] ? '</a>' : ''; |
| 468 | + } |
|
| 454 | 469 | |
| 455 | 470 | |
| 456 | 471 | // Show a link to the member's profile. |
@@ -463,51 +478,59 @@ discard block |
||
| 463 | 478 | |
| 464 | 479 | |
| 465 | 480 | // Show the user's avatar. |
| 466 | - if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) |
|
| 467 | - echo ' |
|
| 481 | + if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) { |
|
| 482 | + echo ' |
|
| 468 | 483 | <li class="avatar"> |
| 469 | 484 | <a href="', $message['member']['href'], '">', $message['member']['avatar']['image'], '</a> |
| 470 | 485 | </li>'; |
| 486 | + } |
|
| 471 | 487 | |
| 472 | 488 | // Are there any custom fields below the avatar? |
| 473 | - if (!empty($message['custom_fields']['below_avatar'])) |
|
| 474 | - foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
| 489 | + if (!empty($message['custom_fields']['below_avatar'])) { |
|
| 490 | + foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
| 475 | 491 | echo ' |
| 476 | 492 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 493 | + } |
|
| 477 | 494 | |
| 478 | 495 | // Show the post group icons, but not for guests. |
| 479 | - if (!$message['member']['is_guest']) |
|
| 480 | - echo ' |
|
| 496 | + if (!$message['member']['is_guest']) { |
|
| 497 | + echo ' |
|
| 481 | 498 | <li class="icons">', $message['member']['group_icons'], '</li>'; |
| 499 | + } |
|
| 482 | 500 | |
| 483 | 501 | // Show the member's primary group (like 'Administrator') if they have one. |
| 484 | - if (!empty($message['member']['group'])) |
|
| 485 | - echo ' |
|
| 502 | + if (!empty($message['member']['group'])) { |
|
| 503 | + echo ' |
|
| 486 | 504 | <li class="membergroup">', $message['member']['group'], '</li>'; |
| 505 | + } |
|
| 487 | 506 | |
| 488 | 507 | // Show the member's custom title, if they have one. |
| 489 | - if (!empty($message['member']['title'])) |
|
| 490 | - echo ' |
|
| 508 | + if (!empty($message['member']['title'])) { |
|
| 509 | + echo ' |
|
| 491 | 510 | <li class="title">', $message['member']['title'], '</li>'; |
| 511 | + } |
|
| 492 | 512 | |
| 493 | 513 | // Don't show these things for guests. |
| 494 | 514 | if (!$message['member']['is_guest']) |
| 495 | 515 | { |
| 496 | 516 | |
| 497 | 517 | // Show the post group if and only if they have no other group or the option is on, and they are in a post group. |
| 498 | - if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) |
|
| 499 | - echo ' |
|
| 518 | + if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) { |
|
| 519 | + echo ' |
|
| 500 | 520 | <li class="postgroup">', $message['member']['post_group'], '</li>'; |
| 521 | + } |
|
| 501 | 522 | |
| 502 | 523 | // Show how many posts they have made. |
| 503 | - if (!isset($context['disabled_fields']['posts'])) |
|
| 504 | - echo ' |
|
| 524 | + if (!isset($context['disabled_fields']['posts'])) { |
|
| 525 | + echo ' |
|
| 505 | 526 | <li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>'; |
| 527 | + } |
|
| 506 | 528 | |
| 507 | 529 | // Show their personal text? |
| 508 | - if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) |
|
| 509 | - echo ' |
|
| 530 | + if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) { |
|
| 531 | + echo ' |
|
| 510 | 532 | <li class="blurb">', $message['member']['blurb'], '</li>'; |
| 533 | + } |
|
| 511 | 534 | |
| 512 | 535 | // Any custom fields to show as icons? |
| 513 | 536 | if (!empty($message['custom_fields']['icons'])) |
@@ -516,9 +539,10 @@ discard block |
||
| 516 | 539 | <li class="im_icons"> |
| 517 | 540 | <ol>'; |
| 518 | 541 | |
| 519 | - foreach ($message['custom_fields']['icons'] as $custom) |
|
| 520 | - echo ' |
|
| 542 | + foreach ($message['custom_fields']['icons'] as $custom) { |
|
| 543 | + echo ' |
|
| 521 | 544 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 545 | + } |
|
| 522 | 546 | |
| 523 | 547 | echo ' |
| 524 | 548 | </ol> |
@@ -533,19 +557,22 @@ discard block |
||
| 533 | 557 | <ol class="profile_icons">'; |
| 534 | 558 | |
| 535 | 559 | // Don't show an icon if they haven't specified a website. |
| 536 | - if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) |
|
| 537 | - echo ' |
|
| 560 | + if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) { |
|
| 561 | + echo ' |
|
| 538 | 562 | <li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" class="new_win">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
| 563 | + } |
|
| 539 | 564 | |
| 540 | 565 | // Since we know this person isn't a guest, you *can* message them. |
| 541 | - if ($context['can_send_pm']) |
|
| 542 | - echo ' |
|
| 566 | + if ($context['can_send_pm']) { |
|
| 567 | + echo ' |
|
| 543 | 568 | <li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="generic_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>'; |
| 569 | + } |
|
| 544 | 570 | |
| 545 | 571 | // Show the email if necessary |
| 546 | - if (!empty($message['member']['email']) && $message['member']['show_email']) |
|
| 547 | - echo ' |
|
| 572 | + if (!empty($message['member']['email']) && $message['member']['show_email']) { |
|
| 573 | + echo ' |
|
| 548 | 574 | <li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>'; |
| 575 | + } |
|
| 549 | 576 | |
| 550 | 577 | echo ' |
| 551 | 578 | </ol> |
@@ -553,48 +580,56 @@ discard block |
||
| 553 | 580 | } |
| 554 | 581 | |
| 555 | 582 | // Any custom fields for standard placement? |
| 556 | - if (!empty($message['custom_fields']['standard'])) |
|
| 557 | - foreach ($message['custom_fields']['standard'] as $custom) |
|
| 583 | + if (!empty($message['custom_fields']['standard'])) { |
|
| 584 | + foreach ($message['custom_fields']['standard'] as $custom) |
|
| 558 | 585 | echo ' |
| 559 | 586 | <li class="custom ', $custom['col_name'] ,'">', $custom['title'], ': ', $custom['value'], '</li>'; |
| 587 | + } |
|
| 560 | 588 | |
| 561 | 589 | } |
| 562 | 590 | // Otherwise, show the guest's email. |
| 563 | - elseif (!empty($message['member']['email']) && $message['member']['show_email']) |
|
| 564 | - echo ' |
|
| 591 | + elseif (!empty($message['member']['email']) && $message['member']['show_email']) { |
|
| 592 | + echo ' |
|
| 565 | 593 | <li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>'; |
| 594 | + } |
|
| 566 | 595 | |
| 567 | 596 | // Show the IP to this user for this post - because you can moderate? |
| 568 | - if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) |
|
| 569 | - echo ' |
|
| 597 | + if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) { |
|
| 598 | + echo ' |
|
| 570 | 599 | <li class="poster_ip"><a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a></li>'; |
| 600 | + } |
|
| 571 | 601 | |
| 572 | 602 | // Or, should we show it because this is you? |
| 573 | - elseif ($message['can_see_ip']) |
|
| 574 | - echo ' |
|
| 603 | + elseif ($message['can_see_ip']) { |
|
| 604 | + echo ' |
|
| 575 | 605 | <li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a></li>'; |
| 606 | + } |
|
| 576 | 607 | |
| 577 | 608 | // Okay, are you at least logged in? Then we can show something about why IPs are logged... |
| 578 | - elseif (!$context['user']['is_guest']) |
|
| 579 | - echo ' |
|
| 609 | + elseif (!$context['user']['is_guest']) { |
|
| 610 | + echo ' |
|
| 580 | 611 | <li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a></li>'; |
| 612 | + } |
|
| 581 | 613 | |
| 582 | 614 | // Otherwise, you see NOTHING! |
| 583 | - else |
|
| 584 | - echo ' |
|
| 615 | + else { |
|
| 616 | + echo ' |
|
| 585 | 617 | <li class="poster_ip">', $txt['logged'], '</li>'; |
| 618 | + } |
|
| 586 | 619 | |
| 587 | 620 | // Are we showing the warning status? |
| 588 | 621 | // Don't show these things for guests. |
| 589 | - if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) |
|
| 590 | - echo ' |
|
| 622 | + if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) { |
|
| 623 | + echo ' |
|
| 591 | 624 | <li class="warning">', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="generic_icons warning_', $message['member']['warning_status'], '"></span> ', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>'; |
| 625 | + } |
|
| 592 | 626 | |
| 593 | 627 | // Are there any custom fields to show at the bottom of the poster info? |
| 594 | - if (!empty($message['custom_fields']['bottom_poster'])) |
|
| 595 | - foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
| 628 | + if (!empty($message['custom_fields']['bottom_poster'])) { |
|
| 629 | + foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
| 596 | 630 | echo ' |
| 597 | 631 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 632 | + } |
|
| 598 | 633 | |
| 599 | 634 | // Poster info ends. |
| 600 | 635 | echo ' |
@@ -623,9 +658,10 @@ discard block |
||
| 623 | 658 | echo ' |
| 624 | 659 | <span class="smalltext modified" id="modified_', $message['id'], '">'; |
| 625 | 660 | |
| 626 | - if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) |
|
| 627 | - echo |
|
| 661 | + if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) { |
|
| 662 | + echo |
|
| 628 | 663 | $message['modified']['last_edit_text']; |
| 664 | + } |
|
| 629 | 665 | |
| 630 | 666 | echo ' |
| 631 | 667 | </span>'; |
@@ -636,22 +672,24 @@ discard block |
||
| 636 | 672 | </div>'; |
| 637 | 673 | |
| 638 | 674 | // Ignoring this user? Hide the post. |
| 639 | - if ($ignoring) |
|
| 640 | - echo ' |
|
| 675 | + if ($ignoring) { |
|
| 676 | + echo ' |
|
| 641 | 677 | <div id="msg_', $message['id'], '_ignored_prompt"> |
| 642 | 678 | ', $txt['ignoring_user'], ' |
| 643 | 679 | <a href="#" id="msg_', $message['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a> |
| 644 | 680 | </div>'; |
| 681 | + } |
|
| 645 | 682 | |
| 646 | 683 | // Show the post itself, finally! |
| 647 | 684 | echo ' |
| 648 | 685 | <div class="post">'; |
| 649 | 686 | |
| 650 | - if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) |
|
| 651 | - echo ' |
|
| 687 | + if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) { |
|
| 688 | + echo ' |
|
| 652 | 689 | <div class="approve_post"> |
| 653 | 690 | ', $txt['post_awaiting_approval'], ' |
| 654 | 691 | </div>'; |
| 692 | + } |
|
| 655 | 693 | echo ' |
| 656 | 694 | <div class="inner" data-msgid="', $message['id'], '" id="msg_', $message['id'], '"', $ignoring ? ' style="display:none;"' : '', '>', $message['body'], '</div> |
| 657 | 695 | </div>'; |
@@ -668,9 +706,9 @@ discard block |
||
| 668 | 706 | foreach ($message['attachment'] as $attachment) |
| 669 | 707 | { |
| 670 | 708 | // Do we want this attachment to not be showed here? |
| 671 | - if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) |
|
| 672 | - continue; |
|
| 673 | - elseif (!$div_output) |
|
| 709 | + if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) { |
|
| 710 | + continue; |
|
| 711 | + } elseif (!$div_output) |
|
| 674 | 712 | { |
| 675 | 713 | $div_output = true; |
| 676 | 714 | |
@@ -686,9 +724,10 @@ discard block |
||
| 686 | 724 | <fieldset> |
| 687 | 725 | <legend>', $txt['attach_awaiting_approve']; |
| 688 | 726 | |
| 689 | - if ($context['can_approve']) |
|
| 690 | - echo ' |
|
| 727 | + if ($context['can_approve']) { |
|
| 728 | + echo ' |
|
| 691 | 729 | [<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]'; |
| 730 | + } |
|
| 692 | 731 | |
| 693 | 732 | echo ' |
| 694 | 733 | </legend>'; |
@@ -702,12 +741,13 @@ discard block |
||
| 702 | 741 | echo ' |
| 703 | 742 | <div class="attachments_top">'; |
| 704 | 743 | |
| 705 | - if ($attachment['thumbnail']['has_thumb']) |
|
| 706 | - echo ' |
|
| 744 | + if ($attachment['thumbnail']['has_thumb']) { |
|
| 745 | + echo ' |
|
| 707 | 746 | <a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" class="atc_img"></a>'; |
| 708 | - else |
|
| 709 | - echo ' |
|
| 747 | + } else { |
|
| 748 | + echo ' |
|
| 710 | 749 | <img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" class="atc_img">'; |
| 750 | + } |
|
| 711 | 751 | |
| 712 | 752 | echo ' |
| 713 | 753 | </div>'; |
@@ -717,9 +757,10 @@ discard block |
||
| 717 | 757 | <div class="attachments_bot"> |
| 718 | 758 | <a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.png" class="centericon" alt="*"> ' . $attachment['name'] . '</a> '; |
| 719 | 759 | |
| 720 | - if (!$attachment['is_approved'] && $context['can_approve']) |
|
| 721 | - echo ' |
|
| 760 | + if (!$attachment['is_approved'] && $context['can_approve']) { |
|
| 761 | + echo ' |
|
| 722 | 762 | [<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>] | [<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] '; |
| 763 | + } |
|
| 723 | 764 | echo ' |
| 724 | 765 | <br>', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . '<br>' . sprintf($txt['attach_viewed'], $attachment['downloads']) : '<br>' . sprintf($txt['attach_downloaded'], $attachment['downloads'])), ' |
| 725 | 766 | </div>'; |
@@ -728,33 +769,38 @@ discard block |
||
| 728 | 769 | </div>'; |
| 729 | 770 | |
| 730 | 771 | // Next attachment line ? |
| 731 | - if (++$i % $attachments_per_line === 0) |
|
| 732 | - echo ' |
|
| 772 | + if (++$i % $attachments_per_line === 0) { |
|
| 773 | + echo ' |
|
| 733 | 774 | <br>'; |
| 775 | + } |
|
| 734 | 776 | } |
| 735 | 777 | |
| 736 | 778 | // If we had unapproved attachments clean up. |
| 737 | - if ($last_approved_state == 0) |
|
| 738 | - echo ' |
|
| 779 | + if ($last_approved_state == 0) { |
|
| 780 | + echo ' |
|
| 739 | 781 | </fieldset>'; |
| 782 | + } |
|
| 740 | 783 | |
| 741 | 784 | // Only do this if we output a div above - otherwise it'll break things |
| 742 | - if ($div_output) |
|
| 743 | - echo ' |
|
| 785 | + if ($div_output) { |
|
| 786 | + echo ' |
|
| 744 | 787 | </div>'; |
| 788 | + } |
|
| 745 | 789 | } |
| 746 | 790 | |
| 747 | 791 | // And stuff below the attachments. |
| 748 | - if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) |
|
| 749 | - echo ' |
|
| 792 | + if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) { |
|
| 793 | + echo ' |
|
| 750 | 794 | <div class="under_message">'; |
| 795 | + } |
|
| 751 | 796 | |
| 752 | 797 | // Maybe they want to report this post to the moderator(s)? |
| 753 | - if ($context['can_report_moderator']) |
|
| 754 | - echo ' |
|
| 798 | + if ($context['can_report_moderator']) { |
|
| 799 | + echo ' |
|
| 755 | 800 | <ul class="floatright smalltext"> |
| 756 | 801 | <li class="report_link"><a href="', $scripturl, '?action=reporttm;topic=', $context['current_topic'], '.', $message['counter'], ';msg=', $message['id'], '">', $txt['report_to_mod'], '</a></li> |
| 757 | 802 | </ul>'; |
| 803 | + } |
|
| 758 | 804 | |
| 759 | 805 | // What about likes? |
| 760 | 806 | if (!empty($modSettings['enable_likes'])) |
@@ -795,78 +841,91 @@ discard block |
||
| 795 | 841 | <ul class="quickbuttons">'; |
| 796 | 842 | |
| 797 | 843 | // Can they quote? if so they can select and quote as well! |
| 798 | - if ($context['can_quote']) |
|
| 799 | - echo ' |
|
| 844 | + if ($context['can_quote']) { |
|
| 845 | + echo ' |
|
| 800 | 846 | <li><a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';last_msg=', $context['topic_last_message'], '" onclick="return oQuickReply.quote(', $message['id'], ');"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li> |
| 801 | 847 | <li style="display:none;" id="quoteSelected_', $message['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'] ,'</a></li>'; |
| 848 | + } |
|
| 802 | 849 | |
| 803 | 850 | // Can the user modify the contents of this post? Show the modify inline image. |
| 804 | - if ($message['can_modify']) |
|
| 805 | - echo ' |
|
| 851 | + if ($message['can_modify']) { |
|
| 852 | + echo ' |
|
| 806 | 853 | <li class="quick_edit"><a title="', $txt['modify_msg'], '" class="modifybutton" id="modify_button_', $message['id'], '" onclick="oQuickModify.modifyMsg(\'', $message['id'], '\', \'', !empty($modSettings['toggle_subject']), '\')"><span class="generic_icons quick_edit_button"></span>', $txt['quick_edit'], '</a></li>'; |
| 854 | + } |
|
| 807 | 855 | |
| 808 | - if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) |
|
| 809 | - echo ' |
|
| 856 | + if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) { |
|
| 857 | + echo ' |
|
| 810 | 858 | <li class="post_options">', $txt['post_options']; |
| 859 | + } |
|
| 811 | 860 | |
| 812 | 861 | echo ' |
| 813 | 862 | <ul>'; |
| 814 | 863 | |
| 815 | 864 | // Can the user modify the contents of this post? |
| 816 | - if ($message['can_modify']) |
|
| 817 | - echo ' |
|
| 865 | + if ($message['can_modify']) { |
|
| 866 | + echo ' |
|
| 818 | 867 | <li><a href="', $scripturl, '?action=post;msg=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], '"><span class="generic_icons modify_button"></span>', $txt['modify'], '</a></li>'; |
| 868 | + } |
|
| 819 | 869 | |
| 820 | 870 | // How about... even... remove it entirely?! |
| 821 | - if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) |
|
| 822 | - echo ' |
|
| 871 | + if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) { |
|
| 872 | + echo ' |
|
| 823 | 873 | <li><a href="', $scripturl, '?action=removetopic2;topic=', $context['current_topic'], '.', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['are_sure_remove_topic'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove_topic'],'</a></li>'; |
| 824 | - elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) |
|
| 825 | - echo ' |
|
| 874 | + } elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) { |
|
| 875 | + echo ' |
|
| 826 | 876 | <li><a href="', $scripturl, '?action=deletemsg;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message_question'] ,'" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
| 877 | + } |
|
| 827 | 878 | |
| 828 | 879 | // What about splitting it off the rest of the topic? |
| 829 | - if ($context['can_split'] && !empty($context['real_num_replies'])) |
|
| 830 | - echo ' |
|
| 880 | + if ($context['can_split'] && !empty($context['real_num_replies'])) { |
|
| 881 | + echo ' |
|
| 831 | 882 | <li><a href="', $scripturl, '?action=splittopics;topic=', $context['current_topic'], '.0;at=', $message['id'], '"><span class="generic_icons split_button"></span>', $txt['split'], '</a></li>'; |
| 883 | + } |
|
| 832 | 884 | |
| 833 | 885 | // Can we issue a warning because of this post? Remember, we can't give guests warnings. |
| 834 | - if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) |
|
| 835 | - echo ' |
|
| 886 | + if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) { |
|
| 887 | + echo ' |
|
| 836 | 888 | <li><a href="', $scripturl, '?action=profile;area=issuewarning;u=', $message['member']['id'], ';msg=', $message['id'], '"><span class="generic_icons warn_button"></span>', $txt['issue_warning'], '</a></li>'; |
| 889 | + } |
|
| 837 | 890 | |
| 838 | 891 | // Can we restore topics? |
| 839 | - if ($context['can_restore_msg']) |
|
| 840 | - echo ' |
|
| 892 | + if ($context['can_restore_msg']) { |
|
| 893 | + echo ' |
|
| 841 | 894 | <li><a href="', $scripturl, '?action=restoretopic;msgs=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons restore_button"></span>', $txt['restore_message'], '</a></li>'; |
| 895 | + } |
|
| 842 | 896 | |
| 843 | 897 | // Maybe we can approve it, maybe we should? |
| 844 | - if ($message['can_approve']) |
|
| 845 | - echo ' |
|
| 898 | + if ($message['can_approve']) { |
|
| 899 | + echo ' |
|
| 846 | 900 | <li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons approve_button"></span>', $txt['approve'], '</a></li>'; |
| 901 | + } |
|
| 847 | 902 | |
| 848 | 903 | // Maybe we can unapprove it? |
| 849 | - if ($message['can_unapprove']) |
|
| 850 | - echo ' |
|
| 904 | + if ($message['can_unapprove']) { |
|
| 905 | + echo ' |
|
| 851 | 906 | <li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons unapprove_button"></span>', $txt['unapprove'], '</a></li>'; |
| 907 | + } |
|
| 852 | 908 | |
| 853 | 909 | echo ' |
| 854 | 910 | </ul> |
| 855 | 911 | </li>'; |
| 856 | 912 | |
| 857 | 913 | // Show a checkbox for quick moderation? |
| 858 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) |
|
| 859 | - echo ' |
|
| 914 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) { |
|
| 915 | + echo ' |
|
| 860 | 916 | <li style="display: none;" id="in_topic_mod_check_', $message['id'], '"></li>'; |
| 917 | + } |
|
| 861 | 918 | |
| 862 | - if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) |
|
| 863 | - echo ' |
|
| 919 | + if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) { |
|
| 920 | + echo ' |
|
| 864 | 921 | </ul>'; |
| 922 | + } |
|
| 865 | 923 | } |
| 866 | 924 | |
| 867 | - if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) |
|
| 868 | - echo ' |
|
| 925 | + if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) { |
|
| 926 | + echo ' |
|
| 869 | 927 | </div>'; |
| 928 | + } |
|
| 870 | 929 | |
| 871 | 930 | echo ' |
| 872 | 931 | </div> |
@@ -879,9 +938,10 @@ discard block |
||
| 879 | 938 | <div class="custom_fields_above_signature"> |
| 880 | 939 | <ul class="nolist">'; |
| 881 | 940 | |
| 882 | - foreach ($message['custom_fields']['above_signature'] as $custom) |
|
| 883 | - echo ' |
|
| 941 | + foreach ($message['custom_fields']['above_signature'] as $custom) { |
|
| 942 | + echo ' |
|
| 884 | 943 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 944 | + } |
|
| 885 | 945 | |
| 886 | 946 | echo ' |
| 887 | 947 | </ul> |
@@ -889,9 +949,10 @@ discard block |
||
| 889 | 949 | } |
| 890 | 950 | |
| 891 | 951 | // Show the member's signature? |
| 892 | - if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) |
|
| 893 | - echo ' |
|
| 952 | + if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) { |
|
| 953 | + echo ' |
|
| 894 | 954 | <div class="signature" id="msg_', $message['id'], '_signature"', $ignoring ? ' style="display:none;"' : '', '>', $message['member']['signature'], '</div>'; |
| 955 | + } |
|
| 895 | 956 | |
| 896 | 957 | |
| 897 | 958 | // Are there any custom profile fields for below the signature? |
@@ -901,9 +962,10 @@ discard block |
||
| 901 | 962 | <div class="custom_fields_below_signature"> |
| 902 | 963 | <ul class="nolist">'; |
| 903 | 964 | |
| 904 | - foreach ($message['custom_fields']['below_signature'] as $custom) |
|
| 905 | - echo ' |
|
| 965 | + foreach ($message['custom_fields']['below_signature'] as $custom) { |
|
| 966 | + echo ' |
|
| 906 | 967 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
| 968 | + } |
|
| 907 | 969 | |
| 908 | 970 | echo ' |
| 909 | 971 | </ul> |
@@ -951,8 +1013,8 @@ discard block |
||
| 951 | 1013 | <input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '">'; |
| 952 | 1014 | |
| 953 | 1015 | // Guests just need more. |
| 954 | - if ($context['user']['is_guest']) |
|
| 955 | - echo ' |
|
| 1016 | + if ($context['user']['is_guest']) { |
|
| 1017 | + echo ' |
|
| 956 | 1018 | <dl id="post_header"> |
| 957 | 1019 | <dt> |
| 958 | 1020 | ', $txt['name'], ': |
@@ -967,6 +1029,7 @@ discard block |
||
| 967 | 1029 | <input type="email" name="email" size="25" value="', $context['email'], '" tabindex="', $context['tabindex']++, '" class="input_text" required> |
| 968 | 1030 | </dd> |
| 969 | 1031 | </dl>'; |
| 1032 | + } |
|
| 970 | 1033 | |
| 971 | 1034 | echo ' |
| 972 | 1035 | ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'), ' |
@@ -1014,8 +1077,8 @@ discard block |
||
| 1014 | 1077 | <br class="clear">'; |
| 1015 | 1078 | |
| 1016 | 1079 | // draft autosave available and the user has it enabled? |
| 1017 | - if (!empty($context['drafts_autosave'])) |
|
| 1018 | - echo ' |
|
| 1080 | + if (!empty($context['drafts_autosave'])) { |
|
| 1081 | + echo ' |
|
| 1019 | 1082 | <script> |
| 1020 | 1083 | var oDraftAutoSave = new smf_DraftAutoSave({ |
| 1021 | 1084 | sSelf: \'oDraftAutoSave\', |
@@ -1027,10 +1090,12 @@ discard block |
||
| 1027 | 1090 | iFreq: ', (empty($modSettings['masterAutoSaveDraftsDelay']) ? 60000 : $modSettings['masterAutoSaveDraftsDelay'] * 1000), ' |
| 1028 | 1091 | }); |
| 1029 | 1092 | </script>'; |
| 1093 | + } |
|
| 1030 | 1094 | |
| 1031 | - if ($context['show_spellchecking']) |
|
| 1032 | - echo ' |
|
| 1095 | + if ($context['show_spellchecking']) { |
|
| 1096 | + echo ' |
|
| 1033 | 1097 | <form action="', $scripturl, '?action=spellcheck" method="post" accept-charset="', $context['character_set'], '" name="spell_form" id="spell_form" target="spellWindow"><input type="hidden" name="spellstring" value=""></form>'; |
| 1098 | + } |
|
| 1034 | 1099 | |
| 1035 | 1100 | echo ' |
| 1036 | 1101 | <script> |
@@ -72,9 +72,10 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | // Allow css/js files to be disable for this specific theme. |
| 74 | 74 | // Add the identifier as an array key. IE array('smf_script'); Some external files might not add identifiers, on those cases SMF uses its filename as reference. |
| 75 | - if (!isset($settings['disable_files'])) |
|
| 76 | - $settings['disable_files'] = array(); |
|
| 77 | -} |
|
| 75 | + if (!isset($settings['disable_files'])) { |
|
| 76 | + $settings['disable_files'] = array(); |
|
| 77 | + } |
|
| 78 | + } |
|
| 78 | 79 | |
| 79 | 80 | /** |
| 80 | 81 | * The main sub template above the content. |
@@ -111,8 +112,9 @@ discard block |
||
| 111 | 112 | echo ' |
| 112 | 113 | <meta'; |
| 113 | 114 | |
| 114 | - foreach ($meta_tag as $meta_key => $meta_value) |
|
| 115 | - echo ' ', $meta_key, '="', $meta_value, '"'; |
|
| 115 | + foreach ($meta_tag as $meta_key => $meta_value) { |
|
| 116 | + echo ' ', $meta_key, '="', $meta_value, '"'; |
|
| 117 | + } |
|
| 116 | 118 | |
| 117 | 119 | echo '>'; |
| 118 | 120 | } |
@@ -123,14 +125,16 @@ discard block |
||
| 123 | 125 | <meta name="theme-color" content="#557EA0">'; |
| 124 | 126 | |
| 125 | 127 | // Please don't index these Mr Robot. |
| 126 | - if (!empty($context['robot_no_index'])) |
|
| 127 | - echo ' |
|
| 128 | + if (!empty($context['robot_no_index'])) { |
|
| 129 | + echo ' |
|
| 128 | 130 | <meta name="robots" content="noindex">'; |
| 131 | + } |
|
| 129 | 132 | |
| 130 | 133 | // Present a canonical url for search engines to prevent duplicate content in their indices. |
| 131 | - if (!empty($context['canonical_url'])) |
|
| 132 | - echo ' |
|
| 134 | + if (!empty($context['canonical_url'])) { |
|
| 135 | + echo ' |
|
| 133 | 136 | <link rel="canonical" href="', $context['canonical_url'], '">'; |
| 137 | + } |
|
| 134 | 138 | |
| 135 | 139 | // Show all the relative links, such as help, search, contents, and the like. |
| 136 | 140 | echo ' |
@@ -139,10 +143,11 @@ discard block |
||
| 139 | 143 | <link rel="search" href="' . $scripturl . '?action=search">' : ''); |
| 140 | 144 | |
| 141 | 145 | // If RSS feeds are enabled, advertise the presence of one. |
| 142 | - if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged'])) |
|
| 143 | - echo ' |
|
| 146 | + if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged'])) { |
|
| 147 | + echo ' |
|
| 144 | 148 | <link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['rss'], '" href="', $scripturl, '?type=rss2;action=.xml"> |
| 145 | 149 | <link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['atom'], '" href="', $scripturl, '?type=atom;action=.xml">'; |
| 150 | + } |
|
| 146 | 151 | |
| 147 | 152 | // If we're viewing a topic, these should be the previous and next topics, respectively. |
| 148 | 153 | if (!empty($context['links']['next'])) |
@@ -158,9 +163,10 @@ discard block |
||
| 158 | 163 | } |
| 159 | 164 | |
| 160 | 165 | // If we're in a board, or a topic for that matter, the index will be the board's index. |
| 161 | - if (!empty($context['current_board'])) |
|
| 162 | - echo ' |
|
| 166 | + if (!empty($context['current_board'])) { |
|
| 167 | + echo ' |
|
| 163 | 168 | <link rel="index" href="', $scripturl, '?board=', $context['current_board'], '.0">'; |
| 169 | + } |
|
| 164 | 170 | |
| 165 | 171 | // Output any remaining HTML headers. (from mods, maybe?) |
| 166 | 172 | echo $context['html_headers']; |
@@ -191,8 +197,9 @@ discard block |
||
| 191 | 197 | <ul class="floatleft" id="top_info"> |
| 192 | 198 | <li> |
| 193 | 199 | <a href="', $scripturl, '?action=profile"', !empty($context['self_profile']) ? ' class="active"' : '', ' id="profile_menu_top" onclick="return false;">'; |
| 194 | - if (!empty($context['user']['avatar'])) |
|
| 195 | - echo $context['user']['avatar']['image']; |
|
| 200 | + if (!empty($context['user']['avatar'])) { |
|
| 201 | + echo $context['user']['avatar']['image']; |
|
| 202 | + } |
|
| 196 | 203 | echo $context['user']['name'], '</a> |
| 197 | 204 | <div id="profile_menu" class="top_menu"></div> |
| 198 | 205 | </li>'; |
@@ -219,11 +226,12 @@ discard block |
||
| 219 | 226 | </ul>'; |
| 220 | 227 | } |
| 221 | 228 | // Otherwise they're a guest. Ask them to either register or login. |
| 222 | - else |
|
| 223 | - echo ' |
|
| 229 | + else { |
|
| 230 | + echo ' |
|
| 224 | 231 | <ul class="floatleft welcome"> |
| 225 | 232 | <li>', sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'), '</li> |
| 226 | 233 | </ul>'; |
| 234 | + } |
|
| 227 | 235 | |
| 228 | 236 | if (!empty($modSettings['userLanguage']) && !empty($context['languages']) && count($context['languages']) > 1) |
| 229 | 237 | { |
@@ -231,9 +239,10 @@ discard block |
||
| 231 | 239 | <form id="languages_form" method="get" class="floatright"> |
| 232 | 240 | <select id="language_select" name="language" onchange="this.form.submit()">'; |
| 233 | 241 | |
| 234 | - foreach ($context['languages'] as $language) |
|
| 235 | - echo ' |
|
| 242 | + foreach ($context['languages'] as $language) { |
|
| 243 | + echo ' |
|
| 236 | 244 | <option value="', $language['filename'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' selected="selected"' : '', '>', str_replace('-utf8', '', $language['name']), '</option>'; |
| 245 | + } |
|
| 237 | 246 | |
| 238 | 247 | echo ' |
| 239 | 248 | </select> |
@@ -257,31 +266,36 @@ discard block |
||
| 257 | 266 | <option value="all"', ($selected == 'all' ? ' selected' : ''), '>', $txt['search_entireforum'], ' </option>'; |
| 258 | 267 | |
| 259 | 268 | // Can't limit it to a specific topic if we are not in one |
| 260 | - if (!empty($context['current_topic'])) |
|
| 261 | - echo ' |
|
| 269 | + if (!empty($context['current_topic'])) { |
|
| 270 | + echo ' |
|
| 262 | 271 | <option value="topic"', ($selected == 'current_topic' ? ' selected' : ''), '>', $txt['search_thistopic'], '</option>'; |
| 272 | + } |
|
| 263 | 273 | |
| 264 | 274 | // Can't limit it to a specific board if we are not in one |
| 265 | - if (!empty($context['current_board'])) |
|
| 266 | - echo ' |
|
| 275 | + if (!empty($context['current_board'])) { |
|
| 276 | + echo ' |
|
| 267 | 277 | <option value="board"', ($selected == 'current_board' ? ' selected' : ''), '>', $txt['search_thisbrd'], '</option>'; |
| 278 | + } |
|
| 268 | 279 | |
| 269 | 280 | // Can't search for members if we can't see the memberlist |
| 270 | - if (!empty($context['allow_memberlist'])) |
|
| 271 | - echo ' |
|
| 281 | + if (!empty($context['allow_memberlist'])) { |
|
| 282 | + echo ' |
|
| 272 | 283 | <option value="members"', ($selected == 'members' ? ' selected' : ''), '>', $txt['search_members'], ' </option>'; |
| 284 | + } |
|
| 273 | 285 | |
| 274 | 286 | echo ' |
| 275 | 287 | </select>'; |
| 276 | 288 | |
| 277 | 289 | // Search within current topic? |
| 278 | - if (!empty($context['current_topic'])) |
|
| 279 | - echo ' |
|
| 290 | + if (!empty($context['current_topic'])) { |
|
| 291 | + echo ' |
|
| 280 | 292 | <input type="hidden" name="sd_topic" value="', $context['current_topic'], '">'; |
| 293 | + } |
|
| 281 | 294 | // If we're on a certain board, limit it to this board ;). |
| 282 | - elseif (!empty($context['current_board'])) |
|
| 283 | - echo ' |
|
| 295 | + elseif (!empty($context['current_board'])) { |
|
| 296 | + echo ' |
|
| 284 | 297 | <input type="hidden" name="sd_brd" value="', $context['current_board'], '">'; |
| 298 | + } |
|
| 285 | 299 | |
| 286 | 300 | echo ' |
| 287 | 301 | <input type="submit" name="search2" value="', $txt['search'], '" class="button_submit"> |
@@ -311,12 +325,13 @@ discard block |
||
| 311 | 325 | ', $context['current_time'], ' |
| 312 | 326 | </div>'; |
| 313 | 327 | // Show a random news item? (or you could pick one from news_lines...) |
| 314 | - if (!empty($settings['enable_news']) && !empty($context['random_news_line'])) |
|
| 315 | - echo ' |
|
| 328 | + if (!empty($settings['enable_news']) && !empty($context['random_news_line'])) { |
|
| 329 | + echo ' |
|
| 316 | 330 | <div class="news"> |
| 317 | 331 | <h2>', $txt['news'], ': </h2> |
| 318 | 332 | <p>', $context['random_news_line'], '</p> |
| 319 | 333 | </div>'; |
| 334 | + } |
|
| 320 | 335 | |
| 321 | 336 | echo ' |
| 322 | 337 | <hr class="clear"> |
@@ -379,9 +394,10 @@ discard block |
||
| 379 | 394 | </ul>'; |
| 380 | 395 | |
| 381 | 396 | // Show the load time? |
| 382 | - if ($context['show_load_time']) |
|
| 383 | - echo ' |
|
| 397 | + if ($context['show_load_time']) { |
|
| 398 | + echo ' |
|
| 384 | 399 | <p>', sprintf($txt['page_created_full'], $context['load_time'], $context['load_queries']), '</p>'; |
| 400 | + } |
|
| 385 | 401 | |
| 386 | 402 | echo ' |
| 387 | 403 | </div>'; |
@@ -411,19 +427,21 @@ discard block |
||
| 411 | 427 | global $context, $shown_linktree, $scripturl, $txt; |
| 412 | 428 | |
| 413 | 429 | // If linktree is empty, just return - also allow an override. |
| 414 | - if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show)) |
|
| 415 | - return; |
|
| 430 | + if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show)) { |
|
| 431 | + return; |
|
| 432 | + } |
|
| 416 | 433 | |
| 417 | 434 | echo ' |
| 418 | 435 | <div class="navigate_section"> |
| 419 | 436 | <ul>'; |
| 420 | 437 | |
| 421 | - if ($context['user']['is_logged']) |
|
| 422 | - echo ' |
|
| 438 | + if ($context['user']['is_logged']) { |
|
| 439 | + echo ' |
|
| 423 | 440 | <li class="unread_links"> |
| 424 | 441 | <a href="', $scripturl, '?action=unread" title="', $txt['unread_since_visit'], '">', $txt['view_unread_category'], '</a> |
| 425 | 442 | <a href="', $scripturl, '?action=unreadreplies" title="', $txt['show_unread_replies'], '">', $txt['unread_replies'], '</a> |
| 426 | 443 | </li>'; |
| 444 | + } |
|
| 427 | 445 | |
| 428 | 446 | // Each tree item has a URL and name. Some may have extra_before and extra_after. |
| 429 | 447 | foreach ($context['linktree'] as $link_num => $tree) |
@@ -434,25 +452,29 @@ discard block |
||
| 434 | 452 | // Don't show a separator for the first one. |
| 435 | 453 | // Better here. Always points to the next level when the linktree breaks to a second line. |
| 436 | 454 | // Picked a better looking HTML entity, and added support for RTL plus a span for styling. |
| 437 | - if ($link_num != 0) |
|
| 438 | - echo ' |
|
| 455 | + if ($link_num != 0) { |
|
| 456 | + echo ' |
|
| 439 | 457 | <span class="dividers">', $context['right_to_left'] ? ' ◄ ' : ' ► ', '</span>'; |
| 458 | + } |
|
| 440 | 459 | |
| 441 | 460 | // Show something before the link? |
| 442 | - if (isset($tree['extra_before'])) |
|
| 443 | - echo $tree['extra_before'], ' '; |
|
| 461 | + if (isset($tree['extra_before'])) { |
|
| 462 | + echo $tree['extra_before'], ' '; |
|
| 463 | + } |
|
| 444 | 464 | |
| 445 | 465 | // Show the link, including a URL if it should have one. |
| 446 | - if (isset($tree['url'])) |
|
| 447 | - echo ' |
|
| 466 | + if (isset($tree['url'])) { |
|
| 467 | + echo ' |
|
| 448 | 468 | <a href="' . $tree['url'] . '"><span>' . $tree['name'] . '</span></a>'; |
| 449 | - else |
|
| 450 | - echo ' |
|
| 469 | + } else { |
|
| 470 | + echo ' |
|
| 451 | 471 | <span>' . $tree['name'] . '</span>'; |
| 472 | + } |
|
| 452 | 473 | |
| 453 | 474 | // Show something after the link...? |
| 454 | - if (isset($tree['extra_after'])) |
|
| 455 | - echo ' ', $tree['extra_after']; |
|
| 475 | + if (isset($tree['extra_after'])) { |
|
| 476 | + echo ' ', $tree['extra_after']; |
|
| 477 | + } |
|
| 456 | 478 | |
| 457 | 479 | echo ' |
| 458 | 480 | </li>'; |
@@ -502,13 +524,14 @@ discard block |
||
| 502 | 524 | echo ' |
| 503 | 525 | <ul>'; |
| 504 | 526 | |
| 505 | - foreach ($childbutton['sub_buttons'] as $grandchildbutton) |
|
| 506 | - echo ' |
|
| 527 | + foreach ($childbutton['sub_buttons'] as $grandchildbutton) { |
|
| 528 | + echo ' |
|
| 507 | 529 | <li> |
| 508 | 530 | <a href="', $grandchildbutton['href'], '"' , isset($grandchildbutton['target']) ? ' target="' . $grandchildbutton['target'] . '"' : '', '> |
| 509 | 531 | ', $grandchildbutton['title'], ' |
| 510 | 532 | </a> |
| 511 | 533 | </li>'; |
| 534 | + } |
|
| 512 | 535 | |
| 513 | 536 | echo ' |
| 514 | 537 | </ul>'; |
@@ -539,8 +562,9 @@ discard block |
||
| 539 | 562 | { |
| 540 | 563 | global $context, $txt; |
| 541 | 564 | |
| 542 | - if (!is_array($strip_options)) |
|
| 543 | - $strip_options = array(); |
|
| 565 | + if (!is_array($strip_options)) { |
|
| 566 | + $strip_options = array(); |
|
| 567 | + } |
|
| 544 | 568 | |
| 545 | 569 | // Create the buttons... |
| 546 | 570 | $buttons = array(); |
@@ -549,8 +573,9 @@ discard block |
||
| 549 | 573 | // As of 2.1, the 'test' for each button happens while the array is being generated. The extra 'test' check here is deprecated but kept for backward compatibility (update your mods, folks!) |
| 550 | 574 | if (!isset($value['test']) || !empty($context[$value['test']])) |
| 551 | 575 | { |
| 552 | - if (!isset($value['id'])) |
|
| 553 | - $value['id'] = $key; |
|
| 576 | + if (!isset($value['id'])) { |
|
| 577 | + $value['id'] = $key; |
|
| 578 | + } |
|
| 554 | 579 | |
| 555 | 580 | $button = ' |
| 556 | 581 | <a class="button button_strip_' . $key . (!empty($value['active']) ? ' active' : '') . (isset($value['class']) ? ' '. $value['class'] : '') . '" ' . (!empty($value['url']) ? 'href="'. $value['url'] .'"' : '') . ' ' . (isset($value['custom']) ? ' ' . $value['custom'] : '') . '>' . $txt[$value['text']] . '</a>'; |
@@ -563,13 +588,15 @@ discard block |
||
| 563 | 588 | <div class="overview">'; |
| 564 | 589 | foreach ($value['sub_buttons'] as $element) |
| 565 | 590 | { |
| 566 | - if (isset($element['test']) && empty($context[$element['test']])) |
|
| 567 | - continue; |
|
| 591 | + if (isset($element['test']) && empty($context[$element['test']])) { |
|
| 592 | + continue; |
|
| 593 | + } |
|
| 568 | 594 | |
| 569 | 595 | $button .= ' |
| 570 | 596 | <a href="' . $element['url'] . '"><strong>' . $txt[$element['text']] . '</strong>'; |
| 571 | - if (isset($txt[$element['text'] . '_desc'])) |
|
| 572 | - $button .= '<br /><span>' . $txt[$element['text'] . '_desc'] . '</span>'; |
|
| 597 | + if (isset($txt[$element['text'] . '_desc'])) { |
|
| 598 | + $button .= '<br /><span>' . $txt[$element['text'] . '_desc'] . '</span>'; |
|
| 599 | + } |
|
| 573 | 600 | $button .= '</a>'; |
| 574 | 601 | } |
| 575 | 602 | $button .= ' |
@@ -583,8 +610,9 @@ discard block |
||
| 583 | 610 | } |
| 584 | 611 | |
| 585 | 612 | // No buttons? No button strip either. |
| 586 | - if (empty($buttons)) |
|
| 587 | - return; |
|
| 613 | + if (empty($buttons)) { |
|
| 614 | + return; |
|
| 615 | + } |
|
| 588 | 616 | |
| 589 | 617 | echo ' |
| 590 | 618 | <div class="buttonlist', !empty($direction) ? ' float' . $direction : '', '"', (empty($buttons) ? ' style="display: none;"' : ''), (!empty($strip_options['id']) ? ' id="' . $strip_options['id'] . '"': ''), '> |
@@ -145,11 +145,12 @@ discard block |
||
| 145 | 145 | <div class="question">', $txt['poll_question'], ': <strong>', $context['poll']['question'], '</strong>'; |
| 146 | 146 | |
| 147 | 147 | $options = 1; |
| 148 | - foreach ($context['poll']['options'] as $option) |
|
| 149 | - echo ' |
|
| 148 | + foreach ($context['poll']['options'] as $option) { |
|
| 149 | + echo ' |
|
| 150 | 150 | <div class="', $option['voted_this'] ? 'voted' : '', '">', $txt['option'], ' ', $options++, ': <strong>', $option['option'], '</strong> |
| 151 | 151 | ', $context['allow_poll_view'] ? $txt['votes'] . ': ' . $option['votes'] . '' : '', ' |
| 152 | 152 | </div>'; |
| 153 | + } |
|
| 153 | 154 | |
| 154 | 155 | echo ' |
| 155 | 156 | </div>'; |
@@ -171,9 +172,10 @@ discard block |
||
| 171 | 172 | echo ' |
| 172 | 173 | <hr>'; |
| 173 | 174 | |
| 174 | - foreach ($context['printattach'][$post['id_msg']] as $attach) |
|
| 175 | - echo ' |
|
| 175 | + foreach ($context['printattach'][$post['id_msg']] as $attach) { |
|
| 176 | + echo ' |
|
| 176 | 177 | <img width="' . $attach['width'] . '" height="' . $attach['height'] . '" src="', $scripturl . '?action=dlattach;topic=' . $topic . '.0;attach=' . $attach['id_attach'] . '" alt="">'; |
| 178 | + } |
|
| 177 | 179 | } |
| 178 | 180 | |
| 179 | 181 | echo ' |
@@ -213,11 +215,12 @@ discard block |
||
| 213 | 215 | <div class="print_options">'; |
| 214 | 216 | |
| 215 | 217 | // which option is set, text or text&images |
| 216 | - if (isset($_REQUEST['images'])) |
|
| 217 | - echo ' |
|
| 218 | + if (isset($_REQUEST['images'])) { |
|
| 219 | + echo ' |
|
| 218 | 220 | <a href="', $url_text, '">', $txt['print_page_text'], '</a> | <strong><a href="', $url_images, '">', $txt['print_page_images'], '</a></strong>'; |
| 219 | - else |
|
| 220 | - echo ' |
|
| 221 | + } else { |
|
| 222 | + echo ' |
|
| 221 | 223 | <strong><a href="', $url_text, '">', $txt['print_page_text'], '</a></strong> | <a href="', $url_images, '">', $txt['print_page_images'], '</a>'; |
| 222 | -} |
|
| 224 | + } |
|
| 225 | + } |
|
| 223 | 226 | ?> |
| 224 | 227 | \ No newline at end of file |
@@ -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 | * Maps the implementations in this file (smf_db_function_name) |
@@ -33,8 +34,8 @@ discard block |
||
| 33 | 34 | global $smcFunc, $mysql_set_mode; |
| 34 | 35 | |
| 35 | 36 | // Map some database specific functions, only do this once. |
| 36 | - if (!isset($smcFunc['db_fetch_assoc']) || $smcFunc['db_fetch_assoc'] != 'mysql_fetch_assoc') |
|
| 37 | - $smcFunc += array( |
|
| 37 | + if (!isset($smcFunc['db_fetch_assoc']) || $smcFunc['db_fetch_assoc'] != 'mysql_fetch_assoc') { |
|
| 38 | + $smcFunc += array( |
|
| 38 | 39 | 'db_query' => 'smf_db_query', |
| 39 | 40 | 'db_quote' => 'smf_db_quote', |
| 40 | 41 | 'db_fetch_assoc' => 'mysql_fetch_assoc', |
@@ -58,36 +59,42 @@ discard block |
||
| 58 | 59 | 'db_escape_wildcard_string' => 'smf_db_escape_wildcard_string', |
| 59 | 60 | 'db_is_resource' => 'is_resource', |
| 60 | 61 | ); |
| 62 | + } |
|
| 61 | 63 | |
| 62 | - if (!empty($db_options['port'])) |
|
| 63 | - $db_server .= ':' . $db_options['port']; |
|
| 64 | + if (!empty($db_options['port'])) { |
|
| 65 | + $db_server .= ':' . $db_options['port']; |
|
| 66 | + } |
|
| 64 | 67 | |
| 65 | 68 | $flags = 2; //#define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */ |
| 66 | 69 | |
| 67 | - if (!empty($db_options['persist'])) |
|
| 68 | - $connection = @mysql_pconnect($db_server, $db_user, $db_passwd, $flags); |
|
| 69 | - else |
|
| 70 | - $connection = @mysql_connect($db_server, $db_user, $db_passwd, false, $flags); |
|
| 70 | + if (!empty($db_options['persist'])) { |
|
| 71 | + $connection = @mysql_pconnect($db_server, $db_user, $db_passwd, $flags); |
|
| 72 | + } else { |
|
| 73 | + $connection = @mysql_connect($db_server, $db_user, $db_passwd, false, $flags); |
|
| 74 | + } |
|
| 71 | 75 | |
| 72 | 76 | // Something's wrong, show an error if its fatal (which we assume it is) |
| 73 | 77 | if (!$connection) |
| 74 | 78 | { |
| 75 | - if (!empty($db_options['non_fatal'])) |
|
| 76 | - return null; |
|
| 77 | - else |
|
| 78 | - display_db_error(); |
|
| 79 | + if (!empty($db_options['non_fatal'])) { |
|
| 80 | + return null; |
|
| 81 | + } else { |
|
| 82 | + display_db_error(); |
|
| 83 | + } |
|
| 79 | 84 | } |
| 80 | 85 | |
| 81 | 86 | // Select the database, unless told not to |
| 82 | - if (empty($db_options['dont_select_db']) && !@mysql_select_db($db_name, $connection) && empty($db_options['non_fatal'])) |
|
| 83 | - display_db_error(); |
|
| 87 | + if (empty($db_options['dont_select_db']) && !@mysql_select_db($db_name, $connection) && empty($db_options['non_fatal'])) { |
|
| 88 | + display_db_error(); |
|
| 89 | + } |
|
| 84 | 90 | |
| 85 | 91 | // This makes it possible to have SMF automatically change the sql_mode and autocommit if needed. |
| 86 | - if (isset($mysql_set_mode) && $mysql_set_mode === true) |
|
| 87 | - $smcFunc['db_query']('', 'SET sql_mode = \'\', AUTOCOMMIT = 1', |
|
| 92 | + if (isset($mysql_set_mode) && $mysql_set_mode === true) { |
|
| 93 | + $smcFunc['db_query']('', 'SET sql_mode = \'\', AUTOCOMMIT = 1', |
|
| 88 | 94 | array(), |
| 89 | 95 | false |
| 90 | 96 | ); |
| 97 | + } |
|
| 91 | 98 | |
| 92 | 99 | return $connection; |
| 93 | 100 | } |
@@ -134,37 +141,46 @@ discard block |
||
| 134 | 141 | list ($values, $connection) = $db_callback; |
| 135 | 142 | |
| 136 | 143 | // Connection gone??? This should *never* happen at this point, yet it does :'( |
| 137 | - if (!is_resource($connection)) |
|
| 138 | - display_db_error(); |
|
| 144 | + if (!is_resource($connection)) { |
|
| 145 | + display_db_error(); |
|
| 146 | + } |
|
| 139 | 147 | |
| 140 | - if ($matches[1] === 'db_prefix') |
|
| 141 | - return $db_prefix; |
|
| 148 | + if ($matches[1] === 'db_prefix') { |
|
| 149 | + return $db_prefix; |
|
| 150 | + } |
|
| 142 | 151 | |
| 143 | - if ($matches[1] === 'query_see_board') |
|
| 144 | - return $user_info['query_see_board']; |
|
| 152 | + if ($matches[1] === 'query_see_board') { |
|
| 153 | + return $user_info['query_see_board']; |
|
| 154 | + } |
|
| 145 | 155 | |
| 146 | - if ($matches[1] === 'query_wanna_see_board') |
|
| 147 | - return $user_info['query_wanna_see_board']; |
|
| 156 | + if ($matches[1] === 'query_wanna_see_board') { |
|
| 157 | + return $user_info['query_wanna_see_board']; |
|
| 158 | + } |
|
| 148 | 159 | |
| 149 | - if ($matches[1] === 'empty') |
|
| 150 | - return '\'\''; |
|
| 160 | + if ($matches[1] === 'empty') { |
|
| 161 | + return '\'\''; |
|
| 162 | + } |
|
| 151 | 163 | |
| 152 | - if (!isset($matches[2])) |
|
| 153 | - smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 164 | + if (!isset($matches[2])) { |
|
| 165 | + smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 166 | + } |
|
| 154 | 167 | |
| 155 | - if ($matches[1] === 'literal') |
|
| 156 | - return '\'' . mysql_real_escape_string($matches[2], $connection) . '\''; |
|
| 168 | + if ($matches[1] === 'literal') { |
|
| 169 | + return '\'' . mysql_real_escape_string($matches[2], $connection) . '\''; |
|
| 170 | + } |
|
| 157 | 171 | |
| 158 | - if (!isset($values[$matches[2]])) |
|
| 159 | - smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 172 | + if (!isset($values[$matches[2]])) { |
|
| 173 | + smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 174 | + } |
|
| 160 | 175 | |
| 161 | 176 | $replacement = $values[$matches[2]]; |
| 162 | 177 | |
| 163 | 178 | switch ($matches[1]) |
| 164 | 179 | { |
| 165 | 180 | case 'int': |
| 166 | - if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) |
|
| 167 | - smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 181 | + if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) { |
|
| 182 | + smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 183 | + } |
|
| 168 | 184 | return (string) (int) $replacement; |
| 169 | 185 | break; |
| 170 | 186 | |
@@ -176,49 +192,55 @@ discard block |
||
| 176 | 192 | case 'array_int': |
| 177 | 193 | if (is_array($replacement)) |
| 178 | 194 | { |
| 179 | - if (empty($replacement)) |
|
| 180 | - smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 195 | + if (empty($replacement)) { |
|
| 196 | + smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 197 | + } |
|
| 181 | 198 | |
| 182 | 199 | foreach ($replacement as $key => $value) |
| 183 | 200 | { |
| 184 | - if (!is_numeric($value) || (string) $value !== (string) (int) $value) |
|
| 185 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 201 | + if (!is_numeric($value) || (string) $value !== (string) (int) $value) { |
|
| 202 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 203 | + } |
|
| 186 | 204 | |
| 187 | 205 | $replacement[$key] = (string) (int) $value; |
| 188 | 206 | } |
| 189 | 207 | |
| 190 | 208 | return implode(', ', $replacement); |
| 209 | + } else { |
|
| 210 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 191 | 211 | } |
| 192 | - else |
|
| 193 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 194 | 212 | |
| 195 | 213 | break; |
| 196 | 214 | |
| 197 | 215 | case 'array_string': |
| 198 | 216 | if (is_array($replacement)) |
| 199 | 217 | { |
| 200 | - if (empty($replacement)) |
|
| 201 | - smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 218 | + if (empty($replacement)) { |
|
| 219 | + smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 220 | + } |
|
| 202 | 221 | |
| 203 | - foreach ($replacement as $key => $value) |
|
| 204 | - $replacement[$key] = sprintf('\'%1$s\'', mysql_real_escape_string($value, $connection)); |
|
| 222 | + foreach ($replacement as $key => $value) { |
|
| 223 | + $replacement[$key] = sprintf('\'%1$s\'', mysql_real_escape_string($value, $connection)); |
|
| 224 | + } |
|
| 205 | 225 | |
| 206 | 226 | return implode(', ', $replacement); |
| 227 | + } else { |
|
| 228 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 207 | 229 | } |
| 208 | - else |
|
| 209 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 210 | 230 | break; |
| 211 | 231 | |
| 212 | 232 | case 'date': |
| 213 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) |
|
| 214 | - return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]); |
|
| 215 | - else |
|
| 216 | - smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 233 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) { |
|
| 234 | + return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]); |
|
| 235 | + } else { |
|
| 236 | + smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 237 | + } |
|
| 217 | 238 | break; |
| 218 | 239 | |
| 219 | 240 | case 'float': |
| 220 | - if (!is_numeric($replacement)) |
|
| 221 | - smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 241 | + if (!is_numeric($replacement)) { |
|
| 242 | + smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 243 | + } |
|
| 222 | 244 | return (string) (float) $replacement; |
| 223 | 245 | break; |
| 224 | 246 | |
@@ -232,10 +254,12 @@ discard block |
||
| 232 | 254 | break; |
| 233 | 255 | |
| 234 | 256 | case 'inet': |
| 235 | - if ($replacement == 'null' || $replacement == '') |
|
| 236 | - return 'null'; |
|
| 237 | - if (!isValidIP($replacement)) |
|
| 238 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 257 | + if ($replacement == 'null' || $replacement == '') { |
|
| 258 | + return 'null'; |
|
| 259 | + } |
|
| 260 | + if (!isValidIP($replacement)) { |
|
| 261 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 262 | + } |
|
| 239 | 263 | //we don't use the native support of mysql > 5.6.2 |
| 240 | 264 | return sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($replacement))); |
| 241 | 265 | break; |
@@ -243,22 +267,25 @@ discard block |
||
| 243 | 267 | case 'array_inet': |
| 244 | 268 | if (is_array($replacement)) |
| 245 | 269 | { |
| 246 | - if (empty($replacement)) |
|
| 247 | - smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 270 | + if (empty($replacement)) { |
|
| 271 | + smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 272 | + } |
|
| 248 | 273 | |
| 249 | 274 | foreach ($replacement as $key => $value) |
| 250 | 275 | { |
| 251 | - if ($replacement == 'null' || $replacement == '') |
|
| 252 | - $replacement[$key] = 'null'; |
|
| 253 | - if (!isValidIP($value)) |
|
| 254 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 276 | + if ($replacement == 'null' || $replacement == '') { |
|
| 277 | + $replacement[$key] = 'null'; |
|
| 278 | + } |
|
| 279 | + if (!isValidIP($value)) { |
|
| 280 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 281 | + } |
|
| 255 | 282 | $replacement[$key] = sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($value))); |
| 256 | 283 | } |
| 257 | 284 | |
| 258 | 285 | return implode(', ', $replacement); |
| 286 | + } else { |
|
| 287 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 259 | 288 | } |
| 260 | - else |
|
| 261 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 262 | 289 | break; |
| 263 | 290 | |
| 264 | 291 | default: |
@@ -329,18 +356,20 @@ discard block |
||
| 329 | 356 | // One more query.... |
| 330 | 357 | $db_count = !isset($db_count) ? 1 : $db_count + 1; |
| 331 | 358 | |
| 332 | - if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) |
|
| 333 | - smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
| 359 | + if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) { |
|
| 360 | + smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
| 361 | + } |
|
| 334 | 362 | |
| 335 | 363 | // Use "ORDER BY null" to prevent Mysql doing filesorts for Group By clauses without an Order By |
| 336 | 364 | if (strpos($db_string, 'GROUP BY') !== false && strpos($db_string, 'ORDER BY') === false && preg_match('~^\s+SELECT~i', $db_string)) |
| 337 | 365 | { |
| 338 | 366 | // Add before LIMIT |
| 339 | - if ($pos = strpos($db_string, 'LIMIT ')) |
|
| 340 | - $db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string)); |
|
| 341 | - else |
|
| 342 | - // Append it. |
|
| 367 | + if ($pos = strpos($db_string, 'LIMIT ')) { |
|
| 368 | + $db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string)); |
|
| 369 | + } else { |
|
| 370 | + // Append it. |
|
| 343 | 371 | $db_string .= "\n\t\t\tORDER BY null"; |
| 372 | + } |
|
| 344 | 373 | } |
| 345 | 374 | |
| 346 | 375 | if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false)) |
@@ -362,8 +391,9 @@ discard block |
||
| 362 | 391 | list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__); |
| 363 | 392 | |
| 364 | 393 | // Initialize $db_cache if not already initialized. |
| 365 | - if (!isset($db_cache)) |
|
| 366 | - $db_cache = array(); |
|
| 394 | + if (!isset($db_cache)) { |
|
| 395 | + $db_cache = array(); |
|
| 396 | + } |
|
| 367 | 397 | |
| 368 | 398 | if (!empty($_SESSION['debug_redirect'])) |
| 369 | 399 | { |
@@ -389,17 +419,18 @@ discard block |
||
| 389 | 419 | while (true) |
| 390 | 420 | { |
| 391 | 421 | $pos = strpos($db_string, '\'', $pos + 1); |
| 392 | - if ($pos === false) |
|
| 393 | - break; |
|
| 422 | + if ($pos === false) { |
|
| 423 | + break; |
|
| 424 | + } |
|
| 394 | 425 | $clean .= substr($db_string, $old_pos, $pos - $old_pos); |
| 395 | 426 | |
| 396 | 427 | while (true) |
| 397 | 428 | { |
| 398 | 429 | $pos1 = strpos($db_string, '\'', $pos + 1); |
| 399 | 430 | $pos2 = strpos($db_string, '\\', $pos + 1); |
| 400 | - if ($pos1 === false) |
|
| 401 | - break; |
|
| 402 | - elseif ($pos2 == false || $pos2 > $pos1) |
|
| 431 | + if ($pos1 === false) { |
|
| 432 | + break; |
|
| 433 | + } elseif ($pos2 == false || $pos2 > $pos1) |
|
| 403 | 434 | { |
| 404 | 435 | $pos = $pos1; |
| 405 | 436 | break; |
@@ -415,29 +446,35 @@ discard block |
||
| 415 | 446 | $clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean))); |
| 416 | 447 | |
| 417 | 448 | // Comments? We don't use comments in our queries, we leave 'em outside! |
| 418 | - if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) |
|
| 419 | - $fail = true; |
|
| 449 | + if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) { |
|
| 450 | + $fail = true; |
|
| 451 | + } |
|
| 420 | 452 | // Trying to change passwords, slow us down, or something? |
| 421 | - elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) |
|
| 422 | - $fail = true; |
|
| 423 | - elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) |
|
| 424 | - $fail = true; |
|
| 453 | + elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) { |
|
| 454 | + $fail = true; |
|
| 455 | + } elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) { |
|
| 456 | + $fail = true; |
|
| 457 | + } |
|
| 425 | 458 | |
| 426 | - if (!empty($fail) && function_exists('log_error')) |
|
| 427 | - smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
| 459 | + if (!empty($fail) && function_exists('log_error')) { |
|
| 460 | + smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
| 461 | + } |
|
| 428 | 462 | } |
| 429 | 463 | |
| 430 | - if (empty($db_unbuffered)) |
|
| 431 | - $ret = @mysql_query($db_string, $connection); |
|
| 432 | - else |
|
| 433 | - $ret = @mysql_unbuffered_query($db_string, $connection); |
|
| 464 | + if (empty($db_unbuffered)) { |
|
| 465 | + $ret = @mysql_query($db_string, $connection); |
|
| 466 | + } else { |
|
| 467 | + $ret = @mysql_unbuffered_query($db_string, $connection); |
|
| 468 | + } |
|
| 434 | 469 | |
| 435 | - if ($ret === false && empty($db_values['db_error_skip'])) |
|
| 436 | - $ret = smf_db_error($db_string, $connection); |
|
| 470 | + if ($ret === false && empty($db_values['db_error_skip'])) { |
|
| 471 | + $ret = smf_db_error($db_string, $connection); |
|
| 472 | + } |
|
| 437 | 473 | |
| 438 | 474 | // Debugging. |
| 439 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 440 | - $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 475 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 476 | + $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 477 | + } |
|
| 441 | 478 | |
| 442 | 479 | return $ret; |
| 443 | 480 | } |
@@ -486,12 +523,13 @@ discard block |
||
| 486 | 523 | // Decide which connection to use |
| 487 | 524 | $connection = $connection === null ? $db_connection : $connection; |
| 488 | 525 | |
| 489 | - if ($type == 'begin') |
|
| 490 | - return @mysql_query('BEGIN', $connection); |
|
| 491 | - elseif ($type == 'rollback') |
|
| 492 | - return @mysql_query('ROLLBACK', $connection); |
|
| 493 | - elseif ($type == 'commit') |
|
| 494 | - return @mysql_query('COMMIT', $connection); |
|
| 526 | + if ($type == 'begin') { |
|
| 527 | + return @mysql_query('BEGIN', $connection); |
|
| 528 | + } elseif ($type == 'rollback') { |
|
| 529 | + return @mysql_query('ROLLBACK', $connection); |
|
| 530 | + } elseif ($type == 'commit') { |
|
| 531 | + return @mysql_query('COMMIT', $connection); |
|
| 532 | + } |
|
| 495 | 533 | |
| 496 | 534 | return false; |
| 497 | 535 | } |
@@ -531,8 +569,9 @@ discard block |
||
| 531 | 569 | // 2013: Lost connection to server during query. |
| 532 | 570 | |
| 533 | 571 | // Log the error. |
| 534 | - if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) |
|
| 535 | - log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line); |
|
| 572 | + if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) { |
|
| 573 | + log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line); |
|
| 574 | + } |
|
| 536 | 575 | |
| 537 | 576 | // Database error auto fixing ;). |
| 538 | 577 | if (function_exists('cache_get_data') && (!isset($modSettings['autoFixDatabase']) || $modSettings['autoFixDatabase'] == '1')) |
@@ -541,8 +580,9 @@ discard block |
||
| 541 | 580 | $old_cache = @$modSettings['cache_enable']; |
| 542 | 581 | $modSettings['cache_enable'] = '1'; |
| 543 | 582 | |
| 544 | - if (($temp = cache_get_data('db_last_error', 600)) !== null) |
|
| 545 | - $db_last_error = max(@$db_last_error, $temp); |
|
| 583 | + if (($temp = cache_get_data('db_last_error', 600)) !== null) { |
|
| 584 | + $db_last_error = max(@$db_last_error, $temp); |
|
| 585 | + } |
|
| 546 | 586 | |
| 547 | 587 | if (@$db_last_error < time() - 3600 * 24 * 3) |
| 548 | 588 | { |
@@ -558,8 +598,9 @@ discard block |
||
| 558 | 598 | foreach ($tables as $table) |
| 559 | 599 | { |
| 560 | 600 | // Now, it's still theoretically possible this could be an injection. So backtick it! |
| 561 | - if (trim($table) != '') |
|
| 562 | - $fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`'; |
|
| 601 | + if (trim($table) != '') { |
|
| 602 | + $fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`'; |
|
| 603 | + } |
|
| 563 | 604 | } |
| 564 | 605 | } |
| 565 | 606 | |
@@ -568,8 +609,9 @@ discard block |
||
| 568 | 609 | // Table crashed. Let's try to fix it. |
| 569 | 610 | elseif ($query_errno == 1016) |
| 570 | 611 | { |
| 571 | - if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) |
|
| 572 | - $fix_tables = array('`' . $match[1] . '`'); |
|
| 612 | + if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) { |
|
| 613 | + $fix_tables = array('`' . $match[1] . '`'); |
|
| 614 | + } |
|
| 573 | 615 | } |
| 574 | 616 | // Indexes crashed. Should be easy to fix! |
| 575 | 617 | elseif ($query_errno == 1034 || $query_errno == 1035) |
@@ -588,13 +630,15 @@ discard block |
||
| 588 | 630 | |
| 589 | 631 | // Make a note of the REPAIR... |
| 590 | 632 | cache_put_data('db_last_error', time(), 600); |
| 591 | - if (($temp = cache_get_data('db_last_error', 600)) === null) |
|
| 592 | - updateSettingsFile(array('db_last_error' => time())); |
|
| 633 | + if (($temp = cache_get_data('db_last_error', 600)) === null) { |
|
| 634 | + updateSettingsFile(array('db_last_error' => time())); |
|
| 635 | + } |
|
| 593 | 636 | |
| 594 | 637 | // Attempt to find and repair the broken table. |
| 595 | - foreach ($fix_tables as $table) |
|
| 596 | - $smcFunc['db_query']('', " |
|
| 638 | + foreach ($fix_tables as $table) { |
|
| 639 | + $smcFunc['db_query']('', " |
|
| 597 | 640 | REPAIR TABLE $table", false, false); |
| 641 | + } |
|
| 598 | 642 | |
| 599 | 643 | // And send off an email! |
| 600 | 644 | sendmail($webmaster_email, $txt['database_error'], $txt['tried_to_repair'], null, 'dberror'); |
@@ -603,11 +647,12 @@ discard block |
||
| 603 | 647 | |
| 604 | 648 | // Try the query again...? |
| 605 | 649 | $ret = $smcFunc['db_query']('', $db_string, false, false); |
| 606 | - if ($ret !== false) |
|
| 607 | - return $ret; |
|
| 650 | + if ($ret !== false) { |
|
| 651 | + return $ret; |
|
| 652 | + } |
|
| 653 | + } else { |
|
| 654 | + $modSettings['cache_enable'] = $old_cache; |
|
| 608 | 655 | } |
| 609 | - else |
|
| 610 | - $modSettings['cache_enable'] = $old_cache; |
|
| 611 | 656 | |
| 612 | 657 | // Check for the "lost connection" or "deadlock found" errors - and try it just one more time. |
| 613 | 658 | if (in_array($query_errno, array(1205, 1213, 2006, 2013))) |
@@ -617,22 +662,25 @@ discard block |
||
| 617 | 662 | // Are we in SSI mode? If so try that username and password first |
| 618 | 663 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
| 619 | 664 | { |
| 620 | - if (empty($db_persist)) |
|
| 621 | - $db_connection = @mysql_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 622 | - else |
|
| 623 | - $db_connection = @mysql_pconnect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 665 | + if (empty($db_persist)) { |
|
| 666 | + $db_connection = @mysql_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 667 | + } else { |
|
| 668 | + $db_connection = @mysql_pconnect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 669 | + } |
|
| 624 | 670 | } |
| 625 | 671 | // Fall back to the regular username and password if need be |
| 626 | 672 | if (!$db_connection) |
| 627 | 673 | { |
| 628 | - if (empty($db_persist)) |
|
| 629 | - $db_connection = @mysql_connect($db_server, $db_user, $db_passwd); |
|
| 630 | - else |
|
| 631 | - $db_connection = @mysql_pconnect($db_server, $db_user, $db_passwd); |
|
| 674 | + if (empty($db_persist)) { |
|
| 675 | + $db_connection = @mysql_connect($db_server, $db_user, $db_passwd); |
|
| 676 | + } else { |
|
| 677 | + $db_connection = @mysql_pconnect($db_server, $db_user, $db_passwd); |
|
| 678 | + } |
|
| 632 | 679 | } |
| 633 | 680 | |
| 634 | - if (!$db_connection || !@mysql_select_db($db_name, $db_connection)) |
|
| 635 | - $db_connection = false; |
|
| 681 | + if (!$db_connection || !@mysql_select_db($db_name, $db_connection)) { |
|
| 682 | + $db_connection = false; |
|
| 683 | + } |
|
| 636 | 684 | } |
| 637 | 685 | |
| 638 | 686 | if ($db_connection) |
@@ -643,24 +691,27 @@ discard block |
||
| 643 | 691 | $ret = $smcFunc['db_query']('', $db_string, false, false); |
| 644 | 692 | |
| 645 | 693 | $new_errno = mysql_errno($db_connection); |
| 646 | - if ($ret !== false || in_array($new_errno, array(1205, 1213))) |
|
| 647 | - break; |
|
| 694 | + if ($ret !== false || in_array($new_errno, array(1205, 1213))) { |
|
| 695 | + break; |
|
| 696 | + } |
|
| 648 | 697 | } |
| 649 | 698 | |
| 650 | 699 | // If it failed again, shucks to be you... we're not trying it over and over. |
| 651 | - if ($ret !== false) |
|
| 652 | - return $ret; |
|
| 700 | + if ($ret !== false) { |
|
| 701 | + return $ret; |
|
| 702 | + } |
|
| 653 | 703 | } |
| 654 | 704 | } |
| 655 | 705 | // Are they out of space, perhaps? |
| 656 | 706 | elseif ($query_errno == 1030 && (strpos($query_error, ' -1 ') !== false || strpos($query_error, ' 28 ') !== false || strpos($query_error, ' 12 ') !== false)) |
| 657 | 707 | { |
| 658 | - if (!isset($txt)) |
|
| 659 | - $query_error .= ' - check database storage space.'; |
|
| 660 | - else |
|
| 708 | + if (!isset($txt)) { |
|
| 709 | + $query_error .= ' - check database storage space.'; |
|
| 710 | + } else |
|
| 661 | 711 | { |
| 662 | - if (!isset($txt['mysql_error_space'])) |
|
| 663 | - loadLanguage('Errors'); |
|
| 712 | + if (!isset($txt['mysql_error_space'])) { |
|
| 713 | + loadLanguage('Errors'); |
|
| 714 | + } |
|
| 664 | 715 | |
| 665 | 716 | $query_error .= !isset($txt['mysql_error_space']) ? ' - check database storage space.' : $txt['mysql_error_space']; |
| 666 | 717 | } |
@@ -668,15 +719,17 @@ discard block |
||
| 668 | 719 | } |
| 669 | 720 | |
| 670 | 721 | // Nothing's defined yet... just die with it. |
| 671 | - if (empty($context) || empty($txt)) |
|
| 672 | - die($query_error); |
|
| 722 | + if (empty($context) || empty($txt)) { |
|
| 723 | + die($query_error); |
|
| 724 | + } |
|
| 673 | 725 | |
| 674 | 726 | // Show an error message, if possible. |
| 675 | 727 | $context['error_title'] = $txt['database_error']; |
| 676 | - if (allowedTo('admin_forum')) |
|
| 677 | - $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
| 678 | - else |
|
| 679 | - $context['error_message'] = $txt['try_again']; |
|
| 728 | + if (allowedTo('admin_forum')) { |
|
| 729 | + $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
| 730 | + } else { |
|
| 731 | + $context['error_message'] = $txt['try_again']; |
|
| 732 | + } |
|
| 680 | 733 | |
| 681 | 734 | if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true) |
| 682 | 735 | { |
@@ -705,25 +758,28 @@ discard block |
||
| 705 | 758 | $connection = $connection === null ? $db_connection : $connection; |
| 706 | 759 | |
| 707 | 760 | // With nothing to insert, simply return. |
| 708 | - if (empty($data)) |
|
| 709 | - return; |
|
| 761 | + if (empty($data)) { |
|
| 762 | + return; |
|
| 763 | + } |
|
| 710 | 764 | |
| 711 | 765 | // Replace the prefix holder with the actual prefix. |
| 712 | 766 | $table = str_replace('{db_prefix}', $db_prefix, $table); |
| 713 | 767 | |
| 714 | 768 | // Inserting data as a single row can be done as a single array. |
| 715 | - if (!is_array($data[array_rand($data)])) |
|
| 716 | - $data = array($data); |
|
| 769 | + if (!is_array($data[array_rand($data)])) { |
|
| 770 | + $data = array($data); |
|
| 771 | + } |
|
| 717 | 772 | |
| 718 | 773 | // Create the mold for a single row insert. |
| 719 | 774 | $insertData = '('; |
| 720 | 775 | foreach ($columns as $columnName => $type) |
| 721 | 776 | { |
| 722 | 777 | // Are we restricting the length? |
| 723 | - if (strpos($type, 'string-') !== false) |
|
| 724 | - $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
| 725 | - else |
|
| 726 | - $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
| 778 | + if (strpos($type, 'string-') !== false) { |
|
| 779 | + $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
| 780 | + } else { |
|
| 781 | + $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
| 782 | + } |
|
| 727 | 783 | } |
| 728 | 784 | $insertData = substr($insertData, 0, -2) . ')'; |
| 729 | 785 | |
@@ -732,8 +788,9 @@ discard block |
||
| 732 | 788 | |
| 733 | 789 | // Here's where the variables are injected to the query. |
| 734 | 790 | $insertRows = array(); |
| 735 | - foreach ($data as $dataRow) |
|
| 736 | - $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
| 791 | + foreach ($data as $dataRow) { |
|
| 792 | + $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
| 793 | + } |
|
| 737 | 794 | |
| 738 | 795 | // Determine the method of insertion. |
| 739 | 796 | $queryTitle = $method == 'replace' ? 'REPLACE' : ($method == 'ignore' ? 'INSERT IGNORE' : 'INSERT'); |
@@ -764,8 +821,9 @@ discard block |
||
| 764 | 821 | */ |
| 765 | 822 | function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null) |
| 766 | 823 | { |
| 767 | - if (empty($log_message)) |
|
| 768 | - $log_message = $error_message; |
|
| 824 | + if (empty($log_message)) { |
|
| 825 | + $log_message = $error_message; |
|
| 826 | + } |
|
| 769 | 827 | |
| 770 | 828 | foreach (debug_backtrace() as $step) |
| 771 | 829 | { |
@@ -784,12 +842,14 @@ discard block |
||
| 784 | 842 | } |
| 785 | 843 | |
| 786 | 844 | // A special case - we want the file and line numbers for debugging. |
| 787 | - if ($error_type == 'return') |
|
| 788 | - return array($file, $line); |
|
| 845 | + if ($error_type == 'return') { |
|
| 846 | + return array($file, $line); |
|
| 847 | + } |
|
| 789 | 848 | |
| 790 | 849 | // Is always a critical error. |
| 791 | - if (function_exists('log_error')) |
|
| 792 | - log_error($log_message, 'critical', $file, $line); |
|
| 850 | + if (function_exists('log_error')) { |
|
| 851 | + log_error($log_message, 'critical', $file, $line); |
|
| 852 | + } |
|
| 793 | 853 | |
| 794 | 854 | if (function_exists('fatal_error')) |
| 795 | 855 | { |
@@ -797,12 +857,12 @@ discard block |
||
| 797 | 857 | |
| 798 | 858 | // Cannot continue... |
| 799 | 859 | exit; |
| 860 | + } elseif ($error_type) { |
|
| 861 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 862 | + } else { |
|
| 863 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 864 | + } |
|
| 800 | 865 | } |
| 801 | - elseif ($error_type) |
|
| 802 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 803 | - else |
|
| 804 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 805 | -} |
|
| 806 | 866 | |
| 807 | 867 | /** |
| 808 | 868 | * Escape the LIKE wildcards so that they match the character and not the wildcard. |
@@ -819,10 +879,11 @@ discard block |
||
| 819 | 879 | '\\' => '\\\\', |
| 820 | 880 | ); |
| 821 | 881 | |
| 822 | - if ($translate_human_wildcards) |
|
| 823 | - $replacements += array( |
|
| 882 | + if ($translate_human_wildcards) { |
|
| 883 | + $replacements += array( |
|
| 824 | 884 | '*' => '%', |
| 825 | 885 | ); |
| 886 | + } |
|
| 826 | 887 | |
| 827 | 888 | return strtr($string, $replacements); |
| 828 | 889 | } |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Shows a listing of registered members. |
@@ -110,8 +111,9 @@ discard block |
||
| 110 | 111 | |
| 111 | 112 | $context['custom_profile_fields'] = getCustFieldsMList(); |
| 112 | 113 | |
| 113 | - if (!empty($context['custom_profile_fields']['columns'])) |
|
| 114 | - $context['columns'] += $context['custom_profile_fields']['columns']; |
|
| 114 | + if (!empty($context['custom_profile_fields']['columns'])) { |
|
| 115 | + $context['columns'] += $context['custom_profile_fields']['columns']; |
|
| 116 | + } |
|
| 115 | 117 | |
| 116 | 118 | $context['colspan'] = 0; |
| 117 | 119 | $context['disabled_fields'] = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); |
@@ -147,12 +149,12 @@ discard block |
||
| 147 | 149 | call_integration_hook('integrate_memberlist_buttons'); |
| 148 | 150 | |
| 149 | 151 | // Jump to the sub action. |
| 150 | - if (isset($subActions[$context['listing_by']])) |
|
| 151 | - call_helper($subActions[$context['listing_by']][1]); |
|
| 152 | - |
|
| 153 | - else |
|
| 154 | - call_helper($subActions['all'][1]); |
|
| 155 | -} |
|
| 152 | + if (isset($subActions[$context['listing_by']])) { |
|
| 153 | + call_helper($subActions[$context['listing_by']][1]); |
|
| 154 | + } else { |
|
| 155 | + call_helper($subActions['all'][1]); |
|
| 156 | + } |
|
| 157 | + } |
|
| 156 | 158 | |
| 157 | 159 | /** |
| 158 | 160 | * List all members, page by page, with sorting. |
@@ -177,8 +179,9 @@ discard block |
||
| 177 | 179 | if ($use_cache) |
| 178 | 180 | { |
| 179 | 181 | // Maybe there's something cached already. |
| 180 | - if (!empty($modSettings['memberlist_cache'])) |
|
| 181 | - $memberlist_cache = smf_json_decode($modSettings['memberlist_cache'], true); |
|
| 182 | + if (!empty($modSettings['memberlist_cache'])) { |
|
| 183 | + $memberlist_cache = smf_json_decode($modSettings['memberlist_cache'], true); |
|
| 184 | + } |
|
| 182 | 185 | |
| 183 | 186 | // The chunk size for the cached index. |
| 184 | 187 | $cache_step_size = 500; |
@@ -234,13 +237,15 @@ discard block |
||
| 234 | 237 | } |
| 235 | 238 | |
| 236 | 239 | // Set defaults for sort (real_name) and start. (0) |
| 237 | - if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) |
|
| 238 | - $_REQUEST['sort'] = 'real_name'; |
|
| 240 | + if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) { |
|
| 241 | + $_REQUEST['sort'] = 'real_name'; |
|
| 242 | + } |
|
| 239 | 243 | |
| 240 | 244 | if (!is_numeric($_REQUEST['start'])) |
| 241 | 245 | { |
| 242 | - if (preg_match('~^[^\'\\\\/]~' . ($context['utf8'] ? 'u' : ''), $smcFunc['strtolower']($_REQUEST['start']), $match) === 0) |
|
| 243 | - fatal_error('Hacker?', false); |
|
| 246 | + if (preg_match('~^[^\'\\\\/]~' . ($context['utf8'] ? 'u' : ''), $smcFunc['strtolower']($_REQUEST['start']), $match) === 0) { |
|
| 247 | + fatal_error('Hacker?', false); |
|
| 248 | + } |
|
| 244 | 249 | |
| 245 | 250 | $_REQUEST['start'] = $match[0]; |
| 246 | 251 | |
@@ -259,16 +264,18 @@ discard block |
||
| 259 | 264 | } |
| 260 | 265 | |
| 261 | 266 | $context['letter_links'] = ''; |
| 262 | - for ($i = 97; $i < 123; $i++) |
|
| 263 | - $context['letter_links'] .= '<a href="' . $scripturl . '?action=mlist;sa=all;start=' . chr($i) . '#letter' . chr($i) . '">' . strtoupper(chr($i)) . '</a> '; |
|
| 267 | + for ($i = 97; $i < 123; $i++) { |
|
| 268 | + $context['letter_links'] .= '<a href="' . $scripturl . '?action=mlist;sa=all;start=' . chr($i) . '#letter' . chr($i) . '">' . strtoupper(chr($i)) . '</a> '; |
|
| 269 | + } |
|
| 264 | 270 | |
| 265 | 271 | // Sort out the column information. |
| 266 | 272 | foreach ($context['columns'] as $col => $column_details) |
| 267 | 273 | { |
| 268 | 274 | $context['columns'][$col]['href'] = $scripturl . '?action=mlist;sort=' . $col . ';start=0'; |
| 269 | 275 | |
| 270 | - if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) |
|
| 271 | - $context['columns'][$col]['href'] .= ';desc'; |
|
| 276 | + if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) { |
|
| 277 | + $context['columns'][$col]['href'] .= ';desc'; |
|
| 278 | + } |
|
| 272 | 279 | |
| 273 | 280 | $context['columns'][$col]['link'] = '<a href="' . $context['columns'][$col]['href'] . '" rel="nofollow">' . $context['columns'][$col]['label'] . '</a>'; |
| 274 | 281 | $context['columns'][$col]['selected'] = $_REQUEST['sort'] == $col; |
@@ -317,8 +324,9 @@ discard block |
||
| 317 | 324 | elseif ($use_cache && $_REQUEST['sort'] === 'real_name') |
| 318 | 325 | { |
| 319 | 326 | $first_offset = floor(($memberlist_cache['num_members'] - $modSettings['defaultMaxMembers'] - $_REQUEST['start']) / $cache_step_size) * $cache_step_size; |
| 320 | - if ($first_offset < 0) |
|
| 321 | - $first_offset = 0; |
|
| 327 | + if ($first_offset < 0) { |
|
| 328 | + $first_offset = 0; |
|
| 329 | + } |
|
| 322 | 330 | $second_offset = ceil(($memberlist_cache['num_members'] - $_REQUEST['start']) / $cache_step_size) * $cache_step_size; |
| 323 | 331 | |
| 324 | 332 | $where = 'mem.real_name BETWEEN {string:real_name_low} AND {string:real_name_high}'; |
@@ -395,12 +403,13 @@ discard block |
||
| 395 | 403 | ) |
| 396 | 404 | ); |
| 397 | 405 | $context['custom_search_fields'] = array(); |
| 398 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 399 | - $context['custom_search_fields'][$row['col_name']] = array( |
|
| 406 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 407 | + $context['custom_search_fields'][$row['col_name']] = array( |
|
| 400 | 408 | 'colname' => $row['col_name'], |
| 401 | 409 | 'name' => $row['field_name'], |
| 402 | 410 | 'desc' => $row['field_desc'], |
| 403 | 411 | ); |
| 412 | + } |
|
| 404 | 413 | $smcFunc['db_free_result']($request); |
| 405 | 414 | |
| 406 | 415 | // They're searching.. |
@@ -413,23 +422,27 @@ discard block |
||
| 413 | 422 | $context['old_search_value'] = urlencode($_REQUEST['search']); |
| 414 | 423 | |
| 415 | 424 | // No fields? Use default... |
| 416 | - if (empty($_POST['fields'])) |
|
| 417 | - $_POST['fields'] = array('name'); |
|
| 425 | + if (empty($_POST['fields'])) { |
|
| 426 | + $_POST['fields'] = array('name'); |
|
| 427 | + } |
|
| 418 | 428 | |
| 419 | 429 | // Set defaults for how the results are sorted |
| 420 | - if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) |
|
| 421 | - $_REQUEST['sort'] = 'real_name'; |
|
| 430 | + if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) { |
|
| 431 | + $_REQUEST['sort'] = 'real_name'; |
|
| 432 | + } |
|
| 422 | 433 | |
| 423 | 434 | // Build the column link / sort information. |
| 424 | 435 | foreach ($context['columns'] as $col => $column_details) |
| 425 | 436 | { |
| 426 | 437 | $context['columns'][$col]['href'] = $scripturl . '?action=mlist;sa=search;start=0;sort=' . $col; |
| 427 | 438 | |
| 428 | - if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) |
|
| 429 | - $context['columns'][$col]['href'] .= ';desc'; |
|
| 439 | + if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) { |
|
| 440 | + $context['columns'][$col]['href'] .= ';desc'; |
|
| 441 | + } |
|
| 430 | 442 | |
| 431 | - if (isset($_POST['search']) && isset($_POST['fields'])) |
|
| 432 | - $context['columns'][$col]['href'] .= ';search=' . $_POST['search'] . ';fields=' . implode(',', $_POST['fields']); |
|
| 443 | + if (isset($_POST['search']) && isset($_POST['fields'])) { |
|
| 444 | + $context['columns'][$col]['href'] .= ';search=' . $_POST['search'] . ';fields=' . implode(',', $_POST['fields']); |
|
| 445 | + } |
|
| 433 | 446 | |
| 434 | 447 | $context['columns'][$col]['link'] = '<a href="' . $context['columns'][$col]['href'] . '" rel="nofollow">' . $context['columns'][$col]['label'] . '</a>'; |
| 435 | 448 | $context['columns'][$col]['selected'] = $_REQUEST['sort'] == $col; |
@@ -452,8 +465,7 @@ discard block |
||
| 452 | 465 | { |
| 453 | 466 | $fields = allowedTo('moderate_forum') ? array('member_name', 'real_name') : array('real_name'); |
| 454 | 467 | $search_fields[] = 'name'; |
| 455 | - } |
|
| 456 | - else |
|
| 468 | + } else |
|
| 457 | 469 | { |
| 458 | 470 | $fields = array(); |
| 459 | 471 | $search_fields = array(); |
@@ -478,9 +490,10 @@ discard block |
||
| 478 | 490 | $search_fields[] = 'email'; |
| 479 | 491 | } |
| 480 | 492 | |
| 481 | - if ($smcFunc['db_case_sensitive']) |
|
| 482 | - foreach ($fields as $key => $field) |
|
| 493 | + if ($smcFunc['db_case_sensitive']) { |
|
| 494 | + foreach ($fields as $key => $field) |
|
| 483 | 495 | $fields[$key] = 'LOWER(' . $field . ')'; |
| 496 | + } |
|
| 484 | 497 | |
| 485 | 498 | $customJoin = array(); |
| 486 | 499 | $customCount = 10; |
@@ -499,8 +512,9 @@ discard block |
||
| 499 | 512 | } |
| 500 | 513 | |
| 501 | 514 | // No search fields? That means you're trying to hack things |
| 502 | - if (empty($search_fields)) |
|
| 503 | - fatal_lang_error('invalid_search_string', false); |
|
| 515 | + if (empty($search_fields)) { |
|
| 516 | + fatal_lang_error('invalid_search_string', false); |
|
| 517 | + } |
|
| 504 | 518 | |
| 505 | 519 | $query = $_POST['search'] == '' ? '= {string:blank_string}' : ($smcFunc['db_case_sensitive'] ? 'LIKE LOWER({string:search})' : 'LIKE {string:search}'); |
| 506 | 520 | |
@@ -538,8 +552,7 @@ discard block |
||
| 538 | 552 | ); |
| 539 | 553 | printMemberListRows($request); |
| 540 | 554 | $smcFunc['db_free_result']($request); |
| 541 | - } |
|
| 542 | - else |
|
| 555 | + } else |
|
| 543 | 556 | { |
| 544 | 557 | // These are all the possible fields. |
| 545 | 558 | $context['search_fields'] = array( |
@@ -554,14 +567,14 @@ discard block |
||
| 554 | 567 | { |
| 555 | 568 | unset($context['search_fields']['email']); |
| 556 | 569 | $context['search_defaults'] = array('name'); |
| 557 | - } |
|
| 558 | - else |
|
| 570 | + } else |
|
| 559 | 571 | { |
| 560 | 572 | $context['search_defaults'] = array('name', 'email'); |
| 561 | 573 | } |
| 562 | 574 | |
| 563 | - foreach ($context['custom_search_fields'] as $field) |
|
| 564 | - $context['search_fields']['cust_' . $field['colname']] = sprintf($txt['mlist_search_by'], $field['name']); |
|
| 575 | + foreach ($context['custom_search_fields'] as $field) { |
|
| 576 | + $context['search_fields']['cust_' . $field['colname']] = sprintf($txt['mlist_search_by'], $field['name']); |
|
| 577 | + } |
|
| 565 | 578 | |
| 566 | 579 | $context['sub_template'] = 'search'; |
| 567 | 580 | $context['old_search'] = isset($_GET['search']) ? $_GET['search'] : (isset($_POST['search']) ? $smcFunc['htmlspecialchars']($_POST['search']) : ''); |
@@ -603,12 +616,14 @@ discard block |
||
| 603 | 616 | $smcFunc['db_free_result']($result); |
| 604 | 617 | |
| 605 | 618 | // Avoid division by zero... |
| 606 | - if ($most_posts == 0) |
|
| 607 | - $most_posts = 1; |
|
| 619 | + if ($most_posts == 0) { |
|
| 620 | + $most_posts = 1; |
|
| 621 | + } |
|
| 608 | 622 | |
| 609 | 623 | $members = array(); |
| 610 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 611 | - $members[] = $row['id_member']; |
|
| 624 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 625 | + $members[] = $row['id_member']; |
|
| 626 | + } |
|
| 612 | 627 | |
| 613 | 628 | // Load all the members for display. |
| 614 | 629 | loadMemberData($members); |
@@ -616,8 +631,9 @@ discard block |
||
| 616 | 631 | $context['members'] = array(); |
| 617 | 632 | foreach ($members as $member) |
| 618 | 633 | { |
| 619 | - if (!loadMemberContext($member)) |
|
| 620 | - continue; |
|
| 634 | + if (!loadMemberContext($member)) { |
|
| 635 | + continue; |
|
| 636 | + } |
|
| 621 | 637 | |
| 622 | 638 | $context['members'][$member] = $memberContext[$member]; |
| 623 | 639 | $context['members'][$member]['post_percent'] = round(($context['members'][$member]['real_posts'] * 100) / $most_posts); |
@@ -634,20 +650,21 @@ discard block |
||
| 634 | 650 | continue; |
| 635 | 651 | } |
| 636 | 652 | |
| 637 | - if ($column['bbc'] && !empty($context['members'][$member]['options'][$key])) |
|
| 638 | - $context['members'][$member]['options'][$key] = strip_tags(parse_bbc($context['members'][$member]['options'][$key])); |
|
| 639 | - |
|
| 640 | - elseif ($column['type'] == 'check') |
|
| 641 | - $context['members'][$member]['options'][$key] = $context['members'][$member]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 653 | + if ($column['bbc'] && !empty($context['members'][$member]['options'][$key])) { |
|
| 654 | + $context['members'][$member]['options'][$key] = strip_tags(parse_bbc($context['members'][$member]['options'][$key])); |
|
| 655 | + } elseif ($column['type'] == 'check') { |
|
| 656 | + $context['members'][$member]['options'][$key] = $context['members'][$member]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 657 | + } |
|
| 642 | 658 | |
| 643 | 659 | // Enclosing the user input within some other text? |
| 644 | - if (!empty($column['enclose'])) |
|
| 645 | - $context['members'][$member]['options'][$key] = strtr($column['enclose'], array( |
|
| 660 | + if (!empty($column['enclose'])) { |
|
| 661 | + $context['members'][$member]['options'][$key] = strtr($column['enclose'], array( |
|
| 646 | 662 | '{SCRIPTURL}' => $scripturl, |
| 647 | 663 | '{IMAGES_URL}' => $settings['images_url'], |
| 648 | 664 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 649 | 665 | '{INPUT}' => $context['members'][$member]['options'][$key], |
| 650 | 666 | )); |
| 667 | + } |
|
| 651 | 668 | } |
| 652 | 669 | } |
| 653 | 670 | } |
@@ -688,17 +705,17 @@ discard block |
||
| 688 | 705 | ); |
| 689 | 706 | |
| 690 | 707 | // Get the right sort method depending on the cust field type. |
| 691 | - if ($row['field_type'] != 'check') |
|
| 692 | - $cpf['columns'][$row['col_name']]['sort'] = array( |
|
| 708 | + if ($row['field_type'] != 'check') { |
|
| 709 | + $cpf['columns'][$row['col_name']]['sort'] = array( |
|
| 693 | 710 | 'down' => 'LENGTH(t' . $row['col_name'] . '.value) > 0 ASC, COALESCE(t' . $row['col_name'] . '.value, "") DESC', |
| 694 | 711 | 'up' => 'LENGTH(t' . $row['col_name'] . '.value) > 0 DESC, COALESCE(t' . $row['col_name'] . '.value, "") ASC' |
| 695 | 712 | ); |
| 696 | - |
|
| 697 | - else |
|
| 698 | - $cpf['columns'][$row['col_name']]['sort'] = array( |
|
| 713 | + } else { |
|
| 714 | + $cpf['columns'][$row['col_name']]['sort'] = array( |
|
| 699 | 715 | 'down' => 't' . $row['col_name'] . '.value DESC', |
| 700 | 716 | 'up' => 't' . $row['col_name'] . '.value ASC' |
| 701 | 717 | ); |
| 718 | + } |
|
| 702 | 719 | |
| 703 | 720 | $cpf['join'][$row['col_name']] = 'LEFT JOIN {db_prefix}themes AS t' . $row['col_name'] . ' ON (t' . $row['col_name'] . '.variable = {literal:' . $row['col_name'] . '} AND t' . $row['col_name'] . '.id_theme = 1 AND t' . $row['col_name'] . '.id_member = mem.id_member)'; |
| 704 | 721 | } |
@@ -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 | * Put this user in the online log. |
@@ -33,8 +34,9 @@ discard block |
||
| 33 | 34 | // Don't update for every page - this isn't wholly accurate but who cares. |
| 34 | 35 | if ($topic) |
| 35 | 36 | { |
| 36 | - if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) |
|
| 37 | - $force = false; |
|
| 37 | + if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) { |
|
| 38 | + $force = false; |
|
| 39 | + } |
|
| 38 | 40 | $_SESSION['last_topic_id'] = $topic; |
| 39 | 41 | } |
| 40 | 42 | } |
@@ -47,22 +49,24 @@ discard block |
||
| 47 | 49 | } |
| 48 | 50 | |
| 49 | 51 | // Don't mark them as online more than every so often. |
| 50 | - if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) |
|
| 51 | - return; |
|
| 52 | + if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) { |
|
| 53 | + return; |
|
| 54 | + } |
|
| 52 | 55 | |
| 53 | 56 | if (!empty($modSettings['who_enabled'])) |
| 54 | 57 | { |
| 55 | 58 | $serialized = $_GET + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']); |
| 56 | 59 | |
| 57 | 60 | // In the case of a dlattach action, session_var may not be set. |
| 58 | - if (!isset($context['session_var'])) |
|
| 59 | - $context['session_var'] = $_SESSION['session_var']; |
|
| 61 | + if (!isset($context['session_var'])) { |
|
| 62 | + $context['session_var'] = $_SESSION['session_var']; |
|
| 63 | + } |
|
| 60 | 64 | |
| 61 | 65 | unset($serialized['sesc'], $serialized[$context['session_var']]); |
| 62 | 66 | $serialized = json_encode($serialized); |
| 67 | + } else { |
|
| 68 | + $serialized = ''; |
|
| 63 | 69 | } |
| 64 | - else |
|
| 65 | - $serialized = ''; |
|
| 66 | 70 | |
| 67 | 71 | // Guests use 0, members use their session ID. |
| 68 | 72 | $session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id(); |
@@ -102,17 +106,18 @@ discard block |
||
| 102 | 106 | ); |
| 103 | 107 | |
| 104 | 108 | // Guess it got deleted. |
| 105 | - if ($smcFunc['db_affected_rows']() == 0) |
|
| 109 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
| 110 | + $_SESSION['log_time'] = 0; |
|
| 111 | + } |
|
| 112 | + } else { |
|
| 106 | 113 | $_SESSION['log_time'] = 0; |
| 107 | 114 | } |
| 108 | - else |
|
| 109 | - $_SESSION['log_time'] = 0; |
|
| 110 | 115 | |
| 111 | 116 | // Otherwise, we have to delete and insert. |
| 112 | 117 | if (empty($_SESSION['log_time'])) |
| 113 | 118 | { |
| 114 | - if ($do_delete || !empty($user_info['id'])) |
|
| 115 | - $smcFunc['db_query']('', ' |
|
| 119 | + if ($do_delete || !empty($user_info['id'])) { |
|
| 120 | + $smcFunc['db_query']('', ' |
|
| 116 | 121 | DELETE FROM {db_prefix}log_online |
| 117 | 122 | WHERE ' . ($do_delete ? 'log_time < {int:log_time}' : '') . ($do_delete && !empty($user_info['id']) ? ' OR ' : '') . (empty($user_info['id']) ? '' : 'id_member = {int:current_member}'), |
| 118 | 123 | array( |
@@ -120,6 +125,7 @@ discard block |
||
| 120 | 125 | 'log_time' => time() - $modSettings['lastActive'] * 60, |
| 121 | 126 | ) |
| 122 | 127 | ); |
| 128 | + } |
|
| 123 | 129 | |
| 124 | 130 | $smcFunc['db_insert']($do_delete ? 'ignore' : 'replace', |
| 125 | 131 | '{db_prefix}log_online', |
@@ -133,21 +139,24 @@ discard block |
||
| 133 | 139 | $_SESSION['log_time'] = time(); |
| 134 | 140 | |
| 135 | 141 | // Well, they are online now. |
| 136 | - if (empty($_SESSION['timeOnlineUpdated'])) |
|
| 137 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
| 142 | + if (empty($_SESSION['timeOnlineUpdated'])) { |
|
| 143 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
| 144 | + } |
|
| 138 | 145 | |
| 139 | 146 | // Set their login time, if not already done within the last minute. |
| 140 | 147 | if (SMF != 'SSI' && !empty($user_info['last_login']) && $user_info['last_login'] < time() - 60 && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('.xml', 'login2', 'logintfa')))) |
| 141 | 148 | { |
| 142 | 149 | // Don't count longer than 15 minutes. |
| 143 | - if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) |
|
| 144 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
| 150 | + if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) { |
|
| 151 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
| 152 | + } |
|
| 145 | 153 | |
| 146 | 154 | $user_settings['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
| 147 | 155 | updateMemberData($user_info['id'], array('last_login' => time(), 'member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'], 'total_time_logged_in' => $user_settings['total_time_logged_in'])); |
| 148 | 156 | |
| 149 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 150 | - cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
| 157 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 158 | + cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
| 159 | + } |
|
| 151 | 160 | |
| 152 | 161 | $user_info['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
| 153 | 162 | $_SESSION['timeOnlineUpdated'] = time(); |
@@ -184,8 +193,7 @@ discard block |
||
| 184 | 193 | // Oops. maybe we have no more disk space left, or some other troubles, troubles... |
| 185 | 194 | // Copy the file back and run for your life! |
| 186 | 195 | @copy($boarddir . '/db_last_error_bak.php', $boarddir . '/db_last_error.php'); |
| 187 | - } |
|
| 188 | - else |
|
| 196 | + } else |
|
| 189 | 197 | { |
| 190 | 198 | @touch($boarddir . '/' . 'Settings.php'); |
| 191 | 199 | return true; |
@@ -205,22 +213,27 @@ discard block |
||
| 205 | 213 | global $db_cache, $db_count, $cache_misses, $cache_count_misses, $db_show_debug, $cache_count, $cache_hits, $smcFunc, $txt; |
| 206 | 214 | |
| 207 | 215 | // Add to Settings.php if you want to show the debugging information. |
| 208 | - if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) |
|
| 209 | - return; |
|
| 216 | + if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) { |
|
| 217 | + return; |
|
| 218 | + } |
|
| 210 | 219 | |
| 211 | - if (empty($_SESSION['view_queries'])) |
|
| 212 | - $_SESSION['view_queries'] = 0; |
|
| 213 | - if (empty($context['debug']['language_files'])) |
|
| 214 | - $context['debug']['language_files'] = array(); |
|
| 215 | - if (empty($context['debug']['sheets'])) |
|
| 216 | - $context['debug']['sheets'] = array(); |
|
| 220 | + if (empty($_SESSION['view_queries'])) { |
|
| 221 | + $_SESSION['view_queries'] = 0; |
|
| 222 | + } |
|
| 223 | + if (empty($context['debug']['language_files'])) { |
|
| 224 | + $context['debug']['language_files'] = array(); |
|
| 225 | + } |
|
| 226 | + if (empty($context['debug']['sheets'])) { |
|
| 227 | + $context['debug']['sheets'] = array(); |
|
| 228 | + } |
|
| 217 | 229 | |
| 218 | 230 | $files = get_included_files(); |
| 219 | 231 | $total_size = 0; |
| 220 | 232 | for ($i = 0, $n = count($files); $i < $n; $i++) |
| 221 | 233 | { |
| 222 | - if (file_exists($files[$i])) |
|
| 223 | - $total_size += filesize($files[$i]); |
|
| 234 | + if (file_exists($files[$i])) { |
|
| 235 | + $total_size += filesize($files[$i]); |
|
| 236 | + } |
|
| 224 | 237 | $files[$i] = strtr($files[$i], array($boarddir => '.', $sourcedir => '(Sources)', $cachedir => '(Cache)', $settings['actual_theme_dir'] => '(Current Theme)')); |
| 225 | 238 | } |
| 226 | 239 | |
@@ -229,8 +242,9 @@ discard block |
||
| 229 | 242 | { |
| 230 | 243 | foreach ($db_cache as $q => $qq) |
| 231 | 244 | { |
| 232 | - if (!empty($qq['w'])) |
|
| 233 | - $warnings += count($qq['w']); |
|
| 245 | + if (!empty($qq['w'])) { |
|
| 246 | + $warnings += count($qq['w']); |
|
| 247 | + } |
|
| 234 | 248 | } |
| 235 | 249 | |
| 236 | 250 | $_SESSION['debug'] = &$db_cache; |
@@ -251,12 +265,14 @@ discard block |
||
| 251 | 265 | ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),' |
| 252 | 266 | ', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>'; |
| 253 | 267 | |
| 254 | - if (function_exists('memory_get_peak_usage')) |
|
| 255 | - echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
| 268 | + if (function_exists('memory_get_peak_usage')) { |
|
| 269 | + echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
| 270 | + } |
|
| 256 | 271 | |
| 257 | 272 | // What tokens are active? |
| 258 | - if (isset($_SESSION['token'])) |
|
| 259 | - echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
| 273 | + if (isset($_SESSION['token'])) { |
|
| 274 | + echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
| 275 | + } |
|
| 260 | 276 | |
| 261 | 277 | if (!empty($modSettings['cache_enable']) && !empty($cache_hits)) |
| 262 | 278 | { |
@@ -269,10 +285,12 @@ discard block |
||
| 269 | 285 | $total_t += $cache_hit['t']; |
| 270 | 286 | $total_s += $cache_hit['s']; |
| 271 | 287 | } |
| 272 | - if (!isset($cache_misses)) |
|
| 273 | - $cache_misses = array(); |
|
| 274 | - foreach ($cache_misses as $missed) |
|
| 275 | - $missed_entires[] = $missed['d'] . ' ' . $missed['k']; |
|
| 288 | + if (!isset($cache_misses)) { |
|
| 289 | + $cache_misses = array(); |
|
| 290 | + } |
|
| 291 | + foreach ($cache_misses as $missed) { |
|
| 292 | + $missed_entires[] = $missed['d'] . ' ' . $missed['k']; |
|
| 293 | + } |
|
| 276 | 294 | |
| 277 | 295 | echo ' |
| 278 | 296 | ', $txt['debug_cache_hits'], $cache_count, ': ', sprintf($txt['debug_cache_seconds_bytes_total'], comma_format($total_t, 5), comma_format($total_s)), ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_cache_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_cache_info" style="display: none;"><em>', implode('</em>, <em>', $entries), '</em></span>)<br> |
@@ -283,38 +301,44 @@ discard block |
||
| 283 | 301 | <a href="', $scripturl, '?action=viewquery" target="_blank" class="new_win">', $warnings == 0 ? sprintf($txt['debug_queries_used'], (int) $db_count) : sprintf($txt['debug_queries_used_and_warnings'], (int) $db_count, $warnings), '</a><br> |
| 284 | 302 | <br>'; |
| 285 | 303 | |
| 286 | - if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) |
|
| 287 | - foreach ($db_cache as $q => $qq) |
|
| 304 | + if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) { |
|
| 305 | + foreach ($db_cache as $q => $qq) |
|
| 288 | 306 | { |
| 289 | 307 | $is_select = strpos(trim($qq['q']), 'SELECT') === 0 || preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+SELECT .+$~s', trim($qq['q'])) != 0; |
| 308 | + } |
|
| 290 | 309 | // Temporary tables created in earlier queries are not explainable. |
| 291 | 310 | if ($is_select) |
| 292 | 311 | { |
| 293 | - foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) |
|
| 294 | - if (strpos(trim($qq['q']), $tmp) !== false) |
|
| 312 | + foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) { |
|
| 313 | + if (strpos(trim($qq['q']), $tmp) !== false) |
|
| 295 | 314 | { |
| 296 | 315 | $is_select = false; |
| 316 | + } |
|
| 297 | 317 | break; |
| 298 | 318 | } |
| 299 | 319 | } |
| 300 | 320 | // But actual creation of the temporary tables are. |
| 301 | - elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) |
|
| 302 | - $is_select = true; |
|
| 321 | + elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) { |
|
| 322 | + $is_select = true; |
|
| 323 | + } |
|
| 303 | 324 | |
| 304 | 325 | // Make the filenames look a bit better. |
| 305 | - if (isset($qq['f'])) |
|
| 306 | - $qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']); |
|
| 326 | + if (isset($qq['f'])) { |
|
| 327 | + $qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']); |
|
| 328 | + } |
|
| 307 | 329 | |
| 308 | 330 | echo ' |
| 309 | 331 | <strong>', $is_select ? '<a href="' . $scripturl . '?action=viewquery;qq=' . ($q + 1) . '#qq' . $q . '" target="_blank" class="new_win" style="text-decoration: none;">' : '', nl2br(str_replace("\t", ' ', $smcFunc['htmlspecialchars'](ltrim($qq['q'], "\n\r")))) . ($is_select ? '</a></strong>' : '</strong>') . '<br> |
| 310 | 332 | '; |
| 311 | - if (!empty($qq['f']) && !empty($qq['l'])) |
|
| 312 | - echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']); |
|
| 333 | + if (!empty($qq['f']) && !empty($qq['l'])) { |
|
| 334 | + echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']); |
|
| 335 | + } |
|
| 313 | 336 | |
| 314 | - if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at'])) |
|
| 315 | - echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>'; |
|
| 316 | - elseif (isset($qq['t'])) |
|
| 317 | - echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>'; |
|
| 337 | + if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at'])) { |
|
| 338 | + echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>'; |
|
| 339 | + } elseif (isset($qq['t'])) { |
|
| 340 | + echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>'; |
|
| 341 | + } |
|
| 318 | 342 | echo ' |
| 319 | 343 | <br>'; |
| 320 | 344 | } |
@@ -339,12 +363,14 @@ discard block |
||
| 339 | 363 | global $modSettings, $smcFunc; |
| 340 | 364 | static $cache_stats = array(); |
| 341 | 365 | |
| 342 | - if (empty($modSettings['trackStats'])) |
|
| 343 | - return false; |
|
| 344 | - if (!empty($stats)) |
|
| 345 | - return $cache_stats = array_merge($cache_stats, $stats); |
|
| 346 | - elseif (empty($cache_stats)) |
|
| 347 | - return false; |
|
| 366 | + if (empty($modSettings['trackStats'])) { |
|
| 367 | + return false; |
|
| 368 | + } |
|
| 369 | + if (!empty($stats)) { |
|
| 370 | + return $cache_stats = array_merge($cache_stats, $stats); |
|
| 371 | + } elseif (empty($cache_stats)) { |
|
| 372 | + return false; |
|
| 373 | + } |
|
| 348 | 374 | |
| 349 | 375 | $setStringUpdate = ''; |
| 350 | 376 | $insert_keys = array(); |
@@ -357,10 +383,11 @@ discard block |
||
| 357 | 383 | $setStringUpdate .= ' |
| 358 | 384 | ' . $field . ' = ' . ($change === '+' ? $field . ' + 1' : '{int:' . $field . '}') . ','; |
| 359 | 385 | |
| 360 | - if ($change === '+') |
|
| 361 | - $cache_stats[$field] = 1; |
|
| 362 | - else |
|
| 363 | - $update_parameters[$field] = $change; |
|
| 386 | + if ($change === '+') { |
|
| 387 | + $cache_stats[$field] = 1; |
|
| 388 | + } else { |
|
| 389 | + $update_parameters[$field] = $change; |
|
| 390 | + } |
|
| 364 | 391 | $insert_keys[$field] = 'int'; |
| 365 | 392 | } |
| 366 | 393 | |
@@ -424,43 +451,50 @@ discard block |
||
| 424 | 451 | ); |
| 425 | 452 | |
| 426 | 453 | // Make sure this particular log is enabled first... |
| 427 | - if (empty($modSettings['modlog_enabled'])) |
|
| 428 | - unset ($log_types['moderate']); |
|
| 429 | - if (empty($modSettings['userlog_enabled'])) |
|
| 430 | - unset ($log_types['user']); |
|
| 431 | - if (empty($modSettings['adminlog_enabled'])) |
|
| 432 | - unset ($log_types['admin']); |
|
| 454 | + if (empty($modSettings['modlog_enabled'])) { |
|
| 455 | + unset ($log_types['moderate']); |
|
| 456 | + } |
|
| 457 | + if (empty($modSettings['userlog_enabled'])) { |
|
| 458 | + unset ($log_types['user']); |
|
| 459 | + } |
|
| 460 | + if (empty($modSettings['adminlog_enabled'])) { |
|
| 461 | + unset ($log_types['admin']); |
|
| 462 | + } |
|
| 433 | 463 | |
| 434 | 464 | call_integration_hook('integrate_log_types', array(&$log_types)); |
| 435 | 465 | |
| 436 | 466 | foreach ($logs as $log) |
| 437 | 467 | { |
| 438 | - if (!isset($log_types[$log['log_type']])) |
|
| 439 | - return false; |
|
| 468 | + if (!isset($log_types[$log['log_type']])) { |
|
| 469 | + return false; |
|
| 470 | + } |
|
| 440 | 471 | |
| 441 | - if (!is_array($log['extra'])) |
|
| 442 | - trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
| 472 | + if (!is_array($log['extra'])) { |
|
| 473 | + trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
| 474 | + } |
|
| 443 | 475 | |
| 444 | 476 | // Pull out the parts we want to store separately, but also make sure that the data is proper |
| 445 | 477 | if (isset($log['extra']['topic'])) |
| 446 | 478 | { |
| 447 | - if (!is_numeric($log['extra']['topic'])) |
|
| 448 | - trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
| 479 | + if (!is_numeric($log['extra']['topic'])) { |
|
| 480 | + trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
| 481 | + } |
|
| 449 | 482 | $topic_id = empty($log['extra']['topic']) ? 0 : (int) $log['extra']['topic']; |
| 450 | 483 | unset($log['extra']['topic']); |
| 484 | + } else { |
|
| 485 | + $topic_id = 0; |
|
| 451 | 486 | } |
| 452 | - else |
|
| 453 | - $topic_id = 0; |
|
| 454 | 487 | |
| 455 | 488 | if (isset($log['extra']['message'])) |
| 456 | 489 | { |
| 457 | - if (!is_numeric($log['extra']['message'])) |
|
| 458 | - trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
| 490 | + if (!is_numeric($log['extra']['message'])) { |
|
| 491 | + trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
| 492 | + } |
|
| 459 | 493 | $msg_id = empty($log['extra']['message']) ? 0 : (int) $log['extra']['message']; |
| 460 | 494 | unset($log['extra']['message']); |
| 495 | + } else { |
|
| 496 | + $msg_id = 0; |
|
| 461 | 497 | } |
| 462 | - else |
|
| 463 | - $msg_id = 0; |
|
| 464 | 498 | |
| 465 | 499 | // @todo cache this? |
| 466 | 500 | // Is there an associated report on this? |
@@ -487,23 +521,26 @@ discard block |
||
| 487 | 521 | $smcFunc['db_free_result']($request); |
| 488 | 522 | } |
| 489 | 523 | |
| 490 | - if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) |
|
| 491 | - trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
| 524 | + if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) { |
|
| 525 | + trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
| 526 | + } |
|
| 492 | 527 | |
| 493 | 528 | if (isset($log['extra']['board'])) |
| 494 | 529 | { |
| 495 | - if (!is_numeric($log['extra']['board'])) |
|
| 496 | - trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
| 530 | + if (!is_numeric($log['extra']['board'])) { |
|
| 531 | + trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
| 532 | + } |
|
| 497 | 533 | $board_id = empty($log['extra']['board']) ? 0 : (int) $log['extra']['board']; |
| 498 | 534 | unset($log['extra']['board']); |
| 535 | + } else { |
|
| 536 | + $board_id = 0; |
|
| 499 | 537 | } |
| 500 | - else |
|
| 501 | - $board_id = 0; |
|
| 502 | 538 | |
| 503 | 539 | if (isset($log['extra']['board_to'])) |
| 504 | 540 | { |
| 505 | - if (!is_numeric($log['extra']['board_to'])) |
|
| 506 | - trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
| 541 | + if (!is_numeric($log['extra']['board_to'])) { |
|
| 542 | + trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
| 543 | + } |
|
| 507 | 544 | if (empty($board_id)) |
| 508 | 545 | { |
| 509 | 546 | $board_id = empty($log['extra']['board_to']) ? 0 : (int) $log['extra']['board_to']; |
@@ -511,10 +548,11 @@ discard block |
||
| 511 | 548 | } |
| 512 | 549 | } |
| 513 | 550 | |
| 514 | - if (isset($log['extra']['member_affected'])) |
|
| 515 | - $memID = $log['extra']['member_affected']; |
|
| 516 | - else |
|
| 517 | - $memID = $user_info['id']; |
|
| 551 | + if (isset($log['extra']['member_affected'])) { |
|
| 552 | + $memID = $log['extra']['member_affected']; |
|
| 553 | + } else { |
|
| 554 | + $memID = $user_info['id']; |
|
| 555 | + } |
|
| 518 | 556 | |
| 519 | 557 | $inserts[] = array( |
| 520 | 558 | time(), $log_types[$log['log_type']], $memID, $user_info['ip'], $log['action'], |
@@ -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 | * Gets a single theme's info. |
@@ -27,8 +28,9 @@ discard block |
||
| 27 | 28 | global $smcFunc, $modSettings; |
| 28 | 29 | |
| 29 | 30 | // No data, no fun! |
| 30 | - if (empty($id)) |
|
| 31 | - return false; |
|
| 31 | + if (empty($id)) { |
|
| 32 | + return false; |
|
| 33 | + } |
|
| 32 | 34 | |
| 33 | 35 | // Make sure $id is an int. |
| 34 | 36 | $id = (int) $id; |
@@ -171,8 +173,9 @@ discard block |
||
| 171 | 173 | global $sourcedir, $forum_version, $txt, $scripturl, $context; |
| 172 | 174 | global $explicit_images; |
| 173 | 175 | |
| 174 | - if (empty($path)) |
|
| 175 | - return false; |
|
| 176 | + if (empty($path)) { |
|
| 177 | + return false; |
|
| 178 | + } |
|
| 176 | 179 | |
| 177 | 180 | $xml_data = array(); |
| 178 | 181 | $explicit_images = false; |
@@ -229,9 +232,10 @@ discard block |
||
| 229 | 232 | ); |
| 230 | 233 | |
| 231 | 234 | // Assign the values to be stored. |
| 232 | - foreach ($xml_elements as $var => $name) |
|
| 233 | - if (!empty($theme_info_xml[$name])) |
|
| 235 | + foreach ($xml_elements as $var => $name) { |
|
| 236 | + if (!empty($theme_info_xml[$name])) |
|
| 234 | 237 | $xml_data[$var] = $theme_info_xml[$name]; |
| 238 | + } |
|
| 235 | 239 | |
| 236 | 240 | // Add the supported versions. |
| 237 | 241 | $xml_data['install_for'] = $install_versions; |
@@ -243,8 +247,9 @@ discard block |
||
| 243 | 247 | $explicit_images = true; |
| 244 | 248 | } |
| 245 | 249 | |
| 246 | - if (!empty($theme_info_xml['extra'])) |
|
| 247 | - $xml_data += smf_json_decode($theme_info_xml['extra'], true); |
|
| 250 | + if (!empty($theme_info_xml['extra'])) { |
|
| 251 | + $xml_data += smf_json_decode($theme_info_xml['extra'], true); |
|
| 252 | + } |
|
| 248 | 253 | |
| 249 | 254 | return $xml_data; |
| 250 | 255 | } |
@@ -262,12 +267,14 @@ discard block |
||
| 262 | 267 | global $settings, $explicit_images; |
| 263 | 268 | |
| 264 | 269 | // External use? no problem! |
| 265 | - if ($to_install) |
|
| 266 | - $context['to_install'] = $to_install; |
|
| 270 | + if ($to_install) { |
|
| 271 | + $context['to_install'] = $to_install; |
|
| 272 | + } |
|
| 267 | 273 | |
| 268 | 274 | // One last check. |
| 269 | - if (empty($context['to_install']['theme_dir']) || basename($context['to_install']['theme_dir']) == 'Themes') |
|
| 270 | - fatal_lang_error('theme_install_invalid_dir', false); |
|
| 275 | + if (empty($context['to_install']['theme_dir']) || basename($context['to_install']['theme_dir']) == 'Themes') { |
|
| 276 | + fatal_lang_error('theme_install_invalid_dir', false); |
|
| 277 | + } |
|
| 271 | 278 | |
| 272 | 279 | // OK, is this a newer version of an already installed theme? |
| 273 | 280 | if (!empty($context['to_install']['version'])) |
@@ -292,8 +299,8 @@ discard block |
||
| 292 | 299 | $smcFunc['db_free_result']($request); |
| 293 | 300 | |
| 294 | 301 | // Got something, lets figure it out what to do next. |
| 295 | - if (!empty($to_update) && !empty($to_update['version'])) |
|
| 296 | - switch (compareVersions($context['to_install']['version'], $to_update['version'])) |
|
| 302 | + if (!empty($to_update) && !empty($to_update['version'])) { |
|
| 303 | + switch (compareVersions($context['to_install']['version'], $to_update['version'])) |
|
| 297 | 304 | { |
| 298 | 305 | case 1: // Got a newer version, update the old entry. |
| 299 | 306 | $smcFunc['db_query']('', ' |
@@ -307,6 +314,7 @@ discard block |
||
| 307 | 314 | 'id_theme' => $to_update['id_theme'], |
| 308 | 315 | ) |
| 309 | 316 | ); |
| 317 | + } |
|
| 310 | 318 | |
| 311 | 319 | // Done with the update, tell the user about it. |
| 312 | 320 | $context['to_install']['updated'] = true; |
@@ -372,13 +380,15 @@ discard block |
||
| 372 | 380 | $context['to_install']['base_theme_url'] = $temp['theme_url']; |
| 373 | 381 | $context['to_install']['base_theme_dir'] = $temp['theme_dir']; |
| 374 | 382 | |
| 375 | - if (empty($explicit_images) && !empty($context['to_install']['base_theme_url'])) |
|
| 376 | - $context['to_install']['theme_url'] = $context['to_install']['base_theme_url']; |
|
| 383 | + if (empty($explicit_images) && !empty($context['to_install']['base_theme_url'])) { |
|
| 384 | + $context['to_install']['theme_url'] = $context['to_install']['base_theme_url']; |
|
| 385 | + } |
|
| 377 | 386 | } |
| 378 | 387 | |
| 379 | 388 | // Nope, sorry, couldn't find any theme already installed. |
| 380 | - else |
|
| 381 | - fatal_lang_error('package_get_error_theme_no_based_on_found', false, $context['to_install']['based_on']); |
|
| 389 | + else { |
|
| 390 | + fatal_lang_error('package_get_error_theme_no_based_on_found', false, $context['to_install']['based_on']); |
|
| 391 | + } |
|
| 382 | 392 | } |
| 383 | 393 | |
| 384 | 394 | unset($context['to_install']['based_on']); |
@@ -401,16 +411,18 @@ discard block |
||
| 401 | 411 | call_integration_hook('integrate_theme_install', array(&$context['to_install'], $id_theme)); |
| 402 | 412 | |
| 403 | 413 | $inserts = array(); |
| 404 | - foreach ($context['to_install'] as $var => $val) |
|
| 405 | - $inserts[] = array($id_theme, $var, $val); |
|
| 414 | + foreach ($context['to_install'] as $var => $val) { |
|
| 415 | + $inserts[] = array($id_theme, $var, $val); |
|
| 416 | + } |
|
| 406 | 417 | |
| 407 | - if (!empty($inserts)) |
|
| 408 | - $smcFunc['db_insert']('insert', |
|
| 418 | + if (!empty($inserts)) { |
|
| 419 | + $smcFunc['db_insert']('insert', |
|
| 409 | 420 | '{db_prefix}themes', |
| 410 | 421 | array('id_theme' => 'int', 'variable' => 'string-255', 'value' => 'string-65534'), |
| 411 | 422 | $inserts, |
| 412 | 423 | array('id_theme', 'variable') |
| 413 | 424 | ); |
| 425 | + } |
|
| 414 | 426 | |
| 415 | 427 | // Update the known and enable Theme's settings. |
| 416 | 428 | $known = strtr($modSettings['knownThemes'] . ',' . $id_theme, array(',,' => ',')); |
@@ -429,21 +441,24 @@ discard block |
||
| 429 | 441 | */ |
| 430 | 442 | function remove_dir($path) |
| 431 | 443 | { |
| 432 | - if (empty($path)) |
|
| 433 | - return false; |
|
| 444 | + if (empty($path)) { |
|
| 445 | + return false; |
|
| 446 | + } |
|
| 434 | 447 | |
| 435 | 448 | if (is_dir($path)) |
| 436 | 449 | { |
| 437 | 450 | $objects = scandir($path); |
| 438 | 451 | |
| 439 | - foreach ($objects as $object) |
|
| 440 | - if ($object != '.' && $object != '..') |
|
| 452 | + foreach ($objects as $object) { |
|
| 453 | + if ($object != '.' && $object != '..') |
|
| 441 | 454 | { |
| 442 | 455 | if (filetype($path .'/'. $object) == 'dir') |
| 443 | 456 | remove_dir($path .'/'.$object); |
| 457 | + } |
|
| 444 | 458 | |
| 445 | - else |
|
| 446 | - unlink($path .'/'. $object); |
|
| 459 | + else { |
|
| 460 | + unlink($path .'/'. $object); |
|
| 461 | + } |
|
| 447 | 462 | } |
| 448 | 463 | } |
| 449 | 464 | |
@@ -462,8 +477,9 @@ discard block |
||
| 462 | 477 | global $smcFunc, $modSettings; |
| 463 | 478 | |
| 464 | 479 | // Can't delete the default theme, sorry! |
| 465 | - if (empty($themeID) || $themeID == 1) |
|
| 466 | - return false; |
|
| 480 | + if (empty($themeID) || $themeID == 1) { |
|
| 481 | + return false; |
|
| 482 | + } |
|
| 467 | 483 | |
| 468 | 484 | $known = explode(',', $modSettings['knownThemes']); |
| 469 | 485 | $enable = explode(',', $modSettings['enableThemes']); |
@@ -513,8 +529,9 @@ discard block |
||
| 513 | 529 | updateSettings(array('enableThemes' => $enable, 'knownThemes' => $known)); |
| 514 | 530 | |
| 515 | 531 | // Fix it if the theme was the overall default theme. |
| 516 | - if ($modSettings['theme_guests'] == $themeID) |
|
| 517 | - updateSettings(array('theme_guests' => '1')); |
|
| 532 | + if ($modSettings['theme_guests'] == $themeID) { |
|
| 533 | + updateSettings(array('theme_guests' => '1')); |
|
| 534 | + } |
|
| 518 | 535 | |
| 519 | 536 | return true; |
| 520 | 537 | } |
@@ -531,13 +548,15 @@ discard block |
||
| 531 | 548 | global $scripturl, $txt, $context; |
| 532 | 549 | |
| 533 | 550 | // Is it even a directory? |
| 534 | - if (!is_dir($path)) |
|
| 535 | - fatal_lang_error('error_invalid_dir', 'critical'); |
|
| 551 | + if (!is_dir($path)) { |
|
| 552 | + fatal_lang_error('error_invalid_dir', 'critical'); |
|
| 553 | + } |
|
| 536 | 554 | |
| 537 | 555 | $dir = dir($path); |
| 538 | 556 | $entries = array(); |
| 539 | - while ($entry = $dir->read()) |
|
| 540 | - $entries[] = $entry; |
|
| 557 | + while ($entry = $dir->read()) { |
|
| 558 | + $entries[] = $entry; |
|
| 559 | + } |
|
| 541 | 560 | $dir->close(); |
| 542 | 561 | |
| 543 | 562 | natcasesort($entries); |
@@ -548,11 +567,12 @@ discard block |
||
| 548 | 567 | foreach ($entries as $entry) |
| 549 | 568 | { |
| 550 | 569 | // Skip all dot files, including .htaccess. |
| 551 | - if (substr($entry, 0, 1) == '.' || $entry == 'CVS') |
|
| 552 | - continue; |
|
| 570 | + if (substr($entry, 0, 1) == '.' || $entry == 'CVS') { |
|
| 571 | + continue; |
|
| 572 | + } |
|
| 553 | 573 | |
| 554 | - if (is_dir($path . '/' . $entry)) |
|
| 555 | - $listing1[] = array( |
|
| 574 | + if (is_dir($path . '/' . $entry)) { |
|
| 575 | + $listing1[] = array( |
|
| 556 | 576 | 'filename' => $entry, |
| 557 | 577 | 'is_writable' => is_writable($path . '/' . $entry), |
| 558 | 578 | 'is_directory' => true, |
@@ -562,13 +582,14 @@ discard block |
||
| 562 | 582 | 'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $relative . $entry, |
| 563 | 583 | 'size' => '', |
| 564 | 584 | ); |
| 565 | - else |
|
| 585 | + } else |
|
| 566 | 586 | { |
| 567 | 587 | $size = filesize($path . '/' . $entry); |
| 568 | - if ($size > 2048 || $size == 1024) |
|
| 569 | - $size = comma_format($size / 1024) . ' ' . $txt['themeadmin_edit_kilobytes']; |
|
| 570 | - else |
|
| 571 | - $size = comma_format($size) . ' ' . $txt['themeadmin_edit_bytes']; |
|
| 588 | + if ($size > 2048 || $size == 1024) { |
|
| 589 | + $size = comma_format($size / 1024) . ' ' . $txt['themeadmin_edit_kilobytes']; |
|
| 590 | + } else { |
|
| 591 | + $size = comma_format($size) . ' ' . $txt['themeadmin_edit_bytes']; |
|
| 592 | + } |
|
| 572 | 593 | |
| 573 | 594 | $listing2[] = array( |
| 574 | 595 | 'filename' => $entry, |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Who's online, and what are they doing? |
@@ -35,8 +36,9 @@ discard block |
||
| 35 | 36 | isAllowedTo('who_view'); |
| 36 | 37 | |
| 37 | 38 | // You can't do anything if this is off. |
| 38 | - if (empty($modSettings['who_enabled'])) |
|
| 39 | - fatal_lang_error('who_off', false); |
|
| 39 | + if (empty($modSettings['who_enabled'])) { |
|
| 40 | + fatal_lang_error('who_off', false); |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | 43 | // Load the 'Who' template. |
| 42 | 44 | loadTemplate('Who'); |
@@ -71,9 +73,9 @@ discard block |
||
| 71 | 73 | $show_methods['spiders'] = '(lo.id_member = 0 AND lo.id_spider > 0)'; |
| 72 | 74 | $show_methods['guests'] = '(lo.id_member = 0 AND lo.id_spider = 0)'; |
| 73 | 75 | $context['show_methods']['spiders'] = $txt['who_show_spiders_only']; |
| 76 | + } elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') { |
|
| 77 | + unset($_SESSION['who_online_filter']); |
|
| 74 | 78 | } |
| 75 | - elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') |
|
| 76 | - unset($_SESSION['who_online_filter']); |
|
| 77 | 79 | |
| 78 | 80 | // Does the user prefer a different sort direction? |
| 79 | 81 | if (isset($_REQUEST['sort']) && isset($sort_methods[$_REQUEST['sort']])) |
@@ -97,20 +99,24 @@ discard block |
||
| 97 | 99 | $context['sort_direction'] = isset($_REQUEST['asc']) || (isset($_REQUEST['sort_dir']) && $_REQUEST['sort_dir'] == 'asc') ? 'up' : 'down'; |
| 98 | 100 | |
| 99 | 101 | $conditions = array(); |
| 100 | - if (!allowedTo('moderate_forum')) |
|
| 101 | - $conditions[] = '(COALESCE(mem.show_online, 1) = 1)'; |
|
| 102 | + if (!allowedTo('moderate_forum')) { |
|
| 103 | + $conditions[] = '(COALESCE(mem.show_online, 1) = 1)'; |
|
| 104 | + } |
|
| 102 | 105 | |
| 103 | 106 | // Fallback to top filter? |
| 104 | - if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) |
|
| 105 | - $_REQUEST['show'] = $_REQUEST['show_top']; |
|
| 107 | + if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) { |
|
| 108 | + $_REQUEST['show'] = $_REQUEST['show_top']; |
|
| 109 | + } |
|
| 106 | 110 | // Does the user wish to apply a filter? |
| 107 | - if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) |
|
| 108 | - $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show']; |
|
| 111 | + if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) { |
|
| 112 | + $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show']; |
|
| 113 | + } |
|
| 109 | 114 | // Perhaps we saved a filter earlier in the session? |
| 110 | - elseif (isset($_SESSION['who_online_filter'])) |
|
| 111 | - $context['show_by'] = $_SESSION['who_online_filter']; |
|
| 112 | - else |
|
| 113 | - $context['show_by'] = 'members'; |
|
| 115 | + elseif (isset($_SESSION['who_online_filter'])) { |
|
| 116 | + $context['show_by'] = $_SESSION['who_online_filter']; |
|
| 117 | + } else { |
|
| 118 | + $context['show_by'] = 'members'; |
|
| 119 | + } |
|
| 114 | 120 | |
| 115 | 121 | $conditions[] = $show_methods[$context['show_by']]; |
| 116 | 122 | |
@@ -156,8 +162,9 @@ discard block |
||
| 156 | 162 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 157 | 163 | { |
| 158 | 164 | $actions = smf_json_decode($row['url'], true); |
| 159 | - if ($actions === false) |
|
| 160 | - continue; |
|
| 165 | + if ($actions === false) { |
|
| 166 | + continue; |
|
| 167 | + } |
|
| 161 | 168 | |
| 162 | 169 | // Send the information to the template. |
| 163 | 170 | $context['members'][$row['session']] = array( |
@@ -195,8 +202,8 @@ discard block |
||
| 195 | 202 | $spiderContext = array(); |
| 196 | 203 | if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) |
| 197 | 204 | { |
| 198 | - foreach (smf_json_decode($modSettings['spider_name_cache'], true) as $id => $name) |
|
| 199 | - $spiderContext[$id] = array( |
|
| 205 | + foreach (smf_json_decode($modSettings['spider_name_cache'], true) as $id => $name) { |
|
| 206 | + $spiderContext[$id] = array( |
|
| 200 | 207 | 'id' => 0, |
| 201 | 208 | 'name' => $name, |
| 202 | 209 | 'group' => $txt['spiders'], |
@@ -205,6 +212,7 @@ discard block |
||
| 205 | 212 | 'email' => $name, |
| 206 | 213 | 'is_guest' => true |
| 207 | 214 | ); |
| 215 | + } |
|
| 208 | 216 | } |
| 209 | 217 | |
| 210 | 218 | $url_data = determineActions($url_data); |
@@ -219,16 +227,18 @@ discard block |
||
| 219 | 227 | // Put it in the context variables. |
| 220 | 228 | foreach ($context['members'] as $i => $member) |
| 221 | 229 | { |
| 222 | - if ($member['id'] != 0) |
|
| 223 | - $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0; |
|
| 230 | + if ($member['id'] != 0) { |
|
| 231 | + $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0; |
|
| 232 | + } |
|
| 224 | 233 | |
| 225 | 234 | // Keep the IP that came from the database. |
| 226 | 235 | $memberContext[$member['id']]['ip'] = $member['ip']; |
| 227 | 236 | $context['members'][$i]['action'] = isset($url_data[$i]) ? $url_data[$i] : $txt['who_hidden']; |
| 228 | - if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) |
|
| 229 | - $context['members'][$i] += $spiderContext[$member['id_spider']]; |
|
| 230 | - else |
|
| 231 | - $context['members'][$i] += $memberContext[$member['id']]; |
|
| 237 | + if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) { |
|
| 238 | + $context['members'][$i] += $spiderContext[$member['id_spider']]; |
|
| 239 | + } else { |
|
| 240 | + $context['members'][$i] += $memberContext[$member['id']]; |
|
| 241 | + } |
|
| 232 | 242 | } |
| 233 | 243 | |
| 234 | 244 | // Some people can't send personal messages... |
@@ -263,8 +273,9 @@ discard block |
||
| 263 | 273 | { |
| 264 | 274 | global $txt, $user_info, $modSettings, $smcFunc; |
| 265 | 275 | |
| 266 | - if (!allowedTo('who_view')) |
|
| 267 | - return array(); |
|
| 276 | + if (!allowedTo('who_view')) { |
|
| 277 | + return array(); |
|
| 278 | + } |
|
| 268 | 279 | loadLanguage('Who'); |
| 269 | 280 | |
| 270 | 281 | // Actions that require a specific permission level. |
@@ -292,10 +303,11 @@ discard block |
||
| 292 | 303 | ); |
| 293 | 304 | call_integration_hook('who_allowed', array(&$allowedActions)); |
| 294 | 305 | |
| 295 | - if (!is_array($urls)) |
|
| 296 | - $url_list = array(array($urls, $user_info['id'])); |
|
| 297 | - else |
|
| 298 | - $url_list = $urls; |
|
| 306 | + if (!is_array($urls)) { |
|
| 307 | + $url_list = array(array($urls, $user_info['id'])); |
|
| 308 | + } else { |
|
| 309 | + $url_list = $urls; |
|
| 310 | + } |
|
| 299 | 311 | |
| 300 | 312 | // These are done to later query these in large chunks. (instead of one by one.) |
| 301 | 313 | $topic_ids = array(); |
@@ -307,12 +319,14 @@ discard block |
||
| 307 | 319 | { |
| 308 | 320 | // Get the request parameters.. |
| 309 | 321 | $actions = smf_json_decode($url[0], true); |
| 310 | - if ($actions === false) |
|
| 311 | - continue; |
|
| 322 | + if ($actions === false) { |
|
| 323 | + continue; |
|
| 324 | + } |
|
| 312 | 325 | |
| 313 | 326 | // If it's the admin or moderation center, and there is an area set, use that instead. |
| 314 | - if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area'])) |
|
| 315 | - $actions['action'] = $actions['area']; |
|
| 327 | + if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area'])) { |
|
| 328 | + $actions['action'] = $actions['area']; |
|
| 329 | + } |
|
| 316 | 330 | |
| 317 | 331 | // Check if there was no action or the action is display. |
| 318 | 332 | if (!isset($actions['action']) || $actions['action'] == 'display') |
@@ -332,12 +346,14 @@ discard block |
||
| 332 | 346 | $board_ids[$actions['board']][$k] = $txt['who_board']; |
| 333 | 347 | } |
| 334 | 348 | // It's the board index!! It must be! |
| 335 | - else |
|
| 336 | - $data[$k] = $txt['who_index']; |
|
| 349 | + else { |
|
| 350 | + $data[$k] = $txt['who_index']; |
|
| 351 | + } |
|
| 337 | 352 | } |
| 338 | 353 | // Probably an error or some goon? |
| 339 | - elseif ($actions['action'] == '') |
|
| 340 | - $data[$k] = $txt['who_index']; |
|
| 354 | + elseif ($actions['action'] == '') { |
|
| 355 | + $data[$k] = $txt['who_index']; |
|
| 356 | + } |
|
| 341 | 357 | // Some other normal action...? |
| 342 | 358 | else |
| 343 | 359 | { |
@@ -345,23 +361,25 @@ discard block |
||
| 345 | 361 | if ($actions['action'] == 'profile') |
| 346 | 362 | { |
| 347 | 363 | // Whose? Their own? |
| 348 | - if (empty($actions['u'])) |
|
| 349 | - $actions['u'] = $url[1]; |
|
| 364 | + if (empty($actions['u'])) { |
|
| 365 | + $actions['u'] = $url[1]; |
|
| 366 | + } |
|
| 350 | 367 | |
| 351 | 368 | $data[$k] = $txt['who_hidden']; |
| 352 | 369 | $profile_ids[(int) $actions['u']][$k] = $actions['u'] == $url[1] ? $txt['who_viewownprofile'] : $txt['who_viewprofile']; |
| 353 | - } |
|
| 354 | - elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board'])) |
|
| 370 | + } elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board'])) |
|
| 355 | 371 | { |
| 356 | 372 | $data[$k] = $txt['who_hidden']; |
| 357 | 373 | $board_ids[(int) $actions['board']][$k] = isset($actions['poll']) ? $txt['who_poll'] : $txt['who_post']; |
| 358 | 374 | } |
| 359 | 375 | // A subaction anyone can view... if the language string is there, show it. |
| 360 | - elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']])) |
|
| 361 | - $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']]; |
|
| 376 | + elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']])) { |
|
| 377 | + $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']]; |
|
| 378 | + } |
|
| 362 | 379 | // An action any old fellow can look at. (if ['whoall_' . $action] exists, we know everyone can see it.) |
| 363 | - elseif (isset($txt['whoall_' . $actions['action']])) |
|
| 364 | - $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']]; |
|
| 380 | + elseif (isset($txt['whoall_' . $actions['action']])) { |
|
| 381 | + $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']]; |
|
| 382 | + } |
|
| 365 | 383 | // Viewable if and only if they can see the board... |
| 366 | 384 | elseif (isset($txt['whotopic_' . $actions['action']])) |
| 367 | 385 | { |
@@ -370,8 +388,7 @@ discard block |
||
| 370 | 388 | |
| 371 | 389 | $data[$k] = $txt['who_hidden']; |
| 372 | 390 | $topic_ids[$topic][$k] = $txt['whotopic_' . $actions['action']]; |
| 373 | - } |
|
| 374 | - elseif (isset($txt['whopost_' . $actions['action']])) |
|
| 391 | + } elseif (isset($txt['whopost_' . $actions['action']])) |
|
| 375 | 392 | { |
| 376 | 393 | // Find out what message they are accessing. |
| 377 | 394 | $msgid = (int) (isset($actions['msg']) ? $actions['msg'] : (isset($actions['quote']) ? $actions['quote'] : 0)); |
@@ -394,41 +411,46 @@ discard block |
||
| 394 | 411 | $data[$k] = sprintf($txt['whopost_' . $actions['action']], $id_topic, $subject); |
| 395 | 412 | $smcFunc['db_free_result']($result); |
| 396 | 413 | |
| 397 | - if (empty($id_topic)) |
|
| 398 | - $data[$k] = $txt['who_hidden']; |
|
| 414 | + if (empty($id_topic)) { |
|
| 415 | + $data[$k] = $txt['who_hidden']; |
|
| 416 | + } |
|
| 399 | 417 | } |
| 400 | 418 | // Viewable only by administrators.. (if it starts with whoadmin, it's admin only!) |
| 401 | - elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']])) |
|
| 402 | - $data[$k] = $txt['whoadmin_' . $actions['action']]; |
|
| 419 | + elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']])) { |
|
| 420 | + $data[$k] = $txt['whoadmin_' . $actions['action']]; |
|
| 421 | + } |
|
| 403 | 422 | // Viewable by permission level. |
| 404 | 423 | elseif (isset($allowedActions[$actions['action']])) |
| 405 | 424 | { |
| 406 | - if (allowedTo($allowedActions[$actions['action']])) |
|
| 407 | - $data[$k] = $txt['whoallow_' . $actions['action']]; |
|
| 408 | - elseif (in_array('moderate_forum', $allowedActions[$actions['action']])) |
|
| 409 | - $data[$k] = $txt['who_moderate']; |
|
| 410 | - elseif (in_array('admin_forum', $allowedActions[$actions['action']])) |
|
| 411 | - $data[$k] = $txt['who_admin']; |
|
| 412 | - else |
|
| 413 | - $data[$k] = $txt['who_hidden']; |
|
| 425 | + if (allowedTo($allowedActions[$actions['action']])) { |
|
| 426 | + $data[$k] = $txt['whoallow_' . $actions['action']]; |
|
| 427 | + } elseif (in_array('moderate_forum', $allowedActions[$actions['action']])) { |
|
| 428 | + $data[$k] = $txt['who_moderate']; |
|
| 429 | + } elseif (in_array('admin_forum', $allowedActions[$actions['action']])) { |
|
| 430 | + $data[$k] = $txt['who_admin']; |
|
| 431 | + } else { |
|
| 432 | + $data[$k] = $txt['who_hidden']; |
|
| 433 | + } |
|
| 434 | + } elseif (!empty($actions['action'])) { |
|
| 435 | + $data[$k] = $txt['who_generic'] . ' ' . $actions['action']; |
|
| 436 | + } else { |
|
| 437 | + $data[$k] = $txt['who_unknown']; |
|
| 414 | 438 | } |
| 415 | - elseif (!empty($actions['action'])) |
|
| 416 | - $data[$k] = $txt['who_generic'] . ' ' . $actions['action']; |
|
| 417 | - else |
|
| 418 | - $data[$k] = $txt['who_unknown']; |
|
| 419 | 439 | } |
| 420 | 440 | |
| 421 | 441 | if (isset($actions['error'])) |
| 422 | 442 | { |
| 423 | - if (isset($txt[$actions['error']])) |
|
| 424 | - $error_message = str_replace('"', '"', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params'])); |
|
| 425 | - elseif ($actions['error'] == 'guest_login') |
|
| 426 | - $error_message = str_replace('"', '"', $txt['who_guest_login']); |
|
| 427 | - else |
|
| 428 | - $error_message = str_replace('"', '"', $actions['error']); |
|
| 429 | - |
|
| 430 | - if (!empty($error_message)) |
|
| 431 | - $data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>'; |
|
| 443 | + if (isset($txt[$actions['error']])) { |
|
| 444 | + $error_message = str_replace('"', '"', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params'])); |
|
| 445 | + } elseif ($actions['error'] == 'guest_login') { |
|
| 446 | + $error_message = str_replace('"', '"', $txt['who_guest_login']); |
|
| 447 | + } else { |
|
| 448 | + $error_message = str_replace('"', '"', $actions['error']); |
|
| 449 | + } |
|
| 450 | + |
|
| 451 | + if (!empty($error_message)) { |
|
| 452 | + $data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>'; |
|
| 453 | + } |
|
| 432 | 454 | } |
| 433 | 455 | |
| 434 | 456 | // Maybe the action is integrated into another system? |
@@ -439,12 +461,15 @@ discard block |
||
| 439 | 461 | if (!empty($integrate_action)) |
| 440 | 462 | { |
| 441 | 463 | $data[$k] = $integrate_action; |
| 442 | - if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k])) |
|
| 443 | - $topic_ids[(int) $actions['topic']][$k] = $integrate_action; |
|
| 444 | - if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k])) |
|
| 445 | - $board_ids[(int) $actions['board']][$k] = $integrate_action; |
|
| 446 | - if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k])) |
|
| 447 | - $profile_ids[(int) $actions['u']][$k] = $integrate_action; |
|
| 464 | + if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k])) { |
|
| 465 | + $topic_ids[(int) $actions['topic']][$k] = $integrate_action; |
|
| 466 | + } |
|
| 467 | + if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k])) { |
|
| 468 | + $board_ids[(int) $actions['board']][$k] = $integrate_action; |
|
| 469 | + } |
|
| 470 | + if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k])) { |
|
| 471 | + $profile_ids[(int) $actions['u']][$k] = $integrate_action; |
|
| 472 | + } |
|
| 448 | 473 | break; |
| 449 | 474 | } |
| 450 | 475 | } |
@@ -472,8 +497,9 @@ discard block |
||
| 472 | 497 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 473 | 498 | { |
| 474 | 499 | // Show the topic's subject for each of the actions. |
| 475 | - foreach ($topic_ids[$row['id_topic']] as $k => $session_text) |
|
| 476 | - $data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject'])); |
|
| 500 | + foreach ($topic_ids[$row['id_topic']] as $k => $session_text) { |
|
| 501 | + $data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject'])); |
|
| 502 | + } |
|
| 477 | 503 | } |
| 478 | 504 | $smcFunc['db_free_result']($result); |
| 479 | 505 | } |
@@ -495,8 +521,9 @@ discard block |
||
| 495 | 521 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 496 | 522 | { |
| 497 | 523 | // Put the board name into the string for each member... |
| 498 | - foreach ($board_ids[$row['id_board']] as $k => $session_text) |
|
| 499 | - $data[$k] = sprintf($session_text, $row['id_board'], $row['name']); |
|
| 524 | + foreach ($board_ids[$row['id_board']] as $k => $session_text) { |
|
| 525 | + $data[$k] = sprintf($session_text, $row['id_board'], $row['name']); |
|
| 526 | + } |
|
| 500 | 527 | } |
| 501 | 528 | $smcFunc['db_free_result']($result); |
| 502 | 529 | } |
@@ -518,23 +545,26 @@ discard block |
||
| 518 | 545 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 519 | 546 | { |
| 520 | 547 | // If they aren't allowed to view this person's profile, skip it. |
| 521 | - if (!$allow_view_any && ($user_info['id'] != $row['id_member'])) |
|
| 522 | - continue; |
|
| 548 | + if (!$allow_view_any && ($user_info['id'] != $row['id_member'])) { |
|
| 549 | + continue; |
|
| 550 | + } |
|
| 523 | 551 | |
| 524 | 552 | // Set their action on each - session/text to sprintf. |
| 525 | - foreach ($profile_ids[$row['id_member']] as $k => $session_text) |
|
| 526 | - $data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']); |
|
| 553 | + foreach ($profile_ids[$row['id_member']] as $k => $session_text) { |
|
| 554 | + $data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']); |
|
| 555 | + } |
|
| 527 | 556 | } |
| 528 | 557 | $smcFunc['db_free_result']($result); |
| 529 | 558 | } |
| 530 | 559 | |
| 531 | 560 | call_integration_hook('whos_online_after', array(&$urls, &$data)); |
| 532 | 561 | |
| 533 | - if (!is_array($urls)) |
|
| 534 | - return isset($data[0]) ? $data[0] : false; |
|
| 535 | - else |
|
| 536 | - return $data; |
|
| 537 | -} |
|
| 562 | + if (!is_array($urls)) { |
|
| 563 | + return isset($data[0]) ? $data[0] : false; |
|
| 564 | + } else { |
|
| 565 | + return $data; |
|
| 566 | + } |
|
| 567 | + } |
|
| 538 | 568 | |
| 539 | 569 | /** |
| 540 | 570 | * It prepares credit and copyright information for the credits page or the admin page |
@@ -709,8 +739,8 @@ discard block |
||
| 709 | 739 | ); |
| 710 | 740 | |
| 711 | 741 | // Give the translators some credit for their hard work. |
| 712 | - if (!empty($txt['translation_credits'])) |
|
| 713 | - $context['credits'][] = array( |
|
| 742 | + if (!empty($txt['translation_credits'])) { |
|
| 743 | + $context['credits'][] = array( |
|
| 714 | 744 | 'title' => $txt['credits_groups_translation'], |
| 715 | 745 | 'groups' => array( |
| 716 | 746 | array( |
@@ -719,6 +749,7 @@ discard block |
||
| 719 | 749 | ), |
| 720 | 750 | ), |
| 721 | 751 | ); |
| 752 | + } |
|
| 722 | 753 | |
| 723 | 754 | $context['credits'][] = array( |
| 724 | 755 | 'title' => $txt['credits_special'], |
@@ -793,7 +793,7 @@ discard block |
||
| 793 | 793 | if (!$this->connection) |
| 794 | 794 | { |
| 795 | 795 | $this->error = 'bad_server'; |
| 796 | - $this->last_message = 'Invalid Server'; |
|
| 796 | + $this->last_message = 'Invalid Server'; |
|
| 797 | 797 | return; |
| 798 | 798 | } |
| 799 | 799 | |
@@ -801,7 +801,7 @@ discard block |
||
| 801 | 801 | if (!$this->check_response(220)) |
| 802 | 802 | { |
| 803 | 803 | $this->error = 'bad_response'; |
| 804 | - $this->last_message = 'Bad Response'; |
|
| 804 | + $this->last_message = 'Bad Response'; |
|
| 805 | 805 | return; |
| 806 | 806 | } |
| 807 | 807 | |