@@ -22,24 +22,26 @@ discard block |
||
22 | 22 | <script>'; |
23 | 23 | |
24 | 24 | // When using Go Back due to fatal_error, allow the form to be re-submitted with changes. |
25 | - if (isBrowser('is_firefox')) |
|
26 | - echo ' |
|
25 | + if (isBrowser('is_firefox')) { |
|
26 | + echo ' |
|
27 | 27 | window.addEventListener("pageshow", reActivate, false);'; |
28 | + } |
|
28 | 29 | |
29 | 30 | // Start with message icons - and any missing from this theme. |
30 | 31 | echo ' |
31 | 32 | var icon_urls = {'; |
32 | 33 | |
33 | - foreach ($context['icons'] as $icon) |
|
34 | - echo ' |
|
34 | + foreach ($context['icons'] as $icon) { |
|
35 | + echo ' |
|
35 | 36 | \'', $icon['value'], '\': \'', $icon['url'], '\'', $icon['is_last'] ? '' : ','; |
37 | + } |
|
36 | 38 | |
37 | 39 | echo ' |
38 | 40 | };'; |
39 | 41 | |
40 | 42 | // If this is a poll - use some javascript to ensure the user doesn't create a poll with illegal option combinations. |
41 | - if ($context['make_poll']) |
|
42 | - echo ' |
|
43 | + if ($context['make_poll']) { |
|
44 | + echo ' |
|
43 | 45 | var pollOptionNum = 0, pollTabIndex; |
44 | 46 | var pollOptionId = ', $context['last_choice_id'], '; |
45 | 47 | function addPollOption() |
@@ -58,11 +60,13 @@ discard block |
||
58 | 60 | |
59 | 61 | setOuterHTML(document.getElementById(\'pollMoreOptions\'), ', JavaScriptEscape('<dt><label for="options-'), ' + pollOptionId + ', JavaScriptEscape('">' . $txt['option'] . ' '), ' + pollOptionNum + ', JavaScriptEscape('</label>:</dt><dd><input type="text" name="options['), ' + pollOptionId + ', JavaScriptEscape(']" id="options-'), ' + pollOptionId + ', JavaScriptEscape('" value="" size="80" maxlength="255" tabindex="'), ' + pollTabIndex + ', JavaScriptEscape('"></dd><p id="pollMoreOptions"></p>'), '); |
60 | 62 | }'; |
63 | + } |
|
61 | 64 | |
62 | 65 | // If we are making a calendar event we want to ensure we show the current days in a month etc... this is done here. |
63 | - if ($context['make_event']) |
|
64 | - echo ' |
|
66 | + if ($context['make_event']) { |
|
67 | + echo ' |
|
65 | 68 | var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];'; |
69 | + } |
|
66 | 70 | |
67 | 71 | // End of the javascript, start the form and display the link tree. |
68 | 72 | echo ' |
@@ -83,9 +87,10 @@ discard block |
||
83 | 87 | </div> |
84 | 88 | <br>'; |
85 | 89 | |
86 | - if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board']))) |
|
87 | - echo ' |
|
90 | + if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board']))) { |
|
91 | + echo ' |
|
88 | 92 | <input type="hidden" name="eventid" value="', $context['event']['id'], '">'; |
93 | + } |
|
89 | 94 | |
90 | 95 | // Start the main table. |
91 | 96 | echo ' |
@@ -110,26 +115,29 @@ discard block |
||
110 | 115 | </div>'; |
111 | 116 | |
112 | 117 | // If this won't be approved let them know! |
113 | - if (!$context['becomes_approved']) |
|
114 | - echo ' |
|
118 | + if (!$context['becomes_approved']) { |
|
119 | + echo ' |
|
115 | 120 | <div class="noticebox"> |
116 | 121 | <em>', $txt['wait_for_approval'], '</em> |
117 | 122 | <input type="hidden" name="not_approved" value="1"> |
118 | 123 | </div>'; |
124 | + } |
|
119 | 125 | |
120 | 126 | // If it's locked, show a message to warn the replier. |
121 | - if (!empty($context['locked'])) |
|
122 | - echo ' |
|
127 | + if (!empty($context['locked'])) { |
|
128 | + echo ' |
|
123 | 129 | <div class="errorbox"> |
124 | 130 | ', $txt['topic_locked_no_reply'], ' |
125 | 131 | </div>'; |
132 | + } |
|
126 | 133 | |
127 | - if (!empty($modSettings['drafts_post_enabled'])) |
|
128 | - echo ' |
|
134 | + if (!empty($modSettings['drafts_post_enabled'])) { |
|
135 | + echo ' |
|
129 | 136 | <div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>', |
130 | 137 | sprintf($txt['draft_saved'], $scripturl . '?action=profile;u=' . $context['user']['id'] . ';area=showdrafts'), ' |
131 | 138 | ', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), ' |
132 | 139 | </div>'; |
140 | + } |
|
133 | 141 | |
134 | 142 | // The post header... important stuff |
135 | 143 | template_post_header(); |
@@ -162,9 +170,10 @@ discard block |
||
162 | 170 | echo ' |
163 | 171 | <optgroup label="', $category['name'], '">'; |
164 | 172 | |
165 | - foreach ($category['boards'] as $board) |
|
166 | - echo ' |
|
173 | + foreach ($category['boards'] as $board) { |
|
174 | + echo ' |
|
167 | 175 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=>' : '', ' ', $board['name'], '</option>'; |
176 | + } |
|
168 | 177 | echo ' |
169 | 178 | </optgroup>'; |
170 | 179 | } |
@@ -200,9 +209,10 @@ discard block |
||
200 | 209 | <span class="label">', $txt['calendar_timezone'], '</span> |
201 | 210 | <select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>'; |
202 | 211 | |
203 | - foreach ($context['all_timezones'] as $tz => $tzname) |
|
204 | - echo ' |
|
212 | + foreach ($context['all_timezones'] as $tz => $tzname) { |
|
213 | + echo ' |
|
205 | 214 | <option', is_numeric($tz) ? ' value="" disabled' : ' value="' . $tz . '"', $tz === $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>'; |
215 | + } |
|
206 | 216 | |
207 | 217 | echo ' |
208 | 218 | </select> |
@@ -231,14 +241,15 @@ discard block |
||
231 | 241 | </dd>'; |
232 | 242 | |
233 | 243 | // Loop through all the choices and print them out. |
234 | - foreach ($context['choices'] as $choice) |
|
235 | - echo ' |
|
244 | + foreach ($context['choices'] as $choice) { |
|
245 | + echo ' |
|
236 | 246 | <dt> |
237 | 247 | <label for="options-', $choice['id'], '">', $txt['option'], ' ', $choice['number'], '</label>: |
238 | 248 | </dt> |
239 | 249 | <dd> |
240 | 250 | <input type="text" name="options[', $choice['id'], ']" id="options-', $choice['id'], '" value="', $choice['label'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="255"> |
241 | 251 | </dd>'; |
252 | + } |
|
242 | 253 | |
243 | 254 | echo ' |
244 | 255 | <p id="pollMoreOptions"></p> |
@@ -268,14 +279,15 @@ discard block |
||
268 | 279 | <input type="checkbox" id="poll_change_vote" name="poll_change_vote"', !empty($context['poll']['change_vote']) ? ' checked' : '', '> |
269 | 280 | </dd>'; |
270 | 281 | |
271 | - if ($context['poll_options']['guest_vote_enabled']) |
|
272 | - echo ' |
|
282 | + if ($context['poll_options']['guest_vote_enabled']) { |
|
283 | + echo ' |
|
273 | 284 | <dt> |
274 | 285 | <label for="poll_guest_vote">', $txt['poll_guest_vote'], ':</label> |
275 | 286 | </dt> |
276 | 287 | <dd> |
277 | 288 | <input type="checkbox" id="poll_guest_vote" name="poll_guest_vote"', !empty($context['poll_options']['guest_vote']) ? ' checked' : '', '> |
278 | 289 | </dd>'; |
290 | + } |
|
279 | 291 | |
280 | 292 | echo ' |
281 | 293 | <dt> |
@@ -296,8 +308,8 @@ discard block |
||
296 | 308 | ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'); |
297 | 309 | |
298 | 310 | // If we're editing and displaying edit details, show a box where they can say why |
299 | - if (isset($context['editing']) && $modSettings['show_modify']) |
|
300 | - echo ' |
|
311 | + if (isset($context['editing']) && $modSettings['show_modify']) { |
|
312 | + echo ' |
|
301 | 313 | <dl> |
302 | 314 | <dt class="clear"> |
303 | 315 | <span id="caption_edit_reason">', $txt['reason_for_edit'], ':</span> |
@@ -306,20 +318,23 @@ discard block |
||
306 | 318 | <input type="text" name="modify_reason"', isset($context['last_modified_reason']) ? ' value="' . $context['last_modified_reason'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80"> |
307 | 319 | </dd> |
308 | 320 | </dl>'; |
321 | + } |
|
309 | 322 | |
310 | 323 | // If this message has been edited in the past - display when it was. |
311 | - if (isset($context['last_modified'])) |
|
312 | - echo ' |
|
324 | + if (isset($context['last_modified'])) { |
|
325 | + echo ' |
|
313 | 326 | <div class="padding smalltext"> |
314 | 327 | ', $context['last_modified_text'], ' |
315 | 328 | </div>'; |
329 | + } |
|
316 | 330 | |
317 | 331 | // If the admin has enabled the hiding of the additional options - show a link and image for it. |
318 | - if (!empty($modSettings['additional_options_collapsable'])) |
|
319 | - echo ' |
|
332 | + if (!empty($modSettings['additional_options_collapsable'])) { |
|
333 | + echo ' |
|
320 | 334 | <div id="postAdditionalOptionsHeader"> |
321 | 335 | <strong><a href="#" id="postMoreExpandLink"> ', $context['can_post_attachment'] ? $txt['post_additionalopt_attach'] : $txt['post_additionalopt'], '</a></strong> |
322 | 336 | </div>'; |
337 | + } |
|
323 | 338 | |
324 | 339 | echo ' |
325 | 340 | <div id="postAdditionalOptions">'; |
@@ -352,19 +367,21 @@ discard block |
||
352 | 367 | ', $txt['uncheck_unwatchd_attach'], ': |
353 | 368 | </dd>'; |
354 | 369 | |
355 | - foreach ($context['current_attachments'] as $attachment) |
|
356 | - echo ' |
|
370 | + foreach ($context['current_attachments'] as $attachment) { |
|
371 | + echo ' |
|
357 | 372 | <dd class="smalltext"> |
358 | 373 | <label for="attachment_', $attachment['attachID'], '"><input type="checkbox" id="attachment_', $attachment['attachID'], '" name="attach_del[]" value="', $attachment['attachID'], '"', empty($attachment['unchecked']) ? ' checked' : '', '> ', $attachment['name'], (empty($attachment['approved']) ? ' (' . $txt['awaiting_approval'] . ')' : ''), |
359 | 374 | !empty($modSettings['attachmentPostLimit']) || !empty($modSettings['attachmentSizeLimit']) ? sprintf($txt['attach_kb'], comma_format(round(max($attachment['size'], 1024) / 1024), 0)) : '', '</label> |
360 | 375 | </dd>'; |
376 | + } |
|
361 | 377 | |
362 | 378 | echo ' |
363 | 379 | </dl>'; |
364 | 380 | |
365 | - if (!empty($context['files_in_session_warning'])) |
|
366 | - echo ' |
|
381 | + if (!empty($context['files_in_session_warning'])) { |
|
382 | + echo ' |
|
367 | 383 | <div class="smalltext">', $context['files_in_session_warning'], '</div>'; |
384 | + } |
|
368 | 385 | } |
369 | 386 | |
370 | 387 | // Is the user allowed to post any additional ones? If so give them the boxes to do it! |
@@ -429,13 +446,14 @@ discard block |
||
429 | 446 | <div class="fallback"> |
430 | 447 | <input type="file" multiple="multiple" name="attachment[]" id="attachment1" class="fallback"> (<a href="javascript:void(0);" onclick="cleanFileInput(\'attachment1\');">', $txt['clean_attach'], '</a>)'; |
431 | 448 | |
432 | - if (!empty($modSettings['attachmentSizeLimit'])) |
|
433 | - echo ' |
|
449 | + if (!empty($modSettings['attachmentSizeLimit'])) { |
|
450 | + echo ' |
|
434 | 451 | <input type="hidden" name="MAX_FILE_SIZE" value="' . $modSettings['attachmentSizeLimit'] * 1024 . '">'; |
452 | + } |
|
435 | 453 | |
436 | 454 | // Show more boxes if they aren't approaching that limit. |
437 | - if ($context['num_allowed_attachments'] > 1) |
|
438 | - echo ' |
|
455 | + if ($context['num_allowed_attachments'] > 1) { |
|
456 | + echo ' |
|
439 | 457 | <script> |
440 | 458 | var allowed_attachments = ', $context['num_allowed_attachments'], '; |
441 | 459 | var current_attachment = 1; |
@@ -455,6 +473,7 @@ discard block |
||
455 | 473 | <a href="#" onclick="addAttachment(); return false;">(', $txt['more_attachments'], ')</a> |
456 | 474 | </div><!-- .fallback --> |
457 | 475 | </div><!-- #attachUpload -->'; |
476 | + } |
|
458 | 477 | |
459 | 478 | echo ' |
460 | 479 | </dd>'; |
@@ -466,21 +485,25 @@ discard block |
||
466 | 485 | <dd class="smalltext">'; |
467 | 486 | |
468 | 487 | // Show some useful information such as allowed extensions, maximum size and amount of attachments allowed. |
469 | - if (!empty($modSettings['attachmentCheckExtensions'])) |
|
470 | - echo ' |
|
488 | + if (!empty($modSettings['attachmentCheckExtensions'])) { |
|
489 | + echo ' |
|
471 | 490 | ', $txt['allowed_types'], ': ', $context['allowed_extensions'], '<br>'; |
491 | + } |
|
472 | 492 | |
473 | - if (!empty($context['attachment_restrictions'])) |
|
474 | - echo ' |
|
493 | + if (!empty($context['attachment_restrictions'])) { |
|
494 | + echo ' |
|
475 | 495 | ', $txt['attach_restrictions'], ' ', implode(', ', $context['attachment_restrictions']), '<br>'; |
496 | + } |
|
476 | 497 | |
477 | - if ($context['num_allowed_attachments'] == 0) |
|
478 | - echo ' |
|
498 | + if ($context['num_allowed_attachments'] == 0) { |
|
499 | + echo ' |
|
479 | 500 | ', $txt['attach_limit_nag'], '<br>'; |
501 | + } |
|
480 | 502 | |
481 | - if (!$context['can_post_attachment_unapproved']) |
|
482 | - echo ' |
|
503 | + if (!$context['can_post_attachment_unapproved']) { |
|
504 | + echo ' |
|
483 | 505 | <span class="alert">', $txt['attachment_requires_approval'], '</span>', '<br>'; |
506 | + } |
|
484 | 507 | |
485 | 508 | echo ' |
486 | 509 | </dd> |
@@ -504,24 +527,26 @@ discard block |
||
504 | 527 | <dt><strong>', $txt['subject'], '</strong></dt> |
505 | 528 | <dd><strong>', $txt['draft_saved_on'], '</strong></dd>'; |
506 | 529 | |
507 | - foreach ($context['drafts'] as $draft) |
|
508 | - echo ' |
|
530 | + foreach ($context['drafts'] as $draft) { |
|
531 | + echo ' |
|
509 | 532 | <dt>', $draft['link'], '</dt> |
510 | 533 | <dd>', $draft['poster_time'], '</dd>'; |
534 | + } |
|
511 | 535 | echo ' |
512 | 536 | </dl> |
513 | 537 | </div>'; |
514 | 538 | } |
515 | 539 | |
516 | 540 | // Is visual verification enabled? |
517 | - if ($context['require_verification']) |
|
518 | - echo ' |
|
541 | + if ($context['require_verification']) { |
|
542 | + echo ' |
|
519 | 543 | <div class="post_verification"> |
520 | 544 | <span', !empty($context['post_error']['need_qr_verification']) ? ' class="error"' : '', '> |
521 | 545 | <strong>', $txt['verification'], ':</strong> |
522 | 546 | </span> |
523 | 547 | ', template_control_verification($context['visual_verification_id'], 'all'), ' |
524 | 548 | </div>'; |
549 | + } |
|
525 | 550 | |
526 | 551 | // Finally, the submit buttons. |
527 | 552 | echo ' |
@@ -530,9 +555,10 @@ discard block |
||
530 | 555 | ', template_control_richedit_buttons($context['post_box_name']); |
531 | 556 | |
532 | 557 | // Option to delete an event if user is editing one. |
533 | - if ($context['make_event'] && !$context['event']['new']) |
|
534 | - echo ' |
|
558 | + if ($context['make_event'] && !$context['event']['new']) { |
|
559 | + echo ' |
|
535 | 560 | <input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'] ,'" class="button you_sure">'; |
561 | + } |
|
536 | 562 | |
537 | 563 | echo ' |
538 | 564 | </span> |
@@ -541,9 +567,10 @@ discard block |
||
541 | 567 | <br class="clear">'; |
542 | 568 | |
543 | 569 | // Assuming this isn't a new topic pass across the last message id. |
544 | - if (isset($context['topic_last_message'])) |
|
545 | - echo ' |
|
570 | + if (isset($context['topic_last_message'])) { |
|
571 | + echo ' |
|
546 | 572 | <input type="hidden" name="last_msg" value="', $context['topic_last_message'], '">'; |
573 | + } |
|
547 | 574 | |
548 | 575 | echo ' |
549 | 576 | <input type="hidden" name="additional_options" id="additional_options" value="', $context['show_additional_options'] ? '1' : '0', '"> |
@@ -564,13 +591,14 @@ discard block |
||
564 | 591 | </h5> |
565 | 592 | - %PostTime% » <span class="new_posts" id="image_new_%PostID%">' . $txt['new'] . '</span>'; |
566 | 593 | |
567 | - if ($context['can_quote']) |
|
568 | - $newPostsHTML .= ' |
|
594 | + if ($context['can_quote']) { |
|
595 | + $newPostsHTML .= ' |
|
569 | 596 | <ul class="quickbuttons sf-js-enabled sf-arrows" id="msg_%PostID%_quote" style="touch-action: pan-y;"> |
570 | 597 | <li id="post_modify"> |
571 | 598 | <a href="#postmodify" onclick="return insertQuoteFast(%PostID%);" class="quote_button"><span class="generic_icons quote"></span>' . $txt['quote'] . '</a> |
572 | 599 | </li> |
573 | 600 | </ul>'; |
601 | + } |
|
574 | 602 | |
575 | 603 | $newPostsHTML .= ' |
576 | 604 | <br class="clear"> |
@@ -596,16 +624,17 @@ discard block |
||
596 | 624 | sSessionVar: ', JavaScriptEscape($context['session_var']), ', |
597 | 625 | newPostsTemplate:', JavaScriptEscape($newPostsHTML); |
598 | 626 | |
599 | - if (!empty($context['current_board'])) |
|
600 | - echo ', |
|
627 | + if (!empty($context['current_board'])) { |
|
628 | + echo ', |
|
601 | 629 | iCurrentBoard: ', $context['current_board'], ''; |
630 | + } |
|
602 | 631 | |
603 | 632 | echo ' |
604 | 633 | });'; |
605 | 634 | |
606 | 635 | // Code for showing and hiding additional options. |
607 | - if (!empty($modSettings['additional_options_collapsable'])) |
|
608 | - echo ' |
|
636 | + if (!empty($modSettings['additional_options_collapsable'])) { |
|
637 | + echo ' |
|
609 | 638 | var oSwapAdditionalOptions = new smc_Toggle({ |
610 | 639 | bToggleEnabled: true, |
611 | 640 | bCurrentlyCollapsed: ', $context['show_additional_options'] ? 'false' : 'true', ', |
@@ -633,10 +662,11 @@ discard block |
||
633 | 662 | } |
634 | 663 | ] |
635 | 664 | });'; |
665 | + } |
|
636 | 666 | |
637 | 667 | // Code for showing and hiding drafts |
638 | - if (!empty($context['drafts'])) |
|
639 | - echo ' |
|
668 | + if (!empty($context['drafts'])) { |
|
669 | + echo ' |
|
640 | 670 | var oSwapDraftOptions = new smc_Toggle({ |
641 | 671 | bToggleEnabled: true, |
642 | 672 | bCurrentlyCollapsed: true, |
@@ -658,6 +688,7 @@ discard block |
||
658 | 688 | } |
659 | 689 | ] |
660 | 690 | });'; |
691 | + } |
|
661 | 692 | |
662 | 693 | echo ' |
663 | 694 | var oEditorID = "', $context['post_box_name'] ,'"; |
@@ -678,8 +709,9 @@ discard block |
||
678 | 709 | foreach ($context['previous_posts'] as $post) |
679 | 710 | { |
680 | 711 | $ignoring = false; |
681 | - if (!empty($post['is_ignored'])) |
|
682 | - $ignored_posts[] = $ignoring = $post['id']; |
|
712 | + if (!empty($post['is_ignored'])) { |
|
713 | + $ignored_posts[] = $ignoring = $post['id']; |
|
714 | + } |
|
683 | 715 | |
684 | 716 | echo ' |
685 | 717 | <div class="windowbg"> |
@@ -689,22 +721,24 @@ discard block |
||
689 | 721 | </h5> |
690 | 722 | - ', $post['time']; |
691 | 723 | |
692 | - if ($context['can_quote']) |
|
693 | - echo ' |
|
724 | + if ($context['can_quote']) { |
|
725 | + echo ' |
|
694 | 726 | <ul class="quickbuttons" id="msg_', $post['id'], '_quote"> |
695 | 727 | <li style="display:none;" id="quoteSelected_', $post['id'], '" data-msgid="', $post['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'] ,'</a></li> |
696 | 728 | <li id="post_modify"><a href="#postmodify" onclick="return insertQuoteFast(', $post['id'], ');"><span class="generic_icons quote"></span>', $txt['quote'], '</a></li> |
697 | 729 | </ul>'; |
730 | + } |
|
698 | 731 | |
699 | 732 | echo ' |
700 | 733 | <br class="clear">'; |
701 | 734 | |
702 | - if ($ignoring) |
|
703 | - echo ' |
|
735 | + if ($ignoring) { |
|
736 | + echo ' |
|
704 | 737 | <div id="msg_', $post['id'], '_ignored_prompt" class="smalltext"> |
705 | 738 | ', $txt['ignoring_user'], ' |
706 | 739 | <a href="#" id="msg_', $post['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a> |
707 | 740 | </div>'; |
741 | + } |
|
708 | 742 | |
709 | 743 | echo ' |
710 | 744 | <div class="list_posts smalltext" id="msg_', $post['id'], '_body" data-msgid="', $post['id'], '">', $post['message'], '</div> |
@@ -859,10 +893,10 @@ discard block |
||
859 | 893 | <div id="temporary_posting_area" style="display: none;"></div> |
860 | 894 | <script>'; |
861 | 895 | |
862 | - if ($context['close_window']) |
|
863 | - echo ' |
|
896 | + if ($context['close_window']) { |
|
897 | + echo ' |
|
864 | 898 | window.close();'; |
865 | - else |
|
899 | + } else |
|
866 | 900 | { |
867 | 901 | // Lucky for us, Internet Explorer has an "innerText" feature which basically converts entities <--> text. Use it if possible ;) |
868 | 902 | echo ' |
@@ -916,11 +950,12 @@ discard block |
||
916 | 950 | </p> |
917 | 951 | <ul>'; |
918 | 952 | |
919 | - foreach ($context['groups'] as $group) |
|
920 | - echo ' |
|
953 | + foreach ($context['groups'] as $group) { |
|
954 | + echo ' |
|
921 | 955 | <li> |
922 | 956 | <label for="who_', $group['id'], '"><input type="checkbox" name="who[', $group['id'], ']" id="who_', $group['id'], '" value="', $group['id'], '" checked> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em> |
923 | 957 | </li>'; |
958 | + } |
|
924 | 959 | |
925 | 960 | echo ' |
926 | 961 | <li> |
@@ -1027,28 +1062,32 @@ discard block |
||
1027 | 1062 | foreach ($context['posting_fields'] as $pfid => $pf) |
1028 | 1063 | { |
1029 | 1064 | // We need both a label and an input |
1030 | - if (empty($pf['label']) || empty($pf['input'])) |
|
1031 | - continue; |
|
1065 | + if (empty($pf['label']) || empty($pf['input'])) { |
|
1066 | + continue; |
|
1067 | + } |
|
1032 | 1068 | |
1033 | 1069 | // The labels are pretty simple... |
1034 | 1070 | echo ' |
1035 | 1071 | <dt class="clear pf_', $pfid, '">'; |
1036 | 1072 | |
1037 | 1073 | // Any leading HTML before the label |
1038 | - if (!empty($pf['label']['before'])) |
|
1039 | - echo ' |
|
1074 | + if (!empty($pf['label']['before'])) { |
|
1075 | + echo ' |
|
1040 | 1076 | ', $pf['label']['before']; |
1077 | + } |
|
1041 | 1078 | |
1042 | - if (!empty($pf['label']['html'])) |
|
1043 | - echo $pf['label']['html']; |
|
1044 | - else |
|
1045 | - echo ' |
|
1079 | + if (!empty($pf['label']['html'])) { |
|
1080 | + echo $pf['label']['html']; |
|
1081 | + } else { |
|
1082 | + echo ' |
|
1046 | 1083 | <label for="', !empty($pf['input']['attributes']['name']) ? $pf['input']['attributes']['name'] : $pfid, '" id="caption_', $pfid, '"', !empty($pf['label']['class']) ? ' class="' . $pf['label']['class'] . '"' : '', '>', $pf['label']['text'], '</label>'; |
1084 | + } |
|
1047 | 1085 | |
1048 | 1086 | // Any trailing HTML after the label |
1049 | - if (!empty($pf['label']['after'])) |
|
1050 | - echo ' |
|
1087 | + if (!empty($pf['label']['after'])) { |
|
1088 | + echo ' |
|
1051 | 1089 | ', $pf['label']['after']; |
1090 | + } |
|
1052 | 1091 | |
1053 | 1092 | echo ' |
1054 | 1093 | </dt>'; |
@@ -1058,9 +1097,10 @@ discard block |
||
1058 | 1097 | <dd class="pf_', $pfid, '">'; |
1059 | 1098 | |
1060 | 1099 | // Any leading HTML before the main input |
1061 | - if (!empty($pf['input']['before'])) |
|
1062 | - echo ' |
|
1100 | + if (!empty($pf['input']['before'])) { |
|
1101 | + echo ' |
|
1063 | 1102 | ', $pf['input']['before']; |
1103 | + } |
|
1064 | 1104 | |
1065 | 1105 | // If there is a literal HTML string already defined, just print it. |
1066 | 1106 | if (!empty($pf['input']['html'])) |
@@ -1073,17 +1113,19 @@ discard block |
||
1073 | 1113 | echo ' |
1074 | 1114 | <input type="', $pf['input']['type'], '"'; |
1075 | 1115 | |
1076 | - if (empty($pf['input']['attributes']['name'])) |
|
1077 | - echo ' name="', $pfid, '"'; |
|
1116 | + if (empty($pf['input']['attributes']['name'])) { |
|
1117 | + echo ' name="', $pfid, '"'; |
|
1118 | + } |
|
1078 | 1119 | |
1079 | 1120 | if (!empty($pf['input']['attributes']) && is_array($pf['input']['attributes'])) |
1080 | 1121 | { |
1081 | 1122 | foreach ($pf['input']['attributes'] as $attribute => $value) |
1082 | 1123 | { |
1083 | - if (is_bool($value)) |
|
1084 | - echo $value ? ' ' . $attribute : ''; |
|
1085 | - else |
|
1086 | - echo ' ', $attribute, '="', $value, '"'; |
|
1124 | + if (is_bool($value)) { |
|
1125 | + echo $value ? ' ' . $attribute : ''; |
|
1126 | + } else { |
|
1127 | + echo ' ', $attribute, '="', $value, '"'; |
|
1128 | + } |
|
1087 | 1129 | } |
1088 | 1130 | } |
1089 | 1131 | |
@@ -1095,19 +1137,21 @@ discard block |
||
1095 | 1137 | echo ' |
1096 | 1138 | <textarea'; |
1097 | 1139 | |
1098 | - if (empty($pf['input']['attributes']['name'])) |
|
1099 | - echo ' name="', $pfid, '"'; |
|
1140 | + if (empty($pf['input']['attributes']['name'])) { |
|
1141 | + echo ' name="', $pfid, '"'; |
|
1142 | + } |
|
1100 | 1143 | |
1101 | 1144 | if (!empty($pf['input']['attributes']) && is_array($pf['input']['attributes'])) |
1102 | 1145 | { |
1103 | 1146 | foreach ($pf['input']['attributes'] as $attribute => $value) |
1104 | 1147 | { |
1105 | - if ($attribute === 'value') |
|
1106 | - continue; |
|
1107 | - elseif (is_bool($value)) |
|
1108 | - echo $value ? ' ' . $attribute : ''; |
|
1109 | - else |
|
1110 | - echo ' ', $attribute, '="', $value, '"'; |
|
1148 | + if ($attribute === 'value') { |
|
1149 | + continue; |
|
1150 | + } elseif (is_bool($value)) { |
|
1151 | + echo $value ? ' ' . $attribute : ''; |
|
1152 | + } else { |
|
1153 | + echo ' ', $attribute, '="', $value, '"'; |
|
1154 | + } |
|
1111 | 1155 | } |
1112 | 1156 | } |
1113 | 1157 | |
@@ -1120,17 +1164,19 @@ discard block |
||
1120 | 1164 | echo ' |
1121 | 1165 | <select'; |
1122 | 1166 | |
1123 | - if (empty($pf['input']['attributes']['name'])) |
|
1124 | - echo ' name="', $pfid, '"'; |
|
1167 | + if (empty($pf['input']['attributes']['name'])) { |
|
1168 | + echo ' name="', $pfid, '"'; |
|
1169 | + } |
|
1125 | 1170 | |
1126 | 1171 | if (!empty($pf['input']['attributes']) && is_array($pf['input']['attributes'])) |
1127 | 1172 | { |
1128 | 1173 | foreach ($pf['input']['attributes'] as $attribute => $value) |
1129 | 1174 | { |
1130 | - if (is_bool($value)) |
|
1131 | - echo $value ? ' ' . $attribute : ''; |
|
1132 | - else |
|
1133 | - echo ' ', $attribute, '="', $value, '"'; |
|
1175 | + if (is_bool($value)) { |
|
1176 | + echo $value ? ' ' . $attribute : ''; |
|
1177 | + } else { |
|
1178 | + echo ' ', $attribute, '="', $value, '"'; |
|
1179 | + } |
|
1134 | 1180 | } |
1135 | 1181 | } |
1136 | 1182 | |
@@ -1145,17 +1191,19 @@ discard block |
||
1145 | 1191 | echo ' |
1146 | 1192 | <optgroup'; |
1147 | 1193 | |
1148 | - if (empty($option['attributes']['label'])) |
|
1149 | - echo ' label="', $optlabel, '"'; |
|
1194 | + if (empty($option['attributes']['label'])) { |
|
1195 | + echo ' label="', $optlabel, '"'; |
|
1196 | + } |
|
1150 | 1197 | |
1151 | 1198 | if (!empty($option['attributes']) && is_array($option['attributes'])) |
1152 | 1199 | { |
1153 | 1200 | foreach ($option['attributes'] as $attribute => $value) |
1154 | 1201 | { |
1155 | - if (is_bool($value)) |
|
1156 | - echo $value ? ' ' . $attribute : ''; |
|
1157 | - else |
|
1158 | - echo ' ', $attribute, '="', $value, '"'; |
|
1202 | + if (is_bool($value)) { |
|
1203 | + echo $value ? ' ' . $attribute : ''; |
|
1204 | + } else { |
|
1205 | + echo ' ', $attribute, '="', $value, '"'; |
|
1206 | + } |
|
1159 | 1207 | } |
1160 | 1208 | } |
1161 | 1209 | |
@@ -1168,10 +1216,11 @@ discard block |
||
1168 | 1216 | |
1169 | 1217 | foreach ($grouped_option['attributes'] as $attribute => $value) |
1170 | 1218 | { |
1171 | - if (is_bool($value)) |
|
1172 | - echo $value ? ' ' . $attribute : ''; |
|
1173 | - else |
|
1174 | - echo ' ', $attribute, '="', $value, '"'; |
|
1219 | + if (is_bool($value)) { |
|
1220 | + echo $value ? ' ' . $attribute : ''; |
|
1221 | + } else { |
|
1222 | + echo ' ', $attribute, '="', $value, '"'; |
|
1223 | + } |
|
1175 | 1224 | } |
1176 | 1225 | |
1177 | 1226 | echo '>', $grouped_optlabel, '</option>'; |
@@ -1189,10 +1238,11 @@ discard block |
||
1189 | 1238 | |
1190 | 1239 | foreach ($option['attributes'] as $attribute => $value) |
1191 | 1240 | { |
1192 | - if (is_bool($value)) |
|
1193 | - echo $value ? ' ' . $attribute : ''; |
|
1194 | - else |
|
1195 | - echo ' ', $attribute, '="', $value, '"'; |
|
1241 | + if (is_bool($value)) { |
|
1242 | + echo $value ? ' ' . $attribute : ''; |
|
1243 | + } else { |
|
1244 | + echo ' ', $attribute, '="', $value, '"'; |
|
1245 | + } |
|
1196 | 1246 | } |
1197 | 1247 | |
1198 | 1248 | echo '>', $optlabel, '</option>'; |
@@ -1213,12 +1263,13 @@ discard block |
||
1213 | 1263 | { |
1214 | 1264 | foreach ($pf['input']['attributes'] as $attribute => $value) |
1215 | 1265 | { |
1216 | - if ($attribute === 'name') |
|
1217 | - continue; |
|
1218 | - elseif (is_bool($value)) |
|
1219 | - echo $value ? ' ' . $attribute : ''; |
|
1220 | - else |
|
1221 | - echo ' ', $attribute, '="', $value, '"'; |
|
1266 | + if ($attribute === 'name') { |
|
1267 | + continue; |
|
1268 | + } elseif (is_bool($value)) { |
|
1269 | + echo $value ? ' ' . $attribute : ''; |
|
1270 | + } else { |
|
1271 | + echo ' ', $attribute, '="', $value, '"'; |
|
1272 | + } |
|
1222 | 1273 | } |
1223 | 1274 | } |
1224 | 1275 | |
@@ -1231,10 +1282,11 @@ discard block |
||
1231 | 1282 | |
1232 | 1283 | foreach ($option['attributes'] as $attribute => $value) |
1233 | 1284 | { |
1234 | - if (is_bool($value)) |
|
1235 | - echo $value ? ' ' . $attribute : ''; |
|
1236 | - else |
|
1237 | - echo ' ', $attribute, '="', $value, '"'; |
|
1285 | + if (is_bool($value)) { |
|
1286 | + echo $value ? ' ' . $attribute : ''; |
|
1287 | + } else { |
|
1288 | + echo ' ', $attribute, '="', $value, '"'; |
|
1289 | + } |
|
1238 | 1290 | } |
1239 | 1291 | |
1240 | 1292 | echo ' tabindex="', $context['tabindex']++, '">', $optlabel, '</input>'; |
@@ -1245,9 +1297,10 @@ discard block |
||
1245 | 1297 | } |
1246 | 1298 | |
1247 | 1299 | // Any trailing HTML after the main input |
1248 | - if (!empty($pf['input']['after'])) |
|
1249 | - echo ' |
|
1300 | + if (!empty($pf['input']['after'])) { |
|
1301 | + echo ' |
|
1250 | 1302 | ', $pf['input']['after']; |
1303 | + } |
|
1251 | 1304 | |
1252 | 1305 | echo ' |
1253 | 1306 | </dd>'; |
@@ -30,8 +30,9 @@ discard block |
||
30 | 30 | * @version 2.1 Beta 4 |
31 | 31 | */ |
32 | 32 | |
33 | -if (!defined('SMF')) |
|
33 | +if (!defined('SMF')) { |
|
34 | 34 | die('No direct access...'); |
35 | +} |
|
35 | 36 | |
36 | 37 | /** |
37 | 38 | * Subaction handler - manages the action and delegates control to the proper |
@@ -103,12 +104,12 @@ discard block |
||
103 | 104 | cache_put_data('minimized_css', null); |
104 | 105 | |
105 | 106 | // Follow the sa or just go to administration. |
106 | - if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) |
|
107 | - call_helper($subActions[$_GET['sa']]); |
|
108 | - |
|
109 | - else |
|
110 | - call_helper($subActions['admin']); |
|
111 | -} |
|
107 | + if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) { |
|
108 | + call_helper($subActions[$_GET['sa']]); |
|
109 | + } else { |
|
110 | + call_helper($subActions['admin']); |
|
111 | + } |
|
112 | + } |
|
112 | 113 | |
113 | 114 | /** |
114 | 115 | * This function allows administration of themes and their settings, |
@@ -130,15 +131,16 @@ discard block |
||
130 | 131 | checkSession(); |
131 | 132 | validateToken('admin-tm'); |
132 | 133 | |
133 | - if (isset($_POST['options']['known_themes'])) |
|
134 | - foreach ($_POST['options']['known_themes'] as $key => $id) |
|
134 | + if (isset($_POST['options']['known_themes'])) { |
|
135 | + foreach ($_POST['options']['known_themes'] as $key => $id) |
|
135 | 136 | $_POST['options']['known_themes'][$key] = (int) $id; |
137 | + } else { |
|
138 | + fatal_lang_error('themes_none_selectable', false); |
|
139 | + } |
|
136 | 140 | |
137 | - else |
|
138 | - fatal_lang_error('themes_none_selectable', false); |
|
139 | - |
|
140 | - if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) |
|
141 | - fatal_lang_error('themes_default_selectable', false); |
|
141 | + if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) { |
|
142 | + fatal_lang_error('themes_default_selectable', false); |
|
143 | + } |
|
142 | 144 | |
143 | 145 | // Commit the new settings. |
144 | 146 | updateSettings(array( |
@@ -146,8 +148,9 @@ discard block |
||
146 | 148 | 'theme_guests' => $_POST['options']['theme_guests'], |
147 | 149 | 'knownThemes' => implode(',', $_POST['options']['known_themes']), |
148 | 150 | )); |
149 | - if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) |
|
150 | - updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset'])); |
|
151 | + if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) { |
|
152 | + updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset'])); |
|
153 | + } |
|
151 | 154 | |
152 | 155 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=admin'); |
153 | 156 | } |
@@ -166,8 +169,9 @@ discard block |
||
166 | 169 | // Look for a non existent theme directory. (ie theme87.) |
167 | 170 | $theme_dir = $boarddir . '/Themes/theme'; |
168 | 171 | $i = 1; |
169 | - while (file_exists($theme_dir . $i)) |
|
170 | - $i++; |
|
172 | + while (file_exists($theme_dir . $i)) { |
|
173 | + $i++; |
|
174 | + } |
|
171 | 175 | |
172 | 176 | $context['new_theme_name'] = 'theme' . $i; |
173 | 177 | |
@@ -189,8 +193,9 @@ discard block |
||
189 | 193 | loadLanguage('Admin'); |
190 | 194 | isAllowedTo('admin_forum'); |
191 | 195 | |
192 | - if (isset($_REQUEST['th'])) |
|
193 | - return SetThemeSettings(); |
|
196 | + if (isset($_REQUEST['th'])) { |
|
197 | + return SetThemeSettings(); |
|
198 | + } |
|
194 | 199 | |
195 | 200 | if (isset($_POST['save'])) |
196 | 201 | { |
@@ -274,12 +279,13 @@ discard block |
||
274 | 279 | $context['themes'] = array(); |
275 | 280 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
276 | 281 | { |
277 | - if (!isset($context['themes'][$row['id_theme']])) |
|
278 | - $context['themes'][$row['id_theme']] = array( |
|
282 | + if (!isset($context['themes'][$row['id_theme']])) { |
|
283 | + $context['themes'][$row['id_theme']] = array( |
|
279 | 284 | 'id' => $row['id_theme'], |
280 | 285 | 'num_default_options' => 0, |
281 | 286 | 'num_members' => 0, |
282 | 287 | ); |
288 | + } |
|
283 | 289 | $context['themes'][$row['id_theme']][$row['variable']] = $row['value']; |
284 | 290 | } |
285 | 291 | $smcFunc['db_free_result']($request); |
@@ -293,8 +299,9 @@ discard block |
||
293 | 299 | 'guest_member' => -1, |
294 | 300 | ) |
295 | 301 | ); |
296 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
297 | - $context['themes'][$row['id_theme']]['num_default_options'] = $row['value']; |
|
302 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
303 | + $context['themes'][$row['id_theme']]['num_default_options'] = $row['value']; |
|
304 | + } |
|
298 | 305 | $smcFunc['db_free_result']($request); |
299 | 306 | |
300 | 307 | // Need to make sure we don't do custom fields. |
@@ -305,8 +312,9 @@ discard block |
||
305 | 312 | ) |
306 | 313 | ); |
307 | 314 | $customFields = array(); |
308 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
309 | - $customFields[] = $row['col_name']; |
|
315 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
316 | + $customFields[] = $row['col_name']; |
|
317 | + } |
|
310 | 318 | $smcFunc['db_free_result']($request); |
311 | 319 | $customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})'); |
312 | 320 | |
@@ -321,14 +329,16 @@ discard block |
||
321 | 329 | 'custom_fields' => empty($customFields) ? array() : $customFields, |
322 | 330 | ) |
323 | 331 | ); |
324 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
325 | - $context['themes'][$row['id_theme']]['num_members'] = $row['value']; |
|
332 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
333 | + $context['themes'][$row['id_theme']]['num_members'] = $row['value']; |
|
334 | + } |
|
326 | 335 | $smcFunc['db_free_result']($request); |
327 | 336 | |
328 | 337 | // There has to be a Settings template! |
329 | - foreach ($context['themes'] as $k => $v) |
|
330 | - if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members']))) |
|
338 | + foreach ($context['themes'] as $k => $v) { |
|
339 | + if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members']))) |
|
331 | 340 | unset($context['themes'][$k]); |
341 | + } |
|
332 | 342 | |
333 | 343 | loadTemplate('Themes'); |
334 | 344 | $context['sub_template'] = 'reset_list'; |
@@ -343,16 +353,19 @@ discard block |
||
343 | 353 | checkSession(); |
344 | 354 | validateToken('admin-sto'); |
345 | 355 | |
346 | - if (empty($_POST['options'])) |
|
347 | - $_POST['options'] = array(); |
|
348 | - if (empty($_POST['default_options'])) |
|
349 | - $_POST['default_options'] = array(); |
|
356 | + if (empty($_POST['options'])) { |
|
357 | + $_POST['options'] = array(); |
|
358 | + } |
|
359 | + if (empty($_POST['default_options'])) { |
|
360 | + $_POST['default_options'] = array(); |
|
361 | + } |
|
350 | 362 | |
351 | 363 | // Set up the sql query. |
352 | 364 | $setValues = array(); |
353 | 365 | |
354 | - foreach ($_POST['options'] as $opt => $val) |
|
355 | - $setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
366 | + foreach ($_POST['options'] as $opt => $val) { |
|
367 | + $setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
368 | + } |
|
356 | 369 | |
357 | 370 | $old_settings = array(); |
358 | 371 | foreach ($_POST['default_options'] as $opt => $val) |
@@ -366,8 +379,8 @@ discard block |
||
366 | 379 | if (!empty($setValues)) |
367 | 380 | { |
368 | 381 | // Are there options in non-default themes set that should be cleared? |
369 | - if (!empty($old_settings)) |
|
370 | - $smcFunc['db_query']('', ' |
|
382 | + if (!empty($old_settings)) { |
|
383 | + $smcFunc['db_query']('', ' |
|
371 | 384 | DELETE FROM {db_prefix}themes |
372 | 385 | WHERE id_theme != {int:default_theme} |
373 | 386 | AND id_member = {int:guest_member} |
@@ -378,6 +391,7 @@ discard block |
||
378 | 391 | 'old_settings' => $old_settings, |
379 | 392 | ) |
380 | 393 | ); |
394 | + } |
|
381 | 395 | |
382 | 396 | $smcFunc['db_insert']('replace', |
383 | 397 | '{db_prefix}themes', |
@@ -391,8 +405,7 @@ discard block |
||
391 | 405 | cache_put_data('theme_settings-1', null, 90); |
392 | 406 | |
393 | 407 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset'); |
394 | - } |
|
395 | - elseif (isset($_POST['submit']) && $_POST['who'] == 1) |
|
408 | + } elseif (isset($_POST['submit']) && $_POST['who'] == 1) |
|
396 | 409 | { |
397 | 410 | checkSession(); |
398 | 411 | validateToken('admin-sto'); |
@@ -405,9 +418,9 @@ discard block |
||
405 | 418 | $old_settings = array(); |
406 | 419 | foreach ($_POST['default_options'] as $opt => $val) |
407 | 420 | { |
408 | - if ($_POST['default_options_master'][$opt] == 0) |
|
409 | - continue; |
|
410 | - elseif ($_POST['default_options_master'][$opt] == 1) |
|
421 | + if ($_POST['default_options_master'][$opt] == 0) { |
|
422 | + continue; |
|
423 | + } elseif ($_POST['default_options_master'][$opt] == 1) |
|
411 | 424 | { |
412 | 425 | // Delete then insert for ease of database compatibility! |
413 | 426 | $smcFunc['db_query']('substring', ' |
@@ -433,8 +446,7 @@ discard block |
||
433 | 446 | ); |
434 | 447 | |
435 | 448 | $old_settings[] = $opt; |
436 | - } |
|
437 | - elseif ($_POST['default_options_master'][$opt] == 2) |
|
449 | + } elseif ($_POST['default_options_master'][$opt] == 2) |
|
438 | 450 | { |
439 | 451 | $smcFunc['db_query']('', ' |
440 | 452 | DELETE FROM {db_prefix}themes |
@@ -449,8 +461,8 @@ discard block |
||
449 | 461 | } |
450 | 462 | |
451 | 463 | // Delete options from other themes. |
452 | - if (!empty($old_settings)) |
|
453 | - $smcFunc['db_query']('', ' |
|
464 | + if (!empty($old_settings)) { |
|
465 | + $smcFunc['db_query']('', ' |
|
454 | 466 | DELETE FROM {db_prefix}themes |
455 | 467 | WHERE id_theme != {int:default_theme} |
456 | 468 | AND id_member > {int:no_member} |
@@ -461,12 +473,13 @@ discard block |
||
461 | 473 | 'old_settings' => $old_settings, |
462 | 474 | ) |
463 | 475 | ); |
476 | + } |
|
464 | 477 | |
465 | 478 | foreach ($_POST['options'] as $opt => $val) |
466 | 479 | { |
467 | - if ($_POST['options_master'][$opt] == 0) |
|
468 | - continue; |
|
469 | - elseif ($_POST['options_master'][$opt] == 1) |
|
480 | + if ($_POST['options_master'][$opt] == 0) { |
|
481 | + continue; |
|
482 | + } elseif ($_POST['options_master'][$opt] == 1) |
|
470 | 483 | { |
471 | 484 | // Delete then insert for ease of database compatibility - again! |
472 | 485 | $smcFunc['db_query']('substring', ' |
@@ -491,8 +504,7 @@ discard block |
||
491 | 504 | 'value' => (is_array($val) ? implode(',', $val) : $val), |
492 | 505 | ) |
493 | 506 | ); |
494 | - } |
|
495 | - elseif ($_POST['options_master'][$opt] == 2) |
|
507 | + } elseif ($_POST['options_master'][$opt] == 2) |
|
496 | 508 | { |
497 | 509 | $smcFunc['db_query']('', ' |
498 | 510 | DELETE FROM {db_prefix}themes |
@@ -509,8 +521,7 @@ discard block |
||
509 | 521 | } |
510 | 522 | |
511 | 523 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset'); |
512 | - } |
|
513 | - elseif (!empty($_GET['who']) && $_GET['who'] == 2) |
|
524 | + } elseif (!empty($_GET['who']) && $_GET['who'] == 2) |
|
514 | 525 | { |
515 | 526 | checkSession('get'); |
516 | 527 | validateToken('admin-stor', 'request'); |
@@ -525,8 +536,9 @@ discard block |
||
525 | 536 | ) |
526 | 537 | ); |
527 | 538 | $customFields = array(); |
528 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
529 | - $customFields[] = $row['col_name']; |
|
539 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
540 | + $customFields[] = $row['col_name']; |
|
541 | + } |
|
530 | 542 | $smcFunc['db_free_result']($request); |
531 | 543 | } |
532 | 544 | $customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})'); |
@@ -581,13 +593,13 @@ discard block |
||
581 | 593 | ) |
582 | 594 | ); |
583 | 595 | $context['theme_options'] = array(); |
584 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
585 | - $context['theme_options'][$row['variable']] = $row['value']; |
|
596 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
597 | + $context['theme_options'][$row['variable']] = $row['value']; |
|
598 | + } |
|
586 | 599 | $smcFunc['db_free_result']($request); |
587 | 600 | |
588 | 601 | $context['theme_options_reset'] = false; |
589 | - } |
|
590 | - else |
|
602 | + } else |
|
591 | 603 | { |
592 | 604 | $context['theme_options'] = array(); |
593 | 605 | $context['theme_options_reset'] = true; |
@@ -596,8 +608,9 @@ discard block |
||
596 | 608 | foreach ($context['options'] as $i => $setting) |
597 | 609 | { |
598 | 610 | // Just skip separators |
599 | - if (!is_array($setting)) |
|
600 | - continue; |
|
611 | + if (!is_array($setting)) { |
|
612 | + continue; |
|
613 | + } |
|
601 | 614 | |
602 | 615 | // Is this disabled? |
603 | 616 | if (isset($setting['enabled']) && $setting['enabled'] === false) |
@@ -606,15 +619,17 @@ discard block |
||
606 | 619 | continue; |
607 | 620 | } |
608 | 621 | |
609 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
610 | - $context['options'][$i]['type'] = 'checkbox'; |
|
611 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
612 | - $context['options'][$i]['type'] = 'number'; |
|
613 | - elseif ($setting['type'] == 'string') |
|
614 | - $context['options'][$i]['type'] = 'text'; |
|
622 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
623 | + $context['options'][$i]['type'] = 'checkbox'; |
|
624 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
625 | + $context['options'][$i]['type'] = 'number'; |
|
626 | + } elseif ($setting['type'] == 'string') { |
|
627 | + $context['options'][$i]['type'] = 'text'; |
|
628 | + } |
|
615 | 629 | |
616 | - if (isset($setting['options'])) |
|
617 | - $context['options'][$i]['type'] = 'list'; |
|
630 | + if (isset($setting['options'])) { |
|
631 | + $context['options'][$i]['type'] = 'list'; |
|
632 | + } |
|
618 | 633 | |
619 | 634 | $context['options'][$i]['value'] = !isset($context['theme_options'][$setting['id']]) ? '' : $context['theme_options'][$setting['id']]; |
620 | 635 | } |
@@ -639,8 +654,9 @@ discard block |
||
639 | 654 | { |
640 | 655 | global $txt, $context, $settings, $modSettings, $smcFunc; |
641 | 656 | |
642 | - if (empty($_GET['th']) && empty($_GET['id'])) |
|
643 | - return ThemeAdmin(); |
|
657 | + if (empty($_GET['th']) && empty($_GET['id'])) { |
|
658 | + return ThemeAdmin(); |
|
659 | + } |
|
644 | 660 | |
645 | 661 | $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
646 | 662 | |
@@ -651,8 +667,9 @@ discard block |
||
651 | 667 | isAllowedTo('admin_forum'); |
652 | 668 | |
653 | 669 | // Validate inputs/user. |
654 | - if (empty($_GET['th'])) |
|
655 | - fatal_lang_error('no_theme', false); |
|
670 | + if (empty($_GET['th'])) { |
|
671 | + fatal_lang_error('no_theme', false); |
|
672 | + } |
|
656 | 673 | |
657 | 674 | // Fetch the smiley sets... |
658 | 675 | $sets = explode(',', 'none,' . $modSettings['smiley_sets_known']); |
@@ -660,8 +677,9 @@ discard block |
||
660 | 677 | $context['smiley_sets'] = array( |
661 | 678 | '' => $txt['smileys_no_default'] |
662 | 679 | ); |
663 | - foreach ($sets as $i => $set) |
|
664 | - $context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]); |
|
680 | + foreach ($sets as $i => $set) { |
|
681 | + $context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]); |
|
682 | + } |
|
665 | 683 | |
666 | 684 | $old_id = $settings['theme_id']; |
667 | 685 | $old_settings = $settings; |
@@ -686,8 +704,9 @@ discard block |
||
686 | 704 | if (file_exists($settings['theme_dir'] . '/index.template.php')) |
687 | 705 | { |
688 | 706 | $file_contents = implode('', file($settings['theme_dir'] . '/index.template.php')); |
689 | - if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) |
|
690 | - eval('global $settings;' . $matches[0]); |
|
707 | + if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) { |
|
708 | + eval('global $settings;' . $matches[0]); |
|
709 | + } |
|
691 | 710 | } |
692 | 711 | |
693 | 712 | // Let mods hook into the theme settings. |
@@ -699,37 +718,45 @@ discard block |
||
699 | 718 | checkSession(); |
700 | 719 | validateToken('admin-sts'); |
701 | 720 | |
702 | - if (empty($_POST['options'])) |
|
703 | - $_POST['options'] = array(); |
|
704 | - if (empty($_POST['default_options'])) |
|
705 | - $_POST['default_options'] = array(); |
|
721 | + if (empty($_POST['options'])) { |
|
722 | + $_POST['options'] = array(); |
|
723 | + } |
|
724 | + if (empty($_POST['default_options'])) { |
|
725 | + $_POST['default_options'] = array(); |
|
726 | + } |
|
706 | 727 | |
707 | 728 | // Make sure items are cast correctly. |
708 | 729 | foreach ($context['theme_settings'] as $item) |
709 | 730 | { |
710 | 731 | // Disregard this item if this is just a separator. |
711 | - if (!is_array($item)) |
|
712 | - continue; |
|
732 | + if (!is_array($item)) { |
|
733 | + continue; |
|
734 | + } |
|
713 | 735 | |
714 | 736 | foreach (array('options', 'default_options') as $option) |
715 | 737 | { |
716 | - if (!isset($_POST[$option][$item['id']])) |
|
717 | - continue; |
|
738 | + if (!isset($_POST[$option][$item['id']])) { |
|
739 | + continue; |
|
740 | + } |
|
718 | 741 | // Checkbox. |
719 | - elseif (empty($item['type'])) |
|
720 | - $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0; |
|
742 | + elseif (empty($item['type'])) { |
|
743 | + $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0; |
|
744 | + } |
|
721 | 745 | // Number |
722 | - elseif ($item['type'] == 'number') |
|
723 | - $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']]; |
|
746 | + elseif ($item['type'] == 'number') { |
|
747 | + $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']]; |
|
748 | + } |
|
724 | 749 | } |
725 | 750 | } |
726 | 751 | |
727 | 752 | // Set up the sql query. |
728 | 753 | $inserts = array(); |
729 | - foreach ($_POST['options'] as $opt => $val) |
|
730 | - $inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
731 | - foreach ($_POST['default_options'] as $opt => $val) |
|
732 | - $inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
754 | + foreach ($_POST['options'] as $opt => $val) { |
|
755 | + $inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
756 | + } |
|
757 | + foreach ($_POST['default_options'] as $opt => $val) { |
|
758 | + $inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
759 | + } |
|
733 | 760 | // If we're actually inserting something.. |
734 | 761 | if (!empty($inserts)) |
735 | 762 | { |
@@ -755,8 +782,9 @@ discard block |
||
755 | 782 | |
756 | 783 | foreach ($settings as $setting => $dummy) |
757 | 784 | { |
758 | - if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) |
|
759 | - $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
785 | + if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) { |
|
786 | + $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
787 | + } |
|
760 | 788 | } |
761 | 789 | |
762 | 790 | $context['settings'] = $context['theme_settings']; |
@@ -765,18 +793,21 @@ discard block |
||
765 | 793 | foreach ($context['settings'] as $i => $setting) |
766 | 794 | { |
767 | 795 | // Separators are dummies, so leave them alone. |
768 | - if (!is_array($setting)) |
|
769 | - continue; |
|
796 | + if (!is_array($setting)) { |
|
797 | + continue; |
|
798 | + } |
|
770 | 799 | |
771 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
772 | - $context['settings'][$i]['type'] = 'checkbox'; |
|
773 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
774 | - $context['settings'][$i]['type'] = 'number'; |
|
775 | - elseif ($setting['type'] == 'string') |
|
776 | - $context['settings'][$i]['type'] = 'text'; |
|
800 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
801 | + $context['settings'][$i]['type'] = 'checkbox'; |
|
802 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
803 | + $context['settings'][$i]['type'] = 'number'; |
|
804 | + } elseif ($setting['type'] == 'string') { |
|
805 | + $context['settings'][$i]['type'] = 'text'; |
|
806 | + } |
|
777 | 807 | |
778 | - if (isset($setting['options'])) |
|
779 | - $context['settings'][$i]['type'] = 'list'; |
|
808 | + if (isset($setting['options'])) { |
|
809 | + $context['settings'][$i]['type'] = 'list'; |
|
810 | + } |
|
780 | 811 | |
781 | 812 | $context['settings'][$i]['value'] = !isset($settings[$setting['id']]) ? '' : $settings[$setting['id']]; |
782 | 813 | } |
@@ -829,8 +860,9 @@ discard block |
||
829 | 860 | $themeID = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
830 | 861 | |
831 | 862 | // You can't delete the default theme! |
832 | - if ($themeID == 1) |
|
833 | - fatal_lang_error('no_access', false); |
|
863 | + if ($themeID == 1) { |
|
864 | + fatal_lang_error('no_access', false); |
|
865 | + } |
|
834 | 866 | |
835 | 867 | $theme_info = get_single_theme($themeID); |
836 | 868 | |
@@ -838,8 +870,9 @@ discard block |
||
838 | 870 | remove_theme($themeID); |
839 | 871 | |
840 | 872 | // And remove all its files and folders too. |
841 | - if (!empty($theme_info) && !empty($theme_info['theme_dir'])) |
|
842 | - remove_dir($theme_info['theme_dir']); |
|
873 | + if (!empty($theme_info) && !empty($theme_info['theme_dir'])) { |
|
874 | + remove_dir($theme_info['theme_dir']); |
|
875 | + } |
|
843 | 876 | |
844 | 877 | // Go back to the list page. |
845 | 878 | redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id'] . ';done=removing'); |
@@ -864,12 +897,14 @@ discard block |
||
864 | 897 | $enableThemes = explode(',', $modSettings['enableThemes']); |
865 | 898 | |
866 | 899 | // Are we disabling it? |
867 | - if (isset($_GET['disabled'])) |
|
868 | - $enableThemes = array_diff($enableThemes, array($themeID)); |
|
900 | + if (isset($_GET['disabled'])) { |
|
901 | + $enableThemes = array_diff($enableThemes, array($themeID)); |
|
902 | + } |
|
869 | 903 | |
870 | 904 | // Nope? then enable it! |
871 | - else |
|
872 | - $enableThemes[] = (string) $themeID; |
|
905 | + else { |
|
906 | + $enableThemes[] = (string) $themeID; |
|
907 | + } |
|
873 | 908 | |
874 | 909 | // Update the setting. |
875 | 910 | $enableThemes = strtr(implode(',', $enableThemes), array(',,' => ',')); |
@@ -904,18 +939,21 @@ discard block |
||
904 | 939 | |
905 | 940 | $_SESSION['id_theme'] = 0; |
906 | 941 | |
907 | - if (isset($_GET['id'])) |
|
908 | - $_GET['th'] = $_GET['id']; |
|
942 | + if (isset($_GET['id'])) { |
|
943 | + $_GET['th'] = $_GET['id']; |
|
944 | + } |
|
909 | 945 | |
910 | 946 | // Saving a variant cause JS doesn't work - pretend it did ;) |
911 | 947 | if (isset($_POST['save'])) |
912 | 948 | { |
913 | 949 | // Which theme? |
914 | - foreach ($_POST['save'] as $k => $v) |
|
915 | - $_GET['th'] = (int) $k; |
|
950 | + foreach ($_POST['save'] as $k => $v) { |
|
951 | + $_GET['th'] = (int) $k; |
|
952 | + } |
|
916 | 953 | |
917 | - if (isset($_POST['vrt'][$k])) |
|
918 | - $_GET['vrt'] = $_POST['vrt'][$k]; |
|
954 | + if (isset($_POST['vrt'][$k])) { |
|
955 | + $_GET['vrt'] = $_POST['vrt'][$k]; |
|
956 | + } |
|
919 | 957 | } |
920 | 958 | |
921 | 959 | // Have we made a decision, or are we just browsing? |
@@ -1004,10 +1042,10 @@ discard block |
||
1004 | 1042 | ); |
1005 | 1043 | cache_put_data('theme_settings-' . $_GET['th'] . ':' . (int) $_REQUEST['u'], null, 90); |
1006 | 1044 | |
1007 | - if ($user_info['id'] == $_REQUEST['u']) |
|
1008 | - $_SESSION['id_variant'] = 0; |
|
1009 | - } |
|
1010 | - elseif ($_GET['th'] == 0) |
|
1045 | + if ($user_info['id'] == $_REQUEST['u']) { |
|
1046 | + $_SESSION['id_variant'] = 0; |
|
1047 | + } |
|
1048 | + } elseif ($_GET['th'] == 0) |
|
1011 | 1049 | { |
1012 | 1050 | // Remove any custom variants. |
1013 | 1051 | $smcFunc['db_query']('', ' |
@@ -1088,12 +1126,13 @@ discard block |
||
1088 | 1126 | ); |
1089 | 1127 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1090 | 1128 | { |
1091 | - if (!isset($context['available_themes'][$row['id_theme']])) |
|
1092 | - $context['available_themes'][$row['id_theme']] = array( |
|
1129 | + if (!isset($context['available_themes'][$row['id_theme']])) { |
|
1130 | + $context['available_themes'][$row['id_theme']] = array( |
|
1093 | 1131 | 'id' => $row['id_theme'], |
1094 | 1132 | 'selected' => $context['current_theme'] == $row['id_theme'], |
1095 | 1133 | 'num_users' => 0 |
1096 | 1134 | ); |
1135 | + } |
|
1097 | 1136 | $context['available_themes'][$row['id_theme']][$row['variable']] = $row['value']; |
1098 | 1137 | } |
1099 | 1138 | $smcFunc['db_free_result']($request); |
@@ -1106,9 +1145,9 @@ discard block |
||
1106 | 1145 | 'num_users' => 0 |
1107 | 1146 | ); |
1108 | 1147 | $guest_theme = 0; |
1148 | + } else { |
|
1149 | + $guest_theme = $modSettings['theme_guests']; |
|
1109 | 1150 | } |
1110 | - else |
|
1111 | - $guest_theme = $modSettings['theme_guests']; |
|
1112 | 1151 | |
1113 | 1152 | $request = $smcFunc['db_query']('', ' |
1114 | 1153 | SELECT id_theme, COUNT(*) AS the_count |
@@ -1121,15 +1160,17 @@ discard block |
||
1121 | 1160 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1122 | 1161 | { |
1123 | 1162 | // Figure out which theme it is they are REALLY using. |
1124 | - if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) |
|
1125 | - $row['id_theme'] = $guest_theme; |
|
1126 | - elseif (empty($modSettings['theme_allow'])) |
|
1127 | - $row['id_theme'] = $guest_theme; |
|
1163 | + if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) { |
|
1164 | + $row['id_theme'] = $guest_theme; |
|
1165 | + } elseif (empty($modSettings['theme_allow'])) { |
|
1166 | + $row['id_theme'] = $guest_theme; |
|
1167 | + } |
|
1128 | 1168 | |
1129 | - if (isset($context['available_themes'][$row['id_theme']])) |
|
1130 | - $context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count']; |
|
1131 | - else |
|
1132 | - $context['available_themes'][$guest_theme]['num_users'] += $row['the_count']; |
|
1169 | + if (isset($context['available_themes'][$row['id_theme']])) { |
|
1170 | + $context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count']; |
|
1171 | + } else { |
|
1172 | + $context['available_themes'][$guest_theme]['num_users'] += $row['the_count']; |
|
1173 | + } |
|
1133 | 1174 | } |
1134 | 1175 | $smcFunc['db_free_result']($request); |
1135 | 1176 | |
@@ -1148,8 +1189,9 @@ discard block |
||
1148 | 1189 | 'id_member' => isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? array(-1, $context['current_member']) : array(-1), |
1149 | 1190 | ) |
1150 | 1191 | ); |
1151 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1152 | - $variant_preferences[$row['id_theme']] = $row['value']; |
|
1192 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1193 | + $variant_preferences[$row['id_theme']] = $row['value']; |
|
1194 | + } |
|
1153 | 1195 | $smcFunc['db_free_result']($request); |
1154 | 1196 | } |
1155 | 1197 | |
@@ -1160,17 +1202,18 @@ discard block |
||
1160 | 1202 | foreach ($context['available_themes'] as $id_theme => $theme_data) |
1161 | 1203 | { |
1162 | 1204 | // Don't try to load the forum or board default theme's data... it doesn't have any! |
1163 | - if ($id_theme == 0) |
|
1164 | - continue; |
|
1205 | + if ($id_theme == 0) { |
|
1206 | + continue; |
|
1207 | + } |
|
1165 | 1208 | |
1166 | 1209 | // The thumbnail needs the correct path. |
1167 | 1210 | $settings['images_url'] = &$theme_data['images_url']; |
1168 | 1211 | |
1169 | - if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) |
|
1170 | - include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'); |
|
1171 | - elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) |
|
1172 | - include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'); |
|
1173 | - else |
|
1212 | + if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) { |
|
1213 | + include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'); |
|
1214 | + } elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) { |
|
1215 | + include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'); |
|
1216 | + } else |
|
1174 | 1217 | { |
1175 | 1218 | $txt['theme_thumbnail_href'] = $theme_data['images_url'] . '/thumbnail.png'; |
1176 | 1219 | $txt['theme_description'] = ''; |
@@ -1195,15 +1238,17 @@ discard block |
||
1195 | 1238 | loadLanguage('Settings'); |
1196 | 1239 | |
1197 | 1240 | $context['available_themes'][$id_theme]['variants'] = array(); |
1198 | - foreach ($settings['theme_variants'] as $variant) |
|
1199 | - $context['available_themes'][$id_theme]['variants'][$variant] = array( |
|
1241 | + foreach ($settings['theme_variants'] as $variant) { |
|
1242 | + $context['available_themes'][$id_theme]['variants'][$variant] = array( |
|
1200 | 1243 | 'label' => isset($txt['variant_' . $variant]) ? $txt['variant_' . $variant] : $variant, |
1201 | 1244 | 'thumbnail' => !file_exists($theme_data['theme_dir'] . '/images/thumbnail.png') || file_exists($theme_data['theme_dir'] . '/images/thumbnail_' . $variant . '.png') ? $theme_data['images_url'] . '/thumbnail_' . $variant . '.png' : ($theme_data['images_url'] . '/thumbnail.png'), |
1202 | 1245 | ); |
1246 | + } |
|
1203 | 1247 | |
1204 | 1248 | $context['available_themes'][$id_theme]['selected_variant'] = isset($_GET['vrt']) ? $_GET['vrt'] : (!empty($variant_preferences[$id_theme]) ? $variant_preferences[$id_theme] : (!empty($settings['default_variant']) ? $settings['default_variant'] : $settings['theme_variants'][0])); |
1205 | - if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) |
|
1206 | - $context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0]; |
|
1249 | + if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) { |
|
1250 | + $context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0]; |
|
1251 | + } |
|
1207 | 1252 | |
1208 | 1253 | $context['available_themes'][$id_theme]['thumbnail_href'] = $context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail']; |
1209 | 1254 | // Allow themes to override the text. |
@@ -1219,8 +1264,9 @@ discard block |
||
1219 | 1264 | // As long as we're not doing the default theme... |
1220 | 1265 | if (!isset($_REQUEST['u']) || $_REQUEST['u'] >= 0) |
1221 | 1266 | { |
1222 | - if ($guest_theme != 0) |
|
1223 | - $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
1267 | + if ($guest_theme != 0) { |
|
1268 | + $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
1269 | + } |
|
1224 | 1270 | |
1225 | 1271 | $context['available_themes'][0]['id'] = 0; |
1226 | 1272 | $context['available_themes'][0]['name'] = $txt['theme_forum_default']; |
@@ -1269,14 +1315,16 @@ discard block |
||
1269 | 1315 | $action = $smcFunc['htmlspecialchars'](trim($_GET['do'])); |
1270 | 1316 | |
1271 | 1317 | // Got any info from the specific form? |
1272 | - if (!isset($_POST['save_' . $action])) |
|
1273 | - fatal_lang_error('theme_install_no_action', false); |
|
1318 | + if (!isset($_POST['save_' . $action])) { |
|
1319 | + fatal_lang_error('theme_install_no_action', false); |
|
1320 | + } |
|
1274 | 1321 | |
1275 | 1322 | validateToken('admin-t-' . $action); |
1276 | 1323 | |
1277 | 1324 | // Hopefully the themes directory is writable, or we might have a problem. |
1278 | - if (!is_writable($themedir)) |
|
1279 | - fatal_lang_error('theme_install_write_error', 'critical'); |
|
1325 | + if (!is_writable($themedir)) { |
|
1326 | + fatal_lang_error('theme_install_write_error', 'critical'); |
|
1327 | + } |
|
1280 | 1328 | |
1281 | 1329 | // Call the function and handle the result. |
1282 | 1330 | $result = $subActions[$action](); |
@@ -1291,9 +1339,10 @@ discard block |
||
1291 | 1339 | } |
1292 | 1340 | |
1293 | 1341 | // Nope, show a nice error. |
1294 | - else |
|
1295 | - fatal_lang_error('theme_install_no_action', false); |
|
1296 | -} |
|
1342 | + else { |
|
1343 | + fatal_lang_error('theme_install_no_action', false); |
|
1344 | + } |
|
1345 | + } |
|
1297 | 1346 | |
1298 | 1347 | /** |
1299 | 1348 | * Installs a theme from a theme package. |
@@ -1309,8 +1358,9 @@ discard block |
||
1309 | 1358 | $dirtemp = $themedir . '/temp'; |
1310 | 1359 | |
1311 | 1360 | // Make sure the temp dir doesn't already exist |
1312 | - if (file_exists($dirtemp)) |
|
1313 | - remove_dir($dirtemp); |
|
1361 | + if (file_exists($dirtemp)) { |
|
1362 | + remove_dir($dirtemp); |
|
1363 | + } |
|
1314 | 1364 | |
1315 | 1365 | // Create the temp dir. |
1316 | 1366 | mkdir($dirtemp, 0777); |
@@ -1322,17 +1372,20 @@ discard block |
||
1322 | 1372 | smf_chmod($dirtemp, '0755'); |
1323 | 1373 | |
1324 | 1374 | // How about now? |
1325 | - if (!is_writable($dirtemp)) |
|
1326 | - fatal_lang_error('theme_install_write_error', 'critical'); |
|
1375 | + if (!is_writable($dirtemp)) { |
|
1376 | + fatal_lang_error('theme_install_write_error', 'critical'); |
|
1377 | + } |
|
1327 | 1378 | } |
1328 | 1379 | |
1329 | 1380 | // This happens when the admin session is gone and the user has to login again. |
1330 | - if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) |
|
1331 | - redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']); |
|
1381 | + if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) { |
|
1382 | + redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']); |
|
1383 | + } |
|
1332 | 1384 | |
1333 | 1385 | // Another error check layer, something went wrong with the upload. |
1334 | - if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) |
|
1335 | - fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false); |
|
1386 | + if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) { |
|
1387 | + fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false); |
|
1388 | + } |
|
1336 | 1389 | |
1337 | 1390 | // Get the theme's name. |
1338 | 1391 | $name = pathinfo($_FILES['theme_gz']['name'], PATHINFO_FILENAME); |
@@ -1363,11 +1416,10 @@ discard block |
||
1363 | 1416 | |
1364 | 1417 | // return all the info. |
1365 | 1418 | return $context['to_install']; |
1419 | + } else { |
|
1420 | + fatal_lang_error('theme_install_error_title', false); |
|
1421 | + } |
|
1366 | 1422 | } |
1367 | - |
|
1368 | - else |
|
1369 | - fatal_lang_error('theme_install_error_title', false); |
|
1370 | -} |
|
1371 | 1423 | |
1372 | 1424 | /** |
1373 | 1425 | * Makes a copy from the default theme, assigns a name for it and installs it. |
@@ -1381,15 +1433,17 @@ discard block |
||
1381 | 1433 | global $forum_version; |
1382 | 1434 | |
1383 | 1435 | // There's gotta be something to work with. |
1384 | - if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) |
|
1385 | - fatal_lang_error('theme_install_error_title', false); |
|
1436 | + if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) { |
|
1437 | + fatal_lang_error('theme_install_error_title', false); |
|
1438 | + } |
|
1386 | 1439 | |
1387 | 1440 | // Get a cleaner version. |
1388 | 1441 | $name = preg_replace('~[^A-Za-z0-9_\- ]~', '', $_REQUEST['copy']); |
1389 | 1442 | |
1390 | 1443 | // Is there a theme already named like this? |
1391 | - if (file_exists($themedir . '/' . $name)) |
|
1392 | - fatal_lang_error('theme_install_already_dir', false); |
|
1444 | + if (file_exists($themedir . '/' . $name)) { |
|
1445 | + fatal_lang_error('theme_install_already_dir', false); |
|
1446 | + } |
|
1393 | 1447 | |
1394 | 1448 | // This is a brand new theme so set all possible values. |
1395 | 1449 | $context['to_install'] = array( |
@@ -1409,8 +1463,9 @@ discard block |
||
1409 | 1463 | |
1410 | 1464 | // Buy some time. |
1411 | 1465 | @set_time_limit(600); |
1412 | - if (function_exists('apache_reset_timeout')) |
|
1413 | - @apache_reset_timeout(); |
|
1466 | + if (function_exists('apache_reset_timeout')) { |
|
1467 | + @apache_reset_timeout(); |
|
1468 | + } |
|
1414 | 1469 | |
1415 | 1470 | // Create subdirectories for css and javascript files. |
1416 | 1471 | mkdir($context['to_install']['theme_dir'] . '/css', 0777); |
@@ -1446,12 +1501,13 @@ discard block |
||
1446 | 1501 | |
1447 | 1502 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1448 | 1503 | { |
1449 | - if ($row['variable'] == 'theme_templates') |
|
1450 | - $theme_templates = $row['value']; |
|
1451 | - elseif ($row['variable'] == 'theme_layers') |
|
1452 | - $theme_layers = $row['value']; |
|
1453 | - else |
|
1454 | - continue; |
|
1504 | + if ($row['variable'] == 'theme_templates') { |
|
1505 | + $theme_templates = $row['value']; |
|
1506 | + } elseif ($row['variable'] == 'theme_layers') { |
|
1507 | + $theme_layers = $row['value']; |
|
1508 | + } else { |
|
1509 | + continue; |
|
1510 | + } |
|
1455 | 1511 | } |
1456 | 1512 | |
1457 | 1513 | $smcFunc['db_free_result']($request); |
@@ -1510,12 +1566,14 @@ discard block |
||
1510 | 1566 | global $themedir, $themeurl, $context; |
1511 | 1567 | |
1512 | 1568 | // Cannot use the theme dir as a theme dir. |
1513 | - if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) |
|
1514 | - fatal_lang_error('theme_install_invalid_dir', false); |
|
1569 | + if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) { |
|
1570 | + fatal_lang_error('theme_install_invalid_dir', false); |
|
1571 | + } |
|
1515 | 1572 | |
1516 | 1573 | // Check is there is "something" on the dir. |
1517 | - elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) |
|
1518 | - fatal_lang_error('theme_install_error', false); |
|
1574 | + elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) { |
|
1575 | + fatal_lang_error('theme_install_error', false); |
|
1576 | + } |
|
1519 | 1577 | |
1520 | 1578 | $name = basename($_REQUEST['theme_dir']); |
1521 | 1579 | $name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $name); |
@@ -1559,24 +1617,27 @@ discard block |
||
1559 | 1617 | } |
1560 | 1618 | |
1561 | 1619 | // Any special layers? |
1562 | - if (isset($settings['catch_action']['layers'])) |
|
1563 | - $context['template_layers'] = $settings['catch_action']['layers']; |
|
1620 | + if (isset($settings['catch_action']['layers'])) { |
|
1621 | + $context['template_layers'] = $settings['catch_action']['layers']; |
|
1622 | + } |
|
1564 | 1623 | |
1565 | 1624 | // Any function to call? |
1566 | 1625 | if (isset($settings['catch_action']['function'])) |
1567 | 1626 | { |
1568 | 1627 | $hook = $settings['catch_action']['function']; |
1569 | 1628 | |
1570 | - if (!isset($settings['catch_action']['filename'])) |
|
1571 | - $settings['catch_action']['filename'] = ''; |
|
1629 | + if (!isset($settings['catch_action']['filename'])) { |
|
1630 | + $settings['catch_action']['filename'] = ''; |
|
1631 | + } |
|
1572 | 1632 | |
1573 | 1633 | add_integration_function('integrate_wrap_action', $hook, false, $settings['catch_action']['filename'], false); |
1574 | 1634 | call_integration_hook('integrate_wrap_action'); |
1575 | 1635 | } |
1576 | 1636 | // And finally, the main sub template ;). |
1577 | - if (isset($settings['catch_action']['sub_template'])) |
|
1578 | - $context['sub_template'] = $settings['catch_action']['sub_template']; |
|
1579 | -} |
|
1637 | + if (isset($settings['catch_action']['sub_template'])) { |
|
1638 | + $context['sub_template'] = $settings['catch_action']['sub_template']; |
|
1639 | + } |
|
1640 | + } |
|
1580 | 1641 | |
1581 | 1642 | /** |
1582 | 1643 | * Set an option via javascript. |
@@ -1595,12 +1656,14 @@ discard block |
||
1595 | 1656 | checkSession('get'); |
1596 | 1657 | |
1597 | 1658 | // This good-for-nothing pixel is being used to keep the session alive. |
1598 | - if (empty($_GET['var']) || !isset($_GET['val'])) |
|
1599 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
1659 | + if (empty($_GET['var']) || !isset($_GET['val'])) { |
|
1660 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
1661 | + } |
|
1600 | 1662 | |
1601 | 1663 | // Sorry, guests can't go any further than this. |
1602 | - if ($user_info['is_guest'] || $user_info['id'] == 0) |
|
1603 | - obExit(false); |
|
1664 | + if ($user_info['is_guest'] || $user_info['id'] == 0) { |
|
1665 | + obExit(false); |
|
1666 | + } |
|
1604 | 1667 | |
1605 | 1668 | $reservedVars = array( |
1606 | 1669 | 'actual_theme_url', |
@@ -1623,8 +1686,9 @@ discard block |
||
1623 | 1686 | ); |
1624 | 1687 | |
1625 | 1688 | // Can't change reserved vars. |
1626 | - if (in_array(strtolower($_GET['var']), $reservedVars)) |
|
1627 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
1689 | + if (in_array(strtolower($_GET['var']), $reservedVars)) { |
|
1690 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
1691 | + } |
|
1628 | 1692 | |
1629 | 1693 | // Use a specific theme? |
1630 | 1694 | if (isset($_GET['th']) || isset($_GET['id'])) |
@@ -1640,8 +1704,9 @@ discard block |
||
1640 | 1704 | { |
1641 | 1705 | $options['admin_preferences'] = !empty($options['admin_preferences']) ? $smcFunc['json_decode']($options['admin_preferences'], true) : array(); |
1642 | 1706 | // New thingy... |
1643 | - if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) |
|
1644 | - $options['admin_preferences'][$_GET['admin_key']] = $_GET['val']; |
|
1707 | + if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) { |
|
1708 | + $options['admin_preferences'][$_GET['admin_key']] = $_GET['val']; |
|
1709 | + } |
|
1645 | 1710 | |
1646 | 1711 | // Change the value to be something nice, |
1647 | 1712 | $_GET['val'] = $smcFunc['json_encode']($options['admin_preferences']); |
@@ -1671,8 +1736,9 @@ discard block |
||
1671 | 1736 | global $context, $scripturl, $boarddir, $smcFunc, $txt; |
1672 | 1737 | |
1673 | 1738 | // @todo Should this be removed? |
1674 | - if (isset($_REQUEST['preview'])) |
|
1675 | - die('die() with fire'); |
|
1739 | + if (isset($_REQUEST['preview'])) { |
|
1740 | + die('die() with fire'); |
|
1741 | + } |
|
1676 | 1742 | |
1677 | 1743 | isAllowedTo('admin_forum'); |
1678 | 1744 | loadTemplate('Themes'); |
@@ -1686,11 +1752,11 @@ discard block |
||
1686 | 1752 | foreach ($context['themes'] as $key => $theme) |
1687 | 1753 | { |
1688 | 1754 | // There has to be a Settings template! |
1689 | - if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) |
|
1690 | - unset($context['themes'][$key]); |
|
1691 | - |
|
1692 | - else |
|
1693 | - $context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css'); |
|
1755 | + if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) { |
|
1756 | + unset($context['themes'][$key]); |
|
1757 | + } else { |
|
1758 | + $context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css'); |
|
1759 | + } |
|
1694 | 1760 | } |
1695 | 1761 | |
1696 | 1762 | $context['sub_template'] = 'edit_list'; |
@@ -1705,22 +1771,24 @@ discard block |
||
1705 | 1771 | $context['theme_id'] = $currentTheme['id']; |
1706 | 1772 | $context['browse_title'] = sprintf($txt['themeadmin_browsing_theme'], $currentTheme['name']); |
1707 | 1773 | |
1708 | - if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) |
|
1709 | - fatal_lang_error('theme_edit_missing', false); |
|
1774 | + if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) { |
|
1775 | + fatal_lang_error('theme_edit_missing', false); |
|
1776 | + } |
|
1710 | 1777 | |
1711 | 1778 | if (!isset($_REQUEST['filename'])) |
1712 | 1779 | { |
1713 | 1780 | if (isset($_GET['directory'])) |
1714 | 1781 | { |
1715 | - if (substr($_GET['directory'], 0, 1) == '.') |
|
1716 | - $_GET['directory'] = ''; |
|
1717 | - else |
|
1782 | + if (substr($_GET['directory'], 0, 1) == '.') { |
|
1783 | + $_GET['directory'] = ''; |
|
1784 | + } else |
|
1718 | 1785 | { |
1719 | 1786 | $_GET['directory'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_GET['directory']); |
1720 | 1787 | |
1721 | 1788 | $temp = realpath($currentTheme['theme_dir'] . '/' . $_GET['directory']); |
1722 | - if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) |
|
1723 | - $_GET['directory'] = ''; |
|
1789 | + if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) { |
|
1790 | + $_GET['directory'] = ''; |
|
1791 | + } |
|
1724 | 1792 | } |
1725 | 1793 | } |
1726 | 1794 | |
@@ -1739,44 +1807,47 @@ discard block |
||
1739 | 1807 | 'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $temp, |
1740 | 1808 | 'size' => '', |
1741 | 1809 | )); |
1810 | + } else { |
|
1811 | + $context['theme_files'] = get_file_listing($currentTheme['theme_dir'], ''); |
|
1742 | 1812 | } |
1743 | - else |
|
1744 | - $context['theme_files'] = get_file_listing($currentTheme['theme_dir'], ''); |
|
1745 | 1813 | |
1746 | 1814 | // Do not list minified_ files |
1747 | 1815 | foreach($context['theme_files'] as $key=>$file) |
1748 | 1816 | { |
1749 | - if(strpos($file['filename'], 'minified_') !== FALSE) |
|
1750 | - unset($context['theme_files'][$key]); |
|
1817 | + if(strpos($file['filename'], 'minified_') !== FALSE) { |
|
1818 | + unset($context['theme_files'][$key]); |
|
1819 | + } |
|
1751 | 1820 | } |
1752 | 1821 | |
1753 | 1822 | $context['sub_template'] = 'edit_browse'; |
1754 | 1823 | |
1755 | 1824 | return; |
1756 | - } |
|
1757 | - else |
|
1825 | + } else |
|
1758 | 1826 | { |
1759 | - if (substr($_REQUEST['filename'], 0, 1) == '.') |
|
1760 | - $_REQUEST['filename'] = ''; |
|
1761 | - else |
|
1827 | + if (substr($_REQUEST['filename'], 0, 1) == '.') { |
|
1828 | + $_REQUEST['filename'] = ''; |
|
1829 | + } else |
|
1762 | 1830 | { |
1763 | 1831 | $_REQUEST['filename'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_REQUEST['filename']); |
1764 | 1832 | |
1765 | 1833 | $temp = realpath($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
1766 | - if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) |
|
1767 | - $_REQUEST['filename'] = ''; |
|
1834 | + if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) { |
|
1835 | + $_REQUEST['filename'] = ''; |
|
1836 | + } |
|
1768 | 1837 | } |
1769 | 1838 | |
1770 | - if (empty($_REQUEST['filename'])) |
|
1771 | - fatal_lang_error('theme_edit_missing', false); |
|
1839 | + if (empty($_REQUEST['filename'])) { |
|
1840 | + fatal_lang_error('theme_edit_missing', false); |
|
1841 | + } |
|
1772 | 1842 | } |
1773 | 1843 | |
1774 | 1844 | if (isset($_POST['save'])) |
1775 | 1845 | { |
1776 | 1846 | if (checkSession('post', '', false) == '' && validateToken('admin-te-' . md5($_GET['th'] . '-' . $_REQUEST['filename']), 'post', false) == true) |
1777 | 1847 | { |
1778 | - if (is_array($_POST['entire_file'])) |
|
1779 | - $_POST['entire_file'] = implode("\n", $_POST['entire_file']); |
|
1848 | + if (is_array($_POST['entire_file'])) { |
|
1849 | + $_POST['entire_file'] = implode("\n", $_POST['entire_file']); |
|
1850 | + } |
|
1780 | 1851 | |
1781 | 1852 | $_POST['entire_file'] = rtrim(strtr($_POST['entire_file'], array("\r" => '', ' ' => "\t"))); |
1782 | 1853 | |
@@ -1788,10 +1859,11 @@ discard block |
||
1788 | 1859 | fclose($fp); |
1789 | 1860 | |
1790 | 1861 | $error = @file_get_contents($currentTheme['theme_url'] . '/tmp_' . session_id() . '.php'); |
1791 | - if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) |
|
1792 | - $error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'; |
|
1793 | - else |
|
1794 | - unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'); |
|
1862 | + if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) { |
|
1863 | + $error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'; |
|
1864 | + } else { |
|
1865 | + unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'); |
|
1866 | + } |
|
1795 | 1867 | } |
1796 | 1868 | |
1797 | 1869 | if (!isset($error_file)) |
@@ -1812,10 +1884,11 @@ discard block |
||
1812 | 1884 | $context['sub_template'] = 'edit_file'; |
1813 | 1885 | |
1814 | 1886 | // Recycle the submitted data. |
1815 | - if (is_array($_POST['entire_file'])) |
|
1816 | - $context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file'])); |
|
1817 | - else |
|
1818 | - $context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']); |
|
1887 | + if (is_array($_POST['entire_file'])) { |
|
1888 | + $context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file'])); |
|
1889 | + } else { |
|
1890 | + $context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']); |
|
1891 | + } |
|
1819 | 1892 | |
1820 | 1893 | $context['edit_filename'] = $smcFunc['htmlspecialchars']($_POST['filename']); |
1821 | 1894 | |
@@ -1838,17 +1911,17 @@ discard block |
||
1838 | 1911 | $context['sub_template'] = 'edit_style'; |
1839 | 1912 | |
1840 | 1913 | $context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(file_get_contents($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']), array("\t" => ' '))); |
1841 | - } |
|
1842 | - elseif (substr($_REQUEST['filename'], -13) == '.template.php') |
|
1914 | + } elseif (substr($_REQUEST['filename'], -13) == '.template.php') |
|
1843 | 1915 | { |
1844 | 1916 | $context['sub_template'] = 'edit_template'; |
1845 | 1917 | |
1846 | - if (!isset($error_file)) |
|
1847 | - $file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
|
1848 | - else |
|
1918 | + if (!isset($error_file)) { |
|
1919 | + $file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
|
1920 | + } else |
|
1849 | 1921 | { |
1850 | - if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) |
|
1851 | - $context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2]; |
|
1922 | + if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) { |
|
1923 | + $context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2]; |
|
1924 | + } |
|
1852 | 1925 | $file_data = file($error_file); |
1853 | 1926 | unlink($error_file); |
1854 | 1927 | } |
@@ -1862,8 +1935,9 @@ discard block |
||
1862 | 1935 | // Try to format the functions a little nicer... |
1863 | 1936 | $context['file_parts'][$j]['data'] = trim($context['file_parts'][$j]['data']) . "\n"; |
1864 | 1937 | |
1865 | - if (empty($context['file_parts'][$j]['lines'])) |
|
1866 | - unset($context['file_parts'][$j]); |
|
1938 | + if (empty($context['file_parts'][$j]['lines'])) { |
|
1939 | + unset($context['file_parts'][$j]); |
|
1940 | + } |
|
1867 | 1941 | $context['file_parts'][++$j] = array('lines' => 0, 'line' => $i + 1, 'data' => ''); |
1868 | 1942 | } |
1869 | 1943 | |
@@ -1872,8 +1946,7 @@ discard block |
||
1872 | 1946 | } |
1873 | 1947 | |
1874 | 1948 | $context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(implode('', $file_data), array("\t" => ' '))); |
1875 | - } |
|
1876 | - else |
|
1949 | + } else |
|
1877 | 1950 | { |
1878 | 1951 | $context['sub_template'] = 'edit_file'; |
1879 | 1952 | |
@@ -1899,8 +1972,9 @@ discard block |
||
1899 | 1972 | |
1900 | 1973 | $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
1901 | 1974 | |
1902 | - if (empty($_GET['th'])) |
|
1903 | - fatal_lang_error('theme_install_invalid_id'); |
|
1975 | + if (empty($_GET['th'])) { |
|
1976 | + fatal_lang_error('theme_install_invalid_id'); |
|
1977 | + } |
|
1904 | 1978 | |
1905 | 1979 | // Get the theme info. |
1906 | 1980 | $theme = get_single_theme($_GET['th']); |
@@ -1908,25 +1982,24 @@ discard block |
||
1908 | 1982 | |
1909 | 1983 | if (isset($_REQUEST['template']) && preg_match('~[\./\\\\:\0]~', $_REQUEST['template']) == 0) |
1910 | 1984 | { |
1911 | - if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) |
|
1912 | - $filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'; |
|
1913 | - |
|
1914 | - else |
|
1915 | - fatal_lang_error('no_access', false); |
|
1985 | + if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) { |
|
1986 | + $filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'; |
|
1987 | + } else { |
|
1988 | + fatal_lang_error('no_access', false); |
|
1989 | + } |
|
1916 | 1990 | |
1917 | 1991 | $fp = fopen($theme['theme_dir'] . '/' . $_REQUEST['template'] . '.template.php', 'w'); |
1918 | 1992 | fwrite($fp, file_get_contents($filename)); |
1919 | 1993 | fclose($fp); |
1920 | 1994 | |
1921 | 1995 | redirectexit('action=admin;area=theme;th=' . $context['theme_id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=copy'); |
1922 | - } |
|
1923 | - elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0) |
|
1996 | + } elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0) |
|
1924 | 1997 | { |
1925 | - if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) |
|
1926 | - $filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'; |
|
1927 | - |
|
1928 | - else |
|
1929 | - fatal_lang_error('no_access', false); |
|
1998 | + if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) { |
|
1999 | + $filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'; |
|
2000 | + } else { |
|
2001 | + fatal_lang_error('no_access', false); |
|
2002 | + } |
|
1930 | 2003 | |
1931 | 2004 | $fp = fopen($theme['theme_dir'] . '/languages/' . $_REQUEST['lang_file'] . '.php', 'w'); |
1932 | 2005 | fwrite($fp, file_get_contents($filename)); |
@@ -1941,16 +2014,18 @@ discard block |
||
1941 | 2014 | $dir = dir($settings['default_theme_dir']); |
1942 | 2015 | while ($entry = $dir->read()) |
1943 | 2016 | { |
1944 | - if (substr($entry, -13) == '.template.php') |
|
1945 | - $templates[] = substr($entry, 0, -13); |
|
2017 | + if (substr($entry, -13) == '.template.php') { |
|
2018 | + $templates[] = substr($entry, 0, -13); |
|
2019 | + } |
|
1946 | 2020 | } |
1947 | 2021 | $dir->close(); |
1948 | 2022 | |
1949 | 2023 | $dir = dir($settings['default_theme_dir'] . '/languages'); |
1950 | 2024 | while ($entry = $dir->read()) |
1951 | 2025 | { |
1952 | - if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) |
|
1953 | - $lang_files[] = $matches[1]; |
|
2026 | + if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) { |
|
2027 | + $lang_files[] = $matches[1]; |
|
2028 | + } |
|
1954 | 2029 | } |
1955 | 2030 | $dir->close(); |
1956 | 2031 | |
@@ -1958,21 +2033,23 @@ discard block |
||
1958 | 2033 | natcasesort($lang_files); |
1959 | 2034 | |
1960 | 2035 | $context['available_templates'] = array(); |
1961 | - foreach ($templates as $template) |
|
1962 | - $context['available_templates'][$template] = array( |
|
2036 | + foreach ($templates as $template) { |
|
2037 | + $context['available_templates'][$template] = array( |
|
1963 | 2038 | 'filename' => $template . '.template.php', |
1964 | 2039 | 'value' => $template, |
1965 | 2040 | 'already_exists' => false, |
1966 | 2041 | 'can_copy' => is_writable($theme['theme_dir']), |
1967 | 2042 | ); |
2043 | + } |
|
1968 | 2044 | $context['available_language_files'] = array(); |
1969 | - foreach ($lang_files as $file) |
|
1970 | - $context['available_language_files'][$file] = array( |
|
2045 | + foreach ($lang_files as $file) { |
|
2046 | + $context['available_language_files'][$file] = array( |
|
1971 | 2047 | 'filename' => $file . '.php', |
1972 | 2048 | 'value' => $file, |
1973 | 2049 | 'already_exists' => false, |
1974 | 2050 | 'can_copy' => file_exists($theme['theme_dir'] . '/languages') ? is_writable($theme['theme_dir'] . '/languages') : is_writable($theme['theme_dir']), |
1975 | 2051 | ); |
2052 | + } |
|
1976 | 2053 | |
1977 | 2054 | $dir = dir($theme['theme_dir']); |
1978 | 2055 | while ($entry = $dir->read()) |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Mark a board or multiple boards read. |
@@ -28,14 +29,16 @@ discard block |
||
28 | 29 | global $user_info, $modSettings, $smcFunc; |
29 | 30 | |
30 | 31 | // Force $boards to be an array. |
31 | - if (!is_array($boards)) |
|
32 | - $boards = array($boards); |
|
33 | - else |
|
34 | - $boards = array_unique($boards); |
|
32 | + if (!is_array($boards)) { |
|
33 | + $boards = array($boards); |
|
34 | + } else { |
|
35 | + $boards = array_unique($boards); |
|
36 | + } |
|
35 | 37 | |
36 | 38 | // No boards, nothing to mark as read. |
37 | - if (empty($boards)) |
|
38 | - return; |
|
39 | + if (empty($boards)) { |
|
40 | + return; |
|
41 | + } |
|
39 | 42 | |
40 | 43 | // Allow the user to mark a board as unread. |
41 | 44 | if ($unread) |
@@ -65,8 +68,9 @@ discard block |
||
65 | 68 | else |
66 | 69 | { |
67 | 70 | $markRead = array(); |
68 | - foreach ($boards as $board) |
|
69 | - $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $board); |
|
71 | + foreach ($boards as $board) { |
|
72 | + $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $board); |
|
73 | + } |
|
70 | 74 | |
71 | 75 | // Update log_mark_read and log_boards. |
72 | 76 | $smcFunc['db_insert']('replace', |
@@ -99,8 +103,9 @@ discard block |
||
99 | 103 | list ($lowest_topic) = $smcFunc['db_fetch_row']($result); |
100 | 104 | $smcFunc['db_free_result']($result); |
101 | 105 | |
102 | - if (empty($lowest_topic)) |
|
103 | - return; |
|
106 | + if (empty($lowest_topic)) { |
|
107 | + return; |
|
108 | + } |
|
104 | 109 | |
105 | 110 | // @todo SLOW This query seems to eat it sometimes. |
106 | 111 | $result = $smcFunc['db_query']('', ' |
@@ -118,12 +123,13 @@ discard block |
||
118 | 123 | ) |
119 | 124 | ); |
120 | 125 | $topics = array(); |
121 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
122 | - $topics[] = $row['id_topic']; |
|
126 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
127 | + $topics[] = $row['id_topic']; |
|
128 | + } |
|
123 | 129 | $smcFunc['db_free_result']($result); |
124 | 130 | |
125 | - if (!empty($topics)) |
|
126 | - $smcFunc['db_query']('', ' |
|
131 | + if (!empty($topics)) { |
|
132 | + $smcFunc['db_query']('', ' |
|
127 | 133 | DELETE FROM {db_prefix}log_topics |
128 | 134 | WHERE id_member = {int:current_member} |
129 | 135 | AND id_topic IN ({array_int:topic_list})', |
@@ -132,7 +138,8 @@ discard block |
||
132 | 138 | 'topic_list' => $topics, |
133 | 139 | ) |
134 | 140 | ); |
135 | -} |
|
141 | + } |
|
142 | + } |
|
136 | 143 | |
137 | 144 | /** |
138 | 145 | * Mark one or more boards as read. |
@@ -157,23 +164,26 @@ discard block |
||
157 | 164 | ) |
158 | 165 | ); |
159 | 166 | $boards = array(); |
160 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
161 | - $boards[] = $row['id_board']; |
|
167 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
168 | + $boards[] = $row['id_board']; |
|
169 | + } |
|
162 | 170 | $smcFunc['db_free_result']($result); |
163 | 171 | |
164 | - if (!empty($boards)) |
|
165 | - markBoardsRead($boards, isset($_REQUEST['unread'])); |
|
172 | + if (!empty($boards)) { |
|
173 | + markBoardsRead($boards, isset($_REQUEST['unread'])); |
|
174 | + } |
|
166 | 175 | |
167 | 176 | $_SESSION['id_msg_last_visit'] = $modSettings['maxMsgID']; |
168 | - if (!empty($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'action=unread') !== false) |
|
169 | - redirectexit('action=unread'); |
|
177 | + if (!empty($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'action=unread') !== false) { |
|
178 | + redirectexit('action=unread'); |
|
179 | + } |
|
170 | 180 | |
171 | - if (isset($_SESSION['topicseen_cache'])) |
|
172 | - $_SESSION['topicseen_cache'] = array(); |
|
181 | + if (isset($_SESSION['topicseen_cache'])) { |
|
182 | + $_SESSION['topicseen_cache'] = array(); |
|
183 | + } |
|
173 | 184 | |
174 | 185 | redirectexit(); |
175 | - } |
|
176 | - elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies') |
|
186 | + } elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies') |
|
177 | 187 | { |
178 | 188 | // Make sure all the topics are integers! |
179 | 189 | $topics = array_map('intval', explode('-', $_REQUEST['topics'])); |
@@ -189,13 +199,15 @@ discard block |
||
189 | 199 | ) |
190 | 200 | ); |
191 | 201 | $logged_topics = array(); |
192 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
193 | - $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
202 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
203 | + $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
204 | + } |
|
194 | 205 | $smcFunc['db_free_result']($request); |
195 | 206 | |
196 | 207 | $markRead = array(); |
197 | - foreach ($topics as $id_topic) |
|
198 | - $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $id_topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
208 | + foreach ($topics as $id_topic) { |
|
209 | + $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $id_topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
210 | + } |
|
199 | 211 | |
200 | 212 | $smcFunc['db_insert']('replace', |
201 | 213 | '{db_prefix}log_topics', |
@@ -204,8 +216,9 @@ discard block |
||
204 | 216 | array('id_member', 'id_topic') |
205 | 217 | ); |
206 | 218 | |
207 | - if (isset($_SESSION['topicseen_cache'])) |
|
208 | - $_SESSION['topicseen_cache'] = array(); |
|
219 | + if (isset($_SESSION['topicseen_cache'])) { |
|
220 | + $_SESSION['topicseen_cache'] = array(); |
|
221 | + } |
|
209 | 222 | |
210 | 223 | redirectexit('action=unreadreplies'); |
211 | 224 | } |
@@ -230,11 +243,13 @@ discard block |
||
230 | 243 | if (!empty($_GET['t'])) |
231 | 244 | { |
232 | 245 | // If they read the whole topic, go back to the beginning. |
233 | - if ($_GET['t'] >= $topicinfo['id_last_msg']) |
|
234 | - $earlyMsg = 0; |
|
246 | + if ($_GET['t'] >= $topicinfo['id_last_msg']) { |
|
247 | + $earlyMsg = 0; |
|
248 | + } |
|
235 | 249 | // If they want to mark the whole thing read, same. |
236 | - elseif ($_GET['t'] <= $topicinfo['id_first_msg']) |
|
237 | - $earlyMsg = 0; |
|
250 | + elseif ($_GET['t'] <= $topicinfo['id_first_msg']) { |
|
251 | + $earlyMsg = 0; |
|
252 | + } |
|
238 | 253 | // Otherwise, get the latest message before the named one. |
239 | 254 | else |
240 | 255 | { |
@@ -255,9 +270,9 @@ discard block |
||
255 | 270 | } |
256 | 271 | } |
257 | 272 | // Marking read from first page? That's the whole topic. |
258 | - elseif ($_REQUEST['start'] == 0) |
|
259 | - $earlyMsg = 0; |
|
260 | - else |
|
273 | + elseif ($_REQUEST['start'] == 0) { |
|
274 | + $earlyMsg = 0; |
|
275 | + } else |
|
261 | 276 | { |
262 | 277 | $result = $smcFunc['db_query']('', ' |
263 | 278 | SELECT id_msg |
@@ -285,8 +300,7 @@ discard block |
||
285 | 300 | ); |
286 | 301 | |
287 | 302 | redirectexit('board=' . $board . '.0'); |
288 | - } |
|
289 | - else |
|
303 | + } else |
|
290 | 304 | { |
291 | 305 | $categories = array(); |
292 | 306 | $boards = array(); |
@@ -294,17 +308,20 @@ discard block |
||
294 | 308 | if (isset($_REQUEST['c'])) |
295 | 309 | { |
296 | 310 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
297 | - foreach ($_REQUEST['c'] as $c) |
|
298 | - $categories[] = (int) $c; |
|
311 | + foreach ($_REQUEST['c'] as $c) { |
|
312 | + $categories[] = (int) $c; |
|
313 | + } |
|
299 | 314 | } |
300 | 315 | if (isset($_REQUEST['boards'])) |
301 | 316 | { |
302 | 317 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
303 | - foreach ($_REQUEST['boards'] as $b) |
|
304 | - $boards[] = (int) $b; |
|
318 | + foreach ($_REQUEST['boards'] as $b) { |
|
319 | + $boards[] = (int) $b; |
|
320 | + } |
|
321 | + } |
|
322 | + if (!empty($board)) { |
|
323 | + $boards[] = (int) $board; |
|
305 | 324 | } |
306 | - if (!empty($board)) |
|
307 | - $boards[] = (int) $board; |
|
308 | 325 | |
309 | 326 | if (isset($_REQUEST['children']) && !empty($boards)) |
310 | 327 | { |
@@ -324,9 +341,10 @@ discard block |
||
324 | 341 | 'board_list' => $boards, |
325 | 342 | ) |
326 | 343 | ); |
327 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
328 | - if (in_array($row['id_parent'], $boards)) |
|
344 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
345 | + if (in_array($row['id_parent'], $boards)) |
|
329 | 346 | $boards[] = $row['id_board']; |
347 | + } |
|
330 | 348 | $smcFunc['db_free_result']($request); |
331 | 349 | } |
332 | 350 | |
@@ -343,8 +361,9 @@ discard block |
||
343 | 361 | $clauseParameters['board_list'] = $boards; |
344 | 362 | } |
345 | 363 | |
346 | - if (empty($clauses)) |
|
347 | - redirectexit(); |
|
364 | + if (empty($clauses)) { |
|
365 | + redirectexit(); |
|
366 | + } |
|
348 | 367 | |
349 | 368 | $request = $smcFunc['db_query']('', ' |
350 | 369 | SELECT b.id_board |
@@ -355,19 +374,22 @@ discard block |
||
355 | 374 | )) |
356 | 375 | ); |
357 | 376 | $boards = array(); |
358 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
359 | - $boards[] = $row['id_board']; |
|
377 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
378 | + $boards[] = $row['id_board']; |
|
379 | + } |
|
360 | 380 | $smcFunc['db_free_result']($request); |
361 | 381 | |
362 | - if (empty($boards)) |
|
363 | - redirectexit(); |
|
382 | + if (empty($boards)) { |
|
383 | + redirectexit(); |
|
384 | + } |
|
364 | 385 | |
365 | 386 | markBoardsRead($boards, isset($_REQUEST['unread'])); |
366 | 387 | |
367 | 388 | foreach ($boards as $b) |
368 | 389 | { |
369 | - if (isset($_SESSION['topicseen_cache'][$b])) |
|
370 | - $_SESSION['topicseen_cache'][$b] = array(); |
|
390 | + if (isset($_SESSION['topicseen_cache'][$b])) { |
|
391 | + $_SESSION['topicseen_cache'][$b] = array(); |
|
392 | + } |
|
371 | 393 | } |
372 | 394 | |
373 | 395 | if (!isset($_REQUEST['unread'])) |
@@ -385,8 +407,9 @@ discard block |
||
385 | 407 | if ($smcFunc['db_num_rows']($result) > 0) |
386 | 408 | { |
387 | 409 | $logBoardInserts = array(); |
388 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
389 | - $logBoardInserts[] = array($modSettings['maxMsgID'], $user_info['id'], $row['id_board']); |
|
410 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
411 | + $logBoardInserts[] = array($modSettings['maxMsgID'], $user_info['id'], $row['id_board']); |
|
412 | + } |
|
390 | 413 | |
391 | 414 | $smcFunc['db_insert']('replace', |
392 | 415 | '{db_prefix}log_boards', |
@@ -397,17 +420,18 @@ discard block |
||
397 | 420 | } |
398 | 421 | $smcFunc['db_free_result']($result); |
399 | 422 | |
400 | - if (empty($board)) |
|
401 | - redirectexit(); |
|
402 | - else |
|
403 | - redirectexit('board=' . $board . '.0'); |
|
404 | - } |
|
405 | - else |
|
423 | + if (empty($board)) { |
|
424 | + redirectexit(); |
|
425 | + } else { |
|
426 | + redirectexit('board=' . $board . '.0'); |
|
427 | + } |
|
428 | + } else |
|
406 | 429 | { |
407 | - if (empty($board_info['parent'])) |
|
408 | - redirectexit(); |
|
409 | - else |
|
410 | - redirectexit('board=' . $board_info['parent'] . '.0'); |
|
430 | + if (empty($board_info['parent'])) { |
|
431 | + redirectexit(); |
|
432 | + } else { |
|
433 | + redirectexit('board=' . $board_info['parent'] . '.0'); |
|
434 | + } |
|
411 | 435 | } |
412 | 436 | } |
413 | 437 | } |
@@ -432,11 +456,13 @@ discard block |
||
432 | 456 | 'selected_message' => (int) $messageID, |
433 | 457 | ) |
434 | 458 | ); |
435 | - if ($smcFunc['db_num_rows']($result) > 0) |
|
436 | - list ($memberID) = $smcFunc['db_fetch_row']($result); |
|
459 | + if ($smcFunc['db_num_rows']($result) > 0) { |
|
460 | + list ($memberID) = $smcFunc['db_fetch_row']($result); |
|
461 | + } |
|
437 | 462 | // The message doesn't even exist. |
438 | - else |
|
439 | - $memberID = 0; |
|
463 | + else { |
|
464 | + $memberID = 0; |
|
465 | + } |
|
440 | 466 | $smcFunc['db_free_result']($result); |
441 | 467 | |
442 | 468 | return (int) $memberID; |
@@ -457,8 +483,9 @@ discard block |
||
457 | 483 | getBoardTree(); |
458 | 484 | |
459 | 485 | // Make sure given boards and categories exist. |
460 | - if (!isset($boards[$board_id]) || (isset($boardOptions['target_board']) && !isset($boards[$boardOptions['target_board']])) || (isset($boardOptions['target_category']) && !isset($cat_tree[$boardOptions['target_category']]))) |
|
461 | - fatal_lang_error('no_board'); |
|
486 | + if (!isset($boards[$board_id]) || (isset($boardOptions['target_board']) && !isset($boards[$boardOptions['target_board']])) || (isset($boardOptions['target_category']) && !isset($cat_tree[$boardOptions['target_category']]))) { |
|
487 | + fatal_lang_error('no_board'); |
|
488 | + } |
|
462 | 489 | |
463 | 490 | $id = $board_id; |
464 | 491 | call_integration_hook('integrate_pre_modify_board', array($id, &$boardOptions)); |
@@ -486,8 +513,9 @@ discard block |
||
486 | 513 | $child_level = 0; |
487 | 514 | $id_parent = 0; |
488 | 515 | $after = 0; |
489 | - foreach ($cat_tree[$id_cat]['children'] as $id_board => $dummy) |
|
490 | - $after = max($after, $boards[$id_board]['order']); |
|
516 | + foreach ($cat_tree[$id_cat]['children'] as $id_board => $dummy) { |
|
517 | + $after = max($after, $boards[$id_board]['order']); |
|
518 | + } |
|
491 | 519 | } |
492 | 520 | |
493 | 521 | // Make the board a child of a given board. |
@@ -498,17 +526,19 @@ discard block |
||
498 | 526 | $id_parent = $boardOptions['target_board']; |
499 | 527 | |
500 | 528 | // People can be creative, in many ways... |
501 | - if (isChildOf($id_parent, $board_id)) |
|
502 | - fatal_lang_error('mboards_parent_own_child_error', false); |
|
503 | - elseif ($id_parent == $board_id) |
|
504 | - fatal_lang_error('mboards_board_own_child_error', false); |
|
529 | + if (isChildOf($id_parent, $board_id)) { |
|
530 | + fatal_lang_error('mboards_parent_own_child_error', false); |
|
531 | + } elseif ($id_parent == $board_id) { |
|
532 | + fatal_lang_error('mboards_board_own_child_error', false); |
|
533 | + } |
|
505 | 534 | |
506 | 535 | $after = $boards[$boardOptions['target_board']]['order']; |
507 | 536 | |
508 | 537 | // Check if there are already children and (if so) get the max board order. |
509 | - if (!empty($boards[$id_parent]['tree']['children']) && empty($boardOptions['move_first_child'])) |
|
510 | - foreach ($boards[$id_parent]['tree']['children'] as $childBoard_id => $dummy) |
|
538 | + if (!empty($boards[$id_parent]['tree']['children']) && empty($boardOptions['move_first_child'])) { |
|
539 | + foreach ($boards[$id_parent]['tree']['children'] as $childBoard_id => $dummy) |
|
511 | 540 | $after = max($after, $boards[$childBoard_id]['order']); |
541 | + } |
|
512 | 542 | } |
513 | 543 | |
514 | 544 | // Place a board before or after another board, on the same child level. |
@@ -521,8 +551,9 @@ discard block |
||
521 | 551 | } |
522 | 552 | |
523 | 553 | // Oops...? |
524 | - else |
|
525 | - trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR); |
|
554 | + else { |
|
555 | + trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR); |
|
556 | + } |
|
526 | 557 | |
527 | 558 | // Get a list of children of this board. |
528 | 559 | $childList = array(); |
@@ -531,14 +562,16 @@ discard block |
||
531 | 562 | // See if there are changes that affect children. |
532 | 563 | $childUpdates = array(); |
533 | 564 | $levelDiff = $child_level - $boards[$board_id]['level']; |
534 | - if ($levelDiff != 0) |
|
535 | - $childUpdates[] = 'child_level = child_level ' . ($levelDiff > 0 ? '+ ' : '') . '{int:level_diff}'; |
|
536 | - if ($id_cat != $boards[$board_id]['category']) |
|
537 | - $childUpdates[] = 'id_cat = {int:category}'; |
|
565 | + if ($levelDiff != 0) { |
|
566 | + $childUpdates[] = 'child_level = child_level ' . ($levelDiff > 0 ? '+ ' : '') . '{int:level_diff}'; |
|
567 | + } |
|
568 | + if ($id_cat != $boards[$board_id]['category']) { |
|
569 | + $childUpdates[] = 'id_cat = {int:category}'; |
|
570 | + } |
|
538 | 571 | |
539 | 572 | // Fix the children of this board. |
540 | - if (!empty($childList) && !empty($childUpdates)) |
|
541 | - $smcFunc['db_query']('', ' |
|
573 | + if (!empty($childList) && !empty($childUpdates)) { |
|
574 | + $smcFunc['db_query']('', ' |
|
542 | 575 | UPDATE {db_prefix}boards |
543 | 576 | SET ' . implode(', |
544 | 577 | ', $childUpdates) . ' |
@@ -549,6 +582,7 @@ discard block |
||
549 | 582 | 'level_diff' => $levelDiff, |
550 | 583 | ) |
551 | 584 | ); |
585 | + } |
|
552 | 586 | |
553 | 587 | // Make some room for this spot. |
554 | 588 | $smcFunc['db_query']('', ' |
@@ -644,8 +678,8 @@ discard block |
||
644 | 678 | call_integration_hook('integrate_modify_board', array($id, $boardOptions, &$boardUpdates, &$boardUpdateParameters)); |
645 | 679 | |
646 | 680 | // Do the updates (if any). |
647 | - if (!empty($boardUpdates)) |
|
648 | - $smcFunc['db_query']('', ' |
|
681 | + if (!empty($boardUpdates)) { |
|
682 | + $smcFunc['db_query']('', ' |
|
649 | 683 | UPDATE {db_prefix}boards |
650 | 684 | SET |
651 | 685 | ' . implode(', |
@@ -655,13 +689,15 @@ discard block |
||
655 | 689 | 'selected_board' => $board_id, |
656 | 690 | )) |
657 | 691 | ); |
692 | + } |
|
658 | 693 | |
659 | 694 | // Do permission sync |
660 | 695 | if (!empty($boardUpdateParameters['deny_groups'])) |
661 | 696 | { |
662 | 697 | $insert = array(); |
663 | - foreach($boardOptions['deny_groups'] as $value) |
|
664 | - $insert[] = array($value, $board_id, 1); |
|
698 | + foreach($boardOptions['deny_groups'] as $value) { |
|
699 | + $insert[] = array($value, $board_id, 1); |
|
700 | + } |
|
665 | 701 | |
666 | 702 | $smcFunc['db_query']('', ' |
667 | 703 | DELETE FROM {db_prefix}board_permissions_view |
@@ -681,8 +717,9 @@ discard block |
||
681 | 717 | if (!empty($boardUpdateParameters['member_groups'])) |
682 | 718 | { |
683 | 719 | $insert = array(); |
684 | - foreach($boardOptions['access_groups'] as $value) |
|
685 | - $insert[] = array($value, $board_id, 0); |
|
720 | + foreach($boardOptions['access_groups'] as $value) { |
|
721 | + $insert[] = array($value, $board_id, 0); |
|
722 | + } |
|
686 | 723 | $smcFunc['db_query']('', ' |
687 | 724 | DELETE FROM {db_prefix}board_permissions_view |
688 | 725 | WHERE id_board = {int:selected_board} AND deny = 0', |
@@ -722,13 +759,15 @@ discard block |
||
722 | 759 | { |
723 | 760 | $moderators[$k] = trim($moderators[$k]); |
724 | 761 | |
725 | - if (strlen($moderators[$k]) == 0) |
|
726 | - unset($moderators[$k]); |
|
762 | + if (strlen($moderators[$k]) == 0) { |
|
763 | + unset($moderators[$k]); |
|
764 | + } |
|
727 | 765 | } |
728 | 766 | |
729 | 767 | // Find all the id_member's for the member_name's in the list. |
730 | - if (empty($boardOptions['moderators'])) |
|
731 | - $boardOptions['moderators'] = array(); |
|
768 | + if (empty($boardOptions['moderators'])) { |
|
769 | + $boardOptions['moderators'] = array(); |
|
770 | + } |
|
732 | 771 | if (!empty($moderators)) |
733 | 772 | { |
734 | 773 | $request = $smcFunc['db_query']('', ' |
@@ -741,8 +780,9 @@ discard block |
||
741 | 780 | 'limit' => count($moderators), |
742 | 781 | ) |
743 | 782 | ); |
744 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
745 | - $boardOptions['moderators'][] = $row['id_member']; |
|
783 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
784 | + $boardOptions['moderators'][] = $row['id_member']; |
|
785 | + } |
|
746 | 786 | $smcFunc['db_free_result']($request); |
747 | 787 | } |
748 | 788 | } |
@@ -751,8 +791,9 @@ discard block |
||
751 | 791 | if (!empty($boardOptions['moderators'])) |
752 | 792 | { |
753 | 793 | $inserts = array(); |
754 | - foreach ($boardOptions['moderators'] as $moderator) |
|
755 | - $inserts[] = array($board_id, $moderator); |
|
794 | + foreach ($boardOptions['moderators'] as $moderator) { |
|
795 | + $inserts[] = array($board_id, $moderator); |
|
796 | + } |
|
756 | 797 | |
757 | 798 | $smcFunc['db_insert']('insert', |
758 | 799 | '{db_prefix}moderators', |
@@ -782,14 +823,16 @@ discard block |
||
782 | 823 | { |
783 | 824 | $moderator_groups[$k] = trim($moderator_groups[$k]); |
784 | 825 | |
785 | - if (strlen($moderator_groups[$k]) == 0) |
|
786 | - unset($moderator_groups[$k]); |
|
826 | + if (strlen($moderator_groups[$k]) == 0) { |
|
827 | + unset($moderator_groups[$k]); |
|
828 | + } |
|
787 | 829 | } |
788 | 830 | |
789 | 831 | /* Find all the id_group's for all the group names in the list |
790 | 832 | But skip any invalid ones (invisible/post groups/Administrator/Moderator) */ |
791 | - if (empty($boardOptions['moderator_groups'])) |
|
792 | - $boardOptions['moderator_groups'] = array(); |
|
833 | + if (empty($boardOptions['moderator_groups'])) { |
|
834 | + $boardOptions['moderator_groups'] = array(); |
|
835 | + } |
|
793 | 836 | if (!empty($moderator_groups)) |
794 | 837 | { |
795 | 838 | $request = $smcFunc['db_query']('', ' |
@@ -820,8 +863,9 @@ discard block |
||
820 | 863 | if (!empty($boardOptions['moderator_groups'])) |
821 | 864 | { |
822 | 865 | $inserts = array(); |
823 | - foreach ($boardOptions['moderator_groups'] as $moderator_group) |
|
824 | - $inserts[] = array($board_id, $moderator_group); |
|
866 | + foreach ($boardOptions['moderator_groups'] as $moderator_group) { |
|
867 | + $inserts[] = array($board_id, $moderator_group); |
|
868 | + } |
|
825 | 869 | |
826 | 870 | $smcFunc['db_insert']('insert', |
827 | 871 | '{db_prefix}moderator_groups', |
@@ -835,14 +879,16 @@ discard block |
||
835 | 879 | updateSettings(array('settings_updated' => time())); |
836 | 880 | } |
837 | 881 | |
838 | - if (isset($boardOptions['move_to'])) |
|
839 | - reorderBoards(); |
|
882 | + if (isset($boardOptions['move_to'])) { |
|
883 | + reorderBoards(); |
|
884 | + } |
|
840 | 885 | |
841 | 886 | clean_cache('data'); |
842 | 887 | |
843 | - if (empty($boardOptions['dont_log'])) |
|
844 | - logAction('edit_board', array('board' => $board_id), 'admin'); |
|
845 | -} |
|
888 | + if (empty($boardOptions['dont_log'])) { |
|
889 | + logAction('edit_board', array('board' => $board_id), 'admin'); |
|
890 | + } |
|
891 | + } |
|
846 | 892 | |
847 | 893 | /** |
848 | 894 | * Create a new board and set its properties and position. |
@@ -858,11 +904,13 @@ discard block |
||
858 | 904 | global $boards, $smcFunc; |
859 | 905 | |
860 | 906 | // Trigger an error if one of the required values is not set. |
861 | - if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category'])) |
|
862 | - trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR); |
|
907 | + if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category'])) { |
|
908 | + trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR); |
|
909 | + } |
|
863 | 910 | |
864 | - if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board'])) |
|
865 | - trigger_error('createBoard(): Target board is not set', E_USER_ERROR); |
|
911 | + if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board'])) { |
|
912 | + trigger_error('createBoard(): Target board is not set', E_USER_ERROR); |
|
913 | + } |
|
866 | 914 | |
867 | 915 | // Set every optional value to its default value. |
868 | 916 | $boardOptions += array( |
@@ -901,8 +949,9 @@ discard block |
||
901 | 949 | |
902 | 950 | $insert = array(); |
903 | 951 | |
904 | - foreach(explode(',', $default_memgrps) as $value) |
|
905 | - $insert[] = array($value, $board_id, 0); |
|
952 | + foreach(explode(',', $default_memgrps) as $value) { |
|
953 | + $insert[] = array($value, $board_id, 0); |
|
954 | + } |
|
906 | 955 | |
907 | 956 | $smcFunc['db_insert']('', |
908 | 957 | '{db_prefix}board_permissions_view', |
@@ -912,8 +961,9 @@ discard block |
||
912 | 961 | 1 |
913 | 962 | ); |
914 | 963 | |
915 | - if (empty($board_id)) |
|
916 | - return 0; |
|
964 | + if (empty($board_id)) { |
|
965 | + return 0; |
|
966 | + } |
|
917 | 967 | |
918 | 968 | // Change the board according to the given specifications. |
919 | 969 | modifyBoard($board_id, $boardOptions); |
@@ -976,8 +1026,9 @@ discard block |
||
976 | 1026 | global $sourcedir, $boards, $smcFunc; |
977 | 1027 | |
978 | 1028 | // No boards to delete? Return! |
979 | - if (empty($boards_to_remove)) |
|
980 | - return; |
|
1029 | + if (empty($boards_to_remove)) { |
|
1030 | + return; |
|
1031 | + } |
|
981 | 1032 | |
982 | 1033 | getBoardTree(); |
983 | 1034 | |
@@ -988,12 +1039,14 @@ discard block |
||
988 | 1039 | { |
989 | 1040 | // Get a list of the child boards that will also be removed. |
990 | 1041 | $child_boards_to_remove = array(); |
991 | - foreach ($boards_to_remove as $board_to_remove) |
|
992 | - recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']); |
|
1042 | + foreach ($boards_to_remove as $board_to_remove) { |
|
1043 | + recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']); |
|
1044 | + } |
|
993 | 1045 | |
994 | 1046 | // Merge the children with their parents. |
995 | - if (!empty($child_boards_to_remove)) |
|
996 | - $boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove)); |
|
1047 | + if (!empty($child_boards_to_remove)) { |
|
1048 | + $boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove)); |
|
1049 | + } |
|
997 | 1050 | } |
998 | 1051 | // Move the children to a safe home. |
999 | 1052 | else |
@@ -1001,10 +1054,11 @@ discard block |
||
1001 | 1054 | foreach ($boards_to_remove as $id_board) |
1002 | 1055 | { |
1003 | 1056 | // @todo Separate category? |
1004 | - if ($moveChildrenTo === 0) |
|
1005 | - fixChildren($id_board, 0, 0); |
|
1006 | - else |
|
1007 | - fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo); |
|
1057 | + if ($moveChildrenTo === 0) { |
|
1058 | + fixChildren($id_board, 0, 0); |
|
1059 | + } else { |
|
1060 | + fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo); |
|
1061 | + } |
|
1008 | 1062 | } |
1009 | 1063 | } |
1010 | 1064 | |
@@ -1018,8 +1072,9 @@ discard block |
||
1018 | 1072 | ) |
1019 | 1073 | ); |
1020 | 1074 | $topics = array(); |
1021 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1022 | - $topics[] = $row['id_topic']; |
|
1075 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1076 | + $topics[] = $row['id_topic']; |
|
1077 | + } |
|
1023 | 1078 | $smcFunc['db_free_result']($request); |
1024 | 1079 | |
1025 | 1080 | require_once($sourcedir . '/RemoveTopic.php'); |
@@ -1116,8 +1171,9 @@ discard block |
||
1116 | 1171 | clean_cache('data'); |
1117 | 1172 | |
1118 | 1173 | // Let's do some serious logging. |
1119 | - foreach ($boards_to_remove as $id_board) |
|
1120 | - logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin'); |
|
1174 | + foreach ($boards_to_remove as $id_board) { |
|
1175 | + logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin'); |
|
1176 | + } |
|
1121 | 1177 | |
1122 | 1178 | reorderBoards(); |
1123 | 1179 | } |
@@ -1136,8 +1192,8 @@ discard block |
||
1136 | 1192 | $board_order = 0; |
1137 | 1193 | foreach ($cat_tree as $catID => $dummy) |
1138 | 1194 | { |
1139 | - foreach ($boardList[$catID] as $boardID) |
|
1140 | - if ($boards[$boardID]['order'] != ++$board_order) |
|
1195 | + foreach ($boardList[$catID] as $boardID) { |
|
1196 | + if ($boards[$boardID]['order'] != ++$board_order) |
|
1141 | 1197 | $smcFunc['db_query']('', ' |
1142 | 1198 | UPDATE {db_prefix}boards |
1143 | 1199 | SET board_order = {int:new_order} |
@@ -1147,6 +1203,7 @@ discard block |
||
1147 | 1203 | 'selected_board' => $boardID, |
1148 | 1204 | ) |
1149 | 1205 | ); |
1206 | + } |
|
1150 | 1207 | } |
1151 | 1208 | |
1152 | 1209 | // Empty the board order cache |
@@ -1175,8 +1232,9 @@ discard block |
||
1175 | 1232 | ) |
1176 | 1233 | ); |
1177 | 1234 | $children = array(); |
1178 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1179 | - $children[] = $row['id_board']; |
|
1235 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1236 | + $children[] = $row['id_board']; |
|
1237 | + } |
|
1180 | 1238 | $smcFunc['db_free_result']($result); |
1181 | 1239 | |
1182 | 1240 | // ...and set it to a new parent and child_level. |
@@ -1192,9 +1250,10 @@ discard block |
||
1192 | 1250 | ); |
1193 | 1251 | |
1194 | 1252 | // Recursively fix the children of the children. |
1195 | - foreach ($children as $child) |
|
1196 | - fixChildren($child, $newLevel + 1, $child); |
|
1197 | -} |
|
1253 | + foreach ($children as $child) { |
|
1254 | + fixChildren($child, $newLevel + 1, $child); |
|
1255 | + } |
|
1256 | + } |
|
1198 | 1257 | |
1199 | 1258 | /** |
1200 | 1259 | * Tries to load up the entire board order and category very very quickly |
@@ -1211,8 +1270,9 @@ discard block |
||
1211 | 1270 | 'boards' => array(), |
1212 | 1271 | ); |
1213 | 1272 | |
1214 | - if (!empty($tree_order['boards'])) |
|
1215 | - return $tree_order; |
|
1273 | + if (!empty($tree_order['boards'])) { |
|
1274 | + return $tree_order; |
|
1275 | + } |
|
1216 | 1276 | |
1217 | 1277 | if (($cached = cache_get_data('board_order', 86400)) !== null) |
1218 | 1278 | { |
@@ -1228,8 +1288,9 @@ discard block |
||
1228 | 1288 | ); |
1229 | 1289 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1230 | 1290 | { |
1231 | - if (!in_array($row['id_cat'], $tree_order['cats'])) |
|
1232 | - $tree_order['cats'][] = $row['id_cat']; |
|
1291 | + if (!in_array($row['id_cat'], $tree_order['cats'])) { |
|
1292 | + $tree_order['cats'][] = $row['id_cat']; |
|
1293 | + } |
|
1233 | 1294 | $tree_order['boards'][] = $row['id_board']; |
1234 | 1295 | } |
1235 | 1296 | $smcFunc['db_free_result']($request); |
@@ -1249,16 +1310,19 @@ discard block |
||
1249 | 1310 | $tree = getTreeOrder(); |
1250 | 1311 | |
1251 | 1312 | $ordered = array(); |
1252 | - foreach ($tree['boards'] as $board) |
|
1253 | - if (!empty($boards[$board])) |
|
1313 | + foreach ($tree['boards'] as $board) { |
|
1314 | + if (!empty($boards[$board])) |
|
1254 | 1315 | { |
1255 | 1316 | $ordered[$board] = $boards[$board]; |
1317 | + } |
|
1256 | 1318 | |
1257 | - if (is_array($ordered[$board]) && !empty($ordered[$board]['boards'])) |
|
1258 | - sortBoards($ordered[$board]['boards']); |
|
1319 | + if (is_array($ordered[$board]) && !empty($ordered[$board]['boards'])) { |
|
1320 | + sortBoards($ordered[$board]['boards']); |
|
1321 | + } |
|
1259 | 1322 | |
1260 | - if (is_array($ordered[$board]) && !empty($ordered[$board]['children'])) |
|
1261 | - sortBoards($ordered[$board]['children']); |
|
1323 | + if (is_array($ordered[$board]) && !empty($ordered[$board]['children'])) { |
|
1324 | + sortBoards($ordered[$board]['children']); |
|
1325 | + } |
|
1262 | 1326 | } |
1263 | 1327 | |
1264 | 1328 | $boards = $ordered; |
@@ -1274,12 +1338,14 @@ discard block |
||
1274 | 1338 | $tree = getTreeOrder(); |
1275 | 1339 | |
1276 | 1340 | $ordered = array(); |
1277 | - foreach ($tree['cats'] as $cat) |
|
1278 | - if (!empty($categories[$cat])) |
|
1341 | + foreach ($tree['cats'] as $cat) { |
|
1342 | + if (!empty($categories[$cat])) |
|
1279 | 1343 | { |
1280 | 1344 | $ordered[$cat] = $categories[$cat]; |
1281 | - if (!empty($ordered[$cat]['boards'])) |
|
1282 | - sortBoards($ordered[$cat]['boards']); |
|
1345 | + } |
|
1346 | + if (!empty($ordered[$cat]['boards'])) { |
|
1347 | + sortBoards($ordered[$cat]['boards']); |
|
1348 | + } |
|
1283 | 1349 | } |
1284 | 1350 | |
1285 | 1351 | $categories = $ordered; |
@@ -1295,8 +1361,9 @@ discard block |
||
1295 | 1361 | { |
1296 | 1362 | global $smcFunc, $scripturl, $txt; |
1297 | 1363 | |
1298 | - if (empty($boards)) |
|
1299 | - return array(); |
|
1364 | + if (empty($boards)) { |
|
1365 | + return array(); |
|
1366 | + } |
|
1300 | 1367 | |
1301 | 1368 | $request = $smcFunc['db_query']('', ' |
1302 | 1369 | SELECT mem.id_member, mem.real_name, mo.id_board |
@@ -1310,8 +1377,9 @@ discard block |
||
1310 | 1377 | $moderators = array(); |
1311 | 1378 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1312 | 1379 | { |
1313 | - if (empty($moderators[$row['id_board']])) |
|
1314 | - $moderators[$row['id_board']] = array(); |
|
1380 | + if (empty($moderators[$row['id_board']])) { |
|
1381 | + $moderators[$row['id_board']] = array(); |
|
1382 | + } |
|
1315 | 1383 | |
1316 | 1384 | $moderators[$row['id_board']][] = array( |
1317 | 1385 | 'id' => $row['id_member'], |
@@ -1335,8 +1403,9 @@ discard block |
||
1335 | 1403 | { |
1336 | 1404 | global $smcFunc, $scripturl, $txt; |
1337 | 1405 | |
1338 | - if (empty($boards)) |
|
1339 | - return array(); |
|
1406 | + if (empty($boards)) { |
|
1407 | + return array(); |
|
1408 | + } |
|
1340 | 1409 | |
1341 | 1410 | $request = $smcFunc['db_query']('', ' |
1342 | 1411 | SELECT mg.id_group, mg.group_name, bg.id_board |
@@ -1350,8 +1419,9 @@ discard block |
||
1350 | 1419 | $groups = array(); |
1351 | 1420 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1352 | 1421 | { |
1353 | - if (empty($groups[$row['id_board']])) |
|
1354 | - $groups[$row['id_board']] = array(); |
|
1422 | + if (empty($groups[$row['id_board']])) { |
|
1423 | + $groups[$row['id_board']] = array(); |
|
1424 | + } |
|
1355 | 1425 | |
1356 | 1426 | $groups[$row['id_board']][] = array( |
1357 | 1427 | 'id' => $row['id_group'], |
@@ -1426,8 +1496,9 @@ discard block |
||
1426 | 1496 | |
1427 | 1497 | if (!empty($row['id_board'])) |
1428 | 1498 | { |
1429 | - if ($row['child_level'] != $curLevel) |
|
1430 | - $prevBoard = 0; |
|
1499 | + if ($row['child_level'] != $curLevel) { |
|
1500 | + $prevBoard = 0; |
|
1501 | + } |
|
1431 | 1502 | |
1432 | 1503 | $boards[$row['id_board']] = array( |
1433 | 1504 | 'id' => $row['id_board'], |
@@ -1459,16 +1530,16 @@ discard block |
||
1459 | 1530 | 'children' => array() |
1460 | 1531 | ); |
1461 | 1532 | $boards[$row['id_board']]['tree'] = &$cat_tree[$row['id_cat']]['children'][$row['id_board']]; |
1462 | - } |
|
1463 | - else |
|
1533 | + } else |
|
1464 | 1534 | { |
1465 | 1535 | // Parent doesn't exist! |
1466 | - if (!isset($boards[$row['id_parent']]['tree'])) |
|
1467 | - fatal_lang_error('no_valid_parent', false, array($row['board_name'])); |
|
1536 | + if (!isset($boards[$row['id_parent']]['tree'])) { |
|
1537 | + fatal_lang_error('no_valid_parent', false, array($row['board_name'])); |
|
1538 | + } |
|
1468 | 1539 | |
1469 | 1540 | // Wrong childlevel...we can silently fix this... |
1470 | - if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1) |
|
1471 | - $smcFunc['db_query']('', ' |
|
1541 | + if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1) { |
|
1542 | + $smcFunc['db_query']('', ' |
|
1472 | 1543 | UPDATE {db_prefix}boards |
1473 | 1544 | SET child_level = {int:new_child_level} |
1474 | 1545 | WHERE id_board = {int:selected_board}', |
@@ -1477,6 +1548,7 @@ discard block |
||
1477 | 1548 | 'selected_board' => $row['id_board'], |
1478 | 1549 | ) |
1479 | 1550 | ); |
1551 | + } |
|
1480 | 1552 | |
1481 | 1553 | $boards[$row['id_parent']]['tree']['children'][$row['id_board']] = array( |
1482 | 1554 | 'node' => &$boards[$row['id_board']], |
@@ -1510,8 +1582,9 @@ discard block |
||
1510 | 1582 | */ |
1511 | 1583 | function recursiveBoards(&$_boardList, &$_tree) |
1512 | 1584 | { |
1513 | - if (empty($_tree['children'])) |
|
1514 | - return; |
|
1585 | + if (empty($_tree['children'])) { |
|
1586 | + return; |
|
1587 | + } |
|
1515 | 1588 | |
1516 | 1589 | foreach ($_tree['children'] as $id => $node) |
1517 | 1590 | { |
@@ -1530,11 +1603,13 @@ discard block |
||
1530 | 1603 | { |
1531 | 1604 | global $boards; |
1532 | 1605 | |
1533 | - if (empty($boards[$child]['parent'])) |
|
1534 | - return false; |
|
1606 | + if (empty($boards[$child]['parent'])) { |
|
1607 | + return false; |
|
1608 | + } |
|
1535 | 1609 | |
1536 | - if ($boards[$child]['parent'] == $parent) |
|
1537 | - return true; |
|
1610 | + if ($boards[$child]['parent'] == $parent) { |
|
1611 | + return true; |
|
1612 | + } |
|
1538 | 1613 | |
1539 | 1614 | return isChildOf($boards[$child]['parent'], $parent); |
1540 | 1615 | } |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Create a menu. |
@@ -64,22 +65,26 @@ discard block |
||
64 | 65 | $menu_context['current_action'] = isset($menuOptions['action']) ? $menuOptions['action'] : $context['current_action']; |
65 | 66 | |
66 | 67 | // Allow extend *any* menu with a single hook |
67 | - if (!empty($menu_context['current_action'])) |
|
68 | - call_integration_hook('integrate_' . $menu_context['current_action'] . '_areas', array(&$menuData)); |
|
68 | + if (!empty($menu_context['current_action'])) { |
|
69 | + call_integration_hook('integrate_' . $menu_context['current_action'] . '_areas', array(&$menuData)); |
|
70 | + } |
|
69 | 71 | |
70 | 72 | // What is the current area selected? |
71 | - if (isset($menuOptions['current_area']) || isset($_GET['area'])) |
|
72 | - $menu_context['current_area'] = isset($menuOptions['current_area']) ? $menuOptions['current_area'] : $_GET['area']; |
|
73 | + if (isset($menuOptions['current_area']) || isset($_GET['area'])) { |
|
74 | + $menu_context['current_area'] = isset($menuOptions['current_area']) ? $menuOptions['current_area'] : $_GET['area']; |
|
75 | + } |
|
73 | 76 | |
74 | 77 | // Build a list of additional parameters that should go in the URL. |
75 | 78 | $menu_context['extra_parameters'] = ''; |
76 | - if (!empty($menuOptions['extra_url_parameters'])) |
|
77 | - foreach ($menuOptions['extra_url_parameters'] as $key => $value) |
|
79 | + if (!empty($menuOptions['extra_url_parameters'])) { |
|
80 | + foreach ($menuOptions['extra_url_parameters'] as $key => $value) |
|
78 | 81 | $menu_context['extra_parameters'] .= ';' . $key . '=' . $value; |
82 | + } |
|
79 | 83 | |
80 | 84 | // Only include the session ID in the URL if it's strictly necessary. |
81 | - if (empty($menuOptions['disable_url_session_check'])) |
|
82 | - $menu_context['extra_parameters'] .= ';' . $context['session_var'] . '=' . $context['session_id']; |
|
85 | + if (empty($menuOptions['disable_url_session_check'])) { |
|
86 | + $menu_context['extra_parameters'] .= ';' . $context['session_var'] . '=' . $context['session_id']; |
|
87 | + } |
|
83 | 88 | |
84 | 89 | $include_data = array(); |
85 | 90 | |
@@ -87,8 +92,9 @@ discard block |
||
87 | 92 | foreach ($menuData as $section_id => $section) |
88 | 93 | { |
89 | 94 | // Is this enabled - or has as permission check - which fails? |
90 | - if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($section['permission']) && !allowedTo($section['permission']))) |
|
91 | - continue; |
|
95 | + if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($section['permission']) && !allowedTo($section['permission']))) { |
|
96 | + continue; |
|
97 | + } |
|
92 | 98 | |
93 | 99 | // Now we cycle through the sections to pick the right area. |
94 | 100 | foreach ($section['areas'] as $area_id => $area) |
@@ -110,67 +116,67 @@ discard block |
||
110 | 116 | if (empty($area['hidden'])) |
111 | 117 | { |
112 | 118 | // First time this section? |
113 | - if (!isset($menu_context['sections'][$section_id])) |
|
114 | - $menu_context['sections'][$section_id]['title'] = $section['title']; |
|
119 | + if (!isset($menu_context['sections'][$section_id])) { |
|
120 | + $menu_context['sections'][$section_id]['title'] = $section['title']; |
|
121 | + } |
|
115 | 122 | |
116 | 123 | // Is there a counter amount to show for this section? |
117 | - if (!empty($section['amt'])) |
|
118 | - $menu_context['sections'][$section_id]['amt'] = $section['amt']; |
|
124 | + if (!empty($section['amt'])) { |
|
125 | + $menu_context['sections'][$section_id]['amt'] = $section['amt']; |
|
126 | + } |
|
119 | 127 | |
120 | 128 | $menu_context['sections'][$section_id]['areas'][$area_id] = array('label' => isset($area['label']) ? $area['label'] : $txt[$area_id]); |
121 | 129 | // We'll need the ID as well... |
122 | 130 | $menu_context['sections'][$section_id]['id'] = $section_id; |
123 | 131 | // Does it have a custom URL? |
124 | - if (isset($area['custom_url'])) |
|
125 | - $menu_context['sections'][$section_id]['areas'][$area_id]['url'] = $area['custom_url']; |
|
132 | + if (isset($area['custom_url'])) { |
|
133 | + $menu_context['sections'][$section_id]['areas'][$area_id]['url'] = $area['custom_url']; |
|
134 | + } |
|
126 | 135 | |
127 | 136 | // Is there a counter amount to show for this area? |
128 | - if (!empty($area['amt'])) |
|
129 | - $menu_context['sections'][$section_id]['areas'][$area_id]['amt'] = $area['amt']; |
|
137 | + if (!empty($area['amt'])) { |
|
138 | + $menu_context['sections'][$section_id]['areas'][$area_id]['amt'] = $area['amt']; |
|
139 | + } |
|
130 | 140 | |
131 | 141 | // Does this area have its own icon? |
132 | 142 | if (!isset($area['force_menu_into_arms_of_another_menu']) && $user_info['name'] == 'iamanoompaloompa') |
133 | 143 | { |
134 | 144 | $menu_context['sections'][$section_id]['areas'][$area_id] = $smcFunc['json_decode'](base64_decode('eyJsYWJlbCI6Ik9vbXBhIExvb21wYSIsInVybCI6Imh0dHBzOlwvXC9lbi53aWtpcGVkaWEub3JnXC93aWtpXC9Pb21wYV9Mb29tcGFzPyIsImljb24iOiI8aW1nIHNyYz1cImh0dHBzOlwvXC93d3cuc2ltcGxlbWFjaGluZXMub3JnXC9pbWFnZXNcL29vbXBhLmdpZlwiIGFsdD1cIkknbSBhbiBPb21wYSBMb29tcGFcIiBcLz4ifQ=='), true); |
135 | - } |
|
136 | - elseif (isset($area['icon'])) |
|
145 | + } elseif (isset($area['icon'])) |
|
137 | 146 | { |
138 | 147 | if (file_exists($settings['theme_dir'] . '/images/admin/' . $area['icon'])) |
139 | 148 | { |
140 | 149 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['images_url'] . '/admin/' . $area['icon'] . '" alt="">'; |
141 | - } |
|
142 | - elseif (file_exists($settings['default_theme_dir'] . '/images/admin/' . $area['icon'])) |
|
150 | + } elseif (file_exists($settings['default_theme_dir'] . '/images/admin/' . $area['icon'])) |
|
143 | 151 | { |
144 | 152 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['default_images_url'] . '/admin/' . $area['icon'] . '" alt="">'; |
153 | + } else { |
|
154 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area['icon'] . '"></span>'; |
|
145 | 155 | } |
146 | - else |
|
147 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area['icon'] . '"></span>'; |
|
156 | + } else { |
|
157 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area_id . '"></span>'; |
|
148 | 158 | } |
149 | - else |
|
150 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area_id . '"></span>'; |
|
151 | 159 | |
152 | 160 | if (isset($area['icon_class']) && empty($menu_context['sections'][$section_id]['areas'][$area_id]['icon'])) |
153 | 161 | { |
154 | 162 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . $area['icon_class']; |
155 | - } |
|
156 | - elseif (isset($area['icon'])) |
|
163 | + } elseif (isset($area['icon'])) |
|
157 | 164 | { |
158 | 165 | if (substr($area['icon'], -4) === '.png' || substr($area['icon'], -4) === '.gif') |
159 | 166 | { |
160 | 167 | if (file_exists($settings['theme_dir'] . '/images/admin/big/' . $area['icon'])) |
161 | 168 | { |
162 | 169 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['theme_url'] . '/images/admin/big/' . $area['icon']; |
163 | - } |
|
164 | - elseif (file_exists($settings['default_theme_dir'] . '/images/admin/big/' . $area['icon'])) |
|
170 | + } elseif (file_exists($settings['default_theme_dir'] . '/images/admin/big/' . $area['icon'])) |
|
165 | 171 | { |
166 | 172 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['default_theme_url'] . '/images/admin/big/' . $area['icon']; |
167 | 173 | } |
168 | 174 | } |
169 | 175 | |
170 | 176 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area['icon']); |
177 | + } else { |
|
178 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area_id); |
|
171 | 179 | } |
172 | - else |
|
173 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area_id); |
|
174 | 180 | |
175 | 181 | // This is a shortcut for Font-Icon users so they don't have to re-do whole CSS. |
176 | 182 | $menu_context['sections'][$section_id]['areas'][$area_id]['plain_class'] = !empty($area['icon']) ? $area['icon'] : ''; |
@@ -187,39 +193,46 @@ discard block |
||
187 | 193 | { |
188 | 194 | if ((empty($sub[1]) || allowedTo($sub[1])) && (!isset($sub['enabled']) || !empty($sub['enabled']))) |
189 | 195 | { |
190 | - if ($first_sa == null) |
|
191 | - $first_sa = $sa; |
|
196 | + if ($first_sa == null) { |
|
197 | + $first_sa = $sa; |
|
198 | + } |
|
192 | 199 | |
193 | 200 | $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa] = array('label' => $sub[0]); |
194 | 201 | // Custom URL? |
195 | - if (isset($sub['url'])) |
|
196 | - $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['url'] = $sub['url']; |
|
202 | + if (isset($sub['url'])) { |
|
203 | + $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['url'] = $sub['url']; |
|
204 | + } |
|
197 | 205 | |
198 | 206 | // Is there a counter amount to show for this subsection? |
199 | - if (!empty($sub['amt'])) |
|
200 | - $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['amt'] = $sub['amt']; |
|
207 | + if (!empty($sub['amt'])) { |
|
208 | + $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['amt'] = $sub['amt']; |
|
209 | + } |
|
201 | 210 | |
202 | 211 | // A bit complicated - but is this set? |
203 | 212 | if ($menu_context['current_area'] == $area_id) |
204 | 213 | { |
205 | 214 | // Save which is the first... |
206 | - if (empty($first_sa)) |
|
207 | - $first_sa = $sa; |
|
215 | + if (empty($first_sa)) { |
|
216 | + $first_sa = $sa; |
|
217 | + } |
|
208 | 218 | |
209 | 219 | // Is this the current subsection? |
210 | - if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == $sa) |
|
211 | - $menu_context['current_subsection'] = $sa; |
|
220 | + if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == $sa) { |
|
221 | + $menu_context['current_subsection'] = $sa; |
|
222 | + } |
|
212 | 223 | // Otherwise is it the default? |
213 | - elseif (!isset($menu_context['current_subsection']) && !empty($sub[2])) |
|
214 | - $menu_context['current_subsection'] = $sa; |
|
224 | + elseif (!isset($menu_context['current_subsection']) && !empty($sub[2])) { |
|
225 | + $menu_context['current_subsection'] = $sa; |
|
226 | + } |
|
215 | 227 | } |
216 | 228 | |
217 | 229 | // Let's assume this is the last, for now. |
218 | 230 | $last_sa = $sa; |
219 | 231 | } |
220 | 232 | // Mark it as disabled... |
221 | - else |
|
222 | - $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['disabled'] = true; |
|
233 | + else { |
|
234 | + $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['disabled'] = true; |
|
235 | + } |
|
223 | 236 | } |
224 | 237 | |
225 | 238 | // Set which one is first, last and selected in the group. |
@@ -228,8 +241,9 @@ discard block |
||
228 | 241 | $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$context['right_to_left'] ? $last_sa : $first_sa]['is_first'] = true; |
229 | 242 | $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$context['right_to_left'] ? $first_sa : $last_sa]['is_last'] = true; |
230 | 243 | |
231 | - if ($menu_context['current_area'] == $area_id && !isset($menu_context['current_subsection'])) |
|
232 | - $menu_context['current_subsection'] = $first_sa; |
|
244 | + if ($menu_context['current_area'] == $area_id && !isset($menu_context['current_subsection'])) { |
|
245 | + $menu_context['current_subsection'] = $first_sa; |
|
246 | + } |
|
233 | 247 | } |
234 | 248 | } |
235 | 249 | } |
@@ -263,23 +277,26 @@ discard block |
||
263 | 277 | $menu_context['base_url'] = isset($menuOptions['base_url']) ? $menuOptions['base_url'] : $scripturl . '?action=' . $menu_context['current_action']; |
264 | 278 | |
265 | 279 | // If we didn't find the area we were looking for go to a default one. |
266 | - if (isset($backup_area) && empty($found_section)) |
|
267 | - $menu_context['current_area'] = $backup_area; |
|
280 | + if (isset($backup_area) && empty($found_section)) { |
|
281 | + $menu_context['current_area'] = $backup_area; |
|
282 | + } |
|
268 | 283 | |
269 | 284 | // If there are sections quickly goes through all the sections to check if the base menu has an url |
270 | 285 | if (!empty($menu_context['current_section'])) |
271 | 286 | { |
272 | 287 | $menu_context['sections'][$menu_context['current_section']]['selected'] = true; |
273 | 288 | $menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['selected'] = true; |
274 | - if (!empty($menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']])) |
|
275 | - $menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]['selected'] = true; |
|
289 | + if (!empty($menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']])) { |
|
290 | + $menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]['selected'] = true; |
|
291 | + } |
|
276 | 292 | |
277 | - foreach ($menu_context['sections'] as $section_id => $section) |
|
278 | - foreach ($section['areas'] as $area_id => $area) |
|
293 | + foreach ($menu_context['sections'] as $section_id => $section) { |
|
294 | + foreach ($section['areas'] as $area_id => $area) |
|
279 | 295 | { |
280 | 296 | if (!isset($menu_context['sections'][$section_id]['url'])) |
281 | 297 | { |
282 | 298 | $menu_context['sections'][$section_id]['url'] = isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $area_id; |
299 | + } |
|
283 | 300 | break; |
284 | 301 | } |
285 | 302 | } |
@@ -290,8 +307,9 @@ discard block |
||
290 | 307 | { |
291 | 308 | // Never happened! |
292 | 309 | $context['max_menu_id']--; |
293 | - if ($context['max_menu_id'] == 0) |
|
294 | - unset($context['max_menu_id']); |
|
310 | + if ($context['max_menu_id'] == 0) { |
|
311 | + unset($context['max_menu_id']); |
|
312 | + } |
|
295 | 313 | |
296 | 314 | return false; |
297 | 315 | } |
@@ -302,8 +320,9 @@ discard block |
||
302 | 320 | $context['template_layers'][] = $menu_context['layer_name']; |
303 | 321 | |
304 | 322 | // Check we had something - for sanity sake. |
305 | - if (empty($include_data)) |
|
306 | - return false; |
|
323 | + if (empty($include_data)) { |
|
324 | + return false; |
|
325 | + } |
|
307 | 326 | |
308 | 327 | // Finally - return information on the selected item. |
309 | 328 | $include_data += array( |
@@ -326,12 +345,14 @@ discard block |
||
326 | 345 | global $context; |
327 | 346 | |
328 | 347 | $menu_name = $menu_id == 'last' && isset($context['max_menu_id']) && isset($context['menu_data_' . $context['max_menu_id']]) ? 'menu_data_' . $context['max_menu_id'] : 'menu_data_' . $menu_id; |
329 | - if (!isset($context[$menu_name])) |
|
330 | - return false; |
|
348 | + if (!isset($context[$menu_name])) { |
|
349 | + return false; |
|
350 | + } |
|
331 | 351 | |
332 | 352 | $layer_index = array_search($context[$menu_name]['layer_name'], $context['template_layers']); |
333 | - if ($layer_index !== false) |
|
334 | - unset($context['template_layers'][$layer_index]); |
|
353 | + if ($layer_index !== false) { |
|
354 | + unset($context['template_layers'][$layer_index]); |
|
355 | + } |
|
335 | 356 | |
336 | 357 | unset($context[$menu_name]); |
337 | 358 | } |
@@ -83,16 +83,18 @@ discard block |
||
83 | 83 | foreach ($section['areas'] as $i => $area) |
84 | 84 | { |
85 | 85 | // Not supposed to be printed? |
86 | - if (empty($area['label'])) |
|
87 | - continue; |
|
86 | + if (empty($area['label'])) { |
|
87 | + continue; |
|
88 | + } |
|
88 | 89 | |
89 | 90 | echo ' |
90 | 91 | <li', !empty($area['subsections']) ? ' class="subsections"' : '', '> |
91 | 92 | <a class="', $area['icon_class'], !empty($area['selected']) ? ' chosen ' : '', '" href="', (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i), $menu_context['extra_parameters'], '">', $area['icon'], $area['label'], !empty($area['amt']) ? ' <span class="amt">' . $area['amt'] . '</span>' : '', '</a>'; |
92 | 93 | |
93 | 94 | // Is this the current area, or just some area? |
94 | - if (!empty($area['selected']) && empty($context['tabs'])) |
|
95 | - $context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array(); |
|
95 | + if (!empty($area['selected']) && empty($context['tabs'])) { |
|
96 | + $context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array(); |
|
97 | + } |
|
96 | 98 | |
97 | 99 | // Are there any subsections? |
98 | 100 | if (!empty($area['subsections'])) |
@@ -102,8 +104,9 @@ discard block |
||
102 | 104 | |
103 | 105 | foreach ($area['subsections'] as $sa => $sub) |
104 | 106 | { |
105 | - if (!empty($sub['disabled'])) |
|
106 | - continue; |
|
107 | + if (!empty($sub['disabled'])) { |
|
108 | + continue; |
|
109 | + } |
|
107 | 110 | |
108 | 111 | $url = isset($sub['url']) ? $sub['url'] : (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i) . ';sa=' . $sa; |
109 | 112 | |
@@ -150,8 +153,9 @@ discard block |
||
150 | 153 | <h3 class="catbg">'; |
151 | 154 | |
152 | 155 | // The function is in Admin.template.php, but since this template is used elsewhere too better check if the function is available |
153 | - if (function_exists('template_admin_quick_search')) |
|
154 | - template_admin_quick_search(); |
|
156 | + if (function_exists('template_admin_quick_search')) { |
|
157 | + template_admin_quick_search(); |
|
158 | + } |
|
155 | 159 | |
156 | 160 | // Exactly how many tabs do we have? |
157 | 161 | if (!empty($context['tabs'])) |
@@ -166,30 +170,36 @@ discard block |
||
166 | 170 | } |
167 | 171 | |
168 | 172 | // Did this not even exist - or do we not have a label? |
169 | - if (!isset($tab_context['tabs'][$id])) |
|
170 | - $tab_context['tabs'][$id] = array('label' => $tab['label']); |
|
171 | - elseif (!isset($tab_context['tabs'][$id]['label'])) |
|
172 | - $tab_context['tabs'][$id]['label'] = $tab['label']; |
|
173 | + if (!isset($tab_context['tabs'][$id])) { |
|
174 | + $tab_context['tabs'][$id] = array('label' => $tab['label']); |
|
175 | + } elseif (!isset($tab_context['tabs'][$id]['label'])) { |
|
176 | + $tab_context['tabs'][$id]['label'] = $tab['label']; |
|
177 | + } |
|
173 | 178 | |
174 | 179 | // Has a custom URL defined in the main admin structure? |
175 | - if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url'])) |
|
176 | - $tab_context['tabs'][$id]['url'] = $tab['url']; |
|
180 | + if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url'])) { |
|
181 | + $tab_context['tabs'][$id]['url'] = $tab['url']; |
|
182 | + } |
|
177 | 183 | |
178 | 184 | // Any additional paramaters for the url? |
179 | - if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params'])) |
|
180 | - $tab_context['tabs'][$id]['add_params'] = $tab['add_params']; |
|
185 | + if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params'])) { |
|
186 | + $tab_context['tabs'][$id]['add_params'] = $tab['add_params']; |
|
187 | + } |
|
181 | 188 | |
182 | 189 | // Has it been deemed selected? |
183 | - if (!empty($tab['is_selected'])) |
|
184 | - $tab_context['tabs'][$id]['is_selected'] = true; |
|
190 | + if (!empty($tab['is_selected'])) { |
|
191 | + $tab_context['tabs'][$id]['is_selected'] = true; |
|
192 | + } |
|
185 | 193 | |
186 | 194 | // Does it have its own help? |
187 | - if (!empty($tab['help'])) |
|
188 | - $tab_context['tabs'][$id]['help'] = $tab['help']; |
|
195 | + if (!empty($tab['help'])) { |
|
196 | + $tab_context['tabs'][$id]['help'] = $tab['help']; |
|
197 | + } |
|
189 | 198 | |
190 | 199 | // Is this the last one? |
191 | - if (!empty($tab['is_last']) && !isset($tab_context['override_last'])) |
|
192 | - $tab_context['tabs'][$id]['is_last'] = true; |
|
200 | + if (!empty($tab['is_last']) && !isset($tab_context['override_last'])) { |
|
201 | + $tab_context['tabs'][$id]['is_last'] = true; |
|
202 | + } |
|
193 | 203 | } |
194 | 204 | |
195 | 205 | // Find the selected tab |
@@ -206,22 +216,24 @@ discard block |
||
206 | 216 | // Show an icon and/or a help item? |
207 | 217 | if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']) || !empty($selected_tab['icon']) || !empty($tab_context['icon']) || !empty($selected_tab['help']) || !empty($tab_context['help'])) |
208 | 218 | { |
209 | - if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class'])) |
|
210 | - echo ' |
|
219 | + if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class'])) { |
|
220 | + echo ' |
|
211 | 221 | <span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>'; |
212 | - elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon'])) |
|
213 | - echo ' |
|
222 | + } elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon'])) { |
|
223 | + echo ' |
|
214 | 224 | <img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">'; |
225 | + } |
|
215 | 226 | |
216 | - if (!empty($selected_tab['help']) || !empty($tab_context['help'])) |
|
217 | - echo ' |
|
227 | + if (!empty($selected_tab['help']) || !empty($tab_context['help'])) { |
|
228 | + echo ' |
|
218 | 229 | <a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>'; |
230 | + } |
|
219 | 231 | |
220 | 232 | echo $tab_context['title']; |
221 | - } |
|
222 | - else |
|
223 | - echo ' |
|
233 | + } else { |
|
234 | + echo ' |
|
224 | 235 | ', $tab_context['title']; |
236 | + } |
|
225 | 237 | |
226 | 238 | echo ' |
227 | 239 | </h3>', (function_exists('template_admin_quick_search') ? ' |
@@ -230,11 +242,12 @@ discard block |
||
230 | 242 | } |
231 | 243 | |
232 | 244 | // Shall we use the tabs? Yes, it's the only known way! |
233 | - if (!empty($selected_tab['description']) || !empty($tab_context['description'])) |
|
234 | - echo ' |
|
245 | + if (!empty($selected_tab['description']) || !empty($tab_context['description'])) { |
|
246 | + echo ' |
|
235 | 247 | <p class="information"> |
236 | 248 | ', !empty($selected_tab['description']) ? $selected_tab['description'] : $tab_context['description'], ' |
237 | 249 | </p>'; |
250 | + } |
|
238 | 251 | |
239 | 252 | // Print out all the items in this tab (if any). |
240 | 253 | if (!empty($context['tabs'])) |
@@ -246,19 +259,21 @@ discard block |
||
246 | 259 | |
247 | 260 | foreach ($tab_context['tabs'] as $sa => $tab) |
248 | 261 | { |
249 | - if (!empty($tab['disabled'])) |
|
250 | - continue; |
|
262 | + if (!empty($tab['disabled'])) { |
|
263 | + continue; |
|
264 | + } |
|
251 | 265 | |
252 | - if (!empty($tab['is_selected'])) |
|
253 | - echo ' |
|
266 | + if (!empty($tab['is_selected'])) { |
|
267 | + echo ' |
|
254 | 268 | <li> |
255 | 269 | <a class="active" href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a> |
256 | 270 | </li>'; |
257 | - else |
|
258 | - echo ' |
|
271 | + } else { |
|
272 | + echo ' |
|
259 | 273 | <li> |
260 | 274 | <a href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a> |
261 | 275 | </li>'; |
276 | + } |
|
262 | 277 | } |
263 | 278 | |
264 | 279 | // The end of tabs |
@@ -72,9 +72,10 @@ discard block |
||
72 | 72 | |
73 | 73 | // Allow css/js files to be disabled for this specific theme. |
74 | 74 | // Add the identifier as an array key. IE array('smf_script'); Some external files might not add identifiers, on those cases SMF uses its filename as reference. |
75 | - if (!isset($settings['disable_files'])) |
|
76 | - $settings['disable_files'] = array(); |
|
77 | -} |
|
75 | + if (!isset($settings['disable_files'])) { |
|
76 | + $settings['disable_files'] = array(); |
|
77 | + } |
|
78 | + } |
|
78 | 79 | |
79 | 80 | /** |
80 | 81 | * The main sub template above the content. |
@@ -121,8 +122,9 @@ discard block |
||
121 | 122 | echo ' |
122 | 123 | <meta'; |
123 | 124 | |
124 | - foreach ($meta_tag as $meta_key => $meta_value) |
|
125 | - echo ' ', $meta_key, '="', $meta_value, '"'; |
|
125 | + foreach ($meta_tag as $meta_key => $meta_value) { |
|
126 | + echo ' ', $meta_key, '="', $meta_value, '"'; |
|
127 | + } |
|
126 | 128 | |
127 | 129 | echo '>'; |
128 | 130 | } |
@@ -133,14 +135,16 @@ discard block |
||
133 | 135 | <meta name="theme-color" content="#557EA0">'; |
134 | 136 | |
135 | 137 | // Please don't index these Mr Robot. |
136 | - if (!empty($context['robot_no_index'])) |
|
137 | - echo ' |
|
138 | + if (!empty($context['robot_no_index'])) { |
|
139 | + echo ' |
|
138 | 140 | <meta name="robots" content="noindex">'; |
141 | + } |
|
139 | 142 | |
140 | 143 | // Present a canonical url for search engines to prevent duplicate content in their indices. |
141 | - if (!empty($context['canonical_url'])) |
|
142 | - echo ' |
|
144 | + if (!empty($context['canonical_url'])) { |
|
145 | + echo ' |
|
143 | 146 | <link rel="canonical" href="', $context['canonical_url'], '">'; |
147 | + } |
|
144 | 148 | |
145 | 149 | // Show all the relative links, such as help, search, contents, and the like. |
146 | 150 | echo ' |
@@ -149,24 +153,28 @@ discard block |
||
149 | 153 | <link rel="search" href="' . $scripturl . '?action=search">' : ''); |
150 | 154 | |
151 | 155 | // If RSS feeds are enabled, advertise the presence of one. |
152 | - if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged'])) |
|
153 | - echo ' |
|
156 | + if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged'])) { |
|
157 | + echo ' |
|
154 | 158 | <link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['rss'], '" href="', $scripturl, '?action=.xml;type=rss2', !empty($context['current_board']) ? ';board=' . $context['current_board'] : '', '"> |
155 | 159 | <link rel="alternate" type="application/atom+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['atom'], '" href="', $scripturl, '?action=.xml;type=atom', !empty($context['current_board']) ? ';board=' . $context['current_board'] : '', '">'; |
160 | + } |
|
156 | 161 | |
157 | 162 | // If we're viewing a topic, these should be the previous and next topics, respectively. |
158 | - if (!empty($context['links']['next'])) |
|
159 | - echo ' |
|
163 | + if (!empty($context['links']['next'])) { |
|
164 | + echo ' |
|
160 | 165 | <link rel="next" href="', $context['links']['next'], '">'; |
166 | + } |
|
161 | 167 | |
162 | - if (!empty($context['links']['prev'])) |
|
163 | - echo ' |
|
168 | + if (!empty($context['links']['prev'])) { |
|
169 | + echo ' |
|
164 | 170 | <link rel="prev" href="', $context['links']['prev'], '">'; |
171 | + } |
|
165 | 172 | |
166 | 173 | // If we're in a board, or a topic for that matter, the index will be the board's index. |
167 | - if (!empty($context['current_board'])) |
|
168 | - echo ' |
|
174 | + if (!empty($context['current_board'])) { |
|
175 | + echo ' |
|
169 | 176 | <link rel="index" href="', $scripturl, '?board=', $context['current_board'], '.0">'; |
177 | + } |
|
170 | 178 | |
171 | 179 | // Output any remaining HTML headers. (from mods, maybe?) |
172 | 180 | echo $context['html_headers']; |
@@ -199,20 +207,22 @@ discard block |
||
199 | 207 | <li> |
200 | 208 | <a href="', $scripturl, '?action=profile"', !empty($context['self_profile']) ? ' class="active"' : '', ' id="profile_menu_top" onclick="return false;">'; |
201 | 209 | |
202 | - if (!empty($context['user']['avatar'])) |
|
203 | - echo $context['user']['avatar']['image']; |
|
210 | + if (!empty($context['user']['avatar'])) { |
|
211 | + echo $context['user']['avatar']['image']; |
|
212 | + } |
|
204 | 213 | |
205 | 214 | echo $context['user']['name'], '</a> |
206 | 215 | <div id="profile_menu" class="top_menu"></div> |
207 | 216 | </li>'; |
208 | 217 | |
209 | 218 | // Secondly, PMs if we're doing them |
210 | - if ($context['allow_pm']) |
|
211 | - echo ' |
|
219 | + if ($context['allow_pm']) { |
|
220 | + echo ' |
|
212 | 221 | <li> |
213 | 222 | <a href="', $scripturl, '?action=pm"', !empty($context['self_pm']) ? ' class="active"' : '', ' id="pm_menu_top">', $txt['pm_short'], !empty($context['user']['unread_messages']) ? ' <span class="amt">' . $context['user']['unread_messages'] . '</span>' : '', '</a> |
214 | 223 | <div id="pm_menu" class="top_menu scrollable"></div> |
215 | 224 | </li>'; |
225 | + } |
|
216 | 226 | |
217 | 227 | // Thirdly, alerts |
218 | 228 | echo ' |
@@ -227,17 +237,18 @@ discard block |
||
227 | 237 | } |
228 | 238 | // Otherwise they're a guest. Ask them to either register or login. |
229 | 239 | else |
230 | - if (empty($maintenance)) |
|
231 | - echo ' |
|
240 | + if (empty($maintenance)) { |
|
241 | + echo ' |
|
232 | 242 | <ul class="floatleft welcome"> |
233 | 243 | <li>', sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'), '</li> |
234 | 244 | </ul>'; |
235 | - else |
|
236 | - // In maintenance mode, only login is allowed and don't show OverlayDiv |
|
245 | + } else { |
|
246 | + // In maintenance mode, only login is allowed and don't show OverlayDiv |
|
237 | 247 | echo ' |
238 | 248 | <ul class="floatleft welcome"> |
239 | 249 | <li>', sprintf($txt['welcome_guest'], $txt['guest_title'], '', $scripturl. '?action=login', 'return true;'), '</li> |
240 | 250 | </ul>'; |
251 | + } |
|
241 | 252 | |
242 | 253 | if (!empty($modSettings['userLanguage']) && !empty($context['languages']) && count($context['languages']) > 1) |
243 | 254 | { |
@@ -245,9 +256,10 @@ discard block |
||
245 | 256 | <form id="languages_form" method="get" class="floatright"> |
246 | 257 | <select id="language_select" name="language" onchange="this.form.submit()">'; |
247 | 258 | |
248 | - foreach ($context['languages'] as $language) |
|
249 | - echo ' |
|
259 | + foreach ($context['languages'] as $language) { |
|
260 | + echo ' |
|
250 | 261 | <option value="', $language['filename'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' selected="selected"' : '', '>', str_replace('-utf8', '', $language['name']), '</option>'; |
262 | + } |
|
251 | 263 | |
252 | 264 | echo ' |
253 | 265 | </select> |
@@ -271,32 +283,37 @@ discard block |
||
271 | 283 | <option value="all"', ($selected == 'all' ? ' selected' : ''), '>', $txt['search_entireforum'], ' </option>'; |
272 | 284 | |
273 | 285 | // Can't limit it to a specific topic if we are not in one |
274 | - if (!empty($context['current_topic'])) |
|
275 | - echo ' |
|
286 | + if (!empty($context['current_topic'])) { |
|
287 | + echo ' |
|
276 | 288 | <option value="topic"', ($selected == 'current_topic' ? ' selected' : ''), '>', $txt['search_thistopic'], '</option>'; |
289 | + } |
|
277 | 290 | |
278 | 291 | // Can't limit it to a specific board if we are not in one |
279 | - if (!empty($context['current_board'])) |
|
280 | - echo ' |
|
292 | + if (!empty($context['current_board'])) { |
|
293 | + echo ' |
|
281 | 294 | <option value="board"', ($selected == 'current_board' ? ' selected' : ''), '>', $txt['search_thisbrd'], '</option>'; |
295 | + } |
|
282 | 296 | |
283 | 297 | // Can't search for members if we can't see the memberlist |
284 | - if (!empty($context['allow_memberlist'])) |
|
285 | - echo ' |
|
298 | + if (!empty($context['allow_memberlist'])) { |
|
299 | + echo ' |
|
286 | 300 | <option value="members"', ($selected == 'members' ? ' selected' : ''), '>', $txt['search_members'], ' </option>'; |
301 | + } |
|
287 | 302 | |
288 | 303 | echo ' |
289 | 304 | </select>'; |
290 | 305 | |
291 | 306 | // Search within current topic? |
292 | - if (!empty($context['current_topic'])) |
|
293 | - echo ' |
|
307 | + if (!empty($context['current_topic'])) { |
|
308 | + echo ' |
|
294 | 309 | <input type="hidden" name="sd_topic" value="', $context['current_topic'], '">'; |
310 | + } |
|
295 | 311 | |
296 | 312 | // If we're on a certain board, limit it to this board ;). |
297 | - elseif (!empty($context['current_board'])) |
|
298 | - echo ' |
|
313 | + elseif (!empty($context['current_board'])) { |
|
314 | + echo ' |
|
299 | 315 | <input type="hidden" name="sd_brd" value="', $context['current_board'], '">'; |
316 | + } |
|
300 | 317 | |
301 | 318 | echo ' |
302 | 319 | <input type="submit" name="search2" value="', $txt['search'], '" class="button"> |
@@ -328,12 +345,13 @@ discard block |
||
328 | 345 | </div>'; |
329 | 346 | |
330 | 347 | // Show a random news item? (or you could pick one from news_lines...) |
331 | - if (!empty($settings['enable_news']) && !empty($context['random_news_line'])) |
|
332 | - echo ' |
|
348 | + if (!empty($settings['enable_news']) && !empty($context['random_news_line'])) { |
|
349 | + echo ' |
|
333 | 350 | <div class="news"> |
334 | 351 | <h2>', $txt['news'], ': </h2> |
335 | 352 | <p>', $context['random_news_line'], '</p> |
336 | 353 | </div>'; |
354 | + } |
|
337 | 355 | |
338 | 356 | echo ' |
339 | 357 | <hr class="clear"> |
@@ -392,9 +410,10 @@ discard block |
||
392 | 410 | </ul>'; |
393 | 411 | |
394 | 412 | // Show the load time? |
395 | - if ($context['show_load_time']) |
|
396 | - echo ' |
|
413 | + if ($context['show_load_time']) { |
|
414 | + echo ' |
|
397 | 415 | <p>', sprintf($txt['page_created_full'], $context['load_time'], $context['load_queries']), '</p>'; |
416 | + } |
|
398 | 417 | |
399 | 418 | echo ' |
400 | 419 | </div> |
@@ -425,18 +444,20 @@ discard block |
||
425 | 444 | global $context, $shown_linktree, $scripturl, $txt; |
426 | 445 | |
427 | 446 | // If linktree is empty, just return - also allow an override. |
428 | - if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show)) |
|
429 | - return; |
|
447 | + if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show)) { |
|
448 | + return; |
|
449 | + } |
|
430 | 450 | echo ' |
431 | 451 | <div class="navigate_section"> |
432 | 452 | <ul>'; |
433 | 453 | |
434 | - if ($context['user']['is_logged']) |
|
435 | - echo ' |
|
454 | + if ($context['user']['is_logged']) { |
|
455 | + echo ' |
|
436 | 456 | <li class="unread_links"> |
437 | 457 | <a href="', $scripturl, '?action=unread" title="', $txt['unread_since_visit'], '">', $txt['view_unread_category'], '</a> |
438 | 458 | <a href="', $scripturl, '?action=unreadreplies" title="', $txt['show_unread_replies'], '">', $txt['unread_replies'], '</a> |
439 | 459 | </li>'; |
460 | + } |
|
440 | 461 | |
441 | 462 | // Each tree item has a URL and name. Some may have extra_before and extra_after. |
442 | 463 | foreach ($context['linktree'] as $link_num => $tree) |
@@ -447,25 +468,29 @@ discard block |
||
447 | 468 | // Don't show a separator for the first one. |
448 | 469 | // Better here. Always points to the next level when the linktree breaks to a second line. |
449 | 470 | // Picked a better looking HTML entity, and added support for RTL plus a span for styling. |
450 | - if ($link_num != 0) |
|
451 | - echo ' |
|
471 | + if ($link_num != 0) { |
|
472 | + echo ' |
|
452 | 473 | <span class="dividers">', $context['right_to_left'] ? ' ◄ ' : ' ► ', '</span>'; |
474 | + } |
|
453 | 475 | |
454 | 476 | // Show something before the link? |
455 | - if (isset($tree['extra_before'])) |
|
456 | - echo $tree['extra_before'], ' '; |
|
477 | + if (isset($tree['extra_before'])) { |
|
478 | + echo $tree['extra_before'], ' '; |
|
479 | + } |
|
457 | 480 | |
458 | 481 | // Show the link, including a URL if it should have one. |
459 | - if (isset($tree['url'])) |
|
460 | - echo ' |
|
482 | + if (isset($tree['url'])) { |
|
483 | + echo ' |
|
461 | 484 | <a href="' . $tree['url'] . '"><span>' . $tree['name'] . '</span></a>'; |
462 | - else |
|
463 | - echo ' |
|
485 | + } else { |
|
486 | + echo ' |
|
464 | 487 | <span>' . $tree['name'] . '</span>'; |
488 | + } |
|
465 | 489 | |
466 | 490 | // Show something after the link...? |
467 | - if (isset($tree['extra_after'])) |
|
468 | - echo ' ', $tree['extra_after']; |
|
491 | + if (isset($tree['extra_after'])) { |
|
492 | + echo ' ', $tree['extra_after']; |
|
493 | + } |
|
469 | 494 | |
470 | 495 | echo ' |
471 | 496 | </li>'; |
@@ -516,13 +541,14 @@ discard block |
||
516 | 541 | echo ' |
517 | 542 | <ul>'; |
518 | 543 | |
519 | - foreach ($childbutton['sub_buttons'] as $grandchildbutton) |
|
520 | - echo ' |
|
544 | + foreach ($childbutton['sub_buttons'] as $grandchildbutton) { |
|
545 | + echo ' |
|
521 | 546 | <li> |
522 | 547 | <a href="', $grandchildbutton['href'], '"', isset($grandchildbutton['target']) ? ' target="' . $grandchildbutton['target'] . '"' : '', '> |
523 | 548 | ', $grandchildbutton['title'], !empty($grandchildbutton['amt']) ? ' <span class="amt">' . $grandchildbutton['amt'] . '</span>' : '', ' |
524 | 549 | </a> |
525 | 550 | </li>'; |
551 | + } |
|
526 | 552 | |
527 | 553 | echo ' |
528 | 554 | </ul>'; |
@@ -553,8 +579,9 @@ discard block |
||
553 | 579 | { |
554 | 580 | global $context, $txt; |
555 | 581 | |
556 | - if (!is_array($strip_options)) |
|
557 | - $strip_options = array(); |
|
582 | + if (!is_array($strip_options)) { |
|
583 | + $strip_options = array(); |
|
584 | + } |
|
558 | 585 | |
559 | 586 | // Create the buttons... |
560 | 587 | $buttons = array(); |
@@ -563,8 +590,9 @@ discard block |
||
563 | 590 | // As of 2.1, the 'test' for each button happens while the array is being generated. The extra 'test' check here is deprecated but kept for backward compatibility (update your mods, folks!) |
564 | 591 | if (!isset($value['test']) || !empty($context[$value['test']])) |
565 | 592 | { |
566 | - if (!isset($value['id'])) |
|
567 | - $value['id'] = $key; |
|
593 | + if (!isset($value['id'])) { |
|
594 | + $value['id'] = $key; |
|
595 | + } |
|
568 | 596 | |
569 | 597 | $button = ' |
570 | 598 | <a class="button button_strip_' . $key . (!empty($value['active']) ? ' active' : '') . (isset($value['class']) ? ' ' . $value['class'] : '') . '" ' . (!empty($value['url']) ? 'href="' . $value['url'] . '"' : '') . ' ' . (isset($value['custom']) ? ' ' . $value['custom'] : '') . '>' . $txt[$value['text']] . '</a>'; |
@@ -577,13 +605,15 @@ discard block |
||
577 | 605 | <div class="overview">'; |
578 | 606 | foreach ($value['sub_buttons'] as $element) |
579 | 607 | { |
580 | - if (isset($element['test']) && empty($context[$element['test']])) |
|
581 | - continue; |
|
608 | + if (isset($element['test']) && empty($context[$element['test']])) { |
|
609 | + continue; |
|
610 | + } |
|
582 | 611 | |
583 | 612 | $button .= ' |
584 | 613 | <a href="' . $element['url'] . '"><strong>' . $txt[$element['text']] . '</strong>'; |
585 | - if (isset($txt[$element['text'] . '_desc'])) |
|
586 | - $button .= '<br><span>' . $txt[$element['text'] . '_desc'] . '</span>'; |
|
614 | + if (isset($txt[$element['text'] . '_desc'])) { |
|
615 | + $button .= '<br><span>' . $txt[$element['text'] . '_desc'] . '</span>'; |
|
616 | + } |
|
587 | 617 | $button .= '</a>'; |
588 | 618 | } |
589 | 619 | $button .= ' |
@@ -597,8 +627,9 @@ discard block |
||
597 | 627 | } |
598 | 628 | |
599 | 629 | // No buttons? No button strip either. |
600 | - if (empty($buttons)) |
|
601 | - return; |
|
630 | + if (empty($buttons)) { |
|
631 | + return; |
|
632 | + } |
|
602 | 633 | |
603 | 634 | echo ' |
604 | 635 | <div class="buttonlist', !empty($direction) ? ' float' . $direction : '', '"', (empty($buttons) ? ' style="display: none;"' : ''), (!empty($strip_options['id']) ? ' id="' . $strip_options['id'] . '"' : ''), '> |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 4 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * Takes a message and parses it, returning nothing. |
@@ -31,8 +32,9 @@ discard block |
||
31 | 32 | global $user_info, $modSettings, $context, $sourcedir; |
32 | 33 | |
33 | 34 | // This line makes all languages *theoretically* work even with the wrong charset ;). |
34 | - if (empty($context['utf8'])) |
|
35 | - $message = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $message); |
|
35 | + if (empty($context['utf8'])) { |
|
36 | + $message = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $message); |
|
37 | + } |
|
36 | 38 | |
37 | 39 | // Clean up after nobbc ;). |
38 | 40 | $message = preg_replace_callback('~\[nobbc\](.+?)\[/nobbc\]~is', function($a) |
@@ -47,17 +49,19 @@ discard block |
||
47 | 49 | $message = preg_replace('~\.{100,}~', '...', $message); |
48 | 50 | |
49 | 51 | // Trim off trailing quotes - these often happen by accident. |
50 | - while (substr($message, -7) == '[quote]') |
|
51 | - $message = substr($message, 0, -7); |
|
52 | - while (substr($message, 0, 8) == '[/quote]') |
|
53 | - $message = substr($message, 8); |
|
52 | + while (substr($message, -7) == '[quote]') { |
|
53 | + $message = substr($message, 0, -7); |
|
54 | + } |
|
55 | + while (substr($message, 0, 8) == '[/quote]') { |
|
56 | + $message = substr($message, 8); |
|
57 | + } |
|
54 | 58 | |
55 | 59 | // Find all code blocks, work out whether we'd be parsing them, then ensure they are all closed. |
56 | 60 | $in_tag = false; |
57 | 61 | $had_tag = false; |
58 | 62 | $codeopen = 0; |
59 | - if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches)) |
|
60 | - foreach ($matches[0] as $index => $dummy) |
|
63 | + if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches)) { |
|
64 | + foreach ($matches[0] as $index => $dummy) |
|
61 | 65 | { |
62 | 66 | // Closing? |
63 | 67 | if (!empty($matches[2][$index])) |
@@ -65,6 +69,7 @@ discard block |
||
65 | 69 | // If it's closing and we're not in a tag we need to open it... |
66 | 70 | if (!$in_tag) |
67 | 71 | $codeopen = true; |
72 | + } |
|
68 | 73 | // Either way we ain't in one any more. |
69 | 74 | $in_tag = false; |
70 | 75 | } |
@@ -73,17 +78,20 @@ discard block |
||
73 | 78 | { |
74 | 79 | $had_tag = true; |
75 | 80 | // If we're in a tag don't do nought! |
76 | - if (!$in_tag) |
|
77 | - $in_tag = true; |
|
81 | + if (!$in_tag) { |
|
82 | + $in_tag = true; |
|
83 | + } |
|
78 | 84 | } |
79 | 85 | } |
80 | 86 | |
81 | 87 | // If we have an open tag, close it. |
82 | - if ($in_tag) |
|
83 | - $message .= '[/code]'; |
|
88 | + if ($in_tag) { |
|
89 | + $message .= '[/code]'; |
|
90 | + } |
|
84 | 91 | // Open any ones that need to be open, only if we've never had a tag. |
85 | - if ($codeopen && !$had_tag) |
|
86 | - $message = '[code]' . $message; |
|
92 | + if ($codeopen && !$had_tag) { |
|
93 | + $message = '[code]' . $message; |
|
94 | + } |
|
87 | 95 | |
88 | 96 | // Replace code BBC with placeholders. We'll restore them at the end. |
89 | 97 | $parts = preg_split('~(\[/code\]|\[code(?:=[^\]]+)?\])~i', $message, -1, PREG_SPLIT_DELIM_CAPTURE); |
@@ -108,23 +116,26 @@ discard block |
||
108 | 116 | fixTags($message); |
109 | 117 | |
110 | 118 | // Replace /me.+?\n with [me=name]dsf[/me]\n. |
111 | - if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false) |
|
112 | - $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me="' . $user_info['name'] . '"]$2[/me]', $message); |
|
113 | - else |
|
114 | - $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message); |
|
119 | + if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false) { |
|
120 | + $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me="' . $user_info['name'] . '"]$2[/me]', $message); |
|
121 | + } else { |
|
122 | + $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message); |
|
123 | + } |
|
115 | 124 | |
116 | 125 | if (!$previewing && strpos($message, '[html]') !== false) |
117 | 126 | { |
118 | - if (allowedTo('admin_forum')) |
|
119 | - $message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) { |
|
127 | + if (allowedTo('admin_forum')) { |
|
128 | + $message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) { |
|
120 | 129 | return '[html]' . strtr(un_htmlspecialchars($m[1]), array("\n" => ' ', ' ' => '  ', '[' => '[', ']' => ']')) . '[/html]'; |
130 | + } |
|
121 | 131 | }, $message); |
122 | 132 | |
123 | 133 | // We should edit them out, or else if an admin edits the message they will get shown... |
124 | 134 | else |
125 | 135 | { |
126 | - while (strpos($message, '[html]') !== false) |
|
127 | - $message = preg_replace('~\[[/]?html\]~i', '', $message); |
|
136 | + while (strpos($message, '[html]') !== false) { |
|
137 | + $message = preg_replace('~\[[/]?html\]~i', '', $message); |
|
138 | + } |
|
128 | 139 | } |
129 | 140 | } |
130 | 141 | |
@@ -146,10 +157,12 @@ discard block |
||
146 | 157 | |
147 | 158 | $list_open = substr_count($message, '[list]') + substr_count($message, '[list '); |
148 | 159 | $list_close = substr_count($message, '[/list]'); |
149 | - if ($list_close - $list_open > 0) |
|
150 | - $message = str_repeat('[list]', $list_close - $list_open) . $message; |
|
151 | - if ($list_open - $list_close > 0) |
|
152 | - $message = $message . str_repeat('[/list]', $list_open - $list_close); |
|
160 | + if ($list_close - $list_open > 0) { |
|
161 | + $message = str_repeat('[list]', $list_close - $list_open) . $message; |
|
162 | + } |
|
163 | + if ($list_open - $list_close > 0) { |
|
164 | + $message = $message . str_repeat('[/list]', $list_open - $list_close); |
|
165 | + } |
|
153 | 166 | |
154 | 167 | $mistake_fixes = array( |
155 | 168 | // Find [table]s not followed by [tr]. |
@@ -198,8 +211,9 @@ discard block |
||
198 | 211 | ); |
199 | 212 | |
200 | 213 | // Fix up some use of tables without [tr]s, etc. (it has to be done more than once to catch it all.) |
201 | - for ($j = 0; $j < 3; $j++) |
|
202 | - $message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message); |
|
214 | + for ($j = 0; $j < 3; $j++) { |
|
215 | + $message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message); |
|
216 | + } |
|
203 | 217 | |
204 | 218 | // Remove empty bbc from the sections outside the code tags |
205 | 219 | $allowedEmpty = array( |
@@ -210,24 +224,28 @@ discard block |
||
210 | 224 | require_once($sourcedir . '/Subs.php'); |
211 | 225 | |
212 | 226 | $alltags = array(); |
213 | - foreach (($codes = parse_bbc(false)) as $code) |
|
214 | - if (!in_array($code['tag'], $allowedEmpty)) |
|
227 | + foreach (($codes = parse_bbc(false)) as $code) { |
|
228 | + if (!in_array($code['tag'], $allowedEmpty)) |
|
215 | 229 | $alltags[] = $code['tag']; |
230 | + } |
|
216 | 231 | |
217 | 232 | $alltags_regex = '\b' . implode("\b|\b", array_unique($alltags)) . '\b'; |
218 | 233 | |
219 | - while (preg_match('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', $message)) |
|
220 | - $message = preg_replace('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', '', $message); |
|
234 | + while (preg_match('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', $message)) { |
|
235 | + $message = preg_replace('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', '', $message); |
|
236 | + } |
|
221 | 237 | |
222 | 238 | // Restore code blocks |
223 | - if (!empty($code_tags)) |
|
224 | - $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
239 | + if (!empty($code_tags)) { |
|
240 | + $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
241 | + } |
|
225 | 242 | |
226 | 243 | // Restore white space entities |
227 | - if (!$previewing) |
|
228 | - $message = strtr($message, array(' ' => ' ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
229 | - else |
|
230 | - $message = strtr($message, array(' ' => ' ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
244 | + if (!$previewing) { |
|
245 | + $message = strtr($message, array(' ' => ' ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
246 | + } else { |
|
247 | + $message = strtr($message, array(' ' => ' ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
248 | + } |
|
231 | 249 | |
232 | 250 | // Now let's quickly clean up things that will slow our parser (which are common in posted code.) |
233 | 251 | $message = strtr($message, array('[]' => '[]', '['' => '['')); |
@@ -270,8 +288,9 @@ discard block |
||
270 | 288 | return "[time]" . timeformat("$m[1]", false) . "[/time]"; |
271 | 289 | }, $message); |
272 | 290 | |
273 | - if (!empty($code_tags)) |
|
274 | - $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
291 | + if (!empty($code_tags)) { |
|
292 | + $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
293 | + } |
|
275 | 294 | |
276 | 295 | // Change breaks back to \n's and &nsbp; back to spaces. |
277 | 296 | return preg_replace('~<br( /)?' . '>~', "\n", str_replace(' ', ' ', $message)); |
@@ -352,8 +371,9 @@ discard block |
||
352 | 371 | ); |
353 | 372 | |
354 | 373 | // Fix each type of tag. |
355 | - foreach ($fixArray as $param) |
|
356 | - fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra'])); |
|
374 | + foreach ($fixArray as $param) { |
|
375 | + fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra'])); |
|
376 | + } |
|
357 | 377 | |
358 | 378 | // Now fix possible security problems with images loading links automatically... |
359 | 379 | $message = preg_replace_callback('~(\[img.*?\])(.+?)\[/img\]~is', function($m) |
@@ -378,10 +398,11 @@ discard block |
||
378 | 398 | { |
379 | 399 | global $boardurl, $scripturl; |
380 | 400 | |
381 | - if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0) |
|
382 | - $domain_url = $match[1]; |
|
383 | - else |
|
384 | - $domain_url = $boardurl . '/'; |
|
401 | + if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0) { |
|
402 | + $domain_url = $match[1]; |
|
403 | + } else { |
|
404 | + $domain_url = $boardurl . '/'; |
|
405 | + } |
|
385 | 406 | |
386 | 407 | $replaces = array(); |
387 | 408 | |
@@ -389,11 +410,11 @@ discard block |
||
389 | 410 | { |
390 | 411 | $quoted = preg_match('~\[(' . $myTag . ')="~', $message); |
391 | 412 | preg_match_all('~\[(' . $myTag . ')=' . ($quoted ? '"(.*?)"' : '([^\]]*?)') . '\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches); |
413 | + } elseif ($hasEqualSign) { |
|
414 | + preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches); |
|
415 | + } else { |
|
416 | + preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches); |
|
392 | 417 | } |
393 | - elseif ($hasEqualSign) |
|
394 | - preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches); |
|
395 | - else |
|
396 | - preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches); |
|
397 | 418 | |
398 | 419 | foreach ($matches[0] as $k => $dummy) |
399 | 420 | { |
@@ -406,49 +427,53 @@ discard block |
||
406 | 427 | foreach ($protocols as $protocol) |
407 | 428 | { |
408 | 429 | $found = strncasecmp($replace, $protocol . '://', strlen($protocol) + 3) === 0; |
409 | - if ($found) |
|
410 | - break; |
|
430 | + if ($found) { |
|
431 | + break; |
|
432 | + } |
|
411 | 433 | } |
412 | 434 | |
413 | 435 | if (!$found && $protocols[0] == 'http') |
414 | 436 | { |
415 | - if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//') |
|
416 | - $replace = $domain_url . $replace; |
|
417 | - elseif (substr($replace, 0, 1) == '?') |
|
418 | - $replace = $scripturl . $replace; |
|
419 | - elseif (substr($replace, 0, 1) == '#' && $embeddedUrl) |
|
437 | + if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//') { |
|
438 | + $replace = $domain_url . $replace; |
|
439 | + } elseif (substr($replace, 0, 1) == '?') { |
|
440 | + $replace = $scripturl . $replace; |
|
441 | + } elseif (substr($replace, 0, 1) == '#' && $embeddedUrl) |
|
420 | 442 | { |
421 | 443 | $replace = '#' . preg_replace('~[^A-Za-z0-9_\-#]~', '', substr($replace, 1)); |
422 | 444 | $this_tag = 'iurl'; |
423 | 445 | $this_close = 'iurl'; |
446 | + } elseif (substr($replace, 0, 2) != '//') { |
|
447 | + $replace = $protocols[0] . '://' . $replace; |
|
424 | 448 | } |
425 | - elseif (substr($replace, 0, 2) != '//') |
|
426 | - $replace = $protocols[0] . '://' . $replace; |
|
427 | - } |
|
428 | - elseif (!$found && $protocols[0] == 'ftp') |
|
429 | - $replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace); |
|
430 | - elseif (!$found) |
|
431 | - $replace = $protocols[0] . '://' . $replace; |
|
432 | - |
|
433 | - if ($hasEqualSign && $embeddedUrl) |
|
434 | - $replaces[$matches[0][$k]] = '[' . $this_tag . '="' . $replace . '"]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']'); |
|
435 | - elseif ($hasEqualSign) |
|
436 | - $replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']'; |
|
437 | - elseif ($embeddedUrl) |
|
438 | - $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']'; |
|
439 | - else |
|
440 | - $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']'; |
|
449 | + } elseif (!$found && $protocols[0] == 'ftp') { |
|
450 | + $replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace); |
|
451 | + } elseif (!$found) { |
|
452 | + $replace = $protocols[0] . '://' . $replace; |
|
453 | + } |
|
454 | + |
|
455 | + if ($hasEqualSign && $embeddedUrl) { |
|
456 | + $replaces[$matches[0][$k]] = '[' . $this_tag . '="' . $replace . '"]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']'); |
|
457 | + } elseif ($hasEqualSign) { |
|
458 | + $replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']'; |
|
459 | + } elseif ($embeddedUrl) { |
|
460 | + $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']'; |
|
461 | + } else { |
|
462 | + $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']'; |
|
463 | + } |
|
441 | 464 | } |
442 | 465 | |
443 | 466 | foreach ($replaces as $k => $v) |
444 | 467 | { |
445 | - if ($k == $v) |
|
446 | - unset($replaces[$k]); |
|
468 | + if ($k == $v) { |
|
469 | + unset($replaces[$k]); |
|
470 | + } |
|
447 | 471 | } |
448 | 472 | |
449 | - if (!empty($replaces)) |
|
450 | - $message = strtr($message, $replaces); |
|
451 | -} |
|
473 | + if (!empty($replaces)) { |
|
474 | + $message = strtr($message, $replaces); |
|
475 | + } |
|
476 | + } |
|
452 | 477 | |
453 | 478 | /** |
454 | 479 | * This function sends an email to the specified recipient(s). |
@@ -492,8 +517,9 @@ discard block |
||
492 | 517 | } |
493 | 518 | |
494 | 519 | // Nothing left? Nothing else to do |
495 | - if (empty($to_array)) |
|
496 | - return true; |
|
520 | + if (empty($to_array)) { |
|
521 | + return true; |
|
522 | + } |
|
497 | 523 | |
498 | 524 | // Once upon a time, Hotmail could not interpret non-ASCII mails. |
499 | 525 | // In honour of those days, it's still called the 'hotmail fix'. |
@@ -510,15 +536,17 @@ discard block |
||
510 | 536 | } |
511 | 537 | |
512 | 538 | // Call this function recursively for the hotmail addresses. |
513 | - if (!empty($hotmail_to)) |
|
514 | - $mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private); |
|
539 | + if (!empty($hotmail_to)) { |
|
540 | + $mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private); |
|
541 | + } |
|
515 | 542 | |
516 | 543 | // The remaining addresses no longer need the fix. |
517 | 544 | $hotmail_fix = false; |
518 | 545 | |
519 | 546 | // No other addresses left? Return instantly. |
520 | - if (empty($to_array)) |
|
521 | - return $mail_result; |
|
547 | + if (empty($to_array)) { |
|
548 | + return $mail_result; |
|
549 | + } |
|
522 | 550 | } |
523 | 551 | |
524 | 552 | // Get rid of entities. |
@@ -543,13 +571,15 @@ discard block |
||
543 | 571 | $headers .= 'Return-Path: ' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . $line_break; |
544 | 572 | $headers .= 'Date: ' . gmdate('D, d M Y H:i:s') . ' -0000' . $line_break; |
545 | 573 | |
546 | - if ($message_id !== null && empty($modSettings['mail_no_message_id'])) |
|
547 | - $headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break; |
|
574 | + if ($message_id !== null && empty($modSettings['mail_no_message_id'])) { |
|
575 | + $headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break; |
|
576 | + } |
|
548 | 577 | $headers .= 'X-Mailer: SMF' . $line_break; |
549 | 578 | |
550 | 579 | // Pass this to the integration before we start modifying the output -- it'll make it easier later. |
551 | - if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true)) |
|
552 | - return false; |
|
580 | + if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true)) { |
|
581 | + return false; |
|
582 | + } |
|
553 | 583 | |
554 | 584 | // Save the original message... |
555 | 585 | $orig_message = $message; |
@@ -598,17 +628,19 @@ discard block |
||
598 | 628 | } |
599 | 629 | |
600 | 630 | // Are we using the mail queue, if so this is where we butt in... |
601 | - if ($priority != 0) |
|
602 | - return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private); |
|
631 | + if ($priority != 0) { |
|
632 | + return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private); |
|
633 | + } |
|
603 | 634 | |
604 | 635 | // If it's a priority mail, send it now - note though that this should NOT be used for sending many at once. |
605 | 636 | elseif (!empty($modSettings['mail_limit'])) |
606 | 637 | { |
607 | 638 | list ($last_mail_time, $mails_this_minute) = @explode('|', $modSettings['mail_recent']); |
608 | - if (empty($mails_this_minute) || time() > $last_mail_time + 60) |
|
609 | - $new_queue_stat = time() . '|' . 1; |
|
610 | - else |
|
611 | - $new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1); |
|
639 | + if (empty($mails_this_minute) || time() > $last_mail_time + 60) { |
|
640 | + $new_queue_stat = time() . '|' . 1; |
|
641 | + } else { |
|
642 | + $new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1); |
|
643 | + } |
|
612 | 644 | |
613 | 645 | updateSettings(array('mail_recent' => $new_queue_stat)); |
614 | 646 | } |
@@ -642,8 +674,7 @@ discard block |
||
642 | 674 | log_error(sprintf($txt['mail_send_unable'], $to)); |
643 | 675 | $mail_result = false; |
644 | 676 | } |
645 | - } |
|
646 | - catch(ErrorException $e) |
|
677 | + } catch(ErrorException $e) |
|
647 | 678 | { |
648 | 679 | log_error($e->getMessage(), 'general', $e->getFile(), $e->getLine()); |
649 | 680 | log_error(sprintf($txt['mail_send_unable'], $to)); |
@@ -653,12 +684,13 @@ discard block |
||
653 | 684 | |
654 | 685 | // Wait, wait, I'm still sending here! |
655 | 686 | @set_time_limit(300); |
656 | - if (function_exists('apache_reset_timeout')) |
|
657 | - @apache_reset_timeout(); |
|
687 | + if (function_exists('apache_reset_timeout')) { |
|
688 | + @apache_reset_timeout(); |
|
689 | + } |
|
658 | 690 | } |
691 | + } else { |
|
692 | + $mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers); |
|
659 | 693 | } |
660 | - else |
|
661 | - $mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers); |
|
662 | 694 | |
663 | 695 | // Everything go smoothly? |
664 | 696 | return $mail_result; |
@@ -684,8 +716,9 @@ discard block |
||
684 | 716 | static $cur_insert = array(); |
685 | 717 | static $cur_insert_len = 0; |
686 | 718 | |
687 | - if ($cur_insert_len == 0) |
|
688 | - $cur_insert = array(); |
|
719 | + if ($cur_insert_len == 0) { |
|
720 | + $cur_insert = array(); |
|
721 | + } |
|
689 | 722 | |
690 | 723 | // If we're flushing, make the final inserts - also if we're near the MySQL length limit! |
691 | 724 | if (($flush || $cur_insert_len > 800000) && !empty($cur_insert)) |
@@ -760,8 +793,9 @@ discard block |
||
760 | 793 | } |
761 | 794 | |
762 | 795 | // If they are using SSI there is a good chance obExit will never be called. So lets be nice and flush it for them. |
763 | - if (SMF === 'SSI' || SMF === 'BACKGROUND') |
|
764 | - return AddMailQueue(true); |
|
796 | + if (SMF === 'SSI' || SMF === 'BACKGROUND') { |
|
797 | + return AddMailQueue(true); |
|
798 | + } |
|
765 | 799 | |
766 | 800 | return true; |
767 | 801 | } |
@@ -792,23 +826,26 @@ discard block |
||
792 | 826 | 'sent' => array() |
793 | 827 | ); |
794 | 828 | |
795 | - if ($from === null) |
|
796 | - $from = array( |
|
829 | + if ($from === null) { |
|
830 | + $from = array( |
|
797 | 831 | 'id' => $user_info['id'], |
798 | 832 | 'name' => $user_info['name'], |
799 | 833 | 'username' => $user_info['username'] |
800 | 834 | ); |
835 | + } |
|
801 | 836 | |
802 | 837 | // This is the one that will go in their inbox. |
803 | 838 | $htmlmessage = $smcFunc['htmlspecialchars']($message, ENT_QUOTES); |
804 | 839 | preparsecode($htmlmessage); |
805 | 840 | $htmlsubject = strtr($smcFunc['htmlspecialchars']($subject), array("\r" => '', "\n" => '', "\t" => '')); |
806 | - if ($smcFunc['strlen']($htmlsubject) > 100) |
|
807 | - $htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100); |
|
841 | + if ($smcFunc['strlen']($htmlsubject) > 100) { |
|
842 | + $htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100); |
|
843 | + } |
|
808 | 844 | |
809 | 845 | // Make sure is an array |
810 | - if (!is_array($recipients)) |
|
811 | - $recipients = array($recipients); |
|
846 | + if (!is_array($recipients)) { |
|
847 | + $recipients = array($recipients); |
|
848 | + } |
|
812 | 849 | |
813 | 850 | // Integrated PMs |
814 | 851 | call_integration_hook('integrate_personal_message', array(&$recipients, &$from, &$subject, &$message)); |
@@ -836,21 +873,23 @@ discard block |
||
836 | 873 | 'usernames' => array_keys($usernames), |
837 | 874 | ) |
838 | 875 | ); |
839 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
840 | - if (isset($usernames[$smcFunc['strtolower']($row['member_name'])])) |
|
876 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
877 | + if (isset($usernames[$smcFunc['strtolower']($row['member_name'])])) |
|
841 | 878 | $usernames[$smcFunc['strtolower']($row['member_name'])] = $row['id_member']; |
879 | + } |
|
842 | 880 | $smcFunc['db_free_result']($request); |
843 | 881 | |
844 | 882 | // Replace the usernames with IDs. Drop usernames that couldn't be found. |
845 | - foreach ($recipients as $rec_type => $rec) |
|
846 | - foreach ($rec as $id => $member) |
|
883 | + foreach ($recipients as $rec_type => $rec) { |
|
884 | + foreach ($rec as $id => $member) |
|
847 | 885 | { |
848 | 886 | if (is_numeric($recipients[$rec_type][$id])) |
849 | 887 | continue; |
888 | + } |
|
850 | 889 | |
851 | - if (!empty($usernames[$member])) |
|
852 | - $recipients[$rec_type][$id] = $usernames[$member]; |
|
853 | - else |
|
890 | + if (!empty($usernames[$member])) { |
|
891 | + $recipients[$rec_type][$id] = $usernames[$member]; |
|
892 | + } else |
|
854 | 893 | { |
855 | 894 | $log['failed'][$id] = sprintf($txt['pm_error_user_not_found'], $recipients[$rec_type][$id]); |
856 | 895 | unset($recipients[$rec_type][$id]); |
@@ -888,8 +927,9 @@ discard block |
||
888 | 927 | $delete = false; |
889 | 928 | foreach ($criteria as $criterium) |
890 | 929 | { |
891 | - if (($criterium['t'] == 'mid' && $criterium['v'] == $from['id']) || ($criterium['t'] == 'gid' && in_array($criterium['v'], $user_info['groups'])) || ($criterium['t'] == 'sub' && strpos($subject, $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($message, $criterium['v']) !== false)) |
|
892 | - $delete = true; |
|
930 | + if (($criterium['t'] == 'mid' && $criterium['v'] == $from['id']) || ($criterium['t'] == 'gid' && in_array($criterium['v'], $user_info['groups'])) || ($criterium['t'] == 'sub' && strpos($subject, $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($message, $criterium['v']) !== false)) { |
|
931 | + $delete = true; |
|
932 | + } |
|
893 | 933 | // If we're adding and one criteria don't match then we stop! |
894 | 934 | elseif (!$row['is_or']) |
895 | 935 | { |
@@ -897,8 +937,9 @@ discard block |
||
897 | 937 | break; |
898 | 938 | } |
899 | 939 | } |
900 | - if ($delete) |
|
901 | - $deletes[$row['id_member']] = 1; |
|
940 | + if ($delete) { |
|
941 | + $deletes[$row['id_member']] = 1; |
|
942 | + } |
|
902 | 943 | } |
903 | 944 | $smcFunc['db_free_result']($request); |
904 | 945 | |
@@ -913,8 +954,9 @@ discard block |
||
913 | 954 | array( |
914 | 955 | ) |
915 | 956 | ); |
916 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
917 | - $message_limit_cache[$row['id_group']] = $row['max_messages']; |
|
957 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
958 | + $message_limit_cache[$row['id_group']] = $row['max_messages']; |
|
959 | + } |
|
918 | 960 | $smcFunc['db_free_result']($request); |
919 | 961 | } |
920 | 962 | |
@@ -922,8 +964,9 @@ discard block |
||
922 | 964 | require_once($sourcedir . '/Subs-Members.php'); |
923 | 965 | $pmReadGroups = groupsAllowedTo('pm_read'); |
924 | 966 | |
925 | - if (empty($modSettings['permission_enable_deny'])) |
|
926 | - $pmReadGroups['denied'] = array(); |
|
967 | + if (empty($modSettings['permission_enable_deny'])) { |
|
968 | + $pmReadGroups['denied'] = array(); |
|
969 | + } |
|
927 | 970 | |
928 | 971 | // Load their alert preferences |
929 | 972 | require_once($sourcedir . '/Subs-Notify.php'); |
@@ -955,8 +998,9 @@ discard block |
||
955 | 998 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
956 | 999 | { |
957 | 1000 | // Don't do anything for members to be deleted! |
958 | - if (isset($deletes[$row['id_member']])) |
|
959 | - continue; |
|
1001 | + if (isset($deletes[$row['id_member']])) { |
|
1002 | + continue; |
|
1003 | + } |
|
960 | 1004 | |
961 | 1005 | // Load the preferences for this member (if any) |
962 | 1006 | $prefs = !empty($notifyPrefs[$row['id_member']]) ? $notifyPrefs[$row['id_member']] : array(); |
@@ -977,8 +1021,9 @@ discard block |
||
977 | 1021 | { |
978 | 1022 | foreach ($groups as $id) |
979 | 1023 | { |
980 | - if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id]) |
|
981 | - $message_limit = $message_limit_cache[$id]; |
|
1024 | + if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id]) { |
|
1025 | + $message_limit = $message_limit_cache[$id]; |
|
1026 | + } |
|
982 | 1027 | } |
983 | 1028 | |
984 | 1029 | if ($message_limit > 0 && $message_limit <= $row['instant_messages']) |
@@ -1026,8 +1071,9 @@ discard block |
||
1026 | 1071 | $smcFunc['db_free_result']($request); |
1027 | 1072 | |
1028 | 1073 | // Only 'send' the message if there are any recipients left. |
1029 | - if (empty($all_to)) |
|
1030 | - return $log; |
|
1074 | + if (empty($all_to)) { |
|
1075 | + return $log; |
|
1076 | + } |
|
1031 | 1077 | |
1032 | 1078 | // Insert the message itself and then grab the last insert id. |
1033 | 1079 | $id_pm = $smcFunc['db_insert']('', |
@@ -1048,8 +1094,8 @@ discard block |
||
1048 | 1094 | if (!empty($id_pm)) |
1049 | 1095 | { |
1050 | 1096 | // If this is new we need to set it part of it's own conversation. |
1051 | - if (empty($pm_head)) |
|
1052 | - $smcFunc['db_query']('', ' |
|
1097 | + if (empty($pm_head)) { |
|
1098 | + $smcFunc['db_query']('', ' |
|
1053 | 1099 | UPDATE {db_prefix}personal_messages |
1054 | 1100 | SET id_pm_head = {int:id_pm_head} |
1055 | 1101 | WHERE id_pm = {int:id_pm_head}', |
@@ -1057,6 +1103,7 @@ discard block |
||
1057 | 1103 | 'id_pm_head' => $id_pm, |
1058 | 1104 | ) |
1059 | 1105 | ); |
1106 | + } |
|
1060 | 1107 | |
1061 | 1108 | // Some people think manually deleting personal_messages is fun... it's not. We protect against it though :) |
1062 | 1109 | $smcFunc['db_query']('', ' |
@@ -1072,8 +1119,9 @@ discard block |
||
1072 | 1119 | foreach ($all_to as $to) |
1073 | 1120 | { |
1074 | 1121 | $insertRows[] = array($id_pm, $to, in_array($to, $recipients['bcc']) ? 1 : 0, isset($deletes[$to]) ? 1 : 0, 1); |
1075 | - if (!in_array($to, $recipients['bcc'])) |
|
1076 | - $to_list[] = $to; |
|
1122 | + if (!in_array($to, $recipients['bcc'])) { |
|
1123 | + $to_list[] = $to; |
|
1124 | + } |
|
1077 | 1125 | } |
1078 | 1126 | |
1079 | 1127 | $smcFunc['db_insert']('insert', |
@@ -1091,9 +1139,9 @@ discard block |
||
1091 | 1139 | { |
1092 | 1140 | censorText($message); |
1093 | 1141 | $message = trim(un_htmlspecialchars(strip_tags(strtr(parse_bbc($smcFunc['htmlspecialchars']($message), false), array('<br>' => "\n", '</div>' => "\n", '</li>' => "\n", '[' => '[', ']' => ']'))))); |
1142 | + } else { |
|
1143 | + $message = ''; |
|
1094 | 1144 | } |
1095 | - else |
|
1096 | - $message = ''; |
|
1097 | 1145 | |
1098 | 1146 | $to_names = array(); |
1099 | 1147 | if (count($to_list) > 1) |
@@ -1106,8 +1154,9 @@ discard block |
||
1106 | 1154 | 'to_members' => $to_list, |
1107 | 1155 | ) |
1108 | 1156 | ); |
1109 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1110 | - $to_names[] = un_htmlspecialchars($row['real_name']); |
|
1157 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1158 | + $to_names[] = un_htmlspecialchars($row['real_name']); |
|
1159 | + } |
|
1111 | 1160 | $smcFunc['db_free_result']($request); |
1112 | 1161 | } |
1113 | 1162 | $replacements = array( |
@@ -1135,11 +1184,13 @@ discard block |
||
1135 | 1184 | loadLanguage('index+PersonalMessage'); |
1136 | 1185 | |
1137 | 1186 | // Add one to their unread and read message counts. |
1138 | - foreach ($all_to as $k => $id) |
|
1139 | - if (isset($deletes[$id])) |
|
1187 | + foreach ($all_to as $k => $id) { |
|
1188 | + if (isset($deletes[$id])) |
|
1140 | 1189 | unset($all_to[$k]); |
1141 | - if (!empty($all_to)) |
|
1142 | - updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1)); |
|
1190 | + } |
|
1191 | + if (!empty($all_to)) { |
|
1192 | + updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1)); |
|
1193 | + } |
|
1143 | 1194 | |
1144 | 1195 | return $log; |
1145 | 1196 | } |
@@ -1169,15 +1220,17 @@ discard block |
||
1169 | 1220 | // Let's, for now, assume there are only 'ish characters. |
1170 | 1221 | $simple = true; |
1171 | 1222 | |
1172 | - foreach ($matches[1] as $entity) |
|
1173 | - if ($entity > 128) |
|
1223 | + foreach ($matches[1] as $entity) { |
|
1224 | + if ($entity > 128) |
|
1174 | 1225 | $simple = false; |
1226 | + } |
|
1175 | 1227 | unset($matches); |
1176 | 1228 | |
1177 | - if ($simple) |
|
1178 | - $string = preg_replace_callback('~&#(\d{3,8});~', function($m) |
|
1229 | + if ($simple) { |
|
1230 | + $string = preg_replace_callback('~&#(\d{3,8});~', function($m) |
|
1179 | 1231 | { |
1180 | 1232 | return chr("$m[1]"); |
1233 | + } |
|
1181 | 1234 | }, $string); |
1182 | 1235 | else |
1183 | 1236 | { |
@@ -1185,8 +1238,9 @@ discard block |
||
1185 | 1238 | if (!$context['utf8'] && function_exists('iconv')) |
1186 | 1239 | { |
1187 | 1240 | $newstring = @iconv($context['character_set'], 'UTF-8', $string); |
1188 | - if ($newstring) |
|
1189 | - $string = $newstring; |
|
1241 | + if ($newstring) { |
|
1242 | + $string = $newstring; |
|
1243 | + } |
|
1190 | 1244 | } |
1191 | 1245 | |
1192 | 1246 | $string = preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $string); |
@@ -1202,23 +1256,25 @@ discard block |
||
1202 | 1256 | if (!$context['utf8'] && function_exists('iconv')) |
1203 | 1257 | { |
1204 | 1258 | $newstring = @iconv($context['character_set'], 'UTF-8', $string); |
1205 | - if ($newstring) |
|
1206 | - $string = $newstring; |
|
1259 | + if ($newstring) { |
|
1260 | + $string = $newstring; |
|
1261 | + } |
|
1207 | 1262 | } |
1208 | 1263 | |
1209 | 1264 | $entityConvert = function($m) |
1210 | 1265 | { |
1211 | 1266 | $c = $m[1]; |
1212 | - if (strlen($c) === 1 && ord($c[0]) <= 0x7F) |
|
1213 | - return $c; |
|
1214 | - elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF) |
|
1215 | - return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";"; |
|
1216 | - elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF) |
|
1217 | - return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";"; |
|
1218 | - elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7) |
|
1219 | - return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";"; |
|
1220 | - else |
|
1221 | - return ""; |
|
1267 | + if (strlen($c) === 1 && ord($c[0]) <= 0x7F) { |
|
1268 | + return $c; |
|
1269 | + } elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF) { |
|
1270 | + return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";"; |
|
1271 | + } elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF) { |
|
1272 | + return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";"; |
|
1273 | + } elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7) { |
|
1274 | + return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";"; |
|
1275 | + } else { |
|
1276 | + return ""; |
|
1277 | + } |
|
1222 | 1278 | }; |
1223 | 1279 | |
1224 | 1280 | // Convert all 'special' characters to HTML entities. |
@@ -1232,19 +1288,20 @@ discard block |
||
1232 | 1288 | $string = base64_encode($string); |
1233 | 1289 | |
1234 | 1290 | // Show the characterset and the transfer-encoding for header strings. |
1235 | - if ($with_charset) |
|
1236 | - $string = '=?' . $charset . '?B?' . $string . '?='; |
|
1291 | + if ($with_charset) { |
|
1292 | + $string = '=?' . $charset . '?B?' . $string . '?='; |
|
1293 | + } |
|
1237 | 1294 | |
1238 | 1295 | // Break it up in lines (mail body). |
1239 | - else |
|
1240 | - $string = chunk_split($string, 76, $line_break); |
|
1296 | + else { |
|
1297 | + $string = chunk_split($string, 76, $line_break); |
|
1298 | + } |
|
1241 | 1299 | |
1242 | 1300 | return array($charset, $string, 'base64'); |
1301 | + } else { |
|
1302 | + return array($charset, $string, '7bit'); |
|
1303 | + } |
|
1243 | 1304 | } |
1244 | - |
|
1245 | - else |
|
1246 | - return array($charset, $string, '7bit'); |
|
1247 | -} |
|
1248 | 1305 | |
1249 | 1306 | /** |
1250 | 1307 | * Sends mail, like mail() but over SMTP. |
@@ -1270,8 +1327,9 @@ discard block |
||
1270 | 1327 | if ($modSettings['mail_type'] == 3 && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '') |
1271 | 1328 | { |
1272 | 1329 | $socket = fsockopen($modSettings['smtp_host'], 110, $errno, $errstr, 2); |
1273 | - if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.')) |
|
1274 | - $socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2); |
|
1330 | + if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.')) { |
|
1331 | + $socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2); |
|
1332 | + } |
|
1275 | 1333 | |
1276 | 1334 | if ($socket) |
1277 | 1335 | { |
@@ -1293,11 +1351,13 @@ discard block |
||
1293 | 1351 | if (substr($modSettings['smtp_host'], 0, 4) == 'ssl:' && (empty($modSettings['smtp_port']) || $modSettings['smtp_port'] == 25)) |
1294 | 1352 | { |
1295 | 1353 | // ssl:hostname can cause fsocketopen to fail with a lookup failure, ensure it exists for this test. |
1296 | - if (substr($modSettings['smtp_host'], 0, 6) != 'ssl://') |
|
1297 | - $modSettings['smtp_host'] = str_replace('ssl:', 'ss://', $modSettings['smtp_host']); |
|
1354 | + if (substr($modSettings['smtp_host'], 0, 6) != 'ssl://') { |
|
1355 | + $modSettings['smtp_host'] = str_replace('ssl:', 'ss://', $modSettings['smtp_host']); |
|
1356 | + } |
|
1298 | 1357 | |
1299 | - if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3)) |
|
1300 | - log_error($txt['smtp_port_ssl']); |
|
1358 | + if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3)) { |
|
1359 | + log_error($txt['smtp_port_ssl']); |
|
1360 | + } |
|
1301 | 1361 | } |
1302 | 1362 | |
1303 | 1363 | // Unable to connect! Don't show any error message, but just log one and try to continue anyway. |
@@ -1309,26 +1369,30 @@ discard block |
||
1309 | 1369 | } |
1310 | 1370 | |
1311 | 1371 | // Wait for a response of 220, without "-" continuer. |
1312 | - if (!server_parse(null, $socket, '220')) |
|
1313 | - return false; |
|
1372 | + if (!server_parse(null, $socket, '220')) { |
|
1373 | + return false; |
|
1374 | + } |
|
1314 | 1375 | |
1315 | 1376 | // Try to determine the server's fully qualified domain name |
1316 | 1377 | // Can't rely on $_SERVER['SERVER_NAME'] because it can be spoofed on Apache |
1317 | 1378 | if (empty($helo)) |
1318 | 1379 | { |
1319 | 1380 | // See if we can get the domain name from the host itself |
1320 | - if (function_exists('gethostname')) |
|
1321 | - $helo = gethostname(); |
|
1322 | - elseif (function_exists('php_uname')) |
|
1323 | - $helo = php_uname('n'); |
|
1381 | + if (function_exists('gethostname')) { |
|
1382 | + $helo = gethostname(); |
|
1383 | + } elseif (function_exists('php_uname')) { |
|
1384 | + $helo = php_uname('n'); |
|
1385 | + } |
|
1324 | 1386 | |
1325 | 1387 | // If the hostname isn't a fully qualified domain name, we can use the host name from $boardurl instead |
1326 | - if (empty($helo) || strpos($helo, '.') === false || substr_compare($helo, '.local', -6) === 0 || (!empty($modSettings['tld_regex']) && !preg_match('/\.' . $modSettings['tld_regex'] . '$/u', $helo))) |
|
1327 | - $helo = parse_url($boardurl, PHP_URL_HOST); |
|
1388 | + if (empty($helo) || strpos($helo, '.') === false || substr_compare($helo, '.local', -6) === 0 || (!empty($modSettings['tld_regex']) && !preg_match('/\.' . $modSettings['tld_regex'] . '$/u', $helo))) { |
|
1389 | + $helo = parse_url($boardurl, PHP_URL_HOST); |
|
1390 | + } |
|
1328 | 1391 | |
1329 | 1392 | // This is one of those situations where 'www.' is undesirable |
1330 | - if (strpos($helo, 'www.') === 0) |
|
1331 | - $helo = substr($helo, 4); |
|
1393 | + if (strpos($helo, 'www.') === 0) { |
|
1394 | + $helo = substr($helo, 4); |
|
1395 | + } |
|
1332 | 1396 | } |
1333 | 1397 | |
1334 | 1398 | // SMTP = 1, SMTP - STARTTLS = 2 |
@@ -1341,8 +1405,9 @@ discard block |
||
1341 | 1405 | if ($modSettings['mail_type'] == 2 && preg_match("~250( |-)STARTTLS~mi", $response)) |
1342 | 1406 | { |
1343 | 1407 | // Send STARTTLS to enable encryption |
1344 | - if (!server_parse('STARTTLS', $socket, '220')) |
|
1345 | - return false; |
|
1408 | + if (!server_parse('STARTTLS', $socket, '220')) { |
|
1409 | + return false; |
|
1410 | + } |
|
1346 | 1411 | // Enable the encryption |
1347 | 1412 | // php 5.6+ fix |
1348 | 1413 | $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT; |
@@ -1353,30 +1418,35 @@ discard block |
||
1353 | 1418 | $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT; |
1354 | 1419 | } |
1355 | 1420 | |
1356 | - if (!@stream_socket_enable_crypto($socket, true, $crypto_method)) |
|
1357 | - return false; |
|
1421 | + if (!@stream_socket_enable_crypto($socket, true, $crypto_method)) { |
|
1422 | + return false; |
|
1423 | + } |
|
1358 | 1424 | // Send the EHLO command again |
1359 | - if (!server_parse('EHLO ' . $helo, $socket, null) == '250') |
|
1360 | - return false; |
|
1425 | + if (!server_parse('EHLO ' . $helo, $socket, null) == '250') { |
|
1426 | + return false; |
|
1427 | + } |
|
1361 | 1428 | } |
1362 | 1429 | |
1363 | - if (!server_parse('AUTH LOGIN', $socket, '334')) |
|
1364 | - return false; |
|
1430 | + if (!server_parse('AUTH LOGIN', $socket, '334')) { |
|
1431 | + return false; |
|
1432 | + } |
|
1365 | 1433 | // Send the username and password, encoded. |
1366 | - if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334')) |
|
1367 | - return false; |
|
1434 | + if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334')) { |
|
1435 | + return false; |
|
1436 | + } |
|
1368 | 1437 | // The password is already encoded ;) |
1369 | - if (!server_parse($modSettings['smtp_password'], $socket, '235')) |
|
1370 | - return false; |
|
1438 | + if (!server_parse($modSettings['smtp_password'], $socket, '235')) { |
|
1439 | + return false; |
|
1440 | + } |
|
1441 | + } elseif (!server_parse('HELO ' . $helo, $socket, '250')) { |
|
1442 | + return false; |
|
1371 | 1443 | } |
1372 | - elseif (!server_parse('HELO ' . $helo, $socket, '250')) |
|
1373 | - return false; |
|
1374 | - } |
|
1375 | - else |
|
1444 | + } else |
|
1376 | 1445 | { |
1377 | 1446 | // Just say "helo". |
1378 | - if (!server_parse('HELO ' . $helo, $socket, '250')) |
|
1379 | - return false; |
|
1447 | + if (!server_parse('HELO ' . $helo, $socket, '250')) { |
|
1448 | + return false; |
|
1449 | + } |
|
1380 | 1450 | } |
1381 | 1451 | |
1382 | 1452 | // Fix the message for any lines beginning with a period! (the first is ignored, you see.) |
@@ -1389,31 +1459,38 @@ discard block |
||
1389 | 1459 | // Reset the connection to send another email. |
1390 | 1460 | if ($i != 0) |
1391 | 1461 | { |
1392 | - if (!server_parse('RSET', $socket, '250')) |
|
1393 | - return false; |
|
1462 | + if (!server_parse('RSET', $socket, '250')) { |
|
1463 | + return false; |
|
1464 | + } |
|
1394 | 1465 | } |
1395 | 1466 | |
1396 | 1467 | // From, to, and then start the data... |
1397 | - if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250')) |
|
1398 | - return false; |
|
1399 | - if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250')) |
|
1400 | - return false; |
|
1401 | - if (!server_parse('DATA', $socket, '354')) |
|
1402 | - return false; |
|
1468 | + if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250')) { |
|
1469 | + return false; |
|
1470 | + } |
|
1471 | + if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250')) { |
|
1472 | + return false; |
|
1473 | + } |
|
1474 | + if (!server_parse('DATA', $socket, '354')) { |
|
1475 | + return false; |
|
1476 | + } |
|
1403 | 1477 | fputs($socket, 'Subject: ' . $subject . "\r\n"); |
1404 | - if (strlen($mail_to) > 0) |
|
1405 | - fputs($socket, 'To: <' . $mail_to . '>' . "\r\n"); |
|
1478 | + if (strlen($mail_to) > 0) { |
|
1479 | + fputs($socket, 'To: <' . $mail_to . '>' . "\r\n"); |
|
1480 | + } |
|
1406 | 1481 | fputs($socket, $headers . "\r\n\r\n"); |
1407 | 1482 | fputs($socket, $message . "\r\n"); |
1408 | 1483 | |
1409 | 1484 | // Send a ., or in other words "end of data". |
1410 | - if (!server_parse('.', $socket, '250')) |
|
1411 | - return false; |
|
1485 | + if (!server_parse('.', $socket, '250')) { |
|
1486 | + return false; |
|
1487 | + } |
|
1412 | 1488 | |
1413 | 1489 | // Almost done, almost done... don't stop me just yet! |
1414 | 1490 | @set_time_limit(300); |
1415 | - if (function_exists('apache_reset_timeout')) |
|
1416 | - @apache_reset_timeout(); |
|
1491 | + if (function_exists('apache_reset_timeout')) { |
|
1492 | + @apache_reset_timeout(); |
|
1493 | + } |
|
1417 | 1494 | } |
1418 | 1495 | fputs($socket, 'QUIT' . "\r\n"); |
1419 | 1496 | fclose($socket); |
@@ -1437,8 +1514,9 @@ discard block |
||
1437 | 1514 | { |
1438 | 1515 | global $txt; |
1439 | 1516 | |
1440 | - if ($message !== null) |
|
1441 | - fputs($socket, $message . "\r\n"); |
|
1517 | + if ($message !== null) { |
|
1518 | + fputs($socket, $message . "\r\n"); |
|
1519 | + } |
|
1442 | 1520 | |
1443 | 1521 | // No response yet. |
1444 | 1522 | $server_response = ''; |
@@ -1454,8 +1532,9 @@ discard block |
||
1454 | 1532 | $response .= $server_response; |
1455 | 1533 | } |
1456 | 1534 | |
1457 | - if ($code === null) |
|
1458 | - return substr($server_response, 0, 3); |
|
1535 | + if ($code === null) { |
|
1536 | + return substr($server_response, 0, 3); |
|
1537 | + } |
|
1459 | 1538 | |
1460 | 1539 | if (substr($server_response, 0, 3) != $code) |
1461 | 1540 | { |
@@ -1485,8 +1564,9 @@ discard block |
||
1485 | 1564 | // Create a pspell or enchant dictionary resource |
1486 | 1565 | $dict = spell_init(); |
1487 | 1566 | |
1488 | - if (!isset($_POST['spellstring']) || !$dict) |
|
1489 | - die; |
|
1567 | + if (!isset($_POST['spellstring']) || !$dict) { |
|
1568 | + die; |
|
1569 | + } |
|
1490 | 1570 | |
1491 | 1571 | // Construct a bit of Javascript code. |
1492 | 1572 | $context['spell_js'] = ' |
@@ -1504,8 +1584,9 @@ discard block |
||
1504 | 1584 | $check_word = explode('|', $alphas[$i]); |
1505 | 1585 | |
1506 | 1586 | // If the word is a known word, or spelled right... |
1507 | - if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2])) |
|
1508 | - continue; |
|
1587 | + if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2])) { |
|
1588 | + continue; |
|
1589 | + } |
|
1509 | 1590 | |
1510 | 1591 | // Find the word, and move up the "last occurrence" to here. |
1511 | 1592 | $found_words = true; |
@@ -1519,20 +1600,23 @@ discard block |
||
1519 | 1600 | if (!empty($suggestions)) |
1520 | 1601 | { |
1521 | 1602 | // But first check they aren't going to be censored - no naughty words! |
1522 | - foreach ($suggestions as $k => $word) |
|
1523 | - if ($suggestions[$k] != censorText($word)) |
|
1603 | + foreach ($suggestions as $k => $word) { |
|
1604 | + if ($suggestions[$k] != censorText($word)) |
|
1524 | 1605 | unset($suggestions[$k]); |
1606 | + } |
|
1525 | 1607 | |
1526 | - if (!empty($suggestions)) |
|
1527 | - $context['spell_js'] .= '"' . implode('", "', $suggestions) . '"'; |
|
1608 | + if (!empty($suggestions)) { |
|
1609 | + $context['spell_js'] .= '"' . implode('", "', $suggestions) . '"'; |
|
1610 | + } |
|
1528 | 1611 | } |
1529 | 1612 | |
1530 | 1613 | $context['spell_js'] .= ']),'; |
1531 | 1614 | } |
1532 | 1615 | |
1533 | 1616 | // If words were found, take off the last comma. |
1534 | - if ($found_words) |
|
1535 | - $context['spell_js'] = substr($context['spell_js'], 0, -1); |
|
1617 | + if ($found_words) { |
|
1618 | + $context['spell_js'] = substr($context['spell_js'], 0, -1); |
|
1619 | + } |
|
1536 | 1620 | |
1537 | 1621 | $context['spell_js'] .= ' |
1538 | 1622 | );'; |
@@ -1567,11 +1651,13 @@ discard block |
||
1567 | 1651 | global $user_info, $smcFunc; |
1568 | 1652 | |
1569 | 1653 | // Can't do it if there's no topics. |
1570 | - if (empty($topics)) |
|
1571 | - return; |
|
1654 | + if (empty($topics)) { |
|
1655 | + return; |
|
1656 | + } |
|
1572 | 1657 | // It must be an array - it must! |
1573 | - if (!is_array($topics)) |
|
1574 | - $topics = array($topics); |
|
1658 | + if (!is_array($topics)) { |
|
1659 | + $topics = array($topics); |
|
1660 | + } |
|
1575 | 1661 | |
1576 | 1662 | // Get the subject and body... |
1577 | 1663 | $result = $smcFunc['db_query']('', ' |
@@ -1619,14 +1705,15 @@ discard block |
||
1619 | 1705 | } |
1620 | 1706 | $smcFunc['db_free_result']($result); |
1621 | 1707 | |
1622 | - if (!empty($task_rows)) |
|
1623 | - $smcFunc['db_insert']('', |
|
1708 | + if (!empty($task_rows)) { |
|
1709 | + $smcFunc['db_insert']('', |
|
1624 | 1710 | '{db_prefix}background_tasks', |
1625 | 1711 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
1626 | 1712 | $task_rows, |
1627 | 1713 | array('id_task') |
1628 | 1714 | ); |
1629 | -} |
|
1715 | + } |
|
1716 | + } |
|
1630 | 1717 | |
1631 | 1718 | /** |
1632 | 1719 | * Create a post, either as new topic (id_topic = 0) or in an existing one. |
@@ -1664,9 +1751,9 @@ discard block |
||
1664 | 1751 | $msgOptions['send_notifications'] = isset($msgOptions['send_notifications']) ? (bool) $msgOptions['send_notifications'] : true; |
1665 | 1752 | |
1666 | 1753 | // We need to know if the topic is approved. If we're told that's great - if not find out. |
1667 | - if (!$modSettings['postmod_active']) |
|
1668 | - $topicOptions['is_approved'] = true; |
|
1669 | - elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved'])) |
|
1754 | + if (!$modSettings['postmod_active']) { |
|
1755 | + $topicOptions['is_approved'] = true; |
|
1756 | + } elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved'])) |
|
1670 | 1757 | { |
1671 | 1758 | $request = $smcFunc['db_query']('', ' |
1672 | 1759 | SELECT approved |
@@ -1689,8 +1776,7 @@ discard block |
||
1689 | 1776 | $posterOptions['id'] = 0; |
1690 | 1777 | $posterOptions['name'] = $txt['guest_title']; |
1691 | 1778 | $posterOptions['email'] = ''; |
1692 | - } |
|
1693 | - elseif ($posterOptions['id'] != $user_info['id']) |
|
1779 | + } elseif ($posterOptions['id'] != $user_info['id']) |
|
1694 | 1780 | { |
1695 | 1781 | $request = $smcFunc['db_query']('', ' |
1696 | 1782 | SELECT member_name, email_address |
@@ -1708,12 +1794,11 @@ discard block |
||
1708 | 1794 | $posterOptions['id'] = 0; |
1709 | 1795 | $posterOptions['name'] = $txt['guest_title']; |
1710 | 1796 | $posterOptions['email'] = ''; |
1797 | + } else { |
|
1798 | + list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request); |
|
1711 | 1799 | } |
1712 | - else |
|
1713 | - list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request); |
|
1714 | 1800 | $smcFunc['db_free_result']($request); |
1715 | - } |
|
1716 | - else |
|
1801 | + } else |
|
1717 | 1802 | { |
1718 | 1803 | $posterOptions['name'] = $user_info['name']; |
1719 | 1804 | $posterOptions['email'] = $user_info['email']; |
@@ -1723,8 +1808,9 @@ discard block |
||
1723 | 1808 | if (!empty($modSettings['enable_mentions'])) |
1724 | 1809 | { |
1725 | 1810 | $msgOptions['mentioned_members'] = Mentions::getMentionedMembers($msgOptions['body']); |
1726 | - if (!empty($msgOptions['mentioned_members'])) |
|
1727 | - $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']); |
|
1811 | + if (!empty($msgOptions['mentioned_members'])) { |
|
1812 | + $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']); |
|
1813 | + } |
|
1728 | 1814 | } |
1729 | 1815 | |
1730 | 1816 | // It's do or die time: forget any user aborts! |
@@ -1757,12 +1843,13 @@ discard block |
||
1757 | 1843 | ); |
1758 | 1844 | |
1759 | 1845 | // Something went wrong creating the message... |
1760 | - if (empty($msgOptions['id'])) |
|
1761 | - return false; |
|
1846 | + if (empty($msgOptions['id'])) { |
|
1847 | + return false; |
|
1848 | + } |
|
1762 | 1849 | |
1763 | 1850 | // Fix the attachments. |
1764 | - if (!empty($msgOptions['attachments'])) |
|
1765 | - $smcFunc['db_query']('', ' |
|
1851 | + if (!empty($msgOptions['attachments'])) { |
|
1852 | + $smcFunc['db_query']('', ' |
|
1766 | 1853 | UPDATE {db_prefix}attachments |
1767 | 1854 | SET id_msg = {int:id_msg} |
1768 | 1855 | WHERE id_attach IN ({array_int:attachment_list})', |
@@ -1771,6 +1858,7 @@ discard block |
||
1771 | 1858 | 'id_msg' => $msgOptions['id'], |
1772 | 1859 | ) |
1773 | 1860 | ); |
1861 | + } |
|
1774 | 1862 | |
1775 | 1863 | // What if we want to export new posts out to a CMS? |
1776 | 1864 | call_integration_hook('integrate_after_create_post', array($msgOptions, $topicOptions, $posterOptions, $message_columns, $message_parameters)); |
@@ -1847,20 +1935,23 @@ discard block |
||
1847 | 1935 | 'id_topic' => $topicOptions['id'], |
1848 | 1936 | 'counter_increment' => 1, |
1849 | 1937 | ); |
1850 | - if ($msgOptions['approved']) |
|
1851 | - $topics_columns = array( |
|
1938 | + if ($msgOptions['approved']) { |
|
1939 | + $topics_columns = array( |
|
1852 | 1940 | 'id_member_updated = {int:poster_id}', |
1853 | 1941 | 'id_last_msg = {int:id_msg}', |
1854 | 1942 | 'num_replies = num_replies + {int:counter_increment}', |
1855 | 1943 | ); |
1856 | - else |
|
1857 | - $topics_columns = array( |
|
1944 | + } else { |
|
1945 | + $topics_columns = array( |
|
1858 | 1946 | 'unapproved_posts = unapproved_posts + {int:counter_increment}', |
1859 | 1947 | ); |
1860 | - if ($topicOptions['lock_mode'] !== null) |
|
1861 | - $topics_columns[] = 'locked = {int:locked}'; |
|
1862 | - if ($topicOptions['sticky_mode'] !== null) |
|
1863 | - $topics_columns[] = 'is_sticky = {int:is_sticky}'; |
|
1948 | + } |
|
1949 | + if ($topicOptions['lock_mode'] !== null) { |
|
1950 | + $topics_columns[] = 'locked = {int:locked}'; |
|
1951 | + } |
|
1952 | + if ($topicOptions['sticky_mode'] !== null) { |
|
1953 | + $topics_columns[] = 'is_sticky = {int:is_sticky}'; |
|
1954 | + } |
|
1864 | 1955 | |
1865 | 1956 | call_integration_hook('integrate_modify_topic', array(&$topics_columns, &$update_parameters, &$msgOptions, &$topicOptions, &$posterOptions)); |
1866 | 1957 | |
@@ -1889,8 +1980,8 @@ discard block |
||
1889 | 1980 | ); |
1890 | 1981 | |
1891 | 1982 | // Increase the number of posts and topics on the board. |
1892 | - if ($msgOptions['approved']) |
|
1893 | - $smcFunc['db_query']('', ' |
|
1983 | + if ($msgOptions['approved']) { |
|
1984 | + $smcFunc['db_query']('', ' |
|
1894 | 1985 | UPDATE {db_prefix}boards |
1895 | 1986 | SET num_posts = num_posts + 1' . ($new_topic ? ', num_topics = num_topics + 1' : '') . ' |
1896 | 1987 | WHERE id_board = {int:id_board}', |
@@ -1898,7 +1989,7 @@ discard block |
||
1898 | 1989 | 'id_board' => $topicOptions['board'], |
1899 | 1990 | ) |
1900 | 1991 | ); |
1901 | - else |
|
1992 | + } else |
|
1902 | 1993 | { |
1903 | 1994 | $smcFunc['db_query']('', ' |
1904 | 1995 | UPDATE {db_prefix}boards |
@@ -1968,8 +2059,8 @@ discard block |
||
1968 | 2059 | } |
1969 | 2060 | } |
1970 | 2061 | |
1971 | - if ($msgOptions['approved'] && empty($topicOptions['is_approved'])) |
|
1972 | - $smcFunc['db_insert']('', |
|
2062 | + if ($msgOptions['approved'] && empty($topicOptions['is_approved'])) { |
|
2063 | + $smcFunc['db_insert']('', |
|
1973 | 2064 | '{db_prefix}background_tasks', |
1974 | 2065 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
1975 | 2066 | array( |
@@ -1981,19 +2072,22 @@ discard block |
||
1981 | 2072 | ), |
1982 | 2073 | array('id_task') |
1983 | 2074 | ); |
2075 | + } |
|
1984 | 2076 | |
1985 | 2077 | // If there's a custom search index, it may need updating... |
1986 | 2078 | require_once($sourcedir . '/Search.php'); |
1987 | 2079 | $searchAPI = findSearchAPI(); |
1988 | - if (is_callable(array($searchAPI, 'postCreated'))) |
|
1989 | - $searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions); |
|
2080 | + if (is_callable(array($searchAPI, 'postCreated'))) { |
|
2081 | + $searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions); |
|
2082 | + } |
|
1990 | 2083 | |
1991 | 2084 | // Increase the post counter for the user that created the post. |
1992 | 2085 | if (!empty($posterOptions['update_post_count']) && !empty($posterOptions['id']) && $msgOptions['approved']) |
1993 | 2086 | { |
1994 | 2087 | // Are you the one that happened to create this post? |
1995 | - if ($user_info['id'] == $posterOptions['id']) |
|
1996 | - $user_info['posts']++; |
|
2088 | + if ($user_info['id'] == $posterOptions['id']) { |
|
2089 | + $user_info['posts']++; |
|
2090 | + } |
|
1997 | 2091 | updateMemberData($posterOptions['id'], array('posts' => '+')); |
1998 | 2092 | } |
1999 | 2093 | |
@@ -2001,19 +2095,21 @@ discard block |
||
2001 | 2095 | $_SESSION['last_read_topic'] = 0; |
2002 | 2096 | |
2003 | 2097 | // Better safe than sorry. |
2004 | - if (isset($_SESSION['topicseen_cache'][$topicOptions['board']])) |
|
2005 | - $_SESSION['topicseen_cache'][$topicOptions['board']]--; |
|
2098 | + if (isset($_SESSION['topicseen_cache'][$topicOptions['board']])) { |
|
2099 | + $_SESSION['topicseen_cache'][$topicOptions['board']]--; |
|
2100 | + } |
|
2006 | 2101 | |
2007 | 2102 | // Update all the stats so everyone knows about this new topic and message. |
2008 | 2103 | updateStats('message', true, $msgOptions['id']); |
2009 | 2104 | |
2010 | 2105 | // Update the last message on the board assuming it's approved AND the topic is. |
2011 | - if ($msgOptions['approved']) |
|
2012 | - updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0); |
|
2106 | + if ($msgOptions['approved']) { |
|
2107 | + updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0); |
|
2108 | + } |
|
2013 | 2109 | |
2014 | 2110 | // Queue createPost background notification |
2015 | - if ($msgOptions['send_notifications'] && $msgOptions['approved']) |
|
2016 | - $smcFunc['db_insert']('', |
|
2111 | + if ($msgOptions['send_notifications'] && $msgOptions['approved']) { |
|
2112 | + $smcFunc['db_insert']('', |
|
2017 | 2113 | '{db_prefix}background_tasks', |
2018 | 2114 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
2019 | 2115 | array('$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', $smcFunc['json_encode'](array( |
@@ -2024,6 +2120,7 @@ discard block |
||
2024 | 2120 | )), 0), |
2025 | 2121 | array('id_task') |
2026 | 2122 | ); |
2123 | + } |
|
2027 | 2124 | |
2028 | 2125 | // Alright, done now... we can abort now, I guess... at least this much is done. |
2029 | 2126 | ignore_user_abort($previous_ignore_user_abort); |
@@ -2050,14 +2147,18 @@ discard block |
||
2050 | 2147 | |
2051 | 2148 | // This is longer than it has to be, but makes it so we only set/change what we have to. |
2052 | 2149 | $messages_columns = array(); |
2053 | - if (isset($posterOptions['name'])) |
|
2054 | - $messages_columns['poster_name'] = $posterOptions['name']; |
|
2055 | - if (isset($posterOptions['email'])) |
|
2056 | - $messages_columns['poster_email'] = $posterOptions['email']; |
|
2057 | - if (isset($msgOptions['icon'])) |
|
2058 | - $messages_columns['icon'] = $msgOptions['icon']; |
|
2059 | - if (isset($msgOptions['subject'])) |
|
2060 | - $messages_columns['subject'] = $msgOptions['subject']; |
|
2150 | + if (isset($posterOptions['name'])) { |
|
2151 | + $messages_columns['poster_name'] = $posterOptions['name']; |
|
2152 | + } |
|
2153 | + if (isset($posterOptions['email'])) { |
|
2154 | + $messages_columns['poster_email'] = $posterOptions['email']; |
|
2155 | + } |
|
2156 | + if (isset($msgOptions['icon'])) { |
|
2157 | + $messages_columns['icon'] = $msgOptions['icon']; |
|
2158 | + } |
|
2159 | + if (isset($msgOptions['subject'])) { |
|
2160 | + $messages_columns['subject'] = $msgOptions['subject']; |
|
2161 | + } |
|
2061 | 2162 | if (isset($msgOptions['body'])) |
2062 | 2163 | { |
2063 | 2164 | $messages_columns['body'] = $msgOptions['body']; |
@@ -2084,8 +2185,9 @@ discard block |
||
2084 | 2185 | $messages_columns['modified_reason'] = $msgOptions['modify_reason']; |
2085 | 2186 | $messages_columns['id_msg_modified'] = $modSettings['maxMsgID']; |
2086 | 2187 | } |
2087 | - if (isset($msgOptions['smileys_enabled'])) |
|
2088 | - $messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1; |
|
2188 | + if (isset($msgOptions['smileys_enabled'])) { |
|
2189 | + $messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1; |
|
2190 | + } |
|
2089 | 2191 | |
2090 | 2192 | // Which columns need to be ints? |
2091 | 2193 | $messageInts = array('modified_time', 'id_msg_modified', 'smileys_enabled'); |
@@ -2096,8 +2198,9 @@ discard block |
||
2096 | 2198 | // Update search api |
2097 | 2199 | require_once($sourcedir . '/Search.php'); |
2098 | 2200 | $searchAPI = findSearchAPI(); |
2099 | - if ($searchAPI->supportsMethod('postRemoved')) |
|
2100 | - $searchAPI->postRemoved($msgOptions['id']); |
|
2201 | + if ($searchAPI->supportsMethod('postRemoved')) { |
|
2202 | + $searchAPI->postRemoved($msgOptions['id']); |
|
2203 | + } |
|
2101 | 2204 | |
2102 | 2205 | if (!empty($modSettings['enable_mentions']) && isset($msgOptions['body'])) |
2103 | 2206 | { |
@@ -2109,23 +2212,27 @@ discard block |
||
2109 | 2212 | { |
2110 | 2213 | preg_match_all('/\[member\=([0-9]+)\]([^\[]*)\[\/member\]/U', $msgOptions['old_body'], $match); |
2111 | 2214 | |
2112 | - if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2])) |
|
2113 | - foreach ($match[1] as $i => $oldID) |
|
2215 | + if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2])) { |
|
2216 | + foreach ($match[1] as $i => $oldID) |
|
2114 | 2217 | $oldmentions[$oldID] = array('id' => $oldID, 'real_name' => $match[2][$i]); |
2218 | + } |
|
2115 | 2219 | |
2116 | - if (empty($modSettings['search_custom_index_config'])) |
|
2117 | - unset($msgOptions['old_body']); |
|
2220 | + if (empty($modSettings['search_custom_index_config'])) { |
|
2221 | + unset($msgOptions['old_body']); |
|
2222 | + } |
|
2118 | 2223 | } |
2119 | 2224 | |
2120 | 2225 | $mentions = Mentions::getMentionedMembers($msgOptions['body']); |
2121 | 2226 | $messages_columns['body'] = $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $mentions); |
2122 | 2227 | |
2123 | 2228 | // Remove the poster. |
2124 | - if (isset($mentions[$user_info['id']])) |
|
2125 | - unset($mentions[$user_info['id']]); |
|
2229 | + if (isset($mentions[$user_info['id']])) { |
|
2230 | + unset($mentions[$user_info['id']]); |
|
2231 | + } |
|
2126 | 2232 | |
2127 | - if (isset($oldmentions[$user_info['id']])) |
|
2128 | - unset($oldmentions[$user_info['id']]); |
|
2233 | + if (isset($oldmentions[$user_info['id']])) { |
|
2234 | + unset($oldmentions[$user_info['id']]); |
|
2235 | + } |
|
2129 | 2236 | |
2130 | 2237 | if (is_array($mentions) && is_array($oldmentions) && count(array_diff_key($mentions, $oldmentions)) > 0 && count($mentions) > count($oldmentions)) |
2131 | 2238 | { |
@@ -2155,8 +2262,9 @@ discard block |
||
2155 | 2262 | } |
2156 | 2263 | |
2157 | 2264 | // Nothing to do? |
2158 | - if (empty($messages_columns)) |
|
2159 | - return true; |
|
2265 | + if (empty($messages_columns)) { |
|
2266 | + return true; |
|
2267 | + } |
|
2160 | 2268 | |
2161 | 2269 | // Change the post. |
2162 | 2270 | $smcFunc['db_query']('', ' |
@@ -2217,8 +2325,9 @@ discard block |
||
2217 | 2325 | // If there's a custom search index, it needs to be modified... |
2218 | 2326 | require_once($sourcedir . '/Search.php'); |
2219 | 2327 | $searchAPI = findSearchAPI(); |
2220 | - if (is_callable(array($searchAPI, 'postModified'))) |
|
2221 | - $searchAPI->postModified($msgOptions, $topicOptions, $posterOptions); |
|
2328 | + if (is_callable(array($searchAPI, 'postModified'))) { |
|
2329 | + $searchAPI->postModified($msgOptions, $topicOptions, $posterOptions); |
|
2330 | + } |
|
2222 | 2331 | |
2223 | 2332 | if (isset($msgOptions['subject'])) |
2224 | 2333 | { |
@@ -2232,14 +2341,16 @@ discard block |
||
2232 | 2341 | 'id_first_msg' => $msgOptions['id'], |
2233 | 2342 | ) |
2234 | 2343 | ); |
2235 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
2236 | - updateStats('subject', $topicOptions['id'], $msgOptions['subject']); |
|
2344 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
2345 | + updateStats('subject', $topicOptions['id'], $msgOptions['subject']); |
|
2346 | + } |
|
2237 | 2347 | $smcFunc['db_free_result']($request); |
2238 | 2348 | } |
2239 | 2349 | |
2240 | 2350 | // Finally, if we are setting the approved state we need to do much more work :( |
2241 | - if ($modSettings['postmod_active'] && isset($msgOptions['approved'])) |
|
2242 | - approvePosts($msgOptions['id'], $msgOptions['approved']); |
|
2351 | + if ($modSettings['postmod_active'] && isset($msgOptions['approved'])) { |
|
2352 | + approvePosts($msgOptions['id'], $msgOptions['approved']); |
|
2353 | + } |
|
2243 | 2354 | |
2244 | 2355 | return true; |
2245 | 2356 | } |
@@ -2256,11 +2367,13 @@ discard block |
||
2256 | 2367 | { |
2257 | 2368 | global $smcFunc; |
2258 | 2369 | |
2259 | - if (!is_array($msgs)) |
|
2260 | - $msgs = array($msgs); |
|
2370 | + if (!is_array($msgs)) { |
|
2371 | + $msgs = array($msgs); |
|
2372 | + } |
|
2261 | 2373 | |
2262 | - if (empty($msgs)) |
|
2263 | - return false; |
|
2374 | + if (empty($msgs)) { |
|
2375 | + return false; |
|
2376 | + } |
|
2264 | 2377 | |
2265 | 2378 | // May as well start at the beginning, working out *what* we need to change. |
2266 | 2379 | $request = $smcFunc['db_query']('', ' |
@@ -2292,20 +2405,22 @@ discard block |
||
2292 | 2405 | $topics[] = $row['id_topic']; |
2293 | 2406 | |
2294 | 2407 | // Ensure our change array exists already. |
2295 | - if (!isset($topic_changes[$row['id_topic']])) |
|
2296 | - $topic_changes[$row['id_topic']] = array( |
|
2408 | + if (!isset($topic_changes[$row['id_topic']])) { |
|
2409 | + $topic_changes[$row['id_topic']] = array( |
|
2297 | 2410 | 'id_last_msg' => $row['id_last_msg'], |
2298 | 2411 | 'approved' => $row['topic_approved'], |
2299 | 2412 | 'replies' => 0, |
2300 | 2413 | 'unapproved_posts' => 0, |
2301 | 2414 | ); |
2302 | - if (!isset($board_changes[$row['id_board']])) |
|
2303 | - $board_changes[$row['id_board']] = array( |
|
2415 | + } |
|
2416 | + if (!isset($board_changes[$row['id_board']])) { |
|
2417 | + $board_changes[$row['id_board']] = array( |
|
2304 | 2418 | 'posts' => 0, |
2305 | 2419 | 'topics' => 0, |
2306 | 2420 | 'unapproved_posts' => 0, |
2307 | 2421 | 'unapproved_topics' => 0, |
2308 | 2422 | ); |
2423 | + } |
|
2309 | 2424 | |
2310 | 2425 | // If it's the first message then the topic state changes! |
2311 | 2426 | if ($row['id_msg'] == $row['id_first_msg']) |
@@ -2326,14 +2441,13 @@ discard block |
||
2326 | 2441 | 'poster' => $row['id_member'], |
2327 | 2442 | 'new_topic' => true, |
2328 | 2443 | ); |
2329 | - } |
|
2330 | - else |
|
2444 | + } else |
|
2331 | 2445 | { |
2332 | 2446 | $topic_changes[$row['id_topic']]['replies'] += $approve ? 1 : -1; |
2333 | 2447 | |
2334 | 2448 | // This will be a post... but don't notify unless it's not followed by approved ones. |
2335 | - if ($row['id_msg'] > $row['id_last_msg']) |
|
2336 | - $notification_posts[$row['id_topic']] = array( |
|
2449 | + if ($row['id_msg'] > $row['id_last_msg']) { |
|
2450 | + $notification_posts[$row['id_topic']] = array( |
|
2337 | 2451 | 'id' => $row['id_msg'], |
2338 | 2452 | 'body' => $row['body'], |
2339 | 2453 | 'subject' => $row['subject'], |
@@ -2344,28 +2458,33 @@ discard block |
||
2344 | 2458 | 'new_topic' => false, |
2345 | 2459 | 'msg' => $row['id_msg'], |
2346 | 2460 | ); |
2461 | + } |
|
2347 | 2462 | } |
2348 | 2463 | |
2349 | 2464 | // If this is being approved and id_msg is higher than the current id_last_msg then it changes. |
2350 | - if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg']) |
|
2351 | - $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg']; |
|
2465 | + if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg']) { |
|
2466 | + $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg']; |
|
2467 | + } |
|
2352 | 2468 | // If this is being unapproved, and it's equal to the id_last_msg we need to find a new one! |
2353 | - elseif (!$approve) |
|
2354 | - // Default to the first message and then we'll override in a bit ;) |
|
2469 | + elseif (!$approve) { |
|
2470 | + // Default to the first message and then we'll override in a bit ;) |
|
2355 | 2471 | $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_first_msg']; |
2472 | + } |
|
2356 | 2473 | |
2357 | 2474 | $topic_changes[$row['id_topic']]['unapproved_posts'] += $approve ? -1 : 1; |
2358 | 2475 | $board_changes[$row['id_board']]['unapproved_posts'] += $approve ? -1 : 1; |
2359 | 2476 | $board_changes[$row['id_board']]['posts'] += $approve ? 1 : -1; |
2360 | 2477 | |
2361 | 2478 | // Post count for the user? |
2362 | - if ($row['id_member'] && empty($row['count_posts'])) |
|
2363 | - $member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1; |
|
2479 | + if ($row['id_member'] && empty($row['count_posts'])) { |
|
2480 | + $member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1; |
|
2481 | + } |
|
2364 | 2482 | } |
2365 | 2483 | $smcFunc['db_free_result']($request); |
2366 | 2484 | |
2367 | - if (empty($msgs)) |
|
2368 | - return; |
|
2485 | + if (empty($msgs)) { |
|
2486 | + return; |
|
2487 | + } |
|
2369 | 2488 | |
2370 | 2489 | // Now we have the differences make the changes, first the easy one. |
2371 | 2490 | $smcFunc['db_query']('', ' |
@@ -2392,14 +2511,15 @@ discard block |
||
2392 | 2511 | 'approved' => 1, |
2393 | 2512 | ) |
2394 | 2513 | ); |
2395 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2396 | - $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg']; |
|
2514 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2515 | + $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg']; |
|
2516 | + } |
|
2397 | 2517 | $smcFunc['db_free_result']($request); |
2398 | 2518 | } |
2399 | 2519 | |
2400 | 2520 | // ... next the topics... |
2401 | - foreach ($topic_changes as $id => $changes) |
|
2402 | - $smcFunc['db_query']('', ' |
|
2521 | + foreach ($topic_changes as $id => $changes) { |
|
2522 | + $smcFunc['db_query']('', ' |
|
2403 | 2523 | UPDATE {db_prefix}topics |
2404 | 2524 | SET approved = {int:approved}, unapproved_posts = unapproved_posts + {int:unapproved_posts}, |
2405 | 2525 | num_replies = num_replies + {int:num_replies}, id_last_msg = {int:id_last_msg} |
@@ -2412,10 +2532,11 @@ discard block |
||
2412 | 2532 | 'id_topic' => $id, |
2413 | 2533 | ) |
2414 | 2534 | ); |
2535 | + } |
|
2415 | 2536 | |
2416 | 2537 | // ... finally the boards... |
2417 | - foreach ($board_changes as $id => $changes) |
|
2418 | - $smcFunc['db_query']('', ' |
|
2538 | + foreach ($board_changes as $id => $changes) { |
|
2539 | + $smcFunc['db_query']('', ' |
|
2419 | 2540 | UPDATE {db_prefix}boards |
2420 | 2541 | SET num_posts = num_posts + {int:num_posts}, unapproved_posts = unapproved_posts + {int:unapproved_posts}, |
2421 | 2542 | num_topics = num_topics + {int:num_topics}, unapproved_topics = unapproved_topics + {int:unapproved_topics} |
@@ -2428,13 +2549,14 @@ discard block |
||
2428 | 2549 | 'id_board' => $id, |
2429 | 2550 | ) |
2430 | 2551 | ); |
2552 | + } |
|
2431 | 2553 | |
2432 | 2554 | // Finally, least importantly, notifications! |
2433 | 2555 | if ($approve) |
2434 | 2556 | { |
2435 | 2557 | $task_rows = array(); |
2436 | - foreach (array_merge($notification_topics, $notification_posts) as $topic) |
|
2437 | - $task_rows[] = array( |
|
2558 | + foreach (array_merge($notification_topics, $notification_posts) as $topic) { |
|
2559 | + $task_rows[] = array( |
|
2438 | 2560 | '$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', $smcFunc['json_encode'](array( |
2439 | 2561 | 'msgOptions' => array( |
2440 | 2562 | 'id' => $topic['msg'], |
@@ -2452,14 +2574,16 @@ discard block |
||
2452 | 2574 | 'type' => $topic['new_topic'] ? 'topic' : 'reply', |
2453 | 2575 | )), 0 |
2454 | 2576 | ); |
2577 | + } |
|
2455 | 2578 | |
2456 | - if ($notify) |
|
2457 | - $smcFunc['db_insert']('', |
|
2579 | + if ($notify) { |
|
2580 | + $smcFunc['db_insert']('', |
|
2458 | 2581 | '{db_prefix}background_tasks', |
2459 | 2582 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
2460 | 2583 | $task_rows, |
2461 | 2584 | array('id_task') |
2462 | 2585 | ); |
2586 | + } |
|
2463 | 2587 | |
2464 | 2588 | $smcFunc['db_query']('', ' |
2465 | 2589 | DELETE FROM {db_prefix}approval_queue |
@@ -2475,8 +2599,9 @@ discard block |
||
2475 | 2599 | else |
2476 | 2600 | { |
2477 | 2601 | $msgInserts = array(); |
2478 | - foreach ($msgs as $msg) |
|
2479 | - $msgInserts[] = array($msg); |
|
2602 | + foreach ($msgs as $msg) { |
|
2603 | + $msgInserts[] = array($msg); |
|
2604 | + } |
|
2480 | 2605 | |
2481 | 2606 | $smcFunc['db_insert']('ignore', |
2482 | 2607 | '{db_prefix}approval_queue', |
@@ -2490,9 +2615,10 @@ discard block |
||
2490 | 2615 | updateLastMessages(array_keys($board_changes)); |
2491 | 2616 | |
2492 | 2617 | // Post count for the members? |
2493 | - if (!empty($member_post_changes)) |
|
2494 | - foreach ($member_post_changes as $id_member => $count_change) |
|
2618 | + if (!empty($member_post_changes)) { |
|
2619 | + foreach ($member_post_changes as $id_member => $count_change) |
|
2495 | 2620 | updateMemberData($id_member, array('posts' => 'posts ' . ($approve ? '+' : '-') . ' ' . $count_change)); |
2621 | + } |
|
2496 | 2622 | |
2497 | 2623 | return true; |
2498 | 2624 | } |
@@ -2509,11 +2635,13 @@ discard block |
||
2509 | 2635 | { |
2510 | 2636 | global $smcFunc; |
2511 | 2637 | |
2512 | - if (!is_array($topics)) |
|
2513 | - $topics = array($topics); |
|
2638 | + if (!is_array($topics)) { |
|
2639 | + $topics = array($topics); |
|
2640 | + } |
|
2514 | 2641 | |
2515 | - if (empty($topics)) |
|
2516 | - return false; |
|
2642 | + if (empty($topics)) { |
|
2643 | + return false; |
|
2644 | + } |
|
2517 | 2645 | |
2518 | 2646 | $approve_type = $approve ? 0 : 1; |
2519 | 2647 | |
@@ -2529,8 +2657,9 @@ discard block |
||
2529 | 2657 | ) |
2530 | 2658 | ); |
2531 | 2659 | $msgs = array(); |
2532 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2533 | - $msgs[] = $row['id_msg']; |
|
2660 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2661 | + $msgs[] = $row['id_msg']; |
|
2662 | + } |
|
2534 | 2663 | $smcFunc['db_free_result']($request); |
2535 | 2664 | |
2536 | 2665 | return approvePosts($msgs, $approve); |
@@ -2553,11 +2682,13 @@ discard block |
||
2553 | 2682 | global $board_info, $board, $smcFunc; |
2554 | 2683 | |
2555 | 2684 | // Please - let's be sane. |
2556 | - if (empty($setboards)) |
|
2557 | - return false; |
|
2685 | + if (empty($setboards)) { |
|
2686 | + return false; |
|
2687 | + } |
|
2558 | 2688 | |
2559 | - if (!is_array($setboards)) |
|
2560 | - $setboards = array($setboards); |
|
2689 | + if (!is_array($setboards)) { |
|
2690 | + $setboards = array($setboards); |
|
2691 | + } |
|
2561 | 2692 | |
2562 | 2693 | // If we don't know the id_msg we need to find it. |
2563 | 2694 | if (!$id_msg) |
@@ -2575,15 +2706,16 @@ discard block |
||
2575 | 2706 | ) |
2576 | 2707 | ); |
2577 | 2708 | $lastMsg = array(); |
2578 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2579 | - $lastMsg[$row['id_board']] = $row['id_msg']; |
|
2709 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2710 | + $lastMsg[$row['id_board']] = $row['id_msg']; |
|
2711 | + } |
|
2580 | 2712 | $smcFunc['db_free_result']($request); |
2581 | - } |
|
2582 | - else |
|
2713 | + } else |
|
2583 | 2714 | { |
2584 | 2715 | // Just to note - there should only be one board passed if we are doing this. |
2585 | - foreach ($setboards as $id_board) |
|
2586 | - $lastMsg[$id_board] = $id_msg; |
|
2716 | + foreach ($setboards as $id_board) { |
|
2717 | + $lastMsg[$id_board] = $id_msg; |
|
2718 | + } |
|
2587 | 2719 | } |
2588 | 2720 | |
2589 | 2721 | $parent_boards = array(); |
@@ -2598,10 +2730,11 @@ discard block |
||
2598 | 2730 | $lastModified[$id_board] = 0; |
2599 | 2731 | } |
2600 | 2732 | |
2601 | - if (!empty($board) && $id_board == $board) |
|
2602 | - $parents = $board_info['parent_boards']; |
|
2603 | - else |
|
2604 | - $parents = getBoardParents($id_board); |
|
2733 | + if (!empty($board) && $id_board == $board) { |
|
2734 | + $parents = $board_info['parent_boards']; |
|
2735 | + } else { |
|
2736 | + $parents = getBoardParents($id_board); |
|
2737 | + } |
|
2605 | 2738 | |
2606 | 2739 | // Ignore any parents on the top child level. |
2607 | 2740 | // @todo Why? |
@@ -2610,10 +2743,11 @@ discard block |
||
2610 | 2743 | if ($parent['level'] != 0) |
2611 | 2744 | { |
2612 | 2745 | // If we're already doing this one as a board, is this a higher last modified? |
2613 | - if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id]) |
|
2614 | - $lastModified[$id] = $lastModified[$id_board]; |
|
2615 | - elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board])) |
|
2616 | - $parent_boards[$id] = $lastModified[$id_board]; |
|
2746 | + if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id]) { |
|
2747 | + $lastModified[$id] = $lastModified[$id_board]; |
|
2748 | + } elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board])) { |
|
2749 | + $parent_boards[$id] = $lastModified[$id_board]; |
|
2750 | + } |
|
2617 | 2751 | } |
2618 | 2752 | } |
2619 | 2753 | } |
@@ -2626,23 +2760,24 @@ discard block |
||
2626 | 2760 | // Finally, to save on queries make the changes... |
2627 | 2761 | foreach ($parent_boards as $id => $msg) |
2628 | 2762 | { |
2629 | - if (!isset($parent_updates[$msg])) |
|
2630 | - $parent_updates[$msg] = array($id); |
|
2631 | - else |
|
2632 | - $parent_updates[$msg][] = $id; |
|
2763 | + if (!isset($parent_updates[$msg])) { |
|
2764 | + $parent_updates[$msg] = array($id); |
|
2765 | + } else { |
|
2766 | + $parent_updates[$msg][] = $id; |
|
2767 | + } |
|
2633 | 2768 | } |
2634 | 2769 | |
2635 | 2770 | foreach ($lastMsg as $id => $msg) |
2636 | 2771 | { |
2637 | - if (!isset($board_updates[$msg . '-' . $lastModified[$id]])) |
|
2638 | - $board_updates[$msg . '-' . $lastModified[$id]] = array( |
|
2772 | + if (!isset($board_updates[$msg . '-' . $lastModified[$id]])) { |
|
2773 | + $board_updates[$msg . '-' . $lastModified[$id]] = array( |
|
2639 | 2774 | 'id' => $msg, |
2640 | 2775 | 'updated' => $lastModified[$id], |
2641 | 2776 | 'boards' => array($id) |
2642 | 2777 | ); |
2643 | - |
|
2644 | - else |
|
2645 | - $board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id; |
|
2778 | + } else { |
|
2779 | + $board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id; |
|
2780 | + } |
|
2646 | 2781 | } |
2647 | 2782 | |
2648 | 2783 | // Now commit the changes! |
@@ -2734,11 +2869,13 @@ discard block |
||
2734 | 2869 | global $txt, $mbname, $scripturl, $settings; |
2735 | 2870 | |
2736 | 2871 | // First things first, load up the email templates language file, if we need to. |
2737 | - if ($loadLang) |
|
2738 | - loadLanguage('EmailTemplates', $lang); |
|
2872 | + if ($loadLang) { |
|
2873 | + loadLanguage('EmailTemplates', $lang); |
|
2874 | + } |
|
2739 | 2875 | |
2740 | - if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body'])) |
|
2741 | - fatal_lang_error('email_no_template', 'template', array($template)); |
|
2876 | + if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body'])) { |
|
2877 | + fatal_lang_error('email_no_template', 'template', array($template)); |
|
2878 | + } |
|
2742 | 2879 | |
2743 | 2880 | $ret = array( |
2744 | 2881 | 'subject' => $txt[$template . '_subject'], |
@@ -2788,17 +2925,18 @@ discard block |
||
2788 | 2925 | function user_info_callback($matches) |
2789 | 2926 | { |
2790 | 2927 | global $user_info; |
2791 | - if (empty($matches[1])) |
|
2792 | - return ''; |
|
2928 | + if (empty($matches[1])) { |
|
2929 | + return ''; |
|
2930 | + } |
|
2793 | 2931 | |
2794 | 2932 | $use_ref = true; |
2795 | 2933 | $ref = &$user_info; |
2796 | 2934 | |
2797 | 2935 | foreach (explode('.', $matches[1]) as $index) |
2798 | 2936 | { |
2799 | - if ($use_ref && isset($ref[$index])) |
|
2800 | - $ref = &$ref[$index]; |
|
2801 | - else |
|
2937 | + if ($use_ref && isset($ref[$index])) { |
|
2938 | + $ref = &$ref[$index]; |
|
2939 | + } else |
|
2802 | 2940 | { |
2803 | 2941 | $use_ref = false; |
2804 | 2942 | break; |
@@ -2835,8 +2973,7 @@ discard block |
||
2835 | 2973 | if (!empty($lang_locale) && enchant_broker_dict_exists($context['enchant_broker'], $lang_locale)) |
2836 | 2974 | { |
2837 | 2975 | $enchant_link = enchant_broker_request_dict($context['enchant_broker'], $lang_locale); |
2838 | - } |
|
2839 | - elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary'])) |
|
2976 | + } elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary'])) |
|
2840 | 2977 | { |
2841 | 2978 | $enchant_link = enchant_broker_request_dict($context['enchant_broker'], $txt['lang_dictionary']); |
2842 | 2979 | } |
@@ -2846,8 +2983,7 @@ discard block |
||
2846 | 2983 | { |
2847 | 2984 | $context['provider'] = 'enchant'; |
2848 | 2985 | return $enchant_link; |
2849 | - } |
|
2850 | - else |
|
2986 | + } else |
|
2851 | 2987 | { |
2852 | 2988 | // Free up any resources used... |
2853 | 2989 | @enchant_broker_free($context['enchant_broker']); |
@@ -2868,8 +3004,9 @@ discard block |
||
2868 | 3004 | $pspell_link = pspell_new($txt['lang_dictionary'], $txt['lang_spelling'], '', strtr($context['character_set'], array('iso-' => 'iso', 'ISO-' => 'iso')), PSPELL_FAST | PSPELL_RUN_TOGETHER); |
2869 | 3005 | |
2870 | 3006 | // Most people don't have anything but English installed... So we use English as a last resort. |
2871 | - if (!$pspell_link) |
|
2872 | - $pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER); |
|
3007 | + if (!$pspell_link) { |
|
3008 | + $pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER); |
|
3009 | + } |
|
2873 | 3010 | |
2874 | 3011 | error_reporting($old); |
2875 | 3012 | ob_end_clean(); |
@@ -2909,8 +3046,7 @@ discard block |
||
2909 | 3046 | $word = iconv($txt['lang_character_set'], 'UTF-8', $word); |
2910 | 3047 | } |
2911 | 3048 | return enchant_dict_check($dict, $word); |
2912 | - } |
|
2913 | - elseif ($context['provider'] == 'pspell') |
|
3049 | + } elseif ($context['provider'] == 'pspell') |
|
2914 | 3050 | { |
2915 | 3051 | return pspell_check($dict, $word); |
2916 | 3052 | } |
@@ -2946,13 +3082,11 @@ discard block |
||
2946 | 3082 | } |
2947 | 3083 | |
2948 | 3084 | return $suggestions; |
2949 | - } |
|
2950 | - else |
|
3085 | + } else |
|
2951 | 3086 | { |
2952 | 3087 | return enchant_dict_suggest($dict, $word); |
2953 | 3088 | } |
2954 | - } |
|
2955 | - elseif ($context['provider'] == 'pspell') |
|
3089 | + } elseif ($context['provider'] == 'pspell') |
|
2956 | 3090 | { |
2957 | 3091 | return pspell_suggest($dict, $word); |
2958 | 3092 | } |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Get the latest post made on the system |
@@ -44,8 +45,9 @@ discard block |
||
44 | 45 | 'is_approved' => 1, |
45 | 46 | ) |
46 | 47 | ); |
47 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
48 | - return array(); |
|
48 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
49 | + return array(); |
|
50 | + } |
|
49 | 51 | $row = $smcFunc['db_fetch_assoc']($request); |
50 | 52 | $smcFunc['db_free_result']($request); |
51 | 53 | |
@@ -54,8 +56,9 @@ discard block |
||
54 | 56 | censorText($row['body']); |
55 | 57 | |
56 | 58 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled']), array('<br>' => ' '))); |
57 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
58 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
59 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
60 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
61 | + } |
|
59 | 62 | |
60 | 63 | // Send the data. |
61 | 64 | return array( |
@@ -83,8 +86,9 @@ discard block |
||
83 | 86 | |
84 | 87 | $context['is_redirect'] = false; |
85 | 88 | |
86 | - if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) |
|
87 | - $_REQUEST['start'] = 95; |
|
89 | + if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) { |
|
90 | + $_REQUEST['start'] = 95; |
|
91 | + } |
|
88 | 92 | |
89 | 93 | $_REQUEST['start'] = (int) $_REQUEST['start']; |
90 | 94 | |
@@ -92,8 +96,9 @@ discard block |
||
92 | 96 | if (!empty($_REQUEST['c']) && empty($board)) |
93 | 97 | { |
94 | 98 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
95 | - foreach ($_REQUEST['c'] as $i => $c) |
|
96 | - $_REQUEST['c'][$i] = (int) $c; |
|
99 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
100 | + $_REQUEST['c'][$i] = (int) $c; |
|
101 | + } |
|
97 | 102 | |
98 | 103 | if (count($_REQUEST['c']) == 1) |
99 | 104 | { |
@@ -109,8 +114,9 @@ discard block |
||
109 | 114 | list ($name) = $smcFunc['db_fetch_row']($request); |
110 | 115 | $smcFunc['db_free_result']($request); |
111 | 116 | |
112 | - if (empty($name)) |
|
113 | - fatal_lang_error('no_access', false); |
|
117 | + if (empty($name)) { |
|
118 | + fatal_lang_error('no_access', false); |
|
119 | + } |
|
114 | 120 | |
115 | 121 | $context['linktree'][] = array( |
116 | 122 | 'url' => $scripturl . '#c' . (int) $_REQUEST['c'], |
@@ -142,8 +148,9 @@ discard block |
||
142 | 148 | } |
143 | 149 | $smcFunc['db_free_result']($request); |
144 | 150 | |
145 | - if (empty($boards)) |
|
146 | - fatal_lang_error('error_no_boards_selected'); |
|
151 | + if (empty($boards)) { |
|
152 | + fatal_lang_error('error_no_boards_selected'); |
|
153 | + } |
|
147 | 154 | |
148 | 155 | $query_this_board = 'b.id_board IN ({array_int:boards})'; |
149 | 156 | $query_parameters['boards'] = $boards; |
@@ -157,12 +164,12 @@ discard block |
||
157 | 164 | } |
158 | 165 | |
159 | 166 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;c=' . implode(',', $_REQUEST['c']), $_REQUEST['start'], min(100, $total_cat_posts), 10, false); |
160 | - } |
|
161 | - elseif (!empty($_REQUEST['boards'])) |
|
167 | + } elseif (!empty($_REQUEST['boards'])) |
|
162 | 168 | { |
163 | 169 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
164 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
165 | - $_REQUEST['boards'][$i] = (int) $b; |
|
170 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
171 | + $_REQUEST['boards'][$i] = (int) $b; |
|
172 | + } |
|
166 | 173 | |
167 | 174 | $request = $smcFunc['db_query']('', ' |
168 | 175 | SELECT b.id_board, b.num_posts |
@@ -186,8 +193,9 @@ discard block |
||
186 | 193 | } |
187 | 194 | $smcFunc['db_free_result']($request); |
188 | 195 | |
189 | - if (empty($boards)) |
|
190 | - fatal_lang_error('error_no_boards_selected'); |
|
196 | + if (empty($boards)) { |
|
197 | + fatal_lang_error('error_no_boards_selected'); |
|
198 | + } |
|
191 | 199 | |
192 | 200 | $query_this_board = 'b.id_board IN ({array_int:boards})'; |
193 | 201 | $query_parameters['boards'] = $boards; |
@@ -201,8 +209,7 @@ discard block |
||
201 | 209 | } |
202 | 210 | |
203 | 211 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;boards=' . implode(',', $_REQUEST['boards']), $_REQUEST['start'], min(100, $total_posts), 10, false); |
204 | - } |
|
205 | - elseif (!empty($board)) |
|
212 | + } elseif (!empty($board)) |
|
206 | 213 | { |
207 | 214 | $request = $smcFunc['db_query']('', ' |
208 | 215 | SELECT num_posts, redirect |
@@ -235,8 +242,7 @@ discard block |
||
235 | 242 | } |
236 | 243 | |
237 | 244 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;board=' . $board . '.%1$d', $_REQUEST['start'], min(100, $total_posts), 10, true); |
238 | - } |
|
239 | - else |
|
245 | + } else |
|
240 | 246 | { |
241 | 247 | $query_this_board = '{query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' |
242 | 248 | AND b.id_board != {int:recycle_board}' : ''). ' |
@@ -271,8 +277,9 @@ discard block |
||
271 | 277 | ); |
272 | 278 | |
273 | 279 | // If you selected a redirection board, don't try getting posts for it... |
274 | - if ($context['is_redirect']) |
|
275 | - $messages = 0; |
|
280 | + if ($context['is_redirect']) { |
|
281 | + $messages = 0; |
|
282 | + } |
|
276 | 283 | |
277 | 284 | $key = 'recent-' . $user_info['id'] . '-' . md5($smcFunc['json_encode'](array_diff_key($query_parameters, array('max_id_msg' => 0)))) . '-' . (int) $_REQUEST['start']; |
278 | 285 | if (!$context['is_redirect'] && (empty($modSettings['cache_enable']) || ($messages = cache_get_data($key, 120)) == null)) |
@@ -303,16 +310,18 @@ discard block |
||
303 | 310 | $query_this_board = str_replace('AND m.id_msg >= {int:max_id_msg}', '', $query_this_board); |
304 | 311 | $cache_results = true; |
305 | 312 | unset($query_parameters['max_id_msg']); |
313 | + } else { |
|
314 | + $done = true; |
|
306 | 315 | } |
307 | - else |
|
308 | - $done = true; |
|
309 | 316 | } |
310 | 317 | $messages = array(); |
311 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
312 | - $messages[] = $row['id_msg']; |
|
318 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
319 | + $messages[] = $row['id_msg']; |
|
320 | + } |
|
313 | 321 | $smcFunc['db_free_result']($request); |
314 | - if (!empty($cache_results)) |
|
315 | - cache_put_data($key, $messages, 120); |
|
322 | + if (!empty($cache_results)) { |
|
323 | + cache_put_data($key, $messages, 120); |
|
324 | + } |
|
316 | 325 | } |
317 | 326 | |
318 | 327 | // Nothing here... Or at least, nothing you can see... |
@@ -399,8 +408,9 @@ discard block |
||
399 | 408 | 'css_class' => 'windowbg', |
400 | 409 | ); |
401 | 410 | |
402 | - if ($user_info['id'] == $row['id_first_member']) |
|
403 | - $board_ids['own'][$row['id_board']][] = $row['id_msg']; |
|
411 | + if ($user_info['id'] == $row['id_first_member']) { |
|
412 | + $board_ids['own'][$row['id_board']][] = $row['id_msg']; |
|
413 | + } |
|
404 | 414 | $board_ids['any'][$row['id_board']][] = $row['id_msg']; |
405 | 415 | } |
406 | 416 | $smcFunc['db_free_result']($request); |
@@ -426,20 +436,23 @@ discard block |
||
426 | 436 | $boards = boardsAllowedTo($permission); |
427 | 437 | |
428 | 438 | // If 0 is the only thing in the array, they can do it everywhere! |
429 | - if (!empty($boards) && $boards[0] == 0) |
|
430 | - $boards = array_keys($board_ids[$type]); |
|
439 | + if (!empty($boards) && $boards[0] == 0) { |
|
440 | + $boards = array_keys($board_ids[$type]); |
|
441 | + } |
|
431 | 442 | |
432 | 443 | // Go through the boards, and look for posts they can do this on. |
433 | 444 | foreach ($boards as $board_id) |
434 | 445 | { |
435 | 446 | // Hmm, they have permission, but there are no topics from that board on this page. |
436 | - if (!isset($board_ids[$type][$board_id])) |
|
437 | - continue; |
|
447 | + if (!isset($board_ids[$type][$board_id])) { |
|
448 | + continue; |
|
449 | + } |
|
438 | 450 | |
439 | 451 | // Okay, looks like they can do it for these posts. |
440 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
441 | - if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id']) |
|
452 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
453 | + if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id']) |
|
442 | 454 | $context['posts'][$counter][$allowed] = true; |
455 | + } |
|
443 | 456 | } |
444 | 457 | } |
445 | 458 | } |
@@ -482,17 +495,19 @@ discard block |
||
482 | 495 | $context['showing_all_topics'] = isset($_GET['all']); |
483 | 496 | $context['start'] = (int) $_REQUEST['start']; |
484 | 497 | $context['topics_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
485 | - if ($_REQUEST['action'] == 'unread') |
|
486 | - $context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit']; |
|
487 | - else |
|
488 | - $context['page_title'] = $txt['unread_replies']; |
|
498 | + if ($_REQUEST['action'] == 'unread') { |
|
499 | + $context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit']; |
|
500 | + } else { |
|
501 | + $context['page_title'] = $txt['unread_replies']; |
|
502 | + } |
|
489 | 503 | |
490 | - if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) |
|
491 | - fatal_lang_error('loadavg_allunread_disabled', false); |
|
492 | - elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) |
|
493 | - fatal_lang_error('loadavg_unreadreplies_disabled', false); |
|
494 | - elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) |
|
495 | - fatal_lang_error('loadavg_unread_disabled', false); |
|
504 | + if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) { |
|
505 | + fatal_lang_error('loadavg_allunread_disabled', false); |
|
506 | + } elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) { |
|
507 | + fatal_lang_error('loadavg_unreadreplies_disabled', false); |
|
508 | + } elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) { |
|
509 | + fatal_lang_error('loadavg_unread_disabled', false); |
|
510 | + } |
|
496 | 511 | |
497 | 512 | // Parameters for the main query. |
498 | 513 | $query_parameters = array(); |
@@ -505,12 +520,14 @@ discard block |
||
505 | 520 | if (!empty($_REQUEST['boards'])) |
506 | 521 | { |
507 | 522 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
508 | - foreach ($_REQUEST['boards'] as $b) |
|
509 | - $boards[] = (int) $b; |
|
523 | + foreach ($_REQUEST['boards'] as $b) { |
|
524 | + $boards[] = (int) $b; |
|
525 | + } |
|
510 | 526 | } |
511 | 527 | |
512 | - if (!empty($board)) |
|
513 | - $boards[] = (int) $board; |
|
528 | + if (!empty($board)) { |
|
529 | + $boards[] = (int) $board; |
|
530 | + } |
|
514 | 531 | |
515 | 532 | // The easiest thing is to just get all the boards they can see, but since we've specified the top of tree we ignore some of them |
516 | 533 | $request = $smcFunc['db_query']('', ' |
@@ -527,30 +544,31 @@ discard block |
||
527 | 544 | ) |
528 | 545 | ); |
529 | 546 | |
530 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
531 | - if (in_array($row['id_parent'], $boards)) |
|
547 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
548 | + if (in_array($row['id_parent'], $boards)) |
|
532 | 549 | $boards[] = $row['id_board']; |
550 | + } |
|
533 | 551 | |
534 | 552 | $smcFunc['db_free_result']($request); |
535 | 553 | |
536 | - if (empty($boards)) |
|
537 | - fatal_lang_error('error_no_boards_selected'); |
|
554 | + if (empty($boards)) { |
|
555 | + fatal_lang_error('error_no_boards_selected'); |
|
556 | + } |
|
538 | 557 | |
539 | 558 | $query_this_board = 'id_board IN ({array_int:boards})'; |
540 | 559 | $query_parameters['boards'] = $boards; |
541 | 560 | $context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%d'; |
542 | - } |
|
543 | - elseif (!empty($board)) |
|
561 | + } elseif (!empty($board)) |
|
544 | 562 | { |
545 | 563 | $query_this_board = 'id_board = {int:board}'; |
546 | 564 | $query_parameters['board'] = $board; |
547 | 565 | $context['querystring_board_limits'] = ';board=' . $board . '.%1$d'; |
548 | - } |
|
549 | - elseif (!empty($_REQUEST['boards'])) |
|
566 | + } elseif (!empty($_REQUEST['boards'])) |
|
550 | 567 | { |
551 | 568 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
552 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
553 | - $_REQUEST['boards'][$i] = (int) $b; |
|
569 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
570 | + $_REQUEST['boards'][$i] = (int) $b; |
|
571 | + } |
|
554 | 572 | |
555 | 573 | $request = $smcFunc['db_query']('', ' |
556 | 574 | SELECT b.id_board |
@@ -562,22 +580,24 @@ discard block |
||
562 | 580 | ) |
563 | 581 | ); |
564 | 582 | $boards = array(); |
565 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
566 | - $boards[] = $row['id_board']; |
|
583 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
584 | + $boards[] = $row['id_board']; |
|
585 | + } |
|
567 | 586 | $smcFunc['db_free_result']($request); |
568 | 587 | |
569 | - if (empty($boards)) |
|
570 | - fatal_lang_error('error_no_boards_selected'); |
|
588 | + if (empty($boards)) { |
|
589 | + fatal_lang_error('error_no_boards_selected'); |
|
590 | + } |
|
571 | 591 | |
572 | 592 | $query_this_board = 'id_board IN ({array_int:boards})'; |
573 | 593 | $query_parameters['boards'] = $boards; |
574 | 594 | $context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%1$d'; |
575 | - } |
|
576 | - elseif (!empty($_REQUEST['c'])) |
|
595 | + } elseif (!empty($_REQUEST['c'])) |
|
577 | 596 | { |
578 | 597 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
579 | - foreach ($_REQUEST['c'] as $i => $c) |
|
580 | - $_REQUEST['c'][$i] = (int) $c; |
|
598 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
599 | + $_REQUEST['c'][$i] = (int) $c; |
|
600 | + } |
|
581 | 601 | |
582 | 602 | $see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board'; |
583 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -590,18 +610,19 @@ discard block |
||
590 | 610 | ) |
591 | 611 | ); |
592 | 612 | $boards = array(); |
593 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
594 | - $boards[] = $row['id_board']; |
|
613 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
614 | + $boards[] = $row['id_board']; |
|
615 | + } |
|
595 | 616 | $smcFunc['db_free_result']($request); |
596 | 617 | |
597 | - if (empty($boards)) |
|
598 | - fatal_lang_error('error_no_boards_selected'); |
|
618 | + if (empty($boards)) { |
|
619 | + fatal_lang_error('error_no_boards_selected'); |
|
620 | + } |
|
599 | 621 | |
600 | 622 | $query_this_board = 'id_board IN ({array_int:boards})'; |
601 | 623 | $query_parameters['boards'] = $boards; |
602 | 624 | $context['querystring_board_limits'] = ';c=' . implode(',', $_REQUEST['c']) . ';start=%1$d'; |
603 | - } |
|
604 | - else |
|
625 | + } else |
|
605 | 626 | { |
606 | 627 | $see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board'; |
607 | 628 | // Don't bother to show deleted posts! |
@@ -615,12 +636,14 @@ discard block |
||
615 | 636 | ) |
616 | 637 | ); |
617 | 638 | $boards = array(); |
618 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
619 | - $boards[] = $row['id_board']; |
|
639 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
640 | + $boards[] = $row['id_board']; |
|
641 | + } |
|
620 | 642 | $smcFunc['db_free_result']($request); |
621 | 643 | |
622 | - if (empty($boards)) |
|
623 | - fatal_lang_error('error_no_boards_available', false); |
|
644 | + if (empty($boards)) { |
|
645 | + fatal_lang_error('error_no_boards_available', false); |
|
646 | + } |
|
624 | 647 | |
625 | 648 | $query_this_board = 'id_board IN ({array_int:boards})'; |
626 | 649 | $query_parameters['boards'] = $boards; |
@@ -682,13 +705,14 @@ discard block |
||
682 | 705 | 'name' => $_REQUEST['action'] == 'unread' ? $txt['unread_topics_visit'] : $txt['unread_replies'] |
683 | 706 | ); |
684 | 707 | |
685 | - if ($context['showing_all_topics']) |
|
686 | - $context['linktree'][] = array( |
|
708 | + if ($context['showing_all_topics']) { |
|
709 | + $context['linktree'][] = array( |
|
687 | 710 | 'url' => $scripturl . '?action=' . $_REQUEST['action'] . ';all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'], |
688 | 711 | 'name' => $txt['unread_topics_all'] |
689 | 712 | ); |
690 | - else |
|
691 | - $txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'])); |
|
713 | + } else { |
|
714 | + $txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'])); |
|
715 | + } |
|
692 | 716 | |
693 | 717 | loadTemplate('Recent'); |
694 | 718 | loadTemplate('MessageIndex'); |
@@ -696,8 +720,9 @@ discard block |
||
696 | 720 | |
697 | 721 | // Setup the default topic icons... for checking they exist and the like ;) |
698 | 722 | $context['icon_sources'] = array(); |
699 | - foreach ($context['stable_icons'] as $icon) |
|
700 | - $context['icon_sources'][$icon] = 'images_url'; |
|
723 | + foreach ($context['stable_icons'] as $icon) { |
|
724 | + $context['icon_sources'][$icon] = 'images_url'; |
|
725 | + } |
|
701 | 726 | |
702 | 727 | $is_topics = $_REQUEST['action'] == 'unread'; |
703 | 728 | |
@@ -727,8 +752,7 @@ discard block |
||
727 | 752 | ); |
728 | 753 | list ($earliest_msg) = $smcFunc['db_fetch_row']($request); |
729 | 754 | $smcFunc['db_free_result']($request); |
730 | - } |
|
731 | - else |
|
755 | + } else |
|
732 | 756 | { |
733 | 757 | $request = $smcFunc['db_query']('', ' |
734 | 758 | SELECT MIN(lmr.id_msg) |
@@ -744,14 +768,14 @@ discard block |
||
744 | 768 | } |
745 | 769 | |
746 | 770 | // This is needed in case of topics marked unread. |
747 | - if (empty($earliest_msg)) |
|
748 | - $earliest_msg = 0; |
|
749 | - else |
|
771 | + if (empty($earliest_msg)) { |
|
772 | + $earliest_msg = 0; |
|
773 | + } else |
|
750 | 774 | { |
751 | 775 | // Using caching, when possible, to ignore the below slow query. |
752 | - if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) |
|
753 | - $earliest_msg2 = $_SESSION['cached_log_time'][1]; |
|
754 | - else |
|
776 | + if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) { |
|
777 | + $earliest_msg2 = $_SESSION['cached_log_time'][1]; |
|
778 | + } else |
|
755 | 779 | { |
756 | 780 | // This query is pretty slow, but it's needed to ensure nothing crucial is ignored. |
757 | 781 | $request = $smcFunc['db_query']('', ' |
@@ -766,8 +790,9 @@ discard block |
||
766 | 790 | $smcFunc['db_free_result']($request); |
767 | 791 | |
768 | 792 | // In theory this could be zero, if the first ever post is unread, so fudge it ;) |
769 | - if ($earliest_msg2 == 0) |
|
770 | - $earliest_msg2 = -1; |
|
793 | + if ($earliest_msg2 == 0) { |
|
794 | + $earliest_msg2 = -1; |
|
795 | + } |
|
771 | 796 | |
772 | 797 | $_SESSION['cached_log_time'] = array(time(), $earliest_msg2); |
773 | 798 | } |
@@ -805,9 +830,9 @@ discard block |
||
805 | 830 | 'db_error_skip' => true, |
806 | 831 | )) |
807 | 832 | ) !== false; |
833 | + } else { |
|
834 | + $have_temp_table = false; |
|
808 | 835 | } |
809 | - else |
|
810 | - $have_temp_table = false; |
|
811 | 836 | |
812 | 837 | if ($context['showing_all_topics'] && $have_temp_table) |
813 | 838 | { |
@@ -853,14 +878,15 @@ discard block |
||
853 | 878 | |
854 | 879 | $context['topics'] = array(); |
855 | 880 | $context['no_topic_listing'] = true; |
856 | - if ($context['querystring_board_limits'] == ';start=%1$d') |
|
857 | - $context['querystring_board_limits'] = ''; |
|
858 | - else |
|
859 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
881 | + if ($context['querystring_board_limits'] == ';start=%1$d') { |
|
882 | + $context['querystring_board_limits'] = ''; |
|
883 | + } else { |
|
884 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
885 | + } |
|
860 | 886 | return; |
887 | + } else { |
|
888 | + $min_message = (int) $min_message; |
|
861 | 889 | } |
862 | - else |
|
863 | - $min_message = (int) $min_message; |
|
864 | 890 | |
865 | 891 | $request = $smcFunc['db_query']('substring', ' |
866 | 892 | SELECT ' . $select_clause . ' |
@@ -889,8 +915,7 @@ discard block |
||
889 | 915 | 'limit' => $context['topics_per_page'], |
890 | 916 | )) |
891 | 917 | ); |
892 | - } |
|
893 | - elseif ($is_topics) |
|
918 | + } elseif ($is_topics) |
|
894 | 919 | { |
895 | 920 | $request = $smcFunc['db_query']('', ' |
896 | 921 | SELECT COUNT(*), MIN(t.id_last_msg) |
@@ -941,14 +966,15 @@ discard block |
||
941 | 966 | |
942 | 967 | $context['topics'] = array(); |
943 | 968 | $context['no_topic_listing'] = true; |
944 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
945 | - $context['querystring_board_limits'] = ''; |
|
946 | - else |
|
947 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
969 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
970 | + $context['querystring_board_limits'] = ''; |
|
971 | + } else { |
|
972 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
973 | + } |
|
948 | 974 | return; |
975 | + } else { |
|
976 | + $min_message = (int) $min_message; |
|
949 | 977 | } |
950 | - else |
|
951 | - $min_message = (int) $min_message; |
|
952 | 978 | |
953 | 979 | $request = $smcFunc['db_query']('substring', ' |
954 | 980 | SELECT ' . $select_clause . ' |
@@ -978,8 +1004,7 @@ discard block |
||
978 | 1004 | 'limit' => $context['topics_per_page'], |
979 | 1005 | )) |
980 | 1006 | ); |
981 | - } |
|
982 | - else |
|
1007 | + } else |
|
983 | 1008 | { |
984 | 1009 | if ($modSettings['totalMessages'] > 100000) |
985 | 1010 | { |
@@ -1031,8 +1056,8 @@ discard block |
||
1031 | 1056 | ) !== false; |
1032 | 1057 | |
1033 | 1058 | // If that worked, create a sample of the log_topics table too. |
1034 | - if ($have_temp_table) |
|
1035 | - $have_temp_table = $smcFunc['db_query']('', ' |
|
1059 | + if ($have_temp_table) { |
|
1060 | + $have_temp_table = $smcFunc['db_query']('', ' |
|
1036 | 1061 | CREATE TEMPORARY TABLE {db_prefix}log_topics_posted_in ( |
1037 | 1062 | PRIMARY KEY (id_topic) |
1038 | 1063 | ) |
@@ -1045,6 +1070,7 @@ discard block |
||
1045 | 1070 | 'db_error_skip' => true, |
1046 | 1071 | ) |
1047 | 1072 | ) !== false; |
1073 | + } |
|
1048 | 1074 | } |
1049 | 1075 | |
1050 | 1076 | if (!empty($have_temp_table)) |
@@ -1060,8 +1086,7 @@ discard block |
||
1060 | 1086 | ); |
1061 | 1087 | list ($num_topics) = $smcFunc['db_fetch_row']($request); |
1062 | 1088 | $smcFunc['db_free_result']($request); |
1063 | - } |
|
1064 | - else |
|
1089 | + } else |
|
1065 | 1090 | { |
1066 | 1091 | $request = $smcFunc['db_query']('unread_fetch_topic_count', ' |
1067 | 1092 | SELECT COUNT(DISTINCT t.id_topic), MIN(t.id_last_msg) |
@@ -1102,15 +1127,16 @@ discard block |
||
1102 | 1127 | { |
1103 | 1128 | $context['topics'] = array(); |
1104 | 1129 | $context['no_topic_listing'] = true; |
1105 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
1106 | - $context['querystring_board_limits'] = ''; |
|
1107 | - else |
|
1108 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1130 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
1131 | + $context['querystring_board_limits'] = ''; |
|
1132 | + } else { |
|
1133 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1134 | + } |
|
1109 | 1135 | return; |
1110 | 1136 | } |
1111 | 1137 | |
1112 | - if (!empty($have_temp_table)) |
|
1113 | - $request = $smcFunc['db_query']('', ' |
|
1138 | + if (!empty($have_temp_table)) { |
|
1139 | + $request = $smcFunc['db_query']('', ' |
|
1114 | 1140 | SELECT t.id_topic |
1115 | 1141 | FROM {db_prefix}topics_posted_in AS t |
1116 | 1142 | LEFT JOIN {db_prefix}log_topics_posted_in AS lt ON (lt.id_topic = t.id_topic) |
@@ -1124,8 +1150,8 @@ discard block |
||
1124 | 1150 | 'limit' => $context['topics_per_page'], |
1125 | 1151 | )) |
1126 | 1152 | ); |
1127 | - else |
|
1128 | - $request = $smcFunc['db_query']('', ' |
|
1153 | + } else { |
|
1154 | + $request = $smcFunc['db_query']('', ' |
|
1129 | 1155 | SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'].' |
1130 | 1156 | FROM {db_prefix}topics AS t |
1131 | 1157 | INNER JOIN {db_prefix}messages AS m ON (m.id_topic = t.id_topic AND m.id_member = {int:current_member})' . (strpos($_REQUEST['sort'], 'ms.') === false ? '' : ' |
@@ -1149,10 +1175,12 @@ discard block |
||
1149 | 1175 | 'sort' => $_REQUEST['sort'], |
1150 | 1176 | )) |
1151 | 1177 | ); |
1178 | + } |
|
1152 | 1179 | |
1153 | 1180 | $topics = array(); |
1154 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1155 | - $topics[] = $row['id_topic']; |
|
1181 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1182 | + $topics[] = $row['id_topic']; |
|
1183 | + } |
|
1156 | 1184 | $smcFunc['db_free_result']($request); |
1157 | 1185 | |
1158 | 1186 | // Sanity... where have you gone? |
@@ -1160,10 +1188,11 @@ discard block |
||
1160 | 1188 | { |
1161 | 1189 | $context['topics'] = array(); |
1162 | 1190 | $context['no_topic_listing'] = true; |
1163 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
1164 | - $context['querystring_board_limits'] = ''; |
|
1165 | - else |
|
1166 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1191 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
1192 | + $context['querystring_board_limits'] = ''; |
|
1193 | + } else { |
|
1194 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1195 | + } |
|
1167 | 1196 | return; |
1168 | 1197 | } |
1169 | 1198 | |
@@ -1197,8 +1226,9 @@ discard block |
||
1197 | 1226 | |
1198 | 1227 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1199 | 1228 | { |
1200 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
1201 | - continue; |
|
1229 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
1230 | + continue; |
|
1231 | + } |
|
1202 | 1232 | |
1203 | 1233 | $topic_ids[] = $row['id_topic']; |
1204 | 1234 | |
@@ -1206,11 +1236,13 @@ discard block |
||
1206 | 1236 | { |
1207 | 1237 | // Limit them to 128 characters - do this FIRST because it's a lot of wasted censoring otherwise. |
1208 | 1238 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
1209 | - if ($smcFunc['strlen']($row['first_body']) > 128) |
|
1210 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...'; |
|
1239 | + if ($smcFunc['strlen']($row['first_body']) > 128) { |
|
1240 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...'; |
|
1241 | + } |
|
1211 | 1242 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
1212 | - if ($smcFunc['strlen']($row['last_body']) > 128) |
|
1213 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...'; |
|
1243 | + if ($smcFunc['strlen']($row['last_body']) > 128) { |
|
1244 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...'; |
|
1245 | + } |
|
1214 | 1246 | |
1215 | 1247 | // Censor the subject and message preview. |
1216 | 1248 | censorText($row['first_subject']); |
@@ -1221,23 +1253,22 @@ discard block |
||
1221 | 1253 | { |
1222 | 1254 | $row['last_subject'] = $row['first_subject']; |
1223 | 1255 | $row['last_body'] = $row['first_body']; |
1224 | - } |
|
1225 | - else |
|
1256 | + } else |
|
1226 | 1257 | { |
1227 | 1258 | censorText($row['last_subject']); |
1228 | 1259 | censorText($row['last_body']); |
1229 | 1260 | } |
1230 | - } |
|
1231 | - else |
|
1261 | + } else |
|
1232 | 1262 | { |
1233 | 1263 | $row['first_body'] = ''; |
1234 | 1264 | $row['last_body'] = ''; |
1235 | 1265 | censorText($row['first_subject']); |
1236 | 1266 | |
1237 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
1238 | - $row['last_subject'] = $row['first_subject']; |
|
1239 | - else |
|
1240 | - censorText($row['last_subject']); |
|
1267 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
1268 | + $row['last_subject'] = $row['first_subject']; |
|
1269 | + } else { |
|
1270 | + censorText($row['last_subject']); |
|
1271 | + } |
|
1241 | 1272 | } |
1242 | 1273 | |
1243 | 1274 | // Decide how many pages the topic should have. |
@@ -1249,29 +1280,32 @@ discard block |
||
1249 | 1280 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $topic_length, $messages_per_page, true, false); |
1250 | 1281 | |
1251 | 1282 | // If we can use all, show all. |
1252 | - if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) |
|
1253 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
1283 | + if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) { |
|
1284 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
1285 | + } |
|
1286 | + } else { |
|
1287 | + $pages = ''; |
|
1254 | 1288 | } |
1255 | 1289 | |
1256 | - else |
|
1257 | - $pages = ''; |
|
1258 | - |
|
1259 | 1290 | // We need to check the topic icons exist... you can never be too sure! |
1260 | 1291 | if (!empty($modSettings['messageIconChecks_enable'])) |
1261 | 1292 | { |
1262 | 1293 | // First icon first... as you'd expect. |
1263 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
1264 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1294 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
1295 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1296 | + } |
|
1265 | 1297 | // Last icon... last... duh. |
1266 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
1267 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1268 | - } |
|
1269 | - else |
|
1298 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
1299 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1300 | + } |
|
1301 | + } else |
|
1270 | 1302 | { |
1271 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
1272 | - $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
1273 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
1274 | - $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
1303 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
1304 | + $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
1305 | + } |
|
1306 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
1307 | + $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
1308 | + } |
|
1275 | 1309 | } |
1276 | 1310 | |
1277 | 1311 | // Force the recycling icon if appropriate |
@@ -1285,12 +1319,14 @@ discard block |
||
1285 | 1319 | $colorClass = 'windowbg'; |
1286 | 1320 | |
1287 | 1321 | // Sticky topics should get a different color, too. |
1288 | - if ($row['is_sticky']) |
|
1289 | - $colorClass .= ' sticky'; |
|
1322 | + if ($row['is_sticky']) { |
|
1323 | + $colorClass .= ' sticky'; |
|
1324 | + } |
|
1290 | 1325 | |
1291 | 1326 | // Locked topics get special treatment as well. |
1292 | - if ($row['locked']) |
|
1293 | - $colorClass .= ' locked'; |
|
1327 | + if ($row['locked']) { |
|
1328 | + $colorClass .= ' locked'; |
|
1329 | + } |
|
1294 | 1330 | |
1295 | 1331 | // And build the array. |
1296 | 1332 | $context['topics'][$row['id_topic']] = array( |
@@ -1387,8 +1423,9 @@ discard block |
||
1387 | 1423 | ); |
1388 | 1424 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
1389 | 1425 | { |
1390 | - if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) |
|
1391 | - $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
1426 | + if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) { |
|
1427 | + $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
1428 | + } |
|
1392 | 1429 | } |
1393 | 1430 | $smcFunc['db_free_result']($result); |
1394 | 1431 | } |
@@ -1403,28 +1440,30 @@ discard block |
||
1403 | 1440 | 'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']), |
1404 | 1441 | ); |
1405 | 1442 | |
1406 | - if ($context['showCheckboxes']) |
|
1407 | - $context['recent_buttons']['markselectread'] = array( |
|
1443 | + if ($context['showCheckboxes']) { |
|
1444 | + $context['recent_buttons']['markselectread'] = array( |
|
1408 | 1445 | 'text' => 'quick_mod_markread', |
1409 | 1446 | 'image' => 'markselectedread.png', |
1410 | 1447 | 'url' => 'javascript:document.quickModForm.submit();', |
1411 | 1448 | ); |
1449 | + } |
|
1412 | 1450 | |
1413 | - if (!empty($context['topics']) && !$context['showing_all_topics']) |
|
1414 | - $context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true); |
|
1415 | - } |
|
1416 | - elseif (!$is_topics && isset($context['topics_to_mark'])) |
|
1451 | + if (!empty($context['topics']) && !$context['showing_all_topics']) { |
|
1452 | + $context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true); |
|
1453 | + } |
|
1454 | + } elseif (!$is_topics && isset($context['topics_to_mark'])) |
|
1417 | 1455 | { |
1418 | 1456 | $context['recent_buttons'] = array( |
1419 | 1457 | 'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']), |
1420 | 1458 | ); |
1421 | 1459 | |
1422 | - if ($context['showCheckboxes']) |
|
1423 | - $context['recent_buttons']['markselectread'] = array( |
|
1460 | + if ($context['showCheckboxes']) { |
|
1461 | + $context['recent_buttons']['markselectread'] = array( |
|
1424 | 1462 | 'text' => 'quick_mod_markread', |
1425 | 1463 | 'image' => 'markselectedread.png', |
1426 | 1464 | 'url' => 'javascript:document.quickModForm.submit();', |
1427 | 1465 | ); |
1466 | + } |
|
1428 | 1467 | } |
1429 | 1468 | |
1430 | 1469 | // Allow mods to add additional buttons here |
@@ -12,8 +12,9 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Don't do anything if SMF is already loaded. |
15 | -if (defined('SMF')) |
|
15 | +if (defined('SMF')) { |
|
16 | 16 | return true; |
17 | +} |
|
17 | 18 | |
18 | 19 | define('SMF', 'SSI'); |
19 | 20 | |
@@ -28,16 +29,18 @@ discard block |
||
28 | 29 | $time_start = microtime(true); |
29 | 30 | |
30 | 31 | // Just being safe... |
31 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
32 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
32 | 33 | if (isset($GLOBALS[$variable])) |
33 | 34 | unset($GLOBALS[$variable]); |
35 | +} |
|
34 | 36 | |
35 | 37 | // Get the forum's settings for database and file paths. |
36 | 38 | require_once(dirname(__FILE__) . '/Settings.php'); |
37 | 39 | |
38 | 40 | // Make absolutely sure the cache directory is defined. |
39 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
41 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
40 | 42 | $cachedir = $boarddir . '/cache'; |
43 | +} |
|
41 | 44 | |
42 | 45 | $ssi_error_reporting = error_reporting(E_ALL); |
43 | 46 | /* Set this to one of three values depending on what you want to happen in the case of a fatal error. |
@@ -48,12 +51,14 @@ discard block |
||
48 | 51 | $ssi_on_error_method = false; |
49 | 52 | |
50 | 53 | // Don't do john didley if the forum's been shut down completely. |
51 | -if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) |
|
54 | +if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) { |
|
52 | 55 | die($mmessage); |
56 | +} |
|
53 | 57 | |
54 | 58 | // Fix for using the current directory as a path. |
55 | -if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') |
|
59 | +if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') { |
|
56 | 60 | $sourcedir = dirname(__FILE__) . substr($sourcedir, 1); |
61 | +} |
|
57 | 62 | |
58 | 63 | // Load the important includes. |
59 | 64 | require_once($sourcedir . '/QueryString.php'); |
@@ -78,26 +83,30 @@ discard block |
||
78 | 83 | cleanRequest(); |
79 | 84 | |
80 | 85 | // Seed the random generator? |
81 | -if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) |
|
86 | +if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) { |
|
82 | 87 | smf_seed_generator(); |
88 | +} |
|
83 | 89 | |
84 | 90 | // Check on any hacking attempts. |
85 | -if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) |
|
91 | +if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) { |
|
86 | 92 | die('No direct access...'); |
87 | -elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) |
|
93 | +} elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) { |
|
88 | 94 | die('No direct access...'); |
89 | -elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) |
|
95 | +} elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) { |
|
90 | 96 | die('No direct access...'); |
91 | -elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) |
|
97 | +} elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) { |
|
92 | 98 | die('No direct access...'); |
93 | -if (isset($_REQUEST['context'])) |
|
99 | +} |
|
100 | +if (isset($_REQUEST['context'])) { |
|
94 | 101 | die('No direct access...'); |
102 | +} |
|
95 | 103 | |
96 | 104 | // Gzip output? (because it must be boolean and true, this can't be hacked.) |
97 | -if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) |
|
105 | +if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) { |
|
98 | 106 | ob_start('ob_gzhandler'); |
99 | -else |
|
107 | +} else { |
|
100 | 108 | $modSettings['enableCompressedOutput'] = '0'; |
109 | +} |
|
101 | 110 | |
102 | 111 | /** |
103 | 112 | * An autoloader for certain classes. |
@@ -146,9 +155,9 @@ discard block |
||
146 | 155 | ob_start('ob_sessrewrite'); |
147 | 156 | |
148 | 157 | // Start the session... known to scramble SSI includes in cases... |
149 | -if (!headers_sent()) |
|
158 | +if (!headers_sent()) { |
|
150 | 159 | loadSession(); |
151 | -else |
|
160 | +} else |
|
152 | 161 | { |
153 | 162 | if (isset($_COOKIE[session_name()]) || isset($_REQUEST[session_name()])) |
154 | 163 | { |
@@ -182,12 +191,14 @@ discard block |
||
182 | 191 | loadTheme(isset($ssi_theme) ? (int) $ssi_theme : 0); |
183 | 192 | |
184 | 193 | // @todo: probably not the best place, but somewhere it should be set... |
185 | -if (!headers_sent()) |
|
194 | +if (!headers_sent()) { |
|
186 | 195 | header('content-type: text/html; charset=' . (empty($modSettings['global_character_set']) ? (empty($txt['lang_character_set']) ? 'ISO-8859-1' : $txt['lang_character_set']) : $modSettings['global_character_set'])); |
196 | +} |
|
187 | 197 | |
188 | 198 | // Take care of any banning that needs to be done. |
189 | -if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) |
|
199 | +if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) { |
|
190 | 200 | is_not_banned(); |
201 | +} |
|
191 | 202 | |
192 | 203 | // Do we allow guests in here? |
193 | 204 | if (empty($ssi_guest_access) && empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && basename($_SERVER['PHP_SELF']) != 'SSI.php') |
@@ -202,17 +213,19 @@ discard block |
||
202 | 213 | { |
203 | 214 | $context['template_layers'] = $ssi_layers; |
204 | 215 | template_header(); |
205 | -} |
|
206 | -else |
|
216 | +} else { |
|
207 | 217 | setupThemeContext(); |
218 | +} |
|
208 | 219 | |
209 | 220 | // Make sure they didn't muss around with the settings... but only if it's not cli. |
210 | -if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') |
|
221 | +if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') { |
|
211 | 222 | trigger_error($txt['ssi_session_broken'], E_USER_NOTICE); |
223 | +} |
|
212 | 224 | |
213 | 225 | // Without visiting the forum this session variable might not be set on submit. |
214 | -if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) |
|
226 | +if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) { |
|
215 | 227 | $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; |
228 | +} |
|
216 | 229 | |
217 | 230 | // Have the ability to easily add functions to SSI. |
218 | 231 | call_integration_hook('integrate_SSI'); |
@@ -221,11 +234,13 @@ discard block |
||
221 | 234 | if (basename($_SERVER['PHP_SELF']) == 'SSI.php') |
222 | 235 | { |
223 | 236 | // You shouldn't just access SSI.php directly by URL!! |
224 | - if (!isset($_GET['ssi_function'])) |
|
225 | - die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\'')); |
|
237 | + if (!isset($_GET['ssi_function'])) { |
|
238 | + die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\'')); |
|
239 | + } |
|
226 | 240 | // Call a function passed by GET. |
227 | - if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) |
|
228 | - call_user_func('ssi_' . $_GET['ssi_function']); |
|
241 | + if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) { |
|
242 | + call_user_func('ssi_' . $_GET['ssi_function']); |
|
243 | + } |
|
229 | 244 | exit; |
230 | 245 | } |
231 | 246 | |
@@ -242,9 +257,10 @@ discard block |
||
242 | 257 | */ |
243 | 258 | function ssi_shutdown() |
244 | 259 | { |
245 | - if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') |
|
246 | - template_footer(); |
|
247 | -} |
|
260 | + if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') { |
|
261 | + template_footer(); |
|
262 | + } |
|
263 | + } |
|
248 | 264 | |
249 | 265 | /** |
250 | 266 | * Display a welcome message, like: Hey, User, you have 0 messages, 0 are new. |
@@ -257,15 +273,17 @@ discard block |
||
257 | 273 | |
258 | 274 | if ($output_method == 'echo') |
259 | 275 | { |
260 | - if ($context['user']['is_guest']) |
|
261 | - echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'); |
|
262 | - else |
|
263 | - echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : ''; |
|
276 | + if ($context['user']['is_guest']) { |
|
277 | + echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'); |
|
278 | + } else { |
|
279 | + echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : ''; |
|
280 | + } |
|
264 | 281 | } |
265 | 282 | // Don't echo... then do what?! |
266 | - else |
|
267 | - return $context['user']; |
|
268 | -} |
|
283 | + else { |
|
284 | + return $context['user']; |
|
285 | + } |
|
286 | + } |
|
269 | 287 | |
270 | 288 | /** |
271 | 289 | * Display a menu bar, like is displayed at the top of the forum. |
@@ -276,12 +294,14 @@ discard block |
||
276 | 294 | { |
277 | 295 | global $context; |
278 | 296 | |
279 | - if ($output_method == 'echo') |
|
280 | - template_menu(); |
|
297 | + if ($output_method == 'echo') { |
|
298 | + template_menu(); |
|
299 | + } |
|
281 | 300 | // What else could this do? |
282 | - else |
|
283 | - return $context['menu_buttons']; |
|
284 | -} |
|
301 | + else { |
|
302 | + return $context['menu_buttons']; |
|
303 | + } |
|
304 | + } |
|
285 | 305 | |
286 | 306 | /** |
287 | 307 | * Show a logout link. |
@@ -293,20 +313,23 @@ discard block |
||
293 | 313 | { |
294 | 314 | global $context, $txt, $scripturl; |
295 | 315 | |
296 | - if ($redirect_to != '') |
|
297 | - $_SESSION['logout_url'] = $redirect_to; |
|
316 | + if ($redirect_to != '') { |
|
317 | + $_SESSION['logout_url'] = $redirect_to; |
|
318 | + } |
|
298 | 319 | |
299 | 320 | // Guests can't log out. |
300 | - if ($context['user']['is_guest']) |
|
301 | - return false; |
|
321 | + if ($context['user']['is_guest']) { |
|
322 | + return false; |
|
323 | + } |
|
302 | 324 | |
303 | 325 | $link = '<a href="' . $scripturl . '?action=logout;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['logout'] . '</a>'; |
304 | 326 | |
305 | - if ($output_method == 'echo') |
|
306 | - echo $link; |
|
307 | - else |
|
308 | - return $link; |
|
309 | -} |
|
327 | + if ($output_method == 'echo') { |
|
328 | + echo $link; |
|
329 | + } else { |
|
330 | + return $link; |
|
331 | + } |
|
332 | + } |
|
310 | 333 | |
311 | 334 | /** |
312 | 335 | * Recent post list: [board] Subject by Poster Date |
@@ -322,17 +345,17 @@ discard block |
||
322 | 345 | global $modSettings, $context; |
323 | 346 | |
324 | 347 | // Excluding certain boards... |
325 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
326 | - $exclude_boards = array($modSettings['recycle_board']); |
|
327 | - else |
|
328 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
348 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
349 | + $exclude_boards = array($modSettings['recycle_board']); |
|
350 | + } else { |
|
351 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
352 | + } |
|
329 | 353 | |
330 | 354 | // What about including certain boards - note we do some protection here as pre-2.0 didn't have this parameter. |
331 | 355 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
332 | 356 | { |
333 | 357 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
334 | - } |
|
335 | - elseif ($include_boards != null) |
|
358 | + } elseif ($include_boards != null) |
|
336 | 359 | { |
337 | 360 | $include_boards = array(); |
338 | 361 | } |
@@ -369,8 +392,9 @@ discard block |
||
369 | 392 | { |
370 | 393 | global $modSettings; |
371 | 394 | |
372 | - if (empty($post_ids)) |
|
373 | - return; |
|
395 | + if (empty($post_ids)) { |
|
396 | + return; |
|
397 | + } |
|
374 | 398 | |
375 | 399 | // Allow the user to request more than one - why not? |
376 | 400 | $post_ids = is_array($post_ids) ? $post_ids : array($post_ids); |
@@ -405,8 +429,9 @@ discard block |
||
405 | 429 | global $scripturl, $txt, $user_info; |
406 | 430 | global $modSettings, $smcFunc, $context; |
407 | 431 | |
408 | - if (!empty($modSettings['enable_likes'])) |
|
409 | - $context['can_like'] = allowedTo('likes_like'); |
|
432 | + if (!empty($modSettings['enable_likes'])) { |
|
433 | + $context['can_like'] = allowedTo('likes_like'); |
|
434 | + } |
|
410 | 435 | |
411 | 436 | // Find all the posts. Newer ones will have higher IDs. |
412 | 437 | $request = $smcFunc['db_query']('substring', ' |
@@ -472,12 +497,13 @@ discard block |
||
472 | 497 | ); |
473 | 498 | |
474 | 499 | // Get the likes for each message. |
475 | - if (!empty($modSettings['enable_likes'])) |
|
476 | - $posts[$row['id_msg']]['likes'] = array( |
|
500 | + if (!empty($modSettings['enable_likes'])) { |
|
501 | + $posts[$row['id_msg']]['likes'] = array( |
|
477 | 502 | 'count' => $row['likes'], |
478 | 503 | 'you' => in_array($row['id_msg'], prepareLikesContext($row['id_topic'])), |
479 | 504 | 'can_like' => !$context['user']['is_guest'] && $row['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
480 | 505 | ); |
506 | + } |
|
481 | 507 | } |
482 | 508 | $smcFunc['db_free_result']($request); |
483 | 509 | |
@@ -485,13 +511,14 @@ discard block |
||
485 | 511 | call_integration_hook('integrate_ssi_queryPosts', array(&$posts)); |
486 | 512 | |
487 | 513 | // Just return it. |
488 | - if ($output_method != 'echo' || empty($posts)) |
|
489 | - return $posts; |
|
514 | + if ($output_method != 'echo' || empty($posts)) { |
|
515 | + return $posts; |
|
516 | + } |
|
490 | 517 | |
491 | 518 | echo ' |
492 | 519 | <table style="border: none" class="ssi_table">'; |
493 | - foreach ($posts as $post) |
|
494 | - echo ' |
|
520 | + foreach ($posts as $post) { |
|
521 | + echo ' |
|
495 | 522 | <tr> |
496 | 523 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
497 | 524 | [', $post['board']['link'], '] |
@@ -505,6 +532,7 @@ discard block |
||
505 | 532 | ', $post['time'], ' |
506 | 533 | </td> |
507 | 534 | </tr>'; |
535 | + } |
|
508 | 536 | echo ' |
509 | 537 | </table>'; |
510 | 538 | } |
@@ -522,25 +550,26 @@ discard block |
||
522 | 550 | global $settings, $scripturl, $txt, $user_info; |
523 | 551 | global $modSettings, $smcFunc, $context; |
524 | 552 | |
525 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
526 | - $exclude_boards = array($modSettings['recycle_board']); |
|
527 | - else |
|
528 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
553 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
554 | + $exclude_boards = array($modSettings['recycle_board']); |
|
555 | + } else { |
|
556 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
557 | + } |
|
529 | 558 | |
530 | 559 | // Only some boards?. |
531 | 560 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
532 | 561 | { |
533 | 562 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
534 | - } |
|
535 | - elseif ($include_boards != null) |
|
563 | + } elseif ($include_boards != null) |
|
536 | 564 | { |
537 | 565 | $output_method = $include_boards; |
538 | 566 | $include_boards = array(); |
539 | 567 | } |
540 | 568 | |
541 | 569 | $icon_sources = array(); |
542 | - foreach ($context['stable_icons'] as $icon) |
|
543 | - $icon_sources[$icon] = 'images_url'; |
|
570 | + foreach ($context['stable_icons'] as $icon) { |
|
571 | + $icon_sources[$icon] = 'images_url'; |
|
572 | + } |
|
544 | 573 | |
545 | 574 | // Find all the posts in distinct topics. Newer ones will have higher IDs. |
546 | 575 | $request = $smcFunc['db_query']('substring', ' |
@@ -565,13 +594,15 @@ discard block |
||
565 | 594 | ) |
566 | 595 | ); |
567 | 596 | $topics = array(); |
568 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
569 | - $topics[$row['id_topic']] = $row; |
|
597 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
598 | + $topics[$row['id_topic']] = $row; |
|
599 | + } |
|
570 | 600 | $smcFunc['db_free_result']($request); |
571 | 601 | |
572 | 602 | // Did we find anything? If not, bail. |
573 | - if (empty($topics)) |
|
574 | - return array(); |
|
603 | + if (empty($topics)) { |
|
604 | + return array(); |
|
605 | + } |
|
575 | 606 | |
576 | 607 | $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
577 | 608 | |
@@ -599,21 +630,24 @@ discard block |
||
599 | 630 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
600 | 631 | { |
601 | 632 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => ' '))); |
602 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
603 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
633 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
634 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
635 | + } |
|
604 | 636 | |
605 | 637 | // Censor the subject. |
606 | 638 | censorText($row['subject']); |
607 | 639 | censorText($row['body']); |
608 | 640 | |
609 | 641 | // Recycled icon |
610 | - if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) |
|
611 | - $row['icon'] = 'recycled'; |
|
642 | + if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) { |
|
643 | + $row['icon'] = 'recycled'; |
|
644 | + } |
|
612 | 645 | |
613 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
614 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
615 | - elseif (!isset($icon_sources[$row['icon']])) |
|
616 | - $icon_sources[$row['icon']] = 'images_url'; |
|
646 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
647 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
648 | + } elseif (!isset($icon_sources[$row['icon']])) { |
|
649 | + $icon_sources[$row['icon']] = 'images_url'; |
|
650 | + } |
|
617 | 651 | |
618 | 652 | // Build the array. |
619 | 653 | $posts[] = array( |
@@ -652,13 +686,14 @@ discard block |
||
652 | 686 | call_integration_hook('integrate_ssi_recentTopics', array(&$posts)); |
653 | 687 | |
654 | 688 | // Just return it. |
655 | - if ($output_method != 'echo' || empty($posts)) |
|
656 | - return $posts; |
|
689 | + if ($output_method != 'echo' || empty($posts)) { |
|
690 | + return $posts; |
|
691 | + } |
|
657 | 692 | |
658 | 693 | echo ' |
659 | 694 | <table style="border: none" class="ssi_table">'; |
660 | - foreach ($posts as $post) |
|
661 | - echo ' |
|
695 | + foreach ($posts as $post) { |
|
696 | + echo ' |
|
662 | 697 | <tr> |
663 | 698 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
664 | 699 | [', $post['board']['link'], '] |
@@ -672,6 +707,7 @@ discard block |
||
672 | 707 | ', $post['time'], ' |
673 | 708 | </td> |
674 | 709 | </tr>'; |
710 | + } |
|
675 | 711 | echo ' |
676 | 712 | </table>'; |
677 | 713 | } |
@@ -696,27 +732,30 @@ discard block |
||
696 | 732 | ) |
697 | 733 | ); |
698 | 734 | $return = array(); |
699 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
700 | - $return[] = array( |
|
735 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
736 | + $return[] = array( |
|
701 | 737 | 'id' => $row['id_member'], |
702 | 738 | 'name' => $row['real_name'], |
703 | 739 | 'href' => $scripturl . '?action=profile;u=' . $row['id_member'], |
704 | 740 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>', |
705 | 741 | 'posts' => $row['posts'] |
706 | 742 | ); |
743 | + } |
|
707 | 744 | $smcFunc['db_free_result']($request); |
708 | 745 | |
709 | 746 | // If mods want to do somthing with this list of members, let them do that now. |
710 | 747 | call_integration_hook('integrate_ssi_topPoster', array(&$return)); |
711 | 748 | |
712 | 749 | // Just return all the top posters. |
713 | - if ($output_method != 'echo') |
|
714 | - return $return; |
|
750 | + if ($output_method != 'echo') { |
|
751 | + return $return; |
|
752 | + } |
|
715 | 753 | |
716 | 754 | // Make a quick array to list the links in. |
717 | 755 | $temp_array = array(); |
718 | - foreach ($return as $member) |
|
719 | - $temp_array[] = $member['link']; |
|
756 | + foreach ($return as $member) { |
|
757 | + $temp_array[] = $member['link']; |
|
758 | + } |
|
720 | 759 | |
721 | 760 | echo implode(', ', $temp_array); |
722 | 761 | } |
@@ -748,8 +787,8 @@ discard block |
||
748 | 787 | ) |
749 | 788 | ); |
750 | 789 | $boards = array(); |
751 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
752 | - $boards[] = array( |
|
790 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
791 | + $boards[] = array( |
|
753 | 792 | 'id' => $row['id_board'], |
754 | 793 | 'num_posts' => $row['num_posts'], |
755 | 794 | 'num_topics' => $row['num_topics'], |
@@ -758,14 +797,16 @@ discard block |
||
758 | 797 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
759 | 798 | 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>' |
760 | 799 | ); |
800 | + } |
|
761 | 801 | $smcFunc['db_free_result']($request); |
762 | 802 | |
763 | 803 | // If mods want to do somthing with this list of boards, let them do that now. |
764 | 804 | call_integration_hook('integrate_ssi_topBoards', array(&$boards)); |
765 | 805 | |
766 | 806 | // If we shouldn't output or have nothing to output, just jump out. |
767 | - if ($output_method != 'echo' || empty($boards)) |
|
768 | - return $boards; |
|
807 | + if ($output_method != 'echo' || empty($boards)) { |
|
808 | + return $boards; |
|
809 | + } |
|
769 | 810 | |
770 | 811 | echo ' |
771 | 812 | <table class="ssi_table"> |
@@ -774,13 +815,14 @@ discard block |
||
774 | 815 | <th style="text-align: left">', $txt['board_topics'], '</th> |
775 | 816 | <th style="text-align: left">', $txt['posts'], '</th> |
776 | 817 | </tr>'; |
777 | - foreach ($boards as $sBoard) |
|
778 | - echo ' |
|
818 | + foreach ($boards as $sBoard) { |
|
819 | + echo ' |
|
779 | 820 | <tr> |
780 | 821 | <td>', $sBoard['link'], $sBoard['new'] ? ' <a href="' . $sBoard['href'] . '" class="new_posts">' . $txt['new'] . '</a>' : '', '</td> |
781 | 822 | <td style="text-align: right">', comma_format($sBoard['num_topics']), '</td> |
782 | 823 | <td style="text-align: right">', comma_format($sBoard['num_posts']), '</td> |
783 | 824 | </tr>'; |
825 | + } |
|
784 | 826 | echo ' |
785 | 827 | </table>'; |
786 | 828 | } |
@@ -813,12 +855,13 @@ discard block |
||
813 | 855 | ) |
814 | 856 | ); |
815 | 857 | $topic_ids = array(); |
816 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
817 | - $topic_ids[] = $row['id_topic']; |
|
858 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
859 | + $topic_ids[] = $row['id_topic']; |
|
860 | + } |
|
818 | 861 | $smcFunc['db_free_result']($request); |
862 | + } else { |
|
863 | + $topic_ids = array(); |
|
819 | 864 | } |
820 | - else |
|
821 | - $topic_ids = array(); |
|
822 | 865 | |
823 | 866 | $request = $smcFunc['db_query']('', ' |
824 | 867 | SELECT m.subject, m.id_topic, t.num_views, t.num_replies |
@@ -857,8 +900,9 @@ discard block |
||
857 | 900 | // If mods want to do somthing with this list of topics, let them do that now. |
858 | 901 | call_integration_hook('integrate_ssi_topTopics', array(&$topics, $type)); |
859 | 902 | |
860 | - if ($output_method != 'echo' || empty($topics)) |
|
861 | - return $topics; |
|
903 | + if ($output_method != 'echo' || empty($topics)) { |
|
904 | + return $topics; |
|
905 | + } |
|
862 | 906 | |
863 | 907 | echo ' |
864 | 908 | <table class="ssi_table"> |
@@ -867,8 +911,8 @@ discard block |
||
867 | 911 | <th style="text-align: left">', $txt['views'], '</th> |
868 | 912 | <th style="text-align: left">', $txt['replies'], '</th> |
869 | 913 | </tr>'; |
870 | - foreach ($topics as $sTopic) |
|
871 | - echo ' |
|
914 | + foreach ($topics as $sTopic) { |
|
915 | + echo ' |
|
872 | 916 | <tr> |
873 | 917 | <td style="text-align: left"> |
874 | 918 | ', $sTopic['link'], ' |
@@ -876,6 +920,7 @@ discard block |
||
876 | 920 | <td style="text-align: right">', comma_format($sTopic['num_views']), '</td> |
877 | 921 | <td style="text-align: right">', comma_format($sTopic['num_replies']), '</td> |
878 | 922 | </tr>'; |
923 | + } |
|
879 | 924 | echo ' |
880 | 925 | </table>'; |
881 | 926 | } |
@@ -911,12 +956,13 @@ discard block |
||
911 | 956 | { |
912 | 957 | global $txt, $context; |
913 | 958 | |
914 | - if ($output_method == 'echo') |
|
915 | - echo ' |
|
959 | + if ($output_method == 'echo') { |
|
960 | + echo ' |
|
916 | 961 | ', sprintf($txt['welcome_newest_member'], $context['common_stats']['latest_member']['link']), '<br>'; |
917 | - else |
|
918 | - return $context['common_stats']['latest_member']; |
|
919 | -} |
|
962 | + } else { |
|
963 | + return $context['common_stats']['latest_member']; |
|
964 | + } |
|
965 | + } |
|
920 | 966 | |
921 | 967 | /** |
922 | 968 | * Fetches a random member. |
@@ -965,8 +1011,9 @@ discard block |
||
965 | 1011 | } |
966 | 1012 | |
967 | 1013 | // Just to be sure put the random generator back to something... random. |
968 | - if ($random_type != '') |
|
969 | - mt_srand(time()); |
|
1014 | + if ($random_type != '') { |
|
1015 | + mt_srand(time()); |
|
1016 | + } |
|
970 | 1017 | |
971 | 1018 | return $result; |
972 | 1019 | } |
@@ -979,8 +1026,9 @@ discard block |
||
979 | 1026 | */ |
980 | 1027 | function ssi_fetchMember($member_ids = array(), $output_method = 'echo') |
981 | 1028 | { |
982 | - if (empty($member_ids)) |
|
983 | - return; |
|
1029 | + if (empty($member_ids)) { |
|
1030 | + return; |
|
1031 | + } |
|
984 | 1032 | |
985 | 1033 | // Can have more than one member if you really want... |
986 | 1034 | $member_ids = is_array($member_ids) ? $member_ids : array($member_ids); |
@@ -1005,8 +1053,9 @@ discard block |
||
1005 | 1053 | */ |
1006 | 1054 | function ssi_fetchGroupMembers($group_id = null, $output_method = 'echo') |
1007 | 1055 | { |
1008 | - if ($group_id === null) |
|
1009 | - return; |
|
1056 | + if ($group_id === null) { |
|
1057 | + return; |
|
1058 | + } |
|
1010 | 1059 | |
1011 | 1060 | $query_where = ' |
1012 | 1061 | id_group = {int:id_group} |
@@ -1033,8 +1082,9 @@ discard block |
||
1033 | 1082 | { |
1034 | 1083 | global $smcFunc, $memberContext; |
1035 | 1084 | |
1036 | - if ($query_where === null) |
|
1037 | - return; |
|
1085 | + if ($query_where === null) { |
|
1086 | + return; |
|
1087 | + } |
|
1038 | 1088 | |
1039 | 1089 | // Fetch the members in question. |
1040 | 1090 | $request = $smcFunc['db_query']('', ' |
@@ -1047,12 +1097,14 @@ discard block |
||
1047 | 1097 | )) |
1048 | 1098 | ); |
1049 | 1099 | $members = array(); |
1050 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1051 | - $members[] = $row['id_member']; |
|
1100 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1101 | + $members[] = $row['id_member']; |
|
1102 | + } |
|
1052 | 1103 | $smcFunc['db_free_result']($request); |
1053 | 1104 | |
1054 | - if (empty($members)) |
|
1055 | - return array(); |
|
1105 | + if (empty($members)) { |
|
1106 | + return array(); |
|
1107 | + } |
|
1056 | 1108 | |
1057 | 1109 | // If mods want to do somthing with this list of members, let them do that now. |
1058 | 1110 | call_integration_hook('integrate_ssi_queryMembers', array(&$members)); |
@@ -1061,23 +1113,25 @@ discard block |
||
1061 | 1113 | loadMemberData($members); |
1062 | 1114 | |
1063 | 1115 | // Draw the table! |
1064 | - if ($output_method == 'echo') |
|
1065 | - echo ' |
|
1116 | + if ($output_method == 'echo') { |
|
1117 | + echo ' |
|
1066 | 1118 | <table style="border: none" class="ssi_table">'; |
1119 | + } |
|
1067 | 1120 | |
1068 | 1121 | $query_members = array(); |
1069 | 1122 | foreach ($members as $member) |
1070 | 1123 | { |
1071 | 1124 | // Load their context data. |
1072 | - if (!loadMemberContext($member)) |
|
1073 | - continue; |
|
1125 | + if (!loadMemberContext($member)) { |
|
1126 | + continue; |
|
1127 | + } |
|
1074 | 1128 | |
1075 | 1129 | // Store this member's information. |
1076 | 1130 | $query_members[$member] = $memberContext[$member]; |
1077 | 1131 | |
1078 | 1132 | // Only do something if we're echo'ing. |
1079 | - if ($output_method == 'echo') |
|
1080 | - echo ' |
|
1133 | + if ($output_method == 'echo') { |
|
1134 | + echo ' |
|
1081 | 1135 | <tr> |
1082 | 1136 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
1083 | 1137 | ', $query_members[$member]['link'], ' |
@@ -1085,12 +1139,14 @@ discard block |
||
1085 | 1139 | <br>', $query_members[$member]['avatar']['image'], ' |
1086 | 1140 | </td> |
1087 | 1141 | </tr>'; |
1142 | + } |
|
1088 | 1143 | } |
1089 | 1144 | |
1090 | 1145 | // End the table if appropriate. |
1091 | - if ($output_method == 'echo') |
|
1092 | - echo ' |
|
1146 | + if ($output_method == 'echo') { |
|
1147 | + echo ' |
|
1093 | 1148 | </table>'; |
1149 | + } |
|
1094 | 1150 | |
1095 | 1151 | // Send back the data. |
1096 | 1152 | return $query_members; |
@@ -1105,8 +1161,9 @@ discard block |
||
1105 | 1161 | { |
1106 | 1162 | global $txt, $scripturl, $modSettings, $smcFunc; |
1107 | 1163 | |
1108 | - if (!allowedTo('view_stats')) |
|
1109 | - return; |
|
1164 | + if (!allowedTo('view_stats')) { |
|
1165 | + return; |
|
1166 | + } |
|
1110 | 1167 | |
1111 | 1168 | $totals = array( |
1112 | 1169 | 'members' => $modSettings['totalMembers'], |
@@ -1135,8 +1192,9 @@ discard block |
||
1135 | 1192 | // If mods want to do somthing with the board stats, let them do that now. |
1136 | 1193 | call_integration_hook('integrate_ssi_boardStats', array(&$totals)); |
1137 | 1194 | |
1138 | - if ($output_method != 'echo') |
|
1139 | - return $totals; |
|
1195 | + if ($output_method != 'echo') { |
|
1196 | + return $totals; |
|
1197 | + } |
|
1140 | 1198 | |
1141 | 1199 | echo ' |
1142 | 1200 | ', $txt['total_members'], ': <a href="', $scripturl . '?action=mlist">', comma_format($totals['members']), '</a><br> |
@@ -1165,8 +1223,8 @@ discard block |
||
1165 | 1223 | call_integration_hook('integrate_ssi_whosOnline', array(&$return)); |
1166 | 1224 | |
1167 | 1225 | // Add some redundancy for backwards compatibility reasons. |
1168 | - if ($output_method != 'echo') |
|
1169 | - return $return + array( |
|
1226 | + if ($output_method != 'echo') { |
|
1227 | + return $return + array( |
|
1170 | 1228 | 'users' => $return['users_online'], |
1171 | 1229 | 'guests' => $return['num_guests'], |
1172 | 1230 | 'hidden' => $return['num_users_hidden'], |
@@ -1174,29 +1232,35 @@ discard block |
||
1174 | 1232 | 'num_users' => $return['num_users_online'], |
1175 | 1233 | 'total_users' => $return['num_users_online'] + $return['num_guests'], |
1176 | 1234 | ); |
1235 | + } |
|
1177 | 1236 | |
1178 | 1237 | echo ' |
1179 | 1238 | ', comma_format($return['num_guests']), ' ', $return['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', comma_format($return['num_users_online']), ' ', $return['num_users_online'] == 1 ? $txt['user'] : $txt['users']; |
1180 | 1239 | |
1181 | 1240 | $bracketList = array(); |
1182 | - if (!empty($user_info['buddies'])) |
|
1183 | - $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
1184 | - if (!empty($return['num_spiders'])) |
|
1185 | - $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
1186 | - if (!empty($return['num_users_hidden'])) |
|
1187 | - $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
1241 | + if (!empty($user_info['buddies'])) { |
|
1242 | + $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
1243 | + } |
|
1244 | + if (!empty($return['num_spiders'])) { |
|
1245 | + $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
1246 | + } |
|
1247 | + if (!empty($return['num_users_hidden'])) { |
|
1248 | + $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
1249 | + } |
|
1188 | 1250 | |
1189 | - if (!empty($bracketList)) |
|
1190 | - echo ' (' . implode(', ', $bracketList) . ')'; |
|
1251 | + if (!empty($bracketList)) { |
|
1252 | + echo ' (' . implode(', ', $bracketList) . ')'; |
|
1253 | + } |
|
1191 | 1254 | |
1192 | 1255 | echo '<br> |
1193 | 1256 | ', implode(', ', $return['list_users_online']); |
1194 | 1257 | |
1195 | 1258 | // Showing membergroups? |
1196 | - if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) |
|
1197 | - echo '<br> |
|
1259 | + if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) { |
|
1260 | + echo '<br> |
|
1198 | 1261 | [' . implode('] [', $return['membergroups']) . ']'; |
1199 | -} |
|
1262 | + } |
|
1263 | + } |
|
1200 | 1264 | |
1201 | 1265 | /** |
1202 | 1266 | * Just like whosOnline except it also logs the online presence. |
@@ -1207,11 +1271,12 @@ discard block |
||
1207 | 1271 | { |
1208 | 1272 | writeLog(); |
1209 | 1273 | |
1210 | - if ($output_method != 'echo') |
|
1211 | - return ssi_whosOnline($output_method); |
|
1212 | - else |
|
1213 | - ssi_whosOnline($output_method); |
|
1214 | -} |
|
1274 | + if ($output_method != 'echo') { |
|
1275 | + return ssi_whosOnline($output_method); |
|
1276 | + } else { |
|
1277 | + ssi_whosOnline($output_method); |
|
1278 | + } |
|
1279 | + } |
|
1215 | 1280 | |
1216 | 1281 | // Shows a login box. |
1217 | 1282 | /** |
@@ -1224,11 +1289,13 @@ discard block |
||
1224 | 1289 | { |
1225 | 1290 | global $scripturl, $txt, $user_info, $context; |
1226 | 1291 | |
1227 | - if ($redirect_to != '') |
|
1228 | - $_SESSION['login_url'] = $redirect_to; |
|
1292 | + if ($redirect_to != '') { |
|
1293 | + $_SESSION['login_url'] = $redirect_to; |
|
1294 | + } |
|
1229 | 1295 | |
1230 | - if ($output_method != 'echo' || !$user_info['is_guest']) |
|
1231 | - return $user_info['is_guest']; |
|
1296 | + if ($output_method != 'echo' || !$user_info['is_guest']) { |
|
1297 | + return $user_info['is_guest']; |
|
1298 | + } |
|
1232 | 1299 | |
1233 | 1300 | // Create a login token |
1234 | 1301 | createToken('login'); |
@@ -1280,8 +1347,9 @@ discard block |
||
1280 | 1347 | |
1281 | 1348 | $boardsAllowed = array_intersect(boardsAllowedTo('poll_view'), boardsAllowedTo('poll_vote')); |
1282 | 1349 | |
1283 | - if (empty($boardsAllowed)) |
|
1284 | - return array(); |
|
1350 | + if (empty($boardsAllowed)) { |
|
1351 | + return array(); |
|
1352 | + } |
|
1285 | 1353 | |
1286 | 1354 | $request = $smcFunc['db_query']('', ' |
1287 | 1355 | SELECT p.id_poll, p.question, t.id_topic, p.max_votes, p.guest_vote, p.hide_results, p.expire_time |
@@ -1314,12 +1382,14 @@ discard block |
||
1314 | 1382 | $smcFunc['db_free_result']($request); |
1315 | 1383 | |
1316 | 1384 | // This user has voted on all the polls. |
1317 | - if (empty($row) || !is_array($row)) |
|
1318 | - return array(); |
|
1385 | + if (empty($row) || !is_array($row)) { |
|
1386 | + return array(); |
|
1387 | + } |
|
1319 | 1388 | |
1320 | 1389 | // If this is a guest who's voted we'll through ourselves to show poll to show the results. |
1321 | - if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) |
|
1322 | - return ssi_showPoll($row['id_topic'], $output_method); |
|
1390 | + if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) { |
|
1391 | + return ssi_showPoll($row['id_topic'], $output_method); |
|
1392 | + } |
|
1323 | 1393 | |
1324 | 1394 | $request = $smcFunc['db_query']('', ' |
1325 | 1395 | SELECT COUNT(DISTINCT id_member) |
@@ -1383,8 +1453,9 @@ discard block |
||
1383 | 1453 | // If mods want to do somthing with this list of polls, let them do that now. |
1384 | 1454 | call_integration_hook('integrate_ssi_recentPoll', array(&$return, $topPollInstead)); |
1385 | 1455 | |
1386 | - if ($output_method != 'echo') |
|
1387 | - return $return; |
|
1456 | + if ($output_method != 'echo') { |
|
1457 | + return $return; |
|
1458 | + } |
|
1388 | 1459 | |
1389 | 1460 | if ($allow_view_results) |
1390 | 1461 | { |
@@ -1393,19 +1464,20 @@ discard block |
||
1393 | 1464 | <strong>', $return['question'], '</strong><br> |
1394 | 1465 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
1395 | 1466 | |
1396 | - foreach ($return['options'] as $option) |
|
1397 | - echo ' |
|
1467 | + foreach ($return['options'] as $option) { |
|
1468 | + echo ' |
|
1398 | 1469 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
1470 | + } |
|
1399 | 1471 | |
1400 | 1472 | echo ' |
1401 | 1473 | <input type="submit" value="', $txt['poll_vote'], '" class="button"> |
1402 | 1474 | <input type="hidden" name="poll" value="', $return['id'], '"> |
1403 | 1475 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1404 | 1476 | </form>'; |
1477 | + } else { |
|
1478 | + echo $txt['poll_cannot_see']; |
|
1479 | + } |
|
1405 | 1480 | } |
1406 | - else |
|
1407 | - echo $txt['poll_cannot_see']; |
|
1408 | -} |
|
1409 | 1481 | |
1410 | 1482 | /** |
1411 | 1483 | * Shows the poll from the specified topic |
@@ -1419,13 +1491,15 @@ discard block |
||
1419 | 1491 | |
1420 | 1492 | $boardsAllowed = boardsAllowedTo('poll_view'); |
1421 | 1493 | |
1422 | - if (empty($boardsAllowed)) |
|
1423 | - return array(); |
|
1494 | + if (empty($boardsAllowed)) { |
|
1495 | + return array(); |
|
1496 | + } |
|
1424 | 1497 | |
1425 | - if ($topic === null && isset($_REQUEST['ssi_topic'])) |
|
1426 | - $topic = (int) $_REQUEST['ssi_topic']; |
|
1427 | - else |
|
1428 | - $topic = (int) $topic; |
|
1498 | + if ($topic === null && isset($_REQUEST['ssi_topic'])) { |
|
1499 | + $topic = (int) $_REQUEST['ssi_topic']; |
|
1500 | + } else { |
|
1501 | + $topic = (int) $topic; |
|
1502 | + } |
|
1429 | 1503 | |
1430 | 1504 | $request = $smcFunc['db_query']('', ' |
1431 | 1505 | SELECT |
@@ -1446,17 +1520,18 @@ discard block |
||
1446 | 1520 | ); |
1447 | 1521 | |
1448 | 1522 | // Either this topic has no poll, or the user cannot view it. |
1449 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1450 | - return array(); |
|
1523 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1524 | + return array(); |
|
1525 | + } |
|
1451 | 1526 | |
1452 | 1527 | $row = $smcFunc['db_fetch_assoc']($request); |
1453 | 1528 | $smcFunc['db_free_result']($request); |
1454 | 1529 | |
1455 | 1530 | // Check if they can vote. |
1456 | 1531 | $already_voted = false; |
1457 | - if (!empty($row['expire_time']) && $row['expire_time'] < time()) |
|
1458 | - $allow_vote = false; |
|
1459 | - elseif ($user_info['is_guest']) |
|
1532 | + if (!empty($row['expire_time']) && $row['expire_time'] < time()) { |
|
1533 | + $allow_vote = false; |
|
1534 | + } elseif ($user_info['is_guest']) |
|
1460 | 1535 | { |
1461 | 1536 | // There's a difference between "allowed to vote" and "already voted"... |
1462 | 1537 | $allow_vote = $row['guest_vote']; |
@@ -1466,10 +1541,9 @@ discard block |
||
1466 | 1541 | { |
1467 | 1542 | $already_voted = true; |
1468 | 1543 | } |
1469 | - } |
|
1470 | - elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) |
|
1471 | - $allow_vote = false; |
|
1472 | - else |
|
1544 | + } elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) { |
|
1545 | + $allow_vote = false; |
|
1546 | + } else |
|
1473 | 1547 | { |
1474 | 1548 | $request = $smcFunc['db_query']('', ' |
1475 | 1549 | SELECT id_member |
@@ -1551,8 +1625,9 @@ discard block |
||
1551 | 1625 | // If mods want to do somthing with this poll, let them do that now. |
1552 | 1626 | call_integration_hook('integrate_ssi_showPoll', array(&$return)); |
1553 | 1627 | |
1554 | - if ($output_method != 'echo') |
|
1555 | - return $return; |
|
1628 | + if ($output_method != 'echo') { |
|
1629 | + return $return; |
|
1630 | + } |
|
1556 | 1631 | |
1557 | 1632 | if ($return['allow_vote']) |
1558 | 1633 | { |
@@ -1561,17 +1636,17 @@ discard block |
||
1561 | 1636 | <strong>', $return['question'], '</strong><br> |
1562 | 1637 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
1563 | 1638 | |
1564 | - foreach ($return['options'] as $option) |
|
1565 | - echo ' |
|
1639 | + foreach ($return['options'] as $option) { |
|
1640 | + echo ' |
|
1566 | 1641 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
1642 | + } |
|
1567 | 1643 | |
1568 | 1644 | echo ' |
1569 | 1645 | <input type="submit" value="', $txt['poll_vote'], '" class="button"> |
1570 | 1646 | <input type="hidden" name="poll" value="', $return['id'], '"> |
1571 | 1647 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1572 | 1648 | </form>'; |
1573 | - } |
|
1574 | - else |
|
1649 | + } else |
|
1575 | 1650 | { |
1576 | 1651 | echo ' |
1577 | 1652 | <div class="ssi_poll"> |
@@ -1651,27 +1726,32 @@ discard block |
||
1651 | 1726 | 'is_approved' => 1, |
1652 | 1727 | ) |
1653 | 1728 | ); |
1654 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1655 | - die; |
|
1729 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1730 | + die; |
|
1731 | + } |
|
1656 | 1732 | $row = $smcFunc['db_fetch_assoc']($request); |
1657 | 1733 | $smcFunc['db_free_result']($request); |
1658 | 1734 | |
1659 | - if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) |
|
1660 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1735 | + if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) { |
|
1736 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1737 | + } |
|
1661 | 1738 | |
1662 | 1739 | // Too many options checked? |
1663 | - if (count($_REQUEST['options']) > $row['max_votes']) |
|
1664 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1740 | + if (count($_REQUEST['options']) > $row['max_votes']) { |
|
1741 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1742 | + } |
|
1665 | 1743 | |
1666 | 1744 | // It's a guest who has already voted? |
1667 | 1745 | if ($user_info['is_guest']) |
1668 | 1746 | { |
1669 | 1747 | // Guest voting disabled? |
1670 | - if (!$row['guest_vote']) |
|
1671 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1748 | + if (!$row['guest_vote']) { |
|
1749 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1750 | + } |
|
1672 | 1751 | // Already voted? |
1673 | - elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) |
|
1674 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1752 | + elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) { |
|
1753 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1754 | + } |
|
1675 | 1755 | } |
1676 | 1756 | |
1677 | 1757 | $sOptions = array(); |
@@ -1725,11 +1805,13 @@ discard block |
||
1725 | 1805 | { |
1726 | 1806 | global $scripturl, $txt, $context; |
1727 | 1807 | |
1728 | - if (!allowedTo('search_posts')) |
|
1729 | - return; |
|
1808 | + if (!allowedTo('search_posts')) { |
|
1809 | + return; |
|
1810 | + } |
|
1730 | 1811 | |
1731 | - if ($output_method != 'echo') |
|
1732 | - return $scripturl . '?action=search'; |
|
1812 | + if ($output_method != 'echo') { |
|
1813 | + return $scripturl . '?action=search'; |
|
1814 | + } |
|
1733 | 1815 | |
1734 | 1816 | echo ' |
1735 | 1817 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '"> |
@@ -1751,8 +1833,9 @@ discard block |
||
1751 | 1833 | // If mods want to do somthing with the news, let them do that now. Don't need to pass the news line itself, since it is already in $context. |
1752 | 1834 | call_integration_hook('integrate_ssi_news'); |
1753 | 1835 | |
1754 | - if ($output_method != 'echo') |
|
1755 | - return $context['random_news_line']; |
|
1836 | + if ($output_method != 'echo') { |
|
1837 | + return $context['random_news_line']; |
|
1838 | + } |
|
1756 | 1839 | |
1757 | 1840 | echo $context['random_news_line']; |
1758 | 1841 | } |
@@ -1766,8 +1849,9 @@ discard block |
||
1766 | 1849 | { |
1767 | 1850 | global $scripturl, $modSettings, $user_info; |
1768 | 1851 | |
1769 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) |
|
1770 | - return; |
|
1852 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) { |
|
1853 | + return; |
|
1854 | + } |
|
1771 | 1855 | |
1772 | 1856 | $eventOptions = array( |
1773 | 1857 | 'include_birthdays' => true, |
@@ -1778,13 +1862,15 @@ discard block |
||
1778 | 1862 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1779 | 1863 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1780 | 1864 | |
1781 | - if ($output_method != 'echo') |
|
1782 | - return $return['calendar_birthdays']; |
|
1865 | + if ($output_method != 'echo') { |
|
1866 | + return $return['calendar_birthdays']; |
|
1867 | + } |
|
1783 | 1868 | |
1784 | - foreach ($return['calendar_birthdays'] as $member) |
|
1785 | - echo ' |
|
1869 | + foreach ($return['calendar_birthdays'] as $member) { |
|
1870 | + echo ' |
|
1786 | 1871 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">' . $member['name'] . '</span>' . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>' . (!$member['is_last'] ? ', ' : ''); |
1787 | -} |
|
1872 | + } |
|
1873 | + } |
|
1788 | 1874 | |
1789 | 1875 | /** |
1790 | 1876 | * Shows today's holidays. |
@@ -1795,8 +1881,9 @@ discard block |
||
1795 | 1881 | { |
1796 | 1882 | global $modSettings, $user_info; |
1797 | 1883 | |
1798 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
1799 | - return; |
|
1884 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
1885 | + return; |
|
1886 | + } |
|
1800 | 1887 | |
1801 | 1888 | $eventOptions = array( |
1802 | 1889 | 'include_holidays' => true, |
@@ -1807,8 +1894,9 @@ discard block |
||
1807 | 1894 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1808 | 1895 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1809 | 1896 | |
1810 | - if ($output_method != 'echo') |
|
1811 | - return $return['calendar_holidays']; |
|
1897 | + if ($output_method != 'echo') { |
|
1898 | + return $return['calendar_holidays']; |
|
1899 | + } |
|
1812 | 1900 | |
1813 | 1901 | echo ' |
1814 | 1902 | ', implode(', ', $return['calendar_holidays']); |
@@ -1822,8 +1910,9 @@ discard block |
||
1822 | 1910 | { |
1823 | 1911 | global $modSettings, $user_info; |
1824 | 1912 | |
1825 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
1826 | - return; |
|
1913 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
1914 | + return; |
|
1915 | + } |
|
1827 | 1916 | |
1828 | 1917 | $eventOptions = array( |
1829 | 1918 | 'include_events' => true, |
@@ -1834,14 +1923,16 @@ discard block |
||
1834 | 1923 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1835 | 1924 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1836 | 1925 | |
1837 | - if ($output_method != 'echo') |
|
1838 | - return $return['calendar_events']; |
|
1926 | + if ($output_method != 'echo') { |
|
1927 | + return $return['calendar_events']; |
|
1928 | + } |
|
1839 | 1929 | |
1840 | 1930 | foreach ($return['calendar_events'] as $event) |
1841 | 1931 | { |
1842 | - if ($event['can_edit']) |
|
1843 | - echo ' |
|
1932 | + if ($event['can_edit']) { |
|
1933 | + echo ' |
|
1844 | 1934 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
1935 | + } |
|
1845 | 1936 | echo ' |
1846 | 1937 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
1847 | 1938 | } |
@@ -1856,8 +1947,9 @@ discard block |
||
1856 | 1947 | { |
1857 | 1948 | global $modSettings, $txt, $scripturl, $user_info; |
1858 | 1949 | |
1859 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
1860 | - return; |
|
1950 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
1951 | + return; |
|
1952 | + } |
|
1861 | 1953 | |
1862 | 1954 | $eventOptions = array( |
1863 | 1955 | 'include_birthdays' => allowedTo('profile_view'), |
@@ -1870,19 +1962,22 @@ discard block |
||
1870 | 1962 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1871 | 1963 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1872 | 1964 | |
1873 | - if ($output_method != 'echo') |
|
1874 | - return $return; |
|
1965 | + if ($output_method != 'echo') { |
|
1966 | + return $return; |
|
1967 | + } |
|
1875 | 1968 | |
1876 | - if (!empty($return['calendar_holidays'])) |
|
1877 | - echo ' |
|
1969 | + if (!empty($return['calendar_holidays'])) { |
|
1970 | + echo ' |
|
1878 | 1971 | <span class="holiday">' . $txt['calendar_prompt'] . ' ' . implode(', ', $return['calendar_holidays']) . '<br></span>'; |
1972 | + } |
|
1879 | 1973 | if (!empty($return['calendar_birthdays'])) |
1880 | 1974 | { |
1881 | 1975 | echo ' |
1882 | 1976 | <span class="birthday">' . $txt['birthdays_upcoming'] . '</span> '; |
1883 | - foreach ($return['calendar_birthdays'] as $member) |
|
1884 | - echo ' |
|
1977 | + foreach ($return['calendar_birthdays'] as $member) { |
|
1978 | + echo ' |
|
1885 | 1979 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', !$member['is_last'] ? ', ' : ''; |
1980 | + } |
|
1886 | 1981 | echo ' |
1887 | 1982 | <br>'; |
1888 | 1983 | } |
@@ -1892,9 +1987,10 @@ discard block |
||
1892 | 1987 | <span class="event">' . $txt['events_upcoming'] . '</span> '; |
1893 | 1988 | foreach ($return['calendar_events'] as $event) |
1894 | 1989 | { |
1895 | - if ($event['can_edit']) |
|
1896 | - echo ' |
|
1990 | + if ($event['can_edit']) { |
|
1991 | + echo ' |
|
1897 | 1992 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
1993 | + } |
|
1898 | 1994 | echo ' |
1899 | 1995 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
1900 | 1996 | } |
@@ -1918,25 +2014,29 @@ discard block |
||
1918 | 2014 | loadLanguage('Stats'); |
1919 | 2015 | |
1920 | 2016 | // Must be integers.... |
1921 | - if ($limit === null) |
|
1922 | - $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
1923 | - else |
|
1924 | - $limit = (int) $limit; |
|
1925 | - |
|
1926 | - if ($start === null) |
|
1927 | - $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
1928 | - else |
|
1929 | - $start = (int) $start; |
|
1930 | - |
|
1931 | - if ($board !== null) |
|
1932 | - $board = (int) $board; |
|
1933 | - elseif (isset($_GET['board'])) |
|
1934 | - $board = (int) $_GET['board']; |
|
1935 | - |
|
1936 | - if ($length === null) |
|
1937 | - $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
1938 | - else |
|
1939 | - $length = (int) $length; |
|
2017 | + if ($limit === null) { |
|
2018 | + $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
2019 | + } else { |
|
2020 | + $limit = (int) $limit; |
|
2021 | + } |
|
2022 | + |
|
2023 | + if ($start === null) { |
|
2024 | + $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
2025 | + } else { |
|
2026 | + $start = (int) $start; |
|
2027 | + } |
|
2028 | + |
|
2029 | + if ($board !== null) { |
|
2030 | + $board = (int) $board; |
|
2031 | + } elseif (isset($_GET['board'])) { |
|
2032 | + $board = (int) $_GET['board']; |
|
2033 | + } |
|
2034 | + |
|
2035 | + if ($length === null) { |
|
2036 | + $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
2037 | + } else { |
|
2038 | + $length = (int) $length; |
|
2039 | + } |
|
1940 | 2040 | |
1941 | 2041 | $limit = max(0, $limit); |
1942 | 2042 | $start = max(0, $start); |
@@ -1954,17 +2054,19 @@ discard block |
||
1954 | 2054 | ); |
1955 | 2055 | if ($smcFunc['db_num_rows']($request) == 0) |
1956 | 2056 | { |
1957 | - if ($output_method == 'echo') |
|
1958 | - die($txt['ssi_no_guests']); |
|
1959 | - else |
|
1960 | - return array(); |
|
2057 | + if ($output_method == 'echo') { |
|
2058 | + die($txt['ssi_no_guests']); |
|
2059 | + } else { |
|
2060 | + return array(); |
|
2061 | + } |
|
1961 | 2062 | } |
1962 | 2063 | list ($board) = $smcFunc['db_fetch_row']($request); |
1963 | 2064 | $smcFunc['db_free_result']($request); |
1964 | 2065 | |
1965 | 2066 | $icon_sources = array(); |
1966 | - foreach ($context['stable_icons'] as $icon) |
|
1967 | - $icon_sources[$icon] = 'images_url'; |
|
2067 | + foreach ($context['stable_icons'] as $icon) { |
|
2068 | + $icon_sources[$icon] = 'images_url'; |
|
2069 | + } |
|
1968 | 2070 | |
1969 | 2071 | if (!empty($modSettings['enable_likes'])) |
1970 | 2072 | { |
@@ -1987,12 +2089,14 @@ discard block |
||
1987 | 2089 | ) |
1988 | 2090 | ); |
1989 | 2091 | $posts = array(); |
1990 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1991 | - $posts[] = $row['id_first_msg']; |
|
2092 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2093 | + $posts[] = $row['id_first_msg']; |
|
2094 | + } |
|
1992 | 2095 | $smcFunc['db_free_result']($request); |
1993 | 2096 | |
1994 | - if (empty($posts)) |
|
1995 | - return array(); |
|
2097 | + if (empty($posts)) { |
|
2098 | + return array(); |
|
2099 | + } |
|
1996 | 2100 | |
1997 | 2101 | // Find the posts. |
1998 | 2102 | $request = $smcFunc['db_query']('', ' |
@@ -2022,26 +2126,30 @@ discard block |
||
2022 | 2126 | $last_space = strrpos($row['body'], ' '); |
2023 | 2127 | $last_open = strrpos($row['body'], '<'); |
2024 | 2128 | $last_close = strrpos($row['body'], '>'); |
2025 | - if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) |
|
2026 | - $cutoff = $last_open; |
|
2027 | - elseif (empty($last_close) || $last_close < $last_open) |
|
2028 | - $cutoff = $last_space; |
|
2129 | + if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) { |
|
2130 | + $cutoff = $last_open; |
|
2131 | + } elseif (empty($last_close) || $last_close < $last_open) { |
|
2132 | + $cutoff = $last_space; |
|
2133 | + } |
|
2029 | 2134 | |
2030 | - if ($cutoff !== false) |
|
2031 | - $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
2135 | + if ($cutoff !== false) { |
|
2136 | + $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
2137 | + } |
|
2032 | 2138 | $row['body'] .= '...'; |
2033 | 2139 | } |
2034 | 2140 | |
2035 | 2141 | $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); |
2036 | 2142 | |
2037 | - if (!empty($recycle_board) && $row['id_board'] == $recycle_board) |
|
2038 | - $row['icon'] = 'recycled'; |
|
2143 | + if (!empty($recycle_board) && $row['id_board'] == $recycle_board) { |
|
2144 | + $row['icon'] = 'recycled'; |
|
2145 | + } |
|
2039 | 2146 | |
2040 | 2147 | // Check that this message icon is there... |
2041 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
2042 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2043 | - elseif (!isset($icon_sources[$row['icon']])) |
|
2044 | - $icon_sources[$row['icon']] = 'images_url'; |
|
2148 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
2149 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2150 | + } elseif (!isset($icon_sources[$row['icon']])) { |
|
2151 | + $icon_sources[$row['icon']] = 'images_url'; |
|
2152 | + } |
|
2045 | 2153 | |
2046 | 2154 | censorText($row['subject']); |
2047 | 2155 | censorText($row['body']); |
@@ -2078,16 +2186,18 @@ discard block |
||
2078 | 2186 | } |
2079 | 2187 | $smcFunc['db_free_result']($request); |
2080 | 2188 | |
2081 | - if (empty($return)) |
|
2082 | - return $return; |
|
2189 | + if (empty($return)) { |
|
2190 | + return $return; |
|
2191 | + } |
|
2083 | 2192 | |
2084 | 2193 | $return[count($return) - 1]['is_last'] = true; |
2085 | 2194 | |
2086 | 2195 | // If mods want to do somthing with this list of posts, let them do that now. |
2087 | 2196 | call_integration_hook('integrate_ssi_boardNews', array(&$return)); |
2088 | 2197 | |
2089 | - if ($output_method != 'echo') |
|
2090 | - return $return; |
|
2198 | + if ($output_method != 'echo') { |
|
2199 | + return $return; |
|
2200 | + } |
|
2091 | 2201 | |
2092 | 2202 | foreach ($return as $news) |
2093 | 2203 | { |
@@ -2139,9 +2249,10 @@ discard block |
||
2139 | 2249 | echo ' |
2140 | 2250 | </div>'; |
2141 | 2251 | |
2142 | - if (!$news['is_last']) |
|
2143 | - echo ' |
|
2252 | + if (!$news['is_last']) { |
|
2253 | + echo ' |
|
2144 | 2254 | <hr>'; |
2255 | + } |
|
2145 | 2256 | } |
2146 | 2257 | } |
2147 | 2258 | |
@@ -2155,8 +2266,9 @@ discard block |
||
2155 | 2266 | { |
2156 | 2267 | global $user_info, $scripturl, $modSettings, $txt, $context, $smcFunc; |
2157 | 2268 | |
2158 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
2159 | - return; |
|
2269 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
2270 | + return; |
|
2271 | + } |
|
2160 | 2272 | |
2161 | 2273 | // Find all events which are happening in the near future that the member can see. |
2162 | 2274 | $request = $smcFunc['db_query']('', ' |
@@ -2182,20 +2294,23 @@ discard block |
||
2182 | 2294 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2183 | 2295 | { |
2184 | 2296 | // Check if we've already come by an event linked to this same topic with the same title... and don't display it if we have. |
2185 | - if (!empty($duplicates[$row['title'] . $row['id_topic']])) |
|
2186 | - continue; |
|
2297 | + if (!empty($duplicates[$row['title'] . $row['id_topic']])) { |
|
2298 | + continue; |
|
2299 | + } |
|
2187 | 2300 | |
2188 | 2301 | // Censor the title. |
2189 | 2302 | censorText($row['title']); |
2190 | 2303 | |
2191 | - if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) |
|
2192 | - $date = strftime('%Y-%m-%d', forum_time(false)); |
|
2193 | - else |
|
2194 | - $date = $row['start_date']; |
|
2304 | + if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) { |
|
2305 | + $date = strftime('%Y-%m-%d', forum_time(false)); |
|
2306 | + } else { |
|
2307 | + $date = $row['start_date']; |
|
2308 | + } |
|
2195 | 2309 | |
2196 | 2310 | // If the topic it is attached to is not approved then don't link it. |
2197 | - if (!empty($row['id_first_msg']) && !$row['approved']) |
|
2198 | - $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
2311 | + if (!empty($row['id_first_msg']) && !$row['approved']) { |
|
2312 | + $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
2313 | + } |
|
2199 | 2314 | |
2200 | 2315 | $allday = (empty($row['start_time']) || empty($row['end_time']) || empty($row['timezone']) || !in_array($row['timezone'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) ? true : false; |
2201 | 2316 | |
@@ -2221,24 +2336,27 @@ discard block |
||
2221 | 2336 | } |
2222 | 2337 | $smcFunc['db_free_result']($request); |
2223 | 2338 | |
2224 | - foreach ($return as $mday => $array) |
|
2225 | - $return[$mday][count($array) - 1]['is_last'] = true; |
|
2339 | + foreach ($return as $mday => $array) { |
|
2340 | + $return[$mday][count($array) - 1]['is_last'] = true; |
|
2341 | + } |
|
2226 | 2342 | |
2227 | 2343 | // If mods want to do somthing with this list of events, let them do that now. |
2228 | 2344 | call_integration_hook('integrate_ssi_recentEvents', array(&$return)); |
2229 | 2345 | |
2230 | - if ($output_method != 'echo' || empty($return)) |
|
2231 | - return $return; |
|
2346 | + if ($output_method != 'echo' || empty($return)) { |
|
2347 | + return $return; |
|
2348 | + } |
|
2232 | 2349 | |
2233 | 2350 | // Well the output method is echo. |
2234 | 2351 | echo ' |
2235 | 2352 | <span class="event">' . $txt['events'] . '</span> '; |
2236 | - foreach ($return as $mday => $array) |
|
2237 | - foreach ($array as $event) |
|
2353 | + foreach ($return as $mday => $array) { |
|
2354 | + foreach ($array as $event) |
|
2238 | 2355 | { |
2239 | 2356 | if ($event['can_edit']) |
2240 | 2357 | echo ' |
2241 | 2358 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
2359 | + } |
|
2242 | 2360 | |
2243 | 2361 | echo ' |
2244 | 2362 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
@@ -2257,8 +2375,9 @@ discard block |
||
2257 | 2375 | global $smcFunc; |
2258 | 2376 | |
2259 | 2377 | // If $id is null, this was most likely called from a query string and should do nothing. |
2260 | - if ($id === null) |
|
2261 | - return; |
|
2378 | + if ($id === null) { |
|
2379 | + return; |
|
2380 | + } |
|
2262 | 2381 | |
2263 | 2382 | $request = $smcFunc['db_query']('', ' |
2264 | 2383 | SELECT passwd, member_name, is_activated |
@@ -2290,8 +2409,9 @@ discard block |
||
2290 | 2409 | $attachments_boards = boardsAllowedTo('view_attachments'); |
2291 | 2410 | |
2292 | 2411 | // No boards? Adios amigo. |
2293 | - if (empty($attachments_boards)) |
|
2294 | - return array(); |
|
2412 | + if (empty($attachments_boards)) { |
|
2413 | + return array(); |
|
2414 | + } |
|
2295 | 2415 | |
2296 | 2416 | // Is it an array? |
2297 | 2417 | $attachment_ext = (array) $attachment_ext; |
@@ -2375,8 +2495,9 @@ discard block |
||
2375 | 2495 | call_integration_hook('integrate_ssi_recentAttachments', array(&$attachments)); |
2376 | 2496 | |
2377 | 2497 | // So you just want an array? Here you can have it. |
2378 | - if ($output_method == 'array' || empty($attachments)) |
|
2379 | - return $attachments; |
|
2498 | + if ($output_method == 'array' || empty($attachments)) { |
|
2499 | + return $attachments; |
|
2500 | + } |
|
2380 | 2501 | |
2381 | 2502 | // Give them the default. |
2382 | 2503 | echo ' |
@@ -2387,14 +2508,15 @@ discard block |
||
2387 | 2508 | <th style="text-align: left; padding: 2">', $txt['downloads'], '</th> |
2388 | 2509 | <th style="text-align: left; padding: 2">', $txt['filesize'], '</th> |
2389 | 2510 | </tr>'; |
2390 | - foreach ($attachments as $attach) |
|
2391 | - echo ' |
|
2511 | + foreach ($attachments as $attach) { |
|
2512 | + echo ' |
|
2392 | 2513 | <tr> |
2393 | 2514 | <td>', $attach['file']['link'], '</td> |
2394 | 2515 | <td>', $attach['member']['link'], '</td> |
2395 | 2516 | <td style="text-align: center">', $attach['file']['downloads'], '</td> |
2396 | 2517 | <td>', $attach['file']['filesize'], '</td> |
2397 | 2518 | </tr>'; |
2519 | + } |
|
2398 | 2520 | echo ' |
2399 | 2521 | </table>'; |
2400 | 2522 | } |