Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php session_start(); ?>
- <!DOCTYPE html>
- <html>
- <?php
- require 'include/config.php';
- require 'include/common_db.php';
- require 'tmp/head.php';
- ?>
- <body>
- <div id="menu-corner">
- <?php require 'tmp/menu.php'; ?>
- </div>
- <div id="content">
- <?php
- if(empty($_GET))
- header('Location: index.php');
- require 'include/lightopenid/openid.php';
- $_STEAMAPI = "56EB53A80CBC104337A721EA5631360B";
- try
- {
- $openid = new LightOpenID($url);
- if(!$openid->mode)
- {
- if(isset($_GET['login']))
- {
- if(isset($_SESSION['SteamID']))
- header('Location: index.php');
- $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());
- }
- }
- elseif($openid->mode == 'cancel')
- {
- echo '<font color="red">Il y\'a eu un problème a la connexion</font>';
- }
- else
- {
- if($openid->validate())
- {
- $id = $openid->identity;
- $ptn = "/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/";
- preg_match($ptn, $id, $matches);
- echo $matches[1];
- $url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=$_STEAMAPI&steamids=$matches[1]";
- $json_object = file_get_contents($url);
- echo $json_object;
- $json_decoded = json_decode($json_object);
- echo $json_decoded;
- foreach ($json_decoded->response->players as $player)
- {
- // My steamid for testing purposes
- $id = $player->steamid;
- function parseInt($string) {
- // return intval($string);
- if(preg_match('/(\d+)/', $string, $array)) {
- return $array[1];
- } else {
- return 0;
- }}
- // Convert SteamID64 into SteamID
- $steamY = parseInt($id);
- $steamY = $steamY - 76561197960265728;
- $steamX = 0;
- if ($steamY%2 == 1){
- $steamX = 1;
- } else {
- $steamX = 0;
- }
- $steamY = (($steamY - $steamX) / 2);
- $steamID = "STEAM_0:" . (string)$steamX . ":" . (string)$steamY;
- $_SESSION['SteamID'] = $steamID;
- $_SESSION['UserName'] = $player->personaname;
- $_SESSION['ProfilLink'] = $player->profileurl;
- $_SESSION['Avatar'] = '<img src='.$player->avatar.'/>';
- $_SESSION['AvatarFull'] = '<img src='.$player->avatarfull.'/>';
- }
- $req = $db->query('SELECT * FROM '.$db->prefix.'users WHERE SteamID = "'.$_SESSION['SteamID'].'"');
- if (!$db->num_rows($req))
- $db->query('INSERT INTO '.$db->prefix.'users (`SteamID`, `Admin`) VALUES(\''.$db->escape($_SESSION['SteamID']).'\', \'0\')');
- echo '<font color="green">Vous venez de vous connectez ...</font>';
- }
- else
- {
- echo "<font color='red'>Vous êtes pas connectez.</font>";
- }
- }
- }
- catch(ErrorException $e)
- {
- echo $e->getMessage();
- }
- if(isset($_GET['deco'])) {
- session_destroy();
- session_unset();
- echo '<font color="red">Vous venez de vous deconnectez ...</font>';
- echo '<meta http-equiv="refresh" CONTENT="1; URL=index.php"> ';
- }
- ?>
- </div>
- <?php require 'tmp/footer.php'; ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement