联系官方销售客服

1835022288

028-61286886

开发框架 版主:迅睿框架研发组
如何判断当前的验证码是来自用户注册还是修改手机还是重置密码?
类型:迅睿CMS 更新时间:2020-12-08 21:13:21

请问如何判断当前的验证码是来自用户注册还是修改手机还是重置密码?

官方代码中的短信发送方法中传递的参数无法判断,现在需要根据不同的操作发送不同的短信模板,请问有什么办法,谢谢。

public function sendsms_text($mobile, $content, $type = 'text') {

    if (!$mobile || !$content) {
        return dr_return_data(0, dr_lang('手机号码或内容不能为空'));
    }

    $file = WRITEPATH.'config/sms.php';
    if (!is_file($file)) {
        log_message('error', '短信接口配置文件不存在');
        return dr_return_data(0, dr_lang('接口配置文件不存在'));
    }

    $config = require_once $file;
    if ($config['third']) {
        if (is_file(ROOTPATH.'config/mysms.php')) {
            require_once ROOTPATH.'config/mysms.php';
        }
        $method = 'my_sendsms_'.$type;
        if (function_exists($method)) {
            return call_user_func_array($method, [
                $mobile,
                $content,
                $config['third'],
            ]);
        } else {
            $error = dr_lang('你没有定义第三方短信接口: '. $method);
            @file_put_contents(WRITEPATH.'sms_log.php', date('Y-m-d H:i:s').' ['.$mobile.'] ['.$error.'] ('.str_replace(array(chr(13), chr(10)), '', $content).')'.PHP_EOL, FILE_APPEND);
            return dr_return_data(0, $error);
        }
    } else {
        $content = $type == 'code' ? dr_lang('您的本次验证码是: %s', $content) : $content;
        $url = 'https://www.xunruicms.com/index.php?s=vip&c=home&uid='.$config['uid'].'&key='.$config['key'].'&mobile='.$mobile.'&content='.$content.'【'.$config['note'].'】&domain='.trim(str_replace('http://', '', SITE_URL), '/').'&sitename='.SITE_NAME;
        $result = dr_catcher_data($url);
        if (!$result) {
            log_message('error', '访问官方云短信服务器失败');
            return dr_return_data(0, dr_lang('访问官方云短信服务器失败'));
        }
        $result = json_decode($result, true);
    }

    @file_put_contents(WRITEPATH.'sms_log.php', date('Y-m-d H:i:s').' ['.$mobile.'] ['.$result['msg'].'] ('.str_replace(array(chr(13), chr(10)), '', $content).')'.PHP_EOL, FILE_APPEND);

    return $result;
}


回帖
  • #1楼    迅睿框架创始人
    2019-12-19 15:19:44
    Chrome 0
    这个判断不了,是公共类
  • rewalax
    #2楼    rewalax
    2019-12-19 15:24:11
    Chrome 0
    回复迅睿框架创始人 好的明白了,希望可以在原函数sendsms_text()中加入一个自由参数,由开发者自行传参,已在后台提交建议工单,希望可以采纳,谢谢。
    满意答案
  • 往事别了
    #3楼    往事别了
    2019-12-19 15:24:16
    Chrome 0
    一楼说的一定对,除非自己写接口了
  • rewalax
    #4楼    rewalax
    2020-12-08 21:13:21
    Edge 0
    @rewalax:谢谢回复