Witam mam błąd w kodzie mcInfo.php, proszę o poprawę tego, nie rozumiem co jest źle.
index.php
<?php
include('mcinfo.php');
$info = fetch_server_info($config['server']['ip'], $config['server']['posrt']);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://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>
<hl>
<?php echo $config['server']['ip']; ?></hl>
<?php
if ($info === false){
?>
<p>
Status: Wyłaczony
</p>
<?php
}else{
?>
<p>
Status: Włączony
</p>
<p>
Sloty
<?php echo $info['playerCount']; ?> /
<?php echo $info['maxplayers']; ?> </p>
<p>
Gracze:
<?php echo implode(', ', $info['playerList']); ?> </p>
<?php
}
?>
</div>
</body>
</html>
mcInfo.php
<?php
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);
}
?>
mcconfig.php
<?php
$config['server']['ip'] = 'localhost';
$config['server']['port'] = '25565';
?>
Notice: Undefined variable: config in C:\Program Files\xampp\htdocs\Index.php on line 5
Notice: Undefined variable: config in C:\Program Files\xampp\htdocs\Index.php on line 5
Warning: fsockopen() [function.fsockopen]: unable to connect to :0 (Failed to parse address "") in C:\Program Files\xampp\htdocs\mcInfo.php on line 4
Notice: Undefined variable: config in C:\Program Files\xampp\htdocs\Index.php on line 12
Status
Notice: Undefined variable: config in C:\Program Files\xampp\htdocs\Index.php on line 16
Status: Wy�aczony
Ten post edytował mikoz55 15.05.2012, 16:50:54