<?php
/*======================================================================*\
|| #################################################################### ||
|| # eGamers of Tomorrow functions.php Battlefield 3 Leaderboard      # ||
|| # ---------------------------------------------------------------- # ||
|| # Dieses Copyright darf nicht entfernt werden                      # ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # ---------------functionen von und fuer den EoT-Clan--------------# ||
|| #                      http://eot-clan.net                         # ||
|| #################################################################### ||
\*======================================================================*/


class eGamersofTomorrow {
 
	
	  function db_query($q) {
       global $goodqueries, $badqueries, $totalqueries;
        $x=mysql_query($q);
      if($x===false) $badqueries++;
      if($x!=false) $goodqueries++;
     $totalqueries++;
    return $x;
  } 
	
	function accuracy ($wert1 ,$wert2){
	if ($wert2 > 0){
		$return = number_format($wert1*100/$wert2, 2, ',', ' ').'%';
	}else{
		$return = "0,00%";
	}
	return $return;
}
	
	function box_shadow($count){
      	if ($count == 1){
      		$shadow = "box-shadow:1px 2px 3px #00FF00";
      	}else{
      		$shadow = "box-shadow:1px 2px 3px #FF0000";
      	}
      return $shadow;
      }
	
	
   function umlaute ($umlaute) {
       $search = Array("ä","ö","ü","Ä","Ü","Ö","ß");
       $replace = Array("&auml;","&ouml;","&uuml;","&Auml;","&Uuml;","&Ouml;","&szlig");
       $result = str_replace($search, $replace, $umlaute);  
     return $result;
  }

    function progress($points,$class,$count) {
    	if ($class == "assault"){
    		$need = 220000;
    	}else if($class == "support"){
    		  $need = 170000;
    	}else if($class == "engineer"){
    		  $need = 145000;
    	}else if($class == "recon"){
    		  $need = 195000;	  	  
    	 }else if($class == "vehicleah"){
    		  $need = 60000;
    	 }else if($class == "vehiclesh"){
    		  $need = 48000;
    	 }else if($class == "vehiclejet"){
    		  $need = 35000;
    	 }else if($class == "vehiclembt"){
    		  $need = 100000;
    	 }else if($class == "vehicleaa"){
    		  $need = 32000;  
    	 }else if($class == "vehicleifv"){
    		  $need = 90000;  		  
    	}
    		  
    		  
       if($count >= 1){
         $result = ($points-($need*$count))*100/$need;
         }else{
         	$result = $points*100/$need;
        } 
      
     return $result;
  }
  
  
   function sStarPoints($points,$class,$count) {
    	if ($class == "assault"){
    		$need = 220000;
    	}else if($class == "support"){
    		  $need = 170000;
    	}else if($class == "engineer"){
    		  $need = 145000;
    	}else if($class == "recon"){
    		  $need = 195000;	  	  
    	 }else if($class == "vehicleah"){
    		  $need = 60000;
    	 }else if($class == "vehiclesh"){
    		  $need = 48000;
    	 }else if($class == "vehiclejet"){
    		  $need = 35000;
    	 }else if($class == "vehiclembt"){
    		  $need = 100000;
    	 }else if($class == "vehicleaa"){
    		  $need = 32000;  
    	 }else if($class == "vehicleifv"){
    		  $need = 90000;  		  
    	}  
    		  
    		  
       if($count >= 1){
         $result = $need-($points-($need*$count));
         }else{
         	$result = $need-$points;
        } 
      
     return $result;
  }


   function points ($numbers) {    
       $result = number_format($numbers, 0, ',', ' ');      
     return $result;
  }


   function implodeAPI ($array) {    
      $array = implode(",", $array);
      #$urlencode = rawurlencode($array);
     return $array;
  }

   function kd ($kills , $deaths) {    
       if ($deaths > 0 ){
         $KD = $kills/$deaths;
       }else{
      	 $KD = 0;
       }       
     $KD = number_format($KD, 2, ',', '.');       
       if ($KD >= 1){
         $result = '<font class="positiv">'.$KD.'</font>';
       }else{
   	     $result = '<font class="negativ">'.$KD.'</font>';
       }           
      return $result;
  }




   function timeIndex ($seconds) {    
        $s = $seconds;
        $time = sprintf("%02dh %02dm",$s/60/60 ,$s/60%60);
      return $time; 
  }



