热搜词
发表于 2024-6-17 19:12:14 | 显示全部楼层 |阅读模式
Discuz! X3.5( dzx3.5)版本,安装“注册短信验证_商户赞助版v7.8.5 (zhanmishu_sms)”插件,新注册用户时提示"手机号码格式错误"

zhanmishu_sms_手机号码格式错误.png

后台插件设置中的“手机号正则规则”设置如下:

手机号正则规则.png

解决方法:
1.手机号正则规则改一下,修改后如下:

修改-手机号正则规则.png

2.修改source/plugin/zhanmishu_sms/include/top/zhanmishu_sms.php 这个文件,变动的相关代码如下:

  1.         if (!$this->verify_mobile_number($phone, $nationcode)) {
  2.             $return = array('code' => '-91', 'msg' => $this->to_utf8(lang('plugin/zhanmishu_sms', 'wrongmobile_number')));
  3.             return $return;
  4.         }
复制代码
  1.     public function verify_mobile_number($phone, $nationcode = '')
  2.     {
  3.         $config = $this->config;
  4.         $flag = false;
  5.         if (file_exists($zmstemplatevarfile = DISCUZ_ROOT . './data/sysdata/cache_zhanmishu_sms.php')) {
  6.             @include $zmstemplatevarfile;
  7.         }

  8.         // 默认没有传手机号
  9.         if (!$nationcode) {
  10.             $nationcode = $this->get_nationcode($phone); // 根据历史记录查询国家编号
  11.         }
  12.         // 还是没有呢?
  13.         if (!$nationcode && strlen($phone) == '11') {
  14.             $nationcode = 86;
  15.         }

  16.         if ($nationcode && $zmstemplatevar['nationcode']) {
  17.             $nations = $zmstemplatevar['nationcode'];
  18.             if (!empty($nations)) {
  19.                 $isSet = false;
  20.                 foreach ($nations as $key => $value) {
  21.                     if ($value['value'] == $nationcode) {
  22.                         $flag = true;
  23.                     }
  24.                     if($value['value'] > 0) {
  25.                         $isSet = true;
  26.                     }
  27.                 }
  28.                 if (!$isSet) {
  29.                     $flag = true;
  30.                 }
  31.             }
  32.         } else {
  33.             // 没有国家编号,即不校验国家吧
  34.             $flag = true;
  35.         }

  36.         if (!$flag || !preg_match($config['mobilerule'], $phone)) {
  37.             return false;
  38.         }

  39.         return true;
  40.     }
复制代码


全部评论0
回复
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|小黑屋|管理员之家 ( 苏ICP备2023053177号-2 )

GMT+8, 2024-6-26 21:48 , Processed in 0.191642 second(s), 26 queries .

Powered by Discuz! X3.5

Cpoyright © 2001-2024 Discuz! Team