Advertisement
Guest User

userInfo.php

a guest
Jun 28th, 2015
592
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.25 KB | None | 0 0
  1. <?php
  2.  
  3. //We make sure that the user has logged in before attempting to use the Steam API to avoid warnings and wasted resources.
  4. if(isset($_SESSION['steamid'])){
  5.  
  6. include("settings.php");
  7. if (empty($_SESSION['steam_uptodate']) or $_SESSION['steam_uptodate'] == false or empty($_SESSION['steam_personaname'])) {
  8. //We mute alerts from the following line because we do not want to give away our API key in case file_get_contents() throws a warning.
  9. @ $url = file_get_contents("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=".$steamauth['apikey']."&steamids=".$_SESSION['steamid']);
  10. if($url === FALSE) { die('Error: failed to fetch content form Steam. It may be down. Please, try again later.'); }
  11. $content = json_decode($url, true);
  12. $_SESSION['steam_steamid'] = $content['response']['players'][0]['steamid'];
  13. $_SESSION['steam_communityvisibilitystate'] = $content['response']['players'][0]['communityvisibilitystate'];
  14. $_SESSION['steam_profilestate'] = $content['response']['players'][0]['profilestate'];
  15. $_SESSION['steam_personaname'] = $content['response']['players'][0]['personaname'];
  16. $_SESSION['steam_lastlogoff'] = $content['response']['players'][0]['lastlogoff'];
  17. $_SESSION['steam_profileurl'] = $content['response']['players'][0]['profileurl'];
  18. $_SESSION['steam_avatar'] = $content['response']['players'][0]['avatar'];
  19. $_SESSION['steam_avatarmedium'] = $content['response']['players'][0]['avatarmedium'];
  20. $_SESSION['steam_avatarfull'] = $content['response']['players'][0]['avatarfull'];
  21. $_SESSION['steam_personastate'] = $content['response']['players'][0]['personastate'];
  22. if (isset($content['response']['players'][0]['realname'])) {
  23. $_SESSION['steam_realname'] = $content['response']['players'][0]['realname'];
  24. } else {
  25. $_SESSION['steam_realname'] = "Real name not given";
  26. }
  27. $_SESSION['steam_primaryclanid'] = $content['response']['players'][0]['primaryclanid'];
  28. $_SESSION['steam_timecreated'] = $content['response']['players'][0]['timecreated'];
  29. $_SESSION['steam_uptodate'] = true;
  30. }
  31.  
  32. $steamprofile['steamid'] = $_SESSION['steam_steamid'];
  33. $steamprofile['communityvisibilitystate'] = $_SESSION['steam_communityvisibilitystate'];
  34. $steamprofile['profilestate'] = $_SESSION['steam_profilestate'];
  35. $steamprofile['personaname'] = $_SESSION['steam_personaname'];
  36. $steamprofile['lastlogoff'] = $_SESSION['steam_lastlogoff'];
  37. $steamprofile['profileurl'] = $_SESSION['steam_profileurl'];
  38. $steamprofile['avatar'] = $_SESSION['steam_avatar'];
  39. $steamprofile['avatarmedium'] = $_SESSION['steam_avatarmedium'];
  40. $steamprofile['avatarfull'] = $_SESSION['steam_avatarfull'];
  41. $steamprofile['personastate'] = $_SESSION['steam_personastate'];
  42. $steamprofile['realname'] = $_SESSION['steam_realname'];
  43. $steamprofile['primaryclanid'] = $_SESSION['steam_primaryclanid'];
  44. $steamprofile['timecreated'] = $_SESSION['steam_timecreated'];
  45.  
  46.  
  47. }
  48.  
  49.  
  50.  
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement