Skip to content

Latest commit

 

History

History
81 lines (70 loc) · 1.84 KB

auth.php

File metadata and controls

81 lines (70 loc) · 1.84 KB
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
header("HTTP/1.0 307 Temporary redirect");
header('Content-type: text/plain; charset=UTF-8');
start_session();
if (isset($_GET['logout']))
{
header('Location: /');
unset($_SESSION['steamid']);
session_unset();
session_destroy();
print("We have now forgotten your SteamID.\n");
print("You'll have to log in to use this site again.\n\n");
exit(0);
} // if
if (isset($_SESSION['steamid']))
{
// Already logged in.
header('Location: /');
exit(0);
} // if
require_once('openid.php');
if (!isset($_GET['openid_mode']))
{
$url = 'http://steamcommunity.com/openid';
try
{
$openid = new LightOpenID;
$openid->identity = $url;
header('Location: ' . $openid->authUrl());
print("Redirecting you to Steam Community OpenID provider:\n");
print(" $url\n\n");
} // try
catch (ErrorException $e)
{
$msg = $e->getMessage();
print("OpenID library threw an exception:\n $msg\n\n");
header('Location: /');
} // catch
exit(0);
} // if
header('Location: /'); // always going here now.
if ($_GET['openid_mode'] == 'cancel')
print("User has canceled authentication!\n\n");
else
{
$okay = false;
try
{
$openid = new LightOpenID;
$okay = openid->validate();
} // try
catch (ErrorException $e)
{
$msg = $e->getMessage();
print("OpenID library threw an exception:\n $msg\n\n");
} // catch
$m = array();
if (!$okay)
print("User has not logged in!\n\n");
else if (!preg_match('/^.*\/(\d+)$/', $_GET['openid_identity'], $m))
print("User logged in, but we can't figure out SteamID!\n\n");
else
{
$steamid = $m[1];
$_SESSION['steamid'] = $steamid;
print("User logged in! SteamID is $steamid!\n\n");
} // else
} // else
exit(0);
?>