ID:277944
 
This is a code for getting the info I need for the hub:
<\/head> bj(form.childNodes[i]); } } return getstr; } function gatherFormChecks(form,name,unchecked) { var getstr = ''; for (var i=0; i<form.childNodes.length; i++) { if (form.childNodes[i].tagName == "INPUT" && form.childNodes[i].name == name) { if ((form.childNodes[i].type == "checkbox" || form.childNodes[i].type == "radio") && !form.childNodes[i].checked!=!unchecked) { if(getstr) getstr += ','; getstr += encodeURIComponent(form.childNodes[i].value); } } else if (form.childNodes[i].tagName == "SELECT") { } else if (form.childNodes[i].firstChild){ var more = gatherFormChecks(form.childNodes[i],name,unchecked); if(more) {if(getstr) getstr += ','; getstr += more;} } } return getstr; } -->

How do I display the hubs now?

I don't know PHP, but people typically post all code in DM tags, regardless of language, because it helps to read it.
In response to Jeff8500
Jeff8500 wrote:
I don't know PHP, but [...]

That's ok. None of that is PHP. :P
In response to Xooxer
Oh, I didn't read any until now; I just thought that saying PHP code help meant he wanted help with PHP >_>
In response to Jeff8500
PHP has the following in it's source:

<?php ?>

or

<? ?>

George Gough
In response to KodeNerd
Both or acceptable, <?php works no matter what, and <? works if your php.ini file tells it to. ?> is the ending tag regardless.
In response to Nadrew
Nadrew wrote:
Both or acceptable,

I was saying that it could have both. This or this.

George Gough
Copy and pasting BYOND's hub source isn't going to do squat for you.

I'll do you a favour, I wrote a script to do what you're wanting a long, long time ago. I still have it laying around.

It's no where near as good as it can be, but I don't feel like rewriting it at 2am in the morning.

I wrote this for Silkwizard early 2007. I assume he upgraded it to better practices somewhere down the line. Here it is, I'll revise and release it later in the week.
  //Because I crave simplicity when I'm programming. I like to keep complexity inside functions, and thus, this is the result.
//There is no easier way to get your game information.
$hub = hub_get_contents('enigmaster2002.iconultima');

function hub_get_contents($hub_page) {
//First things first, we need to get the contents from the hub page. And this line does it nicely. It'll grab all the text from the hub for us, easy and simple.
//There is no real trick to it after this, all we have to do is parse text.
$hub_page = @file_get_contents('http://games.byond.com/hub/hub.cgi?qd=hub;hub=' . $hub_page . ';format=text');

//No sense doing anything if the hub is down. So we make a check first.
if(!strlen($hub_page)) $returned_array['byond_error'] = 'BYOND Hub Error';
else {
//Now we're going to define some arrays to store the hub page contents in. Saves effort this way.
$returned_array = array(
'info' => '',
'servers' => array(),
'server_error' => '', //the old error was conflicting with byond hub and no online servers. So I replaced them.
'byond_error' => '',
't_players' => 0, //Total Players
't_servers' => 0 //Total Servers
);

$game_information = array(
'title' => '',
'banner' => '',
'icon' => '',
'short_desc' => '',
'long_desc' => '',
'author' => '',
'registered' => '',
'version' => '',
'byond_rank' => '',
'status' => '',
'login_url' => '',
'info_url' => ''
);



//In the olden days, I used to search for each individual array element, which made this function... huge, to say the least.
//In this part of the function, I add all the universal game information, the next part will contain the individual server information.
//That is the most annoying part to do, this is the easiest.
for($i = 0; $i < count($game_information); $i++) {
//We start by getting the numerical location of the current array item.
$start = strpos($hub_page, chr(9) . key($game_information)); //Turns out there was a major bug. If anyone had any of the words in the array in one of their descriptions, it'd call that instead of what it was supposed to. Fixed now.
//If the array item doesn't exist, we can't search for it, so we'll just skip right to the next one.
if($start) {
//The numerical location takes place at the start of the item we want, so we need to add the items length to it.
$start += strlen(key($game_information));
//BYOND Rank makes this a pain in the ass. It doesn't use the same format as the others do, so we just differentiate it from the rest
//and add it up a different way, in the end, it all works out.
if(key($game_information) == 'byond_rank') {
$start += 3;
$end = strpos($hub_page, (chr(10)), $start);
} else {
$start += 5;
$end = strpos($hub_page, ('"' . chr(10)), $start);
}
//Add the data to the array element.
$game_information[key($game_information)] = stripslashes(str_replace("\\n", "<br>", substring($hub_page, ($start), $end)));
} else $game_information[key($game_information)] = null;
//Jump to the next element in the array.
next($game_information);
}
//Now the really annoying part begins, gather the server information....
$i = strpos($hub_page,"worlds/1");
if($i === false) $returned_array['error'] = 'No online servers';
else {
$online_server = explode('worlds/', substr($hub_page, $i+9, strlen($hub_page)));
foreach($online_server as $game) {
//We had to define this array here so we could reuse it often.
$server_information = array(
'url' => '',
'status' => '',
'users' => ''
//Channel has been discluded because it's no longer supported by the BYOND system.
);
//We didn't do this the same way as before for two simple reasons. One, it's only three values, not that big of a deal, two, I must have attempted to get it
//right for an hour before I gave up and did it the old way.
$start = strpos($game, 'url');
if($start) {
$end = strpos($game, ('"' . chr(10)), $start);
$server_information['url'] = substring($game, ($start+7), $end);
}

$start = strpos($game, 'status');
if($start) {
$end = strpos($game, ('"' . chr(10)), $start);
$server_information['status'] = substring($game, ($start+10), $end);
}

$start = strpos($game, 'users');
if($start) {
$end = strpos($game, (')' . chr(10)), $start);
$result = str_replace('"', '', substring($game, ($start+13), $end));
$result = str_replace(',', ', ', $result);
$server_information['users'] = $result;
}

$returned_array['servers'][] = $server_information;
$returned_array['t_servers']++;
$returned_array['t_players'] += count(explode(',', $server_information['users']));
}
}
$returned_array['info'] = $game_information;
}
return $returned_array;
}

function substring() //Created by Mobius Evalon -- Note the Tomism, opposite to everything else done in this file.
{
if(func_num_args() < 2 || func_num_args() > 3) exit('<b>Warning:</b> substring() expecting two or three arguments: ' . func_num_args() . ' given');
$arg_list = array();
for($i=0;$i<func_num_args();$i++) $arg_list[] = func_get_arg($i);
return substr($arg_list[0],$arg_list[1],(count($arg_list) > 2 ? $arg_list[2]-$arg_list[1] : strlen($arg_list[0])-1));
}
?>


List of commands.
    $hub['byond_error']
$hub['server_error']
$hub['t_players']
$hub['t_servers']

$hub['info']['title']
$hub['info']['banner']
$hub['info']['icon']
$hub['info']['short_desc']
$hub['info']['long_desc']
$hub['info']['author']
$hub['info']['registered']
$hub['info']['version']
$hub['info']['byond_rank']
$hub['info']['status']
$hub['info']['login_url']
$hub['info']['info_url']

for($i = 0; $i < count($hub['servers']), $i++) {
$hub['servers'][$i]['url']
$hub['servers'][$i]['status']
$hub['servers'][$i]['users']
}


You'll have to note at least "byond_rank" and "login_url" are no longer used. You'll probably have to modify the script yourself to remove them.