[REQ] Verify Minecraft Username

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Get Involved
User avatar
Saldash
Registered User
Posts: 619
Joined: Mon Nov 10, 2008 8:08 am
Location: Flintshire, UK
Name: Stuart Jackson
Contact:

Re: [REQ] Verify Minecraft Username

Post by Saldash »

This is why I suggested having a separate method of verification.

I's very unfortunate that, for now at least, minecraft does not have an API function specifically for this.
So yes, the only thing stopping people falsifying information is their conscience, and as the site owner you would be none the wiser :?

By all means, verify whether an account has paid, but it's not a very good defense.
World Recoded UK - DreamHost Site of the Month winner February 2011!
codman1
Registered User
Posts: 3
Joined: Sun Aug 12, 2012 9:09 am

Re: [REQ] Verify Minecraft Username

Post by codman1 »

Saldash wrote: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.
Hiya, I fully understand where your coming from let me just explain a little further. I am not really bothered if someone does use someone elses username I'm purely using it so that people can sort of think "Oh thats xxx in game". The main reason I wanted it to be Unique is because I and the other admins have signed up with their legit in game names and we didn't one a new person using our names as this really could confuse people. So if rather than making the code use a unique name we could exclude some names i.e. our in game names that would be just as good.

Regards,
Codman
User avatar
AmigoJack
Registered User
Posts: 5782
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: [REQ] Verify Minecraft Username

Post by AmigoJack »

codman1 wrote:a unique name
As I don't know Minecraft's rules: can you define this? I.e. for phpBB a unique username is not affected by case sensitivity (latin characters only) or leading/trailing whitespaces.
  • The worst thing about censorship is ███████████
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
codman1
Registered User
Posts: 3
Joined: Sun Aug 12, 2012 9:09 am

Re: [REQ] Verify Minecraft Username

Post by codman1 »

AmigoJack wrote:
codman1 wrote:a unique name
As I don't know Minecraft's rules: can you define this? I.e. for phpBB a unique username is not affected by case sensitivity (latin characters only) or leading/trailing whitespaces.
Hiya yeh Minecraft does not appear to be case sensitive and only can use letters numbers and _

Regards
User avatar
AmigoJack
Registered User
Posts: 5782
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: [REQ] Verify Minecraft Username

Post by AmigoJack »

Open /includes/functions_profile_fields.php and find:

