function getPlayerPsychoStats($playerId, &$registry)
{
$dbh = mysql_connect($registry->options['psychostats_hostname'],
$registry->options['psychostats_username'],
$registry->options['psychostats_password']) or standard_error(mysql_error());
mysql_select_db($registry->options['psychostats_database'], $dbh) or standard_error(mysql_error());
$playerDataQuery = mysql_query("
SELECT `name`, `skill`, `activity`, `rank`, `prevrank`
FROM `{$registry->options['psychostats_tableprefix']}plr`
LEFT JOIN `{$registry->options['psychostats_tableprefix']}plr_ids_name` USING(`plrid`)
WHERE `plrid` = {$playerId}
LIMIT 1
") or standard_error(mysql_error());
if (mysql_num_rows($playerDataQuery) == 0)
{
return false;
}
$playerData = mysql_fetch_assoc($playerDataQuery);
$playerVictimsQuery = mysql_query("
SELECT SUM(`kills`) AS `kills`, SUM(`deaths`) AS `deaths`
FROM `{$registry->options['psychostats_tableprefix']}c_plr_victims`
WHERE `plrid` = {$playerId}
") or standard_error(mysql_error());
$playerVictims = mysql_fetch_assoc($playerVictimsQuery);
return array(
"nickname" => $playerData['name'],
"skill" => $playerData['skill'],
"activity" => $playerData['activity'],
"rank" => $playerData['rank'],
"prevrank" => $playerData['prevrank'],
"kills" => $playerVictims['kills'],
"deaths" => $playerVictims['deaths']
);
}
if (preg_match('|id=([0-9]*)|', $profileobj->userinfo[$vbulletin->options['psychostats_userfield']], $playerId) &&
$playerPsychoStats = getPlayerPsychoStats($playerId[1], $vbulletin))
{
$template_hook['profile_left_last'] .= '<!-- psychostats -->
<div id="psychostats" class="tborder content_block">
<h4 class="thead block_title">
<a href="#top" class="collapse_gadget" onclick="return toggle_collapse(\'psychostats\')"><img id="collapseimg_stats" src="images/buttons/collapse_generic.gif" alt="" border="0" /></a>
<a name="stats"></a>
<span class="block_name">Статистика игрока</span>
</h4>
<div class="block_content" id="collapseobj_stats" style=""><div class="alt1 block_row">
<fieldset class="statistics_group">
<legend>Статистика игрока</legend>
<ul class="list_no_decoration">
<li><span class="shade">Ник:</span> ' . htmlspecialchars($playerPsychoStats['nickname']) . '</li>
<li><span class="shade">Убийств:</span> ' . $playerPsychoStats['kills'] . '</li>
<li><span class="shade">Смертей:</span> ' . $playerPsychoStats['deaths'] . '</li>
<li><span class="shade">Скилл:</span> ' . $playerPsychoStats['skill'] . '</li>
<li><span class="shade">Активность:</span> ' . $playerPsychoStats['activity'] . '</li>
<li><span class="shade">Позиция в ранке:</span> ' . $playerPsychoStats['rank'] . '</li>
<li><span class="shade">Предыдущая позиций:</span> ' . $playerPsychoStats['prevrank'] . '</li>
</ul>
</fieldset>
</div></div>
</div>
<!-- / psychostats -->';
}