<?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                         # ||
|| #################################################################### ||
\*======================================================================*/

 $iCounter = 0;
  $ikills = 0;
  $ideaths = 0;
  $iscore = 0;
  $pingAll = 0;
?><div style="float:left;">
   <table class="default_h"  cellspacing="0" cellpadding="0" style="float:left;width:392px;height:182px;margin-bottom:12px;margin-left:8px;">
     <thead>
      <td class="head" colspan="8" style="height:20px;"><?php echo $Team1; ?></td>
       <tr>
        <td class="result" style="font-size:10px;border-bottom: 1px solid #303030;" colspan="8"><b><?php echo server_details_sqdm_a.$Team1.server_details_sqdm_b.$aServerSettings[9].server_details_sqdm_c.$NeedAplha.server_details_sqdm_d.$aServerSettings[13].server_details_sqdm_e; ?></b></a></td>
       </tr> 
   <tr style="height:20px;">
	    <th width="45px"><?php echo server_tag; ?></th> 
	     <th width="20px"></th> 
	       <th><?php echo server_name; ?></th> 
           <th width="30px" align="right"><img src="img/viewer/kills.png" title="<?php echo lang_kills; ?>" /></th> 
            <th width="30px" align="right"><img src="img/viewer/deaths.png" title="<?php echo lang_deaths; ?>" /></th>  
          <th width="45px" align="right"><img src="img/viewer/kd.png" title="<?php echo lang_kd; ?>" /></th>  
        <th width="60px"><?php echo server_points; ?></th> 
       <th width="32px" align="right"><img src="img/viewer/ping.png" title="Ping" /></th> 
    </tr>
 </thead>
<tbody>

