forked from Bigjoos/U-232-V1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
forums.php
637 lines (573 loc) · 30.2 KB
/
forums.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
<?php
/**
* https://09source.kicks-ass.net:8443/svn/installer09/
* Licence Info: GPL
* Copyright (C) 2010 Installer09 v.1
* A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon.
* Project Leaders: Mindless,putyn,kidvision.
**/
/**********************************************************
New 2010 forums that don't suck for TB based sites....
mostly coded up either from scratch, or based on code from the following sources:
TBsource, BrokenStones, TBDev
with inspiration from SMF forums, Google, php.net
Retro, System, CoLdFuSiOn, pdq, putyn, bigjoos, x0r, Laffin
and the many many other
coders who helped develop TB based sites and code over the years
and will be added when I have more of a brain :P
Beta Thurs Sept 9th 2010 v0.5
Powered by Bunnies!!!
***************************************************************/
define('BUNNY_FORUMS', TRUE);
require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'bittorrent.php');
require_once(INCL_DIR.'user_functions.php');
dbconn(false);
loggedinorreturn();
$lang = array_merge( load_language('global'), load_language('forums') );
//$allowed_ids = array(1); //== 1 Is Sysop - add userids you want access
//if (!in_array($CURUSER['id'], $allowed_ids))
//stderr('Error', 'New forum under construction - call back next year lol');
if ($TBDEV['forums_online'] == 0 AND $CURUSER['class'] < UC_MODERATOR)
stderr('Information', 'The forums are currently offline for maintainance work');
if (function_exists('parked'))
parked();
$HTMLOUT='';
//=== bubble tool tip
function bubble($link, $text)
{
$bubble = '<a href="#" class="tt"><span class="tooltip"><span class="top"></span><span class="middle">'.$text.'</span><span class="bottom"></span></span>'.$link.'</a>';
return $bubble;
}
//=== tool tip
function tool_tip($link, $text, $title = false)
{
$bubble = '<a href="#" class="tt2"><span class="tooltip"><span class="top">'.$title.'</span><span class="middle">'.$text.'</span></span>'.$link.'</a>';
return $bubble;
}
//=== let admin and above delete shite
if ($CURUSER['class'] >= UC_ADMINISTRATOR)
{
$HTMLOUT .="<script type='text/javascript'>
/*<![CDATA[*/
function confirm_delete(id)
{
if(confirm('Are you sure you want to delete this forum?'))
{
self.location.href='forum_manage.php?action=delete&id='+id;
}
}
/*]]>*/
</script>";
}
///=== update members last forums access
sql_query('UPDATE users SET forum_access='.TIME_NOW.' WHERE id='.$CURUSER['id']);
//=== get config info from the DB (comment out and use hard coded if you prefer)
$config_id = 13;
$config_res = sql_query ('SELECT delete_for_real, min_delete_view_class, readpost_expiry, min_upload_class, accepted_file_extension,
accepted_file_types, max_file_size, upload_folder FROM forum_config WHERE id = '.$config_id);
$config_arr = mysql_fetch_array($config_res);
//=== all config stuff:
$delete_for_real = ($config_arr['delete_for_real'] == 1 ? 1 : 0);
$min_delete_view_class = intval($config_arr['min_delete_view_class']);
$readpost_expiry = (intval($config_arr['readpost_expiry']) * 86400);
$min_upload_class = intval($config_arr['min_upload_class']);
//$accepted_file_extension = unserialize($config_arr['accepted_file_extension']);
//$accepted_file_types = unserialize($config_arr['accepted_file_types']);
$accepted_file_extension = ($config_arr['accepted_file_extension']);
$accepted_file_types = ($config_arr['accepted_file_types']);
$max_file_size = intval($config_arr['max_file_size']);
$upload_folder = htmlspecialchars(trim($config_arr['upload_folder']));
//=== post / get action posted so we know what to do :P
$posted_action = strip_tags((isset($_GET['action']) ? $_GET['action'] : (isset($_POST['action']) ? $_POST['action'] : '')));
//=== add all possible actions here and check them to be sure they are ok
if ($CURUSER['class'] >= UC_MODERATOR)
{
$valid_actions = array('forum', 'view_forum', 'section_view', 'new_topic', 'view_topic', 'post_reply', 'delete_post', 'edit_post', 'subscriptions', 'delete_subscription', 'add_subscription', 'search', 'new_replies', 'view_unread_posts', 'view_my_posts', 'mark_all_as_read', 'clear_unread_post', 'download_attachment', 'poll', 'view_post_history', 'staff_actions', 'member_post_history');
}
else
{
$valid_actions = array('forum', 'view_forum', 'section_view', 'new_topic', 'view_topic', 'post_reply', 'delete_post', 'edit_post', 'subscriptions', 'delete_subscription', 'add_subscription', 'search', 'new_replies', 'view_unread_posts', 'view_my_posts', 'mark_all_as_read', 'clear_unread_post', 'download_attachment', 'poll', 'member_post_history');
}
//=== check posted action, and if no action was posted, show the default main forums page
$action = (in_array($posted_action, $valid_actions) ? $posted_action : 'forum');
//=== some default global type stuff
//=== mini menu
$mini_menu = '<a class="altlink" href="forums.php?action=subscriptions">My Subscriptions</a> |
<a class="altlink" href="forums.php?action=search">Search</a> |
<a class="altlink" href="forums.php?action=view_unread_posts">Unread Posts</a> |
<a class="altlink" href="forums.php?action=new_replies">New Replies</a> |
<a class="altlink" href="forums.php?action=view_my_posts">My Posts</a> |
<a class="altlink" href="forums.php?action=mark_all_as_read">Mark All As Read</a>';
$location_bar = '<h1><a class="altlink" href="index.php">'.$TBDEV['site_name'].'</a><img src="pic/forums/arrow_next.gif" alt="►" title="►" />
<a class="altlink" href="forums.php">Forums</a></h1>
<span style="text-align: center;">'.$mini_menu.'</span><br />'.(isset($_GET['m']) ? '<h1>All forums up to date.</h1>' : '<br />');
$legend = '<br />
<table border="0" cellspacing="5" cellpadding="5" width="600" align="center">
<tr>
<td class="forum_head_dark" colspan="8" align="center">legend</td>
</tr>
<tr>
<td class="one" align="center"><img src="pic/forums/unlockednew.gif" alt="unlockednew" title="unlockednew" /></td>
<td class="one">unread forum</td>
<td class="one" align="center"><img src="pic/forums/unlocked.gif" alt="unlocked" title="unlocked" /></td>
<td class="one">read forum</td>
<td class="one" align="center"><img src="pic/forums/topicnew.gif" alt="topicnew" title="topicnew" /></td>
<td class="one">unread post</td>
<td class="one" align="center"><img src="pic/forums/topic.gif" alt="topic" title="topic" /></td>
<td class="one">read post</td>
</tr>
<tr>
<td class="one" align="center"><img src="pic/forums/hot_topic_new.gif" alt="hot_topic_new" title="hot_topic_new" /></td>
<td class="one">hot topic un-read</td>
<td class="one" align="center"><img src="pic/forums/hot_topic.gif" alt="hot_topic" title="hot_topic" /></td>
<td class="one">hot topic [more than 30 replies]<br /></td>
<td class="one" align="center"><img src="pic/forums/lockednew.gif" alt="lockednew" title="lockednew" /></td>
<td class="one">locked un-read</td>
<td class="one" align="center"><img src="pic/forums/locked.gif" alt="locked" title="locked" /></td>
<td class="one">locked<br /></td>
</tr>
<tr>
<td class="one" align="center"><img src="pic/forums/poll.gif" alt="poll" title="poll" /></td>
<td class="one">Poll</td>
<td class="one" align="center"><img src="pic/forums/pinned.gif" alt="pinned" title="pinned" /></td>
<td class="one">Pinned<br /></td>
<td class="one" align="center"><img src="pic/forums/subscriptions.gif" alt="Subscribed" title="Subscribed" /></td>
<td class="one">Subscribed to thread</td>
<td class="one" align="center"><img src="pic/forums/posted.gif" alt="posted" title="posted" /></td>
<td class="one">you have posted here<br /></td>
</tr>
<tr>
<td class="one" align="center"><img src="pic/forums/mg.gif" height="20" alt="1st Post Preview" title="1st Post Preview" /></td>
<td class="one">1st Post Preview<br /></td>
<td class="one" align="center"><img src="pic/forums/last_post.gif" alt="last post" title="last post" /></td>
<td class="one">Last Post</td>
<td class="one" align="center"><img src="pic/forums/topic_normal.gif" alt="Thread Icon" title="Thread Icon" /></td>
<td class="one">Thread Icon</td>
<td class="one" align="center"></td>
<td class="one"></td>
</tr>
<tr>
<td class="forum_head_dark" colspan="8" align="center">
<a href="http://btdev.net/">
<img src="pic/forums/powered_by_bunnies.gif" alt="These forums are powerd by bunnies!!! for more info click here!" title="These forums are powerd by bunnies!!! for more info click here!!" /></a>
</td></tr>
</table><br />
<br />';
//=== more options poll & atachments
$poll_starts = (isset($_POST['poll_starts']) ? intval($_POST['poll_starts']) : 0);
$poll_ends = (isset($_POST['poll_ends']) ? intval($_POST['poll_ends']) : 1356048000);
$change_vote = ((isset($_POST['change_vote']) && $_POST['change_vote'] === 'yes') ? 'yes' : 'no');
$multi_options = (isset($_POST['multi_options']) ? intval($_POST['multi_options']) : 1);
//$can_add_poll = (isset($_GET['action']) && $_GET['action'] == 'new_topic' ? 1 : 0);
//=== options for amount of options lol
$options = '';
for($i = 2; $i < 21; $i++)
{
$options .='<option class="body" value="'.$i.'" '.($multi_options === $i ? 'selected' : '').'>'.$i.' options</option>';
}
$more_options = '<div id="tools" '.((isset($_POST['poll_question']) && $_POST['poll_question'] !== '') ? '' : 'style="display:none"').' >
<br /><table border="0" cellspacing="0" cellpadding="5" width="800" align="center">
<tr>
<td class="forum_head_dark" align="left" colspan="3">Additional Options...</td>
</tr>
'.($CURUSER['class'] < $min_upload_class ? '' :
'<tr>
<td class="three" align="center" valign="middle" width="10"><img src="pic/forums/attach.gif" alt="attach" title="Attach" /></td>
<td class="three" align="right" valign="middle" width="20"><span style="white-space:nowrap;font-weight: bold;">Attachments:</span></td>
<td class="three" align="left" valign="top">
<input type="file" size="30" name="attachment[]" /> <a title="Add more attachments" id="more" style="white-space:nowrap;font-weight:bold;cursor:pointer;">Add more attachments</a>
<img src="pic/forums/zip.gif" alt=" " width="18" style="vertical-align: middle;" />
<img src="pic/forums/rar.gif" alt=" " width="18" style="vertical-align: middle;" /><br />
<div id="attach_more" style="display:none">
<input type="file" size="30" name="attachment[]" /><br />
<input type="file" size="30" name="attachment[]" /><br />
<input type="file" size="30" name="attachment[]" />
</div>
</td>
</tr>').((isset($_GET['action']) && $_GET['action'] <> 'new_topic') ? '' :
'<tr>
<td class="three" align="center" valign="middle" width="10"></td>
<td class="three" align="right" valign="middle" width="20"></td>
<td class="three" align="left"><span style="white-space:nowrap;font-weight: bold;"> <img src="pic/forums/poll.gif" alt="poll" title="Poll" style="vertical-align: middle;" /> Add poll to topic</span>
</td>
</tr>
<tr>
<td class="three" align="center" valign="middle"><img src="pic/forums/question.png" alt="question" title="Question" width="24" style="vertical-align: middle;" /></td>
<td class="three" align="right"><span style="white-space:nowrap;font-weight: bold;">Poll question:</span></td>
<td class="three" align="left"><input type="text" name="poll_question" class="text_default" value="'.(isset($_POST['poll_question']) ? strip_tags($_POST['poll_question']) : '').'" /></td>
</tr>
<tr>
<td class="three" align="center" valign="top"><img src="pic/forums/options.gif" alt="options" title="Options" width="24" style="vertical-align: middle;" /></td>
<td class="three" align="right" valign="top"><span style="white-space:nowrap;font-weight: bold;">Poll answers:</span></td>
<td class="three" align="left" valign="top"><textarea cols="30" rows="4" name="poll_answers" class="text_area_small">'.(isset($_POST['poll_answers']) ? strip_tags($_POST['poll_answers']) : '').'</textarea><br /> One option per line. There is a minimum of 2 options, and a maximun of 20 options. BBcode is enabled.</td>
</tr>
<tr>
<td class="three" align="center" valign="middle"><img src="pic/forums/clock.png" alt="clock" title="Clock" width="30" style="vertical-align: middle;" /></td>
<td class="three" align="right"><span style="white-space:nowrap;font-weight: bold;">Poll starts:</span></td>
<td class="three" align="left"><select name="poll_starts">
<option class="body" value="0" '.($poll_starts === 0 ? 'selected="selected"' : '').'>Start Now!</option>
<option class="body" value="1" '.($poll_starts === 1 ? 'selected="selected"' : '').'>in 1 day</option>
<option class="body" value="2" '.($poll_starts === 2 ? 'selected="selected"' : '').'>in 2 days</option>
<option class="body" value="3" '.($poll_starts === 3 ? 'selected="selected"' : '').'>in 3 days</option>
<option class="body" value="4" '.($poll_starts === 4 ? 'selected="selected"' : '').'>in 4 days</option>
<option class="body" value="5" '.($poll_starts === 5 ? 'selected="selected"' : '').'>in 5 days</option>
<option class="body" value="6" '.($poll_starts === 6 ? 'selected="selected"' : '').'>in 6 days</option>
<option class="body" value="7" '.($poll_starts === 7? 'selected="selected"' : '').'>in 1 week</option>
</select> When to start the poll. Default is "Start Now!"</td>
</tr>
<tr>
<td class="three" align="center" valign="middle"><img src="pic/forums/stop.png" alt="stop" title="Stop" width="20" style="vertical-align: middle;" /></td>
<td class="three" align="right"><span style="white-space:nowrap;font-weight: bold;">Poll ends:</span></td>
<td class="three" align="left"><select name="poll_ends">
<option class="body" value="1356048000" '.($poll_ends === 1356048000 ? 'selected="selected"' : '').'>Run Forever</option>
<option class="body" value="1" '.($poll_ends === 1 ? 'selected="selected"' : '').'>in 1 day</option>
<option class="body" value="2" '.($poll_ends === 2 ? 'selected="selected"' : '').'>in 2 days</option>
<option class="body" value="3" '.($poll_ends === 3 ? 'selected="selected"' : '').'>in 3 days</option>
<option class="body" value="4" '.($poll_ends === 4 ? 'selected="selected"' : '').'>in 4 days</option>
<option class="body" value="5" '.($poll_ends === 5 ? 'selected="selected"' : '').'>in 5 days</option>
<option class="body" value="6" '.($poll_ends === 6 ? 'selected="selected"' : '').'>in 6 days</option>
<option class="body" value="7" '.($poll_ends === 7 ? 'selected="selected"' : '').'>in 1 week</option>
<option class="body" value="14" '.($poll_ends === 14 ? 'selected="selected"' : '').'>in 2 weeks</option>
<option class="body" value="21" '.($poll_ends === 21 ? 'selected="selected"' : '').'>in 3 weeks</option>
<option class="body" value="28" '.($poll_ends === 28 ? 'selected="selected"' : '').'>in 1 month</option>
<option class="body" value="56" '.($poll_ends === 56 ? 'selected="selected"' : '').'>in 2 months</option>
<option class="body" value="84" '.($poll_ends === 84 ? 'selected="selected"' : '').'>in 3 months</option>
</select> How long should this poll run? Default is "run forever"</td>
</tr>
<tr>
<td class="three" align="center" valign="middle"><img src="pic/forums/multi.gif" alt="multi" title="Multi" width="20" style="vertical-align: middle;" /></td>
<td class="three" align="right"><span style="white-space:nowrap;font-weight: bold;">Multi options:</span></td>
<td class="three" align="left"><select name="multi_options">
<option class="body" value="1" '.($multi_options === 1 ? 'selected="selected"' : '').'>Single option!</option>
'.$options.'
</select> Allow members to have more then one selection? Default is "Single option!"</td>
</tr>
<tr>
<td class="three" align="center" valign="middle"></td>
<td class="three" align="right"><span style="white-space:nowrap;font-weight: bold;">Change vote:</span></td>
<td class="three" align="left"><input name="change_vote" value="yes" type="radio"'.($change_vote === 'yes' ? ' checked="checked"' : '').' />Yes
<input name="change_vote" value="no" type="radio"'.($change_vote === 'no' ? ' checked="checked"' : '').' />No <br /> Allow members to change their vote? Default is "no"</td>
</tr>').'
</table>
</div>';
$forum_id = (isset($_GET['forum_id']) ? intval($_GET['forum_id']) : (isset($_POST['forum_id']) ? intval($_POST['forum_id']) : 0));
//=== print the bottom of the page
$the_bottom_of_the_page ='';
$the_bottom_of_the_page .= insert_quick_jump_menu($forum_id).$legend;
$the_bottom_of_the_page .= stdfoot();
//=== here we go with all the possibilities \\o\o/o//
//=== will be sure to put these in order of most hit to make it a bit faster...
switch ($action)
{
//=== view forum section
case 'view_forum':
require_once(INCL_DIR.'bbcode_functions.php');
require_once(INCL_DIR.'pager_new.php');
require_once(FORUM_DIR.'view_forum.php');
$HTMLOUT .= $the_bottom_of_the_page;
break;
//=== view topic
case 'view_topic':
require_once(INCL_DIR.'bbcode_functions.php');
require_once(INCL_DIR.'pager_new.php');
require_once(FORUM_DIR.'view_topic.php');
$HTMLOUT .= $the_bottom_of_the_page2;
break;
//=== view section
case 'section_view':
require_once(FORUM_DIR.'section_view.php');
$HTMLOUT .= $the_bottom_of_the_page;
break;
//=== poll stuff
case 'poll':
//require_once 'include/bbcode_functions.php';
require_once(FORUM_DIR.'poll.php');
break;
//=== subscriptions add_subscription
case 'subscriptions':
require_once(INCL_DIR.'bbcode_functions.php');
require_once(INCL_DIR.'pager_new.php');
require_once(FORUM_DIR.'subscriptions.php');
$HTMLOUT .= $the_bottom_of_the_page;
break;
//=== add subscription
case 'add_subscription':
require_once(FORUM_DIR.'add_subscription.php');
break;
//=== add delete post
case 'delete_post':
require_once(FORUM_DIR.'delete_post.php');
break;
//=== delete subscription
case 'delete_subscription':
require_once(FORUM_DIR.'delete_subscription.php');
break;
//=== new topic
case 'new_topic':
require_once(INCL_DIR.'bbcode_functions.php');
require_once(FORUM_DIR.'new_topic.php');
$HTMLOUT .= $the_bottom_of_the_page;
break;
//=== post reply
case 'post_reply':
require_once(INCL_DIR.'bbcode_functions.php');
require_once(FORUM_DIR.'post_reply.php');
$HTMLOUT .= $the_bottom_of_the_page;
break;
//==Search
case 'search':
require_once(INCL_DIR.'bbcode_functions.php');
require_once(INCL_DIR.'pager_new.php');
require_once(FORUM_DIR.'search.php');
$HTMLOUT .= $the_bottom_of_the_page;
break;
//==View unread
case 'view_unread_posts':
require_once(INCL_DIR.'bbcode_functions.php');
require_once(INCL_DIR.'pager_new.php');
require_once(FORUM_DIR.'view_unread_posts.php');
$HTMLOUT .= $the_bottom_of_the_page;
break;
//==New replies
case 'new_replies':
require_once(INCL_DIR.'bbcode_functions.php');
require_once(INCL_DIR.'pager_new.php');
require_once(FORUM_DIR.'new_replies.php');
$HTMLOUT .= $the_bottom_of_the_page;
break;
//==View my posts
case 'view_my_posts':
require_once(INCL_DIR.'bbcode_functions.php');
require_once(INCL_DIR.'pager_new.php');
require_once(FORUM_DIR.'view_my_posts.php');
$HTMLOUT .= $the_bottom_of_the_page;
break;
//==Member post history
case 'member_post_history':
require_once(INCL_DIR.'bbcode_functions.php');
require_once(INCL_DIR.'pager_new.php');
require_once(FORUM_DIR.'member_post_history.php');
$HTMLOUT .= $the_bottom_of_the_page;
break;
//==Mark all unread
case 'mark_all_as_read':
require_once(FORUM_DIR.'mark_all_as_read.php');
break;
//D-load attachment
case 'download_attachment':
require_once(FORUM_DIR.'download_attachment.php');
break;
//==Clear unread
case 'clear_unread_post':
require_once(FORUM_DIR.'clear_unread_post.php');
break;
//==Edit post
case 'edit_post':
require_once(INCL_DIR.'bbcode_functions.php');
require_once(FORUM_DIR.'edit_post.php');
$HTMLOUT .= $the_bottom_of_the_page;
break;
//==View post history
case 'view_post_history':
if ($CURUSER['class'] < UC_MODERATOR)
{
stderr('Error', 'No access for you Mr. Fancy-Pants.');
}
require_once(INCL_DIR.'bbcode_functions.php');
require_once(FORUM_DIR.'view_post_history.php');
$HTMLOUT .= $the_bottom_of_the_page;
break;
//==Staff actions
case 'staff_actions':
if ($CURUSER['class'] < UC_MODERATOR)
{
stderr('Error', 'No access for you Mr. Fancy-Pants.');
}
require_once(FORUM_DIR.'staff_actions.php');
break;
//=== default action / forums
case 'forum':
/**********************************************************************
wanted to include this as another file, but keep geting errors lol...
it's the default forums.php page
If I can't figure out why it won't work as it's own file, then I'll move it to the top
***********************************************************************/
//=== some default stuff
//=== main huge query:
$res_forums = sql_query('SELECT o_f.id AS over_forum_id, o_f.name AS over_forum_name, o_f.description AS over_forum_description, o_f.min_class_view AS over_forum_min_class_view,
f.id AS real_forum_id, f.name, f.description, f.post_count, f.topic_count, f.forum_id
FROM over_forums AS o_f JOIN forums AS f
WHERE o_f.min_class_view <= '.$CURUSER['class'].'
AND f.min_class_read <= '.$CURUSER['class'].'
AND parent_forum = 0
ORDER BY o_f.sort, f.sort ASC');
$over_forum_id='';
$HTMLOUT .= $location_bar.'<br />
<table border="0" cellspacing="0" cellpadding="5" width="95%">';
//=== well... let's do the loop and make the damned page!
$count='';
$child_boards = '';
$now_viewing = '';
while ($arr_forums = mysql_fetch_assoc($res_forums))
{
//=== if it's a forums section print it, if not, list the fourm sections in it \o/
$HTMLOUT .= ($arr_forums['over_forum_id'] !== $over_forum_id ?
'<tr>
<td align="left" class="forum_head_dark" colspan="3">
<a class="altlink" href="forums.php?action=section_view&forum_id='.$arr_forums['over_forum_id'].'" title="'.htmlentities($arr_forums['over_forum_description'], ENT_QUOTES).'">
<span style="color: white;">'.htmlentities($arr_forums['over_forum_name'], ENT_QUOTES).'</span></a></td>
</tr>' : '');
if ($arr_forums['forum_id'] === $arr_forums['over_forum_id'])
{
//=== change colors
$count= (++$count)%2;
$class = ($count == 0 ? 'one' : 'two');
$forum_id = $arr_forums['real_forum_id'];
$forum_name = htmlentities($arr_forums['name'], ENT_QUOTES);
$forum_description = htmlentities($arr_forums['description'], ENT_QUOTES);
$topic_count = number_format($arr_forums['topic_count']);
$post_count = number_format($arr_forums['post_count']);
//=== Find last post ID
$last_post_res = sql_query('SELECT t.id AS topic_id, t.topic_name, t.last_post, p.added, u.id, u.username, u.suspended, u.class, u.donor, u.warned, u.enabled, u.chatpost, u.leechwarn, u.pirate, u.king, u.avatar_rights
FROM topics AS t LEFT JOIN posts AS p ON p.topic_id = t.id RIGHT JOIN users AS u ON u.id = p.user_id
WHERE '.($CURUSER['class'] < UC_MODERATOR ? 'p.status = \'ok\' AND t.status = \'ok\' AND' :
($CURUSER['class'] < $min_delete_view_class ? ' t.status != \'deleted\' AND p.status != \'deleted\' AND' : '')).' t.forum_id = '.$forum_id.'
ORDER BY p.id DESC LIMIT 1');
$last_post_arr = mysql_fetch_assoc($last_post_res);
//=== only do more if there is a post there...
if ($last_post_arr['last_post'] > 0)
{
$last_post_id = $last_post_arr['last_post'];
//=== get the last post read by CURUSER (with Retro's $readpost_expiry thingie)
$last_read_post_res = sql_query('SELECT last_post_read FROM read_posts WHERE user_id='.$CURUSER['id'].' AND topic_id='.$last_post_arr['topic_id']);
$last_read_post_arr = mysql_fetch_row($last_read_post_res);
$image_to_use = ($last_post_arr['added'] > (time() - $readpost_expiry)) ? (!$last_read_post_arr OR $last_post_id > $last_read_post_arr[0]) : 0;
$img = ($image_to_use ? 'unlockednew' : 'unlocked');
$last_post = '<span style="white-space:nowrap;">Last Post by: '.print_user_stuff($last_post_arr).' <span style="font-size: x-small;"> [ '.get_user_class_name($last_post_arr['class']).' ] </span><br />
in ► <a class="altlink" href="forums.php?action=view_topic&topic_id='.$last_post_arr['topic_id'].'&page=p'.$last_post_id.'#'.$last_post_id.'" title="'.htmlentities($last_post_arr['topic_name'], ENT_QUOTES).'">
<span style="font-weight: bold;">'.CutName(htmlentities($last_post_arr['topic_name'], ENT_QUOTES), 30).'</span></a><br />
'.get_date($last_post_arr['added'],'').'<br /></span>';
//=== get child boards if any
$child_boards_res = sql_query('SELECT name, id FROM forums WHERE parent_forum = '.$arr_forums['real_forum_id'].' AND min_class_read <= '.$CURUSER['class'].' ORDER BY sort ASC');
while ($child_boards_arr = mysql_fetch_assoc($child_boards_res))
{
if ($child_boards !== '')
$child_boards .= ', ';
$child_boards .= '<a href="forums.php?action=view_forum&forum_id='.$child_boards_arr['id'].'" title="click to view!" class="altlink">'.htmlentities($child_boards_arr['name'], ENT_QUOTES).'</a>';
}
if ($child_boards !== '')
{
$child_boards = '<hr /><span style="font-size: xx-small;">child boards:</span> '.$child_boards;
}
//=== now_viewing
$now_viewing_res = sql_query('SELECT n_v.user_id, u.id, u.username, u.class, u.donor, u.warned, u.suspended, u.enabled, u.chatpost, u.leechwarn, u.pirate, u.king, u.avatar_rights
FROM now_viewing AS n_v LEFT JOIN users AS u ON n_v.user_id = u.id WHERE forum_id = '.$arr_forums['real_forum_id']);
//=== let's see whos lookng in here...
while ($now_viewing_arr = mysql_fetch_assoc($now_viewing_res))
{
$now_viewing .= print_user_stuff($now_viewing_arr);
}
if ($now_viewing !== '')
{
$now_viewing = '<hr /><span style="font-size: xx-small;">now viewing:</span>'.$now_viewing;
}
} //=== end of only do more if there is a post there...
else
{
$img = 'unlocked';
$now_viewing = '';
$last_post = 'N/A';
}
$child_boards = '';
$HTMLOUT .= '<tr>
<td align="left" class="'.$class.'">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="'.$class.'" align="left" width="30"><img src="pic/forums/'.$img.'.gif" alt="'.$img.'" /></td>
<td class="'.$class.'" align="left">
'.bubble('<span style="font-weight: bold;"><a class="altlink" href="?action=view_forum&forum_id='.$arr_forums['real_forum_id'].'">
'.$forum_name.'</a></span>', '<span style="font-size: x-small;">'.$forum_name.'</span>
'.$forum_description).($CURUSER['class'] >= UC_ADMINISTRATOR ? '<span style="font-size: x-small;">
[<a class="altlink" href="staffpanel.php?tool=forum_manage&action=forum_manage&action2=edit_forum_page&id='.$forum_id.'">Edit</a>]
[<a class="altlink" href="javascript:confirm_delete(\''.$forum_id.'\');">Delete</a>]</span>' : '').'
<br />
<span style="font-size: x-small;"> '.$forum_description.'</span>'.$child_boards.$now_viewing.'</td>
</tr>
</table>
</td>
<td class="'.$class.'" align="center" width="80"><span style="font-size: x-small;">'.$post_count.' Posts<br />'.$topic_count.' Topics</span></td>
<td class="'.$class.'" align="left" width="140"><span style="font-size: x-small;">'.$last_post.'</span></td>
</tr>';
} //== end of section
$over_forum_id = $arr_forums['over_forum_id'];
} //=== end while loop!
$HTMLOUT .= '</table><br />'.$location_bar.insert_quick_jump_menu().'<br />';
//=== members active in forums
$active_members_res = sql_query('SELECT n_v.user_id, u.id, u.username, u.class, u.donor, u.warned, u.suspended, u.enabled, u.chatpost, u.leechwarn, u.pirate, u.king, u.avatar_rights FROM now_viewing AS n_v LEFT JOIN users AS u ON n_v.user_id = u.id');
//=== let's see whos lookng in here...
$now_viewing = '';
while ($active_members_arr = mysql_fetch_assoc($active_members_res))
{
$now_viewing .= print_user_stuff($active_members_arr);
}
$HTMLOUT .= '<table border="0" cellspacing="5" cellpadding="5" style="max-width:80%;min-width:600px;" align="center">
<tr>
<td class="forum_head_dark" align="center">Members currently active</td>
</tr>
<tr>
<td class="three" align="center">'.$now_viewing.'</td>
</tr>
</table><br />'.$legend. stdfoot();
break;
} //=== end switch
//=== all functions
//=== search string highlighting by fusion found at stackoverflow.com :D
function highlightWords($text, $words) {
preg_match_all('~\w+~', $words, $m);
if(!$m)
return $text;
$re = '~\\b(' . implode('|', $m[0]) . ')~i';
$string = preg_replace($re, '<span style="color: black; background-color: yellow;font-weight: bold;">$0</span>', $text);
return $string;
}
//=== not currently used, but most likely will delete and go with a jquery based thing
function ratingpic_forums($num)
{
$r = round($num * 2) / 2;
if ($r < 1 || $r > 5)
return;
return '<img src="pic/forums/rating/'.$r.'.gif" alt="rating: '.$num.' / 5" title="rating: '.$num.' / 5" />';
}
//=== Inserts a quick jump menu ......UPDATED! now used for staff stuff too \o/
function insert_quick_jump_menu($current_forum = 0, $staff = false)
{
global $CURUSER;
$switch='';
$quick_jump_menu = ($staff === false ? '
<table><tr><td>
<form method="get" action="forums.php" name="jump">
<span style="text-align: center;font-weight: bold;">
<input type="hidden" name="action" value="view_forum" />Quick jump:
<select name="forum_id" onchange="if(this.options[this.selectedIndex].value != -1){ forms[\'jump\'].submit() }">
<option class="head" value="0"> Select a forum to jump to</option>' : '');
$res = sql_query('SELECT f.id, f.name, f.parent_forum, f.min_class_read, of.name AS over_forum_name FROM forums AS f LEFT JOIN over_forums AS of ON f.forum_id = of.id ORDER BY of.sort, f.parent_forum, f.sort ASC');
if (mysql_num_rows($res) > 0)
{
while ($arr = mysql_fetch_array($res))
{
if ($CURUSER['class'] >= $arr['min_class_read'])
{
if ($switch !== $arr['over_forum_name'])
{
$quick_jump_menu .= '<option class="head" value="-1"> '.$arr['over_forum_name'] . ' </option>';
}
$switch = $arr['over_forum_name'];
$quick_jump_menu .= '<option class="body" value="' . $arr['id'].'">'.($arr['parent_forum'] != 0 ? '° '.$arr['name'].' [ child-board ]' : $arr['name']).'</option>';
}
}
}
$quick_jump_menu .= ($staff === false ? '</select></span></form></td></tr></table><br />' : '');
return $quick_jump_menu;
}
print stdhead($TBDEV['site_name'].' Forums') . $HTMLOUT;
?>