   function time_m ($seconds) {    
       $s = $seconds;
       $time = sprintf("%02dm %02ds",$s/60 ,$s%60);
     return $time;
  }


function time_H_M ($seconds) {    
       $s = $seconds;
       $time = sprintf("%02dh %02dm",$s/60/60,$s/60%60);
     return $time;
  }
  
  function time_h ($seconds) {    
       $s = $seconds;
       $time = sprintf("%2dh",$s/60/60);
     return $time;
  }
  
  
  function time_map_stats ($seconds) {    
       $s = $seconds;
       $time = sprintf("%02dh %02dm %02ds",$s/60/60,$s/60%60,$s%60);
     return $time;
  }
  




   function time_complete ($seconds) {    
       $s = $seconds;
       $time = sprintf("%02d:%02d:%02d" ,$s/60/60,$s/60%60,$s%60);
      return $time; 
  }


 function weaponsStars ($kills) {    
     if ($kills < 100){
     	$star = "";
     }else if ($kills >= 1000){
     	$star = substr($kills,0,2);
    }else{
      $star = substr($kills,0,1);
    }
     
      return $star;
  }


   function blaetterfunktion($seite,$maxseite,$more,$url="",$anzahl=6,$get_name="page") {
        if(preg_match("/\?/",$url)) $anhang = "&";
         else $anhang = "?";
      if(substr($url,-1,1) == "&") {
         $url = substr_replace($url,"",-1,1);
      }elseif(substr($url,-1,1) == "?") {
         $anhang = "?";
         $url = substr_replace($url,"",-1,1);
     }
       if($anzahl%2 != 0) $anzahl++;
          $a = $seite-($anzahl/2);
          $b = 0;
          $blaetter = array();
        while($b <= $anzahl) {
          if($a > 0 AND $a <= $maxseite) {
            $blaetter[] = $a;
             $b++;
          }
       elseif($a > $maxseite AND ($a-$anzahl-2)>=0) {
         $blaetter = array();
         $a -= ($anzahl+2);
         $b = 0;
       }
      elseif($a > $maxseite AND ($a-$anzahl-2)<0) {
         break;
      }
      $a++;
      }
       $return = "";
        if(!in_array(1,$blaetter) AND count($blaetter) > 1) {
          if(!in_array(2,$blaetter)) $return .= "&nbsp;<a href=\"{$url}{$more}{$get_name}=1\">1</a>&nbsp;...";
          else $return .= "&nbsp;<a href=\"{$url}{$more}{$get_name}=1\">1</a>&nbsp;";
        }

        foreach($blaetter AS $blatt) {
          if($blatt == $seite) $return .= "&nbsp;<font class=DIVtext>$blatt</font>&nbsp;";
          else $return .= "&nbsp;<a href=\"{$url}{$more}{$get_name}=$blatt\">$blatt</a>&nbsp;";
        }

       if(!in_array($maxseite,$blaetter) AND count($blaetter) > 1) {
          if(!in_array(($maxseite-1),$blaetter)) $return .= "...&nbsp;<a href=\"{$url}{$more}{$get_name}=$maxseite\">Letzte:($maxseite)</a>&nbsp;";
          else $return .= "&nbsp;<a href=\"{$url}{$more}{$get_name}=$maxseite\">$maxseite</a>&nbsp;";
       }

      if(empty($return))
         return  "&nbsp;<b>1</b>&nbsp;";
     else
       return $return;
  }  
   
   
   
   function date_time_to_unix ($datetime) {
      $remove = explode(" ", $datetime);
       $remove_day = explode("-",$remove[0]);
       $remove_time = explode(":",$remove[1]);
      
      $hour = $remove_time[0];
      $min = $remove_time[1];
      $sek = $remove_time[2];
      $year = $remove_day[0];
      $month = $remove_day[1];
      $day = $remove_day[2];

     $unix = mktime($hour,$min,$sek,$month,$day,$year);
    return $unix; 
  }
     
     
     
   function unix_to_time($unix){
   	if ($unix == 0 OR $unix == "null"){
   		$result = "----";
   	}else{
     	$result = date("d.m.Y - H:i:s",$unix);
    }
    return $result;      	
  }
    
   
       
