Guest User

Untitled

a guest
May 18th, 2017
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.31 KB | None | 0 0
  1. <?php
  2.        
  3.         $steamid = $_GET["steamid"];
  4.         $key = "5F96F7D2AE585388F1E5987557DDD6FA";
  5.        
  6.         if(strlen($steamid) == 17){ // Wanneer er gebruik wordt gemaakt van SteamID64
  7.            
  8.             $urlSteamStatsForGame = "http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid=730&key=$key&steamid=$steamid";
  9.             $urlSteamUserInfo = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=$key&steamids=$steamid";
  10.            
  11.         } elseif (strlen($steamid) < 17){ // Wanneer er gebruik wordt gemaakt van custom steam id
  12.            
  13.             $vanityurl = "http://api.steampowered.com/ISteamUser/ResolveVanityURL/v0001/?key=$key&vanityurl=$steamid";
  14.            
  15.             $ch = curl_init();
  16.             curl_setopt($ch, CURLOPT_URL, $vanityurl);
  17.             curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  18.             curl_setopt($ch, CURLOPT_HTTPGET, true);
  19.  
  20.             $steamid64 = curl_exec($ch);
  21.            
  22.             curl_close($ch);
  23.            
  24.             $steamid64json = json_decode($steamid64, true);
  25.             $doesexist = $steamid64json['response']['success']; // Checkt of profiel wel bestaat
  26.            
  27.             if($doesexist == 42){ // Profiel bestaat niet
  28.                
  29.                 Alert("This profile doesn't exist, Error code 42");
  30.                    
  31.             } elseif($doesexist == 1){ // Profiel bestaat
  32.                 $steamid64 = $steamid64json['response']['steamid'];
  33.                
  34.                 $urlSteamStatsForGame = "http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid=730&key=$key&steamid=$steamid64";
  35.                 $urlSteamUserInfo = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=$key&steamids=$steamid64";
  36.             }
  37.         }
  38.  
  39.         // Haal data op van URL
  40.         $ch = curl_init();
  41.         curl_setopt($ch, CURLOPT_URL, $urlSteamUserInfo);
  42.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  43.         curl_setopt($ch, CURLOPT_HTTPGET, true);
  44.  
  45.         $SteamUserInfoResult = curl_exec($ch);
  46.  
  47.         curl_setopt($ch, CURLOPT_URL, $urlSteamStatsForGame);
  48.  
  49.         $SteamStatsForGameResult = curl_exec($ch);
  50.  
  51.         curl_close($ch);
  52.        
  53.         // Sla de informatie op in JSON vanuit arrays
  54.         $jsonforuser = json_decode($SteamUserInfoResult, true);
  55.         $jsonforgame = json_decode($SteamStatsForGameResult, true);
  56.  
  57.         if(empty($jsonforgame)){ // Profiel bestaat wel, maar heeft de game counterstrike niet in bezit/gespeeld
  58.            
  59.             Alert("This profile doesn't have the game counterstrike, Error code 43");
  60.            
  61.         }
  62.  
  63.         // Haal variablen op uit JSON
  64.         $personname = $jsonforuser['response']['players'][0]['personaname'];
  65.         $urlAvatar = $jsonforuser['response']['players'][0]['avatarfull'];
  66.         $urlProfile = $jsonforuser['response']['players'][0]['profileurl'];
  67.         $profilestate = $jsonforuser['response']['players'][0]['personastate'];
  68.        
  69.         $kills = $jsonforgame['playerstats']['stats'][0]['value'];
  70.         $deaths = $jsonforgame['playerstats']['stats'][1]['value'];
  71.         $kdr = $kills/$deaths;
  72.        
  73.         $headshot = $jsonforgame['playerstats']['stats'][25]['value'];
  74.         $fired = $jsonforgame['playerstats']['stats'][46]['value'];
  75.         $hit = $jsonforgame['playerstats']['stats'][47]['value'];
  76.         $accuracy =  $hit/$fired;
  77.         $accuracypercentage = $accuracy * 100; 
  78. ?>
Advertisement
Add Comment
Please, Sign In to add comment