|
@@ -1 +1,200 @@
|
|
|
<?php
|
|
|
+
|
|
|
+use think\Db;
|
|
|
+
|
|
|
+function getCountryMobile($countryCode){
|
|
|
+
|
|
|
+ $where['country_id']=$countryCode;
|
|
|
+ $lists = Db::name('directory_country')->where($where)->find();
|
|
|
+ $country = $lists['iso2_code'];
|
|
|
+ $countrys_en = [ "China", "Afghanistan", "Albania", "Algera",
|
|
|
+ "Andorra", "Angola", "Anguilla", "Ascension",
|
|
|
+ "Antigua and Barbuda", "Argentina", "Armenia", "Aruba",
|
|
|
+ "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain",
|
|
|
+ "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin",
|
|
|
+ "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegovina",
|
|
|
+ "Botwana", "Brazill", "Brunei", "Bulgaria", "Burkina Faso",
|
|
|
+ "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde",
|
|
|
+ "Cayman Islands", "Central African Republic", "Chad", "Chile",
|
|
|
+ "Colombia", "Comoros", "Republic of the Congo",
|
|
|
+ "Democratic Republic of the Congo", "Cook Islands", "Costa Rica",
|
|
|
+ "Cote divoire", "Croatia", "Cuba", "Cyprus", "+Czech Republic",
|
|
|
+ "Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador",
|
|
|
+ "Egypt", "EISalvador", "Estonia", "Ethiopia", "Faroe Islands",
|
|
|
+ "Fiji", "Finland", "France", "French Guiana", "French Polynesia",
|
|
|
+ "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Gibraltar",
|
|
|
+ "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam",
|
|
|
+ "Guatemala", "Guinea", "Guernsey", "Guinea", "Guyana", "Haiti",
|
|
|
+ "Honduras", "Hong Kong", "Myanmar", "Hungary", "Iceland", "Indea",
|
|
|
+ "Indonesia", "Iran", "Iraq", "Ireland", "Isle of Man", "Israel",
|
|
|
+ "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazeakhstan",
|
|
|
+ "Kenya", "Kosovo", "Kuwait", "Kyrgyzstan", "Laos", "Latvia",
|
|
|
+ "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein",
|
|
|
+ "Lithuania", "Luxembourg", "Macao", "Macedonia", "Madagascar",
|
|
|
+ "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Martinique",
|
|
|
+ "Mauritania", "Mauritius", "Mayotte", "Mexico", "Moldova",
|
|
|
+ "Monaco", "Mongolia", "Montenegro", "Montserrat", "Morocco",
|
|
|
+ "Mozambique", "Namibia", "Nepal", "Netherlands",
|
|
|
+ "Netherlands Antillse", "New Caledonia", "NewZealand", "Nicaragua",
|
|
|
+ "Niger", "Nigeria", "Norway", "Oman", "Pakistan", "Palestinian",
|
|
|
+ "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines",
|
|
|
+ "Poland", "Portugal", "PuertoRico", "Qotar", "Reunion", "Romania",
|
|
|
+ "Russia", "Rwanda", "Samoa Eastern", "Samoa Western", "San Marino",
|
|
|
+ "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia",
|
|
|
+ "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia",
|
|
|
+ "South Africa", "Korea", "Spain", "SriLanka", "St Kitts and Nevis",
|
|
|
+ "St.Lucia", "St.Vincent", "Sudan", "Suriname", "Swaziland",
|
|
|
+ "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan",
|
|
|
+ "Tanzania", "Thailand", "Timor Leste", "Togo", "Tonga",
|
|
|
+ "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan",
|
|
|
+ "Turks and Caicos Islands", "Uganda", "Ukraine",
|
|
|
+ "United Arab Emirates", "United Kingdom", "USA", "Uruguay",
|
|
|
+ "Uzbekistan", "Vanuatu", "Venezuela", "Vietnam", "Virgin Islands",
|
|
|
+ "Yemen", "Zambia", "Zimbabwe" ];
|
|
|
+ $countrys = array_keys($countrys_en,$country,true);
|
|
|
+ if(empty($countrys)){
|
|
|
+ $country=$lists['iso3_code'];
|
|
|
+ $countrys =array_keys($countrys_en,$country,true);
|
|
|
+ }
|
|
|
+ if($countrys[0]){
|
|
|
+ $countryMobile =getCountryCode($countrys[0]);
|
|
|
+ }else{
|
|
|
+ $countryMobile ='+1';
|
|
|
+ }
|
|
|
+ $countryMobile = str_replace('+','',$countryMobile);
|
|
|
+ return (int)$countryMobile;
|
|
|
+}
|
|
|
+
|
|
|
+//获取国家手机编号
|
|
|
+function getCountryCode($countryCode){
|
|
|
+ $codes = [ "+86", "+93", "+355", "+213", "+376", "+244", "+1264",
|
|
|
+ "+247", "+1268", "+54", "+374", "+297", "+61", "+43", "+994",
|
|
|
+ "+1242", "+973", "+880", "+1246", "+375", "+32", "+501", "+229",
|
|
|
+ "+1441", "+975", "+591", "+387", "+267", "+55", "+673", "+359",
|
|
|
+ "+226", "+257", "+855", "+237", "+1", "+238", "+1345", "+236",
|
|
|
+ "+235", "+56", "+57", "+269", "+242", "+243", "+682", "+506",
|
|
|
+ "+225", "+385", "+53", "+357", "+420", "+45", "+253", "+1767",
|
|
|
+ "+1809", "+593", "+20", "+503", "+372", "+251", "+298", "+679",
|
|
|
+ "+358", "+33", "+594", "+689", "+241", "+220", "+995", "+94",
|
|
|
+ "+233", "+350", "+30", "+299", "+1473", "+590", "+1671", "+502",
|
|
|
+ "+240", "+44", "+224", "+592", "+509", "+504", "+852", "+95",
|
|
|
+ "+36", "+354", "+91", "+62", "+98", "+964", "+353", "+44", "+972",
|
|
|
+ "+93", "+1876", "+81", "+44", "+962", "+7", "+254", "+383", "+965",
|
|
|
+ "+996", "+856", "+371", "+961", "+266", "+231", "+218", "+423",
|
|
|
+ "+370", "+352", "+853", "+389", "+261", "+265", "+60", "+960",
|
|
|
+ "+223", "+356", "+596", "+222", "+230", "+262", "+52", "+373",
|
|
|
+ "+377", "+976", "+382", "+1664", "+212", "+258", "+264", "+977",
|
|
|
+ "+31", "+599", "+687", "+64", "+505", "+227", "+234", "+47",
|
|
|
+ "+968", "+92", "+970", "+507", "+675", "+595", "+51", "+63", "+48",
|
|
|
+ "+351", "+1", "+974", "+262", "+40", "+7", "+250", "+684", "+685",
|
|
|
+ "+378", "+239", "+966", "+221", "+381", "+248", "+232", "+65",
|
|
|
+ "+421", "+386", "+27", "+82", "+34", "+94", "+1869", "+1758",
|
|
|
+ "+1784", "+249", "+597", "+268", "+46", "+41", "+963", "+886",
|
|
|
+ "+992", "+255", "+66", "+670", "+228", "+676", "+1868", "+216",
|
|
|
+ "+90", "+993", "+1649", "+256", "+380", "+971", "+44", "+1",
|
|
|
+ "+598", "+998", "+678", "+58", "+84", "+1340", "+967", "+260",
|
|
|
+ "+263" ];
|
|
|
+ return $codes[$countryCode];
|
|
|
+}
|
|
|
+
|
|
|
+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;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|