forked from stevelove/Dope-OpenID
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
79 lines (71 loc) · 2.7 KB
/
index.php
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
<?php
/**
* This file is part of Dope OpenID.
* Author: Steve Love (http://www.stevelove.org)
*
* Some code has been modified from Simple OpenID:
* http://www.phpclasses.org/browse/package/3290.html
*
* Yadis Library provided by JanRain:
* http://www.openidenabled.com/php-openid/
*
* Dope OpenID is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Dope OpenID is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Dope OpenID. If not, see <http://www.gnu.org/licenses/>.
**/
/*
* YOU MUST EDIT THIS LINE
* This must be discoverable by sites like Yahoo to prevent security warnings.
* Make sure this line points to the location of your XRDF file. It must be located
* in the directory you specify as the "trust root". See login.php (line 104).
*/
header('X-XRDS-Location:http://www.stevelove.org/projects/dope-openid/demo/yadis.xrdf');
/*
* Example uses default PHP sessions.
* Feel free to use whatever session management you prefer.
*/
session_start();
if (isset($_GET['openid_mode'])) {
// $_SESSION is used here for example purposes. You can use
// whatever session management method your script uses instead.
// If the user is not logged in, redirect to login script.
if(!isset($_SESSION['loggedin'],$_SESSION['username']) || $_SESSION['username'] == ''){
header("Location: login.php");
exit;
}
}
/*
* This is just a welcome message. Your default index page may differ.
* The second and fourth lines use the ternary operator for conciseness.
* Info: http://us2.php.net/ternary#language.operators.comparison.ternary
*/
$message = "Welcome, ";
$message .= ($_SESSION['loggedin'])?$_SESSION['username']:"guest";
$message .= "!<br /><br />";
$message .= ($_SESSION['loggedin'])?'<a href="logout.php">Log Out</a>':'<a href="login.php">Log In</a>';
/*
* Begin HTML display below.
* Again, this is just an example. Your index page may differ.
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Dope OpenID Demo</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
</head>
<body>
<?php echo $message; ?>
</body>
</html>