<?php
$i = 0;
if ($aServerSettings[2] >=1){
    if (is_array($Players_ar)) foreach ($Players_ar as $Players){
    	if ($Players['teamid'] == 1){
   
	       if ($Players['deaths'] == 0){
		        $s_KD = '0';
	       }else{ $s_KD = ($Players['kills']/$Players['deaths']); 
	       	
	     }
             if($s_KD  == 0 && ($Players['kills'] >= 1)){
	             $sKd = '<span class="positiv">'.$Players['kills'].'.00</span>';
	           }elseif ($s_KD  == 0 && ($Players['deaths'] >= 1)){
             	 $sKd = "<span class='negativ'>0.00</span>";	
	           }elseif ($s_KD  == 0 && ($Players['deaths'] == 0)){
	             $sKd = '0.00';
	           }elseif($s_KD  >= 1){
               $sKd = "<span class='positiv'>" . number_format($s_KD, 2, '.', '.') . "</span>";	
             }else{
               $sKd = "<span class='negativ'>" . number_format($s_KD, 2, '.', '.') . "</span>";	
            }
            
            
         if (in_array($Players['clantag'], $ClanTag)) {
		        $clantag = '<tr class="own_viewer" style="height:20px;"><td class="result"><span class="sonstige">' .htmlspecialchars($Players['clantag']) . '</span></td>';
           }elseif ($Players['clantag'] != "") {
           $clantag = '<tr style="height:20px;"><td class="result">' .htmlspecialchars($Players['clantag']) . '</td>'; 
          }else{
	         $clantag = '<tr style="height:20px;"><td class="result">&nbsp;</td>';
	      }
	      
  if(strlen($Players['name']) <= 12) {
           $PlayerN = $Players['name'];
        } else {
          $PlayerN = substr($Players['name'],0,10) . '..'; 
      }
    $abfrage = "SELECT a.PlayerID,SoldierName, b.bfbcsID,Rank FROM tbl_playerdata a
    Left JOIN tbl_bfbcs b ON a.PlayerID = b.bfbcsID
       WHERE a.SoldierName = '{$Players['name']}'"; 
      $ergebnis = mysql_query($abfrage);
     $row = mysql_fetch_assoc($ergebnis);
  if(isset($row['Rank'])){
   $Rank = $row['Rank'];
  }else{
  	$Rank = '0';
}

if ($Players['name'] == $row['SoldierName']){
	$link = '<td class="result"><a href="ministats.php?name='.urlencode($row['SoldierName']).'" target="_blank">'.htmlspecialchars($PlayerN).'</a></td>';
}else{
	$link = '<td class="result"><a href="http://bfbcs.com/stats_pc/'.urlencode($Players['name']).'" target="_blank">'.htmlspecialchars($PlayerN).'</a></td>';
}
 
         ?>
	       <?php echo $clantag ?>
	       <td class="result"><img src="img/rank/thumb/<?php echo $Rank; ?>.png" border="0" width="20px" title="<?php echo htmlspecialchars($PlayerN).lang_stats_haverank.$Rank.'('.$rankname[$Rank].')'; ?>" /></td>
	          <?php echo $link; ?><td class="result"><?php echo $Players['kills'] ?></td>
	            <td class="result"><?php echo $Players['deaths'] ?></td>
	           <td class="result"><?php echo $sKd ?></td>
	          <td class="result"><?php echo $Players['score'] ?></td>
	        <td class="result"><?php echo $Players['ping'] ?></td>
	       <?php
    ++$iCounter;
	       $ikills = $Players['kills']+$Players['kills'];
	       $ideaths += $Players['deaths'];
	       $iscore += $Players['score'];
	       $pingAll += $Players['ping']; 
    }
  }
 }
 
 
 if ($ideaths == 0 ){
 	  $iPlayerKD = 0;
 	}else{
    $iPlayerKD = ($ikills/$ideaths);
  }
    if($iPlayerKD  == 0 && ($ikills >= 1)){
	             $iKd = '<span class="positiv">'.$ikills.'.00</span>';
	           }elseif ($iPlayerKD  == 0 && ($ideaths >= 1)){
             	 $iKd = '<span class="negativ">0.00</span>';	
	           }elseif ($iPlayerKD  == 0 && ($ideaths == 0)){
	             $iKd = '0.00';
	           }elseif($iPlayerKD  >= 1){
               $iKd = '<span class="positiv">' . number_format($iPlayerKD, 2, '.', '.') . '</span>';	
             }else{
               $iKd = '<span class="negativ">' . number_format($iPlayerKD, 2, '.', '.') . '</span>';	
            }
            
           if ($pingAll == 0){
 	           $ping = '0';
 	        }else{
            $ping = number_format($pingAll/$iCounter, 0, ',', '.');
        }
  ?>
</tbody>
     <td class="result" height="25px"><b>&oslash;</b></td>
       	<td class="result">&nbsp;</td> 
         <td class="result"><b><?php echo server_players; ?> <span class="sonstige"><?php echo $iCounter ?></span></b></td>
  	      <td class="result"><b><?php echo $ikills ?></b></td>
  	       <td class="result"><b><?php echo $ideaths ?></b></td>
  	      <td class="result"><b><?php echo $iKd ?></b></td>
  	    <td class="result"><b><?php echo $iscore ?></b></td>
  	   <td class="result"><b><?php echo $ping ?></b></td>
  </table>
 </div>
   <?php
  $aiCounter = 0;
  $aikills = 0;
  $aideaths = 0;
  $aiscore = 0;
  $apingAll = 0;
  ?>
 <div style="float:right;margin-right:8px;">
  <table class="default_h"  cellspacing="0" cellpadding="0" style="float:left;width:392px;height:182px;margin-bottom:12px;margin-left:8px;">
     <thead>
      <td class="head" colspan="8" style="height:20px;"><?php echo $Team2; ?></td>
       <tr>
        <td class="result" style="font-size:10px;border-bottom: 1px solid #303030;" colspan="8"><b><?php echo server_details_sqdm_a.$Team2.server_details_sqdm_b.$aServerSettings[10].server_details_sqdm_c.$NeedBravo.server_details_sqdm_d.$aServerSettings[13].server_details_sqdm_e; ?></b></a></td>
       </tr> 
   <tr style="height:20px;"> 
	     <th width="45px"><?php echo server_tag; ?></th> 
	     <th width="20px"></th> 
	       <th><?php echo server_name; ?></th> 
           <th width="30px" align="right"><img src="img/viewer/kills.png" title="<?php echo lang_kills; ?>" /></th> 
            <th width="30px" align="right"><img src="img/viewer/deaths.png" title="<?php echo lang_deaths; ?>" /></th>  
          <th width="45px" align="right"><img src="img/viewer/kd.png" title="<?php echo lang_kd; ?>" /></th>  
        <th width="60px"><?php echo server_points; ?></th> 
       <th width="32px" align="right"><img src="img/viewer/ping.png" title="Ping" /></th> 
    </tr>
 </thead>
