[HELP!] Minecraft Server Status Page
Posted: Wed Aug 31, 2011 4:19 pm
Hello,
I have been following this video...
...but it's not working.
First off here is my code:
init.inc.php
I have been following this video...
...but it's not working.
First off here is my code:
init.inc.php
<?php
$servers = array(
array('192.168.1.70', '25565'),
array('127.0.0.1', '25565'),
);
error_reporting(0);
$path = dirname(__FILE__);
include("{$path}/lib/minecraft_server.inc.php");
?>
minecraft_server.inc.php
<?php
// Checks if the given server is online.
function server_online($server, $port){
fsockopen($server, $port, $errno, $errstr, 0.1);
return ($errno === 0);
}
?>
index.php
<?php
include('core/init.inc.php');
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Minecraft Server Status</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<table>
<thead>
<tr>
<th>Server</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php
foreach($servers as $server){
$online = server_online($server[0], $server[1]);
?>
<tr>
<td><?php echo $server[0], ':', $server[1]; ?></td>
<td class="<?php echo ($online) ? 'online' : 'offline'; ?>"><?php echo ($online) ? 'Online' : 'Offline'; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</body>
</html>
No matter what i do it always shows as red/offline even if the server is online. What's the problem?