注册短信验证_商户赞助版v7.8.5 (zhanmishu_sms)提示"手机号码格式错误"
Discuz! X3.5( dzx3.5)版本,安装“注册短信验证_商户赞助版v7.8.5 (zhanmishu_sms)”插件,新注册用户时提示"手机号码格式错误"后台插件设置中的“手机号正则规则”设置如下:
解决方法:
1.手机号正则规则改一下,修改后如下:
2.修改source/plugin/zhanmishu_sms/include/top/zhanmishu_sms.php 这个文件,变动的相关代码如下:
if (!$this->verify_mobile_number($phone, $nationcode)) {
$return = array('code' => '-91', 'msg' => $this->to_utf8(lang('plugin/zhanmishu_sms', 'wrongmobile_number')));
return $return;
}
public function verify_mobile_number($phone, $nationcode = '')
{
$config = $this->config;
$flag = false;
if (file_exists($zmstemplatevarfile = DISCUZ_ROOT . './data/sysdata/cache_zhanmishu_sms.php')) {
@include $zmstemplatevarfile;
}
// 默认没有传手机号
if (!$nationcode) {
$nationcode = $this->get_nationcode($phone); // 根据历史记录查询国家编号
}
// 还是没有呢?
if (!$nationcode && strlen($phone) == '11') {
$nationcode = 86;
}
if ($nationcode && $zmstemplatevar['nationcode']) {
$nations = $zmstemplatevar['nationcode'];
if (!empty($nations)) {
$isSet = false;
foreach ($nations as $key => $value) {
if ($value['value'] == $nationcode) {
$flag = true;
}
if($value['value'] > 0) {
$isSet = true;
}
}
if (!$isSet) {
$flag = true;
}
}
} else {
// 没有国家编号,即不校验国家吧
$flag = true;
}
if (!$flag || !preg_match($config['mobilerule'], $phone)) {
return false;
}
return true;
}
页:
[1]