Guest User

Untitled

a guest
Jun 3rd, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.24 KB | None | 0 0
  1. <?php
  2.         /*
  3.         DATABASE INFO FOR steamids
  4.         1       userid  int(11) //when u have login and register system, here u put user's id
  5.         2       steamid varchar(30)
  6.         3       profileurl      text
  7.         4       nickname        varchar(50)
  8.         5       name    varchar(50)    
  9.         6       avatar  text
  10.         */
  11.         $api = "";
  12.         include 'includes/lightopenid/openid.php';
  13.         // DOWNLOAD IT HERE IF U DONT HAVE IT
  14.         // http://pastebin.com/xqEgaeX9
  15.        
  16.         mysql_connect("localhost","root","");
  17.         mysql_select_db("steam"); // change steam into your database name
  18.        
  19.         $my_id = "steam"; //change steam into user's id
  20.         $OpenID = new LightOpenID("localhost");
  21.        
  22.         if(isset($_GET['disconnect'])) {
  23.                 mysql_query("DELETE FROM steamids WHERE userid='$my_id'");
  24.         }
  25.        
  26.         $query = mysql_query("SELECT * FROM steamids WHERE userid='$my_id'");
  27.        
  28.         $rows = mysql_num_rows($query);
  29.        
  30.  
  31.         if($rows == 0) {
  32.                 if(!$OpenID->mode) {
  33.                         $OpenID->identity = "https://steamcommunity.com/openid/";
  34.                         $logmein = $OpenID->authUrl();
  35.                        
  36.                         echo "<a href=$logmein><img src='http://steamcommunity-a.akamaihd.net/public/images/signinthroughsteam/sits_large_noborder.png' /></a>";
  37.                        
  38.                 } elseif($openid->mode == 'cancel') {
  39.                         echo 'User has canceled authentication!';
  40.                 } else {
  41.                         $_SESSION['T2SteamAuth'] = $OpenID->validate() ? $OpenID->identity : null;
  42.                         $_SESSION['T2SteamID64'] = str_replace("http://steamcommunity.com/openid/id/", "", $_SESSION['T2SteamAuth']);
  43.                         if($_SESSION['T2SteamAuth'] !== null) {
  44.                                 $steamidonly = $_SESSION['T2SteamID64'];
  45.                                 $query = mysql_query("INSERT INTO steamids VALUES('$my_id','$steamidonly','','','','')");
  46.                         }
  47.                         header("Location: login_steam.php"); //change it to your file
  48.                 }
  49.         } else {
  50.                 $resultid = mysql_result($query, 0, 'steamid');
  51.                
  52.                 $getcontent = file_get_contents("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=$api&steamids=$resultid");
  53.                 $data = json_decode($getcontent);
  54.                 $user_steamid = $data->response->players[0]->steamid;
  55.                 $personaname = $data->response->players[0]->personaname;
  56.                 $profileurl = $data->response->players[0]->profileurl;
  57.                 $avatarfull = $data->response->players[0]->avatarfull;
  58.                 $realname = $data->response->players[0]->realname;
  59.                 mysql_query("UPDATE steamids SET profileurl='$profileurl', nickname='$personaname', name='$realname', avatar='$avatarfull'");
  60.                
  61.                 //EXAMPLE
  62.                 echo "<a href='$profileurl'><img src='$avatarfull' width='50px'></a>
  63.                $personaname<br>
  64.                <a href='?disconnect'><input type='button' value='DISCONNECT'></a> ";
  65.         }
  66.                
  67. ?>
Add Comment
Please, Sign In to add comment