-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathprofile.php
More file actions
253 lines (207 loc) · 10.6 KB
/
profile.php
File metadata and controls
253 lines (207 loc) · 10.6 KB
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
<?php
require 'lib/function.php';
$user = @$sql->fetchq("SELECT * FROM `users` WHERE `id`='$id'");
if (!$user) {
require 'lib/layout.php';
// @todo i'm pretty sure we have a function for this, somewhere
print "$header<br>$tblstart$tccell1>The specified user doesn't exist.$tblend$footer";
printtimedif($startingtime);
die();
}
$windowtitle = "$boardname -- Profile for $user[name]";
require 'lib/layout.php';
// Get various stats ...
// the highest post count of any user on the forum
$maxposts = $sql->resultq("SELECT MAX(`posts`) FROM `users`");
// guh
$userrank = getrank($user['useranks'],$user['title'],$user['posts'],$user['powerlevel']);
$threadsposted = $sql->resultq("SELECT COUNT(`id`) AS cnt FROM `threads` WHERE `user` = '$id'");
// Last post, and a link to the post itself
$lastpostdate = "None";
$lastpostlink = "";
if ($user['posts']) {
$lastpostdate = date($dateformat, $user['lastposttime'] + $tzoff);
$post = @$sql->fetchq("SELECT `id`, `thread` FROM `posts` WHERE `user`='$id' AND `date`='$user[lastposttime]'");
// @TODO refactor into join
if ($post && $thread = $sql->fetchq("SELECT `title`, `forum` FROM `threads` WHERE `id` = '$post[thread]'")) {
$forum = $sql->fetchq("SELECT `id`, `title`, `minpower` FROM `forums` WHERE `id` = '$thread[forum]'");
$thread['title'] = htmlspecialchars($thread['title']);
if ($forum['minpower'] > 0 && $forum['minpower'] > $loguser['powerlevel']) {
$lastpostlink = ", in a restricted forum";
} else {
$lastpostlink = ", in <a href=thread.php?pid=$post[id]#$post[id]>$thread[title]</a> (<a href=forum.php?id=$forum[id]>$forum[title]</a>)";
}
}
}
// Logged in users get a private message link
$sendpmsg = $log ? " | <a href='sendprivate.php?userid=$id'>Send private message</a>" : "";
$adminopts = "";
$lastip = "";
if ($isadmin) {
$lastip = $user['lastip'] ? ", with IP: <a href='ipsearch.php?ip={$user['lastip']}' style='font-style:italic;'>$user[lastip]</a>" : "";
$adminopts = "<tr>$tccell1s colspan=2><a href='private.php?id={$id}' style='font-style:italic;'>View private messages</a> |"
." <a href='forum.php?fav=1&user={$id}' style='font-style:italic;'>View favorites</a> |"
." <a href='edituser.php?id={$id}' style='font-style:italic;'>Edit user</a>";
}
$aim = str_replace(" ", "+", $user['aim']);
$schname = $sql->resultq("SELECT `name` FROM `schemes` WHERE `id`='$user[scheme]'");
$numdays = (ctime() - $user['regdate']) / 86400;
$user['signature'] = doreplace($user['signature'], $user['posts'], $numdays, $user['name']);
$user['postheader'] = doreplace($user['postheader'], $user['posts'], $numdays, $user['name']);
$picture = $user['picture'] ? "<img src=\"$user[picture]\">" : "";
$moodavatar = $user['moodurl'] ? " | <a href='avatar.php?id=$id' class=\"popout\" target=\"_blank\">Preview mood avatar</a>" : "";
$icqicon = $user['icq'] ? htmlspecialchars($user['icq']) : "";
$tccellha = "<td bgcolor=$tableheadbg";
$tccellhb = "><center>$fonthead";
$tzoffset = $user['timezone'];
$tzoffrel = $tzoffset - $loguser['timezone'];
$tzdate = date($dateformat, ctime() + $tzoffset * 3600);
$isbirthday = false;
$birthday = "";
$age = "";
if ($user['birthday']) {
// Todo: This is a clear hack. Remove it.
// -- you, 10 years ago
$isbirthday = (date('m-d', $user['birthday']) == date('m-d', ctime() + $tzoff));
$birthday = date("l, F j, Y",$user['birthday']);
$age = "(". floor((ctime() - $user['birthday']) / 86400 / 365.2425) ." years old)";
}
$namecolor = getnamecolor($isbirthday ? 255 : $user['sex'], $user['powerlevel'], false);
// RPG fun shit
$exp = calcexp($user['posts'], (ctime() - $user['regdate']) / 86400);
$lvl = calclvl($exp);
$expleft = calcexpleft($exp);
$expstatus = "Level: $lvl<br>EXP: $exp (for next level: $expleft)";
if($user['posts'] > 0) {
$expstatus .= "<br>Gain: ". calcexpgainpost($user['posts'], (ctime()-$user['regdate'])/86400) ." EXP per post, ". calcexpgaintime($user['posts'], (ctime()-$user['regdate'])/86400) ." seconds to gain 1 EXP when idle";
}
$postavg = sprintf("%01.2f", $user['posts'] / (ctime() - $user['regdate']) * 86400);
$totalwidth = 116;
$barwidth = max(0, floor(($user['posts'] / $maxposts) * $totalwidth));
$baron = $barwidth > 0 ? "<img src='images/$numdir"."bar-on.gif' width='$barwidth' height='8'>" : "";
$baroff = $barwidth < $totalwidth ? "<img src='images/$numdir"."bar-off.gif' width='". ($totalwidth - $barwidth) ."' height='8'>" : "";
$bar = "<img src='images/$numdir"."barleft.gif'>$baron$baroff<img src='images/$numdir"."barright.gif'><br>";
// In the future, maybe this could be redone to do like, "last 90 days' worth of posting",
// but uh, right now pretty much any estimate for anyone will be ... far in the future, so
// for now, we just, won't.
$projdate = "";
/*
if(!$topposts) $topposts=5000;
if($user['posts']) $projdate=ctime()+(ctime()-$user['regdate'])*($topposts-$user['posts'])/($user['posts']);
var_dump($projdate, date("Y-m-d H:i:s", $projdate));
if(!$user['posts'] or $user['posts']>=$topposts or $projdate>2000000000 or $projdate<ctime()) $projdate="";
else $projdate=" -- Projected date for $topposts posts: ".date($dateformat,$projdate+$tzoff);
*/
$minipic = $user['minipic'] ? "<img src=\"". htmlspecialchars($user['minipic']) ."\" width='16' height='16' align='absmiddle'> " : "";
$homepage = "";
if ($user['homepageurl']) {
if ($user['homepagename']) {
$homepage = "<a href=\"". htmlspecialchars($user['homepageurl']) ."\">". htmlspecialchars($user['homepagename']) ."</a> - ". htmlspecialchars($user['homepageurl']);
} else {
$homepage = "<a href=\"". htmlspecialchars($user['homepageurl']) ."\">". htmlspecialchars($user['homepageurl']) ."</a>";
}
}
// @todo: remove postbg forever
$postbg = $user['postbg'] ? "<div style=\"background:url('". htmlspecialchars($user['postbg']) ."');\" height='100%'>" : "";
loadtlayout();
$user['headtext'] = $user['postheader'];
$user['signtext'] = $user['signature'];
$user['text'] = "Sample text. [quote=fhqwhgads]A sample quote, with a <a href=about:blank>link</a>, for testing your layout.[/quote]This is how your post will appear.";
$user['uid'] = $_GET['id'];
$user['date'] = ctime();
// force layouts on so they're always visible in profiles
$loguser['viewsig'] = 1;
// shop/rpg such
$shops = $sql->getarray("SELECT * FROM `itemcateg` ORDER BY `corder`");
$eq = $sql->fetchq("SELECT * FROM `users_rpg` WHERE `uid` = '$id'");
$itemids = array($eq['eq1'], $eq['eq2'], $eq['eq3'], $eq['eq4'], $eq['eq5'], $eq['eq6'], $eq['eq7']);
$itemids = implode(',', $itemids);
$eqitems = $sql->query("SELECT * FROM items WHERE id IN ({$itemids})");
while ($item = $sql->fetch($eqitems)) $items[$item['id']] = $item;
$shoplist = "";
foreach($shops as $shop) {
$shoplist .= "
<tr>
$tccell1s>$shop[name]</td>
$tccell2s width=100%>". ($items[$eq['eq'.$shop['id']]]['name'] ?? "") ." </td>
";
}
$email = "";
if ($user['email']) {
if ($log) {
$email = "<a href=\"mailto:". htmlspecialchars($user['email']) ."\">$user[email]</a>";
} else {
$email = "(Not visible to guest users)";
}
}
// AKA
if ($user['aka'] && $user['aka'] != $user['name'])
$aka = "$tccell1l width=150><b>Also known as</td> $tccell2l>$user[aka]<tr>";
else $aka='';
print "
$header
<div>$fonttag Profile for <b>$minipic<span style='color:#{$namecolor}'>$user[name]</span></b></div>
<table cellpadding=0 cellspacing=0 border=0>
<td width=100% valign=top>
$tblstart
$tccellh colspan=2><center>General information<tr>
<!-- $tccell1l width=150><b>Username</td> $tccell2l>$user[name]<tr> -->
$aka
$tccell1l width=150><b>Total posts</td> $tccell2l>$user[posts] ($postavg per day) $projdate<br>$bar<tr>
$tccell1l width=150><b>Total threads</td> $tccell2l>$threadsposted<tr>
$tccell1l width=150><b>EXP</td> $tccell2l>$expstatus<tr>
$tccell1l width=150><b>Registered on</td> $tccell2l>".@date($dateformat,$user['regdate']+$tzoff)." (".floor((ctime()-$user['regdate'])/86400)." days ago)<tr>
$tccell1l width=150><b>Last post</td> $tccell2l>$lastpostdate$lastpostlink<tr>
$tccell1l width=150><b>Last activity</td> $tccell2l>".date($dateformat,$user['lastactivity']+$tzoff)."$lastip<tr>
$tblend
<br>$tblstart
$tccellh colspan=2><center>Contact information<tr>
$tccell1l width=150><b>Email address</td> $tccell2l>$email</a> <tr>
$tccell1l width=150><b>Homepage</td> $tccell2l>$homepage <tr>
$tccell1l width=150><b>ICQ number</td> $tccell2l>$icqicon <tr>
$tccell1l width=150><b>AIM screen name</td> $tccell2l><a href='aim:goim?screenname=$aim'>$user[aim]</a> <tr>
$tblend
<br>$tblstart
$tccellh colspan=2><center>User settings<tr>
$tccell1l width=150><b>Timezone offset</td> $tccell2l>$tzoffset hours from the server, $tzoffrel hours from you (current time: $tzdate)<tr>
$tccell1l width=150><b>Items per page</td> $tccell2l>". $user['threadsperpage'] ." threads, ". $user['postsperpage'] ." posts<tr>
$tccell1l width=150><b>Color scheme</td> $tccell2l>".$schname."<tr>
$tblend
</td><td> </td><td valign=top>
$tblstart
$tccellh><center>RPG status<tr>
$tccell1l><img src='status.php?u=$id'>
$tblend
<br>$tblstart
$tccellh colspan=2><center>Equipped Items<tr>
$shoplist
$tblend
</td></table>
<br>$tblstart
$tccellh colspan=2><center>Personal information<tr>
$tccell1l width=150><b>Real name</td> $tccell2l>$user[realname] <tr>
$tccell1l width=150><b>Pronouns</td> $tccell2l>". htmlspecialchars($user['pronouns']) ." <tr>
$tccell1l width=150><b>Location</td> $tccell2l>$user[location] <tr>
$tccell1l width=150><b>Birthday</td> $tccell2l>$birthday $age <tr>
$tccell1l width=150><b>User bio</td> $tccell2l>". dofilters(doreplace2(doreplace($user['bio'], $user['posts'], (ctime()-$user['regdate'])/86400, $user['name']))) ." <tr>
$tblend
<br>$tblstart
$tccellh colspan=2><center>Sample post<tr>
$tblend
". threadpost($user, 1) ."
<br>$tblstart
$tccellhs colspan=2><center>Options<tr>
$tccell2s colspan=2>
<a href=thread.php?user=$id>Show posts</a> |
<a href=forum.php?user=$id>View threads by this user</a>
$sendpmsg
$moodavatar
<tr>
$tccell2s colspan=2>
<a href=postsbyuser.php?id=$id>List posts by this user</a> |
<a href=postsbytime.php?id=$id>Posts by time of day</a> |
<a href=postsbythread.php?id=$id>Posts by thread</a> |
<a href=postsbyforum.php?id=$id>Posts by forum</td>$adminopts
$tblend$footer
";
printtimedif($startingtime);