ID:153725
 
I've seen the post before, and I have the code that Lummox Jr (page output that generates a .dms file to a live game, written in php) put up. The problem I have, is I'm trying to figure out to get it to intergrate w/ php and am having some problems with that (ok..alot, i'm trying to figure out where to start amongst other things)

[was unsure of where this post belonged]
Cryptic wrote:
I've seen the post before, and I have the code that Lummox Jr (page output that generates a .dms file to a live game, written in php) put up. The problem I have, is I'm trying to figure out to get it to intergrate w/ php and am having some problems with that (ok..alot, i'm trying to figure out where to start amongst other things)

What are the problems you're having, specifically? The PHP section should plug in nicely; I'm not sure if there are compatability issues with older versions but I don't think that's likely. If you could specify any errors you get, it'd help.

[was unsure of where this post belonged]

This'll do.

Lummox JR
In response to Lummox JR
Warning: file("http://www.byond.com/hub/ hub.cgi?qd=hub;hub=MyName.MyGame;format=text;content=|worlds |users|") - Success in /home/r/rokugononline/public_html/phpBB2/games_live.php on line 7

Warning: Variable passed to each() is not an array or object in /home/r/rokugononline/public_html/phpBB2/games_live.php on line 10

I also trying to figure out how to intergrate it into the template my site is using (well..just template usage period)

I hadn't changed the hub settings yet because I was trying to see if it would just work...guess I'll change those and see if the output page will work
[edit]
I was trying to make a mod with this (for phpBB) , but i really dunno where to start..and than release the mod to the public(free of course) and it would prolly encourage game devs to create websites for their games(by that i mean, people could just bookmark their home page and look for the "game live" link instad of scanning the HUB for games)i'm always looking for more info on games aside from hub entries[/edit]

[edit]I changed hub entry and that part works fine now, I just need to figure out template integration and a quick link[/edit]
In response to Cryptic
Cryptic wrote:
Warning: file("http://www.byond.com/hub/ hub.cgi?qd=hub;hub=MyName.MyGame;format=text;content=|worlds |users|") - Success in /home/r/rokugononline/public_html/phpBB2/games_live.php on line 7

Warning: Variable passed to each() is not an array or object in /home/r/rokugononline/public_html/phpBB2/games_live.php on line 10

You haven't filled in your hub entry yet; one of the vars in the script has the entry, which right now is set to "MyName.MyGame". You need to replace that with your game.
I think it's possible that the result you're getting isn't valid because the hub doesn't recognize it.

It's also possible that your distro of PHP isn't set to automatically read from files given as URLs. You'd have to use some kind of workaround for that, though I don't have any offhand. You can find more information at php.net.

I also trying to figure out how to intergrate it into the template my site is using (well..just template usage period)

You should be able to just stick the PHP section into the .php file for your site. I don't know what you mean by a template, unless you're saying that you're using a so-called WYSIWYG editor to make it. If you are, don't! Those things are unreliable and spit out crappy HTML.

Lummox JR
In response to Lummox JR
with what i have, it works, I fixed the problem and defined my game..what I mean by template, is phpBB uses "template" files, basic a set array of how the page is viewed (goto my website http://rokugon.cjb.net the main page is actually a combination of 3 templates...overall_header.tpl, portal_body.tpl and overall_footer.tpl) The template is more or less to add some visual flare to the site (much like what you see in the BYOND hub) my only problem is is that I am not fluent enough in php to figure out exactly how I could do this.

One problem I encountered (i tested out the whole thing after i got it to work) when there are no games available, the page just outputs a blank white page. and than it didn't execute the program, but thats prolly because of my own doing, so I can fix that (obj didn't exist, so i prolly just put in a wrong address, i can fix that though :P )

I'm not using the WYSIWYG portion of my editor to mess with the code (i'm using Dreamweaver MX)

...I just lost my train of thought (blast it!) I'm sorry about that, so if the post seems incomplete thats why.

~Cryptic

to get an example of templates and phpBB it self, check out http://www.phpbb.com
Ok, Ive cut it down to this....
How would I change this portion
if(count($worlds)) {
echo "<DIV STYLE=\"text-indent: 0\"><center><TABLE STYLE=\"border:0;margin:5px\"><TR>";
echo "<TD STYLE=\"padding-right:20px\"><H2>Games Online</h2></td>";
echo "<TD STYLE=\"padding:0\">";
while(list($n,$lst)=each($worlds)) {
$url='http://www.polarhome.com:793/~rokugononline/public_html/phpBB2/mods/byond/world.php?'.urlencode($lst['url']);
if(!$lst['status']) $lst['status']='(No status info available)';
echo "<A HREF=\"".$url."\">".$lst['status']."</a><BR>";
echo join(" - ",$lst["users"])."<P>\n";
}
echo "</td></tr></table></center></div>";
}
to this

//assign template
$page_title = $lang['Live'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);

$template->set_filenames(array(
'body' => 'games_live_body.tpl')
);

$template->assign_vars(array(
'game' => //while(list($n,$lst)=each($worlds)...
'status' => //if(!$lst['status']) $lst['status']='(No status info available)';
echo "<A HREF=\"".$url."\">".$lst['status']."</a><BR>";
'join' => //(" - ",$lst["users"])."<P>\n";
);


each portion of the
'blah' => $blah['bleh']

is insterted into the template file, defined as such:
<tr>
<th class="catHead" height="25"><span class="genmed"><b>{blah}: {blah}</b></span></th>
</tr>
In response to Cryptic
Okay, I've checked this out, and I think the answer is to use assign_block_vars().
if(count($worlds)) {
while(list($n,$lst)=each($worlds)) {
$url='http://www.polarhome.com:793/~rokugononline/public_html/phpBB2/mods/byond/world.php?'.urlencode($lst['url']);
if(!$lst['status']) $lst['status']='(No status info available)';
$template->assign_block_vars('games_live', array(
'GAME'=$url,
'STATUS'=$lst['status'],
'USERS'=join(" - ",$lst["users"]).")
);
}
}
else assign_block_vars('no_games',array());

$template->pparse('body')
The template should then have a section something like this:
<DIV><TABLE>
<!-- BEGIN games_live -->
<TR>
<TD><A HREF="{GAME}">{STATUS}</a></td>
<TD>{USERS}</td>
</tr>
<!-- END games_live -->
<!-- BEGIN no_games -->
<TR>
<TD STYLE="text-align:center; font-weight:bold">No games are live.</td>
</tr>
<!-- END no_games -->
</table></div>
Now I knew nothing about phpBB before today, so I could be wrong on all this, but I hope I could at least point you in the right direction.

Lummox JR
In response to Lummox JR
:D thanx Lummox, I'll take it from there ^_^, when I'm done i'll release a mod to the community..so as anyone can have "game status" page :)
In response to Cryptic
I took a look last night and it looked like you had it working; I didn't click the link because I was in another game, but the world.php script is simple enough so I doubt you had trouble with that one. Is everything working out for you?

Lummox JR
In response to Lummox JR
yeap, everything is workin out, i'm messing around with it to get the .tpl and .php files to corrolate properly with out any "error"s--and when its done, i'll host a MOD dl for everyone, i'll also host to .php script files for people who don't use phpBB -- so it should all work out good