ID:1711934
 
Keywords: php, players, server, status
(See the best response by NNAAAAHH.)
Code:
 <?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.

Best response
At the top, it includes the hub reference. Merely insert the hub owner and the hub name in place of Exadv1.spacestation13


'[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.
Just replace on the second line where it says 'Exadv1.spacestation13' with your HUB, and it should display statistics of your servers. But if you have no knowledge on what you are doing this will much ratter not help you at all.
It is generally frowned upon to copy/paste. I wish you luck in your learning progress.
Help with? What's happening?
In response to NNAAAAHH
NNAAAAHH wrote:
Help with? What's happening?
I need information(status,players) about my server not all servers on hub.

And you are doing so from a remote server or within the server? It would probably be better to use world.Topic() world.Export(). If it's within your own server, there is a lot simpler ways to get that information.
In response to NNAAAAHH
NNAAAAHH wrote:
And you are doing so from a remote server or within the server? It would probably be better to use world.Topic() world.Export(). If it's within your own server, there is a lot simpler ways to get that information.

Can you please send me code with that functions?