-
Notifications
You must be signed in to change notification settings - Fork 1
/
common.php
53 lines (45 loc) · 1.42 KB
/
common.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
<?php
require_once("Auth/OpenID.php");
require_once("Auth/OpenID/MemcachedStore.php");
require_once("Auth/OpenID/Consumer.php");
require_once("Auth/OpenID/SReg.php");
require_once("server.php");
if(mysqli_connect_errno()) {
echo "Connection Failed: " . mysqli_connect_errno();
exit();
}
function getScheme() {
$scheme = 'http';
if (isset($_SERVER['HTTPS']) and $_SERVER['HTTPS'] == 'on') {
$scheme .= 's';
}
return $scheme;
}
function getTrustRoot() {
return sprintf("%s://%s:%s%s/",
getScheme(), $_SERVER['SERVER_NAME'],
$_SERVER['SERVER_PORT'],
dirname($_SERVER['PHP_SELF']));
}
function getReturnTo() {
return sprintf("%s://%s:%s%s/finish.php",
getScheme(), $_SERVER['SERVER_NAME'],
$_SERVER['SERVER_PORT'],
dirname($_SERVER['PHP_SELF']));
}
// $skyrates_prefix = "http://skyrates.net/OpenID/index.php/idpage?user=";
$skyrates_discovered = "http://skyrates.net/OpenID/";
$memcache = new Memcache();
$memcache->connect('localhost', 11211) or die("Could not connect to memcached");
$store = new Auth_OpenID_MemcachedStore($memcache);
$consumer = new Auth_OpenID_Consumer($store);
session_start();
if (isset($_SESSION['openid'])) {
$loggedin = true;
$openid = $_SESSION['openid'];
$username = $_SESSION['username'];
$faction = $_SESSION['faction'];
} else {
$loggedin = false;
}
?>