123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <?php
- use think\Db;
- function getCountryMobile($countryCode){
- $where['country_id']=$countryCode;
- $lists = Db::name('directory_country')->where($where)->find();
- $countryMobile="9999";
- if($lists){
- $countryMobile =$lists['mobile_code'];
- }
- return (int)$countryMobile;
- }
- function checkMobile($countryMobile,$mobile,$countryCode)
- {
- $mobile= str_replace('-', '', $mobile);
- $mobile= str_replace('_', '', $mobile);
- $mobile= str_replace('(', '', $mobile);
- $mobile= str_replace(')', '', $mobile);
- $mobile= str_replace('+', '', $mobile);
- $mobile= str_replace(' ', '', $mobile);
- $mobile=trim($mobile);
- $lenth=strlen($mobile);
- $data['status']=5;//不发送
- $data['mobile']=$mobile;//不发送
- $frist =(int)substr($mobile, 0, 1 );
- if($countryMobile==1){//美国 加拿大
- $code=0;
- if($lenth==11&&$frist==1){//例:14696305087
- $data['mobile'] = $mobile;
- $code = substr($mobile , 1 , 3);
- //$data['status']=1;//待发送
- }
- if($lenth==10&&$frist!=1){
- $data['mobile'] = $countryMobile.$mobile;
- $code = substr($mobile , 0 , 3);
- //$data['status']=1;//待发送
- }
- if($code){
- $re=checkMobileCode($code);
- if($re){
- $data['status']=1;//待发送
- }
- }
- $data['sign']='13013071800';//签名
- }
- /*if($countryMobile==44){//UK
- if($lenth==10&&$frist==7){
- $data['mobile'] = $countryMobile.$mobile;
- $data['status']=1;//待发送
- }
- if($lenth==11&&$frist==0){
- $mobile =substr($mobile,1);
- $frists =(int)substr($mobile, 0, 1 );
- if($frists==7){
- $data['mobile'] = $countryMobile.$mobile;
- $data['status']=1;//待发送
- }
- }
- if($lenth==12&&$frist==4){
- $mobile=substr($mobile,2);
- $frists =(int)substr($mobile, 0, 1 );
- if($frists==7){
- $data['mobile'] = $countryMobile.$mobile;
- $data['status']=1;//待发送
- }
- }
- }
- if($countryMobile==33){//France
- if($lenth==9){
- if($frist==7||$frist==6){
- $data['mobile'] = $countryMobile.$mobile;
- $data['status']=1;//待发送
- }
- }
- if($lenth==10&&$frist==0){
- $mobile =substr($mobile,1);
- $frists =(int)substr($mobile, 0, 1 );
- if($frists==7||$frists==6){
- $data['mobile'] = $countryMobile.$mobile;
- $data['status']=1;//待发送
- }
- }
- if($lenth==11&&$frist==3){
- $mobile=substr($mobile,0,2);
- $frists =(int)substr($mobile, 0, 1 );
- if($frists==7||$frists==6){
- $data['mobile'] = $countryMobile.$mobile;
- $data['status']=1;//待发送
- }
- }
- }*/
- return $data;
- }
- function checkMobileCode($code){
- $lists = Db::name('directory_country_code')->select();
- $token=[];
- foreach ($lists as $v){
- $token[]=$v['code'];
- }
- if (in_array($code, $token)) {
- return true;
- }else{
- return false;
- }
- }
|