<?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;



if(isset($_GET['ribbon']) && !empty($_GET['ribbon']) && $_GET['ribbon'] != '') {
       $ribbon = $_GET['ribbon']; 
   }else{
     $ribbon = "r1";
 }
 
 
            $sSql = "SELECT SUM(".$ribbon."_count) AS counts FROM ".DBPrefix."ribbons";       
             $result= mysql_query($sSql)or die(mysql_error()) ;
             $data = mysql_fetch_assoc($result);
             $allR = $data['counts'];
 	
 
 
            $sSql = "SELECT a.soldiername,a.pid,b.".$ribbon."_count,b.".$ribbon."_date,b.stats_pid, SUM(b.".$ribbon."_count) AS counts FROM ".DBPrefix."generalStats a
                      Left JOIN 
                      ".DBPrefix."ribbons b  ON a.pid = b.stats_pid WHERE b.".$ribbon."_count > 0
                       GROUP BY pid ORDER BY ".$ribbon."_count DESC";       
             $result= mysql_query($sSql)or die(mysql_error()) ;
         
         $Ribbonsconstante = 'LANG_RIBBONS_TEXT_'.$ribbon.'';
             
?>      <!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_RIBBONS_TITLE; ?></title>
         <?php echo $styleSettings; ?>
          <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"><?php echo LANG_CLANSTATS_TAB_WEAPONS; ?></a></li>
        <li><a href="ribbonsstats.php"  class="selected">Ribbons</a></li>
        <li><a href="medalsstats.php">Medals</a></li>
        <li><a href="events.php">NEvents</a></li>
        <li><a href="serverHistory.php">S.History</a></li>
      </ul>
				<table class="default" style="width:<?php echo $style['IndexTableWidth']; ?>px;" cellspacing="0" cellpadding="0">
					<tr>
           <td class="head" colspan="8" height="20px"><?php echo LANG_CLANSTATS_RIBBONS_TITLE; ?></td>
           <tr>
        	<td colspan="8">
      		<img src="<?php echo $domain; ?>/img/ribbons/<?php echo $ribbon; ?>.png" /><br /><?php echo constant($Ribbonsconstante); ?>
      		</td>
      	<tr>
      		<td class="object" width="20px"><?php echo LANG_INDEX_PLACE; ?></td> 
      <td class="object"width="160px"><?php echo LANG_INDEX_NAME; ?></td> 
       <td class="object" width="120px"><?php echo LANG_RIBBONS_3; ?></td> 
      <td class="object" width="80px"><?php echo LANG_RIBBONS_5; ?></td>
      <td class="object"><?php echo LANG_RIBBONS_4; ?></td>
	  <tr height=20px >
     
   <?php
       $num = mysql_num_rows($result); 
        if ($num == 0){
        	echo '<td class="result" colspan="8">'.LANG_RIBBONS_TEXT_NO_RIBBON_DETAILS.'</td>';
        }else{
      $place = 1;
   
      while ($data = mysql_fetch_assoc($result)) {	
        $percent = $data[$ribbon.'_count']*100/ $allR;
     ?>
      <td class="result"><?php echo $place++; ?></td>
      <td class="result"><a href="../stats.php?name=<?php echo rawurlencode($data['soldiername']); ?>" target="_self"><?php echo $EoT->nameTrimchars($data['soldiername']); ?></a></td>
      <td class="result"><?php echo $data[$ribbon.'_count']; ?></td>
      <td class="result"><?php echo number_format($percent, 2, ',', ' '); ?>%</td>
      <td class="result"><?php echo $EoT->unix_to_time($data[$ribbon.'_date']); ?></td> 
     <tr>
      <?php
  }
}

   echo '</table>';
   include_once '../inc/footer.php';
   echo '</div>
       </html>';