<?php
 include '../common/function.php';
$row = Db::table('app_web')
         ->find();

$type=$_GET['type'];
$http_typex=get_http_type();
$appid=$row['APPID'];
$appkey=$row['APPKEY'];
$redirect_uri="&redirect_uri=".$http_typex.$_SERVER['HTTP_HOST']."/user/loginreturn.php?type=".$type;
$typex="&type=".$type;
$url= "https://login.1atech.cn/connect.php?act=login&appid=".$appid."&appkey=".$appkey.$redirect_uri.$typex;
echo $url;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER,0);
    $output = curl_exec($ch);
    $data=  json_decode($output, true);
   echo $data['url'];

$url = $data['url']; // 需要跳转的网页链接 

Header("Location:$url"); 

    curl_close($ch);
function get_http_type()
{
    $http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
    return $http_type;
}
