• 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

Number of people in chat....?

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

Post a reply
16 posts • Page 1 of 2 • 1, 2

Postby drnic2032 » Mon Sep 29, 2008 5:45 am

Is there any way to call into the PHP routine in order to output how many people are currently in the chat?

I'm trying to setup a page with a link into the chat that says how many people are already there. Please le t me know. Thanks!!
drnic2032
Member
 
Posts: 12
Joined: Tue Jul 22, 2008 5:27 am
Top

Postby Jamesiv4 » Wed Oct 01, 2008 12:57 am

In your chat.php page, you must have this parameter:

$params["serverid"] = md5("Whatever you Want"); // calculate a unique id for this chat

Put this in the page where you want the User list to display:

Code: Select all
            <?php
         require_once dirname(__FILE__)."/chat/src/pfcinfo.class.php";
         $info  = new pfcInfo( md5("Whatever you Want") );
         // 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 align="center">';
         $info = "";
         $nb_users = count($users);
         if ($nb_users <= 0)
           $info = "<center>%d users in the Chat Room</center>";
         echo "</div>";
         echo "<div>";
         echo "<p>".sprintf($info, $nb_users)."</p>";
         echo "<ol>";
         foreach($users as $u)
         {
           echo "<li>".$u."</li>";
         }
         echo "</ol>";
         echo "</div>";
         ?>
Jamesiv4
Member
 
Posts: 57
Joined: Sat Sep 06, 2008 11:18 am
Top

Postby dieq41 » Wed Oct 29, 2008 7:09 am

Thanx Jamesiv4
./ dieq41
newbie php
dieq41
New member
 
Posts: 9
Joined: Sat Mar 15, 2008 10:50 am
Location: Jakarta, Indonesia
  • Website
  • YIM
Top

Postby MarkHoward » Mon Oct 19, 2009 5:03 am

Got errors when I tried this.
I have
Code: Select all
$params["serverid"] = md5(__FILE__); // calculate a unique id for this chat

in chat.php
I have exactly the code presented above in another php page (was just html before)
But when I open that page I get this
Code: Select all
Warning: require_once(D:xampphtdocsDirectory/chat/src/pfcinfo.class.php) [function.require-once]: failed to open stream: No such file or directory in D:xampphtdocsDirectorydirectory.php on line 36

Fatal error: require_once() [function.require]: Failed opening required 'D:xampphtdocsDirectory/chat/src/pfcinfo.class.php' (include_path='.;D:xamppphppear') in D:xampphtdocsDirectorydirectory.php on line 36

I'd be most grateful for some assistance, thanks.
MarkHoward
Member
 
Posts: 20
Joined: Sun Jul 19, 2009 12:47 am
Top

Postby MarkHoward » Wed Nov 18, 2009 1:56 am

In case my problems are related to testing on a localhost I'm now trying this live on the web-server.
I have
Code: Select all
$params["serverid"] = md5(ForumChat); // calculate a unique id for this chat

in chat.php.

This is the (first part) of the code I have in ../directory/directory.php ( in relation to the Chat folder )
Code: Select all
      <?php
            require_once dirname(__FILE__)."/chat/src/pfcinfo.class.php";
            $info  = new pfcInfo( md5(ForumChat) );
            // 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);

and the error messages are
Code: Select all
Warning: require_once(/home/nzmotorh/public_html/directory/chat/src/pfcinfo.class.php) [function.require-once]: failed to open stream: No such file or directory in /home/nzmotorh/public_html/directory/directory.php on line 36

Fatal error: require_once() [function.require]: Failed opening required '/home/nzmotorh/public_html/directory/chat/src/pfcinfo.class.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/nzmotorh/public_html/directory/directory.php on line 36

There is no "chat" folder in /directory but when I try to hard-code "/home/nzmotorh/public_html/chat/src/pfcinfo.class.php", I still get error messages.

