Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require 'openid.php';
- $_STEAMAPI = "491B84BC11C975F8E38902076C59A79E";
- $servername = "localhost";
- $username = "goberdns_sadmin";
- $password = "iKilledchu12.";
- $dbname = "goberdns_steam";
- try
- {
- $openid = new LightOpenID('http://gobets.pw/');
- if(!$openid->mode)
- {
- if(isset($_GET['login']))
- {
- $openid->identity = 'http://steamcommunity.com/openid/?l=english'; // This is forcing english because it has a weird habit of selecting a random language otherwise
- header('Location: ' . $openid->authUrl());
- }
- ?>
- <?php
- }
- elseif($openid->mode == 'cancel')
- {
- echo 'User has canceled authentication!';
- }
- else
- {
- if($openid->validate())
- {
- $id = $openid->identity;
- // identity is something like: http://steamcommunity.com/openid/id/76561197960435530
- // we only care about the unique account ID at the end of the URL.
- $ptn = "/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/";
- preg_match($ptn, $id, $matches);
- echo "User is logged in (steamID: $matches[1])\n";
- $url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=$_STEAMAPI&steamids=$matches[1]";
- $json_object= file_get_contents($url);
- $json_decoded = json_decode($json_object);
- foreach ($json_decoded->response->players as $player)
- {
- echo "
- <br/>Player ID: $player->steamid
- <br/>Player Name: $player->personaname
- <br/>Profile URL: $player->profileurl
- <br/>SmallAvatar: <img src='$player->avatar'/>
- <br/>MediumAvatar: <img src='$player->avatarmedium'/>
- <br/>LargeAvatar: <img src='$player->avatarfull'/>
- ";
- }
- $steamid= $player->steamid;
- $conn = new mysqli($servername, $username, $password, $dbname);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- echo "<br/>Connection successfully\n";
- $duplicatecheck = $conn->query("SELECT * FROM members WHERE steamid= '". $steamid ."'");
- $num_rows = $duplicatecheck->num_rows;
- if ($num_rows > 0)
- {
- die("<script>location.href = 'http://www.gobets.pw'</script>");
- } else {
- $sql = "INSERT INTO members VALUES ('','$steamid','0')";
- if ($conn->query($sql) === TRUE) {
- echo "<br/>Record updated successfully\n";
- } else {
- echo "<br/>Error updating record: " . $conn->error;
- }
- }
- $conn->close();
- }
- else
- {
- echo "User is not logged in.\n";
- }
- }
- }
- catch(ErrorException $e)
- {
- echo $e->getMessage();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement