2004-12-08 22:05:56 +00:00
|
|
|
<?php
|
2004-06-30 18:53:35 +00:00
|
|
|
|
2004-12-08 22:05:56 +00:00
|
|
|
require_once("../inc/cache.inc");
|
|
|
|
require_once("../inc/util.inc");
|
|
|
|
require_once("../inc/team.inc");
|
2004-06-30 18:53:35 +00:00
|
|
|
|
2004-12-08 22:05:56 +00:00
|
|
|
$n = 20;
|
2004-06-07 03:34:07 +00:00
|
|
|
|
2004-12-08 22:05:56 +00:00
|
|
|
$sort_by = $_GET["sort_by"];
|
|
|
|
if (!$sort_by) $sort_by = "expavg_credit";
|
|
|
|
$offset = $_GET["offset"];
|
|
|
|
if (!$offset) $offset=0;
|
|
|
|
$type = $_GET["type"];
|
|
|
|
$type = $type + 0;
|
|
|
|
if ($type < 1 || $type > 7) {
|
|
|
|
$type = null;
|
|
|
|
}
|
|
|
|
if ($type) {
|
|
|
|
$type_url = "&type=$type";
|
|
|
|
$type_sql = "where type=$type";
|
|
|
|
$type_name = team_type_name($type);
|
|
|
|
}
|
2004-06-30 18:53:35 +00:00
|
|
|
|
2004-12-08 22:05:56 +00:00
|
|
|
if ($offset % $n) $offset = 0;
|
2003-09-08 00:04:55 +00:00
|
|
|
|
2004-12-08 22:05:56 +00:00
|
|
|
if ($offset < 1000) {
|
|
|
|
$cache_args = "sort_by=$sort_by&offset=$offset".$type_url;
|
|
|
|
start_cache(TOP_PAGES_TTL, $cache_args);
|
|
|
|
} else {
|
|
|
|
page_head("Limit exceeded");
|
|
|
|
echo "Sorry - first 1000 only.";
|
|
|
|
page_tail();
|
|
|
|
exit();
|
|
|
|
}
|
2002-11-11 19:40:22 +00:00
|
|
|
|
2004-12-08 22:05:56 +00:00
|
|
|
require_once("../inc/db.inc");
|
|
|
|
require_once("../inc/user.inc");
|
2002-11-11 19:40:22 +00:00
|
|
|
|
2004-12-08 22:05:56 +00:00
|
|
|
db_init();
|
|
|
|
|
|
|
|
page_head("Top $type_name teams");
|
|
|
|
if ($sort_by == "total_credit") {
|
|
|
|
$sort_clause = "total_credit desc";
|
|
|
|
} else {
|
|
|
|
$sort_clause = "expavg_credit desc";
|
|
|
|
}
|
|
|
|
$result = mysql_query("select * from team $type_sql order by $sort_clause limit $offset,$n");
|
|
|
|
start_table();
|
|
|
|
row1("Teams", 6);
|
|
|
|
team_table_start($sort_by);
|
|
|
|
$i = $offset + 1;
|
|
|
|
while ($team = mysql_fetch_object($result)) {
|
2003-09-08 00:04:55 +00:00
|
|
|
if ($sort_by == "total_credit") {
|
2004-12-08 22:05:56 +00:00
|
|
|
show_team_row($team, $i);
|
|
|
|
$i++;
|
2003-09-08 00:04:55 +00:00
|
|
|
} else {
|
2004-12-08 22:05:56 +00:00
|
|
|
if (!team_inactive_ndays($team, 7)) {
|
2004-11-01 23:10:02 +00:00
|
|
|
show_team_row($team, $i);
|
|
|
|
$i++;
|
|
|
|
}
|
2002-11-08 22:30:13 +00:00
|
|
|
}
|
2004-12-08 22:05:56 +00:00
|
|
|
}
|
|
|
|
mysql_free_result($result);
|
|
|
|
echo "</table>\n<p>\n";
|
|
|
|
if ($offset > 0) {
|
|
|
|
$new_offset = $offset - $n;
|
|
|
|
echo "<a href=top_teams.php?sort_by=$sort_by&offset=$new_offset".$type_url.">Last $n</a> | ";
|
2004-06-07 03:34:07 +00:00
|
|
|
|
2004-12-08 22:05:56 +00:00
|
|
|
}
|
|
|
|
$new_offset = $offset + $n;
|
|
|
|
echo "<a href=top_teams.php?sort_by=$sort_by&offset=$new_offset".$type_url.">Next $n</a>";
|
2004-06-07 03:34:07 +00:00
|
|
|
|
2004-12-08 22:05:56 +00:00
|
|
|
if ($offset < 1000) {
|
|
|
|
page_tail(true);
|
|
|
|
end_cache(TOP_PAGES_TTL, $cache_args);
|
|
|
|
} else {
|
|
|
|
page_tail();
|
|
|
|
}
|
2004-04-14 20:55:37 +00:00
|
|
|
|
2004-12-08 22:05:56 +00:00
|
|
|
?>
|