短信验证码加倒计时:
public function sendmess()
{
require('Public/Sendmessage/postmt.php');
$type=I('post.type');//接受类型 1是注册验证 2是手机登录验证 3是绑定微信QQ微博手机号
$piccode=I('post.Piccode');//图形验证码
$verify = new \Think\Verify();
$i=$verify->check($piccode);//判断图形验证码是否正确
$time=60-(time()-$_SESSION['sendtime']);
$U_Tel = I('post.Tel');//用户名
$dbuser=D('User');
$flag=$dbuser->CheckUser($U_Tel);
if ($time > 0) {
$this->ajaxreturn(3);
exit();
}
else{//flag=2 type=1 是手机号不存在注册发送用的 flag=1 type=2是手机号存在改密码和登录用的 type=3 是微信QQ绑定手机号发送消息用的
if (preg_match("/^13[0-9]{9}$|14[0-9]{9}|15[0-9]{9}$|17[0-9]{9}$|18[0-9]{9}$/", $U_Tel)&&$i==true) {
if(($flag==2&&$type==1)||($flag==1&&$type==2)||$type==3) {
$_SESSION["sendtime"] = time();//存储发送短信时间
session(array('name' => 'verifycode', 'expire' => 10));
$_SESSION["verifycode"] = rand(100000, 999999);
$content = "您的手机号:" . $U_Tel . ",验证码:" . $_SESSION['verifycode'] . ",请及时验证。【优议】"; //UEE感谢您的注册!
SMS($U_Tel, $content);
$this->ajaxreturn(1);
exit();
}
else{
$this->ajaxreturn(2);
exit;
}
}
else {
$this->ajaxreturn(2);
exit;
}
}
}