Page 1 of 1
phpFreeChat & Browser MMO Tutorial
Posted: Mon Jun 20, 2011 7:21 pm
by Tim
Has anyone been able to integrate the phpFreeChat software (
http://www.phpfreechat.net/]found here) with the Browser MMO tutorial?
I am currently working on it but am running into issues carrying the username over to the chat script. I think this is a must so someone doesn't join the chat room and /nick Tim and pretend they are me if I'm not there.
Changing
to
doesn't work.
Just looking for some assistance with this. If successful I will update this post and give a tutorial on how we got it working for all the users wanting to get a chat room on their game.
Thanks!
Re: phpFreeChat & Browser MMO Tutorial
Posted: Mon Jun 20, 2011 7:40 pm
by hallsofvallhalla
Where is $username coming from? Session? Do you have session start?
Re: phpFreeChat & Browser MMO Tutorial
Posted: Mon Jun 20, 2011 7:45 pm
by Jackolantern
I am assuming that code is coming from a FreeChat script, and not a PBBG script. Like Halls asked, where is $username coming from? If you do add your session_start code to it, and actually pull the $username variable out of the $_SESSION global array, you should be able to pull it over to that script fairly easily.
EDIT: Some difficulty may come from having to go all through the Freechat scripts and make sure you are enforcing the connection all the way through, or some large holes could be formed. Not that I am familiar at all with FreeChat, however. If that is the only place where the username comes in to play, this would be a very good candidate for other devs here wanting a chat system in the tutorial game.
Re: phpFreeChat & Browser MMO Tutorial
Posted: Mon Jun 20, 2011 7:59 pm
by Tim
Yes, here is the upper portion of the index.php of the chat directory.
Code: Select all
<?php
session_start();
include_once '../connect.php';
include_once '../session.php';
require_once dirname(__FILE__)."/src/phpfreechat.class.php";
$params = array();
$params["title"] = "Quick chat";
$params["nick"] = $username;
$params['firstisadmin'] = true;
//$params["isadmin"] = true; // makes everybody admin: do not use it on production servers ;)
$params["serverid"] = md5(__FILE__); // calculate a unique id for this chat
$params["debug"] = false;
$chat = new phpFreeChat( $params );
When I add the includes for session start, connect.php, and session.php it gets stuck on:
I will continue looking through the other .php files and see if there are any other instances of "nick" that might be causing problems.
EDIT:
I found the following code in ../chat/src/pfcglobalconfig.class.php
Code: Select all
/**
* <p>If you have already identified the user (forum, portal...) you can force the user's nickname with this parameter.
* Defining a nick will skip the "Please enter your nickname" popup.</p>
* <p>Warning : Nicknames must be encoded in UTF-8.
* For example, if you get nicks from a databases where they are ISO-8859-1 encoded,
* you must convert it: <code>$params["nick"] = iconv("ISO-8859-1", "UTF-8", $bdd_nickname);</code>
* (Of course, change the <code>$bdd_nickname</code> parameter for your needs.)</p>
* <p>(Default value: "" - means users must choose a nickname when s/he connects.)</p>
*/
var $nick = "";
I believe this is where I would put the
and change the code to
but it's giving me the following error
Code: Select all
Warning: include_once(../../session.php) [function.include-once]: failed to open stream: No such file or directory
The structure is /public_html/game/chat/
Re: phpFreeChat & Browser MMO Tutorial
Posted: Mon Jun 20, 2011 8:29 pm
by 62896dude
Not sure if my idea will work, but try keeping every file in just one folder. That way, you only need to call for session.php, and not /../../session.php
Re: phpFreeChat & Browser MMO Tutorial
Posted: Mon Jun 20, 2011 8:32 pm
by Tim
62896dude wrote:Not sure if my idea will work, but try keeping every file in just one folder. That way, you only need to call for session.php, and not /../../session.php
phpFreeChat is 553 different files. Could get pretty messy if I have everything in one folder. I can't figure out why ../../session.php won't work.
EDIT:
It looks like this works for some reason (doesn't give me errors).
Code: Select all
session_start();
include_once '../connect.php';
include_once '../session.php';
When I add the above code though, the chat system displays
and never loads. When I remove it, it loads fine.
Re: phpFreeChat & Browser MMO Tutorial
Posted: Tue Jun 21, 2011 12:12 am
by Jackolantern
Does your session.php file actually get the value out of the session global and assign it to $username?