  function nameTrimchars ($name){
     if(strlen($name) <= 20) {
        $result = $name;
      } else {
        $result = substr($name,0,17) . '..'; 
      }      
      global $color;
      global $vip;
      if ($vip == 1){
       echo '<font color='.$color.'>'.htmlspecialchars($result).'</font>';
      }else{
        echo htmlspecialchars($result);
    }
 }
 
 
 function vName($name){
     if(strlen($name) <= 10) {
        $result = $name;
      } else {
        $result = substr($name,0,7) . '...'; 
      }     
      return $result; 
 }
 
 
 
 
 
  function sort($sortVar){
       if(isset($sortVar) && !empty($sortVar) && $sortVar != ''){
         $check = $sortVar;
       }else{
         $check = "desc";
      }
    return $check;
 }
 
 
 
  function order($order){    
       if ($order == "desc"){
       $check = "asc";
     }else{
       $check = "desc";
   }      
   return $check;
 }
 
 
 
 
 function language($lang){
      if ($lang == "german"){
	      $array = array("German"=>"german","Englisch"=>"englisch","French"=>"french");
      }else if ($lang == "englisch") {
	      $array =  array("Englisch"=>"englisch","German"=>"german","French"=>"french");
      }else{
      	$array =  array("French"=>"french","Englisch"=>"englisch","German"=>"german");
      }
      
    foreach ($array as $key => $language){
	     echo '<option value="'.$language.'">'.$key.'</option>';
      } 
 }
 
  function defaultSort(){     
	  $array =  array(LANG_INDEX_POINTS => "points", LANG_INDEX_KILLS => "kills", LANG_INDEX_NAME => "soldiername", LANG_INDEX_PLAYTIME => "playtime", LANG_INDEX_DEATHS => "deaths", LANG_INDEX_ROUNDS => "rounds", LANG_INDEX_DOGTAGS => "dogtags", LANG_INDEX_KD => "KD", "Team" => "team", LANG_INDEX_RANK => "rank");    
    foreach ($array as $key => $sort){
	     echo '<option value="'.$sort.'">'.$key.'</option>';
      } 
 }
 
 
 
 function style($style){
      if ($style == "acp"){
	      $array = array("ACP"=>"acp","CSS"=>"css");
      }else{
	      $array =  array("CSS"=>"css","ACP"=>"acp");
      }
      
    foreach ($array as $key => $style){
	     echo '<option value="'.$style.'">'.$key.'</option>';
      } 
 }
 
 
 
 
 function errorReport($error){	
 	if ($error == "1"){
	      $array = array("".LANG_ADMIN_YES.""=>"1","".LANG_ADMIN_NO.""=>"0");
      }else{
	      $array =  array("".LANG_ADMIN_NO.""=>"0","".LANG_ADMIN_YES.""=>"1");
      }
      
    foreach ($array as $key => $error){
	     echo '<option value="'.$error.'">'.$key.'</option>';
      } 
 }
 
 
 
