diff --git a/login.php b/login.php index 4416d89..a80def3 100644 --- a/login.php +++ b/login.php @@ -6,7 +6,7 @@ * @wx 123456 * @qq 123456 --> -store_result(); 我已阅读并同意 用户协议及隐私协议 登 录 -
-
+
+
Linux.Do登录 -
Linux.do登录
+
Linux.do
+
+
+ 奶昔登录 +
奶昔登录
@@ -127,8 +131,13 @@ $stmt->store_result(); switchBtn = $('#switchBtn'); const linuxdoConnect = $("#linuxdoConnect") linuxdoConnect.click(()=>{ - location.href="https://connect.linux.do/oauth2/authorize?response_type=code&client_id=tfKevot5lSwB5A5gcqPQMMhaXDLjib0P" + location.href="https://connect.linux.do/oauth2/authorize?response_type=code&client_id=fqAFU2cQVWtM3CiSLWZEzHb1nFw6evlY" }) + const naixiConnect = $("#naixiConnect") + naixiConnect.click(()=>{ + location.href="https://auth.naixi.net/login/oauth/authorize?client_id=6c597d1551b868dce9fe&redirect_uri=http://cq.eb.cx/naixi_callback&response_type=code&scope=profile&state=STATE" + }) + var isPhone = isMobile(), agent_id = getQueryString('agent_id'), codeOpen = , diff --git a/naixi_callback.php b/naixi_callback.php new file mode 100644 index 0000000..9e03c7f --- /dev/null +++ b/naixi_callback.php @@ -0,0 +1,183 @@ +'https://auth.naixi.net', + 'client_id' => '6c597d1551b868dce9fe', + 'client_secret' => '065b759106ce704cb49082b9ebc790266f4e7105' +]; +// cURL 函数 +function get_curl($url, $post = 0, $referer = 0, $cookie = 0, $header = 0, $ua = 0, $nobaody = 0, $addheader = 0) +{ + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + $httpheader[] = "Accept: */*"; + $httpheader[] = "Accept-Encoding: gzip,deflate,sdch"; + $httpheader[] = "Accept-Language: zh-CN,zh;q=0.8"; + $httpheader[] = "Connection: close"; + if ($header) { + $httpheader = array_merge($httpheader, $header); + } + curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader); + if ($post) { + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $post); + } + if ($header) { + curl_setopt($ch, CURLOPT_HEADER, false); + } + if ($cookie) { + curl_setopt($ch, CURLOPT_COOKIE, $cookie); + } + if ($referer) { + if ($referer == 1) { + curl_setopt($ch, CURLOPT_REFERER, ''); + } else { + curl_setopt($ch, CURLOPT_REFERER, $referer); + } + } + if ($ua) { + curl_setopt($ch, CURLOPT_USERAGENT, $ua); + } else { + curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"); + } + if ($nobaody) { + curl_setopt($ch, CURLOPT_NOBODY, 1); + } + curl_setopt($ch, CURLOPT_ENCODING, "gzip"); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + $ret = curl_exec($ch); + curl_close($ch); + return $ret; +} + +$code = $_GET['code']; +$header = []; +$post = http_build_query([ + 'grant_type' => 'authorization_code', + 'code' => $code, + "client_id"=> $_LINUXDO_CONNECT["client_id"], + "client_secret"=> $_LINUXDO_CONNECT["client_secret"], +]); + +$getTokenRes = get_curl($_LINUXDO_CONNECT["base"].'/api/login/oauth/access_token', $post, 0, 0, $header); + +$getTokenArr = json_decode($getTokenRes, true); + +if (isset($getTokenArr['access_token'])) { + $access_token = $getTokenArr['access_token']; + + $header = [ + 'Authorization: Bearer ' . $access_token + ]; + + $getUserRes = get_curl($_LINUXDO_CONNECT["base"].'/api/userinfo', 0, 0, 0, $header); + $getUserArr = json_decode($getUserRes, true); +} else { + $err = json_encode($getTokenArr); +} + +?> + + + + + + + + + + + + + + + + + + + + + <?= $_CONFIG['game_name'] ?> <?= $_CONFIG['game_description'] ?> + + + + + + + + + + + + + + + 授权发生异常: + + + + \ No newline at end of file