/** * 发送短信 * * @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; }
/** * 有post提交 * 采用post提交 * return json array('status'=>'0','msg'=>'成功') */ public function execute($request) { if ($request->format == 'json') { if ($request->type == "pwdcode") { //发送修改账号短信验证码 $result = $this->checkCaptchaAndUser($request->username, $request->code, $request->type); if (TRUE === $result) { $username = $request->username; //计算验证码 $code = rand(100000, 999999); $content = "您本次在会通网修改密码的验证码为:" . $code . ",任何人索取验证码均为咋骗,切勿泄露!此验证码会在15分钟后失效"; $sms = array(); $sms['username'] = $username; $sms['content'] = $content; $sms['type'] = 'pwdcode'; $sms['code'] = $code; $sms['user_id'] = Sp_Account_SignIn::getUserIdBySignIn($username); Sp_Sendmsg::send($sms); return array('status' => '0', 'msg' => '发送成功'); } else { return $result; } } else { if ($request->type == "repwd") { //修改密码 $result = $this->checkCodeAndUser($request->username, $request->code, 'pwdcode'); if (TRUE === $result) { $username = $request->username; //计算验证码 $code = rand(100000, 999999); $ret = Sp_Account_User::RePwd($username, $code); if ($ret) { $content = "您本次修改的密码为:" . $code . ",任何人索取验证码均为咋骗,切勿泄露!此验证码会在15分钟后失效"; $sms = array(); $sms['username'] = $username; $sms['content'] = $content; $sms['type'] = 'repwd'; $sms['user_id'] = Sp_Account_SignIn::getUserIdBySignIn($username); Sp_Sendmsg::send($sms); return array('status' => '0', 'msg' => '发送成功'); } else { return array('status' => '-1', 'msg' => '修改失败'); } } else { return $result; } } else { return array('status' => '-101', 'msg' => '提交参数错误'); } } } // else{ // //var_dump($list); // $view = new Sp_View; // $view->display('test/home.html'); // } }
public function sendCode($username = '') { $code = rand(100000, 999999); $content = "您本次在会通网修改密码的验证码为:" . $code . ",任何人索取验证码均为咋骗,切勿泄露!此验证码会在15分钟后失效"; $data = array('code' => $code, 'content' => $content, 'username' => $username, 'type' => 'Auth'); if (Sp_Sendmsg::send($data)) { $return = array("status" => 1, "msg" => "发送成功"); } else { $return = array("status" => 0, "msg" => "发送失败"); } return $return; }
/** * 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' => '数据有误'); } } }