Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- DATABASE INFO FOR steamids
- 1 userid int(11) //when u have login and register system, here u put user's id
- 2 steamid varchar(30)
- 3 profileurl text
- 4 nickname varchar(50)
- 5 name varchar(50)
- 6 avatar text
- */
- $api = "";
- include 'includes/lightopenid/openid.php';
- // DOWNLOAD IT HERE IF U DONT HAVE IT
- // http://pastebin.com/xqEgaeX9
- mysql_connect("localhost","root","");
- mysql_select_db("steam"); // change steam into your database name
- $my_id = "steam"; //change steam into user's id
- $OpenID = new LightOpenID("localhost");
- if(isset($_GET['disconnect'])) {
- mysql_query("DELETE FROM steamids WHERE userid='$my_id'");
- }
- $query = mysql_query("SELECT * FROM steamids WHERE userid='$my_id'");
- $rows = mysql_num_rows($query);
- if($rows == 0) {
- if(!$OpenID->mode) {
- $OpenID->identity = "https://steamcommunity.com/openid/";
- $logmein = $OpenID->authUrl();
- echo "<a href=$logmein><img src='http://steamcommunity-a.akamaihd.net/public/images/signinthroughsteam/sits_large_noborder.png' /></a>";
- } elseif($openid->mode == 'cancel') {
- echo 'User has canceled authentication!';
- } else {
- $_SESSION['T2SteamAuth'] = $OpenID->validate() ? $OpenID->identity : null;
- $_SESSION['T2SteamID64'] = str_replace("http://steamcommunity.com/openid/id/", "", $_SESSION['T2SteamAuth']);
- if($_SESSION['T2SteamAuth'] !== null) {
- $steamidonly = $_SESSION['T2SteamID64'];
- $query = mysql_query("INSERT INTO steamids VALUES('$my_id','$steamidonly','','','','')");
- }
- header("Location: login_steam.php"); //change it to your file
- }
- } else {
- $resultid = mysql_result($query, 0, 'steamid');
- $getcontent = file_get_contents("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=$api&steamids=$resultid");
- $data = json_decode($getcontent);
- $user_steamid = $data->response->players[0]->steamid;
- $personaname = $data->response->players[0]->personaname;
- $profileurl = $data->response->players[0]->profileurl;
- $avatarfull = $data->response->players[0]->avatarfull;
- $realname = $data->response->players[0]->realname;
- mysql_query("UPDATE steamids SET profileurl='$profileurl', nickname='$personaname', name='$realname', avatar='$avatarfull'");
- //EXAMPLE
- echo "<a href='$profileurl'><img src='$avatarfull' width='50px'></a>
- $personaname<br>
- <a href='?disconnect'><input type='button' value='DISCONNECT'></a> ";
- }
- ?>
Add Comment
Please, Sign In to add comment