• Forum
  • Doc
  • Screenshots
  • Download
  • Donate
  • Contributors
  • Contact
  • Follow @phpfreechat
  • DEMO
  • Board index ‹ Version 1.x branch ‹ General Support (v1.x)
  • Change font size
  • FAQ
  • Register
  • Login

Display number of users logged in

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

Post a reply
6 posts • Page 1 of 1

Postby Greedfeed » Thu Feb 03, 2011 3:44 pm

Hey guys, I have PHP Free Chat setup that integrates with a MySQL server and I would like to make it so that I can display elsewhere on my website how many users are currently in the chatroom, is there an easy way to extract this number from the DB, or do I need to write something custom in the app itself in order to get that number to the DB for me to grab it. Any help is really appreciated, thanks so much guys!
Greedfeed
New member
 
Posts: 2
Joined: Thu Feb 03, 2011 3:34 pm
Top

Postby re*s.t.a.r.s.*2 » Thu Feb 03, 2011 5:05 pm

I dont remember if this code works with the MYSQL container or file container but check it out and tell me if works..

change "any_word" string for the name you use..in your chat.

Code: Select all
<?php

require_once dirname(__FILE__)."/src/pfcinfo.class.php";
$info  = new pfcInfo( md5("any_word") );
// NULL is used to get all the connected users, but you can specify
// a channel name to get only the connected user on a specific channel
$users = $info->getOnlineNick(NULL);
echo '<div style="margin: auto; width: 100px; padding: 1em;text-align:left;">';
$info = "";
$nb_users = count($users);
if ($nb_users <= 1)
  $info = "<strong>%d</strong> user connected !";
else
  $info = "<strong>%d</strong> users connected !";
echo "<p>".sprintf($info, $nb_users)."</p>";

echo "<ul>";
foreach($users as $u)
{
  echo "<li>".$u."</li>";
}
echo "</ul>";
echo "</div>";

?>
Last edited by re*s.t.a.r.s.*2 on Thu Feb 03, 2011 5:30 pm, edited 1 time in total.
Free Singles Chat Rooms No Registration Required
Text and Chat Singles no need to register or app required
Sala De Bate Papo Online Grátis E Sem Cadastro
re*s.t.a.r.s.*2
Support Team
 
Posts: 612
Joined: Wed Sep 24, 2008 4:04 pm
Location: los angeles CA
  • Website
Top

Postby Greedfeed » Thu Feb 03, 2011 6:21 pm

Thanks for the help! I modified that code a bit and it works like a charm.
Greedfeed
New member
 
Posts: 2
Joined: Thu Feb 03, 2011 3:34 pm
Top

Postby pearlshark » Wed Feb 09, 2011 6:38 am

What did you need to modify to make it work here? Does this work with mysql?
pearlshark
Member
 
Posts: 14
Joined: Thu Jan 06, 2011 6:47 pm
Top

Postby re*s.t.a.r.s.*2 » Wed Feb 09, 2011 6:43 am

yes it does work for mysql container, because he said he is using it..

So I guess it works..
Free Singles Chat Rooms No Registration Required
Text and Chat Singles no need to register or app required
Sala De Bate Papo Online Grátis E Sem Cadastro
re*s.t.a.r.s.*2
Support Team
 
Posts: 612
Joined: Wed Sep 24, 2008 4:04 pm
Location: los angeles CA
  • Website
Top

Postby Cyb » Sat Mar 05, 2011 4:19 pm

Hi,

I tried to do the same, but I don't know what have I to change for
change "any_word" string for the name you use..in your chat.

my chat has this params :
Code: Select all
$params['title'] = "Phobiesociale";
$params['channels'] = array('pschannel');
$params["serverid"]      = md5(__FILE__);

Is that the thrid word ? Because I have writen
Code: Select all
$info  = new pfcInfo( md5(__FILE__));

at the beginin but it doesn't work.
Of course I tried with the two others words behind : Phobiesociale and pschannel to test but without any success :)

I think I havn't understand what I have to do to make this script work !


Sorry, I have a little research done and have found this :
http://www.phpfreechat.net/forum/viewtopic.php?id=3242

It works much better ;)
Last edited by Cyb on Sat Mar 05, 2011 4:26 pm, edited 1 time in total.
Cyb
Member
 
Posts: 11
Joined: Fri Mar 04, 2011 2:53 pm
Top


Post a reply
6 posts • Page 1 of 1

Return to General Support (v1.x)

Who is online

Users browsing this forum: No registered users and 9 guests

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