[Resource] Using the Blockland auth server with PHP

Author Topic: [Resource] Using the Blockland auth server with PHP  (Read 3597 times)

First, you will need to insert this function into your PHP code:

Code: [Select]
function BlocklandAuthenticate($username)
{
//Zapk 12270
$postdata = http_build_query(
array(
'NAME' => $username,
'IP' => $_SERVER['REMOTE_ADDR']
)
);

$opts = array('http' =>
array(
'method'  => 'POST',
'header'  => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);

$context  = stream_context_create($opts);

$result = file_get_contents('http://auth.blockland.us/authQuery.php', false, $context);

return $result;
}

The function returns a string of the auth server's response.

  • Usage
    Say the user wants to register under the name "Badspot", and you want valid Blockland users only.
    You would handle the string returned by BlocklandAuthenticate(username). In this case, username would be "Badspot".

    It sends the username and the client's IP address to the auth server, where it checks to see if the IP has played under that username last.

    If their IP address does not match Badspot's IP address (which is saved on the auth server), it will return incorrect. If it does, it will return correct.

  • Correct
    When correct, it will return "YES 0" where 0 is the user's Blockland ID.

  • Incorrect
    If it's incorrect, it will simply return "NO".

Here is an example:

Code: [Select]
$authstring = BlocklandAuthenticate($_POST['user_name']);
 
$autharray = explode(' ',trim($authstring));
   
if($autharray[0] == "YES")
{
$blid = $autharray[1];
//allow registration or whatever
}
else
{
//give them an error and deny registration
}

Please note: the username is not case-sensitive.
« Last Edit: January 21, 2014, 09:34:18 PM by Subpixel »

This is useful, but shouldn't it belong in the coding section as a resource?

This is useful, but shouldn't it belong in the coding section as a resource?
It's not TorqueScript, so not really.

It's not TorqueScript, so not really.
No, I guess not. But more people in coding help would find it useful that people in general discussion? If you don't think so than that is okay too.



You forgot to mention after like 9 minutes you de-auth.


typed in snake

said no

works!

whats this useful for?
It allows for websites who have users sign up to them get their IP authenticated by the master server. This would allow for users to sign up under their in-game ID without doing something stupid like using their Key to prove that they are in fact the owner of the ID.

This is from my own understanding and I may be wrong.

This could allow steam users to make forum accounts and be able to sign up for dedicated hosting.

Bump.

DrenDran's looking for this.


I know some people might not be able to figure it out, but still, this is literally just a dead simple HTTP request. It doesn't even process the output received from the auth server.

usefull for my future social network, thanks!