<?php
/*======================================================================*\
|| #################################################################### ||
|| # EoT-Clan BC2 Leaderboard                                         # ||
|| # ---------------------------------------------------------------- # ||
|| # Dieses Copyright darf nicht entfernt werden                      # ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # -----------------BC2 Leaderboard 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);
	

 //Delete chat which is older than 4 days
db_query ("DELETE FROM tbl_chatlog WHERE TO_DAYS(logDate)+{$serverChat} < TO_DAYS(NOW())")
or die ("Ungültige Abfrage1: " . mysql_error());

 

 //Delete Mapstats which is older than 10 days
db_query ("DELETE FROM tbl_mapstats WHERE TO_DAYS(TimeMapLoad)+{$Mapstats} < TO_DAYS(NOW())")
or die ("Ungültige Abfrage2: " . mysql_error());
 
 
//Start Transaction
db_query ("START TRANSACTION")
or die ("Ungültige Abfrage3: " . mysql_error());        
   $sSql = "
   SELECT a.SoldierName,a.PlayerID,a.tUpdate,a.BonusPoints, b.*, c.* FROM tbl_playerdata a
    Left JOIN tbl_playerstats b ON a.PlayerID = b.StatsID
    Left JOIN tbl_weaponstats c ON a.PlayerID = c.WeaponStatsID
     WHERE TO_DAYS(b.LastSeenOnServer)+{$PlayerUpdates} > TO_DAYS(NOW()) ORDER by tUpdate ASC Limit {$PlayerupdateLimit}"; 
         
         
    $rResult   = db_query($sSql) or $bError .= "\nError in Query: " . mysql_error() . ' in SQL: ' . print_r($sSql, true);
    $iall = 0;
  while($data = mysql_fetch_assoc($rResult)){
  	include_once ('../inc/weapons_array.php');
 $time = time();
 $sSql = "SELECT * FROM tbl_stars WHERE stars_id = '{$data['PlayerID']}'";
		$rResultUser = db_query($sSql) or die ("Fehler: ".mysql_error(). " -> " . $sSql);
		$aUser = mysql_fetch_assoc($rResultUser);
		if ($aUser['stars_id'] <= 0){
			db_query("INSERT INTO tbl_stars (stars_id) VALUES ('{$data['PlayerID']}')");
	  }
	  
	  //Berechnung der Waffen und Count
	  $i = 0; 
	  $points = 0;
 	foreach ($aStarWeapons  as $weapons){		
	  if ($data[$weapons.'_kills'] >= 25 && $aUser[$weapons.'_count'] == 0){
	  	$count = '`'.$weapons.'_count`';
	  	$timeF = '`'.$weapons.'_time`';
	  	$points = 500;
	  	db_query("Update tbl_stars SET {$count} = '1',{$timeF} = '{$time}' ,last_weapon = '{$weapons}', last_count = '1', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage1: " . mysql_error());  
	  	++$i;  
	  }elseif ($data[$weapons.'_kills'] >= 50 && $aUser[$weapons.'_count'] == 1){
	  	$count = '`'.$weapons.'_count`';
	  	$timeF = '`'.$weapons.'_time`';
	  	$points = 1000;
	  	db_query("Update tbl_stars SET {$count} = '2',{$timeF} = '{$time}',last_weapon = '{$weapons}', last_count = '2', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage2: " . mysql_error());  
	  	++$i;  
	  }elseif ($data[$weapons.'_kills'] >= 100 && $aUser[$weapons.'_count'] == 2){
	  	$count = '`'.$weapons.'_count`';
	  	$timeF = '`'.$weapons.'_time`';
	  	$points = 5000;
	  	db_query("Update tbl_stars SET {$count} = '3',{$timeF} = '{$time}',last_weapon = '{$weapons}', last_count = '3', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error());  
	  	++$i;  
	  }elseif ($data[$weapons.'_kills'] >= 200 && $aUser[$weapons.'_count'] == 3){
	  	$count = '`'.$weapons.'_count`';
	  	$timeF = '`'.$weapons.'_time`';
	  	$points = 5000;
	  	db_query("Update tbl_stars SET {$count} = '4',{$timeF} = '{$time}',last_weapon = '{$weapons}', last_count = '4', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error()); 
	  	++$i;  	
	  }elseif ($data[$weapons.'_kills'] >= 300 && $aUser[$weapons.'_count'] == 4){
	  	$count = '`'.$weapons.'_count`';
	  	$timeF = '`'.$weapons.'_time`';
	  	$points = 5000;
	  	db_query("Update tbl_stars SET {$count} = '5',{$timeF} = '{$time}',last_weapon = '{$weapons}', last_count = '5', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error());  
	  	++$i;  
	  }elseif ($data[$weapons.'_kills'] >= 400 && $aUser[$weapons.'_count'] == 5){
	  	$count = '`'.$weapons.'_count`';
	  	$timeF = '`'.$weapons.'_time`';
	  	$points = 5000;
	  	db_query("Update tbl_stars SET {$count} = '6',{$timeF} = '{$time}',last_weapon = '{$weapons}', last_count = '6', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error());  
	  	++$i;	
	  }elseif ($data[$weapons.'_kills'] >= 500 && $aUser[$weapons.'_count'] == 6){
	  	$count = '`'.$weapons.'_count`';
	  	$timeF = '`'.$weapons.'_time`';
	  	$points = 5000;
	  	db_query("Update tbl_stars SET {$count} = '7',{$timeF} = '{$time}',last_weapon = '{$weapons}', last_count = '7', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error());  
	  	++$i;  	
	  }elseif ($data[$weapons.'_kills'] >= 600 && $aUser[$weapons.'_count'] == 7){
	  	$count = '`'.$weapons.'_count`';
	  	$timeF = '`'.$weapons.'_time`';
	  	$points = 5000;
	  	db_query("Update tbl_stars SET {$count} = '8',{$timeF} = '{$time}',last_weapon = '{$weapons}', last_count = '8', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error()); 
	  	++$i;  	
	  }elseif ($data[$weapons.'_kills'] >= 700 && $aUser[$weapons.'_count'] == 8){
	  	$count = '`'.$weapons.'_count`';
	  	$timeF = '`'.$weapons.'_time`';
	  	$points = 5000;
	  	db_query("Update tbl_stars SET {$count} = '9',{$timeF} = '{$time}',last_weapon = '{$weapons}', last_count = '9', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error());  
	  	++$i;   	
	  }elseif ($data[$weapons.'_kills'] >= 800 && $aUser[$weapons.'_count'] == 9){
	  	$count = '`'.$weapons.'_count`';
	  	$timeF = '`'.$weapons.'_time`';
	  	$points = 5000;
	  	db_query("Update tbl_stars SET {$count} = '10',{$timeF} = '{$time}',last_weapon = '{$weapons}', last_count = '10', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error());  
	  	++$i;  
	  }elseif ($data[$weapons.'_kills'] >= 900 && $aUser[$weapons.'_count'] == 10){
	    $count = '`'.$weapons.'_count`';
	  	$timeF = '`'.$weapons.'_time`';
	  	$points = 5000;
	  	db_query("Update tbl_stars SET {$count} = '11',{$timeF} = '{$time}',last_weapon = '{$weapons}', last_count = '11', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error());  
	  	++$i;  
	  }elseif ($data[$weapons.'_kills'] >= 1000 && $aUser[$weapons.'_count'] == 11){				
	  	$count = '`'.$weapons.'_count`';
	  	$timeF = '`'.$weapons.'_time`';
	  	$points = 10000;
	  	db_query("Update tbl_stars SET {$count} = '12',{$timeF} = '{$time}',last_weapon = '{$weapons}', last_count = '12', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error()); 
	  	++$i;  
	  }
	 
  }
  include('../inc/weapons_S.php');
   //Berchnung der Gadgets und Count
   $ii = 0;
   $pointsg = 0;
 	foreach ($aGadgets as $gadgets){		
	  if ($data[$gadgets.'_kills'] >= 15 && $aUser[$gadgets.'_count'] == 0){
	  	$count = '`'.$gadgets.'_count`';
	  	$timeF = '`'.$gadgets.'_time`';
	  	$pointsg = 500;
	  	db_query("Update tbl_stars SET {$count} = '1',{$timeF} = '{$time}',last_weapon = '{$gadgets}', last_count = '1', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error());  
	  	++$ii;  
	  }elseif ($data[$gadgets.'_kills'] >= 25 && $aUser[$gadgets.'_count'] == 1){
	  	$count = '`'.$gadgets.'_count`';
	  	$timeF = '`'.$gadgets.'_time`';
	  	$pointsg = 1000;
	  	db_query("Update tbl_stars SET {$count} = '2',{$timeF} = '{$time}',last_weapon = '{$gadgets}', last_count = '2', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error());  
	  	++$ii;  
	  }elseif ($data[$gadgets.'_kills'] >= 50 && $aUser[$gadgets.'_count'] == 2){
	  	$count = '`'.$gadgets.'_count`';
	  	$timeF = '`'.$gadgets.'_time`';
	  	$pointsg = 5000;
	  	db_query("Update tbl_stars SET {$count} = '3',{$timeF} = '{$time}',last_weapon = '{$gadgets}', last_count = '3', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error()); 
	  	++$ii;   	
	  }elseif ($data[$gadgets.'_kills'] >= 100 && $aUser[$gadgets.'_count'] == 3){
	  	$count = '`'.$gadgets.'_count`';
	  	$timeF = '`'.$gadgets.'_time`';
	  	$pointsg = 5000;
	  	db_query("Update tbl_stars SET {$count} = '4',{$timeF} = '{$time}',last_weapon = '{$gadgets}', last_count = '4', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error()); 
	  	++$ii; 
	  }elseif ($data[$gadgets.'_kills'] >= 150 && $aUser[$gadgets.'_count'] == 4){
	  	$count = '`'.$gadgets.'_count`';
	  	$timeF = '`'.$gadgets.'_time`';
	  	$pointsg = 5000;
	  	db_query("Update tbl_stars SET {$count} = '5',{$timeF} = '{$time}',last_weapon = '{$gadgets}', last_count = '5', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error());  
	  	++$ii; 
	  }elseif ($data[$gadgets.'_kills'] >= 200 && $aUser[$gadgets.'_count'] == 5){
	  	$count = '`'.$gadgets.'_count`';
	  	$timeF = '`'.$gadgets.'_time`';
	  	$pointsg = 5000;
	  	db_query("Update tbl_stars SET {$count} = '6',{$timeF} = '{$time}',last_weapon = '{$gadgets}', last_count = '6', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error()); 
	  	++$ii; 
	  }elseif ($data[$gadgets.'_kills'] >= 250 && $aUser[$gadgets.'_count'] == 6){
	  	$count = '`'.$gadgets.'_count`';
	  	$timeF = '`'.$gadgets.'_time`';
	  	$pointsg = 5000;
	  	db_query("Update tbl_stars SET {$count} = '7',{$timeF} = '{$time}',last_weapon = '{$gadgets}', last_count = '7', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error()); 
	  	++$ii; 
	  }elseif ($data[$gadgets.'_kills'] >= 300 && $aUser[$gadgets.'_count'] == 7){
	  	$count = '`'.$gadgets.'_count`';
	  	$timeF = '`'.$gadgets.'_time`';
	  	$pointsg = 5000;
	  	db_query("Update tbl_stars SET {$count} = '8',{$timeF} = '{$time}',last_weapon = '{$gadgets}', last_count = '8', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error());  
	  	++$ii; 
	  }elseif ($data[$gadgets.'_kills'] >= 350 && $aUser[$gadgets.'_count'] == 8){
	  	$count = '`'.$gadgets.'_count`';
	  	$timeF = '`'.$gadgets.'_time`';
	  	$pointsg = 5000;
	  	db_query("Update tbl_stars SET {$count} = '9',{$timeF} = '{$time}',last_weapon = '{$gadgets}', last_count = '9', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error());  
	  	++$ii; 
	  }elseif ($data[$gadgets.'_kills'] >= 400 && $aUser[$gadgets.'_count'] == 9){
	  	$count = '`'.$gadgets.'_count`';
	  	$timeF = '`'.$gadgets.'_time`';
	  	$pointsg = 5000;
	  	db_query("Update tbl_stars SET {$count} = '10',{$timeF} = '{$time}',last_weapon = '{$gadgets}', last_count = '10', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error());  
	  	++$ii; 
	  }elseif ($data[$gadgets.'_kills'] >= 450 && $aUser[$gadgets.'_count'] == 10){
	    $count = '`'.$gadgets.'_count`';
	  	$timeF = '`'.$gadgets.'_time`';
	  	$pointsg = 5000;
	  	db_query("Update tbl_stars SET {$count} = '11',{$timeF} = '{$time}',last_weapon = '{$gadgets}', last_count = '11', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error());  
	  	++$ii; 
	  }elseif ($data[$gadgets.'_kills'] >= 500 && $aUser[$gadgets.'_count'] == 11){				
	  	$count = '`'.$gadgets.'_count`';
	  	$timeF = '`'.$gadgets.'_time`';
	  	$pointsg = 10000;
	  	db_query("Update tbl_stars SET {$count} = '12',{$timeF} = '{$time}',last_weapon = '{$gadgets}', last_count = '12', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error());  
	  	++$ii; 
	  }  	  
  }
  
      $g_smgpoints = 0;
  if ($g_smgkills >= 500 && $aUser['smg_count'] == 0){
  	$g_smgpoints = 5000;
  	db_query("Update tbl_stars SET smg_count = '1', smg_time = '{$time}',last_weapon = 'smg', last_count = '1', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error());
  }
  
       $g_assaultpoints = 0;
   if ($g_assaultkills >= 500 && $aUser['assault_count'] == 0){
  	$g_assaultpoints = 5000;
  	db_query("Update tbl_stars SET assault_count = '1', assault_time = '{$time}',last_weapon = 'assault', last_count = '1', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error()); 
  }
  
       $g_medicpoints = 0;
   if ($g_medickills >= 500 && $aUser['medic_count'] == 0){
  	$g_medicpoints = 5000;
  	db_query("Update tbl_stars SET medic_count = '1', medic_time = '{$time}',last_weapon = 'medic', last_count = '1', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error());
  }
  
       $g_reconpoints = 0;
   if ($g_reconkills >= 500 && $aUser['recon_count'] == 0){
  	$g_reconpoints = 5000;
  	db_query("Update tbl_stars SET recon_count = '1', recon_time = '{$time}',last_weapon = 'recon', last_count = '1', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error()); 
  }
  
       $g_shotgunpoints = 0;
   if ($g_shotgunkills >= 500 && $aUser['shotgun_count'] == 0){
  	$g_shotgunpoints = 5000;
  	db_query("Update tbl_stars SET shotgun_count = '1', shotgun_time = '{$time}',last_weapon = 'shotgun', last_count = '1', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error()); 
  }
  
       $g_pistolpoints = 0;
   if ($g_pistolkills >= 200 && $aUser['pistol_count'] == 0){
  	$g_pistolpoints = 5000;
  	db_query("Update tbl_stars SET pistol_count = '1', pistol_time = '{$time}',last_weapon = 'pistol', last_count = '1', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error()); 
  }
       $g_vietnampoints = 0;
   if ($g_vietnamkills >= 1500 && $aUser['vietnam_count'] == 0){
  	$g_vietnampoints = 5000;
  	db_query("Update tbl_stars SET vietnam_count = '1', vietnam_time = '{$time}',last_weapon = 'vietnam', last_count = '1', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error()); 
  }

       $g_lightpoints = 0;
   if ($g_vlightkills >= 200 && $aUser['light_count'] == 0){
  	$g_lightpoints = 10000;
  	db_query("Update tbl_stars SET light_count = '1', light_time = '{$time}',last_weapon = 'light', last_count = '1', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error()); 
  }
  
       $g_heavypoints = 0;
   if ($g_vheavykills >= 500 && $aUser['heavy_count'] == 0){
  	$g_heavypoints = 5000;
  	db_query("Update tbl_stars SET heavy_count = '1', heavy_time = '{$time}',last_weapon = 'heavy', last_count = '1', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error());
  }
  
       $g_airpoints = 0;
   if ($g_vairkills >= 500 && $aUser['air_count'] == 0){
  	$g_airpoints = 5000;
  	db_query("Update tbl_stars SET air_count = '1', air_time = '{$time}',last_weapon = 'air', last_count = '1', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error());
  }
  
       $g_waterpoints = 0;
   if ($g_vwaterkills >= 200 && $aUser['water_count'] == 0){
  	$g_waterpoints = 10000;
  	db_query("Update tbl_stars SET water_count = '1', water_time = '{$time}',last_weapon = 'water', last_count = '1', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error()); 
  }
  
       $g_statpoints = 0;
   if ($g_vstatkills >= 200 && $aUser['stat_count'] == 0){
  	$g_statpoints = 10000;
  	db_query("Update tbl_stars SET stat_count = '1', stat_time = '{$time}',last_weapon = 'stat', last_count = '1', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error());
  }
  
       $g_timepoints = 0;
   if ($data['playerPlaytime'] >= 86400 && $aUser['time1_count'] == 0){
  	   $g_timepoints = 5000;
  	db_query("Update tbl_stars SET time1_count = '1', time1_time = '{$time}',last_weapon = 'time1', last_count = '1', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error()); 
  }elseif($data['playerPlaytime'] >= 172800 && $aUser['time2_count'] == 0){
  	   $g_timepoints = 5000;
  	db_query("Update tbl_stars SET time2_count = '1', time2_time = '{$time}',last_weapon = 'time2', last_count = '1', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error()); 
  }elseif($data['playerPlaytime'] >= 432000 && $aUser['time3_count'] == 0){
  	   $g_timepoints = 10000;
  	db_query("Update tbl_stars SET time3_count = '1', time3_time = '{$time}',last_weapon = 'time3', last_count = '1', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error()); 
  }
  
       $g_killsapoints = 0;
   if ($data['playerKills'] >= 10000 && $aUser['kills_count'] == 0){
  	$g_killsapoints = 10000;
  	db_query("Update tbl_stars SET kills_count = '1', kills_time = '{$time}',last_weapon = 'kills', last_count = '1', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error()); 
  }
  
       $g_headapoints = 0;
   if ($data['playerHeadshots'] >= 500 && $aUser['head_count'] == 0){
  	$g_headapoints = 5000;
  	db_query("Update tbl_stars SET head_count = '1', head_time = '{$time}',last_weapon = 'head', last_count = '1', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error());
  }elseif($data['playerHeadshots'] >= 1500 && $aUser['head2_count'] == 0){
  	$g_headapoints = 10000;
  	db_query("Update tbl_stars SET head2_count = '1', head2_time = '{$time}',last_weapon = 'head2', last_count = '1', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error()); 
  }
  
  
       $g_knifepoints = 0;
   if ($data['KNV-1_kills'] >= 200 && $aUser['knife_count'] == 0){
  	$g_knifepoints = 5000;
  	db_query("Update tbl_stars SET knife_count = '1', knife_time = '{$time}',last_weapon = 'knife', last_count = '1', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error()); 
  }elseif($data['KNV-1_kills'] >= 500 && $aUser['knife2_count'] == 0){
  	$g_knifepoints = 1000;
  	db_query("Update tbl_stars SET knife2_count = '1', knife2_time = '{$time}',last_weapon = 'knife2', last_count = '1', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error()); 
  }
  
       $g_grenadepoints = 0;
   if ($data['HG-2_kills'] >= 200 && $aUser['grenade_count'] == 0){
  	$g_grenadepoints = 5000;
  	db_query("Update tbl_stars SET grenade_count = '1', grenade_time = '{$time}',last_weapon = 'grenade', last_count = '1', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error()); 
  }elseif($data['HG-2_kills'] >= 500 && $aUser['grenade2_count'] == 0){
  	$g_grenadepoints = 1000;
  	db_query("Update tbl_stars SET grenade2_count = '1', grenade2_time = '{$time}',last_weapon = 'grenade2', last_count = '1', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error()); 
  }
  
      $g_c4points = 0;
  if ($data['DTN-4_kills'] >= 200 && $aUser['c4_count'] == 0){
  	$g_c4points = 5000;
  	db_query("Update tbl_stars SET c4_count = '1', c4_time = '{$time}',last_weapon = 'c4', last_count = '{$count}', last_time = '1' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error());
  }
  
      $g_flamepoints = 0;
  if ($data['FLAMETHROWER_kills'] >= 500 && $aUser['flame_count'] == 0){
  	$g_flamepoints = 5000;
  	db_query("Update tbl_stars SET flame_count = '1', flame_time = '{$time}',last_weapon = 'flame', last_count = '1', last_time = '{$time}' WHERE stars_id = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error()); 
  }
  
   $ipoints = ($i*$points);
   $ipointsg = ($ii*$pointsg);
   $BonusPoints = ($data['BonusPoints']+$ipoints+$ipointsg+$g_smgpoints+$g_assaultpoints+$g_medicpoints+$g_shotgunpoints+$g_pistolpoints+$g_vietnampoints+$g_lightpoints+$g_heavypoints+$g_airpoints+$g_waterpoints+$g_statpoints+$g_timepoints+$g_killsapoints+$g_headapoints+$g_knifepoints+$g_grenadepoints+$g_c4points+$g_flamepoints);
   $BonusPointsS = ($ipoints+$ipointsg+$g_smgpoints+$g_assaultpoints+$g_medicpoints+$g_shotgunpoints+$g_pistolpoints+$g_vietnampoints+$g_lightpoints+$g_heavypoints+$g_airpoints+$g_waterpoints+$g_statpoints+$g_timepoints+$g_killsapoints+$g_headapoints+$g_knifepoints+$g_grenadepoints+$g_c4points+$g_flamepoints);
  db_query("Update tbl_playerdata SET tUpdate = '{$time}',BonusPoints = '{$BonusPoints}' WHERE PlayerID = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error());
  
  $GesamtPoints = ($data['playerScore']+$BonusPointsS);
  db_query("Update tbl_playerstats SET playerScore = '{$GesamtPoints}' WHERE StatsID = '{$data['PlayerID']}'")or die ("Ungültige Abfrage: " . mysql_error());
  ++$iall;
}

db_query("Update tbl_general SET LastCleanup  = NOW()")or die ("Ungültige Abfrage: " . mysql_error());
//COMMIT Transaction
db_query ("COMMIT")
or die ("Ungültige Abfrage: " . mysql_error()); 
?>
         <head>
					<title>Cleanup Stats</title>
	        <link rel="stylesheet" type="text/css" href="../css/style.css" /> 
	      </head>
<div class="body_leaderboard_viewer">
     <table class="default_h" style="margin-top:12px;" cellspacing="0" cellpadding="2">
       <td class="head"><a href="<?php echo $installdir; ?>/index.php" target="_self"><span style="float:left;margin-left:5px;"><?php echo lang_index_startseite; ?></a></span><span style="margin-left:-80px;">Cleanup Stats</span></td>
     <tr class="hov">	
      	<td class="result">
      		<?php echo lang_update_players.$iall.lang_update_players2; ?><br />
      	  <?php $microtime = microtime(true) - $microtime; echo lang_update_time.$microtime.lang_update_time2; ?><br /> 
      		<?php echo lang_update_querys.$totalqueries.lang_update_querys2; ?><br />
      		
      </td>  	
    </table> 
    <?php include_once ("../inc/footer.php"); ?>
    <br />
  </div>
     