  function platform($platform){	
 	    if ($platform == "pc"){
	      $array = array("PC"=>"pc","XboX360"=>"360","PS3"=>"ps3");
      }elseif ($platform == "360"){
	      $array =  array("XboX360"=>"360","PS3"=>"ps3","PC"=>"pc");
      }else{
      	$array =  array("PS3"=>"ps3","XboX360"=>"360","PC"=>"pc");
      }
      
      
      
      
    foreach ($array as $key => $platform){
	     echo '<option value="'.$platform.'">'.$key.'</option>';
      } 
 }
 

 
  function rankname($rankname){
         $array = array(
       "0" => "Private",
       "1" => "Private First Class I",
       "2" => "Private First Class II",
       "3" => "Private First Class III",
       "4" => "Private First Class IV",
       "5" => "Lance Corporal I",
       "6" => "Lance Corporal II",
       "7" => "Lance Corporal III",
       "8" => "Lance Corporal IV",
       "9" => "Corporal I",
       "10" => "Corporal II",
       "11" => "Corporal III",
       "12" => "Corporal IV",
       "13" => "Sergeant I",
       "14" => "Sergeant II",
       "15" => "Sergeant III",
       "16" => "Sergeant IV",
       "17" => "Staff Sergeant I",
       "18" => "Staff Sergeant II",
       "19" => "Staff Sergeant III",
       "20" => "Gunnery Sergeant I",
       "21" => "Gunnery Sergeant II",
       "22" => "Gunnery Sergeant III",
       "23" => "Master Sergeant I",
       "24" => "Master Sergeant II",
       "25" => "Master Sergeant III",
       "26" => "First Sergeant I",
       "27" => "First Sergeant II",
       "28" => "First Sergeant III",
       "29" => "Master Gunnery Sergeant I",
       "30" => "Master Gunnery Sergeant II",
       "31" => "Master Gunnery Sergeant III",
       "32" => "Sergeant Major I",
       "33" => "Sergeant Major II",
       "34" => "Sergeant Major III",
       "35" => "Warrant Officer",
       "36" => "Chief Warrant Officer 2",
       "37" => "Chief Warrant Officer 3",
       "38" => "Chief Warrant Officer 4",
       "39" => "Chief Warrant Officer 5",
       "40" => "Second Lieutenant",
       "41" => "First Lieutenant",
       "42" => "Captain",
       "43" => "Major",
       "44" => "Colonel",
       "45" => "Colonel II",
       "46" => "Colonel Service Star 1",
       "47" => "Colonel Service Star 2",
       "48" => "Colonel Service Star 3",
       "49" => "Colonel Service Star 4",
       "50" => "Colonel Service Star 5",
       "51" => "Colonel Service Star 6",
       "52" => "Colonel Service Star 7",
       "53" => "Colonel Service Star 8",
       "54" => "Colonel Service Star 9",
       "55" => "Colonel Service Star 10",
       "56" => "Colonel Service Star 11",
       "57" => "Colonel Service Star 12",
       "58" => "Colonel Service Star 13",
       "59" => "Colonel Service Star 14",
       "60" => "Colonel Service Star 15",
       "61" => "Colonel Service Star 16",
       "62" => "Colonel Service Star 17",
       "63" => "Colonel Service Star 18",
       "64" => "Colonel Service Star 19",
       "65" => "Colonel Service Star 20",
       "66" => "Colonel Service Star 21",
       "67" => "Colonel Service Star 22",
       "68" => "Colonel Service Star 23",
       "69" => "Colonel Service Star 24",
       "70" => "Colonel Service Star 25",
       "71" => "Colonel Service Star 26",
       "72" => "Colomel Service Star 27",
       "73" => "Colonel Service Star 28",
       "74" => "Colonel Service Star 29",
       "75" => "Colonel Service Star 30",
       "76" => "Colonel Service Star 31",
       "77" => "Colonel Service Star 32",
       "78" => "Colonel Service Star 33",
       "79" => "Colonel Service Star 34",
       "80" => "Colonel Service Star 35",
       "81" => "Colonel Service Star 36",
       "82" => "Colonel Service Star 37",
       "83" => "Colonel Service Star 38",
       "84" => "Colonel Service Star 39",
       "85" => "Colonel Service Star 40",
       "86" => "Colonel Service Star 41",
       "87" => "Colonel Service Star 42",
       "88" => "Colonel Service Star 43",
       "89" => "Colonel Service Star 44",
       "90" => "Colonel Service Star 45",
       "91" => "Colonel Service Star 46",
       "92" => "Colonel Service Star 47",
       "93" => "Colonel Service Star 48",
       "94" => "Colonel Service Star 49",
       "95" => "Colonel Service Star 50",
       "96" => "Colonel Service Star 51",
       "97" => "Colonel Service Star 52",
       "98" => "Colonel Service Star 53",
       "99" => "Colonel Service Star 54",
       "100" => "Colonel Service Star 55",
       "101" => "Colonel Service Star 56",
       "102" => "Colonel Service Star 57",
       "103" => "Colonel Service Star 58",
       "104" => "Colonel Service Star 59",
       "105" => "Colonel Service Star 60",
       "106" => "Colonel Service Star 61",
       "107" => "Colonel Service Star 62",
       "108" => "Colonel Service Star 63",
       "109" => "Colonel Service Star 64",
       "110" => "Colonel Service Star 65",
       "111" => "Colonel Service Star 66",
       "112" => "Colonel Service Star 67",
       "113" => "Colonel Service Star 68",
       "114" => "Colonel Service Star 69",
       "115" => "Colonel Service Star 70",
       "116" => "Colonel Service Star 71",
       "117" => "Colonel Service Star 72",
       "118" => "Colonel Service Star 73",
       "119" => "Colonel Service Star 74",
       "120" => "Colonel Service Star 75",
       "121" => "Colonel Service Star 76",
       "122" => "Colonel Service Star 77",
       "123" => "Colonel Service Star 78",
       "124" => "Colonel Service Star 79",
       "125" => "Colonel Service Star 80",
       "126" => "Colonel Service Star 81",
       "127" => "Colonel Service Star 82",
       "128" => "Colonel Service Star 83",
       "129" => "Colonel Service Star 84",
       "130" => "Colonel Service Star 85",
       "131" => "Colonel Service Star 86",
       "132" => "Colonel Service Star 87",
       "133" => "Colonel Service Star 88",
       "134" => "Colonel Service Star 89",
       "135" => "Colonel Service Star 90",
       "136" => "Colonel Service Star 91",
       "137" => "Colonel Service Star 92",
       "138" => "Colonel Service Star 93",
       "139" => "Colonel Service Star 94",
       "140" => "Colonel Service Star 95",
       "141" => "Colonel Service Star 96",
       "142" => "Colonel Service Star 97",
       "143" => "Colonel Service Star 98",
       "144" => "Colonel Service Star 99",
       "145" => "Colonel Service Star 100" 
     
       
       );
       $array = $array[$rankname];
    return $array;
  }
 
 
 