I really would appreciate some help with what must be a somewhat simple problem - although it defeats me.
MarkHoward
Member
 
Posts: 20
Joined: Sun Jul 19, 2009 12:47 am
Top

Postby waiheke » Mon Sep 13, 2010 3:15 pm

Got it working, thanks to another thread here

require_once dirname(__FILE__)."/src/pfcinfo.class.php";

// the next line you MUST EDIT FOR YOUR OWN SERVER ...........
$serverId = "xxxxe0c89fxxxxxxxxbf618b4608xxxx";


$chatinfo= new pfcInfo($serverId );
$users = $chatinfo->getOnlineNick(NULL);

sort($users);
$nd_users = count($users);
$info = "";
if ($nd_users==0) {
echo "There are no users online";
} else {
echo "$nd_users users online";
foreach($users as $u)
{
echo "<li>".$u."</li>";
}}
echo "</ul>";

what worked for me was to look at the unique number generated in the private/log/folder on my server (as shown above) using a standard FTP programme - just substitute your folder string
Last edited by waiheke on Thu Oct 21, 2010 3:52 pm, edited 1 time in total.
waiheke
Member
 
Posts: 126
Joined: Sun Sep 12, 2010 4:33 pm
Top

Postby sandarminaye » Fri Oct 15, 2010 4:27 am

i testing now that number of people in chat, but now , it is not ok .. :( .. pls tell me if u know.

firstly i run this following code.

require_once dirname(__FILE__)."/LIVE_CHAT/src/pfcinfo.class.php";
$info = new pfcInfo( md5(__FILE__) );
// 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 align="center">';
$info = "";
$nb_users = count($users);
if ($nb_users <= 0)
$info = "<center>%d users in the Chat Room</center>";
echo "</div>";
echo "<div>";
echo "<p>".sprintf($info, $nb_users)."</p>";
echo "<ol>";
foreach($users as $u)
{
echo "<li>".$u."</li>";
}
echo "</ol>";
echo "</div>";

and then i enter the chat with 2 browsers and 2 nickname. The result is still 0 users in the chat.

Second , i run this following code.

/*require_once dirname(__FILE__)."/src/pfcinfo.class.php";*/
$serverId = "dfb9e0c89fa5f31b6abf618b460839bc";
$chatinfo= new pfcInfo($serverId );
$users = $chatinfo->getOnlineNick(NULL);

sort($users);
$nd_users = count($users);
$info = "";
if ($nd_users==0) {
echo "There are no users online";
} else {
echo "$nd_users users online";
foreach($users as $u)
{
echo "<li>".$u."</li>";
}}
echo "</ul>";

and then i enter the chat with 2 browsers and 2 nickname. The result is still "There is no users online".

why?? pls tell me if u know ..

thanks all
sandarminaye
New member
 
Posts: 5
Joined: Thu Oct 14, 2010 9:38 am
Top

Postby waiheke » Sun Oct 17, 2010 9:56 pm

$serverId = "dfb9e0c89fa5f31b6abf618b460839bc"; ???
is this correct ? Do you know that, for your server ?
waiheke
Member
 
Posts: 126
Joined: Sun Sep 12, 2010 4:33 pm
Top

Postby OldWolf » Sun Oct 17, 2010 11:35 pm

Serverid can be set to whatever you want, it just needs to be the same on both, and something that can't be easily guessed.
Signature:
Read before Posting: Forum Rules
Note: I am unable to offer support through PM/e-mail at this time.
OldWolf
Site Admin
 
Posts: 1918
Joined: Sun Sep 23, 2007 5:48 am
Top

Postby waiheke » Mon Oct 18, 2010 1:31 am

Make this file, called findchatinfo.php and upload to your chat folder, then run it.
(assuming you are using the default settings, out-of-the-box installation, for the $startdir)

The final string, of the numbers echoed to screen should the numbers you're looking for :)






<?php
function folderlist(){
$startdir = '././data/private/logs/';
$ignoredDirectory[] = '.';
$ignoredDirectory[] = '..';
if (is_dir($startdir)){
if ($dh = opendir($startdir)){
while (($folder = readdir($dh)) !== false){
if (!(array_search($folder,$ignoredDirectory) > -1)){
if (filetype($startdir . $folder) == "dir"){
$directorylist[$startdir . $folder]['name'] = $folder;
$directorylist[$startdir . $folder]['path'] = $startdir;
}
}
}
closedir($dh);
}
}
return($directorylist);
}

$folders = folderlist();

$keys = array_keys($folders);
$path=implode(", ",$keys);
echo $path;
?>
waiheke
Member
 
Posts: 126
Joined: Sun Sep 12, 2010 4:33 pm
Top

Postby waiheke » Mon Oct 18, 2010 4:56 am

Oh
I just found a post by Old Wolf, with much more elegant code :)


