Advertisement
Guest User

Untitled

a guest
Feb 1st, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.61 KB | None | 0 0
  1. if (isset($_GET['login'])){
  2.     require 'openid.php';
  3.     function get_client_ip_env()
  4.     {
  5.         $ipaddress = '';
  6.         if (getenv('HTTP_CLIENT_IP'))
  7.             $ipaddress = getenv('HTTP_CLIENT_IP');
  8.         else if(getenv('HTTP_X_FORWARDED_FOR'))
  9.             $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
  10.         else if(getenv('HTTP_X_FORWARDED'))
  11.             $ipaddress = getenv('HTTP_X_FORWARDED');
  12.         else if(getenv('HTTP_FORWARDED_FOR'))
  13.             $ipaddress = getenv('HTTP_FORWARDED_FOR');
  14.         else if(getenv('HTTP_FORWARDED'))
  15.             $ipaddress = getenv('HTTP_FORWARDED');
  16.         else if(getenv('REMOTE_ADDR'))
  17.             $ipaddress = getenv('REMOTE_ADDR');
  18.         else
  19.             $ipaddress = 'UNKNOWN';
  20.         return $ipaddress;
  21.     }
  22.     $ipaddress=get_client_ip_env();
  23.  
  24.     try {
  25.         require 'SteamConfig.php';
  26.         $openid = new LightOpenID($steamauth['domainname']);
  27.        
  28.         if(!$openid->mode) {
  29.             $openid->identity = 'http://steamcommunity.com/openid';
  30.             header('Location: ' . $openid->authUrl());
  31.         } elseif ($openid->mode == 'cancel') {
  32.             echo 'User has canceled authentication!';
  33.         } else {
  34.             if($openid->validate()) {
  35.                 $id = $openid->identity;
  36.                 $ptn = "/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/";
  37.                 preg_match($ptn, $id, $matches);
  38.                
  39.                 $_SESSION['steamid'] = $matches[1];
  40.                 if (!headers_sent()) {
  41.                             $servername = "localhost";
  42.                             $username = "id4501784_website";
  43.                             $password = "website";
  44.                             $dbname = "id4501784_website";
  45.                            
  46.                             $con = new mysqli($servername, $username, $password, $dbname);
  47.                             if ($con->connect_error) {
  48.                                 die("Connection failed: " . $conn->connect_error);
  49.                             }
  50.                            
  51.                             $json_decoded = $content;
  52.                             foreach ($json_decoded->response->players as $player)
  53.                             {
  54.                                 $sql_fetch_id="SELECT * FROM users WHERE uid = $player->steamid";
  55.                                 $query_id = mysqli($con, $sql_fetch_id);
  56.                                 if(mysqli_num_rows($query_id) == 0)
  57.                                 {
  58.                                     $insert=mysqli_query($con,"INSERT INTO users (uid, name, ip, playerLevel) VALUES (
  59.                                         '".$steamprofile['steamid']."',
  60.                                         '".$steamprofile['personaname']."',
  61.                                         '$ipaddress',
  62.                                         '0'
  63.                                         )");
  64.                                 }
  65.                             }
  66.                            
  67.  
  68.                                
  69.                                
  70.                     header('Location: '.$steamauth['loginpage']);
  71.                     exit;
  72.                 } else {
  73.                     ?>
  74.                     <script type="text/javascript">
  75.                         window.location.href="<?=$steamauth['loginpage']?>";
  76.                     </script>
  77.                     <noscript>
  78.                         <meta http-equiv="refresh" content="0;url=<?=$steamauth['loginpage']?>" />
  79.                     </noscript>
  80.                     <?php
  81.                     exit;
  82.                 }
  83.             } else {
  84.                 echo "User is not logged in.\n";
  85.             }
  86.         }
  87.     } catch(ErrorException $e) {
  88.         echo $e->getMessage();
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement