コード例 #1
0
/**
 * 发送短信
 *
 * @param string $phone 手机号
 */
function sendSms($phone)
{
    $content = '您的验证码为: [code], 任何人索取验证码均为咋骗,切勿泄露!此验证码会在15分钟后失效';
    $code = mt_rand(100000, 999999);
    Sp_Sendmsg::send(array('type' => Sp_Dictionary::getSmsType(0), 'username' => $phone, 'code' => $code, 'content' => str_replace('[code]', $code, $content)));
    return true;
}
コード例 #2
0
 public function authCode($phone, $code, $model = 'phoneAuth')
 {
     if (Sp_Sendmsg::authCode($phone, $code, $model)) {
         $return = array("status" => 1, "msg" => "验证成功");
     } else {
         $return = array("status" => 0, "msg" => "验证失败,请重新获取验证码");
     }
     return $return;
 }
コード例 #3
0
 /**
  * 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' => '数据有误');
         }
     }
 }
コード例 #4
0
 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' => '格式不正确');
     }
 }
コード例 #5
0
 public function authCode($account = '', $code = '', $type = 'phone')
 {
     $auth = Sp_Sendmsg::authCode($account, $code, $type);
     if (1 === $auth) {
         $return = array("status" => 1, "msg" => "验证成功");
     } else {
         if (false === $auth) {
             $return = array("status" => 0, "msg" => "验证失败,请重新获取验证码");
         } else {
             $return = $auth;
         }
     }
     return $return;
 }