<tbody>


<?php
if ($aServerSettings[2] >=1){
    if (is_array($Players_ar)) foreach ($Players_ar as $Players){
    	if ($Players['teamid'] == 2){
  
	       if ($Players['deaths'] == 0){
		        $s_KD = '0';
	       }else{ $s_KD = ($Players['kills']/$Players['deaths']); 
	       	
	     }
            if($s_KD  == 0 && ($Players['kills'] >= 1)){
	             $sKd = '<span class="positiv">'.$Players['kills'].'.00</span>';
	           }elseif ($s_KD  == 0 && ($Players['deaths'] >= 1)){
             	 $sKd = "<span class='negativ'>0.00</span>";	
	           }elseif ($s_KD  == 0 && ($Players['deaths'] == 0)){
	             $sKd = '0.00';
	           }elseif($s_KD  >= 1){
               $sKd = "<span class='positiv'>" . number_format($s_KD, 2, '.', '.') . "</span>";	
             }else{
               $sKd = "<span class='negativ'>" . number_format($s_KD, 2, '.', '.') . "</span>";	
            }
            
  
         if (in_array($Players['clantag'], $ClanTag)) {
		        $clantag = '<tr class="own_viewer" style="height:20px;"><td class="result"><span class="sonstige">' .htmlspecialchars($Players['clantag']) . '</span></td>';
           }elseif ($Players['clantag'] != "") {
           $clantag = '<tr style="height:20px;"><td class="result">' .htmlspecialchars($Players['clantag']) . '</td>'; 
          }else{
	         $clantag = '<tr style="height:20px;"><td class="result">&nbsp;</td>';
	      }
	      
	   if(strlen($Players['name']) <= 12) {
           $PlayerN = $Players['name'];
        } else {
          $PlayerN = substr($Players['name'],0,10) . '..'; 
      }
    $abfrage = "SELECT a.PlayerID,SoldierName, b.bfbcsID,Rank FROM tbl_playerdata a
    Left JOIN tbl_bfbcs b ON a.PlayerID = b.bfbcsID
       WHERE a.SoldierName = '{$Players['name']}'"; 
      $ergebnis = mysql_query($abfrage);
     $row = mysql_fetch_assoc($ergebnis);
  if(isset($row['Rank'])){
   $Rank = $row['Rank'];
  }else{
  	$Rank = '0';
}

    if ($Players['name'] == $row['SoldierName']){
	$link = '<td class="result"><a href="ministats.php?name='.urlencode($row['SoldierName']).'" target="_blank">'.htmlspecialchars($PlayerN).'</a></td>';
}else{
	$link = '<td class="result"><a href="http://bfbcs.com/stats_pc/'.urlencode($Players['name']).'" target="_blank">'.htmlspecialchars($PlayerN).'</a></td>';
}
  

         ?>
	       <?php echo $clantag ?>
	       <td class="result"><img src="img/rank/thumb/<?php echo $Rank; ?>.png" border="0" width="20px" title="<?php echo htmlspecialchars($PlayerN).lang_stats_haverank.$Rank.'('.$rankname[$Rank].')'; ?>" /></td>
	          <?php echo $link; ?>
	             <td class="result"><?php echo $Players['kills'] ?></td>
	            <td class="result"><?php echo $Players['deaths'] ?></td>
	           <td class="result"><?php echo $sKd ?></td>
	          <td class="result"><?php echo $Players['score'] ?></td>
	        <td class="result"><?php echo $Players['ping'] ?></td>
	       <?php
	       
  ++$aiCounter;
	       $aikills += $Players['kills'];
	       $aideaths += $Players['deaths'];
	       $aiscore += $Players['score'];
	       $apingAll += $Players['ping'];
	       
    }
  }
}

 
 if ($aideaths == 0 ){
 	  $aiPlayerKD = 0;
 	}else{
    $aiPlayerKD = ($aikills/$aideaths);
  }
    if($aiPlayerKD  == 0 && ($aikills >= 1)){
	             $aiKd = '<span class="positiv">'.$aikills.'.00</span>';
	           }elseif ($aiPlayerKD  == 0 && ($aideaths >= 1)){
             	 $aiKd = "<span class='negativ'>0.00</span>";	
	           }elseif ($aiPlayerKD  == 0 && ($aideaths == 0)){
	             $aiKd = '0.00';
	           }elseif($aiPlayerKD  >= 1){
               $aiKd = "<span class='positiv'>" . number_format($aiPlayerKD, 2, '.', '.') . "</span>";	
             }else{
               $aiKd = "<span class='negativ'>" . number_format($aiPlayerKD, 2, '.', '.') . "</span>";	
            }
            
           if ($apingAll == 0){
 	           $aping = '0';
 	        }else{
            $aping = number_format($apingAll/$aiCounter, 0, ',', '.');
        }
  ?>
