-
Notifications
You must be signed in to change notification settings - Fork 0
/
topicdisplay.php
635 lines (454 loc) · 18.6 KB
/
topicdisplay.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
<?php
ob_start();
// = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
// TextfileBB
// Website: http://tfbb.jcink.com
//
// Modify freely, as long as you're not turning the forum
// into a board service of any form. Please ask for permission
// first to redistribute any of the TextfileBB code.
//
// Thanks.
//
// ----------------------------------------------------------------------------------------
// Module: topicdisplay.php - Last update: Sept 28, 2006
// ----------------------------------------------------------------------------------------
//
//
// = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
// "wear" are the files?!
require("header.php");
require("moderate.php");
require("forum_conf.php");
$cookie_filter_forum=str_replace(" ", "_", $forum);
$cookievarname="newposts_{$cookie_filter_forum}";
$NewPostsCheck=explode(",", $_COOKIE[$cookievarname]);
$TopicNewCheckArray=Array();
foreach($NewPostsCheck as $key=>$value){
$gogobunchierangeeeerrrrsss=explode("|", $value);
$TopicNewCheckArray[$gogobunchierangeeeerrrrsss[0]]=$gogobunchierangeeeerrrrsss[1];
}
$arch='';
// Are we opening an archive?
if ($_GET['archive'] == 1) {
$arch = 'old/';
}
// Get the permissions file...
$forum=htmlspecialchars($forum, ENT_QUOTES);
if(file_exists("./permissions/{$forum}.php")) {
require("./permissions/{$forum}.php");
if ($can_read["$status"] != allowed) {
error("You do not have permission to view this forum.");
}
} else {
error("Invalid forum ID");
}
if ($password_needed == Yes) { // start if password needed
$PasswordCookie = $_COOKIE["textfilebb_board_password"];
if (!isset($PasswordCookie)) {
if ($_POST['LoL_Sean']) {
require("./permissions/{$forum}.php");
if ($board_password != $_POST['LoL_Sean']) {
error("Access denied. Password incorrect.");
} else {
setcookie("textfilebb_board_password", $_POST['LoL_Sean']);
error ("Access approved. Password correct. <a href='topicdisplay.php?forum=$forum'>Click here</a>");
}
}
echo "<div align='center'><div class='tableborder'><table width=100%% cellpadding='4' cellspacing='1'><td width=60%% align=center class=headertableblock>Password Required</td><tr><td class=arcade1 valign=top><div align=center>This forum is password protected. If you are authorized, please enter the password below. <br><br><form action='' method='POST'><input type=text name=LoL_Sean><input type=submit name=go value=Go></form></div></td></table></div><br>";
require("footer.php");
die();
} //end isset
if ($board_password != $PasswordCookie) {
error("Access denied. Password cookie was wrong.");
} // end check
} // end if password needed
//gues this is wear i put the function
//======================================
function topiclist($forum,$topictitle,$sticky) {
$counter = "./forumposts_{$forum}/{$sticky}{$topictitle}.php";
$hits = count(@file($counter))/3;
require('forum_conf.php');
if ($hits-1 > $intopiclim) {
// Page 1 starts here
echo " (Pages: <a href='viewtopic.php?topicid=$topictitle&forum=$forum&limit=0&show=$intopiclim&p=1'><u>1</u></a>";
// Page 2 check
if ($hits-1 > $intopiclim) {
$thing = $intopiclim+$intopiclim;
echo " <a href='viewtopic.php?topicid=$topictitle&forum=$forum&limit=$intopiclim&show=$thing&p=2'><u>2</u></a>";
}
// Page 3 check
if ($hits-1 > $intopiclim+$intopiclim) {
$thingpage3 = $intopiclim+$intopiclim+$intopiclim;
echo " <a href='viewtopic.php?topicid=$topictitle&forum=$forum&limit=$thing&show=$thingpage3&p=3'><u>3</u></a>";
}
$finalpage = $intopiclim + $intopiclim + $intopiclim;
// Final Page
if ($hits-1 > $finalpage) {
$howmany = $hits/$intopiclim;
// Hmm I think it's that what, even though you have .5 you still round down?
// So I add .2
// I can see it now... if DM ever sees this it will be "wHY are you rounding?!?!"
$r = round($howmany+.2);
$s=$intopiclim*$r;
$l=$s-$intopiclim;
//if ($l == $hits-1) {
//$s=$intopiclim*$r2;
//$l=$s-$intopiclim;
//}
echo " ... <a href='viewtopic.php?topicid=$topictitle&forum=$forum&limit=$l&show=$s'><u>»</u></a>";
}
echo ")";
}
}
//=====================================
// Define limit and show...
// And check for the limit var
$limit = $_GET['limit'];
$show = $_GET['show'];
if (!$limit) {
$limit=0;
}
if (!$page) {
$page=1;
}
if (!$show) {
require('forum_conf.php');
$countstuff = opendir("./forumposts_{$forum}/{$arch}");
$total_forums = 0;
while($file = readdir($countstuff)){
if($file != '.' && $file != '..' && $file != 'sticky' ){
$total_forums++;
}
}
closedir($countstuff);
if ($showtopics > $total_forums ) {
$show = "$total_forums";
} else {
$show = "$showtopics";
}
}
// lazyness or "smth" >_>
$num_pages_of = $showtopics;
// *************************
// Get for Pages
// *************************
$sw = $_GET['show'];
$page = $_GET['page'];
$pgn = $page + 1;
$pgnm = $page - 1;
//**************************
// *************************
// Get for the LIMIT
// *************************
$lim = $_GET['limit'];
$limn = $limit + $num_pages_of;
$limnm = $limit - $num_pages_of;
//**************************
// *************************
// Get for the LIMIT
// *************************
$sw = $_GET['show'];
$swn = $show + $num_pages_of;
$swnm = $show - $num_pages_of;
//**************************
require("forum_conf.php");
echo "<title>$forum_name - $forum</title>";
if(file_exists("./locked/{$forum}_forumhide_lockfile.lock")) {
?>
<br>
<div align='center'>
<div class='tableborder'><table width=100%% cellpadding='4' cellspacing='1'><td width=60%% align=center class=headertableblock>Locked Forum</td><tr>
<td class=arcade1 valign="top"><div align=center>This forum has been locked from view.</div>
</td>
</table>
</div>
<br>
<?php
require("footer.php");
die();
}
if ($forum == "") {
?>
<br>
<div align='center'>
<div class='tableborder'><table width=100%% cellpadding='4' cellspacing='1'><td width=60%% align=center class=headertableblock>Error</td><tr>
<td class=arcade1 valign="top"><div align=center>There is no forum here. Are you looking for the <a href="index.php">forum index?</a></div>
</td>
</table>
</div>
<br>
<?php
require("footer.php");
die();
}
?>
<div class=tableborder><table width=100% cellpadding='4' cellspacing='1'><td class=arcade1><div style="float: left;"><a href=index.php><?php echo "$forum_name" ?></a> » <a href='topicdisplay.php?forum=<?php echo "$forum"; ?>'><?php if ($forum) { echo "<b>$forum</b>"; } ?></a> <?php if ($archive==1) { echo "» <i>Archive.</i>"; } ?></div><div align=right><a href='new_topic.php?forum=<?php echo "$forum"; ?>'><?php echo $newtopic; ?></a></div></td></table></div>
<br>
<div class='tableborder'><table width=100%% cellpadding='5' cellspacing='1'><td width=2%% align=center class=headertableblock></td><td width=30%% align=center class=headertableblock>Topic</td><td width=2%% align=center class=headertableblock>Replies</td><td width=10%% align=center class=headertableblock>Author</td><td width=2%% align=center class=headertableblock>Views</td><td width=20%% align=center class=headertableblock>Last Reply</td><td width=1%% align=center class=headertableblock></td><tr>
<form action="" method="GET">
<?php
//````````````````````````````````````````````````````````````````````````````````````````````
//
// This area can be really shortened, but I did this quickly. A same copy and paste
//
// ```````````````````````````````````````````````````````````````````````````````````````````
# START THE STICKY
$countstuff = opendir("./forumposts_{$forum}/sticky/");
$total_topics = 0;
while($file = readdir($countstuff)){
if($file != '.' && $file != '..' && $file != 'sticky' && $file != 'old' ){
$total_topics++;
}
}
closedir($countstuff);
if ($total_topics != 0 ) {
$s = "./forumposts_{$forum}/sticky/";
$handle = opendir($s);
while($topic = readdir($handle ))
{
if( $topic == '.' || $topic == '..' || $topic == 'sticky' || $topic == 'old' )
continue;
$forumtopiclist [$topic] = filemtime($s."/".$topic);
}
// use arsort to show them by last modified date
// arsort also lets us have "bumped" topics because it doesnt go by creation but last modified.
// so when a topic is replied to, it gets bumped to the top because then it's "modified"
// get it?
arsort($forumtopiclist);
// bah
$x=0;
foreach($forumtopiclist as $key=>$value){
$t[$x]=$key;
$x++;
}
if ($total_topics < $show) {
$dosubtract = $show - $total_topics;
$resultoftest = $show - $dosubtract;
} else {
$resultoftest = $show;
}
for ($x=0; $x<$total_topics; $x++)
{
//strip the .txt off the end of the topics.
$thetopic = "$t[$x]";
$topicstrip = strrpos($thetopic, '.');
$topictitle = substr($thetopic, 0, $topicstrip);
if(file_exists("./locked/{$forum}_{$topictitle}.lock")) {
$img = "$locked_topic";
} else {
if ($hits < 15) {
$img = "$normal_topic";
} else {
$img = "$hot_topic";
}
}
$counter = "./forumposts_{$forum}/sticky/{$topictitle}.php";
$hits = count(file($counter))/3;
// ============================
// Pull up who the author is
//============================
$register_id = file("./id_data/member_names_num.txt");
$names_array = file("./forumposts_{$forum}/sticky/{$topictitle}.php");
$theauthorid = rtrim($names_array[3]);
$author = $register_id[$theauthorid];
// ============================
// And now the last replier
//============================
$key = count(file($counter))-3;
$last_replier = rtrim($names_array[$key]);
$thelastreplierid = rtrim($names_array[$key]);
$replier = $register_id[$thelastreplierid];
$date = date("m.d.y", filemtime("./forumposts_{$forum}/sticky/{$topictitle}.php"));
// Get the topic name
// We grab out of only the first line of the file
$TopicFile ="./forumposts_{$forum}/sticky/{$topictitle}.php";
$TopicName = file($TopicFile);
// get the views
$views = file("./id_data/topic_view_count.txt");
$realht = $hits-2;
// can use mod cp?
if ($can_use_modcp == Yes) {
echo "<tr><td class=arcade1 valign=top>$img</td><td class=arcade1 valign=top><b>Sticky:</b> <a href='viewtopic.php?topicid=$topictitle&p=1'>$TopicName[0]</a><br>$TopicName[1]";
topiclist($forum, $topictitle, "sticky/");
echo "</td><td class=arcade1 valign=top><div align=center>$realht</div></td><td class=arcade1 valign=top><div align=center><a href='viewprofile.php?showuser=$theauthorid'>$author</a></div></td><td class=arcade1 valign=top><div align=center>$views[$topictitle]</div></td><td class=arcade1 valign=top><div align=center>Date: $date<br> Reply by: <A href='viewprofile.php?showuser=$thelastreplierid'>$replier</a></div></td><td class=arcade1 valign=top><div align=center><input type='checkbox' name='topica[]' value='$topictitle'></div></td></div>";
} else {
echo "<tr><td class=arcade1 valign=top>$img</td><td class=arcade1 valign=top><b>Sticky:</b><a href='viewtopic.php?topicid=$topictitle&p=1'> $TopicName[0]</a><br>$TopicName[1]";
topiclist($forum,$topictitle,"sticky/");
echo "</td><td class=arcade1 valign=top><div align=center>$realht</div></td><td class=arcade1 valign=top><div align=center><a href='viewprofile.php?showuser=$theauthorid'>$author</a></div></td><td class=arcade1 valign=top><div align=center>$views[$topictitle]</div></td><td class=arcade1 valign=top><div align=center>Date: $date<br> Reply by: <A href='viewprofile.php?showuser=$thelastreplierid'>$replier</a></div></td><td class=arcade1 valign=top><div align=center></div></td></div>";
}
}
echo "<tr><td class=headertableblock colspan=8><b>^</b></td></tr>";
} else {
echo "<tr><td class=arcade1 valign=top></td><td class=arcade1 valign=top></td><td class=arcade1 valign=top></td><td class=arcade1 valign=top></td><td class=arcade1 valign=top></td><td class=arcade1 valign=top></td><td class=arcade1 valign=top></td></div>";
}
unset($countstuff);
unset($total_topics);
unset($file);
unset($topic);
unset($forumtopiclist);
# END THE STICKY
#
# Start the NON sticky topic display
#
$countstuff = opendir("./forumposts_{$forum}/{$arch}");
$total_topics = 0;
while($file = readdir($countstuff)){
if($file != '.' && $file != '..' && $file != 'sticky' && $file != 'old' ){
$total_topics++;
}
}
closedir($countstuff);
if ($total_topics != 0 ) {
$s = "./forumposts_{$forum}/{$arch}";
$handle = opendir($s);
while($topic = readdir($handle ))
{
if( $topic == '.' || $topic == '..' || $topic == 'sticky' || $topic == 'old')
continue;
$forumtopiclist [$topic] = filemtime($s."/".$topic);
}
// use arsort to show them by last modified date
// arsort also lets us have "bumped" topics because it doesnt go by creation but last modified.
// so when a topic is replied to, it gets bumped to the top because then it's "modified"
// get it?
arsort($forumtopiclist);
// bah
$x=0;
foreach($forumtopiclist as $key=>$value){
$t[$x]=$key;
$x++;
}
if ($total_topics < $show) {
$dosubtract = $show - $total_topics;
$resultoftest = $show - $dosubtract;
} else {
$resultoftest = $show;
}
for ($x=$limit; $x<$resultoftest; $x++)
{
//strip the .txt off the end of the topics.
$thetopic = "$t[$x]";
$topicstrip = strrpos($thetopic, '.');
$topictitle = substr($thetopic, 0, $topicstrip);
// ============================
// Pull up who the author is
//============================
$register_id = file("./id_data/member_names_num.txt");
$names_array = @file("./forumposts_{$forum}/{$arch}{$topictitle}.php");
$hits = count($names_array)/3;
if(file_exists("./locked/{$forum}_{$topictitle}.lock")) {
$img = "$locked_topic";
} else {
if ($hits < 15) {
$img = "$normal_topic";
} else {
$img = "$hot_topic";
}
}
$theauthorid = rtrim($names_array[3]);
$author = $register_id[$theauthorid];
// ============================
// And now the last replier
//============================
$key = count($names_array)-3;
$last_replier = rtrim($names_array[$key]);
$thelastreplierid = rtrim($names_array[$key]);
$replier = $register_id[$thelastreplierid];
$lastdate=filemtime("./forumposts_{$forum}/{$arch}{$topictitle}.php");
if(!$_GET['archive'] && !$_GET['page']) {
if(isset($_COOKIE[$cookievarname])) {
if($TopicNewCheckArray[$topictitle]<$lastdate) {
$img = "$new_posts_topicindex";
}
}
}
$date = date("m.d.y", $lastdate);
// Get the topic name
// We grab out of only the first line of the file
$lastpost_cookie_data .="$topictitle|$lastdate,";
$TopicFile ="./forumposts_{$forum}/{$arch}{$topictitle}.php";
$TopicName = $names_array;
// get the views
$views = file("./id_data/topic_view_count.txt");
$realht = $hits-2;
if ($can_use_modcp == Yes) {
if ($topictitle != "") {
echo "<tr><td class=arcade1 valign=top>$img</td><td class=arcade1 valign=top><a href='viewtopic.php?topicid=$topictitle&p=1'>$TopicName[0]</a><br>$TopicName[1]";
}
topiclist($forum, $topictitle, $arch);
if ($topictitle != "") {
echo "</td><td class=arcade1 valign=top><div align=center>$realht</div></td><td class=arcade1 valign=top><div align=center><a href='viewprofile.php?showuser=$theauthorid'>$author</a></div></td><td class=arcade1 valign=top><div align=center>$views[$topictitle]</div></td><td class=arcade1 valign=top><div align=center>Date: $date<br> Reply by: <A href='viewprofile.php?showuser=$thelastreplierid'>$replier</a></div></td><td class=arcade1 valign=top><div align=center><input type='checkbox' name='topica[]' value='$topictitle'></div></td></div>";
}
} else {
if ($topictitle != "") {
echo "<tr><td class=arcade1 valign=top>$img</td><td class=arcade1 valign=top><a href='viewtopic.php?topicid=$topictitle&p=1'>$TopicName[0]</a><br>$TopicName[1]";
}
topiclist($forum,$topictitle, $arch);
$realht = $hits-1;
if ($topictitle != "") {
echo "</td><td class=arcade1 valign=top><div align=center>$realht</div></td><td class=arcade1 valign=top><div align=center><a href='viewprofile.php?showuser=$theauthorid'>$author</a></div></td><td class=arcade1 valign=top><div align=center>$views[$topictitle]</div></td><td class=arcade1 valign=top><div align=center>Date: $date<br> Reply by: <A href='viewprofile.php?showuser=$thelastreplierid'>$replier</a></div></td><td class=arcade1 valign=top><div align=center></div></td></div>";
}
}
}
} else {
echo "<tr><td class=arcade1 valign=top></td><td class=arcade1 valign=top></td><td class=arcade1 valign=top></td><td class=arcade1 valign=top></td><td class=arcade1 valign=top></td><td class=arcade1 valign=top></td><td class=arcade1 valign=top></td></div>";
}
echo "<tr>
<td class=headertableblock colspan=9>";
?>
<div style="float: right;">
<?php
if ($limit > 0) {
echo "<a href='topicdisplay.php?&forum=$forum&limit=$limnm&show=$swnm&page=$pgnm'>Previous Page ($pgnm)</a> · ";
}
if ($total_topics < $show || $total_topics < $showtopics || $total_topics == $showtopics ) {
echo "";
} else {
echo "<a href='topicdisplay.php?&forum=$forum&limit=$limn&show=$swn&page=$pgn'> Next Page ($pgn)</a>";
}
?>
</div>
<div align="left">
<input type=hidden name=forum value='<?php echo $forum; ?>'>
<select size="1" name="archive">
<?php if ($archive == "1") {
echo "<option value=1 selected>Old Posts Archive</option>";
echo "<option value=2>Latest Threads</option>";
} else {
echo "<option value=2 selected>Latest Threads</option>";
echo "<option value=1>Old Posts Archive</option>";
}
?>
</select> <input type=submit value='Go'>
<?php
echo "</td></tr>";
?>
</font>
</table>
</div>
<br>
<?php
// Set the cookie crap
if(!$_GET['archive'] && !$_GET['page']) {
$forum_Cookie=str_replace(" ", "_", $forum);
setcookie("newposts_{$forum_Cookie}", $lastpost_cookie_data,time()+9999999);
}
//
if ($can_use_modcp == Yes) {
?>
<div align='center'>
<div class='tableborder'><table width=100%% cellpadding='0' cellspacing='1'><td width=60%% align=center class=headertableblock><select size="1" name="action"><option value='Default' selected>Action...</option><option value='stickythis'>Sticky</option><option value='unstickythis'>Unsticky</option><option value='delete'>Delete</option><option value='move'>Move</option><option value='lock'>Lock</option><option value='unlock'>Unlock</option><option value='bump'>Bump</option></select><input type=hidden name=forum value='<?php echo "$forum"; ?>'><input type=submit value=Go> </td>
</table>
</div>
</form>
<?php
}
?>
<br>
<br>
<br>
<?php
require("footer.php");
ob_end_flush();
?>