Files
youlegames/codes/agent/game-docker/api/source/login/login_tj.php
2026-04-10 16:44:13 +08:00

187 lines
5.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<link href="css/style.css" rel="stylesheet">
<link href="css/bootstrap.min.css" rel="stylesheet">
<script language="JavaScript" src="js/jquery-2.1.4.min.js"></script>
<script language="JavaScript" src="js/common.js"></script>
<title>授权登录</title>
</head>
<?php
require_once dirname(__FILE__) . '/common.php';
/// 获取参数GET
$app_id = isset($_GET['app_id']) ? $_GET['app_id'] : ''; /// appid
$dev_key = isset($_GET['dev_key']) ? $_GET['dev_key'] : ''; /// 开发者key
$market_key = isset($_GET['market_key']) ? $_GET['market_key'] : ''; /// 门店key
$login_type = isset($_GET['login_type']) ? $_GET['login_type'] : ''; /// 登陆方式
$redirect_uri = isset($_GET['redirect_uri']) ? $_GET['redirect_uri'] : ''; /// 回调页面地址
$error_uri = isset($_GET['error_uri']) ? $_GET['error_uri'] : ''; /// 错误页面地址
$scode = isset($_GET['scode']) ? $_GET['scode'] : md5(date('Ymdhis') . rand(1000, 9999)); /// 随机数
$forms = '';
/// 其他的参数
$attach_array = GetAttachParameters(array('app_id','dev_key','market_key','login_type','redirect_uri','error_uri',), $_GET);
$attach_param = ''; /// 链接用的附加参数
$attach_items = ''; /// 创建表单用的附加参数
foreach ($attach_array as $key => $value)
{
$attach_param .= "&{$key}={$value}";
$attach_items .= " <input name=\"{$key}\" type=\"text\" value=\"{$value}\" />" . PHP_EOL;
}
if (empty($redirect_uri))
$redirect_uri = rawurlencode(getLocaleUrl());
if (empty($error_uri))
$error_uri = rawurlencode(dirname(getLocaleUrl()) . '/error.php');
$data = array(
'market_key' => $market_key,
'logintype' => $login_type,
);
$result = json_decode(rawurldecode(SendPost(SITE_API2_DOMAIN . '/api/login/querylist', $data)));
if (empty($result)) /// 为空表示没有获取到任何登录方式
{
$html = <<<EOL
<script>
alert('找不到支援的任何登录方式, 请联系相关管理员!');
</script>
EOL;
}
else /// 正常
{
$third_array = array(); /// 三方认证方式(不需要输入账号密码的方式)
$owner_array = array(); /// 本地认证方式(需要输入账号密码的方式)
foreach ($result as $item)
{
$item = (array)$item;
if (0 != $item['is_third']) /// 三方认证方式
array_push($third_array, $item);
else /// 本地认证方式
array_push($owner_array, $item);
}
$third_count = count($third_array);
$owner_count = count($owner_array);
$third_html = '';
$owner_html = '';
$splitter = '';
$forms = '';
if (0 == $owner_count && 1 == $third_count) /// 只存在一种三方的校验方式则直接跳转到目标连接
{
$url = $third_array[0]['url'] . "?appid={$app_id}&devkey={$dev_key}&scode={$scode}&market_key={$market_key}&target={$redirect_uri}&fail_target={$error_uri}{$attach_param}";
header("Location: {$url}");
exit;
}
/// 如果两种方式都有,则需要分隔元素。
if (0 != $owner_count && 0 != $third_count)
$splitter = <<<EOL
<div class="sigma-content">
<div class="sigma-middle-line">
<span class="sigma-line-text">更多登录方式</span>
</div>
</div>
EOL;
if (0 != $owner_count) /// 如果本地验证方式不为空则需要用于输入账号密码的表单元素。
{
$owner_html = ' <div class="fangshi" id="owner">' . PHP_EOL;
$forms = '';
$index = 0;
foreach ($owner_array as $owner)
{
$index++;
/// 用来提交数据的表单
$forms .= <<<EOL
<form style="display:none;" id="frm{$index}" name="frm{$index}" method="post" action="{$owner['url']}">
<input name="appid" type="text" value="{$app_id}" />
<input name="devkey" type="text" value="{$dev_key}" />
<!--<input name="sscode" type="text" value="{$scode}" />-->
<input name="market_key" type="text" value="{$market_key}" />
<input name="target" type="text" value="{$redirect_uri}" />
<input name="fail_target" type="text" value="{$error_uri}" />
{$attach_items}
</form>
EOL;
/// 用来显示的页面元素
$owner_html .= <<<EOL
<p class="s_row">
<span class="img_tb"><img src="img/zh.png"></span>
<input type="text" placeholder="账号|手机号|邮箱" autofocus>
</p>
<p class="s_row" style="margin-bottom: 30px;">
<span class="img_tb"><img src="img/mm.png"></span>
<input type="text" placeholder="请输入密码">
</p>
<div class="dr_btn">
<button onclick="frm_submit(frm{$index})" class="btn btn-danger">登录</button>
</div>
<div class="wj_row">
<a href="password.php" class="wjmm">忘记密码?</a>
<a href="password_detail.php" class="zczh">没有帐号?立即注册>>></a>
</div>
EOL;
}
$owner_html .= ' </div>' . PHP_EOL;
}
if (0 != $third_count)
{
$third_html = ' <div class="fangshi" id="third">' . PHP_EOL;
$index = 0;
foreach ($third_array as $third)
{
$index++;
$url = $third['url'] . "?appid={$app_id}&devkey={$dev_key}&scode={$scode}&market_key={$market_key}&target={$redirect_uri}&fail_target={$error_uri}{$attach_param}";
$third_html .= <<<EOL
<a class="box" href="{$url}">
<img src="{$third['image']}">
<label>{$third['type_name']}</label>
</a>
EOL;
}
}
$html = $owner_html . $splitter . $third_html;
}
?>
<script>
function frm_submit(form) {
return form.submit();
}
</script>
<body class="body_bg">
<?php echo $forms; ?>
<header class="yl_logo">
<img src="img/yl.png" class="img-responsive">
</header>
<div class="container-fluid">
<?php echo $html; ?>
</div>
</body>
</html>