<?php if (!defined('FLUX_ROOT')) exit; 

if($params->get('action') == 'login')
    {
        $chars = array();
        $guilds = array();
        $sex = array();
        $bsex = array();
		$bclass = array();
    }  else {
		$sex = "<img src='".$this->themePath('img/potm/M/1.png')."' alt=\"Sex\"/>";
					
		$sqlpvp  = "SELECT pvpladder.name AS char_name, pvpladder.kills AS kills, pvpladder.deaths AS deaths, char.char_id, char.base_level AS blvl, char.job_level AS jlvl, char.class AS bclass, login.sex, guild.name as gname, guild.emblem_len, guild.guild_id
					FROM pvpladder
					LEFT JOIN  `char` ON pvpladder.char_id = char.char_id
					LEFT JOIN  `login` ON char.account_id = login.account_id
					LEFT JOIN  `guild` ON char.guild_id = guild.guild_id
					ORDER BY kills DESC 
					LIMIT 1";
		$sthpvp  = $server->connection->getStatement($sqlpvp);
		$sthpvp->execute();
		$chars = $sthpvp->fetchAll();
		
		if (empty($chars[0]->sex)) {
			$bsex = $chars[0]->sex;
			$bclass = $chars[0]->bclass;
			$sex = "<img src='".$this->themePath('./img/potm/'.$bsex.'/'.$bclass.'.png')."' alt=\"Sex\"/>";
		} else {
			$bsex = array();
			$bclass = array();
		}

	}
	?>
<?php if ( $params->get('action') != 'login' ): ?>
<div style="width:100%; height:100%; border:none;">
<?php  if ( empty($chars[0]->char_name) ): ?>
<div style="border:none; position:absolute; float:left; width:75px; height:100px; margin-top:17px; margin-left:18px;">
<table width="100%" border="0" cellpadding="10">
  <tr>
    <td align="center"><?php echo $sex; ?></td>
  </tr>
</table>
</div>
<div style="border:none; position:absolute; float:left; width:130px; height:20px; margin-top:19px; margin-left:100px;">
<table width="100%" height="100%" border="0" cellpadding="3">
  <tr>
    <td align="center"><font class="hof"><?php echo htmlspecialchars(substr($chars[0]->char_name,0, 15)) ?></font></td>
  </tr>
</table>
</div>
<div style="border:none; position:absolute; float:left; width:130px; height:20px; margin-top:45px; margin-left:100px;">
<table width="100%" height="100%" border="0" cellpadding="3">
  <tr>
    <td align="center"><font class="hof"><?php echo htmlspecialchars(substr($chars[0]->gname, 0, 15)) ?></font></td>
  </tr>
</table>
</div>
<div style="border:none; position:absolute; float:left; width:130px; height:20px; margin-top:71px; margin-left:100px;">
<table width="100%" height="100%" border="0" cellpadding="3">
  <tr>
    <td align="center"><font class="hof"><?php echo htmlspecialchars($chars[0]->blvl."/".$chars[0]->jlvl) ?></font></td>
  </tr>
</table>
</div>
<div style="border:none; position:absolute; float:left; width:100px; height:20px; margin-top:97px; margin-left:120px;">
<table width="100%" height="100%" border="0" cellpadding="3">
  <tr>
    <td align="center"><font class="hof"><?php echo number_format($chars[0]->kills) ?></font></td>
  </tr>
</table>
</div>
<?php endif; ?>
</div>
<?php endif; ?>