Bravo List
Register
Go Back   > Bravo List > Source Code > Trackers > Project U-232
Reply
  #1  
Old 11-05-18, 06:57
mclassic's Avatar
mclassic mclassic is offline
Member
 
Join Date: May 2018
Posts: 2
Default How to modify the registration page to support Chinese user name?
How to modify the registration page to support Chinese user name?
Reply With Quote
  #2  
Old 12-05-18, 11:49
darkalchemy's Avatar
darkalchemy darkalchemy is offline
VIP
 
Join Date: Dec 2017
United States
Posts: 30
Default
Quote:
Originally Posted by mclassic View Post
How to modify the registration page to support Chinese user name?
I am assuming V4.
At least 2 things need to be done.

In check.js, change:

Code:
var url = '../namecheck.php?wantusername=' + escape(wantusername);
to
Code:
var url = '../namecheck.php?wantusername=' + encodeURI(wantusername);
and in namecheck.php, change:
Code:
    $allowedchars = $lang['takesignup_allowed_chars'];
    for ($i = 0; $i < $namelength; ++$i) {
        if (strpos($allowedchars, $username[$i]) === false) return false;
    }
to
Code:
    if (!preg_match("/^[\p{L}\p{N}]+$/u", urldecode($username))) {
        return false;
    }

There are many other areas that also need changed, such as take invites, add user, change username. But, this answers your question. This also allows any valid language letter or number, not just Chinese.

If you want ONLY Chinese, then in namecheck.php, change to:

Code:
    if (!preg_match("/^[\p{Han}]+$/u", urldecode($username))) {
        return false;
    }
This last is untested.
__________________
Pu-239's GitHub Page
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT +2. The time now is 17:44. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2018, vBulletin Solutions Inc.