1234567891011121314151617181920212223242526272829303132333435 |
- <?php namespace Msg\Lib;
- use Dever;
- class Template
- {
- # 发送消息
- public function send($template, $account, $param = array())
- {
- $template = Dever::db('template', 'msg')->find(array('key' => $template));
- if (!$template) {
- Dever::error('消息模板不存在');
- }
- if ($template['type'] == 1) {
- $method = 'notify';
- } elseif ($template['type'] == 2) {
- $method = 'code';
- }
- $template['method'] = explode(',', $template['method']);
- return Dever::load('type/' . $method, 'msg')->send($template, $account, $param);
- }
- # 验证码检查
- public function check($template, $account, $code, $update = 1)
- {
- $template = Dever::db('template', 'msg')->find(array('key' => $template));
- if (!$template) {
- Dever::error('消息模板不存在');
- }
- if ($template['type'] == 2) {
- $state = Dever::load('type/code', 'msg')->check($template['id'], $account, $code, $update);
- if (!$state) {
- Dever::error('验证码错误');
- }
- }
- }
- }
|