<?php
/*======================================================================*\
|| #################################################################### ||
|| # EoT-Clan BC2 Server Stats                                        # ||
|| # ---------------------------------------------------------------- # ||
|| # Dieses Copyright darf nicht entfernt werden                      # ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # -----------------BC2 Server Stats is a free Software-------------# ||
|| #                      http://eot-clan.net                         # ||
|| #################################################################### ||
\*======================================================================*/
    if (!defined('INCLUDE_ME')){ 
die('access not allowed'); 
}
       $Rank = '0';
  	    $score = '0';
  	    $kd = '0';
        $kills = '0';
        $deaths = '0';
        $time = '0';
        $update = '0';
        $title = lang_stats_title1error;

    if(isset($data['Rank']) && isset($data['Score']) && isset($data['Kills']) && isset($data['Deaths']) && isset($data['Time']) && isset($data['LastUpdate'])){
     $Rank = $data['Rank'];
     $score = number_format($data['Score'], 0, ',', ' ');
     $kills = number_format($data['Kills'], 0, ',', ' ');
     $deaths = number_format($data['Deaths'], 0, ',', ' ');

         if($data['bfbcsKD'] >= 1){
	           $kd = "<span class=positiv>".number_format($data['bfbcsKD'], 2, '.', '.')."</span>";
	     }else{
             $kd = "<span class=negativ>".number_format($data['bfbcsKD'], 2, '.', '.')."</span>";	
      }
          
          if ($data['Time'] == 0){
          	$time = 0;
          }else{
           $time = round($data['Time']);
           $time = sprintf("%02dd %02dh %02dmin %02ds",$time/24/60/60,$time/60/60%24,$time/60%60,$time%60);
           $update = $data['LastUpdate'];
           $title = lang_stats_title1;
         }
     
     }
        
   include_once ('inc/rankname.php');


if ($data['playerPlaytime'] == 0){
	$ppm = 0;
	$kpm = 0;
}else{
	$Time = ($data['playerPlaytime']/60);
	$ppm = ($data['playerScore']/$Time);
	$kpm = ($data['playerKills']/$Time);
}


if ($data['playerRounds'] == 0){
	$ppr = 0;
	$kpr = 0;
}else{
	$ppr = ($data['playerScore']/$data['playerRounds']);
	$kpr = ($data['playerKills']/$data['playerRounds']);
}


