query
("
SELECT
hlstats_Games.name
FROM
hlstats_Games
WHERE
hlstats_Games.code = '$game'
");
if ($db->num_rows() < 1) error("No such game '$game'.");
list($gamename) = $db->fetch_row();
$db->free_result();
if (isset($_GET['minkills']))
{
$minkills = valid_request($_GET['minkills'], 1);
}
else
{
$minkills = 1;
}
pageHeader
(
array ($gamename, 'Player Rankings'),
array ($gamename=>"%s?game=$game", 'Player Rankings'=>'')
);
$rank_type = 0;
if (isset($_GET['rank_type']))
$rank_type = valid_request(strval($_GET['rank_type']), 0);
// Autocomplete function below implemented by KingJ. Heavy modified to use HTML request instead of JSON.
?>
query
("
SELECT
SQL_CALC_FOUND_ROWS
hlstats_Players.playerId,
hlstats_Players.connection_time,
unhex(replace(hex(hlstats_Players.lastName), 'E280AE', '')) as lastName,
hlstats_Players.flag,
hlstats_Players.country,
hlstats_Players.skill,
hlstats_Players.kills,
hlstats_Players.deaths,
hlstats_Players.last_skill_change,
ROUND(hlstats_Players.kills/(IF(hlstats_Players.deaths=0, 1, hlstats_Players.deaths)), 2) AS kpd,
hlstats_Players.headshots,
ROUND(hlstats_Players.headshots/(IF(hlstats_Players.kills=0, 1, hlstats_Players.kills)), 2) AS hpk,
IFNULL(ROUND((hlstats_Players.hits / hlstats_Players.shots * 100), 1), 0) AS acc,
activity
FROM
hlstats_Players
WHERE
hlstats_Players.game = '$game'
AND hlstats_Players.hideranking = 0
AND hlstats_Players.kills >= $minkills
ORDER BY
$table->sort $table->sortorder,
$table->sort2 $table->sortorder,
hlstats_Players.lastName ASC
LIMIT
$table->startitem,
$table->numperpage
");
$resultCount = $db->query("SELECT FOUND_ROWS()");
list($numitems) = $db->fetch_row($resultCount);
}
else
{
if ($rank_type == "-1")
{
$maxEvent = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
$minEvent = $maxEvent - (86400 * 7);
}
if ($rank_type == "-2")
{
$maxEvent = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
$minEvent = $maxEvent - (86400 * 30);
}
if (!isset($minEvent))
{
$minEvent = split("-", $dates[$rank_type-1]['eventTime']);
$minEvent = mktime(0, 0, 0, $minEvent[1], $minEvent[2], $minEvent[0]);
$maxEvent = $minEvent + 86400;
}
$result = $db->query
("
SELECT
SQL_CALC_FOUND_ROWS
hlstats_Players_History.playerId,
hlstats_Players.lastName,
hlstats_Players.flag,
hlstats_Players.country,
SUM(hlstats_Players_History.connection_time) AS connection_time,
SUM(hlstats_Players_History.skill_change) AS skill,
SUM(hlstats_Players_History.skill_change) AS skill_change,
SUM(hlstats_Players_History.skill_change) AS last_skill_change,
SUM(hlstats_Players_History.kills) AS kills,
SUM(hlstats_Players_History.deaths) AS deaths,
ROUND(SUM(hlstats_Players_History.kills) / IF(SUM(hlstats_Players_History.deaths) = 0, 1, SUM(hlstats_Players_History.deaths)), 2) AS kpd,
SUM(hlstats_Players_History.headshots) AS headshots,
ROUND(SUM(hlstats_Players_History.headshots) / SUM(hlstats_Players_History.kills), 2) AS hpk,
IFNULL(ROUND((SUM(hlstats_Players_History.hits) / SUM(hlstats_Players_History.shots) * 100), 1), 0) AS acc,
activity
FROM
hlstats_Players_History
INNER JOIN
hlstats_Players
ON
hlstats_Players_History.playerId = hlstats_Players.playerId
WHERE
hlstats_Players_History.game = '$game'
AND hlstats_Players.hideranking = 0
AND activity > 0
AND UNIX_TIMESTAMP(hlstats_Players_History.eventTime) >= $minEvent
AND UNIX_TIMESTAMP(hlstats_Players_History.eventTime) <= $maxEvent
GROUP BY
hlstats_Players_History.playerId
HAVING
SUM(hlstats_Players_History.kills) >= $minkills
ORDER BY
$table->sort $table->sortorder,
$table->sort2 $table->sortorder,
hlstats_Players.lastName ASC
LIMIT
$table->startitem,
$table->numperpage
");
$resultCount = $db->query("SELECT FOUND_ROWS()");
list($numitems) = $db->fetch_row($resultCount);
}
$table->draw($result, $numitems, 95);
?>