因为专注
所以专业

Discuz论坛限制只能用中文注册用户名的两种方法

第一种方法:

此方法DiscuzX系都可以实现限制为只能用中文注册,可有效防止注册机恶意注册。

更改“register.htm”文件

template—-default—-member—-register.htm

(我的网站文件使用的是默认模板,那么文件位置就在 www.xueliwuyou.com /template/default/member/register.htm。如使用的不是默认风格 就找你使用的风格包里)

找到

<div class=”rfm”>

<table>

<tr>

<th><span class=”rq”>*</span><label for=”{$this->setting[‘reginput’][‘username’]}”>{lang username}:</label></th>

<td><input type=”text” id=”{$this->setting[‘reginput’][‘username’]}” name=”” class=”px” tabindex=”1″ autocomplete=”off” size=”25″ maxlength=”15″ required /></td>

<td class=”tipcol”><i id=”tip_{$this->setting[‘reginput’][‘username’]}” class=”p_tip”>{lang register_username_tips}</i><kbd id=”chk_{$this->setting[‘reginput’][‘username’]}” class=”p_chk”></kbd></td>

</tr>

</table>

</div>

更改为:

<div class=”rfm”>

<label>提示语:本论坛 『 <font color=red>只接受中文注册</font> 』用户名*</label>

</tr>

</table>

</div>

<div class=”rfm”>

<table>

<tr>

<th><span class=”rq”>*</span><label for=”{$this->setting[‘reginput’][‘username’]}”>{lang username}:</label></th>

<td><input type=”text” id=”{$this->setting[‘reginput’][‘username’]}” name=”” class=”px” tabindex=”1″ autocomplete=”off” size=”25″ maxlength=”15″

onpropertychange=”with(this)if(/[^\u3447-\uFA29]/ig.test(value))value=value.replace(/[^\u3447-\uFA29]/ig,”)” required /></td>

<td class=”tipcol”><i id=”tip_{$this->setting[‘reginput’][‘username’]}” class=”p_tip”>{lang register_username_tips}</i><kbd id=”chk_{$this->setting

[‘reginput’][‘username’]}” class=”p_chk”></kbd></td>

</tr>

</table>

</div>

效果如下:注意红色的字

20200903200551

 

更改“class_member.php”文件

source—-class—-class_member.php

找到

$username = addslashes(trim(dstripslashes($username)));

在它的下面加入

if(!preg_match(“/^[\x7f-\xff]+$/”, $username)) showmessage(‘出错啦!用户名只能全中文。’);

效果如下:

20200903200609

另外一种方法:

后台UCenter管理中心—注册设置—禁止的用户名:

*q*

*w*

*e*

*r*

*t*

*y*

*u*

*i*

*o*

*p*

*a*

*s*

*d*

*f*

*g*

*h*

*j*

*k*

*l*

*z*

*x*

*c*

*v*

*b*

*n*

*m*

*Q*

*W*

*E*

*R*

*T*

*Y*

*U*

*I*

*O*

*A*

*S*

*D*

*F*

*G*

*H*

*J*

*K*

*L*

*Z*

*X*

*C*

*V*

*B*

*N*

*M*

*1*

*2*

*3*

*4*

*5*

*6*

*7*

*8*

*9*

*0*

*1*

*2*

*3*

*4*

*5*

*6*

*7*

*8*

*9*

*0*

未经允许不得转载:肖兴来SEO博客 » Discuz论坛限制只能用中文注册用户名的两种方法
分享到: 更多 (0)

评论 1

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #1

    用英文看起来不是很正规,不过中文还算是不错。一般是限制密码的安全强度。

    秀米下载站3年前 (2020-11-12)回复