Hi,

when activating the "Who is chatting"-Block an error occurs, because the function "_phpfreechat_check_install" is not known. (phpfreechat.inc seems not to be included at that point).
After I commented linw 227-230 out,
$info = new pfcInfo(md5($base_url), $params['data_private_path']);
returns an error:
pfcInfo Object ( [c] => [errors] => Array ( [0] => _Error: the cached config file doesn't exists_ ) )
When I look into the ....private/cache directory, there are two php-files, but none of them has the name of md5($base_url).

Any ideas

Thansk in advance
Markus

Comments

NewToDruballer’s picture

Finally I managed to track it down myself. The problem is, that server_id is not really md5(base_url) but md5("node{nid}"). Where {nid} of course is the id of the node, where the chat exists. So if I want the usernames in all chats on the site, I have to extract all nodes with chats from the {phpfreechat} table and iterate over them manually. So the build-in "pfcInfo::getOnlineNick(NULL);" only returns the users on one node.

Markus

permutations’s picture

I made this change, but it doesn't help because the node information is not being saved in the phpfreechat table. I don't know why this is. I've tried it on a new installation of Drupal 5.7, and I still had the problem. But no one else is reporting it.

I'm running phpfreechat 1.1 instead of phpfreechat 1.0-final. Now I'm wondering if that's why. I'm trying 1.0 now.

permutations’s picture

Nope - doesn't work with 1.0, either, so I'm going back to 1.1.

permutations’s picture

Title: "Who is chatting" does not work » "Who is chatting" does not work (none of the phpfreechat blocks work)

I haven't fixed this problem, but I've done some investigations and can add some information.

It's true that the server-id in the code is wrong. It should be based on the node, not the base_url. I hardcoded the information and it came back correct. I don't know why the module author ever initialized the server-id based on the base_url since it's never correct.

I'm trying to figure out how to get the node id from within the block hook (without hardcoding). It will take a database call, I think. But I fixed the database bug so at least there is data in the database!

permutations’s picture

I fixed it. Here's the code. Look for these three lines in the phpfreechat_block function in phpfreechat.module (lines 231-233 in 5.x-1.0-rc4):

$params = phpfreechat_load_params();
require_once 'phpfreechat/src/pfcinfo.class.php';
$info  = new pfcInfo(md5($base_url), $params['data_private_path']);

Replace that with this:

$params = phpfreechat_load_params();

// Get get all chat nodes (node id).
$query = db_query('SELECT * FROM {phpfreechat}');
$chat_nodes = array();
	
// Drop the nodes that don't have chats on them.
while ($room = db_fetch_object($query)) {
  $node = node_load($room->nid);
  $params = phpfreechat_prepare_params($params, $node, $user);
  $chat_content = variable_get('phpfreechat_nodeapi_'.$node->type, '');
  if (($chat_content == 'always') || ($chat_content == 'pernode' && $room->phpfreechat_enabled)) {
    $chat_nodes[] = $node->nid;
  }
}
// Use only the first chat server in the blocks (quick and dirty solution).
$serverid_node = md5('node'.$chat_nodes[0]);

require_once ('phpfreechat/src/pfcinfo.class.php');
$info  = new pfcInfo($serverid_node, $params['data_private_path']);

Note that this will only work if you first fix the database bug. You can't get the node id without a database call. I posted the fix for the database bug here:

http://drupal.org/node/250069

permutations’s picture

I fixed all the bugs in the phpfreechat module (a few more than are listed above), updated the module version to 5.x-1.1, and posted the full package on my Web site here:

http://permutations.com/drupal/phpfreechat.php

I emailed the original author of the module about creating a new download, but he never answered me. There were too many changes to track of as individual patches.

owahab’s picture

Status: Active » Fixed

Fixed, thanks permutations for your effort.

permutations’s picture

There's a new version with two additional fixes on my Web site (along with many other fixes):

http://permutations.com/drupal/phpfreechat.php

permutations’s picture

I have a version of the phpFreeChat module on my Web site that fixes many different bugs. I just updated it today. If owahab makes me a module maintainer here on Drupal, I'll integrate the changes here and stop posting them separately:

http://permutations.com/drupal/phpfreechat.php

owahab - please stop deleting this link. It is not helpful to the community.

permutations’s picture

I just uploaded a new version (http://permutations.com/drupal/phpfreechat.php).

I backed out setting the default timeout to 35000 in the module. It's not working because the "negative number" error is still happening after clearing the cache (/rehash). The timeout needs to be changed to avoid disconnects, and the easiest way to do this is to change it directly in pfcglobalconfig.class.php. phpFreeChat has an integer check in there, and Drupal's form API doesn't have an integer type. I tried to identify the integer strings and change them and it worked in a test file, but not in the module.

pfcglobalconfig.class.php is in the phpFreeChat src directory (it's not a module file).

  1. To change the default timeout, find this variable assignment and change the 20000 to 35000:

    var $timeout = 35000;
    
  2. To get rid of the negative number error, comment out this code in pfcglobalconfig.class.php:

    /*	
        $numerical_positive_params = $this->_params_type["positivenumeric"];
        foreach( $numerical_positive_params as $npp )
        {
          if (!is_int($this->$npp) || $this->$npp < 0)
            $this->errors[] = _pfc("'%s' parameter must be a positive number", $npp);
        }
    */	
    

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.