/** * 检查是否可以登录 * * @param string $code 验证码 * @param string $phone 手机号 */ function checkLogin($code, $phone) { $row = Sp_Sendmsg::getSmsByPhone($phone, 'smslogin'); $nowTime = time() - $row['crttime']; if (!is_array($row) || $nowTime > 15 * 60 || $row['code'] != $code) { return array('code' => '400', 'msg' => '验证码错误'); } return true; }
/** * function description * * @param * @return void */ public function execute($request) { if ($request->format == 'json') { $id = $request->id; $aid = $request->aid; if (!is_numeric($id) || !is_numeric($aid)) { return array('status' => '-1', 'msg' => '参数错误'); } $user = Sp_Account_User::current(); $active = Sp_Active_Active::getActiveById($aid, $user->id); if (is_array($active) && count($active) > 1) { $at = Sp_Account_Attendee::getAttendeeById($id); if ($at['activeId'] == $aid && $at['status'] == 0 && ($at['checkStatus'] == 0 || $at['checkStatus'] == 1)) { $row = Sp_Sendmsg::getSmsByPhone($at['phone'], 'attendee'); if (is_array($row) && count($row) < 3) { $nowDate = date("Y-m-d", time()); $msgDate = date("Y-m-d", $row['crttime']); if ($nowDate == $msgDate) { return array('status' => '-126', 'msg' => '该电子票已在当天发送过,不能重复发送。', 'data' => $shortArr); } } $code = $this->getSignIdCode($at); if (false == $code) { return array('status' => '-1', 'msg' => '生成电子票失败'); } $url = SP_URL_HOME . "attendee/code/" . $code . ".html"; $shortArr = Util_ShortUrl::shortSina($url); if ($shortArr === FALSE) { return array('status' => '-1', 'msg' => '生成电子票失败'); } else { $content = $at['name'] . "你好:你已报名成功" . $active['title'] . ",会议时间:" . date("Y-m-d H:i", $active['activit_start']) . " ~ " . date("Y-m-d H:i", $active['activit_start']) . ",会议地点:" . $active['address'] . "。您的电子票为" . $shortArr['url_short'] . ",签到码为" . $code . ",请保留此短信至会议结束。"; $sms = array(); $sms['username'] = $at['phone']; $sms['content'] = $content; $sms['type'] = 'attendee'; $sms['user_id'] = $user->id; Sp_Sendmsg::send($sms); if ($at['checkStatus'] == 0) { Sp_Account_Attendee::success($id); } return array('status' => '0', 'msg' => '发送成功'); } } else { return array('status' => '-1', 'msg' => '数据有误'); } } else { return array('status' => '-1', 'msg' => '数据有误'); } } }
public function checkCodeAndUser($username = '', $code = '', $type = '') { $username = trim($username); $code = trim($code); $patternMobile = Sp_Dictionary::getOtherOption('patternMobile'); $patternEmail = Sp_Dictionary::getOtherOption('patternEmail'); if (strlen($code) != 6) { return array('status' => '-126', 'msg' => '验证码长度有误'); } if (preg_match($patternEmail, $username) || preg_match($patternMobile, $username)) { if (preg_match($patternMobile, $username)) { if (TRUE == Sp_Account_Regist::isAvailableMobile($username)) { return array('status' => '-125', 'msg' => '该手机号不存在'); } $row = Sp_Sendmsg::getSmsByPhone($username, $type); $nowTime = time() - $row['crttime']; if (!is_array($row) || $nowTime > 15 * 60 || $row['code'] != $code) { return array('status' => '-126', 'msg' => '验证码错误'); } } if (preg_match($patternEmail, $username)) { if (TRUE == Sp_Account_Regist::isAvailableEmail($username)) { return array('status' => '-126', 'msg' => '该邮箱不存在'); } $row = Sp_Sendmsg::getSmsByEmail($username, $type); $nowTime = time() - $row['crttime']; if (!is_array($row) || $nowTime > 15 * 60 || $row['code'] != $code) { return array('status' => '-126', 'msg' => '验证码错误'); } } return TRUE; } else { return array('status' => '-121', 'msg' => '格式不正确'); } }