forked from punbb/punbb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewtopic.php
703 lines (574 loc) · 34 KB
/
viewtopic.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
<?php
/**
* Lists the posts in the specified topic.
*
* @copyright (C) 2008-2012 PunBB, partially based on code (C) 2008-2009 FluxBB.org
* @license http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
* @package PunBB
*/
if (!defined('FORUM_ROOT'))
define('FORUM_ROOT', './');
require FORUM_ROOT.'include/common.php';
($hook = get_hook('vt_start')) ? eval($hook) : null;
if ($forum_user['g_read_board'] == '0')
message($lang_common['No view']);
// Load the viewtopic.php language file
require FORUM_ROOT.'lang/'.$forum_user['language'].'/topic.php';
$action = isset($_GET['action']) ? $_GET['action'] : null;
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$pid = isset($_GET['pid']) ? intval($_GET['pid']) : 0;
if ($id < 1 && $pid < 1)
message($lang_common['Bad request']);
// If a post ID is specified we determine topic ID and page number so we can redirect to the correct message
if ($pid)
{
$query = array(
'SELECT' => 'p.topic_id, p.posted',
'FROM' => 'posts AS p',
'WHERE' => 'p.id='.$pid
);
($hook = get_hook('vt_qr_get_post_info')) ? eval($hook) : null;
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
$topic_info = $forum_db->fetch_assoc($result);
if (!$topic_info)
{
message($lang_common['Bad request']);
}
$id = $topic_info['topic_id'];
// Determine on what page the post is located (depending on $forum_user['disp_posts'])
$query = array(
'SELECT' => 'COUNT(p.id)',
'FROM' => 'posts AS p',
'WHERE' => 'p.topic_id='.$topic_info['topic_id'].' AND p.posted<'.$topic_info['posted']
);
($hook = get_hook('vt_qr_get_post_page')) ? eval($hook) : null;
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
$num_posts = $forum_db->result($result) + 1;
$_GET['p'] = ceil($num_posts / $forum_user['disp_posts']);
}
// If action=new, we redirect to the first new post (if any)
else if ($action == 'new')
{
if (!$forum_user['is_guest'])
{
// We need to check if this topic has been viewed recently by the user
$tracked_topics = get_tracked_topics();
$last_viewed = isset($tracked_topics['topics'][$id]) ? $tracked_topics['topics'][$id] : $forum_user['last_visit'];
($hook = get_hook('vt_find_new_post')) ? eval($hook) : null;
$query = array(
'SELECT' => 'MIN(p.id)',
'FROM' => 'posts AS p',
'WHERE' => 'p.topic_id='.$id.' AND p.posted>'.$last_viewed
);
($hook = get_hook('vt_qr_get_first_new_post')) ? eval($hook) : null;
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
$first_new_post_id = $forum_db->result($result);
if ($first_new_post_id)
{
header('Location: '.str_replace('&', '&', forum_link($forum_url['post'], $first_new_post_id)));
exit;
}
}
header('Location: '.str_replace('&', '&', forum_link($forum_url['topic_last_post'], $id)));
exit;
}
// If action=last, we redirect to the last post
else if ($action == 'last')
{
$query = array(
'SELECT' => 't.last_post_id',
'FROM' => 'topics AS t',
'WHERE' => 't.id='.$id
);
($hook = get_hook('vt_qr_get_last_post')) ? eval($hook) : null;
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
$last_post_id = $forum_db->result($result);
if ($last_post_id)
{
header('Location: '.str_replace('&', '&', forum_link($forum_url['post'], $last_post_id)));
exit;
}
}
// Fetch some info about the topic
$query = array(
'SELECT' => 't.subject, t.first_post_id, t.closed, t.num_replies, t.sticky, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies',
'FROM' => 'topics AS t',
'JOINS' => array(
array(
'INNER JOIN' => 'forums AS f',
'ON' => 'f.id=t.forum_id'
),
array(
'LEFT JOIN' => 'forum_perms AS fp',
'ON' => '(fp.forum_id=f.id AND fp.group_id='.$forum_user['g_id'].')'
)
),
'WHERE' => '(fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$id.' AND t.moved_to IS NULL'
);
if (!$forum_user['is_guest'] && $forum_config['o_subscriptions'] == '1')
{
$query['SELECT'] .= ', s.user_id AS is_subscribed';
$query['JOINS'][] = array(
'LEFT JOIN' => 'subscriptions AS s',
'ON' => '(t.id=s.topic_id AND s.user_id='.$forum_user['id'].')'
);
}
($hook = get_hook('vt_qr_get_topic_info')) ? eval($hook) : null;
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
$cur_topic = $forum_db->fetch_assoc($result);
if (!$cur_topic)
{
message($lang_common['Bad request']);
}
($hook = get_hook('vt_modify_topic_info')) ? eval($hook) : null;
// Sort out who the moderators are and if we are currently a moderator (or an admin)
$mods_array = ($cur_topic['moderators'] != '') ? unserialize($cur_topic['moderators']) : array();
$forum_page['is_admmod'] = ($forum_user['g_id'] == FORUM_ADMIN || ($forum_user['g_moderator'] == '1' && array_key_exists($forum_user['username'], $mods_array))) ? true : false;
// Can we or can we not post replies?
if ($cur_topic['closed'] == '0' || $forum_page['is_admmod'])
$forum_user['may_post'] = (($cur_topic['post_replies'] == '' && $forum_user['g_post_replies'] == '1') || $cur_topic['post_replies'] == '1' || $forum_page['is_admmod']) ? true : false;
else
$forum_user['may_post'] = false;
// Add/update this topic in our list of tracked topics
if (!$forum_user['is_guest'])
{
$tracked_topics = get_tracked_topics();
$tracked_topics['topics'][$id] = time();
set_tracked_topics($tracked_topics);
}
// Determine the post offset (based on $_GET['p'])
$forum_page['num_pages'] = ceil(($cur_topic['num_replies'] + 1) / $forum_user['disp_posts']);
$forum_page['page'] = (!isset($_GET['p']) || !is_numeric($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $forum_page['num_pages']) ? 1 : $_GET['p'];
$forum_page['start_from'] = $forum_user['disp_posts'] * ($forum_page['page'] - 1);
$forum_page['finish_at'] = min(($forum_page['start_from'] + $forum_user['disp_posts']), ($cur_topic['num_replies'] + 1));
$forum_page['items_info'] = generate_items_info($lang_topic['Posts'], ($forum_page['start_from'] + 1), ($cur_topic['num_replies'] + 1));
($hook = get_hook('vt_modify_page_details')) ? eval($hook) : null;
// Navigation links for header and page numbering for title/meta description
if ($forum_page['page'] < $forum_page['num_pages'])
{
$forum_page['nav']['last'] = '<link rel="last" href="'.forum_sublink($forum_url['topic'], $forum_url['page'], $forum_page['num_pages'], array($id, sef_friendly($cur_topic['subject']))).'" title="'.$lang_common['Page'].' '.$forum_page['num_pages'].'" />';
$forum_page['nav']['next'] = '<link rel="next" href="'.forum_sublink($forum_url['topic'], $forum_url['page'], ($forum_page['page'] + 1), array($id, sef_friendly($cur_topic['subject']))).'" title="'.$lang_common['Page'].' '.($forum_page['page'] + 1).'" />';
}
if ($forum_page['page'] > 1)
{
$forum_page['nav']['prev'] = '<link rel="prev" href="'.forum_sublink($forum_url['topic'], $forum_url['page'], ($forum_page['page'] - 1), array($id, sef_friendly($cur_topic['subject']))).'" title="'.$lang_common['Page'].' '.($forum_page['page'] - 1).'" />';
$forum_page['nav']['first'] = '<link rel="first" href="'.forum_link($forum_url['topic'], array($id, sef_friendly($cur_topic['subject']))).'" title="'.$lang_common['Page'].' 1" />';
}
if ($forum_config['o_censoring'] == '1')
$cur_topic['subject'] = censor_words($cur_topic['subject']);
// Generate paging and posting links
$forum_page['page_post']['paging'] = '<p class="paging"><span class="pages">'.$lang_common['Pages'].'</span> '.paginate($forum_page['num_pages'], $forum_page['page'], $forum_url['topic'], $lang_common['Paging separator'], array($id, sef_friendly($cur_topic['subject']))).'</p>';
if ($forum_user['may_post'])
$forum_page['page_post']['posting'] = '<p class="posting"><a class="newpost" href="'.forum_link($forum_url['new_reply'], $id).'"><span>'.$lang_topic['Post reply'].'</span></a></p>';
else if ($forum_user['is_guest'])
$forum_page['page_post']['posting'] = '<p class="posting">'.sprintf($lang_topic['Login to post'], '<a href="'.forum_link($forum_url['login']).'">'.$lang_common['login'].'</a>', '<a href="'.forum_link($forum_url['register']).'">'.$lang_common['register'].'</a>').'</p>';
else if ($cur_topic['closed'] == '1')
$forum_page['page_post']['posting'] = '<p class="posting">'.$lang_topic['Topic closed info'].'</p>';
else
$forum_page['page_post']['posting'] = '<p class="posting">'.$lang_topic['No permission'].'</p>';
// Setup main options
$forum_page['main_title'] = $lang_topic['Topic options'];
$forum_page['main_head_options'] = array(
'rss' => '<span class="feed first-item"><a class="feed" href="'.forum_link($forum_url['topic_rss'], $id).'">'.$lang_topic['RSS topic feed'].'</a></span>'
);
if (!$forum_user['is_guest'] && $forum_config['o_subscriptions'] == '1')
{
if ($cur_topic['is_subscribed'])
$forum_page['main_head_options']['unsubscribe'] = '<span><a class="sub-option" href="'.forum_link($forum_url['unsubscribe'], array($id, generate_form_token('unsubscribe'.$id.$forum_user['id']))).'"><em>'.$lang_topic['Unsubscribe'].'</em></a></span>';
else
$forum_page['main_head_options']['subscribe'] = '<span><a class="sub-option" href="'.forum_link($forum_url['subscribe'], array($id, generate_form_token('subscribe'.$id.$forum_user['id']))).'" title="'.$lang_topic['Subscribe info'].'">'.$lang_topic['Subscribe'].'</a></span>';
}
if ($forum_page['is_admmod'])
{
$forum_page['main_foot_options'] = array(
'move' => '<span class="first-item"><a class="mod-option" href="'.forum_link($forum_url['move'], array($cur_topic['forum_id'], $id)).'">'.$lang_topic['Move'].'</a></span>',
'delete' => '<span><a class="mod-option" href="'.forum_link($forum_url['delete'], $cur_topic['first_post_id']).'">'.$lang_topic['Delete topic'].'</a></span>',
'close' => (($cur_topic['closed'] == '1') ? '<span><a class="mod-option" href="'.forum_link($forum_url['open'], array($cur_topic['forum_id'], $id, generate_form_token('open'.$id))).'">'.$lang_topic['Open'].'</a></span>' : '<span><a class="mod-option" href="'.forum_link($forum_url['close'], array($cur_topic['forum_id'], $id, generate_form_token('close'.$id))).'">'.$lang_topic['Close'].'</a></span>'),
'sticky' => (($cur_topic['sticky'] == '1') ? '<span><a class="mod-option" href="'.forum_link($forum_url['unstick'], array($cur_topic['forum_id'], $id, generate_form_token('unstick'.$id))).'">'.$lang_topic['Unstick'].'</a></span>' : '<span><a class="mod-option" href="'.forum_link($forum_url['stick'], array($cur_topic['forum_id'], $id, generate_form_token('stick'.$id))).'">'.$lang_topic['Stick'].'</a></span>')
);
if ($cur_topic['num_replies'] != 0)
$forum_page['main_foot_options']['moderate_topic'] = '<span><a class="mod-option" href="'.forum_sublink($forum_url['moderate_topic'], $forum_url['page'], $forum_page['page'], array($cur_topic['forum_id'], $id)).'">'.$lang_topic['Moderate topic'].'</a></span>';
}
// Setup breadcrumbs
$forum_page['crumbs'] = array(
array($forum_config['o_board_title'], forum_link($forum_url['index'])),
array($cur_topic['forum_name'], forum_link($forum_url['forum'], array($cur_topic['forum_id'], sef_friendly($cur_topic['forum_name'])))),
$cur_topic['subject']
);
// Setup main heading
$forum_page['main_title'] = (($cur_topic['closed'] == '1') ? $lang_topic['Topic closed'].' ' : '').'<a class="permalink" href="'.forum_link($forum_url['topic'], array($id, sef_friendly($cur_topic['subject']))).'" rel="bookmark" title="'.$lang_topic['Permalink topic'].'">'.forum_htmlencode($cur_topic['subject']).'</a>';
if ($forum_page['num_pages'] > 1)
$forum_page['main_head_pages'] = sprintf($lang_common['Page info'], $forum_page['page'], $forum_page['num_pages']);
($hook = get_hook('vt_pre_header_load')) ? eval($hook) : null;
// Allow indexing if this is a permalink
if (!$pid)
define('FORUM_ALLOW_INDEX', 1);
define('FORUM_PAGE', 'viewtopic');
require FORUM_ROOT.'header.php';
// START SUBST - <!-- forum_main -->
ob_start();
($hook = get_hook('vt_main_output_start')) ? eval($hook) : null;
?>
<div class="main-head">
<?php
if (!empty($forum_page['main_head_options']))
echo "\t\t".'<p class="options">'.implode(' ', $forum_page['main_head_options']).'</p>'."\n";
?>
<h2 class="hn"><span><?php echo $forum_page['items_info'] ?></span></h2>
</div>
<div id="forum<?php echo $cur_topic['forum_id'] ?>" class="main-content main-topic">
<?php
if (!defined('FORUM_PARSER_LOADED'))
require FORUM_ROOT.'include/parser.php';
$forum_page['item_count'] = 0; // Keep track of post numbers
// 1. Retrieve the posts ids
$query = array(
'SELECT' => 'p.id',
'FROM' => 'posts AS p',
'WHERE' => 'p.topic_id='.$id,
'ORDER BY' => 'p.id',
'LIMIT' => $forum_page['start_from'].','.$forum_user['disp_posts']
);
($hook = get_hook('vt_qr_get_posts_id')) ? eval($hook) : null;
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
$posts_id = array();
while ($row = $forum_db->fetch_assoc($result)) {
$posts_id[] = $row['id'];
}
if (!empty($posts_id))
{
// 2. Retrieve the posts (and their respective poster/online status) by known id`s
$query = array(
'SELECT' => 'u.email, u.title, u.url, u.location, u.signature, u.email_setting, u.num_posts, u.registered, u.admin_note, u.avatar, u.avatar_width, u.avatar_height, p.id, p.poster AS username, p.poster_id, p.poster_ip, p.poster_email, p.message, p.hide_smilies, p.posted, p.edited, p.edited_by, g.g_id, g.g_user_title, o.user_id AS is_online',
'FROM' => 'posts AS p',
'JOINS' => array(
array(
'INNER JOIN' => 'users AS u',
'ON' => 'u.id=p.poster_id'
),
array(
'INNER JOIN' => 'groups AS g',
'ON' => 'g.g_id=u.group_id'
),
array(
'LEFT JOIN' => 'online AS o',
'ON' => '(o.user_id=u.id AND o.user_id!=1 AND o.idle=0)'
),
),
'WHERE' => 'p.id IN ('.implode(',', $posts_id).')',
'ORDER BY' => 'p.id'
);
($hook = get_hook('vt_qr_get_posts')) ? eval($hook) : null;
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
$user_data_cache = array();
while ($cur_post = $forum_db->fetch_assoc($result))
{
($hook = get_hook('vt_post_loop_start')) ? eval($hook) : null;
++$forum_page['item_count'];
$forum_page['post_ident'] = array();
$forum_page['author_ident'] = array();
$forum_page['author_info'] = array();
$forum_page['post_options'] = array();
$forum_page['post_contacts'] = array();
$forum_page['post_actions'] = array();
$forum_page['message'] = array();
// Generate the post heading
$forum_page['post_ident']['num'] = '<span class="post-num">'.forum_number_format($forum_page['start_from'] + $forum_page['item_count']).'</span>';
if ($cur_post['poster_id'] > 1)
$forum_page['post_ident']['byline'] = '<span class="post-byline">'.sprintf((($cur_post['id'] == $cur_topic['first_post_id']) ? $lang_topic['Topic byline'] : $lang_topic['Reply byline']), (($forum_user['g_view_users'] == '1') ? '<a title="'.sprintf($lang_topic['Go to profile'], forum_htmlencode($cur_post['username'])).'" href="'.forum_link($forum_url['user'], $cur_post['poster_id']).'">'.forum_htmlencode($cur_post['username']).'</a>' : '<strong>'.forum_htmlencode($cur_post['username']).'</strong>')).'</span>';
else
$forum_page['post_ident']['byline'] = '<span class="post-byline">'.sprintf((($cur_post['id'] == $cur_topic['first_post_id']) ? $lang_topic['Topic byline'] : $lang_topic['Reply byline']), '<strong>'.forum_htmlencode($cur_post['username']).'</strong>').'</span>';
$forum_page['post_ident']['link'] = '<span class="post-link"><a class="permalink" rel="bookmark" title="'.$lang_topic['Permalink post'].'" href="'.forum_link($forum_url['post'], $cur_post['id']).'">'.format_time($cur_post['posted']).'</a></span>';
if ($cur_post['edited'] != '')
$forum_page['post_ident']['edited'] = '<span class="post-edit">'.sprintf($lang_topic['Last edited'], forum_htmlencode($cur_post['edited_by']), format_time($cur_post['edited'])).'</span>';
($hook = get_hook('vt_row_pre_post_ident_merge')) ? eval($hook) : null;
if (isset($user_data_cache[$cur_post['poster_id']]['author_ident']))
$forum_page['author_ident'] = $user_data_cache[$cur_post['poster_id']]['author_ident'];
else
{
// Generate author identification
if ($cur_post['poster_id'] > 1)
{
if ($forum_config['o_avatars'] == '1' && $forum_user['show_avatars'] != '0')
{
$forum_page['avatar_markup'] = generate_avatar_markup($cur_post['poster_id'], $cur_post['avatar'], $cur_post['avatar_width'], $cur_post['avatar_height'], $cur_post['username']);
if (!empty($forum_page['avatar_markup']))
$forum_page['author_ident']['avatar'] = '<li class="useravatar">'.$forum_page['avatar_markup'].'</li>';
}
$forum_page['author_ident']['username'] = '<li class="username">'.(($forum_user['g_view_users'] == '1') ? '<a title="'.sprintf($lang_topic['Go to profile'], forum_htmlencode($cur_post['username'])).'" href="'.forum_link($forum_url['user'], $cur_post['poster_id']).'">'.forum_htmlencode($cur_post['username']).'</a>' : '<strong>'.forum_htmlencode($cur_post['username']).'</strong>').'</li>';
$forum_page['author_ident']['usertitle'] = '<li class="usertitle"><span>'.get_title($cur_post).'</span></li>';
if ($cur_post['is_online'] == $cur_post['poster_id'])
$forum_page['author_ident']['status'] = '<li class="userstatus"><span>'.$lang_topic['Online'].'</span></li>';
else
$forum_page['author_ident']['status'] = '<li class="userstatus"><span>'.$lang_topic['Offline'].'</span></li>';
}
else
{
$forum_page['author_ident']['username'] = '<li class="username"><strong>'.forum_htmlencode($cur_post['username']).'</strong></li>';
$forum_page['author_ident']['usertitle'] = '<li class="usertitle"><span>'.get_title($cur_post).'</span></li>';
}
}
if (isset($user_data_cache[$cur_post['poster_id']]['author_info']))
$forum_page['author_info'] = $user_data_cache[$cur_post['poster_id']]['author_info'];
else
{
// Generate author information
if ($cur_post['poster_id'] > 1)
{
if ($forum_config['o_show_user_info'] == '1')
{
if ($cur_post['location'] != '')
{
if ($forum_config['o_censoring'] == '1')
$cur_post['location'] = censor_words($cur_post['location']);
$forum_page['author_info']['from'] = '<li><span>'.$lang_topic['From'].' <strong>'.forum_htmlencode($cur_post['location']).'</strong></span></li>';
}
$forum_page['author_info']['registered'] = '<li><span>'.$lang_topic['Registered'].' <strong>'.format_time($cur_post['registered'], 1).'</strong></span></li>';
if ($forum_config['o_show_post_count'] == '1' || $forum_user['is_admmod'])
$forum_page['author_info']['posts'] = '<li><span>'.$lang_topic['Posts info'].' <strong>'.forum_number_format($cur_post['num_posts']).'</strong></span></li>';
}
if ($forum_user['is_admmod'])
{
if ($cur_post['admin_note'] != '')
$forum_page['author_info']['note'] = '<li><span>'.$lang_topic['Note'].' <strong>'.forum_htmlencode($cur_post['admin_note']).'</strong></span></li>';
}
}
}
// Generate IP information for moderators/administrators
if ($forum_user['is_admmod'])
$forum_page['author_info']['ip'] = '<li><span>'.$lang_topic['IP'].' <a href="'.forum_link($forum_url['get_host'], $cur_post['id']).'">'.$cur_post['poster_ip'].'</a></span></li>';
// Generate author contact details
if ($forum_config['o_show_user_info'] == '1')
{
if (isset($user_data_cache[$cur_post['poster_id']]['post_contacts']))
$forum_page['post_contacts'] = $user_data_cache[$cur_post['poster_id']]['post_contacts'];
else
{
if ($cur_post['poster_id'] > 1)
{
if ($cur_post['url'] != '')
$forum_page['post_contacts']['url'] = '<span class="user-url'.(empty($forum_page['post_contacts']) ? ' first-item' : '').'"><a class="external" href="'.forum_htmlencode(($forum_config['o_censoring'] == '1') ? censor_words($cur_post['url']) : $cur_post['url']).'">'.sprintf($lang_topic['Visit website'], '<span>'.sprintf($lang_topic['User possessive'], forum_htmlencode($cur_post['username'])).'</span>').'</a></span>';
if ((($cur_post['email_setting'] == '0' && !$forum_user['is_guest']) || $forum_user['is_admmod']) && $forum_user['g_send_email'] == '1')
$forum_page['post_contacts']['email'] = '<span class="user-email'.(empty($forum_page['post_contacts']) ? ' first-item' : '').'"><a href="mailto:'.forum_htmlencode($cur_post['email']).'">'.$lang_topic['E-mail'].'<span> '.forum_htmlencode($cur_post['username']).'</span></a></span>';
else if ($cur_post['email_setting'] == '1' && !$forum_user['is_guest'] && $forum_user['g_send_email'] == '1')
$forum_page['post_contacts']['email'] = '<span class="user-email'.(empty($forum_page['post_contacts']) ? ' first-item' : '').'"><a href="'.forum_link($forum_url['email'], $cur_post['poster_id']).'">'.$lang_topic['E-mail'].'<span> '.forum_htmlencode($cur_post['username']).'</span></a></span>';
}
else
{
if ($cur_post['poster_email'] != '' && $forum_user['is_admmod'] && $forum_user['g_send_email'] == '1')
$forum_page['post_contacts']['email'] = '<span class="user-email'.(empty($forum_page['post_contacts']) ? ' first-item' : '').'"><a href="mailto:'.forum_htmlencode($cur_post['poster_email']).'">'.$lang_topic['E-mail'].'<span> '.forum_htmlencode($cur_post['username']).'</span></a></span>';
}
}
($hook = get_hook('vt_row_pre_post_contacts_merge')) ? eval($hook) : null;
if (!empty($forum_page['post_contacts']))
$forum_page['post_options']['contacts'] = '<p class="post-contacts">'.implode(' ', $forum_page['post_contacts']).'</p>';
}
// Generate the post options links
if (!$forum_user['is_guest'])
{
$forum_page['post_actions']['report'] = '<span class="report-post'.(empty($forum_page['post_actions']) ? ' first-item' : '').'"><a href="'.forum_link($forum_url['report'], $cur_post['id']).'">'.$lang_topic['Report'].'<span> '.$lang_topic['Post'].' '.forum_number_format($forum_page['start_from'] + $forum_page['item_count']).'</span></a></span>';
if (!$forum_page['is_admmod'])
{
if ($cur_topic['closed'] == '0')
{
if ($cur_post['poster_id'] == $forum_user['id'])
{
if (($forum_page['start_from'] + $forum_page['item_count']) == 1 && $forum_user['g_delete_topics'] == '1')
$forum_page['post_actions']['delete'] = '<span class="delete-topic'.(empty($forum_page['post_actions']) ? ' first-item' : '').'"><a href="'.forum_link($forum_url['delete'], $cur_topic['first_post_id']).'">'.$lang_topic['Delete topic'].'</a></span>';
if (($forum_page['start_from'] + $forum_page['item_count']) > 1 && $forum_user['g_delete_posts'] == '1')
$forum_page['post_actions']['delete'] = '<span class="delete-post'.(empty($forum_page['post_actions']) ? ' first-item' : '').'"><a href="'.forum_link($forum_url['delete'], $cur_post['id']).'">'.$lang_topic['Delete'].'<span> '.$lang_topic['Post'].' '.forum_number_format($forum_page['start_from'] + $forum_page['item_count']).'</span></a></span>';
if ($forum_user['g_edit_posts'] == '1')
$forum_page['post_actions']['edit'] = '<span class="edit-post'.(empty($forum_page['post_actions']) ? ' first-item' : '').'"><a href="'.forum_link($forum_url['edit'], $cur_post['id']).'">'.$lang_topic['Edit'].'<span> '.$lang_topic['Post'].' '.forum_number_format($forum_page['start_from'] + $forum_page['item_count']).'</span></a></span>';
}
if (($cur_topic['post_replies'] == '' && $forum_user['g_post_replies'] == '1') || $cur_topic['post_replies'] == '1')
$forum_page['post_actions']['quote'] = '<span class="quote-post'.(empty($forum_page['post_actions']) ? ' first-item' : '').'"><a href="'.forum_link($forum_url['quote'], array($id, $cur_post['id'])).'">'.$lang_topic['Quote'].'<span> '.$lang_topic['Post'].' '.forum_number_format($forum_page['start_from'] + $forum_page['item_count']).'</span></a></span>';
}
}
else
{
if (($forum_page['start_from'] + $forum_page['item_count']) == 1)
$forum_page['post_actions']['delete'] = '<span class="delete-topic'.(empty($forum_page['post_actions']) ? ' first-item' : '').'"><a href="'.forum_link($forum_url['delete'], $cur_topic['first_post_id']).'">'.$lang_topic['Delete topic'].'</a></span>';
else
$forum_page['post_actions']['delete'] = '<span class="delete-post'.(empty($forum_page['post_actions']) ? ' first-item' : '').'"><a href="'.forum_link($forum_url['delete'], $cur_post['id']).'">'.$lang_topic['Delete'].'<span> '.$lang_topic['Post'].' '.forum_number_format($forum_page['start_from'] + $forum_page['item_count']).'</span></a></span>';
$forum_page['post_actions']['edit'] = '<span class="edit-post'.(empty($forum_page['post_actions']) ? ' first-item' : '').'"><a href="'.forum_link($forum_url['edit'], $cur_post['id']).'">'.$lang_topic['Edit'].'<span> '.$lang_topic['Post'].' '.forum_number_format($forum_page['start_from'] + $forum_page['item_count']).'</span></a></span>';
$forum_page['post_actions']['quote'] = '<span class="quote-post'.(empty($forum_page['post_actions']) ? ' first-item' : '').'"><a href="'.forum_link($forum_url['quote'], array($id, $cur_post['id'])).'">'.$lang_topic['Quote'].'<span> '.$lang_topic['Post'].' '.forum_number_format($forum_page['start_from'] + $forum_page['item_count']).'</span></a></span>';
}
}
else
{
if ($cur_topic['closed'] == '0')
{
if (($cur_topic['post_replies'] == '' && $forum_user['g_post_replies'] == '1') || $cur_topic['post_replies'] == '1')
$forum_page['post_actions']['quote'] = '<span class="report-post'.(empty($forum_page['post_actions']) ? ' first-item' : '').'"><a href="'.forum_link($forum_url['quote'], array($id, $cur_post['id'])).'">'.$lang_topic['Quote'].'<span> '.$lang_topic['Post'].' '.forum_number_format($forum_page['start_from'] + $forum_page['item_count']).'</span></a></span>';
}
}
($hook = get_hook('vt_row_pre_post_actions_merge')) ? eval($hook) : null;
if (!empty($forum_page['post_actions']))
$forum_page['post_options']['actions'] = '<p class="post-actions">'.implode(' ', $forum_page['post_actions']).'</p>';
// Give the post some class
$forum_page['item_status'] = array(
'post',
($forum_page['item_count'] % 2 != 0) ? 'odd' : 'even'
);
if ($forum_page['item_count'] == 1)
$forum_page['item_status']['firstpost'] = 'firstpost';
if (($forum_page['start_from'] + $forum_page['item_count']) == $forum_page['finish_at'])
$forum_page['item_status']['lastpost'] = 'lastpost';
if ($cur_post['id'] == $cur_topic['first_post_id'])
$forum_page['item_status']['topicpost'] = 'topicpost';
else
$forum_page['item_status']['replypost'] = 'replypost';
// Generate the post title
if ($cur_post['id'] == $cur_topic['first_post_id'])
$forum_page['item_subject'] = sprintf($lang_topic['Topic title'], $cur_topic['subject']);
else
$forum_page['item_subject'] = sprintf($lang_topic['Reply title'], $cur_topic['subject']);
$forum_page['item_subject'] = forum_htmlencode($forum_page['item_subject']);
// Perform the main parsing of the message (BBCode, smilies, censor words etc)
$forum_page['message']['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']);
// Do signature parsing/caching
if ($cur_post['signature'] != '' && $forum_user['show_sig'] != '0' && $forum_config['o_signatures'] == '1')
{
if (!isset($signature_cache[$cur_post['poster_id']]))
$signature_cache[$cur_post['poster_id']] = parse_signature($cur_post['signature']);
$forum_page['message']['signature'] = '<div class="sig-content"><span class="sig-line"><!-- --></span>'.$signature_cache[$cur_post['poster_id']].'</div>';
}
($hook = get_hook('vt_row_pre_display')) ? eval($hook) : null;
// Do user data caching for the post
if ($cur_post['poster_id'] > 1 && !isset($user_data_cache[$cur_post['poster_id']]))
{
$user_data_cache[$cur_post['poster_id']] = array(
'author_ident' => $forum_page['author_ident'],
'author_info' => $forum_page['author_info'],
'post_contacts' => $forum_page['post_contacts']
);
($hook = get_hook('vt_row_add_user_data_cache')) ? eval($hook) : null;
}
?>
<div class="<?php echo implode(' ', $forum_page['item_status']) ?>">
<div id="p<?php echo $cur_post['id'] ?>" class="posthead">
<h3 class="hn post-ident"><?php echo implode(' ', $forum_page['post_ident']) ?></h3>
</div>
<div class="postbody<?php if ($cur_post['is_online'] == $cur_post['poster_id']) echo ' online'; ?>">
<div class="post-author">
<ul class="author-ident">
<?php echo implode("\n\t\t\t\t\t\t", $forum_page['author_ident'])."\n" ?>
</ul>
<ul class="author-info">
<?php echo implode("\n\t\t\t\t\t\t", $forum_page['author_info'])."\n" ?>
</ul>
</div>
<div class="post-entry">
<h4 id="pc<?php echo $cur_post['id'] ?>" class="entry-title hn"><?php echo $forum_page['item_subject'] ?></h4>
<div class="entry-content">
<?php echo implode("\n\t\t\t\t\t\t", $forum_page['message'])."\n" ?>
</div>
<?php ($hook = get_hook('vt_row_new_post_entry_data')) ? eval($hook) : null; ?>
</div>
</div>
<?php if (!empty($forum_page['post_options'])): ?>
<div class="postfoot">
<div class="post-options">
<?php echo implode("\n\t\t\t\t\t", $forum_page['post_options'])."\n" ?>
</div>
</div>
<?php endif; ?>
</div>
<?php
}
}
?>
</div>
<div class="main-foot">
<?php
if (!empty($forum_page['main_foot_options']))
echo "\n\t\t\t".'<p class="options">'.implode(' ', $forum_page['main_foot_options']).'</p>';
?>
<h2 class="hn"><span><?php echo $forum_page['items_info'] ?></span></h2>
</div>
<?php
($hook = get_hook('vt_end')) ? eval($hook) : null;
$tpl_temp = forum_trim(ob_get_contents());
$tpl_main = str_replace('<!-- forum_main -->', $tpl_temp, $tpl_main);
ob_end_clean();
// END SUBST - <!-- forum_main -->
// Display quick post if enabled
if ($forum_config['o_quickpost'] == '1' &&
!$forum_user['is_guest'] &&
($cur_topic['post_replies'] == '1' || ($cur_topic['post_replies'] == '' && $forum_user['g_post_replies'] == '1')) &&
($cur_topic['closed'] == '0' || $forum_page['is_admmod']))
{
// START SUBST - <!-- forum_qpost -->
ob_start();
($hook = get_hook('vt_qpost_output_start')) ? eval($hook) : null;
// Setup form
$forum_page['form_action'] = forum_link($forum_url['new_reply'], $id);
$forum_page['form_attributes'] = array();
$forum_page['hidden_fields'] = array(
'form_sent' => '<input type="hidden" name="form_sent" value="1" />',
'form_user' => '<input type="hidden" name="form_user" value="'.((!$forum_user['is_guest']) ? forum_htmlencode($forum_user['username']) : 'Guest').'" />',
'csrf_token' => '<input type="hidden" name="csrf_token" value="'.generate_form_token($forum_page['form_action']).'" />'
);
if (!$forum_user['is_guest'] && $forum_config['o_subscriptions'] == '1' && ($forum_user['auto_notify'] == '1' || $cur_topic['is_subscribed']))
$forum_page['hidden_fields']['subscribe'] = '<input type="hidden" name="subscribe" value="1" />';
// Setup help
$forum_page['main_head_options'] = array();
if ($forum_config['p_message_bbcode'] == '1')
$forum_page['text_options']['bbcode'] = '<span'.(empty($forum_page['text_options']) ? ' class="first-item"' : '').'><a class="exthelp" href="'.forum_link($forum_url['help'], 'bbcode').'" title="'.sprintf($lang_common['Help page'], $lang_common['BBCode']).'">'.$lang_common['BBCode'].'</a></span>';
if ($forum_config['p_message_img_tag'] == '1')
$forum_page['text_options']['img'] = '<span'.(empty($forum_page['text_options']) ? ' class="first-item"' : '').'><a class="exthelp" href="'.forum_link($forum_url['help'], 'img').'" title="'.sprintf($lang_common['Help page'], $lang_common['Images']).'">'.$lang_common['Images'].'</a></span>';
if ($forum_config['o_smilies'] == '1')
$forum_page['text_options']['smilies'] = '<span'.(empty($forum_page['text_options']) ? ' class="first-item"' : '').'><a class="exthelp" href="'.forum_link($forum_url['help'], 'smilies').'" title="'.sprintf($lang_common['Help page'], $lang_common['Smilies']).'">'.$lang_common['Smilies'].'</a></span>';
($hook = get_hook('vt_quickpost_pre_display')) ? eval($hook) : null;
?>
<div class="main-subhead">
<h2 class="hn"><span><?php echo $lang_topic['Quick post'] ?></span></h2>
</div>
<div id="brd-qpost" class="main-content main-frm">
<?php if (!empty($forum_page['text_options'])) echo "\t".'<p class="content-options options">'.sprintf($lang_common['You may use'], implode(' ', $forum_page['text_options'])).'</p>'."\n" ?>
<div id="req-msg" class="req-warn ct-box error-box">
<p class="important"><?php echo $lang_topic['Required warn'] ?></p>
</div>
<form class="frm-form frm-ctrl-submit" method="post" accept-charset="utf-8" action="<?php echo $forum_page['form_action'] ?>"<?php if (!empty($forum_page['form_attributes'])) echo ' '.implode(' ', $forum_page['form_attributes']) ?>>
<div class="hidden">
<?php echo implode("\n\t\t\t\t", $forum_page['hidden_fields'])."\n" ?>
</div>
<?php ($hook = get_hook('vt_quickpost_pre_fieldset')) ? eval($hook) : null; ?>
<fieldset class="frm-group group1">
<legend class="group-legend"><strong><?php echo $lang_common['Write message legend'] ?></strong></legend>
<?php ($hook = get_hook('vt_quickpost_pre_message_box')) ? eval($hook) : null; ?>
<div class="txt-set set1">
<div class="txt-box textarea required">
<label for="fld1"><span><?php echo $lang_common['Write message'] ?></span></label>
<div class="txt-input"><span class="fld-input"><textarea id="fld1" name="req_message" rows="7" cols="95" required spellcheck="true" ></textarea></span></div>
</div>
</div>
<?php ($hook = get_hook('vt_quickpost_pre_fieldset_end')) ? eval($hook) : null; ?>
</fieldset>
<?php ($hook = get_hook('vt_quickpost_fieldset_end')) ? eval($hook) : null; ?>
<div class="frm-buttons">
<span class="submit primary"><input type="submit" name="submit_button" value="<?php echo $lang_common['Submit'] ?>" /></span>
<span class="submit"><input type="submit" name="preview" value="<?php echo $lang_common['Preview'] ?>" /></span>
</div>
</form>
</div>
<?php
($hook = get_hook('vt_quickpost_end')) ? eval($hook) : null;
$tpl_temp = forum_trim(ob_get_contents());
$tpl_main = str_replace('<!-- forum_qpost -->', $tpl_temp, $tpl_main);
ob_end_clean();
// END SUBST - <!-- forum_qpost -->
}
// Increment "num_views" for topic
if ($forum_config['o_topic_views'] == '1')
{
$query = array(
'UPDATE' => 'topics',
'SET' => 'num_views=num_views+1',
'WHERE' => 'id='.$id,
);
($hook = get_hook('vt_qr_increment_num_views')) ? eval($hook) : null;
$forum_db->query_build($query) or error(__FILE__, __LINE__);
}
$forum_id = $cur_topic['forum_id'];
require FORUM_ROOT.'footer.php';