function send_message_mobile() { $username = IFilter::act(IReq::get('username')); $mobile = IFilter::act(IReq::get('mobile')); if ($username === null || !Util::is_username($username)) { die("请输入正确的用户名"); } if ($mobile === null || !IValidate::mobi($mobile)) { die("请输入正确的手机号码"); } $userDB = new IModel('user as u , member as m'); $userRow = $userDB->getObj('u.username = "******" and m.mobile = "' . $mobile . '" and u.id = m.user_id'); if ($userRow) { $findPasswordDB = new IModel('find_password'); $dataRow = $findPasswordDB->query('user_id = ' . $userRow['user_id'], '*', 'addtime', 'desc'); $dataRow = current($dataRow); //120秒是短信发送的间隔 if (isset($dataRow['addtime']) && time() - $dataRow['addtime'] <= 120) { die("申请验证码的时间间隔过短,请稍候再试"); } $mobile_code = rand(10000, 99999); $findPasswordDB->setData(array('user_id' => $userRow['user_id'], 'hash' => $mobile_code, 'addtime' => time())); if ($findPasswordDB->add()) { $content = smsTemplate::findPassword(array('{mobile_code}' => $mobile_code)); $result = Hsms::send($mobile, $content); if ($result == 'success') { die('success'); } die('短信发送失败'); } } else { die('手机号码与用户名不符合'); } }