<?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                         # ||
|| #################################################################### ||
\*======================================================================*/
require_once '../inc/config.php';
include_once ('../lang/language.php');
include_once ('../lang/'.$lang_file.'');

$_GET = security::escape($_GET);
$_POST = security::escape($_POST);

if (isset($_GET['killer']) && !empty($_GET['killer']) && $_GET['killer'] != ''){
	$WHERE = "a.KillerID = '{$_GET['killer']}'";
  $GROUP = "";
}elseif (isset($_GET['victim']) && !empty($_GET['victim']) && $_GET['victim'] != ''){
	$WHERE = "a.VictimID= '{$_GET['victim']}'";
  $GROUP = "";
}else{
	$WHERE = '1';
	$GROUP = 'GROUP BY KillerID';
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
          "http://www.w3.org/TR/html4/loose.dtd">
				<head>
					<title><?php echo lang_details_dogtagtitle; ?></title>
	        <link rel="stylesheet" type="text/css" href="../css/style.css" /> 
	      </head>
		<div class="body_ministats">
<table class="default_m" id="weapons" cellspacing="0" cellpadding="2" style="margin-top:12px;">
     <thead>
       <td class="head" colspan="7" ><a href="<?php echo $installdir; ?>/index.php" target="_self"><span style="float:left;margin-left:5px;"><?php echo lang_index_startseite; ?></a></span><?php echo lang_details_dogtagtitle; ?></td>
      <tr> 
			    <th width="263px"><?php echo lang_details_dogtagN; ?></th>
				    <th width="263px"><?php echo lang_details_dogtagO; ?></th>
				   <th width="263px"><?php echo lang_details_dogtaga; ?></th>
			</tr>
       </thead> 
        <tbody> 
        	<?php
 
          
   $sSql = "SELECT * 
          FROM (Select 
           a.*,
           b.PlayerID,
           b.SoldierName
         FROM
           tbl_dogtags a
         Left JOIN 
           tbl_playerdata b ON a.KillerID = b.PlayerID
          WHERE {$WHERE}
        ORDER BY 
          Count DESC) as Count
          	{$GROUP} Order by Count DESC LIMIT 30";
          
          

        $result = db_query($sSql);
       while($row = mysql_fetch_assoc($result)){
      
       $ID = $row['VictimID'];

       $Count = $row['Count'];
     
          $sSqlN = "SELECT SoldierName FROM tbl_playerdata WHERE PlayerID = {$ID}";
         $resultN = db_query($sSqlN);  
       $rowN = mysql_fetch_assoc($resultN);
      	 $VictimN = $rowN['SoldierName'];

      
   ?>
      <tr class="hov">	
         <td class="result"><a href="<?php echo $installdir; ?>/ministats.php?name=<?php echo urlencode($row['SoldierName']) ?>" target="_blank"><?php echo htmlspecialchars($row['SoldierName']); ?></a></td>
        	<td class="result"><a href="<?php echo $installdir; ?>/ministats.php?name=<?php echo urlencode($VictimN) ?>" target="_blank"><?php echo htmlspecialchars($VictimN); ?></a></td>
         <td class="result"><?php echo $Count; ?>&nbsp;&nbsp;<img src="<?php echo $installdir; ?>/img/sig/dogt.png" border="0" width="17px"/></td>
        <tr>
   <?php    
     	}
   ?>
      </table>
      <?php include_once ("../inc/footerm.php"); ?>
	  <br /> 
 </tbody>
</div>