Rank User Donated 10) break; print("$rank$a[username]" . "$$this"); $last = $this; } end_table(); end_frame(); } */ function usertable($res, $frame_caption) { global $CURUSER; begin_frame($frame_caption, true); begin_table(); ?> $ratio"; } else $ratio = "Inf."; print("$num" . $a["username"] . "" . "" . mksize($a["uploaded"]) . "" . mksize($a["upspeed"]) . "/s" . "" . mksize($a["downloaded"]) . "" . mksize($a["downspeed"]) . "/s" . "" . $ratio . "" . $a["added"] . " (" . get_elapsed_time($a["utadded"]) . " ago)"); } end_table(); end_frame(); } function clientstable($res, $frame_caption) { begin_frame($frame_caption, true); begin_table(); ?> $num". "
". "$a[clientname]
$a[num]"); } end_table(); end_frame(); } function _torrenttable($res, $frame_caption) { begin_frame($frame_caption, true); begin_table(); ?> " . number_format($r, 2) . ""; } else $ratio = "Inf."; print("$num
" . $a["name"] . "" . number_format($a["times_completed"]) . "" . mksize($a["data"]) . "" . number_format($a["seeders"]) . "" . number_format($a["leechers"]) . "" . ($a["leechers"] + $a["seeders"]) . "$ratio"); } end_table(); end_frame(); } function countriestable($res, $frame_caption, $what) { global $CURUSER; begin_frame($frame_caption, true); begin_table(); ?> $num". "
". "$a[name]
$value"); } end_table(); end_frame(); } function peerstable($res, $frame_caption) { begin_frame($frame_caption, true); begin_table(); print("". _('Rank') ."". _('Username')."". _('Upload rate')."". _('Download rate').""); $n = 1; while ($arr = mysql_fetch_assoc($res)) { $highlight = $CURUSER["id"] == $arr["userid"] ? " bgcolor=#CF8474" : ""; print("$n" . $arr["username"] . "" . mksize($arr["uprate"]) . "/s" . mksize($arr["downrate"]) . "/s\n"); ++$n; } end_table(); end_frame(); } stdhead("Top 10"); begin_main_frame(); // $r = do_mysql_query("SELECT * FROM users ORDER BY donated DESC, username LIMIT 100") or die; // donortable($r, "Top 10 Donors"); $type = (int) $_GET["type"]; if (!in_array($type,array(1,2,3,4,5))) $type = 1; $limit = (int) $_GET["lim"]; $subtype = strip_tags($_GET["subtype"]); print("

" . ($type == 1 && !$limit ? "". _('Users')."" : "". _('Users')."") . " | " . ($type == 2 && !$limit ? "". _('Torrents')."" : "". _('Torrents')."") . " | " . ($type == 3 && !$limit ? "". _('Countries')."" : "". _('Countries')."") . " | " . ($type == 4 && !$limit ? "". _('Peers')."" : "". _('Peers')."
") ); $pu = get_user_class() >= UC_POWER_USER; if (!$pu) $limit = 10; if ($type == 1) { // BEGIN CACHE /////////////////////////////////////////////////////////// $cachefile = "$CACHE/topten/topten-type-".$type."-limit-".$lim."-poweruser-".$pu."-subtype-".$subtype.".html"; // Serve from the cache if it is younger than $cachetime if( !$GLOBALS['settings']['cache'] || !($data = $cache_lite->get('topten-type-'.$type.'-limit-'.$lim.'-poweruser-'.$pu.'-subtype-'.$subtype))) { ob_start(); // start the output buffer $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, UNIX_TIMESTAMP(added) as utadded FROM users WHERE enabled = 'yes'"; if (!$limit || $limit > 250) $limit = 10; if ($limit == 10 || $subtype == "wsh") { $order = "uploaded / downloaded ASC, downloaded DESC"; $extrawhere = " AND downloaded > 1073741824"; $r = do_mysql_query($mainquery . $extrawhere . " ORDER BY $order " . " LIMIT $limit") or sqlerr(); print("Leeching:"); usertable($r, sprintf( _("Top %u Worst Sharers (with minimum 1 GB downloaded)"), $limit) . ($limit == 10 && $pu ? " - ["._('Top')." 100] - ["._('Top')." 250]" : "")); } if ($limit == 10 || $subtype == "dl") { $order = "downloaded DESC"; $r = do_mysql_query($mainquery . $extrawhere . " ORDER BY $order " . " LIMIT $limit") or sqlerr(); usertable($r, sprintf( _("Top %u Downloaders"), $limit) . ($limit == 10 && $pu ? " - [Top 100] - [Top 250]" : "")); } if ($limit == 10 || $subtype == "dls") { $order = "downspeed DESC"; $r = do_mysql_query($mainquery . $extrawhere . " ORDER BY $order " . " LIMIT $limit") or sqlerr(); usertable($r, sprintf( _("Top %u Fastest Downloaders (average, includes inactive time)"), $limit) . ($limit == 10 && $pu ? " - [Top 100] - [Top 250]" : "")); } if ($limit == 10 || $subtype == "bsh") { $order = "uploaded / downloaded DESC"; $extrawhere = " AND downloaded > 1073741824"; $r = do_mysql_query($mainquery . $extrawhere . " ORDER BY $order " . " LIMIT $limit") or sqlerr(); print("


Seeding:"); usertable($r, sprintf( _("Top %u Best Sharers (with minimum 1 GB downloaded)"), $limit) . ($limit == 10 && $pu ? " - [Top 100] - [Top 250]" : "")); } if ($limit == 10 || $subtype == "ul") { $order = "uploaded DESC"; $r = do_mysql_query($mainquery . $extrawhere . " ORDER BY $order " . " LIMIT $limit") or sqlerr(); usertable($r, sprintf(_("Top %u Uploaders"),$limit) . ($limit == 10 && $pu ? " - [Top 100] - [Top 250]" : "")); } if ($limit == 10 || $subtype == "uls") { $order = "upspeed DESC"; $r = do_mysql_query($mainquery . $extrawhere . " ORDER BY $order " . " LIMIT $limit") or sqlerr(); usertable($r, sprintf(_("Top %u Fastest Uploaders (average, includes inactive time)"), $limit) . ($limit == 10 && $pu ? " - [Top 100] - [Top 250]" : "")); } //ENd if cache $data = ob_get_clean(); $cache_lite->setLifeTime($GLOBALS['config']['cache_topten']); $cache_lite->save($data, 'topten-type-'.$type.'-limit-'.$lim.'-poweruser-'.$pu.'-subtype-'.$subtype); } echo $data; } elseif ($type == 2) { // BEGIN CACHE /////////////////////////////////////////////////////////// $cachefile = "topten-type-".$type."-limit-".$lim."-poweruser-".$pu."-subtype-".$subtype; if( !$GLOBALS['settings']['cache'] || !($data = $cache_lite->get($cachefile) ) ) { ob_start(); // start the output buffer ///////////////////////////////////////////////////////////////////////////////// if (!$limit || $limit > 50) $limit = 10; if ($limit == 10 || $subtype == "act") { $r = do_mysql_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(); _torrenttable($r, sprintf(_("Top %u Most Active Torrents"), $limit) . ($limit == 10 && $pu ? " - [Top 25] - [Top 50]" : "")); } if ($limit == 10 || $subtype == "sna") { $r = do_mysql_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(); _torrenttable($r, sprintf( _("Top %u Most Snatched Torrents"), $limit) . ($limit == 10 && $pu ? " - [Top 25] - [Top 50]" : "")); } if ($limit == 10 || $subtype == "mdt") { $r = do_mysql_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(); _torrenttable($r, sprintf(_("Top %u Most Data Transferred Torrents"),$limit) . ($limit == 10 && $pu ? " - [Top 25] - [Top 50]" : "")); } if ($limit == 10 || $subtype == "bse") { $r = do_mysql_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(); _torrenttable($r, sprintf(_("Top %u Best Seeded Torrents (with minimum 5 seeders)"), $limit) . ($limit == 10 && $pu ? " - [Top 25] - [Top 50]" : "")); } if ($limit == 10 || $subtype == "wse") { $r = do_mysql_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(); _torrenttable($r, sprintf(_("Top %u Worst Seeded Torrents (with minimum 5 leechers, excluding unsnatched torrents)"), $limit) . ($limit == 10 && $pu ? " - [Top 25] - [Top 50]" : "")); } $data = ob_get_clean(); $cache_lite->setLifeTime($GLOBALS['config']['cache_topten']); $cache_lite->save($data, $cachefile); } echo $data; } elseif ($type == 3) { // BEGIN CACHE /////////////////////////////////////////////////////////// $cachefile = "topten-type-".$type."-limit-".$lim."-poweruser-".$pu."-subtype-".$subtype; if( !$GLOBALS['settings']['cache'] || !($data = $cache_lite->get($cachefile) ) ) { ob_start(); // start the output buffer ///////////////////////////////////////////////////////////////////////////////// if (!$limit || $limit > 25) $limit = 10; if ($limit == 10 || $subtype == "us") { $r = do_mysql_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(); countriestable($r, sprintf(_("Top %u Countries (users)"), $limit) . ($limit == 10 && $pu ? " - [Top 25]" : ""),"Users"); } if ($limit == 10 || $subtype == "ul") { $r = do_mysql_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(); countriestable($r, sprintf(_("Top %u Countries (total uploaded)"), $limit) . ($limit == 10 && $pu ? " - [Top 25]" : ""),"Uploaded"); } if ($limit == 10 || $subtype == "avg") { $r = do_mysql_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(); countriestable($r, sprintf(_("Top %u Countries (average total uploaded per user, with minimum 1TB uploaded and 100 users)"), $limit) . ($limit == 10 && $pu ? " - [Top 25]" : ""),"Average"); } if ($limit == 10 || $subtype == "r") { $r = do_mysql_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(); countriestable($r, sprintf(_("Top %u Countries (ratio, with minimum 1TB uploaded, 1TB downloaded and 100 users)"), $limit) . ($limit == 10 && $pu ? " - [Top 25]" : ""),"Ratio"); } $data = ob_get_clean(); $cache_lite->setLifeTime($GLOBALS['config']['cache_topten']); $cache_lite->save($data, $cachefile); } echo $data; } elseif ($type == 4) { // BEGIN CACHE /////////////////////////////////////////////////////////// $cachefile = "topten-type-".$type."-limit-".$lim."-poweruser-".$pu."-subtype-".$subtype; if( !$GLOBALS['settings']['cache'] || !($data = $cache_lite->get($cachefile) ) ) { ob_start(); // start the output buffer // print("

Under construction!

\n"); if (!$limit || $limit > 250) $limit = 10; if ($limit == 10 || $subtype == "ul") { // $r = do_mysql_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(); // peerstable($r, "Top $limit Fastest Uploaders" . ($limit == 10 && $pu ? " - [Top 100] - [Top 250]" : "")); // $r = do_mysql_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(); // peerstable($r, "Top $limit Fastest Uploaders (timeout corrected)" . ($limit == 10 && $pu ? " - [Top 100] - [Top 250]" : "")); $r = do_mysql_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(); peerstable($r, sprintf(_("Top %u Fastest Uploaders"), $limit) . ($limit == 10 && $pu ? " - [Top 100] - [Top 250]" : "")); } if ($limit == 10 || $subtype == "dl") { // $r = do_mysql_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(); // peerstable($r, "Top $limit Fastest Downloaders (timeout corrected)" . ($limit == 10 && $pu ? " - [Top 100] - [Top 250]" : "")); $r = do_mysql_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(); peerstable($r, sprintf(_("Top %u Fastest Downloaders"), $limit) . ($limit == 10 && $pu ? " - [Top 100] - [Top 250]" : "")); } $data = ob_get_clean(); $cache_lite->setLifeTime($GLOBALS['config']['cache_topten']); $cache_lite->save($data, $cachefile); } echo $data; } end_main_frame(); //print("

Started recording account xfer stats on 2003-08-31

"); stdfoot(); ?>