</tbody>
     <td class="result" height="25px"><b>&oslash;</b></td>
      <td class="result">&nbsp;</td>
       <td class="result"><b><?php echo server_players; ?> <span class="sonstige"><?php echo $aiCounter ?></span></b></td>
  	    <td class="result"><b><?php echo $aikills ?></b></td>
  	     <td class="result"><b><?php echo $aideaths ?></b></td>
  	      <td class="result"><b><?php echo $aiKd ?></b></td>
  	    <td class="result"><b><?php echo $aiscore ?></b></td>
  	   <td class="result"><b><?php echo $aping ?></b></td>
  </table>
 </div>
 <tr>

  <?php
  $biCounter = 0;
  $bikills = 0;
  $bideaths = 0;
  $biscore = 0;
  $bpingAll = 0;
  ?>
<div style="float:left;">
  <table class="default_h"  cellspacing="0" cellpadding="0" style="float:left;width:392px;height:182px;margin-bottom:12px;margin-left:8px;">
     <thead>
      <td class="head" colspan="8" style="height:20px;"><?php echo $Team3; ?></td>
       <tr>
       <td class="result" style="font-size:10px;border-bottom: 1px solid #303030;" colspan="8"><b><?php echo server_details_sqdm_a.$Team3.server_details_sqdm_b.$aServerSettings[11].server_details_sqdm_c.$NeedCharlie.server_details_sqdm_d.$aServerSettings[13].server_details_sqdm_e; ?></b></a></td>
       </tr> 
   <tr style="height:20px;"> 
	    <th width="45px"><?php echo server_tag; ?></th> 
	     <th width="20px"></th> 
	       <th><?php echo server_name; ?></th> 
           <th width="30px" align="right"><img src="img/viewer/kills.png" title="<?php echo lang_kills; ?>" /></th> 
            <th width="30px" align="right"><img src="img/viewer/deaths.png" title="<?php echo lang_deaths; ?>" /></th>  
          <th width="45px" align="right"><img src="img/viewer/kd.png" title="<?php echo lang_kd; ?>" /></th>  
        <th width="60px"><?php echo server_points; ?></th> 
       <th width="32px" align="right"><img src="img/viewer/ping.png" title="Ping" /></th> 
    </tr>
 </thead>
<tbody>


