Tutorial: how to COMPLETELY integrate FlashChat into SMF so you have a cool CHAT

Started by marcnyc, October 09, 2004, 07:21:56 AM

Previous topic - Next topic

Jerry

I tried the installer2.php since I had common.php and all the already edited like it said. in step 3 the values for the mysql were not already set. so I tried the installer2.php and it worked :) This is a gr8 tutorial.


- Jerry
Find me on:
Facebook
Twitter
PlanetSMF

"If all you look for is the negative in things, you will never see the positive."

dg

Quote from: Owdy on October 31, 2004, 12:27:21 PM
How to ad list of users who are in chat

In /FlashChat/info.php, find:

<html>
<title>Who's in the chat?</title>
<head>
<style type="text/css">
<!--
.normal {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: normal;
}
A {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #0000FF;
}
A:hover {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #FF0000;
}
-->
</style>
</head>
<body>
<center>
<p class=normal>There are <?=numusers()?> users in <?=$roomnumb?> rooms.</p>
<?php if($roomnumb) { ?>
<table border="1" cellpadding="1" class="normal">
<tr>
<th>ID</th>
<th>Name</th>
<th>Count</th>
<th>Users</th>
</tr>
<?php foreach($rooms as $room) { ?>
<tr>
<td><?=$room['id']?></td>
<td><?=$room['name']?></td>
<td><?=numusers($room['id'])?></td>
<td><?php

$users usersinroom($room['id']);

foreach( $users as $user ) {
echo $user['login'] . "<br>";
}

?>
</td>
</tr>
<?php ?>
</table>
<?php ?>

<p><a href="javascript:window.close()">Close</a></p>
<center>
</body>
</html>


Replace:

<span style="font-size:xx-small;color:#0232a1">
<?php

$users usersinroom($room['id']);

foreach( $users as $user ) {
echo $user['login'] . ",";
}

?>
</span>



then ad this in index.template.php:

<td colspan="2">
';
if ($context['user']['is_logged'])
echo '
<font size="-2">Users in chat:</font> ';
if ($context['user']['is_logged'])
{

readfile("http://www.example.com/FlashChat/info.php");
}
echo ' 



</td>
With this code only logged users see that list.  Code may be crappy (PHP N00b here), but it works.

hmmm...well when i go and make the change to index.template.php, I get the following error on my website:

---------
Parse error: parse error, unexpected '<' in /home/dgreek/detroitgreeks.com/html/forum/Sources/Load.php(1098) : eval()'d code on line 522

Warning: Cannot add header information - headers already sent by (output started at /home/dgreek/detroitgreeks.com/html/index.php:3) in /home/dgreek/detroitgreeks.com/html/forum/Sources/Load.php on line 1120

Warning: Cannot add header information - headers already sent by (output started at /home/dgreek/detroitgreeks.com/html/index.php:3) in /home/dgreek/detroitgreeks.com/html/forum/Sources/Load.php on line 1121

Warning: Cannot add header information - headers already sent by (output started at /home/dgreek/detroitgreeks.com/html/index.php:3) in /home/dgreek/detroitgreeks.com/html/forum/Sources/Load.php on line 1122

Template Parse Error!
There was a problem loading the /Themes/default/index.template.php template or language file. Please check the syntax and try again - remember, single quotes (') often have to be escaped with a slash (\). To see more specific error information from PHP, try accessing the file directly.

You may want to try to refresh this page or use the default theme.



----

Any thoughts?

Owdy

Its in wrong place then. Try put this only




readfile("http://www.example.com/FlashChat/info.php");

Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

edi67

Quote from: Owdy on October 31, 2004, 12:27:21 PM
How to ad list of users who are in chat

In /FlashChat/info.php, find:

<html>
<title>Who's in the chat?</title>
<head>
<style type="text/css">
<!--
.normal {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: normal;
}
A {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #0000FF;
}
A:hover {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #FF0000;
}
-->
</style>
</head>
<body>
<center>
<p class=normal>There are <?=numusers()?> users in <?=$roomnumb?> rooms.</p>
<?php if($roomnumb) { ?>
<table border="1" cellpadding="1" class="normal">
<tr>
<th>ID</th>
<th>Name</th>
<th>Count</th>
<th>Users</th>
</tr>
<?php foreach($rooms as $room) { ?>
<tr>
<td><?=$room['id']?></td>
<td><?=$room['name']?></td>
<td><?=numusers($room['id'])?></td>
<td><?php

$users usersinroom($room['id']);

foreach( $users as $user ) {
echo $user['login'] . "<br>";
}

?>
</td>
</tr>
<?php ?>
</table>
<?php ?>

<p><a href="javascript:window.close()">Close</a></p>
<center>
</body>
</html>


Replace:

<span style="font-size:xx-small;color:#0232a1">
<?php

$users usersinroom($room['id']);

foreach( $users as $user ) {
echo $user['login'] . ",";
}

?>
</span>



then ad this in index.template.php:

<td colspan="2">
';
if ($context['user']['is_logged'])
echo '
<font size="-2">Users in chat:</font> ';
if ($context['user']['is_logged'])
{

readfile("http://www.example.com/FlashChat/info.php");
}
echo ' 



</td>
With this code only logged users see that list.  Code may be crappy (PHP N00b here), but it works.

this method work perfectly
CrazyZone - My SMF Forum


From the difficult the hardening of the man you can see

dg

I see where I went wrong originally...I forgot to add the 'forum' subdirectory (where I have installed FlashChat).  But even now I'm still getting this:

--------
Template Parse Error!
There was a problem loading the /Themes/default/index.template.php template or language file. Please check the syntax and try again - remember, single quotes (') often have to be escaped with a slash (\). To see more specific error information from PHP, try accessing the file directly.

You may want to try to refresh this page or use the default theme.
--------

>:( >:( What am I doing wrong??

DLD

I'm having the same problem when I edit the template file. It gets a parse error.

I have made several changes to my boardindex.template.php to add a chat stats area to the main stats section of my board. It works perfect until I try to add users online then the page wont load.

This is my code to get the chat stats area in the stats area
// Chat Stats
     $chatrequest = db_query("
            SELECT COUNT(*) AS numb
            FROM  dsnewfor_fc_connections
            WHERE userid IS NOT NULL", __FILE__, __LINE__);
         list ($chatcount) = mysql_fetch_row($chatrequest);   
         mysql_free_result($chatrequest);
         
if ( @$_GET['action'] != "chat" ) {
if ( $chatcount == "1" ) {
$singularplural1 = " is ";
$singularplural2 = "";
} else {
$singularplural1 = " are ";
$singularplural2 = "s";
}
echo'
<tr>
<td class="catbg" colspan="2">', $txt['chatStats'], '</td>
</tr><tr>
<td class="windowbg" width="20" valign="middle" align="center">

<img src="', $settings['images_url'], '/chatIcon.gif" alt="', $txt['chatAlt'], '" border="0" /></a>
</td>
<td class="windowbg2" width="100%">


Currently there ' . $singularplural1 . ' <font color="#FF0000">' . $chatcount . ' User'.$singularplural2.' in the Chat!</font><br>';



}


Can someone help?
Thanks

DLD

I got it working :)

Here is my code maybe this will help others that are using the classic template

// Chat Stats
     $chatrequest = db_query("
            SELECT COUNT(*) AS numb
            FROM  smf_fc_connections
            WHERE userid IS NOT NULL", __FILE__, __LINE__);
         list ($chatcount) = mysql_fetch_row($chatrequest);   
         mysql_free_result($chatrequest);
         
if ( @$_GET['action'] != "chat" ) {
if ( $chatcount == "1" ) {
$singularplural1 = " is ";
$singularplural2 = "";
} else {
$singularplural1 = " are ";
$singularplural2 = "s";
}
echo'
<tr>
<td class="catbg" colspan="2">', $txt['chatStats'], '</td>
</tr><tr>
<td class="windowbg" width="20" valign="middle" align="center">
<a href="', $scripturl, '?action=chat">
<img src="', $settings['images_url'], '/chatIcon.gif" alt="', $txt['chatAlt'], '" border="0" /></a>
</td>
<td class="windowbg2" width="100%">


Currently there ' . $singularplural1 . ' <font color="#FF0000">' . $chatcount . ' User'.$singularplural2.' in the Chat!</font><br>';
if ($context['user']['is_logged'])
echo '
<font size="-2">Users in chat:</font> ';
if ($context['user']['is_logged'])
{

readfile("http://www.mysite.com/yabbse/Flashchat/info.php");
}
}

mediman

Quote from: marcnyc on October 09, 2004, 07:21:56 AM
I couldn't deal with how slow Java chats are

what java chat server (own deamon) is slower as a flash chat with php mysql as backend?

mediman
My Projects: http://ticker-oase.de 
Please do not PM me with support requests.

charlottezweb

This isn't the right forum of course, but anyone had any luck with skinning this?  I've followed their instructions and everything loads great for me, but regular users seem to be loading a different gradient set and colors.  I've verified both files appear correct.  Just thought I'd see if anyone else had similar experiences...

Regards,
Jason

bloc

Quote from: Owdy on October 21, 2004, 01:04:04 PM
It doewsnt allow äö etc in nicknames. How can i fix that?

I had the same problem when I bought it and installed it yesterday. It wont allow ø,æ and å in usernames, just shows gibberish there. But there is a solution posted on the FlashChat board - with some modifications though:

Open up FlashChat/inc/cmses/smfCMS.php and add the things in red : (mind you , these are my needs..look below for a list of more special charachters.)

  function getUser($userid) {


    $rv = NULL;
    if(($rs = $this->getUserStmt->process($userid)) && ($rec = $rs->next())) {
     $rec['roles'] = $this->getRoles($rec['status']);

     $rec['login'] = str_replace('å', 'Ã¥', $rec['login']);
     $rec['login'] = str_replace('ø', 'ø', $rec['login']);
     $rec['login'] = str_replace('æ', 'æ', $rec['login']);
     $rec['login'] = str_replace('Å', 'Ã...', $rec['login']);
     $rec['login'] = str_replace('Ø', 'Ø', $rec['login']);
     $rec['login'] = str_replace('Æ', 'Æ', $rec['login']);

     $rv = $rec;
    }

    return $rv;
  }



Here are more charachters...



                                        'å' => 'Ã¥',
                                        'ä' => 'ä',
                                        'æ' => 'æ',
                                        'ö' => 'ö',
                                        'ø' => 'ø',
                                        'Å' => 'Ã...',
                                        'Ä' => 'Ã,,',
                                        'Æ' => 'Æ',
                                        'Ö' => 'Ö',
                                        'Ø' => 'Ø',
                                        'é' => 'é',
                                        'è' => 'è',
                                        'ü' => 'ü',
                                        'ß' => 'ß',
                                        'ù' => 'ù',
                                        'ì' => 'ì',
                                        'à' => 'Ã ',
                                        'ò' => 'ò');


bbayliss

Does anyone know if it is possible to turn off the chat login and allow members that are logged into the forum just go back and forth between forum and chat without having to log in everytime. I understand that is the way it is supposed to work, but every time I press the chat link and after it loads it says "Incorrect user name or password"
Thank you,
Brian

bloc

If you have followed the instructions  to integrate with  SMF, it should login automatically - even if you type in the direct adress. It reads the cookie just like SMF.

bbayliss

Bloc,
Here is what I mean about my code being deferant from the example.

The example says to find this:

   <a href="', $scripturl, '?action=who">', $context['num_guests'], ' ', $context['num_guests']
== 1 ? $txt['guest'] : $txt['guests'], ', ',
$context['num_users_online'], ' ', $context['num_users_online'] == 1 ? $txt['user'] : $txt['users'], (empty($context['num_users_hidden']) ? '' : ' (' . $context['num_users_hidden'] . ' ' .
$txt['hidden'] . ')'), '</a><br />


But my file has this
'<a href="' . $scripturl . '?action=who">' : '', $context['num_guests'], ' ', $context['num_guests']
== 1 ? $txt['guest'] : $txt['guests'], ', ', $context['num_users_online'], ' ',
$context['num_users_online'] == 1 ? $txt['user'] : $txt['users'], $context['num_users_hidden'] > 0 ? '
(' . $context['num_users_hidden'] . ' ' . $txt['hidden'] . ')' : '', $context['show_who'] ? '</a>' : '', '<br />
<span class="smalltext">';


What do I do with this?
: '', $context['show_who'] ? '</a>' : '', '<br />
<span class="smalltext">';


Thank you for your help.
Brian

bloc

Um, I am guessing you want to put in number of users on the chat.... whats the chunk of code for that?

the last bit of code you have trouble with - the context['show_who'] - is that the FlashChat code or some other mod? 

bbayliss

I am not sure, I do not really have any mods exceot for one that Unknown gave me for searching members by location. I guess I can always remove it and see what if anything changes.
Brian

bloc

Dont do that. I just wondered what it was. The code for showing users in the chat can be added without replacing that whole section. :)

bbayliss

Bloc, I still need help. The problem with my autologin was apparently my browser or something else with my laptop. My desktop worked just fine. However I can not get the code above to work. I have tried adding several differant ways and I always get a parse error. Could you look at it anf give me some ideas as to what to change.
Thank you,
Brian

bloc

Sure. But I need to see your files first. I am not sure what you have done or not done.

garfield

After doing all the work...

I must say: really really great!  8)
Thanx a lot for this nice implementation.


My fresh experience on some problems:
I use it with the classic-theme and SMF beta 5.

The chat-logo in index.template.php
the incorrect tutorial on trufat.com http://www.easterpig.com/demo/flashchat/integration/smf.html cost me the most time.   i  had to remove a "{" and change the arrangement, because otherwise i had problems with the seperators, so my end of the skript looks like this:

// Otherwise, they might want to [logout]...
else
     echo '<a href="', $scripturl, '?action=logout;sesc=', $context['session_id'],
    '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url']
    . '/' . $context['user']['language'] . '/logout.gif" alt="' . $txt[108]
    . '" style="margin: 2px 0;" border="0" />' : $txt[108]),'</a>', $context['menu_separator'];
   
    echo '<a href="', $scripturl, '?action=chat">',
     ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url']
    . '/' . $context['user']['language'] . '/chat_icon.gif" alt="' . $txt[108]
    . '" style="margin: 2px 0;" border="0" />' : $txt[108]),'</a>';

   
}
?>


and added a , $context['menu_separator'] after <a href="', $scripturl, '?action=register">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/register.gif" alt="' . $txt[97] . '" border="0" />' : $txt[97]), '</a>' .




And now i have the same problems like bbayliss with the SUB-TUTORIAL #1

Quote from: bbayliss on November 21, 2004, 04:47:17 AM
Bloc,
Here is what I mean about my code being deferant from the example.

The example says to find this:

   <a href="', $scripturl, '?action=who">', $context['num_guests'], ' ', $context['num_guests']
== 1 ? $txt['guest'] : $txt['guests'], ', ',
$context['num_users_online'], ' ', $context['num_users_online'] == 1 ? $txt['user'] : $txt['users'], (empty($context['num_users_hidden']) ? '' : ' (' . $context['num_users_hidden'] . ' ' .
$txt['hidden'] . ')'), '</a><br />


But my file has this
'<a href="' . $scripturl . '?action=who">' : '', $context['num_guests'], ' ', $context['num_guests']
== 1 ? $txt['guest'] : $txt['guests'], ', ', $context['num_users_online'], ' ',
$context['num_users_online'] == 1 ? $txt['user'] : $txt['users'], $context['num_users_hidden'] > 0 ? '
(' . $context['num_users_hidden'] . ' ' . $txt['hidden'] . ')' : '', $context['show_who'] ? '</a>' : '', '<br />
<span class="smalltext">';


What do I do with this?
: '', $context['show_who'] ? '</a>' : '', '<br />
<span class="smalltext">';


Thank you for your help.
Brian

I've not enough experience with PHP, so i did not make it, to get the , ' . $chatcount . ' User'.$singularplural2.' in Chat in the right place between it.

Would be great if u can help



Anyway the Chat.template is a brilliant idea!

greets frm germany
garfield

Owdy

How can i ad title tag in that chat/template?
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

Advertisement: