1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| <?php
require 'openid.php';
include ($_SEVER["DOCUMENT_ROOT"]."/php/sql_conect.php");
$_STEAMAPI = "9BA24274F7B37157598FA0B0329286F0";
try
{
$openid = new LightOpenID('http://fluffy-online.com/');
if(!$openid->mode)
{
if(isset($_GET['login']))
{
$openid->identity = 'http://steamcommunity.com/openid/?l=french'; // 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'/>
";
}
$id = $player->steamid;
$name = $player->personaname;
$steam = $player->profileurl;
$avatar = $player->avatarmedium;
$avatar_big = $player->avatarfull;
}
else
{
echo "User is not logged in.\n";
}
}
$request ="INSERT into 'users' (ID_STEAM, PSEUDO, STEAM, AVATAR, AVATAR_BIG)
VALUES ('$id','$name','$steam','$avatar','$avatar_big')";
$result =$mysqli->query($request) or die ('Error'.$request' '.$mysqli->error());
$mysqli->close();
}
catch(ErrorException $e)
{
echo $e->getMessage();
}
?> |
Partager