请问如何判断当前的验证码是来自用户注册还是修改手机还是重置密码?
官方代码中的短信发送方法中传递的参数无法判断,现在需要根据不同的操作发送不同的短信模板,请问有什么办法,谢谢。
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;
}