public function actionUpdatePwd() { $response = array(); $user_phone = $this->request->getParam('user_phone'); $new_pwd = trim($this->request->getParam('new_pwd')); $phone_code = trim($this->request->getParam('phone_code')); $verifyCode = FCookie::get(FConfig::item('config.cookie.phone_key')); $verifyCode = Fn::crypt($verifyCode, FConfig::item('config.cookie.phone_code'), 'decode'); if ($phone_code != $verifyCode) { $response['status'] = 100001; $response['content'] = '短信验证失败!'; } else { $res = $this->user_model->updateAll(array('password' => md5($new_pwd)), 'phone_num=:phone', array(':phone' => $user_phone)); if ($res) { $response['status'] = 100000; $response['content'] = '修改密码成功!'; } else { $response['status'] = 100002; $response['content'] = '修改密码失败!'; } } Yii::app()->end(FHelper::json($response['content'], $response['status'])); }
public function actionSendMsgPhone() { $sendMessage = new SendMessage(); $response = array(); $code = FHelper::generate_code(); $content = FConfig::item('siteMessage.register.first') . $code . FConfig::item('siteMessage.register.end'); $user = FConfig::item('config.ws_mobile.userName'); $pass = FConfig::item('config.ws_mobile.passWord'); $today = date('Y-m-d 0:0:0', time()); $condition = array('condition' => "mobile_no = '{$this->user['phone_num']}' and send_time >= '{$today}'"); $messageCount = $sendMessage->count($condition); if ($messageCount < 5) { Yii::import('ext.wsMobile.ws.*'); require_once 'ws-demo.php'; $engine = WS_SDK::getInstance($user, $pass); $res = $engine->sendSmsAsNormal($this->user['phone_num'], $content, '', 0); if (intval($res) === 0) { $cryRes = Fn::crypt($code, FConfig::item('config.cookie.phone_code')); FCookie::set(FConfig::item('config.cookie.phone_key'), $cryRes); $response['status'] = 100000; $response['content'] = '短信发送成功'; $telArr = array('mobile_no' => $this->user['phone_num'], 'mess_code' => $code, 'send_time' => FF_DATE_TIME); $sendMessage->attributes = $telArr; $sendMessage->save(); } else { $response['status'] = 100001; $response['content'] = '短信发送失败,请重试'; } } else { $response['status'] = 100002; $response['content'] = '该手机号码今天发送验证码过多'; } Yii::app()->end(FHelper::json($response['content'], $response['status'])); }