Advertisement
Guest User

Untitled

a guest
May 25th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.67 KB | None | 0 0
  1. <?php session_start(); ?>
  2. <!DOCTYPE html>
  3. <html>
  4. <?php
  5. require 'include/config.php';
  6. require 'include/common_db.php';
  7. require 'tmp/head.php';
  8. ?>
  9. <body>
  10. <div id="menu-corner">
  11. <?php require 'tmp/menu.php'; ?>
  12. </div>
  13.  
  14. <div id="content">
  15. <?php
  16.  
  17. if(empty($_GET))
  18. header('Location: index.php');
  19.  
  20. require 'include/lightopenid/openid.php';
  21. $_STEAMAPI = "56EB53A80CBC104337A721EA5631360B";
  22. try
  23. {
  24. $openid = new LightOpenID($url);
  25. if(!$openid->mode)
  26. {
  27. if(isset($_GET['login']))
  28. {
  29. if(isset($_SESSION['SteamID']))
  30. header('Location: index.php');
  31.  
  32. $openid->identity = 'http://steamcommunity.com/openid/?l=french'; // This is forcing english because it has a weird habit of selecting a random language otherwise
  33. header('Location: ' . $openid->authUrl());
  34. }
  35.  
  36. }
  37. elseif($openid->mode == 'cancel')
  38. {
  39. echo '<font color="red">Il y\'a eu un problème a la connexion</font>';
  40. }
  41. else
  42. {
  43. if($openid->validate())
  44. {
  45. $id = $openid->identity;
  46. $ptn = "/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/";
  47. preg_match($ptn, $id, $matches);
  48. echo $matches[1];
  49. $url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=$_STEAMAPI&steamids=$matches[1]";
  50. $json_object = file_get_contents($url);
  51. echo $json_object;
  52. $json_decoded = json_decode($json_object);
  53. echo $json_decoded;
  54. foreach ($json_decoded->response->players as $player)
  55. {
  56. // My steamid for testing purposes
  57. $id = $player->steamid;
  58.  
  59. function parseInt($string) {
  60. // return intval($string);
  61. if(preg_match('/(\d+)/', $string, $array)) {
  62. return $array[1];
  63. } else {
  64. return 0;
  65. }}
  66.  
  67. // Convert SteamID64 into SteamID
  68.  
  69. $steamY = parseInt($id);
  70. $steamY = $steamY - 76561197960265728;
  71. $steamX = 0;
  72.  
  73. if ($steamY%2 == 1){
  74. $steamX = 1;
  75. } else {
  76. $steamX = 0;
  77. }
  78.  
  79. $steamY = (($steamY - $steamX) / 2);
  80. $steamID = "STEAM_0:" . (string)$steamX . ":" . (string)$steamY;
  81.  
  82. $_SESSION['SteamID'] = $steamID;
  83. $_SESSION['UserName'] = $player->personaname;
  84. $_SESSION['ProfilLink'] = $player->profileurl;
  85. $_SESSION['Avatar'] = '<img src='.$player->avatar.'/>';
  86. $_SESSION['AvatarFull'] = '<img src='.$player->avatarfull.'/>';
  87. }
  88. $req = $db->query('SELECT * FROM '.$db->prefix.'users WHERE SteamID = "'.$_SESSION['SteamID'].'"');
  89.  
  90. if (!$db->num_rows($req))
  91. $db->query('INSERT INTO '.$db->prefix.'users (`SteamID`, `Admin`) VALUES(\''.$db->escape($_SESSION['SteamID']).'\', \'0\')');
  92. echo '<font color="green">Vous venez de vous connectez ...</font>';
  93. }
  94. else
  95. {
  96. echo "<font color='red'>Vous êtes pas connectez.</font>";
  97. }
  98. }
  99. }
  100. catch(ErrorException $e)
  101. {
  102. echo $e->getMessage();
  103. }
  104.  
  105. if(isset($_GET['deco'])) {
  106. session_destroy();
  107. session_unset();
  108.  
  109. echo '<font color="red">Vous venez de vous deconnectez ...</font>';
  110. echo '<meta http-equiv="refresh" CONTENT="1; URL=index.php"> ';
  111. }
  112. ?>
  113. </div>
  114. <?php require 'tmp/footer.php'; ?>
  115. </body>
  116. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement