============================================================================================================================
Modification Name: Username Validation

Version: 1.0

Author: Area51mafia

Description: This modification will do a few things:
 - List all forbidden characters on the registration page so members will not try to register with forbidden characters.
 - If members do decide to ignore all warnings, the error message shows will not say the username is restricted, but it will say that there's a forbidden character in the username.
 - It will tell whether a username is already taken or not.
 - Will perform the default username checks before submitting the form, so members don't need to go back and fill out the entire registration form again if there was something wrong with their username.

Compatibility: XMB 1.9.5 SP1

Code based on coding from: http://www.cyberdummy.co.uk/
Enhanced for XMB compatiblity by: FunForum

License Note: This modification is released under the GPL License v3. A copy is provided with this software package.

Note: For your own safety, backup the effected PHP file and template before proceeding with this modification.
============================================================================================================================
=======
Step 1:
=======

Upload to your forum's /include/ directory:
 - usernamecheck.inc.php
 - Sajax2.inc.php

============================================================================================================================
=======
Step 2:
=======
=================
Edit File: member.php
=================
==========
Find Code:
==========

    if (!isset($regsubmit)) {

================
Replace Code With:
================

    if (!isset($regsubmit)) {
        // Username Validation Mod Begin
        include ROOT.'include/usernamecheck.inc.php';
        // Username Validation Mod End

==========
Find Code:
==========

            eval('echo stripslashes("'.template('member_reg').'");');

===============
Add Code Above:
===============

            // Username Validation Mod Begin
            $find = array('<', '>', '|', '"', '[', ']', '\\', ',', '@', '\'', ' ');
            $bad_chars = array();
            foreach($find as $char) {
                if ($char == ' ') {
                    $char = '<em>Space</em>'; }
                if ($char == '\\') {
                    $char = '&#92;';
                }
                $bad_chars[] = '<strong>'.$char.'</strong>';
            }
            $bad_chars = implode('&nbsp; &nbsp; &nbsp;', $bad_chars);
            // Username Validation Mod End

==========
Find Code:
==========

        foreach ($find as $needle) {
            if (false !== strpos($username, $needle)) {
                error($lang['restricted']);
            }
        }

================
Replace Code With:
================

        foreach ($find as $needle) {
            if (false !== strpos($username, $needle)) {
                error($lang['regunbadchar']);
            }
        }

============================================================================================================================
=======
Step 3:
=======
=======================
Edit File: lang/English.lang.php
=======================
============================
Add Code To End Of File Above  ?>
============================

// Username Validation Mod Begin
$lang['listbadchars'] = 'Banned username characters:';
$lang['regunbadchar'] = 'Invalid character(s) has/have been detected in your username! Please go back and try again!';
$lang['regunstatus0'] = 'Username status:';
$lang['regunstatus1'] = 'Username is available!';
$lang['regunstatus2'] = 'Sorry that username is not available.';
$lang['regunstatus3'] = 'You used a forbidden character in your username.';
$lang['regunstatus4'] = 'Sorry that username is not available, please try one of these:';
// Username Validation Mod End

============================================================================================================================
=======
Step 4:
=======
===============================
Go To Administration Panel --> Templates
===============================
===============
Edit Template: css
===============
==========
Find Code:
==========

/* for bbcode code table */
table.code {

===============
Add Code Above:
===============

#not_available , #available , #char_forbidden , #char_length , #restricted {
    display: none;
}

============================================================================================================================
=======
Step 5:
=======
===============================
Go To Administration Panel --> Templates
===============================
=====================
Edit Template: member_reg
=====================
==========
Find Code:
==========

<tr>
<td bgcolor="$altbg1" width="22%" class="tablerow" >$lang[textusername]</td>
<td bgcolor="$altbg2" class="tablerow"><input type="text" name="username" size="25" maxlength="25" /></td>
</tr>

================
Replace Code With:
================

<tr class="tablerow">
<td bgcolor="$altbg1" width="22%">$lang[textusername]</td>
<td bgcolor="$altbg2"><input type="text" name="username" id="username" onblur="check_user_exist(); return false;" size="25" maxlength="25" /></td>
</tr>
<tr class="tablerow">
<td bgcolor="$altbg1" width="22%">$lang[listbadchars]</td>
<td bgcolor="$altbg2">$bad_chars</td>
</tr>
<tr class="tablerow">
<td bgcolor="$altbg1" width="22%">$lang[regunstatus0]</td>
<td bgcolor="$altbg2">
<div id="available">
$lang[regunstatus1]
</div>
<div id="not_available">
$lang[regunstatus2]
</div>
<div id="restricted">
$lang[restricted]
</div>
<div id="char_forbidden">
$lang[regunstatus3]
</div>
<div id="char_length">
$lang[username_length_invalid]
</div>
</td>
</tr>

============================================================================================================================
Enjoy!