Temos pavadinimas: WordPress, Shopify ir PHPFusion programuotojų bendruomenė :: Dizainas...

Parašė adds123· 2012 Bal. 24 14:04:36
#9

//Start Configs
class Minequery {

public static function query($address, $port = 25566, $timeout = 30) {
$query = array();

$beginning_time = microtime(true);

$socket = @fsockopen($address, $port, $errno, $errstr, $timeout);

if (!$socket) {

return false;
}

$end_time = microtime(true);

fwrite($socket, "QUERY\n");

$response = "";

while(!feof($socket)) {
$response .= fgets($socket, 1024);
}

$response = explode("\n", $response);


$query['serverPort'] = explode(" ", $response[0], 2);
$query['serverPort'] = $query['serverPort'][1];


$query['playerCount'] = explode(" ", $response[1], 2);
$query['playerCount'] = $query['playerCount'][1];


$query['maxPlayers'] = explode(" ", $response[2], 2);
$query['maxPlayers'] = $query['maxPlayers'][1];


$query['playerList'] = explode(" ", $response[3], 2);
$query['playerList'] = explode(", ", trim($query['playerList'][1], "[]"));

$query['latency'] = ($end_time - $beginning_time) * 1000;

return $query;
}


public static function query_json($address, $port = 25566, $timeout = 30) {
$beginning_time = microtime(true);

$socket = @fsockopen($address, $port, $errno, $errstr, $timeout);

if (!$socket) {

return false;
}

$end_time = microtime(true);

fwrite($socket, "QUERY_JSON\n");

$response = "";

while(!feof($socket)) {
$response .= fgets($socket, 1024);
}

$query = json_decode($response);
$query->latency = ($end_time - $beginning_time) * 1000;

return $query;
}
}
$s = Minequery::query("78.58.113.219");
if($s){

echo "<td colspan='7' rowspan='5' background='".THEME."images/header_10.jpg' width='648' height='62' alt=''></td>
<td colspan='2' background='".THEME."images/header_11.jpg' width='157' height='18' alt=''>&nbsp;&nbsp;<span style='color:white;'>Serverio IP: 78.58.113.219</span></td>
<td rowspan='5' background='".THEME."images/header_12.jpg' width='53' height='62' alt=''></td>
</tr>
<tr>
<td colspan='2' background='".THEME."images/header_13.jpg' width='157' height='4' alt=''></td>
</tr>
<tr>
<td colspan='2' background='".THEME."images/header_14.jpg' width='157' height='18' alt=''>&nbsp;&nbsp;<span style='color:white;'>Portas: 25565</span></td>
</tr>
<tr>
<td colspan='2' background='".THEME."images/header_15.jpg' width='157' height='4' alt=''></td>
</tr>
<tr>
<td colspan='2' background='".THEME."images/header_16.jpg' width='157' height='18' alt=''>&nbsp;&nbsp;<span style='color:white;'>Žaidėjų: $s[playerCount]/$s[maxPlayers]</span></td>
</tr>";

if($s['playerCount']>0){
$i=0;
foreach($s['playerList'] as $player)
{
if($i!=0){
echo ", ";}
echo $player;
$i++;
}
}
}else{
echo "<td colspan='7' rowspan='5' background='".THEME."images/header_10.jpg' width='648' height='62' alt=''></td>
<td colspan='2' background='".THEME."images/header_11.jpg' width='157' height='18' alt=''>&nbsp;&nbsp;<span style='color:white;'>Serverio IP: 78.58.113.219</span></td>
<td rowspan='5' background='".THEME."images/header_12.jpg' width='53' height='62' alt=''></td>
</tr>
<tr>
<td colspan='2' background='".THEME."images/header_13.jpg' width='157' height='4' alt=''></td>
</tr>
<tr>
<td colspan='2' background='".THEME."images/header_14.jpg' width='157' height='18' alt=''>&nbsp;&nbsp;<span style='color:white;'>Portas: 25565</span></td>
</tr>
<tr>
<td colspan='2' background='".THEME."images/header_15.jpg' width='157' height='4' alt=''></td>
</tr>
<tr>
<td colspan='2' background='".THEME."images/header_16.jpg' width='157' height='18' alt=''>&nbsp;&nbsp;<span style='color:white;'>Nėra žaidėjų</span></td>
</tr>";

} Stai.