88 lines
2.3 KiB
PHP
88 lines
2.3 KiB
PHP
<?php
|
|
/**
|
|
* 数据中心校验用户
|
|
**/
|
|
|
|
class Userverification
|
|
{
|
|
|
|
|
|
//浅层未充值用户检验
|
|
public function lurkingCheck($userName,$avatar){
|
|
$userType = $this->check($userName,$avatar);
|
|
if($userType==4 || $userType==5 || $userType==6 || $userType==8 || $userType==11 || $userType==12){
|
|
return $userType;
|
|
}else{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public function check($userName,$avatar){
|
|
$url = 'http://dc.cswangmwl.com/api/v1/dc/checkUser';
|
|
$arr = array(
|
|
'userName'=>$userName,
|
|
'avatar'=>$avatar,
|
|
);
|
|
$arr = json_encode($arr);
|
|
$res = $this->pushMessageToClient($url,$arr);
|
|
$res = json_decode($res,true);
|
|
if($res['code']=='200'){
|
|
return $res['result']['userType'];
|
|
}else{
|
|
$this->wrlog($res);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public function cscheck($userName,$avatar){
|
|
$url = 'http://dc.cswangmwl.com/api/v1/dc/checkUser';
|
|
$arr = array(
|
|
'userName'=>$userName,
|
|
'avatar'=>$avatar,
|
|
'qryType'=>"all"
|
|
);
|
|
$arr = json_encode($arr);
|
|
$res = $this->pushMessageToClient($url,$arr);
|
|
return $res;
|
|
$res = json_decode($res,true);
|
|
if($res['code']=='200'){
|
|
return $res;
|
|
}else{
|
|
$this->wrlog($res);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public function wrlog($txt){
|
|
$log = json_encode($txt);
|
|
$log .= ' 时间:'.date("Y-m-d H:i:s",time());
|
|
$log .= "\n";
|
|
//@file_put_contents('log/Userverification.txt',$log,FILE_APPEND);
|
|
}
|
|
|
|
public function pushMessageToClient($url,$data){
|
|
//初使化init方法
|
|
$ch = curl_init();
|
|
//指定URL
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
//设定请求后返回结果
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
//声明使用POST方式来进行发送
|
|
curl_setopt($ch, CURLOPT_POST, 1);
|
|
//发送什么数据呢
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
|
//忽略证书
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
|
//忽略header头信息
|
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
|
//设置超时时间
|
|
curl_setopt($ch, CURLOPT_TIMEOUT,600);
|
|
//发送请求
|
|
$output = curl_exec($ch);
|
|
curl_close($ch);
|
|
//返回数据
|
|
return $output;
|
|
}
|
|
|
|
} |