|
@@ -4,9 +4,9 @@ class Code
|
|
|
{
|
|
|
private $config;
|
|
|
# 发送验证码
|
|
|
- public function send($template, $account, $param = array())
|
|
|
+ public function send($template, $account, $param = [])
|
|
|
{
|
|
|
- $this->config = Dever::db('template_code', 'msg')->find(array('template_id' => $template['id']));
|
|
|
+ $this->config = Dever::db('template_code', 'msg')->find(['template_id' => $template['id']]);
|
|
|
if (!$this->config) {
|
|
|
Dever::error('验证码未配置');
|
|
|
}
|
|
@@ -21,7 +21,7 @@ class Code
|
|
|
$data['account'] = $handle->init($template['id'], $account);
|
|
|
$this->valid($data);
|
|
|
if ($template['status'] == 1) {
|
|
|
- $data['record'] = $handle->send($template['content'], array('code' => $code));
|
|
|
+ $data['record'] = $handle->send($template['content'], ['code' => $code]);
|
|
|
}
|
|
|
$data['code'] = $code;
|
|
|
$data['status'] = 1;
|
|
@@ -37,10 +37,10 @@ class Code
|
|
|
# 检测并使用验证码
|
|
|
public function check($template_id, $account, $code, $update = 1)
|
|
|
{
|
|
|
- $info = Dever::db('code', 'msg')->find(array('template_id' => $template_id, 'account' => $account), array('order' => 'cdate desc'));
|
|
|
+ $info = Dever::db('code', 'msg')->find(['template_id' => $template_id, 'account' => $account], ['order' => 'cdate desc']);
|
|
|
if ($info && $info['status'] == 1 && $code == $info['code']) {
|
|
|
if ($update == 1) {
|
|
|
- Dever::db('code', 'msg')->update($info['id'], array('status' => 2));
|
|
|
+ Dever::db('code', 'msg')->update($info['id'], ['status' => 2]);
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
@@ -61,7 +61,7 @@ class Code
|
|
|
if (DEVER_TIME - $this->config['cdate'] < $this->config['interval']) {
|
|
|
Dever::error('请不要在'.$this->config['interval'].'秒之内申请多次验证码,请您稍后再试');
|
|
|
} elseif (Dever::db('code', 'msg')->count($where) >= $this->config['total']) {
|
|
|
- Dever::alert('很抱歉,您已经申请获取验证码超过' . $this->config['total'] . '次,今天您已经无法获取验证码了,请您明天再来');
|
|
|
+ Dever::error('很抱歉,您已经申请获取验证码超过' . $this->config['total'] . '次,今天您已经无法获取验证码了,请您明天再来');
|
|
|
}
|
|
|
}
|
|
|
}
|