  function coop_icon($count,$difficulty){	
      if ($count == 0){
      	echo '<img src="img/coop/'.$difficulty.'_no.png" />';
      }else{
      	echo '<img src="img/coop/'.$difficulty.'_yes.png" />';
     }
   }
   
   function SQUAD($ID){	
      if ($ID == ""){
      	$SQ = 0;
      }else{
      	$SQ = $ID;
     }
     return $SQ;
   }
   
  
  
  
      function favclass($assault,$recon,$support,$engineer){	
       $favclass = array(
       "assault" => $assault,
       "recon" => $recon,
       "support" => $support,
       "engineer" => $engineer
       );
       
      arsort($favclass);
      $keys = array_keys($favclass);
      $favclass = $keys[0];
      
      #$favclass[$keys[0]]; Wert/Key
      
     return $favclass;
   }
 
 
     function GameMode($id)
	{
		switch ($id)
		{
			case 0:
				return 'Rush';
			case 1:
				return 'Conquest';
			case 2:
				return 'Rush';
			case 4:
				return 'Squad Rush';
			case 8:
				return 'Squad DM';
			case 32:
				return 'Team DM';
			case 64:
				return 'Conquest Large';
		  case 128:
				return 'CQ Assault';
		  case 256:
				return 'CQ Assault';
		  case 512:
				return 'Gun Master';
		  case 1024:
				return 'CQ Domination';
			case 2048:
				return 'TDM CQ DLC';
			default:
				return 'Unknown';
		}
	}
 
  function mapName($id)
	{
		switch ($id)
		{
			case 'MP_001':
				return 'Grand Bazar';
			case 'MP_003':
				return 'Tehran Highway';
			case 'MP_007':
				return 'Caspian Border';
			case 'MP_017':
				return 'Canals';
			case 'MP_013':
				return 'Damavand Peak';
			case 'MP_012':
				return 'Op. Firestorm';
			case 'MP_011':
				return 'Seine Crossing';
			case 'MP_018':
				return 'Kharg Island';
			case 'MP_Subway':
				return 'Operation Metro';
			case 'XP1_002':
				return 'Gulf of Oman';
			case 'XP1_003':
				return 'Sharqi Peninsula';
			case 'XP1_004':
				return 'Wake Island';
		  case 'XP1_001':
				return 'Strike at Karkand';
			case 'XP2_Palace':
				return 'Donya Fortress';
			case 'XP2_Skybar':
				return 'Ziba Tower';
			case 'XP2_Office':
				return 'Operation 925';
			case 'XP2_Factory':
				return 'Scrapmetal';
			default:
				return 'Unknown';
		}
	}
	
	
  function settings($id){
		switch ($id)
		{
			case 1:
				return 'Normal';
			case 2:
				return 'Hardcore';
			case 4:
				return 'Infantry Only';
			case 8:
				return 'Custom';
			default:
				return 'Unknown';
		}
	}
	
