<?php
$config['server']['ip'] = 'romecraft.ru';
$config['server']['port'] = '25566';
function fetch_server_info($ip, $port){
$socket = fsockopen($ip, $port, $errno, $errstr, 0.5);
if ($socket === false){
return false;
}
fwrite($socket, "QUERY_JSON\n");
$responce = stream_get_contents($socket);
return json_decode($responce, true);
}
$info = fetch_server_info($config['server']['ip'], $config['server']['port']);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 Strict//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<html xmlms="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset-utf-8" />
<title><?php echo $config['server']['ip']; ?> Status</title>
</head>
<body>
<div>
<h3>Статус: romecraft.ru</h3>
<?php if ($info === false): ?>
<p><font color = "#0A6E0B">Статус:</font> Offline</p>
<?php else:?>
<p><font color = "#0A6E0B">Статус:</font> Online</p>
<p><font color = "#0A6E0B">Слоты: </font><?php echo $info['playerCount']; ?> / <?php echo $info['maxPlayers']; ?></p>
<?php foreach ($info['playerList'] as $player) echo '$player'/> '; ?></p>
</p>
<?php endif; ?>
</div>
</body>
</html>