forked from kestasjk/webDiplomacy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathforum.php
executable file
·715 lines (587 loc) · 24.6 KB
/
forum.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
704
705
706
707
708
709
710
711
712
713
714
715
<?php
/*
Copyright (C) 2004-2010 Kestas J. Kuliukas
This file is part of webDiplomacy.
webDiplomacy is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
webDiplomacy is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with webDiplomacy. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @package Base
*/
require_once('header.php');
require_once(l_r('pager/pagerforum.php'));
require_once(l_r('lib/message.php'));
/*
* The forum page, unfortunately one of the oldest pieces of code and gradually hacked on
* without getting packaged up. This has left a mess with quite a few script-wide variables,
* but this is the basic flow:
*
* - Check whether we're viewing the postbox or which topic we're viewing
* - Determine the correct page to display given the session data and viewtopic data
* - Check for new threads/replies. Check them for problems and post them.
* - Post the postbox / pager
* - Select the threads for this page
* - For each thread check it's selected, if so print the replies to the thread
* - Post a reply box if needed
* - Once done post the finishing page selector, and save the current time of viewing the forum
* so the user can come back after checking a game and see what's new and what was new before
* he logged on.
*/
/* Is the post box open, which thread are we viewing? */
$postboxopen = false;
$viewthread = false;
if ( isset($_REQUEST['threadID']) )
$_REQUEST['viewthread'] = $_REQUEST['threadID'];
if( $User->type['User'] AND isset($_REQUEST['postboxopen'])) {
$postboxopen = (bool) $_REQUEST['postboxopen'];
} elseif (isset($_REQUEST['viewthread'])) {
$viewthread = (int) $_REQUEST['viewthread'];
} elseif (isset($_SESSION['viewthread'])) {
$viewthread = $_SESSION['viewthread'];
}
if( !$viewthread) $viewthread=false;
$forumPager = new PagerForum($Misc->ForumThreads);
//$pageCount = $currentPage = ceil(($Misc->ForumThreads+1)/$forumPager->pageCount);
if( !isset($_SESSION['lastSeenForum']) || $_SESSION['lastSeenForum'] < $User->timeLastSessionEnded )
{
$_SESSION['lastSeenForum']=$User->timeLastSessionEnded;
}
if( !isset($_REQUEST['page']) && isset($_REQUEST['viewthread']) && $viewthread )
{
unset($orderIndex);
list($orderIndex) = $DB->sql_row("SELECT b.latestReplySent FROM wD_ForumMessages b WHERE b.id = ".$viewthread);
if(!isset($orderIndex) || !$orderIndex)
libHTML::notice(l_t('Thread not found'), l_t("The thread you requested wasn't found."));
list($position) = $DB->sql_row(
"SELECT COUNT(*)-1 FROM wD_ForumMessages a WHERE a.latestReplySent >= ".$orderIndex." AND a.type='ThreadStart'"
);
$forumPager->currentPage = $forumPager->pageCount - floor($position/PagerForum::$defaultPostsPerPage);
}
if( !isset($_REQUEST['newmessage']) ) $_REQUEST['newmessage'] = '';
if( !isset($_REQUEST['newsubject']) ) $_REQUEST['newsubject'] = '';
$new = array('message' => "", 'subject' => "", 'id' => -1);
if(isset($_REQUEST['newmessage']) AND $User->type['User']
AND ($_REQUEST['newmessage'] != "") ) {
// We're being asked to send a message.
$new['message'] = $DB->msg_escape($_REQUEST['newmessage']);
if( isset($_REQUEST['newsubject']) )
{
$new['subject'] = $DB->escape($_REQUEST['newsubject']);
}
$new['sendtothread'] = $viewthread;
if( $User->isSilenced() )
{
$messageproblem = l_t("You have been silenced, if you think this is a mistake please contact the administrator.");
$postboxopen = !$new['sendtothread'];
}
elseif( isset($_SESSION['lastPostText']) && $_SESSION['lastPostText'] == $new['message'] )
{
$messageproblem = l_t("You are posting the same message again, please don't post repeat messages.");
$postboxopen = !$new['sendtothread'];
}
elseif( isset($_SESSION['lastPostTime']) && $_SESSION['lastPostTime'] > (time()-20)
&& ! ( $new['sendtothread'] && isset($_SESSION['lastPostType']) && $_SESSION['lastPostType']=='ThreadStart' ) )
{
$messageproblem = l_t("You are posting too frequently, please slow down.");
$postboxopen = !$new['sendtothread'];
}
else
{
if(!$new['sendtothread']) // New thread to the forum
{
if ( 4 <= substr_count($new['message'], '<br />') )
{
$messageproblem = l_t("Too many lines in this message; ".
"please write a summary of the message in less than 4 ".
"lines and write the rest of the message as a response.");
$postboxopen = true;
}
elseif( 500 < strlen($new['message']) )
{
$messageproblem = l_t("Too many characters in this message; ".
"please write a summary of the message in less than 500 ".
"characters and write the rest of the message as a response.");
$postboxopen = true;
}
elseif( empty($new['subject']) )
{
$messageproblem = l_t("You haven't given a subject.");
$postboxopen = true;
}
elseif( strlen($new['subject'])>=90 )
{
$messageproblem = l_t("Subject is too long, please keep it within 90 characters.");
$postboxopen = true;
}
else
{
try
{
$subjectWords = explode(' ', $new['subject']);
foreach( $subjectWords as $subjectWord )
if( strlen($subjectWord)> 25 )
throw new Exception(l_t("A word in the subject, '%s' is longer than 25 ".
"characters, please choose a subject with normal words.",$subjectWord));
$new['id'] = Message::send(0,
$User->id,
$new['message'],
$new['subject'],
'ThreadStart');
$_SESSION['lastPostText']=$new['message'];
$_SESSION['lastPostTime']=time();
$_SESSION['lastPostType']='ThreadStart';
$messageproblem = l_t("Thread posted sucessfully.");
$new['message'] = "";
$new['subject'] = "";
$postboxopen = false;
$viewthread = $new['id'];
}
catch(Exception $e)
{
$messageproblem=$e->getMessage();
$postboxopen = true;
}
}
}
else
{
// To a thread
$threadDetails = $DB->sql_hash(
"SELECT f.id, f.latestReplySent,
f.silenceID,
silence.userID as silenceUserID,
silence.postID as silencePostID,
silence.moderatorUserID as silenceModeratorUserID,
silence.enabled as silenceEnabled,
silence.startTime as silenceStartTime,
silence.length as silenceLength,
silence.reason as silenceReason
FROM wD_ForumMessages f
LEFT JOIN wD_Silences silence ON ( f.silenceID = silence.id )
WHERE f.id=".$new['sendtothread']."
AND f.type='ThreadStart'");
unset($messageproblem);
if( $threadDetails['latestReplySent'] < $Misc->ThreadAliveThreshold )
{
$messageproblem=l_t("The thread you are attempting to reply to is too old, and has expired.");
}
elseif( Silence::isSilenced($threadDetails) ) {
$silence = new Silence($threadDetails);
if( $silence->isEnabled() ) {
$messageproblem=l_t("The thread you are attempting to reply to has been silenced; ").$silence->reason;
}
unset($silence);
}
if( isset($threadDetails['id']) && !isset($messageproblem) )
{
// It's being sent to an existing, non-silenced / dated thread.
try
{
$new['id'] = Message::send( $new['sendtothread'],
$User->id,
$new['message'],
'',
'ThreadReply');
$_SESSION['lastPostText']=$new['message'];
$_SESSION['lastPostTime']=time();
$_SESSION['lastPostType']='ThreadReply';
header("Location: " . $_SERVER['REQUEST_URI'] . '&reply=success');
}
catch(Exception $e)
{
$messageproblem=$e->getMessage();
}
}
else
{
$messageproblem=l_t("The thread you attempted to reply to doesn't exist.");
}
unset($threadDetails);
}
}
if ( isset($messageproblem) and $new['id'] != -1 )
{
$_REQUEST['newmessage'] = '';
$_REQUEST['newsubject'] = '';
}
}
else
{
/*
* This isn't very secure, it could potentially lead to XSS attacks, but it
* is the easiest way to un-escape a failed post without having to use a
* UTF-8 library to replace strings
*/
$_REQUEST['newmessage'] = '';
$_REQUEST['newsubject'] = '';
}
$_SESSION['viewthread'] = $viewthread;
if (isset($_REQUEST['reply']) && $_REQUEST['reply'] == 'success') {
$messageproblem=l_t("Reply posted sucessfully.");
$new['message']=""; $new['subject']=""; $new['sendtothread']=$viewthread;
}
libHTML::starthtml();
if( $User->type['Guest'] )
print libHTML::pageTitle(l_t('Forum'), l_t('A place to discuss topics/games with other webDiplomacy players.'));
else
print '<div class="content">';
if(isset($messageproblem) and !$new['sendtothread']) {
print '<p class="notice"><a name="postbox"></a>'.$messageproblem.'</p>';
libHTML::pagebreak();
}
print '<div class="forum"><a name="forum"></a>';
print '
<div id="forumPostbox" style="'.($postboxopen?'':libHTML::$hideStyle).'" class="thread threadalternate1 threadborder1">
<div style="margin:0;padding:0">
<div class="message-head">
<strong>'.l_t('Start a new discussion in the public forum').'</strong>
</div>
<div class="message-subject"><strong>'.l_t('Post a new thread').'</strong></div>
<div style="clear:both;"></div>
</div>
<div class="hr"></div>
';
if( $User->isSilenced() ) {
print '<div class="message-body postbox" style="padding-top:0; padding-left:auto; padding-right:auto">';
print '<p>'.l_t('Cannot post due to a temporary silence:').$User->getActiveSilence()->toString().'</p>
<div class="hr"></div>
<p>'.l_t('Please see <a class="light" href="rules.php#silenceInfo">our silenced section</a> '.
'for info on how to dispute it or get the length reduced.').'</p>';
print '</div>';
}
else
{
print '
<div class="message-body threadalternate1 postboxadvice">
'.l_t('If your post relates to a particular game please include the <strong>URL or ID#</strong>
of the game.').'<br />
'.l_t('We get a lot of feature requests. If your feature request isn\'t already on our <a href="https://github.com/kestasjk/webDiplomacy/issues">issue tracker</a>,
then the best place to ask is the forum. This will help us gauge support for your ideas, before we add it to the todo list.').'<br />
'.l_t('If you are posting a question please <strong>check the <a href="faq.php">FAQ</a></strong> before posting.').'<br />
'.l_t('If your message is long you may need to write a summary message, and add the full message as a reply.').'
</div>
<div class="hr" ></div>
<div class="message-body postbox" style="padding-top:0; padding-left:auto; padding-right:auto">
<form class="safeForm" action="forum.php#postbox" method="post"><p>
<div style="text-align:left; width:80%; margin-left:auto; margin-right:auto; float:middle">
<strong>'.l_t('Subject:').'</strong><br />
<input class="new-subject" style="width:100%" maxLength=2000 size=60 name="newsubject" value="'.$_REQUEST['newsubject'].'"><br /><br />
<strong>'.l_t('Message:').'</strong><br />
<TEXTAREA NAME="newmessage" ROWS="6" style="width:100%">'.$_REQUEST['newmessage'].'</TEXTAREA>
<input type="hidden" name="viewthread" value="0" />
</div>
<br />
<input type="submit" class="form-submit" value="'.l_t('Post new thread').'" name="'.l_t('Post').'">
</p></form>
</div>';
}
print '<div class="hr"></div>
<div class="message-foot threadalternate1">
<form action="forum.php" method="get" onsubmit="$(\'forumPostbox\').hide(); $(\'forumOpenPostbox\').show(); return false;">
<input type="hidden" name="postboxopen" value="0" />
<input type="submit" class="form-submit" value="'.l_t('Cancel').'" />
</form>
</div>
</div>';
print '<div>';
print $forumPager->html();
if($User->type['User'] )
{
print '<div id="forumOpenPostbox" style="'.($postboxopen?libHTML::$hideStyle:'').'" >
<form action="forum.php#postbox" method="get" onsubmit="$(\'forumPostbox\').show(); $(\'forumOpenPostbox\').hide(); return false;">
<p style="padding:5px;">
<input type="hidden" name="postboxopen" value="1" />
<input type="hidden" name="page" value="'.$forumPager->pageCount.'" />
<input type="submit" class="form-submit" value="'.l_t('New thread').'" />
</p>
</form>
</div>';
}
print '<div style="clear:both;"> </div>
</div>
';
$cacheHTML=libCache::dirName('forum').'/page_'.$forumPager->currentPage.'.html';
if( file_exists($cacheHTML) )
print $cacheHTML;
$tabl = $DB->sql_tabl("SELECT
f.id, f.fromUserID, f.timeSent, f.message, f.subject, f.replies,
u.username as fromusername, u.points as points, f.latestReplySent, IF(s.userID IS NULL,0,1) as online, u.type as userType,
f.likeCount as likeCount,
f.silenceID,
silence.userID as silenceUserID,
silence.postID as silencePostID,
silence.moderatorUserID as silenceModeratorUserID,
silence.enabled as silenceEnabled,
silence.startTime as silenceStartTime,
silence.length as silenceLength,
silence.reason as silenceReason
FROM wD_ForumMessages f
INNER JOIN wD_Users u ON ( f.fromUserID = u.id )
LEFT JOIN wD_Sessions s ON ( u.id = s.userID )
LEFT JOIN wD_Silences silence ON ( f.silenceID = silence.id )
WHERE f.type = 'ThreadStart'
ORDER BY f.latestReplySent DESC
".$forumPager->SQLLimit());
/*
* If it's a new post, jump to it
*
*/
$switch = 2;
while( $message = $DB->tabl_hash($tabl) )
{
if( Silence::isSilenced($message) )
$silence = new Silence($message);
else
unset($silence);
// Check for mutes first, before continuing
$muteLink='';
if( $User->type['User'] ) {
$isThreadMuted = $User->isThreadMuted($message['id']);
if( isset($_REQUEST['toggleMuteThreadID']) && $_REQUEST['toggleMuteThreadID']==$message['id'] ) {
$User->toggleThreadMute($message['id']);
$isThreadMuted = !$isThreadMuted;
}
if( $isThreadMuted ) continue;
$toggleMuteURL = 'forum.php?toggleMuteThreadID='.$message['id'].'&rand='.rand(1,99999).'#'.$message['id'];
$muteLink = ' <br /><a title="'.l_t('Mute this thread, hiding it from your forum and home page').'" class="light likeMessageToggleLink" href="'.$toggleMuteURL.'">'.l_t(($isThreadMuted ? 'Un-mute' : 'Mute' ).' thread').'</a>';
if( $User->type['Admin'] || $User->type['ForumModerator'] ) {
$muteLink .= '<br /><span class="likeMessageToggleLink">'.l_t('Silence:').' ';
if( isset($silence) && $silence->isEnabled() ) {
$muteLink .= '<a class="light" href="admincp.php?tab=Control%20Panel&silenceID='.$silence->id.'#disableSilence">'.l_t('Disable silence').'</a>';
}
else
{
$muteLink .= '<a class="light" href="admincp.php?tab=Control%20Panel&postID='.$message['id'].'#createThreadSilence">'.l_t('thread').'</a>, ';
$muteLink .= '<a class="light" href="admincp.php?tab=Control%20Panel&postID='.$message['id'].'&userID='.$message['fromUserID'].'#createUserThreadSilence">'.l_t('user').'</a>';
}
$muteLink .= '</span>';
}
}
print '<div class="hr userID'.$message['fromUserID'].' threadID'.$message['id'].'"></div>'; // Add the userID and threadID so muted users/threads dont create lines where their threads were
$switch = 3-$switch; // 1,2,1,2,1,2...
$messageAnchor = '<a name="'.($new['id'] == $message['id'] ? 'postbox' : $message['id']).'"></a>';
print '<div class="thread threadID'.$message['id'].' threadborder'.$switch.' threadalternate'.$switch.' userID'.$message['fromUserID'].'">';
// New or archived posts anchor to the start of the thread
if ( $User->timeLastSessionEnded < $message['timeSent'] || $message['latestReplySent'] < $Misc->ThreadAliveThreshold )
{
print $messageAnchor;
$messageAnchor = '';
}
if ( $message['replies'] == 0 )
{
print $messageAnchor;
}
print '<div class="leftRule message-head threadalternate'.$switch.'">
<a href="profile.php?userID='.$message['fromUserID'].'">'.$message['fromusername'].
' '.
' ('.$message['points'].' '.libHTML::points().User::typeIcon($message['userType']).')</a>'.
'<br />
<strong><em>'.libTime::text($message['timeSent']).'</em></strong>'.$muteLink.'<br />
'.$User->likeMessageToggleLink($message['id'],$message['fromUserID']).libHTML::likeCount($message['likeCount']).
'</div>';
print '<div class="message-subject">';
print libHTML::forumMessage($message['id'],$message['latestReplySent']);
print libHTML::forumParticipated($message['id']);
if ( $message['latestReplySent'] < $Misc->ThreadAliveThreshold ) {
$postLockedReason = l_t("Thread is too old to reply to");
}
elseif(isset($silence) && $silence->isEnabled())
{
$postLockedReason = l_t("This thread has been locked; ").$silence->reason;
}
elseif( $User->isSilenced() )
{
$postLockedReason = l_t("This account has been silenced; ").$User->getActiveSilence()->reason;
}
else
{
unset($postLockedReason);
}
if( isset($postLockedReason) ) {
print '<img src="'.l_s('images/icons/lock.png').'" title="'.$postLockedReason.'" /> ';
}
print '<strong>'.$message['subject'].'</strong>';
print '</div>
<div class="message-body threadalternate'.$switch.'">
<div class="message-contents" fromUserID="'.$message['fromUserID'].'">
'.$message['message'].'
</div>
</div>
<div style="clear:both;"></div>';
if( $message['id'] == $viewthread )
{
$replyToID = $message['id']; // If there are no replies this will ensure the thread is still marked as read
$replyID = $message['id'];
if ( $message['replies'] > 50 )
{
$threadPager = new pagerThread( $message['replies'],$message['id']);
$threadPager->pagerBar('threadPager');
}
// We are viewing the thread; print replies
$replytabl = $DB->sql_tabl(
"SELECT f.id, fromUserID, f.timeSent, f.message, u.points as points, IF(s.userID IS NULL,0,1) as online,
u.username as fromusername, f.toID, u.type as userType,
f.likeCount,
f.silenceID,
silence.userID as silenceUserID,
silence.postID as silencePostID,
silence.moderatorUserID as silenceModeratorUserID,
silence.enabled as silenceEnabled,
silence.startTime as silenceStartTime,
silence.length as silenceLength,
silence.reason as silenceReason
FROM wD_ForumMessages f
INNER JOIN wD_Users u ON f.fromUserID = u.id
LEFT JOIN wD_Sessions s ON ( u.id = s.userID )
LEFT JOIN wD_Silences silence ON ( f.silenceID = silence.id )
WHERE f.toID=".$message['id']." AND f.type='ThreadReply'
order BY f.timeSent ASC
".(isset($threadPager)?$threadPager->SQLLimit():''));
$replyswitch = 2;
$replyNumber = 0;
list($maxReplyID) = $DB->sql_row("SELECT MAX(id) FROM wD_ForumMessages WHERE toID=".$message['id']." AND type='ThreadReply'");
while($reply = $DB->tabl_hash($replytabl) )
{
$replyToID = $reply['toID'];
$replyID = $reply['id'];
$replyswitch = 3-$replyswitch;//1,2,1,2,1...
print '<div class="reply replyborder'.$replyswitch.' replyalternate'.$replyswitch.'
'.($replyNumber ? '' : 'reply-top').' userID'.$reply['fromUserID'].'">';
$replyNumber++;
print '<a name="'.$reply['id'].'"></a>';
if ( $new['id'] == $reply['id'] )
{
print '<a name="postbox"></a>';
$messageAnchor = '';
}
elseif ( $User->timeLastSessionEnded < $reply['timeSent'] )
{
print $messageAnchor;
$messageAnchor = '';
}
elseif ( $reply['id'] == $maxReplyID )
{
print $messageAnchor;
$messageAnchor = '';
}
print '<div class="message-head replyalternate'.$replyswitch.' leftRule">';
print '<strong><a href="profile.php?userID='.$reply['fromUserID'].'">'.$reply['fromusername'].' '.
' ('.$reply['points'].' '.libHTML::points().User::typeIcon($reply['userType']).')</a>'.
'</strong><br />';
print libHTML::forumMessage($message['id'],$reply['id']);
print '<em>'.libTime::text($reply['timeSent']).'</em>';
print '<br />'.$User->likeMessageToggleLink($reply['id'],$reply['fromUserID']).libHTML::likeCount($reply['likeCount']);
if( $User->type['Admin'] || $User->type['ForumModerator'] ) {
if( Silence::isSilenced($reply) )
$silence = new Silence($reply);
else
unset($silence);
print '<br />';
if( isset($silence) && $silence->isEnabled() )
print '<a class="light likeMessageToggleLink" href="admincp.php?tab=Control%20Panel&silenceID='.$silence->id.'#disableSilence">'.l_t('Disable silence').'</a>';
else
print '<a class="light likeMessageToggleLink" href="admincp.php?tab=Control%20Panel&postID='.$reply['id'].'&userID='.$reply['fromUserID'].'#createUserThreadSilence">'.l_t('Silence user').'</a>';
}
print '</div>';
print '
<div class="message-body replyalternate'.$replyswitch.'">
<div class="message-contents" fromUserID="'.$reply['fromUserID'].'">
'.$reply['message'].'
</div>
</div>
<div style="clear:both"></div>
</div>';
}
unset($replytabl, $replyfirst, $replyswitch);
print '<br />';
if (isset($threadPager) && $threadPager->currentPage < $threadPager->pageCount)
{
$threadPager->pagerBar('threadPager');
}
else
{
print '<form action="forum.php#'.$replyID.'" method="get">
<input type="hidden" name="viewthread" value="'.$message['id'].'" />
<input type="hidden" name="rand" value="'.rand(0,99999).'" />
<input type="submit" class="form-submit" value="'.l_t('Refresh').'"
title="'.l_t('Refresh your view of this thread to see if there are any new replies').'" />
</form>';
}
}
// Replies done, now print the footer
print '<div class="message-foot threadalternate'.$switch.'">';
// Now we show the Reply and Close Thread box.
if ( $message['id'] == $viewthread )
{
if($User->type['User'] && !isset($postLockedReason) )
{
print '<div class="postbox">'.
( $new['id'] != (-1) ? '' : '<a name="postbox"></a>').
'<form class="safeForm" action="./forum.php?newsendtothread='.$viewthread.'&viewthread='.$viewthread.'#postbox" method="post">
<input type="hidden" name="page" value="1" />
<p>';
print '<div class="hrthin"></div>';
if ( isset($messageproblem) and $new['sendtothread'] )
{
print '<p class="notice">'.$messageproblem.'</p>';
}
print '<TEXTAREA NAME="newmessage" style="margin-bottom:5px;" ROWS="4">'.$_REQUEST['newmessage'].'</TEXTAREA><br />
<input type="hidden" value="'.libHTML::formTicket().'" name="formTicket">
<input type="hidden" name="page" value="'.$forumPager->pageCount.'" />
<input type="submit" class="form-submit" value="'.l_t('Post reply').'" name="'.l_t('Reply').'"></p></form>
</div>
<div class="hrthin"></div>';
} else {
print '<br />';
}
}
print '<div class="message-foot-notification threadalternate'.$switch.'">
<em><strong>'.$message['replies'].'</strong> '.($message['replies']==1?l_t('reply'):l_t('replies')).'</em>
</div>';
if ( $message['id'] == $viewthread )
{
print '<form action="forum.php#'.$message['id'].'" method="get">
<input type="hidden" name="viewthread" value="0" />
<input type="submit" class="form-submit" value="'.l_t('Close').'" />
</form>';
}
else
{
print '<a href="forum.php?viewthread='.$message['id'].'#'.$message['id'].'" '.
'title="'.l_t('Open this thread to view the replies, or post your own reply').'">'.l_t('Open').'</a>';
/*
print '<form action="forum.php#'.$message['id'].'" method="get">
<input type="hidden" name="viewthread" value="'.$message['id'].'" />
<input type="submit" class="form-submit" value="Open"
title="Open this thread to view the replies, or post your own reply" />
</form>';
*/
}
print "</div>
</div>";
}
print '<div class="hr"></div>';
print '<div>';
print $forumPager->html('bottom');
print '<div><a href="#forum">'.l_t('Back to top').'</a><a name="bottom"></a></div>';
print '<div style="clear:both;"> </div>
</div>';
print '</div>';
print '</div>';
if( $User->type['User'] )
{
if( isset($replyToID) )
libHTML::$footerScript[] = 'readThread('.$replyToID.', '.$replyID.');';
}
libHTML::$footerScript[] = 'makeFormsSafe();';
$_SESSION['lastSeenForum']=time();
libHTML::footer();
?>