?>
		<td class="result">
		 <div style="float:left;height:412px;width:160px;border-right: 1px solid #303030;margin-right:5px;"><a href="http://bfbcs.com/stats_pc/<?php echo urlencode($data['SoldierName']) ?>" target="_blank"><img src="img/rank/big/<?php echo $Rank; ?>.png" border="0" width="100px" style=margin-top:30px;" title="<?php echo htmlspecialchars($data['SoldierName']) ?> hat den Rang <?php echo $Rank; ?>" /></a>
		 	<br /><b><?php echo $rankname[$Rank]; ?></b>
		 <br />
		 	<b><?php echo lang_stats_countryflag; ?></b> <img src="img/flags/<?php echo $data['CountryCode']?>.png" border="0" alt="country" title="Land"/>
		 <?php if ($dChatlog == 1){ ?>
		 <br />
		   <a id="d_h_dn" href="stats/chatentrys.php?player=<?php echo urlencode($data['SoldierName']) ?>"><img class="chatlog" src="./img/1.png" border="0" /></a>
		 <?php } ?>
		 <br />
		 	 <a id="d_h_dn" href="stats/dogtags.php?killer=<?php echo urlencode($data['PlayerID']) ?>"><img class="dogtags" src="./img/1.png" border="0"></a>
		 <br />
		 	 <a id="d_h_dn" href="stats/dogtags.php?victim=<?php echo urlencode($data['PlayerID']) ?>"><img class="n_dogtags" src="./img/1.png" border="0"></a>
		 <br /> 
		 <script type="text/javascript">  	
		$(document).ready(function() {
	
			$("a#d_h_dn").fancybox({
			'autoDimensions'	: true,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'padding' : 0
			});
     });
	</script>
		 	</div>
		 	<div style="float:left;width:640px;text-align:center;height: 34px;">
    <hr style="margin-top:2px;margin-bottom:1px;">
    <b><?php echo $title; ?></b>
		<hr style="margin-top:1px;margin-bottom:1px;">
	 </div>
		 <div style="float:left;width:175px;text-align:left;height:20px;"><b><?php echo lang_stats_name; ?></b>:<a href="http://bfbcs.com/stats_pc/<?php echo urlencode($data['SoldierName']) ?>" target="_blank"><span class="stats_players"><?php echo htmlspecialchars($data['SoldierName']); ?></span></a></div>
		 <div style="float:left;width:125px;text-align:left;height:20px;"><b><?php echo lang_stats_points; ?></b>: <span class="stats_players"><?php echo $score; ?></span></div>
		 <div style="float:left;width:100px;text-align:left;height:20px;"><b><?php echo lang_kills; ?></b>: <span class="stats_players"><?php echo $kills; ?></span></div>
		 <div style="float:left;width:100px;text-align:left;height:20px;"><b><?php echo lang_deaths; ?></b>: <span class="stats_players"><?php echo $deaths; ?></span></div>
		 <div style="float:left;width:140px;text-align:left;height:20px;"><b><?php echo lang_stats_kd; ?></b>: <?php echo $kd; ?></div>
		<br />
		 <div style="float:left;width:175px;text-align:left;height:20px;"><b><?php echo lang_stats_time; ?></b>: <span class="stats_players"><?php echo $time; ?></span></div>
		 <div style="float:left;width:445px;text-align:left;height:20px;"><b><?php echo lang_stats_lastupdate; ?></b>: <span class="stats_players"><?php echo $update; ?></span></div>
		 <div style="float:left;width:640px;text-align:center;height: 34px;">
    <hr style="margin-top:2px;margin-bottom:1px;">
    <b><?php echo lang_stats_title_intern; ?></b>
		<hr style="margin-top:1px;margin-bottom:1px;">
	  </div>
	  <div style="float:left;width:165px;text-align:left;height:20px;"><b><?php echo lang_serverstats_allpoints; ?></b>: <span class="stats_players"><?php echo number_format($data['playerScore'], 0, ',', ' '); ?></span></div>
	  <div style="float:left;width:165px;text-align:left;height:20px;"><b><?php echo lang_stats_points; ?></b>: <span class="stats_players"><?php echo number_format($data['playerScore']-$data['BonusPoints'], 0, ',', ' '); ?></span></div>
	  <div style="float:left;width:165px;text-align:left;height:20px;"><b><?php echo lang_serverstats_bonus; ?></b>: <span class="stats_players"><?php echo number_format($data['BonusPoints'], 0, ',', ' '); ?></span></div>
	  <div style="float:left;width:140px;text-align:left;height:20px;"><b><?php echo lang_details_ppr; ?></b>: <span class="stats_players"><?php echo number_format($ppr, 2, ',', ' '); ?></span></div>
	  
	  <div style="float:left;width:165px;text-align:left;height:20px;"><b><?php echo lang_details_ppm; ?></b>: <span class="stats_players"><?php echo number_format($ppm, 2, ',', ' '); ?></span></div>
	  <div style="float:left;width:165px;text-align:left;height:20px;"><b><?php echo lang_details_kpr; ?></b>: <span class="stats_players"><?php echo number_format($kpr, 2, ',', ' '); ?></span></div>
    <div style="float:left;width:165px;text-align:left;height:20px;"><b><?php echo lang_details_kpm; ?></b>: <span class="stats_players"><?php echo number_format($kpm, 2, ',', ' '); ?></span></div>
	  <div style="float:left;width:140px;text-align:left;height:20px;"><b><?php echo lang_serverstats_kills; ?></b>: <span class="stats_players"><?php echo number_format($data['playerKills'], 0, ',', ' '); ?></span></div>
	  
	  <div style="float:left;width:165px;text-align:left;height:20px;"><b><?php echo lang_deaths; ?></b>: <span class="stats_players"><?php echo number_format($data['playerDeaths'], 0, ',', ' '); ?></span></div>
	  <div style="float:left;width:165px;text-align:left;height:20px;"><b><?php echo lang_stats_head; ?></b>: <span class="stats_players"><?php echo number_format($data['playerHeadshots'], 0, ',', ' '); ?></span></div>
	  <?php
	 
     if($data['KD'] >= 1){
	    $kd = "<span class=positiv>".number_format($data['KD'], 2, '.', '.')."</span>";
	  }else{
      $kd = "<span class=negativ>".number_format($data['KD'], 2, '.', '.')."</span>";	
   }
	  ?>
	  <div style="float:left;width:165px;text-align:left;height:20px;"><b><?php echo lang_stats_kd; ?></b>: <?php echo $kd; ?></div>
	  <div style="float:left;width:125px;text-align:left;height:20px;"><b><?php echo lang_stats_suic; ?></b>: <span class="stats_players"><?php echo number_format($data['playerSuicide'], 0, ',', ' '); ?></span></div>
	  <div style="float:left;width:165px;text-align:left;height:20px;"><b><?php echo lang_stats_tk; ?></b>: <span class="stats_players"><?php echo number_format($data['playerTKs'], 0, ',', ' '); ?></span></div>
	  <div style="float:left;width:165px;text-align:left;height:20px;"><b><?php echo lang_stats_rounds; ?></b>: <span class="stats_players"><?php echo number_format($data['playerRounds'], 0, ',', ' '); ?></span></div>
	  <br />
	  <div style="float:left;width:165px;text-align:left;height:20px;"><b><?php echo lang_stats_kstreak2; ?></b>: <span class="stats_players"><?php echo number_format($data['Killstreak'], 0, ',', ' '); ?></span></div>
	  <div style="float:left;width:140px;text-align:left;height:20px;"><b><?php echo lang_stats_dstreak2; ?></b>: <span class="stats_players"><?php echo number_format($data['Deathstreak'], 0, ',', ' '); ?></span></div>
	   <?php 
	  $Sql = "SELECT 
           Count(a.KillerID) AS uniqueDogs,
           SUM(a.Count) AS Count
          FROM 
           tbl_dogtags a
         WHERE
          a.KillerID = '{$data['PlayerID']}'"; 
        $result = db_query($Sql);
        $row = mysql_fetch_assoc($result);
	  ?>
	  <div style="float:left;width:165px;text-align:left;height:20px;"><b><?php echo lang_details_dogtags; ?></b>: <span class="stats_players"><?php echo $row['Count']; ?></span></div>
	  <div style="float:left;width:165px;text-align:left;height:20px;"><b><?php echo lang_details_unique; ?></b>: <span class="stats_players"><?php echo $row['uniqueDogs']; ?></span></div>
	  <?php
	        $name = lang_details_dogtagerror;
        	$Count = '';
	       $sSqlK = "SELECT 
	                  a.*,
	                  b.SoldierName 
	                 FROM 
	                  tbl_dogtags a
	                 Left Join 
	                  tbl_playerdata b ON a.VictimID = b.PlayerID
	                 WHERE
	                  a.KillerID = '{$data['PlayerID']}' 
	                 ORDER BY 
	                  a.Count DESC LIMIT 1";
        $resultK = db_query($sSqlK);
        if($resultK){
       while($killers = mysql_fetch_assoc($resultK)){
       $ID = $killers['VictimID'];
       $Count = $killers['Count'];
       $name = '<a href="ministats.php?name='.urlencode($killers['SoldierName']).'">'.htmlspecialchars($killers['SoldierName']).'</a>';
       $Count = '('.$Count.')';
        }   
      } 	
	?>  
	  <div style="float:left;width:290px;text-align:left;height:20px;"><b><?php echo lang_details_dogtagall; ?></b>: <span class="stats_players"><?php echo $name; ?> <?php echo $Count; ?></span></div>
	
	  <div style="float:left;width:330px;text-align:left;height:20px;"><b><?php echo lang_stats_first; ?></b>: <span class="stats_players"><?php echo $data['FirstSeenOnServer']; ?></span></div>
	  <div style="float:left;width:290px;text-align:left;height:20px;"><b><?php echo lang_stats_last; ?></b>: <span class="stats_players"><?php echo $data['LastSeenOnServer']; ?></span></div>
	<br />
	<?php  $time = sprintf("%02dd %02dh %02dmin %02ds",$data['playerPlaytime']/24/60/60,$data['playerPlaytime']/60/60%24,$data['playerPlaytime']/60%60,$data['playerPlaytime']%60); ?>
	  <div style="float:left;width:330px;text-align:left;height:20px;"><b><?php echo lang_stats_time; ?></b>: <span class="stats_players"><?php echo $time; ?></span></div>
	  <div style="float:left;width:645px;text-align:left;"><img src="signatur.php?player=<?php echo urlencode($data['SoldierName']); ?>" border="0" /></div>

       <div style="float:left;width:50px;text-align:left;margin-top:7px;">URL:</div>
       <div style="float:right;width:595px;text-align:left;"><input class="inputfield" type="text" name="Link" value="http://<?php echo $_SERVER['HTTP_HOST']; ?>/<?php echo $url['1']; ?>/signatur.php?player=<?php echo urlencode($data['SoldierName']); ?>" readonly /></div>
	     <div style="float:left;width:50px;text-align:left;margin-top:11px;">BBCode:</div>
       <div style="float:right;width:595px;text-align:left;"><input class="inputfield" type="text" name="Link" value="[URL=http://<?php echo $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; ?>][IMG]http://<?php echo $_SERVER['HTTP_HOST']; ?>/<?php echo $url['1']; ?>/signatur.php?player=<?php echo urlencode($data['SoldierName']); ?>[/IMG]" readonly /></div>
	</td>	
	</table>