Wer was damit anfangen kann hat:
Funktion im Spoiler:
PHP Code:
<?php
/******************************************************************\
|* Copyright (c) by starlex.de, Alexander Becker
|*
|* Visit:
|* http://starlex.de
|*
|* License:
|* http://creativecommons.org/licenses/by-sa/3.0/deed.en
|*
\******************************************************************/
function mc_status( $server ) {
if($socket = stream_socket_client('tcp://'.$server , $errno, $errstr, 1)) // connect to the server
{
fwrite($socket, "\xfe"); // writes the query
$tmp = fread($socket, 2048); // reads the serverinfo
$tmp = str_replace("\x00","",$tmp); // removes all 0x00
$tmp = substr ($tmp,2); // removes the first 2 bytes
$info = explode("§",$tmp); // splits the sting into a array
unset($tmp);
if(count($info) == 3) // check array (if modt contains invalid chars(§))
{
return( // returns a new Array (END)
Array(
"motd" => $info[0],
"cur_players" => $info[1],
"max_players" => $info[2]
)
);
} else if(count($info) > 3){ // DEAL ERRORS - INVALID CHARS : !!! not added in the minecraft client !!!
$tmp = "";
for ($i = 0; $i < count($info) - 2; $i++) {
$tmp .= $info[$i];
if(!($i == count($info) - 2 - 1))
{
$tmp .= "§";
}
}
return( // returns a new Array (END)
Array(
"motd" => $tmp,
"cur_players" => $info[count($info) - 2],
"max_players" => $info[count($info) - 1]
)
);
} else {
return false; // return false (if syntax is wrong)
}
} else {
return false; // return false (if connection failed in first step)
}
}
?>
mfg. cioqvvnr / BlackTrader