Quantcast
Channel: Forum Pasja Informatyki - Najnowsze pytania i odpowiedzi
Viewing all articles
Browse latest Browse all 83252

Rejestracja przez steam.

$
0
0

Witam! Mam problem z logowaniem/rejestracja przez steam robię stronę typu jackpot
i mam problem gdyż wyskakuje mi że w czwartej linijce poniższego kodu niedziała
$db_user = "root". Jest to plik dp.php

<?php

	$db_host = "localhost"
	$db_user = "root"
	$db_password = ""
	$db_name = "steam"

?>

A poniżej kod odpowiadający za rejestracje i włożenie wszystkiego do bazy danych.

<?php
				require 'lightopenid/openid.php';
				include_once("db.php");
 
				$_STEAMAPI = "Tu jest muj steam api";
				try {
				$openid = new LightOpenID('');
				if(!$openid->mode) {
                if(isset($_GET['login'])) {
                    $openid->identity = 'http://steamcommunity.com/openid/?l=english';
                    header('Location: ' . $openid->authUrl());
                } else {
              
                                echo "<form action='?login' method='post'>";
                                echo "<input type='image' src='http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_large_noborder.png'>";
                                echo "</form>";
                }
				} 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);
 
                $url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=$_STEAMAPI&steamids=$matches[1]";
                $json_object= file_get_contents($url);
                $json_decoded = json_decode($json_object);
 
                foreach ($json_decoded->response->players as $player)
                {
                        $sql_fetch_id = "SELECT * FROM users_steam WHERE steamid = '$player->steamid'";
                                        $query_id = mysqli_query($db, $sql_fetch_id);
 
                                        $_SESSION['name'] = $player->personaname;
                                        $_SESSION['steamid'] = $player->steamid;
                        $_SESSION['avatar'] = $player->avatar;
 
                                        if (mysqli_num_rows($query_id) == 0) {
                                                $sql_steam = "INSERT INTO users_steam (name, steamid, avatar) VALUES  ('$player->personaname', '$player->steamid', '$player->avatar')";
                                                mysqli_query($db, $sql_steam);
                                        }
                }
                } else {
                                echo "User is not logged in.\n";
                }
				}
			} catch(ErrorException $e) {
            echo $e->getMessage();
			}
			?>

 


Viewing all articles
Browse latest Browse all 83252

Latest Images