|
@@ -14,8 +14,9 @@ discard block |
|
|
block discarded – undo |
|
14
|
14
|
* @version 2.1 Beta 3 |
|
15
|
15
|
*/ |
|
16
|
16
|
|
|
17
|
|
-if (!defined('SMF')) |
|
|
17
|
+if (!defined('SMF')) { |
|
18
|
18
|
die('No direct access...'); |
|
|
19
|
+} |
|
19
|
20
|
|
|
20
|
21
|
/** |
|
21
|
22
|
* The central part of the board - topic display. |
|
@@ -34,8 +35,9 @@ discard block |
|
|
block discarded – undo |
|
34
|
35
|
global $messages_request, $language, $smcFunc; |
|
35
|
36
|
|
|
36
|
37
|
// What are you gonna display if these are empty?! |
|
37
|
|
- if (empty($topic)) |
|
38
|
|
- fatal_lang_error('no_board', false); |
|
|
38
|
+ if (empty($topic)) { |
|
|
39
|
+ fatal_lang_error('no_board', false); |
|
|
40
|
+ } |
|
39
|
41
|
|
|
40
|
42
|
// Load the proper template. |
|
41
|
43
|
loadTemplate('Display'); |
|
@@ -52,15 +54,17 @@ discard block |
|
|
block discarded – undo |
|
52
|
54
|
$context['messages_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
53
|
55
|
|
|
54
|
56
|
// Let's do some work on what to search index. |
|
55
|
|
- if (count($_GET) > 2) |
|
56
|
|
- foreach ($_GET as $k => $v) |
|
|
57
|
+ if (count($_GET) > 2) { |
|
|
58
|
+ foreach ($_GET as $k => $v) |
|
57
|
59
|
{ |
|
58
|
60
|
if (!in_array($k, array('topic', 'board', 'start', session_name()))) |
|
59
|
61
|
$context['robot_no_index'] = true; |
|
|
62
|
+ } |
|
60
|
63
|
} |
|
61
|
64
|
|
|
62
|
|
- if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
63
|
|
- $context['robot_no_index'] = true; |
|
|
65
|
+ if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
|
66
|
+ $context['robot_no_index'] = true; |
|
|
67
|
+ } |
|
64
|
68
|
|
|
65
|
69
|
// Find the previous or next topic. Make a fuss if there are no more. |
|
66
|
70
|
if (isset($_REQUEST['prev_next']) && ($_REQUEST['prev_next'] == 'prev' || $_REQUEST['prev_next'] == 'next')) |
|
@@ -172,8 +176,9 @@ discard block |
|
|
block discarded – undo |
|
172
|
176
|
$topic_parameters |
|
173
|
177
|
); |
|
174
|
178
|
|
|
175
|
|
- if ($smcFunc['db_num_rows']($request) == 0) |
|
176
|
|
- fatal_lang_error('not_a_topic', false, 404); |
|
|
179
|
+ if ($smcFunc['db_num_rows']($request) == 0) { |
|
|
180
|
+ fatal_lang_error('not_a_topic', false, 404); |
|
|
181
|
+ } |
|
177
|
182
|
$context['topicinfo'] = $smcFunc['db_fetch_assoc']($request); |
|
178
|
183
|
$smcFunc['db_free_result']($request); |
|
179
|
184
|
|
|
@@ -210,8 +215,9 @@ discard block |
|
|
block discarded – undo |
|
210
|
215
|
$context['topic_unwatched'] = isset($context['topicinfo']['unwatched']) ? $context['topicinfo']['unwatched'] : 0; |
|
211
|
216
|
|
|
212
|
217
|
// Add up unapproved replies to get real number of replies... |
|
213
|
|
- if ($modSettings['postmod_active'] && $approve_posts) |
|
214
|
|
- $context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1); |
|
|
218
|
+ if ($modSettings['postmod_active'] && $approve_posts) { |
|
|
219
|
+ $context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1); |
|
|
220
|
+ } |
|
215
|
221
|
|
|
216
|
222
|
// If this topic has unapproved posts, we need to work out how many posts the user can see, for page indexing. |
|
217
|
223
|
if ($modSettings['postmod_active'] && $context['topicinfo']['unapproved_posts'] && !$user_info['is_guest'] && !$approve_posts) |
|
@@ -231,11 +237,11 @@ discard block |
|
|
block discarded – undo |
|
231
|
237
|
$smcFunc['db_free_result']($request); |
|
232
|
238
|
|
|
233
|
239
|
$context['total_visible_posts'] = $context['num_replies'] + $myUnapprovedPosts + ($context['topicinfo']['approved'] ? 1 : 0); |
|
|
240
|
+ } elseif ($user_info['is_guest']) { |
|
|
241
|
+ $context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
|
242
|
+ } else { |
|
|
243
|
+ $context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
234
|
244
|
} |
|
235
|
|
- elseif ($user_info['is_guest']) |
|
236
|
|
- $context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
237
|
|
- else |
|
238
|
|
- $context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
239
|
245
|
|
|
240
|
246
|
// The start isn't a number; it's information about what to do, where to go. |
|
241
|
247
|
if (!is_numeric($_REQUEST['start'])) |
|
@@ -248,8 +254,7 @@ discard block |
|
|
block discarded – undo |
|
248
|
254
|
{ |
|
249
|
255
|
$context['start_from'] = $context['total_visible_posts'] - 1; |
|
250
|
256
|
$_REQUEST['start'] = empty($options['view_newest_first']) ? $context['start_from'] : 0; |
|
251
|
|
- } |
|
252
|
|
- else |
|
|
257
|
+ } else |
|
253
|
258
|
{ |
|
254
|
259
|
// Find the earliest unread message in the topic. (the use of topics here is just for both tables.) |
|
255
|
260
|
$request = $smcFunc['db_query']('', ' |
|
@@ -277,9 +282,9 @@ discard block |
|
|
block discarded – undo |
|
277
|
282
|
if (substr($_REQUEST['start'], 0, 4) == 'from') |
|
278
|
283
|
{ |
|
279
|
284
|
$timestamp = (int) substr($_REQUEST['start'], 4); |
|
280
|
|
- if ($timestamp === 0) |
|
281
|
|
- $_REQUEST['start'] = 0; |
|
282
|
|
- else |
|
|
285
|
+ if ($timestamp === 0) { |
|
|
286
|
+ $_REQUEST['start'] = 0; |
|
|
287
|
+ } else |
|
283
|
288
|
{ |
|
284
|
289
|
// Find the number of messages posted before said time... |
|
285
|
290
|
$request = $smcFunc['db_query']('', ' |
|
@@ -307,11 +312,11 @@ discard block |
|
|
block discarded – undo |
|
307
|
312
|
elseif (substr($_REQUEST['start'], 0, 3) == 'msg') |
|
308
|
313
|
{ |
|
309
|
314
|
$virtual_msg = (int) substr($_REQUEST['start'], 3); |
|
310
|
|
- if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) |
|
311
|
|
- $context['start_from'] = $context['total_visible_posts'] - 1; |
|
312
|
|
- elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) |
|
313
|
|
- $context['start_from'] = 0; |
|
314
|
|
- else |
|
|
315
|
+ if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) { |
|
|
316
|
+ $context['start_from'] = $context['total_visible_posts'] - 1; |
|
|
317
|
+ } elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) { |
|
|
318
|
+ $context['start_from'] = 0; |
|
|
319
|
+ } else |
|
315
|
320
|
{ |
|
316
|
321
|
// Find the start value for that message...... |
|
317
|
322
|
$request = $smcFunc['db_query']('', ' |
|
@@ -394,21 +399,25 @@ discard block |
|
|
block discarded – undo |
|
394
|
399
|
); |
|
395
|
400
|
while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
396
|
401
|
{ |
|
397
|
|
- if (empty($row['id_member'])) |
|
398
|
|
- continue; |
|
|
402
|
+ if (empty($row['id_member'])) { |
|
|
403
|
+ continue; |
|
|
404
|
+ } |
|
399
|
405
|
|
|
400
|
|
- if (!empty($row['online_color'])) |
|
401
|
|
- $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
402
|
|
- else |
|
403
|
|
- $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
|
406
|
+ if (!empty($row['online_color'])) { |
|
|
407
|
+ $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
|
408
|
+ } else { |
|
|
409
|
+ $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
|
410
|
+ } |
|
404
|
411
|
|
|
405
|
412
|
$is_buddy = in_array($row['id_member'], $user_info['buddies']); |
|
406
|
|
- if ($is_buddy) |
|
407
|
|
- $link = '<strong>' . $link . '</strong>'; |
|
|
413
|
+ if ($is_buddy) { |
|
|
414
|
+ $link = '<strong>' . $link . '</strong>'; |
|
|
415
|
+ } |
|
408
|
416
|
|
|
409
|
417
|
// Add them both to the list and to the more detailed list. |
|
410
|
|
- if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
411
|
|
- $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
|
418
|
+ if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
|
419
|
+ $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
|
420
|
+ } |
|
412
|
421
|
$context['view_members'][$row['log_time'] . $row['member_name']] = array( |
|
413
|
422
|
'id' => $row['id_member'], |
|
414
|
423
|
'username' => $row['member_name'], |
|
@@ -420,8 +429,9 @@ discard block |
|
|
block discarded – undo |
|
420
|
429
|
'hidden' => empty($row['show_online']), |
|
421
|
430
|
); |
|
422
|
431
|
|
|
423
|
|
- if (empty($row['show_online'])) |
|
424
|
|
- $context['view_num_hidden']++; |
|
|
432
|
+ if (empty($row['show_online'])) { |
|
|
433
|
+ $context['view_num_hidden']++; |
|
|
434
|
+ } |
|
425
|
435
|
} |
|
426
|
436
|
|
|
427
|
437
|
// The number of guests is equal to the rows minus the ones we actually used ;). |
|
@@ -435,11 +445,13 @@ discard block |
|
|
block discarded – undo |
|
435
|
445
|
|
|
436
|
446
|
// If all is set, but not allowed... just unset it. |
|
437
|
447
|
$can_show_all = !empty($modSettings['enableAllMessages']) && $context['total_visible_posts'] > $context['messages_per_page'] && $context['total_visible_posts'] < $modSettings['enableAllMessages']; |
|
438
|
|
- if (isset($_REQUEST['all']) && !$can_show_all) |
|
439
|
|
- unset($_REQUEST['all']); |
|
|
448
|
+ if (isset($_REQUEST['all']) && !$can_show_all) { |
|
|
449
|
+ unset($_REQUEST['all']); |
|
|
450
|
+ } |
|
440
|
451
|
// Otherwise, it must be allowed... so pretend start was -1. |
|
441
|
|
- elseif (isset($_REQUEST['all'])) |
|
442
|
|
- $_REQUEST['start'] = -1; |
|
|
452
|
+ elseif (isset($_REQUEST['all'])) { |
|
|
453
|
+ $_REQUEST['start'] = -1; |
|
|
454
|
+ } |
|
443
|
455
|
|
|
444
|
456
|
// Construct the page index, allowing for the .START method... |
|
445
|
457
|
$context['page_index'] = constructPageIndex($scripturl . '?topic=' . $topic . '.%1$d', $_REQUEST['start'], $context['total_visible_posts'], $context['messages_per_page'], true); |
|
@@ -476,8 +488,9 @@ discard block |
|
|
block discarded – undo |
|
476
|
488
|
$_REQUEST['start'] = 0; |
|
477
|
489
|
} |
|
478
|
490
|
// They aren't using it, but the *option* is there, at least. |
|
479
|
|
- else |
|
480
|
|
- $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
|
491
|
+ else { |
|
|
492
|
+ $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
|
493
|
+ } |
|
481
|
494
|
} |
|
482
|
495
|
|
|
483
|
496
|
// Build the link tree. |
|
@@ -493,14 +506,16 @@ discard block |
|
|
block discarded – undo |
|
493
|
506
|
if (!empty($board_info['moderators'])) |
|
494
|
507
|
{ |
|
495
|
508
|
// Add a link for each moderator... |
|
496
|
|
- foreach ($board_info['moderators'] as $mod) |
|
497
|
|
- $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
|
509
|
+ foreach ($board_info['moderators'] as $mod) { |
|
|
510
|
+ $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
|
511
|
+ } |
|
498
|
512
|
} |
|
499
|
513
|
if (!empty($board_info['moderator_groups'])) |
|
500
|
514
|
{ |
|
501
|
515
|
// Add a link for each moderator group as well... |
|
502
|
|
- foreach ($board_info['moderator_groups'] as $mod_group) |
|
503
|
|
- $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
|
516
|
+ foreach ($board_info['moderator_groups'] as $mod_group) { |
|
|
517
|
+ $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
|
518
|
+ } |
|
504
|
519
|
} |
|
505
|
520
|
|
|
506
|
521
|
if (!empty($context['link_moderators'])) |
|
@@ -531,9 +546,9 @@ discard block |
|
|
block discarded – undo |
|
531
|
546
|
// For quick reply we need a response prefix in the default forum language. |
|
532
|
547
|
if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix', 600))) |
|
533
|
548
|
{ |
|
534
|
|
- if ($language === $user_info['language']) |
|
535
|
|
- $context['response_prefix'] = $txt['response_prefix']; |
|
536
|
|
- else |
|
|
549
|
+ if ($language === $user_info['language']) { |
|
|
550
|
+ $context['response_prefix'] = $txt['response_prefix']; |
|
|
551
|
+ } else |
|
537
|
552
|
{ |
|
538
|
553
|
loadLanguage('index', $language, false); |
|
539
|
554
|
$context['response_prefix'] = $txt['response_prefix']; |
|
@@ -565,8 +580,9 @@ discard block |
|
|
block discarded – undo |
|
565
|
580
|
list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
|
566
|
581
|
|
|
567
|
582
|
// Sanity check |
|
568
|
|
- if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
569
|
|
- continue; |
|
|
583
|
+ if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
|
584
|
+ continue; |
|
|
585
|
+ } |
|
570
|
586
|
|
|
571
|
587
|
$linked_calendar_event = array( |
|
572
|
588
|
'id' => $row['id_event'], |
|
@@ -615,8 +631,9 @@ discard block |
|
|
block discarded – undo |
|
615
|
631
|
} |
|
616
|
632
|
$smcFunc['db_free_result']($request); |
|
617
|
633
|
|
|
618
|
|
- if (!empty($context['linked_calendar_events'])) |
|
619
|
|
- $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
|
634
|
+ if (!empty($context['linked_calendar_events'])) { |
|
|
635
|
+ $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
|
636
|
+ } |
|
620
|
637
|
} |
|
621
|
638
|
|
|
622
|
639
|
// Create the poll info if it exists. |
|
@@ -679,8 +696,9 @@ discard block |
|
|
block discarded – undo |
|
679
|
696
|
$smcFunc['db_free_result']($request); |
|
680
|
697
|
|
|
681
|
698
|
// Got we multi choice? |
|
682
|
|
- if ($pollinfo['max_votes'] > 1) |
|
683
|
|
- $realtotal = $pollinfo['total']; |
|
|
699
|
+ if ($pollinfo['max_votes'] > 1) { |
|
|
700
|
+ $realtotal = $pollinfo['total']; |
|
|
701
|
+ } |
|
684
|
702
|
|
|
685
|
703
|
// If this is a guest we need to do our best to work out if they have voted, and what they voted for. |
|
686
|
704
|
if ($user_info['is_guest'] && $pollinfo['guest_vote'] && allowedTo('poll_vote')) |
|
@@ -693,20 +711,21 @@ discard block |
|
|
block discarded – undo |
|
693
|
711
|
foreach ($guestinfo as $i => $guestvoted) |
|
694
|
712
|
{ |
|
695
|
713
|
$guestvoted = explode(',', $guestvoted); |
|
696
|
|
- if ($guestvoted[0] == $context['topicinfo']['id_poll']) |
|
697
|
|
- break; |
|
|
714
|
+ if ($guestvoted[0] == $context['topicinfo']['id_poll']) { |
|
|
715
|
+ break; |
|
|
716
|
+ } |
|
698
|
717
|
} |
|
699
|
718
|
// Has the poll been reset since guest voted? |
|
700
|
719
|
if ($pollinfo['reset_poll'] > $guestvoted[1]) |
|
701
|
720
|
{ |
|
702
|
721
|
// Remove the poll info from the cookie to allow guest to vote again |
|
703
|
722
|
unset($guestinfo[$i]); |
|
704
|
|
- if (!empty($guestinfo)) |
|
705
|
|
- $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
706
|
|
- else |
|
707
|
|
- unset($_COOKIE['guest_poll_vote']); |
|
708
|
|
- } |
|
709
|
|
- else |
|
|
723
|
+ if (!empty($guestinfo)) { |
|
|
724
|
+ $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
|
725
|
+ } else { |
|
|
726
|
+ unset($_COOKIE['guest_poll_vote']); |
|
|
727
|
+ } |
|
|
728
|
+ } else |
|
710
|
729
|
{ |
|
711
|
730
|
// What did they vote for? |
|
712
|
731
|
unset($guestvoted[0], $guestvoted[1]); |
|
@@ -820,23 +839,29 @@ discard block |
|
|
block discarded – undo |
|
820
|
839
|
// Build the poll moderation button array. |
|
821
|
840
|
$context['poll_buttons'] = array(); |
|
822
|
841
|
|
|
823
|
|
- if ($context['allow_return_vote']) |
|
824
|
|
- $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
|
842
|
+ if ($context['allow_return_vote']) { |
|
|
843
|
+ $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
|
844
|
+ } |
|
825
|
845
|
|
|
826
|
|
- if ($context['show_view_results_button']) |
|
827
|
|
- $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
|
846
|
+ if ($context['show_view_results_button']) { |
|
|
847
|
+ $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
|
848
|
+ } |
|
828
|
849
|
|
|
829
|
|
- if ($context['allow_change_vote']) |
|
830
|
|
- $context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
|
850
|
+ if ($context['allow_change_vote']) { |
|
|
851
|
+ $context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
|
852
|
+ } |
|
831
|
853
|
|
|
832
|
|
- if ($context['allow_lock_poll']) |
|
833
|
|
- $context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
|
854
|
+ if ($context['allow_lock_poll']) { |
|
|
855
|
+ $context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
|
856
|
+ } |
|
834
|
857
|
|
|
835
|
|
- if ($context['allow_edit_poll']) |
|
836
|
|
- $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
|
858
|
+ if ($context['allow_edit_poll']) { |
|
|
859
|
+ $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
|
860
|
+ } |
|
837
|
861
|
|
|
838
|
|
- if ($context['can_remove_poll']) |
|
839
|
|
- $context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
|
862
|
+ if ($context['can_remove_poll']) { |
|
|
863
|
+ $context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
|
864
|
+ } |
|
840
|
865
|
|
|
841
|
866
|
// Allow mods to add additional buttons here |
|
842
|
867
|
call_integration_hook('integrate_poll_buttons'); |
|
@@ -877,8 +902,9 @@ discard block |
|
|
block discarded – undo |
|
877
|
902
|
$all_posters = array(); |
|
878
|
903
|
while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
879
|
904
|
{ |
|
880
|
|
- if (!empty($row['id_member'])) |
|
881
|
|
- $all_posters[$row['id_msg']] = $row['id_member']; |
|
|
905
|
+ if (!empty($row['id_member'])) { |
|
|
906
|
+ $all_posters[$row['id_msg']] = $row['id_member']; |
|
|
907
|
+ } |
|
882
|
908
|
$messages[] = $row['id_msg']; |
|
883
|
909
|
} |
|
884
|
910
|
$smcFunc['db_free_result']($request); |
|
@@ -890,8 +916,9 @@ discard block |
|
|
block discarded – undo |
|
890
|
916
|
if (!$user_info['is_guest'] && !empty($messages)) |
|
891
|
917
|
{ |
|
892
|
918
|
$mark_at_msg = max($messages); |
|
893
|
|
- if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) |
|
894
|
|
- $mark_at_msg = $modSettings['maxMsgID']; |
|
|
919
|
+ if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) { |
|
|
920
|
+ $mark_at_msg = $modSettings['maxMsgID']; |
|
|
921
|
+ } |
|
895
|
922
|
if ($mark_at_msg >= $context['topicinfo']['new_from']) |
|
896
|
923
|
{ |
|
897
|
924
|
$smcFunc['db_insert']($context['topicinfo']['new_from'] == 0 ? 'ignore' : 'replace', |
|
@@ -923,8 +950,9 @@ discard block |
|
|
block discarded – undo |
|
923
|
950
|
while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
924
|
951
|
{ |
|
925
|
952
|
// Find if this topic is marked for notification... |
|
926
|
|
- if (!empty($row['id_topic'])) |
|
927
|
|
- $context['is_marked_notify'] = true; |
|
|
953
|
+ if (!empty($row['id_topic'])) { |
|
|
954
|
+ $context['is_marked_notify'] = true; |
|
|
955
|
+ } |
|
928
|
956
|
|
|
929
|
957
|
// Only do this once, but mark the notifications as "not sent yet" for next time. |
|
930
|
958
|
if (!empty($row['sent']) && $do_once) |
|
@@ -946,8 +974,9 @@ discard block |
|
|
block discarded – undo |
|
946
|
974
|
} |
|
947
|
975
|
|
|
948
|
976
|
// Have we recently cached the number of new topics in this board, and it's still a lot? |
|
949
|
|
- if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) |
|
950
|
|
- $_SESSION['topicseen_cache'][$board]--; |
|
|
977
|
+ if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) { |
|
|
978
|
+ $_SESSION['topicseen_cache'][$board]--; |
|
|
979
|
+ } |
|
951
|
980
|
// Mark board as seen if this is the only new topic. |
|
952
|
981
|
elseif (isset($_REQUEST['topicseen'])) |
|
953
|
982
|
{ |
|
@@ -971,14 +1000,16 @@ discard block |
|
|
block discarded – undo |
|
971
|
1000
|
$smcFunc['db_free_result']($request); |
|
972
|
1001
|
|
|
973
|
1002
|
// If there're no real new topics in this board, mark the board as seen. |
|
974
|
|
- if (empty($numNewTopics)) |
|
975
|
|
- $_REQUEST['boardseen'] = true; |
|
976
|
|
- else |
|
977
|
|
- $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
|
1003
|
+ if (empty($numNewTopics)) { |
|
|
1004
|
+ $_REQUEST['boardseen'] = true; |
|
|
1005
|
+ } else { |
|
|
1006
|
+ $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
|
1007
|
+ } |
|
978
|
1008
|
} |
|
979
|
1009
|
// Probably one less topic - maybe not, but even if we decrease this too fast it will only make us look more often. |
|
980
|
|
- elseif (isset($_SESSION['topicseen_cache'][$board])) |
|
981
|
|
- $_SESSION['topicseen_cache'][$board]--; |
|
|
1010
|
+ elseif (isset($_SESSION['topicseen_cache'][$board])) { |
|
|
1011
|
+ $_SESSION['topicseen_cache'][$board]--; |
|
|
1012
|
+ } |
|
982
|
1013
|
|
|
983
|
1014
|
// Mark board as seen if we came using last post link from BoardIndex. (or other places...) |
|
984
|
1015
|
if (isset($_REQUEST['boardseen'])) |
|
@@ -1035,23 +1066,26 @@ discard block |
|
|
block discarded – undo |
|
1035
|
1066
|
$temp = array(); |
|
1036
|
1067
|
while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1037
|
1068
|
{ |
|
1038
|
|
- if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) |
|
1039
|
|
- continue; |
|
|
1069
|
+ if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) { |
|
|
1070
|
+ continue; |
|
|
1071
|
+ } |
|
1040
|
1072
|
|
|
1041
|
1073
|
$temp[$row['id_attach']] = $row; |
|
1042
|
1074
|
$temp[$row['id_attach']]['topic'] = $topic; |
|
1043
|
1075
|
$temp[$row['id_attach']]['board'] = $board; |
|
1044
|
1076
|
|
|
1045
|
|
- if (!isset($context['loaded_attachments'][$row['id_msg']])) |
|
1046
|
|
- $context['loaded_attachments'][$row['id_msg']] = array(); |
|
|
1077
|
+ if (!isset($context['loaded_attachments'][$row['id_msg']])) { |
|
|
1078
|
+ $context['loaded_attachments'][$row['id_msg']] = array(); |
|
|
1079
|
+ } |
|
1047
|
1080
|
} |
|
1048
|
1081
|
$smcFunc['db_free_result']($request); |
|
1049
|
1082
|
|
|
1050
|
1083
|
// This is better than sorting it with the query... |
|
1051
|
1084
|
ksort($temp); |
|
1052
|
1085
|
|
|
1053
|
|
- foreach ($temp as $row) |
|
1054
|
|
- $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
|
1086
|
+ foreach ($temp as $row) { |
|
|
1087
|
+ $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
|
1088
|
+ } |
|
1055
|
1089
|
} |
|
1056
|
1090
|
|
|
1057
|
1091
|
$msg_parameters = array( |
|
@@ -1078,21 +1112,23 @@ discard block |
|
|
block discarded – undo |
|
1078
|
1112
|
); |
|
1079
|
1113
|
|
|
1080
|
1114
|
// And the likes |
|
1081
|
|
- if (!empty($modSettings['enable_likes'])) |
|
1082
|
|
- $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
|
1115
|
+ if (!empty($modSettings['enable_likes'])) { |
|
|
1116
|
+ $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
|
1117
|
+ } |
|
1083
|
1118
|
|
|
1084
|
1119
|
// Go to the last message if the given time is beyond the time of the last message. |
|
1085
|
|
- if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) |
|
1086
|
|
- $context['start_from'] = $context['topicinfo']['num_replies']; |
|
|
1120
|
+ if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) { |
|
|
1121
|
+ $context['start_from'] = $context['topicinfo']['num_replies']; |
|
|
1122
|
+ } |
|
1087
|
1123
|
|
|
1088
|
1124
|
// Since the anchor information is needed on the top of the page we load these variables beforehand. |
|
1089
|
1125
|
$context['first_message'] = isset($messages[$firstIndex]) ? $messages[$firstIndex] : $messages[0]; |
|
1090
|
|
- if (empty($options['view_newest_first'])) |
|
1091
|
|
- $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
1092
|
|
- else |
|
1093
|
|
- $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
1094
|
|
- } |
|
1095
|
|
- else |
|
|
1126
|
+ if (empty($options['view_newest_first'])) { |
|
|
1127
|
+ $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
|
1128
|
+ } else { |
|
|
1129
|
+ $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
|
1130
|
+ } |
|
|
1131
|
+ } else |
|
1096
|
1132
|
{ |
|
1097
|
1133
|
$messages_request = false; |
|
1098
|
1134
|
$context['first_message'] = 0; |
|
@@ -1128,8 +1164,9 @@ discard block |
|
|
block discarded – undo |
|
1128
|
1164
|
'can_see_likes' => 'likes_view', |
|
1129
|
1165
|
'can_like' => 'likes_like', |
|
1130
|
1166
|
); |
|
1131
|
|
- foreach ($common_permissions as $contextual => $perm) |
|
1132
|
|
- $context[$contextual] = allowedTo($perm); |
|
|
1167
|
+ foreach ($common_permissions as $contextual => $perm) { |
|
|
1168
|
+ $context[$contextual] = allowedTo($perm); |
|
|
1169
|
+ } |
|
1133
|
1170
|
|
|
1134
|
1171
|
// Permissions with _any/_own versions. $context[YYY] => ZZZ_any/_own. |
|
1135
|
1172
|
$anyown_permissions = array( |
|
@@ -1142,8 +1179,9 @@ discard block |
|
|
block discarded – undo |
|
1142
|
1179
|
'can_reply_unapproved' => 'post_unapproved_replies', |
|
1143
|
1180
|
'can_view_warning' => 'profile_warning', |
|
1144
|
1181
|
); |
|
1145
|
|
- foreach ($anyown_permissions as $contextual => $perm) |
|
1146
|
|
- $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
|
1182
|
+ foreach ($anyown_permissions as $contextual => $perm) { |
|
|
1183
|
+ $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
|
1184
|
+ } |
|
1147
|
1185
|
|
|
1148
|
1186
|
if (!$user_info['is_admin'] && !$modSettings['topic_move_any']) |
|
1149
|
1187
|
{ |
|
@@ -1189,8 +1227,9 @@ discard block |
|
|
block discarded – undo |
|
1189
|
1227
|
// Check if the draft functions are enabled and that they have permission to use them (for quick reply.) |
|
1190
|
1228
|
$context['drafts_save'] = !empty($modSettings['drafts_post_enabled']) && allowedTo('post_draft') && $context['can_reply']; |
|
1191
|
1229
|
$context['drafts_autosave'] = !empty($context['drafts_save']) && !empty($modSettings['drafts_autosave_enabled']); |
|
1192
|
|
- if (!empty($context['drafts_save'])) |
|
1193
|
|
- loadLanguage('Drafts'); |
|
|
1230
|
+ if (!empty($context['drafts_save'])) { |
|
|
1231
|
+ loadLanguage('Drafts'); |
|
|
1232
|
+ } |
|
1194
|
1233
|
|
|
1195
|
1234
|
// When was the last time this topic was replied to? Should we warn them about it? |
|
1196
|
1235
|
if (!empty($modSettings['oldTopicDays']) && ($context['can_reply'] || $context['can_reply_unapproved']) && empty($context['topicinfo']['is_sticky'])) |
|
@@ -1251,26 +1290,31 @@ discard block |
|
|
block discarded – undo |
|
1251
|
1290
|
// Message icons - customized icons are off? |
|
1252
|
1291
|
$context['icons'] = getMessageIcons($board); |
|
1253
|
1292
|
|
|
1254
|
|
- if (!empty($context['icons'])) |
|
1255
|
|
- $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
|
1293
|
+ if (!empty($context['icons'])) { |
|
|
1294
|
+ $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
|
1295
|
+ } |
|
1256
|
1296
|
|
|
1257
|
1297
|
// Build the normal button array. |
|
1258
|
1298
|
$context['normal_buttons'] = array(); |
|
1259
|
1299
|
|
|
1260
|
|
- if ($context['can_reply']) |
|
1261
|
|
- $context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true); |
|
|
1300
|
+ if ($context['can_reply']) { |
|
|
1301
|
+ $context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true); |
|
|
1302
|
+ } |
|
1262
|
1303
|
|
|
1263
|
|
- if ($context['can_add_poll']) |
|
1264
|
|
- $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
|
1304
|
+ if ($context['can_add_poll']) { |
|
|
1305
|
+ $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
|
1306
|
+ } |
|
1265
|
1307
|
|
|
1266
|
|
- if ($context['can_mark_unread']) |
|
1267
|
|
- $context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
|
1308
|
+ if ($context['can_mark_unread']) { |
|
|
1309
|
+ $context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
|
1310
|
+ } |
|
1268
|
1311
|
|
|
1269
|
|
- if ($context['can_print']) |
|
1270
|
|
- $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
|
1312
|
+ if ($context['can_print']) { |
|
|
1313
|
+ $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
|
1314
|
+ } |
|
1271
|
1315
|
|
|
1272
|
|
- if ($context['can_set_notify']) |
|
1273
|
|
- $context['normal_buttons']['notify'] = array( |
|
|
1316
|
+ if ($context['can_set_notify']) { |
|
|
1317
|
+ $context['normal_buttons']['notify'] = array( |
|
1274
|
1318
|
'text' => 'notify_topic_' . $context['topic_notification_mode'], |
|
1275
|
1319
|
'sub_buttons' => array( |
|
1276
|
1320
|
array( |
|
@@ -1292,38 +1336,47 @@ discard block |
|
|
block discarded – undo |
|
1292
|
1336
|
), |
|
1293
|
1337
|
), |
|
1294
|
1338
|
); |
|
|
1339
|
+ } |
|
1295
|
1340
|
|
|
1296
|
1341
|
// Build the mod button array |
|
1297
|
1342
|
$context['mod_buttons'] = array(); |
|
1298
|
1343
|
|
|
1299
|
|
- if ($context['can_move']) |
|
1300
|
|
- $context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'); |
|
|
1344
|
+ if ($context['can_move']) { |
|
|
1345
|
+ $context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'); |
|
|
1346
|
+ } |
|
1301
|
1347
|
|
|
1302
|
|
- if ($context['can_delete']) |
|
1303
|
|
- $context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
|
1348
|
+ if ($context['can_delete']) { |
|
|
1349
|
+ $context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
|
1350
|
+ } |
|
1304
|
1351
|
|
|
1305
|
|
- if ($context['can_lock']) |
|
1306
|
|
- $context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
|
1352
|
+ if ($context['can_lock']) { |
|
|
1353
|
+ $context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
|
1354
|
+ } |
|
1307
|
1355
|
|
|
1308
|
|
- if ($context['can_sticky']) |
|
1309
|
|
- $context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
|
1356
|
+ if ($context['can_sticky']) { |
|
|
1357
|
+ $context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
|
1358
|
+ } |
|
1310
|
1359
|
|
|
1311
|
|
- if ($context['can_merge']) |
|
1312
|
|
- $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
|
1360
|
+ if ($context['can_merge']) { |
|
|
1361
|
+ $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
|
1362
|
+ } |
|
1313
|
1363
|
|
|
1314
|
|
- if ($context['calendar_post']) |
|
1315
|
|
- $context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'); |
|
|
1364
|
+ if ($context['calendar_post']) { |
|
|
1365
|
+ $context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'); |
|
|
1366
|
+ } |
|
1316
|
1367
|
|
|
1317
|
1368
|
// Restore topic. eh? No monkey business. |
|
1318
|
|
- if ($context['can_restore_topic']) |
|
1319
|
|
- $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
|
1369
|
+ if ($context['can_restore_topic']) { |
|
|
1370
|
+ $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
|
1371
|
+ } |
|
1320
|
1372
|
|
|
1321
|
1373
|
// Show a message in case a recently posted message became unapproved. |
|
1322
|
1374
|
$context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
|
1323
|
1375
|
|
|
1324
|
1376
|
// Don't want to show this forever... |
|
1325
|
|
- if ($context['becomesUnapproved']) |
|
1326
|
|
- unset($_SESSION['becomesUnapproved']); |
|
|
1377
|
+ if ($context['becomesUnapproved']) { |
|
|
1378
|
+ unset($_SESSION['becomesUnapproved']); |
|
|
1379
|
+ } |
|
1327
|
1380
|
|
|
1328
|
1381
|
// Allow adding new mod buttons easily. |
|
1329
|
1382
|
// Note: $context['normal_buttons'] and $context['mod_buttons'] are added for backward compatibility with 2.0, but are deprecated and should not be used |
|
@@ -1332,12 +1385,14 @@ discard block |
|
|
block discarded – undo |
|
1332
|
1385
|
call_integration_hook('integrate_mod_buttons', array(&$context['mod_buttons'])); |
|
1333
|
1386
|
|
|
1334
|
1387
|
// Load the drafts js file |
|
1335
|
|
- if ($context['drafts_autosave']) |
|
1336
|
|
- loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts'); |
|
|
1388
|
+ if ($context['drafts_autosave']) { |
|
|
1389
|
+ loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts'); |
|
|
1390
|
+ } |
|
1337
|
1391
|
|
|
1338
|
1392
|
// Spellcheck |
|
1339
|
|
- if ($context['show_spellchecking']) |
|
1340
|
|
- loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
|
1393
|
+ if ($context['show_spellchecking']) { |
|
|
1394
|
+ loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
|
1395
|
+ } |
|
1341
|
1396
|
|
|
1342
|
1397
|
// topic.js |
|
1343
|
1398
|
loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic'); |
|
@@ -1371,16 +1426,19 @@ discard block |
|
|
block discarded – undo |
|
1371
|
1426
|
static $counter = null; |
|
1372
|
1427
|
|
|
1373
|
1428
|
// If the query returned false, bail. |
|
1374
|
|
- if ($messages_request == false) |
|
1375
|
|
- return false; |
|
|
1429
|
+ if ($messages_request == false) { |
|
|
1430
|
+ return false; |
|
|
1431
|
+ } |
|
1376
|
1432
|
|
|
1377
|
1433
|
// Remember which message this is. (ie. reply #83) |
|
1378
|
|
- if ($counter === null || $reset) |
|
1379
|
|
- $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
|
1434
|
+ if ($counter === null || $reset) { |
|
|
1435
|
+ $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
|
1436
|
+ } |
|
1380
|
1437
|
|
|
1381
|
1438
|
// Start from the beginning... |
|
1382
|
|
- if ($reset) |
|
1383
|
|
- return @$smcFunc['db_data_seek']($messages_request, 0); |
|
|
1439
|
+ if ($reset) { |
|
|
1440
|
+ return @$smcFunc['db_data_seek']($messages_request, 0); |
|
|
1441
|
+ } |
|
1384
|
1442
|
|
|
1385
|
1443
|
// Attempt to get the next message. |
|
1386
|
1444
|
$message = $smcFunc['db_fetch_assoc']($messages_request); |
|
@@ -1394,19 +1452,21 @@ discard block |
|
|
block discarded – undo |
|
1394
|
1452
|
if (empty($context['icon_sources'])) |
|
1395
|
1453
|
{ |
|
1396
|
1454
|
$context['icon_sources'] = array(); |
|
1397
|
|
- foreach ($context['stable_icons'] as $icon) |
|
1398
|
|
- $context['icon_sources'][$icon] = 'images_url'; |
|
|
1455
|
+ foreach ($context['stable_icons'] as $icon) { |
|
|
1456
|
+ $context['icon_sources'][$icon] = 'images_url'; |
|
|
1457
|
+ } |
|
1399
|
1458
|
} |
|
1400
|
1459
|
|
|
1401
|
1460
|
// Message Icon Management... check the images exist. |
|
1402
|
1461
|
if (empty($modSettings['messageIconChecks_disable'])) |
|
1403
|
1462
|
{ |
|
1404
|
1463
|
// If the current icon isn't known, then we need to do something... |
|
1405
|
|
- if (!isset($context['icon_sources'][$message['icon']])) |
|
1406
|
|
- $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
|
1464
|
+ if (!isset($context['icon_sources'][$message['icon']])) { |
|
|
1465
|
+ $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
|
1466
|
+ } |
|
|
1467
|
+ } elseif (!isset($context['icon_sources'][$message['icon']])) { |
|
|
1468
|
+ $context['icon_sources'][$message['icon']] = 'images_url'; |
|
1407
|
1469
|
} |
|
1408
|
|
- elseif (!isset($context['icon_sources'][$message['icon']])) |
|
1409
|
|
- $context['icon_sources'][$message['icon']] = 'images_url'; |
|
1410
|
1470
|
|
|
1411
|
1471
|
// If you're a lazy bum, you probably didn't give a subject... |
|
1412
|
1472
|
$message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject']; |
|
@@ -1431,8 +1491,7 @@ discard block |
|
|
block discarded – undo |
|
1431
|
1491
|
$memberContext[$message['id_member']]['email'] = $message['poster_email']; |
|
1432
|
1492
|
$memberContext[$message['id_member']]['show_email'] = allowedTo('moderate_forum'); |
|
1433
|
1493
|
$memberContext[$message['id_member']]['is_guest'] = true; |
|
1434
|
|
- } |
|
1435
|
|
- else |
|
|
1494
|
+ } else |
|
1436
|
1495
|
{ |
|
1437
|
1496
|
// Define this here to make things a bit more readable |
|
1438
|
1497
|
$can_view_warning = $context['user']['can_mod'] || allowedTo('view_warning_any') || ($message['id_member'] == $user_info['id'] && allowedTo('view_warning_own')); |
|
@@ -1455,8 +1514,9 @@ discard block |
|
|
block discarded – undo |
|
1455
|
1514
|
$message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']); |
|
1456
|
1515
|
|
|
1457
|
1516
|
// If it's in the recycle bin we need to override whatever icon we did have. |
|
1458
|
|
- if (!empty($board_info['recycle'])) |
|
1459
|
|
- $message['icon'] = 'recycled'; |
|
|
1517
|
+ if (!empty($board_info['recycle'])) { |
|
|
1518
|
+ $message['icon'] = 'recycled'; |
|
|
1519
|
+ } |
|
1460
|
1520
|
|
|
1461
|
1521
|
require_once($sourcedir . '/Subs-Attachments.php'); |
|
1462
|
1522
|
|
|
@@ -1500,32 +1560,36 @@ discard block |
|
|
block discarded – undo |
|
1500
|
1560
|
} |
|
1501
|
1561
|
|
|
1502
|
1562
|
// Are likes enable? |
|
1503
|
|
- if (!empty($modSettings['enable_likes'])) |
|
1504
|
|
- $output['likes'] = array( |
|
|
1563
|
+ if (!empty($modSettings['enable_likes'])) { |
|
|
1564
|
+ $output['likes'] = array( |
|
1505
|
1565
|
'count' => $message['likes'], |
|
1506
|
1566
|
'you' => in_array($message['id_msg'], $context['my_likes']), |
|
1507
|
1567
|
'can_like' => !$context['user']['is_guest'] && $message['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
|
1508
|
1568
|
); |
|
|
1569
|
+ } |
|
1509
|
1570
|
|
|
1510
|
1571
|
// Is this user the message author? |
|
1511
|
1572
|
$output['is_message_author'] = $message['id_member'] == $user_info['id']; |
|
1512
|
|
- if (!empty($output['modified']['name'])) |
|
1513
|
|
- $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
|
1573
|
+ if (!empty($output['modified']['name'])) { |
|
|
1574
|
+ $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
|
1575
|
+ } |
|
1514
|
1576
|
|
|
1515
|
1577
|
// Did they give a reason for editing? |
|
1516
|
|
- if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) |
|
1517
|
|
- $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
|
1578
|
+ if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) { |
|
|
1579
|
+ $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
|
1580
|
+ } |
|
1518
|
1581
|
|
|
1519
|
1582
|
// Any custom profile fields? |
|
1520
|
|
- if (!empty($memberContext[$message['id_member']]['custom_fields'])) |
|
1521
|
|
- foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
|
1583
|
+ if (!empty($memberContext[$message['id_member']]['custom_fields'])) { |
|
|
1584
|
+ foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
1522
|
1585
|
$output['custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
|
|
1586
|
+ } |
|
1523
|
1587
|
|
|
1524
|
|
- if (empty($options['view_newest_first'])) |
|
1525
|
|
- $counter++; |
|
1526
|
|
- |
|
1527
|
|
- else |
|
1528
|
|
- $counter--; |
|
|
1588
|
+ if (empty($options['view_newest_first'])) { |
|
|
1589
|
+ $counter++; |
|
|
1590
|
+ } else { |
|
|
1591
|
+ $counter--; |
|
|
1592
|
+ } |
|
1529
|
1593
|
|
|
1530
|
1594
|
call_integration_hook('integrate_prepare_display_context', array(&$output, &$message, $counter)); |
|
1531
|
1595
|
|
|
@@ -1551,21 +1615,23 @@ discard block |
|
|
block discarded – undo |
|
1551
|
1615
|
$context['no_last_modified'] = true; |
|
1552
|
1616
|
|
|
1553
|
1617
|
// Prevent a preview image from being displayed twice. |
|
1554
|
|
- if (isset($_GET['action']) && $_GET['action'] == 'dlattach' && isset($_GET['type']) && ($_GET['type'] == 'avatar' || $_GET['type'] == 'preview')) |
|
1555
|
|
- return; |
|
|
1618
|
+ if (isset($_GET['action']) && $_GET['action'] == 'dlattach' && isset($_GET['type']) && ($_GET['type'] == 'avatar' || $_GET['type'] == 'preview')) { |
|
|
1619
|
+ return; |
|
|
1620
|
+ } |
|
1556
|
1621
|
|
|
1557
|
1622
|
// Make sure some attachment was requested! |
|
1558
|
|
- if (!isset($_REQUEST['attach']) && !isset($_REQUEST['id'])) |
|
1559
|
|
- fatal_lang_error('no_access', false); |
|
|
1623
|
+ if (!isset($_REQUEST['attach']) && !isset($_REQUEST['id'])) { |
|
|
1624
|
+ fatal_lang_error('no_access', false); |
|
|
1625
|
+ } |
|
1560
|
1626
|
|
|
1561
|
1627
|
$_REQUEST['attach'] = isset($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : (int) $_REQUEST['id']; |
|
1562
|
1628
|
|
|
1563
|
1629
|
// Do we have a hook wanting to use our attachment system? We use $attachRequest to prevent accidental usage of $request. |
|
1564
|
1630
|
$attachRequest = null; |
|
1565
|
1631
|
call_integration_hook('integrate_download_request', array(&$attachRequest)); |
|
1566
|
|
- if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) |
|
1567
|
|
- $request = $attachRequest; |
|
1568
|
|
- else |
|
|
1632
|
+ if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) { |
|
|
1633
|
+ $request = $attachRequest; |
|
|
1634
|
+ } else |
|
1569
|
1635
|
{ |
|
1570
|
1636
|
// This checks only the current board for $board/$topic's permissions. |
|
1571
|
1637
|
isAllowedTo('view_attachments'); |
|
@@ -1586,19 +1652,21 @@ discard block |
|
|
block discarded – undo |
|
1586
|
1652
|
); |
|
1587
|
1653
|
} |
|
1588
|
1654
|
|
|
1589
|
|
- if ($smcFunc['db_num_rows']($request) == 0) |
|
1590
|
|
- fatal_lang_error('no_access', false); |
|
|
1655
|
+ if ($smcFunc['db_num_rows']($request) == 0) { |
|
|
1656
|
+ fatal_lang_error('no_access', false); |
|
|
1657
|
+ } |
|
1591
|
1658
|
|
|
1592
|
1659
|
list ($id_folder, $real_filename, $file_hash, $file_ext, $id_attach, $attachment_type, $mime_type, $is_approved, $id_member) = $smcFunc['db_fetch_row']($request); |
|
1593
|
1660
|
$smcFunc['db_free_result']($request); |
|
1594
|
1661
|
|
|
1595
|
1662
|
// If it isn't yet approved, do they have permission to view it? |
|
1596
|
|
- if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3)) |
|
1597
|
|
- isAllowedTo('approve_posts'); |
|
|
1663
|
+ if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3)) { |
|
|
1664
|
+ isAllowedTo('approve_posts'); |
|
|
1665
|
+ } |
|
1598
|
1666
|
|
|
1599
|
1667
|
// Update the download counter (unless it's a thumbnail). |
|
1600
|
|
- if ($attachment_type != 3) |
|
1601
|
|
- $smcFunc['db_query']('attach_download_increase', ' |
|
|
1668
|
+ if ($attachment_type != 3) { |
|
|
1669
|
+ $smcFunc['db_query']('attach_download_increase', ' |
|
1602
|
1670
|
UPDATE LOW_PRIORITY {db_prefix}attachments |
|
1603
|
1671
|
SET downloads = downloads + 1 |
|
1604
|
1672
|
WHERE id_attach = {int:id_attach}', |
|
@@ -1606,15 +1674,15 @@ discard block |
|
|
block discarded – undo |
|
1606
|
1674
|
'id_attach' => $id_attach, |
|
1607
|
1675
|
) |
|
1608
|
1676
|
); |
|
|
1677
|
+ } |
|
1609
|
1678
|
|
|
1610
|
1679
|
$filename = getAttachmentFilename($real_filename, $_REQUEST['attach'], $id_folder, false, $file_hash); |
|
1611
|
1680
|
|
|
1612
|
1681
|
// This is done to clear any output that was made before now. |
|
1613
|
1682
|
ob_end_clean(); |
|
1614
|
|
- if (!empty($modSettings['enableCompressedOutput']) && @filesize($filename) <= 4194304 && in_array($file_ext, array('txt', 'html', 'htm', 'js', 'doc', 'docx', 'rtf', 'css', 'php', 'log', 'xml', 'sql', 'c', 'java'))) |
|
1615
|
|
- @ob_start('ob_gzhandler'); |
|
1616
|
|
- |
|
1617
|
|
- else |
|
|
1683
|
+ if (!empty($modSettings['enableCompressedOutput']) && @filesize($filename) <= 4194304 && in_array($file_ext, array('txt', 'html', 'htm', 'js', 'doc', 'docx', 'rtf', 'css', 'php', 'log', 'xml', 'sql', 'c', 'java'))) { |
|
|
1684
|
+ @ob_start('ob_gzhandler'); |
|
|
1685
|
+ } else |
|
1618
|
1686
|
{ |
|
1619
|
1687
|
ob_start(); |
|
1620
|
1688
|
header('Content-Encoding: none'); |
|
@@ -1657,8 +1725,9 @@ discard block |
|
|
block discarded – undo |
|
1657
|
1725
|
// Send the attachment headers. |
|
1658
|
1726
|
header('Pragma: '); |
|
1659
|
1727
|
|
|
1660
|
|
- if (!isBrowser('gecko')) |
|
1661
|
|
- header('Content-Transfer-Encoding: binary'); |
|
|
1728
|
+ if (!isBrowser('gecko')) { |
|
|
1729
|
+ header('Content-Transfer-Encoding: binary'); |
|
|
1730
|
+ } |
|
1662
|
1731
|
|
|
1663
|
1732
|
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
|
1664
|
1733
|
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($filename)) . ' GMT'); |
|
@@ -1667,18 +1736,19 @@ discard block |
|
|
block discarded – undo |
|
1667
|
1736
|
header('ETag: ' . $eTag); |
|
1668
|
1737
|
|
|
1669
|
1738
|
// Make sure the mime type warrants an inline display. |
|
1670
|
|
- if (isset($_REQUEST['image']) && !empty($mime_type) && strpos($mime_type, 'image/') !== 0) |
|
1671
|
|
- unset($_REQUEST['image']); |
|
|
1739
|
+ if (isset($_REQUEST['image']) && !empty($mime_type) && strpos($mime_type, 'image/') !== 0) { |
|
|
1740
|
+ unset($_REQUEST['image']); |
|
|
1741
|
+ } |
|
1672
|
1742
|
|
|
1673
|
1743
|
// Does this have a mime type? |
|
1674
|
|
- elseif (!empty($mime_type) && (isset($_REQUEST['image']) || !in_array($file_ext, array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) |
|
1675
|
|
- header('Content-Type: ' . strtr($mime_type, array('image/bmp' => 'image/x-ms-bmp'))); |
|
1676
|
|
- |
|
1677
|
|
- else |
|
|
1744
|
+ elseif (!empty($mime_type) && (isset($_REQUEST['image']) || !in_array($file_ext, array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) { |
|
|
1745
|
+ header('Content-Type: ' . strtr($mime_type, array('image/bmp' => 'image/x-ms-bmp'))); |
|
|
1746
|
+ } else |
|
1678
|
1747
|
{ |
|
1679
|
1748
|
header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream')); |
|
1680
|
|
- if (isset($_REQUEST['image'])) |
|
1681
|
|
- unset($_REQUEST['image']); |
|
|
1749
|
+ if (isset($_REQUEST['image'])) { |
|
|
1750
|
+ unset($_REQUEST['image']); |
|
|
1751
|
+ } |
|
1682
|
1752
|
} |
|
1683
|
1753
|
|
|
1684
|
1754
|
// Convert the file to UTF-8, cuz most browsers dig that. |
|
@@ -1686,23 +1756,22 @@ discard block |
|
|
block discarded – undo |
|
1686
|
1756
|
$disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline'; |
|
1687
|
1757
|
|
|
1688
|
1758
|
// Different browsers like different standards... |
|
1689
|
|
- if (isBrowser('firefox')) |
|
1690
|
|
- header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
1691
|
|
- |
|
1692
|
|
- elseif (isBrowser('opera')) |
|
1693
|
|
- header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
1694
|
|
- |
|
1695
|
|
- elseif (isBrowser('ie')) |
|
1696
|
|
- header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
1697
|
|
- |
|
1698
|
|
- else |
|
1699
|
|
- header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
|
1759
|
+ if (isBrowser('firefox')) { |
|
|
1760
|
+ header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
|
1761
|
+ } elseif (isBrowser('opera')) { |
|
|
1762
|
+ header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
|
1763
|
+ } elseif (isBrowser('ie')) { |
|
|
1764
|
+ header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
|
1765
|
+ } else { |
|
|
1766
|
+ header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
|
1767
|
+ } |
|
1700
|
1768
|
|
|
1701
|
1769
|
// If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE. |
|
1702
|
|
- if (!isset($_REQUEST['image']) && in_array($file_ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) |
|
1703
|
|
- header('Cache-Control: no-cache'); |
|
1704
|
|
- else |
|
1705
|
|
- header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
|
1770
|
+ if (!isset($_REQUEST['image']) && in_array($file_ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) { |
|
|
1771
|
+ header('Cache-Control: no-cache'); |
|
|
1772
|
+ } else { |
|
|
1773
|
+ header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
|
1774
|
+ } |
|
1706
|
1775
|
|
|
1707
|
1776
|
header('Content-Length: ' . filesize($filename)); |
|
1708
|
1777
|
|
|
@@ -1712,20 +1781,23 @@ discard block |
|
|
block discarded – undo |
|
1712
|
1781
|
// Recode line endings for text files, if enabled. |
|
1713
|
1782
|
if (!empty($modSettings['attachmentRecodeLineEndings']) && !isset($_REQUEST['image']) && in_array($file_ext, array('txt', 'css', 'htm', 'html', 'php', 'xml'))) |
|
1714
|
1783
|
{ |
|
1715
|
|
- if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) |
|
1716
|
|
- $callback = function($buffer) |
|
|
1784
|
+ if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) { |
|
|
1785
|
+ $callback = function($buffer) |
|
1717
|
1786
|
{ |
|
1718
|
1787
|
return preg_replace('~[\r]?\n~', "\r\n", $buffer); |
|
|
1788
|
+ } |
|
1719
|
1789
|
}; |
|
1720
|
|
- elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) |
|
1721
|
|
- $callback = function($buffer) |
|
|
1790
|
+ elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) { |
|
|
1791
|
+ $callback = function($buffer) |
|
1722
|
1792
|
{ |
|
1723
|
1793
|
return preg_replace('~[\r]?\n~', "\r", $buffer); |
|
|
1794
|
+ } |
|
1724
|
1795
|
}; |
|
1725
|
|
- else |
|
1726
|
|
- $callback = function($buffer) |
|
|
1796
|
+ else { |
|
|
1797
|
+ $callback = function($buffer) |
|
1727
|
1798
|
{ |
|
1728
|
1799
|
return preg_replace('~[\r]?\n~', "\n", $buffer); |
|
|
1800
|
+ } |
|
1729
|
1801
|
}; |
|
1730
|
1802
|
} |
|
1731
|
1803
|
|
|
@@ -1733,23 +1805,26 @@ discard block |
|
|
block discarded – undo |
|
1733
|
1805
|
if (filesize($filename) > 4194304) |
|
1734
|
1806
|
{ |
|
1735
|
1807
|
// Forcibly end any output buffering going on. |
|
1736
|
|
- while (@ob_get_level() > 0) |
|
1737
|
|
- @ob_end_clean(); |
|
|
1808
|
+ while (@ob_get_level() > 0) { |
|
|
1809
|
+ @ob_end_clean(); |
|
|
1810
|
+ } |
|
1738
|
1811
|
|
|
1739
|
1812
|
$fp = fopen($filename, 'rb'); |
|
1740
|
1813
|
while (!feof($fp)) |
|
1741
|
1814
|
{ |
|
1742
|
|
- if (isset($callback)) |
|
1743
|
|
- echo $callback(fread($fp, 8192)); |
|
1744
|
|
- else |
|
1745
|
|
- echo fread($fp, 8192); |
|
|
1815
|
+ if (isset($callback)) { |
|
|
1816
|
+ echo $callback(fread($fp, 8192)); |
|
|
1817
|
+ } else { |
|
|
1818
|
+ echo fread($fp, 8192); |
|
|
1819
|
+ } |
|
1746
|
1820
|
flush(); |
|
1747
|
1821
|
} |
|
1748
|
1822
|
fclose($fp); |
|
1749
|
1823
|
} |
|
1750
|
1824
|
// On some of the less-bright hosts, readfile() is disabled. It's just a faster, more byte safe, version of what's in the if. |
|
1751
|
|
- elseif (isset($callback) || @readfile($filename) === null) |
|
1752
|
|
- echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename); |
|
|
1825
|
+ elseif (isset($callback) || @readfile($filename) === null) { |
|
|
1826
|
+ echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename); |
|
|
1827
|
+ } |
|
1753
|
1828
|
|
|
1754
|
1829
|
obExit(false); |
|
1755
|
1830
|
} |
|
@@ -1762,8 +1837,9 @@ discard block |
|
|
block discarded – undo |
|
1762
|
1837
|
*/ |
|
1763
|
1838
|
function approved_attach_sort($a, $b) |
|
1764
|
1839
|
{ |
|
1765
|
|
- if ($a['is_approved'] == $b['is_approved']) |
|
1766
|
|
- return 0; |
|
|
1840
|
+ if ($a['is_approved'] == $b['is_approved']) { |
|
|
1841
|
+ return 0; |
|
|
1842
|
+ } |
|
1767
|
1843
|
|
|
1768
|
1844
|
return $a['is_approved'] > $b['is_approved'] ? -1 : 1; |
|
1769
|
1845
|
} |
|
@@ -1780,16 +1856,19 @@ discard block |
|
|
block discarded – undo |
|
1780
|
1856
|
|
|
1781
|
1857
|
require_once($sourcedir . '/RemoveTopic.php'); |
|
1782
|
1858
|
|
|
1783
|
|
- if (empty($_REQUEST['msgs'])) |
|
1784
|
|
- redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
|
1859
|
+ if (empty($_REQUEST['msgs'])) { |
|
|
1860
|
+ redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
|
1861
|
+ } |
|
1785
|
1862
|
|
|
1786
|
1863
|
$messages = array(); |
|
1787
|
|
- foreach ($_REQUEST['msgs'] as $dummy) |
|
1788
|
|
- $messages[] = (int) $dummy; |
|
|
1864
|
+ foreach ($_REQUEST['msgs'] as $dummy) { |
|
|
1865
|
+ $messages[] = (int) $dummy; |
|
|
1866
|
+ } |
|
1789
|
1867
|
|
|
1790
|
1868
|
// We are restoring messages. We handle this in another place. |
|
1791
|
|
- if (isset($_REQUEST['restore_selected'])) |
|
1792
|
|
- redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
|
1869
|
+ if (isset($_REQUEST['restore_selected'])) { |
|
|
1870
|
+ redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
|
1871
|
+ } |
|
1793
|
1872
|
if (isset($_REQUEST['split_selection'])) |
|
1794
|
1873
|
{ |
|
1795
|
1874
|
$request = $smcFunc['db_query']('', ' |
|
@@ -1808,8 +1887,9 @@ discard block |
|
|
block discarded – undo |
|
1808
|
1887
|
} |
|
1809
|
1888
|
|
|
1810
|
1889
|
// Allowed to delete any message? |
|
1811
|
|
- if (allowedTo('delete_any')) |
|
1812
|
|
- $allowed_all = true; |
|
|
1890
|
+ if (allowedTo('delete_any')) { |
|
|
1891
|
+ $allowed_all = true; |
|
|
1892
|
+ } |
|
1813
|
1893
|
// Allowed to delete replies to their messages? |
|
1814
|
1894
|
elseif (allowedTo('delete_replies')) |
|
1815
|
1895
|
{ |
|
@@ -1826,13 +1906,14 @@ discard block |
|
|
block discarded – undo |
|
1826
|
1906
|
$smcFunc['db_free_result']($request); |
|
1827
|
1907
|
|
|
1828
|
1908
|
$allowed_all = $starter == $user_info['id']; |
|
|
1909
|
+ } else { |
|
|
1910
|
+ $allowed_all = false; |
|
1829
|
1911
|
} |
|
1830
|
|
- else |
|
1831
|
|
- $allowed_all = false; |
|
1832
|
1912
|
|
|
1833
|
1913
|
// Make sure they're allowed to delete their own messages, if not any. |
|
1834
|
|
- if (!$allowed_all) |
|
1835
|
|
- isAllowedTo('delete_own'); |
|
|
1914
|
+ if (!$allowed_all) { |
|
|
1915
|
+ isAllowedTo('delete_own'); |
|
|
1916
|
+ } |
|
1836
|
1917
|
|
|
1837
|
1918
|
// Allowed to remove which messages? |
|
1838
|
1919
|
$request = $smcFunc['db_query']('', ' |
|
@@ -1852,8 +1933,9 @@ discard block |
|
|
block discarded – undo |
|
1852
|
1933
|
$messages = array(); |
|
1853
|
1934
|
while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1854
|
1935
|
{ |
|
1855
|
|
- if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) |
|
1856
|
|
- continue; |
|
|
1936
|
+ if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) { |
|
|
1937
|
+ continue; |
|
|
1938
|
+ } |
|
1857
|
1939
|
|
|
1858
|
1940
|
$messages[$row['id_msg']] = array($row['subject'], $row['id_member']); |
|
1859
|
1941
|
} |
|
@@ -1876,17 +1958,20 @@ discard block |
|
|
block discarded – undo |
|
1876
|
1958
|
foreach ($messages as $message => $info) |
|
1877
|
1959
|
{ |
|
1878
|
1960
|
// Just skip the first message - if it's not the last. |
|
1879
|
|
- if ($message == $first_message && $message != $last_message) |
|
1880
|
|
- continue; |
|
|
1961
|
+ if ($message == $first_message && $message != $last_message) { |
|
|
1962
|
+ continue; |
|
|
1963
|
+ } |
|
1881
|
1964
|
// If the first message is going then don't bother going back to the topic as we're effectively deleting it. |
|
1882
|
|
- elseif ($message == $first_message) |
|
1883
|
|
- $topicGone = true; |
|
|
1965
|
+ elseif ($message == $first_message) { |
|
|
1966
|
+ $topicGone = true; |
|
|
1967
|
+ } |
|
1884
|
1968
|
|
|
1885
|
1969
|
removeMessage($message); |
|
1886
|
1970
|
|
|
1887
|
1971
|
// Log this moderation action ;). |
|
1888
|
|
- if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
1889
|
|
- logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
|
1972
|
+ if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
|
1973
|
+ logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
|
1974
|
+ } |
|
1890
|
1975
|
} |
|
1891
|
1976
|
|
|
1892
|
1977
|
redirectexit(!empty($topicGone) ? 'board=' . $board : 'topic=' . $topic . '.' . $_REQUEST['start']); |