Copy this to the very bottom of your chat page and upload and run it to see the params
The 1st entry is the number string you want

<?php
echo '<h2>Debug</h2>';
echo '<pre>';
$c =& pfcGlobalConfig::Instance();
print_r($c);
print_r($_SERVER);
echo '</pre>';
?>
waiheke
Member
 
Posts: 126
Joined: Sun Sep 12, 2010 4:33 pm
Top

Postby sandarminaye » Wed Oct 20, 2010 7:59 am

hi,

i also want to know the number of people in chat, so , how do i write in my page.

pls help me and tell me complete code. :D

i had try above coding but it can't. :(

thanks all.
sandarminaye
New member
 
Posts: 5
Joined: Thu Oct 14, 2010 9:38 am
Top

Postby waiheke » Thu Oct 21, 2010 2:50 pm

sandarminaye wrote:hi,

i also want to know the number of people in chat, so , how do i write in my page.

pls help me and tell me complete code. :D

i had try above coding but it can't. :(

thanks all.

"tell me complete code."
??
You have it, there above you
Post 6 and Post 11

Change only the ID string in the code in Post 6 AFTER using the Post 11 to find out what it is.
No one can tell you what it is - you need to find it out for yourself, because it's unique to your server. Only for you.
Last edited by waiheke on Thu Oct 21, 2010 3:54 pm, edited 1 time in total.
waiheke
Member
 
Posts: 126
Joined: Sun Sep 12, 2010 4:33 pm
Top

Postby sandarminaye » Tue Nov 23, 2010 9:46 am

hi , waiheke ..

thanks for reply ..

it is now ok for me .. :P

can i ask something question about this chat ?

now i complete modified this chat in my local host. i want to upload this chat folder to my website, www.stampsmyanmar.com. i think this chat folder contains many files and many pages (e.g. .php , .css, .js and so on). so that i want to delete some files or pages (e.g. demo file) , but i don't know what files or pages delete. if u know , pls tell me ..

thanks again for sharing knowledge.

rgds,
sanda
sandarminaye
New member
 
Posts: 5
Joined: Thu Oct 14, 2010 9:38 am
Top

Postby Monday » Mon Jan 23, 2012 2:10 pm

waiheke wrote:Oh
I just found a post by Old Wolf, with much more elegant code :)


Copy this to the very bottom of your chat page and upload and run it to see the params
The 1st entry is the number string you want

<?php
echo '<h2>Debug</h2>';
echo '<pre>';
$c =& pfcGlobalConfig::Instance();
print_r($c);
print_r($_SERVER);
echo '</pre>';
?>

I'm getting the following error:

Fatal error: Class 'pfcGlobalConfig' not found in /hsphere/local[...]phpfreechat-0.9.3/index.php on line 27

Please help! :)
Monday
New member
 
Posts: 2
Joined: Mon Jan 23, 2012 2:09 pm
Top

Next

Post a reply
16 posts • Page 1 of 2 • 1, 2

Return to General Support (v1.x)

Who is online

Users browsing this forum: No registered users and 41 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