Skip to content

Latest commit

 

History

History
90 lines (77 loc) · 2.01 KB

auth.php

File metadata and controls

90 lines (77 loc) · 2.01 KB
 
1
2
3
4
5
<?php
header("HTTP/1.0 307 Temporary redirect");
header('Content-type: text/plain; charset=UTF-8');
Jul 5, 2010
Jul 5, 2010
6
7
require_once('localcfg.php');
Jul 3, 2010
Jul 3, 2010
8
session_start();
9
10
11
12
13
14
15
16
17
18
19
20
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
Jul 5, 2010
Jul 5, 2010
21
22
23
24
25
26
27
// This is set in localcfg.php.
if ($GAllowForceAuth)
{
if (isset($_GET['force']))
$_SESSION['steamid'] = $_GET['force'];
} //if
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
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;
Jul 3, 2010
Jul 3, 2010
67
$okay = $openid->validate();
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
} // 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);
?>