News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

phpfreechat

Started by ozbob, May 13, 2013, 07:13:18 PM

Previous topic - Next topic

ozbob

Howdy,

I have phpfreechat running standalone fine.  Would like to be able to restrict to SMF forum users and use their forum names as the name in chat.

There are a couple of older solutions on the Community here, and have tried them but the chat does not load.

Has anyone been able to do this please with 2.0.4?

Thanks
Bob

Matthew K.

Are you comfortable with modifying PHP? Off the top of my head - without looking at the script, I don't think it'd be too difficult to hack up without a specific modification.

ziycon

As far as I remember there is a file were the user details are assigned to a session, you just do a quick check on ssi.php and assign the relevant details and all else works as intended, about an hours work if even that.

Matthew K.

Should be a lot less, actually :) You'd just set the username to SMF's username from SSI.php and then you could probably also use: is_not_guest();.

ozbob

Thanks for the prompt replies.

Could you please post the additional code to include call the ssi.php and then pass the user details if possible please.

This is the present file.


<?php

require_once dirname(__FILE__)."/src/phpfreechat.class.php";
$params["serverid"] = md5(__FILE__);
$params["title"]    = "RAIL BoT Forum Chat Room";
$params["theme"]    = "green";
$params['admins'] = array('Ozbob'  => 'xxxxxx',
                           
'Admin' => 'xxxxx');
$params['time_offset'] = 60*60*17// offset in seconds
$chat = new phpFreeChat$params );

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>RAIL BoT Forum Chat Room</title>
    <?php $chat->printJavascript(); ?>
    <?php $chat->printStyle(); ?>
</head>
<body>
<?php $chat->printChat(); ?>


</body>
</html>



the parameter for the name is

$params["nick"] = ""; // setup the intitial nickname

Matthew K.

Something like this then, most likely...
<?php

// A global from SMF.
global $user_info;

// Enter your path to SSI in the function below.
require_once('/path/to/SSI.php');

// Show the login form for those who are not logged into SMF.
is_not_guest();

// Require the freeChat file.
require_once(dirname(__FILE__) . '/src/phpfreechat.class.php');

// The initial $params for phpFreeChat constructor.
$params = array(
'serverid' => md5(__FILE__),
'title' => "RAIL BoT Forum Chat Room",
'theme' => 'green',
'admins' => array('0zbob' => 'xxxxxx''Admin' => 'xxxxx',),
'time_offset' => 60*60*17// !! Consider using the users time offset from $user_info?
'nick' => $user_info['name'],
);

// Instantiate $chat from phpFreeChat Class.
$chat = new phpFreeChat($params);

echo 
'
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>RAIL BoT Forum Chat Room</title>
'
$chat->printJavascript(), '
'
$chat->printStyle(), '
</head>
<body>
'
$chat->printChat(), '
</body>
</html>
'
;

Matthew K.

As I noted in the code...you could also send in the specific users time offset rather than defining a static one :) That should be in $user_info, if you want to do a print_r(); and make sure I'm not wrong :P

Also - You'll have to replace the require_once(); path for SSI.php with whatever the path is, since I can't be positive without seeing your directory structure. I also cleaned up some of the source while I had the code :)

ozbob

Many thanks, will give it a try.

Matthew K.

No problem, let me know how it goes for sure :)

ozbob

Works fine!

Yee Haa!!

Thank you again.

Matthew K.

Not a problem! Enjoy! :)

Spatry

#11
This is how I got PHPfreechat 1.7 to integrate with SMF 2.0.7! I had to do a lot of digging around and I wanted to share this with the community!

First, I installed PFC in a subdirectory of my forum on the server (ex. /SMF/chat)

Then I edited index.php (in the chat directory) with the following:  it identifies user groups and assigns them accordingly. THIS DOES NOT ALLOW GUESTS TO ENTER CHAT. They must register on your forum.

<?php
//ignores the theme the forum is using
$ssi_theme 1;
// A global from SMF.
global $user_info;

// Enter your path to SSI in the function below.
require_once('../SSI.php');


// Show the login form for those who are not logged into SMF.
is_not_guest();

// Require the freeChat file.
require_once(dirname(__FILE__) . '/src/phpfreechat.class.php');

// The initial $params for phpFreeChat constructor.
$params = array(
'serverid' => md5(__FILE__),
'admins' => array('ADMIN_NAME' => 'ADMIN_PASSWORD',),
'time_offset' => 60*60*17// !! Consider using the users time offset from $user_info?
'nick' => $user_info['name'],
);

if(
$context['user']['is_admin'])
{
$params["isadmin"] = true;
}
else
{
$allowed_groups = array(12);
foreach ($allowed_groups as $allowed)
{
if (in_array($allowed$user_info['groups']))
{
$params["isadmin"] = true;
}
}
}

// Instantiate $chat from phpFreeChat Class.
$chat = new phpFreeChat($params);

echo 
'
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<style type="text/css">
<!--
body {
background-image: url(http://www.yoursite.com/pic.png);
}
-->
</style>
        <head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Cup of Linux Lounge</title>
'
$chat->printJavascript(), '
'
$chat->printStyle(), '
</head>
<body>
                <div align="center"><img src="http://www.yoursite.com/banner.png" width="363" height="75" /></div>

                <div style="width: 95%; margin: auto;">
'
$chat->printChat(), '
</body>
</html>
'
;


In the code you will see that I decided to put a banner on my page... I also wanted a wallpaper. Additionally the code ignores loading my site template because I created a custom header for SMF which for some reason prevented phpfreechat from starting. I hope this will help someone looking to integrate phpfreechat into the latest SMF!

Matthew K.

Why bump an old topic? Over a year old. Create your own if you're wanting to help.

Deezel

thanks spatry, i appreciate your help.


Advertisement: