<?php $root = realpath($_SERVER["DOCUMENT_ROOT"]); include_once "{$root}/../include/queries.php"; include_once "{$root}/../include/steam_openid.php"; include_once "{$root}/../include/config.php"; $api_key = file_get_contents("{$root}/../api_key.txt"); $open_id_validate = 0; if (!empty($_GET['openid_assoc_handle'])) { $open_id_validate = SteamSignIn::validate(); } $steam_open_id_url = SteamSignIn::genUrl(); if ($open_id_validate) { $_SESSION["steam_id"] = $open_id_validate; query_getUserBySteamID($mysqli, $user_id, $_SESSION["steam_id"]); $redirect_page = strtok($_SERVER['REQUEST_URI'], '?'); if ($user_id == -1) { query_createUser($mysqli, $new_user_id, $_SESSION["steam_id"]); $_SESSION["user_id"] = $new_user_id; $redirect_page = "/profile/"; } else { $_SESSION["user_id"] = $user_id; } $fetch_string = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=" . $api_key . "&steamids=" . $_SESSION["steam_id"]; $user_JSON_data = @file_get_contents($fetch_string); if ($user_JSON_data === FALSE) { header("Location: /error.php"); } $user_data = json_decode($user_JSON_data); if (count($user_data->response->players) == 1) { $player = $user_data->response->players[0];
$db = new DB(); $db->createUser($_SESSION['steamID'], $_POST['email'], $playerSummary['personaname'], $_POST['charity_ID']); // Update session variables $_SESSION['email'] = $_POST['email']; $_SESSION['activated'] = true; header('location: /'); } if (!$atNewUserPage && basename($_SERVER['PHP_SELF']) != 'index.php') { // Redirect to ask for email page if we are not already there header('location: /newAccount.php'); } } // If the user is not logged in at all if (!isset($_SESSION['steamID'])) { // Validate the login with class $loginAttempt = $steamSignIn->validate(); // Echo steam ID if login was successful if ($loginAttempt != '') { include_once 'db.class.php'; $dbclass = new DB(); $db = $dbclass->getConnection(); // Check if the user exists already if ($result = $db->query("SELECT email FROM Users WHERE steamID={$loginAttempt}")) { // Store steam ID $_SESSION['steamID'] = $loginAttempt; // Get more information about the player include_once "SteamAPI.class.php"; $steamAPI = new SteamAPI(); $playerSummary = $steamAPI->getPlayerInfo($loginAttempt); // Store avatar and name print_r($playerSummary);
<?php session_start(); require 'func.php'; if (isset($_SESSION['steamlogin'])) { $steam_login_verify = $_SESSION['steamlogin']; } else { $steam_login_verify = SteamSignIn::validate(); } if (!empty($steam_login_verify)) { $_SESSION['steamlogin'] = $steam_login_verify; echo "<h1>Welcome. <a href=dash.php>Continue</a></h1>"; } else { $steam_sign_in_url = SteamSignIn::genUrl(); echo ' <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <meta name="author" content=""> <title>Signin</title> <!-- Bootstrap core CSS --> <link href="../css/bootstrap.min.css" rel="stylesheet"> <!-- Custom styles for this template -->
<h3>Interested?</h3> <?php if (isset($_GET["logout"])) { session_start(); session_destroy(); session_regenerate_id(TRUE); } session_start(); if (isset($_SESSION["steamid"])) { $steamid = $_SESSION["steamid"]; } error_reporting(E_ALL & ~E_NOTICE); $steamsignin = new SteamSignIn(); if (!isset($steamid)) { $steamid = $steamsignin->validate(); if ($steamid) { $_SESSION["steamid"] = $steamid; } } ?> <h2>Step 1: Sign in through Steam<?php if ($steamid) { ?> <img src="check.png" style="width:60px;" alt="Validated"><?php } ?> </h2> <?php