Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   Project U-232 (http://www.bvlist.com/forumdisplay.php?f=80)
-   -   How to modify the registration page to support Chinese user name? (http://www.bvlist.com/showthread.php?t=11570)

mclassic 11th May 2018 06:57

How to modify the registration page to support Chinese user name?
 
How to modify the registration page to support Chinese user name?

darkalchemy 12th May 2018 11:49

Quote:

Originally Posted by mclassic (Post 51862)
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.


All times are GMT +2. The time now is 21:43.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.