New project help.

Any help topics that don't fit in the current categories can go here.
Post Reply
SureShotM
Posts: 14
Joined: Mon May 06, 2013 3:44 pm

New project help.

Post by SureShotM »

Ok so I want to create a system on my web site for minecraft that will set a pre login and a temporary pass word. This system needs to go into the player list ever day to check if there is a new player and then take the user name and use that as the login name then from there create a password based on it till they can change it. My issue is im not sure if ill need to use mysql or the path i need to take to achieve this in the most simple way.

Any suggestions and help will be appreciated.
User avatar
FrederickGeek8
Posts: 148
Joined: Wed Nov 30, 2011 10:31 pm

Re: New project help.

Post by FrederickGeek8 »

To me it sounds like you are going to need to use MySQL and file paths....
What I would do is...

Have something that runs everyday and checks the player files folder of the world (there is one in every Minecraft folder), converts the file list to an array, and compares it to a previously stored array (stored in a text file).

If there is an new player you would insert into a database the Minecraft username (filename minus the extension) and then generate a password (maybe Playername_12345)
SureShotM
Posts: 14
Joined: Mon May 06, 2013 3:44 pm

Re: New project help.

Post by SureShotM »

Ok, now i guess that par i understand but hers were im lost, im not quite sure how to accesses the minecraft server host with php to grab the player files or even the player list that it creates, from there i know how to read the information put it into an array and then send it to a mysql database.
User avatar
FrederickGeek8
Posts: 148
Joined: Wed Nov 30, 2011 10:31 pm

Re: New project help.

Post by FrederickGeek8 »

this was a function I used a while ago to get server players (you need to have query enabled in server.properties for this to work)
[syntax=php]function server_players($host, $port, $timeout = 3){
//Set up our socket
$fp = fsockopen("udp://" . $host, $port, $errno, $errstr, $timeout);

if(!$fp){
echo "$errstr ($errno)<br />\n";
die();
}

// Get the challenge token; send 0xFE 0xFD 0x09 and a 4-byte session id
$str1 = "\xFE\xFD\x09\x01\x02\x03\x04"; // Arbitrary session id at the end (4 bytes)
fwrite($fp, $str1);
$resp1 = fread($fp, 256);

// if(isset($rep1[0]) === false){
// echo 'Query is not enabled.';
// die();
// }

if($resp1[0] != "\x09"){ // Check for a valid response
echo 'Query is not enabled.';
die();
}
// Parse the challenge token from string to integer
$token = 0;
for($i = 5; $i < (strlen($resp1) - 1); $i++)
{
$token *= 10;
$token += $resp1[$i];
}

// Divide the int32 into 4 bytes
$token_arr = array( 0 => ($token / (256*256*256)) % 256,
1 => ($token / (256*256)) % 256,
2 => ($token / 256) % 256,
3 => ($token % 256)
);

// Get the full version of server status. ID and challenge tokens appended to command 0x00, payload padded to 8 bytes.
$str = "\xFE\xFD\x00\x01\x02\x03\x04"
. chr($token_arr[0]) . chr($token_arr[1]) . chr($token_arr[2]) . chr($token_arr[3])
. "\x00\x00\x00\x00";
fwrite($fp, $str);
$data2 = fread($fp, 4096);
$full_stat = substr($data2, 11); // Strip the crap from the start

$tmp = explode("\x00\x01player_\x00\x00", $full_stat); // First, split the payload in two parts
$t = explode("\x00", $tmp[0]); // Divide the first part from every NULL-terminated string end into key1 val1 key2 val2...
unset($t[count($t) - 1]); // Unset the last entry, because the are two 0x00 bytes at the end
$t2 = explode("\x00", $tmp[1]); // Explode the player information from the second part

$players = array();
foreach($t2 as $one)
{
if($one == null)
break;

$players[] = $one;
}

return $players;
}[/syntax]
Now I don't really know how much you know about PHP but before going into what sounds to be a big project, you probably want to look up basic concepts in PHP like writing files, the serialize function, and database use. I would also look into the tool phpMyAdmin.

Also follow the BetterPHP User Registration/Login System tutorial.
Post Reply