		function region($id)
	{
		switch ($id)
		{
			case 1:
				return 'North America';
			case 2:
				return 'South America';
			case 4:
				return 'Antarctica';
			case 8:
				return 'Africa';
			case 16:
				return 'Europe';
			case 32:
				return 'Asia';
			case 64:
				return 'Oceania';
			default:
				return 'Unknown';
		}
	}
   
   
    function WEAPON($name)
	{
		switch ($name)
		{
			case 'm320':
				return 'wahUGL';
			case 'm16a3':
				return 'arM16A3';
			case 'aek971':
				return 'arAEK';
		  case 'm416':
				return 'arM416';
		  case 'm26mass':
				return 'wahUSG';
		  case 'm16a4':
				return 'arM16A4_2';
			case 'm16a4_russian':
				return 'arM16A4';
			case 'ak74m_american':
				return 'arAK74A';
		 case 'ak74m':
				return 'arAK74';
			case 'f2000':
				return 'arF2';
			case 'g3':
				return 'arG3';
			case 'kh2002':
				return 'arKH';
			case 'an94':
				return 'arAN94';
			case 'a91':
				return 'caA91';	
			case 'aks74u':
				return 'caAKS';
			case 'aks74u_american':
				return 'caAKSA';
			case 'g36c':
				return 'caG36';
			case 'm4a1':
				return 'caM4';
			case 'm4a1_russian':
				return 'caM4R';
			case 'scarh':
				return 'caSCAR';
			case 'sg553lb':
				return 'caSG553';
			case 'm240':
				return 'mgM240';
			case 'm249':
				return 'mgM249';
			case 'm27_russian':
				return 'mgM27R';
			case 'm27':
				return 'mgM27';
			case 'pecheneg':
				return 'mgPech';
			case 'rpk':
				return 'mgRPK';
			case 'rpk_american':
				return 'mgRPKA';
			case 'type88':
				return 'mgT88';
			case 'glock17_silenced':
				return 'pG17S';
			case 'glock17':
				return 'pG17';
			case 'glock18_silenced':
				return 'pg18S';
			case 'glock18':
				return 'pg18';
			case 'm1911tactical_fancy':
				return 'pM1911L';
			case 'm1911':
				return 'pM1911';
			case 'm1911silenced_fancy':
				return 'pM1911S';
			case 'm1911flashlight_fancy':
				return 'pM1911T';
			case 'mp412rex':
				return 'pM412';
			case 'm9_flashlight':
				return 'pM9F';
			case 'm9_silenced':
				return 'pM9S';
			case 'm9':
				return 'pM9';
			case 'm93r':
				return 'pM93R';
			case 'mp443_flashlight':
				return 'pMP443L';
			case 'mp443_silenced':
				return 'pMP443S';
			case 'mp443_grach':
				return 'pMP443';
			case 'taurus_scope':
				return 'pTaurS';
			case 'taurus44':
				return 'pTaur';
			case 'remington870':
				return 'sg870';
			case 'dao12':
				return 'sgDAO';
			case 'm1014':
				return 'sgM1014';
			case 'saiga12':
				return 'sgSaiga';
			case 'usas12':
				return 'sgUSAS';
			case 'mp7':
				return 'smMP7';
			case 'p90':
				return 'smP90';
			case 'magpul':
				return 'smPDR';
			case 'pp2000':
				return 'smPP2000';
			case 'ump':
				return 'smUMP';
			case 'asval':
				return 'smVAL';
			case 'm39':
				return 'srM39';
			case 'm40a5':
				return 'srM40';
			case 'm98b':
				return 'srM98';
			case 'mk11':
				return 'srMK11';
			case 'mk11_russian':
				return 'srMK11R';
			case 'sks':
				return 'srSKS';
			case 'svd':
				return 'srSVD';
			case 'svd_american':
				return 'srSVDA';
			case 'knife':
				return 'wasK';
			case 'fim92a_stinger':
				return 'wLAAFIM';
			case 'sa18igla':
				return 'wLAAIGL';
			case 'fgm148':
				return 'wLATJAV';
			case 'rpg7':
				return 'wLATRPG';
			case 'smaw':
				return 'wLATSMAW';
			case 'sv98':
				return 'srSV98';
			case 'm60':
				return 'mgM60';
			case 'xp1_famas':
				return 'arFAMAS';
			case 'xp1_l85a2':
				return 'arL85A2';
			case 'xp1_hk53':
				return 'caHK53';
			case 'xp1_qbz95b':
				return 'caQBZ95B';
			case 'xp1_qbb95':
				return 'mgQBB95';
			case 'xp1_mg36':
				return 'mgMG36';
			case 'xp1_qbu88':
				return 'srQBU88';
			case 'xp1_l96':
				return 'srL96';
			case 'xp1_pp19':
				return 'smPP19';
			case 'xp1_jackhammer':
				return 'sgJackH';
			case 'm67-grenade':
				return 'waeM67';			
			case 'radiobeacon':
				return 'seqRad';
			case 'defib':
				return 'wasDef';
			case 'c4':
				return 'waeC4';
			case 'tugs':
				return 'seqUGS';
			case 'mine':
				return 'waeMine';
			case 'claymore':
				return 'waeClay';
			case 'eod':
				return 'seqEOD';
			case 'soflam':
				return 'seqSOF';
			case 'm224_mortar':
				return 'waeMort';
			case 'mav':
				return 'seqMAV';
			case 'repairtool':
				return 'wasRT';	
		  case 'xp2_steyraug':
				return 'arAUG';
			case 'xp2_scarl':
				return 'arSCARL';
			case 'xp2_l86':
				return 'mgL86A1';
			case 'xp2_lsat':
				return 'mgLSAT';
			case 'xp2_acr':
				return 'caACR';
			case 'xp2_mtar':
				return 'caMTAR21';
			case 'xp2_hk417':
				return 'srHK417';
			case 'xp2_jng90':
				return 'srJNG90';
			case 'xp2_spas12':
				return 'sgSPAS12';
			case 'xp2_mp5k':
				return 'smM5K';
      default:
				return 'unknown';
		}
	}
   
   
    function VEHICLE($name)
	{
		switch ($name)
		{
			case 'tunguska':
				return 'aa9k22';
			case 'lav-ad':
				return 'aaLAV';
		  case 'ah1z':
				return 'ahAH1Z';
		  case 'mi28':
				return 'ahMi28';
		  case 'tow':
				return 'atTOW';
			case 'bmp2':
				return 'ifvBMP';
			case 'lav-25':
				return 'ifvLAV';
			case 'a10':
				return 'jaA10';
			case 'su39':
				return 'jaSU25';
			case 'f18':
				return 'jfF18';
			case 'su35':
				return 'jfSu35';
			case 'm1a2':
				return 'mbtM1A';
			case 't90':
				return 'mbtT90';
			case 'centurion':
				return 'saaCRAM';
			case 'pantsir':
				return 'saaPant';
			case 'ah6':
				return 'shAH6';
			case 'z11':
				return 'shz11';
			case 'kornet':
				return 'sKorn';
			case 'aav':
				return 'trAAV';
			case 'humvee':
				return 'trHum';
			case 'growler':
				return 'trITV';
			case 'ka60':
				return 'trKA60';
			case 'rhib':
				return 'trRIB';
			case 'venom':
				return 'trUH1';
			case 'vdv':
				return 'trVDV';
			case 'vodnik':
				return 'trVod';
			case 'skidloader':
				return 'trSkid';
			case 'dpv':
				return 'trDpv';
			case 'btr90':
				return 'ifvBTR90';
			case 'f35':
				return 'jfx1F35JSF';	
      default:
				return 'unknown';
		}
	}
   
}