<?php
if ($aServerSettings[2] >=1){
    if (is_array($Players_ar)) foreach ($Players_ar as $Players){
    	if ($Players['teamid'] == 3){
  
	       if ($Players['deaths'] == 0){
		        $s_KD = '0';
	       }else{ $s_KD = ($Players['kills']/$Players['deaths']); 
	       	
	     }
            if($s_KD  == 0 && ($Players['kills'] >= 1)){
	             $sKd = '<span class="positiv">'.$Players['kills'].'.00</span>';
	           }elseif ($s_KD  == 0 && ($Players['deaths'] >= 1)){
             	 $sKd = "<span class='negativ'>0.00</span>";	
	           }elseif ($s_KD  == 0 && ($Players['deaths'] == 0)){
	             $sKd = '0.00';
	           }elseif($s_KD  >= 1){
               $sKd = "<span class='positiv'>" . number_format($s_KD, 2, '.', '.') . "</span>";	
             }else{
               $sKd = "<span class='negativ'>" . number_format($s_KD, 2, '.', '.') . "</span>";	
            }
            
            
         if (in_array($Players['clantag'], $ClanTag)) {
		        $clantag = '<tr class="own_viewer" style="height:20px;"><td class="result"><span class="sonstige">' .htmlspecialchars($Players['clantag']) . '</span></td>';
           }elseif ($Players['clantag'] != "") {
           $clantag = '<tr style="height:20px;"><td class="result">' .htmlspecialchars($Players['clantag']) . '</td>'; 
          }else{
	         $clantag = '<tr style="height:20px;"><td class="result">&nbsp;</td>';
	      }
	      
	   if(strlen($Players['name']) <= 12) {
           $PlayerN = $Players['name'];
        } else {
          $PlayerN = substr($Players['name'],0,10) . '..'; 
      }
   $abfrage = "SELECT a.PlayerID,SoldierName, b.bfbcsID,Rank FROM tbl_playerdata a
    Left JOIN tbl_bfbcs b ON a.PlayerID = b.bfbcsID
       WHERE a.SoldierName = '{$Players['name']}'"; 
      $ergebnis = mysql_query($abfrage);
     $row = mysql_fetch_assoc($ergebnis);
  if(isset($row['Rank'])){
   $Rank = $row['Rank'];
  }else{
  	$Rank = '0';
}

      if ($Players['name'] == $row['SoldierName']){
	$link = '<td class="result"><a href="ministats.php?name='.urlencode($row['SoldierName']).'" target="_blank">'.htmlspecialchars($PlayerN).'</a></td>';
}else{
	$link = '<td class="result"><a href="http://bfbcs.com/stats_pc/'.urlencode($Players['name']).'" target="_blank">'.htmlspecialchars($PlayerN).'</a></td>';
}
  

         ?>
	       <?php echo $clantag ?>
	       <td class="result"><img src="img/rank/thumb/<?php echo $Rank; ?>.png" border="0" width="20px" title="<?php echo htmlspecialchars($PlayerN).lang_stats_haverank.$Rank.'('.$rankname[$Rank].')'; ?>" /></td>
	          <?php echo $link; ?>
	             <td class="result"><?php echo $Players['kills'] ?></td>
	            <td class="result"><?php echo $Players['deaths'] ?></td>
	           <td class="result"><?php echo $sKd ?></td>
	          <td class="result"><?php echo $Players['score'] ?></td>
	        <td class="result"><?php echo $Players['ping'] ?></td>
	       <?php
	       
 ++$biCounter;
	       $bikills += $Players['kills'];
	       $bideaths += $Players['deaths'];
	       $biscore += $Players['score'];
	       $bpingAll += $Players['ping'];
	     
	      
    }
  }
 }

 if ($bideaths == 0 ){
 	  $biPlayerKD = 0;
 	}else{
    $biPlayerKD = ($bikills/$bideaths);
  }
   if($biPlayerKD  == 0 && ($bikills >= 1)){
	             $biKd = '<span class="positiv">'.$bikills.'.00</span>';
	           }elseif ($biPlayerKD  == 0 && ($bideaths >= 1)){
             	 $biKd = "<span class='negativ'>0.00</span>";	
	           }elseif ($biPlayerKD  == 0 && ($bideaths == 0)){
	             $biKd = '0.00';
	           }elseif($biPlayerKD  >= 1){
               $biKd = "<span class='positiv'>" . number_format($biPlayerKD, 2, '.', '.') . "</span>";	
             }else{
               $biKd = "<span class='negativ'>" . number_format($biPlayerKD, 2, '.', '.') . "</span>";	
            }
            
           if ($bpingAll == 0){
 	           $bping = '0';
 	        }else{
            $bping = number_format($bpingAll/$biCounter, 0, ',', '.');
        }
  ?>
