=======================================================================================================

Hack Name: Username Length Control v3.0

Author: Jonathon of JDMnet ( jonathon@jdmnet.org | www.jdmnet.org )
Updated for 1.9.8 by: WormHole @ XMB Garage

Last Updated: 11/16/07

Description:
Allows you to control how long; or short; of usernames you will allow people to register with.
Minimum being 1 (one) character, maximum being 255 characters.

Supported Version: XMB 1.9.8. Do Not Use On Any Other Version Of XMB.

Notes:

This hack is released under the GPL. You should have recieved a copy of it with this hack.

Please backup your files before installing this mod. Neither XMB Garage nor the author can be held 
responsible if your board stops functioning properly due to you installing this hack.

NOTES:
 - Back up all templates, PHP files, and database BEFORE proceeding
 - This version is designed for 1.9.8 and may not work with any previous version of 1.9.x.
 - Long dashes are NOT part of the actual code; unless otherwise stated
 - Directions are based on a default/un-modified board. You may need to do a little searching for the code if you have already modified your forums
 - DO NOT upload any files until told to do so.

=======================================================================================================

=======
Step 1:
=======

=============================
Go To Admin Panel -> Insert Raw SQL
=============================

=========================================
Paste the following code in the textarea box and hit submit:
=========================================

ALTER TABLE `$table_members` CHANGE `username` `username` VARCHAR(225) NOT NULL;
ALTER TABLE `$table_settings` 
 ADD `namecontrol` CHAR(3) DEFAULT 'on' NOT NULL,
 ADD `namelength` INT(3) DEFAULT '25' NOT NULL;

=======================================================================================================

=======
Step 2:
=======

=================
Edit File: member.php
=================

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

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

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

                // Username Length Control Mod Begin
                $max_length = $length = $username_control = '';
                if ( $SETTINGS['namecontrol'] == 'on' ) {
                    // controls the length of the username box -- if turned "on"
                    $max_length = $SETTINGS['namelength'];
                    $length = ($SETTINGS['namelength'] + 8);

                    $username_control = '<input type="text" name="username" size="' .$length. '" maxlength="' .$max_length. '" /><br />&nbsp;<small><em>' .$lang['namecontrol_text1'].$max_length. '.</e></small>';
                } elseif ( $SETTINGS['namecontrol'] == 'off' ) {
                    // default size if turned off
                    // do not change this part
                    $username_control = '<input type="text" name="username" size="25" maxlength="25" /><br />&nbsp;<small><em>' .$lang['namecontrol_text1']. ' 25.</e></small>';
                }
                // Username Length Control Mod End

=======================================================================================================

=======
Step 3:
=======

=============
Edit File: cp.php
=============

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

        $onselect = $offselect = '';
        settingHTML('bbstatus', $onselect, $offselect);

===============
Add Code Below:
===============

        // Username Length Control Mod Begin
        $namecontrol_on = $namecontrol_off = '';
        settingHTML('namecontrol', $namecontrol_on, $namecontrol_off);
        // Username Length Control Mod End

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

        printsetting2($lang['pruneusers'], 'pruneusersnew', ((int)$SETTINGS['pruneusers']), 3);

===============
Add Code Below:
===============

        // Username Length Control Mod Begin
        printsetting1($lang['namecontrol_settings1'], 'namecontrol_new', $namecontrol_on, $namecontrol_off);
        printsetting2($lang['namecontrol_settings2'], 'namecontrol_length_new', $SETTINGS['namelength'], 3);
        // Username Length Control Mod End

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

        $allowrankeditnew = formOnOff('allowrankeditnew');

===============
Add Code Below:
===============

        // Username Length Control Mod Begin
        $namecontrol_new = formOnOff('namecontrol_new');
        // Username Length Control Mod End

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

            showsubforums='$showsubforumsnew'

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

            showsubforums='$showsubforumsnew',
            namecontrol='$namecontrol_new',
            namelength='$namecontrol_length_new'

=======================================================================================================

=======
Step 4:
=======

===================
Edit File: English/lang.php
===================

================
Find At End Of File
================

?>

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

// Username Length Control Mod Begin
$lang['namecontrol_text1'] = 'Maximum amount of characters:';
$lang['namecontrol_settings1'] = "Control Username's Lengths?";
$lang['namecontrol_settings2'] = 'Max amount of characters allowed:<br><small><em>Please note that above option must be selected; plus, you can not set the limit above 255</em></small>';
// Username Length Control Mod End

=======================================================================================================

=======
Step 5:
=======

============================================
NOW UPLOAD ALL EDIT FILES OVER THE OLD FILES

TO RE-CAP - THE EDITED FILES ARE:
 - member.php
 - cp.php
 - YOUR LANG FILE
============================================

=======================================================================================================

=======
Step 3:
=======

=====================
Edit Template: member_reg
=====================

<input type="text" name="username" size="25" maxlength="25" />

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

$username_control

=======================================================================================================

By default this option is turned to on and the maximum characters are set to 25 (the default for a fresh install of 1.9.8).

You will need to go to your admin panel then to Settings and look under the "User Control" section. It will be listed last.

=======================================================================================================