forked from yunasc/tbdev
/
topten.php
339 lines (298 loc) · 20.5 KB
/
topten.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
<?php
/*
// +--------------------------------------------------------------------------+
// | Project: TBDevYSE - TBDev Yuna Scatari Edition |
// +--------------------------------------------------------------------------+
// | This file is part of TBDevYSE. TBDevYSE is based on TBDev, |
// | originally by RedBeard of TorrentBits, extensively modified by |
// | Gartenzwerg. |
// | |
// | TBDevYSE is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by |
// | the Free Software Foundation; either version 2 of the License, or |
// | (at your option) any later version. |
// | |
// | TBDevYSE is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with TBDevYSE; if not, write to the Free Software Foundation, |
// | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +--------------------------------------------------------------------------+
// | Do not remove above lines! |
// +--------------------------------------------------------------------------+
*/
require "include/bittorrent.php";
dbconn(false);
loggedinorreturn();
function usertable($res, $frame_caption)
{
global $CURUSER;
begin_frame($frame_caption, true);
begin_table();
?>
<tr>
<td class=colhead>Ìåñòî</td>
<td class=colhead align=left>Ïîëüçîâàòåëü</td>
<td class=colhead>Ðàçäà÷</td>
<td class=colhead align=left>Ñêîðîñòü ðàçäà÷è</td>
<td class=colhead>Çàêà÷àë</td>
<td class=colhead align=left>Ñêîðîñòü çàêà÷êè</td>
<td class=colhead align=right>Ðåéòèíã</td>
<td class=colhead align=left>Çàðåãèñòðèðîâàí</td>
</tr>
<?
$num = 0;
while ($a = mysql_fetch_assoc($res))
{
++$num;
$highlight = $CURUSER["id"] == $a["userid"] ? " bgcolor=#BBAF9B" : "";
if ($a["downloaded"])
{
$ratio = $a["uploaded"] / $a["downloaded"];
$color = get_ratio_color($ratio);
$ratio = number_format($ratio, 2);
if ($color)
$ratio = "<font color=$color>$ratio</font>";
}
else
$ratio = "Inf.";
print("<tr$highlight><td align=center>$num</td><td align=left$highlight><a href=userdetails.php?id=" .
$a["userid"] . "><b>" . $a["username"] . "</b>" .
"</td><td align=right$highlight>" . mksize($a["uploaded"]) .
"</td><td align=right$highlight>" . mksize($a["upspeed"]) . "/s" .
"</td><td align=right$highlight>" . mksize($a["downloaded"]) .
"</td><td align=right$highlight>" . mksize($a["downspeed"]) . "/s" .
"</td><td align=right$highlight>" . $ratio .
"</td><td align=left>" . date("Y-m-d",strtotime($a["added"])) . " (" .
get_elapsed_time(sql_timestamp_to_unix_timestamp($a["added"])) . " íàçàä)</td></tr>");
}
end_table();
end_frame();
}
function _torrenttable($res, $frame_caption)
{
begin_frame($frame_caption, true);
begin_table();
?>
<tr>
<td class=colhead align=center>Ìåñòî</td>
<td class=colhead align=left>Íàçâàíèå</td>
<td class=colhead align=right>Ñêà÷åíî</td>
<td class=colhead align=right>Äàííûå</td>
<td class=colhead align=right>Ðàçäàþùèõ</td>
<td class=colhead align=right>Êà÷àþùèõ</td>
<td class=colhead align=right>Âñåãî</td>
<td class=colhead align=right>Ðåéòèíã</td>
</tr>
<?
$num = 0;
while ($a = mysql_fetch_assoc($res))
{
++$num;
if ($a["leechers"])
{
$r = $a["seeders"] / $a["leechers"];
$ratio = "<font color=" . get_ratio_color($r) . ">" . number_format($r, 2) . "</font>";
}
else
$ratio = "Inf.";
print("<tr><td align=center>$num</td><td align=left><a href=details.php?id=" . $a["id"] . "&hit=1><b>" .
$a["name"] . "</b></a></td><td align=right>" . number_format($a["times_completed"]) .
"</td><td align=right>" . mksize($a["data"]) . "</td><td align=right>" . number_format($a["seeders"]) .
"</td><td align=right>" . number_format($a["leechers"]) . "</td><td align=right>" . ($a["leechers"] + $a["seeders"]) .
"</td><td align=right>$ratio</td>\n");
}
end_table();
end_frame();
}
function countriestable($res, $frame_caption, $what)
{
global $CURUSER;
begin_frame($frame_caption, true);
begin_table();
?>
<tr>
<td class=colhead>Ìåñòî</td>
<td class=colhead align=left>Ñòðàíà</td>
<td class=colhead align=right><?=$what?></td>
</tr>
<?
$num = 0;
while ($a = mysql_fetch_assoc($res))
{
++$num;
if ($what == "Ïîëüçîâàòåëè")
$value = number_format($a["num"]);
elseif ($what == "Ðàçäà÷à")
$value = mksize($a["ul"]);
elseif ($what == "Ñðåäíåå")
$value = mksize($a["ul_avg"]);
elseif ($what == "Ðåéòèíã")
$value = number_format($a["r"],2);
print("<tr><td align=center>$num</td><td align=left><table border=0 class=main cellspacing=0 cellpadding=0><tr><td class=embedded>".
"<img align=center src=pic/flag/$a[flagpic]></td><td class=embedded style='padding-left: 5px'><b>$a[name]</b></td>".
"</tr></table></td><td align=right>$value</td></tr>\n");
}
end_table();
end_frame();
}
function peerstable($res, $frame_caption)
{
begin_frame($frame_caption, true);
begin_table();
print("<tr><td class=colhead>Rank</td><td class=colhead>Username</td><td class=colhead>Upload rate</td><td class=colhead>Download rate</td></tr>");
$n = 1;
while ($arr = mysql_fetch_assoc($res))
{
$highlight = $CURUSER["id"] == $arr["userid"] ? " bgcolor=#BBAF9B" : "";
print("<tr><td$highlight>$n</td><td$highlight><a href=userdetails.php?id=" . $arr["userid"] . "><b>" . $arr["username"] . "</b></td><td$highlight>" . mksize($arr["uprate"]) . "/s</td><td$highlight>" . mksize($arr["downrate"]) . "/s</td></tr>\n");
++$n;
}
end_table();
end_frame();
}
stdhead("Top 10");
begin_main_frame();
// $r = sql_query("SELECT * FROM users ORDER BY donated DESC, username LIMIT 100") or die;
// donortable($r, "Top 10 Donors");
$type = isset($_GET["type"]) ? (int)$_GET["type"] : 0;
if (!in_array($type,array(1,2,3,4)))
$type = 1;
$limit = isset($_GET["lim"]) ? (int)$_GET["lim"] : false;
$subtype = isset($_GET["subtype"]) ? $_GET["subtype"] : false;
print("<p align=center>" .
($type == 1 && !$limit ? "<b>Ïîëüçîâàòåëè</b>" : "<a href=topten.php?type=1>Ïîëüçîâàòåëè</a>") . " | " .
($type == 2 && !$limit ? "<b>Òîððåíòû</b>" : "<a href=topten.php?type=2>Òîððåíòû</a>") . " | " .
($type == 3 && !$limit ? "<b>Ñòðàíû</b>" : "<a href=topten.php?type=3>Ñòðàíû</a>") . " | " .
($type == 4 && !$limit ? "<b>Ïèðû</b>" : "<a href=topten.php?type=4>Ïèðû</a>") . "</p>\n");
$pu = get_user_class() >= UC_POWER_USER;
if (!$pu)
$limit = 10;
if ($type == 1)
{
$mainquery = "SELECT id as userid, username, added, uploaded, downloaded, uploaded / (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(added)) AS upspeed, downloaded / (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(added)) AS downspeed FROM users WHERE enabled = 'yes'";
if (!$limit || $limit > 250)
$limit = 10;
if ($limit == 10 || $subtype == "ul")
{
$order = "uploaded DESC";
$r = sql_query($mainquery . " ORDER BY $order " . " LIMIT $limit") or sqlerr(__FILE__, __LINE__);
usertable($r, "Top $limit çàëèâàþùèõ" . ($limit == 10 && $pu ? " <font class=small> - [<a href=topten.php?type=1&lim=100&subtype=ul>Top 100</a>] - [<a href=topten.php?type=1&lim=250&subtype=ul>Top 250</a>]</font>" : ""));
}
if ($limit == 10 || $subtype == "dl")
{
$order = "downloaded DESC";
$r = sql_query($mainquery . " ORDER BY $order " . " LIMIT $limit") or sqlerr(__FILE__, __LINE__);
usertable($r, "Top $limit êà÷àþùèõ" . ($limit == 10 && $pu ? " <font class=small> - [<a href=topten.php?type=1&lim=100&subtype=dl>Top 100</a>] - [<a href=topten.php?type=1&lim=250&subtype=dl>Top 250</a>]</font>" : ""));
}
if ($limit == 10 || $subtype == "uls")
{
$order = "upspeed DESC";
$r = sql_query($mainquery . " ORDER BY $order " . " LIMIT $limit") or sqlerr(__FILE__, __LINE__);
usertable($r, "Top $limit áûñòðåéøèõ çàëèâàþùèõ <font class=small>(ñðåäíåå, âêëþ÷àÿ ïåðèîä íåàêòèâíîñòè)</font>" . ($limit == 10 && $pu ? " <font class=small> - [<a href=topten.php?type=1&lim=100&subtype=uls>Top 100</a>] - [<a href=topten.php?type=1&lim=250&subtype=uls>Top 250</a>]</font>" : ""));
}
if ($limit == 10 || $subtype == "dls")
{
$order = "downspeed DESC";
$r = sql_query($mainquery . " ORDER BY $order " . " LIMIT $limit") or sqlerr(__FILE__, __LINE__);
usertable($r, "Top $limit áûñòðåéøèõ êà÷àþùèõ <font class=small>(ñðåäíåå, âêëþ÷àÿ ïåðèîä íåàêòèâíîñòè)</font>" . ($limit == 10 && $pu ? " <font class=small> - [<a href=topten.php?type=1&lim=100&subtype=dls>Top 100</a>] - [<a href=topten.php?type=1&lim=250&subtype=dls>Top 250</a>]</font>" : ""));
}
if ($limit == 10 || $subtype == "bsh")
{
$order = "uploaded / downloaded DESC";
$extrawhere = " AND downloaded > 1073741824";
$r = sql_query($mainquery . $extrawhere . " ORDER BY $order " . " LIMIT $limit") or sqlerr(__FILE__, __LINE__);
usertable($r, "Top $limit ëó÷øèõ ðàçäàþùèõ <font class=small>(ìèíèìóì 1 GB ñêà÷àíî)</font>" . ($limit == 10 && $pu ? " <font class=small> - [<a href=topten.php?type=1&lim=100&subtype=bsh>Top 100</a>] - [<a href=topten.php?type=1&lim=250&subtype=bsh>Top 250</a>]</font>" : ""));
}
if ($limit == 10 || $subtype == "wsh")
{
$order = "uploaded / downloaded ASC, downloaded DESC";
$extrawhere = " AND downloaded > 1073741824";
$r = sql_query($mainquery . $extrawhere . " ORDER BY $order " . " LIMIT $limit") or sqlerr(__FILE__, __LINE__);
usertable($r, "Top $limit õóäøèõ ðàçäàþùèõ <font class=small>(ìèíèìóì 1 GB ñêà÷àíî)</font>" . ($limit == 10 && $pu ? " <font class=small> - [<a href=topten.php?type=1&lim=100&subtype=wsh>Top 100</a>] - [<a href=topten.php?type=1&lim=250&subtype=wsh>Top 250</a>]</font>" : ""));
}
}
elseif ($type == 2)
{
if (!$limit || $limit > 50)
$limit = 10;
if ($limit == 10 || $subtype == "act")
{
$r = sql_query("SELECT t.*, (t.size * t.times_completed + SUM(p.downloaded)) AS data FROM torrents AS t LEFT JOIN peers AS p ON t.id = p.torrent WHERE p.seeder = 'no' GROUP BY t.id ORDER BY seeders + leechers DESC, seeders DESC, added ASC LIMIT $limit") or sqlerr(__FILE__, __LINE__);
_torrenttable($r, "Top $limit Most Active Torrents" . ($limit == 10 && $pu ? " <font class=small> - [<a href=topten.php?type=2&lim=25&subtype=act>Top 25</a>] - [<a href=topten.php?type=2&lim=50&subtype=act>Top 50</a>]</font>" : ""));
}
if ($limit == 10 || $subtype == "sna")
{
$r = sql_query("SELECT t.*, (t.size * t.times_completed + SUM(p.downloaded)) AS data FROM torrents AS t LEFT JOIN peers AS p ON t.id = p.torrent WHERE p.seeder = 'no' GROUP BY t.id ORDER BY times_completed DESC LIMIT $limit") or sqlerr(__FILE__, __LINE__);
_torrenttable($r, "Top $limit Most Snatched Torrents" . ($limit == 10 && $pu ? " <font class=small> - [<a href=topten.php?type=2&lim=25&subtype=sna>Top 25</a>] - [<a href=topten.php?type=2&lim=50&subtype=sna>Top 50</a>]</font>" : ""));
}
if ($limit == 10 || $subtype == "mdt")
{
$r = sql_query("SELECT t.*, (t.size * t.times_completed + SUM(p.downloaded)) AS data FROM torrents AS t LEFT JOIN peers AS p ON t.id = p.torrent WHERE p.seeder = 'no' AND leechers >= 5 AND times_completed > 0 GROUP BY t.id ORDER BY data DESC, added ASC LIMIT $limit") or sqlerr(__FILE__, __LINE__);
_torrenttable($r, "Top $limit Most Data Transferred Torrents" . ($limit == 10 && $pu ? " <font class=small> - [<a href=topten.php?type=2&lim=25&subtype=mdt>Top 25</a>] - [<a href=topten.php?type=2&lim=50&subtype=mdt>Top 50</a>]</font>" : ""));
}
if ($limit == 10 || $subtype == "bse")
{
$r = sql_query("SELECT t.*, (t.size * t.times_completed + SUM(p.downloaded)) AS data FROM torrents AS t LEFT JOIN peers AS p ON t.id = p.torrent WHERE p.seeder = 'no' AND seeders >= 5 GROUP BY t.id ORDER BY seeders / leechers DESC, seeders DESC, added ASC LIMIT $limit") or sqlerr(__FILE__, __LINE__);
_torrenttable($r, "Top $limit Best Seeded Torrents <font class=small>(with minimum 5 seeders)</font>" . ($limit == 10 && $pu ? " <font class=small> - [<a href=topten.php?type=2&lim=25&subtype=bse>Top 25</a>] - [<a href=topten.php?type=2&lim=50&subtype=bse>Top 50</a>]</font>" : ""));
}
if ($limit == 10 || $subtype == "wse")
{
$r = sql_query("SELECT t.*, (t.size * t.times_completed + SUM(p.downloaded)) AS data FROM torrents AS t LEFT JOIN peers AS p ON t.id = p.torrent WHERE p.seeder = 'no' AND leechers >= 5 AND times_completed > 0 GROUP BY t.id ORDER BY seeders / leechers ASC, leechers DESC LIMIT $limit") or sqlerr(__FILE__, __LINE__);
_torrenttable($r, "Top $limit Worst Seeded Torrents <font class=small>(with minimum 5 leechers, excluding unsnatched torrents)</font>" . ($limit == 10 && $pu ? " <font class=small> - [<a href=topten.php?type=2&lim=25&subtype=wse>Top 25</a>] - [<a href=topten.php?type=2&lim=50&subtype=wse>Top 50</a>]</font>" : ""));
}
}
elseif ($type == 3)
{
if (!$limit || $limit > 25)
$limit = 10;
if ($limit == 10 || $subtype == "us")
{
$r = sql_query("SELECT name, flagpic, COUNT(users.country) as num FROM countries LEFT JOIN users ON users.country = countries.id GROUP BY name ORDER BY num DESC LIMIT $limit") or sqlerr(__FILE__, __LINE__);
countriestable($r, "Top $limit Countries<font class=small> (users)</font>" . ($limit == 10 && $pu ? " <font class=small> - [<a href=topten.php?type=3&lim=25&subtype=us>Top 25</a>]</font>" : ""),"Ïîëüçîâàòåëè");
}
if ($limit == 10 || $subtype == "ul")
{
$r = sql_query("SELECT c.name, c.flagpic, sum(u.uploaded) AS ul FROM users AS u LEFT JOIN countries AS c ON u.country = c.id WHERE u.enabled = 'yes' GROUP BY c.name ORDER BY ul DESC LIMIT $limit") or sqlerr(__FILE__, __LINE__);
countriestable($r, "Top $limit Countries<font class=small> (total uploaded)</font>" . ($limit == 10 && $pu ? " <font class=small> - [<a href=topten.php?type=3&lim=25&subtype=ul>Top 25</a>]</font>" : ""),"Ðàçäà÷à");
}
if ($limit == 10 || $subtype == "avg")
{
$r = sql_query("SELECT c.name, c.flagpic, sum(u.uploaded)/count(u.id) AS ul_avg FROM users AS u LEFT JOIN countries AS c ON u.country = c.id WHERE u.enabled = 'yes' GROUP BY c.name HAVING sum(u.uploaded) > 1099511627776 AND count(u.id) >= 100 ORDER BY ul_avg DESC LIMIT $limit") or sqlerr(__FILE__, __LINE__);
countriestable($r, "Top $limit Countries<font class=small> (average total uploaded per user, with minimum 1TB uploaded and 100 users)</font>" . ($limit == 10 && $pu ? " <font class=small> - [<a href=topten.php?type=3&lim=25&subtype=avg>Top 25</a>]</font>" : ""),"Ñðåäíåå");
}
if ($limit == 10 || $subtype == "r")
{
$r = sql_query("SELECT c.name, c.flagpic, sum(u.uploaded)/sum(u.downloaded) AS r FROM users AS u LEFT JOIN countries AS c ON u.country = c.id WHERE u.enabled = 'yes' GROUP BY c.name HAVING sum(u.uploaded) > 1099511627776 AND sum(u.downloaded) > 1099511627776 AND count(u.id) >= 100 ORDER BY r DESC LIMIT $limit") or sqlerr(__FILE__, __LINE__);
countriestable($r, "Top $limit Countries<font class=small> (ratio, with minimum 1TB uploaded, 1TB downloaded and 100 users)</font>" . ($limit == 10 && $pu ? " <font class=small> - [<a href=topten.php?type=3&lim=25&subtype=r>Top 25</a>]</font>" : ""),"Ðåéèòíã");
}
}
elseif ($type == 4)
{
print("<h1 align=center><font color=red>Under construction!</font></h1>\n");
if (!$limit || $limit > 250)
$limit = 10;
if ($limit == 10 || $subtype == "ul")
{
// $r = sql_query("SELECT users.id AS userid, peers.id AS peerid, username, peers.uploaded, peers.downloaded, peers.uploaded / (UNIX_TIMESTAMP(NOW()) - (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(last_action)) - UNIX_TIMESTAMP(started)) AS uprate, peers.downloaded / (UNIX_TIMESTAMP(NOW()) - (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(last_action)) - UNIX_TIMESTAMP(started)) AS downrate FROM peers LEFT JOIN users ON peers.userid = users.id ORDER BY uprate DESC LIMIT $limit") or sqlerr(__FILE__, __LINE__);
// peerstable($r, "Top $limit Fastest Uploaders" . ($limit == 10 && $pu ? " <font class=small> - [<a href=topten.php?type=4&lim=100&subtype=ul>Top 100</a>] - [<a href=topten.php?type=4&lim=250&subtype=ul>Top 250</a>]</font>" : ""));
// $r = sql_query("SELECT users.id AS userid, peers.id AS peerid, username, peers.uploaded, peers.downloaded, (peers.uploaded - peers.uploadoffset) / (UNIX_TIMESTAMP(last_action) - UNIX_TIMESTAMP(started)) AS uprate, (peers.downloaded - peers.downloadoffset) / (UNIX_TIMESTAMP(last_action) - UNIX_TIMESTAMP(started)) AS downrate FROM peers LEFT JOIN users ON peers.userid = users.id ORDER BY uprate DESC LIMIT $limit") or sqlerr(__FILE__, __LINE__);
// peerstable($r, "Top $limit Fastest Uploaders (timeout corrected)" . ($limit == 10 && $pu ? " <font class=small> - [<a href=topten.php?type=4&lim=100&subtype=ul>Top 100</a>] - [<a href=topten.php?type=4&lim=250&subtype=ul>Top 250</a>]</font>" : ""));
$r = sql_query( "SELECT users.id AS userid, username, (peers.uploaded - peers.uploadoffset) / (UNIX_TIMESTAMP(last_action) - UNIX_TIMESTAMP(started)) AS uprate, IF(seeder = 'yes',(peers.downloaded - peers.downloadoffset) / (finishedat - UNIX_TIMESTAMP(started)),(peers.downloaded - peers.downloadoffset) / (UNIX_TIMESTAMP(last_action) - UNIX_TIMESTAMP(started))) AS downrate FROM peers LEFT JOIN users ON peers.userid = users.id ORDER BY uprate DESC LIMIT $limit") or sqlerr(__FILE__, __LINE__);
peerstable($r, "Top $limit Fastest Uploaders" . ($limit == 10 && $pu ? " <font class=small> - [<a href=topten.php?type=4&lim=100&subtype=ul>Top 100</a>] - [<a href=topten.php?type=4&lim=250&subtype=ul>Top 250</a>]</font>" : ""));
}
if ($limit == 10 || $subtype == "dl")
{
// $r = sql_query("SELECT users.id AS userid, peers.id AS peerid, username, peers.uploaded, peers.downloaded, (peers.uploaded - peers.uploadoffset) / (UNIX_TIMESTAMP(last_action) - UNIX_TIMESTAMP(started)) AS uprate, (peers.downloaded - peers.downloadoffset) / (UNIX_TIMESTAMP(last_action) - UNIX_TIMESTAMP(started)) AS downrate FROM peers LEFT JOIN users ON peers.userid = users.id ORDER BY downrate DESC LIMIT $limit") or sqlerr(__FILE__, __LINE__);
// peerstable($r, "Top $limit Fastest Downloaders (timeout corrected)" . ($limit == 10 && $pu ? " <font class=small> - [<a href=topten.php?type=4&lim=100&subtype=dl>Top 100</a>] - [<a href=topten.php?type=4&lim=250&subtype=dl>Top 250</a>]</font>" : ""));
$r = sql_query("SELECT users.id AS userid, peers.id AS peerid, username, peers.uploaded, peers.downloaded,(peers.uploaded - peers.uploadoffset) / (UNIX_TIMESTAMP(last_action) - UNIX_TIMESTAMP(started)) AS uprate, IF(seeder = 'yes',(peers.downloaded - peers.downloadoffset) / (finishedat - UNIX_TIMESTAMP(started)),(peers.downloaded - peers.downloadoffset) / (UNIX_TIMESTAMP(last_action) - UNIX_TIMESTAMP(started))) AS downrate FROM peers LEFT JOIN users ON peers.userid = users.id ORDER BY downrate DESC LIMIT $limit") or sqlerr(__FILE__, __LINE__);
peerstable($r, "Top $limit Fastest Downloaders" . ($limit == 10 && $pu ? " <font class=small> - [<a href=topten.php?type=4&lim=100&subtype=dl>Top 100</a>] - [<a href=topten.php?type=4&lim=250&subtype=dl>Top 250</a>]</font>" : ""));
}
}
end_main_frame();
//print("<p><font class=small>Started recording account xfer stats on 2003-08-31</font></p>");
stdfoot();
?>