|
@@ -15,12 +15,17 @@ class Base
|
|
|
|
|
|
const MCODE = 'mcode';
|
|
|
|
|
|
- protected $save;
|
|
|
+ protected $save = false;
|
|
|
+ protected $save_type = 'session';
|
|
|
|
|
|
public function __construct()
|
|
|
{
|
|
|
//$this->save = new Save(false, 'cookie');
|
|
|
- $this->save = new Save(false, 'session');
|
|
|
+ $save_type = $this->save_type = Dever::config('base', 'project')->mobileCode['save'];
|
|
|
+ if ($this->save_type == 'db') {
|
|
|
+ $save_type = 'session';
|
|
|
+ }
|
|
|
+ $this->save = new Save(false, $save_type);
|
|
|
}
|
|
|
|
|
|
# 返回加密的用户信息
|
|
@@ -465,22 +470,30 @@ class Base
|
|
|
|
|
|
protected function mcode($mobile, $code = false)
|
|
|
{
|
|
|
- if ($code) {
|
|
|
- $save = $this->save->get(self::MCODE);
|
|
|
- return $mobile . '_' . $code == $save;
|
|
|
- }
|
|
|
-
|
|
|
$day = date('Ymd', time());
|
|
|
|
|
|
# 检测当前手机号最新一次发送时间,不允许一分钟之内发送
|
|
|
$param['option_day'] = $day;
|
|
|
$param['option_mobile'] = $mobile;
|
|
|
|
|
|
+ if ($code) {
|
|
|
+ if ($this->save_type == 'db') {
|
|
|
+ $check = Dever::db('passport/code')->getNew($param);
|
|
|
+ if ($check) {
|
|
|
+ return $check['mobile'] . '_' . $check['code'] == $save;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ $save = $this->save->get(self::MCODE);
|
|
|
+ return $mobile . '_' . $code == $save;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
# 检测当前手机号今天已经发送多少验证码了
|
|
|
$info = Dever::load('passport/code-total', $param);
|
|
|
|
|
|
if ($info >= 1) {
|
|
|
- $check = Dever::load('passport/code-one', $param);
|
|
|
+ $check = Dever::db('passport/code')->getNew($param);
|
|
|
|
|
|
if ($check) {
|
|
|
if (time() - $check['cdate'] < Dever::config('base', 'project')->mobileCode['time']) {
|
|
@@ -506,7 +519,9 @@ class Base
|
|
|
# 启动发送
|
|
|
$this->send($mobile, $insert['add_code'], $id);
|
|
|
|
|
|
- $this->save->add(self::MCODE, $mobile . '_' . $code->mcode, Dever::config('base', 'project')->mobileCode['timeout']);
|
|
|
+ if ($this->save_type != 'db') {
|
|
|
+ $this->save->add(self::MCODE, $mobile . '_' . $code->mcode, Dever::config('base', 'project')->mobileCode['timeout']);
|
|
|
+ }
|
|
|
|
|
|
return $code->mcode;
|
|
|
}
|