码迷,mamicode.com
首页 > 其他好文 > 详细

discuz 限制只能中文注册用户名称

时间:2014-07-20 22:01:28      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:discuz   style   strong   os   io   for   

1:修改uc_client\model\user.php
 function check_username($username) {
  $guestexp = ‘\xA1\xA1|\xAC\xA3|^Guest|^\xD3\xCE\xBF\xCD|\xB9\x43\xAB\xC8‘;
  $len = $this->dstrlen($username);
  if($len > 15 || $len < 3 || !(preg_match("/^[\x{4e00}-\x{9fa5}]+$/u",$username)) || preg_match("/\s+|^c:\\con\\con|[%,\*\"\s\<\>\&]|$guestexp/is", $username)) {
   return FALSE;
  } else {
   return TRUE;
  }
 }
 
2:修改source\language\lang_message.php
在229行左右加 一个错误消息
  ‘profile_username_tooshort‘ => ‘抱歉,您输入的用户名小于 3 个字符,请输入一个较长的用户名‘,
    ‘profile_username_notallchinese‘ => ‘抱歉,用户名必须全部是中文‘,
‘profile_username_toolong‘ => ‘抱歉,您的用户名超过 15 个字符,请输入一个较短的用户名‘,
 
3:source\module\forum\forum_ajax.php
在20行左右加一个判断
if($usernamelen < 3) {
  showmessage(‘profile_username_tooshort‘, ‘‘, array(), array(‘handle‘ => false));
 } elseif($usernamelen > 15) {
  showmessage(‘profile_username_toolong‘, ‘‘, array(), array(‘handle‘ => false));
 }
  if(!(preg_match("/^[\x{4e00}-\x{9fa5}]+$/u",$username))) {
   showmessage(‘profile_username_notallchinese‘, ‘‘, array(), array(‘handle‘ => false));
 }
 
4:source\class\class_member.php
在581行左右加一个判断
if($usernamelen < 3) {
     showmessage(‘profile_username_tooshort‘);
    } elseif($usernamelen > 15) {
     showmessage(‘profile_username_toolong‘);
    }
    if(!(preg_match("/^[\x{4e00}-\x{9fa5}]+$/u",$username))) {
       showmessage(‘profile_username_notallchinese‘);
    }

discuz 限制只能中文注册用户名称,布布扣,bubuko.com

discuz 限制只能中文注册用户名称

标签:discuz   style   strong   os   io   for   

原文地址:http://www.cnblogs.com/csandroid/p/3856540.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!