query
("
SELECT
hlstats_Players.lastName,
hlstats_Players.game
FROM
hlstats_Players
WHERE
hlstats_Players.playerId = $player
");
if ($db->num_rows() != 1)
{
error("No such player '$player'.");
}
$playerdata = $db->fetch_array();
$pl_name = $playerdata['lastName'];
if (strlen($pl_name) > 10)
{
$pl_shortname = substr($pl_name, 0, 8) . '...';
}
else
{
$pl_shortname = $pl_name;
}
$pl_name = htmlspecialchars($pl_name, ENT_COMPAT);
$pl_shortname = htmlspecialchars($pl_shortname, ENT_COMPAT);
$game = $playerdata['game'];
$db->query
("
SELECT
hlstats_Games.name
FROM
hlstats_Games
WHERE
hlstats_Games.code = '$game'
");
if ($db->num_rows() != 1)
{
$gamename = ucfirst($game);
}
else
{
list($gamename) = $db->fetch_row();
}
pageHeader
(
array ($gamename, 'Event History', $pl_name),
array
(
$gamename=>$g_options['scripturl'] . "?game=$game",
'Player Rankings'=>$g_options['scripturl'] . "?mode=players&game=$game",
'Player Details'=>$g_options['scripturl'] . "?mode=playerinfo&player=$player",
'Event History'=>''
),
$playername
);
flush();
$table = new Table
(
array
(
new TableColumn
(
'eventTime',
'Date',
'width=20'
),
new TableColumn
(
'eventType',
'Type',
'width=10&align=center'
),
new TableColumn
(
'eventDesc',
'Description',
'width=40&sort=no&append=.&embedlink=yes'
),
new TableColumn
(
'serverName',
'Server',
'width=20'
),
new TableColumn
(
'map',
'Map',
'width=10'
)
),
'eventTime',
'eventTime',
'eventType',
false,
50,
'page',
'sort',
'sortorder'
);
$surl = $g_options['scripturl'];
// This would be better done with a UNION query, I think, but MySQL doesn't
// support them yet. (NOTE you need MySQL 3.23 for temporary table support.)
$db->query
("
DROP TABLE IF EXISTS
hlstats_EventHistory
");
$db->query
("
CREATE TEMPORARY TABLE
hlstats_EventHistory
(
eventType VARCHAR(32) NOT NULL,
eventTime DATETIME NOT NULL,
eventDesc VARCHAR(255) NOT NULL,
serverName VARCHAR(255) NOT NULL,
map VARCHAR(64) NOT NULL
) DEFAULT CHARSET=utf8
");
function insertEvents ($table, $select)
{
global $db;
$select = str_replace("
", "hlstats_Events_$table", $select);
$db->query
("
INSERT INTO
hlstats_EventHistory
(
eventType,
eventTime,
eventDesc,
serverName,
map
)
$select
");
}
insertEvents
('TeamBonuses', "
SELECT
'Team Bonus',
.eventTime,
CONCAT('My team received a points bonus of ', bonus, ' for triggering \"', IFNULL(hlstats_Actions.description,'Unknown'), '\"'),
IFNULL(hlstats_Servers.name, 'Unknown'),
.map
FROM
LEFT JOIN
hlstats_Actions
ON
.actionId = hlstats_Actions.id
LEFT JOIN
hlstats_Servers
ON
hlstats_Servers.serverId = .serverId
WHERE
.playerId = $player
AND
hlstats_Actions.game = '$game'
");
if ($g_options["Mode"] == "LAN")
{
$uqIdStr = "IP Address:";
}
else
{
$uqIdStr = "Unique ID:";
}
insertEvents
('Connects', "
SELECT
'Connect',
.eventTime,
CONCAT('I connected to the server'),
IFNULL(hlstats_Servers.name, 'Unknown'),
.map
FROM
LEFT JOIN
hlstats_Servers
ON
hlstats_Servers.serverId = .serverId
WHERE
.playerId = $player
");
insertEvents
('Disconnects', "
SELECT
'Disconnect',
.eventTime,
'I left the game',
IFNULL(hlstats_Servers.name, 'Unknown'),
.map
FROM
LEFT JOIN
hlstats_Servers
ON
hlstats_Servers.serverId = .serverId
WHERE
.playerId = $player
");
insertEvents
('Entries', "
SELECT
'Entry',
.eventTime,
'I entered the game',
IFNULL(hlstats_Servers.name, 'Unknown'),
.map
FROM
LEFT JOIN
hlstats_Servers
ON
hlstats_Servers.serverId = .serverId
WHERE
.playerId = $player
");
insertEvents
('Frags', "
SELECT
'Kill',
.eventTime,
CONCAT('I killed %A%$surl?mode=playerinfo&player=', victimId, '%', IFNULL(hlstats_Players.lastName,'Unknown'), '%/A%', ' with ', weapon),
IFNULL(hlstats_Servers.name, 'Unknown'),
.map
FROM
LEFT JOIN
hlstats_Servers
ON
hlstats_Servers.serverId = .serverId
LEFT JOIN
hlstats_Players
ON
hlstats_Players.playerId = .victimId
WHERE
.killerId = $player
AND .headshot = 0
");
insertEvents
('Frags', "
SELECT
'Kill',
.eventTime,
CONCAT('I killed %A%$surl?mode=playerinfo&player=', victimId, '%', IFNULL(hlstats_Players.lastName,'Unknown'), '%/A%', ' with a headshot from ', weapon),
IFNULL(hlstats_Servers.name, 'Unknown'),
.map
FROM
LEFT JOIN
hlstats_Servers
ON
hlstats_Servers.serverId = .serverId
LEFT JOIN
hlstats_Players
ON
hlstats_Players.playerId = .victimId
WHERE
.killerId = $player
AND .headshot = 1
");
insertEvents
('Frags', "
SELECT
'Death',
.eventTime,
CONCAT('%A%$surl?mode=playerinfo&player=', killerId, '%', IFNULL(hlstats_Players.lastName,'Unknown'), '%/A%', ' killed me with ', weapon),
IFNULL(hlstats_Servers.name, 'Unknown'),
.map
FROM
LEFT JOIN
hlstats_Servers
ON
hlstats_Servers.serverId = .serverId
LEFT JOIN
hlstats_Players
ON
hlstats_Players.playerId = .killerId
WHERE
.victimId = $player
");
insertEvents
('Teamkills', "
SELECT
'Team Kill',
.eventTime,
CONCAT('I killed teammate %A%$surl?mode=playerinfo&player=', victimId, '%', IFNULL(hlstats_Players.lastName,'Unknown'), '%/A%', ' with ', weapon),
IFNULL(hlstats_Servers.name, 'Unknown'),
.map
FROM
LEFT JOIN
hlstats_Servers
ON
hlstats_Servers.serverId = .serverId
LEFT JOIN
hlstats_Players
ON
hlstats_Players.playerId = .victimId
WHERE
.killerId = $player
");
insertEvents
('Teamkills', "
SELECT
'Friendly Fire',
.eventTime,
CONCAT('My teammate %A%$surl?mode=playerinfo&player=', killerId, '%', IFNULL(hlstats_Players.lastName, 'Unknown'), '%/A%', ' killed me with ', weapon),
IFNULL(hlstats_Servers.name, 'Unknown'),
.map
FROM
LEFT JOIN
hlstats_Servers
ON
hlstats_Servers.serverId = .serverId
LEFT JOIN
hlstats_Players
ON
hlstats_Players.playerId = .killerId
WHERE
.victimId = $player
");
insertEvents
('ChangeRole', "
SELECT
'Role',
.eventTime,
CONCAT('I changed role to ', role),
IFNULL(hlstats_Servers.name, 'Unknown'),
.map
FROM
LEFT JOIN
hlstats_Servers
ON
hlstats_Servers.serverId = .serverId
WHERE
.playerId = $player
");
insertEvents
('ChangeName', "
SELECT
'Name',
.eventTime,
CONCAT('I changed my name from \"', oldName, '\" to \"', newName, '\"'),
IFNULL(hlstats_Servers.name, 'Unknown'),
.map
FROM
LEFT JOIN
hlstats_Servers
ON
hlstats_Servers.serverId = .serverId
WHERE
.playerId = $player
");
insertEvents
('PlayerActions', "
SELECT
'Action',
.eventTime,
CONCAT('I received a points bonus of ', bonus, ' for triggering \"', IFNULL(hlstats_Actions.description,'Unknown'), '\"'),
IFNULL(hlstats_Servers.name, 'Unknown'),
.map
FROM
LEFT JOIN
hlstats_Servers
ON
hlstats_Servers.serverId = .serverId
LEFT JOIN
hlstats_Actions
ON
hlstats_Actions.id = .actionId
WHERE
.playerId = $player
AND
hlstats_Actions.game = '$game'
");
insertEvents
('PlayerPlayerActions', "
SELECT
'Action',
.eventTime,
CONCAT('I received a points bonus of ', bonus, ' for triggering \"', IFNULL(hlstats_Actions.description,'Unknown'), '\" against %A%$surl?mode=playerinfo&player=', victimId, '%', IFNULL(hlstats_Players.lastName,'Unknown'), '%/A%'),
IFNULL(hlstats_Servers.name, 'Unknown'),
.map
FROM
LEFT JOIN
hlstats_Servers
ON
hlstats_Servers.serverId = .serverId
LEFT JOIN
hlstats_Actions
ON
hlstats_Actions.id = .actionId
LEFT JOIN hlstats_Players ON
hlstats_Players.playerId = .victimId
WHERE
.playerId = $player
AND
hlstats_Actions.game = '$game'
");
insertEvents
('PlayerPlayerActions', "
SELECT
'Action',
.eventTime,
CONCAT('%A%$surl?mode=playerinfo&player=', .playerId, '%', IFNULL(hlstats_Players.lastName,'Unknown'), '%/A% triggered \"', IFNULL(hlstats_Actions.description,'Unknown'), '\" against me'),
IFNULL(hlstats_Servers.name, 'Unknown'),
.map
FROM
LEFT JOIN
hlstats_Servers
ON
hlstats_Servers.serverId = .serverId
LEFT JOIN
hlstats_Actions
ON
hlstats_Actions.id = .actionId
LEFT JOIN
hlstats_Players
ON
hlstats_Players.playerId = .playerId
WHERE
.victimId = $player
AND
hlstats_Actions.game = '$game'
");
insertEvents
('Suicides', "
SELECT
'Suicide',
.eventTime,
CONCAT('I committed suicide with \"', weapon, '\"'),
IFNULL(hlstats_Servers.name, 'Unknown'),
.map
FROM
LEFT JOIN
hlstats_Servers
ON
hlstats_Servers.serverId = .serverId
WHERE
.playerId = $player
");
insertEvents
('ChangeTeam', "
SELECT
'Team',
.eventTime,
IF(hlstats_Teams.name IS NULL, CONCAT('I joined team \"', team, '\"'), CONCAT('I joined team \"', team, '\" (', hlstats_Teams.name, ')')),
IFNULL(hlstats_Servers.name, 'Unknown'),
.map
FROM
LEFT JOIN
hlstats_Servers
ON
hlstats_Servers.serverId = .serverId
LEFT JOIN
hlstats_Teams
ON
hlstats_Teams.code = .team
WHERE
.playerId = $player
AND
hlstats_Teams.game = '$game'
");
$result = $db->query
("
SELECT
hlstats_EventHistory.eventTime,
hlstats_EventHistory.eventType,
hlstats_EventHistory.eventDesc,
hlstats_EventHistory.serverName,
hlstats_EventHistory.map
FROM
hlstats_EventHistory
ORDER BY
$table->sort $table->sortorder,
$table->sort2 $table->sortorder
LIMIT
$table->startitem,
$table->numperpage
");
$resultCount = $db->query
("
SELECT
COUNT(*)
FROM
hlstats_EventHistory
");
list($numitems) = $db->fetch_row($resultCount);
?>
0)
{
$table->draw($result, $numitems, 95);
}
?>