function updateStats ($iPid){
	$iPid = str_replace("N", "", $iPid);
	$oRes = new xajaxResponse();
	security::escape($iPid);
	
	$oSoldier = stats::getStats($iPid, 'soldiername', 0);
	if (is_string($oSoldier)){
		$oRes->alert($oSoldier);
	} else {
		$_GET['name'] = $oSoldier['soldiername'];
		$bAjax = true;
		include_once ('update/update.php');
		
		if ($bError !== false){
			if (is_string($bError)){
				$oRes->alert($bError);
			} else {
				$oRes->alert(LANG_ERROR_AJAX."\nError Code from API: ".$aData['status']);
				if ($aData['status'] == "notfound"){
				mysql_query("UPDATE ".DBPrefix."generalStats SET invisible='invisible' WHERE soldiername='{$oSoldier['soldiername']}'	") or die ("	Ungültige Abfrage: " . mysql_error());
			 }
			}
		}
		$data = stats::getStats($iPid, '*', 0);
		$kills =  number_format($data['kills'], 0, ',', ' ');
		$deaths =  number_format($data['deaths'], 0, ',', ' ');
		$time = sprintf("%02dh %02dm",$data['playtime']/60/60 ,$data['playtime']/60%60);
		$rounds =  number_format($data['rounds'], 0, ',', ' ');
		$dogtags =  number_format($data['dogtags'], 0, ',', ' ');	
		$team =  number_format($data['team'], 0, ',', ' ');	
	
		if ($data['deaths'] > 0 ){
         $KD = $data['kills']/$data['deaths'];
       }else{
      	 $KD = 0;
       }       
     $KD = number_format($KD, 2, ',', '.');       
       if ($KD >= 1){
         $kd = '<font class="positiv">'.$KD.'</font>';
       }else{
   	     $kd = '<font class="negativ">'.$KD.'</font>';
       }           
		$score =  number_format($data['points'], 0, ',', ' ');
		
		$oRes->assign("rank_{$iPid}", "innerHTML", "<a href='#' rel='htmltooltip'><img src='img/rank/P0{$data['rank']}.png' alt='Rank' /></a>");	
		$oRes->assign("kills_{$iPid}", "innerHTML", "{$kills}");
		$oRes->assign("deaths_{$iPid}", "innerHTML", "{$deaths}");
		$oRes->assign("time_{$iPid}", "innerHTML", "{$time}");
		$oRes->assign("round_{$iPid}", "innerHTML", "{$rounds}");
		$oRes->assign("dogtags_{$iPid}", "innerHTML", "{$dogtags}");
		$oRes->assign("team_{$iPid}", "innerHTML", "{$team}");
		$oRes->assign("kd_{$iPid}", "innerHTML", "{$kd}");
		global $row;
		
		if ($row['History'] == 1){
		   $oRes->assign("score_{$iPid}", "innerHTML", "<a id='bf3stats_{$data['pid']}' href='history.php?pid={$data['pid']}'>{$score}</a>");
	     }else{
	     $oRes->assign("score_{$iPid}", "innerHTML", "{$score}");
	   }
	}
	$oRes->assign("anim_{$iPid}_loading", "style.display", 'none');
	$oRes->assign("anim_{$iPid}", "style.display", '');
	$oRes->script("document.getElementById('updating').value = parseInt(document.getElementById('updating').value-1);");
	$oRes->assign($iPid, "value", "false");
	
	return $oRes;
}

