-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathpostsbyuser.php
83 lines (69 loc) · 2.49 KB
/
postsbyuser.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
<?php
require 'lib/function.php';
$user = $sql->resultq("SELECT name FROM users WHERE id=$id");
$windowtitle = "Listing posts by $user";
require 'lib/layout.php';
if (!$id)
errorpage('No user specified.', 'return to the board', 'index.php');
if ($_GET['forum']) {
$fid = intval($_GET['forum']);
$forum = $sql->fetchq("SELECT title, minpower FROM forums WHERE id={$fid}");
if ($forum['minpower'] > 0 && $power < $forum['minpower'])
errorpage('You don\'t have access to view posts in this forum.', 'return to the board', 'index.php');
$where = "in $forum[title]";
$forumquery = " AND t.forum = {$fid}";
}
else {
$forumquery = '';
$where = "on the board";
}
if ($_GET['time']) {
$time = intval($_GET['time']);
$when = " over the past ".timeunits2($time);
$timequery = ' AND p.date > ' . (ctime()-$time);
}
else
$timequery = $when = '';
if (!$page) $page=0;
if (!$ppp) $ppp=50;
$min = $ppp*$page;
$posts=$sql->query("SELECT p.id,thread,ip,date,num,t.title,minpower "
."FROM posts p "
."LEFT JOIN threads t ON (thread=t.id) "
."LEFT JOIN forums f ON (t.forum=f.id) "
."WHERE p.user={$id}{$forumquery}{$timequery} ORDER BY p.id DESC");
$posttotal=mysql_num_rows($posts);
// Seek to page
if (!@mysql_data_seek($posts, $min)) $page = 0;
$pagelinks=$smallfont.'Pages:';
for($i=0;$i<($posttotal/$ppp);$i++) {
if($i==$page) $pagelinks.=' '.($i+1);
else {
if($ppp != 50) $postperpage = "&ppp=$ppp";
if($forumquery) $forumlink = '&forum='.intval($_GET['forum']);
$pagelinks.=" <a href=postsbyuser.php?id=$id$postperpage$forumlink&page=$i>".($i+1).'</a>';
}
}
$postlist="
$tccellhs width=50>#</td>
$tccellhs width=50>Post</td>
$tccellhs width=130>Date</td>
$tccellhs>Thread</td>
" . (($isadmin) ? "$tccellhs width=110>IP address</td>" : "");
while(($post = $sql->fetch($posts)) && $ppp--) {
if($post['minpower']<=$power or !$post['minpower'])
$threadlink="<a href=thread.php?pid=$post[0]#$post[0]>".str_replace('<','<',$post['title']).'</a>';
else $threadlink='(restricted)';
if(!$post['num']) $post['num']='?';
$postlist.="<tr>
$tccell1s>$post[0]</td>
$tccell1s>$post[num]</td>
$tccell1s>".date($dateformat,$post[3]+$tzoff)."</td>
$tccell1ls>#<a href=thread.php?id=$post[thread]>$post[1]</a> - $threadlink
" . (($isadmin) ? "</td>$tccell1s>$post[2]" : "") ."
</tr>";
}
print "{$header}{$fonttag}Posts by {$user} {$where}{$when}: ({$posttotal} posts found)
$tblstart$postlist$tblend$pagelinks$footer";
printtimedif($startingtime);
?>