</tbody>
     <td class="result" height="25px"><b>&oslash;</b></td>
       <td class="result">&nbsp;</td>
        <td class="result"><b><?php echo server_players; ?> <span class="sonstige"><?php echo $biCounter ?></span></b></td>
  	      <td class="result"><b><?php echo $bikills ?></b></td>
  	       <td class="result"><b><?php echo $bideaths ?></b></td>
  	      <td class="result"><b><?php echo $biKd ?></b></td>
  	    <td class="result"><b><?php echo $biscore ?></b></td>
  	   <td class="result"><b><?php echo $bping ?></b></td>
  </table>
</div>
<?php
  $ciCounter = 0;
  $cikills = 0;
  $cideaths = 0;
  $ciscore = 0;
  $cpingAll = 0;
  ?>
<div style="float:right;margin-right:8px;">
 <table class="default_h"  cellspacing="0" cellpadding="0" style="float:left;width:392px;height:182px;margin-bottom:12px;margin-left:8px;">
     <thead>
      <td class="head" colspan="8" style="height:20px;"><?php echo $Team4; ?></td>
       <tr>
        <td class="result" style="font-size:10px;border-bottom: 1px solid #303030;" colspan="8"><b><?php echo server_details_sqdm_a.$Team4.server_details_sqdm_b.$aServerSettings[12].server_details_sqdm_c.$NeedDelta.server_details_sqdm_d.$aServerSettings[13].server_details_sqdm_e; ?></b></a></td>
       </tr> 
   <tr style="height:20px;"> 
	     <th width="45px"><?php echo server_tag; ?></th> 
	     <th width="20px"></th> 
	       <th><?php echo server_name; ?></th> 
           <th width="30px" align="right"><img src="img/viewer/kills.png" title="<?php echo lang_kills; ?>" /></th> 
            <th width="30px" align="right"><img src="img/viewer/deaths.png" title="<?php echo lang_deaths; ?>" /></th>  
          <th width="45px" align="right"><img src="img/viewer/kd.png" title="<?php echo lang_kd; ?>" /></th>  
        <th width="60px"><?php echo server_points; ?></th> 
       <th width="32px" align="right"><img src="img/viewer/ping.png" title="Ping" /></th> 
    </tr>
 </thead>
<tbody>


