ID:107634
 
After starting to use this php script, I noticed a problem with it.

The players don't show up, at the minute it's showing only one member that's there. >:/

Also anyone know how I would add onto it to show who is hosting? :O

On this line:

$start = strpos($game, 'users');

Changing 'users' to 'players' should work. Right now, it's only finding the 'users' list from the waiting list.
Just guessing this since I've got minimal experience with PHP... :/ I took a wild guess.
$server = array(
'url' => '',
'status' => '',
'users' => '',
'host' => '',
);

$start = strpos($game, 'host');
if($start) {
$a = strpos($game, '"', $start)+1;
$b = strpos($game, '"', $a);
$server['host'] = substr($game, $a, $b - $a);
}


Again, I'm guessing but it doesn't hurt to try. :/
http://dbzfinalresurrection.com/play.php

See anything wrong with the players bit? I do. :|

Current Code:
        <?php
$servers = hub_get_contents('volkov911.dbzfinalresurrection');
for($i = 0; $i < count($servers); $i++) {
echo("<b>Join:</b> <a href='" . $servers[$i]['url'] . "'>Click Here</a><br>");
echo("<b>Host:</b> " . $servers[$i]['host'] . "<br>");
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(
'url' => '',
'host' => '',
'status' => '',
'users' => '',
);

$start = strpos($game, 'url');
if($start) {
$a = strpos($game, '"', $start)+1;
$b = strpos($game, '"', $a);
$server['url'] = substr($game, $a, $b - $a);
}

$start = strpos($game, 'host');
if($start) {
$a = strpos($game, '"', $start)+1;
$b = strpos($game, '"', $a);
$server['host'] = substr($game, $a, $b - $a);
}

$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;
}
?>
I don't see anything wrong. Whatdya see?
Disregard that... Try this:

        $start = strpos($game, 'players');
if($start) {
$start = $start+15;
$end = strpos($game, ')', $start);
$result = str_replace('"', '', substr($game, $start, $end - ($start)));
$server['users'] = $result;
}
Use this instead.

h is hub.
m is member.
a is additional.

For a game hub: parse_hub("tiberath.storytelling")
For a member site: parse_hub("tiberath", TRUE);
For a full game hub: parse_hub("tiberath.storytelling", FALSE, "long=true");
For a full member site: parse_hub("tiberath", TRUE, "long=true");

<?
echo "<pre>" . print_r(parse_hub($_GET['h'], $_GET['m'], $_GET['a']), TRUE) . "</pre>";

function parse_hub($hub, $member=FALSE, $additional = null) {
$url = "http://www.byond.com/" . ($member ? "members" : "hub") . "/" . $hub . ";format=text" . ($additional ? ";" . $additional : null);

$page = get_headers($url, TRUE);
if(strpos($page["Content-Type"], "text/plain") === false) return false;

$return_array = array(); // Array returned. Duh.
$page = file_get_contents($url);
$page = explode(chr(10), htmlentities($page, ENT_NOQUOTES));
$heading = "";
$subheading = "";

foreach($page as $p) {
if(!strpos($p, "=")) {
if(strpos($p, "/")) {
$p = explode("/", $p);
$heading = trim($p[0]);
$subheading = trim($p[1]);
} else {
$heading = trim($p);
unset($subheading);
}

} else {
$start = strpos($p, "=");
$a = substr($p, 0, $start);
$b = substr($p, $start + 2);

if(strpos($b, "list") === 0) {
$b = str_replace("\"", "", substr($b, 5, strlen($b) - 7));
$b = explode(",", $b);
if(!$b[0]) $b = null;
}

if($subheading) {
$return_array[$heading][$subheading][trim($a)] = ((strpos($b, "\"") === 0) ? substr($b, 1, strlen($b) - 3) : $b);
} else {
$return_array[$heading][trim($a)] = ((strpos($b, "\"") === 0) ? substr($b, 1, strlen($b) - 3) : $b);
}
}
}

return $return_array;
}
?>


Please be aware anything on that PHP page is extreme outdated. (Minus the PHP to DM communication, that's pretty much still the only script for that purpose I'm aware of.)
Also, contacting me directly is a far better means of getting my attention. It was pure luck that I found this post.