Giter Club home page Giter Club logo

steamauthentication's Introduction

SteamAuthentication

SteamAuthentication is a basic set of PHP files that enable users to login using their steam account to view protected content on your website. it creates a session using their steamid as the sessionID and checks for the session when a user visits the page. It also includes a file which allows you to use their profile information such as their avatar and online status.

See a demo at https://bensmith.in/steam/

Gambling Sites

I nor Steam condone the use of this library for the purpose of gambling sites. Any sites that use this library for this purpose violates their API agreement and will receive notices from Steam to cease operations.

Read more here: http://store.steampowered.com/news/22883/

By downloading this library you agree that you will not use it for any gambling or illegal activity.

Issues

For Issues relating directly to this SteamAuthentication Library feel free to create a Github Issue.

For any general PHP or SQL problems please use stackoverflow or similar, else we will generally close these straight away if created here, thanks!

Download

Please note the main repository is constantly being updated so may contain bugs and other bleeding edge risks. For a stable download please visit the releases page: https://github.com/SmItH197/SteamAuthentication/releases

Foreword

Thanks goes to:

Using MySQL? Don't forget to sanitise your inputs!

To Install

Upload the steamauth folder.

Open up SteamConfig.php

Now in the page that you would like to use the steamauth library, add the following at the top:

<?php

require 'steamauth/steamauth.php';

?>

And where you want the protected content to be:

<?php
if(!isset($_SESSION['steamid'])) {

    loginbutton(); //login button

}  else {

    include ('steamauth/userInfo.php'); //To access the $steamprofile array
    //Protected content

    logoutbutton(); //Logout Button
}     
?>

By default, the logout & login buttons reload the current page, this can be changed in the SteamConfig file.

Be aware that naming a file in your webpage root like any file in the steamauth folder will break SteamAuth.

Choosing a login button style

by default loginbutton(); will display image

You can choose the style of the login button by specifying a variable like the following:

loginbutton("rectangle");

image

loginbutton(); -OR- loginbutton("square");

image

Using Profile Variables

I have created a userInfo.php file which creates an array of ready to use variables that includes profile information of the steam user that has logged in:

  • $steamprofile['steamid'] - The user's unique SteamID
  • $steamprofile['communityvisibilitystate'] - This represents whether the profile is visible or not.
  • $steamprofile['profilestate'] - If set, indicates the user has a community profile configured (will be set to '1')
  • $steamprofile['personaname'] - Their current set profile name
  • $steamprofile['lastlogoff'] - Last time the user was online in unix time Check out the wiki for help on converting to date/time
  • $steamprofile['profileurl'] - The URL to their steam profile
  • $steamprofile['avatar'] - The image URL to the smallest size of their avatar (32px x 32px)
  • $steamprofile['avatarmedium'] - The image URL to the medium sized version of their avatar (64px x 64px)
  • $steamprofile['avatarfull'] - The image URL to the largest size of their avatar (184px x 184px)
  • $steamprofile['personastate'] - The user's current state, 1 - Online, 2 - Busy, 3 - Away, 4 - Snooze, 5 - looking to trade, 6 - looking to play
  • $steamprofile['realname'] - The user's "real" name
  • $steamprofile['primaryclanid'] - The user's primary group
  • $steamprofile['timecreated'] - When the account was created in unix time Check out the wiki for help on converting to date/time
  • $_SESSION['steam_uptodate'] - When profile information was last updated in unix time

Please note that some of these variables may be unavailable for some users as it depends on their privacy settings.

Update User Information

To refresh a user's Steam profile data use: html: <a href="?update">update</a> - recommended -OR- php: $_GET['update']=true; - this must be set before require 'steamauth/steamauth.php';

Automatically refresh Steam profile data if older than specified time when they next visit your site

change line 67 of steamauth.php From:

