Page 1 of 3

[REQ] Verify Minecraft Username

Posted: Wed Sep 14, 2011 10:37 pm
by pythros
I have a required field for registration for users on my forum called "Minecraft Username". However, I've been getting bogus bots or people registering that don't have a thing to do with Minecraft let alone play on my Minecraft server. I've seen various of plugins made for MC server owners but not one that verifies the username against Minecraft's own "paid player" database via "http://www.minecraft.net/haspaid.jsp?user=". The player's username would immediately follow = and is case sensitive. It returns back a simple text message of true or false. For example, by checking my Minecraft account by going to http://www.minecraft.net/haspaid.jsp?user=pythros, it would print "true".

What I am exactly requesting is a guide as to how to do this or someone to make it where when the user hits "Submit" on the register page, that it will check the link above for the true/false statement and then allows the user to register to deny them based on the true/false statement. With my coding and logic experience, it doesn't seem it would take a whole lot. However, I know nothing of phpBB API coding :?

Re: [REQ] Verify Minecraft Username

Posted: Thu Sep 15, 2011 10:47 am
by AmigoJack
Open /includes/ucp/ucp_register.php and find:

Code: Select all

            $cp->submit_cp_field('register', $user->get_iso_lang_id(), $cp_data, $error); 
After, add:

Code: Select all

            /*** 2011-09-15 BEGIN AmigoJack
                Check custom fields: has Minecraft nick paid? ***/
            
            // Change "xxxxx" to your actual field name
            define( 'FIELDNAME_MINECRAFT', 'xxxxx' );
            
            if( isset( $cp_data['pf_'. FIELDNAME_MINECRAFT] ) ) {
                $sRes= file_get_contents( 'http://www.minecraft.net/haspaid.jsp?user='. rawurlencode( $cp_data['pf_'. FIELDNAME_MINECRAFT] ) );
                if( strpos( $sRes, 'true' )=== FALSE ) $error[]= 'The Minecraft ID must exist';
            }
            /*** 2011-09-15 END ***/ 
