|
|
@ -149,21 +149,50 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
public function sendcodeAction(){ |
|
|
|
public function sendcodeAction(){ |
|
|
|
$phone = empty($this->POST['phone'])||!isset($this->POST['phone'])? Tool_Fnc::apiMsg('请输入手机号', '500'):Tool_fnc::safe_string($this->POST['phone']); |
|
|
|
$phone = empty($this->POST['phone'])||!isset($this->POST['phone'])? Tool_Fnc::apiMsg('请输入手机号', '500'):Tool_fnc::safe_string($this->POST['phone']); |
|
|
|
// 使用示例 |
|
|
|
// 验证系统是否存在该手机号 |
|
|
|
|
|
|
|
$userinfo = $this->Usermodel->field('username')->where("phone='{$phone}' and is_delete=0 and status=1")->fRow(); |
|
|
|
|
|
|
|
if(empty($userinfo)) Tool_Fnc::apiMsg('当前手机号不存在', '500'); |
|
|
|
|
|
|
|
// 短信接口 |
|
|
|
$accessKeyId = Yaf_Registry::get("config")->aliyun->sms->accessKeyId; |
|
|
|
$accessKeyId = Yaf_Registry::get("config")->aliyun->sms->accessKeyId; |
|
|
|
|
|
|
|
$smsModel = new SmscodeModel(); |
|
|
|
$accessKeySecret = Yaf_Registry::get("config")->aliyun->sms->accessKeySecret; |
|
|
|
$accessKeySecret = Yaf_Registry::get("config")->aliyun->sms->accessKeySecret; |
|
|
|
$signName = Yaf_Registry::get("config")->aliyun->sms->signName; |
|
|
|
$signName = Yaf_Registry::get("config")->aliyun->sms->signName; |
|
|
|
$templateCode = Yaf_Registry::get("config")->aliyun->sms->templateCode; |
|
|
|
$templateCode = Yaf_Registry::get("config")->aliyun->sms->templateCode; |
|
|
|
$sms = new AliyunSms($accessKeyId, $accessKeySecret, $signName, $templateCode); |
|
|
|
$sms = new AliyunSms($accessKeyId, $accessKeySecret, $signName, $templateCode); |
|
|
|
|
|
|
|
$code = substr(str_shuffle('0123456789'),0,6); |
|
|
|
$templateParam = array( |
|
|
|
$templateParam = array( |
|
|
|
'code' => substr(str_shuffle('0123456789'),0,6) // 模板中变量的值 |
|
|
|
'code' => $code // 模板中变量的值 |
|
|
|
); |
|
|
|
); |
|
|
|
$result = $sms->sendSMS($phone, $templateParam); |
|
|
|
$result = $sms->sendSMS($phone, $templateParam); |
|
|
|
if ($result) { |
|
|
|
if(!$result) Tool_Fnc::apiMsg('短信发送失败', '500'); |
|
|
|
echo '短信发送成功'; |
|
|
|
$data['phone'] = $phone; |
|
|
|
} else { |
|
|
|
$data['code'] = $code; |
|
|
|
echo '短信发送失败'; |
|
|
|
$data['created'] = date("Y-m-d H:i:s",time()); |
|
|
|
|
|
|
|
$smsModel->save($data); |
|
|
|
|
|
|
|
Tool_Fnc::apiMsg('短信发送成功', '200'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public function ValidationAction(){ |
|
|
|
|
|
|
|
$phone = empty($this->POST['phone'])||!isset($this->POST['phone'])? Tool_Fnc::apiMsg('请输入手机号', '500'):Tool_fnc::safe_string($this->POST['phone']); |
|
|
|
|
|
|
|
$code = empty($this->POST['code'])||!isset($this->POST['code'])? Tool_Fnc::apiMsg('请输入验证码', '500'):Tool_fnc::safe_string($this->POST['code']); |
|
|
|
|
|
|
|
$smsModel = new SmscodeModel(); |
|
|
|
|
|
|
|
$userinfo = $this->Usermodel->field('id')->where("phone='{$phone}' and is_delete=0 and status=1")->fRow(); |
|
|
|
|
|
|
|
$codedata = $smsModel->field('id')->where("phone='{$phone}' and code='{$code}' and status=0")->fRow(); |
|
|
|
|
|
|
|
if(empty($codedata))Tool_Fnc::apiMsg('验证码不正确', '500'); |
|
|
|
|
|
|
|
$codedata['status']=1; |
|
|
|
|
|
|
|
$smsModel->save($codedata); |
|
|
|
|
|
|
|
Tool_Fnc::apiMsg('验证成功', '200',$userinfo); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public function changePwdAction(){ |
|
|
|
|
|
|
|
$id = empty($this->POST['id'])||!isset($this->POST['id'])? Tool_Fnc::apiMsg('非法调用', '500'):Tool_fnc::safe_string($this->POST['id']); |
|
|
|
|
|
|
|
$password = empty($this->POST['password'])||!isset($this->POST['password'])? Tool_Fnc::apiMsg('非法调用', '500'):Tool_fnc::safe_string($this->POST['password']); |
|
|
|
|
|
|
|
$tpassword = empty($this->POST['tpassword'])||!isset($this->POST['tpassword'])? Tool_Fnc::apiMsg('非法调用', '500'):Tool_fnc::safe_string($this->POST['tpassword']); |
|
|
|
|
|
|
|
if($password!=$tpassword) Tool_Fnc::apiMsg('两次密码不一致', '500'); |
|
|
|
|
|
|
|
$data['password'] = md5($password.Yaf_Registry::get("config")->psd->default->appsecret); |
|
|
|
|
|
|
|
$data['id'] = $id; |
|
|
|
|
|
|
|
if(!$this->Usermodel->update($data)){ |
|
|
|
|
|
|
|
Tool_Fnc::apiMsg('新密码与原密码一致', '500'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Tool_Fnc::apiMsg('修改成功', '200'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|