-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathbiggestposters.php
81 lines (65 loc) · 2.88 KB
/
biggestposters.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
<?php
require 'lib/function.php';
$windowtitle = "$boardname -- Biggest posters";
require 'lib/layout.php';
if ($_GET['sort'] == "posts") { $sort = "posts"; $headertext = 'sorted by post count'; }
elseif ($_GET['sort'] == "avg") { $sort = "average"; $headertext = 'by average post size'; }
else { $sort = "waste"; $headertext = 'by post size'; }
// Time for an update?
if ($sql->resultq("SELECT bigpostersupdate FROM misc") <= ctime()-(3600 * 8)) {
$sql->query("TRUNCATE biggestposters");
$sql->query("INSERT INTO biggestposters "
."(id, posts, waste) "
."SELECT u.id, u.posts, SUM(LENGTH(pt.`text`)) "
."FROM `posts` p "
."LEFT JOIN `users` u ON p.user = u.id "
."LEFT JOIN `posts_text` pt on p.id = pt.pid "
."WHERE (u.posts >= 5 OR u.posts < 0) GROUP BY p.user");
$sql->query("UPDATE biggestposters SET average = waste / posts");
$sql->query("UPDATE misc SET bigpostersupdate = ".ctime());
}
$posters = $sql->query("SELECT bp.*, u.name, u.regdate, u.minipic, u.sex, u.powerlevel FROM biggestposters bp LEFT JOIN users u ON bp.id=u.id ORDER BY $sort DESC");
print "
$header
<br>
$tblstart
<tr>$tccellc colspan=7><b>Biggest posters, $headertext</b></td></tr>
<tr>
$tccellh width=30>#</td>
$tccellh colspan=2>Username</td>
$tccellh width=200>Registered on</td>
$tccellh width=130><a href=\"?sort=posts\">Posts</a></td>
$tccellh width=130><a href=\"?\">Size</a></td>
$tccellh width=130><a href=\"?sort=avg\">Average</a></td>
";
for($i=1; $user = $sql -> fetch($posters); $i++) {
if($i == 1) $max = $user['waste'];
if ($user['waste'] != $oldcnt) $rank = $i;
$oldcnt = $user['waste'];
$namecolor=getnamecolor($user['sex'],$user['powerlevel']);
$col = "";
if ($user['average'] >= 500) $col = "#88ff88";
if ($user['average'] >= 750) $col = "#8888ff";
if ($user['average'] <= 200) $col = "#ffff80";
if ($user['average'] <= 100) $col = "#ff8080";
if ($user['average'] <= 0) $col = "#888888";
$avgc = number_format(abs($user['average']), 1);
if ($col) $avgc = "<font color=$col>$avgc</font>";
print "
<tr>
$tccell1>$rank</td>
$tccell1 width=16>". ($user['minipic'] ? "<img src=\"". htmlspecialchars($user['minipic']) ."\" width=16 height=16>" : " ") ."</td>
$tccell2l><a href=\"profile.php?id=". $user['id'] ."\"><font $namecolor>". $user['name'] ."</font></a></td>
$tccell1>".date($dateformat, $user['regdate'] + $tzoff) ."</td>
$tccell1r>". $user['posts'] ."</td>
$tccell1r><b>". number_format($user['waste']) ."</b></td>
$tccell2r><b>". $avgc ."</b></td>
</tr>";
}
print "
$tblend
$smallfont(Note: this doesn't take into account quotes, joke posts, or other things. It isn't a very good judge of actual post content, just post <i>size</i>.)
<br>(This table is cached and updated every few hours.)</font>
$footer";
printtimedif($startingtime);
?>