Last active
November 26, 2020 07:01
-
-
Save Mo45/404b1b405bcbfd6b0891d02b8b1b897b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (session_status() === PHP_SESSION_NONE) { | |
session_start(); | |
} | |
function logoutbutton() { | |
echo "<form action='' method='get'><button name='logout' type='submit'>Logout</button></form>"; //logout button | |
} | |
function loginbutton($buttonstyle = "square") { | |
$button['rectangle'] = "01"; | |
$button['square'] = "02"; | |
$button = "<a href='?login'><img src='http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_".$button[$buttonstyle].".png'></a>"; | |
echo $button; | |
} | |
if (isset($_GET['login'])){ | |
if (isset($_GET['r'])){$redir = $_GET['r'];}; | |
require 'openid.php'; | |
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 = "/^https:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/"; | |
preg_match($ptn, $id, $matches); | |
$_SESSION['steamid'] = $matches[1]; | |
if (!headers_sent()) { | |
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(); | |
} | |
} | |
if (isset($_GET['logout'])){ | |
require 'SteamConfig.php'; | |
session_unset(); | |
session_destroy(); | |
header('Location: '.$steamauth['logoutpage']); | |
exit; | |
} | |
//if (isset($_GET['update'])){ | |
if (isset($_GET['update']) || !empty($_SESSION['steam_uptodate']) && $_SESSION['steam_uptodate']+(24*60*60) < time()){ | |
unset($_SESSION['steam_uptodate']); | |
require 'userInfo.php'; | |
header('Location: '.$_SERVER['PHP_SELF']); | |
exit; | |
} | |
// Version 3.2 | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment