Resource icon

Require people register on forums with minecraft username

Sway

Active member
#1
Sway submitted a new resource:

Make people register on forums with minecraft username - Require members to register with a valid minecraft username

Locate Register.php (/web/root/library/XenForo/ControllerPublic/Register.php)
Find
/**
* Gets data from the registration form
*
* @return array [$data, $passwords]
*/
protected function _getRegistrationDataFromInput()
{
$data = $this->_input->filter(array(
'username' => XenForo_Input::STRING,
'email' => XenForo_Input::STRING,
'timezone' => XenForo_Input::STRING,
'gender' => XenForo_Input::STRING,
'dob_day' => XenForo_Input::UINT,
'dob_month' =>...
Read more about this resource...
 

Sway

Active member
#4

tyteen4a03

Well-known member
#5
/library/MinecraftAvatar/ControllerPublic/Register.php You're going to have to do the same thing.

It's 4 lines of code.
4 lines of code which you need to apply again and again for each update, and cannot be easily disabled.

Writing a full-fledged addon isn't that hard, especially since you've already written this.
 

tyteen4a03

Well-known member
#7
Here is a repackaged full-fledged addon. It also fixes a bug where it is not throwing errors correctly ($errors array does not exist in that function).

This only works with 1.2.

I don't really want to maintain it, but I suggest putting the username check on a Deferred task in case MC.net derps (which happens more than you think)
 

Attachments

Sway

Active member
#8
The only reason i have not made an add-on is 1. because i don't know php. and 2. because i cbf to get into XF development. I only released this because i had permission from the two credited in OP. I just wanted to share with others that may run minecraft related forums.
 

tyteen4a03

Well-known member
#9
The only reason i have not made an add-on is 1. because i don't know php. and 2. because i cbf to get into XF development. I only released this because i had permission from the two credited in OP. I just wanted to share with others that may run minecraft related forums.
You don't? Since you released the code I thought you did.

Oh well. I'll maintain it in my spare time I guess.
 
#12
Hmm, I added these four lines of code to Register.php on the right location, and added the phrase. I still can register an account where the username would return false on minecraft.net. I cleared my opcode cache, but it still seems to not work, am I forgetting something?

This is the code from Register.php:

Code:
        /**
        * Gets data from the registration form
        *
        * @return array [$data, $passwords]
        */
        protected function _getRegistrationDataFromInput()
        {
                $data = $this->_input->filter(array(
                        'username'  => XenForo_Input::STRING,
                        'email'      => XenForo_Input::STRING,
                        'timezone'  => XenForo_Input::STRING,
                        'gender'    => XenForo_Input::STRING,
                        'dob_day'    => XenForo_Input::UINT,
                        'dob_month'  => XenForo_Input::UINT,
                        'dob_year'  => XenForo_Input::UINT,
                ));

        $sRes= file_get_contents( 'http://www.minecraft.net/haspaid.jsp?user='. rawurlencode( $data['username'] ) );
        if( strpos( $sRes, 'true' )=== FALSE )
        {
                $errors[] = new XenForo_Phrase('invalid_minecraft_user');
        }


                $passwords = $this->_input->filter(array(
                        'password' => XenForo_Input::STRING,
                        'password_confirm' => XenForo_Input::STRING,
                ));

                return array($data, $passwords);
        }
 

Sway

Active member
#13
Hmm, I added these four lines of code to Register.php on the right location, and added the phrase. I still can register an account where the username would return false on minecraft.net. I cleared my opcode cache, but it still seems to not work, am I forgetting something?

This is the code from Register.php:

Code:
        /**
        * Gets data from the registration form
        *
        * @return array [$data, $passwords]
        */
        protected function _getRegistrationDataFromInput()
        {
                $data = $this->_input->filter(array(
                        'username'  => XenForo_Input::STRING,
                        'email'      => XenForo_Input::STRING,
                        'timezone'  => XenForo_Input::STRING,
                        'gender'    => XenForo_Input::STRING,
                        'dob_day'    => XenForo_Input::UINT,
                        'dob_month'  => XenForo_Input::UINT,
                        'dob_year'  => XenForo_Input::UINT,
                ));

        $sRes= file_get_contents( 'http://www.minecraft.net/haspaid.jsp?user='. rawurlencode( $data['username'] ) );
        if( strpos( $sRes, 'true' )=== FALSE )
        {
                $errors[] = new XenForo_Phrase('invalid_minecraft_user');
        }


                $passwords = $this->_input->filter(array(
                        'password' => XenForo_Input::STRING,
                        'password_confirm' => XenForo_Input::STRING,
                ));

                return array($data, $passwords);
        }
If you have another add-on that has a Register.php that would do it. You need to make sure any other add-ons with a Register.php have those 4 lines of code as well. MinecraftAvatar add-on has it's own Register.php, so if you're using that, you need to add those 4 lines.
 

tyteen4a03

Well-known member
#15
If you have another add-on that has a Register.php that would do it. You need to make sure any other add-ons with a Register.php have those 4 lines of code as well. MinecraftAvatar add-on has it's own Register.php, so if you're using that, you need to add those 4 lines.
It is actually a bug in your code mod. See my repackaged add on for fix.
 
Top