|
|
|
@ -1180,7 +1180,11 @@ function think_psw_md5($str, $key = 'ThinkUCenter')
|
|
|
|
|
function age_verify($cardno, $name, $user_id = '')
|
|
|
|
|
{
|
|
|
|
|
$info = '';
|
|
|
|
|
$date = age($cardno, $name, $info);
|
|
|
|
|
if (C('tool_age.status')==1) {
|
|
|
|
|
$date = age($cardno, $name, $info);
|
|
|
|
|
} else if(C('juhe_age.status')==1){
|
|
|
|
|
$date = juhedataAge($cardno, $name, C('juhe_age.appkey'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$arr['name'] = $name;
|
|
|
|
|
$arr['id_card'] = $cardno;
|
|
|
|
@ -1206,6 +1210,26 @@ function age_verify($cardno, $name, $user_id = '')
|
|
|
|
|
$arr['status'] = 0;
|
|
|
|
|
M('idcard_log', 'tab_')->data($arr)->add();
|
|
|
|
|
return 0;
|
|
|
|
|
} elseif(isset($date['error_code']) && $date['error_code'] == 0 && $date['result']['res'] == 1){
|
|
|
|
|
$arr['status'] = 1;
|
|
|
|
|
M('idcard_log', 'tab_')->data($arr)->add();
|
|
|
|
|
$birthday = getIDCardInfo($cardno);
|
|
|
|
|
|
|
|
|
|
if ($birthday['isAdult'] == 1) {
|
|
|
|
|
return 2;
|
|
|
|
|
} else {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
} elseif(isset($date['error_code']) && $date['error_code'] == 0 && $date['result']['res'] == 2){
|
|
|
|
|
$arr['status'] = 0;
|
|
|
|
|
M('idcard_log', 'tab_')->data($arr)->add();
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
} elseif(isset($date['error_code']) && $date['error_code'] == 210304){
|
|
|
|
|
$arr['status'] = 0;
|
|
|
|
|
M('idcard_log', 'tab_')->data($arr)->add();
|
|
|
|
|
|
|
|
|
|
return 3;
|
|
|
|
|
} else {
|
|
|
|
|
$arr['status'] = -1;
|
|
|
|
|
M('idcard_log', 'tab_')->data($arr)->add();
|
|
|
|
@ -1251,6 +1275,20 @@ function age($cardno, $name, &$info)
|
|
|
|
|
return $r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function juhedataAge($cardno, $name, $key) {
|
|
|
|
|
|
|
|
|
|
$url = "http://op.juhe.cn/idcard/query";
|
|
|
|
|
$post['idcard'] = $cardno;
|
|
|
|
|
$post['realname'] = $name;
|
|
|
|
|
$post['orderid'] = 1;
|
|
|
|
|
$post['key'] = $key;
|
|
|
|
|
|
|
|
|
|
$return = json_decode(curl_post($url,$post),true);
|
|
|
|
|
|
|
|
|
|
return $return;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function age2($cardno, $name) {
|
|
|
|
|
$host = "https://idcardcert.market.alicloudapi.com";
|
|
|
|
|
$path = "/idCardCert";
|
|
|
|
@ -1433,3 +1471,56 @@ function curl_post($url = '', $post_data = array()) {
|
|
|
|
|
return $data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getIDCardInfo($IDCard){
|
|
|
|
|
$result['error']=0;//0:未知错误,1:身份证格式错误,2:无错误
|
|
|
|
|
$result['flag']='';//0标示成年,1标示未成年
|
|
|
|
|
$result['tdate']='';//生日,格式如:2012-11-15<br>
|
|
|
|
|
if(!preg_match("/^[1-9]([0-9a-zA-Z]{17}|[0-9a-zA-Z]{14})$/i",$IDCard)){
|
|
|
|
|
//5.3以下
|
|
|
|
|
//if(!eregi("^[1-9]([0-9a-zA-Z]{17}|[0-9a-zA-Z]{14})$",$IDCard)){
|
|
|
|
|
$result['error']=1;
|
|
|
|
|
return $result;
|
|
|
|
|
}else{
|
|
|
|
|
if(strlen($IDCard)==18){
|
|
|
|
|
$tyear=intval(substr($IDCard,6,4));
|
|
|
|
|
$tmonth=intval(substr($IDCard,10,2));
|
|
|
|
|
$tday=intval(substr($IDCard,12,2));
|
|
|
|
|
if($tyear>date("Y")||$tyear<(date("Y")-100)){
|
|
|
|
|
$flag=0;
|
|
|
|
|
}elseif($tmonth<0||$tmonth>12){
|
|
|
|
|
$flag=0;
|
|
|
|
|
}elseif($tday<0||$tday>31){
|
|
|
|
|
$flag=0;
|
|
|
|
|
}else{
|
|
|
|
|
$tdate=$tyear."-".$tmonth."-".$tday." 00:00:00";
|
|
|
|
|
if((time()-mktime(0,0,0,$tmonth,$tday,$tyear))>18*365*24*60*60){
|
|
|
|
|
$flag=0;
|
|
|
|
|
}else{
|
|
|
|
|
$flag=1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}elseif(strlen($IDCard)==15){
|
|
|
|
|
$tyear=intval("19".substr($IDCard,6,2));
|
|
|
|
|
$tmonth=intval(substr($IDCard,8,2));
|
|
|
|
|
$tday=intval(substr($IDCard,10,2));
|
|
|
|
|
if($tyear>date("Y")||$tyear<(date("Y")-100)){
|
|
|
|
|
$flag=0;
|
|
|
|
|
}elseif($tmonth<0||$tmonth>12){
|
|
|
|
|
$flag=0;
|
|
|
|
|
}elseif($tday<0||$tday>31){
|
|
|
|
|
$flag=0;
|
|
|
|
|
}else{
|
|
|
|
|
$tdate=$tyear."-".$tmonth."-".$tday." 00:00:00";
|
|
|
|
|
if((time()-mktime(0,0,0,$tmonth,$tday,$tyear))>18*365*24*60*60){
|
|
|
|
|
$flag=0;
|
|
|
|
|
}else{
|
|
|
|
|
$flag=1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$result['error']=2;//0:未知错误,1:身份证格式错误,2:无错误
|
|
|
|
|
$result['isAdult']=$flag;//0标示成年,1标示未成年
|
|
|
|
|
$result['birthday']=$tdate;//生日日期
|
|
|
|
|
return $result;
|
|
|
|
|
}
|