forked from pouetnet/pouet2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
72 lines (54 loc) · 1.63 KB
/
login.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
<?
require_once("bootstrap.inc.php");
require_once("include_pouet/pouet-user.php");
//$csrf = new CSRFProtect();
if ($_GET["error"])
redirect("error.php?e=".rawurlencode( $_GET["error_description"] ));
if (!$_GET["code"])
{
$_SESSION["__return"] = $_GET["return"];
$sceneID->PerformAuthRedirect();
exit();
}
$rv = null;
$err = "";
try
{
$returnURL = $_SESSION["__return"];
unset($_SESSION["__return"]);
$sceneID->ProcessAuthResponse();
unset($_SESSION["user"]);
session_regenerate_id(true);
$SceneIDuser = $sceneID->Me();
if (!$SceneIDuser["success"] || !$SceneIDuser["user"]["id"])
{
redirect("error.php?e=".rawurlencode("User not found."));
}
$user = PouetUser::Spawn( (int)$SceneIDuser["user"]["id"] );
if (!$user || !$user->id)
{
$entry = glob(POUET_CONTENT_LOCAL."avatars/*.gif");
$r = $entry[array_rand($entry)];
$a = basename($r);
$user = new PouetUser();
$user->id = (int)$SceneIDuser["user"]["id"];
$user->nickname = $SceneIDuser["user"]["display_name"];
$user->avatar = $a;
$user->Create();
$user = PouetUser::Spawn( $user->id );
}
if ( $user->IsBanned() )
{
redirect("error.php?e=".rawurlencode("We dun like yer type 'round these parts."));
}
$_SESSION["user"] = $user;
$currentUserSettings = SQLLib::SelectRow(sprintf_esc("select * from usersettings where id=%d",$user->id));
if ($currentUserSettings)
$ephemeralStorage->set( "settings:".$user->id, $currentUserSettings );
redirect( basename( $returnURL ? $returnURL : "index.php" ) );
}
catch(SceneID3Exception $e)
{
redirect("error.php?e=".rawurlencode( $e->GetMessage() ));
}
?>