本帖最后由 CoolRock 于 2012-5-3 08:58 编辑
适用于与Discuz! X2.0 / Discuz! X2.5
以 修改 用户名最小值为 5 为例说明。最大值一次类推
1.先修改 语言包
/source/language/lang_message.php- 'profile_username_tooshort' => '抱歉,您输入的用户名小于 5 个字符,请输入一个较长的用户名',
复制代码 /source/language/member/lang_template.php
- 'register_username_tips' => '用户名由 5 到 15 个字符组成',
复制代码 2.修改js
/static/js/register.js
- var unlen = username.replace(/[^\x00-\xff]/g, "**").length;
- if(unlen < 3 || unlen > 15) {
- errormessage(id, unlen < 3 ? '用户名小于 3 个字符' : '用户名超过 15 个字符');
- return;
- }
复制代码 修改为
- var unlen = username.replace(/[^\x00-\xff]/g, "**").length;
- if(unlen < 5 || unlen > 15) {
- errormessage(id, unlen < 5 ? '用户名小于 5 个字符' : '用户名超过 15 个字符');
- return;
- }
复制代码3.修改注册文件 source/class/class_member.php - $usernamelen = dstrlen($username);
- if($usernamelen < 3) {
- showmessage('profile_username_tooshort');
- } elseif($usernamelen > 15) {
- showmessage('profile_username_toolong');
- }
复制代码 修改为- $usernamelen = dstrlen($username);
- if($usernamelen < 5) {
- showmessage('profile_username_tooshort');
- } elseif($usernamelen > 15) {
- showmessage('profile_username_toolong');
- }
复制代码 /source/module/forum/forum_ajax.php- $username = trim($_G['gp_username']);
- $usernamelen = dstrlen($username);
- if($usernamelen < 3) {
- showmessage('profile_username_tooshort', '', array(), array('handle' => false));
- } elseif($usernamelen > 15) {
- showmessage('profile_username_toolong', '', array(), array('handle' => false));
- }
复制代码 修改为- $username = trim($_G['gp_username']);
- $usernamelen = dstrlen($username);
- if($usernamelen < 5) {
- showmessage('profile_username_tooshort', '', array(), array('handle' => false));
- } elseif($usernamelen > 15) {
- showmessage('profile_username_toolong', '', array(), array('handle' => false));
- }
复制代码 /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("/\s+|^c:\\con\\con|[%,\*"\s\<\>\&]|$guestexp/is", $username)) {
- return FALSE;
- } else {
- return TRUE;
- }
- }
复制代码 修改为- 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 < 5 || preg_match("/\s+|^c:\\con\\con|[%,\*"\s\<\>\&]|$guestexp/is", $username)) {
- return FALSE;
- } else {
- return TRUE;
- }
- }
复制代码 4.修改Ucenter 独立安装位置: /model/user.php 非独立安装Ucenter位置: /uc_server/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("/\s+|^c:\\con\\con|[%,\*"\s\<\>\&]|$guestexp/is", $username)) {
- return FALSE;
- } else {
- return TRUE;
- }
- }
复制代码 修改为- 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 < 5 || preg_match("/\s+|^c:\\con\\con|[%,\*"\s\<\>\&]|$guestexp/is", $username)) {
- return FALSE;
- } else {
- return TRUE;
- }
- }
复制代码 修改完整,修改最大长度 一次类推修改!! 请支持 下 www.doopen.net
感谢 qqchunchun 的细心
|