-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathranks.php
107 lines (91 loc) · 2.77 KB
/
ranks.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
<?php
require 'lib/function.php';
require 'lib/layout.php';
$set = intval($_GET['set'] ?? -1);
$showall = $_GET['showall'] ?? 0;
$rsets = $sql->query('SELECT * FROM ranksets WHERE id>0 ORDER BY id');
$ranksetlist = "";
while($rset = $sql->fetch($rsets)) {
// First rankset
if($set < 0) $set = $rset['id'];
$selected = (($rset['id']==$set) ? 'selected' : '' );
$ranksetlist.="<option value={$rset['id']} {$selected}>{$rset['name']}";
}
$ch[$showall]='checked';
print "
$header
<form action='ranks.php'>
<br>
$tblstart
$tccellh colspan=2> <tr>
$tccell1><b>Rank set</b></td>
$tccell2l><select name=set>$ranksetlist</select></td><tr>
$tccell1><b>Users to show</b></td>
$tccell2l>
<label>$radio=showall value=0 ". ($ch[0] ?? "") ."> Selected rank set only</label>
<label>$radio=showall value=1 ". ($ch[1] ?? "") ."> All users</label>
</td></tr>
<tr>
$tccellh colspan=2> <tr>
$tccell1> </td>
$tccell2l><input type=submit class=submit value=View></td>
</form>
$tblend
<br>
$tblstart
$tccellh width=150>Rank</td>
$tccellh width=60>Posts</td>
$tccellh width=60>Ranking</td>
$tccellh colspan=2>Users on that rank
";
$useranks = ($showall?'':"AND useranks={$set}");
$btime=ctime()-86400*30;
$ranks = $sql->query("SELECT * FROM ranks WHERE rset=$set ORDER BY num");
$totalranks = mysql_num_rows($ranks);
if ($totalranks > 0) {
$rank = $sql->fetch($ranks);
// 300 queries [11sec] ---> 20 queries [1sec]
$users = $sql->query("SELECT id,name,sex,powerlevel,aka,birthday,posts,lastactivity,lastposttime FROM users WHERE posts >= $rank[num] $useranks ORDER BY posts ASC");
$user = $sql->fetch($users);
$total = mysql_num_rows($users);
}
for($i=0; $i<$totalranks; ++$i) {
$rankn=$sql->fetch($ranks);
if (!$rankn) {
$rankn = ['num' => 8388607];
}
$userarray = array();
$inactive = 0;
for($u=0;$user && $user['posts'] < $rankn['num'];$u++){
if (max($user['lastactivity'], $user['lastposttime']) > $btime)
$userarray[$user['name']] = getuserlink($user);
else ++$inactive;
$user = $sql->fetch($users);
}
@ksort($userarray);
$userlisting = implode(", ", $userarray);
if($inactive) $userlisting.=($userlisting?', ':'')."$inactive inactive";
if(!$userlisting) $userlisting=' ';
if($userlisting != ' ' || $rank['num'] <= $loguser['posts'] || $ismod) {
print "<tr>
$tccell2ls width=200>$rank[text]</td>
$tccell1 width=60>$rank[num]</td>
$tccell1 width=60>$total</td>
$tccell1 width=30>$u</td>
$tccell2s width=*>$userlisting";
}
else {
print "<tr>
$tccell1>? ? ?</td>
$tccell1>???</td>
$tccell1>?</td>
$tccell1>?</td>
$tccell1s>?";
}
$rank = $rankn;
$total -= $u;
}
print $tblend.$footer;
printtimedif($startingtime);
?>