<?php
if ($aServerSettings[2] >=1){
    if (is_array($Players_ar)) foreach ($Players_ar as $Players){
    	if ($Players['teamid'] == 4){
  
	       
	       if ($Players['deaths'] == 0){
		        $s_KD = '0';
	       }else{ $s_KD = ($Players['kills']/$Players['deaths']); 
	       	
	     }
             if($s_KD  == 0 && ($Players['kills'] >= 1)){
	             $sKd = '<span class="positiv">'.$Players['kills'].'.00</span>';
	           }elseif ($s_KD  == 0 && ($Players['deaths'] >= 1)){
             	 $sKd = "<span class='negativ'>0.00</span>";	
	           }elseif ($s_KD  == 0 && ($Players['deaths'] == 0)){
	             $sKd = '0.00';
	           }elseif($s_KD  >= 1){
               $sKd = "<span class='positiv'>" . number_format($s_KD, 2, '.', '.') . "</span>";	
             }else{
               $sKd = "<span class='negativ'>" . number_format($s_KD, 2, '.', '.') . "</span>";	
            }
            
            
         if (in_array($Players['clantag'], $ClanTag)) {
		        $clantag = '<tr class="own_viewer" style="height:20px;"><td class="result"><span class="sonstige">' .htmlspecialchars($Players['clantag']) . '</span></td>';
           }elseif ($Players['clantag'] != "") {
           $clantag = '<tr style="height:20px;"><td class="result">' .htmlspecialchars($Players['clantag']) . '</td>'; 
          }else{
	         $clantag = '<tr style="height:20px;"><td class="result">&nbsp;</td>';
	      }
	      
	   if(strlen($Players['name']) <= 12) {
           $PlayerN = $Players['name'];
        } else {
          $PlayerN = substr($Players['name'],0,10) . '..'; 
      }
	    $abfrage = "SELECT a.PlayerID,SoldierName, b.bfbcsID,Rank FROM tbl_playerdata a
    Left JOIN tbl_bfbcs b ON a.PlayerID = b.bfbcsID
       WHERE a.SoldierName = '{$Players['name']}'"; 
      $ergebnis = mysql_query($abfrage);
     $row = mysql_fetch_assoc($ergebnis);
  if(isset($row['Rank'])){
   $Rank = $row['Rank'];
  }else{
  	$Rank = '0';
}

if ($Players['name'] == $row['SoldierName']){
	$link = '<td class="result"><a href="ministats.php?name='.urlencode($row['SoldierName']).'" target="_blank">'.htmlspecialchars($PlayerN).'</a></td>';
}else{
	$link = '<td class="result"><a href="http://bfbcs.com/stats_pc/'.urlencode($Players['name']).'" target="_blank">'.htmlspecialchars($PlayerN).'</a></td>';
}
  

         ?>
	       <?php echo $clantag ?>
	       <td class="result"><img src="img/rank/thumb/<?php echo $Rank; ?>.png" border="0" width="20px" title="<?php echo htmlspecialchars($PlayerN).lang_stats_haverank.$Rank.'('.$rankname[$Rank].')'; ?>" /></td>
	          <?php echo $link; ?>
	            <td class="result"><?php echo $Players['kills'] ?></td>
	            <td class="result"><?php echo $Players['deaths'] ?></td>
	           <td class="result"><?php echo $sKd ?></td>
	          <td class="result"><?php echo $Players['score'] ?></td>
	        <td class="result"><?php echo $Players['ping'] ?></td>
	       <?php
	       
  ++$ciCounter;
	       $cikills += $Players['kills'];
	       $cideaths += $Players['deaths'];
	       $ciscore += $Players['score'];
	       $cpingAll += $Players['ping'];
	     
	      
    }
  }
 }
 
 
 if ($cideaths == 0 ){
 	  $ciPlayerKD = 0;
 	}else{
    $ciPlayerKD = ($cikills/$cideaths);
  }
   if($ciPlayerKD  == 0 && ($cikills >= 1)){
	             $ciKd = '<span class="positiv">'.$cikills.'.00</span>';
	           }elseif ($ciPlayerKD  == 0 && ($cideaths >= 1)){
             	 $ciKd = "<span class='negativ'>0,00</span>";	
	           }elseif ($ciPlayerKD  == 0 && ($cideaths == 0)){
	             $ciKd = '0.00';
	           }elseif($ciPlayerKD  >= 1){
               $ciKd = "<span class='positiv'>" . number_format($ciPlayerKD, 2, '.', '.') . "</span>";	
             }else{
               $ciKd = "<span class='negativ'>" . number_format($ciPlayerKD, 2, '.', '.') . "</span>";	
            }
            
           if ($cpingAll == 0){
 	           $cping = '0';
 	        }else{
            $cping = number_format($cpingAll/$ciCounter, 0, ',', '.');
        }
  ?>
</tbody>
     <td class="result" height="25px"><b>&oslash;</b></td>
       <td class="result">&nbsp;</td>
         <td class="result"><b><?php echo server_players; ?> <span class="sonstige"><?php echo $ciCounter ?></span></b></td>
  	      <td class="result"><b><?php echo $cikills ?></b></td>
  	       <td class="result"><b><?php echo $cideaths ?></b></td>
  	      <td class="result"><b><?php echo $ciKd ?></b></td>
  	    <td class="result"><b><?php echo $ciscore ?></b></td>
  	   <td class="result"><b><?php echo $cping ?></b></td>
  </table>
 </div> 