Hello,
I'm still having some issues with utf8 stuff.
array(3) { [0]=> string(20) "Minecraft Adventure�" [1]=> string(2) "0�" [2]=> string(2) "20" }
I'm still getting the triangles.
here's my mc.inc.php code:
[syntax=php]<?php
function fetch_server_info($ip, $port){
$socket = @fsockopen($ip, $port, $errno, $errstr, 0.5);
if($socket === false){
return false;
}
fwrite($socket, "\xFE");
$data = fread($socket, 256);
//var_dump($data);
if(substr($data, 0, 1) != "\xFF"){
return false;
}
$data = explode('§', mb_convert_encoding(substr($data, 3), 'UTF8', 'UCS-2'));
var_dump($data);
return array(
'motd' => $data[0],
'players' => intval($data[1]),
'max_players' => intval($data[2]),
);
}
?>[/syntax]
server_list.php
[syntax=php]<?php
include('core/init.inc.php');
?>
<!DOCTYPE html public "-//W3C//DTD XHTML 1.1 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Minecraft server list</title>
</head>
<body>
<div>
<?php
foreach($config['servers'] as $id => $server){
echo '<p><a href="view_server.php?sid=', $id, '">', $server[0],'</a></p>';
}
?>
</div>
</body>
</html>[/syntax]
view_server.php
[syntax=php]<?php
include('core/init.inc.php');
if (!isset($_GET['sid']) || empty($config['servers'][$_GET['sid']])){
header('location: server_list.php');
die();
}
$server_ip = $config['servers'][$_GET['sid']][0];
$server_port = $config['servers'][$_GET['sid']][1];
$info = fetch_server_info($server_ip, $server_port);
?>
<!DOCTYPE html public "-//W3C//DTD XHTML 1.1 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><?php echo $server_ip; ?> Status</title>
</head>
<body>
<div>
<h1><?php echo $server_ip; ?></h1>
<?php
if($info === false){
echo '<p>Status: <span style="color:red">Offline</span></p>';
}else{
echo '<p>Status: <span style="color:green">Online</span></p>';
echo '<p>Motd: ', $info['motd'], '</p>';
echo '<p>Players: ', $info['players'],' / ',$info['max_players'], '</p>';
}
?>
</div>
<a href="server_list.php">Back</a>
</body>
</html>[/syntax]
config.inc.php
[syntax=php]<?php
$config['servers'][] = array('bearlyconnected.com', 25565);
$config['servers'][] = array('bearlyconnected.com', 25566);
$config['servers'][] = array('bearlyconnected.com', 25567);
$config['servers'][] = array('server.mcbans.com', 25565);
?>[/syntax]
Please help with this issue if possible.