forked from jakub/paypal-access-demo
/
verify.php
executable file
·51 lines (39 loc) · 1.33 KB
/
verify.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
<?php
require_once "Auth/OpenID/Consumer.php";
require_once "Auth/OpenID/Store/FileStore.php";
require_once "Auth/OpenID/Extension/AX.php";
require_once "Auth/OpenID/Extension/PAPE.php";
session_start();
$store = new Auth_OpenID_Store_FileStore('./tmp');
$consumer = new Auth_OpenID_Consumer($store);
$scriptPath = implode("/", (explode('/', $_SERVER["REQUEST_URI"], -1)));
$response = $consumer->complete('https://' . $_SERVER["SERVER_NAME"] . $scriptPath . '/verify.php');
$authenticated = false;
if ($response->status == Auth_OpenID_SUCCESS) {
$ax = new Auth_OpenID_Extension_AX_FetchResponse();
$obj = $ax->fromSuccessResponse($response);
$_SESSION['openid_ax'] = $obj->data;
$pape = Auth_OpenID_PAPE_Response::fromSuccessResponse($response);
if ($pape) {
$_SESSION['openid_pape'] = $pape;
}
$msg = "User has been authenticated!";
} elseif ($response->status == Auth_OpenID_CANCEL) {
$msg = "User cancelled authentication.";
} else {
$msg = "User has not been authenticated.";
}
if (isset($_GET['popup'])) {
?>
<h1><?php echo $msg; ?></h1>
<p><i>This window will be closed in 5 seconds.</i></p>
<script>
window.opener.location.href = "index.php";
window.setTimeout(function() {
window.close();
}, 5000);
</script>
<?php
} else {
header('Location: index.php');
}