Advertisement
Guest User

Untitled

a guest
Mar 6th, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. <?php
  2. require 'openid.php';
  3. $_STEAMAPI = "491B84BC11C975F8E38902076C59A79E";
  4. $servername = "localhost";
  5. $username = "goberdns_sadmin";
  6. $password = "iKilledchu12.";
  7. $dbname = "goberdns_steam";
  8.  
  9. try
  10. {
  11. $openid = new LightOpenID('http://gobets.pw/');
  12. if(!$openid->mode)
  13. {
  14. if(isset($_GET['login']))
  15. {
  16. $openid->identity = 'http://steamcommunity.com/openid/?l=english'; // This is forcing english because it has a weird habit of selecting a random language otherwise
  17. header('Location: ' . $openid->authUrl());
  18. }
  19. ?>
  20. <?php
  21. }
  22. elseif($openid->mode == 'cancel')
  23. {
  24. echo 'User has canceled authentication!';
  25. }
  26. else
  27. {
  28. if($openid->validate())
  29. {
  30. $id = $openid->identity;
  31. // identity is something like: http://steamcommunity.com/openid/id/76561197960435530
  32. // we only care about the unique account ID at the end of the URL.
  33. $ptn = "/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/";
  34. preg_match($ptn, $id, $matches);
  35. echo "User is logged in (steamID: $matches[1])\n";
  36.  
  37. $url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=$_STEAMAPI&steamids=$matches[1]";
  38. $json_object= file_get_contents($url);
  39. $json_decoded = json_decode($json_object);
  40.  
  41. foreach ($json_decoded->response->players as $player)
  42. {
  43. echo "
  44. <br/>Player ID: $player->steamid
  45. <br/>Player Name: $player->personaname
  46. <br/>Profile URL: $player->profileurl
  47. <br/>SmallAvatar: <img src='$player->avatar'/>
  48. <br/>MediumAvatar: <img src='$player->avatarmedium'/>
  49. <br/>LargeAvatar: <img src='$player->avatarfull'/>
  50. ";
  51. }
  52. $steamid= $player->steamid;
  53. $conn = new mysqli($servername, $username, $password, $dbname);
  54. if ($conn->connect_error) {
  55. die("Connection failed: " . $conn->connect_error);
  56. }
  57. echo "<br/>Connection successfully\n";
  58. $duplicatecheck = $conn->query("SELECT * FROM members WHERE steamid= '". $steamid ."'");
  59. $num_rows = $duplicatecheck->num_rows;
  60. if ($num_rows > 0)
  61. {
  62. die("<script>location.href = 'http://www.gobets.pw'</script>");
  63. } else {
  64. $sql = "INSERT INTO members VALUES ('','$steamid','0')";
  65. if ($conn->query($sql) === TRUE) {
  66. echo "<br/>Record updated successfully\n";
  67. } else {
  68. echo "<br/>Error updating record: " . $conn->error;
  69. }
  70. }
  71. $conn->close();
  72.  
  73. }
  74. else
  75. {
  76. echo "User is not logged in.\n";
  77. }
  78. }
  79. }
  80. catch(ErrorException $e)
  81. {
  82. echo $e->getMessage();
  83. }
  84. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement