" . ($type == 1 && !$limit ? "Users" : "Users") . " | " . ($type == 2 && !$limit ? "Torrents" : "Torrents") . " | " . ($type == 3 && !$limit ? "Countries" : "Countries") . " | " . ($type == 4 && !$limit ? "Peers" : "Peers") . "
\n"); $pu = get_user_class() >= UC_POWER_USER; if (!$pu) $limit = 10; if ($type == 1) { // START CACHE // $cachefile = "fts-contents/cache/topten-type-".$type."-limit-".$lim."-poweruser-".$pu."-subtype-".$subtype.".html"; $cachetime = @get('cache_topten'); // 60 minutes // Serve from the cache if it is younger than $cachetime if (file_exists($cachefile) && (time() - $cachetime < filemtime($cachefile))) { include($cachefile); print("This page last updated ".date('Y-m-d H:i:s', filemtime($cachefile)).". Cached every ".@sec2hms(@get('cache_topten'))."
"); end_main_frame(); stdfoot(); exit; } 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 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(); usertable($r, "Top $limit Uploaders" . ($limit == 10 && $pu ? " - [Top 100] - [Top 250]" : "")); } if ($limit == 10 || $subtype == "dl") { $order = "downloaded DESC"; $r = sql_query($mainquery . " ORDER BY $order " . " LIMIT $limit") or sqlerr(); usertable($r, "Top $limit Downloaders" . ($limit == 10 && $pu ? " - [Top 100] - [Top 250]" : "")); } if ($limit == 10 || $subtype == "uls") { $order = "upspeed DESC"; $r = sql_query($mainquery . " ORDER BY $order " . " LIMIT $limit") or sqlerr(); usertable($r, "Top $limit Fastest Uploaders (average, includes inactive time)" . ($limit == 10 && $pu ? " - [Top 100] - [Top 250]" : "")); } if ($limit == 10 || $subtype == "dls") { $order = "downspeed DESC"; $r = sql_query($mainquery . " ORDER BY $order " . " LIMIT $limit") or sqlerr(); usertable($r, "Top $limit Fastest Downloaders (average, includes inactive time)" . ($limit == 10 && $pu ? " - [Top 100] - [Top 250]" : "")); } 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(); usertable($r, "Top $limit Best Sharers (with minimum 1 GB downloaded)" . ($limit == 10 && $pu ? " - [Top 100] - [Top 250]" : "")); } 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(); usertable($r, "Top $limit Worst Sharers (with minimum 1 GB downloaded)" . ($limit == 10 && $pu ? " - [Top 100] - [Top 250]" : "")); } // CACHE END ////////////////////////////////////////////////// // open the cache file for writing $fp = fopen($cachefile, 'w'); // save the contents of output buffer to the file fwrite($fp, ob_get_contents()); // close the file fclose($fp); // Send the output to the browser ob_end_flush(); ///////////////////////////////////////////////////////// } elseif ($type == 2) { // START CACHE // $cachefile = "fts-contents/cache/topten-type-".$type."-limit-".$lim."-poweruser-".$pu."-subtype-".$subtype.".html"; $cachetime = @get('cache_topten'); // 60 minutes // Serve from the cache if it is younger than $cachetime if (file_exists($cachefile) && (time() - $cachetime < filemtime($cachefile))) { include($cachefile); print("This page last updated ".date('Y-m-d H:i:s', filemtime($cachefile)).". Cached every ".@sec2hms(@get('cache_topten'))."
"); end_main_frame(); stdfoot(); exit; } ob_start(); // start the output buffer ///////////////////////////////////////////////////////// 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(); _torrenttable($r, "Top $limit Most Active Torrents" . ($limit == 10 && $pu ? " - [Top 25] - [Top 50]" : "")); } 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(); _torrenttable($r, "Top $limit Most Snatched Torrents" . ($limit == 10 && $pu ? " - [Top 25] - [Top 50]" : "")); } 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(); _torrenttable($r, "Top $limit Most Data Transferred Torrents" . ($limit == 10 && $pu ? " - [Top 25] - [Top 50]" : "")); } 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(); _torrenttable($r, "Top $limit Best Seeded Torrents (with minimum 5 seeders)" . ($limit == 10 && $pu ? " - [Top 25] - [Top 50]" : "")); } 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(); _torrenttable($r, "Top $limit Worst Seeded Torrents (with minimum 5 leechers, excluding unsnatched torrents)" . ($limit == 10 && $pu ? " - [Top 25] - [Top 50]" : "")); } // CACHE END ////////////////////////////////////////////////// // open the cache file for writing $fp = fopen($cachefile, 'w'); // save the contents of output buffer to the file fwrite($fp, ob_get_contents()); // close the file fclose($fp); // Send the output to the browser ob_end_flush(); ///////////////////////////////////////////////////////// } elseif ($type == 3) { // START CACHE // $cachefile = "fts-contents/cache/topten-type-".$type."-limit-".$lim."-poweruser-".$pu."-subtype-".$subtype.".html"; $cachetime = @get('cache_topten'); // 60 minutes // Serve from the cache if it is younger than $cachetime if (file_exists($cachefile) && (time() - $cachetime < filemtime($cachefile))) { include($cachefile); print("This page last updated ".date('Y-m-d H:i:s', filemtime($cachefile)).". Cached every ".@sec2hms(@get('cache_topten'))."
"); end_main_frame(); stdfoot(); exit; } ob_start(); // start the output buffer ///////////////////////////////////////////////////////// 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(); countriestable($r, "Top $limit Countries (users)" . ($limit == 10 && $pu ? " - [Top 25]" : ""),"Users"); } 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(); countriestable($r, "Top $limit Countries (total uploaded)" . ($limit == 10 && $pu ? " - [Top 25]" : ""),"Uploaded"); } 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(); countriestable($r, "Top $limit Countries (average total uploaded per user, with minimum 1TB uploaded and 100 users)" . ($limit == 10 && $pu ? " - [Top 25]" : ""),"Average"); } 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(); countriestable($r, "Top $limit Countries (ratio, with minimum 1TB uploaded, 1TB downloaded and 100 users)" . ($limit == 10 && $pu ? " - [Top 25]" : ""),"Ratio"); } // CACHE END ////////////////////////////////////////////////// // open the cache file for writing $fp = fopen($cachefile, 'w'); // save the contents of output buffer to the file fwrite($fp, ob_get_contents()); // close the file fclose($fp); // Send the output to the browser ob_end_flush(); ///////////////////////////////////////////////////////// } elseif ($type == 4) { // START CACHE // $cachefile = "fts-contents/cache/topten-type-".$type."-limit-".$lim."-poweruser-".$pu."-subtype-".$subtype.".html"; $cachetime = @get('cache_topten'); // 60 minutes // Serve from the cache if it is younger than $cachetime if (file_exists($cachefile) && (time() - $cachetime < filemtime($cachefile))) { include($cachefile); print("This page last updated ".date('Y-m-d H:i:s', filemtime($cachefile)).". Cached every ".@sec2hms(@get('cache_topten'))."
"); end_main_frame(); stdfoot(); exit; } ob_start(); // start the output buffer ///////////////////////////////////////////////////////// // print("