if (isset($_GET['update'])){ 

To:

if (isset($_GET['update']) || !empty($_SESSION['steam_uptodate']) && $_SESSION['steam_uptodate']+(24*60*60) < time()){ 
  • example shown would update if older than 24 hours.

  • the numbers in the brackets $_SESSION['steam_uptodate']+(24*60*60) should be the maximum number of seconds before refreshing a user's Steam Profile data.


For more help on laying out the document or using the $steamprofile variable see the example.php or the demo.php file!

steamauthentication's People

Contributors

andrewda avatar aqqadk avatar blackcetha avatar bman46 avatar comentarinformal avatar creyd avatar maxorlovsky avatar mellamopablo avatar muffinpwner1 avatar obilux avatar redsparr0w avatar segeco avatar smith197 avatar thiritin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

steamauthentication's Issues

Mysql databse issue in userInfo.php

Hey i recently found thius and tried to get it all working and whatnot, i managed to get it so you can click "Login with steam", then login from the demo page, but when after i click "Log In" from the steam page it takes a decent ammount of time to load and then gives me this error:

Warning: file_get_contents(http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=[REMOVED_BY_SmItH197]&steamids=76561198181922383): failed to open stream: Connection timed out in /home/csgomark/public_html/steamauth/userInfo.php on line 4

Deprecated: mysql_real_escape_string(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/csgomark/public_html/steamauth/userInfo.php on line 9

Warning: mysql_real_escape_string(): Access denied for user 'root'@'localhost' (using password: NO) in /home/csgomark/public_html/steamauth/userInfo.php on line 9

Warning: mysql_real_escape_string(): A link to the server could not be established in /home/csgomark/public_html/steamauth/userInfo.php on line 9

If you could tell me what im doing wrong i would really apprecite it as i cant find the answer anywhere else and i am fairly new to this.

Also i am using a free hosting site to host this - X10hosting - They support mysql and have databases and stuff, sorry for being a pain...

Thanks,
Cam

steam persona, possible mysql injection

It's just a note, but if someone updates the steam persona directly in a mysql_query (without using mysql_real_escape_string like me :( ), if the persona contains an ' mark, it'd override everyone's persona in the database, or even worse.

Redirects to wrong page after logout

Currently logout.php will redirect you to a page a directory above the actual target.
You can easily fix that with modifying logout.php at line 3 to look like this:
header("Location: ./".$logout_page);

Remember me login

Hi ^^
I need a "remember me login" feature on my website, can you help me ?

Demo page still down

After about three month the demo site is still unavailable.
I would continue hosting it on my own server if thats an option.

Not working after i log-in

Hello, I am making a TF2 trading website and everything works fine when i'm not logged in. But when i log-in this doesn't echo:

require 'steamauth/steamauth.php';
require 'steamauth/userInfo.php';

if (!isset($_SESSION['steamid'])) {
echo "You need to log-in first.";
}

else {
echo "Test";
}

Logout on seperate page

Im having issues putting a logout button on a seperate page.

I have a cover page where the user logs in and is then redirected to the main page. But the logout button on that page does not work.

302 Redirect loop

After Steam authentication, I get a 302 redirection loop. It will occasionally work, but for the most part a Ctrl+F5 is what it takes to make it go through. It happens in Firefox 33.1 and Chrome 39, but not in Explorer 11.

Update SteamAuth-version used in demo page

As far as I can see, you're using a pretty old version in the demo page. Even tho it works, i would recommend updating it for performance reasons and to show new stuff eventually.

stuck on /?login

Hi, I put a login button in the index.php but it's doing nothing and get stuck on /?login.
It work on the example.php but not on the index.php

Storing steamid in mysql

is there any way i can get the steamid of a user and store it in my mysql database as soon as he logs in?

Proper way of using this with CodeIgniter?

First of all, great work, it works great!
Well it does in a standalone application.

I'm trying to get this to work with CodeIgniter, and I sort of did it but can only use the session variables ($_SESSION['steamid'], etc) and not the $steamprofile variable.

I've put the files in the "helper" directory, renamed "steamauth.php" to "steamauth_helper.php", and made it auto load. Then I copied the code from "userInfo.php" and pasted it in "steamauth_helper.php" inside the "if($openid->validate())" section (so it is run when logged in successful).

Like I said: it properly shows the button, logs me in and everything, but I can only use the session variables.
Is it maybe possible to make a proper hook or library from this that I can use? Yes it works but it feels kinda like a hack which I rather not do when possible.

file_get_contents returning "Connection timed out"

Besides the mysql errors you have in 50 other issues probably, I keep getting this one:

Warning: file_get_contents(http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=&steamids=): failed to open stream: Connection timed out in /home/ibreakzo/public_html/libs/steamauth/userInfo.php on line 4

If there is any known fix for this that I cannot seem to find (I have been doing hours of research, literally), PLEASE let me know.

Thank you and have a wonderful rest of your afternoon!

No OpenID Server found.

If I use this, I get the error "No OpenID Server found at http://steamcommunity.com/openid"
How to fix it, It just replaces the button with this whenever you press on it, after 1 minute waiting..

Thanks to all the makers, You are amazing! It worked before..

The login button doesn't work on my website, but works localhost

The title says most of my issue... I managed to set it up to work on my localhost using xampp. However when I upload it and click the login button, I return to the same url with "?login" tacked at the end (of the url). I am not sure what the issue is, I changed setting to redirect to my domain name (and not local host), but I am without a clue.

Here's some of my host's info: http://i.imgur.com/kpJWCEZ.png
And here's a link to my site, with the issue: http://potders.com/awesome-stats/

Page not found on login

When i place the code in certain places on my site i get a page not found error when i click the login button. But there are places where i can place the code and it will work.

"; echo "here is your avatar:
" . '

'; // Display their avatar! logoutbutton(); ``` } ?>

Logging in problem

After logging in, this error always displayed (and it has a typo):
"Error: failed to fetch content form Steam. It may be down. Please, try again later."

...and the logout button is not displayed, so I have to comment out the "include('steamauth/userInfo.php'); line to get the logout button back once I've attempted to log in already.

Create new Release

Since the version since the pull request is NOT backward-compatible with the previous versions, i would suggest finally creating a new release.

Logout site

Does not work. Removing the dot before the header works!

Completely broken right now

#66 completely broke the link-generation.
The way @MeLlamoPablo wanted to carry $_GET-variables through the steam login-screen is not possible since steam strips them from the string.

Already working on a fix.

userInfo.php Error Log

It gives a error log if the user is not logged in PHP Notice: Undefined index: lastlogoff in. So for example someone clicks on the profile page and not logged in the error will show up. But it wont if the person is logged in. Any idea why this is happening?

"User is not logged in" error

I am always getting the User is not logged in error. Is this something with steam? I already tried the older versions but those also aren't working.

Do you know what is causing this error?

License

What is the license of the library?

Login from a page that need initial value?

Hi i needed to implement a steam login in my webpage and this project solved my problems, but now i got an issue. It worked well in "static" pages but when i need to login from a page that need an initial "get value" like a search page it simply doesn't work. When i hit the login button the page ask me for a value to search and doesn't proceed to the login redirect.

The problem is that the button calls a "?login" form action and it clear the get values of the actual page.

Thanks!

PD: I'm using 2.1.3 release.

Session Timeout

I'm having a problem where the session times out extremely fast. How can I increase session time of SteamAuth or make the session permanent? I understand you aren't obligated to give support but this really is a simple thing that nobody on Stackoverflow wants to help me with.

Typo in the Readme

There is a typo that makes it harder to understand part of the installation process.

mysql_real_escape_string() error

Following errors:

Deprecated: mysql_real_escape_string(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/public_html/steamauth/userInfo.php on line 9

Warning: mysql_real_escape_string(): Access denied for user 'root'@'localhost' (using password: NO) in /home/public_html/steamauth/userInfo.php on line 9

Warning: mysql_real_escape_string(): A link to the server could not be established in /home/public_html/steamauth/userInfo.php on line 9

ignoring session_start() - soslidesigns

So far the plugin works great but I get the following error.PHP Notice: A session had already been started - ignoring session_start() in would be nice if it didn't show up that seems to be the only error in this script you got.

userInfo.php - check if realname exists

If the user didn't set his realname, the steam api won't show it in the content, and a notice "Undefined index: realname in .." will be displayed. Not a big issue, but worth fixing it with isset.

Undefined variable and MySQL

I get these errors in my log whenever I try and use PHP to submit to the DB

Errors:

  PHP Notice:  Undefined variable: _SESSION in /home11/example/public_html/steamauth/userInfo.php on line 4
  PHP Notice:  Undefined offset: 0 in /home11/example/public_html/steamauth/userInfo.php on line 6
  PHP Notice:  Undefined offset: 0 in /home11/example/public_html/steamauth/userInfo.php on line 7
  PHP Notice:  Undefined offset: 0 in /home11/example/public_html/steamauth/userInfo.php on line 8
  PHP Notice:  Undefined offset: 0 in /home11/example/public_html/steamauth/userInfo.php on line 9
  PHP Notice:  Undefined offset: 0 in /home11/example/public_html/steamauth/userInfo.php on line 10
  PHP Notice:  Undefined offset: 0 in /home11/example/public_html/steamauth/userInfo.php on line 11
  PHP Notice:  Undefined offset: 0 in /home11/example/public_html/steamauth/userInfo.php on line 12
  PHP Notice:  Undefined offset: 0 in /home11/example/public_html/steamauth/userInfo.php on line 13
  PHP Notice:  Undefined offset: 0 in /home11/example/public_html/steamauth/userInfo.php on line 14
  PHP Notice:  Undefined offset: 0 in /home11/example/public_html/steamauth/userInfo.php on line 15
  PHP Notice:  Undefined offset: 0 in /home11/example/public_html/steamauth/userInfo.php on line 21
  PHP Notice:  Undefined offset: 0 in /home11/example/public_html/steamauth/userInfo.php on line 22

PHP code:

  <?php
  include ('steamauth/userInfo.php');

  $servername = "myserver";
  $username = "myname";
  $password = "mypass";
  $dbname = "mydb";

  // Create connection
  $conn = mysqli_connect($servername, $username, $password, $dbname);
  // Check connection
  if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
  }

  $sql="INSERT INTO enterw (weekly) VALUES ('" . $steamprofile['steamid'] . "')";

  if ($conn->query($sql) === TRUE) {
  echo "Success";
  } else {
  echo "Error: " . $sql . "<br>" . $conn->error;
  }

  $conn->close();

  ?>

As a result I only get 0 submitted to the DB, how would I go about fixing this?

Not working at all

Hi there! This code is exactly what I need for my website I'm grateful that you have made it available, though as of now, I can't get it to work. I have followed all the instructions and have come to no fruition.
With everything set as I believe it should be, when I test my site I get just a blank page.
I don't believe this is an error on my side, but if it is, sorry for reporting it as an error in code.

If you wish to check my files to see this is a new coding error, here they are:

Settings.PHP : http://gyazo.com/5ad364462a8be46ea0cc91472d97f08f
DreamWeaver File & Code : http://gyazo.com/c0441de71442cf68b53323d6b10e0385
Result when run : http://gyazo.com/7bc06fb723bb1281681358b0f4902c36

I also tested the demo code, and the button and steam login also didn't work.
Demo.html : http://gyazo.com/2e6250192a7e8d3c417e3359bb42e8e0

The rest of the .PHP files are unchanged.

Warning: session_start() Cannot send session cache limiter - headers already sent

Hi Guys, If I try to do:

<?php
    require ('steamauth/steamauth.php'); 
    include ('steamauth/userInfo.php');
    if(!isset($_SESSION['steamid'])) { }
    else {
    $userdbfile = file('userfiles/' . $steamprofile['steamid'] . '.txt');   
    }
?>

I get:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at %path%/public_html/beta/index.php:2) in %path%/steamauth/steamauth.php on line 2

(%path is replaced with the path..)

Thanks for everything, Keep up the work!

Not logging in correctly, using example.php

(Sorry, new to site and php!)

Directories are correct but when I try to log in, I get redirected to the steam website, log in, then redirected back, only to see "welcome guest! please login User is not logged in.". Its not running the code inside this if statement? if($openid->validate()) Probably not an issue but me being dumb but help would be appreciated :)

ssl error, using example.php

i have followed the instructions and have changed api key in both the places still getting this error.

welcome guest! please login error:14077458:SSL routines:SSL23_GET_SERVER_HELLO:reason(1112)

Looking to get achievement data with SteamAuthentication

Hello everyone,

I am wondering if it is possible to use this tool to get Steam Achievement data. Achievement data can be found at the following location below. This is just an example for a single game. XXXXXX is the developer key.

http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0001/?appid=204300&key=XXXXXX&steamid=76561198031677651?xml=1

If the dev key is entered, you'll see my personal achievements and stats for this game. However, if my profile were private, I would not be able to pull achievement or statistical data. Is there any way around this using this tool? I know Steam Authentication normally can get you achievement info.

Thanks.

use in wordpress

hi ,
sry for bad english .
i need use your SteamAuth in wordpress pls tell me how to use ?

Cannot modify header information - Also occurs on demo site

The following error code may occur when attempting to sign in:

Warning: Cannot modify header information - headers already sent by (output started at /index.php:10) in /steamauth/steamauth.php on line 19

This issue is currently occurring on the demo site, I will attempt to fix it as soon as possible!

Useless API key in steamauth.php

Hello,

My question is in regards to this step in steamauth.php:
Now find $api_key on line 5 and set it to the api key you got from http://steamcommunity.com/dev/apikey .

I don't see the need for it, the variable $api_key is never used. The only time $api_key is needed is in userinfo.php.

Let me know if I'm wrong! Great script overall, thank you!

"Couldn't connect to host"

You did really good job there. Good work :), but unfortunately it doesn't work for me :(.
I followed your instructions and used example.php as my index.php. When I click "Sign in through steam" it doesn't redirect to the steam page, but it shows me "Couldn't connect to host".
By the way, does SteamAuthentication use curl? Maybe that's the problem becouse my hosting doesn't support it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.