function skimHistory($iPid, $iPage){
	$iPid = intval($iPid);
	$iPage = intval(str_replace('history_page_', '', $iPage));
	$oRes = new xajaxResponse();
	if ($iPid != 0 && $iPage != 0){
		$oRes->script(
			"
			document.getElementById('history_prev').className = 'history_page_" . intval($iPage - 1) . "';
			document.getElementById('history_next').className = 'history_page_" . intval($iPage + 1) . "';
			if ({$iPage} <= 1) {
				document.getElementById('history_first').style.display = 'none';
				document.getElementById('history_prev').style.display = 'none';
				document.getElementById('history_next').style.display = '';
				document.getElementById('history_last').style.display = '';
			} else {
				document.getElementById('history_first').style.display = '';
				document.getElementById('history_prev').style.display = '';
				if ({$iPage} >= " . floor(history::countEntries($iPid) / history::HISTORY_LINES + 1) . ") {
					document.getElementById('history_next').style.display = 'none';
					document.getElementById('history_last').style.display = 'none';
				} else {
					document.getElementById('history_next').style.display = '';
					document.getElementById('history_last').style.display = '';
				}
			}
			"
		);
		
		$sTable = history::createTable($iPid, $iPage);
		$oRes->assign('historyTable', 'innerHTML', $sTable);
	} else {
		$oRes->alert("Fehler, falsche Seitenzahl oder Spieler-ID, konnte keine History ermitteln.");
	}
	return $oRes;
}