Advertisement
I_GRIN_I

Untitled

Apr 5th, 2018
4,490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.72 KB | None | 0 0
  1. <?php
  2. $apiKey = "41A4485DDA5F97E5E31B8BC05EC091E4";
  3. $steam=$_GET['stid'];
  4. $info = "";
  5. if (empty($steam)) {
  6.     $info="ERR_EMPTY";
  7. } else if (preg_match('/^STEAM_0:[01]:[0-9]{2,12}$/', $steam)) {
  8.    
  9.     $steam64 = st32to64($steam);
  10.     $jsonURL =  $steam64;
  11.     $steam32 = $steam;
  12.    
  13. } else if (preg_match('/^http:\/\/steamcommunity.com\/profiles\/\d{17}$/', $steam)) {
  14.    
  15.     preg_match('/^http:\/\/steamcommunity.com\/profiles\/(\d{17})$/', $steam,$steam);
  16.    
  17.     $steam32 = st64to32($steam[1]);
  18.     $jsonURL =  $steam[1];
  19.    
  20. }
  21. else if (preg_match('/^\d{17}$/', $steam)) {
  22.    
  23.     $steam32 = st64to32($steam);
  24.     $jsonURL =  $steam;
  25.    
  26. } else {
  27.     if(empty($info)){
  28.         $info='ERR_NOT_VALID';
  29.     }
  30. }
  31. function st32to64($steam_id)
  32. {
  33.     list( , $m1, $m2) = explode(':', $steam_id, 3);
  34.     list($steam_cid, ) = explode('.', bcadd((((int) $m2 * 2) + $m1), '76561197960265728'), 2);
  35.     return $steam_cid;
  36. }
  37. function st64to32($steam_cid)
  38. {
  39.     $id = array('STEAM_0');
  40.     $id[1] = substr($steam_cid, -1, 1) % 2 == 0 ? 0 : 1;
  41.     $id[2] = bcsub($steam_cid, '76561197960265728');
  42.     if(bccomp($id[2], '0') != 1)
  43.     {
  44.         return false;
  45.     }
  46.     $id[2] = bcsub($id[2], $id[1]);
  47.     list($id[2], ) = explode('.', bcdiv($id[2], 2), 2);
  48.     return implode(':', $id);
  49. }
  50. if($jsonURL){
  51.     $json = file_get_contents("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=$apiKey&steamids=$jsonURL&format=json");
  52.     $json = json_decode($json,true);
  53.     $userdata = $json['response']['players'][0];
  54.     if(empty($userdata)){
  55.         if(empty($info)){
  56.             $info='ERR_PROFILE_NOT_FOUND';
  57.         }
  58.     }
  59. }
  60. if(empty($info)){
  61.     $info='VALID';
  62. }
  63. echo $info;
  64. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement