-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforum.php
346 lines (300 loc) · 9.37 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
<?php
// AcmlmBoard XD - Thread listing page
// Access: all
include("lib/common.php");
if(!isset($_GET['id']))
Kill(__("Forum ID unspecified."));
$fid = (int)$_GET['id'];
AssertForbidden("viewForum", $fid);
$pl = $loguser['powerlevel'];
if($pl < 0) $pl = 0;
$qFora = "select * from forums where id=".$fid;
$rFora = Query($qFora);
if(NumRows($rFora))
{
$forum = Fetch($rFora);
if($forum['minpower'] > $pl)
Kill(__("You are not allowed to browse this forum."));
} else
Kill(__("Unknown forum ID."));
$title = $forum['title'];
$qCat = "select * from categories where id=".$forum['catid'];
$rCat = Query($qCat);
if(NumRows($rCat))
{
$cat = Fetch($rCat);
if($cat['minpower'] > $pl)
Kill(__("You are not allowed to see this category."));
} else
Kill(__("Unknown category ID."));
//Autolock system
if($autoLockMonths > 0)
{
$locktime = time() - (2592000 * $autoLockMonths);
Query("UPDATE threads SET closed=1 WHERE forum=".$fid." AND closed=0 AND lastpostdate<".$locktime);
}
//</autolock>
$isIgnored = FetchResult("select count(*) from ignoredforums where uid=".$loguserid." and fid=".$fid, 0, 0) == 1;
if(isset($_GET['ignore']))
{
if(!$isIgnored)
{
Query("insert into ignoredforums values (".$loguserid.", ".$fid.")");
Alert(__("Forum ignored. You will no longer see any \"New\" markers for this forum."));
}
}
else if(isset($_GET['unignore']))
{
if($isIgnored)
{
Query("delete from ignoredforums where uid=".$loguserid." and fid=".$fid);
Alert(__("Forum unignored."));
}
}
$isIgnored = FetchResult("select count(*) from ignoredforums where uid=".$loguserid." and fid=".$fid, 0, 0) == 1;
if($loguserid && $forum['minpowerthread'] <= $loguser['powerlevel'])
{
if($isIgnored)
$links .= "<li><a href=\"forum.php?id=".$fid."&unignore\">".__("Unignore Forum")."</a></li>";
else
$links .= "<li><a href=\"forum.php?id=".$fid."&ignore\">".__("Ignore Forum")."</a></li>";
$links .= "<li><a href=\"newthread.php?id=".$fid."\">".__("Post Thread")."</a></li>";
$links .= "<li><a href=\"newthread.php?id=".$fid."&poll=1\">".__("Post Poll")."</a></li>";
}
DoPrivateMessageBar();
$bucket = "userBar"; include("./lib/pluginloader.php");
$onlineUsers = OnlineUsers($fid);
if(!$noAjax)
{
write(
"
<script type=\"text/javascript\">
onlineFID = {0};
window.addEventListener(\"load\", startOnlineUsers, false);
</script>
", $fid, $onlineUsers);
}
if($rssBar)
{
write("
<div style=\"float: left; width: {1}px;\"> </div>
<div id=\"rss\">
{0}
</div>
", $rssBar, $rssWidth + 4);
}
write(
"
<div class=\"header0 cell1 center outline smallFonts margin\" style=\"overflow: auto;\">
<span id=\"onlineUsers\">
{0}
</span>
</div>
", $onlineUsers, $rssBar, $rssWidth);
MakeCrumbs(array(__("Main")=>"./", $forum['title']=>"forum.php?id=".$fid), $links);
$total = $forum['numthreads'];
$tpp = $loguser['threadsperpage'];
if(isset($_GET['from']))
$from = (int)$_GET['from'];
else
$from = 0;
if(!$tpp) $tpp = 50;
$rThreads = Query(" SELECT
t.*,
".($loguserid ? "tr.date readdate," : '')."
su.id suid, su.name suname, su.displayname sudisplayname, su.powerlevel supowerlevel, su.sex susex,
lu.id luid, lu.name luname, lu.displayname ludisplayname, lu.powerlevel lupowerlevel, lu.sex lusex
FROM
threads t
".($loguserid ? "LEFT JOIN threadsread tr ON tr.thread=t.id AND tr.id=".$loguserid : '')."
LEFT JOIN users su ON su.id=t.user
LEFT JOIN users lu ON lu.id=t.lastposter
WHERE forum=".$fid."
ORDER BY sticky DESC, lastpostdate DESC LIMIT ".$from.", ".$tpp);
$numonpage = NumRows($rThreads);
for($i = $tpp; $i < $total; $i+=$tpp)
if($i == $from)
$pagelinks .= " ".(($i/$tpp)+1);
else
$pagelinks .= " <a href=\"forum.php?id=".$fid."&from=".$i."\">".(($i/$tpp)+1)."</a>";
if($pagelinks)
{
if($from == 0)
$pagelinks = " 1".$pagelinks;
else
$pagelinks = "<a href=\"forum.php?id=".$fid."\">1</a>".$pagelinks;
Write("<div class=\"smallFonts pages\">".__("Pages:")." {0}</div>", $pagelinks);
}
$ppp = $loguser['postsperpage'];
if(!$ppp) $ppp = 20;
$bucket = "topBar"; include("./lib/pluginloader.php");
if(NumRows($rThreads))
{
$forumList = "";
while($thread = Fetch($rThreads))
{
$user = array('id'=>$thread['suid'], 'name'=>$thread['suname'], 'displayname'=>$thread['sudisplayname'], 'powerlevel'=>$thread['supowerlevel'], 'sex'=>$thread['susex']);
$bucket = "userMangler"; include("./lib/pluginloader.php");
$starter = $user;
$user = array('id'=>$thread['luid'], 'name'=>$thread['luname'], 'displayname'=>$thread['ludisplayname'], 'powerlevel'=>$thread['lupowerlevel'], 'sex'=>$thread['lusex']);
$bucket = "userMangler"; include("./lib/pluginloader.php");
$last = $user;
$tags = ParseThreadTags($thread['title']);
$NewIcon = "";
$newstuff = 0;
if($thread['closed'])
$NewIcon = "off";
if($thread['replies'] >= $misc['hotcount'])
$NewIcon .= "hot";
if((!$loguserid && $thread['lastpostdate'] > time() - 900) ||
($loguserid && $thread['lastpostdate'] > $thread['readdate']) &&
!$isIgnored)
{
$NewIcon .= "new";
$newstuff++;
}
else if(!$thread['closed'] && !$thread['sticky'] && $warnMonths > 0 && $thread['lastpostdate'] < time() - (2592000 * $warnMonths))
$NewIcon = "old";
if($NewIcon)
$NewIcon = "<img src=\"img/status/".$NewIcon.".png\" alt=\"\"/>";
if($thread['icon'])
$ThreadIcon = "<img src=\"".htmlspecialchars($thread['icon'])."\" alt=\"\" class=\"smiley\"/>";
else
$ThreadIcon = "";
$cellClass = ($cellClass + 1) % 2;
//if($thread['sticky'])
// $cellClass = 2;
if($thread['sticky'] == 0 && $haveStickies == 1)
{
$haveStickies = 2;
$forumList .= "<tr class=\"header1\"><th colspan=\"7\" style=\"height: 8px;\"></th></tr>";
}
if($thread['sticky'] && $haveStickies == 0) $haveStickies = 1;
$poll = ($thread['poll'] ? "<img src=\"img/poll.png\" alt=\"Poll\"/> " : "");
$n = 4;
$total = $thread['replies'];
$numpages = floor($total / $ppp);
$pl = "";
if($numpages <= $n * 2)
{
for($i = 1; $i <= $numpages; $i++)
$pl .= " <a href=\"thread.php?id=".$thread['id']."&from=".($i * $ppp)."\">".($i+1)."</a>";
}
else
{
for($i = 1; $i < $n; $i++)
$pl .= " <a href=\"thread.php?id=".$thread['id']."&from=".($i * $ppp)."\">".($i+1)."</a>";
$pl .= " … ";
for($i = $numpages - $n + 1; $i <= $numpages; $i++)
$pl .= " <a href=\"thread.php?id=".$thread['id']."&from=".($i * $ppp)."\">".($i+1)."</a>";
}
if($pl)
$pl = " <span class=\"smallFonts\">[<a href=\"thread.php?id=".$thread['id']."\">1</a>".$pl."]</span>";
$lastLink = "";
if($thread['lastpostid'])
$lastLink = " <a href=\"thread.php?pid=".$thread['lastpostid']."#".$thread['lastpostid']."\">»</a>";
$forumList .= Format(
"
<tr class=\"cell{0}\">
<td class=\"cell2 threadIcon\">{1}</td>
<td class=\"threadIcon\" style=\"border-right: 0px none;\">
{2}
</td>
<td style=\"border-left: 0px none;\">
{3}
<a href=\"thread.php?id={4}\">
{5}
</a>
{6}
{7}
</td>
<td class=\"center\">
{8}
</td>
<td class=\"center\">
{9}
</td>
<td class=\"center\">
{10}
</td>
<td class=\"smallFonts center\">
{11}<br />
".__("by")." {12} {13}</td>
</tr>
", $cellClass, $NewIcon, $ThreadIcon, $poll, $thread['id'], strip_tags($thread['title']), $pl, $tags,
UserLink($starter), $thread['replies'], $thread['views'],
cdate($dateformat,$thread['lastpostdate']), UserLink($last), $lastLink);
}
Write(
"
<table class=\"outline margin width100\">
<tr class=\"header1\">
<th style=\"width: 20px;\"> </th>
<th style=\"width: 16px;\"> </th>
<th style=\"width: 60%;\">".__("Title")."</th>
<th>".__("Started by")."</th>
<th>".__("Replies")."</th>
<th>".__("Views")."</th>
<th>".__("Last post")."</th>
</tr>
{0}
</table>
", $forumList);
} else
if($forum['minpowerthread'] > $loguser['powerlevel'])
Alert(__("You cannot start any threads here."), __("Empty forum"));
elseif($loguserid)
Alert(format(__("Would you like to {0}post something{1}?"), "<a href=\"newthread.php?id=".$fid."\">", "</a>"), __("Empty forum"));
else
Alert(format(__("{0}Log in{1} so you can post something."), "<a href=\"login.php\">", "</a>"), __("Empty forum"));
if($pagelinks)
Write("<div class=\"smallFonts pages\">".__("Pages:")." {0}</div>", $pagelinks);
MakeCrumbs(array(__("Main")=>"./", $forum['title']=>"forum.php?id=".$fid), $links);
ForumJump();
function ForumJump()
{
global $fid, $loguser;
$pl = $loguser['powerlevel'];
if($pl < 0) $pl = 0;
$lastCatID = -1;
$rFora = Query(" SELECT
f.id, f.title, f.catid,
c.name cname
FROM
forums f
LEFT JOIN categories c ON c.id=f.catid
WHERE c.minpower<=".$pl." AND f.minpower<=".$pl.(($pl < 1) ? " AND f.hidden=0" : '')."
ORDER BY c.corder, c.id, f.forder");
$theList = "";
$optgroup = "";
while($forum = Fetch($rFora))
{
if($forum['catid'] != $lastCatID)
{
$lastCatID = $forum['catid'];
$theList .= format(
"
{0}
<optgroup label=\"{1}\">
", $optgroup, strip_tags($forum['cname']));
$optgroup = "</optgroup>";
}
$theList .= format(
"
<option value=\"{0}\"{2}>{1}</option>
", $forum['id'], strip_tags($forum['title']), ($forum['id'] == $fid ? " selected=\"selected\"" : ""));
}
write(
"
<label>
".__("Forum Jump:")."
<select onchange=\"document.location='forum.php?id='+this.options[this.selectedIndex].value;\">
{0}
</optgroup>
</select>
</label>
", $theList);
}
?>