|
|
|
@ -419,6 +419,37 @@ eof;
@@ -419,6 +419,37 @@ eof;
|
|
|
|
|
return $isLimited; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//生成4随机数,并保存生成时间,10 分钟内有效 |
|
|
|
|
protected function generateRandSmsCode() { |
|
|
|
|
if(session_status() !== PHP_SESSION_ACTIVE) { |
|
|
|
|
session_start(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$rndCode = rand(1000, 9999); //4位随机数 |
|
|
|
|
|
|
|
|
|
$_SESSION['randSmsCode'] = $rndCode; |
|
|
|
|
$_SESSION['randSmsCode_created'] = time(); |
|
|
|
|
|
|
|
|
|
return $rndCode; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//短信验证码 10 分钟内有效 |
|
|
|
|
protected function getMySmsCode() { |
|
|
|
|
if(session_status() !== PHP_SESSION_ACTIVE) { |
|
|
|
|
session_start(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$rndCode = !empty($_SESSION['randSmsCode']) ? $_SESSION['randSmsCode'] : 0; |
|
|
|
|
$rndCode_created = !empty($_SESSION['randSmsCode_created']) ? $_SESSION['randSmsCode_created'] : 0; |
|
|
|
|
$current_time = time(); |
|
|
|
|
|
|
|
|
|
if (!empty($rndCode_created) && $current_time - $rndCode_created > 600) { |
|
|
|
|
$rndCode = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $rndCode; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//获取短信验证码 |
|
|
|
|
public function actionSendsmscode() { |
|
|
|
|
$ip = $this->getUserIp(); |
|
|
|
@ -431,8 +462,42 @@ eof;
@@ -431,8 +462,42 @@ eof;
|
|
|
|
|
throw new Exception('Oops,操作太快了,请喝杯咖啡休息会吧...'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
echo "Building..."; |
|
|
|
|
exit; |
|
|
|
|
//返回给视图的变量 |
|
|
|
|
$code = 0; |
|
|
|
|
$msg = ''; |
|
|
|
|
$err = ''; |
|
|
|
|
|
|
|
|
|
$postParams = $this->post(); |
|
|
|
|
if (!empty($postParams)) { |
|
|
|
|
$cellphone = $this->post('phoneNum', ''); |
|
|
|
|
|
|
|
|
|
if (empty($cellphone) || Common::isCellphoneNumber($cellphone) == false) { |
|
|
|
|
$err = "手机号码格式错误,请填写正确的手机号码"; |
|
|
|
|
}else { |
|
|
|
|
$params = array( |
|
|
|
|
'phoneNumber' => $cellphone, |
|
|
|
|
'codeNumber' => $this->generateRandSmsCode(), |
|
|
|
|
'action' => 'register', |
|
|
|
|
); |
|
|
|
|
$params['sign'] = $this->sign($params, FSC::$app['config']['service_3rd_api_key']); |
|
|
|
|
|
|
|
|
|
$api = FSC::$app['config']['service_3rd_api_domain'] . '/aliyun/sendverifycode/'; |
|
|
|
|
$timeout = 10; |
|
|
|
|
$pc = false; |
|
|
|
|
$headers = array("Content-Type: application/json"); |
|
|
|
|
//以json格式post数据 |
|
|
|
|
$res = $this->request($api, json_encode($params), $timeout, $pc, $headers); |
|
|
|
|
|
|
|
|
|
if (!empty($res) && $res['status'] == 200) { |
|
|
|
|
$code = 1; |
|
|
|
|
$msg = '短信验证码已成功发送'; |
|
|
|
|
}else { |
|
|
|
|
$err = '短信验证码发送失败,请稍后再试'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $this->renderJson(compact('code', 'msg', 'err')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//新用户注册 |
|
|
|
@ -470,7 +535,11 @@ eof;
@@ -470,7 +535,11 @@ eof;
|
|
|
|
|
$err = "邀请码不存在,请填写邀请你的朋友的手机号码末 6 位,或者加客服微信索取"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//TODO: 验证短信验证码是否正确 |
|
|
|
|
//验证短信验证码是否正确 |
|
|
|
|
$mySmsCode = $this->getMySmsCode(); |
|
|
|
|
if (empty($mySmsCode) || $mySmsCode != $sms_code) { |
|
|
|
|
$err = "{$sms_code} 验证码已过期或错误,请检查是否输入正确"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (empty($err)) { //如果数据检查通过,尝试注册新用户 |
|
|
|
|
$userDataDir = Common::getUserDataDir($cellphone); |
|
|
|
@ -529,7 +598,11 @@ eof;
@@ -529,7 +598,11 @@ eof;
|
|
|
|
|
$err = "{$cellphone}还没注册哦,先去注册吧"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//TODO: 验证短信验证码是否正确 |
|
|
|
|
//验证短信验证码是否正确 |
|
|
|
|
$mySmsCode = $this->getMySmsCode(); |
|
|
|
|
if (empty($mySmsCode) || $mySmsCode != $sms_code) { |
|
|
|
|
$err = "{$sms_code} 验证码已过期或错误,请检查是否输入正确"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (empty($err)) { //如果数据检查通过,尝试登录 |
|
|
|
|
$newUser = Common::saveUserIntoSession($cellphone); |
|
|
|
@ -547,4 +620,11 @@ eof;
@@ -547,4 +620,11 @@ eof;
|
|
|
|
|
return $this->renderJson(compact('code', 'msg', 'err', 'shareUrl')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//TODO: 分类管理 |
|
|
|
|
|
|
|
|
|
//TODO: 昵称设置 |
|
|
|
|
|
|
|
|
|
//TODO: 视频管理 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|