<?php
$servers = hub_get_contents('Exadv1.spacestation13');
for($i = 0; $i < count($servers); $i++) {
echo("<b>Status:</b> " . $servers[$i]['status'] . "<br>");
echo("<b>Users:</b> " . $servers[$i]['players'] . " <br><br>");
}
function hub_get_contents($hub) {
$hub_page = file_get_contents("http://www.byond.com/games/" . $hub . "&format=text");
$servers = array();
$i = strpos($hub_page,"world/1");
$online_server = explode('world/', substr($hub_page, $i+9, strlen($hub_page)));
foreach($online_server as $game) {
$server = array(
'status' => '',
'users' => '',
);
$start = strpos($game, 'status');
if($start) {
$a = strpos($game, '"', $start) +1;
$b = strpos($game, '"', $a);
$server['status'] = substr($game, $a, $b - $a);
}
$start = strpos($game, 'players');
if($start) {
$start = $start+13;
$end = strpos($game, ')', $start);
$result = str_replace('"', ' ', substr($game, $start, $end - ($start)));
$server['players'] = $result;
}
$servers[] = $server;
}
return $servers;
}
?>
Problem description:
I need just get information about number of players and server status.
Please help PHP newbie.
'[Your key].[hubname]'
Also, it looks as though world/1 here only finds the first server. I only glimpsed over it. I'm sure someone will be able to help you further, if you require. I won't be available.