<?php
/**
* @author dustin.Qin QQ:269061377
* @copyright 深东科技
* @version 1.0
*/
class SMS {
/**短信接口**/
private function Send($data=array()){
$client = new soapclient('http://域名/WebServices/PhpSms.asmx?WSDL');
$param=array();
$param['data']['mobileNo'] = $data['phone'];
$param['data']['msg']=base64_encode($data['msg']);
$result = $client->__call('SendMessage',$param);
$obj=$result->SendMessageResult;
return $obj;
}
/*用于注册短信验证码*/
function SendRegSms($data=array()){
global $mysql;
$code=rand(111111,999999);
$content='您本次操作的验证码是'.$code.",请勿将验证码告知他人并尽快完成验证.";
$sqlsel = "select * from {send_sms_log} where `nber`='{$data['phone']}' and `sendtype`='{$data['sendtype']}' and FROM_UNIXTIME(sendtime,'%y%m%d')=".date("ymd");
$havesends = $mysql->db_fetch_array($sqlsel);
if($havesends==false){
$data['msg'] =iconv("gb2312","utf-8//IGNORE",$content);
$result =SMS::Send($data);
if($result=="0"){
$mysql->db_query("insert into `{send_sms_log}` set sendtype='{$data['sendtype']}',code='{$code}',nber='{$data['phone']}',content='{$content}',countsms=1,sendtime='".time()."',addip='".ip_address()."'");
$Return["Status"]="01";
$Return["msg"]="发送成功";
}else{
$Return["Status"]="02";
$Return["msg"]="发送失败";
}
}else{
if($havesends['countsms'] <3){
if($havesends['sendtime']<(time()-120)){
$result =SMS::Send($data);
if($result=="0"){
$mysql->db_query("update `{send_sms_log}` set sendtype='{$data['sendtype']}',code='{$code}',content='{$content}',countsms=countsms+1,sendtime='".time()."',addip='".ip_address()."' where nber='{$data['phone']}'");
$Return["Status"]="03";
$Return["msg"]="再次发送成功";
}else{
$Return["Status"]="04";
$Return["msg"]="再次发送失败";
}
}else{
$Return["Status"]="05";
$Return["msg"]="已经发送验证码到您的手机,请".(120-(time()-$havesends['sendtime']))."秒后重试!";
}
}else{
$Return["Status"]="06";
$Return["msg"]="每日只允许发送三次,请明日再注册,或联系客服。";
}
}
$Return["msg"]=iconv("gb2312","utf-8//IGNORE",$Return["msg"]);
return $Return;
}
/*用于站内提醒短信*/
function SendRemindSms($data=array()){
global $mysql;
$datas['sendtype']="11";
$datas['phone']=$data['phone'];
$regex = "/13[0-9]{9}|15[0|1|2|3|5|6|7|8|9]\d{8}|18[0|5|6|7|8|9]\d{8}/";
preg_match_all($regex,$data['phone'], $phone);
if($phone && isset($data['msg'])){
$datas['msg'] =iconv("gb2312","utf-8//IGNORE",$data['msg']);
$result =SMS::Send($datas);
if($result=="0"){
$mysql->db_query("insert into `{send_sms_log}` set sendtype='{$datas['sendtype']}',nber='{$data['phone']}',content='{$data['msg']}',countsms=1,sendtime='".time()."',addip='".ip_address()."'");
return true;
}
}
return false;
}
}
?>
/**
* @author dustin.Qin QQ:269061377
* @copyright 深东科技
* @version 1.0
*/
class SMS {
/**短信接口**/
private function Send($data=array()){
$client = new soapclient('http://域名/WebServices/PhpSms.asmx?WSDL');
$param=array();
$param['data']['mobileNo'] = $data['phone'];
$param['data']['msg']=base64_encode($data['msg']);
$result = $client->__call('SendMessage',$param);
$obj=$result->SendMessageResult;
return $obj;
}
/*用于注册短信验证码*/
function SendRegSms($data=array()){
global $mysql;
$code=rand(111111,999999);
$content='您本次操作的验证码是'.$code.",请勿将验证码告知他人并尽快完成验证.";
$sqlsel = "select * from {send_sms_log} where `nber`='{$data['phone']}' and `sendtype`='{$data['sendtype']}' and FROM_UNIXTIME(sendtime,'%y%m%d')=".date("ymd");
$havesends = $mysql->db_fetch_array($sqlsel);
if($havesends==false){
$data['msg'] =iconv("gb2312","utf-8//IGNORE",$content);
$result =SMS::Send($data);
if($result=="0"){
$mysql->db_query("insert into `{send_sms_log}` set sendtype='{$data['sendtype']}',code='{$code}',nber='{$data['phone']}',content='{$content}',countsms=1,sendtime='".time()."',addip='".ip_address()."'");
$Return["Status"]="01";
$Return["msg"]="发送成功";
}else{
$Return["Status"]="02";
$Return["msg"]="发送失败";
}
}else{
if($havesends['countsms'] <3){
if($havesends['sendtime']<(time()-120)){
$result =SMS::Send($data);
if($result=="0"){
$mysql->db_query("update `{send_sms_log}` set sendtype='{$data['sendtype']}',code='{$code}',content='{$content}',countsms=countsms+1,sendtime='".time()."',addip='".ip_address()."' where nber='{$data['phone']}'");
$Return["Status"]="03";
$Return["msg"]="再次发送成功";
}else{
$Return["Status"]="04";
$Return["msg"]="再次发送失败";
}
}else{
$Return["Status"]="05";
$Return["msg"]="已经发送验证码到您的手机,请".(120-(time()-$havesends['sendtime']))."秒后重试!";
}
}else{
$Return["Status"]="06";
$Return["msg"]="每日只允许发送三次,请明日再注册,或联系客服。";
}
}
$Return["msg"]=iconv("gb2312","utf-8//IGNORE",$Return["msg"]);
return $Return;
}
/*用于站内提醒短信*/
function SendRemindSms($data=array()){
global $mysql;
$datas['sendtype']="11";
$datas['phone']=$data['phone'];
$regex = "/13[0-9]{9}|15[0|1|2|3|5|6|7|8|9]\d{8}|18[0|5|6|7|8|9]\d{8}/";
preg_match_all($regex,$data['phone'], $phone);
if($phone && isset($data['msg'])){
$datas['msg'] =iconv("gb2312","utf-8//IGNORE",$data['msg']);
$result =SMS::Send($datas);
if($result=="0"){
$mysql->db_query("insert into `{send_sms_log}` set sendtype='{$datas['sendtype']}',nber='{$data['phone']}',content='{$data['msg']}',countsms=1,sendtime='".time()."',addip='".ip_address()."'");
return true;
}
}
return false;
}
}
?>