Notice: Undefined offset: 1 in /usr/share/nginx/html/magikidlab/lab/login.php on line 9
Undefined offset: 1
1
<?php
2
ini_set("display_errors", 1);
3
include "../include/lib.php";
4
5
6
$code = get("code");
7
$labPart = explode("---",get("state")) ;
8
$labDomain = $labPart[0];
9
$page = $labPart[1];
Undefined offset: 1
10
if($code){
11
12
$postValue = [
13
"grant_type"=>"authorization_code",
14
"code"=>"$code",
15
"redirect_uri"=>"https://www.magikidroboticslab.com/lab/login.php",
16
"client_id"=>"1kmWBq2Vas6w48grzEIh69e0RsL0ZflYzX9rND28",
17
"client_secret"=>"ck4Uv3cs4nUU3MTb2wQMMT0fehSyts70bMckfZoD"
18
];
19
20
if(strpos("localhost", $_SERVER['HTTP_HOST'])!==false){
21
$postValue = [
22
"grant_type"=>"authorization_code",
23
"code"=>"$code",
24
"redirect_uri"=>"http://localhost/magikidlab/lab/login.php",
25
"client_id"=>"r1NK34Rijb3i3KVkbXSETD0H6ypuHVYBSL3onnQn",
26
"client_secret"=>"5TjEvdCPL6cI0jRPFqTniz0I7UWcwHvTjwGR0WNV"
27
];
28
}
29
30
$token = httpRequest("https://pike13.com/oauth/token",$postValue);
31
$token = json_decode($token,true);
32
if(isset($token["access_token"])){
33
$token = $token["access_token"];
34
}else{
35
$token = false;
36
}
37
38
if($token){
39
40
$staffMembers = httpRequest("https://$labDomain.pike13.com/api/v2/desk/people/me?access_token=$token");
41
$staffMembers = json_decode($staffMembers,true);
42
43
44
$adminToken = "";
45
if(isset($staffMembers["people"])){
46
//$role = $staffMembers["staff_members"][0]["role"];
47
//if($role=="primary_owner" || $role=="owner" || $role=="manager" || $role=="staff_member"){
48
$adminToken = md5($token.$labDomain."f3f25gLab");
49
//}
50
}
51
52
//$_SESSION["Account"] = $userInfo;
53
54
// $adminToken = "";
55
// foreach($userInfo as $a){
56
// if($a['subdomain'] == $labDomain || ($labDomain=="lab" && $_SERVER['HTTP_HOST']=='localhost')){
57
// if($a["role"]=="primary_owner" || $a["role"]=="owner" || $a["role"]=="manager" || $a["role"]=="staff_member"){
58
// $adminToken = md5($token."f3f25gLab");
59
// }
60
// }
61
// }
62
63
//跳转
64
if(strpos("localhost", $_SERVER['HTTP_HOST'])!==false){
65
echo "<script>";
66
echo "localStorage.token='".$token."';";
67
if($adminToken){
68
echo "localStorage.admin_token='$adminToken';";
69
}
70
echo "localStorage.lab='".$labDomain."';";
71
echo "location.href='https://".$_SERVER['HTTP_HOST']."/magikidlab/lab/#$page'";
72
echo "</script>";
73
}else{
74
echo "<script>";
75
echo "localStorage.token='".$token."';";
76
if($adminToken){
77
echo "localStorage.admin_token='$adminToken';";
78
}
79
80
$labDomainDic = [
81
'magikidirvinelab'=>"irvine",
82
'magikidstudiocitylab'=>"studiocity",
83
'magikidtorrancelab'=>"torrance",
84
'magikidclaremontlab'=>"claremont",
85
'magikidlakeforestlab'=>"lakeforest"
86
];
87
88
echo "localStorage.lab='".$labDomain."';";
89
echo "location.href='https://".$_SERVER['HTTP_HOST']."/".$labDomainDic[$labDomain]."/#$page'";
90
echo "</script>";
91
}
92
}
93
}
94
95
?>
96
97
<style>
98
99
.bussiness{
100
padding:10px;
101
border:1px solid #666;
102
border-radius: 5px;
103
margin-bottom: 4px;
104
cursor: pointer;
105
font-family: "Helvetica","Arial";
106
}
107
108
</style>