-
Notifications
You must be signed in to change notification settings - Fork 10
/
server.class.php
35 lines (30 loc) · 1.07 KB
/
server.class.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
<?php
require(dirname(__FILE__).'/config.php');
ini_set('error_reporting',E_ALL);ini_set('display_errors',true);
class Sso_Server {
function __construct() {
global $conf;
$this->pdo = new PDO('mysql:host='.$conf['db']['hostSpec'].';dbname='.$conf['db']['dbName'],$conf['db']['dbUser'],$conf['db']['dbPass']);
$this->pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
}
function getAccount($hash,$cookie) {
$query='select * from connections where hash=? and cookie=?';
$sth=$this->pdo->prepare($query);
$sth->execute(array($hash,$cookie));
if ($account=$sth->fetch()) {
return $account;
} else {
return false;
}
}
function createAccount($hash,$cookie) {
$query='insert into connections (hash,cookie,loggedin) values (?,?,0)';
$sth=$this->pdo->prepare($query);
$sth->execute(array($hash,$cookie));
}
function updateAccount($hash,$cookie,$loggedin,$email) {
$query='update connections set email=?, loggedin=? where hash=? and cookie=?';
$sth=$this->pdo->prepare($query);
$sth->execute(array($email,$loggedin,$hash,$cookie));
}
}