". "$a[clientname] | ". "
". " | $a[name] | ". "
" .
($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("
Started recording account xfer stats on 2003-08-31
"); stdfoot(); ?>