<?php
/*======================================================================*\
|| #################################################################### ||
|| # EoT-Clan BF3 Leaderboard                                         # ||
|| # ---------------------------------------------------------------- # ||
|| # Dieses Copyright darf nicht entfernet werden                     # ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # -----------------BF3 Leaderboard is a free Software--------------# ||
|| #                   http://eot-clan.net                            # ||
|| #################################################################### ||
\*======================================================================*/
require_once ('../inc/config.php');
require_once ('../language/'.$row['language'].'.php');

$_GET = security::escape($_GET);
$_POST = security::escape($_POST);
$EoT = new eGamersofTomorrow;


   $aSsql = array("arAK74","wahUGL","arM416","wahUSG","arAEK","arM16","arAN94","arF2","arG3","arKH","srM40","srM98","srMK11","srSKS","srSV98","srSVD","mgM240","mgM249","mgM27","mgM60","mgPech","mgRPK","mgT88","caA91","caAKS","caG36","caM4","caSCAR","caSG553","srM39","wLAAFIM","wLAAIGL","wLATJAV","wLATRPG","wLATSMAW","pG17S","pG17","pg18S","pg18","pM1911L","pM1911","pM1911S","pM1911T","pM412","pM9F","pM9S","pM9","pM93R","pMP443L","pMP443S","pMP443","pTaurS","pTaur","sg870","sgDAO","sgM1014","sgSaiga","sgUSAS","smMP7","smP90","smPDR","smPP2000","smUMP","smVAL","wasK","arFAMAS","arL85A2","caHK53","caQBZ95B","mgQBB95","mgMG36","srQBU88","srL96","smPP19","sgJackH","arAUG","arSCARL","mgL86A1","mgLSAT","caACR","caMTAR21","srHK417","srJNG90","sgSPAS12","smM5K");


    foreach ($aSsql as $WeaponsSUM){
       $kills = 'SUM(`'.$WeaponsSUM.'_kills`) AS `'.$WeaponsSUM.'_kills`';      
        $akills[] = $kills;
       $hits = 'SUM(`'.$WeaponsSUM.'_hits`) AS `'.$WeaponsSUM.'_hits`';
        $ahits[] = $hits;
       $shots = 'SUM(`'.$WeaponsSUM.'_shots`) AS `'.$WeaponsSUM.'_shots`';
        $ashots[] = $shots;
       $time = 'SUM(`'.$WeaponsSUM.'_time`) AS `'.$WeaponsSUM.'_time`';
        $atime[] = $time;
       $headshots = 'SUM(`'.$WeaponsSUM.'_headshots`) AS `'.$WeaponsSUM.'_headshots`';
        $aheadshots[] = $headshots;
        
   }

      $akills = implode(", " , $akills);
      $ahits = implode(", " , $ahits);
      $ashots = implode(", " , $ashots);
      $atime = implode(", " , $atime);
      $aheadshots = implode(", " , $aheadshots);


 $sSql = "SELECT  
                  ".$akills." , 
                  ".$ahits." , 
                  ".$ashots.",
                  ".$atime.",
                  ".$aheadshots."
                 FROM 
                  ".DBPrefix."weapons";
     $result = mysql_query($sSql);
 while ($row = mysql_fetch_assoc($result)) {	
      foreach ($aSsql as $weapons){
         $sWeapons = $weapons.'_kills';
         $aKills[$weapons] = $row[$sWeapons];
     }
  


arsort($aKills);
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
          "http://www.w3.org/TR/html4/loose.dtd">
 <title>BF3 LB / <?php echo LANG_CLANSTATS_WEAPONS_STATS; ?></title>
 <?php echo $styleSettings; ?>
 <script type="text/javascript" src="../js/jquery-1.4.3.min.js"></script>
 <script type="text/javascript" src="../js/jquery.tablesorter.js"></script>
  <div class="body_bfLB" style="width:<?php echo $style['IndexDivWidth']; ?>px;">   
	           <?php echo $Banner; ?>
        <ul id="statstabs" class="shadetabs" style="margin-top:10px;margin-bottom:-10px;">
        <li><a href="../index.php">Leaderboard</a></li>
        <li><a href="class.php"><?php echo LANG_CLANSTATS_TAB_KITS; ?></a></li>
        <li><a href="skill.php"><?php echo LANG_CLANSTATS_TAB_SKILL; ?></a></li>
        <li><a href="teamplay.php" >Teamplay</a></li>
        <li><a href="vehicles.php"><?php echo LANG_CLANSTATS_TAB_VEHICLES; ?></a></li>
        <li><a href="weaponstats.php" class="selected"><?php echo LANG_CLANSTATS_TAB_WEAPONS; ?></a></li>
        <li><a href="ribbonsstats.php">Ribbons</a></li>
        <li><a href="medalsstats.php">Medals</a></li>
        <li><a href="events.php">Events</a></li>
        <li><a href="serverHistory.php">S.History</a></li>
      </ul>
				<table class="default" id="weapons" style="width:<?php echo $style['IndexTableWidth']; ?>px;">
					<thead>
        <td class="head" colspan="13" cellspacing="0"><?php echo LANG_CLANSTATS_WEAPONS_STATS; ?></td>
        <tr>
      <th class="object" width="140px"><?php echo LANG_WEAPONS_WEAPON; ?></th> 
      <th class="object" width="120px"><?php echo LANG_CLANSTATS_WEAPONS_PROGRESS; ?></th> 
       <th class="object" width="46px"><?php echo LANG_WEAPONS_STARS; ?></th>
        <th class="object" width="80px"><?php echo LANG_WEAPONS_TIME; ?></th>
         <th class="object" width="87px"><?php echo LANG_WEAPONS_KILLS; ?></th>
         <th class="object" width="87px"><?php echo LANG_WEAPONS_HEADSHOTS; ?></th>
        <th class="object" width="87px"><?php echo LANG_WEAPONS_SHOTS; ?></th> 
       <th class="object" width="85px"><?php echo LANG_WEAPONS_HITS; ?></th>
      <th class="object" width="60px"><?php echo LANG_WEAPONS_ACCURACY; ?></th>
      </thead> 
        <tbody> 
	  <tr height="20px" >
<?php

$allkills = 0;
foreach ($aKills as $kills){
$allkills += $kills;
}

 foreach ($aKills as $key => $kills){
    	if ($row[$key.'_shots'] > 0){
      $accuracy = $row[$key.'_hits']*100/$row[$key.'_shots'];
   
    $weaponsName = 'LANG_WEAPONS_'.$key;
	  $weaponsTEXT = 'LANG_WEAPONS_TEXT_'.$key;
	  	
	  	if ($row[$key.'_kills'] < 100){
	  		$Star = '<td class="result" width="90px">----</td>';
	  	}else{
	  	  $Star = '<td class="result" width="90px"><img src="'.$domain.'/img/stars/stars_back20px.png" />
	  	           <div style="margin-left:35px;margin-top:-15px;position:absolute;font-size:11px">'.floor($row[$key.'_kills']/100).'</div></td>';
	  }
        
        $aAssault = array("arAEK","arAK74","arAN94","arF2","arG3","arKH","arM16","arM416","wahUGL","wahUSG","arFAMAS","arL85A2","arAUG","arSCARL");
	  		$aRecon = array("srM40","srM98","srMK11","srSKS","srSV98","srSVD","srQBU88","srL96","srM39","srHK417","srJNG90");
	  		$aSupport = array("mgM240","mgM249","mgM27","mgM60","mgPech","mgRPK","mgT88","mgQBB95","mgMG36","mgL86A1","mgLSAT");
	  		$aEngineer = array("caA91","caAKS","caG36","arF2","caM4","caSCAR","caSG553","wLAAFIM","wLAAIGL","wLATJAV","wLATRPG","wLATSMAW","caHK53","caQBZ95B","caACR","caMTAR21");
	  		
	  		
	  		 if (in_array($key,$aAssault)){
	  		 	$class = '<div style="margin-left:3px;position:absolute;font-size:11px"><img src="'.$domain.'/img/weapons/class/assault.png" title="Assault"/></div>';
	  		}else if (in_array($key,$aRecon)){
	  		 	$class = '<div style="margin-left:3px;position:absolute;font-size:11px"><img src="'.$domain.'/img/weapons/class/recon.png" title="Recon"/></div>';
	  		}else if (in_array($key,$aSupport)){
	  		 	$class = '<div style="margin-left:3px;position:absolute;font-size:11px"><img src="'.$domain.'/img/weapons/class/support.png" title="Support"/></div>';
	  		}else if (in_array($key,$aEngineer)){
	  		 	$class = '<div style="margin-left:3px;position:absolute;font-size:11px"><img src="'.$domain.'/img/weapons/class/engineer.png" title="Engineer"/></div>';
	  		
	  		}else{
	  			$class = '<div style="margin-left:3px;position:absolute;font-size:11px"><img src="'.$domain.'/img/weapons/class/all.png" title="All other"/></div>';
	  		}
    
    
        if ($allkills > 0){
      	$prozent = number_format($kills*100/$allkills, 2, ',', '.');
      	$progress = $kills*100/$allkills;
      }else{
      	$prozent = 0;
      	$progress = 0;
      }
    
     $B2K = array("arFAMAS","arL85A2","caHK53","caQBZ95B","mgQBB95","mgMG36","srQBU88","srL96","smPP19","sgJackH");
	  $b2k = "";
	  if (in_array($key,$B2K)){
	  	$b2k = '<img src="'.$domain.'/img/b2k.png" style="position:absolute;margin-left:10px;" />';
	  }
	  
	  $CQ = array("arAUG","arSCARL","mgL86A1","mgLSAT","caACR","caMTAR21","srHK417","srJNG90","sgSPAS12","smM5K");
	  $cq = "";
	  if (in_array($key,$CQ)){
	  	$cq = '<img src="'.$domain.'/img/cq.png" style="position:absolute;margin-left:10px;" />';
	  }
	  
    ?>
      <td class="result" width="120px"><?php echo $class; ?><a class="tooltip"><div style="text-align:left;width:100px;margin-left:22px;"><?php echo constant($weaponsName).$b2k.$cq; ?></div>
      	<span style="margin-top:-155px;margin-left:130px;width:250px;">
      		<div style="text-align:center;width:120px;"><b><?php echo constant($weaponsName); ?></b></div><br />
	  			<div style="float:left;"><img src="<?php echo $domain; ?>/img/weapons/<?php echo $key; ?>.png" width="120px"/></div><div style="text-align:left;"><?php echo constant($weaponsTEXT); ?></div>
	  		 </span></a>
      	</td>
       <td class="result">
      	<span style="float:left;font-size:9px;margin-left:40px;margin-top:-1px;"><b><?php echo $prozent; ?>%</b></span>
      	<div class="progress" style="width:120px;">
      		<div class="progress_size" style="width:<?php echo $progress; ?>%;max-width:119px;" title="<?php echo $prozent; ?>%">&nbsp;</div>
				</div></td>
      	<?php echo $Star; ?>
    	<td class="result" width="90px"><?php echo $EoT->time_complete($row[$key.'_time']); ?></td>
	    <td class="result" width="90px"><?php echo $EoT->points($row[$key.'_kills']); ?></td>
	    <td class="result" width="90px"><?php echo $EoT->points($row[$key.'_headshots']); ?></td>
	  	<td class="result" width="90px"><?php echo $EoT->points($row[$key.'_shots']); ?></td>
	  	<td class="result" width="90px"><?php echo $EoT->points($row[$key.'_hits']); ?></td>
	  	<td class="result" width="90px"><?php echo number_format($accuracy, 2, ',', ' '); ?>%</td>
	  	<tr>
    <?php
    }
  }
    ?>
    </td> 
		  </tr>
	</table>
	
	 <script type="text/javascript">
     $(document).ready(function() { 
 jQuery.tablesorter.addParser({
  id: "blank",
  is: function(s, table) {
     return false;
  },
  format: function(s) {
    return jQuery.tablesorter.formatFloat(s.replace(/ /g, ""));
  },
  type: "numeric"
});
    $("#weapons").tablesorter({ 
        headers: { 
            0: {   
                sorter: false 
            }, 
             1: {   
                sorter: false 
            },   
             2: {   
                sorter: false 
            },                
             3: {   
                sorter: 'blank' 
            },    
             4: {   
                sorter: 'blank' 
            },    
             5: {   
                sorter: 'blank' 
            },  
             6: {   
                sorter: 'blank' 
            }, 
             7: {   
                sorter: 'blank' 
            },  
            8: {   
                sorter: 'blank' 
            },  
            
        } 
     
    }); 
});
 </script>
	<?php 
 
}
	 include_once '../inc/footer.php';
	 echo '</div>';