Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (isset($_GET['login'])){
- require 'openid.php';
- require 'userInfo.php';
- function get_client_ip_env()
- {
- $ipaddress = '';
- if (getenv('HTTP_CLIENT_IP'))
- $ipaddress = getenv('HTTP_CLIENT_IP');
- else if(getenv('HTTP_X_FORWARDED_FOR'))
- $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
- else if(getenv('HTTP_X_FORWARDED'))
- $ipaddress = getenv('HTTP_X_FORWARDED');
- else if(getenv('HTTP_FORWARDED_FOR'))
- $ipaddress = getenv('HTTP_FORWARDED_FOR');
- else if(getenv('HTTP_FORWARDED'))
- $ipaddress = getenv('HTTP_FORWARDED');
- else if(getenv('REMOTE_ADDR'))
- $ipaddress = getenv('REMOTE_ADDR');
- else
- $ipaddress = 'UNKNOWN';
- return $ipaddress;
- }
- $ipaddress=get_client_ip_env();
- try {
- require 'SteamConfig.php';
- $openid = new LightOpenID($steamauth['domainname']);
- if(!$openid->mode) {
- $openid->identity = 'http://steamcommunity.com/openid';
- header('Location: ' . $openid->authUrl());
- } elseif ($openid->mode == 'cancel') {
- echo 'User has canceled authentication!';
- } else {
- if($openid->validate()) {
- $id = $openid->identity;
- $ptn = "/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/";
- preg_match($ptn, $id, $matches);
- $_SESSION['steamid'] = $matches[1];
- if (!headers_sent()) {
- $servername = "localhost";
- $username = "id4501784_website";
- $password = "website";
- $dbname = "id4501784_website";
- $con = new mysqli($servername, $username, $password, $dbname);
- if ($con->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $json_decoded = $content;
- foreach ($json_decoded->response->players as $player)
- {
- $sql_fetch_id="SELECT * FROM users WHERE uid = $player->steamid";
- $query_id = mysqli($con, $sql_fetch_id);
- if(mysqli_num_rows($query_id) == 0)
- {
- $insert=mysqli_query($con,"INSERT INTO users (uid, name, ip, playerLevel) VALUES (
- '".$steamprofile['steamid']."',
- '".$steamprofile['personaname']."',
- '$ipaddress',
- '0'
- )");
- }
- }
- header('Location: '.$steamauth['loginpage']);
- exit;
- } else {
- ?>
- <script type="text/javascript">
- window.location.href="<?=$steamauth['loginpage']?>";
- </script>
- <noscript>
- <meta http-equiv="refresh" content="0;url=<?=$steamauth['loginpage']?>" />
- </noscript>
- <?php
- exit;
- }
- } else {
- echo "User is not logged in.\n";
- }
- }
- } catch(ErrorException $e) {
- echo $e->getMessage();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement