• Forum
  • Doc
  • Screenshots
  • Download
  • Donate
  • Contributors
  • Contact
  • Follow @phpfreechat
  • DEMO
  • Board index ‹ Version 1.x branch ‹ phpBB, Simple Machines Forum (SMF), and Forum Software (v1.x)
  • Change font size
  • FAQ
  • Register
  • Login

[Guide] \"Who is Online\" in the index of a phpbb forum

Moderators: OldWolf, re*s.t.a.r.s.*2

Post a reply
8 posts • Page 1 of 1

Postby Ewelthen » Wed Jan 17, 2007 3:29 am

First I'm speaking in french, so I appologie for my english ^^

I've made a guide for those who want to show online users from the chat, in a phpbb forum, in the section "Who is online" in the index.

I hope it will be usefull (I think the solution wasn't clearly post in the forum. If it was, I haven't found it).

Here is the code (I've try to show it like a Mod installation instruction)

Important, please read the annotations in the code "// ..."

Code: Select all
##############################################################
## MOD Title: www.phpfreechat.net: integration of online users in the index of a phpbb forum
## MOD Author: Adaptation of the code from: "demo31_show_who_is_online-whoisonline.php"
##      by Ewelthen - www.guilde-echoes.net
## MOD Description: This will add online users from your chat in the index of your phpbb forum
##
## Installation Level: easy
## Installation Time: 5 Minutes
## Files To Edit: 2
##   index.php
##   templates/YourTemplate/index_body.tpl
##
##############################################################

#
#-----[ OPEN ]---------------------------------------------
#
index.php

#
#-----[ FIND ]---------------------------------------------
#
   //
   // Start output of page
   //
   define('SHOW_ONLINE', true);
   $page_title = $lang['Index'];
   include($phpbb_root_path . 'includes/page_header.'.$phpEx);

#
#-----[ BEFORE, ADD ]--------------------------------------
#
// Show users on chat - code from: www.phpfreechat.net
   require_once "PARENT_DIRECTORY/chat/src/pfcinfo.class.php";
// You need to change the path with your configuration
   $info_chat  = new pfcInfo( md5("Chat Name") );
// You need to change the name !
// Take the same as define in the index page of your chat, here : $params["serverid"] = md5("Chat Name");
   $users_chat = $info_chat->getOnlineNick(NULL);
   $info_chat = "";
   $nb_users_chat = count($users_chat);
   if ($nb_users_chat <= 1)
        $info_chat = "In total there are <strong>%d</strong> user online on chat.";
   else
        $info_chat = " In total there are <strong>%d</strong> users online on chat.";
   foreach($users_chat as $u){
   $u = "<b>".$u." </b>";}

#
#-----[ FIND ]---------------------------------------------
#
   $template->assign_vars(array(
      'TOTAL_POSTS' => sprintf($l_total_post_s, $total_posts),
      'TOTAL_USERS' => sprintf($l_total_user_s, $total_users),
      'NEWEST_USER' => sprintf($lang['Newest_user'], '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$newest_uid") . '">', $newest_user, '</a>'),

#
#-----[ AFTER, ADD ]--------------------------------------
#

      'TOTAL_USERS_ONCHAT' => sprintf($info_chat, $nb_users_chat),
      'USERS_ONCHAT' => sprintf($u),

#
#-----[ OPEN ]---------------------------------------------
#
templates/YourTemplate/index_body.tpl
// the code may be a bite different, depends of your template!

#
#-----[ FIND ]---------------------------------------------
#
   <td class="row1" align="left"><span class="gensmall">{TOTAL_USERS_ONLINE}   [ {L_WHOSONLINE_ADMIN} ]   [ {L_WHOSONLINE_MOD} ]<br />{RECORD_USERS}<br />{LOGGED_IN_USER_LIST}</span></td>
  </tr> 

#
#-----[ AFTER, ADD ]--------------------------------------
#
   <td class="row1" align="left"><span class="gensmall">{TOTAL_USERS_ONCHAT}<br />Utilisateurs enregistrés : {USERS_ONCHAT}</span></td>
  </tr>


#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM

If you want to correct my english, add more features ... you are Welcome.

Thank you all from phpfreechat, you have done a great job!
Last edited by Ewelthen on Wed Jan 17, 2007 3:30 am, edited 1 time in total.
Ewelthen
New member
 
Posts: 1
Joined: Wed Jan 17, 2007 3:16 am
Top

Postby TheMash » Sat Mar 03, 2007 3:19 pm

Hello, thanks for your contribution! It's great!
Like phpFreeChat of course.
But I cant get it working.
I added the script in the index.php and in the template file of phpBB forum,but when i try to load the forum index I get this error:

Please correct these errors:

* 'serverid' parameter is mandatory by default use 'md5(__FILE__)' value

I dont understand the reason.. I wrote the same "chat name" that's in the index.php of the chat...
What's wrong?
Thanks in advance!
TheMash
New member
 
Posts: 2
Joined: Sat Mar 03, 2007 1:48 pm
Top

Postby Niryk » Mon Mar 05, 2007 5:03 pm

You are going to have to make some changes to the file manually...
Code: Select all
// Show users on chat - code from: www.phpfreechat.net
    require_once "PARENT_DIRECTORY/chat/src/pfcinfo.class.php";
// You need to change the path with your configuration
    $info_chat  = new pfcInfo( md5("Chat Name") );

Needs to have your information in there, and be sure you're using the same md5 value in both places (your actual chat app, and your phpBB page) or you won't get the same value you're expecting.
Niryk
New member
 
Posts: 5
Joined: Mon Feb 26, 2007 9:48 pm
Top

Postby TheMash » Mon Mar 05, 2007 8:21 pm

Hello Niryk,
thanks for the reply.
I have made that changes to file of course, with the path of pfcinfo file.
The problem wasnt it. Btw I solved.
the serverid parameter was the same in both files.
But with if I set __FILE__ as chat name doesnt work.
I read again the guide i had i thought the script maybe need a string with " " in serverid parameter.
So I set the value to "chat" in both files and it magically worked! I think it was expecting a string and didnt like __FILE__ variable in chat name.
But there is one more problem (sorry for my english).
In the index of phpbb forum the script print how many and who is in the chat.
The counting of users is working correctly, but who is in the chat doesnt work properly.
It show me just one user.
The script that print who is in the chat is the following:

// Show users on chat - code from: www.phpfreechat.net
require_once "../chat/src/pfcinfo.class.php";
// You need to change the path with your configuration
$info_chat = new pfcInfo( md5("chat") );
// You need to change the name !
// Take the same as define in the index page of your chat, here : $params["serverid"] = md5("Chat Name");
$users_chat = $info_chat->getOnlineNick(NULL);
$info_chat = "";
$nb_users_chat = count($users_chat);
if ($nb_users_chat <= 1)
$info_chat = "Attualmente ci sono <span class='testo_forum'><strong>%d</strong></span> utenti in chat.";
else
$info_chat = " Attualmente ci sono <span class='testo_forum_acceso'><strong>%d</strong></span> utenti in chat.";
foreach($users_chat as $u){
$u = "<b>".$u." </b>";}


if ($nb_users_chat <= 0)
$u = "Nessuno";

The last two rows of code was added by me, so when there no users in the chat script print the word "Nessuno", that in Italian means "none".
Btw the problem is in this part of script, i think:

foreach($users_chat as $u){
$u = "<b>".$u." </b>";}

What's wrong?
TheMash
New member
 
Posts: 2
Joined: Sat Mar 03, 2007 1:48 pm
Top

Postby dbass » Thu Apr 12, 2007 8:24 pm

The last two rows of code was added by me, so when there no users in the chat script print the word "Nessuno", that in Italian means "none".
Btw the problem is in this part of script, i think:

foreach($users_chat as $u){
$u = "<b>".$u." </b>";}

What's wrong?

I have exactly the same problem... Anybody have a good idea? When I use "echo" like it is in the script on demo31:

foreach($users_chat as $u){
echo "<b>".$u." </b>";}

I can see all the connected users, but I have errors from phpbb (template), the number and name of connected users is displayed on the top of the page, not where the TPL want...
dbass
New member
 
Posts: 2
Joined: Thu Apr 12, 2007 8:13 pm
Top

Postby zinx » Tue Aug 14, 2007 4:30 am

Has anyone figured this out? Just finished the phpBB integration and i'm getting the same problem with it displaying the correct number in the chat but only the last user in the list.
Last edited by zinx on Tue Aug 14, 2007 4:30 am, edited 1 time in total.
zinx
New member
 
Posts: 1
Joined: Tue Aug 14, 2007 4:15 am
Top

Postby Yautja_cetanu » Mon Aug 27, 2007 3:09 pm

is this for phpbb2 or 3?
Yautja_cetanu
Member
 
Posts: 18
Joined: Sat Feb 25, 2006 1:47 am
Top

Postby JamesSg » Wed Nov 14, 2007 2:12 pm

//Added by OZ//
// Show users on chat - code from: www.phpfreechat.net
require_once "../chat/src/pfcinfo.class.php";
// You need to change the path with your configuration
$info_chat = new pfcInfo( md5("fkchat") );
// You need to change the name ! // Take the same as define in the index page of your chat, here : $params["serverid"] = md5("Chat Name");
$users_chat = $info_chat->getOnlineNick(NULL);
$info_chat = "";
$nb_users_chat = count($users_chat);
if ($nb_users_chat <= 1)
$info_chat = "In total there is <strong>%d</strong> user online on chat.";
else
$info_chat = "In total there are <strong>%d</strong> users online on chat.";
$countercheck=1;
foreach($users_chat as $u){
if ($countercheck==$nb_users_chat){
$u = "<b>".$u." </b>";
}
else
{
$u = "<b>".$u.", </b>";
$countercheck=$countercheck+1;
}
$z = $z.$u;
}
$u = $z;
if ($nb_users_chat <= 0)
$u = "None";
//Added by OZ//
JamesSg
New member
 
Posts: 1
Joined: Tue Nov 13, 2007 7:58 am
Top


Post a reply
8 posts • Page 1 of 1

Return to phpBB, Simple Machines Forum (SMF), and Forum Software (v1.x)

Who is online

Users browsing this forum: No registered users and 4 guests

  • Board index
  • The team • Delete all board cookies • All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
Sign in
Wrong credentials
Sign up I forgot my password
.
jeu-gratuit.net | more partners
Fork me on GitHub