-
Notifications
You must be signed in to change notification settings - Fork 10
/
auth.php
34 lines (34 loc) · 916 Bytes
/
auth.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
<?php
require(dirname(__FILE__).'/server.class.php');
$server=new Sso_Server();
$loggedin=0;
$hash=$_REQUEST['hash'];
if (isset($_COOKIE['cdsso'])) {
$cookie=$_COOKIE['cdsso'];
$account=$server->getAccount($hash,$cookie);
if ($account===false) {
$server->createAccount($hash,$cookie);
} else {
$loggedin=$account['loggedin'];
}
} else {
$cookie=md5(__FILE__.$hash.microtime()).date('YmdHis');
$server->createAccount($hash,$cookie);
setcookie('cdsso',$cookie, time()+3600*2);
}
$message=json_encode(array('cookie'=>$cookie,'loggedin'=>$loggedin));
?>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript">
if ( window.self !== window.top ) {
window.onload = function(){
parent.socket.postMessage('<?php echo $message;?>');
};
};
</script>
</head>
<body>
</body>
</html>