See comment to replace the given string. Untested (because currently I can't request that site).

Re: [REQ] Verify Minecraft Username

Posted: Thu Sep 15, 2011 1:28 pm
by Saldash
pythros, are you validating these custom fields as unique to stop people sharing usernames?
And what's to stop someone from using the username of person they know has paid? :?

Re: [REQ] Verify Minecraft Username

Posted: Fri Sep 16, 2011 4:53 am
by pythros
@AmigoJack
I was first thinking you meant by "Field Name" as Field identification. After I put I in the correct name in there, it worked like a charm! Thank you very much! However, I will let you know that if the incorrect field name is there, it treated it as an incorrect MC username. No harm there since it does work! ^_^

@Saldash
I have a few players who are siblings that only use one account so that part doesn't bother me. It was the fact that I was getting bogus spam accounts and people "spying" on my server from a former server I was on that kept creating accounts. At least this way, I don't have to look up the name manually to see if it is a valid account or not on Minecraft. I do have it as a "requirement" that they use here Minecraft name as their forum name. However, we all know people don't like to read or follow directions. >.>

Re: [REQ] Verify Minecraft Username

Posted: Sat Jan 07, 2012 6:52 pm
by creepinevil
Hello,
I would like to do something very similar to this but instead of the custom field i would like the main username to be their Minecraft name. What altercations would i need to make?

Thanks!

Re: [REQ] Verify Minecraft Username

Posted: Sat Jan 07, 2012 9:01 pm
by AmigoJack
Open /includes/ucp/ucp_register.php and find:

Code: Select all

            $cp->submit_cp_field('register', $user->get_iso_lang_id(), $cp_data, $error); 
After, add:

Code: Select all

            /*** 2012-01-07 BEGIN AmigoJack
                Check username: has Minecraft nick paid? ***/
            $sRes= file_get_contents( 'http://www.minecraft.net/haspaid.jsp?user='. rawurlencode( $data['username'] ) );
            if( strpos( $sRes, 'true' )=== FALSE ) $error[]= 'The username must exist on Minecraft';
            /*** 2012-01-07 END ***/ 

Re: [REQ] Verify Minecraft Username

Posted: Sat Jan 07, 2012 9:55 pm
by creepinevil
AmigoJack wrote:Open /includes/ucp/ucp_register.php and find:

Code: Select all

            $cp->submit_cp_field('register', $user->get_iso_lang_id(), $cp_data, $error); 
After, add:

Code: Select all

            /*** 2012-01-07 BEGIN AmigoJack
                Check username: has Minecraft nick paid? ***/
            $sRes= file_get_contents( 'http://www.minecraft.net/haspaid.jsp?user='. rawurlencode( $user-> data['username'] ) );
            if( strpos( $aRes, 'true' )=== FALSE ) $error[]= 'The username must exist on Minecraft';
            /*** 2012-01-07 END ***/ 

Hi,

This doesn't seem to work... Players who are using their existing Minecraft account usernames get denied (The username must exist on Minecraft)

Re: [REQ] Verify Minecraft Username

Posted: Sat Jan 07, 2012 11:51 pm
by AmigoJack
My fault: $user-> data['username'] must be $data['username'] - I've edited my post.

Re: [REQ] Verify Minecraft Username

Posted: Sun Jan 08, 2012 1:13 am
by creepinevil
AmigoJack wrote:My fault: $user-> data['username'] must be $data['username'] - I've edited my post.
Still no luck D:

Re: [REQ] Verify Minecraft Username

Posted: Sun Jan 08, 2012 1:33 am
by AmigoJack
Then you have to give at least one example username which is refused at registration but which exists on Minecraft.

Re: [REQ] Verify Minecraft Username

Posted: Sun Jan 08, 2012 1:59 am
by creepinevil
The names we tried were:
  • Creepinevil
    EC2Jonathan
    DeFuZee
    SteamAnimator
    Ret311
    Spaniol
    Alexxa3889
    bigboyhy4
    Cho_gall
Used in case sensitive, then in all caps, then in lowercase.

:S

EDIT:

I will try to set it up again, i need to change some other things first that are unrelated.

Re: [REQ] Verify Minecraft Username

Posted: Sun Jan 08, 2012 2:39 am
by AmigoJack
Found a typo, so it never worked in the first place. $aRes must be $sRes. Updated my both code posts and now also tested it: all your given names exist, except Alexxa3889 (found out it was also a typo, because Alexa3889 exists).

Re: [REQ] Verify Minecraft Username

Posted: Mon Jan 09, 2012 10:48 pm
by creepinevil
Works perfectly!

Thanks!

Re: [REQ] Verify Minecraft Username

Posted: Sun Aug 12, 2012 9:13 am
by codman1
AmigoJack wrote:Open /includes/ucp/ucp_register.php and find:

Code: Select all

            $cp->submit_cp_field('register', $user->get_iso_lang_id(), $cp_data, $error);  
After, add:

Code: Select all

            /*** 2011-09-15 BEGIN AmigoJack
                Check custom fields: has Minecraft nick paid? ***/
            
            // Change "xxxxx" to your actual field name
            define( 'FIELDNAME_MINECRAFT', 'xxxxx' );
            
            if( isset( $cp_data['pf_'. FIELDNAME_MINECRAFT] ) ) {
                $sRes= file_get_contents( 'http://www.minecraft.net/haspaid.jsp?user='. rawurlencode( $cp_data['pf_'. FIELDNAME_MINECRAFT] ) );
                if( strpos( $sRes, 'true' )=== FALSE ) $error[]= 'The Minecraft ID must exist';
            }
            /*** 2011-09-15 END ***/  
See comment to replace the given string. Untested (because currently I can't request that site).
Hi, I'm sorry for bumping this old topic but my request in part uses the above. I just wondered is there a way to make the custom field for the Minecraft Username be unique as I personally would like that feature along with the verifying of the username.

Re: [REQ] Verify Minecraft Username

Posted: Sun Aug 12, 2012 5:00 pm
by Saldash
Which ever way you do it, you still can't truly validate the Minecraft username..
All you can do is check to see if the account has bought the game, not whether that person is who they say they are.

I could create a bogus account, use a minecraft username I know has paid and then access your site.
And doubly, because your making it unique, if the real person wanted to sign up they couldn't because they'd already be registered...

It's just a bad way of managing the whole thing..

You'd be better off allowing accounts to be created but put them in a default group with no access...
On a separate page, have the verifier (if the minecraft API will allow it) check the username and password combination. You don't even have to store more than just a check key of 1 or 0. Or if you must you can then store the username..

But as it stands at the moment, your way is very open to misuse.