//设置支付密码 public function editPwd(){ $userId=addslashes(I('post.userId')); //支付密码 $loginPwd = addslashes(I('post.PayPwd')); //手机号 $condition['userPhone'] =addslashes(I('post.userPhone')); $condition['userId'] =$userId; //验证码 $verification=addslashes(I('post.verification')); $list = M('users')->where('userId='.$userId)->find(); $time1= $list['time']; $time = time()-strtotime($time1); //过期时间 $n=intval($time/60); $note=$list['num']; //设置时间 if($verification!=$note || $n>10){ $response = array( 'code' => 202, 'message' => '验证码不正确!', ); }else{ $data1=array( 'lastTime'=>date("Y-m-d H;i:s"), 'payPwd'=>md5($loginPwd.$list['loginSecret']), ); $list = M('users')->where($condition)->save($data1); if($list){ $response = array( 'code' => 200, 'message' => '设置密码成功', ); }else{ $response = array( 'code' => 201, 'message' => '设置密码失败', ); } } echo json_encode($response); }
// 手机号基础验证 public function verify_mobile($mobile){ if(!$mobile){ echo $this->callback.'('.json_encode(array( 'code' => 1, 'status' => '手机号不能为空!' )).')';exit; } $pattern = "/^13[0-9]{1}[0-9]{8}$|15[0-9]{1}[0-9]{8}$|18[0-9]{1}[0-9]{8}$|14[5|7]{1}[0-9]{8}$|17[3|6|7|8]{1}[0-9]{8}$/"; $match = preg_match($pattern,$mobile); if(!$match){ echo $this->callback.'('.json_encode(array( 'code' => 2, 'status' => '手机号格式不正确!' )).')';exit; } }//获取短信验证码 public function PayScode(){ //获取手机号 $loginPhone =18810980234; $num= rand(1000, 9999);//设置随机数 //查询手机号 $m=M('users'); $condition['userPhone'] =$loginPhone; $time=date('Y-m-d H:i:s'); $data=array( 'time'=>$time, 'num'=>$num, ); $re=$m->where($condition)->save($data); if($re){ $note=$m->where($condition)->find(); //短信验证码 $num1=$note['num']; $sendAPI = new \Think\SendAPI(); $data = array( 'content' => '您的验证码: '.$num1.';本验证码10分钟内有效',//短信内容 'mobile' => $loginPhone,//手机号码 'xh' => ''//小号 ); $sendAPI->data = $data;//初始化数据包 $re=$sendAPI->sendSMS('POST');//GET or POST if($re){ $response = array( 'code' => 200, 'message' => '验证码发送成功', ); }else{ $response = array( 'code' => 201, 'message' => '验证码发送失败', ); } }else{ $response = array( 'code' => 202, 'message' => '手机号不存在', ); } echo json_encode($response); }http://pan.baidu.com/s/1gf6C9rH 密码 ngtj
版权声明:本文为adminyan原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。