Code: Select all

        while ($row = $db->sql_fetchrow($result))
        {
            $cp_data['pf_' . $row['field_ident']] = $this->get_profile_field($row);
            $check_value = $cp_data['pf_' . $row['field_ident']];
After, add:

Code: Select all

            /*** 2012-08-23 BEGIN AmigoJack
                Check unique value, in this case: Minecraft username.
                Error messages are in EN only. ***/
            if( $row['field_ident']== 'minecraft'  // Change 'minecraft' to your custom IDENT
             && $check_value
              ) {
                // Characters allowed
                if( !preg_match( '#[a-zA-Z0-9_]+#', $check_value ) ) $cp_error[]= sprintf( 'The field "%s" has invalid characters, only letters, numbers and underscores are allowed.', $row['lang_name'] );

                // Each user must have another value
                $iExist= 0;
                $sSql= 'SELECT user_id
                    FROM '. PROFILE_FIELDS_DATA_TABLE. '
                    WHERE pf_'. $row['field_ident']. '= \''. $db-> sql_escape( $check_value ). '\'';
                $hResult= $db-> sql_query( $sSql );
                while( $aRow= $db-> sql_fetchrow( $hResult ) ) $iExist++;
                if( $iExist ) $cp_error[]= sprintf( 'The name "%s" in the field "%s" is already used by another member.', $check_value, $row['lang_name'] );
            }
            /*** 2012-08-23 END ***/
As the comment indicates: change minecraft to the identification you have given. Tested.
  • The worst thing about censorship is ███████████
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
drachenauge1000
Registered User
Posts: 4
Joined: Sat Aug 31, 2013 7:01 am

Re: [REQ] Verify Minecraft Username

Post by drachenauge1000 »

Hey guys!

Sry for bring out this old topic but I have a problem with the code.
I've installed the code the way shown below:
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 ***/
If I want to register a minecraft verified username like "drachenauge1000", the following error is displayed on top of the page:

Code: Select all

[phpBB Debug] PHP Warning: in file [ROOT]/includes/ucp/ucp_register.php on line 236: file_get_contents() [function.file-get-contents]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0
[phpBB Debug] PHP Warning: in file [ROOT]/includes/ucp/ucp_register.php on line 236: file_get_contents(http://www.minecraft.net/haspaid.jsp?user=drachenauge1000) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4718: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4720: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4721: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4722: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
By the way, it displays the message:

Code: Select all

The username must exist on Minecraft
Can anybody help me with this problem?
Sry for my bad english, but i've learned it only in school. :D

drachenauge1000
Last edited by drachenauge1000 on Sun Sep 01, 2013 10:30 am, edited 1 time in total.
User avatar
AmigoJack
Registered User
Posts: 5782
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: [REQ] Verify Minecraft Username

Post by AmigoJack »

drachenauge1000 wrote:thread
Topic.
drachenauge1000 wrote:

Code: Select all

[function.file-get-contents]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0
That's a PHP setting - either ask your hoster to enable this for you or apply the modification below, which requires cURL to be installed.

In my code, find:

Code: Select all

            $sRes= file_get_contents( 'http://www.minecraft.net/haspaid.jsp?user='. rawurlencode( $user-> data['username'] ) ); 
Replace with: 

Code: Select all

            $hCurl= curl_init( 'http://www.minecraft.net/haspaid.jsp?user='. rawurlencode( $user-> data['username'] ) );
            curl_setopt( $hCurl, CURLOPT_RETURNTRANSFER, 1 );
            $sRes= curl_exec( $hCurl );
            curl_close( $hCurl );
Untested.
  • The worst thing about censorship is ███████████
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
drachenauge1000
Registered User
Posts: 4
Joined: Sat Aug 31, 2013 7:01 am

Re: [REQ] Verify Minecraft Username

Post by drachenauge1000 »

Thanks for response. I activated allow_url_fopen in the server configuration.

It fixed the error but if i want register a paid minecraft account (drachenauge1000) it always displays this message:

Code: Select all

The username must exist on Minecraft
I try to install cURL on the server but I didnt' find the correct file. Can you send me the downloadlink?

drachenauge1000
User avatar
Sajaki
Registered User
Posts: 1372
Joined: Mon Mar 02, 2009 1:41 pm
Location: Amsterdam
Contact:

Re: [REQ] Verify Minecraft Username

Post by Sajaki »

drachenauge1000 wrote:I try to install cURL on the server but I didnt' find the correct file. Can you send me the downloadlink?
drachenauge1000
  • sudo apt-get install php5-curl
  • sudo service apache2 restart
User avatar
AmigoJack
Registered User
Posts: 5782
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: [REQ] Verify Minecraft Username

Post by AmigoJack »

drachenauge1000 wrote:I've installed the code the way shown below:
AmigoJack wrote:Open /includes/ucp/ucp_register.php and find:

Code: Select all

            if( strpos( $aRes, 'true' )=== FALSE ) $error[]= 'The username must exist on Minecraft';
This code is wrong - read the topic from the very beginning instead of copying outdated code from a quote - it must be $sRes instead of $aRes.
drachenauge1000 wrote:I activated allow_url_fopen
In that case you don't need cURL anymore. Also you might want to update the request URI from http: to https:.
  • The worst thing about censorship is ███████████
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
drachenauge1000
Registered User
Posts: 4
Joined: Sat Aug 31, 2013 7:01 am

Re: [REQ] Verify Minecraft Username

Post by drachenauge1000 »

Thanks man. Works perfectly! :D

drachenauge1000
jlryan92
Registered User
Posts: 3
Joined: Wed Jan 29, 2014 5:36 pm

Re: [REQ] Verify Minecraft Username

Post by jlryan92 »

Hi,

Sorry to be a bother and yet-again re open this thread, but I've decided to do a complete overhaul of my Minecraft servers and forums (moving over from mybb).

I've been using your code, AmigoJack, and so far it's working perfect.

However, instead of verifying a Minecraft Username with the forum's Username, I would like to have a custom field verified against Minecraft's haspaid system, the same custom field that I'm using this code with currently.

Code: Select all

/*** 2012-08-23 BEGIN AmigoJack
                Check unique value, in this case: Minecraft username.
                Error messages are in EN only. ***/
            if( $row['field_ident']== 'minecraft'  // Change 'minecraft' to your custom IDENT
             && $check_value
              ) {
                // Characters allowed
                if( !preg_match( '#[a-zA-Z0-9_]+#', $check_value ) ) $cp_error[]= sprintf( 'The field "%s" has invalid characters, only letters, numbers and underscores are allowed.', $row['lang_name'] );

                // Each user must have another value
                $iExist= 0;
                $sSql= 'SELECT user_id
                    FROM '. PROFILE_FIELDS_DATA_TABLE. '
                    WHERE pf_'. $row['field_ident']. '= \''. $db-> sql_escape( $check_value ). '\'';
                $hResult= $db-> sql_query( $sSql );
                while( $aRow= $db-> sql_fetchrow( $hResult ) ) $iExist++;
                if( $iExist ) $cp_error[]= sprintf( 'The name "%s" in the field "%s" is already used by another member.', $check_value, $row['lang_name'] );
            }
            /*** 2012-08-23 END ***/
I attempted to merge the verification code with this username conflict code with no success, as I don't know much with php.

Regards,
User avatar
AmigoJack
Registered User
Posts: 5782
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: [REQ] Verify Minecraft Username

Post by AmigoJack »

jlryan92 wrote:with no success
What have you done? What did you expect? What happened instead?

The instructions are clear on where to insert the code and how to identify your custom profile field, so I have no clue where you failed exactly.
  • The worst thing about censorship is ███████████
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
jlryan92
Registered User
Posts: 3
Joined: Wed Jan 29, 2014 5:36 pm

Re: [REQ] Verify Minecraft Username

Post by jlryan92 »

AmigoJack wrote:
jlryan92 wrote:with no success
What have you done? What did you expect? What happened instead?

The instructions are clear on where to insert the code and how to identify your custom profile field, so I have no clue where you failed exactly.
I could have written it better actually...

Both the codes worked fine, but when I tried to merge them (The code for verifying the user has paid for MC, and the code for checking against other people in the forum).

What I want it to do, is have the premium user verification on the Minecraft user field, so as it's checking for other names on the forum, I want it to also check for premium status.

I can't think of a better way to word it, I've had a bad day and I just can't brain at the moment haha.
User avatar
AmigoJack
Registered User
Posts: 5782
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: [REQ] Verify Minecraft Username

Post by AmigoJack »

Why posting back at all when being in a bad condition? I still don't get the problem: post 13052524 checks for a paid MineCraft account and post 13175832 checks against duplicates - both use a custom profile field and don't collide. Thus, I have no idea what you "merged" and why it shouldn't do what is expected.
  • The worst thing about censorship is ███████████
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
Locked

Return to “[3.0.x] MOD Requests”